-
Notifications
You must be signed in to change notification settings - Fork 1
/
client-entry.tsx
35 lines (26 loc) · 952 Bytes
/
client-entry.tsx
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
import { withCopyButton } from './src/CodeWithCopyButton';
declare const growiFacade: any;
const activate = (): void => {
if (growiFacade == null || growiFacade.markdownRenderer == null) {
return;
}
const { optionsGenerators } = growiFacade.markdownRenderer;
const originalCustomViewOptions = optionsGenerators.customGenerateViewOptions;
optionsGenerators.customGenerateViewOptions = (...args: any[]) => {
const options = originalCustomViewOptions ? originalCustomViewOptions(...args) : optionsGenerators.generateViewOptions(...args);
const Code = options.components.code;
// replace
options.components.code = withCopyButton(Code);
return options;
};
};
const deactivate = (): void => {
};
// register activate
if ((window as any).pluginActivators == null) {
(window as any).pluginActivators = {};
}
(window as any).pluginActivators['growi-plugin-copy-code-to-clipboard'] = {
activate,
deactivate,
};