-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathediting.js
49 lines (40 loc) · 1 KB
/
editing.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
import Plugin from "@ckeditor/ckeditor5-core/src/plugin";
import AttributeCommand from "./attributecommand";
const SUPER = "super";
const SUB = "sub";
export class SuperEditing extends Plugin {
init() {
const editor = this.editor;
editor.model.schema.extend("$text", { allowAttributes: SUPER });
editor.conversion.attributeToElement({
model: SUPER,
view: "sup",
upcastAlso: [
{
styles: {
"vertical-align": "super"
}
}
]
});
editor.commands.add(SUPER, new AttributeCommand(editor, SUPER));
}
}
export class SubEditing extends Plugin {
init() {
const editor = this.editor;
editor.model.schema.extend("$text", { allowAttributes: SUB });
editor.conversion.attributeToElement({
model: SUB,
view: "sub",
upcastAlso: [
{
styles: {
"vertical-align": "SUb"
}
}
]
});
editor.commands.add(SUB, new AttributeCommand(editor, SUB));
}
}