@ohos-ports/advanced-mark.js 3.0.0-beta.0
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/CHANGELOG.md +107 -0
- package/LICENSE +21 -0
- package/README.md +25 -0
- package/dist/jquery.mark.d.ts +235 -0
- package/dist/jquery.mark.es6.d.ts +235 -0
- package/dist/jquery.mark.es6.js +1281 -0
- package/dist/jquery.mark.es6.min.js +8 -0
- package/dist/jquery.mark.js +1681 -0
- package/dist/jquery.mark.min.js +8 -0
- package/dist/mark.d.ts +210 -0
- package/dist/mark.es6.d.ts +210 -0
- package/dist/mark.es6.js +1284 -0
- package/dist/mark.es6.min.js +8 -0
- package/dist/mark.js +1682 -0
- package/dist/mark.min.js +8 -0
- package/package.json +72 -0
- package/src/jquery.js +24 -0
- package/src/jquery_es6.js +23 -0
- package/src/lib/domiterator.js +419 -0
- package/src/lib/mark.js +1817 -0
- package/src/lib/regexpcreator.js +397 -0
- package/src/types/jquery.mark.d.ts +235 -0
- package/src/types/mark.d.ts +210 -0
- package/src/vanilla.js +25 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
|
|
2
|
+
### 3.0.0
|
|
3
|
+
* Combine pattern become the default in the `mark()` API.
|
|
4
|
+
* The default number of the `combineBy` (old name `combinePatterns`) option is increase from 10 to 100.
|
|
5
|
+
* Added requirement for `g` flag in `markRegExp()` API when not using `acrossElements` option.
|
|
6
|
+
* Dropped support to highlight RegExp groups without `d` flag.
|
|
7
|
+
* Removed RegExpCreator module from the npm package.
|
|
8
|
+
* Added the ability to abort a method execution on the 'each' callback.
|
|
9
|
+
* Removed the 'execution' object from the 'filter ' and 'each' callbacks' info object.
|
|
10
|
+
* Added support for CSS Custom Highlight API.
|
|
11
|
+
* Dropped support of very older browsers.
|
|
12
|
+
|
|
13
|
+
### 2.7.1
|
|
14
|
+
* Fixed the 'filter' callback 'matchesSoFar' counter (3 parameter) that affected the mark() method with the 'combinePatterns' option.
|
|
15
|
+
|
|
16
|
+
### 2.7.0
|
|
17
|
+
* Added source code to the npm package.
|
|
18
|
+
|
|
19
|
+
### 2.6.0
|
|
20
|
+
* Added ability to mark inside iframes in shadow DOM.
|
|
21
|
+
* Changed the way to truck iframes states (dropped using attribute).
|
|
22
|
+
* Added ability to use HTMLCollection (returned by 'getElementsByClassName()' and 'getElementsByTagName()').
|
|
23
|
+
|
|
24
|
+
### 2.5.0
|
|
25
|
+
* Added ability to select iframe elements when using non-jQuery libraries and iframe elements are dynamically created by javascript.
|
|
26
|
+
* Fixed multiple wrapping of highlighted text in mark elements that can occur on some conditions with `iframes` option (page contains several iframes and selecting several contexts). Previous 2.x.x versions correctly handle only one context.
|
|
27
|
+
* Fixed bug that is related to old browsers in DOMIterator class, e.g. IE11. (introduced in v2.4.1)
|
|
28
|
+
|
|
29
|
+
### 2.4.2
|
|
30
|
+
* Fixed bug that occurs in `markRanges()` API then an array of ranges have a single item and a range `start` property is zero.
|
|
31
|
+
|
|
32
|
+
### 2.4.1
|
|
33
|
+
* Fixed infinite loop that can occur with `ignoreGroups` option in markRegExp() API with the conditional main group.
|
|
34
|
+
* Fixed missing window object of the Node interface (causes an exception in virtual DOM environments when context is an array of elements).
|
|
35
|
+
|
|
36
|
+
### 2.4.0
|
|
37
|
+
* Fixed handling escaped wildcards characters (backslashes were stripped from searching string, e.g. 'C:\\\\\\\\*' resulted in 'C:\\\\*' and is treated as escape '*', not a wildcard)
|
|
38
|
+
* Fixed breaking UTF-16 surrogate pairs and continues pairs of backslashes by joiners/punctuation
|
|
39
|
+
* Slightly reduce a code size
|
|
40
|
+
|
|
41
|
+
### 2.3.0
|
|
42
|
+
|
|
43
|
+
* Added `preserveTerms` value for `separateWordSearch` option that allows highlight exact term(s) alone side with separate word(s).
|
|
44
|
+
* Added 'startsWith' value for accuracy option that allows highlight whole word(s) just typing the start of it(s). It also works with `preserveTerms`.
|
|
45
|
+
|
|
46
|
+
### 2.2.0
|
|
47
|
+
|
|
48
|
+
* Added ability to mark line ranges (`markRanges()` API with `markLines` option).
|
|
49
|
+
* Fixed handling `br` element in `getTextNodesAcross()` method.
|
|
50
|
+
* Fixed negative value of the start index in `wrapRangeAcross()` method with `wrapAllRanges` option, which can occur in some cases.
|
|
51
|
+
* An improvement that allows usage of RegExp conditional capturing groups with `ignoreGroups` option in `markRegExp()` API.
|
|
52
|
+
|
|
53
|
+
### 2.1.2
|
|
54
|
+
|
|
55
|
+
* Fixed problem with 'jquery.mark.es6.js' module by adding `node.jquery.mark.es6.js` module, which contains `import $ from 'jquery';` statement necessary on Node.js.
|
|
56
|
+
* Added missing `őŐűŰ` diacritic characters in RegExpCreator class.
|
|
57
|
+
|
|
58
|
+
### 2.1.1
|
|
59
|
+
|
|
60
|
+
* Fixed debug logging to the console.
|
|
61
|
+
* Improved detection of custom window object and as a result getting a clear error message on the non-valid object.
|
|
62
|
+
|
|
63
|
+
### 2.1.0
|
|
64
|
+
|
|
65
|
+
* Fixed bug related using a wildcards character `*` with `wildcards : 'withSpaces'`, `acrossElements` , and `blockElementsBoundary` options.
|
|
66
|
+
* Added supports for virtual DOM environments such as JSDOM. Thanks to [Tyler Nickerson](https://github.com/Nickersoft) for the contribution.
|
|
67
|
+
|
|
68
|
+
### 2.0.0
|
|
69
|
+
|
|
70
|
+
* Rewrote `DOMIterator` iframe related code. Added code sorting a custom array of elements by the DOM order - can affect `markRanges()` method.
|
|
71
|
+
* Rewrote `unwrapMatches()` method for performance reason.
|
|
72
|
+
* Rewrote `getTextNodesAcross()` method (previously named as 'getTextNodesAcrossElements') to change the logic which determines does the two text nodes are separated by block element.
|
|
73
|
+
* Rewrote `markRanges` related code (to simplify the code).
|
|
74
|
+
* Changes in `mark()` and `markRegExp()` methods: the `filter` callback parameters that count mark elements has been changed to count matches. It can affect the old code that uses `acrossElements` option.
|
|
75
|
+
* Simplified `getSeparatedKeywords()` method.
|
|
76
|
+
* Got rid of empty sibling text nodes that are created when `Text.splitText()` method splits a text node at the start or/and at the end.
|
|
77
|
+
* Changes in RegExpCreator class:
|
|
78
|
+
1. removed unnecessary escaping of characters in a RegExp character set
|
|
79
|
+
2. added ability to using string instead of array in 'ignorePunctuation' option and accuracy object
|
|
80
|
+
3. added code which remove duplicate from array of characters or synonyms
|
|
81
|
+
|
|
82
|
+
### 1.1.2
|
|
83
|
+
|
|
84
|
+
* Fixed bug related using a wildcards character `*` with `wildcards : 'withSpaces'`, `acrossElements` , and `blockElementsBoundary` options.
|
|
85
|
+
* Fixed types path in package.json.
|
|
86
|
+
|
|
87
|
+
### 1.1.1
|
|
88
|
+
|
|
89
|
+
* Fixed bug that affect wrapping separate groups across elements with combination of `acrossElements`, `cacheTextNodes`, and `separateGroups` options
|
|
90
|
+
* Implemented missing `offset` property in filter callback info object with combination of `acrossElements` and `separateGroups` options
|
|
91
|
+
* Corrected some mistakes in TypeScript declaration files
|
|
92
|
+
|
|
93
|
+
### 1.1.0
|
|
94
|
+
|
|
95
|
+
* Added ability to extend the default boundary elements with custom elements (`blockElementsBoundary` option)
|
|
96
|
+
|
|
97
|
+
### 1.0.3
|
|
98
|
+
|
|
99
|
+
* Added TypeScript types declaration files.
|
|
100
|
+
* Rewrote `setupIgnoreJoinersRegExp()` method to get rid of a capturing group in `createSynonymsRegExp()` method (it breaks group/term relation when using synonyms with combinePatterns option).
|
|
101
|
+
* Rewrote `createDiacriticsRegExp()` method to reduce the size.
|
|
102
|
+
* Optimized cache object code.
|
|
103
|
+
* Corrected `Elements boundaries` doc.
|
|
104
|
+
|
|
105
|
+
### 1.0.2
|
|
106
|
+
|
|
107
|
+
* Initial release
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 angezid
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# advanced-mark.js
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/advanced-mark.js)
|
|
4
|
+
|
|
5
|
+
### A fast JavaScript library to highlight any text on a browser page
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
- Pure Vanilla Javascript
|
|
9
|
+
- Zero Dependencies
|
|
10
|
+
- Iframes Support
|
|
11
|
+
- Shadow DOM Support
|
|
12
|
+
- Diacritics Support
|
|
13
|
+
- CSS Custom Highlight API
|
|
14
|
+
- Virtual DOMs like JSDOM Support
|
|
15
|
+
- Highly Customizable
|
|
16
|
+
|
|
17
|
+
See [Playground](https://angezid.github.io/advanced-mark.js/playground-v3) which can speak better than any words.
|
|
18
|
+
See [Performance page](https://angezid.github.io/advanced-mark.js/performance-v3) which demonstrate the library performance.
|
|
19
|
+
[Documentation](https://angezid.github.io/advanced-mark.js/doc-v3).
|
|
20
|
+
|
|
21
|
+
Happy highlighting!
|
|
22
|
+
|
|
23
|
+
### License
|
|
24
|
+
|
|
25
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
|
|
2
|
+
// Type definitions for advanced-mark.js v3.0.0
|
|
3
|
+
// Based on "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/mark.js"
|
|
4
|
+
|
|
5
|
+
/// <reference types="jquery"/>
|
|
6
|
+
|
|
7
|
+
declare namespace Mark {
|
|
8
|
+
|
|
9
|
+
interface BoundaryObject {
|
|
10
|
+
tags?: string[];
|
|
11
|
+
extend?: boolean;
|
|
12
|
+
char?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface ShadowObject {
|
|
16
|
+
style: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface IframesObject {
|
|
20
|
+
style: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface AccuracyObject {
|
|
24
|
+
value: 'exactly' | 'startsWith' | 'complementary';
|
|
25
|
+
limiters: string | string[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface MarkOptions {
|
|
29
|
+
element?: string;
|
|
30
|
+
window?: Window;
|
|
31
|
+
className?: string;
|
|
32
|
+
exclude?: string | string[];
|
|
33
|
+
separateWordSearch?: boolean | 'preserveTerms';
|
|
34
|
+
acrossElements?: boolean;
|
|
35
|
+
accuracy?: 'partially' | 'exactly' | 'startsWith' | 'complementary' | AccuracyObject;
|
|
36
|
+
diacritics?: boolean;
|
|
37
|
+
synonyms?: { [index: string] : string | string[] };
|
|
38
|
+
caseSensitive?: boolean;
|
|
39
|
+
ignoreJoiners?: boolean;
|
|
40
|
+
ignorePunctuation?: string | string[];
|
|
41
|
+
wildcards?: 'disabled' | 'enabled' | 'withSpaces';
|
|
42
|
+
iframes?: boolean | IframesObject;
|
|
43
|
+
iframesTimeout?: number;
|
|
44
|
+
|
|
45
|
+
highlight?: Highlight;
|
|
46
|
+
highlightName?: string;
|
|
47
|
+
staticRanges?: boolean;
|
|
48
|
+
rangeAcrossElements?: boolean;
|
|
49
|
+
combineby?: number;
|
|
50
|
+
blockElementsBoundary?: boolean | BoundaryObject;
|
|
51
|
+
shadowDOM?: boolean | ShadowObject;
|
|
52
|
+
|
|
53
|
+
filter?(
|
|
54
|
+
nodeOrArray: Text | Text[], term: string, totalMatchesSoFar: number, termMatchesSoFar: number, filterInfo: MarkFilterInfo
|
|
55
|
+
) : boolean;
|
|
56
|
+
each?(elementOrRange: Element | StaticRange | Range, eachInfo: MarkEachInfo) : void;
|
|
57
|
+
done?(totalMarks: number, totalMatches: number, termStats: TermStats) : void;
|
|
58
|
+
|
|
59
|
+
noMatch?(term: string[]) : void;
|
|
60
|
+
debug?: boolean;
|
|
61
|
+
log?: object;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
interface MarkFilterInfo {
|
|
65
|
+
match: RegExpExecArray;
|
|
66
|
+
matchStart?: boolean;
|
|
67
|
+
count: number;
|
|
68
|
+
abort: boolean;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
interface MarkEachInfo {
|
|
72
|
+
match: RegExpExecArray;
|
|
73
|
+
matchStart?: boolean;
|
|
74
|
+
count: number;
|
|
75
|
+
abort: boolean;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
interface TermStats {
|
|
79
|
+
[index: string] : number;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
interface RegExpOptions {
|
|
83
|
+
element?: string;
|
|
84
|
+
className?: string;
|
|
85
|
+
exclude?: string | string[];
|
|
86
|
+
acrossElements?: boolean;
|
|
87
|
+
ignoreGroups?: number;
|
|
88
|
+
iframes?: boolean | IframesObject;
|
|
89
|
+
iframesTimeout?: number;
|
|
90
|
+
|
|
91
|
+
highlight?: Highlight;
|
|
92
|
+
highlightName?: string;
|
|
93
|
+
staticRanges?: boolean;
|
|
94
|
+
rangeAcrossElements?: boolean;
|
|
95
|
+
separateGroups?: boolean;
|
|
96
|
+
wrapAllRanges?: boolean;
|
|
97
|
+
blockElementsBoundary?: boolean | BoundaryObject;
|
|
98
|
+
shadowDOM?: boolean | ShadowObject;
|
|
99
|
+
|
|
100
|
+
filter?(nodeOrArray: Text | Text[], regexp: string, matchesSoFar: number, filterInfo: RegExpFilterInfo) : boolean;
|
|
101
|
+
each?(elementOrRange: Element | StaticRange | Range, eachInfo: RegExpEachInfo) : void;
|
|
102
|
+
done?(totalMarks: number, totalMatches: number) : void;
|
|
103
|
+
|
|
104
|
+
noMatch?(regexp: string) : void;
|
|
105
|
+
debug?: boolean;
|
|
106
|
+
log?: object;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
interface RegExpFilterInfo {
|
|
110
|
+
match: RegExpExecArray;
|
|
111
|
+
matchStart?: boolean;
|
|
112
|
+
count: number;
|
|
113
|
+
groupIndex?: number;
|
|
114
|
+
abort: boolean;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
interface RegExpEachInfo {
|
|
118
|
+
match: RegExpExecArray;
|
|
119
|
+
matchStart?: boolean;
|
|
120
|
+
count: number;
|
|
121
|
+
groupIndex?: number;
|
|
122
|
+
groupStart?: boolean;
|
|
123
|
+
abort: boolean;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
interface RangesOptions {
|
|
127
|
+
element?: string;
|
|
128
|
+
className?: string;
|
|
129
|
+
exclude?: string | string[];
|
|
130
|
+
iframes?: boolean | IframesObject;
|
|
131
|
+
iframesTimeout?: number;
|
|
132
|
+
|
|
133
|
+
highlight?: Highlight;
|
|
134
|
+
highlightName?: string;
|
|
135
|
+
staticRanges?: boolean;
|
|
136
|
+
rangeAcrossElements?: boolean;
|
|
137
|
+
wrapAllRanges?: boolean;
|
|
138
|
+
markLines?: boolean;
|
|
139
|
+
shadowDOM?: boolean | ShadowObject;
|
|
140
|
+
|
|
141
|
+
filter?(nodeOrArray: Text | Text[], range: MarkRange, matchingString: string, currentIndex: number) : boolean;
|
|
142
|
+
each?(elementOrRange: Element | StaticRange | Range, range: MarkRange, eachInfo: RangeEachInfo) : void;
|
|
143
|
+
done?(totalMarks: number, totalRanges: number) : void;
|
|
144
|
+
|
|
145
|
+
noMatch?(range: MarkRange) : void;
|
|
146
|
+
debug?: boolean;
|
|
147
|
+
log?: object;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
interface MarkRange {
|
|
151
|
+
start: number;
|
|
152
|
+
length: number;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
interface RangeEachInfo {
|
|
156
|
+
matchStart?: boolean;
|
|
157
|
+
count: number;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
interface UnmarkOptions {
|
|
161
|
+
element?: string;
|
|
162
|
+
className?: string;
|
|
163
|
+
exclude?: string | string[];
|
|
164
|
+
iframes?: boolean | IframesObject;
|
|
165
|
+
iframesTimeout?: number;
|
|
166
|
+
shadowDOM?: boolean;
|
|
167
|
+
highlight?: Highlight;
|
|
168
|
+
highlightName?: string | string[];
|
|
169
|
+
|
|
170
|
+
done?() : void;
|
|
171
|
+
debug?: boolean;
|
|
172
|
+
log?: object;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
declare class Mark {
|
|
177
|
+
constructor(context: string | HTMLElement | ReadonlyArray<HTMLElement> | NodeList | null);
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Highlights the specified search terms.
|
|
181
|
+
* @param term The string to be marked. Can also be an array with multiple strings.
|
|
182
|
+
* Note that keywords will be escaped. If you need to mark unescaped keywords (e.g. containing a pattern),
|
|
183
|
+
* have a look at the `markRegExp()`
|
|
184
|
+
* @param options Optional options
|
|
185
|
+
*/
|
|
186
|
+
mark(term: string | ReadonlyArray<string>, options?: Mark.MarkOptions) : void;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Highlights a custom regular expression.
|
|
190
|
+
* @param regexp The regular expression to be marked. Example: /Lor[^]?m/gmi.
|
|
191
|
+
* Note that the `g` flag must be present when `acrossElements : true`, otherwise the RegExp is recompiled.
|
|
192
|
+
* @param options Optional options
|
|
193
|
+
*/
|
|
194
|
+
markRegExp(regexp: RegExp, options?: Mark.RegExpOptions) : void;
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* A method to mark ranges with a start position and length. They will be applied
|
|
198
|
+
* to text nodes in the specified context.
|
|
199
|
+
* @param ranges An array of objects with a start and length property.
|
|
200
|
+
* Note that the start positions must be specified including whitespace characters.
|
|
201
|
+
* @param options Optional options
|
|
202
|
+
*/
|
|
203
|
+
markRanges(ranges: ReadonlyArray<Mark.MarkRange>, options?: Mark.RangesOptions) : void;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* A method to remove mark elements created by mark.js and normalize text nodes.
|
|
207
|
+
* @param options Optional options
|
|
208
|
+
*/
|
|
209
|
+
unmark(options?: Mark.UnmarkOptions) : void;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export = Mark;
|
|
213
|
+
|
|
214
|
+
/* augment JQuery */
|
|
215
|
+
declare global {
|
|
216
|
+
interface JQuery {
|
|
217
|
+
mark(term: string | ReadonlyArray<string>, options?: Mark.MarkOptions) : void;
|
|
218
|
+
|
|
219
|
+
markRegExp(regexp: RegExp, options?: Mark.RegExpOptions) : void;
|
|
220
|
+
|
|
221
|
+
markRanges(ranges: ReadonlyArray<Mark.MarkRange>, options?: Mark.RangesOptions) : void;
|
|
222
|
+
|
|
223
|
+
unmark(options?: Mark.UnmarkOptions) : void;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
interface JQueryStatic {
|
|
227
|
+
mark(term: string | ReadonlyArray<string>, options?: Mark.MarkOptions) : void;
|
|
228
|
+
|
|
229
|
+
markRegExp(regexp: RegExp, options?: Mark.RegExpOptions) : void;
|
|
230
|
+
|
|
231
|
+
markRanges(ranges: ReadonlyArray<Mark.MarkRange>, options?: Mark.RangesOptions) : void;
|
|
232
|
+
|
|
233
|
+
unmark(options?: Mark.UnmarkOptions) : void;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
|
|
2
|
+
// Type definitions for advanced-mark.js v3.0.0
|
|
3
|
+
// Based on "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/mark.js"
|
|
4
|
+
|
|
5
|
+
/// <reference types="jquery"/>
|
|
6
|
+
|
|
7
|
+
declare namespace Mark {
|
|
8
|
+
|
|
9
|
+
interface BoundaryObject {
|
|
10
|
+
tags?: string[];
|
|
11
|
+
extend?: boolean;
|
|
12
|
+
char?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface ShadowObject {
|
|
16
|
+
style: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface IframesObject {
|
|
20
|
+
style: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface AccuracyObject {
|
|
24
|
+
value: 'exactly' | 'startsWith' | 'complementary';
|
|
25
|
+
limiters: string | string[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface MarkOptions {
|
|
29
|
+
element?: string;
|
|
30
|
+
window?: Window;
|
|
31
|
+
className?: string;
|
|
32
|
+
exclude?: string | string[];
|
|
33
|
+
separateWordSearch?: boolean | 'preserveTerms';
|
|
34
|
+
acrossElements?: boolean;
|
|
35
|
+
accuracy?: 'partially' | 'exactly' | 'startsWith' | 'complementary' | AccuracyObject;
|
|
36
|
+
diacritics?: boolean;
|
|
37
|
+
synonyms?: { [index: string] : string | string[] };
|
|
38
|
+
caseSensitive?: boolean;
|
|
39
|
+
ignoreJoiners?: boolean;
|
|
40
|
+
ignorePunctuation?: string | string[];
|
|
41
|
+
wildcards?: 'disabled' | 'enabled' | 'withSpaces';
|
|
42
|
+
iframes?: boolean | IframesObject;
|
|
43
|
+
iframesTimeout?: number;
|
|
44
|
+
|
|
45
|
+
highlight?: Highlight;
|
|
46
|
+
highlightName?: string;
|
|
47
|
+
staticRanges?: boolean;
|
|
48
|
+
rangeAcrossElements?: boolean;
|
|
49
|
+
combineby?: number;
|
|
50
|
+
blockElementsBoundary?: boolean | BoundaryObject;
|
|
51
|
+
shadowDOM?: boolean | ShadowObject;
|
|
52
|
+
|
|
53
|
+
filter?(
|
|
54
|
+
nodeOrArray: Text | Text[], term: string, totalMatchesSoFar: number, termMatchesSoFar: number, filterInfo: MarkFilterInfo
|
|
55
|
+
) : boolean;
|
|
56
|
+
each?(elementOrRange: Element | StaticRange | Range, eachInfo: MarkEachInfo) : void;
|
|
57
|
+
done?(totalMarks: number, totalMatches: number, termStats: TermStats) : void;
|
|
58
|
+
|
|
59
|
+
noMatch?(term: string[]) : void;
|
|
60
|
+
debug?: boolean;
|
|
61
|
+
log?: object;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
interface MarkFilterInfo {
|
|
65
|
+
match: RegExpExecArray;
|
|
66
|
+
matchStart?: boolean;
|
|
67
|
+
count: number;
|
|
68
|
+
abort: boolean;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
interface MarkEachInfo {
|
|
72
|
+
match: RegExpExecArray;
|
|
73
|
+
matchStart?: boolean;
|
|
74
|
+
count: number;
|
|
75
|
+
abort: boolean;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
interface TermStats {
|
|
79
|
+
[index: string] : number;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
interface RegExpOptions {
|
|
83
|
+
element?: string;
|
|
84
|
+
className?: string;
|
|
85
|
+
exclude?: string | string[];
|
|
86
|
+
acrossElements?: boolean;
|
|
87
|
+
ignoreGroups?: number;
|
|
88
|
+
iframes?: boolean | IframesObject;
|
|
89
|
+
iframesTimeout?: number;
|
|
90
|
+
|
|
91
|
+
highlight?: Highlight;
|
|
92
|
+
highlightName?: string;
|
|
93
|
+
staticRanges?: boolean;
|
|
94
|
+
rangeAcrossElements?: boolean;
|
|
95
|
+
separateGroups?: boolean;
|
|
96
|
+
wrapAllRanges?: boolean;
|
|
97
|
+
blockElementsBoundary?: boolean | BoundaryObject;
|
|
98
|
+
shadowDOM?: boolean | ShadowObject;
|
|
99
|
+
|
|
100
|
+
filter?(nodeOrArray: Text | Text[], regexp: string, matchesSoFar: number, filterInfo: RegExpFilterInfo) : boolean;
|
|
101
|
+
each?(elementOrRange: Element | StaticRange | Range, eachInfo: RegExpEachInfo) : void;
|
|
102
|
+
done?(totalMarks: number, totalMatches: number) : void;
|
|
103
|
+
|
|
104
|
+
noMatch?(regexp: string) : void;
|
|
105
|
+
debug?: boolean;
|
|
106
|
+
log?: object;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
interface RegExpFilterInfo {
|
|
110
|
+
match: RegExpExecArray;
|
|
111
|
+
matchStart?: boolean;
|
|
112
|
+
count: number;
|
|
113
|
+
groupIndex?: number;
|
|
114
|
+
abort: boolean;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
interface RegExpEachInfo {
|
|
118
|
+
match: RegExpExecArray;
|
|
119
|
+
matchStart?: boolean;
|
|
120
|
+
count: number;
|
|
121
|
+
groupIndex?: number;
|
|
122
|
+
groupStart?: boolean;
|
|
123
|
+
abort: boolean;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
interface RangesOptions {
|
|
127
|
+
element?: string;
|
|
128
|
+
className?: string;
|
|
129
|
+
exclude?: string | string[];
|
|
130
|
+
iframes?: boolean | IframesObject;
|
|
131
|
+
iframesTimeout?: number;
|
|
132
|
+
|
|
133
|
+
highlight?: Highlight;
|
|
134
|
+
highlightName?: string;
|
|
135
|
+
staticRanges?: boolean;
|
|
136
|
+
rangeAcrossElements?: boolean;
|
|
137
|
+
wrapAllRanges?: boolean;
|
|
138
|
+
markLines?: boolean;
|
|
139
|
+
shadowDOM?: boolean | ShadowObject;
|
|
140
|
+
|
|
141
|
+
filter?(nodeOrArray: Text | Text[], range: MarkRange, matchingString: string, currentIndex: number) : boolean;
|
|
142
|
+
each?(elementOrRange: Element | StaticRange | Range, range: MarkRange, eachInfo: RangeEachInfo) : void;
|
|
143
|
+
done?(totalMarks: number, totalRanges: number) : void;
|
|
144
|
+
|
|
145
|
+
noMatch?(range: MarkRange) : void;
|
|
146
|
+
debug?: boolean;
|
|
147
|
+
log?: object;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
interface MarkRange {
|
|
151
|
+
start: number;
|
|
152
|
+
length: number;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
interface RangeEachInfo {
|
|
156
|
+
matchStart?: boolean;
|
|
157
|
+
count: number;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
interface UnmarkOptions {
|
|
161
|
+
element?: string;
|
|
162
|
+
className?: string;
|
|
163
|
+
exclude?: string | string[];
|
|
164
|
+
iframes?: boolean | IframesObject;
|
|
165
|
+
iframesTimeout?: number;
|
|
166
|
+
shadowDOM?: boolean;
|
|
167
|
+
highlight?: Highlight;
|
|
168
|
+
highlightName?: string | string[];
|
|
169
|
+
|
|
170
|
+
done?() : void;
|
|
171
|
+
debug?: boolean;
|
|
172
|
+
log?: object;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
declare class Mark {
|
|
177
|
+
constructor(context: string | HTMLElement | ReadonlyArray<HTMLElement> | NodeList | null);
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Highlights the specified search terms.
|
|
181
|
+
* @param term The string to be marked. Can also be an array with multiple strings.
|
|
182
|
+
* Note that keywords will be escaped. If you need to mark unescaped keywords (e.g. containing a pattern),
|
|
183
|
+
* have a look at the `markRegExp()`
|
|
184
|
+
* @param options Optional options
|
|
185
|
+
*/
|
|
186
|
+
mark(term: string | ReadonlyArray<string>, options?: Mark.MarkOptions) : void;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Highlights a custom regular expression.
|
|
190
|
+
* @param regexp The regular expression to be marked. Example: /Lor[^]?m/gmi.
|
|
191
|
+
* Note that the `g` flag must be present when `acrossElements : true`, otherwise the RegExp is recompiled.
|
|
192
|
+
* @param options Optional options
|
|
193
|
+
*/
|
|
194
|
+
markRegExp(regexp: RegExp, options?: Mark.RegExpOptions) : void;
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* A method to mark ranges with a start position and length. They will be applied
|
|
198
|
+
* to text nodes in the specified context.
|
|
199
|
+
* @param ranges An array of objects with a start and length property.
|
|
200
|
+
* Note that the start positions must be specified including whitespace characters.
|
|
201
|
+
* @param options Optional options
|
|
202
|
+
*/
|
|
203
|
+
markRanges(ranges: ReadonlyArray<Mark.MarkRange>, options?: Mark.RangesOptions) : void;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* A method to remove mark elements created by mark.js and normalize text nodes.
|
|
207
|
+
* @param options Optional options
|
|
208
|
+
*/
|
|
209
|
+
unmark(options?: Mark.UnmarkOptions) : void;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export = Mark;
|
|
213
|
+
|
|
214
|
+
/* augment JQuery */
|
|
215
|
+
declare global {
|
|
216
|
+
interface JQuery {
|
|
217
|
+
mark(term: string | ReadonlyArray<string>, options?: Mark.MarkOptions) : void;
|
|
218
|
+
|
|
219
|
+
markRegExp(regexp: RegExp, options?: Mark.RegExpOptions) : void;
|
|
220
|
+
|
|
221
|
+
markRanges(ranges: ReadonlyArray<Mark.MarkRange>, options?: Mark.RangesOptions) : void;
|
|
222
|
+
|
|
223
|
+
unmark(options?: Mark.UnmarkOptions) : void;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
interface JQueryStatic {
|
|
227
|
+
mark(term: string | ReadonlyArray<string>, options?: Mark.MarkOptions) : void;
|
|
228
|
+
|
|
229
|
+
markRegExp(regexp: RegExp, options?: Mark.RegExpOptions) : void;
|
|
230
|
+
|
|
231
|
+
markRanges(ranges: ReadonlyArray<Mark.MarkRange>, options?: Mark.RangesOptions) : void;
|
|
232
|
+
|
|
233
|
+
unmark(options?: Mark.UnmarkOptions) : void;
|
|
234
|
+
}
|
|
235
|
+
}
|