@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/npm/lists.js
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var rootListDepth = function (pos, nodes) {
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var prosemirrorModel = require('prosemirror-model');
|
|
4
|
+
var prosemirrorState = require('prosemirror-state');
|
|
5
|
+
var prosemirrorTransform = require('prosemirror-transform');
|
|
6
|
+
var prosemirrorCommands = require('prosemirror-commands');
|
|
7
|
+
var prosemirrorSchemaList = require('prosemirror-schema-list');
|
|
8
|
+
var listSettings = require('./config/list-settings.js');
|
|
9
|
+
|
|
10
|
+
const rootListDepth = (pos, nodes) => {
|
|
12
11
|
// Get the depth of the nearest ancestor list
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
for (
|
|
16
|
-
|
|
12
|
+
const { bulletList, orderedList, listItem } = nodes;
|
|
13
|
+
let depth;
|
|
14
|
+
for (let i = pos.depth - 1; i > 0; i--) {
|
|
15
|
+
const node = pos.node(i);
|
|
17
16
|
if (node.type === bulletList || node.type === orderedList) {
|
|
18
17
|
depth = i;
|
|
19
18
|
}
|
|
@@ -23,14 +22,14 @@ var rootListDepth = function (pos, nodes) {
|
|
|
23
22
|
}
|
|
24
23
|
return depth;
|
|
25
24
|
};
|
|
26
|
-
|
|
25
|
+
const getListLiftTarget = (schema, resPos, options) => {
|
|
27
26
|
// This will return (depth - 1) for root list parent of a list.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
for (
|
|
33
|
-
|
|
27
|
+
let target = resPos.depth;
|
|
28
|
+
const bulletList = schema.nodes[options.bulletList];
|
|
29
|
+
const orderedList = schema.nodes[options.orderedList];
|
|
30
|
+
const listItem = schema.nodes[options.listItem];
|
|
31
|
+
for (let i = resPos.depth; i > 0; i--) {
|
|
32
|
+
const node = resPos.node(i);
|
|
34
33
|
if (node.type === bulletList || node.type === orderedList) {
|
|
35
34
|
target = i;
|
|
36
35
|
}
|
|
@@ -42,26 +41,26 @@ var getListLiftTarget = function (schema, resPos, options) {
|
|
|
42
41
|
};
|
|
43
42
|
function liftSelectionList(state, tr, options) {
|
|
44
43
|
// The function will list paragraphs in selection out to level 1 below root list.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
tr.doc.nodesBetween(from, to,
|
|
44
|
+
const { from, to } = state.selection;
|
|
45
|
+
const { paragraph, heading } = state.schema.nodes;
|
|
46
|
+
const listCol = [];
|
|
47
|
+
tr.doc.nodesBetween(from, to, (node, pos) => {
|
|
49
48
|
if (node.type === paragraph || node.type === heading) {
|
|
50
|
-
listCol.push({ node
|
|
49
|
+
listCol.push({ node, pos });
|
|
51
50
|
}
|
|
52
51
|
});
|
|
53
|
-
for (
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
for (let i = listCol.length - 1; i >= 0; i--) {
|
|
53
|
+
const block = listCol[i];
|
|
54
|
+
const start = tr.doc.resolve(tr.mapping.map(block.pos));
|
|
56
55
|
if (start.depth > 0) {
|
|
57
|
-
|
|
56
|
+
let end;
|
|
58
57
|
if (block.node.textContent && block.node.textContent.length > 0) {
|
|
59
58
|
end = tr.doc.resolve(tr.mapping.map(block.pos + block.node.textContent.length));
|
|
60
59
|
}
|
|
61
60
|
else {
|
|
62
61
|
end = tr.doc.resolve(tr.mapping.map(block.pos + 1));
|
|
63
62
|
}
|
|
64
|
-
|
|
63
|
+
const range = start.blockRange(end);
|
|
65
64
|
if (range) {
|
|
66
65
|
tr.lift(range, getListLiftTarget(state.schema, start, options));
|
|
67
66
|
}
|
|
@@ -75,11 +74,11 @@ function toggleListCommand(options) {
|
|
|
75
74
|
return false;
|
|
76
75
|
}
|
|
77
76
|
state = view.state;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
77
|
+
const listNode = state.schema.nodes[options.listType];
|
|
78
|
+
const { $from, $to } = state.selection;
|
|
79
|
+
const parent = $from.node(-2);
|
|
80
|
+
const grandgrandParent = $from.node(-3);
|
|
81
|
+
const isRangeOfSingleType = isRangeOfType(state.doc, $from, $to, listNode);
|
|
83
82
|
if (((parent && parent.type === listNode) ||
|
|
84
83
|
(grandgrandParent && grandgrandParent.type === listNode)) &&
|
|
85
84
|
isRangeOfSingleType) {
|
|
@@ -97,35 +96,35 @@ function toggleListCommand(options) {
|
|
|
97
96
|
};
|
|
98
97
|
}
|
|
99
98
|
function liftListItem(state, selection, tr, nodeType) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
99
|
+
const listItemNodeType = nodeType || state.schema.nodes.listItem;
|
|
100
|
+
const { $from, $to } = selection;
|
|
101
|
+
let range = $from.blockRange($to, node => node.childCount && node.firstChild.type === listItemNodeType);
|
|
103
102
|
if (!range || range.depth < 2 || $from.node(range.depth - 1).type !== listItemNodeType) {
|
|
104
103
|
return tr;
|
|
105
104
|
}
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
const end = range.end;
|
|
106
|
+
const endOfList = $to.end(range.depth);
|
|
108
107
|
if (end < endOfList) {
|
|
109
|
-
tr.step(new
|
|
110
|
-
range = new
|
|
108
|
+
tr.step(new prosemirrorTransform.ReplaceAroundStep(end - 1, endOfList, end, endOfList, new prosemirrorModel.Slice(prosemirrorModel.Fragment.from(listItemNodeType.create(undefined, range.parent.copy())), 1, 0), 1, true));
|
|
109
|
+
range = new prosemirrorModel.NodeRange(tr.doc.resolve($from.pos), tr.doc.resolve(endOfList), range.depth);
|
|
111
110
|
}
|
|
112
|
-
return tr.lift(range,
|
|
111
|
+
return tr.lift(range, prosemirrorTransform.liftTarget(range)).scrollIntoView();
|
|
113
112
|
}
|
|
114
113
|
function liftFollowingList(state, from, to, rootListDepthNum, tr, listItem) {
|
|
115
114
|
// Function will lift list item following selection to level-1.
|
|
116
115
|
if (!listItem) {
|
|
117
116
|
listItem = state.schema.nodes.listItem;
|
|
118
117
|
}
|
|
119
|
-
|
|
120
|
-
tr.doc.nodesBetween(from, to,
|
|
118
|
+
let lifted = false;
|
|
119
|
+
tr.doc.nodesBetween(from, to, (node, pos) => {
|
|
121
120
|
if (!lifted && node.type === listItem && pos > from) {
|
|
122
121
|
lifted = true;
|
|
123
|
-
|
|
122
|
+
let listDepth = rootListDepthNum + 3;
|
|
124
123
|
while (listDepth > rootListDepthNum + 2) {
|
|
125
|
-
|
|
124
|
+
const start = tr.doc.resolve(tr.mapping.map(pos));
|
|
126
125
|
listDepth = start.depth;
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
const end = tr.doc.resolve(tr.mapping.map(pos + node.textContent.length));
|
|
127
|
+
const sel = new prosemirrorState.TextSelection(start, end);
|
|
129
128
|
tr = liftListItem(state, sel, tr, listItem);
|
|
130
129
|
}
|
|
131
130
|
}
|
|
@@ -135,23 +134,23 @@ function liftFollowingList(state, from, to, rootListDepthNum, tr, listItem) {
|
|
|
135
134
|
function isRangeOfType(doc, $from, $to, nodeType) {
|
|
136
135
|
// Step through block-nodes between $from and $to and returns false if a node is
|
|
137
136
|
// found that isn't of the specified type
|
|
138
|
-
return getAncestorNodesBetween(doc, $from, $to).filter(
|
|
137
|
+
return getAncestorNodesBetween(doc, $from, $to).filter((node) => node.type !== nodeType).length === 0;
|
|
139
138
|
}
|
|
140
139
|
function getAncestorNodesBetween(doc, $from, $to) {
|
|
141
140
|
// Returns all top-level ancestor-nodes between $from and $to
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
141
|
+
const nodes = [];
|
|
142
|
+
const maxDepth = findAncestorPosition(doc, $from).depth;
|
|
143
|
+
let current = doc.resolve($from.start(maxDepth));
|
|
145
144
|
while (current.pos <= $to.start($to.depth)) {
|
|
146
|
-
|
|
147
|
-
|
|
145
|
+
const depth = Math.min(current.depth, maxDepth);
|
|
146
|
+
const node = current.node(depth);
|
|
148
147
|
if (node) {
|
|
149
148
|
nodes.push(node);
|
|
150
149
|
}
|
|
151
150
|
if (depth === 0) {
|
|
152
151
|
break;
|
|
153
152
|
}
|
|
154
|
-
|
|
153
|
+
let next = doc.resolve(current.after(depth));
|
|
155
154
|
if (next.start(depth) >= doc.nodeSize - 2) {
|
|
156
155
|
break;
|
|
157
156
|
}
|
|
@@ -169,12 +168,12 @@ function getAncestorNodesBetween(doc, $from, $to) {
|
|
|
169
168
|
}
|
|
170
169
|
function findAncestorPosition(doc, pos) {
|
|
171
170
|
// Traverse the document until an "ancestor" is found. Any nestable block can be an ancestor.
|
|
172
|
-
|
|
171
|
+
const nestableBlocks = ['blockquote', 'bulletList', 'orderedList'];
|
|
173
172
|
if (pos.depth === 1) {
|
|
174
173
|
return pos;
|
|
175
174
|
}
|
|
176
|
-
|
|
177
|
-
|
|
175
|
+
let node = pos.node(pos.depth);
|
|
176
|
+
let newPos = pos;
|
|
178
177
|
while (pos.depth >= 1) {
|
|
179
178
|
pos = doc.resolve(pos.before(pos.depth));
|
|
180
179
|
node = pos.node(pos.depth);
|
|
@@ -186,18 +185,18 @@ function findAncestorPosition(doc, pos) {
|
|
|
186
185
|
}
|
|
187
186
|
function liftListItems(options) {
|
|
188
187
|
return function (state, dispatch) {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
tr.doc.nodesBetween($from.pos, $to.pos,
|
|
188
|
+
const { tr } = state;
|
|
189
|
+
const { $from, $to } = state.selection;
|
|
190
|
+
tr.doc.nodesBetween($from.pos, $to.pos, (node, pos) => {
|
|
192
191
|
// Following condition will ensure that block types `paragraph`, `heading`, `codeBlock`, `blockquote`, `div` are lifted.
|
|
193
192
|
// isTextblock is true for paragraph, heading, codeBlock.
|
|
194
193
|
if (node.isTextblock || node.type.name === 'blockquote' || node.type.name === 'div') {
|
|
195
|
-
|
|
196
|
-
|
|
194
|
+
const sel = new prosemirrorState.NodeSelection(tr.doc.resolve(tr.mapping.map(pos)));
|
|
195
|
+
const range = sel.$from.blockRange(sel.$to);
|
|
197
196
|
if (!range || sel.$from.parent.type !== state.schema.nodes[options.listItem]) {
|
|
198
197
|
return;
|
|
199
198
|
}
|
|
200
|
-
|
|
199
|
+
const target = range && prosemirrorTransform.liftTarget(range);
|
|
201
200
|
if (target === undefined || target === null) {
|
|
202
201
|
return false;
|
|
203
202
|
}
|
|
@@ -210,64 +209,64 @@ function liftListItems(options) {
|
|
|
210
209
|
return true;
|
|
211
210
|
};
|
|
212
211
|
}
|
|
213
|
-
function wrapInList(nodeType, attrs) {
|
|
214
|
-
|
|
215
|
-
return (0, prosemirror_commands_1.autoJoin)((0, prosemirror_schema_list_1.wrapInList)(nodeType, attrs), function (before, after) { return before.type === after.type && before.type === nodeType; });
|
|
212
|
+
function wrapInList(nodeType, attrs = {}) {
|
|
213
|
+
return prosemirrorCommands.autoJoin(prosemirrorSchemaList.wrapInList(nodeType, attrs), (before, after) => before.type === after.type && before.type === nodeType);
|
|
216
214
|
}
|
|
217
|
-
|
|
215
|
+
const reListStyle = /list\-style\-type:\s?([\w-]+)/;
|
|
218
216
|
/**
|
|
219
217
|
* Extracts list-style-type style from node's attributes.
|
|
220
218
|
*
|
|
221
219
|
* @param attrs - The attributes of the list node
|
|
222
220
|
* @returns The extracted list-style-type.
|
|
223
221
|
*/
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
222
|
+
const listStyle = (attrs) => {
|
|
223
|
+
const styleAttr = attrs.style || '';
|
|
224
|
+
const execArray = reListStyle.exec(styleAttr);
|
|
227
225
|
return (execArray && execArray[1]) || '';
|
|
228
226
|
};
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
(!endNode || endNode.type.name !== listType || (0, exports.listStyle)(endNode.attrs) !== (0, exports.listStyle)(listAttrs))) {
|
|
227
|
+
const toggleList = (state, dispatch, view, options, command) => {
|
|
228
|
+
const { listType, listAttrs = { style: null } } = options;
|
|
229
|
+
const { selection } = state;
|
|
230
|
+
const fromNode = selection.$from.node(selection.$from.depth - 2);
|
|
231
|
+
const endNode = selection.$to.node(selection.$to.depth - 2);
|
|
232
|
+
if (!fromNode || fromNode.type.name !== listType || listStyle(fromNode.attrs) !== listStyle(listAttrs) ||
|
|
233
|
+
(!endNode || endNode.type.name !== listType || listStyle(endNode.attrs) !== listStyle(listAttrs))) {
|
|
237
234
|
return toggleListCommand(options)(state, dispatch, view);
|
|
238
235
|
}
|
|
239
236
|
else {
|
|
240
|
-
|
|
241
|
-
|
|
237
|
+
const nodes = view.state.schema.nodes;
|
|
238
|
+
const listNodes = {
|
|
242
239
|
bulletList: nodes[options.bulletList],
|
|
243
240
|
orderedList: nodes[options.orderedList],
|
|
244
241
|
listItem: nodes[options.listItem]
|
|
245
242
|
};
|
|
246
|
-
|
|
247
|
-
|
|
243
|
+
const depth = rootListDepth(selection.$to, listNodes);
|
|
244
|
+
let tr = liftFollowingList(state, selection.$to.pos, selection.$to.end(depth), depth, view.state.tr, listNodes.listItem);
|
|
248
245
|
tr = liftSelectionList(state, tr, options);
|
|
249
246
|
tr.setMeta('commandName', command);
|
|
250
247
|
dispatch(tr);
|
|
251
248
|
return true;
|
|
252
249
|
}
|
|
253
250
|
};
|
|
254
|
-
exports.toggleList = toggleList;
|
|
255
251
|
function toggleUnorderedList(state, dispatch, view) {
|
|
256
|
-
return
|
|
252
|
+
return toggleList(state, dispatch, view, { listType: listSettings.bulletList.listType, ...listSettings.bulletList.types });
|
|
257
253
|
}
|
|
258
|
-
exports.toggleUnorderedList = toggleUnorderedList;
|
|
259
254
|
function toggleOrderedList(state, dispatch, view) {
|
|
260
|
-
return
|
|
255
|
+
return toggleList(state, dispatch, view, { listType: listSettings.orderedList.listType, ...listSettings.orderedList.types });
|
|
261
256
|
}
|
|
262
|
-
|
|
263
|
-
var splitListItemKeepMarks = function (itemType) { return function (state, dispatch) {
|
|
257
|
+
const splitListItemKeepMarks = (itemType) => (state, dispatch) => {
|
|
264
258
|
// see https://github.com/ProseMirror/prosemirror-commands/blob/master/src/commands.js#L321-L327
|
|
265
|
-
return
|
|
266
|
-
|
|
259
|
+
return prosemirrorSchemaList.splitListItem(itemType)(state, tr => {
|
|
260
|
+
const marks = state.storedMarks || (state.selection.$to.parentOffset && state.selection.$from.marks());
|
|
267
261
|
if (marks) {
|
|
268
262
|
tr.ensureMarks(marks);
|
|
269
263
|
}
|
|
270
264
|
dispatch(tr);
|
|
271
265
|
});
|
|
272
|
-
};
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
exports.listStyle = listStyle;
|
|
273
269
|
exports.splitListItemKeepMarks = splitListItemKeepMarks;
|
|
270
|
+
exports.toggleList = toggleList;
|
|
271
|
+
exports.toggleOrderedList = toggleOrderedList;
|
|
272
|
+
exports.toggleUnorderedList = toggleUnorderedList;
|
package/dist/npm/main.d.ts
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
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 {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export { blockquote, liftBlockquote } from './blockquote';
|
|
13
|
-
export {
|
|
14
|
-
export { Command } from './types/command';
|
|
15
|
-
export {
|
|
16
|
-
export { indentRules, outdentRules } from './config/indent-rules';
|
|
17
|
-
export { PasteCleanupSettings } from './types/paste-cleanup-settings';
|
|
18
|
-
export {
|
|
19
|
-
export { buildKeymap, buildListKeymap } from './config/keymap';
|
|
20
|
-
export { bold, italic,
|
|
21
|
-
export {
|
|
22
|
-
export { convertMsLists } from './listConvert';
|
|
23
|
-
export {
|
|
24
|
-
export { placeholder } from './plugins/placeholder';
|
|
25
|
-
export { spacesFix } from './plugins/spaces-fix';
|
|
26
|
-
export { cspFix } from './plugins/csp-fix';
|
|
27
|
-
export { textHighlight, textHighlightKey
|
|
28
|
-
export {
|
|
29
|
-
export { caretColor, caretColorKey } from './plugins/caret-color';
|
|
30
|
-
export { tableResizing
|
|
31
|
-
export {
|
|
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 { CleanFormattingOptions, 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 { Command } from './types/command.js';
|
|
15
|
+
export { alignCenterRules, alignJustifyRules, alignLeftRules, alignRemoveRules, alignRightRules } from './config/align-rules.js';
|
|
16
|
+
export { indentRules, outdentRules } from './config/indent-rules.js';
|
|
17
|
+
export { PasteCleanupSettings } from './types/paste-cleanup-settings.js';
|
|
18
|
+
export { marks, nodes } from './config/schema.js';
|
|
19
|
+
export { buildKeymap, buildListKeymap } from './config/keymap.js';
|
|
20
|
+
export { bold, italic, link, strikethrough, subscript, superscript, underline } from './config/commands.js';
|
|
21
|
+
export { pasteCleanup, removeAttribute, removeComments, removeTag, replaceImageSourcesFromRtf, sanitize, sanitizeClassAttr, sanitizeStyleAttr } from './paste.js';
|
|
22
|
+
export { convertMsLists } from './listConvert.js';
|
|
23
|
+
export { SearchOptions, find, findAll, findAt, replace, replaceAll } from './find-replace.js';
|
|
24
|
+
export { placeholder } from './plugins/placeholder.js';
|
|
25
|
+
export { spacesFix } from './plugins/spaces-fix.js';
|
|
26
|
+
export { cspFix } from './plugins/csp-fix.js';
|
|
27
|
+
export { InlineDecoration, textHighlight, textHighlightKey } from './plugins/highlight.js';
|
|
28
|
+
export { ImageResizeOptions, imageResizeKey, imageResizing } from './plugins/image-resize.js';
|
|
29
|
+
export { caretColor, caretColorKey } from './plugins/caret-color.js';
|
|
30
|
+
export { tableResizing } from './plugins/table-resize/index.js';
|
|
31
|
+
export { ListMarkersStylesOptions, listMarkersStyles } from './plugins/list-markers-styles.js';
|
|
32
32
|
export * from 'prosemirror-commands';
|
|
33
33
|
export * from 'prosemirror-dropcursor';
|
|
34
34
|
export * from 'prosemirror-gapcursor';
|
|
@@ -38,7 +38,8 @@ export * from 'prosemirror-keymap';
|
|
|
38
38
|
export * from 'prosemirror-model';
|
|
39
39
|
export * from 'prosemirror-schema-list';
|
|
40
40
|
export * from 'prosemirror-state';
|
|
41
|
-
export { TableEditingOptions, TableMap, TableNodes, TableNodesOptions, TableRect, TableRole,
|
|
41
|
+
export { CellAttributes, CellSelection, CellSelectionJSON, GetCellTypeOptions, Rect, TableEditingOptions, TableMap, TableNodes, TableNodesOptions, TableRect, TableRole, addColSpan, addColumn, addRow, cellAround, colCount, columnIsHeader, columnResizing, columnResizingPluginKey, deleteRow, deleteTable, findCell, fixTables, fixTablesKey, getFromDOM, 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, setDOMAttr, splitCell, splitCellWithType, tableEditing, tableEditingKey, tableNodeTypes, tableNodes, toggleHeader, toggleHeaderCell, toggleHeaderColumn, toggleHeaderRow, updateColumnsOnResize } from 'prosemirror-tables';
|
|
42
42
|
export * from 'prosemirror-transform';
|
|
43
43
|
export * from 'prosemirror-view';
|
|
44
|
-
export {
|
|
44
|
+
export { addColumnAfter, addColumnBefore, addRowAfter, addRowBefore, createTable, deleteColumn } from './table.js';
|
|
45
|
+
export { tableColumnResizeKey, tableResizeKey, tableRowResizeKey } from './plugins/table-resize/utils.js';
|