kviewer 0.0.10 → 0.0.11
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 +29 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +19 -0
- package/dist/runtime/annotation/checkbox-styles.d.ts +19 -0
- package/dist/runtime/annotation/checkbox-styles.js +27 -0
- package/dist/runtime/annotation/engine/config.js +44 -0
- package/dist/runtime/annotation/engine/painter.d.ts +4 -1
- package/dist/runtime/annotation/engine/painter.js +26 -1
- package/dist/runtime/annotation/engine/tools/form-field.d.ts +24 -0
- package/dist/runtime/annotation/engine/tools/form-field.js +117 -0
- package/dist/runtime/annotation/engine/types.d.ts +54 -1
- package/dist/runtime/annotation/engine/types.js +4 -0
- package/dist/runtime/annotation/font-style.d.ts +23 -0
- package/dist/runtime/annotation/font-style.js +57 -0
- package/dist/runtime/annotation/parsers/extractCheckboxStyles.d.ts +21 -0
- package/dist/runtime/annotation/parsers/extractCheckboxStyles.js +75 -0
- package/dist/runtime/annotation/parsers/parseFormFields.js +16 -3
- package/dist/runtime/annotation/pdf-export/export-form-fields.d.ts +8 -5
- package/dist/runtime/annotation/pdf-export/export-form-fields.js +245 -1
- package/dist/runtime/annotation/pdf-export/export.d.ts +3 -2
- package/dist/runtime/annotation/pdf-export/export.js +9 -2
- package/dist/runtime/assets/kviewer.css +1 -1
- package/dist/runtime/components/FormFieldLayer.d.vue.ts +5 -0
- package/dist/runtime/components/FormFieldLayer.vue +40 -3
- package/dist/runtime/components/FormFieldLayer.vue.d.ts +5 -0
- package/dist/runtime/components/PdfPage.vue +24 -0
- package/dist/runtime/components/Viewer.d.vue.ts +18 -3
- package/dist/runtime/components/Viewer.vue +66 -7
- package/dist/runtime/components/Viewer.vue.d.ts +18 -3
- package/dist/runtime/components/ViewerBar.vue +24 -2
- package/dist/runtime/components/form-fields/FormButton.vue +16 -4
- package/dist/runtime/components/form-fields/FormCheckbox.vue +31 -15
- package/dist/runtime/components/form-fields/FormDropdown.vue +3 -1
- package/dist/runtime/components/form-fields/FormFieldWrapper.d.vue.ts +12 -1
- package/dist/runtime/components/form-fields/FormFieldWrapper.vue +45 -9
- package/dist/runtime/components/form-fields/FormFieldWrapper.vue.d.ts +12 -1
- package/dist/runtime/components/form-fields/FormRadioButton.vue +3 -1
- package/dist/runtime/components/form-fields/FormSignatureField.vue +2 -1
- package/dist/runtime/components/form-fields/FormTextField.vue +47 -7
- package/dist/runtime/components/form-fields/PlacedFieldChrome.d.vue.ts +16 -0
- package/dist/runtime/components/form-fields/PlacedFieldChrome.vue +131 -0
- package/dist/runtime/components/form-fields/PlacedFieldChrome.vue.d.ts +16 -0
- package/dist/runtime/components/modals/SignatureDrawModal.vue +70 -15
- package/dist/runtime/components/panels/PlacedFieldSidebar.d.vue.ts +3 -0
- package/dist/runtime/components/panels/PlacedFieldSidebar.vue +505 -0
- package/dist/runtime/components/panels/PlacedFieldSidebar.vue.d.ts +3 -0
- package/dist/runtime/components/tools/FormFieldTools.d.vue.ts +3 -0
- package/dist/runtime/components/tools/FormFieldTools.vue +35 -0
- package/dist/runtime/components/tools/FormFieldTools.vue.d.ts +3 -0
- package/dist/runtime/composables/useAnnotationEngine.d.ts +1 -0
- package/dist/runtime/composables/useAnnotationEngine.js +2 -1
- package/dist/runtime/composables/useFormFields.d.ts +29 -2
- package/dist/runtime/composables/useFormFields.js +259 -5
- package/dist/runtime/composables/useInertiaPanzoom.js +3 -0
- package/dist/runtime/composables/usePageVirtualization.d.ts +6 -0
- package/dist/runtime/composables/usePageVirtualization.js +11 -3
- package/dist/runtime/composables/useViewerState.d.ts +3 -0
- package/dist/runtime/composables/useViewerState.js +22 -1
- package/package.json +2 -2
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { FormFieldDefinition } from '../../annotation/engine/types.js';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
field: FormFieldDefinition;
|
|
4
|
+
selected: boolean;
|
|
5
|
+
/** CSS pixels per PDF unit for the current page. */
|
|
6
|
+
scale: number;
|
|
7
|
+
/** PDF-space page height (kept for parity; unused here). */
|
|
8
|
+
pageHeight: number;
|
|
9
|
+
};
|
|
10
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
11
|
+
select: () => any;
|
|
12
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
13
|
+
onSelect?: (() => any) | undefined;
|
|
14
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
15
|
+
declare const _default: typeof __VLS_export;
|
|
16
|
+
export default _default;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- The whole chrome is the interactive surface in form-edit mode:
|
|
3
|
+
click to select, drag anywhere to move, plus a label bar above and
|
|
4
|
+
eight resize handles when selected. -->
|
|
5
|
+
<div
|
|
6
|
+
ref="rootEl"
|
|
7
|
+
class="kviewer-placed-chrome"
|
|
8
|
+
:class="{ 'kviewer-placed-chrome--selected': selected }"
|
|
9
|
+
:style="{ '--kvw-handle-zoom': handleZoom }"
|
|
10
|
+
@pointerdown.stop="onChromePointerDown"
|
|
11
|
+
@click.stop
|
|
12
|
+
>
|
|
13
|
+
<div
|
|
14
|
+
v-if="selected"
|
|
15
|
+
class="kviewer-placed-chrome__grip"
|
|
16
|
+
:title="field.fieldName"
|
|
17
|
+
>
|
|
18
|
+
<UIcon name="i-lucide-grip-vertical" class="kviewer-placed-chrome__grip-dots" />
|
|
19
|
+
<span class="kviewer-placed-chrome__grip-label">{{ field.fieldName }}</span>
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
<template v-if="selected">
|
|
23
|
+
<div
|
|
24
|
+
v-for="h in handles"
|
|
25
|
+
:key="h.name"
|
|
26
|
+
class="kviewer-placed-chrome__handle"
|
|
27
|
+
:class="`kviewer-placed-chrome__handle--${h.name}`"
|
|
28
|
+
:style="{ cursor: h.cursor }"
|
|
29
|
+
@pointerdown.stop="(e) => onHandlePointerDown(e, h.name)"
|
|
30
|
+
/>
|
|
31
|
+
</template>
|
|
32
|
+
</div>
|
|
33
|
+
</template>
|
|
34
|
+
|
|
35
|
+
<script setup>
|
|
36
|
+
import { computed, ref } from "vue";
|
|
37
|
+
import { useFormFields } from "../../composables/useFormFields";
|
|
38
|
+
import { useViewerState } from "../../composables/useViewerState";
|
|
39
|
+
const rootEl = ref(null);
|
|
40
|
+
const viewerState = useViewerState();
|
|
41
|
+
const handleZoom = computed(() => {
|
|
42
|
+
const totalZoom = (props.scale || 1) * (viewerState.visualZoom.value || 1);
|
|
43
|
+
return Math.max(0.4, 1 / totalZoom).toFixed(3);
|
|
44
|
+
});
|
|
45
|
+
const props = defineProps({
|
|
46
|
+
field: { type: Object, required: true },
|
|
47
|
+
selected: { type: Boolean, required: true },
|
|
48
|
+
scale: { type: Number, required: true },
|
|
49
|
+
pageHeight: { type: Number, required: true }
|
|
50
|
+
});
|
|
51
|
+
const emit = defineEmits(["select"]);
|
|
52
|
+
const formFields = useFormFields();
|
|
53
|
+
const handles = [
|
|
54
|
+
{ name: "n", cursor: "ns-resize" },
|
|
55
|
+
{ name: "s", cursor: "ns-resize" },
|
|
56
|
+
{ name: "e", cursor: "ew-resize" },
|
|
57
|
+
{ name: "w", cursor: "ew-resize" },
|
|
58
|
+
{ name: "ne", cursor: "nesw-resize" },
|
|
59
|
+
{ name: "nw", cursor: "nwse-resize" },
|
|
60
|
+
{ name: "se", cursor: "nwse-resize" },
|
|
61
|
+
{ name: "sw", cursor: "nesw-resize" }
|
|
62
|
+
];
|
|
63
|
+
function effectiveScale() {
|
|
64
|
+
const el = rootEl.value;
|
|
65
|
+
if (!el) return props.scale;
|
|
66
|
+
const rect = el.getBoundingClientRect();
|
|
67
|
+
const pdfWidth = props.field.rect[2] - props.field.rect[0];
|
|
68
|
+
if (pdfWidth <= 0 || rect.width <= 0) return props.scale;
|
|
69
|
+
return rect.width / pdfWidth;
|
|
70
|
+
}
|
|
71
|
+
const DRAG_THRESHOLD_PX = 3;
|
|
72
|
+
function onChromePointerDown(e) {
|
|
73
|
+
const startX = e.clientX;
|
|
74
|
+
const startY = e.clientY;
|
|
75
|
+
const startRect = [...props.field.rect];
|
|
76
|
+
const s = effectiveScale();
|
|
77
|
+
let dragging = false;
|
|
78
|
+
const onMove = (ev) => {
|
|
79
|
+
if (!dragging) {
|
|
80
|
+
const adx = Math.abs(ev.clientX - startX);
|
|
81
|
+
const ady = Math.abs(ev.clientY - startY);
|
|
82
|
+
if (adx < DRAG_THRESHOLD_PX && ady < DRAG_THRESHOLD_PX) return;
|
|
83
|
+
dragging = true;
|
|
84
|
+
}
|
|
85
|
+
const dx = (ev.clientX - startX) / s;
|
|
86
|
+
const dy = (ev.clientY - startY) / s;
|
|
87
|
+
const pdfDy = -dy;
|
|
88
|
+
const next = [
|
|
89
|
+
startRect[0] + dx,
|
|
90
|
+
startRect[1] + pdfDy,
|
|
91
|
+
startRect[2] + dx,
|
|
92
|
+
startRect[3] + pdfDy
|
|
93
|
+
];
|
|
94
|
+
formFields.updatePlacedField(props.field.id, { rect: next });
|
|
95
|
+
};
|
|
96
|
+
const onUp = () => {
|
|
97
|
+
window.removeEventListener("pointermove", onMove);
|
|
98
|
+
window.removeEventListener("pointerup", onUp);
|
|
99
|
+
if (!dragging) emit("select");
|
|
100
|
+
};
|
|
101
|
+
window.addEventListener("pointermove", onMove);
|
|
102
|
+
window.addEventListener("pointerup", onUp);
|
|
103
|
+
}
|
|
104
|
+
function onHandlePointerDown(e, name) {
|
|
105
|
+
const startX = e.clientX;
|
|
106
|
+
const startY = e.clientY;
|
|
107
|
+
const [sx1, sy1, sx2, sy2] = props.field.rect;
|
|
108
|
+
const s = effectiveScale();
|
|
109
|
+
const onMove = (ev) => {
|
|
110
|
+
const dx = (ev.clientX - startX) / s;
|
|
111
|
+
const dy = (ev.clientY - startY) / s;
|
|
112
|
+
const pdfDy = -dy;
|
|
113
|
+
let x1 = sx1, y1 = sy1, x2 = sx2, y2 = sy2;
|
|
114
|
+
if (name.includes("n")) y2 = Math.max(y1 + 4, sy2 + pdfDy);
|
|
115
|
+
if (name.includes("s")) y1 = Math.min(y2 - 4, sy1 + pdfDy);
|
|
116
|
+
if (name.includes("e")) x2 = Math.max(x1 + 4, sx2 + dx);
|
|
117
|
+
if (name.includes("w")) x1 = Math.min(x2 - 4, sx1 + dx);
|
|
118
|
+
formFields.updatePlacedField(props.field.id, { rect: [x1, y1, x2, y2] });
|
|
119
|
+
};
|
|
120
|
+
const onUp = () => {
|
|
121
|
+
window.removeEventListener("pointermove", onMove);
|
|
122
|
+
window.removeEventListener("pointerup", onUp);
|
|
123
|
+
};
|
|
124
|
+
window.addEventListener("pointermove", onMove);
|
|
125
|
+
window.addEventListener("pointerup", onUp);
|
|
126
|
+
}
|
|
127
|
+
</script>
|
|
128
|
+
|
|
129
|
+
<style>
|
|
130
|
+
.kviewer-placed-chrome{cursor:move;inset:0;pointer-events:auto;position:absolute;touch-action:none}.kviewer-placed-chrome--selected{outline:1.5px dashed #1677ff;outline-offset:0}.kviewer-placed-chrome__grip{align-items:center;background:rgba(22,119,255,.15);border:1px solid rgba(22,119,255,.4);border-radius:calc(3px*var(--kvw-handle-zoom, 1));bottom:calc(100% + 3px*var(--kvw-handle-zoom, 1));color:#1677ff;cursor:move;display:flex;font-size:calc(9px*var(--kvw-handle-zoom, 1));gap:calc(3px*var(--kvw-handle-zoom, 1));height:calc(16px*var(--kvw-handle-zoom, 1));left:0;line-height:1;overflow:hidden;padding:0 calc(6px*var(--kvw-handle-zoom, 1)) 0 calc(2px*var(--kvw-handle-zoom, 1));pointer-events:auto;position:absolute;right:0;touch-action:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.kviewer-placed-chrome__grip-dots{color:#1677ff;flex:0 0 auto;height:calc(10px*var(--kvw-handle-zoom, 1));width:calc(10px*var(--kvw-handle-zoom, 1))}.kviewer-placed-chrome__grip-label{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.kviewer-placed-chrome__handle{background:#fff;border:1px solid #1677ff;border-radius:2px;height:calc(8px*var(--kvw-handle-zoom, 1));pointer-events:auto;position:absolute;touch-action:none;width:calc(8px*var(--kvw-handle-zoom, 1))}.kviewer-placed-chrome__handle:before{content:"";inset:calc(-8px*var(--kvw-handle-zoom, 1));position:absolute}.kviewer-placed-chrome__handle--n{left:50%;top:calc(-4px*var(--kvw-handle-zoom, 1));transform:translateX(-50%)}.kviewer-placed-chrome__handle--s{bottom:calc(-4px*var(--kvw-handle-zoom, 1));left:50%;transform:translateX(-50%)}.kviewer-placed-chrome__handle--e{right:calc(-4px*var(--kvw-handle-zoom, 1));top:50%;transform:translateY(-50%)}.kviewer-placed-chrome__handle--w{left:calc(-4px*var(--kvw-handle-zoom, 1));top:50%;transform:translateY(-50%)}.kviewer-placed-chrome__handle--ne{right:calc(-4px*var(--kvw-handle-zoom, 1));top:calc(-4px*var(--kvw-handle-zoom, 1))}.kviewer-placed-chrome__handle--nw{left:calc(-4px*var(--kvw-handle-zoom, 1));top:calc(-4px*var(--kvw-handle-zoom, 1))}.kviewer-placed-chrome__handle--se{bottom:calc(-4px*var(--kvw-handle-zoom, 1));right:calc(-4px*var(--kvw-handle-zoom, 1))}.kviewer-placed-chrome__handle--sw{bottom:calc(-4px*var(--kvw-handle-zoom, 1));left:calc(-4px*var(--kvw-handle-zoom, 1))}
|
|
131
|
+
</style>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { FormFieldDefinition } from '../../annotation/engine/types.js';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
field: FormFieldDefinition;
|
|
4
|
+
selected: boolean;
|
|
5
|
+
/** CSS pixels per PDF unit for the current page. */
|
|
6
|
+
scale: number;
|
|
7
|
+
/** PDF-space page height (kept for parity; unused here). */
|
|
8
|
+
pageHeight: number;
|
|
9
|
+
};
|
|
10
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
11
|
+
select: () => any;
|
|
12
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
13
|
+
onSelect?: (() => any) | undefined;
|
|
14
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
15
|
+
declare const _default: typeof __VLS_export;
|
|
16
|
+
export default _default;
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<UModal v-model:open="isOpen" title="Draw Signature" :ui="{ content: 'sm:max-w-
|
|
2
|
+
<UModal v-model:open="isOpen" title="Draw Signature" :ui="{ content: 'sm:max-w-2xl' }">
|
|
3
3
|
<template #body>
|
|
4
4
|
<div class="flex flex-col gap-3">
|
|
5
5
|
<div
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
ref="canvasWrapEl"
|
|
7
|
+
class="border border-default rounded bg-white relative w-full"
|
|
8
|
+
:style="{ aspectRatio: `${canvasAspect}` }"
|
|
8
9
|
>
|
|
9
10
|
<canvas
|
|
10
11
|
ref="canvasRef"
|
|
11
|
-
|
|
12
|
-
:height="canvasHeight"
|
|
13
|
-
class="cursor-crosshair"
|
|
12
|
+
class="cursor-crosshair block w-full h-full"
|
|
14
13
|
@pointerdown="onPointerDown"
|
|
15
14
|
@pointermove="onPointerMove"
|
|
16
15
|
@pointerup="onPointerUp"
|
|
@@ -50,7 +49,7 @@
|
|
|
50
49
|
</template>
|
|
51
50
|
|
|
52
51
|
<script setup>
|
|
53
|
-
import { ref, watch, nextTick } from "vue";
|
|
52
|
+
import { ref, watch, nextTick, onBeforeUnmount } from "vue";
|
|
54
53
|
import { defaultOptions } from "../../annotation/engine/config";
|
|
55
54
|
const props = defineProps({
|
|
56
55
|
open: { type: Boolean, required: true }
|
|
@@ -64,21 +63,51 @@ watch(
|
|
|
64
63
|
if (v) {
|
|
65
64
|
hasDrawn.value = false;
|
|
66
65
|
await nextTick();
|
|
66
|
+
syncCanvasSize();
|
|
67
67
|
clearCanvas();
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
);
|
|
71
71
|
watch(isOpen, (v) => emit("update:open", v));
|
|
72
|
-
const
|
|
73
|
-
const canvasHeight = defaultOptions.signature.HEIGHT;
|
|
72
|
+
const canvasAspect = `${defaultOptions.signature.WIDTH} / ${defaultOptions.signature.HEIGHT}`;
|
|
74
73
|
const signatureColors = defaultOptions.signature.COLORS;
|
|
75
74
|
const canvasRef = ref(null);
|
|
75
|
+
const canvasWrapEl = ref(null);
|
|
76
76
|
const strokeColor = ref(signatureColors[0]);
|
|
77
77
|
const hasDrawn = ref(false);
|
|
78
78
|
let isDrawing = false;
|
|
79
|
+
function syncCanvasSize() {
|
|
80
|
+
const canvas = canvasRef.value;
|
|
81
|
+
const wrap = canvasWrapEl.value;
|
|
82
|
+
if (!canvas || !wrap) return;
|
|
83
|
+
const cssW = Math.round(wrap.clientWidth);
|
|
84
|
+
const cssH = Math.round(wrap.clientHeight);
|
|
85
|
+
if (cssW <= 0 || cssH <= 0) return;
|
|
86
|
+
const dpr = window.devicePixelRatio || 1;
|
|
87
|
+
const targetW = Math.round(cssW * dpr);
|
|
88
|
+
const targetH = Math.round(cssH * dpr);
|
|
89
|
+
if (canvas.width === targetW && canvas.height === targetH) return;
|
|
90
|
+
canvas.width = targetW;
|
|
91
|
+
canvas.height = targetH;
|
|
92
|
+
const ctx = canvas.getContext("2d");
|
|
93
|
+
ctx?.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
94
|
+
hasDrawn.value = false;
|
|
95
|
+
}
|
|
96
|
+
let resizeObserver = null;
|
|
97
|
+
watch(canvasWrapEl, (el) => {
|
|
98
|
+
resizeObserver?.disconnect();
|
|
99
|
+
resizeObserver = null;
|
|
100
|
+
if (!el || typeof ResizeObserver === "undefined") return;
|
|
101
|
+
resizeObserver = new ResizeObserver(() => syncCanvasSize());
|
|
102
|
+
resizeObserver.observe(el);
|
|
103
|
+
});
|
|
104
|
+
onBeforeUnmount(() => resizeObserver?.disconnect());
|
|
79
105
|
function getCtx() {
|
|
80
106
|
return canvasRef.value?.getContext("2d") ?? null;
|
|
81
107
|
}
|
|
108
|
+
const STROKE_WIDTH = 2.5;
|
|
109
|
+
let lastPoint = null;
|
|
110
|
+
let lastMid = null;
|
|
82
111
|
function onPointerDown(e) {
|
|
83
112
|
isDrawing = true;
|
|
84
113
|
hasDrawn.value = true;
|
|
@@ -86,26 +115,52 @@ function onPointerDown(e) {
|
|
|
86
115
|
if (!ctx) return;
|
|
87
116
|
e.target.setPointerCapture(e.pointerId);
|
|
88
117
|
ctx.strokeStyle = strokeColor.value;
|
|
89
|
-
ctx.
|
|
118
|
+
ctx.fillStyle = strokeColor.value;
|
|
119
|
+
ctx.lineWidth = STROKE_WIDTH;
|
|
90
120
|
ctx.lineCap = "round";
|
|
91
121
|
ctx.lineJoin = "round";
|
|
122
|
+
const p = { x: e.offsetX, y: e.offsetY };
|
|
123
|
+
lastPoint = p;
|
|
124
|
+
lastMid = p;
|
|
92
125
|
ctx.beginPath();
|
|
93
|
-
ctx.
|
|
126
|
+
ctx.arc(p.x, p.y, STROKE_WIDTH / 2, 0, Math.PI * 2);
|
|
127
|
+
ctx.fill();
|
|
94
128
|
}
|
|
95
129
|
function onPointerMove(e) {
|
|
96
|
-
if (!isDrawing) return;
|
|
130
|
+
if (!isDrawing || !lastPoint || !lastMid) return;
|
|
97
131
|
const ctx = getCtx();
|
|
98
132
|
if (!ctx) return;
|
|
99
|
-
|
|
133
|
+
const p = { x: e.offsetX, y: e.offsetY };
|
|
134
|
+
const mid = { x: (lastPoint.x + p.x) / 2, y: (lastPoint.y + p.y) / 2 };
|
|
135
|
+
ctx.beginPath();
|
|
136
|
+
ctx.moveTo(lastMid.x, lastMid.y);
|
|
137
|
+
ctx.quadraticCurveTo(lastPoint.x, lastPoint.y, mid.x, mid.y);
|
|
100
138
|
ctx.stroke();
|
|
139
|
+
lastPoint = p;
|
|
140
|
+
lastMid = mid;
|
|
101
141
|
}
|
|
102
142
|
function onPointerUp() {
|
|
143
|
+
if (isDrawing && lastPoint && lastMid) {
|
|
144
|
+
const ctx = getCtx();
|
|
145
|
+
if (ctx) {
|
|
146
|
+
ctx.beginPath();
|
|
147
|
+
ctx.moveTo(lastMid.x, lastMid.y);
|
|
148
|
+
ctx.lineTo(lastPoint.x, lastPoint.y);
|
|
149
|
+
ctx.stroke();
|
|
150
|
+
}
|
|
151
|
+
}
|
|
103
152
|
isDrawing = false;
|
|
153
|
+
lastPoint = null;
|
|
154
|
+
lastMid = null;
|
|
104
155
|
}
|
|
105
156
|
function clearCanvas() {
|
|
157
|
+
const canvas = canvasRef.value;
|
|
106
158
|
const ctx = getCtx();
|
|
107
|
-
if (!ctx) return;
|
|
108
|
-
ctx.
|
|
159
|
+
if (!canvas || !ctx) return;
|
|
160
|
+
ctx.save();
|
|
161
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
162
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
163
|
+
ctx.restore();
|
|
109
164
|
hasDrawn.value = false;
|
|
110
165
|
}
|
|
111
166
|
function submit() {
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|