-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathindex.tsx
More file actions
38 lines (31 loc) · 1006 Bytes
/
index.tsx
File metadata and controls
38 lines (31 loc) · 1006 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import "./styles/index.scss";
import type { BlockContext } from "doc-editor-core";
import type { EditorKit } from "doc-editor-core";
import { BlockPlugin } from "doc-editor-core";
import { DEFAULT_PRIORITY } from "doc-editor-utils";
import { DocMenu } from "./components/doc-menu";
import { DOC_TOOLBAR_MODULES } from "./config";
import { DOC_TOOLBAR_KEY } from "./types";
export class DocToolBarPlugin extends BlockPlugin {
public readonly key = DOC_TOOLBAR_KEY;
public readonly priority = DEFAULT_PRIORITY + 13;
constructor(
private editor: EditorKit,
private readonly: boolean,
private plugins = DOC_TOOLBAR_MODULES
) {
super();
}
public destroy(): void {}
public match(): boolean {
return true;
}
public renderLine(context: BlockContext): JSX.Element {
if (this.readonly) return context.children;
return (
<DocMenu editor={this.editor} element={context.element} plugins={this.plugins}>
{context.children}
</DocMenu>
);
}
}