init: the first public commit for AFFiNE

This commit is contained in:
DarkSky
2022-07-22 15:49:21 +08:00
commit e3e3741393
1451 changed files with 108124 additions and 0 deletions
@@ -0,0 +1,34 @@
import { StrictMode } from 'react';
import { createRoot, type Root } from 'react-dom/client';
import { BasePlugin } from '../../base-plugin';
import { CommandMenu } from './Menu';
const PLUGIN_NAME = 'command-menu';
export class CommandMenuPlugin extends BasePlugin {
private root?: Root;
public static override get pluginName(): string {
return PLUGIN_NAME;
}
protected override on_render(): void {
const container = document.createElement('div');
// TODO remove
container.classList.add(`id-${PLUGIN_NAME}`);
// this.editor.attachElement(this.menu_container);
window.document.body.appendChild(container);
this.root = createRoot(container);
this.render_command_menu();
}
private renderCommandMenu(): void {
//TODO If you change to PluginRenderRoot here, you need to support PluginRenderRoot under body
this.root?.render(
<StrictMode>
<CommandMenu editor={this.editor} hooks={this.hooks} />
</StrictMode>
);
}
}