@plait/draw 0.1.0-next.7 → 0.1.0-next.8

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.
@@ -1,8 +1,8 @@
1
- import { PlaitElement, RectangleClient, PlaitBoard, setStrokeLinecap, isPointInPolygon, getNearestPointBetweenPointAndSegments, isPointInEllipse, drawRectangle, drawRoundRectangle, isPointInRoundRectangle, idCreator, createG, SELECTION_BORDER_COLOR, SELECTION_FILL_COLOR, drawCircle, distanceBetweenPointAndSegments, setPathStrokeLinecap, arrowPoints, drawLinearPath, getElementById, findElements, getSelectedElements, Transforms, clearSelectedElement, addSelectedElement, PlaitNode, Point, PlaitPluginElementComponent, isSelectionMoving, createMask, createRect, transformPoint, toPoint, BoardTransforms, PlaitPointerType, preventTouchMove, createForeignObject, setClipboardData, getDataFromClipboard, depthFirstRecursion, getIsRecursionFunc, getHitElements, isPolylineHitRectangle } from '@plait/core';
1
+ import { PlaitElement, ACTIVE_STROKE_WIDTH, RectangleClient, PlaitBoard, setStrokeLinecap, isPointInPolygon, getNearestPointBetweenPointAndSegments, isPointInEllipse, drawRectangle, drawRoundRectangle, isPointInRoundRectangle, idCreator, createG, SELECTION_BORDER_COLOR, SELECTION_FILL_COLOR, drawCircle, arrowPoints, createPath, drawLinearPath, distanceBetweenPointAndSegments, createMask, createRect, getElementById, findElements, getSelectedElements, Transforms, clearSelectedElement, addSelectedElement, PlaitNode, Point, isSelectionMoving, PlaitPluginElementComponent, transformPoint, toPoint, BoardTransforms, PlaitPointerType, preventTouchMove, createForeignObject, setClipboardData, getDataFromClipboard, depthFirstRecursion, getIsRecursionFunc, getHitElements, isPolylineHitRectangle } from '@plait/core';
2
2
  import * as i0 from '@angular/core';
3
3
  import { Component, ChangeDetectionStrategy } from '@angular/core';
4
4
  import { Subject } from 'rxjs';
5
- import { getRectangleByPoints, Direction, getDirectionByPoint, getPoints, getPointOnPolyline, getFactorByPoints, getDirectionFactor, Generator, normalizeShapePoints, ActiveGenerator, WithTextPluginKey, RESIZE_HANDLE_DIAMETER, isVirtualKey, isDelete, isSpaceHotkey, isDndMode, isDrawingMode, getRectangleResizeHandleRefs, ResizeHandle, withResize, isResizingByCondition, getRatioByPoint } from '@plait/common';
5
+ import { getRectangleByPoints, getFactorByPoints, Direction, getDirectionByPoint, getPoints, getPointOnPolyline, getDirectionFactor, Generator, normalizeShapePoints, CommonPluginElement, ActiveGenerator, WithTextPluginKey, RESIZE_HANDLE_DIAMETER, isVirtualKey, isDelete, isSpaceHotkey, isDndMode, isDrawingMode, getRectangleResizeHandleRefs, ResizeHandle, withResize, isResizingByCondition, getRatioByPoint } from '@plait/common';
6
6
  import { Alignment, buildText, AlignEditor, TextManage, DEFAULT_FONT_SIZE, getTextFromClipboard, getTextSize } from '@plait/text';
7
7
  import { isKeyHotkey } from 'is-hotkey';
8
8
  import { Node } from 'slate';
@@ -18,9 +18,12 @@ var GeometryShape;
18
18
  })(GeometryShape || (GeometryShape = {}));
19
19
  const PlaitGeometry = {
20
20
  getTextEditor(element) {
21
+ return PlaitGeometry.getTextManage(element).componentRef.instance.editor;
22
+ },
23
+ getTextManage(element) {
21
24
  const component = PlaitElement.getComponent(element);
22
25
  if (component) {
23
- return component.textManage.componentRef.instance.editor;
26
+ return component.textManage;
24
27
  }
25
28
  throw new Error('can not get correctly component in get text editor');
26
29
  }
@@ -30,6 +33,9 @@ var LineMarkerType;
30
33
  (function (LineMarkerType) {
31
34
  LineMarkerType["arrow"] = "arrow";
32
35
  LineMarkerType["none"] = "none";
36
+ LineMarkerType["openTriangle"] = "open-triangle";
37
+ LineMarkerType["solidTriangle"] = "solid-triangle";
38
+ LineMarkerType["sharpArrow"] = "sharp-arrow";
33
39
  })(LineMarkerType || (LineMarkerType = {}));
34
40
  var LineShape;
35
41
  (function (LineShape) {
@@ -37,6 +43,11 @@ var LineShape;
37
43
  LineShape["curve"] = "curve";
38
44
  LineShape["elbow"] = "elbow";
39
45
  })(LineShape || (LineShape = {}));
46
+ var LineHandleKey;
47
+ (function (LineHandleKey) {
48
+ LineHandleKey["source"] = "source";
49
+ LineHandleKey["target"] = "target";
50
+ })(LineHandleKey || (LineHandleKey = {}));
40
51
  const PlaitLine = {
41
52
  getTextEditors(element) {
42
53
  const component = PlaitElement.getComponent(element);
@@ -101,8 +112,8 @@ const DefaultGeometryStyle = {
101
112
  fill: 'none'
102
113
  };
103
114
  const DefaultGeometryActiveStyle = {
104
- strokeWidth: 2,
105
- selectionStrokeWidth: 1
115
+ strokeWidth: ACTIVE_STROKE_WIDTH,
116
+ selectionStrokeWidth: ACTIVE_STROKE_WIDTH
106
117
  };
107
118
  const DefaultGeometryProperty = {
108
119
  width: 100,
@@ -365,20 +376,20 @@ const getPointsByCenterPoint = (point, width, height) => {
365
376
  };
366
377
  const getTextRectangle = (element) => {
367
378
  const elementRectangle = getRectangleByPoints(element.points);
379
+ const strokeWidth = getStrokeWidthByElement(element);
368
380
  const height = element.textHeight;
369
- const width = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2;
381
+ const width = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
370
382
  return {
371
383
  height,
372
384
  width: width > 0 ? width : 0,
373
- x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText,
385
+ x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth,
374
386
  y: elementRectangle.y + (elementRectangle.height - height) / 2
375
387
  };
376
388
  };
377
389
  const drawBoundMask = (board, element) => {
378
390
  const G = createG();
379
391
  const rectangle = getRectangleByPoints(element.points);
380
- const offset = (getStrokeWidthByElement(element) + 1) / 2 - 0.1;
381
- const activeRectangle = RectangleClient.getOutlineRectangle(rectangle, -offset);
392
+ const activeRectangle = RectangleClient.inflate(rectangle, ACTIVE_STROKE_WIDTH);
382
393
  const maskG = drawGeometry(board, activeRectangle, element.shape, {
383
394
  stroke: SELECTION_BORDER_COLOR,
384
395
  strokeWidth: 1,
@@ -401,9 +412,9 @@ const drawBoundMask = (board, element) => {
401
412
  const drawGeometry = (board, outerRectangle, shape, options) => {
402
413
  return getEngine(shape).draw(board, outerRectangle, options);
403
414
  };
404
- const getNearestPoint = (element, point, offset = 0) => {
415
+ const getNearestPoint = (element, point, inflateDelta = 0) => {
405
416
  const rectangle = getRectangleByPoints(element.points);
406
- const activeRectangle = RectangleClient.getOutlineRectangle(rectangle, -offset);
417
+ const activeRectangle = RectangleClient.inflate(rectangle, inflateDelta);
407
418
  return getEngine(element.shape).getNearestPoint(activeRectangle, point);
408
419
  };
409
420
  const getCenterPointsOnPolygon = (points) => {
@@ -415,7 +426,91 @@ const getCenterPointsOnPolygon = (points) => {
415
426
  return centerPoint;
416
427
  };
417
428
 
418
- const BOUNDED_HANDLE_OFFSET = 0.5;
429
+ const drawLineArrow = (element, points, options) => {
430
+ const arrowG = createG();
431
+ if (PlaitLine.isSourceMark(element, LineMarkerType.none) && PlaitLine.isTargetMark(element, LineMarkerType.none)) {
432
+ return null;
433
+ }
434
+ if (!PlaitLine.isSourceMark(element, LineMarkerType.none)) {
435
+ const sourceArrow = getArrow(element, element.source.marker, points[1], points[0], options);
436
+ sourceArrow && arrowG.appendChild(sourceArrow);
437
+ }
438
+ if (!PlaitLine.isTargetMark(element, LineMarkerType.none)) {
439
+ const arrow = getArrow(element, element.target.marker, points[points.length - 2], points[points.length - 1], options);
440
+ arrow && arrowG.appendChild(arrow);
441
+ }
442
+ return arrowG;
443
+ };
444
+ const getArrow = (element, marker, source, target, options) => {
445
+ let targetArrow;
446
+ switch (marker) {
447
+ case LineMarkerType.openTriangle: {
448
+ targetArrow = drawOpenTriangle(element, source, target, options);
449
+ break;
450
+ }
451
+ case LineMarkerType.solidTriangle: {
452
+ targetArrow = drawSolidTriangle(source, target, options);
453
+ break;
454
+ }
455
+ case LineMarkerType.arrow: {
456
+ targetArrow = drawArrow(element, source, target, options);
457
+ break;
458
+ }
459
+ case LineMarkerType.sharpArrow: {
460
+ targetArrow = drawSharpArrow(source, target, options);
461
+ break;
462
+ }
463
+ }
464
+ return targetArrow;
465
+ };
466
+ const drawSharpArrow = (source, target, options) => {
467
+ const directionFactor = getFactorByPoints(source, target);
468
+ const startPoint = target;
469
+ // const startPoint: Point = [
470
+ // target[0],
471
+ // target[1]
472
+ // ];
473
+ const { pointLeft, pointRight } = arrowPoints(source, target, 12, 20);
474
+ const g = createG();
475
+ const path = createPath();
476
+ let polylinePath = `M${pointRight[0]},${pointRight[1]}A8,8,20,0,1,${pointLeft[0]},${pointLeft[1]}L${startPoint[0]},${startPoint[1]}Z`;
477
+ path.setAttribute('d', polylinePath);
478
+ path.setAttribute('stroke', `${options?.stroke}`);
479
+ path.setAttribute('stroke-width', `${options?.strokeWidth}`);
480
+ path.setAttribute('fill', `${options?.stroke}`);
481
+ g.appendChild(path);
482
+ return g;
483
+ };
484
+ const drawArrow = (element, source, target, options) => {
485
+ const directionFactor = getFactorByPoints(source, target);
486
+ const strokeWidth = getStrokeWidthByElement(element);
487
+ const endPoint = [
488
+ target[0] + strokeWidth * directionFactor.x / 2,
489
+ target[1] + strokeWidth * directionFactor.y / 2
490
+ ];
491
+ const middlePoint = [endPoint[0] - 8 * directionFactor.x, endPoint[1] - 8 * directionFactor.y];
492
+ const { pointLeft, pointRight } = arrowPoints(source, endPoint, 12, 30);
493
+ const arrowG = drawLinearPath([pointLeft, endPoint, pointRight, middlePoint], { ...options, fill: options.stroke }, true);
494
+ const path = arrowG.querySelector('path');
495
+ path.setAttribute('stroke-linejoin', 'round');
496
+ return arrowG;
497
+ };
498
+ const drawSolidTriangle = (source, target, options) => {
499
+ const endPoint = target;
500
+ const { pointLeft, pointRight } = arrowPoints(source, endPoint, 12, 30);
501
+ return drawLinearPath([pointLeft, endPoint, pointRight], { ...options, fill: options.stroke }, true);
502
+ };
503
+ const drawOpenTriangle = (element, source, target, options) => {
504
+ const directionFactor = getFactorByPoints(source, target);
505
+ const strokeWidth = getStrokeWidthByElement(element);
506
+ const endPoint = [
507
+ target[0] + strokeWidth * directionFactor.x / 2,
508
+ target[1] + strokeWidth * directionFactor.y / 2
509
+ ];
510
+ const { pointLeft, pointRight } = arrowPoints(source, endPoint, 12, 40);
511
+ return drawLinearPath([pointLeft, endPoint, pointRight], options);
512
+ };
513
+
419
514
  const createLineElement = (shape, points, source, target, options) => {
420
515
  return {
421
516
  id: idCreator(),
@@ -482,42 +577,43 @@ const drawLine = (board, element) => {
482
577
  const options = { stroke: strokeColor, strokeWidth, strokeLineDash };
483
578
  const lineG = createG();
484
579
  const points = getLinePoints(board, element);
485
- const line = PlaitBoard.getRoughSVG(board).linearPath(points, options);
486
- const path = line.querySelector('path');
487
- path?.setAttribute('mask', `url(#${element.id})`);
488
- setPathStrokeLinecap(line, 'square');
580
+ const line = drawLinearPath(points, options);
581
+ line.setAttribute('mask', `url(#${element.id})`);
489
582
  lineG.appendChild(line);
583
+ const { mask, maskTargetFillRect } = drawMask(board, element);
584
+ lineG.appendChild(mask);
585
+ line.appendChild(maskTargetFillRect);
490
586
  const arrow = drawLineArrow(element, points, options);
491
587
  arrow && lineG.appendChild(arrow);
492
588
  return lineG;
493
589
  };
494
- const drawLineArrow = (element, points, options) => {
495
- const arrowG = createG();
496
- if (PlaitLine.isSourceMark(element, LineMarkerType.none) && PlaitLine.isTargetMark(element, LineMarkerType.none)) {
497
- return null;
498
- }
499
- if (PlaitLine.isSourceMark(element, LineMarkerType.arrow)) {
500
- const sourcePoint = points[0];
501
- const { pointLeft, pointRight } = arrowPoints(points[1], sourcePoint, 12, 40);
502
- const sourceArrow = drawLinearPath([pointLeft, sourcePoint, pointRight], options);
503
- arrowG.appendChild(sourceArrow);
504
- }
505
- if (PlaitLine.isTargetMark(element, LineMarkerType.arrow)) {
506
- const _endPoint = points[points.length - 1];
507
- const directionFactor = getFactorByPoints(points[points.length - 2], _endPoint);
508
- const endPoint = [
509
- _endPoint[0] + BOUNDED_HANDLE_OFFSET * directionFactor.x,
510
- _endPoint[1] + BOUNDED_HANDLE_OFFSET * directionFactor.y
511
- ];
512
- const { pointLeft, pointRight } = arrowPoints(points[points.length - 2], endPoint, 12, 40);
513
- const targetArrow = drawLinearPath([pointLeft, endPoint, pointRight], options);
514
- arrowG.appendChild(targetArrow);
515
- }
516
- return arrowG;
517
- };
590
+ function drawMask(board, element) {
591
+ const mask = createMask();
592
+ mask.setAttribute('id', element.id);
593
+ const points = getLinePoints(board, element);
594
+ let rectangle = getRectangleByPoints(points);
595
+ rectangle = RectangleClient.getOutlineRectangle(rectangle, -30);
596
+ const maskFillRect = createRect(rectangle, {
597
+ fill: 'white'
598
+ });
599
+ mask.appendChild(maskFillRect);
600
+ const texts = element.texts;
601
+ texts.forEach((text, index) => {
602
+ const textRectangle = getLineTextRectangle(board, element, index);
603
+ const rect = createRect(textRectangle, {
604
+ fill: 'black'
605
+ });
606
+ mask.appendChild(rect);
607
+ });
608
+ //撑开 line
609
+ const maskTargetFillRect = createRect(rectangle);
610
+ maskTargetFillRect.setAttribute('opacity', '0');
611
+ return { mask, maskTargetFillRect };
612
+ }
518
613
  const getSourcePoint = (board, element) => {
519
614
  if (element.source.boundId) {
520
- const connectionOffset = PlaitLine.isSourceMark(element, LineMarkerType.arrow) ? BOUNDED_HANDLE_OFFSET : 0;
615
+ const strokeWidth = getStrokeWidthByElement(element);
616
+ const connectionOffset = PlaitLine.isSourceMark(element, LineMarkerType.none) ? 0 : strokeWidth;
521
617
  const boundElement = getElementById(board, element.source.boundId);
522
618
  return boundElement ? getConnectionPoint(boundElement, element.source.connection, connectionOffset) : element.points[0];
523
619
  }
@@ -525,7 +621,8 @@ const getSourcePoint = (board, element) => {
525
621
  };
526
622
  const getTargetPoint = (board, element) => {
527
623
  if (element.target.boundId) {
528
- const connectionOffset = PlaitLine.isTargetMark(element, LineMarkerType.arrow) ? BOUNDED_HANDLE_OFFSET : 0;
624
+ const strokeWidth = getStrokeWidthByElement(element);
625
+ const connectionOffset = PlaitLine.isTargetMark(element, LineMarkerType.none) ? 0 : strokeWidth;
529
626
  const boundElement = getElementById(board, element.target.boundId);
530
627
  return boundElement
531
628
  ? getConnectionPoint(boundElement, element.target.connection, connectionOffset)
@@ -535,18 +632,16 @@ const getTargetPoint = (board, element) => {
535
632
  };
536
633
  const getConnectionPoint = (geometry, connection, offset) => {
537
634
  const rectangle = getRectangleByPoints(geometry.points);
538
- const strokeWidth = getStrokeWidthByElement(geometry);
539
635
  const directionFactor = getDirectionFactor(getDirectionByPoint(connection, Direction.bottom));
540
636
  return [
541
- rectangle.x + rectangle.width * connection[0] + strokeWidth * directionFactor.x + offset * directionFactor.x,
542
- rectangle.y + rectangle.height * connection[1] + strokeWidth * directionFactor.y + offset * directionFactor.y
637
+ rectangle.x + rectangle.width * connection[0] + directionFactor.x * offset,
638
+ rectangle.y + rectangle.height * connection[1] + directionFactor.y * offset
543
639
  ];
544
640
  };
545
641
  const transformPointToConnection = (board, point, hitElement) => {
546
- const offset = (getStrokeWidthByElement(hitElement) + 1) / 2;
547
642
  let rectangle = getRectangleByPoints(hitElement.points);
548
- rectangle = RectangleClient.getOutlineRectangle(rectangle, -offset);
549
- let nearestPoint = getNearestPoint(hitElement, point, offset);
643
+ rectangle = RectangleClient.inflate(rectangle, ACTIVE_STROKE_WIDTH);
644
+ let nearestPoint = getNearestPoint(hitElement, point, ACTIVE_STROKE_WIDTH);
550
645
  const hitConnector = getHitConnectorPoint(nearestPoint, hitElement, rectangle);
551
646
  nearestPoint = hitConnector ? hitConnector : nearestPoint;
552
647
  return [(nearestPoint[0] - rectangle.x) / rectangle.width, (nearestPoint[1] - rectangle.y) / rectangle.height];
@@ -595,7 +690,7 @@ class GeometryShapeGenerator extends Generator {
595
690
  return true;
596
691
  }
597
692
  baseDraw(element, data) {
598
- const outerRectangle = getRectangleByPoints(element.points);
693
+ const rectangle = getRectangleByPoints(element.points);
599
694
  const shape = element.shape;
600
695
  if (shape === GeometryShape.text) {
601
696
  return;
@@ -604,7 +699,7 @@ class GeometryShapeGenerator extends Generator {
604
699
  const strokeColor = getStrokeColorByElement(element);
605
700
  const fill = getFillByElement(element);
606
701
  const strokeLineDash = getLineDashByElement(element);
607
- return drawGeometry(this.board, outerRectangle, shape, { stroke: strokeColor, strokeWidth, fill, strokeLineDash });
702
+ return drawGeometry(this.board, RectangleClient.inflate(rectangle, -strokeWidth), shape, { stroke: strokeColor, strokeWidth, fill, strokeLineDash });
608
703
  }
609
704
  }
610
705
 
@@ -698,6 +793,12 @@ const removeLineText = (board, element, index) => {
698
793
  newTexts.splice(index, 1);
699
794
  Transforms.setNode(board, { texts: newTexts }, path);
700
795
  };
796
+ const setLineMark = (board, element, handleKey, marker) => {
797
+ const path = PlaitBoard.findPath(board, element);
798
+ let handle = handleKey === LineHandleKey.source ? element.source : element.target;
799
+ handle = { ...handle, marker };
800
+ Transforms.setNode(board, { [handleKey]: handle }, path);
801
+ };
701
802
 
702
803
  const DrawTransforms = {
703
804
  setText,
@@ -707,10 +808,14 @@ const DrawTransforms = {
707
808
  setTextSize,
708
809
  resizeLine,
709
810
  setLineTexts,
710
- removeLineText
811
+ removeLineText,
812
+ setLineMark
711
813
  };
712
814
 
713
- class GeometryComponent extends PlaitPluginElementComponent {
815
+ class GeometryComponent extends CommonPluginElement {
816
+ get textManage() {
817
+ return this.getTextManages()[0];
818
+ }
714
819
  constructor(viewContainerRef, cdr) {
715
820
  super(cdr);
716
821
  this.viewContainerRef = viewContainerRef;
@@ -731,9 +836,6 @@ class GeometryComponent extends PlaitPluginElementComponent {
731
836
  getRectangle: (element) => {
732
837
  return getRectangleByPoints(element.points);
733
838
  },
734
- getStrokeWidthByElement: (element) => {
735
- return getStrokeWidthByElement(element);
736
- },
737
839
  hasResizeHandle: () => {
738
840
  const selectedElements = getSelectedElements(this.board);
739
841
  if (PlaitBoard.hasBeenTextEditing(this.board) && PlaitDrawElement.isText(this.element)) {
@@ -780,7 +882,7 @@ class GeometryComponent extends PlaitPluginElementComponent {
780
882
  }
781
883
  initializeTextManage() {
782
884
  const plugins = this.board.getPluginOptions(WithTextPluginKey).textPlugins;
783
- this.textManage = new TextManage(this.board, this.viewContainerRef, {
885
+ const manage = new TextManage(this.board, this.viewContainerRef, {
784
886
  getRectangle: () => {
785
887
  return getTextRectangle(this.element);
786
888
  },
@@ -800,6 +902,7 @@ class GeometryComponent extends PlaitPluginElementComponent {
800
902
  },
801
903
  textPlugins: plugins
802
904
  });
905
+ this.initializeTextManages([manage]);
803
906
  }
804
907
  ngOnDestroy() {
805
908
  super.ngOnDestroy();
@@ -830,7 +933,6 @@ class LineShapeGenerator extends Generator {
830
933
  case LineShape.elbow:
831
934
  case LineShape.straight:
832
935
  lineG = drawLine(this.board, element);
833
- drawMask(this.board, lineG, element);
834
936
  break;
835
937
  default:
836
938
  break;
@@ -838,27 +940,6 @@ class LineShapeGenerator extends Generator {
838
940
  return lineG;
839
941
  }
840
942
  }
841
- function drawMask(board, g, element) {
842
- const mask = createMask();
843
- mask.setAttribute('id', element.id);
844
- mask.setAttribute('maskUnits', 'userSpaceOnUse');
845
- const points = getLinePoints(board, element);
846
- let rectangle = getRectangleByPoints(points);
847
- rectangle = RectangleClient.getOutlineRectangle(rectangle, -3);
848
- const maskRect = createRect(rectangle, {
849
- fill: 'white'
850
- });
851
- mask.appendChild(maskRect);
852
- const texts = element.texts;
853
- texts.forEach((text, index) => {
854
- const textRectangle = getLineTextRectangle(board, element, index);
855
- const rect = createRect(textRectangle, {
856
- fill: 'black'
857
- });
858
- mask.appendChild(rect);
859
- });
860
- g.appendChild(mask);
861
- }
862
943
 
863
944
  class LineActiveGenerator extends Generator {
864
945
  canDraw(element, data) {
@@ -1110,7 +1191,7 @@ const withGeometryCreateByDrag = (board) => {
1110
1191
  }
1111
1192
  geometryShapeG?.remove();
1112
1193
  geometryShapeG = null;
1113
- preventTouchMove(board, false);
1194
+ preventTouchMove(board, event, false);
1114
1195
  pointerUp(event);
1115
1196
  };
1116
1197
  return board;
@@ -1134,8 +1215,8 @@ const withGeometryCreateByDraw = (board) => {
1134
1215
  if (isGeometryPointer && isDrawingMode(board)) {
1135
1216
  const point = transformPoint(board, toPoint(event.x, event.y, PlaitBoard.getHost(board)));
1136
1217
  start = point;
1137
- preventTouchMove(board, true);
1138
1218
  const pointer = PlaitBoard.getPointer(board);
1219
+ preventTouchMove(board, event, true);
1139
1220
  if (pointer === DrawPointerType.text) {
1140
1221
  const points = getDefaultGeometryPoints(pointer, point);
1141
1222
  const textElement = createGeometryElement(GeometryShape.text, points, DefaultTextProperty.text);
@@ -1144,7 +1225,6 @@ const withGeometryCreateByDraw = (board) => {
1144
1225
  addSelectedElement(board, textElement);
1145
1226
  BoardTransforms.updatePointerType(board, PlaitPointerType.selection);
1146
1227
  start = null;
1147
- preventTouchMove(board, false);
1148
1228
  }
1149
1229
  }
1150
1230
  pointerDown(event);
@@ -1193,7 +1273,7 @@ const withGeometryCreateByDraw = (board) => {
1193
1273
  geometryShapeG = null;
1194
1274
  start = null;
1195
1275
  temporaryElement = null;
1196
- preventTouchMove(board, false);
1276
+ preventTouchMove(board, event, false);
1197
1277
  pointerUp(event);
1198
1278
  };
1199
1279
  return board;
@@ -1358,7 +1438,7 @@ const withLineCreateByDraw = (board) => {
1358
1438
  sourceRef.connection = transformPointToConnection(board, point, hitElement);
1359
1439
  sourceRef.boundId = hitElement.id;
1360
1440
  }
1361
- preventTouchMove(board, true);
1441
+ preventTouchMove(board, event, true);
1362
1442
  }
1363
1443
  pointerDown(event);
1364
1444
  };
@@ -1393,7 +1473,7 @@ const withLineCreateByDraw = (board) => {
1393
1473
  sourceRef = {};
1394
1474
  targetRef = {};
1395
1475
  temporaryElement = null;
1396
- preventTouchMove(board, false);
1476
+ preventTouchMove(board, event, false);
1397
1477
  pointerUp(event);
1398
1478
  };
1399
1479
  return board;
@@ -1417,7 +1497,7 @@ const withGeometryResize = (board) => {
1417
1497
  },
1418
1498
  detect: (point) => {
1419
1499
  const selectedGeometryElements = getSelectedGeometryElements(board);
1420
- if (selectedGeometryElements.length !== 1) {
1500
+ if (selectedGeometryElements.length !== 1 || getSelectedElements(board).length !== 1) {
1421
1501
  return null;
1422
1502
  }
1423
1503
  const target = selectedGeometryElements[0];
@@ -1455,8 +1535,7 @@ const withGeometryResize = (board) => {
1455
1535
  ];
1456
1536
  }
1457
1537
  points = normalizeShapePoints(points, isShift);
1458
- const component = PlaitElement.getComponent(resizeRef.element);
1459
- const { height: textHeight } = component.textManage.getSize();
1538
+ const { height: textHeight } = PlaitGeometry.getTextManage(resizeRef.element).getSize();
1460
1539
  DrawTransforms.resizeGeometry(board, points, textHeight, resizeRef.path);
1461
1540
  }
1462
1541
  };
@@ -1553,15 +1632,14 @@ const withLineBoundReaction = (board) => {
1553
1632
  const hitElement = getHitOutlineGeometry(board, movingPoint, -4);
1554
1633
  if (hitElement) {
1555
1634
  boundShapeG = drawBoundMask(board, hitElement);
1556
- const offset = (getStrokeWidthByElement(hitElement) + 1) / 2;
1557
- let nearestPoint = getNearestPoint(hitElement, movingPoint, offset);
1635
+ let nearestPoint = getNearestPoint(hitElement, movingPoint, ACTIVE_STROKE_WIDTH);
1558
1636
  const rectangle = getRectangleByPoints(hitElement.points);
1559
- const activeRectangle = RectangleClient.getOutlineRectangle(rectangle, -offset);
1637
+ const activeRectangle = RectangleClient.inflate(rectangle, ACTIVE_STROKE_WIDTH);
1560
1638
  const hitConnector = getHitConnectorPoint(nearestPoint, hitElement, activeRectangle);
1561
1639
  nearestPoint = hitConnector ? hitConnector : nearestPoint;
1562
1640
  const circleG = drawCircle(PlaitBoard.getRoughSVG(board), nearestPoint, 6, {
1563
1641
  stroke: SELECTION_BORDER_COLOR,
1564
- strokeWidth: 1,
1642
+ strokeWidth: ACTIVE_STROKE_WIDTH,
1565
1643
  fill: SELECTION_BORDER_COLOR,
1566
1644
  fillStyle: 'solid'
1567
1645
  });
@@ -1689,5 +1767,5 @@ const withDraw = (board) => {
1689
1767
  * Generated bundle index. Do not edit.
1690
1768
  */
1691
1769
 
1692
- export { DefaultGeometryActiveStyle, DefaultGeometryProperty, DefaultGeometryStyle, DefaultTextProperty, DrawPointerType, GeometryComponent, GeometryPointer, GeometryShape, GeometryThreshold, LineComponent, LineMarkerType, LineShape, PlaitDrawElement, PlaitGeometry, PlaitLine, ShapeDefaultSpace, StrokeStyle, createGeometryElement, createLineElement, drawBoundMask, drawGeometry, drawLine, drawLineArrow, getBoardLines, getCenterPointsOnPolygon, getConnectionPoint, getElbowPoints, getFillByElement, getHitConnectorPoint, getHitLineTextIndex, getLineDashByElement, getLinePoints, getLineTextRectangle, getNearestPoint, getPointsByCenterPoint, getSelectedDrawElements, getSelectedGeometryElements, getSelectedLineElements, getSourcePoint, getStraightPoints, getStrokeColorByElement, getStrokeStyleByElement, getStrokeWidthByElement, getTargetPoint, getTextRectangle, isHitLineText, isHitPolyLine, transformPointToConnection, withDraw };
1770
+ export { DefaultGeometryActiveStyle, DefaultGeometryProperty, DefaultGeometryStyle, DefaultTextProperty, DrawPointerType, DrawTransforms, GeometryComponent, GeometryPointer, GeometryShape, GeometryThreshold, LineComponent, LineHandleKey, LineMarkerType, LineShape, PlaitDrawElement, PlaitGeometry, PlaitLine, ShapeDefaultSpace, StrokeStyle, createGeometryElement, createLineElement, drawBoundMask, drawGeometry, drawLine, getBoardLines, getCenterPointsOnPolygon, getConnectionPoint, getElbowPoints, getFillByElement, getHitConnectorPoint, getHitLineTextIndex, getLineDashByElement, getLinePoints, getLineTextRectangle, getNearestPoint, getPointsByCenterPoint, getSelectedDrawElements, getSelectedGeometryElements, getSelectedLineElements, getSourcePoint, getStraightPoints, getStrokeColorByElement, getStrokeStyleByElement, getStrokeWidthByElement, getTargetPoint, getTextRectangle, isHitLineText, isHitPolyLine, transformPointToConnection, withDraw };
1693
1771
  //# sourceMappingURL=plait-draw.mjs.map