UNPKG

1.11 kBJavaScriptView Raw
1import { FONT_STYLE } from '../groups';
2function getAttrFromVerticalAlign(node) {
3 if (node.style.verticalAlign) {
4 var type = node.style.verticalAlign.slice(0, 3);
5 if (type === 'sub' || type === 'sup') {
6 return { type: type };
7 }
8 }
9 return false;
10}
11export var subsup = {
12 inclusive: true,
13 group: FONT_STYLE,
14 attrs: { type: { default: 'sub' } },
15 parseDOM: [
16 { tag: 'sub', attrs: { type: 'sub' } },
17 { tag: 'sup', attrs: { type: 'sup' } },
18 {
19 // Special case for pasting from Google Docs
20 // Google Docs uses vertical align to denote subscript and super script
21 tag: 'span',
22 style: 'vertical-align=super',
23 getAttrs: function (node) { return getAttrFromVerticalAlign(node); },
24 },
25 {
26 tag: 'span',
27 style: 'vertical-align=sub',
28 getAttrs: function (node) { return getAttrFromVerticalAlign(node); },
29 },
30 ],
31 toDOM: function (mark) {
32 return [mark.attrs.type];
33 },
34};
35//# sourceMappingURL=subsup.js.map
\No newline at end of file