@vertexvis/doc-viewer 1.0.2-testing.3 → 1.0.2-testing.4
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 +31 -7
- package/dist/collection/components/document-viewer/document-viewer.css +2 -2
- package/dist/collection/components/document-viewer/document-viewer.js +18 -6
- package/dist/collection/lib/document/layers/controller.js +12 -0
- package/dist/components/vertex-document-viewer.js +2 -2
- package/dist/doc-viewer/doc-viewer.esm.js +1 -1
- package/dist/doc-viewer/{p-96109c78.entry.js → p-d55c9d5e.entry.js} +2 -2
- package/dist/esm/vertex-document-viewer.entry.js +31 -7
- package/dist/types/components/document-viewer/document-viewer.d.ts +1 -0
- package/dist/types/lib/document/layers/controller.d.ts +3 -1
- package/package.json +4 -4
|
@@ -604,10 +604,22 @@ 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) {
|
|
607
612
|
if (apiSupportsLayers(api)) {
|
|
608
613
|
this.apiSupportsLayers = true;
|
|
609
614
|
this.api = api;
|
|
610
615
|
}
|
|
616
|
+
else {
|
|
617
|
+
this.clear();
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
clear() {
|
|
621
|
+
this.apiSupportsLayers = false;
|
|
622
|
+
this.api = undefined;
|
|
611
623
|
}
|
|
612
624
|
/**
|
|
613
625
|
* Returns a boolean indicating whether the document supports layers.
|
|
@@ -34610,7 +34622,7 @@ class PdfJsProvider {
|
|
|
34610
34622
|
}
|
|
34611
34623
|
}
|
|
34612
34624
|
|
|
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:#
|
|
34625
|
+
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:#eeeeee}.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)}`;
|
|
34614
34626
|
|
|
34615
34627
|
const VertexDocumentViewer = class {
|
|
34616
34628
|
constructor(hostRef) {
|
|
@@ -34642,6 +34654,7 @@ const VertexDocumentViewer = class {
|
|
|
34642
34654
|
this.handleDocumentApiStateChanged = this.handleDocumentApiStateChanged.bind(this);
|
|
34643
34655
|
this.handlePageLoaded = this.handlePageLoaded.bind(this);
|
|
34644
34656
|
this.handlePageDrawn = this.handlePageDrawn.bind(this);
|
|
34657
|
+
this.layers = new DocumentLayersController();
|
|
34645
34658
|
this.resizeObserver = new ResizeObserver(this.handleElementResize);
|
|
34646
34659
|
this.registerSlotChangeListeners();
|
|
34647
34660
|
}
|
|
@@ -34654,7 +34667,7 @@ const VertexDocumentViewer = class {
|
|
|
34654
34667
|
var _a;
|
|
34655
34668
|
(_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.observe(this.hostEl);
|
|
34656
34669
|
this.updateComponentDimensions();
|
|
34657
|
-
this.
|
|
34670
|
+
this.loadInitialSrc();
|
|
34658
34671
|
this.injectViewerApi();
|
|
34659
34672
|
}
|
|
34660
34673
|
disconnectedCallback() {
|
|
@@ -34721,12 +34734,13 @@ const VertexDocumentViewer = class {
|
|
|
34721
34734
|
await documentApi.loadPage(pageNumber);
|
|
34722
34735
|
}
|
|
34723
34736
|
async handleSrcChange() {
|
|
34737
|
+
var _a;
|
|
34724
34738
|
if (this.src != null && this.canvasEl != null) {
|
|
34725
34739
|
this.clearCurrentDocument();
|
|
34726
34740
|
const { api, renderer } = this.provider.create(this.canvasEl, this.config);
|
|
34727
34741
|
this.documentApi = api;
|
|
34728
34742
|
this.documentRenderer = renderer;
|
|
34729
|
-
this.layers
|
|
34743
|
+
(_a = this.layers) === null || _a === void 0 ? void 0 : _a.setApi(api);
|
|
34730
34744
|
this.updateInteractionHandler();
|
|
34731
34745
|
this.updateDocumentApiListeners();
|
|
34732
34746
|
await this.documentApi.updateViewport(this.dimensions);
|
|
@@ -34743,9 +34757,9 @@ const VertexDocumentViewer = class {
|
|
|
34743
34757
|
this.updateInteractionHandler();
|
|
34744
34758
|
}
|
|
34745
34759
|
render() {
|
|
34746
|
-
return (h(Host, { key: '
|
|
34760
|
+
return (h(Host, { key: 'a990831d5f2328f2cf21be0b82d4018b05decd51' }, h("div", { key: '349abae36254da570e640417fab459680c576465', ref: ref => (this.viewerContainerElement = ref), class: "viewer-container", onContextMenu: event => event.preventDefault() }, h("div", { key: '6fca3f1d5a2c31bdcc0c8dbbd468e306db981740', ref: ref => (this.canvasContainerElement = ref), class: classNames('canvas-container', {
|
|
34747
34761
|
'enable-pointer-events ': window.PointerEvent != null,
|
|
34748
|
-
}) }, h("canvas", { key: '
|
|
34762
|
+
}) }, h("canvas", { key: 'deb1c58d8d20000053cd829401163bf1e68ca88e', id: "document-viewer-canvas", role: "presentation", ref: el => (this.canvasEl = el) })), h("slot", { key: '6b87846ef17b330b0fae5d03103765bad6fdafa6' }))));
|
|
34749
34763
|
}
|
|
34750
34764
|
getDocumentApi() {
|
|
34751
34765
|
if (this.documentApi == null) {
|
|
@@ -34753,15 +34767,25 @@ const VertexDocumentViewer = class {
|
|
|
34753
34767
|
}
|
|
34754
34768
|
return this.documentApi;
|
|
34755
34769
|
}
|
|
34770
|
+
async loadInitialSrc() {
|
|
34771
|
+
await Promise.resolve();
|
|
34772
|
+
await this.handleSrcChange();
|
|
34773
|
+
}
|
|
34756
34774
|
clearCurrentDocument() {
|
|
34757
|
-
var _a, _b, _c, _d, _e, _f;
|
|
34775
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
34758
34776
|
(_a = this.documentRenderer) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
34759
34777
|
(_b = this.documentApi) === null || _b === void 0 ? void 0 : _b.dispose();
|
|
34760
34778
|
(_c = this.panInteractionHandler) === null || _c === void 0 ? void 0 : _c.dispose();
|
|
34761
34779
|
(_d = this.documentApiStateChangedDisposable) === null || _d === void 0 ? void 0 : _d.dispose();
|
|
34762
34780
|
(_e = this.pageLoadedDisposable) === null || _e === void 0 ? void 0 : _e.dispose();
|
|
34763
34781
|
(_f = this.pageDrawnDisposable) === null || _f === void 0 ? void 0 : _f.dispose();
|
|
34764
|
-
this.
|
|
34782
|
+
this.documentRenderer = undefined;
|
|
34783
|
+
this.documentApi = undefined;
|
|
34784
|
+
this.panInteractionHandler = undefined;
|
|
34785
|
+
this.documentApiStateChangedDisposable = undefined;
|
|
34786
|
+
this.pageLoadedDisposable = undefined;
|
|
34787
|
+
this.pageDrawnDisposable = undefined;
|
|
34788
|
+
(_g = this.layers) === null || _g === void 0 ? void 0 : _g.clear();
|
|
34765
34789
|
}
|
|
34766
34790
|
handleDocumentApiStateChanged(state) {
|
|
34767
34791
|
this.documentState = state;
|
|
@@ -134,6 +134,7 @@ export declare class VertexDocumentViewer implements BasicViewer {
|
|
|
134
134
|
protected handleInteractionModeChange(): void;
|
|
135
135
|
render(): void;
|
|
136
136
|
private getDocumentApi;
|
|
137
|
+
private loadInitialSrc;
|
|
137
138
|
private clearCurrentDocument;
|
|
138
139
|
private handleDocumentApiStateChanged;
|
|
139
140
|
private handlePageLoaded;
|
|
@@ -3,7 +3,9 @@ import { DocumentLayer } from './types';
|
|
|
3
3
|
export declare class DocumentLayersController {
|
|
4
4
|
private apiSupportsLayers;
|
|
5
5
|
private api?;
|
|
6
|
-
constructor(api
|
|
6
|
+
constructor(api?: DocumentApi);
|
|
7
|
+
setApi(api: DocumentApi): void;
|
|
8
|
+
clear(): void;
|
|
7
9
|
/**
|
|
8
10
|
* Returns a boolean indicating whether the document supports layers.
|
|
9
11
|
*/
|
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.4",
|
|
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.4",
|
|
99
|
+
"@vertexvis/utils": "1.0.2-testing.4",
|
|
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": "c1150c7ce0863320b80a997a4139aa816b29864b"
|
|
105
105
|
}
|