@progress/kendo-pdfviewer-common 0.2.6 → 0.2.7-dev.202401031409

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/es/search.js CHANGED
@@ -69,8 +69,12 @@ export class SearchService {
69
69
  matches: []
70
70
  });
71
71
  }
72
+ escapeRegExp(text) {
73
+ return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
74
+ }
72
75
  search({ text, matchCase }) {
73
- let searchRegex = new RegExp(text, matchCase ? 'g' : 'ig');
76
+ let escapedText = this.escapeRegExp(text);
77
+ let searchRegex = new RegExp(escapedText, matchCase ? 'g' : 'ig');
74
78
  let match;
75
79
  if (this.shouldTransformText()) {
76
80
  this.transformTextForSearch();
@@ -78,7 +82,7 @@ export class SearchService {
78
82
  this.state.matches = [];
79
83
  this.state.activeMatchIndex = 0;
80
84
  this.removeIndicators();
81
- if (text === '') {
85
+ if (escapedText === '') {
82
86
  return [];
83
87
  }
84
88
  match = searchRegex.exec(this.state.text);
@@ -69,8 +69,12 @@ export class SearchService {
69
69
  matches: []
70
70
  });
71
71
  }
72
+ escapeRegExp(text) {
73
+ return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
74
+ }
72
75
  search({ text, matchCase }) {
73
- let searchRegex = new RegExp(text, matchCase ? 'g' : 'ig');
76
+ let escapedText = this.escapeRegExp(text);
77
+ let searchRegex = new RegExp(escapedText, matchCase ? 'g' : 'ig');
74
78
  let match;
75
79
  if (this.shouldTransformText()) {
76
80
  this.transformTextForSearch();
@@ -78,7 +82,7 @@ export class SearchService {
78
82
  this.state.matches = [];
79
83
  this.state.activeMatchIndex = 0;
80
84
  this.removeIndicators();
81
- if (text === '') {
85
+ if (escapedText === '') {
82
86
  return [];
83
87
  }
84
88
  match = searchRegex.exec(this.state.text);
@@ -9,6 +9,7 @@ export declare class SearchService {
9
9
  extendOptions(options: any): void;
10
10
  setState(newState: any): void;
11
11
  resetState(): void;
12
+ escapeRegExp(text: string): string;
12
13
  search({ text, matchCase }: any): {
13
14
  startOffset: number;
14
15
  endOffset: number;
@@ -71,8 +71,12 @@ class SearchService {
71
71
  matches: []
72
72
  });
73
73
  }
74
+ escapeRegExp(text) {
75
+ return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
76
+ }
74
77
  search({ text, matchCase }) {
75
- let searchRegex = new RegExp(text, matchCase ? 'g' : 'ig');
78
+ let escapedText = this.escapeRegExp(text);
79
+ let searchRegex = new RegExp(escapedText, matchCase ? 'g' : 'ig');
76
80
  let match;
77
81
  if (this.shouldTransformText()) {
78
82
  this.transformTextForSearch();
@@ -80,7 +84,7 @@ class SearchService {
80
84
  this.state.matches = [];
81
85
  this.state.activeMatchIndex = 0;
82
86
  this.removeIndicators();
83
- if (text === '') {
87
+ if (escapedText === '') {
84
88
  return [];
85
89
  }
86
90
  match = searchRegex.exec(this.state.text);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@progress/kendo-pdfviewer-common",
3
3
  "description": "Kendo UI TypeScript package exporting functions for PDFViewer component",
4
- "version": "0.2.6",
4
+ "version": "0.2.7-dev.202401031409",
5
5
  "keywords": [
6
6
  "Kendo UI"
7
7
  ],