@cocoar/vue-document-viewer 2.3.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.
Files changed (54) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +212 -0
  3. package/dist/CoarDocumentViewer.vue.d.ts +243 -0
  4. package/dist/CoarDocumentViewer.vue.d.ts.map +1 -0
  5. package/dist/index.d.ts +7 -0
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +3283 -0
  8. package/dist/internal/AnnotationLayer.vue.d.ts +23 -0
  9. package/dist/internal/AnnotationLayer.vue.d.ts.map +1 -0
  10. package/dist/internal/AnnotationPopover.vue.d.ts +35 -0
  11. package/dist/internal/AnnotationPopover.vue.d.ts.map +1 -0
  12. package/dist/internal/DocumentAnnotationPanel.vue.d.ts +27 -0
  13. package/dist/internal/DocumentAnnotationPanel.vue.d.ts.map +1 -0
  14. package/dist/internal/DocumentInfoSection.vue.d.ts +18 -0
  15. package/dist/internal/DocumentInfoSection.vue.d.ts.map +1 -0
  16. package/dist/internal/DocumentSearchBar.vue.d.ts +23 -0
  17. package/dist/internal/DocumentSearchBar.vue.d.ts.map +1 -0
  18. package/dist/internal/DocumentSidebar.vue.d.ts +33 -0
  19. package/dist/internal/DocumentSidebar.vue.d.ts.map +1 -0
  20. package/dist/internal/DocumentToolbar.vue.d.ts +92 -0
  21. package/dist/internal/DocumentToolbar.vue.d.ts.map +1 -0
  22. package/dist/internal/PdfOutlineList.vue.d.ts +35 -0
  23. package/dist/internal/PdfOutlineList.vue.d.ts.map +1 -0
  24. package/dist/internal/effective-tools.d.ts +10 -0
  25. package/dist/internal/effective-tools.d.ts.map +1 -0
  26. package/dist/internal/page-provider.d.ts +51 -0
  27. package/dist/internal/page-provider.d.ts.map +1 -0
  28. package/dist/internal/useAnnotationEditor.d.ts +210 -0
  29. package/dist/internal/useAnnotationEditor.d.ts.map +1 -0
  30. package/dist/internal/useDocumentLoader.d.ts +20 -0
  31. package/dist/internal/useDocumentLoader.d.ts.map +1 -0
  32. package/dist/internal/usePageRenderer.d.ts +52 -0
  33. package/dist/internal/usePageRenderer.d.ts.map +1 -0
  34. package/dist/internal/usePdfSearch.d.ts +27 -0
  35. package/dist/internal/usePdfSearch.d.ts.map +1 -0
  36. package/dist/internal/usePositionMemory.d.ts +24 -0
  37. package/dist/internal/usePositionMemory.d.ts.map +1 -0
  38. package/dist/pdf.js +19 -0
  39. package/dist/source-types.d.ts +100 -0
  40. package/dist/source-types.d.ts.map +1 -0
  41. package/dist/sources/image-adapter.d.ts +38 -0
  42. package/dist/sources/image-adapter.d.ts.map +1 -0
  43. package/dist/sources/image-gallery-adapter.d.ts +14 -0
  44. package/dist/sources/image-gallery-adapter.d.ts.map +1 -0
  45. package/dist/sources/image.d.ts +32 -0
  46. package/dist/sources/image.d.ts.map +1 -0
  47. package/dist/sources/pdf-adapter.d.ts +27 -0
  48. package/dist/sources/pdf-adapter.d.ts.map +1 -0
  49. package/dist/sources/pdf.d.ts +20 -0
  50. package/dist/sources/pdf.d.ts.map +1 -0
  51. package/dist/types.d.ts +132 -0
  52. package/dist/types.d.ts.map +1 -0
  53. package/dist/vue-document-viewer.css +2 -0
  54. package/package.json +64 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,212 @@
1
+ # @cocoar/vue-document-viewer
2
+
3
+ Universal document viewer for Vue 3 — renders **PDFs**, **single images**, and **multi-page image galleries** through a single component with shared toolbar, panels, and annotation layer.
4
+
5
+ > **Status: Preview tier.** Ships under the suite version (GitVersion-calculated) but the public API is still settling — small tweaks may land before the Preview marker drops.
6
+
7
+ 📖 **Full reference, live demos, and configuration guide:** [docs.cocoar.dev/cocoar-ui-vue/components/document-viewer/](https://docs.cocoar.dev/cocoar-ui-vue/components/document-viewer/)
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ pnpm add @cocoar/vue-document-viewer @cocoar/vue-ui
13
+ ```
14
+
15
+ `@cocoar/vue-ui` is a peer dependency. **`pdfjs-dist` is optional** — only required if you render PDFs:
16
+
17
+ ```bash
18
+ pnpm add pdfjs-dist # PDF consumers only
19
+ ```
20
+
21
+ Image-only consumers (`imageSource`, `imageGallerySource`) skip pdfjs entirely.
22
+
23
+ ## Three source factories
24
+
25
+ ```ts
26
+ import {
27
+ CoarDocumentViewer,
28
+ imageSource,
29
+ imageGallerySource,
30
+ } from '@cocoar/vue-document-viewer';
31
+ import { pdfSource } from '@cocoar/vue-document-viewer/pdf';
32
+ import '@cocoar/vue-document-viewer/styles';
33
+
34
+ pdfSource({ url, headers?, withCredentials? }) // PDF — pdfjs subpath
35
+ imageSource({ url }) // Single image (JPG / PNG / SVG / WebP / AVIF / GIF / blob: / data:)
36
+ imageGallerySource({ urls }) // Multi-page image document
37
+ ```
38
+
39
+ Each factory returns a frozen `DocumentSource`. Build it inside a `computed` so the viewer rebinds only on real source changes.
40
+
41
+ ## Quick start — image
42
+
43
+ ```vue
44
+ <script setup lang="ts">
45
+ import { computed } from 'vue';
46
+ import { CoarDocumentViewer, imageSource } from '@cocoar/vue-document-viewer';
47
+ import '@cocoar/vue-document-viewer/styles';
48
+
49
+ const source = computed(() => imageSource({ url: '/attachments/diagram.png' }));
50
+ </script>
51
+
52
+ <template>
53
+ <div style="height: 80vh">
54
+ <CoarDocumentViewer :source="source" />
55
+ </div>
56
+ </template>
57
+ ```
58
+
59
+ ## Quick start — image gallery
60
+
61
+ ```vue
62
+ <script setup lang="ts">
63
+ import { computed } from 'vue';
64
+ import { CoarDocumentViewer, imageGallerySource } from '@cocoar/vue-document-viewer';
65
+
66
+ const source = computed(() => imageGallerySource({
67
+ urls: ['/scans/page-1.jpg', '/scans/page-2.jpg', '/scans/page-3.jpg'],
68
+ }));
69
+ </script>
70
+
71
+ <template>
72
+ <CoarDocumentViewer :source="source" :show-thumbnails="true" />
73
+ </template>
74
+ ```
75
+
76
+ Pages may mix orientations — each carries its own intrinsic dimensions.
77
+
78
+ ## Quick start — PDF
79
+
80
+ PDFs need a one-line worker setup at app bootstrap (Vite shown — webpack, Rollup, esbuild all support `?worker`):
81
+
82
+ ```ts
83
+ // main.ts
84
+ import * as pdfjs from 'pdfjs-dist';
85
+ import PdfWorker from 'pdfjs-dist/build/pdf.worker.min.mjs?worker';
86
+
87
+ pdfjs.GlobalWorkerOptions.workerPort = new PdfWorker();
88
+ ```
89
+
90
+ Then:
91
+
92
+ ```vue
93
+ <script setup lang="ts">
94
+ import { computed } from 'vue';
95
+ import { CoarDocumentViewer } from '@cocoar/vue-document-viewer';
96
+ import { pdfSource } from '@cocoar/vue-document-viewer/pdf';
97
+
98
+ const source = computed(() => pdfSource({
99
+ url: '/api/files/contract.pdf',
100
+ withCredentials: true,
101
+ headers: { 'X-Tenant': 'acme' },
102
+ }));
103
+ </script>
104
+
105
+ <template>
106
+ <CoarDocumentViewer
107
+ :source="source"
108
+ :show-thumbnails="true"
109
+ :show-outline="true"
110
+ :show-annotations-panel="true"
111
+ :show-print-download="true"
112
+ />
113
+ </template>
114
+ ```
115
+
116
+ ## Capability-driven toolbar
117
+
118
+ Every source advertises what it can do via `capabilities` flags. The toolbar **disables** unsupported tools rather than hiding them — switching sources never makes buttons jump around. Search and outline are PDF-only; image sources see them greyed out with a tooltip suffix.
119
+
120
+ ```ts
121
+ interface DocumentSourceCapabilities {
122
+ multiPage: boolean; // Prev / Next / page input
123
+ textLayer: boolean; // Text selection, Ctrl+C copy
124
+ search: boolean; // Search button
125
+ outline: boolean; // Outline (TOC) sidebar tab
126
+ print: boolean; // Print button
127
+ }
128
+ ```
129
+
130
+ ## Order-driven custom toolbar
131
+
132
+ The `tools` prop drives BOTH the visible set AND order:
133
+
134
+ ```ts
135
+ import type { CoarDocumentViewerTool } from '@cocoar/vue-document-viewer';
136
+
137
+ const MINIMAL: CoarDocumentViewerTool[] = [
138
+ 'prev-page', 'page-input', 'next-page',
139
+ 'separator',
140
+ 'zoom-out', 'zoom-reset', 'zoom-in',
141
+ ];
142
+ ```
143
+
144
+ ```vue
145
+ <CoarDocumentViewer :source="source" :tools="MINIMAL" />
146
+ ```
147
+
148
+ Leading + trailing separators auto-trim; consecutive separators collapse. See the [toolbar guide](https://docs.cocoar.dev/cocoar-ui-vue/components/document-viewer/toolbar.html) for the full layer model.
149
+
150
+ ## Annotations
151
+
152
+ Four types — marker / comment / ink / freetext — controlled-component pattern: the viewer emits events, the consumer owns persistence.
153
+
154
+ ```vue
155
+ <CoarDocumentViewer
156
+ :source="source"
157
+ v-model:annotation-mode="mode"
158
+ :annotations="annotations"
159
+ :show-annotations-panel="true"
160
+ @annotation:create="onCreate"
161
+ @annotation:update="onUpdate"
162
+ @annotation:delete="onDelete"
163
+ />
164
+ ```
165
+
166
+ Coordinates are page-relative and normalized to `[0..1]`, so annotations render correctly across zoom levels and rotations and stay portable across rendering contexts. Full lifecycle, types, and a worked review example in the [annotations guide](https://docs.cocoar.dev/cocoar-ui-vue/components/document-viewer/annotations.html).
167
+
168
+ ## Position memory
169
+
170
+ Two compatible mechanisms — pick one:
171
+
172
+ ```vue
173
+ <!-- Automatic localStorage persistence -->
174
+ <CoarDocumentViewer :source="source" storage-key="contract-abc" />
175
+
176
+ <!-- Or two-way binding for your own state -->
177
+ <CoarDocumentViewer :source="source" v-model:position="position" />
178
+ ```
179
+
180
+ Position covers `{ page, pageOffset, zoom, rotation }`.
181
+
182
+ ## Theming
183
+
184
+ Component visuals expose CSS custom properties — override on any ancestor:
185
+
186
+ ```css
187
+ .my-doc-modal {
188
+ --coar-pdf-toolbar-bg: #1f2937;
189
+ --coar-pdf-toolbar-fg: #f9fafb;
190
+ --coar-pdf-page-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
191
+ --coar-pdf-highlight-color: rgba(250, 204, 21, 0.5);
192
+ }
193
+ ```
194
+
195
+ (The `--coar-pdf-*` prefix is historical — the component was renamed from `vue-pdf-viewer` to `vue-document-viewer` but the CSS variable names stay stable for back-compat.)
196
+
197
+ ## Known limitations
198
+
199
+ - **PDF worker setup must be done by the consumer** (shown above) — the package can't do it for you because Vite's `?worker` import is a build-time concern.
200
+ - **Large PDFs (> 50 MB)** are not specifically optimized yet — pages render lazily, but the document is loaded fully.
201
+ - **Gallery bulk-print** prints the visible page only; multi-page print for galleries is on the roadmap.
202
+ - **Cross-origin auth** with cookies on a different origin (CORS-with-credentials) is out of scope; same-origin cookies via `withCredentials: true` work.
203
+
204
+ ## Architecture
205
+
206
+ The viewer is **source-agnostic** internally — every source kind (PDF page proxy, HTMLImageElement, future kinds) materializes through the same `PageProvider` interface (`render(canvas, opts)`, `cancel()`, optional `getTextLayer()`). The page renderer never imports `pdfjs-dist`.
207
+
208
+ The seam keeps the public component identical across formats: same toolbar, same side panels, same annotation surface. Adding a future source kind (OCR'd images, DOCX, etc.) is a matter of providing a new factory + adapter.
209
+
210
+ ## License
211
+
212
+ Apache 2.0. See [LICENSE](./LICENSE).
@@ -0,0 +1,243 @@
1
+ import { CoarPdfAnnotation, CoarPdfAnnotationMode, CoarPdfAnnotationCreatePayload, CoarPdfAnnotationUpdatePayload, CoarDocumentViewerTool } from './types';
2
+ import { DocumentSource } from './source-types';
3
+ export type CoarDocumentViewerToolbarPosition = 'left' | 'right' | 'top' | 'bottom';
4
+ export interface CoarDocumentViewerPosition {
5
+ /** 0-based page index currently in view. */
6
+ page: number;
7
+ /** Fractional scroll offset inside the page, 0..1. */
8
+ pageOffset: number;
9
+ /** Zoom factor, 1 = 100%. */
10
+ zoom: number;
11
+ /** Rotation in degrees, multiples of 90. */
12
+ rotation: 0 | 90 | 180 | 270;
13
+ }
14
+ export interface CoarDocumentViewerErrorEvent {
15
+ /** Original error thrown by pdfjs. */
16
+ error: unknown;
17
+ /** Source URL that failed, if available. */
18
+ src?: string;
19
+ }
20
+ /**
21
+ * UI strings. English defaults are baked in; pass any subset to override.
22
+ * `{n}` / `{total}` / `{current}` placeholders are substituted at render time.
23
+ */
24
+ export interface CoarDocumentViewerLabels {
25
+ loading?: string;
26
+ errorTitle?: string;
27
+ errorRetry?: string;
28
+ pageOf?: string;
29
+ pageJumpAria?: string;
30
+ prevPage?: string;
31
+ nextPage?: string;
32
+ zoomIn?: string;
33
+ zoomOut?: string;
34
+ /** Tooltip / aria-label for the percent readout button (click = reset to 100%). */
35
+ resetZoom?: string;
36
+ /** Tooltip / aria-label for the editable zoom-level input. */
37
+ zoomLevel?: string;
38
+ fitWidth?: string;
39
+ fitPage?: string;
40
+ resetView?: string;
41
+ pan?: string;
42
+ rotateCw?: string;
43
+ rotateCcw?: string;
44
+ search?: string;
45
+ searchNext?: string;
46
+ searchPrev?: string;
47
+ searchMatchOf?: string;
48
+ thumbnails?: string;
49
+ outline?: string;
50
+ print?: string;
51
+ download?: string;
52
+ annotationsPanel?: string;
53
+ noAnnotations?: string;
54
+ noMatchingAnnotations?: string;
55
+ searchAnnotations?: string;
56
+ filterBy?: string;
57
+ sortBy?: string;
58
+ sortByPage?: string;
59
+ sortChronological?: string;
60
+ pagePrefix?: string;
61
+ justNow?: string;
62
+ moreActions?: string;
63
+ modeView?: string;
64
+ modeSelect?: string;
65
+ modeEraser?: string;
66
+ modeMarker?: string;
67
+ modeNote?: string;
68
+ modeInk?: string;
69
+ modeFreetext?: string;
70
+ /** Label for the in-toolbar stroke-width picker. */
71
+ strokeWidth?: string;
72
+ annotationDelete?: string;
73
+ annotationEditComment?: string;
74
+ annotationColor?: string;
75
+ /** Appended to a tool's tooltip when the source's capabilities don't support it. */
76
+ notAvailableForSource?: string;
77
+ /** Section title in the right panel (`'Info'` by default). */
78
+ infoSection?: string;
79
+ /** Row labels in the Info section. */
80
+ infoFormat?: string;
81
+ infoPages?: string;
82
+ /** Per-page dimensions row prefix — appears as `"Page 1: 612 × 792 pt"`. */
83
+ infoPage?: string;
84
+ infoSize?: string;
85
+ infoTitle?: string;
86
+ infoAuthor?: string;
87
+ infoSubject?: string;
88
+ infoKeywords?: string;
89
+ infoCreator?: string;
90
+ infoProducer?: string;
91
+ infoCreated?: string;
92
+ infoModified?: string;
93
+ infoPdfVersion?: string;
94
+ }
95
+ export interface CoarDocumentViewerProps {
96
+ /**
97
+ * The document to render. Build via one of the source factories:
98
+ * - `pdfSource({ url, headers?, withCredentials? })` from
99
+ * `@cocoar/vue-document-viewer/pdf`
100
+ * - `imageSource({ url })` (coming in iteration 2)
101
+ *
102
+ * Switching sources (e.g. user clicks a different attachment) keeps the
103
+ * surrounding component mounted: the toolbar, panels, and viewport stay,
104
+ * only the page renderer rebinds. The toolbar greys out tools that the
105
+ * new source doesn't support via `source.capabilities`.
106
+ */
107
+ source: DocumentSource;
108
+ /** Show the toolbar chrome. Default: true. */
109
+ showToolbar?: boolean;
110
+ /** Show the thumbnails sidebar tab. Default: false. */
111
+ showThumbnails?: boolean;
112
+ /** Show the outline (TOC) sidebar tab if the PDF has one. Default: false. */
113
+ showOutline?: boolean;
114
+ /**
115
+ * Show the right-side annotations list panel. Default: false.
116
+ *
117
+ * The panel lists every annotation in the document with filter, search,
118
+ * and sort controls. Clicking an entry selects the annotation and scrolls
119
+ * to it. Inline 3-dot menu offers delete.
120
+ */
121
+ showAnnotationsPanel?: boolean;
122
+ /**
123
+ * Show the source-info section at the top of the annotations panel. Default: true.
124
+ *
125
+ * The section renders format, page count, current-page dimensions, and any
126
+ * PDF metadata the document carries (title, author, creator, etc.) — empty
127
+ * fields are skipped. Only shown when `showAnnotationsPanel` is true and the
128
+ * source has resolved its info (i.e. `status === 'ready'`).
129
+ */
130
+ showInfoSection?: boolean;
131
+ /** Show the search input in the toolbar. Default: true. */
132
+ showSearch?: boolean;
133
+ /** Show print + download buttons in the toolbar. Default: false. */
134
+ showPrintDownload?: boolean;
135
+ /** Show the annotation-mode button group in the toolbar. Default: true. */
136
+ showAnnotationModes?: boolean;
137
+ /**
138
+ * Where the toolbar sits. `'top'` (default) is a horizontal bar above the
139
+ * document; `'left'`/`'right'` are vertical rails flanking it; `'bottom'`
140
+ * pins it below. Matches `@cocoar/vue-markdown-editor`'s `toolbarPosition`
141
+ * shape so the two viewers can share visual chrome decisions.
142
+ */
143
+ toolbarPosition?: CoarDocumentViewerToolbarPosition;
144
+ /**
145
+ * Persist view position (page, scroll offset, zoom, rotation) in localStorage
146
+ * under this key. Mutually compatible with `v-model:position` — when both are
147
+ * present, the bound position wins on mount.
148
+ */
149
+ storageKey?: string;
150
+ /** Two-way bound view position. Consumer owns persistence. */
151
+ position?: CoarDocumentViewerPosition;
152
+ /**
153
+ * Whitelist of toolbar tools. When omitted, all tools are shown. When set,
154
+ * only the listed tools render (in fixed canonical order — passing order
155
+ * does not influence button order; see `COAR_DOCUMENT_VIEWER_ALL_TOOLS`). The
156
+ * coarse-grained `showSearch` / `showPrintDownload` / `showAnnotationModes`
157
+ * props still apply as section-level toggles on top of this whitelist;
158
+ * pass them as `false` for the equivalent shorthand.
159
+ */
160
+ tools?: CoarDocumentViewerTool[];
161
+ /** Annotations to render on top of the PDF. */
162
+ annotations?: CoarPdfAnnotation[];
163
+ /** Current annotation interaction mode. Default: 'view' (read-only). */
164
+ annotationMode?: CoarPdfAnnotationMode;
165
+ /** Palette shown in the annotation color picker. */
166
+ annotationColors?: string[];
167
+ /** UI string overrides. English defaults are baked in. */
168
+ labels?: CoarDocumentViewerLabels;
169
+ }
170
+ declare function __VLS_template(): {
171
+ attrs: Partial<{}>;
172
+ slots: Readonly<{
173
+ loading(): unknown;
174
+ error(props: {
175
+ error: unknown;
176
+ retry: () => void;
177
+ }): unknown;
178
+ }> & {
179
+ loading(): unknown;
180
+ error(props: {
181
+ error: unknown;
182
+ retry: () => void;
183
+ }): unknown;
184
+ };
185
+ refs: {
186
+ viewerRoot: HTMLDivElement;
187
+ scrollContainer: HTMLDivElement;
188
+ };
189
+ rootEl: any;
190
+ };
191
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
192
+ declare const __VLS_component: import('vue').DefineComponent<CoarDocumentViewerProps, {
193
+ /** Manually reload the current document. */
194
+ reload: () => void;
195
+ /** Tear down the loaded document. */
196
+ destroy: () => Promise<void>;
197
+ /** Scroll to a 0-based page index. */
198
+ scrollToPage: (index: number, opts?: {
199
+ behavior?: ScrollBehavior;
200
+ }) => void;
201
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
202
+ error: (payload: CoarDocumentViewerErrorEvent) => any;
203
+ "update:position": (value: CoarDocumentViewerPosition) => any;
204
+ "update:annotationMode": (value: CoarPdfAnnotationMode) => any;
205
+ "annotation:create": (payload: CoarPdfAnnotationCreatePayload) => any;
206
+ "annotation:update": (payload: CoarPdfAnnotationUpdatePayload) => any;
207
+ "annotation:delete": (id: string) => any;
208
+ }, string, import('vue').PublicProps, Readonly<CoarDocumentViewerProps> & Readonly<{
209
+ onError?: ((payload: CoarDocumentViewerErrorEvent) => any) | undefined;
210
+ "onUpdate:position"?: ((value: CoarDocumentViewerPosition) => any) | undefined;
211
+ "onUpdate:annotationMode"?: ((value: CoarPdfAnnotationMode) => any) | undefined;
212
+ "onAnnotation:create"?: ((payload: CoarPdfAnnotationCreatePayload) => any) | undefined;
213
+ "onAnnotation:update"?: ((payload: CoarPdfAnnotationUpdatePayload) => any) | undefined;
214
+ "onAnnotation:delete"?: ((id: string) => any) | undefined;
215
+ }>, {
216
+ annotationMode: CoarPdfAnnotationMode;
217
+ labels: CoarDocumentViewerLabels;
218
+ showSearch: boolean;
219
+ showPrintDownload: boolean;
220
+ showAnnotationModes: boolean;
221
+ tools: CoarDocumentViewerTool[];
222
+ position: CoarDocumentViewerPosition;
223
+ showThumbnails: boolean;
224
+ showOutline: boolean;
225
+ annotations: CoarPdfAnnotation[];
226
+ showToolbar: boolean;
227
+ showAnnotationsPanel: boolean;
228
+ showInfoSection: boolean;
229
+ toolbarPosition: CoarDocumentViewerToolbarPosition;
230
+ storageKey: string;
231
+ annotationColors: string[];
232
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
233
+ viewerRoot: HTMLDivElement;
234
+ scrollContainer: HTMLDivElement;
235
+ }, any>;
236
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
237
+ export default _default;
238
+ type __VLS_WithTemplateSlots<T, S> = T & {
239
+ new (): {
240
+ $slots: S;
241
+ };
242
+ };
243
+ //# sourceMappingURL=CoarDocumentViewer.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CoarDocumentViewer.vue.d.ts","sourceRoot":"","sources":["../src/CoarDocumentViewer.vue"],"names":[],"mappings":"AA4yDA,MAAM,MAAM,iCAAiC,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,CAAC;AACpF,OAAO,KAAK,EACV,iBAAiB,EACjB,qBAAqB,EACrB,8BAA8B,EAC9B,8BAA8B,EAC9B,sBAAsB,EACvB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAerD,MAAM,WAAW,0BAA0B;IACzC,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,sDAAsD;IACtD,UAAU,EAAE,MAAM,CAAC;IACnB,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,GAAG,CAAC;CAC9B;AAED,MAAM,WAAW,4BAA4B;IAC3C,sCAAsC;IACtC,KAAK,EAAE,OAAO,CAAC;IACf,4CAA4C;IAC5C,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,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AEV,OAAO;iBAiDP,iBAAiB,EAAE;iBArDnB,OAAO;0BAYE,OAAO;qBASZ,OAAO;qBAaP,iCAAiC;gBAMtC,MAAM;sBAiBA,MAAM,EAAE;;;;OAokD3B,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAapG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
@@ -0,0 +1,7 @@
1
+ export { default as CoarDocumentViewer } from './CoarDocumentViewer.vue';
2
+ export type { CoarDocumentViewerProps, CoarDocumentViewerLabels, CoarDocumentViewerPosition, CoarDocumentViewerErrorEvent, CoarDocumentViewerToolbarPosition, } from './CoarDocumentViewer.vue';
3
+ export type { CoarPdfAnnotation, CoarPdfAnnotationType, CoarPdfAnnotationMode, CoarPdfMarkerAnnotation, CoarPdfCommentAnnotation, CoarPdfInkAnnotation, CoarPdfFreetextAnnotation, CoarPdfAnnotationCreatePayload, CoarPdfAnnotationUpdatePayload, CoarPdfRect, CoarPdfPoint, CoarDocumentViewerTool, } from './types';
4
+ export { COAR_DOCUMENT_VIEWER_ALL_TOOLS } from './types';
5
+ export type { DocumentSource, DocumentSourceCapabilities, PdfDocumentSource, ImageDocumentSource, ImageGalleryDocumentSource, DocumentInfo, PdfMetadata, } from './source-types';
6
+ export { imageSource, imageGallerySource, type ImageSourceOptions, type ImageGallerySourceOptions, } from './sources/image';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACzE,YAAY,EACV,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,EAC1B,4BAA4B,EAC5B,iCAAiC,GAClC,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACV,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,wBAAwB,EACxB,oBAAoB,EACpB,yBAAyB,EACzB,8BAA8B,EAC9B,8BAA8B,EAC9B,WAAW,EACX,YAAY,EACZ,sBAAsB,GACvB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,8BAA8B,EAAE,MAAM,SAAS,CAAC;AACzD,YAAY,EACV,cAAc,EACd,0BAA0B,EAC1B,iBAAiB,EACjB,mBAAmB,EACnB,0BAA0B,EAC1B,YAAY,EACZ,WAAW,GACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,GAC/B,MAAM,iBAAiB,CAAC"}