@progress/kendo-react-pdf-viewer 5.16.1 → 5.16.2-dev.202308021222
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-react-pdf-viewer.js +1 -1
- package/dist/es/PDFViewer.d.ts +1 -1
- package/dist/es/PDFViewer.js +2 -4
- package/dist/es/main.d.ts +1 -1
- package/dist/es/main.js +1 -1
- package/dist/es/package-metadata.js +1 -1
- package/dist/npm/PDFViewer.d.ts +1 -1
- package/dist/npm/PDFViewer.js +21 -23
- package/dist/npm/main.d.ts +1 -1
- package/dist/npm/main.js +3 -3
- package/dist/npm/package-metadata.js +1 -1
- package/dist/systemjs/kendo-react-pdf-viewer.js +10 -1
- package/dist/systemjs/kendo-react-pdf-viewer.txt +0 -0
- package/package.json +14 -14
- package/dist/es/scroller.d.ts +0 -34
- package/dist/es/scroller.js +0 -226
- package/dist/es/search.d.ts +0 -42
- package/dist/es/search.js +0 -249
- package/dist/es/utils.d.ts +0 -96
- package/dist/es/utils.js +0 -274
- package/dist/npm/scroller.d.ts +0 -34
- package/dist/npm/scroller.js +0 -230
- package/dist/npm/search.d.ts +0 -42
- package/dist/npm/search.js +0 -253
- package/dist/npm/utils.d.ts +0 -96
- package/dist/npm/utils.js +0 -287
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@progress/kendo-react-pdf-viewer",
|
|
3
|
-
"version": "5.16.
|
|
3
|
+
"version": "5.16.2-dev.202308021222",
|
|
4
4
|
"description": "KendoReact PDFViewer package",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -51,9 +51,9 @@
|
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@progress/kendo-draggable": "^3.0.0",
|
|
54
|
-
"@progress/kendo-
|
|
54
|
+
"@progress/kendo-pdfviewer-common": "0.2.1",
|
|
55
|
+
"@progress/kendo-react-common": "5.16.2-dev.202308021222",
|
|
55
56
|
"@typescript/lib-dom": "npm:@types/web",
|
|
56
|
-
"pdfjs-dist": "3.7.107",
|
|
57
57
|
"prop-types": "^15.6.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
@@ -62,17 +62,17 @@
|
|
|
62
62
|
"@progress/kendo-drawing": "^1.17.2",
|
|
63
63
|
"@progress/kendo-file-saver": "^1.1.1",
|
|
64
64
|
"@progress/kendo-licensing": "^1.3.0",
|
|
65
|
-
"@progress/kendo-react-animation": "5.16.
|
|
66
|
-
"@progress/kendo-react-buttons": "5.16.
|
|
67
|
-
"@progress/kendo-react-data-tools": "5.16.
|
|
68
|
-
"@progress/kendo-react-dateinputs": "5.16.
|
|
69
|
-
"@progress/kendo-react-dropdowns": "5.16.
|
|
70
|
-
"@progress/kendo-react-indicators": "5.16.
|
|
71
|
-
"@progress/kendo-react-inputs": "5.16.
|
|
72
|
-
"@progress/kendo-react-intl": "5.16.
|
|
73
|
-
"@progress/kendo-react-progressbars": "5.16.
|
|
74
|
-
"@progress/kendo-react-treeview": "5.16.
|
|
75
|
-
"@progress/kendo-react-upload": "5.16.
|
|
65
|
+
"@progress/kendo-react-animation": "5.16.2-dev.202308021222",
|
|
66
|
+
"@progress/kendo-react-buttons": "5.16.2-dev.202308021222",
|
|
67
|
+
"@progress/kendo-react-data-tools": "5.16.2-dev.202308021222",
|
|
68
|
+
"@progress/kendo-react-dateinputs": "5.16.2-dev.202308021222",
|
|
69
|
+
"@progress/kendo-react-dropdowns": "5.16.2-dev.202308021222",
|
|
70
|
+
"@progress/kendo-react-indicators": "5.16.2-dev.202308021222",
|
|
71
|
+
"@progress/kendo-react-inputs": "5.16.2-dev.202308021222",
|
|
72
|
+
"@progress/kendo-react-intl": "5.16.2-dev.202308021222",
|
|
73
|
+
"@progress/kendo-react-progressbars": "5.16.2-dev.202308021222",
|
|
74
|
+
"@progress/kendo-react-treeview": "5.16.2-dev.202308021222",
|
|
75
|
+
"@progress/kendo-react-upload": "5.16.2-dev.202308021222",
|
|
76
76
|
"@progress/kendo-svg-icons": "^1.0.0"
|
|
77
77
|
},
|
|
78
78
|
"@progress": {
|
package/dist/es/scroller.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @hidden
|
|
3
|
-
*/
|
|
4
|
-
export declare class Scroller {
|
|
5
|
-
options: any;
|
|
6
|
-
state: any;
|
|
7
|
-
element: any;
|
|
8
|
-
throttledOnDrag: any;
|
|
9
|
-
draggable: any;
|
|
10
|
-
throttledOnElementScroll: any;
|
|
11
|
-
constructor(element: any, options: any);
|
|
12
|
-
destroy(): void;
|
|
13
|
-
initDraggable(): void;
|
|
14
|
-
destroyDraggable(): void;
|
|
15
|
-
bindEvents(): void;
|
|
16
|
-
bindDraggableEvents(): void;
|
|
17
|
-
bindElementScroll(): void;
|
|
18
|
-
unbindEvents(): void;
|
|
19
|
-
unbindDraggableEvents(): void;
|
|
20
|
-
unbindElementScroll(): void;
|
|
21
|
-
setState(newState: any): void;
|
|
22
|
-
resetState(): void;
|
|
23
|
-
enablePanEventsTracking(): void;
|
|
24
|
-
disablePanEventsTracking(): void;
|
|
25
|
-
shouldTrackPanEvents(): any;
|
|
26
|
-
onElementScroll: () => void;
|
|
27
|
-
onDragStart: (e: any) => void;
|
|
28
|
-
onDrag: (e: any) => void;
|
|
29
|
-
onDragEnd: () => void;
|
|
30
|
-
calculateEventLocationDelta(e: any): void;
|
|
31
|
-
scrollTo(x: any, y: any, options?: {
|
|
32
|
-
trackScrollEvent: boolean;
|
|
33
|
-
}): void;
|
|
34
|
-
}
|
package/dist/es/scroller.js
DELETED
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
import Draggable from '@progress/kendo-draggable';
|
|
2
|
-
const throttle = function (func, wait, options = {}) {
|
|
3
|
-
let timeout, context, args, result;
|
|
4
|
-
let previous = 0;
|
|
5
|
-
options = options || {};
|
|
6
|
-
const later = function () {
|
|
7
|
-
previous = options.leading === false ? 0 : new Date().getTime();
|
|
8
|
-
timeout = undefined;
|
|
9
|
-
result = func.apply(context, args);
|
|
10
|
-
if (!timeout) {
|
|
11
|
-
context = args = null;
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
const throttled = function () {
|
|
15
|
-
const now = new Date().getTime();
|
|
16
|
-
if (!previous && options.leading === false) {
|
|
17
|
-
previous = now;
|
|
18
|
-
}
|
|
19
|
-
const remaining = wait - (now - previous);
|
|
20
|
-
context = undefined; // this
|
|
21
|
-
args = arguments;
|
|
22
|
-
if (remaining <= 0 || remaining > wait) {
|
|
23
|
-
if (timeout) {
|
|
24
|
-
clearTimeout(timeout);
|
|
25
|
-
timeout = undefined;
|
|
26
|
-
}
|
|
27
|
-
previous = now;
|
|
28
|
-
result = func.apply(context, args);
|
|
29
|
-
if (!timeout) {
|
|
30
|
-
context = args = null;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
else if (!timeout && options.trailing !== false) {
|
|
34
|
-
timeout = window.setTimeout(later, remaining);
|
|
35
|
-
}
|
|
36
|
-
return result;
|
|
37
|
-
};
|
|
38
|
-
return throttled;
|
|
39
|
-
};
|
|
40
|
-
const preventDefault = (e) => {
|
|
41
|
-
if (e.preventDefault) {
|
|
42
|
-
e.preventDefault();
|
|
43
|
-
}
|
|
44
|
-
if (e.originalEvent) {
|
|
45
|
-
e.originalEvent.preventDefault();
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
const matchesElementSelector = (element, selector) => {
|
|
49
|
-
if (!element || !selector) {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
return element.closest(selector);
|
|
53
|
-
};
|
|
54
|
-
const FRAMES_PER_SECOND = 1000 / 60;
|
|
55
|
-
const SCROLL = 'scroll';
|
|
56
|
-
/**
|
|
57
|
-
* @hidden
|
|
58
|
-
*/
|
|
59
|
-
export class Scroller {
|
|
60
|
-
constructor(element, options) {
|
|
61
|
-
this.options = {
|
|
62
|
-
// the drag directions are actually reversed, e.g.
|
|
63
|
-
// dragging to the right actually moves the document to the left
|
|
64
|
-
scrollDirectionModifier: -1,
|
|
65
|
-
// throttle the scroll events to get a more similar experience
|
|
66
|
-
// to the scrolling behavior in Adobe Acrobat Reader
|
|
67
|
-
// as well as allow a way to improve the scrolling performance for large files
|
|
68
|
-
panScrollThrottleDelay: FRAMES_PER_SECOND,
|
|
69
|
-
scrollThrottleDelay: FRAMES_PER_SECOND,
|
|
70
|
-
filter: '',
|
|
71
|
-
events: {
|
|
72
|
-
[SCROLL]: () => { }
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
this.onElementScroll = () => {
|
|
76
|
-
const element = this.element;
|
|
77
|
-
if (this.state.trackNextElementScroll) {
|
|
78
|
-
this.scrollTo(element.scrollLeft, element.scrollTop);
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
// reset the state, so that consecutive scroll events can be handled
|
|
82
|
-
this.state.trackNextElementScroll = true;
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
this.onDragStart = (e) => {
|
|
86
|
-
this.state.dragStarted = false;
|
|
87
|
-
if (!this.shouldTrackPanEvents()) {
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
const target = e.target || (e.originalEvent || {}).target;
|
|
91
|
-
if (this.options.filter && !matchesElementSelector(target, this.options.filter)) {
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
preventDefault(e);
|
|
95
|
-
this.setState({
|
|
96
|
-
dragStarted: true,
|
|
97
|
-
location: {
|
|
98
|
-
pageX: e.pageX,
|
|
99
|
-
pageY: e.pageY
|
|
100
|
-
},
|
|
101
|
-
locationDelta: {
|
|
102
|
-
x: 0,
|
|
103
|
-
y: 0
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
};
|
|
107
|
-
this.onDrag = (e) => {
|
|
108
|
-
if (!this.shouldTrackPanEvents() || !this.state.dragStarted) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
this.calculateEventLocationDelta(e);
|
|
112
|
-
this.setState({
|
|
113
|
-
location: {
|
|
114
|
-
pageX: e.pageX,
|
|
115
|
-
pageY: e.pageY
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
const directionModifier = this.options.scrollDirectionModifier;
|
|
119
|
-
const scrollLeft = this.element.scrollLeft + (directionModifier * this.state.locationDelta.x);
|
|
120
|
-
const scrollTop = this.element.scrollTop + (directionModifier * this.state.locationDelta.y);
|
|
121
|
-
this.scrollTo(scrollLeft, scrollTop);
|
|
122
|
-
};
|
|
123
|
-
this.onDragEnd = () => {
|
|
124
|
-
if (!this.shouldTrackPanEvents()) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
this.element = element;
|
|
129
|
-
this.options = Object.assign({}, this.options, options);
|
|
130
|
-
this.resetState();
|
|
131
|
-
this.bindEvents();
|
|
132
|
-
}
|
|
133
|
-
destroy() {
|
|
134
|
-
this.unbindEvents();
|
|
135
|
-
}
|
|
136
|
-
initDraggable() {
|
|
137
|
-
this.destroyDraggable();
|
|
138
|
-
if (this.options.panScrollThrottleDelay > 0) {
|
|
139
|
-
this.throttledOnDrag = throttle(this.onDrag, this.options.panScrollThrottleDelay);
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
this.throttledOnDrag = this.onDrag;
|
|
143
|
-
}
|
|
144
|
-
this.draggable = new Draggable({
|
|
145
|
-
mouseOnly: false,
|
|
146
|
-
press: this.onDragStart,
|
|
147
|
-
drag: this.throttledOnDrag,
|
|
148
|
-
release: this.onDragEnd
|
|
149
|
-
});
|
|
150
|
-
this.draggable.bindTo(this.element);
|
|
151
|
-
}
|
|
152
|
-
destroyDraggable() {
|
|
153
|
-
if (this.draggable && this.draggable.destroy) {
|
|
154
|
-
this.draggable.destroy();
|
|
155
|
-
if (this.throttledOnDrag && this.throttledOnDrag.cancel) {
|
|
156
|
-
this.throttledOnDrag.cancel();
|
|
157
|
-
this.throttledOnDrag = null;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
bindEvents() {
|
|
162
|
-
this.bindDraggableEvents();
|
|
163
|
-
this.bindElementScroll();
|
|
164
|
-
}
|
|
165
|
-
bindDraggableEvents() {
|
|
166
|
-
this.initDraggable();
|
|
167
|
-
}
|
|
168
|
-
bindElementScroll() {
|
|
169
|
-
if (this.options.scrollThrottleDelay > 0) {
|
|
170
|
-
this.throttledOnElementScroll = throttle(this.onElementScroll, this.options.scrollThrottleDelay);
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
this.throttledOnElementScroll = this.onElementScroll;
|
|
174
|
-
}
|
|
175
|
-
this.element.addEventListener(SCROLL, this.throttledOnElementScroll);
|
|
176
|
-
}
|
|
177
|
-
unbindEvents() {
|
|
178
|
-
this.unbindElementScroll();
|
|
179
|
-
this.unbindDraggableEvents();
|
|
180
|
-
}
|
|
181
|
-
unbindDraggableEvents() {
|
|
182
|
-
this.destroyDraggable();
|
|
183
|
-
}
|
|
184
|
-
unbindElementScroll() {
|
|
185
|
-
if (this.throttledOnElementScroll && this.throttledOnElementScroll.cancel) {
|
|
186
|
-
this.throttledOnElementScroll.cancel();
|
|
187
|
-
this.throttledOnElementScroll = null;
|
|
188
|
-
}
|
|
189
|
-
this.element.removeEventListener(SCROLL, this.throttledOnElementScroll);
|
|
190
|
-
}
|
|
191
|
-
setState(newState) {
|
|
192
|
-
this.state = Object.assign({}, this.state || {}, newState);
|
|
193
|
-
}
|
|
194
|
-
resetState() {
|
|
195
|
-
this.setState({
|
|
196
|
-
trackPanEvents: false,
|
|
197
|
-
trackNextElementScroll: false,
|
|
198
|
-
location: { pageX: 0, pageY: 0 },
|
|
199
|
-
locationDelta: { x: 0, y: 0 }
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
enablePanEventsTracking() {
|
|
203
|
-
this.state.trackPanEvents = true;
|
|
204
|
-
this.bindDraggableEvents();
|
|
205
|
-
}
|
|
206
|
-
disablePanEventsTracking() {
|
|
207
|
-
this.unbindDraggableEvents();
|
|
208
|
-
this.state.trackPanEvents = false;
|
|
209
|
-
}
|
|
210
|
-
shouldTrackPanEvents() {
|
|
211
|
-
return this.state.trackPanEvents;
|
|
212
|
-
}
|
|
213
|
-
calculateEventLocationDelta(e) {
|
|
214
|
-
this.state.locationDelta = {
|
|
215
|
-
x: e.pageX - this.state.location.pageX,
|
|
216
|
-
y: e.pageY - this.state.location.pageY
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
scrollTo(x, y, options = { trackScrollEvent: true }) {
|
|
220
|
-
if (!options.trackScrollEvent) {
|
|
221
|
-
this.state.trackNextElementScroll = false;
|
|
222
|
-
}
|
|
223
|
-
this.element.scrollLeft = x;
|
|
224
|
-
this.element.scrollTop = y;
|
|
225
|
-
}
|
|
226
|
-
}
|
package/dist/es/search.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @hidden
|
|
3
|
-
*/
|
|
4
|
-
export declare class SearchService {
|
|
5
|
-
options: {
|
|
6
|
-
highlightClass: string;
|
|
7
|
-
highlightMarkClass: string;
|
|
8
|
-
charClass: string;
|
|
9
|
-
textContainers: never[];
|
|
10
|
-
};
|
|
11
|
-
state: any;
|
|
12
|
-
constructor(options: any);
|
|
13
|
-
destroy(): void;
|
|
14
|
-
extendOptions(options: any): void;
|
|
15
|
-
setState(newState: any): void;
|
|
16
|
-
resetState(): void;
|
|
17
|
-
search({ text, matchCase }: any): {
|
|
18
|
-
startOffset: number;
|
|
19
|
-
endOffset: number;
|
|
20
|
-
}[];
|
|
21
|
-
clearSearch(): void;
|
|
22
|
-
restoreOriginalText(): void;
|
|
23
|
-
shouldTransformText(): boolean;
|
|
24
|
-
transformTextForSearch(): void;
|
|
25
|
-
extractTextNodes(node: any): void;
|
|
26
|
-
transformTextNodesForSearch(textNodes: any): void;
|
|
27
|
-
transformTextNodeForSearch(node: any): void;
|
|
28
|
-
splitTextByChars(text: any): string;
|
|
29
|
-
forEachTextContainer(callback: any): void;
|
|
30
|
-
highlightAllMatches(): void;
|
|
31
|
-
addMatchHighlight(matchStartOffset: number, matchEndOffset: number, matchIndex: number): void;
|
|
32
|
-
removeMatchHighlights(): void;
|
|
33
|
-
addActiveMatchMark(): void;
|
|
34
|
-
removeActiveMatchMark(): void;
|
|
35
|
-
removeIndicators(): void;
|
|
36
|
-
markNextMatch(): void;
|
|
37
|
-
markPreviousMatch(): void;
|
|
38
|
-
markNextMatchIndex(): void;
|
|
39
|
-
markPreviousMatchIndex(): void;
|
|
40
|
-
moveActiveMatchIndex(delta: any): void;
|
|
41
|
-
getActiveMatchElement(): undefined;
|
|
42
|
-
}
|
package/dist/es/search.js
DELETED
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
const unwrapElement = (element) => {
|
|
2
|
-
const parentElement = element.parentElement;
|
|
3
|
-
if (!element || !parentElement) {
|
|
4
|
-
return;
|
|
5
|
-
}
|
|
6
|
-
parentElement.replaceWith(...Array.from(parentElement.childNodes));
|
|
7
|
-
};
|
|
8
|
-
const unwrapElements = (elements) => {
|
|
9
|
-
if (!elements || !elements.length || elements.length <= 0) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
for (let i = 0; i < elements.length; i++) {
|
|
13
|
-
unwrapElement(elements[i]);
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
const wrapElement = (element, wrapper) => {
|
|
17
|
-
if (element.parentNode) {
|
|
18
|
-
element.parentNode.insertBefore(wrapper, element);
|
|
19
|
-
wrapper.appendChild(element);
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
const wrapInnerElement = (element, wrapper) => {
|
|
23
|
-
if (!element || !element.parentNode || !wrapper) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
element.appendChild(wrapper);
|
|
27
|
-
while (element.firstChild && element.firstChild !== wrapper) {
|
|
28
|
-
wrapper.appendChild(element.firstChild);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
const addClass = (className, element) => { element.classList.add(className); };
|
|
32
|
-
const removeClass = (className, element) => { element.classList.remove(className); };
|
|
33
|
-
const toClassSelector = (className) => `.${className}`;
|
|
34
|
-
const CHAR_INDEX_DATA_ATTR = 'data-char-index';
|
|
35
|
-
const MATCH_INDEX_DATA_ATTR = 'data-match-index';
|
|
36
|
-
/**
|
|
37
|
-
* @hidden
|
|
38
|
-
*/
|
|
39
|
-
export class SearchService {
|
|
40
|
-
constructor(options) {
|
|
41
|
-
this.options = {
|
|
42
|
-
highlightClass: 'k-search-highlight',
|
|
43
|
-
highlightMarkClass: 'k-search-highlight-mark',
|
|
44
|
-
charClass: 'k-text-char',
|
|
45
|
-
textContainers: []
|
|
46
|
-
};
|
|
47
|
-
this.extendOptions(options);
|
|
48
|
-
this.resetState();
|
|
49
|
-
}
|
|
50
|
-
destroy() {
|
|
51
|
-
this.clearSearch();
|
|
52
|
-
}
|
|
53
|
-
extendOptions(options) {
|
|
54
|
-
this.options = Object.assign({}, this.options, options);
|
|
55
|
-
}
|
|
56
|
-
setState(newState) {
|
|
57
|
-
this.state = Object.assign({}, this.state || {}, newState);
|
|
58
|
-
}
|
|
59
|
-
resetState() {
|
|
60
|
-
this.setState({
|
|
61
|
-
text: '',
|
|
62
|
-
textNodes: [],
|
|
63
|
-
charIndex: 0,
|
|
64
|
-
activeMatchIndex: 0,
|
|
65
|
-
matches: []
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
search({ text, matchCase }) {
|
|
69
|
-
let searchRegex = new RegExp(text, matchCase ? 'g' : 'ig');
|
|
70
|
-
let match;
|
|
71
|
-
if (this.shouldTransformText()) {
|
|
72
|
-
this.transformTextForSearch();
|
|
73
|
-
}
|
|
74
|
-
this.state.matches = [];
|
|
75
|
-
this.state.activeMatchIndex = 0;
|
|
76
|
-
this.removeIndicators();
|
|
77
|
-
if (text === '') {
|
|
78
|
-
return [];
|
|
79
|
-
}
|
|
80
|
-
match = searchRegex.exec(this.state.text);
|
|
81
|
-
while (match) {
|
|
82
|
-
this.state.matches.push({
|
|
83
|
-
startOffset: match.index,
|
|
84
|
-
endOffset: match.index + match[0].length
|
|
85
|
-
});
|
|
86
|
-
match = searchRegex.exec(this.state.text);
|
|
87
|
-
}
|
|
88
|
-
this.highlightAllMatches();
|
|
89
|
-
this.addActiveMatchMark();
|
|
90
|
-
return this.state.matches;
|
|
91
|
-
}
|
|
92
|
-
clearSearch() {
|
|
93
|
-
this.removeIndicators();
|
|
94
|
-
this.restoreOriginalText();
|
|
95
|
-
}
|
|
96
|
-
restoreOriginalText() {
|
|
97
|
-
this.forEachTextContainer((textContainer) => {
|
|
98
|
-
const nodes = Array.from(textContainer.querySelectorAll('span:not(.' + this.options.charClass + ')'));
|
|
99
|
-
nodes.forEach((node) => {
|
|
100
|
-
node.innerHTML = node.textContent;
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
shouldTransformText() {
|
|
105
|
-
return !this.state.text;
|
|
106
|
-
}
|
|
107
|
-
transformTextForSearch() {
|
|
108
|
-
this.state.textNodes = [];
|
|
109
|
-
this.state.charIndex = 0;
|
|
110
|
-
this.state.text = '';
|
|
111
|
-
this.forEachTextContainer((textContainer) => {
|
|
112
|
-
this.extractTextNodes(textContainer);
|
|
113
|
-
});
|
|
114
|
-
this.transformTextNodesForSearch(this.state.textNodes);
|
|
115
|
-
}
|
|
116
|
-
extractTextNodes(node) {
|
|
117
|
-
if (node.nodeType === Node.TEXT_NODE) {
|
|
118
|
-
this.state.textNodes.push(node);
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
for (let i = 0; i < node.childNodes.length; i++) {
|
|
122
|
-
this.extractTextNodes(node.childNodes[i]);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
transformTextNodesForSearch(textNodes) {
|
|
127
|
-
for (let i = 0; i < textNodes.length; i++) {
|
|
128
|
-
this.transformTextNodeForSearch(textNodes[i]);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
transformTextNodeForSearch(node) {
|
|
132
|
-
const text = node.textContent;
|
|
133
|
-
if (text.length <= 0) {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
this.state.text = this.state.text + text;
|
|
137
|
-
const span = document.createElement('span');
|
|
138
|
-
wrapElement(node, span);
|
|
139
|
-
const splittedHtml = this.splitTextByChars(text);
|
|
140
|
-
span.innerHTML = splittedHtml;
|
|
141
|
-
unwrapElement(span.childNodes[0]);
|
|
142
|
-
}
|
|
143
|
-
splitTextByChars(text) {
|
|
144
|
-
let splittedTextHtml = '';
|
|
145
|
-
for (let i = 0; i < text.length; i++) {
|
|
146
|
-
splittedTextHtml +=
|
|
147
|
-
'<span class=\'' + this.options.charClass + '\' ' + CHAR_INDEX_DATA_ATTR + '=' + this.state.charIndex + '>' +
|
|
148
|
-
text[i] +
|
|
149
|
-
'</span>';
|
|
150
|
-
this.state.charIndex++;
|
|
151
|
-
}
|
|
152
|
-
return splittedTextHtml;
|
|
153
|
-
}
|
|
154
|
-
forEachTextContainer(callback) {
|
|
155
|
-
for (let i = 0; i < this.options.textContainers.length; i++) {
|
|
156
|
-
const textContainer = this.options.textContainers[i];
|
|
157
|
-
callback(textContainer, i);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
highlightAllMatches() {
|
|
161
|
-
this.state.matches.forEach((match, matchIndex) => {
|
|
162
|
-
this.addMatchHighlight(match.startOffset, match.endOffset, matchIndex);
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
addMatchHighlight(matchStartOffset, matchEndOffset, matchIndex) {
|
|
166
|
-
for (let i = matchStartOffset; i < matchEndOffset; i++) {
|
|
167
|
-
this.forEachTextContainer((textContainer) => {
|
|
168
|
-
const highlights = Array.from(textContainer.querySelectorAll(toClassSelector(this.options.charClass + '[' + CHAR_INDEX_DATA_ATTR + '=\'' + i + '\'' + ']')));
|
|
169
|
-
highlights.forEach((highlight) => {
|
|
170
|
-
addClass(this.options.highlightClass, highlight);
|
|
171
|
-
highlight.setAttribute(MATCH_INDEX_DATA_ATTR, matchIndex);
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
removeMatchHighlights() {
|
|
177
|
-
this.forEachTextContainer((textContainer) => {
|
|
178
|
-
const highlights = Array.from(textContainer.querySelectorAll(toClassSelector(this.options.highlightClass)));
|
|
179
|
-
highlights.forEach((highlight) => {
|
|
180
|
-
removeClass(this.options.highlightClass, highlight);
|
|
181
|
-
highlight.removeAttribute(MATCH_INDEX_DATA_ATTR);
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
addActiveMatchMark() {
|
|
186
|
-
if (!this.state.activeMatchIndex && this.state.activeMatchIndex !== 0) {
|
|
187
|
-
this.state.activeMatchIndex = 0;
|
|
188
|
-
}
|
|
189
|
-
else if (this.state.activeMatchIndex > this.state.matches.length) {
|
|
190
|
-
this.state.activeMatchIndex = this.state.matches.length;
|
|
191
|
-
}
|
|
192
|
-
else {
|
|
193
|
-
this.removeActiveMatchMark();
|
|
194
|
-
}
|
|
195
|
-
const mark = document.createElement('span');
|
|
196
|
-
mark.classList.add(this.options.highlightMarkClass);
|
|
197
|
-
this.forEachTextContainer((textContainer) => {
|
|
198
|
-
const matches = Array.from(textContainer.querySelectorAll(toClassSelector(this.options.charClass + '[' + MATCH_INDEX_DATA_ATTR + '=\'' + this.state.activeMatchIndex + '\']')));
|
|
199
|
-
matches.forEach((match) => {
|
|
200
|
-
wrapInnerElement(match, mark.cloneNode(true));
|
|
201
|
-
});
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
removeActiveMatchMark() {
|
|
205
|
-
this.forEachTextContainer((textContainer) => {
|
|
206
|
-
const marks = Array.from(textContainer.querySelectorAll(toClassSelector(this.options.highlightMarkClass)));
|
|
207
|
-
const childNodes = marks.flatMap((x) => Array.from(x.childNodes));
|
|
208
|
-
unwrapElements(childNodes);
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
removeIndicators() {
|
|
212
|
-
this.removeActiveMatchMark();
|
|
213
|
-
this.removeMatchHighlights();
|
|
214
|
-
}
|
|
215
|
-
markNextMatch() {
|
|
216
|
-
this.markNextMatchIndex();
|
|
217
|
-
this.addActiveMatchMark();
|
|
218
|
-
}
|
|
219
|
-
markPreviousMatch() {
|
|
220
|
-
this.markPreviousMatchIndex();
|
|
221
|
-
this.addActiveMatchMark();
|
|
222
|
-
}
|
|
223
|
-
markNextMatchIndex() {
|
|
224
|
-
this.moveActiveMatchIndex(1);
|
|
225
|
-
}
|
|
226
|
-
markPreviousMatchIndex() {
|
|
227
|
-
this.moveActiveMatchIndex(-1);
|
|
228
|
-
}
|
|
229
|
-
moveActiveMatchIndex(delta) {
|
|
230
|
-
this.state.activeMatchIndex += delta;
|
|
231
|
-
if (this.state.activeMatchIndex < 0) {
|
|
232
|
-
this.state.activeMatchIndex = Math.max(this.state.matches.length - 1, 0);
|
|
233
|
-
}
|
|
234
|
-
else if (this.state.activeMatchIndex > this.state.matches.length - 1) {
|
|
235
|
-
this.state.activeMatchIndex = 0;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
getActiveMatchElement() {
|
|
239
|
-
let markedMatch;
|
|
240
|
-
this.forEachTextContainer((textContainer) => {
|
|
241
|
-
const mark = textContainer.querySelector(toClassSelector(this.options.highlightMarkClass));
|
|
242
|
-
if (mark) {
|
|
243
|
-
markedMatch = mark;
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
});
|
|
247
|
-
return markedMatch;
|
|
248
|
-
}
|
|
249
|
-
}
|
package/dist/es/utils.d.ts
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { SaveOptions } from '@progress/kendo-file-saver';
|
|
2
|
-
import { PDFPageProxy, PDFDocumentProxy } from 'pdfjs-dist';
|
|
3
|
-
import { TypedArray } from 'pdfjs-dist/types/src/display/api';
|
|
4
|
-
/**
|
|
5
|
-
* @hidden
|
|
6
|
-
*/
|
|
7
|
-
export declare type DoneFn = (result: {
|
|
8
|
-
pdfPages: PDFPageProxy[];
|
|
9
|
-
pdfDoc: PDFDocumentProxy;
|
|
10
|
-
zoom: number;
|
|
11
|
-
}) => void;
|
|
12
|
-
/**
|
|
13
|
-
* @hidden
|
|
14
|
-
*/
|
|
15
|
-
export declare type ErrorFn = (e?: any) => void;
|
|
16
|
-
/**
|
|
17
|
-
* @hidden
|
|
18
|
-
*/
|
|
19
|
-
export interface PDFReadParameters {
|
|
20
|
-
url?: string;
|
|
21
|
-
data?: string;
|
|
22
|
-
arrayBuffer?: ArrayBuffer;
|
|
23
|
-
typedArray?: TypedArray;
|
|
24
|
-
error: ErrorFn;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* @hidden
|
|
28
|
-
*/
|
|
29
|
-
export interface PDFReadOptions extends PDFReadParameters {
|
|
30
|
-
dom: HTMLDivElement;
|
|
31
|
-
zoom: number;
|
|
32
|
-
done: DoneFn;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* @hidden
|
|
36
|
-
*/
|
|
37
|
-
export interface PDFReloadParameters {
|
|
38
|
-
pdfDoc: PDFDocumentProxy;
|
|
39
|
-
zoom: number;
|
|
40
|
-
dom: HTMLElement;
|
|
41
|
-
done: (pdfPages: PDFPageProxy[]) => void;
|
|
42
|
-
error: ErrorFn;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* @hidden
|
|
46
|
-
*/
|
|
47
|
-
export declare const DEFAULT_ZOOM_LEVEL = 1.25;
|
|
48
|
-
/**
|
|
49
|
-
* @hidden
|
|
50
|
-
*/
|
|
51
|
-
export declare const removeChildren: (dom: HTMLElement) => void;
|
|
52
|
-
/**
|
|
53
|
-
* @hidden
|
|
54
|
-
*/
|
|
55
|
-
export declare const download: (options: {
|
|
56
|
-
pdf: PDFDocumentProxy | null;
|
|
57
|
-
error: ErrorFn;
|
|
58
|
-
}, fileName: string | undefined, saveOptions: SaveOptions | undefined, onDownload: (blob: Blob, fileName: string, saveOptions: SaveOptions) => boolean) => void;
|
|
59
|
-
/**
|
|
60
|
-
* @hidden
|
|
61
|
-
*/
|
|
62
|
-
export declare const loadPDF: (options: PDFReadOptions) => void;
|
|
63
|
-
/**
|
|
64
|
-
* @hidden
|
|
65
|
-
*/
|
|
66
|
-
export declare const reloadDocument: (params: PDFReloadParameters) => void;
|
|
67
|
-
/**
|
|
68
|
-
* @hidden
|
|
69
|
-
*/
|
|
70
|
-
export declare const print: (pages: PDFPageProxy[], done: () => void, error: ErrorFn) => void;
|
|
71
|
-
/**
|
|
72
|
-
* @hidden
|
|
73
|
-
*/
|
|
74
|
-
export declare const goToNextSearchMatch: (ref: any) => void;
|
|
75
|
-
/**
|
|
76
|
-
* @hidden
|
|
77
|
-
*/
|
|
78
|
-
export declare const goToPreviousSearchMatch: (ref: any) => void;
|
|
79
|
-
/**
|
|
80
|
-
* @hidden
|
|
81
|
-
*/
|
|
82
|
-
export declare const calculateZoomLevel: (zoomLevel: number, zoomLevelType: string, currentZoom: number, dom: HTMLDivElement) => number;
|
|
83
|
-
/**
|
|
84
|
-
* Scrolls the PDFViewer document to the passed page number.
|
|
85
|
-
*
|
|
86
|
-
* @param rootElement The root HTML element of the PDFViewer component.
|
|
87
|
-
* @param pageNumber The page number.
|
|
88
|
-
*/
|
|
89
|
-
export declare const scrollToPage: (rootElement: HTMLElement, pageNumber: number) => void;
|
|
90
|
-
/**
|
|
91
|
-
* A function which gives you the page number of the document according to the scroll position.
|
|
92
|
-
*
|
|
93
|
-
* @param rootElement The root HTML element of the PDFViewer component.
|
|
94
|
-
* @returns The page number.
|
|
95
|
-
*/
|
|
96
|
-
export declare const currentPage: (rootElement: HTMLElement) => number;
|