kviewer 0.0.5 → 0.0.6
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/module.json +1 -1
- package/dist/runtime/components/Viewer.vue +2 -1
- package/dist/runtime/components/ViewerBar.vue +1 -17
- package/dist/runtime/composables/useViewerState.d.ts +2 -0
- package/dist/runtime/composables/useViewerState.js +8 -0
- package/dist/runtime/plugin.d.ts +1 -1
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -189,7 +189,7 @@ const props = defineProps({
|
|
|
189
189
|
});
|
|
190
190
|
const viewerRoot = ref(null);
|
|
191
191
|
const scrollContainer = ref(null);
|
|
192
|
-
const { state: viewerState, setScrollToPageFn } = provideViewerState();
|
|
192
|
+
const { state: viewerState, setScrollToPageFn, setDownloadPdfFn } = provideViewerState();
|
|
193
193
|
watchEffect(() => {
|
|
194
194
|
viewerState.readonly.value = props.readonly ?? false;
|
|
195
195
|
});
|
|
@@ -640,6 +640,7 @@ onMounted(() => {
|
|
|
640
640
|
if (isIPad()) {
|
|
641
641
|
viewerState.setStylusMode(true);
|
|
642
642
|
}
|
|
643
|
+
setDownloadPdfFn(() => exportPdf({ download: true }));
|
|
643
644
|
loadDocument();
|
|
644
645
|
window.addEventListener("keydown", onGlobalKeydown);
|
|
645
646
|
});
|
|
@@ -58,9 +58,6 @@
|
|
|
58
58
|
<script setup>
|
|
59
59
|
import { ref } from "vue";
|
|
60
60
|
import { useViewerState } from "../composables/useViewerState";
|
|
61
|
-
import { getTimestampString } from "../annotation/engine/utils";
|
|
62
|
-
import { downloadPdfBytes } from "../annotation/pdf-export/download";
|
|
63
|
-
import { exportAnnotationsToPdf } from "../annotation/pdf-export/export";
|
|
64
61
|
import PageSettings from "./tools/PageSettings.vue";
|
|
65
62
|
import ZoomControls from "./tools/ZoomControls.vue";
|
|
66
63
|
import HandTool from "./tools/HandTool.vue";
|
|
@@ -77,20 +74,7 @@ function bumpStyleVersion() {
|
|
|
77
74
|
}
|
|
78
75
|
async function onDownload() {
|
|
79
76
|
try {
|
|
80
|
-
|
|
81
|
-
const exportContext = state.painter.value.getExportContext();
|
|
82
|
-
const bytes = await exportAnnotationsToPdf({
|
|
83
|
-
pdfData: await state.doc.value.getData(),
|
|
84
|
-
annotations: exportContext.annotations,
|
|
85
|
-
options: {
|
|
86
|
-
flatten: false,
|
|
87
|
-
preserveOriginalAnnotations: false
|
|
88
|
-
},
|
|
89
|
-
originalAnnotationIds: exportContext.originalIds,
|
|
90
|
-
modifiedAnnotationIds: exportContext.modifiedIds,
|
|
91
|
-
deletedAnnotationIds: exportContext.deletedIds
|
|
92
|
-
});
|
|
93
|
-
downloadPdfBytes(bytes, `annotated_${getTimestampString()}.pdf`);
|
|
77
|
+
await state.downloadPdf();
|
|
94
78
|
} catch (error) {
|
|
95
79
|
console.error("Failed to export PDF from menu action", error);
|
|
96
80
|
}
|
|
@@ -53,6 +53,7 @@ export interface ViewerState {
|
|
|
53
53
|
stylusMode: Ref<boolean>;
|
|
54
54
|
setStylusMode: (enabled: boolean) => void;
|
|
55
55
|
scrollToPage: (pageNumber: number) => void;
|
|
56
|
+
downloadPdf: () => Promise<void>;
|
|
56
57
|
history: AnnotationHistory;
|
|
57
58
|
readonly: Ref<boolean>;
|
|
58
59
|
shapeDetection: Ref<boolean>;
|
|
@@ -60,6 +61,7 @@ export interface ViewerState {
|
|
|
60
61
|
export interface ViewerStateProvider {
|
|
61
62
|
state: ViewerState;
|
|
62
63
|
setScrollToPageFn: (fn: (pageNumber: number) => void) => void;
|
|
64
|
+
setDownloadPdfFn: (fn: () => Promise<void>) => void;
|
|
63
65
|
}
|
|
64
66
|
export declare function provideViewerState(): ViewerStateProvider;
|
|
65
67
|
export declare function useViewerState(): ViewerState;
|
|
@@ -130,9 +130,13 @@ export function provideViewerState() {
|
|
|
130
130
|
return painter.value?.getData() ?? [];
|
|
131
131
|
}
|
|
132
132
|
let _scrollToPageFn = null;
|
|
133
|
+
let _downloadPdfFn = null;
|
|
133
134
|
function scrollToPage(pageNumber) {
|
|
134
135
|
_scrollToPageFn?.(pageNumber);
|
|
135
136
|
}
|
|
137
|
+
async function downloadPdf() {
|
|
138
|
+
await _downloadPdfFn?.();
|
|
139
|
+
}
|
|
136
140
|
const history = createAnnotationHistory(annotations, painter);
|
|
137
141
|
const state = {
|
|
138
142
|
scale,
|
|
@@ -174,6 +178,7 @@ export function provideViewerState() {
|
|
|
174
178
|
stylusMode,
|
|
175
179
|
setStylusMode,
|
|
176
180
|
scrollToPage,
|
|
181
|
+
downloadPdf,
|
|
177
182
|
history,
|
|
178
183
|
readonly,
|
|
179
184
|
shapeDetection: shapeDetectionEnabled
|
|
@@ -183,6 +188,9 @@ export function provideViewerState() {
|
|
|
183
188
|
state,
|
|
184
189
|
setScrollToPageFn(fn) {
|
|
185
190
|
_scrollToPageFn = fn;
|
|
191
|
+
},
|
|
192
|
+
setDownloadPdfFn(fn) {
|
|
193
|
+
_downloadPdfFn = fn;
|
|
186
194
|
}
|
|
187
195
|
};
|
|
188
196
|
}
|
package/dist/runtime/plugin.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
|
|
2
2
|
export default _default;
|