]> BookStack Code Mirror - bookstack/blob - resources/js/editor/schema-marks.js
Added bg-color mark, added color grid selectors
[bookstack] / resources / js / editor / schema-marks.js
1 import {schema as basicSchema} from "prosemirror-schema-basic";
2
3 const baseMarks = basicSchema.spec.marks;
4
5 const underline = {
6     parseDOM: [{tag: "u"}, {style: "text-decoration=underline"}],
7     toDOM() {
8         return ["span", {style: "text-decoration: underline;"}, 0];
9     }
10 };
11
12 const strike = {
13     parseDOM: [{tag: "s"}, {tag: "strike"}, {style: "text-decoration=line-through"}],
14     toDOM() {
15         return ["span", {style: "text-decoration: line-through;"}, 0];
16     }
17 };
18
19 const superscript = {
20     parseDOM: [{tag: "sup"}],
21     toDOM() {
22         return ["sup", 0];
23     }
24 };
25
26 const subscript = {
27     parseDOM: [{tag: "sub"}],
28     toDOM() {
29         return ["sub", 0];
30     }
31 };
32
33 const text_color = {
34     attrs: {
35         color: {},
36     },
37     parseDOM: [{
38         style: 'color',
39         getAttrs(color) {
40             return {color}
41         }
42     }],
43     toDOM(node) {
44         return ['span', {style: `color: ${node.attrs.color};`}, 0];
45     }
46 };
47
48 const background_color = {
49     attrs: {
50         color: {},
51     },
52     parseDOM: [{
53         style: 'background-color',
54         getAttrs(color) {
55             return {color}
56         }
57     }],
58     toDOM(node) {
59         return ['span', {style: `background-color: ${node.attrs.color};`}, 0];
60     }
61 };
62
63 const marks = baseMarks.append({
64     underline,
65     strike,
66     superscript,
67     subscript,
68     text_color,
69     background_color,
70 });
71
72 export default marks;