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
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import Konva from "konva";
|
|
2
|
+
import { AnnotationType } from "../types.js";
|
|
3
|
+
import { Editor } from "../editor/editor.js";
|
|
4
|
+
export class EditorHighLight extends Editor {
|
|
5
|
+
/**
|
|
6
|
+
* Creates an EditorHighLight instance.
|
|
7
|
+
* @param EditorOptions Options used to initialize the editor
|
|
8
|
+
* @param editorType Annotation type
|
|
9
|
+
*/
|
|
10
|
+
constructor(EditorOptions, editorType) {
|
|
11
|
+
super({ ...EditorOptions, editorType });
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Converts selected text areas on the page into shapes and draws them on the canvas.
|
|
15
|
+
* @param elements HTMLSpanElement array containing the elements to draw
|
|
16
|
+
* @param fixElement Element used as the positioning reference
|
|
17
|
+
*/
|
|
18
|
+
convertTextSelection(elements, fixElement) {
|
|
19
|
+
this.currentShapeGroup = this.createShapeGroup();
|
|
20
|
+
this.getBgLayer().add(this.currentShapeGroup.konvaGroup);
|
|
21
|
+
const fixBounding = fixElement.getBoundingClientRect();
|
|
22
|
+
elements.forEach((spanEl) => {
|
|
23
|
+
const bounding = spanEl.getBoundingClientRect();
|
|
24
|
+
const { x, y, width, height } = this.calculateRelativePosition(
|
|
25
|
+
bounding,
|
|
26
|
+
fixBounding
|
|
27
|
+
);
|
|
28
|
+
const shape = this.createShape(x, y, width, height);
|
|
29
|
+
this.currentShapeGroup.konvaGroup.add(shape);
|
|
30
|
+
});
|
|
31
|
+
this.setShapeGroupDone({
|
|
32
|
+
id: this.currentShapeGroup.id,
|
|
33
|
+
contentsObj: {
|
|
34
|
+
text: this.getElementOuterText(elements)
|
|
35
|
+
},
|
|
36
|
+
color: this.currentAnnotation.style.color
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Gets the text content of all elements.
|
|
41
|
+
* @param elements HTMLSpanElement array
|
|
42
|
+
* @returns String containing the text content of all elements
|
|
43
|
+
*/
|
|
44
|
+
getElementOuterText(elements) {
|
|
45
|
+
return elements.map((el) => el.outerText).join("");
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Calculates the relative position and size of an element for the canvas coordinate system.
|
|
49
|
+
* @param elementBounding Element bounding box
|
|
50
|
+
* @param fixBounding Reference element bounding box
|
|
51
|
+
* @returns Relative position and size object { x, y, width, height }
|
|
52
|
+
*/
|
|
53
|
+
calculateRelativePosition(elementBounding, fixBounding) {
|
|
54
|
+
const scale = this.konvaStage.scale();
|
|
55
|
+
const x = (elementBounding.x - fixBounding.x) / scale.x;
|
|
56
|
+
const y = (elementBounding.y - fixBounding.y) / scale.y;
|
|
57
|
+
const width = elementBounding.width / scale.x;
|
|
58
|
+
const height = elementBounding.height / scale.y;
|
|
59
|
+
return { x, y, width, height };
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Creates the corresponding shape for the current annotation type.
|
|
63
|
+
* @param x Shape X coordinate
|
|
64
|
+
* @param y Shape Y coordinate
|
|
65
|
+
* @param width Shape width
|
|
66
|
+
* @param height Shape height
|
|
67
|
+
* @returns A concrete Konva.Shape instance
|
|
68
|
+
*/
|
|
69
|
+
createShape(x, y, width, height) {
|
|
70
|
+
switch (this.currentAnnotation.type) {
|
|
71
|
+
case AnnotationType.HIGHLIGHT:
|
|
72
|
+
return this.createHighlightShape(x, y, width, height);
|
|
73
|
+
case AnnotationType.UNDERLINE:
|
|
74
|
+
return this.createUnderlineShape(x, y, width, height);
|
|
75
|
+
case AnnotationType.STRIKEOUT:
|
|
76
|
+
return this.createStrikeoutShape(x, y, width, height);
|
|
77
|
+
default:
|
|
78
|
+
throw new Error(
|
|
79
|
+
`Unsupported annotation type: ${this.currentAnnotation.type}`
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Creates a highlight shape.
|
|
85
|
+
* @param x Shape X coordinate
|
|
86
|
+
* @param y Shape Y coordinate
|
|
87
|
+
* @param width Shape width
|
|
88
|
+
* @param height Shape height
|
|
89
|
+
* @returns Konva.Rect highlight shape instance
|
|
90
|
+
*/
|
|
91
|
+
createHighlightShape(x, y, width, height) {
|
|
92
|
+
return new Konva.Rect({
|
|
93
|
+
x,
|
|
94
|
+
y,
|
|
95
|
+
width,
|
|
96
|
+
height,
|
|
97
|
+
opacity: 0.5,
|
|
98
|
+
fill: this.currentAnnotation.style.color
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Creates an underline shape.
|
|
103
|
+
* @param x Shape X coordinate
|
|
104
|
+
* @param y Shape Y coordinate
|
|
105
|
+
* @param width Shape width
|
|
106
|
+
* @param height Shape height
|
|
107
|
+
* @returns Konva.Rect underline shape instance
|
|
108
|
+
*/
|
|
109
|
+
createUnderlineShape(x, y, width, height) {
|
|
110
|
+
return new Konva.Rect({
|
|
111
|
+
x,
|
|
112
|
+
y: height + y - 2,
|
|
113
|
+
width,
|
|
114
|
+
stroke: this.currentAnnotation.style.color,
|
|
115
|
+
opacity: 1,
|
|
116
|
+
strokeWidth: 1,
|
|
117
|
+
hitStrokeWidth: 10,
|
|
118
|
+
height: 1
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Creates a strikeout shape.
|
|
123
|
+
* @param x Shape X coordinate
|
|
124
|
+
* @param y Shape Y coordinate
|
|
125
|
+
* @param width Shape width
|
|
126
|
+
* @param height Shape height
|
|
127
|
+
* @returns Konva.Rect strikeout shape instance
|
|
128
|
+
*/
|
|
129
|
+
createStrikeoutShape(x, y, width, height) {
|
|
130
|
+
return new Konva.Rect({
|
|
131
|
+
x,
|
|
132
|
+
y: y + height / 2,
|
|
133
|
+
width,
|
|
134
|
+
stroke: this.currentAnnotation.style.color,
|
|
135
|
+
opacity: 1,
|
|
136
|
+
strokeWidth: 1,
|
|
137
|
+
hitStrokeWidth: 10,
|
|
138
|
+
height: 1
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Handles mouse-down events. No specific logic is implemented yet.
|
|
143
|
+
*/
|
|
144
|
+
mouseDownHandler() {
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Handles mouse-move events. No specific logic is implemented yet.
|
|
148
|
+
*/
|
|
149
|
+
mouseMoveHandler() {
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Handles mouse-up events. No specific logic is implemented yet.
|
|
153
|
+
*/
|
|
154
|
+
mouseUpHandler() {
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* @description Update annotation styles
|
|
158
|
+
* @param annotationStore
|
|
159
|
+
* @param styles
|
|
160
|
+
*/
|
|
161
|
+
changeStyle(annotationStore, styles) {
|
|
162
|
+
const id = annotationStore.id;
|
|
163
|
+
const group = this.getShapeGroupById(id);
|
|
164
|
+
if (group) {
|
|
165
|
+
group.getChildren().forEach((shape) => {
|
|
166
|
+
if (annotationStore.type === AnnotationType.HIGHLIGHT) {
|
|
167
|
+
if (shape instanceof Konva.Rect) {
|
|
168
|
+
if (styles.color !== void 0) {
|
|
169
|
+
shape.fill(styles.color);
|
|
170
|
+
}
|
|
171
|
+
if (styles.strokeWidth !== void 0) {
|
|
172
|
+
shape.strokeWidth(styles.strokeWidth);
|
|
173
|
+
}
|
|
174
|
+
if (styles.opacity !== void 0) {
|
|
175
|
+
shape.opacity(styles.opacity);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if (annotationStore.type === AnnotationType.UNDERLINE) {
|
|
180
|
+
if (shape instanceof Konva.Rect) {
|
|
181
|
+
if (styles.color !== void 0) {
|
|
182
|
+
shape.stroke(styles.color);
|
|
183
|
+
}
|
|
184
|
+
if (styles.strokeWidth !== void 0) {
|
|
185
|
+
shape.strokeWidth(styles.strokeWidth);
|
|
186
|
+
}
|
|
187
|
+
if (styles.opacity !== void 0) {
|
|
188
|
+
shape.opacity(styles.opacity);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
if (annotationStore.type === AnnotationType.STRIKEOUT) {
|
|
193
|
+
if (shape instanceof Konva.Rect) {
|
|
194
|
+
if (styles.color !== void 0) {
|
|
195
|
+
shape.stroke(styles.color);
|
|
196
|
+
}
|
|
197
|
+
if (styles.strokeWidth !== void 0) {
|
|
198
|
+
shape.strokeWidth(styles.strokeWidth);
|
|
199
|
+
}
|
|
200
|
+
if (styles.opacity !== void 0) {
|
|
201
|
+
shape.opacity(styles.opacity);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
const changedPayload = {
|
|
207
|
+
konvaString: group.toJSON()
|
|
208
|
+
};
|
|
209
|
+
if (styles.color !== void 0) {
|
|
210
|
+
changedPayload.color = styles.color;
|
|
211
|
+
}
|
|
212
|
+
this.setChanged(id, changedPayload);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { KonvaEventObject } from 'konva/lib/Node';
|
|
2
|
+
import { Editor, type IEditorOptions } from '../editor/editor.js';
|
|
3
|
+
export declare class EditorNote extends Editor {
|
|
4
|
+
constructor(EditorOptions: IEditorOptions);
|
|
5
|
+
protected mouseDownHandler(): void;
|
|
6
|
+
protected mouseMoveHandler(): void;
|
|
7
|
+
protected mouseUpHandler(e: KonvaEventObject<PointerEvent>): Promise<void>;
|
|
8
|
+
protected changeStyle(): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { AnnotationType } from "../types.js";
|
|
2
|
+
import { Editor } from "../editor/editor.js";
|
|
3
|
+
import { createDocumentIcon } from "../utils.js";
|
|
4
|
+
export class EditorNote extends Editor {
|
|
5
|
+
constructor(EditorOptions) {
|
|
6
|
+
super({ ...EditorOptions, editorType: AnnotationType.NOTE });
|
|
7
|
+
}
|
|
8
|
+
mouseDownHandler() {
|
|
9
|
+
}
|
|
10
|
+
mouseMoveHandler() {
|
|
11
|
+
}
|
|
12
|
+
async mouseUpHandler(e) {
|
|
13
|
+
const color = "rgb(255, 222, 33)";
|
|
14
|
+
const { x, y } = this.konvaStage.getRelativePointerPosition();
|
|
15
|
+
if (e.currentTarget !== this.konvaStage) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
this.isPainting = true;
|
|
19
|
+
this.currentShapeGroup = this.createShapeGroup();
|
|
20
|
+
this.getBgLayer().add(this.currentShapeGroup.konvaGroup);
|
|
21
|
+
const docIcon = createDocumentIcon({ x, y, fill: color });
|
|
22
|
+
this.currentShapeGroup.konvaGroup.add(...docIcon);
|
|
23
|
+
const id = this.currentShapeGroup.konvaGroup.id();
|
|
24
|
+
this.setShapeGroupDone({
|
|
25
|
+
id,
|
|
26
|
+
contentsObj: {
|
|
27
|
+
text: ""
|
|
28
|
+
},
|
|
29
|
+
color
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
changeStyle() {
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { KonvaEventObject } from 'konva/lib/Node';
|
|
2
|
+
import type { IAnnotationStore, IAnnotationStyle } from '../types.js';
|
|
3
|
+
import { Editor, type IEditorOptions } from '../editor/editor.js';
|
|
4
|
+
/**
|
|
5
|
+
* EditorRectangle is a rectangle editor class that extends Editor.
|
|
6
|
+
*/
|
|
7
|
+
export declare class EditorRectangle extends Editor {
|
|
8
|
+
private rect;
|
|
9
|
+
private vertex;
|
|
10
|
+
/**
|
|
11
|
+
* Create an EditorRectangle instance.
|
|
12
|
+
* @param EditorOptions Options to initialize the editor
|
|
13
|
+
*/
|
|
14
|
+
constructor(EditorOptions: IEditorOptions);
|
|
15
|
+
/**
|
|
16
|
+
* Handle mouse down event, create a new rectangle object and add it to the stage.
|
|
17
|
+
* @param e Konva event object
|
|
18
|
+
*/
|
|
19
|
+
protected mouseDownHandler(e: KonvaEventObject<MouseEvent | TouchEvent>): void;
|
|
20
|
+
/**
|
|
21
|
+
* Handle mouse move event, update the drawn rectangle's size and position in real time.
|
|
22
|
+
* @param e Konva event object
|
|
23
|
+
*/
|
|
24
|
+
protected mouseMoveHandler(e: KonvaEventObject<MouseEvent | TouchEvent>): void;
|
|
25
|
+
/**
|
|
26
|
+
* Handle mouse up event, complete the rectangle drawing and update the annotation store.
|
|
27
|
+
*/
|
|
28
|
+
protected mouseUpHandler(): void;
|
|
29
|
+
/**
|
|
30
|
+
* Global mouse up event handler, only handles left button release events.
|
|
31
|
+
* @param e MouseEvent object
|
|
32
|
+
*/
|
|
33
|
+
private globalPointerUpHandler;
|
|
34
|
+
/**
|
|
35
|
+
* Check if the rectangle is too small (smaller than the minimum allowed size).
|
|
36
|
+
* @returns true if the rectangle is too small, false otherwise
|
|
37
|
+
*/
|
|
38
|
+
private isTooSmall;
|
|
39
|
+
/**
|
|
40
|
+
* @description Change annotation style
|
|
41
|
+
* @param annotationStore
|
|
42
|
+
* @param styles
|
|
43
|
+
*/
|
|
44
|
+
protected changeStyle(annotationStore: IAnnotationStore, styles: IAnnotationStyle): void;
|
|
45
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import Konva from "konva";
|
|
2
|
+
import { AnnotationType } from "../types.js";
|
|
3
|
+
import { Editor } from "../editor/editor.js";
|
|
4
|
+
export class EditorRectangle extends Editor {
|
|
5
|
+
rect;
|
|
6
|
+
// The rectangle object currently being drawn
|
|
7
|
+
vertex;
|
|
8
|
+
// Starting vertex coordinates of the rectangle
|
|
9
|
+
/**
|
|
10
|
+
* Create an EditorRectangle instance.
|
|
11
|
+
* @param EditorOptions Options to initialize the editor
|
|
12
|
+
*/
|
|
13
|
+
constructor(EditorOptions) {
|
|
14
|
+
super({ ...EditorOptions, editorType: AnnotationType.RECTANGLE });
|
|
15
|
+
this.rect = null;
|
|
16
|
+
this.vertex = { x: 0, y: 0 };
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Handle mouse down event, create a new rectangle object and add it to the stage.
|
|
20
|
+
* @param e Konva event object
|
|
21
|
+
*/
|
|
22
|
+
mouseDownHandler(e) {
|
|
23
|
+
if (e.currentTarget !== this.konvaStage) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
this.rect = null;
|
|
27
|
+
this.isPainting = true;
|
|
28
|
+
this.currentShapeGroup = this.createShapeGroup();
|
|
29
|
+
this.getBgLayer().add(this.currentShapeGroup.konvaGroup);
|
|
30
|
+
const pos = this.konvaStage.getRelativePointerPosition();
|
|
31
|
+
this.vertex = { x: pos.x, y: pos.y };
|
|
32
|
+
this.rect = new Konva.Rect({
|
|
33
|
+
x: pos.x,
|
|
34
|
+
y: pos.y,
|
|
35
|
+
width: 0,
|
|
36
|
+
height: 0,
|
|
37
|
+
// do not scale strokes
|
|
38
|
+
strokeScaleEnabled: false,
|
|
39
|
+
visible: false,
|
|
40
|
+
stroke: this.currentAnnotation.style.color,
|
|
41
|
+
strokeWidth: this.currentAnnotation.style.strokeWidth || 2,
|
|
42
|
+
opacity: this.currentAnnotation.style.opacity
|
|
43
|
+
});
|
|
44
|
+
this.currentShapeGroup.konvaGroup.add(this.rect);
|
|
45
|
+
window.addEventListener("mouseup", this.globalPointerUpHandler);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Handle mouse move event, update the drawn rectangle's size and position in real time.
|
|
49
|
+
* @param e Konva event object
|
|
50
|
+
*/
|
|
51
|
+
mouseMoveHandler(e) {
|
|
52
|
+
if (!this.isPainting) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
e.evt.preventDefault();
|
|
56
|
+
this.rect.show();
|
|
57
|
+
const pos = this.konvaStage.getRelativePointerPosition();
|
|
58
|
+
const areaAttr = {
|
|
59
|
+
x: Math.min(this.vertex.x, pos.x),
|
|
60
|
+
y: Math.min(this.vertex.y, pos.y),
|
|
61
|
+
width: Math.abs(pos.x - this.vertex.x),
|
|
62
|
+
height: Math.abs(pos.y - this.vertex.y)
|
|
63
|
+
};
|
|
64
|
+
this.rect.setAttrs(areaAttr);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Handle mouse up event, complete the rectangle drawing and update the annotation store.
|
|
68
|
+
*/
|
|
69
|
+
mouseUpHandler() {
|
|
70
|
+
if (!this.isPainting) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
this.isPainting = false;
|
|
74
|
+
const group = this.rect.getParent();
|
|
75
|
+
if (!this.rect.isVisible() && group.getType() === "Group") {
|
|
76
|
+
this.delShapeGroup(group.id());
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (this.isTooSmall()) {
|
|
80
|
+
this.rect.destroy();
|
|
81
|
+
this.delShapeGroup(group.id());
|
|
82
|
+
this.rect = null;
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
this.setShapeGroupDone({
|
|
86
|
+
id: group.id(),
|
|
87
|
+
color: this.currentAnnotation.style.color,
|
|
88
|
+
contentsObj: {
|
|
89
|
+
text: ""
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
this.rect = null;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Global mouse up event handler, only handles left button release events.
|
|
96
|
+
* @param e MouseEvent object
|
|
97
|
+
*/
|
|
98
|
+
globalPointerUpHandler = (e) => {
|
|
99
|
+
if (e.button !== 0) return;
|
|
100
|
+
this.mouseUpHandler();
|
|
101
|
+
window.removeEventListener("mouseup", this.globalPointerUpHandler);
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Check if the rectangle is too small (smaller than the minimum allowed size).
|
|
105
|
+
* @returns true if the rectangle is too small, false otherwise
|
|
106
|
+
*/
|
|
107
|
+
isTooSmall() {
|
|
108
|
+
const { width, height } = this.rect.size();
|
|
109
|
+
return Math.max(width, height) < Editor.MinSize;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* @description Change annotation style
|
|
113
|
+
* @param annotationStore
|
|
114
|
+
* @param styles
|
|
115
|
+
*/
|
|
116
|
+
changeStyle(annotationStore, styles) {
|
|
117
|
+
const id = annotationStore.id;
|
|
118
|
+
const group = this.getShapeGroupById(id);
|
|
119
|
+
if (group) {
|
|
120
|
+
group.getChildren().forEach((shape) => {
|
|
121
|
+
if (shape instanceof Konva.Rect) {
|
|
122
|
+
if (styles.color !== void 0) {
|
|
123
|
+
shape.stroke(styles.color);
|
|
124
|
+
}
|
|
125
|
+
if (styles.strokeWidth !== void 0) {
|
|
126
|
+
shape.strokeWidth(styles.strokeWidth);
|
|
127
|
+
}
|
|
128
|
+
if (styles.opacity !== void 0) {
|
|
129
|
+
shape.opacity(styles.opacity);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
const changedPayload = {
|
|
134
|
+
konvaString: group.toJSON()
|
|
135
|
+
};
|
|
136
|
+
if (styles.color !== void 0) {
|
|
137
|
+
changedPayload.color = styles.color;
|
|
138
|
+
}
|
|
139
|
+
this.setChanged(id, changedPayload);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Konva from 'konva';
|
|
2
|
+
import type { KonvaEventObject } from 'konva/lib/Node';
|
|
3
|
+
import { type IAnnotationType } from '../types.js';
|
|
4
|
+
import { Editor, type IEditorOptions } from '../editor/editor.js';
|
|
5
|
+
export declare class EditorSignature extends Editor {
|
|
6
|
+
private signatureUrl;
|
|
7
|
+
private signatureImage;
|
|
8
|
+
constructor(editorOptions: IEditorOptions, defaultSignatureUrl: string | null);
|
|
9
|
+
private createCursorImg;
|
|
10
|
+
protected mouseDownHandler(e: KonvaEventObject<MouseEvent | TouchEvent>): void;
|
|
11
|
+
activateWithSignature(konvaStage: Konva.Stage, annotation: IAnnotationType, signatureUrl: string | null): void;
|
|
12
|
+
addSerializedGroupToLayer(konvaStage: Konva.Stage, konvaString: string): void;
|
|
13
|
+
protected mouseMoveHandler(): void;
|
|
14
|
+
protected mouseUpHandler(): void;
|
|
15
|
+
protected changeStyle(): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import Konva from "konva";
|
|
2
|
+
import { AnnotationType } from "../types.js";
|
|
3
|
+
import { resizeImage } from "../utils.js";
|
|
4
|
+
import { Editor } from "../editor/editor.js";
|
|
5
|
+
import { defaultOptions } from "../config.js";
|
|
6
|
+
import { showCursorPreview } from "../cursor-preview.js";
|
|
7
|
+
export class EditorSignature extends Editor {
|
|
8
|
+
signatureUrl;
|
|
9
|
+
signatureImage;
|
|
10
|
+
constructor(editorOptions, defaultSignatureUrl) {
|
|
11
|
+
super({ ...editorOptions, editorType: AnnotationType.SIGNATURE });
|
|
12
|
+
this.signatureUrl = defaultSignatureUrl;
|
|
13
|
+
if (defaultSignatureUrl) {
|
|
14
|
+
this.createCursorImg();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
createCursorImg() {
|
|
18
|
+
showCursorPreview(this.signatureUrl, defaultOptions.setting.MAX_CURSOR_SIZE);
|
|
19
|
+
}
|
|
20
|
+
mouseDownHandler(e) {
|
|
21
|
+
if (e.currentTarget !== this.konvaStage) return;
|
|
22
|
+
this.signatureImage = null;
|
|
23
|
+
this.currentShapeGroup = this.createShapeGroup();
|
|
24
|
+
this.getBgLayer().add(this.currentShapeGroup.konvaGroup);
|
|
25
|
+
const pos = this.konvaStage.getRelativePointerPosition();
|
|
26
|
+
Konva.Image.fromURL(this.signatureUrl, async (image) => {
|
|
27
|
+
const { width: width_rec, height: height_rec } = image.getClientRect();
|
|
28
|
+
const { newWidth, newHeight } = resizeImage(width_rec, height_rec, 120);
|
|
29
|
+
const crosshair = { x: newWidth / 2, y: newHeight / 2 };
|
|
30
|
+
this.signatureImage = image;
|
|
31
|
+
this.signatureImage.setAttrs({
|
|
32
|
+
x: pos.x - crosshair.x,
|
|
33
|
+
y: pos.y - crosshair.y,
|
|
34
|
+
width: newWidth,
|
|
35
|
+
height: newHeight,
|
|
36
|
+
base64: this.signatureUrl
|
|
37
|
+
});
|
|
38
|
+
this.currentShapeGroup.konvaGroup.add(this.signatureImage);
|
|
39
|
+
const id = this.currentShapeGroup.konvaGroup.id();
|
|
40
|
+
this.setShapeGroupDone({
|
|
41
|
+
id,
|
|
42
|
+
contentsObj: { text: "", image: this.signatureUrl }
|
|
43
|
+
});
|
|
44
|
+
this.signatureImage = null;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
activateWithSignature(konvaStage, annotation, signatureUrl) {
|
|
48
|
+
super.activate(konvaStage, annotation);
|
|
49
|
+
this.signatureUrl = signatureUrl;
|
|
50
|
+
if (signatureUrl) {
|
|
51
|
+
this.createCursorImg();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
addSerializedGroupToLayer(konvaStage, konvaString) {
|
|
55
|
+
const ghostGroup = Konva.Node.create(konvaString);
|
|
56
|
+
const oldImage = this.getGroupNodesByClassName(
|
|
57
|
+
ghostGroup,
|
|
58
|
+
"Image"
|
|
59
|
+
)[0];
|
|
60
|
+
const imageUrl = oldImage.getAttr("base64");
|
|
61
|
+
Konva.Image.fromURL(imageUrl, async (image) => {
|
|
62
|
+
image.setAttrs(oldImage.getAttrs());
|
|
63
|
+
oldImage.destroy();
|
|
64
|
+
ghostGroup.add(image);
|
|
65
|
+
});
|
|
66
|
+
this.getBgLayer(konvaStage).add(ghostGroup);
|
|
67
|
+
}
|
|
68
|
+
mouseMoveHandler() {
|
|
69
|
+
}
|
|
70
|
+
mouseUpHandler() {
|
|
71
|
+
}
|
|
72
|
+
changeStyle() {
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import Konva from 'konva';
|
|
2
|
+
import type { KonvaEventObject } from 'konva/lib/Node';
|
|
3
|
+
import { type IAnnotationType } from '../types.js';
|
|
4
|
+
import { Editor, type IEditorOptions } from '../editor/editor.js';
|
|
5
|
+
export declare class EditorStamp extends Editor {
|
|
6
|
+
private stampUrl;
|
|
7
|
+
private stampImage;
|
|
8
|
+
private stampWidth;
|
|
9
|
+
private stampHeight;
|
|
10
|
+
constructor(editorOptions: IEditorOptions, defaultStampUrl: string | null);
|
|
11
|
+
private createCursorImg;
|
|
12
|
+
protected mouseDownHandler(e: KonvaEventObject<MouseEvent | TouchEvent>): void;
|
|
13
|
+
activateWithStamp(konvaStage: Konva.Stage, annotation: IAnnotationType, stampUrl: string | null, stampWidth?: number, stampHeight?: number): void;
|
|
14
|
+
addSerializedGroupToLayer(konvaStage: Konva.Stage, konvaString: string): void;
|
|
15
|
+
protected mouseMoveHandler(): void;
|
|
16
|
+
protected mouseUpHandler(): void;
|
|
17
|
+
protected changeStyle(): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import Konva from "konva";
|
|
2
|
+
import { AnnotationType } from "../types.js";
|
|
3
|
+
import { resizeImage } from "../utils.js";
|
|
4
|
+
import { Editor } from "../editor/editor.js";
|
|
5
|
+
import { defaultOptions } from "../config.js";
|
|
6
|
+
import { showCursorPreview } from "../cursor-preview.js";
|
|
7
|
+
export class EditorStamp extends Editor {
|
|
8
|
+
stampUrl;
|
|
9
|
+
stampImage;
|
|
10
|
+
stampWidth = null;
|
|
11
|
+
stampHeight = null;
|
|
12
|
+
constructor(editorOptions, defaultStampUrl) {
|
|
13
|
+
super({ ...editorOptions, editorType: AnnotationType.STAMP });
|
|
14
|
+
this.stampUrl = defaultStampUrl;
|
|
15
|
+
if (defaultStampUrl) {
|
|
16
|
+
this.createCursorImg();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
createCursorImg() {
|
|
20
|
+
const baseSize = this.stampWidth ?? this.stampHeight ?? defaultOptions.setting.MAX_CURSOR_SIZE;
|
|
21
|
+
const scale = this.konvaStage?.scale()?.x ?? 1;
|
|
22
|
+
showCursorPreview(this.stampUrl, Math.round(baseSize * scale));
|
|
23
|
+
}
|
|
24
|
+
mouseDownHandler(e) {
|
|
25
|
+
if (e.currentTarget !== this.konvaStage) return;
|
|
26
|
+
this.stampImage = null;
|
|
27
|
+
this.currentShapeGroup = this.createShapeGroup();
|
|
28
|
+
this.getBgLayer().add(this.currentShapeGroup.konvaGroup);
|
|
29
|
+
const pos = this.konvaStage.getRelativePointerPosition();
|
|
30
|
+
Konva.Image.fromURL(this.stampUrl, async (image) => {
|
|
31
|
+
let newWidth;
|
|
32
|
+
let newHeight;
|
|
33
|
+
if (this.stampWidth && this.stampHeight) {
|
|
34
|
+
newWidth = this.stampWidth;
|
|
35
|
+
newHeight = this.stampHeight;
|
|
36
|
+
} else {
|
|
37
|
+
const { width: width_rec, height: height_rec } = image.getClientRect();
|
|
38
|
+
({ newWidth, newHeight } = resizeImage(width_rec, height_rec, 120));
|
|
39
|
+
}
|
|
40
|
+
const crosshair = { x: newWidth / 2, y: newHeight / 2 };
|
|
41
|
+
this.stampImage = image;
|
|
42
|
+
this.stampImage.setAttrs({
|
|
43
|
+
x: pos.x - crosshair.x,
|
|
44
|
+
y: pos.y - crosshair.y,
|
|
45
|
+
width: newWidth,
|
|
46
|
+
height: newHeight,
|
|
47
|
+
base64: this.stampUrl
|
|
48
|
+
});
|
|
49
|
+
this.currentShapeGroup.konvaGroup.add(this.stampImage);
|
|
50
|
+
const id = this.currentShapeGroup.konvaGroup.id();
|
|
51
|
+
this.setShapeGroupDone({
|
|
52
|
+
id,
|
|
53
|
+
contentsObj: { text: "", image: this.stampUrl }
|
|
54
|
+
});
|
|
55
|
+
this.stampImage = null;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
activateWithStamp(konvaStage, annotation, stampUrl, stampWidth, stampHeight) {
|
|
59
|
+
super.activate(konvaStage, annotation);
|
|
60
|
+
this.stampUrl = stampUrl;
|
|
61
|
+
this.stampWidth = stampWidth ?? null;
|
|
62
|
+
this.stampHeight = stampHeight ?? null;
|
|
63
|
+
if (stampUrl) {
|
|
64
|
+
this.createCursorImg();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
addSerializedGroupToLayer(konvaStage, konvaString) {
|
|
68
|
+
const ghostGroup = Konva.Node.create(konvaString);
|
|
69
|
+
const oldImage = this.getGroupNodesByClassName(
|
|
70
|
+
ghostGroup,
|
|
71
|
+
"Image"
|
|
72
|
+
)[0];
|
|
73
|
+
const imageUrl = oldImage.getAttr("base64");
|
|
74
|
+
const oldText = this.getGroupNodesByClassName(
|
|
75
|
+
ghostGroup,
|
|
76
|
+
"Text"
|
|
77
|
+
)[0];
|
|
78
|
+
Konva.Image.fromURL(imageUrl, async (image) => {
|
|
79
|
+
image.setAttrs(oldImage.getAttrs());
|
|
80
|
+
oldImage.destroy();
|
|
81
|
+
ghostGroup.add(image);
|
|
82
|
+
if (oldText) {
|
|
83
|
+
oldText.moveToTop();
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
this.getBgLayer(konvaStage).add(ghostGroup);
|
|
87
|
+
}
|
|
88
|
+
mouseMoveHandler() {
|
|
89
|
+
}
|
|
90
|
+
mouseUpHandler() {
|
|
91
|
+
}
|
|
92
|
+
changeStyle() {
|
|
93
|
+
}
|
|
94
|
+
}
|