@progress/kendo-editor-common 1.12.3-develop.7 → 1.12.3-develop.9
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/npm/find-replace.js +15 -18
- package/package.json +1 -1
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
|
};
|
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
|
};
|