@progress/kendo-editor-common 1.12.2-develop.5 → 1.12.2-develop.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/js/kendo-editor-common.js +1 -1
- package/dist/cdn/main.js +1 -1
- package/dist/es/DOMSerializer.js +6 -7
- package/dist/es/align.js +3 -6
- package/dist/es/blockNode.js +11 -14
- package/dist/es/blockquote.js +2 -5
- package/dist/es/cleanFormatting.js +3 -6
- package/dist/es/config/align-rules.js +5 -7
- package/dist/es/config/commands.js +13 -9
- package/dist/es/config/constants.js +7 -9
- package/dist/es/config/indent-rules.js +3 -6
- package/dist/es/config/keymap.js +7 -10
- package/dist/es/config/list-settings.js +3 -5
- package/dist/es/config/schema.js +4 -6
- package/dist/es/find-replace.js +8 -10
- package/dist/es/flatten-spans.js +2 -5
- package/dist/es/image.js +2 -5
- package/dist/es/indent.js +11 -14
- package/dist/es/inline-style.js +10 -12
- package/dist/es/link.js +5 -8
- package/dist/es/listConvert.js +8 -9
- package/dist/es/lists.js +12 -15
- package/dist/es/main.js +34 -33
- package/dist/es/mark.js +16 -17
- package/dist/es/paste.js +10 -13
- package/dist/es/plugins/caret-color.js +5 -8
- package/dist/es/plugins/csp-fix.js +2 -5
- package/dist/es/plugins/highlight.js +3 -6
- package/dist/es/plugins/image-resize.js +8 -11
- package/dist/es/plugins/list-markers-styles.js +2 -5
- package/dist/es/plugins/placeholder.js +2 -5
- package/dist/es/plugins/resize-utils.js +2 -4
- package/dist/es/plugins/spaces-fix.js +1 -4
- package/dist/es/plugins/table-resize/column-resize.js +21 -24
- package/dist/es/plugins/table-resize/index.js +6 -9
- package/dist/es/plugins/table-resize/row-resize.js +23 -24
- package/dist/es/plugins/table-resize/table-resize.js +17 -20
- package/dist/es/plugins/table-resize/table-view.js +6 -9
- package/dist/es/plugins/table-resize/utils.js +10 -13
- package/dist/es/source.js +15 -18
- package/dist/es/table.js +15 -18
- package/dist/es/text.js +1 -3
- package/dist/es/types/active-marks.js +1 -0
- package/dist/es/types/command.js +1 -0
- package/dist/es/types/dispatchFn.js +1 -0
- package/dist/es/types/paste-cleanup-settings.js +1 -0
- package/dist/es/types/predicate.js +1 -0
- package/dist/es/utils.js +18 -21
- package/dist/npm/DOMSerializer.d.ts +35 -0
- package/dist/npm/DOMSerializer.js +10 -9
- package/dist/npm/align.d.ts +4 -7
- package/dist/npm/align.js +9 -10
- package/dist/npm/blockNode.d.ts +15 -12
- package/dist/npm/blockNode.js +28 -29
- package/dist/npm/blockquote.d.ts +2 -5
- package/dist/npm/blockquote.js +6 -7
- package/dist/npm/cleanFormatting.d.ts +3 -6
- package/dist/npm/cleanFormatting.js +7 -8
- package/dist/npm/config/align-rules.d.ts +6 -8
- package/dist/npm/config/align-rules.js +8 -13
- package/dist/npm/config/commands.d.ts +19 -11
- package/dist/npm/config/commands.js +16 -17
- package/dist/npm/config/constants.d.ts +7 -0
- package/dist/npm/config/constants.js +10 -17
- package/dist/npm/config/indent-rules.d.ts +4 -6
- package/dist/npm/config/indent-rules.js +8 -11
- package/dist/npm/config/keymap.d.ts +2 -5
- package/dist/npm/config/keymap.js +21 -22
- package/dist/npm/config/list-settings.d.ts +30 -0
- package/dist/npm/config/list-settings.js +10 -13
- package/dist/npm/config/schema.d.ts +2 -3
- package/dist/npm/config/schema.js +19 -20
- package/dist/npm/find-replace.d.ts +7 -10
- package/dist/npm/find-replace.js +20 -20
- package/dist/npm/flatten-spans.d.ts +1 -3
- package/dist/npm/flatten-spans.js +6 -7
- package/dist/npm/image.d.ts +3 -6
- package/dist/npm/image.js +5 -6
- package/dist/npm/indent.d.ts +9 -12
- package/dist/npm/indent.js +37 -38
- package/dist/npm/inline-style.d.ts +4 -7
- package/dist/npm/inline-style.js +28 -28
- package/dist/npm/link.d.ts +2 -4
- package/dist/npm/link.js +21 -22
- package/dist/npm/listConvert.d.ts +1 -3
- package/dist/npm/listConvert.js +13 -12
- package/dist/npm/lists.d.ts +8 -8
- package/dist/npm/lists.js +26 -27
- package/dist/npm/main.d.ts +34 -35
- package/dist/npm/main.js +214 -391
- package/dist/npm/mark.d.ts +17 -12
- package/dist/npm/mark.js +30 -29
- package/dist/npm/paste.d.ts +8 -11
- package/dist/npm/paste.js +19 -20
- package/dist/npm/plugins/caret-color.d.ts +2 -5
- package/dist/npm/plugins/caret-color.js +15 -17
- package/dist/npm/plugins/csp-fix.d.ts +1 -4
- package/dist/npm/plugins/csp-fix.js +8 -9
- package/dist/npm/plugins/highlight.d.ts +4 -7
- package/dist/npm/plugins/highlight.js +11 -13
- package/dist/npm/plugins/image-resize.d.ts +5 -7
- package/dist/npm/plugins/image-resize.js +35 -37
- package/dist/npm/plugins/list-markers-styles.d.ts +2 -5
- package/dist/npm/plugins/list-markers-styles.js +14 -16
- package/dist/npm/plugins/placeholder.d.ts +1 -4
- package/dist/npm/plugins/placeholder.js +10 -12
- package/dist/npm/plugins/resize-utils.d.ts +35 -0
- package/dist/npm/plugins/resize-utils.js +5 -7
- package/dist/npm/plugins/spaces-fix.d.ts +1 -4
- package/dist/npm/plugins/spaces-fix.js +9 -10
- package/dist/npm/plugins/table-resize/column-resize.d.ts +2 -0
- package/dist/npm/plugins/table-resize/column-resize.js +44 -46
- package/dist/npm/plugins/table-resize/index.d.ts +2 -5
- package/dist/npm/plugins/table-resize/index.js +13 -14
- package/dist/npm/plugins/table-resize/row-resize.d.ts +2 -0
- package/dist/npm/plugins/table-resize/row-resize.js +40 -40
- package/dist/npm/plugins/table-resize/table-resize.d.ts +18 -0
- package/dist/npm/plugins/table-resize/table-resize.js +51 -52
- package/dist/npm/plugins/table-resize/table-view.d.ts +28 -0
- package/dist/npm/plugins/table-resize/table-view.js +23 -24
- package/dist/npm/plugins/table-resize/utils.d.ts +17 -7
- package/dist/npm/plugins/table-resize/utils.js +24 -28
- package/dist/npm/source.d.ts +13 -16
- package/dist/npm/source.js +35 -36
- package/dist/npm/table.d.ts +9 -10
- package/dist/npm/table.js +33 -49
- package/dist/npm/text.d.ts +3 -6
- package/dist/npm/text.js +3 -3
- package/dist/npm/types/active-marks.d.ts +1 -4
- package/dist/npm/types/active-marks.js +2 -0
- package/dist/npm/types/command.d.ts +2 -5
- package/dist/npm/types/command.js +2 -0
- package/dist/npm/types/dispatchFn.d.ts +1 -4
- package/dist/npm/types/dispatchFn.js +2 -0
- package/dist/npm/types/paste-cleanup-settings.d.ts +1 -3
- package/dist/npm/types/paste-cleanup-settings.js +2 -0
- package/dist/npm/types/predicate.d.ts +1 -0
- package/dist/npm/types/predicate.js +2 -0
- package/dist/npm/utils.d.ts +33 -14
- package/dist/npm/utils.js +38 -39
- package/package.json +4 -51
- package/dist/es2015/DOMSerializer.js +0 -184
- package/dist/es2015/align.js +0 -43
- package/dist/es2015/blockNode.js +0 -180
- package/dist/es2015/blockquote.js +0 -26
- package/dist/es2015/cleanFormatting.js +0 -20
- package/dist/es2015/config/align-rules.js +0 -30
- package/dist/es2015/config/commands.js +0 -50
- package/dist/es2015/config/constants.js +0 -9
- package/dist/es2015/config/indent-rules.js +0 -42
- package/dist/es2015/config/keymap.js +0 -51
- package/dist/es2015/config/list-settings.js +0 -21
- package/dist/es2015/config/schema.js +0 -314
- package/dist/es2015/find-replace.js +0 -122
- package/dist/es2015/flatten-spans.js +0 -112
- package/dist/es2015/image.js +0 -10
- package/dist/es2015/indent.js +0 -105
- package/dist/es2015/inline-style.js +0 -177
- package/dist/es2015/link.js +0 -105
- package/dist/es2015/listConvert.js +0 -184
- package/dist/es2015/lists.js +0 -266
- package/dist/es2015/main.js +0 -44
- package/dist/es2015/mark.js +0 -239
- package/dist/es2015/node_modules/tslib/tslib.es6.js +0 -35
- package/dist/es2015/paste.js +0 -162
- package/dist/es2015/plugins/caret-color.js +0 -34
- package/dist/es2015/plugins/csp-fix.js +0 -51
- package/dist/es2015/plugins/highlight.js +0 -23
- package/dist/es2015/plugins/image-resize.js +0 -225
- package/dist/es2015/plugins/list-markers-styles.js +0 -104
- package/dist/es2015/plugins/placeholder.js +0 -27
- package/dist/es2015/plugins/resize-utils.js +0 -13
- package/dist/es2015/plugins/spaces-fix.js +0 -46
- package/dist/es2015/plugins/table-resize/column-resize.js +0 -267
- package/dist/es2015/plugins/table-resize/index.js +0 -12
- package/dist/es2015/plugins/table-resize/row-resize.js +0 -234
- package/dist/es2015/plugins/table-resize/table-resize.js +0 -278
- package/dist/es2015/plugins/table-resize/table-view.js +0 -128
- package/dist/es2015/plugins/table-resize/utils.js +0 -93
- package/dist/es2015/source.js +0 -251
- package/dist/es2015/table.js +0 -132
- package/dist/es2015/text.js +0 -5
- package/dist/es2015/utils.js +0 -289
|
@@ -1,314 +0,0 @@
|
|
|
1
|
-
import { Schema } from 'prosemirror-model';
|
|
2
|
-
import { tableNodes } from 'prosemirror-tables';
|
|
3
|
-
import { domToPmDoc, htmlToFragment, pmDocToFragment } from '../source.js';
|
|
4
|
-
import { colgroupAttr, resizableAttr, rowTypeAttr } from './constants.js';
|
|
5
|
-
|
|
6
|
-
const hole = 0;
|
|
7
|
-
const blockquoteDOM = ['blockquote', hole], hrDOM = ['hr'], preDOM = ['pre', ['code', hole]];
|
|
8
|
-
const olDOM = ['ol', 0], ulDOM = ['ul', 0], liDOM = ['li', 0];
|
|
9
|
-
const domAttributes = (dom) => {
|
|
10
|
-
const result = {};
|
|
11
|
-
const attributes = dom.attributes;
|
|
12
|
-
let attr;
|
|
13
|
-
for (let i = 0; i < attributes.length; i++) {
|
|
14
|
-
attr = attributes[i];
|
|
15
|
-
result[attr.name] = attr.value;
|
|
16
|
-
}
|
|
17
|
-
return result;
|
|
18
|
-
};
|
|
19
|
-
const defaultAttrs = (attrs) => {
|
|
20
|
-
const nodeAttrs = {};
|
|
21
|
-
attrs.forEach(attr => {
|
|
22
|
-
nodeAttrs[attr] = { default: null };
|
|
23
|
-
});
|
|
24
|
-
return nodeAttrs;
|
|
25
|
-
};
|
|
26
|
-
const commonAttributes = () => defaultAttrs(['style', 'class', 'id']);
|
|
27
|
-
const hasAttrs = (attrs, exclude) => {
|
|
28
|
-
for (const attr in attrs) {
|
|
29
|
-
if (attr && attrs[attr] !== null && attr !== exclude) {
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return false;
|
|
34
|
-
};
|
|
35
|
-
const pmAttributes = (attrs, exclude = []) => {
|
|
36
|
-
const result = {};
|
|
37
|
-
for (const attr in attrs) {
|
|
38
|
-
if (attr && attrs[attr] !== null && !exclude.find(e => e === attr)) {
|
|
39
|
-
result[attr] = attrs[attr];
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return result;
|
|
43
|
-
};
|
|
44
|
-
const tagMark = tag => {
|
|
45
|
-
return {
|
|
46
|
-
[tag]: {
|
|
47
|
-
name: tag,
|
|
48
|
-
inclusive: true, // https://prosemirror.net/docs/ref/#model.MarkSpec.inclusive
|
|
49
|
-
parseDOM: [{ tag: tag }],
|
|
50
|
-
toDOM: () => [tag, hole]
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
const marks = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({
|
|
55
|
-
// :: MarkSpec A link. Has `href` and `title` attributes. `title`
|
|
56
|
-
// defaults to the empty string. Rendered and parsed as an `<a>`
|
|
57
|
-
// element.
|
|
58
|
-
link: {
|
|
59
|
-
attrs: Object.assign(Object.assign({}, commonAttributes()), { href: { default: null }, target: { default: null }, title: { default: null } }),
|
|
60
|
-
inclusive: false,
|
|
61
|
-
parseDOM: [{ tag: 'a', getAttrs: domAttributes }],
|
|
62
|
-
toDOM: (node) => ['a', pmAttributes(node.attrs), hole]
|
|
63
|
-
} }, tagMark('strong')), tagMark('b')), tagMark('em')), tagMark('i')), tagMark('del')), tagMark('sub')), tagMark('sup')), tagMark('code')), { style: {
|
|
64
|
-
attrs: Object.assign({}, commonAttributes()),
|
|
65
|
-
parseDOM: [{
|
|
66
|
-
tag: 'span',
|
|
67
|
-
getAttrs: domAttributes
|
|
68
|
-
}],
|
|
69
|
-
toDOM: node => hasAttrs(node.attrs) ?
|
|
70
|
-
['span', pmAttributes(node.attrs), hole] : ['span', hole]
|
|
71
|
-
} }), tagMark('u'));
|
|
72
|
-
const cellAttribute = (name) => {
|
|
73
|
-
return {
|
|
74
|
-
[name]: {
|
|
75
|
-
default: null,
|
|
76
|
-
getFromDOM: (cell) => cell.getAttribute(name),
|
|
77
|
-
setDOMAttr: (value, attrs) => { attrs[name] = value; }
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
const cellAttributes = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, cellAttribute('style')), cellAttribute('class')), cellAttribute('id')), cellAttribute('headers')), cellAttribute('scope'));
|
|
82
|
-
const colgroupNodes = {
|
|
83
|
-
doc: { content: 'colgroup*' },
|
|
84
|
-
col: {
|
|
85
|
-
attrs: defaultAttrs(['id', 'class', 'style', 'span']),
|
|
86
|
-
parseDOM: [{ getAttrs: domAttributes, tag: 'col' }],
|
|
87
|
-
toDOM: node => ['col', node.attrs]
|
|
88
|
-
},
|
|
89
|
-
colgroup: {
|
|
90
|
-
attrs: defaultAttrs(['id', 'class', 'style', 'span']),
|
|
91
|
-
content: 'col*',
|
|
92
|
-
parseDOM: [{ getAttrs: domAttributes, tag: 'colgroup' }],
|
|
93
|
-
toDOM: node => ['colgroup', node.attrs, 0]
|
|
94
|
-
},
|
|
95
|
-
text: { inline: true, group: 'inline' }
|
|
96
|
-
};
|
|
97
|
-
const colgroupSchema = new Schema({ nodes: colgroupNodes, marks: {} });
|
|
98
|
-
// will be removed when we implement our own columnResizing
|
|
99
|
-
const shouldSkipColgroup = (node) => {
|
|
100
|
-
let shouldSkip = false;
|
|
101
|
-
const row = node.child(0);
|
|
102
|
-
for (let r = 0; r < row.childCount; r++) {
|
|
103
|
-
const cell = row.child(r);
|
|
104
|
-
if (cell.attrs.colwidth) {
|
|
105
|
-
shouldSkip = true;
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return shouldSkip;
|
|
110
|
-
};
|
|
111
|
-
const parseStrColgroup = (colgroup) => {
|
|
112
|
-
const doc = domToPmDoc(htmlToFragment(colgroup), colgroupSchema, { preserveWhitespace: false });
|
|
113
|
-
const fragment = pmDocToFragment(doc);
|
|
114
|
-
const colgroupEl = fragment.firstChild;
|
|
115
|
-
return colgroupEl;
|
|
116
|
-
};
|
|
117
|
-
const tNodes = tableNodes({ tableGroup: 'block', cellContent: 'block+', cellAttributes });
|
|
118
|
-
tNodes.table_row.attrs = Object.assign(Object.assign({}, tNodes.table_row.attrs), defaultAttrs([rowTypeAttr, 'style', 'class', 'id']));
|
|
119
|
-
tNodes.table_row.toDOM = node => ['tr', pmAttributes(node.attrs), 0];
|
|
120
|
-
tNodes.table_row.parseDOM = [{ tag: 'tr', getAttrs: domAttributes }];
|
|
121
|
-
tNodes.table.attrs = Object.assign(Object.assign({}, tNodes.table.attrs), defaultAttrs(['style', 'class', 'id', colgroupAttr, resizableAttr]));
|
|
122
|
-
tNodes.table.toDOM = (node) => {
|
|
123
|
-
const tableAttrs = hasAttrs(node.attrs) ? pmAttributes(node.attrs, [colgroupAttr, resizableAttr]) : {};
|
|
124
|
-
let colgroup = null;
|
|
125
|
-
if (node.attrs[colgroupAttr] && !shouldSkipColgroup(node)) {
|
|
126
|
-
const colgroupEl = parseStrColgroup(node.attrs[colgroupAttr]);
|
|
127
|
-
if (colgroupEl) {
|
|
128
|
-
const cols = Array.from(colgroupEl.children).map((c) => ['col', domAttributes(c)]);
|
|
129
|
-
colgroup = [
|
|
130
|
-
'colgroup',
|
|
131
|
-
domAttributes(colgroupEl)
|
|
132
|
-
].concat(cols);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
return colgroup ? ['table', tableAttrs, colgroup, ['tbody', 0]] :
|
|
136
|
-
['table', tableAttrs, ['tbody', 0]];
|
|
137
|
-
};
|
|
138
|
-
tNodes.table.parseDOM = [{
|
|
139
|
-
tag: 'table',
|
|
140
|
-
getAttrs: (node) => {
|
|
141
|
-
const attrs = domAttributes(node);
|
|
142
|
-
const colgroup = Array.from(node.childNodes).find(c => c.nodeName === 'COLGROUP');
|
|
143
|
-
if (colgroup) {
|
|
144
|
-
attrs[colgroupAttr] = colgroup.outerHTML;
|
|
145
|
-
}
|
|
146
|
-
return attrs;
|
|
147
|
-
}
|
|
148
|
-
}];
|
|
149
|
-
const nodes = Object.assign({
|
|
150
|
-
// :: NodeSpec The top level document node.
|
|
151
|
-
doc: {
|
|
152
|
-
content: 'block+'
|
|
153
|
-
},
|
|
154
|
-
// :: NodeSpec A plain paragraph textblock. Represented in the DOM
|
|
155
|
-
// as a `<p>` element.
|
|
156
|
-
paragraph: {
|
|
157
|
-
content: 'inline*',
|
|
158
|
-
group: 'block',
|
|
159
|
-
attrs: Object.assign({}, commonAttributes()),
|
|
160
|
-
parseDOM: [{
|
|
161
|
-
tag: 'p',
|
|
162
|
-
getAttrs: domAttributes
|
|
163
|
-
}],
|
|
164
|
-
toDOM: node => hasAttrs(node.attrs) ? ['p', pmAttributes(node.attrs), hole] : ['p', hole]
|
|
165
|
-
}, table_wrapper: {
|
|
166
|
-
content: '(table_caption_external | table)+',
|
|
167
|
-
group: 'block',
|
|
168
|
-
defining: true,
|
|
169
|
-
attrs: {
|
|
170
|
-
table: { default: null },
|
|
171
|
-
style: { default: null }
|
|
172
|
-
},
|
|
173
|
-
parseDOM: [{
|
|
174
|
-
tag: 'div[table]',
|
|
175
|
-
getAttrs: domAttributes
|
|
176
|
-
}],
|
|
177
|
-
toDOM: node => hasAttrs(node.attrs) ? ['div', pmAttributes(node.attrs), hole] : ['div', hole]
|
|
178
|
-
}, table_caption_external: {
|
|
179
|
-
content: 'inline+',
|
|
180
|
-
group: 'block',
|
|
181
|
-
attrs: Object.assign({ caption: { default: null } }, commonAttributes()),
|
|
182
|
-
parseDOM: [{
|
|
183
|
-
tag: 'div[caption]',
|
|
184
|
-
getAttrs: domAttributes
|
|
185
|
-
}],
|
|
186
|
-
toDOM: node => hasAttrs(node.attrs) ? ['div', pmAttributes(node.attrs), hole] : ['div', hole]
|
|
187
|
-
}, div: {
|
|
188
|
-
// Uncaught SyntaxError: Mixing inline and block content (in content expression '(block | inline)*')
|
|
189
|
-
// content: '(block | inline)*',
|
|
190
|
-
content: 'block*',
|
|
191
|
-
group: 'block',
|
|
192
|
-
attrs: Object.assign({}, commonAttributes()),
|
|
193
|
-
parseDOM: [{
|
|
194
|
-
tag: 'div',
|
|
195
|
-
getAttrs: domAttributes
|
|
196
|
-
}],
|
|
197
|
-
toDOM: node => hasAttrs(node.attrs) ? ['div', pmAttributes(node.attrs), hole] : ['div', hole]
|
|
198
|
-
},
|
|
199
|
-
// :: NodeSpec A blockquote (`<blockquote>`) wrapping one or more blocks.
|
|
200
|
-
blockquote: {
|
|
201
|
-
attrs: Object.assign({}, commonAttributes()),
|
|
202
|
-
content: 'block+',
|
|
203
|
-
group: 'block',
|
|
204
|
-
defining: true, // https://prosemirror.net/docs/ref/#model.NodeSpec.defining
|
|
205
|
-
parseDOM: [{
|
|
206
|
-
tag: 'blockquote',
|
|
207
|
-
getAttrs: domAttributes
|
|
208
|
-
}],
|
|
209
|
-
toDOM: node => hasAttrs(node.attrs) ? ['blockquote', pmAttributes(node.attrs), hole] : blockquoteDOM
|
|
210
|
-
},
|
|
211
|
-
// :: NodeSpec A horizontal rule (`<hr>`).
|
|
212
|
-
horizontal_rule: {
|
|
213
|
-
group: 'block',
|
|
214
|
-
parseDOM: [{ tag: 'hr' }],
|
|
215
|
-
toDOM: () => hrDOM
|
|
216
|
-
},
|
|
217
|
-
// :: NodeSpec A heading textblock, with a `level` attribute that
|
|
218
|
-
// has to hold the numbers from 1 to 6. Parsed and serialized as `<h1>` to
|
|
219
|
-
// `<h6>` elements.
|
|
220
|
-
heading: {
|
|
221
|
-
attrs: Object.assign(Object.assign({}, commonAttributes()), { level: { default: 1 } }),
|
|
222
|
-
content: 'inline*',
|
|
223
|
-
group: 'block',
|
|
224
|
-
defining: true,
|
|
225
|
-
parseDOM: [
|
|
226
|
-
{ tag: 'h1', getAttrs: node => (Object.assign(Object.assign({}, domAttributes(node)), { level: 1 })) },
|
|
227
|
-
{ tag: 'h2', getAttrs: node => (Object.assign(Object.assign({}, domAttributes(node)), { level: 2 })) },
|
|
228
|
-
{ tag: 'h3', getAttrs: node => (Object.assign(Object.assign({}, domAttributes(node)), { level: 3 })) },
|
|
229
|
-
{ tag: 'h4', getAttrs: node => (Object.assign(Object.assign({}, domAttributes(node)), { level: 4 })) },
|
|
230
|
-
{ tag: 'h5', getAttrs: node => (Object.assign(Object.assign({}, domAttributes(node)), { level: 5 })) },
|
|
231
|
-
{ tag: 'h6', getAttrs: node => (Object.assign(Object.assign({}, domAttributes(node)), { level: 6 })) }
|
|
232
|
-
],
|
|
233
|
-
toDOM: node => hasAttrs(node.attrs, 'level') ?
|
|
234
|
-
['h' + node.attrs.level, pmAttributes(node.attrs, ['level']), hole] :
|
|
235
|
-
['h' + node.attrs.level, hole]
|
|
236
|
-
},
|
|
237
|
-
// :: NodeSpec A code listing. Disallows marks or non-text inline
|
|
238
|
-
// nodes by default. Represented as a `<pre>` element with a
|
|
239
|
-
// `<code>` element inside it.
|
|
240
|
-
code_block: {
|
|
241
|
-
content: 'text*',
|
|
242
|
-
marks: '',
|
|
243
|
-
group: 'block',
|
|
244
|
-
code: true,
|
|
245
|
-
defining: true,
|
|
246
|
-
parseDOM: [{ tag: 'pre', preserveWhitespace: 'full' }],
|
|
247
|
-
toDOM: () => preDOM
|
|
248
|
-
},
|
|
249
|
-
// :: NodeSpec The text node.
|
|
250
|
-
text: {
|
|
251
|
-
inline: true,
|
|
252
|
-
group: 'inline'
|
|
253
|
-
},
|
|
254
|
-
// :: NodeSpec An inline image (`<img>`) node. Supports `src`,
|
|
255
|
-
// `alt`, and `href` attributes. The latter two default to an empty
|
|
256
|
-
// string.
|
|
257
|
-
image: {
|
|
258
|
-
inline: true,
|
|
259
|
-
attrs: Object.assign({ src: { default: null }, alt: { default: null }, title: { default: null }, width: { default: null }, height: { default: null } }, commonAttributes()),
|
|
260
|
-
group: 'inline',
|
|
261
|
-
draggable: true,
|
|
262
|
-
parseDOM: [{ tag: 'img', getAttrs: domAttributes }],
|
|
263
|
-
toDOM: node => hasAttrs(node.attrs) ? ['img', pmAttributes(node.attrs)] : ['img']
|
|
264
|
-
},
|
|
265
|
-
// :: NodeSpec A hard line break represented in the DOM as a `<br>` element.
|
|
266
|
-
hard_break: {
|
|
267
|
-
inline: true,
|
|
268
|
-
attrs: Object.assign({}, commonAttributes()),
|
|
269
|
-
group: 'inline',
|
|
270
|
-
selectable: false,
|
|
271
|
-
parseDOM: [{
|
|
272
|
-
tag: 'br',
|
|
273
|
-
getAttrs: domAttributes
|
|
274
|
-
}],
|
|
275
|
-
toDOM: node => hasAttrs(node.attrs) ? ['br', pmAttributes(node.attrs)] : ['br']
|
|
276
|
-
},
|
|
277
|
-
// :: NodeSpec
|
|
278
|
-
// An ordered list [node spec](#model.NodeSpec). Has a single
|
|
279
|
-
// attribute, `order`, which determines the number at which the list
|
|
280
|
-
// starts counting, and defaults to 1. Represented as an `<ol>`
|
|
281
|
-
// element.
|
|
282
|
-
ordered_list: {
|
|
283
|
-
content: 'list_item+',
|
|
284
|
-
group: 'block',
|
|
285
|
-
attrs: Object.assign(Object.assign({}, commonAttributes()), { type: { default: null }, order: { default: 1 } }),
|
|
286
|
-
parseDOM: [{ tag: 'ol', getAttrs: (dom) => {
|
|
287
|
-
return Object.assign(Object.assign({}, domAttributes(dom)), { order: dom.hasAttribute('start') ? parseInt(dom.getAttribute('start') || '1', 10) : 1 });
|
|
288
|
-
} }],
|
|
289
|
-
toDOM: node => {
|
|
290
|
-
return node.attrs.order === 1 ?
|
|
291
|
-
(hasAttrs(node.attrs, 'order') ? ['ol', pmAttributes(node.attrs, ['order']), hole] : olDOM) :
|
|
292
|
-
['ol', Object.assign(Object.assign({}, pmAttributes(node.attrs, ['order'])), { start: node.attrs.order }), hole];
|
|
293
|
-
}
|
|
294
|
-
},
|
|
295
|
-
// :: NodeSpec
|
|
296
|
-
// A bullet list node specification represented in the DOM as a `<ul>` element.
|
|
297
|
-
bullet_list: {
|
|
298
|
-
content: 'list_item+',
|
|
299
|
-
group: 'block',
|
|
300
|
-
attrs: Object.assign({}, commonAttributes()),
|
|
301
|
-
parseDOM: [{ tag: 'ul', getAttrs: domAttributes }],
|
|
302
|
-
toDOM: node => hasAttrs(node.attrs) ? ['ul', pmAttributes(node.attrs), hole] : ulDOM
|
|
303
|
-
},
|
|
304
|
-
// :: NodeSpec
|
|
305
|
-
// A list item (`<li>`) specification.
|
|
306
|
-
list_item: {
|
|
307
|
-
content: '(paragraph | heading) block*',
|
|
308
|
-
attrs: Object.assign({}, commonAttributes()),
|
|
309
|
-
parseDOM: [{ tag: 'li', getAttrs: domAttributes }],
|
|
310
|
-
toDOM: node => hasAttrs(node.attrs) ? ['li', pmAttributes(node.attrs), hole] : liDOM,
|
|
311
|
-
defining: true
|
|
312
|
-
} }, tNodes);
|
|
313
|
-
|
|
314
|
-
export { marks, nodes, parseStrColgroup };
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { __rest } from './node_modules/tslib/tslib.es6.js';
|
|
2
|
-
import { TextSelection } from 'prosemirror-state';
|
|
3
|
-
|
|
4
|
-
const findAt = (doc, searchOptions, start, end, exit) => {
|
|
5
|
-
let result = [], exec, text, from, to, childText, nextSibling;
|
|
6
|
-
const nodes = [];
|
|
7
|
-
const { matchCase, matchWord, useRegExp } = searchOptions;
|
|
8
|
-
let searchText = searchOptions.text;
|
|
9
|
-
if (useRegExp && (/^\\$/.test(searchText) || /[^\\]\\$/.test(searchText))) {
|
|
10
|
-
// lookbehind doesn't work in Edge -> /((?<!\\)\\)$/.test(searchText)
|
|
11
|
-
searchText = searchText.substring(0, searchText.length - 1);
|
|
12
|
-
}
|
|
13
|
-
if (!searchText) {
|
|
14
|
-
return result;
|
|
15
|
-
}
|
|
16
|
-
const flags = matchCase ? 'g' : 'gi';
|
|
17
|
-
const regExp = useRegExp ? new RegExp(searchText, flags) : createRegExp(searchText, flags);
|
|
18
|
-
doc.nodesBetween(start, end, (node, pos) => {
|
|
19
|
-
if (exit(result)) {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
if (node.inlineContent && pos + node.content.size >= start) {
|
|
23
|
-
nodes.length = 0;
|
|
24
|
-
node.nodesBetween(0, node.content.size, (child, childPos, parent, i) => {
|
|
25
|
-
if (exit(result)) {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
const posToDoc = 1 + pos + childPos;
|
|
29
|
-
if (child.isText && posToDoc + child.nodeSize >= start) {
|
|
30
|
-
childText = child.text || '';
|
|
31
|
-
nextSibling = parent.childCount - 1 >= i + 1 && parent.child(i + 1);
|
|
32
|
-
nodes.push(start <= posToDoc ?
|
|
33
|
-
{ text: childText, start: posToDoc } :
|
|
34
|
-
{ text: childText.slice(start - posToDoc), start: start });
|
|
35
|
-
if (nextSibling && nextSibling.isText) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
text = nodes.map(t => t.text).join('');
|
|
39
|
-
exec = regExp.exec(text);
|
|
40
|
-
while (exec !== null) {
|
|
41
|
-
from = nodes[0].start + exec.index;
|
|
42
|
-
to = from + exec[0].length;
|
|
43
|
-
if (start <= from && end >= to && shouldMatchWord(exec, matchWord)) {
|
|
44
|
-
result.push(TextSelection.create(doc, from, to));
|
|
45
|
-
}
|
|
46
|
-
if (exit(result)) {
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
exec = regExp.exec(text);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
nodes.length = 0;
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
return result;
|
|
59
|
-
};
|
|
60
|
-
const find = (state, searchOptions) => {
|
|
61
|
-
const { backward, matchCyclic } = searchOptions, options = __rest(searchOptions, ["backward", "matchCyclic"]);
|
|
62
|
-
const exit = backward ? () => false : r => r.length > 0;
|
|
63
|
-
const { doc, selection } = state;
|
|
64
|
-
let result = [];
|
|
65
|
-
if (backward) {
|
|
66
|
-
result = findAt(doc, options, 0, selection.from, exit);
|
|
67
|
-
if (!result.length && matchCyclic) {
|
|
68
|
-
result = findAt(doc, options, selection.from, doc.content.size, exit);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
result = findAt(doc, options, selection.to, doc.content.size, exit);
|
|
73
|
-
if (!result.length && matchCyclic) {
|
|
74
|
-
result = findAt(doc, options, 0, selection.to, exit);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return result.length ? result[result.length - 1] : null;
|
|
78
|
-
};
|
|
79
|
-
const findAll = (doc, searchOptions) => {
|
|
80
|
-
return findAt(doc, searchOptions, 0, doc.content.size, () => false);
|
|
81
|
-
};
|
|
82
|
-
const replace = (selection, text, transaction) => {
|
|
83
|
-
const { from, to } = selection;
|
|
84
|
-
transaction.insertText(text, from, to)
|
|
85
|
-
.setSelection(TextSelection.create(transaction.doc, from, from + text.length));
|
|
86
|
-
return transaction;
|
|
87
|
-
};
|
|
88
|
-
const replaceAll = (state, replaceText, searchOptions) => {
|
|
89
|
-
const result = findAll(state.doc, searchOptions);
|
|
90
|
-
if (result.length === 0) {
|
|
91
|
-
return null;
|
|
92
|
-
}
|
|
93
|
-
const transaction = state.tr;
|
|
94
|
-
for (let i = result.length - 1; i >= 0; i--) {
|
|
95
|
-
transaction.insertText(replaceText, result[i].from, result[i].to);
|
|
96
|
-
}
|
|
97
|
-
return transaction;
|
|
98
|
-
};
|
|
99
|
-
const notLetter = /^[\s0-9~`!@#$%\^&*\(\)_\-=+\\|\[\]{};:'"\?/.,<>]?$/;
|
|
100
|
-
const shouldMatchWord = (exec, matchWord) => {
|
|
101
|
-
if (!matchWord) {
|
|
102
|
-
return true;
|
|
103
|
-
}
|
|
104
|
-
else if (matchWord === true) {
|
|
105
|
-
const text = exec.input;
|
|
106
|
-
const charBefore = text.charAt(exec.index - 1);
|
|
107
|
-
const charAfter = text.charAt(exec.index + exec[0].length);
|
|
108
|
-
return notLetter.test(charBefore) && notLetter.test(charAfter);
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
return matchWord(exec);
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
const createRegExp = (inputString, flags) => {
|
|
115
|
-
const escaped = inputString
|
|
116
|
-
.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
|
|
117
|
-
.replace(/-/g, '\\x2d')
|
|
118
|
-
.replace(/\s/g, '\\s');
|
|
119
|
-
return new RegExp(escaped, flags);
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
export { find, findAll, findAt, replace, replaceAll };
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { htmlToFragment, fragmentToHtml } from './source.js';
|
|
2
|
-
|
|
3
|
-
class DomTreeExtractor {
|
|
4
|
-
constructor(top) {
|
|
5
|
-
this.extractBefore = (edgeNode) => {
|
|
6
|
-
return this._traverseSide({
|
|
7
|
-
edge: edgeNode,
|
|
8
|
-
next: function (node) {
|
|
9
|
-
return node.previousSibling;
|
|
10
|
-
},
|
|
11
|
-
insert: function (fragment, node) {
|
|
12
|
-
fragment.insertBefore(node, fragment.firstChild);
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
this.extractAfter = (edgeNode) => {
|
|
17
|
-
return this._traverseSide({
|
|
18
|
-
edge: edgeNode,
|
|
19
|
-
next: function (node) {
|
|
20
|
-
return node.nextSibling;
|
|
21
|
-
},
|
|
22
|
-
insert: function (fragment, node) {
|
|
23
|
-
fragment.appendChild(node);
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
this._traverseSide = (options) => {
|
|
28
|
-
const top = this.top, doc = top.ownerDocument, fragment = doc.createDocumentFragment();
|
|
29
|
-
let current = options.edge;
|
|
30
|
-
do {
|
|
31
|
-
const parentNode = current.parentNode;
|
|
32
|
-
current = options.next(current);
|
|
33
|
-
while (current) {
|
|
34
|
-
const next = options.next(current);
|
|
35
|
-
options.insert(fragment, current);
|
|
36
|
-
current = next;
|
|
37
|
-
}
|
|
38
|
-
if (top === parentNode || top.contains(parentNode)) {
|
|
39
|
-
const container = parentNode.cloneNode(false);
|
|
40
|
-
container.innerHTML = '';
|
|
41
|
-
container.appendChild(fragment);
|
|
42
|
-
options.insert(fragment, container);
|
|
43
|
-
}
|
|
44
|
-
current = parentNode;
|
|
45
|
-
} while (current && current !== top);
|
|
46
|
-
return fragment;
|
|
47
|
-
};
|
|
48
|
-
this.top = top;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
const getInnerSpan = (dom) => {
|
|
52
|
-
return dom.querySelector('span span');
|
|
53
|
-
};
|
|
54
|
-
const isEmptySpan = (fragment) => {
|
|
55
|
-
return fragment.childNodes.length === 1 && fragment.firstChild.nodeName === 'SPAN' && fragment.firstChild.childNodes.length === 0;
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* Flattens nested <span> elements in the given HTML string while preserving
|
|
59
|
-
* the original styling and formatting.
|
|
60
|
-
*
|
|
61
|
-
* @param content - The HTML content to normalize.
|
|
62
|
-
* @returns The normalized HTML content with flattened <span> elements.
|
|
63
|
-
*/
|
|
64
|
-
const flattenNestedSpans = (content) => {
|
|
65
|
-
const dom = htmlToFragment(content);
|
|
66
|
-
let innerSpan = getInnerSpan(dom);
|
|
67
|
-
while (innerSpan) {
|
|
68
|
-
const parentSpan = innerSpan.parentNode.closest('span');
|
|
69
|
-
if (parentSpan) {
|
|
70
|
-
const extractor = new DomTreeExtractor(parentSpan);
|
|
71
|
-
const right = extractor.extractAfter(innerSpan);
|
|
72
|
-
const left = extractor.extractBefore(innerSpan);
|
|
73
|
-
for (let i = 0; i < innerSpan.style.length; i++) {
|
|
74
|
-
const prop = innerSpan.style.item(i);
|
|
75
|
-
parentSpan.style[prop] = innerSpan.style.getPropertyValue(prop);
|
|
76
|
-
}
|
|
77
|
-
innerSpan.removeAttribute('style');
|
|
78
|
-
if (innerSpan.classList.length) {
|
|
79
|
-
Array.from(innerSpan.classList).forEach((classValue) => {
|
|
80
|
-
if (!parentSpan.classList.contains(classValue)) {
|
|
81
|
-
parentSpan.classList.add(classValue);
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
innerSpan.removeAttribute('class');
|
|
86
|
-
for (let index = 0; index < innerSpan.attributes.length; index++) {
|
|
87
|
-
const attr = innerSpan.attributes.item(index);
|
|
88
|
-
if (attr && attr.nodeValue !== null) {
|
|
89
|
-
parentSpan.setAttribute(attr.nodeName, attr.nodeValue);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
while (innerSpan.firstChild && innerSpan.parentNode) {
|
|
93
|
-
innerSpan.parentNode.insertBefore(innerSpan.firstChild, innerSpan);
|
|
94
|
-
}
|
|
95
|
-
if (innerSpan.parentNode) {
|
|
96
|
-
innerSpan.parentNode.removeChild(innerSpan);
|
|
97
|
-
}
|
|
98
|
-
if (parentSpan.parentNode) {
|
|
99
|
-
if (!isEmptySpan(left)) {
|
|
100
|
-
parentSpan.parentNode.insertBefore(left, parentSpan);
|
|
101
|
-
}
|
|
102
|
-
if (!isEmptySpan(right)) {
|
|
103
|
-
parentSpan.parentNode.insertBefore(right, parentSpan.nextSibling);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
innerSpan = getInnerSpan(dom);
|
|
108
|
-
}
|
|
109
|
-
return fragmentToHtml(dom);
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
export { flattenNestedSpans };
|
package/dist/es2015/image.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { insertNode } from './utils.js';
|
|
2
|
-
|
|
3
|
-
const insertImage = (attrs) => (state, dispatch) => {
|
|
4
|
-
const { image } = state.schema.nodes;
|
|
5
|
-
const commandName = 'insertImage';
|
|
6
|
-
const newImage = image.createAndFill(attrs);
|
|
7
|
-
insertNode(newImage)(state, tr => dispatch(tr.setMeta('commandName', commandName).setMeta('args', attrs)));
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export { insertImage };
|
package/dist/es2015/indent.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { sinkListItem, liftListItem } from 'prosemirror-schema-list';
|
|
2
|
-
import { indentRules, outdentRules } from './config/indent-rules.js';
|
|
3
|
-
import { hasNode, blockNodes, addStyles, changeTextBlock } from './blockNode.js';
|
|
4
|
-
import { findNthParentNodeOfType } from './utils.js';
|
|
5
|
-
import { liftBlockquote } from './blockquote.js';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Indenting block elements in the selection.
|
|
9
|
-
*
|
|
10
|
-
* @returns {boolean} - Returns true if any indentation is applied.
|
|
11
|
-
*/
|
|
12
|
-
const indentBlocks = (actions, command, dir) => (state, dispatch) => {
|
|
13
|
-
const blocks = blockNodes(state);
|
|
14
|
-
const tr = state.tr;
|
|
15
|
-
tr.setMeta('commandName', command);
|
|
16
|
-
blocks.forEach(node => {
|
|
17
|
-
if (node.type.isTextblock) {
|
|
18
|
-
let newAttrs;
|
|
19
|
-
const action = actions.find(a => a.node === node.type.name);
|
|
20
|
-
if (action) {
|
|
21
|
-
const style = dir === 'rtl' ? action.rtlStyle : action.style;
|
|
22
|
-
const newStyle = {
|
|
23
|
-
name: style,
|
|
24
|
-
value: action.step > 0 ? `${action.step}${action.unit}` : ''
|
|
25
|
-
};
|
|
26
|
-
if (node.attrs.style) {
|
|
27
|
-
const re = new RegExp(`${style}:\\s?(\\d+)${action.unit}`, 'i');
|
|
28
|
-
const match = node.attrs.style.match(re);
|
|
29
|
-
if (match) {
|
|
30
|
-
let newMargin = parseFloat(match[1]) + action.step;
|
|
31
|
-
newMargin = newMargin <= 0 ? '' : newMargin;
|
|
32
|
-
newStyle.value = `${newMargin}${newMargin ? action.unit : ''}`;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
newAttrs = addStyles(node, [newStyle]);
|
|
36
|
-
}
|
|
37
|
-
if (newAttrs) {
|
|
38
|
-
changeTextBlock(tr, node, node.type, newAttrs);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
const result = tr.docChanged;
|
|
43
|
-
if (result) {
|
|
44
|
-
dispatch(tr.scrollIntoView());
|
|
45
|
-
}
|
|
46
|
-
return result;
|
|
47
|
-
};
|
|
48
|
-
const isIndented = (state, rules, dir) => {
|
|
49
|
-
const blocks = blockNodes(state);
|
|
50
|
-
let result = false;
|
|
51
|
-
blocks.forEach(node => {
|
|
52
|
-
if (!result && node.type.isTextblock && node.attrs.style) {
|
|
53
|
-
const action = rules.find(a => a.node === node.type.name);
|
|
54
|
-
if (action) {
|
|
55
|
-
const style = dir === 'rtl' ? action.rtlStyle : action.style;
|
|
56
|
-
const reIndent = new RegExp(`${style}:\\s?\\d+${action.unit}`, 'i');
|
|
57
|
-
result = reIndent.test(node.attrs.style);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
return result;
|
|
62
|
-
};
|
|
63
|
-
const canIndentAsListItem = (state, nodeType) => {
|
|
64
|
-
return sinkListItem(nodeType)(state);
|
|
65
|
-
};
|
|
66
|
-
const canOutdentAsListItem = (state, rules) => {
|
|
67
|
-
const listItem = state.schema.nodes[rules.listsTypes.listItem];
|
|
68
|
-
const orderedList = state.schema.nodes[rules.listsTypes.orderedList];
|
|
69
|
-
const bulletList = state.schema.nodes[rules.listsTypes.bulletList];
|
|
70
|
-
const isNestedInOL = !!findNthParentNodeOfType(orderedList, 2)(state.selection);
|
|
71
|
-
const isNestedInUL = !!findNthParentNodeOfType(bulletList, 2)(state.selection);
|
|
72
|
-
return (isNestedInOL || isNestedInUL) && liftListItem(listItem)(state);
|
|
73
|
-
};
|
|
74
|
-
const canBeIndented = (state, rules) => {
|
|
75
|
-
const nodes = state.schema.nodes;
|
|
76
|
-
const listItem = nodes[indentRules.listsTypes.listItem];
|
|
77
|
-
return ((isIndented(state, rules.nodes) || indentRules.nodes.some(rule => nodes[rule.node] && hasNode(state, nodes[rule.node]))) &&
|
|
78
|
-
!hasNode(state, listItem));
|
|
79
|
-
};
|
|
80
|
-
const indent = (state, dispatch) => {
|
|
81
|
-
const listItem = state.schema.nodes[indentRules.listsTypes.listItem];
|
|
82
|
-
const isIndentableBlock = canBeIndented(state, indentRules);
|
|
83
|
-
if (canIndentAsListItem(state, listItem)) {
|
|
84
|
-
sinkListItem(listItem)(state, dispatch);
|
|
85
|
-
}
|
|
86
|
-
else if (isIndentableBlock) {
|
|
87
|
-
indentBlocks(indentRules.nodes)(state, dispatch);
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
const outdent = (state, dispatch) => {
|
|
91
|
-
const nodes = state.schema.nodes;
|
|
92
|
-
const listItem = nodes[outdentRules.listsTypes.listItem];
|
|
93
|
-
const isIndentableBlock = canBeIndented(state, outdentRules);
|
|
94
|
-
if (hasNode(state, nodes.blockquote)) {
|
|
95
|
-
liftBlockquote(state, dispatch);
|
|
96
|
-
}
|
|
97
|
-
else if (canOutdentAsListItem(state, outdentRules)) {
|
|
98
|
-
liftListItem(listItem)(state, dispatch);
|
|
99
|
-
}
|
|
100
|
-
else if (isIndentableBlock) {
|
|
101
|
-
indentBlocks(outdentRules.nodes)(state, dispatch);
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export { canBeIndented, canIndentAsListItem, canOutdentAsListItem, indent, indentBlocks, isIndented, outdent };
|