kviewer 0.0.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/README.md +134 -0
- package/dist/module.d.mts +15 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +26 -0
- package/dist/runtime/annotation/engine/config.d.ts +52 -0
- package/dist/runtime/annotation/engine/config.js +283 -0
- package/dist/runtime/annotation/engine/const.d.ts +6 -0
- package/dist/runtime/annotation/engine/const.js +7 -0
- package/dist/runtime/annotation/engine/cursor-preview.d.ts +2 -0
- package/dist/runtime/annotation/engine/cursor-preview.js +88 -0
- package/dist/runtime/annotation/engine/editor/editor.d.ts +69 -0
- package/dist/runtime/annotation/engine/editor/editor.js +233 -0
- package/dist/runtime/annotation/engine/editor/selector.d.ts +74 -0
- package/dist/runtime/annotation/engine/editor/selector.js +594 -0
- package/dist/runtime/annotation/engine/import-normalize.d.ts +5 -0
- package/dist/runtime/annotation/engine/import-normalize.js +99 -0
- package/dist/runtime/annotation/engine/input-device.d.ts +53 -0
- package/dist/runtime/annotation/engine/input-device.js +64 -0
- package/dist/runtime/annotation/engine/painter.d.ts +97 -0
- package/dist/runtime/annotation/engine/painter.js +591 -0
- package/dist/runtime/annotation/engine/store.d.ts +11 -0
- package/dist/runtime/annotation/engine/store.js +47 -0
- package/dist/runtime/annotation/engine/tools/arrow.d.ts +22 -0
- package/dist/runtime/annotation/engine/tools/arrow.js +126 -0
- package/dist/runtime/annotation/engine/tools/circle.d.ts +45 -0
- package/dist/runtime/annotation/engine/tools/circle.js +148 -0
- package/dist/runtime/annotation/engine/tools/cloud.d.ts +50 -0
- package/dist/runtime/annotation/engine/tools/cloud.js +244 -0
- package/dist/runtime/annotation/engine/tools/free-highlight.d.ts +43 -0
- package/dist/runtime/annotation/engine/tools/free-highlight.js +165 -0
- package/dist/runtime/annotation/engine/tools/free-text.d.ts +27 -0
- package/dist/runtime/annotation/engine/tools/free-text.js +114 -0
- package/dist/runtime/annotation/engine/tools/freehand.d.ts +44 -0
- package/dist/runtime/annotation/engine/tools/freehand.js +151 -0
- package/dist/runtime/annotation/engine/tools/highlight.d.ts +87 -0
- package/dist/runtime/annotation/engine/tools/highlight.js +215 -0
- package/dist/runtime/annotation/engine/tools/note.d.ts +9 -0
- package/dist/runtime/annotation/engine/tools/note.js +34 -0
- package/dist/runtime/annotation/engine/tools/rectangle.d.ts +45 -0
- package/dist/runtime/annotation/engine/tools/rectangle.js +142 -0
- package/dist/runtime/annotation/engine/tools/signature.d.ts +16 -0
- package/dist/runtime/annotation/engine/tools/signature.js +74 -0
- package/dist/runtime/annotation/engine/tools/stamp.d.ts +18 -0
- package/dist/runtime/annotation/engine/tools/stamp.js +94 -0
- package/dist/runtime/annotation/engine/types.d.ts +170 -0
- package/dist/runtime/annotation/engine/types.js +67 -0
- package/dist/runtime/annotation/engine/utils.d.ts +40 -0
- package/dist/runtime/annotation/engine/utils.js +257 -0
- package/dist/runtime/annotation/parsers/parseFormFields.d.ts +9 -0
- package/dist/runtime/annotation/parsers/parseFormFields.js +101 -0
- package/dist/runtime/annotation/pdf-export/download.d.ts +1 -0
- package/dist/runtime/annotation/pdf-export/download.js +10 -0
- package/dist/runtime/annotation/pdf-export/export-form-fields.d.ts +9 -0
- package/dist/runtime/annotation/pdf-export/export-form-fields.js +90 -0
- package/dist/runtime/annotation/pdf-export/export.d.ts +15 -0
- package/dist/runtime/annotation/pdf-export/export.js +145 -0
- package/dist/runtime/annotation/pdf-export/parse.d.ts +10 -0
- package/dist/runtime/annotation/pdf-export/parse.js +19 -0
- package/dist/runtime/annotation/pdf-export/parse_circle.d.ts +4 -0
- package/dist/runtime/annotation/pdf-export/parse_circle.js +41 -0
- package/dist/runtime/annotation/pdf-export/parse_freetext.d.ts +4 -0
- package/dist/runtime/annotation/pdf-export/parse_freetext.js +54 -0
- package/dist/runtime/annotation/pdf-export/parse_highlight.d.ts +4 -0
- package/dist/runtime/annotation/pdf-export/parse_highlight.js +134 -0
- package/dist/runtime/annotation/pdf-export/parse_ink.d.ts +4 -0
- package/dist/runtime/annotation/pdf-export/parse_ink.js +124 -0
- package/dist/runtime/annotation/pdf-export/parse_line.d.ts +4 -0
- package/dist/runtime/annotation/pdf-export/parse_line.js +71 -0
- package/dist/runtime/annotation/pdf-export/parse_polyline.d.ts +4 -0
- package/dist/runtime/annotation/pdf-export/parse_polyline.js +93 -0
- package/dist/runtime/annotation/pdf-export/parse_square.d.ts +4 -0
- package/dist/runtime/annotation/pdf-export/parse_square.js +41 -0
- package/dist/runtime/annotation/pdf-export/parse_stamp.d.ts +4 -0
- package/dist/runtime/annotation/pdf-export/parse_stamp.js +195 -0
- package/dist/runtime/annotation/pdf-export/parse_strikeout.d.ts +4 -0
- package/dist/runtime/annotation/pdf-export/parse_strikeout.js +59 -0
- package/dist/runtime/annotation/pdf-export/parse_text.d.ts +4 -0
- package/dist/runtime/annotation/pdf-export/parse_text.js +42 -0
- package/dist/runtime/annotation/pdf-export/parse_underline.d.ts +4 -0
- package/dist/runtime/annotation/pdf-export/parse_underline.js +59 -0
- package/dist/runtime/assets/kviewer.css +1 -0
- package/dist/runtime/components/AnnotationToolbar.d.vue.ts +3 -0
- package/dist/runtime/components/AnnotationToolbar.vue +125 -0
- package/dist/runtime/components/AnnotationToolbar.vue.d.ts +3 -0
- package/dist/runtime/components/FloatingPageIndicator.d.vue.ts +6 -0
- package/dist/runtime/components/FloatingPageIndicator.vue +93 -0
- package/dist/runtime/components/FloatingPageIndicator.vue.d.ts +6 -0
- package/dist/runtime/components/FormFieldLayer.d.vue.ts +11 -0
- package/dist/runtime/components/FormFieldLayer.vue +40 -0
- package/dist/runtime/components/FormFieldLayer.vue.d.ts +11 -0
- package/dist/runtime/components/PdfPage.d.vue.ts +9 -0
- package/dist/runtime/components/PdfPage.vue +199 -0
- package/dist/runtime/components/PdfPage.vue.d.ts +9 -0
- package/dist/runtime/components/ToolButton.d.vue.ts +13 -0
- package/dist/runtime/components/ToolButton.vue +26 -0
- package/dist/runtime/components/ToolButton.vue.d.ts +13 -0
- package/dist/runtime/components/Toolbar.d.vue.ts +3 -0
- package/dist/runtime/components/Toolbar.vue +11 -0
- package/dist/runtime/components/Toolbar.vue.d.ts +3 -0
- package/dist/runtime/components/Viewer.d.vue.ts +45 -0
- package/dist/runtime/components/Viewer.vue +617 -0
- package/dist/runtime/components/Viewer.vue.d.ts +45 -0
- package/dist/runtime/components/ViewerBar.d.vue.ts +3 -0
- package/dist/runtime/components/ViewerBar.vue +91 -0
- package/dist/runtime/components/ViewerBar.vue.d.ts +3 -0
- package/dist/runtime/components/ViewerTabs.d.vue.ts +381 -0
- package/dist/runtime/components/ViewerTabs.vue +171 -0
- package/dist/runtime/components/ViewerTabs.vue.d.ts +381 -0
- package/dist/runtime/components/form-fields/FormButton.d.vue.ts +7 -0
- package/dist/runtime/components/form-fields/FormButton.vue +39 -0
- package/dist/runtime/components/form-fields/FormButton.vue.d.ts +7 -0
- package/dist/runtime/components/form-fields/FormCheckbox.d.vue.ts +7 -0
- package/dist/runtime/components/form-fields/FormCheckbox.vue +28 -0
- package/dist/runtime/components/form-fields/FormCheckbox.vue.d.ts +7 -0
- package/dist/runtime/components/form-fields/FormDropdown.d.vue.ts +7 -0
- package/dist/runtime/components/form-fields/FormDropdown.vue +112 -0
- package/dist/runtime/components/form-fields/FormDropdown.vue.d.ts +7 -0
- package/dist/runtime/components/form-fields/FormFieldWrapper.d.vue.ts +8 -0
- package/dist/runtime/components/form-fields/FormFieldWrapper.vue +41 -0
- package/dist/runtime/components/form-fields/FormFieldWrapper.vue.d.ts +8 -0
- package/dist/runtime/components/form-fields/FormRadioButton.d.vue.ts +7 -0
- package/dist/runtime/components/form-fields/FormRadioButton.vue +30 -0
- package/dist/runtime/components/form-fields/FormRadioButton.vue.d.ts +7 -0
- package/dist/runtime/components/form-fields/FormSignatureField.d.vue.ts +7 -0
- package/dist/runtime/components/form-fields/FormSignatureField.vue +54 -0
- package/dist/runtime/components/form-fields/FormSignatureField.vue.d.ts +7 -0
- package/dist/runtime/components/form-fields/FormTextField.d.vue.ts +7 -0
- package/dist/runtime/components/form-fields/FormTextField.vue +66 -0
- package/dist/runtime/components/form-fields/FormTextField.vue.d.ts +7 -0
- package/dist/runtime/components/modals/FreeTextModal.d.vue.ts +25 -0
- package/dist/runtime/components/modals/FreeTextModal.vue +89 -0
- package/dist/runtime/components/modals/FreeTextModal.vue.d.ts +25 -0
- package/dist/runtime/components/modals/SignatureDrawModal.d.vue.ts +14 -0
- package/dist/runtime/components/modals/SignatureDrawModal.vue +120 -0
- package/dist/runtime/components/modals/SignatureDrawModal.vue.d.ts +14 -0
- package/dist/runtime/components/panels/SignaturePicker.d.vue.ts +3 -0
- package/dist/runtime/components/panels/SignaturePicker.vue +85 -0
- package/dist/runtime/components/panels/SignaturePicker.vue.d.ts +3 -0
- package/dist/runtime/components/panels/StampPicker.d.vue.ts +3 -0
- package/dist/runtime/components/panels/StampPicker.vue +46 -0
- package/dist/runtime/components/panels/StampPicker.vue.d.ts +3 -0
- package/dist/runtime/components/tools/ActionTools.d.vue.ts +3 -0
- package/dist/runtime/components/tools/ActionTools.vue +32 -0
- package/dist/runtime/components/tools/ActionTools.vue.d.ts +3 -0
- package/dist/runtime/components/tools/DrawingTools.d.vue.ts +6 -0
- package/dist/runtime/components/tools/DrawingTools.vue +57 -0
- package/dist/runtime/components/tools/DrawingTools.vue.d.ts +6 -0
- package/dist/runtime/components/tools/HandTool.d.vue.ts +3 -0
- package/dist/runtime/components/tools/HandTool.vue +14 -0
- package/dist/runtime/components/tools/HandTool.vue.d.ts +3 -0
- package/dist/runtime/components/tools/MarqueeTool.d.vue.ts +3 -0
- package/dist/runtime/components/tools/MarqueeTool.vue +15 -0
- package/dist/runtime/components/tools/MarqueeTool.vue.d.ts +3 -0
- package/dist/runtime/components/tools/PageInfo.d.vue.ts +3 -0
- package/dist/runtime/components/tools/PageInfo.vue +10 -0
- package/dist/runtime/components/tools/PageInfo.vue.d.ts +3 -0
- package/dist/runtime/components/tools/PageSettings.d.vue.ts +3 -0
- package/dist/runtime/components/tools/PageSettings.vue +92 -0
- package/dist/runtime/components/tools/PageSettings.vue.d.ts +3 -0
- package/dist/runtime/components/tools/SearchTool.d.vue.ts +3 -0
- package/dist/runtime/components/tools/SearchTool.vue +149 -0
- package/dist/runtime/components/tools/SearchTool.vue.d.ts +3 -0
- package/dist/runtime/components/tools/ToolProperties.d.vue.ts +7 -0
- package/dist/runtime/components/tools/ToolProperties.vue +174 -0
- package/dist/runtime/components/tools/ToolProperties.vue.d.ts +7 -0
- package/dist/runtime/components/tools/ZoomControls.d.vue.ts +3 -0
- package/dist/runtime/components/tools/ZoomControls.vue +59 -0
- package/dist/runtime/components/tools/ZoomControls.vue.d.ts +3 -0
- package/dist/runtime/composables/search-utils.d.ts +20 -0
- package/dist/runtime/composables/search-utils.js +55 -0
- package/dist/runtime/composables/useAnnotationEngine.d.ts +7 -0
- package/dist/runtime/composables/useAnnotationEngine.js +70 -0
- package/dist/runtime/composables/useAnnotationHistory.d.ts +12 -0
- package/dist/runtime/composables/useAnnotationHistory.js +69 -0
- package/dist/runtime/composables/useFormFields.d.ts +26 -0
- package/dist/runtime/composables/useFormFields.js +112 -0
- package/dist/runtime/composables/usePageProxyCache.d.ts +8 -0
- package/dist/runtime/composables/usePageProxyCache.js +73 -0
- package/dist/runtime/composables/usePageSettings.d.ts +16 -0
- package/dist/runtime/composables/usePageSettings.js +66 -0
- package/dist/runtime/composables/usePageVirtualization.d.ts +19 -0
- package/dist/runtime/composables/usePageVirtualization.js +203 -0
- package/dist/runtime/composables/useSearchIndex.d.ts +11 -0
- package/dist/runtime/composables/useSearchIndex.js +71 -0
- package/dist/runtime/composables/useViewerSearch.d.ts +32 -0
- package/dist/runtime/composables/useViewerSearch.js +418 -0
- package/dist/runtime/composables/useViewerState.d.ts +62 -0
- package/dist/runtime/composables/useViewerState.js +189 -0
- package/dist/runtime/composables/viewMode.d.ts +11 -0
- package/dist/runtime/composables/viewMode.js +19 -0
- package/dist/runtime/plugin.d.ts +2 -0
- package/dist/runtime/plugin.js +3 -0
- package/dist/runtime/public-types.d.ts +2 -0
- package/dist/runtime/public-types.js +0 -0
- package/dist/runtime/server/tsconfig.json +3 -0
- package/dist/types.d.mts +5 -0
- package/package.json +64 -0
package/README.md
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# Kabema PDF Editor
|
|
2
|
+
|
|
3
|
+
[![npm version][npm-version-src]][npm-version-href]
|
|
4
|
+
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
5
|
+
[![License][license-src]][license-href]
|
|
6
|
+
[![Nuxt][nuxt-src]][nuxt-href]
|
|
7
|
+
|
|
8
|
+
A Nuxt module for viewing, annotating, and exporting PDFs. Built on pdfjs-dist, Konva, and pdf-lib.
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- 📄 PDF rendering with optional text selection layer
|
|
13
|
+
- ✏️ 14 annotation tools: Select, Highlight, Strikeout, Underline, Free Text, Signature, Rectangle, Circle, Arrow, Cloud, Freehand, Free Highlight, Stamp, Note
|
|
14
|
+
- 📤 Export PDF with or without flattened annotations
|
|
15
|
+
- 💾 Import/export annotation state for draft saving
|
|
16
|
+
- 📝 Interactive form fields (text, checkbox, radio, dropdown, signature, button)
|
|
17
|
+
- 🔍 Full-text search with match highlighting
|
|
18
|
+
- ⚡ Virtual scrolling for large documents
|
|
19
|
+
- ↩️ Undo/redo history
|
|
20
|
+
- 🗂️ Multi-tab document support (`KViewerTabs`)
|
|
21
|
+
- 🎨 Customizable header and footer slots
|
|
22
|
+
|
|
23
|
+
## Quick Setup
|
|
24
|
+
|
|
25
|
+
Install the module:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pnpm add kviewer
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Add it to your `nuxt.config.ts`:
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
export default defineNuxtConfig({
|
|
35
|
+
modules: ['kviewer'],
|
|
36
|
+
kviewer: {
|
|
37
|
+
prefix: 'K', // component prefix (default)
|
|
38
|
+
},
|
|
39
|
+
})
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Basic Usage
|
|
43
|
+
|
|
44
|
+
```vue
|
|
45
|
+
<template>
|
|
46
|
+
<KViewer
|
|
47
|
+
:source="pdfUrl"
|
|
48
|
+
text-layer
|
|
49
|
+
user-name="Jane Doe"
|
|
50
|
+
/>
|
|
51
|
+
</template>
|
|
52
|
+
|
|
53
|
+
<script setup lang="ts">
|
|
54
|
+
const pdfUrl = '/documents/sample.pdf'
|
|
55
|
+
</script>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
`source` accepts a URL string, `Uint8Array`, or a pdfjs-dist source object.
|
|
59
|
+
|
|
60
|
+
## Viewer Ref API
|
|
61
|
+
|
|
62
|
+
`KViewer` exposes methods via a template ref:
|
|
63
|
+
|
|
64
|
+
```vue
|
|
65
|
+
<template>
|
|
66
|
+
<KViewer ref="viewerRef" :source="pdfUrl" />
|
|
67
|
+
</template>
|
|
68
|
+
|
|
69
|
+
<script setup lang="ts">
|
|
70
|
+
const viewerRef = ref(null)
|
|
71
|
+
|
|
72
|
+
// Export the PDF as bytes (or trigger a download)
|
|
73
|
+
const bytes = await viewerRef.value?.exportPdf()
|
|
74
|
+
await viewerRef.value?.exportPdf({ flatten: true, download: true })
|
|
75
|
+
|
|
76
|
+
// Save / restore annotation drafts
|
|
77
|
+
const draft = viewerRef.value?.getAnnotations() ?? []
|
|
78
|
+
await viewerRef.value?.importAnnotations(draft, { mode: 'replace' })
|
|
79
|
+
|
|
80
|
+
// Read / write form field values
|
|
81
|
+
const fields = viewerRef.value?.getFormFieldValues()
|
|
82
|
+
viewerRef.value?.setFormFieldValue('email', 'user@example.com')
|
|
83
|
+
</script>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
| Method | Returns |
|
|
87
|
+
|---|---|
|
|
88
|
+
| `getAnnotations()` | `IAnnotationStore[]` |
|
|
89
|
+
| `importAnnotations(annotations, options?)` | `Promise<{ loaded: number; skipped: number }>` |
|
|
90
|
+
| `exportPdf(options?)` | `Promise<Uint8Array>` |
|
|
91
|
+
| `getFormFieldValues()` | `FormFieldValue[]` |
|
|
92
|
+
| `setFormFieldValue(fieldName, value)` | `void` |
|
|
93
|
+
| `getKonvaCanvasState()` | `Record<number, string>` |
|
|
94
|
+
|
|
95
|
+
`exportPdf` options default to `{ flatten: false, download: false, preserveOriginalAnnotations: false }`.
|
|
96
|
+
|
|
97
|
+
## Development
|
|
98
|
+
|
|
99
|
+
<details>
|
|
100
|
+
<summary>Local development</summary>
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
# Install dependencies
|
|
104
|
+
pnpm install
|
|
105
|
+
|
|
106
|
+
# Generate type stubs
|
|
107
|
+
pnpm dev:prepare
|
|
108
|
+
|
|
109
|
+
# Develop with the playground
|
|
110
|
+
pnpm dev
|
|
111
|
+
|
|
112
|
+
# Build the playground
|
|
113
|
+
pnpm dev:build
|
|
114
|
+
|
|
115
|
+
# Run ESLint
|
|
116
|
+
pnpm lint
|
|
117
|
+
|
|
118
|
+
# Run Vitest
|
|
119
|
+
pnpm test
|
|
120
|
+
pnpm test:watch
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
</details>
|
|
124
|
+
|
|
125
|
+
<!-- Badges -->
|
|
126
|
+
|
|
127
|
+
[npm-version-src]: https://img.shields.io/npm/v/kviewer/latest.svg?style=flat&colorA=020420&colorB=00DC82
|
|
128
|
+
[npm-version-href]: https://npmjs.com/package/kviewer
|
|
129
|
+
[npm-downloads-src]: https://img.shields.io/npm/dm/kviewer.svg?style=flat&colorA=020420&colorB=00DC82
|
|
130
|
+
[npm-downloads-href]: https://npm.chart.dev/kviewer
|
|
131
|
+
[license-src]: https://img.shields.io/npm/l/kviewer.svg?style=flat&colorA=020420&colorB=00DC82
|
|
132
|
+
[license-href]: https://npmjs.com/package/kviewer
|
|
133
|
+
[nuxt-src]: https://img.shields.io/badge/Nuxt-020420?logo=nuxt
|
|
134
|
+
[nuxt-href]: https://nuxt.com
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
export { ExportPdfOptions } from '../dist/runtime/public-types.js';
|
|
3
|
+
|
|
4
|
+
interface ModuleOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Prefix for components
|
|
7
|
+
* @defaultValue `K`
|
|
8
|
+
*/
|
|
9
|
+
prefix?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
13
|
+
|
|
14
|
+
export { _default as default };
|
|
15
|
+
export type { ModuleOptions };
|
package/dist/module.json
ADDED
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { defineNuxtModule, createResolver, addPlugin, addComponentsDir } from '@nuxt/kit';
|
|
2
|
+
|
|
3
|
+
const module$1 = defineNuxtModule({
|
|
4
|
+
meta: {
|
|
5
|
+
name: "kviewer",
|
|
6
|
+
configKey: "kviewer"
|
|
7
|
+
},
|
|
8
|
+
// Default configuration options of the Nuxt module
|
|
9
|
+
defaults: {
|
|
10
|
+
prefix: "K"
|
|
11
|
+
},
|
|
12
|
+
setup(options, nuxt) {
|
|
13
|
+
const { resolve } = createResolver(import.meta.url);
|
|
14
|
+
nuxt.options.css.push("pdfjs-dist/web/pdf_viewer.css");
|
|
15
|
+
nuxt.options.css.push(resolve("./runtime/assets/kviewer.css"));
|
|
16
|
+
addPlugin(resolve("./runtime/plugin"));
|
|
17
|
+
addComponentsDir({
|
|
18
|
+
path: resolve("./runtime/components"),
|
|
19
|
+
pathPrefix: false,
|
|
20
|
+
prefix: options.prefix,
|
|
21
|
+
ignore: ["color-mode/**", "content/**", "prose/**"]
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export { module$1 as default };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type IAnnotationType } from './types.js';
|
|
2
|
+
export declare const defaultOptions: {
|
|
3
|
+
colors: string[];
|
|
4
|
+
fontSize: number[];
|
|
5
|
+
defaultFontList: {
|
|
6
|
+
label: string;
|
|
7
|
+
value: string;
|
|
8
|
+
}[];
|
|
9
|
+
signature: {
|
|
10
|
+
COLORS: string[];
|
|
11
|
+
WIDTH: number;
|
|
12
|
+
HEIGHT: number;
|
|
13
|
+
TYPE: "Draw";
|
|
14
|
+
MAX_SIZE: number;
|
|
15
|
+
ACCEPT: string;
|
|
16
|
+
};
|
|
17
|
+
stamp: {
|
|
18
|
+
MAX_SIZE: number;
|
|
19
|
+
ACCEPT: string;
|
|
20
|
+
DEFAULT_STAMP: string[];
|
|
21
|
+
editor: {
|
|
22
|
+
DEFAULT_BACKGROUND_COLOR: string;
|
|
23
|
+
DEFAULT_BORDER_COLOR: string | null;
|
|
24
|
+
DEFAULT_TEXT_COLOR: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
chooseSetting: {
|
|
28
|
+
COLOR: string;
|
|
29
|
+
STROKEWIDTH: number;
|
|
30
|
+
OPACITY: number;
|
|
31
|
+
};
|
|
32
|
+
connectorLine: {
|
|
33
|
+
ENABLED: boolean;
|
|
34
|
+
COLOR: string;
|
|
35
|
+
WIDTH: number;
|
|
36
|
+
OPACITY: number;
|
|
37
|
+
};
|
|
38
|
+
setting: {
|
|
39
|
+
COLOR: string | undefined;
|
|
40
|
+
FONT_SIZE: number | undefined;
|
|
41
|
+
HIGHLIGHT_COLOR: string | undefined;
|
|
42
|
+
STRIKEOUT_COLOR: string | undefined;
|
|
43
|
+
UNDERLINE_COLOR: string | undefined;
|
|
44
|
+
STROKE_WIDTH: number;
|
|
45
|
+
OPACITY: number;
|
|
46
|
+
MAX_CURSOR_SIZE: number;
|
|
47
|
+
MAX_UPLOAD_IMAGE_SIZE: number;
|
|
48
|
+
LOAD_PDF_ANNOTATION: boolean;
|
|
49
|
+
DB_CLICK_DELETE: boolean;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
export declare const annotationDefinitions: IAnnotationType[];
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AnnotationType,
|
|
3
|
+
PdfjsAnnotationEditorType,
|
|
4
|
+
PdfjsAnnotationType
|
|
5
|
+
} from "./types.js";
|
|
6
|
+
const colors = [
|
|
7
|
+
"#000000",
|
|
8
|
+
"#ff0000",
|
|
9
|
+
"#ffbe00",
|
|
10
|
+
"#ffff00",
|
|
11
|
+
"#83d33c",
|
|
12
|
+
"#00b445",
|
|
13
|
+
"#00b2f4",
|
|
14
|
+
"#1677ff",
|
|
15
|
+
"#001f63",
|
|
16
|
+
"#7828a4",
|
|
17
|
+
"#ff00ff"
|
|
18
|
+
];
|
|
19
|
+
const fontSizes = [14, 16, 18, 20, 22, 24];
|
|
20
|
+
export const defaultOptions = {
|
|
21
|
+
colors,
|
|
22
|
+
fontSize: fontSizes,
|
|
23
|
+
defaultFontList: [
|
|
24
|
+
{ label: "Arial", value: "Arial" },
|
|
25
|
+
{ label: "Times New Roman", value: "Times New Roman" },
|
|
26
|
+
{ label: "Georgia", value: "Georgia" },
|
|
27
|
+
{ label: "Verdana", value: "Verdana" },
|
|
28
|
+
{ label: "Tahoma", value: "Tahoma, Geneva, sans-serif" },
|
|
29
|
+
{ label: "Trebuchet MS", value: '"Trebuchet MS", sans-serif' },
|
|
30
|
+
{
|
|
31
|
+
label: "Courier New",
|
|
32
|
+
value: '"Courier New", Courier, monospace'
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
label: "Lucida Console",
|
|
36
|
+
value: '"Lucida Console", Monaco, monospace'
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
signature: {
|
|
40
|
+
COLORS: ["#000000", "#ff0000", "#1677ff"],
|
|
41
|
+
WIDTH: 366,
|
|
42
|
+
HEIGHT: 200,
|
|
43
|
+
TYPE: "Draw",
|
|
44
|
+
MAX_SIZE: 1024 * 1024 * 5,
|
|
45
|
+
ACCEPT: ".png,.jpg,.jpeg,.bmp"
|
|
46
|
+
},
|
|
47
|
+
stamp: {
|
|
48
|
+
MAX_SIZE: 1024 * 1024 * 5,
|
|
49
|
+
ACCEPT: ".png,.jpg,.jpeg,.bmp",
|
|
50
|
+
DEFAULT_STAMP: [],
|
|
51
|
+
editor: {
|
|
52
|
+
DEFAULT_BACKGROUND_COLOR: "#00b445",
|
|
53
|
+
DEFAULT_BORDER_COLOR: null,
|
|
54
|
+
DEFAULT_TEXT_COLOR: "#fff"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
chooseSetting: {
|
|
58
|
+
COLOR: "#1677ff",
|
|
59
|
+
STROKEWIDTH: 2,
|
|
60
|
+
OPACITY: 0.7
|
|
61
|
+
},
|
|
62
|
+
connectorLine: {
|
|
63
|
+
ENABLED: true,
|
|
64
|
+
COLOR: "#1677ff",
|
|
65
|
+
WIDTH: 2,
|
|
66
|
+
OPACITY: 0.7
|
|
67
|
+
},
|
|
68
|
+
setting: {
|
|
69
|
+
COLOR: colors[0],
|
|
70
|
+
FONT_SIZE: fontSizes[2],
|
|
71
|
+
HIGHLIGHT_COLOR: colors[3],
|
|
72
|
+
STRIKEOUT_COLOR: colors[1],
|
|
73
|
+
UNDERLINE_COLOR: colors[7],
|
|
74
|
+
STROKE_WIDTH: 2,
|
|
75
|
+
OPACITY: 1,
|
|
76
|
+
MAX_CURSOR_SIZE: 96,
|
|
77
|
+
MAX_UPLOAD_IMAGE_SIZE: 800,
|
|
78
|
+
LOAD_PDF_ANNOTATION: true,
|
|
79
|
+
DB_CLICK_DELETE: false
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
export const annotationDefinitions = [
|
|
83
|
+
{
|
|
84
|
+
name: "select",
|
|
85
|
+
type: AnnotationType.SELECT,
|
|
86
|
+
pdfjsEditorType: PdfjsAnnotationEditorType.NONE,
|
|
87
|
+
pdfjsAnnotationType: PdfjsAnnotationType.NONE,
|
|
88
|
+
isOnce: false,
|
|
89
|
+
resizable: false,
|
|
90
|
+
draggable: false,
|
|
91
|
+
icon: "i-lucide-mouse-pointer-2"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: "highlight",
|
|
95
|
+
type: AnnotationType.HIGHLIGHT,
|
|
96
|
+
pdfjsEditorType: PdfjsAnnotationEditorType.HIGHLIGHT,
|
|
97
|
+
pdfjsAnnotationType: PdfjsAnnotationType.HIGHLIGHT,
|
|
98
|
+
subtype: "Highlight",
|
|
99
|
+
isOnce: false,
|
|
100
|
+
resizable: false,
|
|
101
|
+
draggable: false,
|
|
102
|
+
icon: "i-lucide-highlighter",
|
|
103
|
+
style: { color: defaultOptions.setting.HIGHLIGHT_COLOR },
|
|
104
|
+
styleEditable: { color: true, strokeWidth: false, opacity: false }
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: "strikeout",
|
|
108
|
+
type: AnnotationType.STRIKEOUT,
|
|
109
|
+
pdfjsEditorType: PdfjsAnnotationEditorType.HIGHLIGHT,
|
|
110
|
+
pdfjsAnnotationType: PdfjsAnnotationType.STRIKEOUT,
|
|
111
|
+
subtype: "StrikeOut",
|
|
112
|
+
isOnce: false,
|
|
113
|
+
resizable: false,
|
|
114
|
+
draggable: false,
|
|
115
|
+
icon: "i-lucide-strikethrough",
|
|
116
|
+
style: { color: defaultOptions.setting.STRIKEOUT_COLOR },
|
|
117
|
+
styleEditable: { color: true, opacity: false, strokeWidth: false }
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: "underline",
|
|
121
|
+
type: AnnotationType.UNDERLINE,
|
|
122
|
+
pdfjsEditorType: PdfjsAnnotationEditorType.HIGHLIGHT,
|
|
123
|
+
pdfjsAnnotationType: PdfjsAnnotationType.UNDERLINE,
|
|
124
|
+
subtype: "Underline",
|
|
125
|
+
isOnce: false,
|
|
126
|
+
resizable: false,
|
|
127
|
+
draggable: false,
|
|
128
|
+
icon: "i-lucide-underline",
|
|
129
|
+
style: { color: defaultOptions.setting.UNDERLINE_COLOR },
|
|
130
|
+
styleEditable: { color: true, opacity: false, strokeWidth: false }
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
name: "rectangle",
|
|
134
|
+
type: AnnotationType.RECTANGLE,
|
|
135
|
+
pdfjsEditorType: PdfjsAnnotationEditorType.INK,
|
|
136
|
+
pdfjsAnnotationType: PdfjsAnnotationType.SQUARE,
|
|
137
|
+
subtype: "Square",
|
|
138
|
+
isOnce: true,
|
|
139
|
+
resizable: true,
|
|
140
|
+
draggable: true,
|
|
141
|
+
icon: "i-lucide-square",
|
|
142
|
+
style: {
|
|
143
|
+
color: defaultOptions.setting.COLOR,
|
|
144
|
+
strokeWidth: defaultOptions.setting.STROKE_WIDTH,
|
|
145
|
+
opacity: defaultOptions.setting.OPACITY
|
|
146
|
+
},
|
|
147
|
+
styleEditable: { color: true, opacity: true, strokeWidth: true }
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: "circle",
|
|
151
|
+
type: AnnotationType.CIRCLE,
|
|
152
|
+
pdfjsEditorType: PdfjsAnnotationEditorType.INK,
|
|
153
|
+
pdfjsAnnotationType: PdfjsAnnotationType.CIRCLE,
|
|
154
|
+
subtype: "Circle",
|
|
155
|
+
isOnce: true,
|
|
156
|
+
resizable: true,
|
|
157
|
+
draggable: true,
|
|
158
|
+
icon: "i-lucide-circle",
|
|
159
|
+
style: {
|
|
160
|
+
color: defaultOptions.setting.COLOR,
|
|
161
|
+
strokeWidth: defaultOptions.setting.STROKE_WIDTH,
|
|
162
|
+
opacity: defaultOptions.setting.OPACITY
|
|
163
|
+
},
|
|
164
|
+
styleEditable: { color: true, opacity: true, strokeWidth: true }
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
name: "note",
|
|
168
|
+
type: AnnotationType.NOTE,
|
|
169
|
+
pdfjsEditorType: PdfjsAnnotationEditorType.INK,
|
|
170
|
+
pdfjsAnnotationType: PdfjsAnnotationType.TEXT,
|
|
171
|
+
subtype: "Text",
|
|
172
|
+
isOnce: true,
|
|
173
|
+
resizable: false,
|
|
174
|
+
draggable: true,
|
|
175
|
+
icon: "i-lucide-sticky-note"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
name: "arrow",
|
|
179
|
+
type: AnnotationType.ARROW,
|
|
180
|
+
pdfjsEditorType: PdfjsAnnotationEditorType.INK,
|
|
181
|
+
pdfjsAnnotationType: PdfjsAnnotationType.LINE,
|
|
182
|
+
subtype: "Arrow",
|
|
183
|
+
isOnce: true,
|
|
184
|
+
resizable: true,
|
|
185
|
+
draggable: true,
|
|
186
|
+
icon: "i-lucide-move-up-right",
|
|
187
|
+
style: {
|
|
188
|
+
color: defaultOptions.setting.COLOR,
|
|
189
|
+
strokeWidth: defaultOptions.setting.STROKE_WIDTH,
|
|
190
|
+
opacity: defaultOptions.setting.OPACITY
|
|
191
|
+
},
|
|
192
|
+
styleEditable: { color: true, opacity: true, strokeWidth: true }
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
name: "cloud",
|
|
196
|
+
type: AnnotationType.CLOUD,
|
|
197
|
+
pdfjsEditorType: PdfjsAnnotationEditorType.INK,
|
|
198
|
+
pdfjsAnnotationType: PdfjsAnnotationType.POLYLINE,
|
|
199
|
+
subtype: "PolyLine",
|
|
200
|
+
isOnce: true,
|
|
201
|
+
resizable: true,
|
|
202
|
+
draggable: true,
|
|
203
|
+
icon: "i-lucide-cloud",
|
|
204
|
+
style: {
|
|
205
|
+
color: defaultOptions.setting.COLOR,
|
|
206
|
+
strokeWidth: defaultOptions.setting.STROKE_WIDTH,
|
|
207
|
+
opacity: defaultOptions.setting.OPACITY
|
|
208
|
+
},
|
|
209
|
+
styleEditable: { color: true, opacity: true, strokeWidth: true }
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
name: "freehand",
|
|
213
|
+
type: AnnotationType.FREEHAND,
|
|
214
|
+
pdfjsEditorType: PdfjsAnnotationEditorType.INK,
|
|
215
|
+
pdfjsAnnotationType: PdfjsAnnotationType.INK,
|
|
216
|
+
subtype: "Ink",
|
|
217
|
+
isOnce: true,
|
|
218
|
+
resizable: true,
|
|
219
|
+
draggable: true,
|
|
220
|
+
icon: "i-lucide-pencil",
|
|
221
|
+
style: {
|
|
222
|
+
color: defaultOptions.setting.COLOR,
|
|
223
|
+
strokeWidth: defaultOptions.setting.STROKE_WIDTH,
|
|
224
|
+
opacity: defaultOptions.setting.OPACITY
|
|
225
|
+
},
|
|
226
|
+
styleEditable: { color: true, opacity: true, strokeWidth: true }
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
name: "freeHighlight",
|
|
230
|
+
type: AnnotationType.FREE_HIGHLIGHT,
|
|
231
|
+
pdfjsEditorType: PdfjsAnnotationEditorType.INK,
|
|
232
|
+
pdfjsAnnotationType: PdfjsAnnotationType.INK,
|
|
233
|
+
subtype: "Highlight",
|
|
234
|
+
isOnce: true,
|
|
235
|
+
resizable: true,
|
|
236
|
+
draggable: true,
|
|
237
|
+
icon: "i-lucide-pen-line",
|
|
238
|
+
style: {
|
|
239
|
+
color: defaultOptions.setting.COLOR,
|
|
240
|
+
strokeWidth: 10,
|
|
241
|
+
opacity: 0.5
|
|
242
|
+
},
|
|
243
|
+
styleEditable: { color: true, opacity: true, strokeWidth: false }
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
name: "freeText",
|
|
247
|
+
type: AnnotationType.FREETEXT,
|
|
248
|
+
pdfjsEditorType: PdfjsAnnotationEditorType.STAMP,
|
|
249
|
+
pdfjsAnnotationType: PdfjsAnnotationType.FREETEXT,
|
|
250
|
+
subtype: "FreeText",
|
|
251
|
+
isOnce: true,
|
|
252
|
+
resizable: true,
|
|
253
|
+
draggable: true,
|
|
254
|
+
icon: "i-lucide-type",
|
|
255
|
+
style: {
|
|
256
|
+
color: defaultOptions.setting.COLOR,
|
|
257
|
+
fontSize: defaultOptions.setting.FONT_SIZE
|
|
258
|
+
},
|
|
259
|
+
styleEditable: { color: true, opacity: true, strokeWidth: false }
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
name: "signature",
|
|
263
|
+
type: AnnotationType.SIGNATURE,
|
|
264
|
+
pdfjsEditorType: PdfjsAnnotationEditorType.STAMP,
|
|
265
|
+
pdfjsAnnotationType: PdfjsAnnotationType.STAMP,
|
|
266
|
+
subtype: "Caret",
|
|
267
|
+
isOnce: true,
|
|
268
|
+
resizable: true,
|
|
269
|
+
draggable: true,
|
|
270
|
+
icon: "i-lucide-pen-tool"
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
name: "stamp",
|
|
274
|
+
type: AnnotationType.STAMP,
|
|
275
|
+
pdfjsEditorType: PdfjsAnnotationEditorType.STAMP,
|
|
276
|
+
pdfjsAnnotationType: PdfjsAnnotationType.STAMP,
|
|
277
|
+
subtype: "Stamp",
|
|
278
|
+
isOnce: true,
|
|
279
|
+
resizable: true,
|
|
280
|
+
draggable: true,
|
|
281
|
+
icon: "i-lucide-stamp"
|
|
282
|
+
}
|
|
283
|
+
];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const PAINTER_WRAPPER_PREFIX = "KViewer_painter_wrapper";
|
|
2
|
+
export declare const PAINTER_IS_PAINTING_STYLE = "KViewer_is_painting";
|
|
3
|
+
export declare const PAINTER_PAINTING_TYPE = "KViewer_painting_type";
|
|
4
|
+
export declare const SHAPE_GROUP_NAME = "KViewer_shape_group";
|
|
5
|
+
export declare const SELECTOR_HOVER_STYLE = "KViewer_selector_hover";
|
|
6
|
+
export declare const CURSOR_CSS_PROPERTY = "--KViewer-image-cursor";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const STYLE_PREFIX = "KViewer";
|
|
2
|
+
export const PAINTER_WRAPPER_PREFIX = `${STYLE_PREFIX}_painter_wrapper`;
|
|
3
|
+
export const PAINTER_IS_PAINTING_STYLE = `${STYLE_PREFIX}_is_painting`;
|
|
4
|
+
export const PAINTER_PAINTING_TYPE = `${STYLE_PREFIX}_painting_type`;
|
|
5
|
+
export const SHAPE_GROUP_NAME = `${STYLE_PREFIX}_shape_group`;
|
|
6
|
+
export const SELECTOR_HOVER_STYLE = `${STYLE_PREFIX}_selector_hover`;
|
|
7
|
+
export const CURSOR_CSS_PROPERTY = `--${STYLE_PREFIX}-image-cursor`;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
const PRIMARY_COLOR = "#1677ff";
|
|
2
|
+
const CROSSHAIR_COLOR = "#999";
|
|
3
|
+
const PADDING = 6;
|
|
4
|
+
const CROSSHAIR_SIZE = 12;
|
|
5
|
+
let previewEl = null;
|
|
6
|
+
let mouseMoveHandler = null;
|
|
7
|
+
function isOverPage(e) {
|
|
8
|
+
const target = e.target;
|
|
9
|
+
if (!target) return false;
|
|
10
|
+
return !!target.closest(".kviewer-annotation-layer, .kviewer-page");
|
|
11
|
+
}
|
|
12
|
+
function onMouseMove(e) {
|
|
13
|
+
if (!previewEl) return;
|
|
14
|
+
if (isOverPage(e)) {
|
|
15
|
+
previewEl.style.left = `${e.clientX}px`;
|
|
16
|
+
previewEl.style.top = `${e.clientY}px`;
|
|
17
|
+
previewEl.style.display = "";
|
|
18
|
+
document.body.style.cursor = "none";
|
|
19
|
+
} else {
|
|
20
|
+
previewEl.style.display = "none";
|
|
21
|
+
document.body.style.cursor = "";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export function showCursorPreview(imageUrl, size = 80) {
|
|
25
|
+
hideCursorPreview();
|
|
26
|
+
const outerSize = size + PADDING * 2;
|
|
27
|
+
previewEl = document.createElement("div");
|
|
28
|
+
Object.assign(previewEl.style, {
|
|
29
|
+
position: "fixed",
|
|
30
|
+
zIndex: "9999",
|
|
31
|
+
pointerEvents: "none",
|
|
32
|
+
width: `${outerSize}px`,
|
|
33
|
+
height: `${outerSize}px`,
|
|
34
|
+
transform: "translate(-50%, -50%)",
|
|
35
|
+
border: `2px solid ${PRIMARY_COLOR}`,
|
|
36
|
+
borderRadius: "3px",
|
|
37
|
+
padding: `${PADDING}px`,
|
|
38
|
+
left: "-200px",
|
|
39
|
+
top: "-200px"
|
|
40
|
+
});
|
|
41
|
+
const img = document.createElement("img");
|
|
42
|
+
img.src = imageUrl;
|
|
43
|
+
Object.assign(img.style, {
|
|
44
|
+
width: `${size}px`,
|
|
45
|
+
height: `${size}px`,
|
|
46
|
+
objectFit: "contain",
|
|
47
|
+
display: "block",
|
|
48
|
+
pointerEvents: "none"
|
|
49
|
+
});
|
|
50
|
+
previewEl.appendChild(img);
|
|
51
|
+
const hLine = document.createElement("div");
|
|
52
|
+
Object.assign(hLine.style, {
|
|
53
|
+
position: "absolute",
|
|
54
|
+
left: "50%",
|
|
55
|
+
top: "50%",
|
|
56
|
+
width: `${CROSSHAIR_SIZE}px`,
|
|
57
|
+
height: "1px",
|
|
58
|
+
backgroundColor: CROSSHAIR_COLOR,
|
|
59
|
+
transform: "translate(-50%, -50%)"
|
|
60
|
+
});
|
|
61
|
+
previewEl.appendChild(hLine);
|
|
62
|
+
const vLine = document.createElement("div");
|
|
63
|
+
Object.assign(vLine.style, {
|
|
64
|
+
position: "absolute",
|
|
65
|
+
left: "50%",
|
|
66
|
+
top: "50%",
|
|
67
|
+
width: "1px",
|
|
68
|
+
height: `${CROSSHAIR_SIZE}px`,
|
|
69
|
+
backgroundColor: CROSSHAIR_COLOR,
|
|
70
|
+
transform: "translate(-50%, -50%)"
|
|
71
|
+
});
|
|
72
|
+
previewEl.appendChild(vLine);
|
|
73
|
+
document.body.appendChild(previewEl);
|
|
74
|
+
document.body.style.cursor = "none";
|
|
75
|
+
mouseMoveHandler = onMouseMove;
|
|
76
|
+
document.addEventListener("mousemove", mouseMoveHandler);
|
|
77
|
+
}
|
|
78
|
+
export function hideCursorPreview() {
|
|
79
|
+
if (previewEl) {
|
|
80
|
+
previewEl.remove();
|
|
81
|
+
previewEl = null;
|
|
82
|
+
}
|
|
83
|
+
if (mouseMoveHandler) {
|
|
84
|
+
document.removeEventListener("mousemove", mouseMoveHandler);
|
|
85
|
+
mouseMoveHandler = null;
|
|
86
|
+
}
|
|
87
|
+
document.body.style.cursor = "";
|
|
88
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import Konva from 'konva';
|
|
2
|
+
import type { KonvaEventObject } from 'konva/lib/Node';
|
|
3
|
+
import type { AnnotationType, IAnnotationContentsObj, IAnnotationStore, IAnnotationStyle, IAnnotationType } from '../types.js';
|
|
4
|
+
export interface IEditorOptions {
|
|
5
|
+
userName: string;
|
|
6
|
+
konvaStage: Konva.Stage;
|
|
7
|
+
pageNumber: number;
|
|
8
|
+
annotation: IAnnotationType | null;
|
|
9
|
+
onAdd: (annotationStore: IAnnotationStore) => void;
|
|
10
|
+
onChange: (id: string, updates: Partial<IAnnotationStore>) => void;
|
|
11
|
+
/** When provided and returns true, only pen/mouse input can draw. */
|
|
12
|
+
getStylusModeEnabled?: () => boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface IShapeGroup {
|
|
15
|
+
id: string;
|
|
16
|
+
konvaGroup: Konva.Group;
|
|
17
|
+
isDone: boolean;
|
|
18
|
+
pageNumber: number;
|
|
19
|
+
annotation?: IAnnotationType;
|
|
20
|
+
}
|
|
21
|
+
export declare abstract class Editor {
|
|
22
|
+
protected userName: string;
|
|
23
|
+
readonly id: string;
|
|
24
|
+
readonly onAdd: (annotationStore: IAnnotationStore) => void;
|
|
25
|
+
readonly onChange: (id: string, updates: Partial<IAnnotationStore>) => void;
|
|
26
|
+
protected konvaStage: Konva.Stage;
|
|
27
|
+
protected readonly pageNumber: number;
|
|
28
|
+
protected currentAnnotation: IAnnotationType | null;
|
|
29
|
+
protected isPainting: boolean;
|
|
30
|
+
shapeGroupStore: Map<string, IShapeGroup>;
|
|
31
|
+
currentShapeGroup: IShapeGroup | null;
|
|
32
|
+
protected getStylusModeEnabled?: () => boolean;
|
|
33
|
+
static MinSize: number;
|
|
34
|
+
constructor({ userName, konvaStage, pageNumber, annotation, onAdd, editorType, onChange, getStylusModeEnabled, }: IEditorOptions & {
|
|
35
|
+
editorType: AnnotationType;
|
|
36
|
+
});
|
|
37
|
+
private dispatchAddEvent;
|
|
38
|
+
private dispatchChangedEvent;
|
|
39
|
+
protected enableEditMode(): void;
|
|
40
|
+
protected disableEditMode(): void;
|
|
41
|
+
protected getBgLayer(konvaStage?: Konva.Stage): Konva.Layer;
|
|
42
|
+
protected delShapeGroup(id: string): void;
|
|
43
|
+
protected getShapeGroupById(id: string): Konva.Group;
|
|
44
|
+
protected setShapeGroupDone({ id, contentsObj, color, fontSize, }: {
|
|
45
|
+
id: string;
|
|
46
|
+
contentsObj?: IAnnotationContentsObj;
|
|
47
|
+
color?: string;
|
|
48
|
+
fontSize?: number;
|
|
49
|
+
}): void;
|
|
50
|
+
protected setChanged(id: string, updates: Partial<IAnnotationStore>): void;
|
|
51
|
+
protected getNodesByClassName<T extends Konva.Node>(className: string): T[];
|
|
52
|
+
protected getGroupNodesByClassName<T extends Konva.Node>(group: Konva.Group, className: string): T[];
|
|
53
|
+
protected updateKonvaGroup(id: string, newKonvaGroup: Konva.Group): IShapeGroup | null;
|
|
54
|
+
protected createShapeGroup(): IShapeGroup;
|
|
55
|
+
protected abstract mouseDownHandler(e: KonvaEventObject<MouseEvent | TouchEvent>): void;
|
|
56
|
+
protected abstract mouseMoveHandler(e: KonvaEventObject<MouseEvent | TouchEvent>): void;
|
|
57
|
+
protected abstract mouseUpHandler(e: KonvaEventObject<MouseEvent | TouchEvent>): void;
|
|
58
|
+
protected abstract changeStyle(annotationStore: IAnnotationStore, style: IAnnotationStyle): void;
|
|
59
|
+
activate(konvaStage: Konva.Stage, annotation: IAnnotationType): void;
|
|
60
|
+
rebindEvents(): void;
|
|
61
|
+
addSerializedGroupToLayer(konvaStage: Konva.Stage, konvaString: string): void;
|
|
62
|
+
deleteGroup(id: string, konvaStage: Konva.Stage): void;
|
|
63
|
+
updateStyle(annotationStore: IAnnotationStore, style: IAnnotationStyle): void;
|
|
64
|
+
static Timer: {
|
|
65
|
+
[pageNumber: number]: number;
|
|
66
|
+
};
|
|
67
|
+
static TimerClear(pageNumber: number): void;
|
|
68
|
+
static TimerStart(pageNumber: number, callback: (pageNumber: number) => void): void;
|
|
69
|
+
}
|