-
Notifications
You must be signed in to change notification settings - Fork 1
/
ui.js
56 lines (42 loc) · 1.27 KB
/
ui.js
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import Plugin from "@ckeditor/ckeditor5-core/src/plugin";
import ButtonView from "@ckeditor/ckeditor5-ui/src/button/buttonview";
import superIcon from "./super.svg";
import subIcon from "./sub.svg";
const SUPER = "super";
const SUB = "sub";
export class SuperUI extends Plugin {
init() {
const editor = this.editor;
const t = editor.t;
editor.ui.componentFactory.add(SUPER, locale => {
const command = editor.commands.get(SUPER);
const view = new ButtonView(locale);
view.set({
label: t("Superscript"),
icon: superIcon,
tooltip: true
});
view.bind("isOn", "isEnabled").to(command, "value", "isEnabled");
this.listenTo(view, "execute", () => editor.execute(SUPER));
return view;
});
}
}
export class SubUI extends Plugin {
init() {
const editor = this.editor;
const t = editor.t;
editor.ui.componentFactory.add(SUB, locale => {
const command = editor.commands.get(SUB);
const view = new ButtonView(locale);
view.set({
label: t("Subscript"),
icon: subIcon,
tooltip: true
});
view.bind("isOn", "isEnabled").to(command, "value", "isEnabled");
this.listenTo(view, "execute", () => editor.execute(SUB));
return view;
});
}
}