@progress/kendo-editor-common 1.11.9-dev.202411251354 → 1.11.9-develop.1
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/main.js +1 -1
- package/dist/es/DOMSerializer.js +71 -75
- package/dist/es/align.js +19 -16
- package/dist/es/blockNode.js +76 -78
- package/dist/es/blockquote.js +12 -9
- package/dist/es/cleanFormatting.js +16 -16
- package/dist/es/config/align-rules.js +8 -6
- package/dist/es/config/commands.js +9 -13
- package/dist/es/config/constants.js +9 -7
- package/dist/es/config/indent-rules.js +8 -6
- package/dist/es/config/keymap.js +20 -18
- package/dist/es/config/list-settings.js +7 -6
- package/dist/es/config/schema.js +184 -126
- package/dist/es/find-replace.js +34 -32
- package/dist/es/image.js +10 -7
- package/dist/es/indent.js +47 -44
- package/dist/es/inline-style.js +72 -70
- package/dist/es/link.js +51 -52
- package/dist/es/listConvert.js +37 -34
- package/dist/es/lists.js +83 -82
- package/dist/es/main.js +32 -33
- package/dist/es/mark.js +87 -92
- package/dist/es/paste.js +48 -46
- package/dist/es/plugins/caret-color.js +14 -11
- package/dist/es/plugins/csp-fix.js +23 -23
- package/dist/es/plugins/highlight.js +12 -10
- package/dist/es/plugins/image-resize.js +81 -81
- package/dist/es/plugins/list-markers-styles.js +43 -39
- package/dist/es/plugins/placeholder.js +12 -9
- package/dist/es/plugins/resize-utils.js +11 -9
- package/dist/es/plugins/spaces-fix.js +13 -10
- package/dist/es/plugins/table-resize/column-resize.js +104 -102
- package/dist/es/plugins/table-resize/index.js +10 -7
- package/dist/es/plugins/table-resize/row-resize.js +88 -89
- package/dist/es/plugins/table-resize/table-resize.js +129 -122
- package/dist/es/plugins/table-resize/table-view.js +46 -48
- package/dist/es/plugins/table-resize/utils.js +39 -41
- package/dist/es/source.js +78 -74
- package/dist/es/table.js +64 -66
- package/dist/es/text.js +4 -2
- package/dist/es/utils.js +107 -116
- package/dist/es2015/DOMSerializer.js +20 -17
- package/dist/es2015/align.js +6 -3
- package/dist/es2015/blockNode.js +15 -12
- package/dist/es2015/blockquote.js +5 -2
- package/dist/es2015/cleanFormatting.js +6 -3
- package/dist/es2015/config/align-rules.js +7 -5
- package/dist/es2015/config/commands.js +9 -13
- package/dist/es2015/config/constants.js +9 -7
- package/dist/es2015/config/indent-rules.js +6 -3
- package/dist/es2015/config/keymap.js +10 -7
- package/dist/es2015/config/list-settings.js +5 -3
- package/dist/es2015/config/schema.js +8 -6
- package/dist/es2015/find-replace.js +9 -6
- package/dist/es2015/image.js +5 -2
- package/dist/es2015/indent.js +14 -11
- package/dist/es2015/inline-style.js +9 -6
- package/dist/es2015/link.js +7 -4
- package/dist/es2015/listConvert.js +5 -2
- package/dist/es2015/lists.js +14 -11
- package/dist/es2015/main.js +32 -33
- package/dist/es2015/mark.js +15 -12
- package/dist/es2015/node_modules/tslib/tslib.es6.js +35 -0
- package/dist/es2015/paste.js +14 -11
- package/dist/es2015/plugins/caret-color.js +8 -5
- package/dist/es2015/plugins/csp-fix.js +5 -2
- package/dist/es2015/plugins/highlight.js +6 -3
- package/dist/es2015/plugins/image-resize.js +10 -7
- package/dist/es2015/plugins/list-markers-styles.js +6 -3
- package/dist/es2015/plugins/placeholder.js +5 -2
- package/dist/es2015/plugins/resize-utils.js +11 -9
- package/dist/es2015/plugins/spaces-fix.js +4 -1
- package/dist/es2015/plugins/table-resize/column-resize.js +24 -21
- package/dist/es2015/plugins/table-resize/index.js +9 -6
- package/dist/es2015/plugins/table-resize/row-resize.js +23 -20
- package/dist/es2015/plugins/table-resize/table-resize.js +20 -17
- package/dist/es2015/plugins/table-resize/table-view.js +9 -6
- package/dist/es2015/plugins/table-resize/utils.js +13 -10
- package/dist/es2015/source.js +24 -13
- package/dist/es2015/table.js +18 -15
- package/dist/es2015/text.js +3 -1
- package/dist/es2015/utils.js +22 -25
- package/dist/npm/DOMSerializer.js +73 -78
- package/dist/npm/align.d.ts +7 -4
- package/dist/npm/align.js +22 -21
- package/dist/npm/blockNode.d.ts +14 -15
- package/dist/npm/blockNode.js +91 -95
- package/dist/npm/blockquote.d.ts +5 -2
- package/dist/npm/blockquote.js +16 -15
- package/dist/npm/cleanFormatting.d.ts +6 -3
- package/dist/npm/cleanFormatting.js +17 -19
- package/dist/npm/config/align-rules.d.ts +8 -6
- package/dist/npm/config/align-rules.js +14 -9
- package/dist/npm/config/commands.d.ts +11 -19
- package/dist/npm/config/commands.js +17 -16
- package/dist/npm/config/constants.js +17 -10
- package/dist/npm/config/indent-rules.d.ts +6 -4
- package/dist/npm/config/indent-rules.js +11 -9
- package/dist/npm/config/keymap.d.ts +5 -2
- package/dist/npm/config/keymap.js +30 -30
- package/dist/npm/config/list-settings.js +13 -11
- package/dist/npm/config/schema.d.ts +4 -3
- package/dist/npm/config/schema.js +191 -134
- package/dist/npm/find-replace.d.ts +10 -7
- package/dist/npm/find-replace.js +47 -47
- package/dist/npm/image.d.ts +6 -3
- package/dist/npm/image.js +11 -10
- package/dist/npm/indent.d.ts +12 -9
- package/dist/npm/indent.js +68 -67
- package/dist/npm/inline-style.d.ts +7 -4
- package/dist/npm/inline-style.js +83 -83
- package/dist/npm/link.d.ts +4 -2
- package/dist/npm/link.js +58 -61
- package/dist/npm/listConvert.d.ts +3 -1
- package/dist/npm/listConvert.js +40 -39
- package/dist/npm/lists.d.ts +9 -9
- package/dist/npm/lists.js +94 -95
- package/dist/npm/main.d.ts +34 -33
- package/dist/npm/main.js +388 -198
- package/dist/npm/mark.d.ts +13 -18
- package/dist/npm/mark.js +104 -111
- package/dist/npm/paste.d.ts +12 -9
- package/dist/npm/paste.js +61 -61
- package/dist/npm/plugins/caret-color.d.ts +6 -3
- package/dist/npm/plugins/caret-color.js +21 -19
- package/dist/npm/plugins/csp-fix.d.ts +4 -1
- package/dist/npm/plugins/csp-fix.js +28 -30
- package/dist/npm/plugins/highlight.d.ts +7 -4
- package/dist/npm/plugins/highlight.js +17 -16
- package/dist/npm/plugins/image-resize.d.ts +7 -5
- package/dist/npm/plugins/image-resize.js +96 -97
- package/dist/npm/plugins/list-markers-styles.d.ts +5 -2
- package/dist/npm/plugins/list-markers-styles.js +49 -47
- package/dist/npm/plugins/placeholder.d.ts +4 -1
- package/dist/npm/plugins/placeholder.js +18 -17
- package/dist/npm/plugins/resize-utils.js +14 -12
- package/dist/npm/plugins/spaces-fix.d.ts +4 -1
- package/dist/npm/plugins/spaces-fix.js +19 -18
- package/dist/npm/plugins/table-resize/column-resize.js +117 -117
- package/dist/npm/plugins/table-resize/index.d.ts +5 -2
- package/dist/npm/plugins/table-resize/index.js +16 -15
- package/dist/npm/plugins/table-resize/row-resize.js +98 -101
- package/dist/npm/plugins/table-resize/table-resize.js +144 -139
- package/dist/npm/plugins/table-resize/table-view.js +59 -61
- package/dist/npm/plugins/table-resize/utils.d.ts +7 -17
- package/dist/npm/plugins/table-resize/utils.js +51 -52
- package/dist/npm/source.d.ts +18 -11
- package/dist/npm/source.js +94 -91
- package/dist/npm/table.d.ts +10 -9
- package/dist/npm/table.js +93 -82
- package/dist/npm/text.d.ts +6 -3
- package/dist/npm/text.js +5 -5
- package/dist/npm/types/active-marks.d.ts +4 -1
- package/dist/npm/types/command.d.ts +5 -2
- package/dist/npm/types/dispatchFn.d.ts +4 -1
- package/dist/npm/types/paste-cleanup-settings.d.ts +3 -1
- package/dist/npm/utils.d.ts +13 -32
- package/dist/npm/utils.js +133 -145
- package/package.json +35 -53
- package/dist/cdn/js/kendo-editor-common.js +0 -1
- package/dist/es/types/active-marks.js +0 -1
- package/dist/es/types/command.js +0 -1
- package/dist/es/types/dispatchFn.js +0 -1
- package/dist/es/types/paste-cleanup-settings.js +0 -1
- package/dist/es/types/predicate.js +0 -1
- package/dist/es2015/types/active-marks.js +0 -1
- package/dist/es2015/types/command.js +0 -1
- package/dist/es2015/types/dispatchFn.js +0 -1
- package/dist/es2015/types/paste-cleanup-settings.js +0 -1
- package/dist/es2015/types/predicate.js +0 -1
- package/dist/npm/DOMSerializer.d.ts +0 -35
- package/dist/npm/config/constants.d.ts +0 -7
- package/dist/npm/config/list-settings.d.ts +0 -30
- package/dist/npm/plugins/resize-utils.d.ts +0 -35
- package/dist/npm/plugins/table-resize/column-resize.d.ts +0 -2
- package/dist/npm/plugins/table-resize/row-resize.d.ts +0 -2
- package/dist/npm/plugins/table-resize/table-resize.d.ts +0 -18
- package/dist/npm/plugins/table-resize/table-view.d.ts +0 -28
- package/dist/npm/types/active-marks.js +0 -2
- package/dist/npm/types/command.js +0 -2
- package/dist/npm/types/dispatchFn.js +0 -2
- package/dist/npm/types/paste-cleanup-settings.js +0 -2
- package/dist/npm/types/predicate.d.ts +0 -1
- package/dist/npm/types/predicate.js +0 -2
- package/dist/systemjs/kendo-editor-common.js +0 -1
package/dist/es/listConvert.js
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { htmlToFragment, fragmentToHtml } from './source.js';
|
|
2
|
+
|
|
3
|
+
const msoListRegExp = /style=['"]?[^'"]*?mso-list:\s*[a-zA-Z]+(\d+)\s[a-zA-Z]+(\d+)\s(\w+)/gi;
|
|
4
|
+
const extractListLevels = (html) => {
|
|
5
|
+
html = html.replace(msoListRegExp, (match, list, level) => {
|
|
6
|
+
return `datalist="${list}" datalevel="${level}" ${match}`;
|
|
6
7
|
});
|
|
7
8
|
return html;
|
|
8
9
|
};
|
|
9
|
-
|
|
10
|
+
const isPartOfListItem = (element) => {
|
|
10
11
|
return /^MsoListParagraph/.test(element.className);
|
|
11
12
|
};
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
const innerText = (node) => {
|
|
14
|
+
let text = node.innerHTML;
|
|
14
15
|
text = text.replace(/<!--(.|\s)*?-->/gi, '');
|
|
15
16
|
text = text.replace(/<\/?[^>]+?\/?>/gm, '');
|
|
16
17
|
return text;
|
|
17
18
|
};
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
const createList = (type, styleType) => {
|
|
20
|
+
const list = document.createElement(type);
|
|
20
21
|
list.style.listStyleType = styleType;
|
|
21
22
|
return list;
|
|
22
23
|
};
|
|
23
|
-
|
|
24
|
+
const guessUnorderedListStyle = (symbol) => {
|
|
24
25
|
if (/^[\u2022\u00b7\u00FC\u00D8\u002dv-]/.test(symbol)) {
|
|
25
26
|
return null; // return "disc"; //default CSS value
|
|
26
27
|
}
|
|
@@ -31,21 +32,21 @@ var guessUnorderedListStyle = function (symbol) {
|
|
|
31
32
|
return 'square';
|
|
32
33
|
}
|
|
33
34
|
};
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
const guessOrderedListStyle = (symbol) => {
|
|
36
|
+
let type = null;
|
|
36
37
|
if (!/^\d/.test(symbol)) {
|
|
37
38
|
type = (/^[a-z]/.test(symbol) ? 'lower-' : 'upper-') +
|
|
38
39
|
(/^[ivxlcdm]/i.test(symbol) ? 'roman' : 'alpha');
|
|
39
40
|
}
|
|
40
41
|
return type;
|
|
41
42
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
Array.from(nodes).forEach(
|
|
43
|
+
const mapListsCandidates = (nodes, groups) => {
|
|
44
|
+
let group = [];
|
|
45
|
+
Array.from(nodes).forEach(node => {
|
|
45
46
|
if (node.nodeType !== Node.ELEMENT_NODE) {
|
|
46
47
|
return;
|
|
47
48
|
}
|
|
48
|
-
|
|
49
|
+
const element = node;
|
|
49
50
|
if (element.getAttribute('datalist')) {
|
|
50
51
|
group.push(node);
|
|
51
52
|
groups.add(group);
|
|
@@ -59,16 +60,16 @@ var mapListsCandidates = function (nodes, groups) {
|
|
|
59
60
|
mapListsCandidates(element.children, groups);
|
|
60
61
|
}
|
|
61
62
|
else if (element.nodeName === 'TABLE') {
|
|
62
|
-
Array.from(element.querySelectorAll('td,th')).forEach(
|
|
63
|
+
Array.from(element.querySelectorAll('td,th')).forEach(cell => {
|
|
63
64
|
mapListsCandidates(cell.children, groups);
|
|
64
65
|
});
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
});
|
|
68
69
|
};
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
const listTypes = (p) => {
|
|
71
|
+
let html = p.innerHTML;
|
|
72
|
+
const trimStartText = (t) => {
|
|
72
73
|
return t.replace(/^(?: |[\u00a0\n\r\s])+/, '');
|
|
73
74
|
};
|
|
74
75
|
html = html.replace(/<\/?\w+[^>]*>/g, '').replace(/ /g, '\u00a0');
|
|
@@ -85,8 +86,8 @@ var listTypes = function (p) {
|
|
|
85
86
|
};
|
|
86
87
|
}
|
|
87
88
|
};
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
const convertToLi = (p) => {
|
|
90
|
+
let content, name = p.nodeName.toLowerCase();
|
|
90
91
|
if (p.firstChild && p.firstChild.nodeType === Node.COMMENT_NODE) {
|
|
91
92
|
p.removeChild(p.firstChild);
|
|
92
93
|
}
|
|
@@ -113,20 +114,20 @@ var convertToLi = function (p) {
|
|
|
113
114
|
}
|
|
114
115
|
}
|
|
115
116
|
p.parentNode.removeChild(p);
|
|
116
|
-
|
|
117
|
+
const li = document.createElement('li');
|
|
117
118
|
li.appendChild(htmlToFragment(content));
|
|
118
119
|
return li;
|
|
119
120
|
};
|
|
120
|
-
|
|
121
|
-
|
|
121
|
+
const toList = (blockNodes) => {
|
|
122
|
+
let lastMargin = -1, levels = {}, li, rootMargin, rootIndex, lastRootLi, isLastRootLi, rootList, items, i, p, type, margin, list, listData;
|
|
122
123
|
for (i = 0; i < blockNodes.length; i++) {
|
|
123
124
|
p = blockNodes[i];
|
|
124
125
|
listData = {
|
|
125
126
|
datalist: p.getAttribute('datalist'),
|
|
126
127
|
datalevel: p.getAttribute('datalevel')
|
|
127
128
|
};
|
|
128
|
-
|
|
129
|
-
|
|
129
|
+
const listIndex = listData.datalist;
|
|
130
|
+
const listType = listTypes(p);
|
|
130
131
|
type = listType && listType.tag;
|
|
131
132
|
if (!type) {
|
|
132
133
|
if (li && (!isLastRootLi || isPartOfListItem(p))) {
|
|
@@ -145,14 +146,14 @@ var toList = function (blockNodes) {
|
|
|
145
146
|
if (!listData.datalevel && !p.style.marginLeft) {
|
|
146
147
|
continue;
|
|
147
148
|
}
|
|
148
|
-
|
|
149
|
+
const levelType = type + listIndex;
|
|
149
150
|
if (!levels[margin]) {
|
|
150
151
|
levels[margin] = {};
|
|
151
152
|
}
|
|
152
153
|
if (!rootMargin || rootMargin < 0) {
|
|
153
154
|
rootMargin = margin;
|
|
154
155
|
rootIndex = listIndex;
|
|
155
|
-
items = blockNodes.filter(
|
|
156
|
+
items = blockNodes.filter(e => e.getAttribute('datalist') === String(rootIndex));
|
|
156
157
|
lastRootLi = items[items.length - 1];
|
|
157
158
|
rootList = createList(type, listType && listType.style);
|
|
158
159
|
p.parentNode.insertBefore(rootList, p);
|
|
@@ -176,10 +177,12 @@ var toList = function (blockNodes) {
|
|
|
176
177
|
}
|
|
177
178
|
}
|
|
178
179
|
};
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
180
|
+
const convertMsLists = (html) => {
|
|
181
|
+
const container = htmlToFragment(extractListLevels(html));
|
|
182
|
+
const groups = new Set();
|
|
182
183
|
mapListsCandidates(container.children, groups);
|
|
183
|
-
groups.forEach(
|
|
184
|
+
groups.forEach(listsCandidates => toList(listsCandidates));
|
|
184
185
|
return fragmentToHtml(container);
|
|
185
186
|
};
|
|
187
|
+
|
|
188
|
+
export { convertMsLists };
|
package/dist/es/lists.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Fragment, Slice, NodeRange } from 'prosemirror-model';
|
|
1
|
+
import { Slice, Fragment, NodeRange } from 'prosemirror-model';
|
|
3
2
|
import { TextSelection, NodeSelection } from 'prosemirror-state';
|
|
4
3
|
import { liftTarget, ReplaceAroundStep } from 'prosemirror-transform';
|
|
5
4
|
import { autoJoin } from 'prosemirror-commands';
|
|
6
|
-
import { wrapInList as
|
|
7
|
-
import { bulletList
|
|
8
|
-
|
|
5
|
+
import { wrapInList as wrapInList$1, splitListItem } from 'prosemirror-schema-list';
|
|
6
|
+
import { bulletList, orderedList } from './config/list-settings.js';
|
|
7
|
+
|
|
8
|
+
const rootListDepth = (pos, nodes) => {
|
|
9
9
|
// Get the depth of the nearest ancestor list
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
for (
|
|
13
|
-
|
|
10
|
+
const { bulletList, orderedList, listItem } = nodes;
|
|
11
|
+
let depth;
|
|
12
|
+
for (let i = pos.depth - 1; i > 0; i--) {
|
|
13
|
+
const node = pos.node(i);
|
|
14
14
|
if (node.type === bulletList || node.type === orderedList) {
|
|
15
15
|
depth = i;
|
|
16
16
|
}
|
|
@@ -20,14 +20,14 @@ var rootListDepth = function (pos, nodes) {
|
|
|
20
20
|
}
|
|
21
21
|
return depth;
|
|
22
22
|
};
|
|
23
|
-
|
|
23
|
+
const getListLiftTarget = (schema, resPos, options) => {
|
|
24
24
|
// This will return (depth - 1) for root list parent of a list.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
for (
|
|
30
|
-
|
|
25
|
+
let target = resPos.depth;
|
|
26
|
+
const bulletList = schema.nodes[options.bulletList];
|
|
27
|
+
const orderedList = schema.nodes[options.orderedList];
|
|
28
|
+
const listItem = schema.nodes[options.listItem];
|
|
29
|
+
for (let i = resPos.depth; i > 0; i--) {
|
|
30
|
+
const node = resPos.node(i);
|
|
31
31
|
if (node.type === bulletList || node.type === orderedList) {
|
|
32
32
|
target = i;
|
|
33
33
|
}
|
|
@@ -39,26 +39,26 @@ var getListLiftTarget = function (schema, resPos, options) {
|
|
|
39
39
|
};
|
|
40
40
|
function liftSelectionList(state, tr, options) {
|
|
41
41
|
// The function will list paragraphs in selection out to level 1 below root list.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
tr.doc.nodesBetween(from, to,
|
|
42
|
+
const { from, to } = state.selection;
|
|
43
|
+
const { paragraph, heading } = state.schema.nodes;
|
|
44
|
+
const listCol = [];
|
|
45
|
+
tr.doc.nodesBetween(from, to, (node, pos) => {
|
|
46
46
|
if (node.type === paragraph || node.type === heading) {
|
|
47
|
-
listCol.push({ node
|
|
47
|
+
listCol.push({ node, pos });
|
|
48
48
|
}
|
|
49
49
|
});
|
|
50
|
-
for (
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
for (let i = listCol.length - 1; i >= 0; i--) {
|
|
51
|
+
const block = listCol[i];
|
|
52
|
+
const start = tr.doc.resolve(tr.mapping.map(block.pos));
|
|
53
53
|
if (start.depth > 0) {
|
|
54
|
-
|
|
54
|
+
let end;
|
|
55
55
|
if (block.node.textContent && block.node.textContent.length > 0) {
|
|
56
56
|
end = tr.doc.resolve(tr.mapping.map(block.pos + block.node.textContent.length));
|
|
57
57
|
}
|
|
58
58
|
else {
|
|
59
59
|
end = tr.doc.resolve(tr.mapping.map(block.pos + 1));
|
|
60
60
|
}
|
|
61
|
-
|
|
61
|
+
const range = start.blockRange(end);
|
|
62
62
|
if (range) {
|
|
63
63
|
tr.lift(range, getListLiftTarget(state.schema, start, options));
|
|
64
64
|
}
|
|
@@ -72,11 +72,11 @@ function toggleListCommand(options) {
|
|
|
72
72
|
return false;
|
|
73
73
|
}
|
|
74
74
|
state = view.state;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
const listNode = state.schema.nodes[options.listType];
|
|
76
|
+
const { $from, $to } = state.selection;
|
|
77
|
+
const parent = $from.node(-2);
|
|
78
|
+
const grandgrandParent = $from.node(-3);
|
|
79
|
+
const isRangeOfSingleType = isRangeOfType(state.doc, $from, $to, listNode);
|
|
80
80
|
if (((parent && parent.type === listNode) ||
|
|
81
81
|
(grandgrandParent && grandgrandParent.type === listNode)) &&
|
|
82
82
|
isRangeOfSingleType) {
|
|
@@ -94,14 +94,14 @@ function toggleListCommand(options) {
|
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
96
|
function liftListItem(state, selection, tr, nodeType) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
const listItemNodeType = nodeType || state.schema.nodes.listItem;
|
|
98
|
+
const { $from, $to } = selection;
|
|
99
|
+
let range = $from.blockRange($to, node => node.childCount && node.firstChild.type === listItemNodeType);
|
|
100
100
|
if (!range || range.depth < 2 || $from.node(range.depth - 1).type !== listItemNodeType) {
|
|
101
101
|
return tr;
|
|
102
102
|
}
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
const end = range.end;
|
|
104
|
+
const endOfList = $to.end(range.depth);
|
|
105
105
|
if (end < endOfList) {
|
|
106
106
|
tr.step(new ReplaceAroundStep(end - 1, endOfList, end, endOfList, new Slice(Fragment.from(listItemNodeType.create(undefined, range.parent.copy())), 1, 0), 1, true));
|
|
107
107
|
range = new NodeRange(tr.doc.resolve($from.pos), tr.doc.resolve(endOfList), range.depth);
|
|
@@ -113,16 +113,16 @@ function liftFollowingList(state, from, to, rootListDepthNum, tr, listItem) {
|
|
|
113
113
|
if (!listItem) {
|
|
114
114
|
listItem = state.schema.nodes.listItem;
|
|
115
115
|
}
|
|
116
|
-
|
|
117
|
-
tr.doc.nodesBetween(from, to,
|
|
116
|
+
let lifted = false;
|
|
117
|
+
tr.doc.nodesBetween(from, to, (node, pos) => {
|
|
118
118
|
if (!lifted && node.type === listItem && pos > from) {
|
|
119
119
|
lifted = true;
|
|
120
|
-
|
|
120
|
+
let listDepth = rootListDepthNum + 3;
|
|
121
121
|
while (listDepth > rootListDepthNum + 2) {
|
|
122
|
-
|
|
122
|
+
const start = tr.doc.resolve(tr.mapping.map(pos));
|
|
123
123
|
listDepth = start.depth;
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
const end = tr.doc.resolve(tr.mapping.map(pos + node.textContent.length));
|
|
125
|
+
const sel = new TextSelection(start, end);
|
|
126
126
|
tr = liftListItem(state, sel, tr, listItem);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
@@ -132,23 +132,23 @@ function liftFollowingList(state, from, to, rootListDepthNum, tr, listItem) {
|
|
|
132
132
|
function isRangeOfType(doc, $from, $to, nodeType) {
|
|
133
133
|
// Step through block-nodes between $from and $to and returns false if a node is
|
|
134
134
|
// found that isn't of the specified type
|
|
135
|
-
return getAncestorNodesBetween(doc, $from, $to).filter(
|
|
135
|
+
return getAncestorNodesBetween(doc, $from, $to).filter((node) => node.type !== nodeType).length === 0;
|
|
136
136
|
}
|
|
137
137
|
function getAncestorNodesBetween(doc, $from, $to) {
|
|
138
138
|
// Returns all top-level ancestor-nodes between $from and $to
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
139
|
+
const nodes = [];
|
|
140
|
+
const maxDepth = findAncestorPosition(doc, $from).depth;
|
|
141
|
+
let current = doc.resolve($from.start(maxDepth));
|
|
142
142
|
while (current.pos <= $to.start($to.depth)) {
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
const depth = Math.min(current.depth, maxDepth);
|
|
144
|
+
const node = current.node(depth);
|
|
145
145
|
if (node) {
|
|
146
146
|
nodes.push(node);
|
|
147
147
|
}
|
|
148
148
|
if (depth === 0) {
|
|
149
149
|
break;
|
|
150
150
|
}
|
|
151
|
-
|
|
151
|
+
let next = doc.resolve(current.after(depth));
|
|
152
152
|
if (next.start(depth) >= doc.nodeSize - 2) {
|
|
153
153
|
break;
|
|
154
154
|
}
|
|
@@ -166,12 +166,12 @@ function getAncestorNodesBetween(doc, $from, $to) {
|
|
|
166
166
|
}
|
|
167
167
|
function findAncestorPosition(doc, pos) {
|
|
168
168
|
// Traverse the document until an "ancestor" is found. Any nestable block can be an ancestor.
|
|
169
|
-
|
|
169
|
+
const nestableBlocks = ['blockquote', 'bulletList', 'orderedList'];
|
|
170
170
|
if (pos.depth === 1) {
|
|
171
171
|
return pos;
|
|
172
172
|
}
|
|
173
|
-
|
|
174
|
-
|
|
173
|
+
let node = pos.node(pos.depth);
|
|
174
|
+
let newPos = pos;
|
|
175
175
|
while (pos.depth >= 1) {
|
|
176
176
|
pos = doc.resolve(pos.before(pos.depth));
|
|
177
177
|
node = pos.node(pos.depth);
|
|
@@ -183,18 +183,18 @@ function findAncestorPosition(doc, pos) {
|
|
|
183
183
|
}
|
|
184
184
|
function liftListItems(options) {
|
|
185
185
|
return function (state, dispatch) {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
tr.doc.nodesBetween($from.pos, $to.pos,
|
|
186
|
+
const { tr } = state;
|
|
187
|
+
const { $from, $to } = state.selection;
|
|
188
|
+
tr.doc.nodesBetween($from.pos, $to.pos, (node, pos) => {
|
|
189
189
|
// Following condition will ensure that block types `paragraph`, `heading`, `codeBlock`, `blockquote`, `div` are lifted.
|
|
190
190
|
// isTextblock is true for paragraph, heading, codeBlock.
|
|
191
191
|
if (node.isTextblock || node.type.name === 'blockquote' || node.type.name === 'div') {
|
|
192
|
-
|
|
193
|
-
|
|
192
|
+
const sel = new NodeSelection(tr.doc.resolve(tr.mapping.map(pos)));
|
|
193
|
+
const range = sel.$from.blockRange(sel.$to);
|
|
194
194
|
if (!range || sel.$from.parent.type !== state.schema.nodes[options.listItem]) {
|
|
195
195
|
return;
|
|
196
196
|
}
|
|
197
|
-
|
|
197
|
+
const target = range && liftTarget(range);
|
|
198
198
|
if (target === undefined || target === null) {
|
|
199
199
|
return false;
|
|
200
200
|
}
|
|
@@ -207,59 +207,60 @@ function liftListItems(options) {
|
|
|
207
207
|
return true;
|
|
208
208
|
};
|
|
209
209
|
}
|
|
210
|
-
function wrapInList(nodeType, attrs) {
|
|
211
|
-
|
|
212
|
-
return autoJoin(pmWrapInList(nodeType, attrs), function (before, after) { return before.type === after.type && before.type === nodeType; });
|
|
210
|
+
function wrapInList(nodeType, attrs = {}) {
|
|
211
|
+
return autoJoin(wrapInList$1(nodeType, attrs), (before, after) => before.type === after.type && before.type === nodeType);
|
|
213
212
|
}
|
|
214
|
-
|
|
213
|
+
const reListStyle = /list\-style\-type:\s?([\w-]+)/;
|
|
215
214
|
/**
|
|
216
215
|
* Extracts list-style-type style from node's attributes.
|
|
217
216
|
*
|
|
218
217
|
* @param attrs - The attributes of the list node
|
|
219
218
|
* @returns The extracted list-style-type.
|
|
220
219
|
*/
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
220
|
+
const listStyle = (attrs) => {
|
|
221
|
+
const styleAttr = attrs.style || '';
|
|
222
|
+
const execArray = reListStyle.exec(styleAttr);
|
|
224
223
|
return (execArray && execArray[1]) || '';
|
|
225
224
|
};
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
225
|
+
const toggleList = (state, dispatch, view, options, command) => {
|
|
226
|
+
const { listType, listAttrs = { style: null } } = options;
|
|
227
|
+
const { selection } = state;
|
|
228
|
+
const fromNode = selection.$from.node(selection.$from.depth - 2);
|
|
229
|
+
const endNode = selection.$to.node(selection.$to.depth - 2);
|
|
231
230
|
if (!fromNode || fromNode.type.name !== listType || listStyle(fromNode.attrs) !== listStyle(listAttrs) ||
|
|
232
231
|
(!endNode || endNode.type.name !== listType || listStyle(endNode.attrs) !== listStyle(listAttrs))) {
|
|
233
232
|
return toggleListCommand(options)(state, dispatch, view);
|
|
234
233
|
}
|
|
235
234
|
else {
|
|
236
|
-
|
|
237
|
-
|
|
235
|
+
const nodes = view.state.schema.nodes;
|
|
236
|
+
const listNodes = {
|
|
238
237
|
bulletList: nodes[options.bulletList],
|
|
239
238
|
orderedList: nodes[options.orderedList],
|
|
240
239
|
listItem: nodes[options.listItem]
|
|
241
240
|
};
|
|
242
|
-
|
|
243
|
-
|
|
241
|
+
const depth = rootListDepth(selection.$to, listNodes);
|
|
242
|
+
let tr = liftFollowingList(state, selection.$to.pos, selection.$to.end(depth), depth, view.state.tr, listNodes.listItem);
|
|
244
243
|
tr = liftSelectionList(state, tr, options);
|
|
245
244
|
tr.setMeta('commandName', command);
|
|
246
245
|
dispatch(tr);
|
|
247
246
|
return true;
|
|
248
247
|
}
|
|
249
248
|
};
|
|
250
|
-
|
|
251
|
-
return toggleList(state, dispatch, view,
|
|
249
|
+
function toggleUnorderedList(state, dispatch, view) {
|
|
250
|
+
return toggleList(state, dispatch, view, { listType: bulletList.listType, ...bulletList.types });
|
|
252
251
|
}
|
|
253
|
-
|
|
254
|
-
return toggleList(state, dispatch, view,
|
|
252
|
+
function toggleOrderedList(state, dispatch, view) {
|
|
253
|
+
return toggleList(state, dispatch, view, { listType: orderedList.listType, ...orderedList.types });
|
|
255
254
|
}
|
|
256
|
-
|
|
255
|
+
const splitListItemKeepMarks = (itemType) => (state, dispatch) => {
|
|
257
256
|
// see https://github.com/ProseMirror/prosemirror-commands/blob/master/src/commands.js#L321-L327
|
|
258
|
-
return splitListItem(itemType)(state,
|
|
259
|
-
|
|
257
|
+
return splitListItem(itemType)(state, tr => {
|
|
258
|
+
const marks = state.storedMarks || (state.selection.$to.parentOffset && state.selection.$from.marks());
|
|
260
259
|
if (marks) {
|
|
261
260
|
tr.ensureMarks(marks);
|
|
262
261
|
}
|
|
263
262
|
dispatch(tr);
|
|
264
263
|
});
|
|
265
|
-
};
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
export { listStyle, splitListItemKeepMarks, toggleList, toggleOrderedList, toggleUnorderedList };
|
package/dist/es/main.js
CHANGED
|
@@ -1,33 +1,32 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { applyInlineStyle, getInlineStyles, toggleInlineFormat } from './inline-style';
|
|
3
|
-
export { applyLink, removeLink } from './link';
|
|
4
|
-
export { insertText } from './text';
|
|
5
|
-
export { insertImage } from './image';
|
|
6
|
-
export { alignBlocks, isAligned } from './align';
|
|
7
|
-
export { cleanFormatting } from './cleanFormatting';
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export { blockquote, liftBlockquote } from './blockquote';
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export { indentRules, outdentRules } from './config/indent-rules';
|
|
16
|
-
export {
|
|
17
|
-
export { buildKeymap, buildListKeymap } from './config/keymap';
|
|
18
|
-
export { bold, italic,
|
|
19
|
-
export {
|
|
20
|
-
export { convertMsLists } from './listConvert';
|
|
21
|
-
export { find,
|
|
22
|
-
export { placeholder } from './plugins/placeholder';
|
|
23
|
-
export { spacesFix } from './plugins/spaces-fix';
|
|
24
|
-
export { cspFix } from './plugins/csp-fix';
|
|
25
|
-
export { textHighlight, textHighlightKey } from './plugins/highlight';
|
|
26
|
-
export {
|
|
27
|
-
export { caretColor, caretColorKey } from './plugins/caret-color';
|
|
28
|
-
export { tableResizing
|
|
29
|
-
export { listMarkersStyles } from './plugins/list-markers-styles';
|
|
30
|
-
// ProseMirror re-exports
|
|
1
|
+
export { domToPmDoc, fragmentToHtml, getHtml, hasSameMarkup, htmlToFragment, parseContent, pmDocToFragment, setHtml, trimWhitespace } from './source.js';
|
|
2
|
+
export { applyInlineStyle, getInlineStyles, toggleInlineFormat } from './inline-style.js';
|
|
3
|
+
export { applyLink, removeLink } from './link.js';
|
|
4
|
+
export { insertText } from './text.js';
|
|
5
|
+
export { insertImage } from './image.js';
|
|
6
|
+
export { alignBlocks, isAligned } from './align.js';
|
|
7
|
+
export { cleanFormatting } from './cleanFormatting.js';
|
|
8
|
+
export { activeNode, blockNodes, changeTextBlock, cleanTextBlockFormatting, formatBlockElements, getBlockFormats, hasNode, parentBlockFormat } from './blockNode.js';
|
|
9
|
+
export { cleanMarks, getActiveMarks, getMark, hasMark, removeAllMarks, selectionMarks } from './mark.js';
|
|
10
|
+
export { canBeIndented, canIndentAsListItem, canOutdentAsListItem, indent, indentBlocks, isIndented, outdent } from './indent.js';
|
|
11
|
+
export { listStyle, toggleList, toggleOrderedList, toggleUnorderedList } from './lists.js';
|
|
12
|
+
export { blockquote, liftBlockquote } from './blockquote.js';
|
|
13
|
+
export { canInsert, expandSelection, expandToWordWrap, getNodeFromSelection, getSelectionText, indentHtml, insertNode, selectedLineTextOnly } from './utils.js';
|
|
14
|
+
export { alignCenterRules, alignJustifyRules, alignLeftRules, alignRemoveRules, alignRightRules } from './config/align-rules.js';
|
|
15
|
+
export { indentRules, outdentRules } from './config/indent-rules.js';
|
|
16
|
+
export { marks, nodes } from './config/schema.js';
|
|
17
|
+
export { buildKeymap, buildListKeymap } from './config/keymap.js';
|
|
18
|
+
export { bold, italic, link, strikethrough, subscript, superscript, underline } from './config/commands.js';
|
|
19
|
+
export { pasteCleanup, removeAttribute, removeComments, removeTag, replaceImageSourcesFromRtf, sanitize, sanitizeClassAttr, sanitizeStyleAttr } from './paste.js';
|
|
20
|
+
export { convertMsLists } from './listConvert.js';
|
|
21
|
+
export { find, findAll, findAt, replace, replaceAll } from './find-replace.js';
|
|
22
|
+
export { placeholder } from './plugins/placeholder.js';
|
|
23
|
+
export { spacesFix } from './plugins/spaces-fix.js';
|
|
24
|
+
export { cspFix } from './plugins/csp-fix.js';
|
|
25
|
+
export { textHighlight, textHighlightKey } from './plugins/highlight.js';
|
|
26
|
+
export { imageResizeKey, imageResizing } from './plugins/image-resize.js';
|
|
27
|
+
export { caretColor, caretColorKey } from './plugins/caret-color.js';
|
|
28
|
+
export { tableResizing } from './plugins/table-resize/index.js';
|
|
29
|
+
export { listMarkersStyles } from './plugins/list-markers-styles.js';
|
|
31
30
|
export * from 'prosemirror-commands';
|
|
32
31
|
export * from 'prosemirror-dropcursor';
|
|
33
32
|
export * from 'prosemirror-gapcursor';
|
|
@@ -37,8 +36,8 @@ export * from 'prosemirror-keymap';
|
|
|
37
36
|
export * from 'prosemirror-model';
|
|
38
37
|
export * from 'prosemirror-schema-list';
|
|
39
38
|
export * from 'prosemirror-state';
|
|
40
|
-
|
|
41
|
-
export { TableMap, tableEditing, tableEditingKey, tableNodeTypes, tableNodes, fixTables, fixTablesKey, isInTable, deleteTable, inSameTable, CellSelection, selectedRect, selectionCell, setCellAttr, goToNextCell, toggleHeader, toggleHeaderCell, toggleHeaderColumn, toggleHeaderRow, splitCell, splitCellWithType, mergeCells, deleteRow, rowIsHeader, addRow, addColSpan, addColumn, colCount, columnIsHeader, columnResizing, columnResizingPluginKey, updateColumnsOnResize, cellAround, findCell, removeColSpan, moveCellForward, nextCell } from 'prosemirror-tables';
|
|
39
|
+
export { CellSelection, TableMap, addColSpan, addColumn, addRow, cellAround, colCount, columnIsHeader, columnResizing, columnResizingPluginKey, deleteRow, deleteTable, findCell, fixTables, fixTablesKey, goToNextCell, inSameTable, isInTable, mergeCells, moveCellForward, nextCell, addColumnAfter as pmAddColumnAfter, addColumnBefore as pmAddColumnBefore, addRowAfter as pmAddRowAfter, addRowBefore as pmAddRowBefore, deleteColumn as pmDeleteColumn, removeColSpan, rowIsHeader, selectedRect, selectionCell, setCellAttr, splitCell, splitCellWithType, tableEditing, tableEditingKey, tableNodeTypes, tableNodes, toggleHeader, toggleHeaderCell, toggleHeaderColumn, toggleHeaderRow, updateColumnsOnResize } from 'prosemirror-tables';
|
|
42
40
|
export * from 'prosemirror-transform';
|
|
43
41
|
export * from 'prosemirror-view';
|
|
44
|
-
export {
|
|
42
|
+
export { addColumnAfter, addColumnBefore, addRowAfter, addRowBefore, createTable, deleteColumn } from './table.js';
|
|
43
|
+
export { tableColumnResizeKey, tableResizeKey, tableRowResizeKey } from './plugins/table-resize/utils.js';
|