@progress/kendo-vue-pdf-viewer 9.2.0-develop.2
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/LICENSE.md +11 -0
- package/NOTICE.txt +109 -0
- package/PDFViewer.d.ts +266 -0
- package/PDFViewer.js +8 -0
- package/PDFViewer.mjs +711 -0
- package/README.md +57 -0
- package/dist/cdn/js/kendo-vue-pdf-viewer.js +15 -0
- package/index.d.mts +16 -0
- package/index.d.ts +16 -0
- package/index.js +8 -0
- package/index.mjs +16 -0
- package/messages.d.ts +91 -0
- package/messages.js +8 -0
- package/messages.mjs +52 -0
- package/package-metadata.d.ts +12 -0
- package/package-metadata.js +8 -0
- package/package-metadata.mjs +19 -0
- package/package.json +76 -0
package/PDFViewer.mjs
ADDED
|
@@ -0,0 +1,711 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2026 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
import { defineComponent as Z, h as f, createVNode as s, createTextVNode as M, Fragment as D, isVNode as $ } from "vue";
|
|
9
|
+
import { Button as a, ToolbarSpacer as I, ButtonGroup as y, Toolbar as L } from "@progress/kendo-vue-buttons";
|
|
10
|
+
import { TextBox as P, InputSeparator as O } from "@progress/kendo-vue-inputs";
|
|
11
|
+
import { Pager as F } from "@progress/kendo-vue-data-tools";
|
|
12
|
+
import { Upload as N } from "@progress/kendo-vue-upload";
|
|
13
|
+
import { ComboBox as R } from "@progress/kendo-vue-dropdowns";
|
|
14
|
+
import { Loader as V } from "@progress/kendo-vue-indicators";
|
|
15
|
+
import { templateRendering as v, getListeners as b, getTemplate as k, WatermarkOverlay as B, classNames as A, isRtl as x, validatePackage as j, shouldShowValidationUI as W, getLicenseMessage as U } from "@progress/kendo-vue-common";
|
|
16
|
+
import { arrowUpIcon as K, arrowDownIcon as q, xIcon as G, zoomOutIcon as H, zoomInIcon as J, pointerIcon as Q, handIcon as X, searchIcon as Y, folderOpenIcon as tt, downloadIcon as et, printIcon as ot, convertLowercaseIcon as st } from "@progress/kendo-svg-icons";
|
|
17
|
+
import "pdfjs-dist/build/pdf.worker.min.mjs";
|
|
18
|
+
import { packageMetadata as _ } from "./package-metadata.mjs";
|
|
19
|
+
import { DEFAULT_ZOOM_LEVEL as it, removeChildren as h, loadPDF as C, print as at, download as rt, calculateZoomLevel as lt, currentPage as nt, scrollToPage as z, goToNextSearchMatch as w, goToPreviousSearchMatch as ct, reloadDocument as ht, SearchService as ut, Scroller as dt } from "@progress/kendo-pdfviewer-common";
|
|
20
|
+
import { actualWidth as pt, fitToWidth as mt, fitToPage as gt, canvasAriaLabel as ft, searchPanelAriaLabel as vt, search as S, searchOf as bt, prevMatch as kt, nextMatch as _t, close as zt, zoomOut as yt, zoomIn as xt, zoomLevel as Ct, enableSelection as wt, enablePanning as St, open as Et, download as Tt, print as Zt, popupBlocked as Mt, messages as E, matchCase as Dt } from "./messages.mjs";
|
|
21
|
+
function $t(t) {
|
|
22
|
+
return typeof t == "function" || Object.prototype.toString.call(t) === "[object Object]" && !$(t);
|
|
23
|
+
}
|
|
24
|
+
const T = ["pager", "spacer", "zoomInOut", "zoom", "selection", "spacer", "search", "open", "download", "print"], n = {
|
|
25
|
+
minZoom: 0.5,
|
|
26
|
+
maxZoom: 4,
|
|
27
|
+
tools: [...T],
|
|
28
|
+
zoomRate: 0.25,
|
|
29
|
+
zoomLevels: [{
|
|
30
|
+
id: 1,
|
|
31
|
+
priority: 1,
|
|
32
|
+
value: 1,
|
|
33
|
+
text: "Actual width",
|
|
34
|
+
type: "ActualWidth",
|
|
35
|
+
locationString: pt
|
|
36
|
+
}, {
|
|
37
|
+
id: 2,
|
|
38
|
+
priority: 2,
|
|
39
|
+
value: 1,
|
|
40
|
+
text: "Fit to width",
|
|
41
|
+
type: "FitToWidth",
|
|
42
|
+
locationString: mt
|
|
43
|
+
}, {
|
|
44
|
+
id: 3,
|
|
45
|
+
priority: 3,
|
|
46
|
+
value: 1,
|
|
47
|
+
text: "Fit to page",
|
|
48
|
+
type: "FitToPage",
|
|
49
|
+
locationString: gt
|
|
50
|
+
}, {
|
|
51
|
+
id: 4,
|
|
52
|
+
priority: 4,
|
|
53
|
+
value: 0.5,
|
|
54
|
+
text: "50%",
|
|
55
|
+
type: ""
|
|
56
|
+
}, {
|
|
57
|
+
id: 5,
|
|
58
|
+
priority: 5,
|
|
59
|
+
value: 0.75,
|
|
60
|
+
text: "75%",
|
|
61
|
+
type: ""
|
|
62
|
+
}, {
|
|
63
|
+
id: 6,
|
|
64
|
+
priority: 100,
|
|
65
|
+
value: 1,
|
|
66
|
+
text: "100%",
|
|
67
|
+
type: ""
|
|
68
|
+
}, {
|
|
69
|
+
id: 7,
|
|
70
|
+
priority: 7,
|
|
71
|
+
value: 1.25,
|
|
72
|
+
text: "125%",
|
|
73
|
+
type: ""
|
|
74
|
+
}, {
|
|
75
|
+
id: 8,
|
|
76
|
+
priority: 8,
|
|
77
|
+
value: 1.5,
|
|
78
|
+
text: "150%",
|
|
79
|
+
type: ""
|
|
80
|
+
}, {
|
|
81
|
+
id: 9,
|
|
82
|
+
priority: 9,
|
|
83
|
+
value: 2,
|
|
84
|
+
text: "200%",
|
|
85
|
+
type: ""
|
|
86
|
+
}, {
|
|
87
|
+
id: 10,
|
|
88
|
+
priority: 10,
|
|
89
|
+
value: 3,
|
|
90
|
+
text: "300%",
|
|
91
|
+
type: ""
|
|
92
|
+
}, {
|
|
93
|
+
id: 11,
|
|
94
|
+
priority: 11,
|
|
95
|
+
value: 4,
|
|
96
|
+
text: "400%",
|
|
97
|
+
type: ""
|
|
98
|
+
}],
|
|
99
|
+
defaultZoom: it
|
|
100
|
+
}, It = [".k-toolbar > button", ".k-toolbar .k-combobox > input", ".k-toolbar .k-button-group > button", ".k-toolbar .k-pager > a", ".k-toolbar .k-pager input"], Lt = (t, e) => t.priority > e.priority ? -1 : t.priority < e.priority ? 1 : 0, Gt = /* @__PURE__ */ Z({
|
|
101
|
+
name: "KendoPDFViewer",
|
|
102
|
+
emits: {
|
|
103
|
+
error: (t) => !0,
|
|
104
|
+
load: (t) => !0,
|
|
105
|
+
download: (t) => !0,
|
|
106
|
+
zoom: (t) => !0,
|
|
107
|
+
pagechange: (t) => !0
|
|
108
|
+
},
|
|
109
|
+
props: {
|
|
110
|
+
url: String,
|
|
111
|
+
data: String,
|
|
112
|
+
arrayBuffer: Object,
|
|
113
|
+
typedArray: Object,
|
|
114
|
+
dir: {
|
|
115
|
+
type: String,
|
|
116
|
+
validator: function(t) {
|
|
117
|
+
return [null, "ltr", "rtl"].includes(t);
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
saveFileName: String,
|
|
121
|
+
saveOptions: Object,
|
|
122
|
+
tools: {
|
|
123
|
+
type: Array,
|
|
124
|
+
default: () => [...T]
|
|
125
|
+
},
|
|
126
|
+
zoomLevels: {
|
|
127
|
+
type: Array,
|
|
128
|
+
default: () => n.zoomLevels
|
|
129
|
+
},
|
|
130
|
+
zoom: Number,
|
|
131
|
+
defaultZoom: {
|
|
132
|
+
type: Number,
|
|
133
|
+
default: n.defaultZoom
|
|
134
|
+
},
|
|
135
|
+
minZoom: {
|
|
136
|
+
type: Number,
|
|
137
|
+
default: n.minZoom
|
|
138
|
+
},
|
|
139
|
+
maxZoom: {
|
|
140
|
+
type: Number,
|
|
141
|
+
default: n.maxZoom
|
|
142
|
+
},
|
|
143
|
+
zoomRate: {
|
|
144
|
+
type: Number,
|
|
145
|
+
default: n.zoomRate
|
|
146
|
+
},
|
|
147
|
+
toolbar: [String, Function, Object],
|
|
148
|
+
content: [String, Function, Object],
|
|
149
|
+
loader: [String, Function, Object]
|
|
150
|
+
},
|
|
151
|
+
inject: {
|
|
152
|
+
kendoLocalizationService: {
|
|
153
|
+
default: null
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
data() {
|
|
157
|
+
return {
|
|
158
|
+
stateZoom: this.$props.defaultZoom,
|
|
159
|
+
hasDocument: !1,
|
|
160
|
+
loading: !0,
|
|
161
|
+
skip: 0,
|
|
162
|
+
enabledSelection: !0,
|
|
163
|
+
showSearch: !1,
|
|
164
|
+
matches: 0,
|
|
165
|
+
currentMatch: 0,
|
|
166
|
+
matchCase: !1,
|
|
167
|
+
searchText: "",
|
|
168
|
+
showLicenseWatermark: !1,
|
|
169
|
+
currentRtl: !1
|
|
170
|
+
};
|
|
171
|
+
},
|
|
172
|
+
created() {
|
|
173
|
+
j(_), this.showLicenseWatermark = W(_), this._licenseMessage = U(_), this._pagesEl = null, this._pdfViewerEl = null, this._scroller = null, this._search = null, this._document = null, this._pages = [], this._zoom = null;
|
|
174
|
+
},
|
|
175
|
+
computed: {
|
|
176
|
+
currentZoom() {
|
|
177
|
+
return this.$props.zoom === void 0 ? this.stateZoom : this.$props.zoom;
|
|
178
|
+
},
|
|
179
|
+
currentZoomLevel() {
|
|
180
|
+
const o = this.$props.zoomLevels.slice().sort(Lt).find((i) => i.value === this.currentZoom) || {
|
|
181
|
+
text: this.currentZoom * 100 + "%",
|
|
182
|
+
value: this.currentZoom,
|
|
183
|
+
id: this.currentZoom,
|
|
184
|
+
locationString: ""
|
|
185
|
+
};
|
|
186
|
+
return o.locationString ? {
|
|
187
|
+
...o,
|
|
188
|
+
text: this.localize(o.locationString)
|
|
189
|
+
} : o;
|
|
190
|
+
},
|
|
191
|
+
currentDir() {
|
|
192
|
+
return this.$props.dir !== void 0 ? this.$props.dir : this.currentRtl ? "rtl" : "ltr";
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
watch: {
|
|
196
|
+
url() {
|
|
197
|
+
this.loadDocument();
|
|
198
|
+
},
|
|
199
|
+
data() {
|
|
200
|
+
this.loadDocument();
|
|
201
|
+
},
|
|
202
|
+
arrayBuffer() {
|
|
203
|
+
this.loadDocument();
|
|
204
|
+
},
|
|
205
|
+
currentZoom(t, e) {
|
|
206
|
+
this.setScaleFactor(t), this._pagesEl && this._document && t !== this._zoom && this.reload(this._document, t, this.skip);
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
mounted() {
|
|
210
|
+
this.currentRtl = x(this._pdfViewerEl), this.loadDocument();
|
|
211
|
+
},
|
|
212
|
+
updated() {
|
|
213
|
+
this.currentRtl = x(this._pdfViewerEl);
|
|
214
|
+
},
|
|
215
|
+
beforeUnmount() {
|
|
216
|
+
this._scroller && this._scroller.destroy(), this._search && this._search.destroy(), this._document = null, this._pages = [];
|
|
217
|
+
},
|
|
218
|
+
methods: {
|
|
219
|
+
localize(t) {
|
|
220
|
+
const e = this.kendoLocalizationService;
|
|
221
|
+
return e ? e.toLanguageString(t, E[t]) : E[t];
|
|
222
|
+
},
|
|
223
|
+
getTarget() {
|
|
224
|
+
return {
|
|
225
|
+
element: this._pdfViewerEl,
|
|
226
|
+
props: this.$props,
|
|
227
|
+
document: this._document,
|
|
228
|
+
pages: this._pages
|
|
229
|
+
};
|
|
230
|
+
},
|
|
231
|
+
setScaleFactor(t) {
|
|
232
|
+
this._pagesEl && this._pagesEl.style.setProperty("--scale-factor", String(t));
|
|
233
|
+
},
|
|
234
|
+
loadDocument() {
|
|
235
|
+
if (this._pagesEl)
|
|
236
|
+
if (this.$props.url || this.$props.data || this.$props.arrayBuffer) {
|
|
237
|
+
this.loading = !0, h(this._pagesEl);
|
|
238
|
+
const t = this._pagesEl;
|
|
239
|
+
setTimeout(() => {
|
|
240
|
+
C({
|
|
241
|
+
url: this.$props.url,
|
|
242
|
+
data: this.$props.data,
|
|
243
|
+
arrayBuffer: this.$props.arrayBuffer,
|
|
244
|
+
dom: t,
|
|
245
|
+
zoom: this.currentZoom,
|
|
246
|
+
done: this.onDone,
|
|
247
|
+
error: this.onError
|
|
248
|
+
}), this.setScaleFactor(this.currentZoom);
|
|
249
|
+
});
|
|
250
|
+
} else
|
|
251
|
+
this._document = null, this._pages = [], this.hasDocument = !1, this.loading = !1, h(this._pagesEl);
|
|
252
|
+
},
|
|
253
|
+
onDone({
|
|
254
|
+
pdfPages: t,
|
|
255
|
+
pdfDoc: e,
|
|
256
|
+
zoom: o
|
|
257
|
+
}) {
|
|
258
|
+
this._document = e, this._pages = t, this._zoom = o, this.initScroller(), this.loading = !1, this.hasDocument = !0, this.triggerOnLoad(), this._pagesEl && z(this._pagesEl, 0);
|
|
259
|
+
},
|
|
260
|
+
onError(t) {
|
|
261
|
+
this._document = null, this._pages = [], this.loading = !1, this.hasDocument = !1;
|
|
262
|
+
const e = typeof t == "string" ? {
|
|
263
|
+
message: t
|
|
264
|
+
} : t, o = {
|
|
265
|
+
error: e != null ? e : this.localize(Mt),
|
|
266
|
+
target: this.getTarget()
|
|
267
|
+
};
|
|
268
|
+
this.$emit("error", o);
|
|
269
|
+
},
|
|
270
|
+
triggerOnLoad() {
|
|
271
|
+
const t = {
|
|
272
|
+
target: this.getTarget()
|
|
273
|
+
};
|
|
274
|
+
this.$emit("load", t);
|
|
275
|
+
},
|
|
276
|
+
triggerOnDownload(t, e, o) {
|
|
277
|
+
const i = {
|
|
278
|
+
target: this.getTarget(),
|
|
279
|
+
blob: t,
|
|
280
|
+
fileName: e,
|
|
281
|
+
saveOptions: o
|
|
282
|
+
};
|
|
283
|
+
return this.$emit("download", i), !1;
|
|
284
|
+
},
|
|
285
|
+
initScroller() {
|
|
286
|
+
var t;
|
|
287
|
+
this._scroller && this._scroller.destroy(), this._scroller = new dt((t = this._pagesEl) == null ? void 0 : t.parentNode, {
|
|
288
|
+
filter: ".k-page",
|
|
289
|
+
events: {}
|
|
290
|
+
}), this._scroller.disablePanEventsTracking();
|
|
291
|
+
},
|
|
292
|
+
initSearch(t) {
|
|
293
|
+
const e = Array.from(t.querySelectorAll(".k-text-layer"));
|
|
294
|
+
this._search = new ut({
|
|
295
|
+
textContainers: e || [],
|
|
296
|
+
highlightClass: "k-search-highlight",
|
|
297
|
+
highlightMarkClass: "k-search-highlight-mark",
|
|
298
|
+
charClass: "k-text-char"
|
|
299
|
+
});
|
|
300
|
+
},
|
|
301
|
+
reload(t, e, o) {
|
|
302
|
+
this._pagesEl && this._pdfViewerEl && (this.loading = !0, h(this._pagesEl), ht({
|
|
303
|
+
pdfDoc: t,
|
|
304
|
+
zoom: e,
|
|
305
|
+
dom: this._pagesEl,
|
|
306
|
+
done: (i) => {
|
|
307
|
+
this._pages = i, this._zoom = e, this.loading = !1, this._pagesEl && o > 0 && z(this._pagesEl, o);
|
|
308
|
+
},
|
|
309
|
+
error: this.onError
|
|
310
|
+
}));
|
|
311
|
+
},
|
|
312
|
+
onSearchClick() {
|
|
313
|
+
this.showSearch = !0, this.initSearch(this._pagesEl);
|
|
314
|
+
},
|
|
315
|
+
onSearchTextChange(t) {
|
|
316
|
+
const e = t.value, o = this._search.search({
|
|
317
|
+
text: e,
|
|
318
|
+
matchCase: this.matchCase
|
|
319
|
+
});
|
|
320
|
+
this.currentMatch = o.length ? 1 : 0, this.matches = o.length, this.searchText = e;
|
|
321
|
+
},
|
|
322
|
+
onMatchCaseClick() {
|
|
323
|
+
const t = this._search.search({
|
|
324
|
+
text: this.searchText,
|
|
325
|
+
matchCase: !this.matchCase
|
|
326
|
+
});
|
|
327
|
+
this.currentMatch = t.length ? 1 : 0, this.matches = t.length, this.matchCase = !this.matchCase;
|
|
328
|
+
},
|
|
329
|
+
onNextMatch() {
|
|
330
|
+
w({
|
|
331
|
+
search: this._search,
|
|
332
|
+
scroller: this._scroller
|
|
333
|
+
}), this.currentMatch = this.currentMatch + 1 > this.matches ? 1 : this.currentMatch + 1;
|
|
334
|
+
},
|
|
335
|
+
onPrevMatch() {
|
|
336
|
+
ct({
|
|
337
|
+
search: this._search,
|
|
338
|
+
scroller: this._scroller
|
|
339
|
+
}), this.currentMatch = this.currentMatch - 1 < 1 ? this.matches : this.currentMatch - 1;
|
|
340
|
+
},
|
|
341
|
+
onClose() {
|
|
342
|
+
this._search.destroy(), this.currentMatch = 0, this.matches = 0, this.matchCase = !1, this.searchText = "", this.showSearch = !1;
|
|
343
|
+
},
|
|
344
|
+
onTextBoxKeyDown(t) {
|
|
345
|
+
t.key === "Enter" ? (t.preventDefault(), w({
|
|
346
|
+
search: this._search,
|
|
347
|
+
scroller: this._scroller
|
|
348
|
+
}), this.currentMatch = this.currentMatch + 1 > this.matches ? 1 : this.currentMatch + 1) : t.key === "Escape" && this.onClose();
|
|
349
|
+
},
|
|
350
|
+
onPageChange(t) {
|
|
351
|
+
if (this._pagesEl) {
|
|
352
|
+
const e = t.skip;
|
|
353
|
+
z(this._pagesEl, e);
|
|
354
|
+
const o = {
|
|
355
|
+
page: e + 1,
|
|
356
|
+
target: this.getTarget()
|
|
357
|
+
};
|
|
358
|
+
this.$emit("pagechange", o);
|
|
359
|
+
}
|
|
360
|
+
this.skip = t.skip;
|
|
361
|
+
},
|
|
362
|
+
onScroll(t) {
|
|
363
|
+
if (this._pdfViewerEl) {
|
|
364
|
+
const e = nt(this._pdfViewerEl);
|
|
365
|
+
if (e !== this.skip) {
|
|
366
|
+
this.skip = e;
|
|
367
|
+
const o = {
|
|
368
|
+
page: e + 1,
|
|
369
|
+
target: this.getTarget()
|
|
370
|
+
};
|
|
371
|
+
this.$emit("pagechange", o);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
},
|
|
375
|
+
onZoomIn(t) {
|
|
376
|
+
const e = Math.min(this.currentZoom + this.$props.zoomRate, this.$props.maxZoom);
|
|
377
|
+
if (e !== this.currentZoom && this._document) {
|
|
378
|
+
this.stateZoom = e;
|
|
379
|
+
const o = {
|
|
380
|
+
zoom: e,
|
|
381
|
+
target: this.getTarget()
|
|
382
|
+
};
|
|
383
|
+
this.$emit("zoom", o);
|
|
384
|
+
}
|
|
385
|
+
},
|
|
386
|
+
onZoomOut(t) {
|
|
387
|
+
const e = Math.max(this.currentZoom - this.$props.zoomRate, this.$props.minZoom);
|
|
388
|
+
if (e !== this.currentZoom && this._document) {
|
|
389
|
+
this.stateZoom = e;
|
|
390
|
+
const o = {
|
|
391
|
+
zoom: e,
|
|
392
|
+
target: this.getTarget()
|
|
393
|
+
};
|
|
394
|
+
this.$emit("zoom", o);
|
|
395
|
+
}
|
|
396
|
+
},
|
|
397
|
+
onZoomLevelChange(t) {
|
|
398
|
+
const e = t.value === null ? {
|
|
399
|
+
text: "100%",
|
|
400
|
+
value: 1
|
|
401
|
+
} : {
|
|
402
|
+
...t.value
|
|
403
|
+
};
|
|
404
|
+
if (e.value === void 0) {
|
|
405
|
+
const i = Number.parseFloat(e.text);
|
|
406
|
+
typeof i == "number" && !Number.isNaN(i) ? e.value = i / 100 : e.value = 1;
|
|
407
|
+
}
|
|
408
|
+
let o = e ? lt(e.value, e.type, this.currentZoom, this._pagesEl) : 1;
|
|
409
|
+
if (o = Math.round(o * 100) / 100, this.currentZoom !== o && this._document) {
|
|
410
|
+
this.stateZoom = o;
|
|
411
|
+
const i = {
|
|
412
|
+
zoom: o,
|
|
413
|
+
target: this.getTarget()
|
|
414
|
+
};
|
|
415
|
+
this.$emit("zoom", i);
|
|
416
|
+
}
|
|
417
|
+
},
|
|
418
|
+
onTextSelection() {
|
|
419
|
+
this._scroller.disablePanEventsTracking(), this.enabledSelection = !0;
|
|
420
|
+
},
|
|
421
|
+
onPinning() {
|
|
422
|
+
this._scroller.enablePanEventsTracking(), this.enabledSelection = !1;
|
|
423
|
+
},
|
|
424
|
+
onDownloadClick() {
|
|
425
|
+
rt({
|
|
426
|
+
pdf: this._document,
|
|
427
|
+
error: this.onError
|
|
428
|
+
}, this.$props.saveFileName, this.$props.saveOptions, this.triggerOnDownload);
|
|
429
|
+
},
|
|
430
|
+
onPrintClick() {
|
|
431
|
+
this.loading = !0;
|
|
432
|
+
const t = (o) => {
|
|
433
|
+
this.loading = !1, this.onError(o);
|
|
434
|
+
}, e = () => {
|
|
435
|
+
this.loading = !1;
|
|
436
|
+
};
|
|
437
|
+
at(this._pages, e, t);
|
|
438
|
+
},
|
|
439
|
+
onAdd(t) {
|
|
440
|
+
var o;
|
|
441
|
+
const e = t.newState;
|
|
442
|
+
(o = e[0]) != null && o.getRawFile && e[0].getRawFile().arrayBuffer().then((c) => {
|
|
443
|
+
if (this._pagesEl) {
|
|
444
|
+
this.loading = !0, h(this._pagesEl);
|
|
445
|
+
const r = this.$props.zoom === void 0 ? this.$props.defaultZoom : this.$props.zoom;
|
|
446
|
+
C({
|
|
447
|
+
arrayBuffer: c,
|
|
448
|
+
dom: this._pagesEl,
|
|
449
|
+
zoom: r,
|
|
450
|
+
done: this.onDone,
|
|
451
|
+
error: this.onError
|
|
452
|
+
}), this.stateZoom = r;
|
|
453
|
+
}
|
|
454
|
+
});
|
|
455
|
+
},
|
|
456
|
+
onFileOpen(t) {
|
|
457
|
+
const e = t.target;
|
|
458
|
+
if (e instanceof Element && e.parentNode) {
|
|
459
|
+
const o = e.closest(".k-toolbar"), i = o == null ? void 0 : o.querySelector(".k-upload input");
|
|
460
|
+
i && i.click();
|
|
461
|
+
}
|
|
462
|
+
},
|
|
463
|
+
renderLoader() {
|
|
464
|
+
return this.loading ? s("div", {
|
|
465
|
+
class: "k-loader-container k-loader-container-md k-loader-top"
|
|
466
|
+
}, [s("div", {
|
|
467
|
+
class: "k-overlay"
|
|
468
|
+
}, null), s("div", {
|
|
469
|
+
class: "k-loader-container-inner "
|
|
470
|
+
}, [s(V, {
|
|
471
|
+
size: "large"
|
|
472
|
+
}, null)])]) : null;
|
|
473
|
+
},
|
|
474
|
+
renderToolbar() {
|
|
475
|
+
const t = s(F, {
|
|
476
|
+
previousNext: !0,
|
|
477
|
+
type: "input",
|
|
478
|
+
skip: this.skip,
|
|
479
|
+
take: 1,
|
|
480
|
+
total: this._pages ? this._pages.length : 0,
|
|
481
|
+
info: !1,
|
|
482
|
+
onPagechange: this.onPageChange
|
|
483
|
+
}, null), e = s(I, null, null), o = s(y, {
|
|
484
|
+
class: "k-toolbar-button-group k-button-group-solid"
|
|
485
|
+
}, {
|
|
486
|
+
default: () => [s(a, {
|
|
487
|
+
class: "k-group-start",
|
|
488
|
+
fillMode: "flat",
|
|
489
|
+
themeColor: "base",
|
|
490
|
+
title: this.localize(yt),
|
|
491
|
+
disabled: this.currentZoom <= this.$props.minZoom || !this.hasDocument,
|
|
492
|
+
onClick: this.onZoomOut,
|
|
493
|
+
icon: "zoom-out",
|
|
494
|
+
svgIcon: H
|
|
495
|
+
}, null), s(a, {
|
|
496
|
+
class: "k-group-end",
|
|
497
|
+
fillMode: "flat",
|
|
498
|
+
themeColor: "base",
|
|
499
|
+
title: this.localize(xt),
|
|
500
|
+
disabled: this.currentZoom >= this.$props.maxZoom || !this.hasDocument,
|
|
501
|
+
onClick: this.onZoomIn,
|
|
502
|
+
icon: "zoom-in",
|
|
503
|
+
svgIcon: J
|
|
504
|
+
}, null)]
|
|
505
|
+
}), i = s(R, {
|
|
506
|
+
class: "k-toolbar-combobox",
|
|
507
|
+
disabled: !this.hasDocument,
|
|
508
|
+
dataItems: this.$props.zoomLevels.map((l) => ({
|
|
509
|
+
...l,
|
|
510
|
+
text: l.locationString ? this.localize(l.locationString) : l.text
|
|
511
|
+
})),
|
|
512
|
+
dataItemKey: "id",
|
|
513
|
+
textField: "text",
|
|
514
|
+
value: this.hasDocument ? this.currentZoomLevel : null,
|
|
515
|
+
allowCustom: !0,
|
|
516
|
+
onChange: this.onZoomLevelChange,
|
|
517
|
+
placeholder: this.localize(Ct)
|
|
518
|
+
}, null), c = s(y, {
|
|
519
|
+
class: "k-toolbar-button-group k-button-group-solid"
|
|
520
|
+
}, {
|
|
521
|
+
default: () => [s(a, {
|
|
522
|
+
class: "k-group-start",
|
|
523
|
+
fillMode: "flat",
|
|
524
|
+
themeColor: "base",
|
|
525
|
+
title: this.localize(wt),
|
|
526
|
+
icon: "pointer",
|
|
527
|
+
svgIcon: Q,
|
|
528
|
+
disabled: !this.hasDocument,
|
|
529
|
+
togglable: !0,
|
|
530
|
+
selected: this.enabledSelection && this.hasDocument,
|
|
531
|
+
onClick: this.onTextSelection
|
|
532
|
+
}, null), s(a, {
|
|
533
|
+
class: "k-group-end",
|
|
534
|
+
fillMode: "flat",
|
|
535
|
+
themeColor: "base",
|
|
536
|
+
title: this.localize(St),
|
|
537
|
+
icon: "hand",
|
|
538
|
+
svgIcon: X,
|
|
539
|
+
disabled: !this.hasDocument,
|
|
540
|
+
togglable: !0,
|
|
541
|
+
selected: !this.enabledSelection && this.hasDocument,
|
|
542
|
+
onClick: this.onPinning
|
|
543
|
+
}, null)]
|
|
544
|
+
}), r = s(a, {
|
|
545
|
+
class: "k-toolbar-button",
|
|
546
|
+
fillMode: "flat",
|
|
547
|
+
themeColor: "base",
|
|
548
|
+
title: this.localize(S),
|
|
549
|
+
icon: "search",
|
|
550
|
+
svgIcon: Y,
|
|
551
|
+
disabled: !this.hasDocument,
|
|
552
|
+
onClick: this.onSearchClick,
|
|
553
|
+
"aria-haspopup": "dialog"
|
|
554
|
+
}, null), u = s("span", null, [s(a, {
|
|
555
|
+
class: "k-toolbar-button",
|
|
556
|
+
fillMode: "flat",
|
|
557
|
+
themeColor: "base",
|
|
558
|
+
title: this.localize(Et),
|
|
559
|
+
icon: "folder-open",
|
|
560
|
+
svgIcon: tt,
|
|
561
|
+
onClick: this.onFileOpen
|
|
562
|
+
}, null), s("div", {
|
|
563
|
+
style: {
|
|
564
|
+
display: "none"
|
|
565
|
+
}
|
|
566
|
+
}, [s(N, {
|
|
567
|
+
restrictions: {
|
|
568
|
+
allowedExtensions: [".pdf"]
|
|
569
|
+
},
|
|
570
|
+
onAdd: this.onAdd,
|
|
571
|
+
autoUpload: !1,
|
|
572
|
+
defaultFiles: [],
|
|
573
|
+
multiple: !1,
|
|
574
|
+
accept: ".pdf,.PDF",
|
|
575
|
+
withCredentials: !1
|
|
576
|
+
}, null)])]), d = s(a, {
|
|
577
|
+
class: "k-toolbar-button",
|
|
578
|
+
fillMode: "flat",
|
|
579
|
+
themeColor: "base",
|
|
580
|
+
title: this.localize(Tt),
|
|
581
|
+
icon: "download",
|
|
582
|
+
svgIcon: et,
|
|
583
|
+
disabled: !this.hasDocument,
|
|
584
|
+
onClick: this.onDownloadClick
|
|
585
|
+
}, null), p = s(a, {
|
|
586
|
+
class: "k-toolbar-button",
|
|
587
|
+
fillMode: "flat",
|
|
588
|
+
themeColor: "base",
|
|
589
|
+
title: this.localize(Zt),
|
|
590
|
+
icon: "print",
|
|
591
|
+
svgIcon: ot,
|
|
592
|
+
disabled: !this.hasDocument,
|
|
593
|
+
onClick: this.onPrintClick
|
|
594
|
+
}, null), m = {
|
|
595
|
+
pager: t,
|
|
596
|
+
spacer: e,
|
|
597
|
+
zoomInOut: o,
|
|
598
|
+
zoom: i,
|
|
599
|
+
selection: c,
|
|
600
|
+
search: r,
|
|
601
|
+
open: u,
|
|
602
|
+
download: d,
|
|
603
|
+
print: p
|
|
604
|
+
}, g = (this.$props.tools || n.tools).map((l) => m[l]);
|
|
605
|
+
return s(L, {
|
|
606
|
+
buttons: It,
|
|
607
|
+
overflow: "none",
|
|
608
|
+
class: "k-pdf-viewer-toolbar",
|
|
609
|
+
dir: this.currentDir
|
|
610
|
+
}, $t(g) ? g : {
|
|
611
|
+
default: () => [g]
|
|
612
|
+
});
|
|
613
|
+
},
|
|
614
|
+
renderContent() {
|
|
615
|
+
const t = () => s(D, null, [s(O, null, null), s("span", {
|
|
616
|
+
class: "k-input-suffix"
|
|
617
|
+
}, [s(a, {
|
|
618
|
+
icon: "convert-lowercase",
|
|
619
|
+
svgIcon: st,
|
|
620
|
+
title: this.localize(Dt),
|
|
621
|
+
fillMode: "flat",
|
|
622
|
+
togglable: !0,
|
|
623
|
+
selected: this.matchCase,
|
|
624
|
+
onClick: this.onMatchCaseClick
|
|
625
|
+
}, null)])]);
|
|
626
|
+
return s("div", {
|
|
627
|
+
class: A("k-canvas k-pdf-viewer-canvas k-pos-relative k-overflow-auto", {
|
|
628
|
+
"k-enable-text-select": this.enabledSelection,
|
|
629
|
+
"k-enable-panning": !this.enabledSelection
|
|
630
|
+
}),
|
|
631
|
+
tabindex: 0,
|
|
632
|
+
role: "document",
|
|
633
|
+
"aria-label": this.localize(ft),
|
|
634
|
+
onScroll: this.onScroll
|
|
635
|
+
}, [this.showSearch ? s("div", {
|
|
636
|
+
class: "k-search-panel k-pos-sticky k-top-center",
|
|
637
|
+
role: "dialog",
|
|
638
|
+
"aria-label": this.localize(vt)
|
|
639
|
+
}, [s(P, {
|
|
640
|
+
value: this.searchText,
|
|
641
|
+
onInput: this.onSearchTextChange,
|
|
642
|
+
placeholder: this.localize(S),
|
|
643
|
+
onKeydown: this.onTextBoxKeyDown,
|
|
644
|
+
suffix: t
|
|
645
|
+
}, null), s("span", {
|
|
646
|
+
class: "k-search-matches"
|
|
647
|
+
}, [s("span", null, [this.currentMatch]), M(" "), this.localize(bt), s("span", null, [this.matches])]), s(a, {
|
|
648
|
+
title: this.localize(kt),
|
|
649
|
+
fillMode: "flat",
|
|
650
|
+
icon: "arrow-up",
|
|
651
|
+
svgIcon: K,
|
|
652
|
+
disabled: this.matches === 0,
|
|
653
|
+
onClick: this.onPrevMatch
|
|
654
|
+
}, null), s(a, {
|
|
655
|
+
title: this.localize(_t),
|
|
656
|
+
fillMode: "flat",
|
|
657
|
+
icon: "arrow-down",
|
|
658
|
+
svgIcon: q,
|
|
659
|
+
disabled: this.matches === 0,
|
|
660
|
+
onClick: this.onNextMatch
|
|
661
|
+
}, null), s(a, {
|
|
662
|
+
title: this.localize(zt),
|
|
663
|
+
fillMode: "flat",
|
|
664
|
+
icon: "x",
|
|
665
|
+
svgIcon: G,
|
|
666
|
+
onClick: this.onClose
|
|
667
|
+
}, null)]) : null, s("div", {
|
|
668
|
+
ref: (e) => {
|
|
669
|
+
this._pagesEl = e;
|
|
670
|
+
},
|
|
671
|
+
class: "k-pdf-viewer-pages"
|
|
672
|
+
}, null)]);
|
|
673
|
+
}
|
|
674
|
+
},
|
|
675
|
+
render() {
|
|
676
|
+
const t = this.renderLoader(), e = this.renderToolbar(), o = this.renderContent(), i = v.call(this, this.$props.toolbar, b.call(this)), c = v.call(this, this.$props.content, b.call(this)), r = v.call(this, this.$props.loader, b.call(this)), u = k.call(this, {
|
|
677
|
+
h: f,
|
|
678
|
+
template: i,
|
|
679
|
+
defaultRendering: e,
|
|
680
|
+
additionalProps: {
|
|
681
|
+
defaultRendering: e
|
|
682
|
+
}
|
|
683
|
+
}), d = k.call(this, {
|
|
684
|
+
h: f,
|
|
685
|
+
template: c,
|
|
686
|
+
defaultRendering: o,
|
|
687
|
+
additionalProps: {
|
|
688
|
+
defaultRendering: o
|
|
689
|
+
}
|
|
690
|
+
}), p = k.call(this, {
|
|
691
|
+
h: f,
|
|
692
|
+
template: r,
|
|
693
|
+
defaultRendering: t,
|
|
694
|
+
additionalProps: {
|
|
695
|
+
defaultRendering: t
|
|
696
|
+
}
|
|
697
|
+
});
|
|
698
|
+
return s("div", {
|
|
699
|
+
class: "k-pdf-viewer",
|
|
700
|
+
dir: this.$props.dir,
|
|
701
|
+
ref: (m) => {
|
|
702
|
+
this._pdfViewerEl = m;
|
|
703
|
+
}
|
|
704
|
+
}, [p, u, d, this.showLicenseWatermark ? s(B, {
|
|
705
|
+
message: this._licenseMessage
|
|
706
|
+
}, null) : null]);
|
|
707
|
+
}
|
|
708
|
+
});
|
|
709
|
+
export {
|
|
710
|
+
Gt as PDFViewer
|
|
711
|
+
};
|