mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-12 15:46:29 +08:00
41 lines
1.0 KiB
TypeScript
41 lines
1.0 KiB
TypeScript
import { StrictMode } from 'react';
|
|
import { BasePlugin } from '../base-plugin';
|
|
import { PluginRenderRoot } from '../utils';
|
|
import { AddCommentPluginContainer } from './Container';
|
|
|
|
const PLUGIN_NAME = 'add-comment-plugin';
|
|
|
|
export class AddCommentPlugin extends BasePlugin {
|
|
public static override get pluginName(): string {
|
|
return PLUGIN_NAME;
|
|
}
|
|
|
|
private root: PluginRenderRoot;
|
|
|
|
protected override _onRender(): void {
|
|
this.root = new PluginRenderRoot({
|
|
name: AddCommentPlugin.pluginName,
|
|
render: this.editor.reactRenderRoot?.render,
|
|
});
|
|
|
|
this.root.mount();
|
|
this.renderAddComment();
|
|
}
|
|
|
|
private renderAddComment(): void {
|
|
this.root?.render(
|
|
<StrictMode>
|
|
<AddCommentPluginContainer
|
|
editor={this.editor}
|
|
hooks={this.hooks}
|
|
/>
|
|
</StrictMode>
|
|
);
|
|
}
|
|
|
|
public override dispose() {
|
|
this.root?.unmount();
|
|
super.dispose();
|
|
}
|
|
}
|