Files
AFFiNE-Mirror/libs/components/editor-plugins/src/comment/Plugin.tsx
T
2022-07-26 17:28:19 +08:00

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();
}
}