@vertexvis/doc-viewer 1.0.2-testing.0 → 1.0.2-testing.1
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/cjs/vertex-document-viewer.cjs.entry.js +19 -32
- package/dist/collection/__mocks__/pdfjs-mock.js +2 -1
- package/dist/collection/components/document-viewer/document-viewer.css +11 -0
- package/dist/collection/components/document-viewer/document-viewer.js +6 -18
- package/dist/collection/lib/document/layers/controller.js +0 -12
- package/dist/collection/lib/dom.js +3 -0
- package/dist/collection/lib/pdf/pdfjs-renderer.js +10 -1
- package/dist/components/vertex-document-viewer.js +2 -2
- package/dist/doc-viewer/doc-viewer.esm.js +1 -1
- package/dist/doc-viewer/{p-d397d116.entry.js → p-96109c78.entry.js} +2 -2
- package/dist/esm/vertex-document-viewer.entry.js +19 -32
- package/dist/types/__mocks__/pdfjs-mock.d.ts +2 -2
- package/dist/types/components/document-viewer/document-viewer.d.ts +0 -1
- package/dist/types/lib/document/layers/controller.d.ts +1 -3
- package/dist/types/lib/dom.d.ts +1 -0
- package/package.json +4 -4
|
@@ -604,22 +604,10 @@ function apiSupportsLayers(api) {
|
|
|
604
604
|
class DocumentLayersController {
|
|
605
605
|
constructor(api) {
|
|
606
606
|
this.apiSupportsLayers = false;
|
|
607
|
-
if (api != null) {
|
|
608
|
-
this.setApi(api);
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
setApi(api) {
|
|
612
607
|
if (apiSupportsLayers(api)) {
|
|
613
608
|
this.apiSupportsLayers = true;
|
|
614
609
|
this.api = api;
|
|
615
610
|
}
|
|
616
|
-
else {
|
|
617
|
-
this.clear();
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
clear() {
|
|
621
|
-
this.apiSupportsLayers = false;
|
|
622
|
-
this.api = undefined;
|
|
623
611
|
}
|
|
624
612
|
/**
|
|
625
613
|
* Returns a boolean indicating whether the document supports layers.
|
|
@@ -654,6 +642,9 @@ class DocumentLayersController {
|
|
|
654
642
|
function getElementBoundingClientRect(element) {
|
|
655
643
|
return element.getBoundingClientRect();
|
|
656
644
|
}
|
|
645
|
+
function createElement(tagName) {
|
|
646
|
+
return document.createElement(tagName);
|
|
647
|
+
}
|
|
657
648
|
function getAllVertexElementChildren(element) {
|
|
658
649
|
return getAllChildren(element)
|
|
659
650
|
.filter(node => node.nodeName.startsWith('VERTEX-'))
|
|
@@ -34536,7 +34527,7 @@ class PdfJsRenderer extends DocumentRenderer {
|
|
|
34536
34527
|
this.state = { pages: {}, rendering: false };
|
|
34537
34528
|
// Render pages using an offscreen canvas to avoid flickering that can occur for
|
|
34538
34529
|
// PDFs with annotations.
|
|
34539
|
-
this.offscreenCanvas =
|
|
34530
|
+
this.offscreenCanvas = createElement('canvas');
|
|
34540
34531
|
this.handleStateChanged = this.handleStateChanged.bind(this);
|
|
34541
34532
|
this.stateChangedDisposable = this.api.onStateChanged(this.handleStateChanged);
|
|
34542
34533
|
}
|
|
@@ -34578,10 +34569,18 @@ class PdfJsRenderer extends DocumentRenderer {
|
|
|
34578
34569
|
});
|
|
34579
34570
|
this.offscreenCanvas.width = this.canvas.width;
|
|
34580
34571
|
this.offscreenCanvas.height = this.canvas.height;
|
|
34572
|
+
const offscreenCanvasCtx = this.offscreenCanvas.getContext('2d');
|
|
34573
|
+
// Fill the offscreen canvas with a white background prior to rendering the page to give the content
|
|
34574
|
+
// of the PDF a white background, but maintain the canvas it gets drawn to when copying to the main canvas.
|
|
34575
|
+
if (offscreenCanvasCtx != null) {
|
|
34576
|
+
offscreenCanvasCtx.fillStyle = '#ffffff';
|
|
34577
|
+
offscreenCanvasCtx.fillRect(panOffset.x + centerOffsetX, panOffset.y, scaled.width, scaled.height);
|
|
34578
|
+
}
|
|
34581
34579
|
await page.render({
|
|
34582
34580
|
canvas: this.offscreenCanvas,
|
|
34583
34581
|
viewport: scaled,
|
|
34584
34582
|
intent: 'display',
|
|
34583
|
+
background: 'transparent',
|
|
34585
34584
|
optionalContentConfigPromise: optionalContentConfig != null ? Promise.resolve(optionalContentConfig) : undefined,
|
|
34586
34585
|
}).promise;
|
|
34587
34586
|
// Emit an event before the page is drawn, then draw the page to the canvas on the next
|
|
@@ -34611,7 +34610,7 @@ class PdfJsProvider {
|
|
|
34611
34610
|
}
|
|
34612
34611
|
}
|
|
34613
34612
|
|
|
34614
|
-
const documentViewerCss = () => `:host{display:block;position:relative;width:300px;height:300px;min-width:1px;min-height:1px;user-select:none;-webkit-user-select:none}.viewer-container{width:100%;height:100%;overflow:hidden}.canvas-container{display:flex;justify-content:center;align-items:center;width:100%;height:100%;position:relative}`;
|
|
34613
|
+
const documentViewerCss = () => `:host{display:block;position:relative;width:300px;height:300px;min-width:1px;min-height:1px;user-select:none;-webkit-user-select:none;--viewer-background:#cccccc}.viewer-container{width:100%;height:100%;overflow:hidden}.canvas-container{display:flex;justify-content:center;align-items:center;width:100%;height:100%;position:relative}#document-viewer-canvas{background-color:var(--viewer-background)}`;
|
|
34615
34614
|
|
|
34616
34615
|
const VertexDocumentViewer = class {
|
|
34617
34616
|
constructor(hostRef) {
|
|
@@ -34643,7 +34642,6 @@ const VertexDocumentViewer = class {
|
|
|
34643
34642
|
this.handleDocumentApiStateChanged = this.handleDocumentApiStateChanged.bind(this);
|
|
34644
34643
|
this.handlePageLoaded = this.handlePageLoaded.bind(this);
|
|
34645
34644
|
this.handlePageDrawn = this.handlePageDrawn.bind(this);
|
|
34646
|
-
this.layers = new DocumentLayersController();
|
|
34647
34645
|
this.resizeObserver = new ResizeObserver(this.handleElementResize);
|
|
34648
34646
|
this.registerSlotChangeListeners();
|
|
34649
34647
|
}
|
|
@@ -34656,7 +34654,7 @@ const VertexDocumentViewer = class {
|
|
|
34656
34654
|
var _a;
|
|
34657
34655
|
(_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.observe(this.hostEl);
|
|
34658
34656
|
this.updateComponentDimensions();
|
|
34659
|
-
this.
|
|
34657
|
+
this.handleSrcChange();
|
|
34660
34658
|
this.injectViewerApi();
|
|
34661
34659
|
}
|
|
34662
34660
|
disconnectedCallback() {
|
|
@@ -34723,13 +34721,12 @@ const VertexDocumentViewer = class {
|
|
|
34723
34721
|
await documentApi.loadPage(pageNumber);
|
|
34724
34722
|
}
|
|
34725
34723
|
async handleSrcChange() {
|
|
34726
|
-
var _a;
|
|
34727
34724
|
if (this.src != null && this.canvasEl != null) {
|
|
34728
34725
|
this.clearCurrentDocument();
|
|
34729
34726
|
const { api, renderer } = this.provider.create(this.canvasEl, this.config);
|
|
34730
34727
|
this.documentApi = api;
|
|
34731
34728
|
this.documentRenderer = renderer;
|
|
34732
|
-
|
|
34729
|
+
this.layers = new DocumentLayersController(api);
|
|
34733
34730
|
this.updateInteractionHandler();
|
|
34734
34731
|
this.updateDocumentApiListeners();
|
|
34735
34732
|
await this.documentApi.updateViewport(this.dimensions);
|
|
@@ -34746,9 +34743,9 @@ const VertexDocumentViewer = class {
|
|
|
34746
34743
|
this.updateInteractionHandler();
|
|
34747
34744
|
}
|
|
34748
34745
|
render() {
|
|
34749
|
-
return (h(Host, { key: '
|
|
34746
|
+
return (h(Host, { key: 'f1ddf0b4e321bc244a5d757e48f6d71c23caca3c' }, h("div", { key: '174c64c537f4b0f1c45fc6543e5b7f54515e4063', ref: ref => (this.viewerContainerElement = ref), class: "viewer-container", onContextMenu: event => event.preventDefault() }, h("div", { key: '4c47dadba03b32bde017252a9a8ea7f6e6d323f3', ref: ref => (this.canvasContainerElement = ref), class: classNames('canvas-container', {
|
|
34750
34747
|
'enable-pointer-events ': window.PointerEvent != null,
|
|
34751
|
-
}) }, h("canvas", { key: '
|
|
34748
|
+
}) }, h("canvas", { key: 'ae645889dd5cb93084f820f9f3d14a56de0213f7', id: "document-viewer-canvas", role: "presentation", ref: el => (this.canvasEl = el) })), h("slot", { key: '7762c493306bf5d21cd16218f1abd3c6d0300ace' }))));
|
|
34752
34749
|
}
|
|
34753
34750
|
getDocumentApi() {
|
|
34754
34751
|
if (this.documentApi == null) {
|
|
@@ -34756,25 +34753,15 @@ const VertexDocumentViewer = class {
|
|
|
34756
34753
|
}
|
|
34757
34754
|
return this.documentApi;
|
|
34758
34755
|
}
|
|
34759
|
-
async loadInitialSrc() {
|
|
34760
|
-
await Promise.resolve();
|
|
34761
|
-
await this.handleSrcChange();
|
|
34762
|
-
}
|
|
34763
34756
|
clearCurrentDocument() {
|
|
34764
|
-
var _a, _b, _c, _d, _e, _f
|
|
34757
|
+
var _a, _b, _c, _d, _e, _f;
|
|
34765
34758
|
(_a = this.documentRenderer) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
34766
34759
|
(_b = this.documentApi) === null || _b === void 0 ? void 0 : _b.dispose();
|
|
34767
34760
|
(_c = this.panInteractionHandler) === null || _c === void 0 ? void 0 : _c.dispose();
|
|
34768
34761
|
(_d = this.documentApiStateChangedDisposable) === null || _d === void 0 ? void 0 : _d.dispose();
|
|
34769
34762
|
(_e = this.pageLoadedDisposable) === null || _e === void 0 ? void 0 : _e.dispose();
|
|
34770
34763
|
(_f = this.pageDrawnDisposable) === null || _f === void 0 ? void 0 : _f.dispose();
|
|
34771
|
-
this.
|
|
34772
|
-
this.documentApi = undefined;
|
|
34773
|
-
this.panInteractionHandler = undefined;
|
|
34774
|
-
this.documentApiStateChangedDisposable = undefined;
|
|
34775
|
-
this.pageLoadedDisposable = undefined;
|
|
34776
|
-
this.pageDrawnDisposable = undefined;
|
|
34777
|
-
(_g = this.layers) === null || _g === void 0 ? void 0 : _g.clear();
|
|
34764
|
+
this.layers = undefined;
|
|
34778
34765
|
}
|
|
34779
34766
|
handleDocumentApiStateChanged(state) {
|
|
34780
34767
|
this.documentState = state;
|
|
@@ -8,14 +8,14 @@ export declare const mockGetViewport: jest.Mock<{
|
|
|
8
8
|
}, [], any>;
|
|
9
9
|
export declare const mockPageRender: jest.Mock<{
|
|
10
10
|
promise: Promise<void>;
|
|
11
|
-
}, [], any>;
|
|
11
|
+
}, [args: any], any>;
|
|
12
12
|
export declare const mockGetPage: jest.Mock<{
|
|
13
13
|
getTextContent: jest.Mock<{
|
|
14
14
|
items: never[];
|
|
15
15
|
}, [], any>;
|
|
16
16
|
render: jest.Mock<{
|
|
17
17
|
promise: Promise<void>;
|
|
18
|
-
}, [], any>;
|
|
18
|
+
}, [args: any], any>;
|
|
19
19
|
getViewport: jest.Mock<{
|
|
20
20
|
width: number;
|
|
21
21
|
height: number;
|
|
@@ -134,7 +134,6 @@ export declare class VertexDocumentViewer implements BasicViewer {
|
|
|
134
134
|
protected handleInteractionModeChange(): void;
|
|
135
135
|
render(): void;
|
|
136
136
|
private getDocumentApi;
|
|
137
|
-
private loadInitialSrc;
|
|
138
137
|
private clearCurrentDocument;
|
|
139
138
|
private handleDocumentApiStateChanged;
|
|
140
139
|
private handlePageLoaded;
|
|
@@ -3,9 +3,7 @@ import { DocumentLayer } from './types';
|
|
|
3
3
|
export declare class DocumentLayersController {
|
|
4
4
|
private apiSupportsLayers;
|
|
5
5
|
private api?;
|
|
6
|
-
constructor(api
|
|
7
|
-
setApi(api: DocumentApi): void;
|
|
8
|
-
clear(): void;
|
|
6
|
+
constructor(api: DocumentApi);
|
|
9
7
|
/**
|
|
10
8
|
* Returns a boolean indicating whether the document supports layers.
|
|
11
9
|
*/
|
package/dist/types/lib/dom.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vertexvis/doc-viewer",
|
|
3
|
-
"version": "1.0.2-testing.
|
|
3
|
+
"version": "1.0.2-testing.1",
|
|
4
4
|
"description": "The Vertex SDK for viewing documents.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -95,11 +95,11 @@
|
|
|
95
95
|
"typescript": "~5.9.3"
|
|
96
96
|
},
|
|
97
97
|
"dependencies": {
|
|
98
|
-
"@vertexvis/geometry": "1.0.2-testing.
|
|
99
|
-
"@vertexvis/utils": "1.0.2-testing.
|
|
98
|
+
"@vertexvis/geometry": "1.0.2-testing.1",
|
|
99
|
+
"@vertexvis/utils": "1.0.2-testing.1",
|
|
100
100
|
"classnames": "^2.5.1",
|
|
101
101
|
"pdfjs-dist": "^5.5.207",
|
|
102
102
|
"resize-observer": "^1.0.4"
|
|
103
103
|
},
|
|
104
|
-
"gitHead": "
|
|
104
|
+
"gitHead": "d28706dda29e84edaec7c7f2a5781bf619e2f112"
|
|
105
105
|
}
|