@vaadin-component-factory/vcf-pdf-viewer 1.0.1 → 1.1.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/package.json +1 -1
- package/src/vcf-pdf-viewer.js +42 -12
package/package.json
CHANGED
package/src/vcf-pdf-viewer.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { PolymerElement, html } from '@polymer/polymer/polymer-element';
|
|
2
2
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin';
|
|
3
3
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
4
|
-
import { IronResizableBehavior } from '@polymer/iron-resizable-behavior';
|
|
5
|
-
import { mixinBehaviors } from '@polymer/polymer/lib/legacy/class.js';
|
|
6
4
|
import '@vaadin/polymer-legacy-adapter/template-renderer.js';
|
|
7
5
|
import '@vaadin/text-field';
|
|
8
6
|
import '@vaadin/select';
|
|
@@ -34,8 +32,7 @@ pdfjsLib.GlobalWorkerOptions.workerSrc = pdfjsWorker;
|
|
|
34
32
|
*/
|
|
35
33
|
class PdfViewerElement extends
|
|
36
34
|
ElementMixin(
|
|
37
|
-
ThemableMixin(
|
|
38
|
-
mixinBehaviors([IronResizableBehavior], PolymerElement))) {
|
|
35
|
+
ThemableMixin(PolymerElement)) {
|
|
39
36
|
|
|
40
37
|
static get template() {
|
|
41
38
|
return html`
|
|
@@ -255,8 +252,8 @@ class PdfViewerElement extends
|
|
|
255
252
|
<vaadin-select id="zoom" part="toolbar-zoom" value="{{zoom}}">
|
|
256
253
|
<template>
|
|
257
254
|
<vaadin-list-box>
|
|
258
|
-
<vaadin-item value='auto'>
|
|
259
|
-
<vaadin-item value='page-fit'>
|
|
255
|
+
<vaadin-item value='auto'>{{autoZoomOptionLabel}}</vaadin-item>
|
|
256
|
+
<vaadin-item value='page-fit'>{{fitZoomOptionLabel}}</vaadin-item>
|
|
260
257
|
<vaadin-item value='0.5'>50%</vaadin-item>
|
|
261
258
|
<vaadin-item value='0.75'>75%</vaadin-item>
|
|
262
259
|
<vaadin-item value='1.0'>100%</vaadin-item>
|
|
@@ -292,7 +289,7 @@ class PdfViewerElement extends
|
|
|
292
289
|
}
|
|
293
290
|
|
|
294
291
|
static get version() {
|
|
295
|
-
return '1.
|
|
292
|
+
return '1.1.0';
|
|
296
293
|
}
|
|
297
294
|
|
|
298
295
|
static get properties() {
|
|
@@ -382,6 +379,30 @@ class PdfViewerElement extends
|
|
|
382
379
|
type: Boolean,
|
|
383
380
|
value: false
|
|
384
381
|
},
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Flag to indicate if toolbar should only show filename as title
|
|
385
|
+
*/
|
|
386
|
+
toolbarOnlyFilename: {
|
|
387
|
+
type: Boolean,
|
|
388
|
+
value: false
|
|
389
|
+
},
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Property to define auto zoom label
|
|
393
|
+
*/
|
|
394
|
+
autoZoomOptionLabel: {
|
|
395
|
+
type: String,
|
|
396
|
+
value: "Automatic zoom"
|
|
397
|
+
},
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Property to define page fit zoom label
|
|
401
|
+
*/
|
|
402
|
+
fitZoomOptionLabel: {
|
|
403
|
+
type: String,
|
|
404
|
+
value: "Page fit"
|
|
405
|
+
},
|
|
385
406
|
};
|
|
386
407
|
}
|
|
387
408
|
|
|
@@ -392,7 +413,9 @@ class PdfViewerElement extends
|
|
|
392
413
|
}
|
|
393
414
|
|
|
394
415
|
__setTitle(pdfTitle, filename) {
|
|
395
|
-
if
|
|
416
|
+
if(this.__viewer && this.toolbarOnlyFilename && filename) {
|
|
417
|
+
this.__title = filename;
|
|
418
|
+
} else if (pdfTitle && filename) {
|
|
396
419
|
this.__title = pdfTitle + ' - ' + filename;
|
|
397
420
|
} else if (pdfTitle) {
|
|
398
421
|
this.__title = pdfTitle;
|
|
@@ -401,7 +424,7 @@ class PdfViewerElement extends
|
|
|
401
424
|
} else {
|
|
402
425
|
this.__title = 'PDF';
|
|
403
426
|
}
|
|
404
|
-
|
|
427
|
+
}
|
|
405
428
|
|
|
406
429
|
ready() {
|
|
407
430
|
super.ready();
|
|
@@ -469,8 +492,15 @@ class PdfViewerElement extends
|
|
|
469
492
|
}
|
|
470
493
|
});
|
|
471
494
|
|
|
472
|
-
this.
|
|
473
|
-
|
|
495
|
+
this.__resizeObserver = new ResizeObserver(() => {
|
|
496
|
+
requestAnimationFrame(() => this.__recalculateSizes());
|
|
497
|
+
});
|
|
498
|
+
this.__resizeObserver.observe(this);
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
connectedCallback() {
|
|
502
|
+
super.connectedCallback();
|
|
503
|
+
this.__recalculateSizes();
|
|
474
504
|
}
|
|
475
505
|
|
|
476
506
|
__updateCurrentPageValue(pageNumber){
|
|
@@ -513,7 +543,7 @@ class PdfViewerElement extends
|
|
|
513
543
|
return;
|
|
514
544
|
}
|
|
515
545
|
this.__setFilename(src);
|
|
516
|
-
this.__document = pdfjsLib.getDocument(src);
|
|
546
|
+
this.__document = pdfjsLib.getDocument(new URL(src, document.baseURI).href);
|
|
517
547
|
return this.__document.promise.then((pdfDocument) => {
|
|
518
548
|
// Document loaded, specifying document for the viewer.
|
|
519
549
|
this.__thumbnailViewer.setDocument(pdfDocument);
|