@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
package/dist/es2015/lists.js
DELETED
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
import { Slice, Fragment, NodeRange } from 'prosemirror-model';
|
|
2
|
-
import { TextSelection, NodeSelection } from 'prosemirror-state';
|
|
3
|
-
import { liftTarget, ReplaceAroundStep } from 'prosemirror-transform';
|
|
4
|
-
import { autoJoin } from 'prosemirror-commands';
|
|
5
|
-
import { splitListItem, wrapInList as wrapInList$1 } from 'prosemirror-schema-list';
|
|
6
|
-
import { orderedList, bulletList } from './config/list-settings.js';
|
|
7
|
-
|
|
8
|
-
const rootListDepth = (pos, nodes) => {
|
|
9
|
-
// Get the depth of the nearest ancestor list
|
|
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
|
-
if (node.type === bulletList || node.type === orderedList) {
|
|
15
|
-
depth = i;
|
|
16
|
-
}
|
|
17
|
-
if (node.type !== bulletList && node.type !== orderedList && node.type !== listItem) {
|
|
18
|
-
break;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return depth;
|
|
22
|
-
};
|
|
23
|
-
const getListLiftTarget = (schema, resPos, options) => {
|
|
24
|
-
// This will return (depth - 1) for root list parent of a list.
|
|
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
|
-
if (node.type === bulletList || node.type === orderedList) {
|
|
32
|
-
target = i;
|
|
33
|
-
}
|
|
34
|
-
if (node.type !== bulletList && node.type !== orderedList && node.type !== listItem) {
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return target - 1;
|
|
39
|
-
};
|
|
40
|
-
function liftSelectionList(state, tr, options) {
|
|
41
|
-
// The function will list paragraphs in selection out to level 1 below root list.
|
|
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
|
-
if (node.type === paragraph || node.type === heading) {
|
|
47
|
-
listCol.push({ node, pos });
|
|
48
|
-
}
|
|
49
|
-
});
|
|
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
|
-
if (start.depth > 0) {
|
|
54
|
-
let end;
|
|
55
|
-
if (block.node.textContent && block.node.textContent.length > 0) {
|
|
56
|
-
end = tr.doc.resolve(tr.mapping.map(block.pos + block.node.textContent.length));
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
end = tr.doc.resolve(tr.mapping.map(block.pos + 1));
|
|
60
|
-
}
|
|
61
|
-
const range = start.blockRange(end);
|
|
62
|
-
if (range) {
|
|
63
|
-
tr.lift(range, getListLiftTarget(state.schema, start, options));
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return tr;
|
|
68
|
-
}
|
|
69
|
-
function toggleListCommand(options) {
|
|
70
|
-
return function (state, dispatch, view) {
|
|
71
|
-
if (!view) {
|
|
72
|
-
return false;
|
|
73
|
-
}
|
|
74
|
-
state = view.state;
|
|
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
|
-
if (((parent && parent.type === listNode) ||
|
|
81
|
-
(grandgrandParent && grandgrandParent.type === listNode)) &&
|
|
82
|
-
isRangeOfSingleType) {
|
|
83
|
-
// Untoggles list
|
|
84
|
-
return liftListItems(options)(state, dispatch);
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
// Wraps selection in list and converts list type e.g. bullet_list -> ordered_list if needed
|
|
88
|
-
if (!isRangeOfSingleType) {
|
|
89
|
-
liftListItems(options)(state, dispatch);
|
|
90
|
-
state = view.state;
|
|
91
|
-
}
|
|
92
|
-
return wrapInList(listNode, options.listAttrs)(state, dispatch);
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
function liftListItem(state, selection, tr, nodeType) {
|
|
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
|
-
if (!range || range.depth < 2 || $from.node(range.depth - 1).type !== listItemNodeType) {
|
|
101
|
-
return tr;
|
|
102
|
-
}
|
|
103
|
-
const end = range.end;
|
|
104
|
-
const endOfList = $to.end(range.depth);
|
|
105
|
-
if (end < endOfList) {
|
|
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
|
-
range = new NodeRange(tr.doc.resolve($from.pos), tr.doc.resolve(endOfList), range.depth);
|
|
108
|
-
}
|
|
109
|
-
return tr.lift(range, liftTarget(range)).scrollIntoView();
|
|
110
|
-
}
|
|
111
|
-
function liftFollowingList(state, from, to, rootListDepthNum, tr, listItem) {
|
|
112
|
-
// Function will lift list item following selection to level-1.
|
|
113
|
-
if (!listItem) {
|
|
114
|
-
listItem = state.schema.nodes.listItem;
|
|
115
|
-
}
|
|
116
|
-
let lifted = false;
|
|
117
|
-
tr.doc.nodesBetween(from, to, (node, pos) => {
|
|
118
|
-
if (!lifted && node.type === listItem && pos > from) {
|
|
119
|
-
lifted = true;
|
|
120
|
-
let listDepth = rootListDepthNum + 3;
|
|
121
|
-
while (listDepth > rootListDepthNum + 2) {
|
|
122
|
-
const start = tr.doc.resolve(tr.mapping.map(pos));
|
|
123
|
-
listDepth = start.depth;
|
|
124
|
-
const end = tr.doc.resolve(tr.mapping.map(pos + node.textContent.length));
|
|
125
|
-
const sel = new TextSelection(start, end);
|
|
126
|
-
tr = liftListItem(state, sel, tr, listItem);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
return tr;
|
|
131
|
-
}
|
|
132
|
-
function isRangeOfType(doc, $from, $to, nodeType) {
|
|
133
|
-
// Step through block-nodes between $from and $to and returns false if a node is
|
|
134
|
-
// found that isn't of the specified type
|
|
135
|
-
return getAncestorNodesBetween(doc, $from, $to).filter((node) => node.type !== nodeType).length === 0;
|
|
136
|
-
}
|
|
137
|
-
function getAncestorNodesBetween(doc, $from, $to) {
|
|
138
|
-
// Returns all top-level ancestor-nodes between $from and $to
|
|
139
|
-
const nodes = [];
|
|
140
|
-
const maxDepth = findAncestorPosition(doc, $from).depth;
|
|
141
|
-
let current = doc.resolve($from.start(maxDepth));
|
|
142
|
-
while (current.pos <= $to.start($to.depth)) {
|
|
143
|
-
const depth = Math.min(current.depth, maxDepth);
|
|
144
|
-
const node = current.node(depth);
|
|
145
|
-
if (node) {
|
|
146
|
-
nodes.push(node);
|
|
147
|
-
}
|
|
148
|
-
if (depth === 0) {
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
let next = doc.resolve(current.after(depth));
|
|
152
|
-
if (next.start(depth) >= doc.nodeSize - 2) {
|
|
153
|
-
break;
|
|
154
|
-
}
|
|
155
|
-
if (next.depth !== current.depth) {
|
|
156
|
-
next = doc.resolve(next.pos + 2);
|
|
157
|
-
}
|
|
158
|
-
if (next.depth) {
|
|
159
|
-
current = doc.resolve(next.start(next.depth));
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
current = doc.resolve(next.end(next.depth));
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return nodes;
|
|
166
|
-
}
|
|
167
|
-
function findAncestorPosition(doc, pos) {
|
|
168
|
-
// Traverse the document until an "ancestor" is found. Any nestable block can be an ancestor.
|
|
169
|
-
const nestableBlocks = ['blockquote', 'bulletList', 'orderedList'];
|
|
170
|
-
if (pos.depth === 1) {
|
|
171
|
-
return pos;
|
|
172
|
-
}
|
|
173
|
-
let node = pos.node(pos.depth);
|
|
174
|
-
let newPos = pos;
|
|
175
|
-
while (pos.depth >= 1) {
|
|
176
|
-
pos = doc.resolve(pos.before(pos.depth));
|
|
177
|
-
node = pos.node(pos.depth);
|
|
178
|
-
if (node && nestableBlocks.indexOf(node.type.name) !== -1) {
|
|
179
|
-
newPos = pos;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
return newPos;
|
|
183
|
-
}
|
|
184
|
-
function liftListItems(options) {
|
|
185
|
-
return function (state, dispatch) {
|
|
186
|
-
const { tr } = state;
|
|
187
|
-
const { $from, $to } = state.selection;
|
|
188
|
-
tr.doc.nodesBetween($from.pos, $to.pos, (node, pos) => {
|
|
189
|
-
// Following condition will ensure that block types `paragraph`, `heading`, `codeBlock`, `blockquote`, `div` are lifted.
|
|
190
|
-
// isTextblock is true for paragraph, heading, codeBlock.
|
|
191
|
-
if (node.isTextblock || node.type.name === 'blockquote' || node.type.name === 'div') {
|
|
192
|
-
const sel = new NodeSelection(tr.doc.resolve(tr.mapping.map(pos)));
|
|
193
|
-
const range = sel.$from.blockRange(sel.$to);
|
|
194
|
-
if (!range || sel.$from.parent.type !== state.schema.nodes[options.listItem]) {
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
const target = range && liftTarget(range);
|
|
198
|
-
if (target === undefined || target === null) {
|
|
199
|
-
return false;
|
|
200
|
-
}
|
|
201
|
-
tr.lift(range, target);
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
if (dispatch) {
|
|
205
|
-
dispatch(tr);
|
|
206
|
-
}
|
|
207
|
-
return true;
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
function wrapInList(nodeType, attrs = {}) {
|
|
211
|
-
return autoJoin(wrapInList$1(nodeType, attrs), (before, after) => before.type === after.type && before.type === nodeType);
|
|
212
|
-
}
|
|
213
|
-
const reListStyle = /list\-style\-type:\s?([\w-]+)/;
|
|
214
|
-
/**
|
|
215
|
-
* Extracts list-style-type style from node's attributes.
|
|
216
|
-
*
|
|
217
|
-
* @param attrs - The attributes of the list node
|
|
218
|
-
* @returns The extracted list-style-type.
|
|
219
|
-
*/
|
|
220
|
-
const listStyle = (attrs) => {
|
|
221
|
-
const styleAttr = attrs.style || '';
|
|
222
|
-
const execArray = reListStyle.exec(styleAttr);
|
|
223
|
-
return (execArray && execArray[1]) || '';
|
|
224
|
-
};
|
|
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);
|
|
230
|
-
if (!fromNode || fromNode.type.name !== listType || listStyle(fromNode.attrs) !== listStyle(listAttrs) ||
|
|
231
|
-
(!endNode || endNode.type.name !== listType || listStyle(endNode.attrs) !== listStyle(listAttrs))) {
|
|
232
|
-
return toggleListCommand(options)(state, dispatch, view);
|
|
233
|
-
}
|
|
234
|
-
else {
|
|
235
|
-
const nodes = view.state.schema.nodes;
|
|
236
|
-
const listNodes = {
|
|
237
|
-
bulletList: nodes[options.bulletList],
|
|
238
|
-
orderedList: nodes[options.orderedList],
|
|
239
|
-
listItem: nodes[options.listItem]
|
|
240
|
-
};
|
|
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);
|
|
243
|
-
tr = liftSelectionList(state, tr, options);
|
|
244
|
-
tr.setMeta('commandName', command);
|
|
245
|
-
dispatch(tr);
|
|
246
|
-
return true;
|
|
247
|
-
}
|
|
248
|
-
};
|
|
249
|
-
function toggleUnorderedList(state, dispatch, view) {
|
|
250
|
-
return toggleList(state, dispatch, view, Object.assign({ listType: bulletList.listType }, bulletList.types));
|
|
251
|
-
}
|
|
252
|
-
function toggleOrderedList(state, dispatch, view) {
|
|
253
|
-
return toggleList(state, dispatch, view, Object.assign({ listType: orderedList.listType }, orderedList.types));
|
|
254
|
-
}
|
|
255
|
-
const splitListItemKeepMarks = (itemType) => (state, dispatch) => {
|
|
256
|
-
// see https://github.com/ProseMirror/prosemirror-commands/blob/master/src/commands.js#L321-L327
|
|
257
|
-
return splitListItem(itemType)(state, tr => {
|
|
258
|
-
const marks = state.storedMarks || (state.selection.$to.parentOffset && state.selection.$from.marks());
|
|
259
|
-
if (marks) {
|
|
260
|
-
tr.ensureMarks(marks);
|
|
261
|
-
}
|
|
262
|
-
dispatch(tr);
|
|
263
|
-
});
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
export { listStyle, splitListItemKeepMarks, toggleList, toggleOrderedList, toggleUnorderedList };
|
package/dist/es2015/main.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
export { domToPmDoc, fragmentToHtml, getHtml, hasSameMarkup, htmlToFragment, parseContent, pmDocToFragment, removeComments, setHtml, trimWhitespace } from './source.js';
|
|
2
|
-
export { flattenNestedSpans } from './flatten-spans.js';
|
|
3
|
-
export { applyInlineStyle, getInlineStyles, toggleInlineFormat } from './inline-style.js';
|
|
4
|
-
export { applyLink, removeLink } from './link.js';
|
|
5
|
-
export { insertText } from './text.js';
|
|
6
|
-
export { insertImage } from './image.js';
|
|
7
|
-
export { alignBlocks, isAligned } from './align.js';
|
|
8
|
-
export { cleanFormatting } from './cleanFormatting.js';
|
|
9
|
-
export { activeNode, blockNodes, changeTextBlock, cleanTextBlockFormatting, formatBlockElements, getBlockFormats, hasNode, parentBlockFormat } from './blockNode.js';
|
|
10
|
-
export { cleanMarks, getActiveMarks, getMark, hasMark, removeAllMarks, selectionMarks } from './mark.js';
|
|
11
|
-
export { canBeIndented, canIndentAsListItem, canOutdentAsListItem, indent, indentBlocks, isIndented, outdent } from './indent.js';
|
|
12
|
-
export { listStyle, toggleList, toggleOrderedList, toggleUnorderedList } from './lists.js';
|
|
13
|
-
export { blockquote, liftBlockquote } from './blockquote.js';
|
|
14
|
-
export { canInsert, expandSelection, expandToWordWrap, getNodeFromSelection, getSelectionText, indentHtml, insertNode, parentNode, selectedLineTextOnly } from './utils.js';
|
|
15
|
-
export { alignCenterRules, alignJustifyRules, alignLeftRules, alignRemoveRules, alignRightRules } from './config/align-rules.js';
|
|
16
|
-
export { indentRules, outdentRules } from './config/indent-rules.js';
|
|
17
|
-
export { marks, nodes } from './config/schema.js';
|
|
18
|
-
export { buildKeymap, buildListKeymap } from './config/keymap.js';
|
|
19
|
-
export { bold, italic, link, strikethrough, subscript, superscript, underline } from './config/commands.js';
|
|
20
|
-
export { pasteCleanup, removeAttribute, removeTag, replaceImageSourcesFromRtf, sanitize, sanitizeClassAttr, sanitizeStyleAttr } from './paste.js';
|
|
21
|
-
export { convertMsLists } from './listConvert.js';
|
|
22
|
-
export { find, findAll, findAt, replace, replaceAll } from './find-replace.js';
|
|
23
|
-
export { placeholder } from './plugins/placeholder.js';
|
|
24
|
-
export { spacesFix } from './plugins/spaces-fix.js';
|
|
25
|
-
export { cspFix } from './plugins/csp-fix.js';
|
|
26
|
-
export { textHighlight, textHighlightKey } from './plugins/highlight.js';
|
|
27
|
-
export { imageResizeKey, imageResizing } from './plugins/image-resize.js';
|
|
28
|
-
export { caretColor, caretColorKey } from './plugins/caret-color.js';
|
|
29
|
-
export { tableResizing } from './plugins/table-resize/index.js';
|
|
30
|
-
export { listMarkersStyles } from './plugins/list-markers-styles.js';
|
|
31
|
-
export * from 'prosemirror-commands';
|
|
32
|
-
export * from 'prosemirror-dropcursor';
|
|
33
|
-
export * from 'prosemirror-gapcursor';
|
|
34
|
-
export * from 'prosemirror-history';
|
|
35
|
-
export * from 'prosemirror-inputrules';
|
|
36
|
-
export * from 'prosemirror-keymap';
|
|
37
|
-
export * from 'prosemirror-model';
|
|
38
|
-
export * from 'prosemirror-schema-list';
|
|
39
|
-
export * from 'prosemirror-state';
|
|
40
|
-
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';
|
|
41
|
-
export * from 'prosemirror-transform';
|
|
42
|
-
export * from 'prosemirror-view';
|
|
43
|
-
export { addColumnAfter, addColumnBefore, addRowAfter, addRowBefore, createTable, deleteColumn } from './table.js';
|
|
44
|
-
export { tableColumnResizeKey, tableResizeKey, tableRowResizeKey } from './plugins/table-resize/utils.js';
|
package/dist/es2015/mark.js
DELETED
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
import { RemoveMarkStep } from 'prosemirror-transform';
|
|
2
|
-
import { MarkType } from 'prosemirror-model';
|
|
3
|
-
import { parseStyle } from './utils.js';
|
|
4
|
-
|
|
5
|
-
const markApplies = (doc, ranges, type) => {
|
|
6
|
-
const loop = i => {
|
|
7
|
-
const ref = ranges[i];
|
|
8
|
-
const $from = ref.$from;
|
|
9
|
-
const $to = ref.$to;
|
|
10
|
-
let can = $from.depth === 0 ? doc.type.allowsMarkType(type) : false;
|
|
11
|
-
doc.nodesBetween($from.pos, $to.pos, node => {
|
|
12
|
-
if (can) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
can = node.inlineContent && node.type.allowsMarkType(type);
|
|
16
|
-
});
|
|
17
|
-
if (can) {
|
|
18
|
-
return { v: true };
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
for (let i = 0; i < ranges.length; i++) {
|
|
22
|
-
const returned = loop(i);
|
|
23
|
-
if (returned) {
|
|
24
|
-
return returned.v;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return false;
|
|
28
|
-
};
|
|
29
|
-
const toggleMark = (markType, attrs, tr) => (state, dispatch) => {
|
|
30
|
-
const { empty, $cursor, ranges } = state.selection;
|
|
31
|
-
if ((empty && !$cursor) || !markApplies(state.doc, ranges, markType)) {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
if (dispatch) {
|
|
35
|
-
if ($cursor) {
|
|
36
|
-
if (markType.isInSet(state.storedMarks || $cursor.marks())) {
|
|
37
|
-
dispatch(tr.removeStoredMark(markType));
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
dispatch(tr.addStoredMark(markType.create(attrs)));
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
let has = false;
|
|
45
|
-
for (let i = 0; !has && i < ranges.length; i++) {
|
|
46
|
-
const { $from, $to } = ranges[i];
|
|
47
|
-
has = state.doc.rangeHasMark($from.pos, $to.pos, markType);
|
|
48
|
-
}
|
|
49
|
-
for (let i = 0; i < ranges.length; i++) {
|
|
50
|
-
const { $from, $to } = ranges[i];
|
|
51
|
-
if (has) {
|
|
52
|
-
tr.removeMark($from.pos, $to.pos, markType);
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
tr.addMark($from.pos, $to.pos, markType.create(attrs));
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
dispatch(tr.scrollIntoView());
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return true;
|
|
62
|
-
};
|
|
63
|
-
const removeMark = (tr, from, to, mark) => {
|
|
64
|
-
if (mark === void 0) {
|
|
65
|
-
mark = null;
|
|
66
|
-
}
|
|
67
|
-
let matched = [], step = 0;
|
|
68
|
-
tr.doc.nodesBetween(from, to, (node, pos) => {
|
|
69
|
-
if (!node.isInline) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
step++;
|
|
73
|
-
let toRemove = null;
|
|
74
|
-
if (mark instanceof MarkType) {
|
|
75
|
-
const found = mark.isInSet(node.marks);
|
|
76
|
-
if (found) {
|
|
77
|
-
toRemove = [found];
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
else if (mark) {
|
|
81
|
-
if (mark.isInSet(node.marks)) {
|
|
82
|
-
toRemove = [mark];
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
toRemove = node.marks;
|
|
87
|
-
}
|
|
88
|
-
if (toRemove && toRemove.length) {
|
|
89
|
-
const end = Math.min(pos + node.nodeSize, to);
|
|
90
|
-
for (let i = 0; i < toRemove.length; i++) {
|
|
91
|
-
let style = toRemove[i], found$1 = (void 0);
|
|
92
|
-
for (let j = 0; j < matched.length; j++) {
|
|
93
|
-
const m = matched[j];
|
|
94
|
-
if (m.step === step - 1 && style.eq(m.style)) {
|
|
95
|
-
found$1 = m;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
if (found$1) {
|
|
99
|
-
found$1.to = end;
|
|
100
|
-
found$1.step = step;
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
matched.push({ style: style, from: Math.max(pos, from), to: end, step: step });
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
matched.forEach((m) => { return tr.step(new RemoveMarkStep(m.from, m.to, m.style)); });
|
|
109
|
-
return tr;
|
|
110
|
-
};
|
|
111
|
-
const removeMarks = (marks, state, dispatch, tr) => {
|
|
112
|
-
const { $cursor, ranges } = state.selection;
|
|
113
|
-
tr = tr || state.tr;
|
|
114
|
-
if ($cursor) {
|
|
115
|
-
marks.forEach(m => {
|
|
116
|
-
if (m.isInSet(state.storedMarks || $cursor.marks())) {
|
|
117
|
-
dispatch(tr.removeStoredMark(m));
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
for (let i = 0; i < ranges.length; i++) {
|
|
123
|
-
const { $from, $to } = ranges[i];
|
|
124
|
-
marks.forEach(m => {
|
|
125
|
-
removeMark(tr, $from.pos, $to.pos, m);
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
dispatch(tr.scrollIntoView());
|
|
129
|
-
}
|
|
130
|
-
return true;
|
|
131
|
-
};
|
|
132
|
-
const toArray = (x) => x instanceof Array ? x : [x];
|
|
133
|
-
const removeAllMarks = ({ except = [] } = {}) => (state, dispatch) => {
|
|
134
|
-
const tr = state.tr;
|
|
135
|
-
cleanMarks(tr, { except: toArray(except) });
|
|
136
|
-
if (tr.docChanged) {
|
|
137
|
-
dispatch(tr);
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
/**
|
|
141
|
-
* Removes the marks from the selection base on the passed parameter.
|
|
142
|
-
* Requires to dispatch the transaction.
|
|
143
|
-
*
|
|
144
|
-
* @example
|
|
145
|
-
* See `removeAllMarks` or `cleanFormatting` function.
|
|
146
|
-
*/
|
|
147
|
-
const cleanMarks = (tr, { except }) => {
|
|
148
|
-
const { doc, selection } = tr;
|
|
149
|
-
const schema = doc.type.schema;
|
|
150
|
-
const { empty, ranges } = selection;
|
|
151
|
-
const excludedMarkTypes = (except || []).map(mt => mt.name);
|
|
152
|
-
if (!empty) {
|
|
153
|
-
const marks = Object.keys(schema.marks)
|
|
154
|
-
.map(m => schema.marks[m])
|
|
155
|
-
.filter(mt => excludedMarkTypes.indexOf(mt.name) === -1);
|
|
156
|
-
ranges.forEach(({ $from, $to }) => {
|
|
157
|
-
marks.forEach(mark => tr.removeMark($from.pos, $to.pos, mark));
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
/**
|
|
162
|
-
* Checks if a mark exists in the selection.
|
|
163
|
-
* Used for checking the state of bold, italic, ... and unlink tools.
|
|
164
|
-
*/
|
|
165
|
-
const hasMark = (state, options) => {
|
|
166
|
-
const marks = state.schema.marks;
|
|
167
|
-
const altMarks = (options.altMarks || []).filter(m => marks[m]);
|
|
168
|
-
const altStyle = options.altStyle;
|
|
169
|
-
const { from, $from, to, empty } = state.selection;
|
|
170
|
-
const type = marks[options.mark];
|
|
171
|
-
const doc = state.doc;
|
|
172
|
-
let result = false;
|
|
173
|
-
let currMarks;
|
|
174
|
-
if (empty) {
|
|
175
|
-
currMarks = state.storedMarks || $from.marks();
|
|
176
|
-
result = (type && type.isInSet(currMarks)) || altMarks.some(m => marks[m].isInSet(currMarks));
|
|
177
|
-
}
|
|
178
|
-
else {
|
|
179
|
-
result = (type && doc.rangeHasMark(from, to, type)) || altMarks.some(m => doc.rangeHasMark(from, to, marks[m]));
|
|
180
|
-
}
|
|
181
|
-
if (!result && altStyle && marks.style) {
|
|
182
|
-
return selectionMarks(state, marks.style)
|
|
183
|
-
.some(mark => styleValue(mark, altStyle) !== null);
|
|
184
|
-
}
|
|
185
|
-
return Boolean(result);
|
|
186
|
-
};
|
|
187
|
-
const styleValue = (mark, style) => {
|
|
188
|
-
const styleText = (mark && mark.attrs.style) || '';
|
|
189
|
-
const styles = parseStyle(styleText);
|
|
190
|
-
const styleNames = Object.keys(styles);
|
|
191
|
-
for (let i = 0; i < styleNames.length; i++) {
|
|
192
|
-
const name = styleNames[i];
|
|
193
|
-
if (name.toLowerCase() === style.name && style.value.test(styles[name])) {
|
|
194
|
-
return styles[name];
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
return null;
|
|
198
|
-
};
|
|
199
|
-
/**
|
|
200
|
-
* Returns the marks of a specific type for every inline node in the selection.
|
|
201
|
-
*/
|
|
202
|
-
const selectionMarks = (state, markType) => {
|
|
203
|
-
const { from, $from, to, empty } = state.selection;
|
|
204
|
-
const marks = [];
|
|
205
|
-
if (empty) {
|
|
206
|
-
marks.push(markType.isInSet(state.storedMarks || $from.marks()));
|
|
207
|
-
}
|
|
208
|
-
else {
|
|
209
|
-
state.doc.nodesBetween(from, to, node => {
|
|
210
|
-
if (node.isInline) {
|
|
211
|
-
marks.push(markType.isInSet(node.marks));
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
return marks;
|
|
216
|
-
};
|
|
217
|
-
/**
|
|
218
|
-
* Returns the specified mark which wraps the selection.
|
|
219
|
-
* Used by link tools.
|
|
220
|
-
*/
|
|
221
|
-
const getMark = (state, markType) => {
|
|
222
|
-
const marks = selectionMarks(state, markType);
|
|
223
|
-
const filtered = marks.filter(m => Boolean(m));
|
|
224
|
-
return marks.length === filtered.length ? marks[0] : undefined;
|
|
225
|
-
};
|
|
226
|
-
/**
|
|
227
|
-
* **Deprecated.** Use `selectionMarks` function instead.
|
|
228
|
-
*/
|
|
229
|
-
const getActiveMarks = (state, markType) => {
|
|
230
|
-
const marks = selectionMarks(state, markType);
|
|
231
|
-
const filtered = marks.filter(m => Boolean(m));
|
|
232
|
-
const hasNodesWithoutMarks = marks.length !== filtered.length;
|
|
233
|
-
return {
|
|
234
|
-
hasNodesWithoutMarks,
|
|
235
|
-
marks: filtered
|
|
236
|
-
};
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
export { cleanMarks, getActiveMarks, getMark, hasMark, markApplies, removeAllMarks, removeMark, removeMarks, selectionMarks, styleValue, toggleMark };
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/******************************************************************************
|
|
2
|
-
Copyright (c) Microsoft Corporation.
|
|
3
|
-
|
|
4
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
-
purpose with or without fee is hereby granted.
|
|
6
|
-
|
|
7
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
-
***************************************************************************** */
|
|
15
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
function __rest(s, e) {
|
|
19
|
-
var t = {};
|
|
20
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
21
|
-
t[p] = s[p];
|
|
22
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
23
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
24
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
25
|
-
t[p[i]] = s[p[i]];
|
|
26
|
-
}
|
|
27
|
-
return t;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
31
|
-
var e = new Error(message);
|
|
32
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export { __rest };
|