@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/utils.js
CHANGED
|
@@ -1,104 +1,95 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var regExp = newStyle.value;
|
|
12
|
-
var newValue = newStyle.newValue;
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var prosemirrorModel = require('prosemirror-model');
|
|
4
|
+
var prosemirrorState = require('prosemirror-state');
|
|
5
|
+
var kendoCommon = require('@progress/kendo-common');
|
|
6
|
+
|
|
7
|
+
const changeStylesString = (styleText, newStyle) => {
|
|
8
|
+
const styleToChange = newStyle.style;
|
|
9
|
+
const regExp = newStyle.value;
|
|
10
|
+
const newValue = newStyle.newValue;
|
|
13
11
|
if (!styleText) {
|
|
14
12
|
return { changed: false, style: null };
|
|
15
13
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
for (
|
|
20
|
-
|
|
21
|
-
if (
|
|
22
|
-
filtered.push(
|
|
14
|
+
const styles = parseStyle(styleText);
|
|
15
|
+
const styleNames = Object.keys(styles);
|
|
16
|
+
const filtered = [];
|
|
17
|
+
for (let i = 0; i < styleNames.length; i++) {
|
|
18
|
+
const name = styleNames[i];
|
|
19
|
+
if (name.toLowerCase() !== styleToChange || !regExp.test(styles[name])) {
|
|
20
|
+
filtered.push(`${name}: ${styles[name]}`);
|
|
23
21
|
}
|
|
24
22
|
}
|
|
25
23
|
if (newValue) {
|
|
26
|
-
filtered.push(
|
|
24
|
+
filtered.push(`${styleToChange}: ${newValue}`);
|
|
27
25
|
}
|
|
28
26
|
return {
|
|
29
27
|
style: filtered.join('; ') + (filtered.length ? ';' : ''),
|
|
30
28
|
changed: Boolean(newValue) || filtered.length !== styleNames.length
|
|
31
29
|
};
|
|
32
30
|
};
|
|
33
|
-
|
|
34
|
-
var reAnyValue = /^.+$/;
|
|
31
|
+
const reAnyValue = /^.+$/;
|
|
35
32
|
function setNodeStyle(nodeAttrs, styleType, value) {
|
|
36
|
-
|
|
33
|
+
let attrs;
|
|
37
34
|
if (new RegExp('[^-]?' + styleType + ':').test(nodeAttrs.style || '')) {
|
|
38
|
-
|
|
39
|
-
attrs =
|
|
35
|
+
const { style } = changeStylesString(nodeAttrs.style || '', { style: styleType, value: reAnyValue, newValue: value });
|
|
36
|
+
attrs = { ...nodeAttrs, style };
|
|
40
37
|
}
|
|
41
38
|
else if (nodeAttrs.style) {
|
|
42
|
-
attrs =
|
|
39
|
+
attrs = { ...nodeAttrs, style: nodeAttrs.style.replace(/;$/, '') + '; ' + styleType + ': ' + value + ';' };
|
|
43
40
|
}
|
|
44
41
|
else {
|
|
45
|
-
attrs =
|
|
42
|
+
attrs = { ...nodeAttrs, style: styleType + ': ' + value + ';' };
|
|
46
43
|
}
|
|
47
44
|
return attrs;
|
|
48
45
|
}
|
|
49
|
-
exports.setNodeStyle = setNodeStyle;
|
|
50
46
|
/**
|
|
51
47
|
* Determines if a given node type can be inserted at the current cursor position.
|
|
52
48
|
*/
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
for (
|
|
56
|
-
|
|
49
|
+
const canInsert = (state, nodeType) => {
|
|
50
|
+
const $from = state.selection.$from;
|
|
51
|
+
for (let d = $from.depth; d >= 0; d--) {
|
|
52
|
+
const index = $from.index(d);
|
|
57
53
|
if ($from.node(d).canReplaceWith(index, index, nodeType)) {
|
|
58
54
|
return true;
|
|
59
55
|
}
|
|
60
56
|
}
|
|
61
57
|
return false;
|
|
62
58
|
};
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return n instanceof prosemirror_model_1.Node ? n.type.name : n.name;
|
|
59
|
+
const getTypeName = (n) => {
|
|
60
|
+
return n instanceof prosemirrorModel.Node ? n.type.name : n.name;
|
|
66
61
|
};
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
var node = $from.node(i);
|
|
62
|
+
const findNthParentNode = (predicate, depth = 1) => {
|
|
63
|
+
return (selection) => {
|
|
64
|
+
const { $from } = selection;
|
|
65
|
+
for (let i = $from.depth; i > 0; i--) {
|
|
66
|
+
const node = $from.node(i);
|
|
73
67
|
if (predicate(node)) {
|
|
74
68
|
depth = depth - 1;
|
|
75
69
|
if (depth === 0) {
|
|
76
|
-
return { depth: i, node
|
|
70
|
+
return { depth: i, node };
|
|
77
71
|
}
|
|
78
72
|
}
|
|
79
73
|
}
|
|
80
74
|
};
|
|
81
75
|
};
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return findNthParentNode(function (node) { return getTypeName(node) === getTypeName(nodeType); }, depth)(selection);
|
|
76
|
+
const findNthParentNodeOfType = (nodeType, depth = 1) => {
|
|
77
|
+
return (selection) => {
|
|
78
|
+
return findNthParentNode((node) => getTypeName(node) === getTypeName(nodeType), depth)(selection);
|
|
86
79
|
};
|
|
87
80
|
};
|
|
88
|
-
exports.findNthParentNodeOfType = findNthParentNodeOfType;
|
|
89
81
|
function parentNode(pos, predicate) {
|
|
90
|
-
for (
|
|
91
|
-
|
|
82
|
+
for (let depth = pos.depth; depth > 0; depth--) {
|
|
83
|
+
const node = pos.node(depth);
|
|
92
84
|
if (predicate(node)) {
|
|
93
|
-
return { node
|
|
85
|
+
return { node, depth };
|
|
94
86
|
}
|
|
95
87
|
}
|
|
96
88
|
return null;
|
|
97
89
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
for (var attr in attrs) {
|
|
90
|
+
const filterEmptyAttrs = (attrs) => {
|
|
91
|
+
const result = {};
|
|
92
|
+
for (const attr in attrs) {
|
|
102
93
|
if (attr && (attrs[attr] || attrs[attr] === 0)) {
|
|
103
94
|
result[attr] = attrs[attr];
|
|
104
95
|
}
|
|
@@ -108,13 +99,13 @@ var filterEmptyAttrs = function (attrs) {
|
|
|
108
99
|
/**
|
|
109
100
|
* Inserts the given node at the place of current selection.
|
|
110
101
|
*/
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if (selection instanceof
|
|
102
|
+
const insertNode = (node, scrollIntoView) => (state, dispatch) => {
|
|
103
|
+
const { selection, tr } = state;
|
|
104
|
+
if (selection instanceof prosemirrorState.NodeSelection
|
|
114
105
|
&& selection.node.type.name === node.type.name
|
|
115
106
|
&& node.isLeaf && !node.isText && node.nodeSize === 1) {
|
|
116
|
-
tr.setNodeMarkup(selection.from, null,
|
|
117
|
-
tr.setSelection(
|
|
107
|
+
tr.setNodeMarkup(selection.from, null, { ...filterEmptyAttrs(selection.node.attrs), ...filterEmptyAttrs(node.attrs) });
|
|
108
|
+
tr.setSelection(prosemirrorState.NodeSelection.create(tr.doc, selection.from));
|
|
118
109
|
}
|
|
119
110
|
else {
|
|
120
111
|
tr.replaceSelectionWith(node);
|
|
@@ -123,29 +114,20 @@ var insertNode = function (node, scrollIntoView) { return function (state, dispa
|
|
|
123
114
|
tr.scrollIntoView();
|
|
124
115
|
}
|
|
125
116
|
dispatch(tr);
|
|
126
|
-
}; };
|
|
127
|
-
exports.insertNode = insertNode;
|
|
128
|
-
var hasSameMarkup = function (dom1, dom2, schema, parseOptions) {
|
|
129
|
-
var fragment1 = prosemirror_model_1.Fragment.from((0, source_1.parseContent)(dom1, schema, parseOptions));
|
|
130
|
-
var fragment2 = prosemirror_model_1.Fragment.from((0, source_1.parseContent)(dom2, schema, parseOptions));
|
|
131
|
-
return fragment1.eq(fragment2);
|
|
132
117
|
};
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
var fragment = sel.content().content;
|
|
118
|
+
const getSelectionText = (state) => {
|
|
119
|
+
const sel = state.selection;
|
|
120
|
+
if (sel instanceof prosemirrorState.TextSelection || sel instanceof prosemirrorState.AllSelection) {
|
|
121
|
+
const fragment = sel.content().content;
|
|
138
122
|
return fragment.textBetween(0, fragment.size);
|
|
139
123
|
}
|
|
140
124
|
return '';
|
|
141
125
|
};
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
if (state.selection instanceof prosemirror_state_1.NodeSelection) {
|
|
126
|
+
const getNodeFromSelection = (state) => {
|
|
127
|
+
if (state.selection instanceof prosemirrorState.NodeSelection) {
|
|
145
128
|
return state.selection.node;
|
|
146
129
|
}
|
|
147
130
|
};
|
|
148
|
-
exports.getNodeFromSelection = getNodeFromSelection;
|
|
149
131
|
/**
|
|
150
132
|
* Returns the text from the selection if only text is selected on a single line.
|
|
151
133
|
* If selection contains leaf nodes (br, image) between text elements or
|
|
@@ -154,78 +136,72 @@ exports.getNodeFromSelection = getNodeFromSelection;
|
|
|
154
136
|
* Useful for values of the inputs of Link and Find&Replace dialogs where the inputs value has been retrieved from the selection and
|
|
155
137
|
* should be single line text only.
|
|
156
138
|
*/
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
139
|
+
const selectedLineTextOnly = (state) => {
|
|
140
|
+
let result = '', hasLeafs = false;
|
|
141
|
+
const { selection, doc } = state;
|
|
142
|
+
const { $from, $to, from, to } = selection;
|
|
161
143
|
if ($from.sameParent($to)) {
|
|
162
|
-
doc.nodesBetween(from, to,
|
|
144
|
+
doc.nodesBetween(from, to, (node) => {
|
|
163
145
|
hasLeafs = hasLeafs || (node.isLeaf && !node.isText);
|
|
164
146
|
});
|
|
165
147
|
if (!hasLeafs) {
|
|
166
|
-
result =
|
|
148
|
+
result = getSelectionText(state);
|
|
167
149
|
}
|
|
168
150
|
}
|
|
169
151
|
return result;
|
|
170
152
|
};
|
|
171
|
-
exports.selectedLineTextOnly = selectedLineTextOnly;
|
|
172
153
|
/**
|
|
173
154
|
* Used by ViewHtml/ViewSource dialogs for making the HTML more readable.
|
|
174
155
|
*/
|
|
175
|
-
|
|
156
|
+
const indentHtml = (content) => {
|
|
176
157
|
return content.replace(/<\/(p|li|ul|ol|h[1-6]|table|tr|td|th)>/ig, '</$1>\n')
|
|
177
158
|
.replace(/<(ul|ol)([^>]*)><li/ig, '<$1$2>\n<li')
|
|
178
159
|
.replace(/<br \/>/ig, '<br />\n')
|
|
179
160
|
.replace(/\n$/, '');
|
|
180
161
|
};
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
var keys2 = Object.keys(object2);
|
|
162
|
+
const shallowEqual = (object1, object2) => {
|
|
163
|
+
const keys1 = Object.keys(object1);
|
|
164
|
+
const keys2 = Object.keys(object2);
|
|
185
165
|
return keys1.length === keys2.length &&
|
|
186
|
-
keys1.every(
|
|
166
|
+
keys1.every(k => object1[k] === object2[k]);
|
|
187
167
|
};
|
|
188
|
-
|
|
189
|
-
var applyToWordDefault = { before: /[^ !,?.\[\]{}()]+$/i, after: /^[^ !,?.\[\]{}()]+/i };
|
|
168
|
+
const applyToWordDefault = { before: /[^ !,?.\[\]{}()]+$/i, after: /^[^ !,?.\[\]{}()]+/i };
|
|
190
169
|
/**
|
|
191
170
|
* if options.applyToWord is set, expands the selection to the word where the cursor is and
|
|
192
171
|
* returns modified state and dispatch.
|
|
193
172
|
*/
|
|
194
|
-
|
|
173
|
+
const expandSelection = (state, dispatch, options) => {
|
|
195
174
|
if (!options.applyToWord || !state.selection.empty) {
|
|
196
|
-
return { state
|
|
175
|
+
return { state, dispatch };
|
|
197
176
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
177
|
+
const applyToWordOptions = options.applyToWord === true ? applyToWordDefault : options.applyToWord;
|
|
178
|
+
let initialPosition = null;
|
|
179
|
+
const tr = state.tr;
|
|
180
|
+
const selection = state.selection;
|
|
181
|
+
const before = selection.$head.nodeBefore;
|
|
182
|
+
const after = selection.$head.nodeAfter;
|
|
204
183
|
if (before && before.type.name === 'text' && before.text && after && after.type.name === 'text' && after.text) {
|
|
205
|
-
|
|
206
|
-
selection.$head.parent.descendants(
|
|
207
|
-
|
|
184
|
+
const children = [];
|
|
185
|
+
selection.$head.parent.descendants((node, pos) => {
|
|
186
|
+
children.push({ node, pos });
|
|
208
187
|
return false;
|
|
209
188
|
});
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
var skip = false;
|
|
217
|
-
for (var i = nodeIndex - 1; i >= 0; i--) {
|
|
218
|
-
var element = children_1[i];
|
|
189
|
+
let cursor = selection.$head.parentOffset;
|
|
190
|
+
const nodeIndex = children.findIndex(({ node, pos }) => pos <= cursor && pos + node.nodeSize >= cursor);
|
|
191
|
+
let text = children[nodeIndex].node.text;
|
|
192
|
+
let skip = false;
|
|
193
|
+
for (let i = nodeIndex - 1; i >= 0; i--) {
|
|
194
|
+
const element = children[i];
|
|
219
195
|
if (!skip && element && element.node.type.name === 'text') {
|
|
220
196
|
text = element.node.text + text;
|
|
221
197
|
}
|
|
222
198
|
else {
|
|
223
199
|
skip = true;
|
|
224
|
-
|
|
200
|
+
cursor -= element.node.nodeSize;
|
|
225
201
|
}
|
|
226
202
|
}
|
|
227
|
-
for (
|
|
228
|
-
|
|
203
|
+
for (let i = nodeIndex + 1; i < children.length; i++) {
|
|
204
|
+
const element = children[i];
|
|
229
205
|
if (element && element.node.type.name === 'text') {
|
|
230
206
|
text = text + element.node.text;
|
|
231
207
|
}
|
|
@@ -233,32 +209,31 @@ var expandSelection = function (state, dispatch, options) {
|
|
|
233
209
|
break;
|
|
234
210
|
}
|
|
235
211
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
212
|
+
const textBefore = text.substring(0, cursor);
|
|
213
|
+
const textAfter = text.substring(cursor);
|
|
214
|
+
const matchBefore = applyToWordOptions.before.exec(textBefore);
|
|
215
|
+
const matchAfter = applyToWordOptions.after.exec(textAfter);
|
|
240
216
|
if (matchBefore && matchAfter) {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
tr.setSelection(
|
|
245
|
-
|
|
246
|
-
tr
|
|
217
|
+
const extendLeft = matchBefore[0].length;
|
|
218
|
+
const extendRight = matchAfter[0].length;
|
|
219
|
+
const pos = initialPosition = selection.from;
|
|
220
|
+
tr.setSelection(prosemirrorState.TextSelection.create(state.doc, pos - extendLeft, pos + extendRight));
|
|
221
|
+
const cmdState = {
|
|
222
|
+
tr,
|
|
247
223
|
selection: tr.selection,
|
|
248
224
|
doc: tr.doc,
|
|
249
225
|
storedMarks: null,
|
|
250
226
|
schema: tr.doc.type.schema
|
|
251
227
|
};
|
|
252
|
-
|
|
253
|
-
tran.setSelection(
|
|
228
|
+
const cmdDispatch = tran => {
|
|
229
|
+
tran.setSelection(prosemirrorState.TextSelection.create(tran.doc, initialPosition));
|
|
254
230
|
dispatch(tran);
|
|
255
231
|
};
|
|
256
232
|
return { state: cmdState, dispatch: cmdDispatch };
|
|
257
233
|
}
|
|
258
234
|
}
|
|
259
|
-
return { state
|
|
235
|
+
return { state, dispatch };
|
|
260
236
|
};
|
|
261
|
-
exports.expandSelection = expandSelection;
|
|
262
237
|
/**
|
|
263
238
|
* if options.applyToWord is set, expands the selection to the word where the cursor is and
|
|
264
239
|
* use the modified state for the passed command.
|
|
@@ -271,42 +246,38 @@ exports.expandSelection = expandSelection;
|
|
|
271
246
|
* const command = expandToWordWrap(toggleInlineFormat, {...bold, applyToWord );
|
|
272
247
|
* command(view.state, view.dispatch);
|
|
273
248
|
*/
|
|
274
|
-
|
|
275
|
-
return
|
|
276
|
-
|
|
249
|
+
const expandToWordWrap = (command, options) => {
|
|
250
|
+
return (state, dispatch) => {
|
|
251
|
+
const { state: cmdState, dispatch: cmdDispatch } = expandSelection(state, dispatch, options);
|
|
277
252
|
return command(options)(cmdState, cmdDispatch);
|
|
278
253
|
};
|
|
279
254
|
};
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
return (0, kendo_common_1.parseInlineStyles)(styleText);
|
|
255
|
+
const parseStyle = (styleText) => {
|
|
256
|
+
return kendoCommon.parseInlineStyles(styleText);
|
|
283
257
|
};
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
var styles = (0, exports.parseStyle)(styleText);
|
|
258
|
+
const applyStyle = (styleText, styleType, styleValue) => {
|
|
259
|
+
const styles = parseStyle(styleText);
|
|
287
260
|
styles[styleType] = styleValue;
|
|
288
|
-
|
|
289
|
-
.map(
|
|
261
|
+
const result = Object.keys(styles)
|
|
262
|
+
.map(name => styles[name] ? `${name}: ${styles[name]}` : null)
|
|
290
263
|
.filter(Boolean)
|
|
291
264
|
.join('; ');
|
|
292
265
|
return result ? result + ';' : null;
|
|
293
266
|
};
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
for (var style in styles) {
|
|
267
|
+
const setStyleAttr = (element, styleString) => {
|
|
268
|
+
const styles = parseStyle(styleString);
|
|
269
|
+
for (const style in styles) {
|
|
298
270
|
if (style && typeof element.style[style] !== 'undefined') {
|
|
299
271
|
element.style[style] = styles[style];
|
|
300
272
|
}
|
|
301
273
|
}
|
|
302
274
|
};
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
var current = node.getAttribute(attrName);
|
|
275
|
+
const setAttribute = (node, attrName, value) => {
|
|
276
|
+
const current = node.getAttribute(attrName);
|
|
306
277
|
if (value !== undefined && value !== current) {
|
|
307
278
|
if (attrName === 'style') {
|
|
308
279
|
node.removeAttribute(attrName);
|
|
309
|
-
|
|
280
|
+
setStyleAttr(node, value);
|
|
310
281
|
}
|
|
311
282
|
else {
|
|
312
283
|
node.setAttribute(attrName, value);
|
|
@@ -316,4 +287,21 @@ var setAttribute = function (node, attrName, value) {
|
|
|
316
287
|
node.removeAttribute(attrName);
|
|
317
288
|
}
|
|
318
289
|
};
|
|
290
|
+
|
|
291
|
+
exports.applyStyle = applyStyle;
|
|
292
|
+
exports.canInsert = canInsert;
|
|
293
|
+
exports.changeStylesString = changeStylesString;
|
|
294
|
+
exports.expandSelection = expandSelection;
|
|
295
|
+
exports.expandToWordWrap = expandToWordWrap;
|
|
296
|
+
exports.findNthParentNodeOfType = findNthParentNodeOfType;
|
|
297
|
+
exports.getNodeFromSelection = getNodeFromSelection;
|
|
298
|
+
exports.getSelectionText = getSelectionText;
|
|
299
|
+
exports.indentHtml = indentHtml;
|
|
300
|
+
exports.insertNode = insertNode;
|
|
301
|
+
exports.parentNode = parentNode;
|
|
302
|
+
exports.parseStyle = parseStyle;
|
|
303
|
+
exports.selectedLineTextOnly = selectedLineTextOnly;
|
|
319
304
|
exports.setAttribute = setAttribute;
|
|
305
|
+
exports.setNodeStyle = setNodeStyle;
|
|
306
|
+
exports.setStyleAttr = setStyleAttr;
|
|
307
|
+
exports.shallowEqual = shallowEqual;
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@progress/kendo-editor-common",
|
|
3
3
|
"description": "Kendo UI TypeScript package exporting functions for Editor component",
|
|
4
|
-
"version": "1.11.9-
|
|
4
|
+
"version": "1.11.9-develop.1",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Kendo UI"
|
|
7
7
|
],
|
|
8
|
+
"type": "module",
|
|
8
9
|
"author": "Progress",
|
|
9
10
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
10
11
|
"main": "dist/npm/main.js",
|
|
@@ -15,11 +16,12 @@
|
|
|
15
16
|
"jsdelivr": "dist/cdn/main.js",
|
|
16
17
|
"unpkg": "dist/cdn/main.js",
|
|
17
18
|
"scripts": {
|
|
19
|
+
"start": "vite",
|
|
18
20
|
"test:ci": "jest",
|
|
19
21
|
"test": "jest",
|
|
20
22
|
"lint": "eslint .",
|
|
21
|
-
"build
|
|
22
|
-
"
|
|
23
|
+
"build": "rollup -c",
|
|
24
|
+
"prepare": "husky"
|
|
23
25
|
},
|
|
24
26
|
"dependencies": {
|
|
25
27
|
"@progress/kendo-common": "^1.0.2",
|
|
@@ -29,58 +31,36 @@
|
|
|
29
31
|
"prosemirror-history": "1.4.1",
|
|
30
32
|
"prosemirror-inputrules": "1.4.0",
|
|
31
33
|
"prosemirror-keymap": "1.2.2",
|
|
32
|
-
"prosemirror-model": "1.
|
|
34
|
+
"prosemirror-model": "1.24.0",
|
|
33
35
|
"prosemirror-schema-list": "1.4.1",
|
|
34
36
|
"prosemirror-state": "1.4.3",
|
|
35
37
|
"prosemirror-tables": "1.6.1",
|
|
36
38
|
"prosemirror-transform": "1.10.2",
|
|
37
39
|
"prosemirror-view": "1.37.0",
|
|
38
|
-
"tslib": "^2.
|
|
40
|
+
"tslib": "^2.8.1"
|
|
39
41
|
},
|
|
40
42
|
"devDependencies": {
|
|
41
|
-
"@
|
|
42
|
-
"@
|
|
43
|
-
"@
|
|
44
|
-
"@
|
|
43
|
+
"@rollup/plugin-commonjs": "^28.0.1",
|
|
44
|
+
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
45
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
46
|
+
"@rollup/plugin-typescript": "^12.1.1",
|
|
47
|
+
"@types/jest": "^29.5.14",
|
|
45
48
|
"@typescript-eslint/eslint-plugin": "^7.0.1",
|
|
46
|
-
"cross-env": "^7.0.3",
|
|
47
|
-
"cz-conventional-changelog": "^1.1.5",
|
|
48
49
|
"eslint": "^8.56.0",
|
|
49
50
|
"eslint-plugin-jest": "^27.8.0",
|
|
50
51
|
"eslint-plugin-jsdoc": "^48.1.0",
|
|
51
52
|
"eslint-plugin-typescript": "^0.14.0",
|
|
52
|
-
"
|
|
53
|
-
"gulp": "^4.0.0",
|
|
53
|
+
"husky": "^9.1.7",
|
|
54
54
|
"jest": "^29.7.0",
|
|
55
55
|
"jest-environment-jsdom": "^29.7.0",
|
|
56
|
-
"jest-preset-typescript": "^1.0
|
|
57
|
-
"
|
|
58
|
-
"
|
|
56
|
+
"jest-preset-typescript": "^1.2.0",
|
|
57
|
+
"rollup": "^4.28.0",
|
|
58
|
+
"rollup-plugin-dts": "^6.1.1",
|
|
59
|
+
"semantic-release": "^24.2.0",
|
|
60
|
+
"ts-jest": "^29.2.5",
|
|
61
|
+
"typescript": "^5.7.2",
|
|
59
62
|
"typescript-eslint": "^7.0.1",
|
|
60
|
-
"
|
|
61
|
-
},
|
|
62
|
-
"config": {
|
|
63
|
-
"commitizen": {
|
|
64
|
-
"path": "./node_modules/cz-conventional-changelog"
|
|
65
|
-
},
|
|
66
|
-
"ghooks": {
|
|
67
|
-
"commit-msg": "validate-commit-msg"
|
|
68
|
-
},
|
|
69
|
-
"validate-commit-msg": {
|
|
70
|
-
"types": [
|
|
71
|
-
"feat",
|
|
72
|
-
"fix",
|
|
73
|
-
"docs",
|
|
74
|
-
"style",
|
|
75
|
-
"refactor",
|
|
76
|
-
"perf",
|
|
77
|
-
"test",
|
|
78
|
-
"chore",
|
|
79
|
-
"revert"
|
|
80
|
-
],
|
|
81
|
-
"warnOnFail": false,
|
|
82
|
-
"maxSubjectLength": 100
|
|
83
|
-
}
|
|
63
|
+
"vite": "^6.0.2"
|
|
84
64
|
},
|
|
85
65
|
"jest": {
|
|
86
66
|
"preset": "jest-preset-typescript",
|
|
@@ -94,20 +74,22 @@
|
|
|
94
74
|
"url": "https://github.com/telerik/kendo-angular"
|
|
95
75
|
},
|
|
96
76
|
"release": {
|
|
97
|
-
"
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
77
|
+
"branches": [
|
|
78
|
+
{
|
|
79
|
+
"name": "master",
|
|
80
|
+
"channel": "latest"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"name": "develop",
|
|
84
|
+
"prerelease": true,
|
|
85
|
+
"channel": "dev"
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
},
|
|
89
|
+
"publishConfig": {
|
|
90
|
+
"access": "public"
|
|
109
91
|
},
|
|
110
92
|
"files": [
|
|
111
93
|
"dist"
|
|
112
94
|
]
|
|
113
|
-
}
|
|
95
|
+
}
|