@operato/image-marker 8.0.0-alpha.18 → 8.0.0-alpha.22
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/CHANGELOG.md +9 -0
- package/dist/src/base-image-marker.d.ts +16 -4
- package/dist/src/base-image-marker.js +96 -15
- package/dist/src/base-image-marker.js.map +1 -1
- package/dist/src/ox-image-marker-mode.js +2 -2
- package/dist/src/ox-image-marker-mode.js.map +1 -1
- package/dist/src/ox-image-marker-view.js +2 -2
- package/dist/src/ox-image-marker-view.js.map +1 -1
- package/dist/src/ox-image-marker.d.ts +7 -6
- package/dist/src/ox-image-marker.js +150 -71
- package/dist/src/ox-image-marker.js.map +1 -1
- package/dist/stories/ox-image-marker.stories.js +16 -0
- package/dist/stories/ox-image-marker.stories.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/base-image-marker.ts +114 -19
- package/src/ox-image-marker-mode.ts +2 -2
- package/src/ox-image-marker-view.ts +2 -2
- package/src/ox-image-marker.ts +170 -81
- package/stories/ox-image-marker.stories.ts +16 -0
|
@@ -15,14 +15,27 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
15
15
|
this.startY = 0;
|
|
16
16
|
this.offsetX = 0;
|
|
17
17
|
this.offsetY = 0;
|
|
18
|
-
this.
|
|
19
|
-
if (
|
|
20
|
-
this.
|
|
18
|
+
this.onSvgTouchStart = (event) => {
|
|
19
|
+
if (event.touches.length === 1) {
|
|
20
|
+
this.selectedShape = null;
|
|
21
|
+
this.shapes = this.shapes.map(s => {
|
|
22
|
+
return { ...s, selected: false };
|
|
23
|
+
});
|
|
24
|
+
if (this.currentMode === 'move') {
|
|
25
|
+
this.startPanning(event);
|
|
26
|
+
}
|
|
27
|
+
else if (this.currentMode === 'draw') {
|
|
28
|
+
this.startDrawing(event);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else if (event.touches.length === 2) {
|
|
32
|
+
this.startPinchZooming(event);
|
|
21
33
|
}
|
|
22
34
|
};
|
|
23
|
-
this.
|
|
24
|
-
if (!this.drawing)
|
|
35
|
+
this.onDrawingMouseMove = (event) => {
|
|
36
|
+
if (!this.drawing) {
|
|
25
37
|
return;
|
|
38
|
+
}
|
|
26
39
|
const { x, y } = this.getSvgPoint(event);
|
|
27
40
|
const minDistance = 5;
|
|
28
41
|
const distance = Math.sqrt(Math.pow(x - this.startX, 2) + Math.pow(y - this.startY, 2));
|
|
@@ -114,19 +127,26 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
114
127
|
this.requestUpdate();
|
|
115
128
|
}
|
|
116
129
|
};
|
|
117
|
-
this.
|
|
130
|
+
this.onDrawingMouseUp = (event) => {
|
|
118
131
|
this.drawing = false;
|
|
119
132
|
const svg = this.svg;
|
|
120
|
-
|
|
121
|
-
|
|
133
|
+
if ('touches' in event) {
|
|
134
|
+
svg.removeEventListener('touchmove', this.onDrawingMouseMove);
|
|
135
|
+
svg.removeEventListener('touchend', this.onDrawingMouseUp);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
svg.removeEventListener('mousemove', this.onDrawingMouseMove);
|
|
139
|
+
svg.removeEventListener('mouseup', this.onDrawingMouseUp);
|
|
140
|
+
}
|
|
122
141
|
if (this.selectedShape) {
|
|
123
142
|
this.selectedShape.selected = true;
|
|
124
143
|
}
|
|
125
144
|
this.requestUpdate();
|
|
126
145
|
};
|
|
127
146
|
this.onShapeMouseMove = (event) => {
|
|
128
|
-
if (!this.selectedShape)
|
|
147
|
+
if (!this.selectedShape) {
|
|
129
148
|
return;
|
|
149
|
+
}
|
|
130
150
|
const { x, y } = this.getSvgPoint(event);
|
|
131
151
|
switch (this.selectedShape.type) {
|
|
132
152
|
case 'text':
|
|
@@ -159,24 +179,64 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
159
179
|
}
|
|
160
180
|
this.requestUpdate();
|
|
161
181
|
};
|
|
162
|
-
this.onShapeMouseUp = () => {
|
|
182
|
+
this.onShapeMouseUp = (event) => {
|
|
163
183
|
const svg = this.svg;
|
|
164
|
-
|
|
165
|
-
|
|
184
|
+
if ('touches' in event) {
|
|
185
|
+
svg.removeEventListener('touchmove', this.onShapeMouseMove);
|
|
186
|
+
svg.removeEventListener('touchend', this.onShapeMouseUp);
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
svg.removeEventListener('mousemove', this.onShapeMouseMove);
|
|
190
|
+
svg.removeEventListener('mouseup', this.onShapeMouseUp);
|
|
191
|
+
}
|
|
166
192
|
};
|
|
167
193
|
this.onHandleMouseMove = (event) => {
|
|
168
|
-
if (!this.selectedShape)
|
|
194
|
+
if (!this.selectedShape) {
|
|
169
195
|
return;
|
|
196
|
+
}
|
|
170
197
|
const { x, y } = this.getSvgPoint(event);
|
|
171
198
|
switch (this.selectedShape.type) {
|
|
172
|
-
case 'text':
|
|
199
|
+
// case 'text':
|
|
200
|
+
// this.selectedShape.width = Math.abs(x - this.selectedShape.x!)
|
|
201
|
+
// this.selectedShape.height = Math.abs(y - this.selectedShape.y!)
|
|
202
|
+
// if (x < this.selectedShape.x!) this.selectedShape.x = x
|
|
203
|
+
// if (y < this.selectedShape.y!) this.selectedShape.y = y
|
|
204
|
+
// break
|
|
173
205
|
case 'rectangle':
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
206
|
+
const startX = this.selectedShape.x;
|
|
207
|
+
const startY = this.selectedShape.y;
|
|
208
|
+
const width = this.selectedShape.width;
|
|
209
|
+
const height = this.selectedShape.height;
|
|
210
|
+
// 핸들의 좌표에 따라 너비 및 높이 조정
|
|
211
|
+
if (this.offsetX === startX && this.offsetY === startY) {
|
|
212
|
+
// 상좌 핸들 (왼쪽 위)
|
|
177
213
|
this.selectedShape.x = x;
|
|
178
|
-
if (y < this.selectedShape.y)
|
|
179
214
|
this.selectedShape.y = y;
|
|
215
|
+
this.selectedShape.width = width + (startX - x);
|
|
216
|
+
this.selectedShape.height = height + (startY - y);
|
|
217
|
+
}
|
|
218
|
+
else if (this.offsetX === startX + width && this.offsetY === startY) {
|
|
219
|
+
// 상우 핸들 (오른쪽 위)
|
|
220
|
+
this.selectedShape.y = y;
|
|
221
|
+
this.selectedShape.width = Math.abs(x - startX);
|
|
222
|
+
this.selectedShape.height = height + (startY - y);
|
|
223
|
+
}
|
|
224
|
+
else if (this.offsetX === startX && this.offsetY === startY + height) {
|
|
225
|
+
// 하좌 핸들 (왼쪽 아래)
|
|
226
|
+
this.selectedShape.x = x;
|
|
227
|
+
this.selectedShape.width = width + (startX - x);
|
|
228
|
+
this.selectedShape.height = Math.abs(y - startY);
|
|
229
|
+
}
|
|
230
|
+
else if (this.offsetX === startX + width && this.offsetY === startY + height) {
|
|
231
|
+
// 하우 핸들 (오른쪽 아래)
|
|
232
|
+
this.selectedShape.width = Math.abs(x - startX);
|
|
233
|
+
this.selectedShape.height = Math.abs(y - startY);
|
|
234
|
+
}
|
|
235
|
+
// 최소 너비 및 높이 유지
|
|
236
|
+
this.selectedShape.width = Math.max(10, this.selectedShape.width);
|
|
237
|
+
this.selectedShape.height = Math.max(10, this.selectedShape.height);
|
|
238
|
+
this.offsetX = x;
|
|
239
|
+
this.offsetY = y;
|
|
180
240
|
break;
|
|
181
241
|
case 'circle':
|
|
182
242
|
const dx = x - this.selectedShape.cx;
|
|
@@ -209,12 +269,29 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
209
269
|
}
|
|
210
270
|
this.requestUpdate();
|
|
211
271
|
};
|
|
212
|
-
this.onHandleMouseUp = () => {
|
|
272
|
+
this.onHandleMouseUp = (event) => {
|
|
213
273
|
const svg = this.svg;
|
|
214
|
-
|
|
215
|
-
|
|
274
|
+
if ('touches' in event) {
|
|
275
|
+
svg.removeEventListener('touchmove', this.onHandleMouseMove);
|
|
276
|
+
svg.removeEventListener('touchend', this.onHandleMouseUp);
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
svg.removeEventListener('mousemove', this.onHandleMouseMove);
|
|
280
|
+
svg.removeEventListener('mouseup', this.onHandleMouseUp);
|
|
281
|
+
}
|
|
216
282
|
this.selectedShape = null;
|
|
217
283
|
};
|
|
284
|
+
this.onFocus = () => {
|
|
285
|
+
this.addEventListener('keydown', this.handleKeyDown);
|
|
286
|
+
};
|
|
287
|
+
this.onBlur = () => {
|
|
288
|
+
this.removeEventListener('keydown', this.handleKeyDown);
|
|
289
|
+
};
|
|
290
|
+
this.handleKeyDown = (event) => {
|
|
291
|
+
if ((event.key === 'Delete' || event.key === 'Backspace') && this.selectedShape) {
|
|
292
|
+
this.deleteSelectedShape();
|
|
293
|
+
}
|
|
294
|
+
};
|
|
218
295
|
}
|
|
219
296
|
static { this.styles = [
|
|
220
297
|
...BaseImageMarker.styles,
|
|
@@ -247,28 +324,23 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
247
324
|
]; }
|
|
248
325
|
connectedCallback() {
|
|
249
326
|
super.connectedCallback();
|
|
250
|
-
|
|
251
|
-
|
|
327
|
+
this.setAttribute('tabindex', '0');
|
|
328
|
+
this.addEventListener('focus', this.onFocus);
|
|
329
|
+
this.addEventListener('blur', this.onBlur);
|
|
252
330
|
}
|
|
253
331
|
disconnectedCallback() {
|
|
254
332
|
super.disconnectedCallback();
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}
|
|
258
|
-
deleteSelectedShape() {
|
|
259
|
-
if (this.selectedShape) {
|
|
260
|
-
this.shapes = this.shapes.filter(s => s.id !== this.selectedShape.id);
|
|
261
|
-
this.selectedShape = null;
|
|
262
|
-
this.requestUpdate();
|
|
263
|
-
}
|
|
333
|
+
this.removeEventListener('focus', this.onFocus);
|
|
334
|
+
this.removeEventListener('blur', this.onBlur);
|
|
264
335
|
}
|
|
265
336
|
render() {
|
|
266
337
|
return html `
|
|
267
338
|
<div class="container">
|
|
268
339
|
<svg
|
|
269
340
|
@mousedown=${this.onSvgMouseDown}
|
|
270
|
-
@
|
|
271
|
-
@
|
|
341
|
+
@touchstart=${this.onSvgTouchStart}
|
|
342
|
+
@wheel=${this.onSvgWheel}
|
|
343
|
+
@dblclick=${this.onSvgDoubleClick}
|
|
272
344
|
viewBox=${this.viewBox}
|
|
273
345
|
>
|
|
274
346
|
<image href=${this.imageUrl} @load=${this.onImageLoad}></image>
|
|
@@ -283,8 +355,8 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
283
355
|
const { mode, shapeType } = e.detail;
|
|
284
356
|
this.setMode(mode, shapeType);
|
|
285
357
|
}}
|
|
286
|
-
@
|
|
287
|
-
@
|
|
358
|
+
@tap-delete=${() => this.deleteSelectedShape()}
|
|
359
|
+
@tap-save=${() => {
|
|
288
360
|
this.dispatchEvent(new CustomEvent('shapes-changed', {
|
|
289
361
|
detail: this.shapes,
|
|
290
362
|
bubbles: true,
|
|
@@ -295,35 +367,15 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
295
367
|
`;
|
|
296
368
|
}
|
|
297
369
|
onSvgMouseDown(event) {
|
|
298
|
-
const svg = this.svg;
|
|
299
370
|
this.selectedShape = null;
|
|
300
371
|
this.shapes = this.shapes.map(s => {
|
|
301
372
|
return { ...s, selected: false };
|
|
302
373
|
});
|
|
303
|
-
this.selectedShape = null;
|
|
304
374
|
if (this.currentMode === 'move') {
|
|
305
|
-
this.
|
|
306
|
-
this.panStart = { x: event.clientX, y: event.clientY };
|
|
307
|
-
svg.classList.add('dragging');
|
|
308
|
-
svg.addEventListener('mousemove', this.onPanMouseMove);
|
|
309
|
-
svg.addEventListener('mouseup', this.onPanMouseUp);
|
|
310
|
-
}
|
|
311
|
-
else if (this.currentMode === 'select') {
|
|
312
|
-
this.startShapeDragging(event);
|
|
313
|
-
svg.addEventListener('mousemove', this.onShapeMouseMove);
|
|
314
|
-
svg.addEventListener('mouseup', this.onShapeMouseUp);
|
|
375
|
+
this.startPanning(event);
|
|
315
376
|
}
|
|
316
377
|
else if (this.currentMode === 'draw') {
|
|
317
378
|
this.startDrawing(event);
|
|
318
|
-
svg.addEventListener('mousemove', this.onMouseMove);
|
|
319
|
-
svg.addEventListener('mouseup', this.onMouseUp);
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
startShapeDragging(event) {
|
|
323
|
-
const { x, y } = this.getSvgPoint(event);
|
|
324
|
-
if (this.selectedShape) {
|
|
325
|
-
this.offsetX = x - (this.selectedShape.x || this.selectedShape.cx || 0);
|
|
326
|
-
this.offsetY = y - (this.selectedShape.y || this.selectedShape.cy || 0);
|
|
327
379
|
}
|
|
328
380
|
}
|
|
329
381
|
startDrawing(event) {
|
|
@@ -343,16 +395,25 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
343
395
|
this.startY = y;
|
|
344
396
|
this.drawing = true;
|
|
345
397
|
}
|
|
398
|
+
if ('touches' in event) {
|
|
399
|
+
this.svg.addEventListener('touchmove', this.onDrawingMouseMove);
|
|
400
|
+
this.svg.addEventListener('touchend', this.onDrawingMouseUp);
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
this.svg.addEventListener('mousemove', this.onDrawingMouseMove);
|
|
404
|
+
this.svg.addEventListener('mouseup', this.onDrawingMouseUp);
|
|
405
|
+
}
|
|
346
406
|
}
|
|
347
407
|
setMode(mode, shapeType) {
|
|
348
408
|
this.currentMode = mode;
|
|
349
409
|
this.currentShapeType = shapeType;
|
|
350
410
|
}
|
|
351
411
|
getSvgPoint(event) {
|
|
412
|
+
const { x, y } = this.getPointFromEvent(event);
|
|
352
413
|
const svg = this.svg;
|
|
353
414
|
const point = svg.createSVGPoint();
|
|
354
|
-
point.x =
|
|
355
|
-
point.y =
|
|
415
|
+
point.x = x;
|
|
416
|
+
point.y = y;
|
|
356
417
|
const ctm = svg.getScreenCTM().inverse();
|
|
357
418
|
return point.matrixTransform(ctm);
|
|
358
419
|
}
|
|
@@ -372,6 +433,7 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
372
433
|
fill="${commonAttrs.stroke}"
|
|
373
434
|
style="cursor: ${commonAttrs.cursor}; font-size: 16px;"
|
|
374
435
|
@mousedown="${(e) => this.onShapeMouseDown(e, shape)}"
|
|
436
|
+
@touchstart="${(e) => this.onShapeMouseDown(e, shape)}"
|
|
375
437
|
@dblclick="${(e) => this.onTextDoubleClick(e, shape)}"
|
|
376
438
|
>${shape.text}</text>
|
|
377
439
|
`;
|
|
@@ -387,6 +449,7 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
387
449
|
fill="${commonAttrs.fill}"
|
|
388
450
|
style="cursor: ${commonAttrs.cursor}"
|
|
389
451
|
@mousedown="${(e) => this.onShapeMouseDown(e, shape)}"
|
|
452
|
+
@touchstart="${(e) => this.onShapeMouseDown(e, shape)}"
|
|
390
453
|
></rect>
|
|
391
454
|
${shape.selected ? this.renderResizeHandles(shape) : ''}
|
|
392
455
|
`;
|
|
@@ -401,6 +464,7 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
401
464
|
fill="${commonAttrs.fill}"
|
|
402
465
|
style="cursor: ${commonAttrs.cursor}"
|
|
403
466
|
@mousedown="${(e) => this.onShapeMouseDown(e, shape)}"
|
|
467
|
+
@touchstart="${(e) => this.onShapeMouseDown(e, shape)}"
|
|
404
468
|
></circle>
|
|
405
469
|
${shape.selected ? this.renderResizeHandles(shape) : ''}
|
|
406
470
|
`;
|
|
@@ -413,6 +477,7 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
413
477
|
fill="${commonAttrs.fill}"
|
|
414
478
|
style="cursor: ${commonAttrs.cursor}"
|
|
415
479
|
@mousedown="${(e) => this.onShapeMouseDown(e, shape)}"
|
|
480
|
+
@touchstart="${(e) => this.onShapeMouseDown(e, shape)}"
|
|
416
481
|
></polygon>
|
|
417
482
|
${shape.selected ? this.renderResizeHandles(shape) : ''}
|
|
418
483
|
`;
|
|
@@ -427,6 +492,7 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
427
492
|
stroke-width="${commonAttrs['stroke-width']}"
|
|
428
493
|
style="cursor: ${commonAttrs.cursor}"
|
|
429
494
|
@mousedown="${(e) => this.onShapeMouseDown(e, shape)}"
|
|
495
|
+
@touchstart="${(e) => this.onShapeMouseDown(e, shape)}"
|
|
430
496
|
></line>
|
|
431
497
|
${shape.selected ? this.renderResizeHandles(shape) : ''}
|
|
432
498
|
`;
|
|
@@ -447,6 +513,7 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
447
513
|
marker-end="url(#arrowhead-${shape.id})"
|
|
448
514
|
style="cursor: ${commonAttrs.cursor}"
|
|
449
515
|
@mousedown="${(e) => this.onShapeMouseDown(e, shape)}"
|
|
516
|
+
@touchstart="${(e) => this.onShapeMouseDown(e, shape)}"
|
|
450
517
|
></line>
|
|
451
518
|
${shape.selected ? this.renderResizeHandles(shape) : ''}
|
|
452
519
|
`;
|
|
@@ -482,16 +549,14 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
482
549
|
break;
|
|
483
550
|
}
|
|
484
551
|
const svg = this.svg;
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
const scaleY = vbHeight / this.svg.clientHeight;
|
|
494
|
-
return Math.max(scaleX, scaleY);
|
|
552
|
+
if ('touches' in event) {
|
|
553
|
+
svg.addEventListener('touchmove', this.onShapeMouseMove);
|
|
554
|
+
svg.addEventListener('touchend', this.onShapeMouseUp);
|
|
555
|
+
}
|
|
556
|
+
else {
|
|
557
|
+
svg.addEventListener('mousemove', this.onShapeMouseMove);
|
|
558
|
+
svg.addEventListener('mouseup', this.onShapeMouseUp);
|
|
559
|
+
}
|
|
495
560
|
}
|
|
496
561
|
renderResizeHandles(shape) {
|
|
497
562
|
let handles = [];
|
|
@@ -541,6 +606,7 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
541
606
|
class="resize-handle"
|
|
542
607
|
style="cursor: ${handle.cursor};"
|
|
543
608
|
@mousedown="${(e) => this.onHandleMouseDown(e, shape, handle)}"
|
|
609
|
+
@touchstart="${(e) => this.onHandleMouseDown(e, shape, handle)}"
|
|
544
610
|
></rect>
|
|
545
611
|
</g>
|
|
546
612
|
`)}
|
|
@@ -552,8 +618,14 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
552
618
|
this.offsetX = handle.x;
|
|
553
619
|
this.offsetY = handle.y;
|
|
554
620
|
const svg = this.svg;
|
|
555
|
-
|
|
556
|
-
|
|
621
|
+
if ('touches' in event) {
|
|
622
|
+
svg.addEventListener('touchmove', this.onHandleMouseMove);
|
|
623
|
+
svg.addEventListener('touchend', this.onHandleMouseUp);
|
|
624
|
+
}
|
|
625
|
+
else {
|
|
626
|
+
svg.addEventListener('mousemove', this.onHandleMouseMove);
|
|
627
|
+
svg.addEventListener('mouseup', this.onHandleMouseUp);
|
|
628
|
+
}
|
|
557
629
|
}
|
|
558
630
|
onTextDoubleClick(event, shape) {
|
|
559
631
|
event.stopPropagation();
|
|
@@ -660,6 +732,13 @@ let OxImageMarker = class OxImageMarker extends BaseImageMarker {
|
|
|
660
732
|
context.font = window.getComputedStyle(input).font;
|
|
661
733
|
return context.measureText(text).width;
|
|
662
734
|
}
|
|
735
|
+
deleteSelectedShape() {
|
|
736
|
+
if (this.selectedShape) {
|
|
737
|
+
this.shapes = this.shapes.filter(s => s.id !== this.selectedShape.id);
|
|
738
|
+
this.selectedShape = null;
|
|
739
|
+
this.requestUpdate();
|
|
740
|
+
}
|
|
741
|
+
}
|
|
663
742
|
};
|
|
664
743
|
__decorate([
|
|
665
744
|
state()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ox-image-marker.js","sourceRoot":"","sources":["../../src/ox-image-marker.ts"],"names":[],"mappings":";AAAA,OAAO,wBAAwB,CAAA;AAE/B,OAAO,EAAE,IAAI,EAA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AC;oBACxB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;gBAClC,CAAC;YACH,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC;IAEO,gBAAgB,CAAC,KAAuB;QAC9C,MAAM,QAAQ,GAAG,EAAE,CAAA;QACnB,MAAM,SAAS,GAAG,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,CAAA;QAChF,KAAK,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,GAAG,EAAE,EAAE,QAAQ,CAAC,IAAI,CAAA;IAC/D,CAAC;IAEO,gBAAgB,CAAC,IAAY,EAAE,KAAuB;QAC5D,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;QAC/C,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAE,CAAA;QACxC,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,IAAI,CAAA;QAElD,OAAO,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,KAAK,CAAA;IACxC,CAAC;;AA3rBgB;IAAhB,KAAK,EAAE;uDAAqC;AAC5B;IAAhB,KAAK,EAAE;kDAAgD;AACvC;IAAhB,KAAK,EAAE;oDAA2C;AAjCxC,aAAa;IADzB,aAAa,CAAC,iBAAiB,CAAC;GACpB,aAAa,CA2tBzB","sourcesContent":["import './ox-image-marker-mode'\n\nimport { html, css, svg, nothing } from 'lit'\nimport { state, customElement } from 'lit/decorators.js'\nimport { ifDefined } from 'lit/directives/if-defined.js'\nimport { keyed } from 'lit/directives/keyed.js'\n\nimport { ImageMarkerMode, Shape, ShapeType } from './types'\nimport { BaseImageMarker } from './base-image-marker'\n\n@customElement('ox-image-marker')\nexport class OxImageMarker extends BaseImageMarker {\n static styles = [\n ...BaseImageMarker.styles,\n css`\n :host {\n position: relative;\n display: flex;\n width: 100%;\n height: 100%;\n }\n\n ox-image-marker-mode {\n position: absolute;\n top: 0;\n right: 0;\n }\n\n svg {\n cursor: crosshair;\n }\n\n svg.dragging {\n cursor: move;\n }\n\n .resize-handle {\n cursor: nwse-resize;\n }\n `\n ]\n\n @state() private currentShapeType?: ShapeType\n @state() private currentMode: ImageMarkerMode = 'select'\n @state() private selectedShape: Shape | null = null\n\n private drawing = false\n private startX = 0\n private startY = 0\n private offsetX = 0\n private offsetY = 0\n\n connectedCallback() {\n super.connectedCallback()\n // 키다운 이벤트 리스너 추가\n window.addEventListener('keydown', this.handleKeyDown)\n }\n\n disconnectedCallback() {\n super.disconnectedCallback()\n // 키다운 이벤트 리스너 제거\n window.removeEventListener('keydown', this.handleKeyDown)\n }\n\n private handleKeyDown = (event: KeyboardEvent) => {\n if ((event.key === 'Delete' || event.key === 'Backspace') && this.selectedShape) {\n this.deleteSelectedShape()\n }\n }\n\n private deleteSelectedShape() {\n if (this.selectedShape) {\n this.shapes = this.shapes.filter(s => s.id !== this.selectedShape!.id)\n this.selectedShape = null\n this.requestUpdate()\n }\n }\n\n render() {\n return html`\n <div class=\"container\">\n <svg\n @mousedown=${this.onSvgMouseDown}\n @wheel=${this.onWheel}\n @dblclick=${this.onDoubleClick}\n viewBox=${this.viewBox}\n >\n <image href=${this.imageUrl} @load=${this.onImageLoad}></image>\n ${this.shapes.map(shape => keyed(shape.id, this.renderShape(shape)))}\n </svg>\n </div>\n\n <ox-image-marker-mode\n currentMode=${this.currentMode}\n currentShapeType=${ifDefined(this.currentShapeType)}\n @mode-changed=${(e: CustomEvent) => {\n const { mode, shapeType } = e.detail\n this.setMode(mode, shapeType)\n }}\n @clicked-delete=${() => this.deleteSelectedShape()}\n @clicked-save=${() => {\n this.dispatchEvent(\n new CustomEvent('shapes-changed', {\n detail: this.shapes,\n bubbles: true,\n composed: true\n })\n )\n }}\n ></ox-image-marker-mode>\n `\n }\n\n protected onSvgMouseDown(event: MouseEvent) {\n const svg = this.svg\n\n this.selectedShape = null\n this.shapes = this.shapes.map(s => {\n return { ...s, selected: false }\n })\n\n this.selectedShape = null\n if (this.currentMode === 'move') {\n this.isPanning = true\n this.panStart = { x: event.clientX, y: event.clientY }\n svg.classList.add('dragging')\n svg.addEventListener('mousemove', this.onPanMouseMove)\n svg.addEventListener('mouseup', this.onPanMouseUp)\n } else if (this.currentMode === 'select') {\n this.startShapeDragging(event)\n svg.addEventListener('mousemove', this.onShapeMouseMove)\n svg.addEventListener('mouseup', this.onShapeMouseUp)\n } else if (this.currentMode === 'draw') {\n this.startDrawing(event)\n svg.addEventListener('mousemove', this.onMouseMove)\n svg.addEventListener('mouseup', this.onMouseUp)\n }\n }\n\n private startShapeDragging(event: MouseEvent) {\n const { x, y } = this.getSvgPoint(event)\n if (this.selectedShape) {\n this.offsetX = x - (this.selectedShape.x || this.selectedShape.cx || 0)\n this.offsetY = y - (this.selectedShape.y || this.selectedShape.cy || 0)\n }\n }\n\n private startDrawing(event: MouseEvent) {\n const { x, y } = this.getSvgPoint(event)\n\n if (this.currentShapeType === 'text') {\n const textElement = document.createElementNS('http://www.w3.org/2000/svg', 'text')\n\n textElement.setAttribute('x', x.toString())\n textElement.setAttribute('y', y.toString())\n textElement.textContent = 'ABC'\n\n this.svg.appendChild(textElement)\n\n requestAnimationFrame(() => {\n this.showTextInput(textElement, null, { x, y })\n })\n } else {\n this.startX = x\n this.startY = y\n this.drawing = true\n }\n }\n\n private setMode(mode: ImageMarkerMode, shapeType: ShapeType) {\n this.currentMode = mode\n this.currentShapeType = shapeType\n }\n\n private onMouseMove = (event: MouseEvent) => {\n if (!this.drawing) return\n\n const { x, y } = this.getSvgPoint(event)\n\n const minDistance = 5\n const distance = Math.sqrt(Math.pow(x - this.startX, 2) + Math.pow(y - this.startY, 2))\n\n if (!this.selectedShape && distance >= minDistance) {\n let newShape: Shape\n\n switch (this.currentShapeType) {\n case 'rectangle':\n newShape = {\n id: Date.now().toString(),\n type: 'rectangle',\n x: this.startX,\n y: this.startY,\n width: 0,\n height: 0\n }\n break\n case 'circle':\n newShape = {\n id: Date.now().toString(),\n type: 'circle',\n cx: this.startX,\n cy: this.startY,\n r: 0\n }\n break\n case 'triangle':\n newShape = {\n id: Date.now().toString(),\n type: 'triangle',\n x1: this.startX,\n y1: this.startY,\n width: 0,\n height: 0,\n points: `${this.startX},${this.startY} ${this.startX},${this.startY} ${this.startX},${this.startY}`\n }\n break\n case 'line':\n newShape = {\n id: Date.now().toString(),\n type: 'line',\n x1: this.startX,\n y1: this.startY,\n width: 0,\n height: 0\n }\n break\n case 'arrow':\n newShape = {\n id: Date.now().toString(),\n type: 'arrow',\n x1: this.startX,\n y1: this.startY,\n width: 0,\n height: 0\n }\n break\n default:\n return\n }\n\n this.selectedShape = newShape\n this.shapes = [...this.shapes, newShape]\n }\n\n if (this.selectedShape) {\n switch (this.selectedShape.type) {\n case 'rectangle':\n this.selectedShape.x = Math.min(x, this.startX)\n this.selectedShape.y = Math.min(y, this.startY)\n this.selectedShape.width = Math.abs(x - this.startX)\n this.selectedShape.height = Math.abs(y - this.startY)\n break\n case 'circle':\n const dx = x - this.selectedShape.cx!\n const dy = y - this.selectedShape.cy!\n this.selectedShape.r = Math.sqrt(dx * dx + dy * dy)\n break\n case 'triangle':\n const x2 = x\n const y2 = y\n const x3 = this.startX - (x - this.startX)\n const y3 = y\n this.selectedShape.points = `${this.startX},${this.startY} ${x2},${y2} ${x3},${y3}`\n break\n case 'line':\n case 'arrow':\n this.selectedShape.x2 = x\n this.selectedShape.y2 = y\n break\n }\n\n this.requestUpdate()\n }\n }\n\n private onMouseUp = () => {\n this.drawing = false\n const svg = this.svg as SVGSVGElement\n svg.removeEventListener('mousemove', this.onMouseMove)\n svg.removeEventListener('mouseup', this.onMouseUp)\n\n if (this.selectedShape) {\n this.selectedShape.selected = true\n }\n\n this.requestUpdate()\n }\n\n private getSvgPoint(event: MouseEvent) {\n const svg = this.svg\n const point = svg.createSVGPoint()\n point.x = event.clientX\n point.y = event.clientY\n const ctm = svg.getScreenCTM()!.inverse()\n return point.matrixTransform(ctm)\n }\n\n protected renderShape(shape: Shape) {\n const commonAttrs = {\n stroke: shape.selected ? 'blue' : 'red',\n 'stroke-width': 1,\n fill: 'transparent',\n cursor: 'pointer'\n }\n\n switch (shape.type) {\n case 'text':\n return svg`\n <text\n x=\"${shape.x!}\"\n y=\"${shape.y!}\"\n fill=\"${commonAttrs.stroke}\"\n style=\"cursor: ${commonAttrs.cursor}; font-size: 16px;\"\n @mousedown=\"${(e: MouseEvent) => this.onShapeMouseDown(e, shape)}\"\n @dblclick=\"${(e: MouseEvent) => this.onTextDoubleClick(e, shape)}\"\n >${shape.text}</text>\n `\n\n case 'rectangle':\n return svg`\n <rect\n x=\"${shape.x!}\"\n y=\"${shape.y!}\"\n width=\"${shape.width!}\"\n height=\"${shape.height!}\"\n stroke=\"${commonAttrs.stroke}\"\n stroke-width=\"${commonAttrs['stroke-width']}\"\n fill=\"${commonAttrs.fill}\"\n style=\"cursor: ${commonAttrs.cursor}\"\n @mousedown=\"${(e: MouseEvent) => this.onShapeMouseDown(e, shape)}\"\n ></rect>\n ${shape.selected ? this.renderResizeHandles(shape) : ''}\n `\n\n case 'circle':\n return svg`\n <circle\n cx=\"${shape.cx!}\"\n cy=\"${shape.cy!}\"\n r=\"${shape.r!}\"\n stroke=\"${commonAttrs.stroke}\"\n stroke-width=\"${commonAttrs['stroke-width']}\"\n fill=\"${commonAttrs.fill}\"\n style=\"cursor: ${commonAttrs.cursor}\"\n @mousedown=\"${(e: MouseEvent) => this.onShapeMouseDown(e, shape)}\"\n ></circle>\n ${shape.selected ? this.renderResizeHandles(shape) : ''}\n `\n\n case 'triangle':\n return svg`\n <polygon\n points=\"${shape.points!}\"\n stroke=\"${commonAttrs.stroke}\"\n stroke-width=\"${commonAttrs['stroke-width']}\"\n fill=\"${commonAttrs.fill}\"\n style=\"cursor: ${commonAttrs.cursor}\"\n @mousedown=\"${(e: MouseEvent) => this.onShapeMouseDown(e, shape)}\"\n ></polygon>\n ${shape.selected ? this.renderResizeHandles(shape) : ''}\n `\n\n case 'line':\n return svg`\n <line\n x1=\"${shape.x1!}\"\n y1=\"${shape.y1!}\"\n x2=\"${shape.x2 ?? shape.x1}\"\n y2=\"${shape.y2 ?? shape.y1}\"\n stroke=\"${commonAttrs.stroke}\"\n stroke-width=\"${commonAttrs['stroke-width']}\"\n style=\"cursor: ${commonAttrs.cursor}\"\n @mousedown=\"${(e: MouseEvent) => this.onShapeMouseDown(e, shape)}\"\n ></line>\n ${shape.selected ? this.renderResizeHandles(shape) : ''}\n `\n\n case 'arrow':\n return svg`\n <defs>\n <marker id=\"arrowhead-${shape.id}\" markerWidth=\"10\" markerHeight=\"7\" refX=\"10\" refY=\"3.5\" orient=\"auto\">\n <polygon points=\"0 0, 10 3.5, 0 7\" fill=\"${commonAttrs.stroke}\"></polygon>\n </marker>\n </defs>\n <line\n x1=\"${shape.x1!}\"\n y1=\"${shape.y1!}\"\n x2=\"${shape.x2 ?? shape.x1}\"\n y2=\"${shape.y2 ?? shape.y1}\"\n stroke=\"${commonAttrs.stroke}\"\n stroke-width=\"${commonAttrs['stroke-width']}\"\n marker-end=\"url(#arrowhead-${shape.id})\"\n style=\"cursor: ${commonAttrs.cursor}\"\n @mousedown=\"${(e: MouseEvent) => this.onShapeMouseDown(e, shape)}\"\n ></line>\n ${shape.selected ? this.renderResizeHandles(shape) : ''}\n `\n\n default:\n return nothing\n }\n }\n\n private onShapeMouseDown(event: MouseEvent, shape: Shape) {\n event.stopPropagation()\n\n this.shapes = this.shapes.map(s => ({\n ...s,\n selected: s.id === shape.id\n }))\n\n this.selectedShape = this.shapes.find(s => s.id == shape.id)!\n\n const { x, y } = this.getSvgPoint(event)\n\n switch (shape.type) {\n case 'text':\n case 'rectangle':\n case 'circle':\n this.offsetX = x - (shape.x || shape.cx || 0)\n this.offsetY = y - (shape.y || shape.cy || 0)\n break\n\n case 'triangle':\n const points = this.selectedShape.points!.split(' ').map(p => p.split(',').map(Number))\n const [px, py] = points[0] || [0, 0]\n\n this.offsetX = x - px\n this.offsetY = y - py\n\n break\n\n case 'line':\n case 'arrow':\n this.offsetX = x - shape.x1!\n this.offsetY = y - shape.y1!\n break\n }\n\n const svg = this.svg as SVGSVGElement\n svg.addEventListener('mousemove', this.onShapeMouseMove)\n svg.addEventListener('mouseup', this.onShapeMouseUp)\n }\n\n private onShapeMouseMove = (event: MouseEvent) => {\n if (!this.selectedShape) return\n\n const { x, y } = this.getSvgPoint(event)\n\n switch (this.selectedShape.type) {\n case 'text':\n case 'rectangle':\n this.selectedShape.x = x - this.offsetX\n this.selectedShape.y = y - this.offsetY\n break\n case 'circle':\n this.selectedShape.cx = x - this.offsetX\n this.selectedShape.cy = y - this.offsetY\n break\n case 'triangle':\n const points = this.selectedShape.points!.split(' ').map(p => p.split(',').map(Number))\n const [ox, oy] = points[0]\n\n this.selectedShape.points = points\n .map(([px, py]) => [px - ox + x - this.offsetX, py - oy + y - this.offsetY].join(','))\n .join(' ')\n break\n case 'line':\n case 'arrow':\n const dxLine = x - this.offsetX\n const dyLine = y - this.offsetY\n const deltaX = dxLine - this.selectedShape.x1!\n const deltaY = dyLine - this.selectedShape.y1!\n this.selectedShape.x1 = dxLine\n this.selectedShape.y1 = dyLine\n this.selectedShape.x2 = this.selectedShape.x2! + deltaX\n this.selectedShape.y2 = this.selectedShape.y2! + deltaY\n break\n }\n\n this.requestUpdate()\n }\n\n private onShapeMouseUp = () => {\n const svg = this.svg as SVGSVGElement\n svg.removeEventListener('mousemove', this.onShapeMouseMove)\n svg.removeEventListener('mouseup', this.onShapeMouseUp)\n }\n\n private getScale(): number {\n if (!this.svg) return 1\n\n const [vbWidth, vbHeight] = this.viewBox.split(' ').map(Number)\n\n const scaleX = vbWidth / this.svg.clientWidth\n const scaleY = vbHeight / this.svg.clientHeight\n\n return Math.max(scaleX, scaleY)\n }\n\n private renderResizeHandles(shape: Shape) {\n let handles: Array<{ x: number; y: number; cursor: string }> = []\n\n switch (shape.type) {\n case 'text':\n case 'rectangle':\n handles = [\n { x: shape.x!, y: shape.y!, cursor: 'nwse-resize' },\n { x: shape.x! + shape.width!, y: shape.y!, cursor: 'nesw-resize' },\n { x: shape.x!, y: shape.y! + shape.height!, cursor: 'nesw-resize' },\n { x: shape.x! + shape.width!, y: shape.y! + shape.height!, cursor: 'nwse-resize' }\n ]\n break\n case 'circle':\n handles = [\n { x: shape.cx! + shape.r!, y: shape.cy!, cursor: 'ew-resize' },\n { x: shape.cx! - shape.r!, y: shape.cy!, cursor: 'ew-resize' },\n { x: shape.cx!, y: shape.cy! + shape.r!, cursor: 'ns-resize' },\n { x: shape.cx!, y: shape.cy! - shape.r!, cursor: 'ns-resize' }\n ]\n break\n case 'triangle':\n const points = shape.points!.split(' ').map(p => p.split(',').map(Number))\n handles = points.map(([x, y]) => ({ x, y, cursor: 'move' }))\n break\n case 'line':\n case 'arrow':\n handles = [\n { x: shape.x1!, y: shape.y1!, cursor: 'move' },\n { x: shape.x2!, y: shape.y2!, cursor: 'move' }\n ]\n break\n }\n\n return svg`\n ${handles.map(\n handle => svg`\n <g\n class=\"resize-handle-group\"\n style=\"transform: translate(${handle.x}px, ${handle.y}px) scale(${1 / this.zoomLevel});\"\n >\n <rect\n x=\"-5\"\n y=\"-5\"\n width=\"10\"\n height=\"10\"\n fill=\"white\"\n stroke=\"black\"\n class=\"resize-handle\"\n style=\"cursor: ${handle.cursor};\"\n @mousedown=\"${(e: MouseEvent) => this.onHandleMouseDown(e, shape, handle)}\"\n ></rect>\n </g>\n `\n )}\n `\n }\n\n private onHandleMouseDown(event: MouseEvent, shape: Shape, handle: any) {\n event.stopPropagation()\n this.selectedShape = shape\n this.offsetX = handle.x\n this.offsetY = handle.y\n const svg = this.svg as SVGSVGElement\n svg.addEventListener('mousemove', this.onHandleMouseMove)\n svg.addEventListener('mouseup', this.onHandleMouseUp)\n }\n\n private onHandleMouseMove = (event: MouseEvent) => {\n if (!this.selectedShape) return\n const { x, y } = this.getSvgPoint(event)\n\n switch (this.selectedShape.type) {\n case 'text':\n case 'rectangle':\n this.selectedShape.width = Math.abs(x - this.selectedShape.x!)\n this.selectedShape.height = Math.abs(y - this.selectedShape.y!)\n if (x < this.selectedShape.x!) this.selectedShape.x = x\n if (y < this.selectedShape.y!) this.selectedShape.y = y\n break\n case 'circle':\n const dx = x - this.selectedShape.cx!\n const dy = y - this.selectedShape.cy!\n this.selectedShape.r = Math.sqrt(dx * dx + dy * dy)\n break\n case 'triangle':\n const points = this.selectedShape.points!.split(' ').map(p => p.split(',').map(Number))\n const index = points.findIndex(([px, py]) => px === this.offsetX && py === this.offsetY)\n if (index !== -1) {\n points[index] = [x, y]\n this.selectedShape.points = points.map(p => p.join(',')).join(' ')\n this.offsetX = x\n this.offsetY = y\n }\n break\n case 'line':\n case 'arrow':\n if (this.offsetX === this.selectedShape.x1 && this.offsetY === this.selectedShape.y1) {\n this.selectedShape.x1 = x\n this.selectedShape.y1 = y\n } else if (this.offsetX === this.selectedShape.x2 && this.offsetY === this.selectedShape.y2) {\n this.selectedShape.x2 = x\n this.selectedShape.y2 = y\n }\n this.offsetX = x\n this.offsetY = y\n break\n }\n\n this.requestUpdate()\n }\n\n private onHandleMouseUp = () => {\n const svg = this.svg as SVGSVGElement\n svg.removeEventListener('mousemove', this.onHandleMouseMove)\n svg.removeEventListener('mouseup', this.onHandleMouseUp)\n this.selectedShape = null\n }\n\n private onTextDoubleClick(event: MouseEvent, shape: Shape) {\n event.stopPropagation()\n\n const textElement = event.target as SVGTextElement\n\n this.showTextInput(textElement, shape)\n }\n\n private showTextInput(textElement: SVGTextElement, shape: Shape | null = null, options?: { x: number; y: number }) {\n const input: HTMLInputElement = document.createElement('input')\n input.style.position = 'absolute'\n\n const ctm = textElement.getScreenCTM() || { a: 1, e: 0, d: 1, f: 0 }\n const bbox = textElement.getBBox()\n\n const screenX = bbox.x * ctm.a + ctm.e\n const screenY = bbox.y * ctm.d + ctm.f\n\n input.style.left = `${screenX}px`\n input.style.top = `${screenY}px`\n\n const computedStyle = window.getComputedStyle(textElement)\n const fontSize = parseFloat(computedStyle.fontSize) * ctm.a\n const fontFamily = computedStyle.fontFamily\n const fontWeight = computedStyle.fontWeight\n const textColor = computedStyle.fill || computedStyle.color\n const lineHeight = parseFloat(computedStyle.lineHeight) * ctm.d\n\n input.style.fontSize = `${fontSize}px`\n input.style.fontFamily = fontFamily\n input.style.fontWeight = fontWeight\n input.style.color = textColor\n input.style.lineHeight = `${lineHeight}px`\n input.style.padding = '0'\n input.style.margin = '0'\n input.style.border = 'none'\n input.style.outline = 'none'\n input.style.background = 'transparent'\n\n if (shape) {\n input.value = shape.text || ''\n }\n\n textElement.style.visibility = 'hidden'\n\n document.body.appendChild(input)\n this.adjustInputWidth(input)\n requestAnimationFrame(() => input.focus())\n\n input.addEventListener('input', () => {\n this.adjustInputWidth(input)\n })\n\n input.addEventListener('keydown', e => {\n if (e.key === 'Enter') {\n const textValue = input.value.trim()\n\n if (textValue) {\n if (shape) {\n shape.text = textValue\n } else {\n const newShape: Shape = {\n id: Date.now().toString(),\n type: 'text',\n x: options!.x,\n y: options!.y,\n text: textValue\n }\n\n this.shapes = [...this.shapes, newShape]\n }\n } else if (shape) {\n this.shapes = this.shapes.filter(s => s.id !== shape.id)\n }\n\n document.body.removeChild(input)\n\n if (!shape) {\n this.svg.removeChild(textElement)\n } else {\n textElement.style.visibility = 'visible'\n }\n\n this.requestUpdate()\n } else if (e.key === 'Escape') {\n document.body.removeChild(input)\n\n if (!shape) {\n this.svg.removeChild(textElement)\n } else {\n textElement.style.visibility = 'visible'\n }\n }\n })\n\n input.addEventListener('blur', () => {\n requestAnimationFrame(() => {\n if (!shape) {\n this.svg.removeChild(textElement)\n } else {\n textElement.style.visibility = 'visible'\n }\n\n if (input.parentElement) {\n document.body.removeChild(input)\n }\n })\n })\n }\n\n private adjustInputWidth(input: HTMLInputElement) {\n const minWidth = 50\n const textWidth = this.measureTextWidth(input.value || input.placeholder, input)\n input.style.width = `${Math.max(textWidth + 10, minWidth)}px`\n }\n\n private measureTextWidth(text: string, input: HTMLInputElement): number {\n const canvas = document.createElement('canvas')\n const context = canvas.getContext('2d')!\n context.font = window.getComputedStyle(input).font\n\n return context.measureText(text).width\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ox-image-marker.js","sourceRoot":"","sources":["../../src/ox-image-marker.ts"],"names":[],"mappings":";AAAA,OAAO,wBAAwB,CAAA;AAE/B,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAC7C,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAG/C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAG9C,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,eAAe;IAA3C;;QAgCY,gBAAW,GAAoB,QAAQ,CAAA;QACvC,kBAAa,GAAiB,IAAI,CAAA;QAE3C,YAAO,GAAG,KAAK,CAAA;QACf,WAAM,GAAG,CAAC,CAAA;QACV,WAAM,GAAG,CAAC,CAAA;QACV,YAAO,GAAG,CAAC,CAAA;QACX,YAAO,GAAG,CAAC,CAAA;QAgET,oBAAe,GAAG,CAAC,KAAiB,EAAE,EAAE;YAChD,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC/B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAA;gBACzB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;oBAChC,OAAO,EAAE,GAAG,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAA;gBAClC,CAAC,CAAC,CAAA;gBAEF,IAA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mode'\n\nimport { html, css, svg, nothing } from 'lit'\nimport { state, customElement } from 'lit/decorators.js'\nimport { ifDefined } from 'lit/directives/if-defined.js'\nimport { keyed } from 'lit/directives/keyed.js'\n\nimport { ImageMarkerMode, Shape, ShapeType } from './types'\nimport { BaseImageMarker } from './base-image-marker'\n\n@customElement('ox-image-marker')\nexport class OxImageMarker extends BaseImageMarker {\n static styles = [\n ...BaseImageMarker.styles,\n css`\n :host {\n position: relative;\n display: flex;\n width: 100%;\n height: 100%;\n }\n\n ox-image-marker-mode {\n position: absolute;\n top: 0;\n right: 0;\n }\n\n svg {\n cursor: crosshair;\n }\n\n svg.dragging {\n cursor: move;\n }\n\n .resize-handle {\n cursor: nwse-resize;\n }\n `\n ]\n\n @state() private currentShapeType?: ShapeType\n @state() private currentMode: ImageMarkerMode = 'select'\n @state() private selectedShape: Shape | null = null\n\n private drawing = false\n private startX = 0\n private startY = 0\n private offsetX = 0\n private offsetY = 0\n\n connectedCallback() {\n super.connectedCallback()\n this.setAttribute('tabindex', '0')\n this.addEventListener('focus', this.onFocus)\n this.addEventListener('blur', this.onBlur)\n }\n\n disconnectedCallback() {\n super.disconnectedCallback()\n this.removeEventListener('focus', this.onFocus)\n this.removeEventListener('blur', this.onBlur)\n }\n\n render() {\n return html`\n <div class=\"container\">\n <svg\n @mousedown=${this.onSvgMouseDown}\n @touchstart=${this.onSvgTouchStart}\n @wheel=${this.onSvgWheel}\n @dblclick=${this.onSvgDoubleClick}\n viewBox=${this.viewBox}\n >\n <image href=${this.imageUrl} @load=${this.onImageLoad}></image>\n ${this.shapes.map(shape => keyed(shape.id, this.renderShape(shape)))}\n </svg>\n </div>\n\n <ox-image-marker-mode\n currentMode=${this.currentMode}\n currentShapeType=${ifDefined(this.currentShapeType)}\n @mode-changed=${(e: CustomEvent) => {\n const { mode, shapeType } = e.detail\n this.setMode(mode, shapeType)\n }}\n @tap-delete=${() => this.deleteSelectedShape()}\n @tap-save=${() => {\n this.dispatchEvent(\n new CustomEvent('shapes-changed', {\n detail: this.shapes,\n bubbles: true,\n composed: true\n })\n )\n }}\n ></ox-image-marker-mode>\n `\n }\n\n protected onSvgMouseDown(event: MouseEvent) {\n this.selectedShape = null\n this.shapes = this.shapes.map(s => {\n return { ...s, selected: false }\n })\n\n if (this.currentMode === 'move') {\n this.startPanning(event)\n } else if (this.currentMode === 'draw') {\n this.startDrawing(event)\n }\n }\n\n protected onSvgTouchStart = (event: TouchEvent) => {\n if (event.touches.length === 1) {\n this.selectedShape = null\n this.shapes = this.shapes.map(s => {\n return { ...s, selected: false }\n })\n\n if (this.currentMode === 'move') {\n this.startPanning(event)\n } else if (this.currentMode === 'draw') {\n this.startDrawing(event)\n }\n } else if (event.touches.length === 2) {\n this.startPinchZooming(event)\n }\n }\n\n private startDrawing(event: MouseEvent | TouchEvent) {\n const { x, y } = this.getSvgPoint(event)\n\n if (this.currentShapeType === 'text') {\n const textElement = document.createElementNS('http://www.w3.org/2000/svg', 'text')\n\n textElement.setAttribute('x', x.toString())\n textElement.setAttribute('y', y.toString())\n textElement.textContent = 'ABC'\n\n this.svg.appendChild(textElement)\n\n requestAnimationFrame(() => {\n this.showTextInput(textElement, null, { x, y })\n })\n } else {\n this.startX = x\n this.startY = y\n this.drawing = true\n }\n\n if ('touches' in event) {\n this.svg.addEventListener('touchmove', this.onDrawingMouseMove)\n this.svg.addEventListener('touchend', this.onDrawingMouseUp)\n } else {\n this.svg.addEventListener('mousemove', this.onDrawingMouseMove)\n this.svg.addEventListener('mouseup', this.onDrawingMouseUp)\n }\n }\n\n private setMode(mode: ImageMarkerMode, shapeType: ShapeType) {\n this.currentMode = mode\n this.currentShapeType = shapeType\n }\n\n private onDrawingMouseMove = (event: MouseEvent | TouchEvent) => {\n if (!this.drawing) {\n return\n }\n\n const { x, y } = this.getSvgPoint(event)\n\n const minDistance = 5\n const distance = Math.sqrt(Math.pow(x - this.startX, 2) + Math.pow(y - this.startY, 2))\n\n if (!this.selectedShape && distance >= minDistance) {\n let newShape: Shape\n\n switch (this.currentShapeType) {\n case 'rectangle':\n newShape = {\n id: Date.now().toString(),\n type: 'rectangle',\n x: this.startX,\n y: this.startY,\n width: 0,\n height: 0\n }\n break\n case 'circle':\n newShape = {\n id: Date.now().toString(),\n type: 'circle',\n cx: this.startX,\n cy: this.startY,\n r: 0\n }\n break\n case 'triangle':\n newShape = {\n id: Date.now().toString(),\n type: 'triangle',\n x1: this.startX,\n y1: this.startY,\n width: 0,\n height: 0,\n points: `${this.startX},${this.startY} ${this.startX},${this.startY} ${this.startX},${this.startY}`\n }\n break\n case 'line':\n newShape = {\n id: Date.now().toString(),\n type: 'line',\n x1: this.startX,\n y1: this.startY,\n width: 0,\n height: 0\n }\n break\n case 'arrow':\n newShape = {\n id: Date.now().toString(),\n type: 'arrow',\n x1: this.startX,\n y1: this.startY,\n width: 0,\n height: 0\n }\n break\n default:\n return\n }\n\n this.selectedShape = newShape\n this.shapes = [...this.shapes, newShape]\n }\n\n if (this.selectedShape) {\n switch (this.selectedShape.type) {\n case 'rectangle':\n this.selectedShape.x = Math.min(x, this.startX)\n this.selectedShape.y = Math.min(y, this.startY)\n this.selectedShape.width = Math.abs(x - this.startX)\n this.selectedShape.height = Math.abs(y - this.startY)\n break\n case 'circle':\n const dx = x - this.selectedShape.cx!\n const dy = y - this.selectedShape.cy!\n this.selectedShape.r = Math.sqrt(dx * dx + dy * dy)\n break\n case 'triangle':\n const x2 = x\n const y2 = y\n const x3 = this.startX - (x - this.startX)\n const y3 = y\n this.selectedShape.points = `${this.startX},${this.startY} ${x2},${y2} ${x3},${y3}`\n break\n case 'line':\n case 'arrow':\n this.selectedShape.x2 = x\n this.selectedShape.y2 = y\n break\n }\n\n this.requestUpdate()\n }\n }\n\n private onDrawingMouseUp = (event: MouseEvent | TouchEvent) => {\n this.drawing = false\n\n const svg = this.svg as SVGSVGElement\n\n if ('touches' in event) {\n svg.removeEventListener('touchmove', this.onDrawingMouseMove)\n svg.removeEventListener('touchend', this.onDrawingMouseUp)\n } else {\n svg.removeEventListener('mousemove', this.onDrawingMouseMove)\n svg.removeEventListener('mouseup', this.onDrawingMouseUp)\n }\n\n if (this.selectedShape) {\n this.selectedShape.selected = true\n }\n\n this.requestUpdate()\n }\n\n private getSvgPoint(event: MouseEvent | TouchEvent) {\n const { x, y } = this.getPointFromEvent(event)\n\n const svg = this.svg\n const point = svg.createSVGPoint()\n point.x = x\n point.y = y\n const ctm = svg.getScreenCTM()!.inverse()\n\n return point.matrixTransform(ctm)\n }\n\n protected renderShape(shape: Shape) {\n const commonAttrs = {\n stroke: shape.selected ? 'blue' : 'red',\n 'stroke-width': 1,\n fill: 'transparent',\n cursor: 'pointer'\n }\n\n switch (shape.type) {\n case 'text':\n return svg`\n <text\n x=\"${shape.x!}\"\n y=\"${shape.y!}\"\n fill=\"${commonAttrs.stroke}\"\n style=\"cursor: ${commonAttrs.cursor}; font-size: 16px;\"\n @mousedown=\"${(e: MouseEvent) => this.onShapeMouseDown(e, shape)}\"\n @touchstart=\"${(e: TouchEvent) => this.onShapeMouseDown(e, shape)}\"\n @dblclick=\"${(e: MouseEvent) => this.onTextDoubleClick(e, shape)}\"\n >${shape.text}</text>\n `\n\n case 'rectangle':\n return svg`\n <rect\n x=\"${shape.x!}\"\n y=\"${shape.y!}\"\n width=\"${shape.width!}\"\n height=\"${shape.height!}\"\n stroke=\"${commonAttrs.stroke}\"\n stroke-width=\"${commonAttrs['stroke-width']}\"\n fill=\"${commonAttrs.fill}\"\n style=\"cursor: ${commonAttrs.cursor}\"\n @mousedown=\"${(e: MouseEvent) => this.onShapeMouseDown(e, shape)}\"\n @touchstart=\"${(e: TouchEvent) => this.onShapeMouseDown(e, shape)}\"\n ></rect>\n ${shape.selected ? this.renderResizeHandles(shape) : ''}\n `\n\n case 'circle':\n return svg`\n <circle\n cx=\"${shape.cx!}\"\n cy=\"${shape.cy!}\"\n r=\"${shape.r!}\"\n stroke=\"${commonAttrs.stroke}\"\n stroke-width=\"${commonAttrs['stroke-width']}\"\n fill=\"${commonAttrs.fill}\"\n style=\"cursor: ${commonAttrs.cursor}\"\n @mousedown=\"${(e: MouseEvent) => this.onShapeMouseDown(e, shape)}\"\n @touchstart=\"${(e: TouchEvent) => this.onShapeMouseDown(e, shape)}\"\n ></circle>\n ${shape.selected ? this.renderResizeHandles(shape) : ''}\n `\n\n case 'triangle':\n return svg`\n <polygon\n points=\"${shape.points!}\"\n stroke=\"${commonAttrs.stroke}\"\n stroke-width=\"${commonAttrs['stroke-width']}\"\n fill=\"${commonAttrs.fill}\"\n style=\"cursor: ${commonAttrs.cursor}\"\n @mousedown=\"${(e: MouseEvent) => this.onShapeMouseDown(e, shape)}\"\n @touchstart=\"${(e: TouchEvent) => this.onShapeMouseDown(e, shape)}\"\n ></polygon>\n ${shape.selected ? this.renderResizeHandles(shape) : ''}\n `\n\n case 'line':\n return svg`\n <line\n x1=\"${shape.x1!}\"\n y1=\"${shape.y1!}\"\n x2=\"${shape.x2 ?? shape.x1}\"\n y2=\"${shape.y2 ?? shape.y1}\"\n stroke=\"${commonAttrs.stroke}\"\n stroke-width=\"${commonAttrs['stroke-width']}\"\n style=\"cursor: ${commonAttrs.cursor}\"\n @mousedown=\"${(e: MouseEvent) => this.onShapeMouseDown(e, shape)}\"\n @touchstart=\"${(e: TouchEvent) => this.onShapeMouseDown(e, shape)}\"\n ></line>\n ${shape.selected ? this.renderResizeHandles(shape) : ''}\n `\n\n case 'arrow':\n return svg`\n <defs>\n <marker id=\"arrowhead-${shape.id}\" markerWidth=\"10\" markerHeight=\"7\" refX=\"10\" refY=\"3.5\" orient=\"auto\">\n <polygon points=\"0 0, 10 3.5, 0 7\" fill=\"${commonAttrs.stroke}\"></polygon>\n </marker>\n </defs>\n <line\n x1=\"${shape.x1!}\"\n y1=\"${shape.y1!}\"\n x2=\"${shape.x2 ?? shape.x1}\"\n y2=\"${shape.y2 ?? shape.y1}\"\n stroke=\"${commonAttrs.stroke}\"\n stroke-width=\"${commonAttrs['stroke-width']}\"\n marker-end=\"url(#arrowhead-${shape.id})\"\n style=\"cursor: ${commonAttrs.cursor}\"\n @mousedown=\"${(e: MouseEvent) => this.onShapeMouseDown(e, shape)}\"\n @touchstart=\"${(e: TouchEvent) => this.onShapeMouseDown(e, shape)}\"\n ></line>\n ${shape.selected ? this.renderResizeHandles(shape) : ''}\n `\n\n default:\n return nothing\n }\n }\n\n private onShapeMouseDown(event: MouseEvent | TouchEvent, shape: Shape) {\n event.stopPropagation()\n\n this.shapes = this.shapes.map(s => ({\n ...s,\n selected: s.id === shape.id\n }))\n\n this.selectedShape = this.shapes.find(s => s.id == shape.id)!\n\n const { x, y } = this.getSvgPoint(event)\n\n switch (shape.type) {\n case 'text':\n case 'rectangle':\n case 'circle':\n this.offsetX = x - (shape.x || shape.cx || 0)\n this.offsetY = y - (shape.y || shape.cy || 0)\n break\n\n case 'triangle':\n const points = this.selectedShape.points!.split(' ').map(p => p.split(',').map(Number))\n const [px, py] = points[0] || [0, 0]\n\n this.offsetX = x - px\n this.offsetY = y - py\n\n break\n\n case 'line':\n case 'arrow':\n this.offsetX = x - shape.x1!\n this.offsetY = y - shape.y1!\n break\n }\n\n const svg = this.svg as SVGSVGElement\n\n if ('touches' in event) {\n svg.addEventListener('touchmove', this.onShapeMouseMove)\n svg.addEventListener('touchend', this.onShapeMouseUp)\n } else {\n svg.addEventListener('mousemove', this.onShapeMouseMove)\n svg.addEventListener('mouseup', this.onShapeMouseUp)\n }\n }\n\n private onShapeMouseMove = (event: MouseEvent | TouchEvent) => {\n if (!this.selectedShape) {\n return\n }\n\n const { x, y } = this.getSvgPoint(event)\n\n switch (this.selectedShape.type) {\n case 'text':\n case 'rectangle':\n this.selectedShape.x = x - this.offsetX\n this.selectedShape.y = y - this.offsetY\n break\n case 'circle':\n this.selectedShape.cx = x - this.offsetX\n this.selectedShape.cy = y - this.offsetY\n break\n case 'triangle':\n const points = this.selectedShape.points!.split(' ').map(p => p.split(',').map(Number))\n const [ox, oy] = points[0]\n\n this.selectedShape.points = points\n .map(([px, py]) => [px - ox + x - this.offsetX, py - oy + y - this.offsetY].join(','))\n .join(' ')\n break\n case 'line':\n case 'arrow':\n const dxLine = x - this.offsetX\n const dyLine = y - this.offsetY\n const deltaX = dxLine - this.selectedShape.x1!\n const deltaY = dyLine - this.selectedShape.y1!\n this.selectedShape.x1 = dxLine\n this.selectedShape.y1 = dyLine\n this.selectedShape.x2 = this.selectedShape.x2! + deltaX\n this.selectedShape.y2 = this.selectedShape.y2! + deltaY\n break\n }\n\n this.requestUpdate()\n }\n\n private onShapeMouseUp = (event: MouseEvent | TouchEvent) => {\n const svg = this.svg as SVGSVGElement\n\n if ('touches' in event) {\n svg.removeEventListener('touchmove', this.onShapeMouseMove)\n svg.removeEventListener('touchend', this.onShapeMouseUp)\n } else {\n svg.removeEventListener('mousemove', this.onShapeMouseMove)\n svg.removeEventListener('mouseup', this.onShapeMouseUp)\n }\n }\n\n private renderResizeHandles(shape: Shape) {\n let handles: Array<{ x: number; y: number; cursor: string }> = []\n\n switch (shape.type) {\n case 'text':\n case 'rectangle':\n handles = [\n { x: shape.x!, y: shape.y!, cursor: 'nwse-resize' },\n { x: shape.x! + shape.width!, y: shape.y!, cursor: 'nesw-resize' },\n { x: shape.x!, y: shape.y! + shape.height!, cursor: 'nesw-resize' },\n { x: shape.x! + shape.width!, y: shape.y! + shape.height!, cursor: 'nwse-resize' }\n ]\n break\n case 'circle':\n handles = [\n { x: shape.cx! + shape.r!, y: shape.cy!, cursor: 'ew-resize' },\n { x: shape.cx! - shape.r!, y: shape.cy!, cursor: 'ew-resize' },\n { x: shape.cx!, y: shape.cy! + shape.r!, cursor: 'ns-resize' },\n { x: shape.cx!, y: shape.cy! - shape.r!, cursor: 'ns-resize' }\n ]\n break\n case 'triangle':\n const points = shape.points!.split(' ').map(p => p.split(',').map(Number))\n handles = points.map(([x, y]) => ({ x, y, cursor: 'move' }))\n break\n case 'line':\n case 'arrow':\n handles = [\n { x: shape.x1!, y: shape.y1!, cursor: 'move' },\n { x: shape.x2!, y: shape.y2!, cursor: 'move' }\n ]\n break\n }\n\n return svg`\n ${handles.map(\n handle => svg`\n <g\n class=\"resize-handle-group\"\n style=\"transform: translate(${handle.x}px, ${handle.y}px) scale(${1 / this.zoomLevel});\"\n >\n <rect\n x=\"-5\"\n y=\"-5\"\n width=\"10\"\n height=\"10\"\n fill=\"white\"\n stroke=\"black\"\n class=\"resize-handle\"\n style=\"cursor: ${handle.cursor};\"\n @mousedown=\"${(e: MouseEvent) => this.onHandleMouseDown(e, shape, handle)}\"\n @touchstart=\"${(e: TouchEvent) => this.onHandleMouseDown(e, shape, handle)}\"\n ></rect>\n </g>\n `\n )}\n `\n }\n\n private onHandleMouseDown(event: MouseEvent | TouchEvent, shape: Shape, handle: any) {\n event.stopPropagation()\n\n this.selectedShape = shape\n this.offsetX = handle.x\n this.offsetY = handle.y\n const svg = this.svg as SVGSVGElement\n\n if ('touches' in event) {\n svg.addEventListener('touchmove', this.onHandleMouseMove)\n svg.addEventListener('touchend', this.onHandleMouseUp)\n } else {\n svg.addEventListener('mousemove', this.onHandleMouseMove)\n svg.addEventListener('mouseup', this.onHandleMouseUp)\n }\n }\n\n private onHandleMouseMove = (event: MouseEvent | TouchEvent) => {\n if (!this.selectedShape) {\n return\n }\n\n const { x, y } = this.getSvgPoint(event)\n\n switch (this.selectedShape.type) {\n // case 'text':\n // this.selectedShape.width = Math.abs(x - this.selectedShape.x!)\n // this.selectedShape.height = Math.abs(y - this.selectedShape.y!)\n // if (x < this.selectedShape.x!) this.selectedShape.x = x\n // if (y < this.selectedShape.y!) this.selectedShape.y = y\n // break\n case 'rectangle':\n const startX = this.selectedShape.x!\n const startY = this.selectedShape.y!\n const width = this.selectedShape.width!\n const height = this.selectedShape.height!\n\n // 핸들의 좌표에 따라 너비 및 높이 조정\n if (this.offsetX === startX && this.offsetY === startY) {\n // 상좌 핸들 (왼쪽 위)\n this.selectedShape.x = x\n this.selectedShape.y = y\n this.selectedShape.width = width + (startX - x)\n this.selectedShape.height = height + (startY - y)\n } else if (this.offsetX === startX + width && this.offsetY === startY) {\n // 상우 핸들 (오른쪽 위)\n this.selectedShape.y = y\n this.selectedShape.width = Math.abs(x - startX)\n this.selectedShape.height = height + (startY - y)\n } else if (this.offsetX === startX && this.offsetY === startY + height) {\n // 하좌 핸들 (왼쪽 아래)\n this.selectedShape.x = x\n this.selectedShape.width = width + (startX - x)\n this.selectedShape.height = Math.abs(y - startY)\n } else if (this.offsetX === startX + width && this.offsetY === startY + height) {\n // 하우 핸들 (오른쪽 아래)\n this.selectedShape.width = Math.abs(x - startX)\n this.selectedShape.height = Math.abs(y - startY)\n }\n\n // 최소 너비 및 높이 유지\n this.selectedShape.width = Math.max(10, this.selectedShape.width!)\n this.selectedShape.height = Math.max(10, this.selectedShape.height!)\n\n this.offsetX = x\n this.offsetY = y\n\n break\n case 'circle':\n const dx = x - this.selectedShape.cx!\n const dy = y - this.selectedShape.cy!\n this.selectedShape.r = Math.sqrt(dx * dx + dy * dy)\n break\n case 'triangle':\n const points = this.selectedShape.points!.split(' ').map(p => p.split(',').map(Number))\n const index = points.findIndex(([px, py]) => px === this.offsetX && py === this.offsetY)\n if (index !== -1) {\n points[index] = [x, y]\n this.selectedShape.points = points.map(p => p.join(',')).join(' ')\n this.offsetX = x\n this.offsetY = y\n }\n break\n case 'line':\n case 'arrow':\n if (this.offsetX === this.selectedShape.x1 && this.offsetY === this.selectedShape.y1) {\n this.selectedShape.x1 = x\n this.selectedShape.y1 = y\n } else if (this.offsetX === this.selectedShape.x2 && this.offsetY === this.selectedShape.y2) {\n this.selectedShape.x2 = x\n this.selectedShape.y2 = y\n }\n this.offsetX = x\n this.offsetY = y\n break\n }\n\n this.requestUpdate()\n }\n\n private onHandleMouseUp = (event: MouseEvent | TouchEvent) => {\n const svg = this.svg as SVGSVGElement\n\n if ('touches' in event) {\n svg.removeEventListener('touchmove', this.onHandleMouseMove)\n svg.removeEventListener('touchend', this.onHandleMouseUp)\n } else {\n svg.removeEventListener('mousemove', this.onHandleMouseMove)\n svg.removeEventListener('mouseup', this.onHandleMouseUp)\n }\n\n this.selectedShape = null\n }\n\n private onTextDoubleClick(event: MouseEvent, shape: Shape) {\n event.stopPropagation()\n\n const textElement = event.target as SVGTextElement\n\n this.showTextInput(textElement, shape)\n }\n\n private showTextInput(textElement: SVGTextElement, shape: Shape | null = null, options?: { x: number; y: number }) {\n const input: HTMLInputElement = document.createElement('input')\n input.style.position = 'absolute'\n\n const ctm = textElement.getScreenCTM() || { a: 1, e: 0, d: 1, f: 0 }\n const bbox = textElement.getBBox()\n\n const screenX = bbox.x * ctm.a + ctm.e\n const screenY = bbox.y * ctm.d + ctm.f\n\n input.style.left = `${screenX}px`\n input.style.top = `${screenY}px`\n\n const computedStyle = window.getComputedStyle(textElement)\n const fontSize = parseFloat(computedStyle.fontSize) * ctm.a\n const fontFamily = computedStyle.fontFamily\n const fontWeight = computedStyle.fontWeight\n const textColor = computedStyle.fill || computedStyle.color\n const lineHeight = parseFloat(computedStyle.lineHeight) * ctm.d\n\n input.style.fontSize = `${fontSize}px`\n input.style.fontFamily = fontFamily\n input.style.fontWeight = fontWeight\n input.style.color = textColor\n input.style.lineHeight = `${lineHeight}px`\n input.style.padding = '0'\n input.style.margin = '0'\n input.style.border = 'none'\n input.style.outline = 'none'\n input.style.background = 'transparent'\n\n if (shape) {\n input.value = shape.text || ''\n }\n\n textElement.style.visibility = 'hidden'\n\n document.body.appendChild(input)\n this.adjustInputWidth(input)\n requestAnimationFrame(() => input.focus())\n\n input.addEventListener('input', () => {\n this.adjustInputWidth(input)\n })\n\n input.addEventListener('keydown', e => {\n if (e.key === 'Enter') {\n const textValue = input.value.trim()\n\n if (textValue) {\n if (shape) {\n shape.text = textValue\n } else {\n const newShape: Shape = {\n id: Date.now().toString(),\n type: 'text',\n x: options!.x,\n y: options!.y,\n text: textValue\n }\n\n this.shapes = [...this.shapes, newShape]\n }\n } else if (shape) {\n this.shapes = this.shapes.filter(s => s.id !== shape.id)\n }\n\n document.body.removeChild(input)\n\n if (!shape) {\n this.svg.removeChild(textElement)\n } else {\n textElement.style.visibility = 'visible'\n }\n\n this.requestUpdate()\n } else if (e.key === 'Escape') {\n document.body.removeChild(input)\n\n if (!shape) {\n this.svg.removeChild(textElement)\n } else {\n textElement.style.visibility = 'visible'\n }\n }\n })\n\n input.addEventListener('blur', () => {\n requestAnimationFrame(() => {\n if (!shape) {\n this.svg.removeChild(textElement)\n } else {\n textElement.style.visibility = 'visible'\n }\n\n if (input.parentElement) {\n document.body.removeChild(input)\n }\n })\n })\n }\n\n private adjustInputWidth(input: HTMLInputElement) {\n const minWidth = 50\n const textWidth = this.measureTextWidth(input.value || input.placeholder, input)\n input.style.width = `${Math.max(textWidth + 10, minWidth)}px`\n }\n\n private measureTextWidth(text: string, input: HTMLInputElement): number {\n const canvas = document.createElement('canvas')\n const context = canvas.getContext('2d')!\n context.font = window.getComputedStyle(input).font\n\n return context.measureText(text).width\n }\n\n private onFocus = () => {\n this.addEventListener('keydown', this.handleKeyDown)\n }\n\n private onBlur = () => {\n this.removeEventListener('keydown', this.handleKeyDown)\n }\n\n private handleKeyDown = (event: KeyboardEvent) => {\n if ((event.key === 'Delete' || event.key === 'Backspace') && this.selectedShape) {\n this.deleteSelectedShape()\n }\n }\n\n private deleteSelectedShape() {\n if (this.selectedShape) {\n this.shapes = this.shapes.filter(s => s.id !== this.selectedShape!.id)\n this.selectedShape = null\n this.requestUpdate()\n }\n }\n}\n"]}
|