@progress/kendo-editor-common 1.12.3-develop.1 → 1.12.3-develop.10
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/find-replace.js +15 -18
- package/dist/es/plugins/table-resize/column-resize.js +7 -1
- package/dist/es/plugins/table-resize/table-resize.js +6 -6
- package/dist/es/plugins/table-resize/utils.js +14 -0
- package/dist/npm/find-replace.js +15 -18
- package/dist/npm/plugins/table-resize/column-resize.js +6 -0
- package/dist/npm/plugins/table-resize/table-resize.js +5 -5
- package/dist/npm/plugins/table-resize/utils.d.ts +1 -0
- package/dist/npm/plugins/table-resize/utils.js +15 -0
- package/package.json +6 -6
package/dist/es/find-replace.js
CHANGED
|
@@ -4,16 +4,12 @@ export const findAt = (doc, searchOptions, start, end, exit) => {
|
|
|
4
4
|
let exec, text, from, to, childText, nextSibling;
|
|
5
5
|
const nodes = [];
|
|
6
6
|
const { matchCase, matchWord, useRegExp } = searchOptions;
|
|
7
|
-
|
|
8
|
-
if (useRegExp && (/^\\$/.test(searchText) || /[^\\]\\$/.test(searchText))) {
|
|
9
|
-
// lookbehind doesn't work in Edge -> /((?<!\\)\\)$/.test(searchText)
|
|
10
|
-
searchText = searchText.substring(0, searchText.length - 1);
|
|
11
|
-
}
|
|
7
|
+
const searchText = searchOptions.text;
|
|
12
8
|
if (!searchText) {
|
|
13
9
|
return result;
|
|
14
10
|
}
|
|
15
11
|
const flags = matchCase ? 'g' : 'gi';
|
|
16
|
-
const regExp = useRegExp ? new RegExp(searchText, flags) :
|
|
12
|
+
const regExp = useRegExp ? new RegExp(searchText, flags) : new RegExp(escapeRegExp(searchText), flags);
|
|
17
13
|
doc.nodesBetween(start, end, (node, pos) => {
|
|
18
14
|
if (exit(result)) {
|
|
19
15
|
return false;
|
|
@@ -37,13 +33,18 @@ export const findAt = (doc, searchOptions, start, end, exit) => {
|
|
|
37
33
|
text = nodes.map(t => t.text).join('');
|
|
38
34
|
exec = regExp.exec(text);
|
|
39
35
|
while (exec !== null) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
if (exec[0].length > 0) {
|
|
37
|
+
from = nodes[0].start + exec.index;
|
|
38
|
+
to = from + exec[0].length;
|
|
39
|
+
if (start <= from && end >= to && shouldMatchWord(exec, matchWord)) {
|
|
40
|
+
result.push(TextSelection.create(doc, from, to));
|
|
41
|
+
}
|
|
42
|
+
if (exit(result)) {
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
44
45
|
}
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
else {
|
|
47
|
+
regExp.lastIndex++;
|
|
47
48
|
}
|
|
48
49
|
exec = regExp.exec(text);
|
|
49
50
|
}
|
|
@@ -110,10 +111,6 @@ const shouldMatchWord = (exec, matchWord) => {
|
|
|
110
111
|
return matchWord(exec);
|
|
111
112
|
}
|
|
112
113
|
};
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
|
|
116
|
-
.replace(/-/g, '\\x2d')
|
|
117
|
-
.replace(/\s/g, '\\s');
|
|
118
|
-
return new RegExp(escaped, flags);
|
|
114
|
+
const escapeRegExp = (text) => {
|
|
115
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
119
116
|
};
|
|
@@ -4,7 +4,7 @@ import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
|
4
4
|
import { colgroupAttr } from '../../config/constants';
|
|
5
5
|
import { TableView, TableWrapperView } from './table-view';
|
|
6
6
|
import { parseStyle, setNodeStyle } from './../../utils';
|
|
7
|
-
import { cellIndexes, domCellAround, otherResizeHandle, otherResizing, edgeCell, tableColumnResizeKey as key } from './utils';
|
|
7
|
+
import { cellIndexes, domCellAround, otherResizeHandle, otherResizing, edgeCell, tableColumnResizeKey as key, splitCols } from './utils';
|
|
8
8
|
export function columnResizing() {
|
|
9
9
|
const handleWidth = 5, cellMinWidth = 25;
|
|
10
10
|
const plugin = new Plugin({
|
|
@@ -130,6 +130,12 @@ function handleMouseDown(view, event, cellMinWidth) {
|
|
|
130
130
|
let col, tableAttrs;
|
|
131
131
|
if (tableNode.attrs[colgroupAttr]) {
|
|
132
132
|
const colgroup = tableDom.firstChild;
|
|
133
|
+
if (splitCols(colgroup)) {
|
|
134
|
+
tableAttrs = {
|
|
135
|
+
...tableNode.attrs,
|
|
136
|
+
[colgroupAttr]: colgroup.outerHTML
|
|
137
|
+
};
|
|
138
|
+
}
|
|
133
139
|
col = colgroup.children[colSpan - 1];
|
|
134
140
|
if (!col.style.width) {
|
|
135
141
|
col.style.width = col.offsetWidth + 'px';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NodeSelection, Plugin } from 'prosemirror-state';
|
|
2
2
|
import { colgroupAttr, dataResizeDirTable, resizableAttr } from '../../config/constants';
|
|
3
|
-
import { getTable, tableResizeKey as key } from './utils';
|
|
3
|
+
import { getTable, tableResizeKey as key, splitCols } from './utils';
|
|
4
4
|
import { parseStyle, setNodeStyle, parentNode } from './../../utils';
|
|
5
5
|
import { directions } from './../resize-utils';
|
|
6
6
|
const commonDir = {
|
|
@@ -70,14 +70,14 @@ const handleMouseMove = (view, event) => {
|
|
|
70
70
|
const toPercents = (view, tr, tablePos) => {
|
|
71
71
|
const tableNode = view.state.doc.nodeAt(tablePos);
|
|
72
72
|
const tableDom = getTable(view.nodeDOM(tablePos));
|
|
73
|
-
const { width, height, colsWidth, rowsHeight, offsetWidth, offsetHeight } = tableSize(tableDom);
|
|
74
73
|
const colgroup = tableDom.firstChild;
|
|
74
|
+
let colsChanged = splitCols(colgroup);
|
|
75
|
+
const { width, height, colsWidth, rowsHeight, offsetWidth, offsetHeight } = tableSize(tableDom);
|
|
75
76
|
const cols = Array.from((colgroup && colgroup.children) || []);
|
|
76
|
-
let widthChanged = false;
|
|
77
77
|
cols.forEach((col, i) => {
|
|
78
78
|
if (col.style.width && !/%$/.test(col.style.width)) {
|
|
79
79
|
col.style.width = ((colsWidth[i]) * 100 / width) + '%';
|
|
80
|
-
|
|
80
|
+
colsChanged = true;
|
|
81
81
|
}
|
|
82
82
|
});
|
|
83
83
|
let heightChange = false;
|
|
@@ -92,13 +92,13 @@ const toPercents = (view, tr, tablePos) => {
|
|
|
92
92
|
if (parseStyle(tableAttrs.style).width !== offsetWidth + 'px') {
|
|
93
93
|
tableAttrs = setNodeStyle(tableAttrs, 'width', offsetWidth + 'px');
|
|
94
94
|
}
|
|
95
|
-
if (
|
|
95
|
+
if (colsChanged) {
|
|
96
96
|
tableAttrs[colgroupAttr] = colgroup.outerHTML;
|
|
97
97
|
}
|
|
98
98
|
if (heightChange) {
|
|
99
99
|
tableAttrs = setNodeStyle(tableAttrs, 'height', offsetHeight + 'px');
|
|
100
100
|
}
|
|
101
|
-
if (
|
|
101
|
+
if (colsChanged || heightChange) {
|
|
102
102
|
tr.setNodeMarkup(tablePos, null, tableAttrs);
|
|
103
103
|
}
|
|
104
104
|
};
|
|
@@ -88,3 +88,17 @@ export function edgeCell(view, event, indexes) {
|
|
|
88
88
|
const cell = tablePos + map.map[(map.width * indexes.rowIndex) + indexes.cellIndex];
|
|
89
89
|
return cell;
|
|
90
90
|
}
|
|
91
|
+
export function splitCols(colgroup) {
|
|
92
|
+
const cols = Array.from((colgroup && colgroup.children || []));
|
|
93
|
+
let splitted = false;
|
|
94
|
+
cols.forEach((col) => {
|
|
95
|
+
while (col.span > 1) {
|
|
96
|
+
const newCol = col.cloneNode();
|
|
97
|
+
newCol.span = 1;
|
|
98
|
+
colgroup.insertBefore(newCol, col);
|
|
99
|
+
col.span -= 1;
|
|
100
|
+
splitted = true;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
return splitted;
|
|
104
|
+
}
|
package/dist/npm/find-replace.js
CHANGED
|
@@ -7,16 +7,12 @@ const findAt = (doc, searchOptions, start, end, exit) => {
|
|
|
7
7
|
let exec, text, from, to, childText, nextSibling;
|
|
8
8
|
const nodes = [];
|
|
9
9
|
const { matchCase, matchWord, useRegExp } = searchOptions;
|
|
10
|
-
|
|
11
|
-
if (useRegExp && (/^\\$/.test(searchText) || /[^\\]\\$/.test(searchText))) {
|
|
12
|
-
// lookbehind doesn't work in Edge -> /((?<!\\)\\)$/.test(searchText)
|
|
13
|
-
searchText = searchText.substring(0, searchText.length - 1);
|
|
14
|
-
}
|
|
10
|
+
const searchText = searchOptions.text;
|
|
15
11
|
if (!searchText) {
|
|
16
12
|
return result;
|
|
17
13
|
}
|
|
18
14
|
const flags = matchCase ? 'g' : 'gi';
|
|
19
|
-
const regExp = useRegExp ? new RegExp(searchText, flags) :
|
|
15
|
+
const regExp = useRegExp ? new RegExp(searchText, flags) : new RegExp(escapeRegExp(searchText), flags);
|
|
20
16
|
doc.nodesBetween(start, end, (node, pos) => {
|
|
21
17
|
if (exit(result)) {
|
|
22
18
|
return false;
|
|
@@ -40,13 +36,18 @@ const findAt = (doc, searchOptions, start, end, exit) => {
|
|
|
40
36
|
text = nodes.map(t => t.text).join('');
|
|
41
37
|
exec = regExp.exec(text);
|
|
42
38
|
while (exec !== null) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
if (exec[0].length > 0) {
|
|
40
|
+
from = nodes[0].start + exec.index;
|
|
41
|
+
to = from + exec[0].length;
|
|
42
|
+
if (start <= from && end >= to && shouldMatchWord(exec, matchWord)) {
|
|
43
|
+
result.push(prosemirror_state_1.TextSelection.create(doc, from, to));
|
|
44
|
+
}
|
|
45
|
+
if (exit(result)) {
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
47
48
|
}
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
else {
|
|
50
|
+
regExp.lastIndex++;
|
|
50
51
|
}
|
|
51
52
|
exec = regExp.exec(text);
|
|
52
53
|
}
|
|
@@ -118,10 +119,6 @@ const shouldMatchWord = (exec, matchWord) => {
|
|
|
118
119
|
return matchWord(exec);
|
|
119
120
|
}
|
|
120
121
|
};
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
|
|
124
|
-
.replace(/-/g, '\\x2d')
|
|
125
|
-
.replace(/\s/g, '\\s');
|
|
126
|
-
return new RegExp(escaped, flags);
|
|
122
|
+
const escapeRegExp = (text) => {
|
|
123
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
127
124
|
};
|
|
@@ -133,6 +133,12 @@ function handleMouseDown(view, event, cellMinWidth) {
|
|
|
133
133
|
let col, tableAttrs;
|
|
134
134
|
if (tableNode.attrs[constants_1.colgroupAttr]) {
|
|
135
135
|
const colgroup = tableDom.firstChild;
|
|
136
|
+
if ((0, utils_2.splitCols)(colgroup)) {
|
|
137
|
+
tableAttrs = {
|
|
138
|
+
...tableNode.attrs,
|
|
139
|
+
[constants_1.colgroupAttr]: colgroup.outerHTML
|
|
140
|
+
};
|
|
141
|
+
}
|
|
136
142
|
col = colgroup.children[colSpan - 1];
|
|
137
143
|
if (!col.style.width) {
|
|
138
144
|
col.style.width = col.offsetWidth + 'px';
|
|
@@ -73,14 +73,14 @@ const handleMouseMove = (view, event) => {
|
|
|
73
73
|
const toPercents = (view, tr, tablePos) => {
|
|
74
74
|
const tableNode = view.state.doc.nodeAt(tablePos);
|
|
75
75
|
const tableDom = (0, utils_1.getTable)(view.nodeDOM(tablePos));
|
|
76
|
-
const { width, height, colsWidth, rowsHeight, offsetWidth, offsetHeight } = tableSize(tableDom);
|
|
77
76
|
const colgroup = tableDom.firstChild;
|
|
77
|
+
let colsChanged = (0, utils_1.splitCols)(colgroup);
|
|
78
|
+
const { width, height, colsWidth, rowsHeight, offsetWidth, offsetHeight } = tableSize(tableDom);
|
|
78
79
|
const cols = Array.from((colgroup && colgroup.children) || []);
|
|
79
|
-
let widthChanged = false;
|
|
80
80
|
cols.forEach((col, i) => {
|
|
81
81
|
if (col.style.width && !/%$/.test(col.style.width)) {
|
|
82
82
|
col.style.width = ((colsWidth[i]) * 100 / width) + '%';
|
|
83
|
-
|
|
83
|
+
colsChanged = true;
|
|
84
84
|
}
|
|
85
85
|
});
|
|
86
86
|
let heightChange = false;
|
|
@@ -95,13 +95,13 @@ const toPercents = (view, tr, tablePos) => {
|
|
|
95
95
|
if ((0, utils_2.parseStyle)(tableAttrs.style).width !== offsetWidth + 'px') {
|
|
96
96
|
tableAttrs = (0, utils_2.setNodeStyle)(tableAttrs, 'width', offsetWidth + 'px');
|
|
97
97
|
}
|
|
98
|
-
if (
|
|
98
|
+
if (colsChanged) {
|
|
99
99
|
tableAttrs[constants_1.colgroupAttr] = colgroup.outerHTML;
|
|
100
100
|
}
|
|
101
101
|
if (heightChange) {
|
|
102
102
|
tableAttrs = (0, utils_2.setNodeStyle)(tableAttrs, 'height', offsetHeight + 'px');
|
|
103
103
|
}
|
|
104
|
-
if (
|
|
104
|
+
if (colsChanged || heightChange) {
|
|
105
105
|
tr.setNodeMarkup(tablePos, null, tableAttrs);
|
|
106
106
|
}
|
|
107
107
|
};
|
|
@@ -7,6 +7,7 @@ exports.getTable = getTable;
|
|
|
7
7
|
exports.domCellAround = domCellAround;
|
|
8
8
|
exports.cellIndexes = cellIndexes;
|
|
9
9
|
exports.edgeCell = edgeCell;
|
|
10
|
+
exports.splitCols = splitCols;
|
|
10
11
|
const prosemirror_state_1 = require("prosemirror-state");
|
|
11
12
|
const prosemirror_tables_1 = require("prosemirror-tables");
|
|
12
13
|
const utils_1 = require("../../utils");
|
|
@@ -97,3 +98,17 @@ function edgeCell(view, event, indexes) {
|
|
|
97
98
|
const cell = tablePos + map.map[(map.width * indexes.rowIndex) + indexes.cellIndex];
|
|
98
99
|
return cell;
|
|
99
100
|
}
|
|
101
|
+
function splitCols(colgroup) {
|
|
102
|
+
const cols = Array.from((colgroup && colgroup.children || []));
|
|
103
|
+
let splitted = false;
|
|
104
|
+
cols.forEach((col) => {
|
|
105
|
+
while (col.span > 1) {
|
|
106
|
+
const newCol = col.cloneNode();
|
|
107
|
+
newCol.span = 1;
|
|
108
|
+
colgroup.insertBefore(newCol, col);
|
|
109
|
+
col.span -= 1;
|
|
110
|
+
splitted = true;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
return splitted;
|
|
114
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@progress/kendo-editor-common",
|
|
3
3
|
"description": "Kendo UI TypeScript package exporting functions for Editor component",
|
|
4
|
-
"version": "1.12.3-develop.
|
|
4
|
+
"version": "1.12.3-develop.10",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Kendo UI"
|
|
7
7
|
],
|
|
@@ -15,17 +15,17 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@progress/kendo-common": "^1.0.2",
|
|
17
17
|
"prosemirror-commands": "1.7.1",
|
|
18
|
-
"prosemirror-dropcursor": "1.8.
|
|
18
|
+
"prosemirror-dropcursor": "1.8.2",
|
|
19
19
|
"prosemirror-gapcursor": "1.3.2",
|
|
20
20
|
"prosemirror-history": "1.4.1",
|
|
21
21
|
"prosemirror-inputrules": "1.5.0",
|
|
22
|
-
"prosemirror-keymap": "1.2.
|
|
23
|
-
"prosemirror-model": "1.25.
|
|
22
|
+
"prosemirror-keymap": "1.2.3",
|
|
23
|
+
"prosemirror-model": "1.25.1",
|
|
24
24
|
"prosemirror-schema-list": "1.5.1",
|
|
25
25
|
"prosemirror-state": "1.4.3",
|
|
26
26
|
"prosemirror-tables": "1.7.1",
|
|
27
|
-
"prosemirror-transform": "1.10.
|
|
28
|
-
"prosemirror-view": "1.39.
|
|
27
|
+
"prosemirror-transform": "1.10.4",
|
|
28
|
+
"prosemirror-view": "1.39.3",
|
|
29
29
|
"tslib": "^2.8.1"
|
|
30
30
|
},
|
|
31
31
|
"repository": {
|