mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
34 lines
994 B
TypeScript
34 lines
994 B
TypeScript
import { StrictMode } from 'react';
|
|
import { createRoot, type Root } from 'react-dom/client';
|
|
|
|
import { BasePlugin } from '../../base-plugin';
|
|
import { ReferenceMenu } from './ReferenceMenu';
|
|
|
|
const PLUGIN_NAME = 'reference-menu';
|
|
|
|
export class ReferenceMenuPlugin 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_reference_menu();
|
|
}
|
|
|
|
private render_reference_menu(): void {
|
|
this.root?.render(
|
|
<StrictMode>
|
|
<ReferenceMenu editor={this.editor} hooks={this.hooks} />
|
|
</StrictMode>
|
|
);
|
|
}
|
|
}
|