@progress/kendo-editor-common 1.12.3-develop.7 → 1.12.3-develop.8

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.
@@ -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
- let searchText = searchOptions.text;
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) : createRegExp(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;
@@ -110,10 +106,6 @@ const shouldMatchWord = (exec, matchWord) => {
110
106
  return matchWord(exec);
111
107
  }
112
108
  };
113
- const createRegExp = (inputString, flags) => {
114
- const escaped = inputString
115
- .replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
116
- .replace(/-/g, '\\x2d')
117
- .replace(/\s/g, '\\s');
118
- return new RegExp(escaped, flags);
109
+ const escapeRegExp = (text) => {
110
+ return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
119
111
  };
@@ -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
- let searchText = searchOptions.text;
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) : createRegExp(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;
@@ -118,10 +114,6 @@ const shouldMatchWord = (exec, matchWord) => {
118
114
  return matchWord(exec);
119
115
  }
120
116
  };
121
- const createRegExp = (inputString, flags) => {
122
- const escaped = inputString
123
- .replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
124
- .replace(/-/g, '\\x2d')
125
- .replace(/\s/g, '\\s');
126
- return new RegExp(escaped, flags);
117
+ const escapeRegExp = (text) => {
118
+ return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
127
119
  };
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.7",
4
+ "version": "1.12.3-develop.8",
5
5
  "keywords": [
6
6
  "Kendo UI"
7
7
  ],