@elixpo/lixsketch 5.4.7 → 5.5.0

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.
Files changed (218) hide show
  1. package/dist/react/AIRenderer-M4LMJ66J.js +1105 -0
  2. package/dist/react/AIRenderer-M4LMJ66J.js.map +7 -0
  3. package/dist/react/Arrow-BJDAXPMH.js +8 -0
  4. package/dist/react/Arrow-BJDAXPMH.js.map +7 -0
  5. package/dist/react/Circle-KPG7TKIX.js +8 -0
  6. package/dist/react/Circle-KPG7TKIX.js.map +7 -0
  7. package/dist/react/CodeShape-K4DIZAIV.js +8 -0
  8. package/dist/react/CodeShape-K4DIZAIV.js.map +7 -0
  9. package/dist/react/CopyPaste-4CKJRHJ3.js +569 -0
  10. package/dist/react/CopyPaste-4CKJRHJ3.js.map +7 -0
  11. package/dist/react/EraserTrail-PA6IQLQN.js +20 -0
  12. package/dist/react/EraserTrail-PA6IQLQN.js.map +7 -0
  13. package/dist/react/EventDispatcher-SRFH6LQZ.js +463 -0
  14. package/dist/react/EventDispatcher-SRFH6LQZ.js.map +7 -0
  15. package/dist/react/Frame-6UR5XPAX.js +10 -0
  16. package/dist/react/Frame-6UR5XPAX.js.map +7 -0
  17. package/dist/react/FreehandStroke-CK24NUT3.js +8 -0
  18. package/dist/react/FreehandStroke-CK24NUT3.js.map +7 -0
  19. package/dist/react/GraphEngine-QE5B2PMR.js +340 -0
  20. package/dist/react/GraphEngine-QE5B2PMR.js.map +7 -0
  21. package/dist/react/GraphMathParser-2WMTY4IE.js +10 -0
  22. package/dist/react/GraphMathParser-2WMTY4IE.js.map +7 -0
  23. package/dist/react/IconShape-KMIA6T2H.js +10 -0
  24. package/dist/react/IconShape-KMIA6T2H.js.map +7 -0
  25. package/dist/react/ImageShape-CHHGBXUQ.js +10 -0
  26. package/dist/react/ImageShape-CHHGBXUQ.js.map +7 -0
  27. package/dist/react/LayerOrder-XCHF4MSS.js +66 -0
  28. package/dist/react/LayerOrder-XCHF4MSS.js.map +7 -0
  29. package/dist/react/Line-2KOQEEGA.js +10 -0
  30. package/dist/react/Line-2KOQEEGA.js.map +7 -0
  31. package/dist/react/LixScriptParser-JYWJX375.js +1033 -0
  32. package/dist/react/LixScriptParser-JYWJX375.js.map +7 -0
  33. package/dist/react/MermaidFlowchartRenderer-4QBAZ5MB.js +412 -0
  34. package/dist/react/MermaidFlowchartRenderer-4QBAZ5MB.js.map +7 -0
  35. package/dist/react/MermaidSequenceParser-UKG2NSZY.js +8 -0
  36. package/dist/react/MermaidSequenceParser-UKG2NSZY.js.map +7 -0
  37. package/dist/react/MermaidSequenceRenderer-HPLHY5II.js +387 -0
  38. package/dist/react/MermaidSequenceRenderer-HPLHY5II.js.map +7 -0
  39. package/dist/react/Rectangle-6FE7RN6W.js +8 -0
  40. package/dist/react/Rectangle-6FE7RN6W.js.map +7 -0
  41. package/dist/react/ResizeCode-WAMDTKSW.js +2 -0
  42. package/dist/react/ResizeCode-WAMDTKSW.js.map +7 -0
  43. package/dist/react/ResizeShapes-LKEQTITP.js +250 -0
  44. package/dist/react/ResizeShapes-LKEQTITP.js.map +7 -0
  45. package/dist/react/SceneSerializer-4U4B24JM.js +739 -0
  46. package/dist/react/SceneSerializer-4U4B24JM.js.map +7 -0
  47. package/dist/react/Selection-VVUHY5YJ.js +34 -0
  48. package/dist/react/Selection-VVUHY5YJ.js.map +7 -0
  49. package/dist/react/SketchEngine-YA4RG3KX.js +413 -0
  50. package/dist/react/SketchEngine-YA4RG3KX.js.map +7 -0
  51. package/dist/react/TextShape-54ZJ66E3.js +8 -0
  52. package/dist/react/TextShape-54ZJ66E3.js.map +7 -0
  53. package/dist/react/UndoRedo-M2JZUBKN.js +30 -0
  54. package/dist/react/UndoRedo-M2JZUBKN.js.map +7 -0
  55. package/dist/react/ZoomPan-U3TXC5AJ.js +186 -0
  56. package/dist/react/ZoomPan-U3TXC5AJ.js.map +7 -0
  57. package/dist/react/arrowTool-CWEMIRXK.js +17 -0
  58. package/dist/react/arrowTool-CWEMIRXK.js.map +7 -0
  59. package/dist/react/boxicons-5JNJQPUP.woff +0 -0
  60. package/dist/react/boxicons-6NVWQSCQ.eot +0 -0
  61. package/dist/react/boxicons-AQ5N6WP7.woff2 +0 -0
  62. package/dist/react/boxicons-GDR4JU3X.ttf +0 -0
  63. package/dist/react/boxicons-NNFHLMOR.svg +1660 -0
  64. package/dist/react/chunk-2OQXI7QB.js +564 -0
  65. package/dist/react/chunk-2OQXI7QB.js.map +7 -0
  66. package/dist/react/chunk-5OUBTHHO.js +187 -0
  67. package/dist/react/chunk-5OUBTHHO.js.map +7 -0
  68. package/dist/react/chunk-6PFXZKL2.js +628 -0
  69. package/dist/react/chunk-6PFXZKL2.js.map +7 -0
  70. package/dist/react/chunk-6SFNWGGZ.js +453 -0
  71. package/dist/react/chunk-6SFNWGGZ.js.map +7 -0
  72. package/dist/react/chunk-7TZSIR6V.js +210 -0
  73. package/dist/react/chunk-7TZSIR6V.js.map +7 -0
  74. package/dist/react/chunk-AJAZC37E.js +662 -0
  75. package/dist/react/chunk-AJAZC37E.js.map +7 -0
  76. package/dist/react/chunk-BU4D2WYQ.js +1213 -0
  77. package/dist/react/chunk-BU4D2WYQ.js.map +7 -0
  78. package/dist/react/chunk-BZE4CEBG.js +747 -0
  79. package/dist/react/chunk-BZE4CEBG.js.map +7 -0
  80. package/dist/react/chunk-CB2RANCB.js +212 -0
  81. package/dist/react/chunk-CB2RANCB.js.map +7 -0
  82. package/dist/react/chunk-DNAG7ML6.js +128 -0
  83. package/dist/react/chunk-DNAG7ML6.js.map +7 -0
  84. package/dist/react/chunk-HZWLPXFN.js +198 -0
  85. package/dist/react/chunk-HZWLPXFN.js.map +7 -0
  86. package/dist/react/chunk-I6HCCIXB.js +572 -0
  87. package/dist/react/chunk-I6HCCIXB.js.map +7 -0
  88. package/dist/react/chunk-IZ5OGWGW.js +235 -0
  89. package/dist/react/chunk-IZ5OGWGW.js.map +7 -0
  90. package/dist/react/chunk-JJCJNLNN.js +1490 -0
  91. package/dist/react/chunk-JJCJNLNN.js.map +7 -0
  92. package/dist/react/chunk-JQ3IRFDP.js +222 -0
  93. package/dist/react/chunk-JQ3IRFDP.js.map +7 -0
  94. package/dist/react/chunk-L5OARZJ7.js +1134 -0
  95. package/dist/react/chunk-L5OARZJ7.js.map +7 -0
  96. package/dist/react/chunk-LHRTXNVE.js +1600 -0
  97. package/dist/react/chunk-LHRTXNVE.js.map +7 -0
  98. package/dist/react/chunk-Q2GA4MBZ.js +1653 -0
  99. package/dist/react/chunk-Q2GA4MBZ.js.map +7 -0
  100. package/dist/react/chunk-QNSE5BAY.js +519 -0
  101. package/dist/react/chunk-QNSE5BAY.js.map +7 -0
  102. package/dist/react/chunk-QXFBG7OM.js +191 -0
  103. package/dist/react/chunk-QXFBG7OM.js.map +7 -0
  104. package/dist/react/chunk-T6ZVV5ZO.js +714 -0
  105. package/dist/react/chunk-T6ZVV5ZO.js.map +7 -0
  106. package/dist/react/chunk-URB6MY46.js +974 -0
  107. package/dist/react/chunk-URB6MY46.js.map +7 -0
  108. package/dist/react/chunk-VN62KLOC.js +931 -0
  109. package/dist/react/chunk-VN62KLOC.js.map +7 -0
  110. package/dist/react/chunk-VQVEPJSA.js +158 -0
  111. package/dist/react/chunk-VQVEPJSA.js.map +7 -0
  112. package/dist/react/chunk-XISEAGBV.js +1632 -0
  113. package/dist/react/chunk-XISEAGBV.js.map +7 -0
  114. package/dist/react/chunk-YKJUBFHE.js +575 -0
  115. package/dist/react/chunk-YKJUBFHE.js.map +7 -0
  116. package/dist/react/circleTool-NUATSEI2.js +14 -0
  117. package/dist/react/circleTool-NUATSEI2.js.map +7 -0
  118. package/dist/react/codeTool-MHCB2FNB.js +38 -0
  119. package/dist/react/codeTool-MHCB2FNB.js.map +7 -0
  120. package/dist/react/eraserTool-2GS2LQCS.js +103 -0
  121. package/dist/react/eraserTool-2GS2LQCS.js.map +7 -0
  122. package/dist/react/frameTool-PWVKKXSP.js +14 -0
  123. package/dist/react/frameTool-PWVKKXSP.js.map +7 -0
  124. package/dist/react/freehandTool-SLYGASVP.js +14 -0
  125. package/dist/react/freehandTool-SLYGASVP.js.map +7 -0
  126. package/dist/react/iconTool-GPZ7O7NH.js +18 -0
  127. package/dist/react/iconTool-GPZ7O7NH.js.map +7 -0
  128. package/dist/react/imageTool-D5R4XGEU.js +15 -0
  129. package/dist/react/imageTool-D5R4XGEU.js.map +7 -0
  130. package/dist/react/index.js +5342 -0
  131. package/dist/react/index.js.map +7 -0
  132. package/dist/react/laserTool-XVMV63AV.js +239 -0
  133. package/dist/react/laserTool-XVMV63AV.js.map +7 -0
  134. package/dist/react/lineTool-WNI5EMZ5.js +14 -0
  135. package/dist/react/lineTool-WNI5EMZ5.js.map +7 -0
  136. package/dist/react/lixCode-OJMVUXXI.ttf +0 -0
  137. package/dist/react/lixDefault-JEAPAUJL.ttf +0 -0
  138. package/dist/react/lixFancy-BPXYM5CQ.ttf +0 -0
  139. package/dist/react/lixFont-CPKEUDVM.woff2 +0 -0
  140. package/dist/react/rectangleTool-U7DZ6ZTA.js +14 -0
  141. package/dist/react/rectangleTool-U7DZ6ZTA.js.map +7 -0
  142. package/dist/react/styles.css +6627 -0
  143. package/dist/react/textTool-M7S6F3VC.js +21 -0
  144. package/dist/react/textTool-M7S6F3VC.js.map +7 -0
  145. package/package.json +39 -5
  146. package/src/EngineShortcuts.js +83 -27
  147. package/src/core/AIRenderer.js +30 -18
  148. package/src/core/GraphEngine.js +64 -41
  149. package/src/core/MermaidFlowchartRenderer.js +153 -88
  150. package/src/core/MermaidSequenceRenderer.js +168 -93
  151. package/src/core/SceneSerializer.js +86 -2
  152. package/src/core/Selection.js +119 -19
  153. package/src/core/UndoRedo.js +82 -15
  154. package/src/core/ZoomPan.js +15 -5
  155. package/src/index.js +14 -1
  156. package/src/react/LixSketchCanvas.jsx +347 -0
  157. package/src/react/components/AppMenu.jsx +475 -0
  158. package/src/react/components/Footer.jsx +85 -0
  159. package/src/react/components/Toolbar.jsx +140 -0
  160. package/src/react/components/canvas/CanvasLoadingOverlay.jsx +76 -0
  161. package/src/react/components/canvas/ContextMenu.jsx +466 -0
  162. package/src/react/components/canvas/FindBar.jsx +177 -0
  163. package/src/react/components/canvas/ImageSourcePicker.jsx +133 -0
  164. package/src/react/components/canvas/MultiSelectActions.jsx +120 -0
  165. package/src/react/components/canvas/SVGCanvas.jsx +145 -0
  166. package/src/react/components/canvas/SaveStatusIndicator.jsx +29 -0
  167. package/src/react/components/modals/CanvasPropertiesModal.jsx +358 -0
  168. package/src/react/components/modals/CommandPalette.jsx +307 -0
  169. package/src/react/components/modals/ExportImageModal.jsx +287 -0
  170. package/src/react/components/modals/GraphModal.jsx +174 -0
  171. package/src/react/components/modals/HelpModal.jsx +208 -0
  172. package/src/react/components/modals/LixScriptModal.jsx +130 -0
  173. package/src/react/components/modals/ShortcutsModal.jsx +125 -0
  174. package/src/react/components/sidebars/ArrowSidebar.jsx +173 -0
  175. package/src/react/components/sidebars/CircleSidebar.jsx +134 -0
  176. package/src/react/components/sidebars/FrameSidebar.jsx +263 -0
  177. package/src/react/components/sidebars/IconSidebar.jsx +279 -0
  178. package/src/react/components/sidebars/ImageSidebar.jsx +69 -0
  179. package/src/react/components/sidebars/LineSidebar.jsx +109 -0
  180. package/src/react/components/sidebars/PaintbrushSidebar.jsx +119 -0
  181. package/src/react/components/sidebars/RectangleSidebar.jsx +165 -0
  182. package/src/react/components/sidebars/ShapeSidebar.jsx +130 -0
  183. package/src/react/components/sidebars/TextSidebar.jsx +174 -0
  184. package/src/react/hooks/inertStores.js +58 -0
  185. package/src/react/hooks/useSketchEngine.js +76 -0
  186. package/src/react/hooks/useTranslation.js +92 -0
  187. package/src/react/index.js +41 -0
  188. package/src/react/store/useSketchStore.js +234 -0
  189. package/src/react/store/useUIStore.js +196 -0
  190. package/src/react/styles/arrowSidebar.css +263 -0
  191. package/src/react/styles/canvasStroke.css +47 -0
  192. package/src/react/styles/canvasTools.css +769 -0
  193. package/src/react/styles/circleSidebar.css +206 -0
  194. package/src/react/styles/fonts/fonts.css +29 -0
  195. package/src/react/styles/fonts/lixCode.ttf +0 -0
  196. package/src/react/styles/fonts/lixDefault.ttf +0 -0
  197. package/src/react/styles/fonts/lixDocs.ttf +0 -0
  198. package/src/react/styles/fonts/lixFancy.ttf +0 -0
  199. package/src/react/styles/fonts/lixFont.woff2 +0 -0
  200. package/src/react/styles/lineSidebar.css +207 -0
  201. package/src/react/styles/paintbrushSidebar.css +247 -0
  202. package/src/react/styles/squareSidebar.css +206 -0
  203. package/src/react/styles/writeText.css +149 -0
  204. package/src/react/styles.css +175 -0
  205. package/src/react/toolsEnum.js +20 -0
  206. package/src/react/utils/toast.js +18 -0
  207. package/src/shapes/Frame.js +7 -1
  208. package/src/shapes/Line.js +11 -5
  209. package/src/tools/arrowTool.js +30 -4
  210. package/src/tools/circleTool.js +33 -9
  211. package/src/tools/codeTool.js +5 -3
  212. package/src/tools/frameTool.js +47 -7
  213. package/src/tools/freehandTool.js +12 -4
  214. package/src/tools/iconTool.js +7 -1
  215. package/src/tools/imageTool.js +7 -1
  216. package/src/tools/lineTool.js +27 -3
  217. package/src/tools/rectangleTool.js +45 -8
  218. package/src/tools/textTool.js +23 -6
@@ -0,0 +1,564 @@
1
+ "use client";
2
+ import {
3
+ calculateSnap,
4
+ clearSnapGuides,
5
+ updateAttachedArrows
6
+ } from "./chunk-BZE4CEBG.js";
7
+ import {
8
+ pushCreateAction,
9
+ pushDeleteAction,
10
+ pushFrameAttachmentAction,
11
+ pushOptionsChangeAction,
12
+ pushTransformAction
13
+ } from "./chunk-L5OARZJ7.js";
14
+
15
+ // src/tools/freehandTool.js
16
+ function getThemeStroke() {
17
+ if (typeof document === "undefined") return "#fff";
18
+ return document.body && document.body.classList.contains("theme-dark") ? "#fff" : "#1a1a2e";
19
+ }
20
+ window.__updateArrowsForShape = updateAttachedArrows;
21
+ var strokeColors = document.querySelectorAll(".strokeColors span");
22
+ var strokeThicknesses = document.querySelectorAll(".strokeThickness span");
23
+ var strokeStyles = document.querySelectorAll(".strokeStyleSpan");
24
+ var strokeTapers = document.querySelectorAll(".strokeTaperSpan");
25
+ var strokeRoughnesses = document.querySelectorAll(".strokeRoughnessSpan");
26
+ var strokeColor = null;
27
+ var strokeThickness = 2;
28
+ var strokeStyleValue = "solid";
29
+ var strokeThinning = 0;
30
+ var strokeRoughnessValue = "smooth";
31
+ var points = [];
32
+ var isDrawingStroke = false;
33
+ var currentStroke = null;
34
+ var strokeOpacity = 1;
35
+ var isDraggingStroke = false;
36
+ var isResizingStroke = false;
37
+ var isRotatingStroke = false;
38
+ var dragOldPosStroke = null;
39
+ var resizingAnchorIndex = null;
40
+ var startRotationMouseAngle = null;
41
+ var startShapeRotation = null;
42
+ var startX;
43
+ var startY;
44
+ var draggedShapeInitialFrameStroke = null;
45
+ var hoveredFrameStroke = null;
46
+ var lastPoint = null;
47
+ var lastTime = 0;
48
+ var minDistance = 2;
49
+ var maxDistance = 15;
50
+ var isdraggingOpacity = false;
51
+ function getSvgCoordinates(event) {
52
+ const rect = svg.getBoundingClientRect();
53
+ const scaleX = currentViewBox.width / rect.width;
54
+ const scaleY = currentViewBox.height / rect.height;
55
+ const svgX = currentViewBox.x + (event.clientX - rect.left) * scaleX;
56
+ const svgY = currentViewBox.y + (event.clientY - rect.top) * scaleY;
57
+ return { x: svgX, y: svgY };
58
+ }
59
+ function updateFrameContainmentForStroke(shape) {
60
+ if (shape.isBeingMovedByFrame) return;
61
+ let targetFrame = null;
62
+ shapes.forEach((s) => {
63
+ if (s.shapeName === "frame" && s.isShapeInFrame(shape)) {
64
+ targetFrame = s;
65
+ }
66
+ });
67
+ if (shape.parentFrame && isDraggingStroke) {
68
+ shape.parentFrame.temporarilyRemoveFromFrame(shape);
69
+ }
70
+ if (hoveredFrameStroke && hoveredFrameStroke !== targetFrame) {
71
+ hoveredFrameStroke.removeHighlight();
72
+ }
73
+ if (targetFrame && targetFrame !== hoveredFrameStroke) {
74
+ targetFrame.highlightFrame();
75
+ }
76
+ hoveredFrameStroke = targetFrame;
77
+ }
78
+ function deleteCurrentShape() {
79
+ if (currentShape && currentShape.shapeName === "freehandStroke") {
80
+ const idx = shapes.indexOf(currentShape);
81
+ if (idx !== -1) shapes.splice(idx, 1);
82
+ if (currentShape.group.parentNode) {
83
+ currentShape.group.parentNode.removeChild(currentShape.group);
84
+ }
85
+ pushDeleteAction(currentShape);
86
+ currentShape = null;
87
+ disableAllSideBars();
88
+ }
89
+ }
90
+ document.addEventListener("keydown", (e) => {
91
+ if (e.key === "Delete" && currentShape && currentShape.shapeName === "freehandStroke") {
92
+ deleteCurrentShape();
93
+ }
94
+ });
95
+ function handleMouseDown(e) {
96
+ const { x, y } = getSvgCoordinates(e);
97
+ if (isPaintToolActive) {
98
+ isDrawingStroke = true;
99
+ const pressure = e.pressure || 0.5;
100
+ points = [[x, y, pressure]];
101
+ lastPoint = [x, y, pressure];
102
+ lastTime = Date.now();
103
+ currentStroke = new FreehandStroke(points, {
104
+ stroke: strokeColor ?? getThemeStroke(),
105
+ strokeWidth: strokeThickness
106
+ });
107
+ shapes.push(currentStroke);
108
+ currentShape = currentStroke;
109
+ } else if (isSelectionToolActive) {
110
+ let clickedOnShape = false;
111
+ if (currentShape && currentShape.shapeName === "freehandStroke" && currentShape.isSelected) {
112
+ const anchorInfo = currentShape.isNearAnchor(x, y);
113
+ if (anchorInfo) {
114
+ if (anchorInfo.type === "resize") {
115
+ isResizingStroke = true;
116
+ resizingAnchorIndex = anchorInfo.index;
117
+ dragOldPosStroke = cloneStrokeData(currentShape);
118
+ } else if (anchorInfo.type === "rotate") {
119
+ isRotatingStroke = true;
120
+ const centerX = currentShape.boundingBox.x + currentShape.boundingBox.width / 2;
121
+ const centerY = currentShape.boundingBox.y + currentShape.boundingBox.height / 2;
122
+ startRotationMouseAngle = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI;
123
+ startShapeRotation = currentShape.rotation;
124
+ dragOldPosStroke = cloneStrokeData(currentShape);
125
+ }
126
+ clickedOnShape = true;
127
+ } else if (currentShape.contains(x, y)) {
128
+ isDraggingStroke = true;
129
+ dragOldPosStroke = cloneStrokeData(currentShape);
130
+ draggedShapeInitialFrameStroke = currentShape.parentFrame || null;
131
+ if (currentShape.parentFrame) {
132
+ currentShape.parentFrame.temporarilyRemoveFromFrame(currentShape);
133
+ }
134
+ startX = x;
135
+ startY = y;
136
+ clickedOnShape = true;
137
+ }
138
+ }
139
+ if (!clickedOnShape) {
140
+ let shapeToSelect = null;
141
+ for (let i = shapes.length - 1; i >= 0; i--) {
142
+ const shape = shapes[i];
143
+ if (shape instanceof FreehandStroke && shape.contains(x, y)) {
144
+ shapeToSelect = shape;
145
+ break;
146
+ }
147
+ }
148
+ if (currentShape && currentShape !== shapeToSelect) {
149
+ currentShape.deselectStroke();
150
+ currentShape = null;
151
+ }
152
+ if (shapeToSelect) {
153
+ currentShape = shapeToSelect;
154
+ currentShape.selectStroke();
155
+ const anchorInfo = currentShape.isNearAnchor(x, y);
156
+ if (anchorInfo) {
157
+ if (anchorInfo.type === "resize") {
158
+ isResizingStroke = true;
159
+ resizingAnchorIndex = anchorInfo.index;
160
+ dragOldPosStroke = cloneStrokeData(currentShape);
161
+ } else if (anchorInfo.type === "rotate") {
162
+ isRotatingStroke = true;
163
+ const centerX = currentShape.boundingBox.x + currentShape.boundingBox.width / 2;
164
+ const centerY = currentShape.boundingBox.y + currentShape.boundingBox.height / 2;
165
+ startRotationMouseAngle = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI;
166
+ startShapeRotation = currentShape.rotation;
167
+ dragOldPosStroke = cloneStrokeData(currentShape);
168
+ }
169
+ } else {
170
+ isDraggingStroke = true;
171
+ dragOldPosStroke = cloneStrokeData(currentShape);
172
+ draggedShapeInitialFrameStroke = currentShape.parentFrame || null;
173
+ if (currentShape.parentFrame) {
174
+ currentShape.parentFrame.temporarilyRemoveFromFrame(currentShape);
175
+ }
176
+ startX = x;
177
+ startY = y;
178
+ }
179
+ clickedOnShape = true;
180
+ }
181
+ }
182
+ if (!clickedOnShape && currentShape) {
183
+ currentShape.deselectStroke();
184
+ currentShape = null;
185
+ disableAllSideBars();
186
+ }
187
+ }
188
+ }
189
+ function handleMouseMove(e) {
190
+ let { x, y } = getSvgCoordinates(e);
191
+ const currentTime = Date.now();
192
+ const svgRect = svg.getBoundingClientRect();
193
+ lastMousePos = {
194
+ x: e.clientX - svgRect.left,
195
+ y: e.clientY - svgRect.top
196
+ };
197
+ if (isDrawingStroke && isPaintToolActive) {
198
+ const pressure = e.pressure || 0.5;
199
+ if (e.shiftKey && points.length > 0) {
200
+ const startX2 = points[0][0], startY2 = points[0][1];
201
+ const dx = x - startX2, dy = y - startY2;
202
+ const angle = Math.atan2(dy, dx);
203
+ const snapAngle = Math.round(angle / (Math.PI / 4)) * (Math.PI / 4);
204
+ const dist = Math.sqrt(dx * dx + dy * dy);
205
+ x = startX2 + dist * Math.cos(snapAngle);
206
+ y = startY2 + dist * Math.sin(snapAngle);
207
+ points = [points[0], [x, y, pressure]];
208
+ lastPoint = [x, y, pressure];
209
+ currentStroke.points = points;
210
+ currentStroke.draw();
211
+ return;
212
+ }
213
+ if (lastPoint) {
214
+ const dx = x - lastPoint[0];
215
+ const dy = y - lastPoint[1];
216
+ const distance = Math.sqrt(dx * dx + dy * dy);
217
+ if (distance >= minDistance) {
218
+ if (distance > maxDistance) {
219
+ const steps = Math.ceil(distance / maxDistance);
220
+ for (let i = 1; i < steps; i++) {
221
+ const t = i / steps;
222
+ const interpX = lastPoint[0] + dx * t;
223
+ const interpY = lastPoint[1] + dy * t;
224
+ const interpPressure = lastPoint[2] + (pressure - lastPoint[2]) * t;
225
+ points.push([interpX, interpY, interpPressure]);
226
+ }
227
+ }
228
+ const timeDelta = currentTime - lastTime;
229
+ const velocity = distance / Math.max(timeDelta, 1);
230
+ const velocityPressure = Math.min(1, Math.max(0.1, 1 - velocity * 0.02));
231
+ const finalPressure = (pressure + velocityPressure) * 0.5;
232
+ points.push([x, y, finalPressure]);
233
+ currentStroke.points = points;
234
+ currentStroke.draw();
235
+ lastPoint = [x, y, finalPressure];
236
+ lastTime = currentTime;
237
+ }
238
+ } else {
239
+ lastPoint = [x, y, pressure];
240
+ lastTime = currentTime;
241
+ }
242
+ shapes.forEach((frame) => {
243
+ if (frame.shapeName === "frame") {
244
+ if (frame.isShapeInFrame(currentStroke)) {
245
+ frame.highlightFrame();
246
+ hoveredFrameStroke = frame;
247
+ } else if (hoveredFrameStroke === frame) {
248
+ frame.removeHighlight();
249
+ hoveredFrameStroke = null;
250
+ }
251
+ }
252
+ });
253
+ } else if (isDraggingStroke && currentShape && currentShape.isSelected) {
254
+ const dx = x - startX;
255
+ const dy = y - startY;
256
+ currentShape.move(dx, dy);
257
+ startX = x;
258
+ startY = y;
259
+ if (!currentShape.isBeingMovedByFrame) {
260
+ updateFrameContainmentForStroke(currentShape);
261
+ }
262
+ currentShape.updateAttachedArrows();
263
+ if (window.__sketchStoreApi && window.__sketchStoreApi.getState().snapToObjects) {
264
+ const snap = calculateSnap(currentShape, e.shiftKey, e.clientX, e.clientY);
265
+ if (snap.dx || snap.dy) {
266
+ currentShape.move(snap.dx, snap.dy);
267
+ }
268
+ } else {
269
+ clearSnapGuides();
270
+ }
271
+ } else if (isResizingStroke && currentShape && currentShape.isSelected) {
272
+ currentShape.updatePosition(resizingAnchorIndex, x, y);
273
+ } else if (isRotatingStroke && currentShape && currentShape.isSelected) {
274
+ const centerX = currentShape.boundingBox.x + currentShape.boundingBox.width / 2;
275
+ const centerY = currentShape.boundingBox.y + currentShape.boundingBox.height / 2;
276
+ const currentMouseAngle = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI;
277
+ const angleDiff = currentMouseAngle - startRotationMouseAngle;
278
+ currentShape.rotate(startShapeRotation + angleDiff);
279
+ currentShape.draw();
280
+ }
281
+ }
282
+ function handleMouseUp(e) {
283
+ if (isDrawingStroke) {
284
+ isDrawingStroke = false;
285
+ lastPoint = null;
286
+ if (currentStroke && currentStroke.points.length >= 2) {
287
+ currentStroke.draw();
288
+ pushCreateAction(currentStroke);
289
+ const finalFrame = hoveredFrameStroke;
290
+ if (finalFrame) {
291
+ finalFrame.addShapeToFrame(currentStroke);
292
+ pushFrameAttachmentAction(finalFrame, currentStroke, "attach", null);
293
+ }
294
+ const drawnShape = currentStroke;
295
+ if (window.__sketchStoreApi) window.__sketchStoreApi.setActiveTool("select", { afterDraw: true });
296
+ currentShape = drawnShape;
297
+ currentShape.selectStroke();
298
+ } else if (currentStroke) {
299
+ shapes.pop();
300
+ if (currentStroke.group.parentNode) {
301
+ currentStroke.group.parentNode.removeChild(currentStroke.group);
302
+ }
303
+ }
304
+ if (hoveredFrameStroke) {
305
+ hoveredFrameStroke.removeHighlight();
306
+ hoveredFrameStroke = null;
307
+ }
308
+ currentStroke = null;
309
+ }
310
+ if ((isDraggingStroke || isResizingStroke || isRotatingStroke) && dragOldPosStroke && currentShape) {
311
+ const newPos = cloneStrokeData(currentShape);
312
+ const stateChanged = JSON.stringify(dragOldPosStroke.points) !== JSON.stringify(newPos.points) || dragOldPosStroke.rotation !== newPos.rotation;
313
+ const oldPos = {
314
+ ...dragOldPosStroke,
315
+ parentFrame: draggedShapeInitialFrameStroke
316
+ };
317
+ const newPosForUndo = {
318
+ ...newPos,
319
+ parentFrame: isDraggingStroke ? hoveredFrameStroke || null : currentShape.parentFrame
320
+ };
321
+ const frameChanged = oldPos.parentFrame !== newPosForUndo.parentFrame;
322
+ if (stateChanged || frameChanged) {
323
+ pushTransformAction(currentShape, oldPos, newPosForUndo);
324
+ }
325
+ if (isDraggingStroke) {
326
+ const finalFrame = hoveredFrameStroke;
327
+ if (draggedShapeInitialFrameStroke !== finalFrame) {
328
+ if (draggedShapeInitialFrameStroke) {
329
+ draggedShapeInitialFrameStroke.removeShapeFromFrame(currentShape);
330
+ }
331
+ if (finalFrame) {
332
+ finalFrame.addShapeToFrame(currentShape);
333
+ }
334
+ if (frameChanged) {
335
+ pushFrameAttachmentAction(
336
+ finalFrame || draggedShapeInitialFrameStroke,
337
+ currentShape,
338
+ finalFrame ? "attach" : "detach",
339
+ draggedShapeInitialFrameStroke
340
+ );
341
+ }
342
+ } else if (draggedShapeInitialFrameStroke) {
343
+ draggedShapeInitialFrameStroke.restoreToFrame(currentShape);
344
+ }
345
+ }
346
+ dragOldPosStroke = null;
347
+ draggedShapeInitialFrameStroke = null;
348
+ }
349
+ if (hoveredFrameStroke) {
350
+ hoveredFrameStroke.removeHighlight();
351
+ hoveredFrameStroke = null;
352
+ }
353
+ if (currentShape && typeof currentShape.finalizeMove === "function") {
354
+ currentShape.finalizeMove();
355
+ }
356
+ clearSnapGuides();
357
+ isDraggingStroke = false;
358
+ isResizingStroke = false;
359
+ isRotatingStroke = false;
360
+ resizingAnchorIndex = null;
361
+ startRotationMouseAngle = null;
362
+ startShapeRotation = null;
363
+ svg.style.cursor = "default";
364
+ }
365
+ strokeColors.forEach((span) => {
366
+ span.addEventListener("click", (event) => {
367
+ strokeColors.forEach((el) => el.classList.remove("selected"));
368
+ span.classList.add("selected");
369
+ if (currentShape instanceof FreehandStroke && currentShape.isSelected) {
370
+ const oldOptions = { ...currentShape.options };
371
+ currentShape.options.stroke = span.getAttribute("data-id");
372
+ currentShape.draw();
373
+ pushOptionsChangeAction(currentShape, oldOptions);
374
+ } else {
375
+ strokeColor = span.getAttribute("data-id");
376
+ }
377
+ });
378
+ });
379
+ strokeThicknesses.forEach((span) => {
380
+ span.addEventListener("click", (event) => {
381
+ strokeThicknesses.forEach((el) => el.classList.remove("selected"));
382
+ span.classList.add("selected");
383
+ if (currentShape instanceof FreehandStroke && currentShape.isSelected) {
384
+ const oldOptions = { ...currentShape.options };
385
+ currentShape.options.strokeWidth = parseInt(span.getAttribute("data-id"));
386
+ currentShape.draw();
387
+ pushOptionsChangeAction(currentShape, oldOptions);
388
+ } else {
389
+ strokeThickness = parseInt(span.getAttribute("data-id"));
390
+ }
391
+ });
392
+ });
393
+ strokeStyles.forEach((span) => {
394
+ span.addEventListener("click", () => {
395
+ strokeStyles.forEach((el) => el.classList.remove("selected"));
396
+ span.classList.add("selected");
397
+ const val = span.getAttribute("data-id");
398
+ if (currentShape instanceof FreehandStroke && currentShape.isSelected) {
399
+ const oldOptions = { ...currentShape.options };
400
+ currentShape.options.strokeStyle = val;
401
+ currentShape.draw();
402
+ pushOptionsChangeAction(currentShape, oldOptions);
403
+ } else {
404
+ strokeStyleValue = val;
405
+ }
406
+ });
407
+ });
408
+ strokeTapers.forEach((span) => {
409
+ span.addEventListener("click", () => {
410
+ strokeTapers.forEach((el) => el.classList.remove("selected"));
411
+ span.classList.add("selected");
412
+ const val = parseFloat(span.getAttribute("data-id"));
413
+ if (currentShape instanceof FreehandStroke && currentShape.isSelected) {
414
+ const oldOptions = { ...currentShape.options };
415
+ currentShape.options.thinning = val;
416
+ currentShape.draw();
417
+ pushOptionsChangeAction(currentShape, oldOptions);
418
+ } else {
419
+ strokeThinning = val;
420
+ }
421
+ });
422
+ });
423
+ strokeRoughnesses.forEach((span) => {
424
+ span.addEventListener("click", () => {
425
+ strokeRoughnesses.forEach((el) => el.classList.remove("selected"));
426
+ span.classList.add("selected");
427
+ const val = span.getAttribute("data-id");
428
+ if (currentShape instanceof FreehandStroke && currentShape.isSelected) {
429
+ const oldOptions = { ...currentShape.options };
430
+ currentShape.options.roughness = val;
431
+ currentShape.draw();
432
+ pushOptionsChangeAction(currentShape, oldOptions);
433
+ } else {
434
+ strokeRoughnessValue = val;
435
+ }
436
+ });
437
+ });
438
+ document.getElementById("strokeOpacity")?.addEventListener("mousedown", (event) => {
439
+ isdraggingOpacity = true;
440
+ });
441
+ document.getElementById("strokeOpacity")?.addEventListener("mousemove", (event) => {
442
+ if (isdraggingOpacity) {
443
+ const slider = document.getElementById("strokeOpacity");
444
+ const rect = slider.getBoundingClientRect();
445
+ const mouseX = event.clientX - rect.left;
446
+ const percent = Math.max(0, Math.min(100, mouseX / rect.width * 100));
447
+ document.getElementById("opacityContainerValue").textContent = percent.toFixed(0);
448
+ const opacity = percent / 100;
449
+ if (currentShape instanceof FreehandStroke && currentShape.isSelected) {
450
+ const oldOptions = { ...currentShape.options };
451
+ currentShape.options.strokeOpacity = opacity;
452
+ currentShape.draw();
453
+ pushOptionsChangeAction(currentShape, oldOptions);
454
+ } else {
455
+ strokeOpacity = opacity;
456
+ }
457
+ }
458
+ });
459
+ document.getElementById("strokeOpacity")?.addEventListener("mouseup", (event) => {
460
+ isdraggingOpacity = false;
461
+ });
462
+ function cloneOptions(options) {
463
+ return JSON.parse(JSON.stringify(options));
464
+ }
465
+ function cloneStrokeData(stroke) {
466
+ return {
467
+ points: JSON.parse(JSON.stringify(stroke.points)),
468
+ rotation: stroke.rotation,
469
+ options: cloneOptions(stroke.options)
470
+ };
471
+ }
472
+ window.freehandToolSettings = {
473
+ get strokeColor() {
474
+ return strokeColor;
475
+ },
476
+ set strokeColor(v) {
477
+ strokeColor = v;
478
+ },
479
+ get strokeWidth() {
480
+ return strokeThickness;
481
+ },
482
+ set strokeWidth(v) {
483
+ strokeThickness = v;
484
+ },
485
+ get strokeStyle() {
486
+ return strokeStyleValue;
487
+ },
488
+ set strokeStyle(v) {
489
+ strokeStyleValue = v;
490
+ },
491
+ get thinning() {
492
+ return strokeThinning;
493
+ },
494
+ set thinning(v) {
495
+ strokeThinning = v;
496
+ },
497
+ get roughness() {
498
+ return strokeRoughnessValue;
499
+ },
500
+ set roughness(v) {
501
+ strokeRoughnessValue = v;
502
+ },
503
+ get opacity() {
504
+ return strokeOpacity;
505
+ },
506
+ set opacity(v) {
507
+ strokeOpacity = v;
508
+ }
509
+ };
510
+ window.updateSelectedFreehandStyle = function(changes) {
511
+ if (currentShape && currentShape.shapeName === "freehandStroke" && currentShape.isSelected) {
512
+ if (changes.stroke !== void 0) {
513
+ strokeColor = changes.stroke;
514
+ currentShape.options.stroke = changes.stroke;
515
+ }
516
+ if (changes.strokeWidth !== void 0) {
517
+ strokeThickness = changes.strokeWidth;
518
+ currentShape.options.strokeWidth = changes.strokeWidth;
519
+ }
520
+ if (changes.thinning !== void 0) {
521
+ strokeThinning = changes.thinning;
522
+ currentShape.options.thinning = changes.thinning;
523
+ }
524
+ if (changes.roughness !== void 0) {
525
+ strokeRoughnessValue = changes.roughness;
526
+ currentShape.options.roughness = changes.roughness;
527
+ }
528
+ if (changes.opacity !== void 0) {
529
+ strokeOpacity = changes.opacity;
530
+ currentShape.options.strokeOpacity = changes.opacity;
531
+ }
532
+ currentShape.draw();
533
+ } else {
534
+ if (changes.stroke !== void 0) strokeColor = changes.stroke;
535
+ if (changes.strokeWidth !== void 0) strokeThickness = changes.strokeWidth;
536
+ if (changes.thinning !== void 0) strokeThinning = changes.thinning;
537
+ if (changes.roughness !== void 0) strokeRoughnessValue = changes.roughness;
538
+ if (changes.opacity !== void 0) strokeOpacity = changes.opacity;
539
+ }
540
+ };
541
+ window.addEventListener("pointerup", () => {
542
+ if (isDrawingStroke) {
543
+ isDrawingStroke = false;
544
+ lastPoint = null;
545
+ if (currentStroke && currentStroke.points && currentStroke.points.length >= 2) {
546
+ currentStroke.draw();
547
+ }
548
+ currentStroke = null;
549
+ }
550
+ });
551
+ document.addEventListener("visibilitychange", () => {
552
+ if (document.hidden && isDrawingStroke) {
553
+ isDrawingStroke = false;
554
+ lastPoint = null;
555
+ currentStroke = null;
556
+ }
557
+ });
558
+
559
+ export {
560
+ handleMouseDown,
561
+ handleMouseMove,
562
+ handleMouseUp
563
+ };
564
+ //# sourceMappingURL=chunk-2OQXI7QB.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/tools/freehandTool.js"],
4
+ "sourcesContent": ["/* eslint-disable */\n// Freehand tool event handlers - extracted from canvasStroke.js\nimport { pushCreateAction, pushDeleteAction, pushOptionsChangeAction, pushTransformAction, pushFrameAttachmentAction } from '../core/UndoRedo.js';\nimport { updateAttachedArrows as updateArrowsForShape, cleanupAttachments } from './arrowTool.js';\nimport { calculateSnap, clearSnapGuides } from '../core/SnapGuides.js';\n\nfunction getThemeStroke() { if (typeof document === \"undefined\") return \"#fff\"; return document.body && document.body.classList.contains(\"theme-dark\") ? \"#fff\" : \"#1a1a2e\"; }\n\n// Expose updateArrowsForShape globally so FreehandStroke.updateAttachedArrows() can call it\n// (FreehandStroke.js is a separate module and cannot import freehandTool's local bindings)\nwindow.__updateArrowsForShape = updateArrowsForShape;\n\nconst strokeColors = document.querySelectorAll(\".strokeColors span\");\nconst strokeThicknesses = document.querySelectorAll(\".strokeThickness span\");\nconst strokeStyles = document.querySelectorAll(\".strokeStyleSpan\");\nconst strokeTapers = document.querySelectorAll(\".strokeTaperSpan\");\nconst strokeRoughnesses = document.querySelectorAll(\".strokeRoughnessSpan\");\nlet strokeColor = null;\nlet strokeThickness = 2;\nlet strokeStyleValue = \"solid\";\nlet strokeThinning = 0;\nlet strokeRoughnessValue = \"smooth\";\nlet points = [];\nlet isDrawingStroke = false;\nlet currentStroke = null;\nlet strokeOpacity = 1;\n\n\nlet isDraggingStroke = false;\nlet isResizingStroke = false;\nlet isRotatingStroke = false;\nlet dragOldPosStroke = null;\nlet resizingAnchorIndex = null;\nlet startRotationMouseAngle = null;\nlet startShapeRotation = null;\nlet startX, startY;\n\n// Frame attachment variables\nlet draggedShapeInitialFrameStroke = null;\nlet hoveredFrameStroke = null;\n\n// Enhanced mouse tracking with better point collection\nlet lastPoint = null;\nlet lastTime = 0;\nconst minDistance = 2; // Minimum distance between points\nconst maxDistance = 15; // Maximum distance for interpolation\nlet isdraggingOpacity = false;\n\n\nfunction getSvgCoordinates(event) {\n const rect = svg.getBoundingClientRect();\n const scaleX = currentViewBox.width / rect.width;\n const scaleY = currentViewBox.height / rect.height;\n\n const svgX = currentViewBox.x + (event.clientX - rect.left) * scaleX;\n const svgY = currentViewBox.y + (event.clientY - rect.top) * scaleY;\n\n return { x: svgX, y: svgY };\n}\n\nfunction getSvgPathFromStroke(stroke) {\n if (!stroke.length) return '';\n \n // Use more sophisticated curve fitting\n const pathData = [];\n pathData.push('M', stroke[0][0], stroke[0][1]);\n \n for (let i = 1; i < stroke.length - 1; i++) {\n const curr = stroke[i];\n const next = stroke[i + 1];\n \n // Calculate control points for smoother curves\n const cpX = curr[0] + (next[0] - curr[0]) * 0.5;\n const cpY = curr[1] + (next[1] - curr[1]) * 0.5;\n \n pathData.push('Q', curr[0], curr[1], cpX, cpY);\n }\n \n // Add final point\n if (stroke.length > 1) {\n const lastPoint = stroke[stroke.length - 1];\n pathData.push('L', lastPoint[0], lastPoint[1]);\n }\n \n return pathData.join(' ');\n}\n\n// Frame containment check for a freehand stroke during drag.\n// Lives here (not in FreehandStroke.js) because it needs isDraggingStroke & hoveredFrameStroke.\nfunction updateFrameContainmentForStroke(shape) {\n if (shape.isBeingMovedByFrame) return;\n\n let targetFrame = null;\n shapes.forEach(s => {\n if (s.shapeName === 'frame' && s.isShapeInFrame(shape)) {\n targetFrame = s;\n }\n });\n\n if (shape.parentFrame && isDraggingStroke) {\n shape.parentFrame.temporarilyRemoveFromFrame(shape);\n }\n\n if (hoveredFrameStroke && hoveredFrameStroke !== targetFrame) {\n hoveredFrameStroke.removeHighlight();\n }\n if (targetFrame && targetFrame !== hoveredFrameStroke) {\n targetFrame.highlightFrame();\n }\n hoveredFrameStroke = targetFrame;\n}\n\n// Delete functionality\nfunction deleteCurrentShape() {\n if (currentShape && currentShape.shapeName === 'freehandStroke') {\n const idx = shapes.indexOf(currentShape);\n if (idx !== -1) shapes.splice(idx, 1);\n if (currentShape.group.parentNode) {\n currentShape.group.parentNode.removeChild(currentShape.group);\n }\n pushDeleteAction(currentShape);\n currentShape = null;\n disableAllSideBars();\n }\n}\n\ndocument.addEventListener('keydown', (e) => {\n if (e.key === 'Delete' && currentShape && currentShape.shapeName === 'freehandStroke') {\n deleteCurrentShape();\n }\n});\n\n// Event handlers\nfunction handleMouseDown(e) {\n const { x, y } = getSvgCoordinates(e);\n \n if (isPaintToolActive) {\n isDrawingStroke = true;\n const pressure = e.pressure || 0.5;\n points = [[x, y, pressure]];\n lastPoint = [x, y, pressure];\n lastTime = Date.now();\n\n currentStroke = new FreehandStroke(points, {\n stroke: strokeColor ?? getThemeStroke(),\n strokeWidth: strokeThickness\n });\n\n shapes.push(currentStroke);\n currentShape = currentStroke;\n } else if (isSelectionToolActive) {\n let clickedOnShape = false;\n \n // Check if clicking on current selected stroke\n if (currentShape && currentShape.shapeName === 'freehandStroke' && currentShape.isSelected) {\n const anchorInfo = currentShape.isNearAnchor(x, y);\n if (anchorInfo) {\n if (anchorInfo.type === 'resize') {\n isResizingStroke = true;\n resizingAnchorIndex = anchorInfo.index;\n dragOldPosStroke = cloneStrokeData(currentShape);\n } else if (anchorInfo.type === 'rotate') {\n isRotatingStroke = true;\n const centerX = currentShape.boundingBox.x + currentShape.boundingBox.width / 2;\n const centerY = currentShape.boundingBox.y + currentShape.boundingBox.height / 2;\n startRotationMouseAngle = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI;\n startShapeRotation = currentShape.rotation;\n dragOldPosStroke = cloneStrokeData(currentShape);\n }\n clickedOnShape = true;\n } else if (currentShape.contains(x, y)) {\n isDraggingStroke = true;\n dragOldPosStroke = cloneStrokeData(currentShape);\n \n // Store initial frame state\n draggedShapeInitialFrameStroke = currentShape.parentFrame || null;\n \n // Temporarily remove from frame clipping if dragging\n if (currentShape.parentFrame) {\n currentShape.parentFrame.temporarilyRemoveFromFrame(currentShape);\n }\n \n startX = x;\n startY = y;\n clickedOnShape = true;\n }\n }\n\n // If not clicking on selected shape, check for other shapes\n if (!clickedOnShape) {\n let shapeToSelect = null;\n for (let i = shapes.length - 1; i >= 0; i--) {\n const shape = shapes[i];\n if (shape instanceof FreehandStroke && shape.contains(x, y)) {\n shapeToSelect = shape;\n break;\n }\n }\n\n if (currentShape && currentShape !== shapeToSelect) {\n currentShape.deselectStroke();\n currentShape = null;\n }\n\n if (shapeToSelect) {\n currentShape = shapeToSelect;\n currentShape.selectStroke(); // This will show the sidebar\n \n const anchorInfo = currentShape.isNearAnchor(x, y);\n if (anchorInfo) {\n if (anchorInfo.type === 'resize') {\n isResizingStroke = true;\n resizingAnchorIndex = anchorInfo.index;\n dragOldPosStroke = cloneStrokeData(currentShape);\n } else if (anchorInfo.type === 'rotate') {\n isRotatingStroke = true;\n const centerX = currentShape.boundingBox.x + currentShape.boundingBox.width / 2;\n const centerY = currentShape.boundingBox.y + currentShape.boundingBox.height / 2;\n startRotationMouseAngle = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI;\n startShapeRotation = currentShape.rotation;\n dragOldPosStroke = cloneStrokeData(currentShape);\n }\n } else {\n isDraggingStroke = true;\n dragOldPosStroke = cloneStrokeData(currentShape);\n \n // Store initial frame state\n draggedShapeInitialFrameStroke = currentShape.parentFrame || null;\n \n // Temporarily remove from frame clipping if dragging\n if (currentShape.parentFrame) {\n currentShape.parentFrame.temporarilyRemoveFromFrame(currentShape);\n }\n \n startX = x;\n startY = y;\n }\n clickedOnShape = true;\n }\n }\n\n if (!clickedOnShape && currentShape) {\n currentShape.deselectStroke();\n currentShape = null;\n disableAllSideBars(); // Hide sidebar when deselecting\n }\n }\n}\n\nfunction handleMouseMove(e) {\n let { x, y } = getSvgCoordinates(e);\n const currentTime = Date.now();\n \n // Keep lastMousePos in screen coordinates for other functions\n const svgRect = svg.getBoundingClientRect();\n lastMousePos = {\n x: e.clientX - svgRect.left, \n y: e.clientY - svgRect.top\n };\n \n if (isDrawingStroke && isPaintToolActive) {\n const pressure = e.pressure || 0.5;\n\n // Shift key constrains to straight line from start point\n if (e.shiftKey && points.length > 0) {\n const startX = points[0][0], startY = points[0][1];\n const dx = x - startX, dy = y - startY;\n const angle = Math.atan2(dy, dx);\n const snapAngle = Math.round(angle / (Math.PI / 4)) * (Math.PI / 4);\n const dist = Math.sqrt(dx * dx + dy * dy);\n x = startX + dist * Math.cos(snapAngle);\n y = startY + dist * Math.sin(snapAngle);\n // Reset points to just start + current for straight line\n points = [points[0], [x, y, pressure]];\n lastPoint = [x, y, pressure];\n currentStroke.points = points;\n currentStroke.draw();\n return;\n }\n\n if (lastPoint) {\n const dx = x - lastPoint[0];\n const dy = y - lastPoint[1];\n const distance = Math.sqrt(dx * dx + dy * dy);\n \n // Only add point if it's far enough from the last one\n if (distance >= minDistance) {\n // If distance is too large, interpolate points\n if (distance > maxDistance) {\n const steps = Math.ceil(distance / maxDistance);\n for (let i = 1; i < steps; i++) {\n const t = i / steps;\n const interpX = lastPoint[0] + dx * t;\n const interpY = lastPoint[1] + dy * t;\n const interpPressure = lastPoint[2] + (pressure - lastPoint[2]) * t;\n points.push([interpX, interpY, interpPressure]);\n }\n }\n \n // Calculate velocity-based pressure\n const timeDelta = currentTime - lastTime;\n const velocity = distance / Math.max(timeDelta, 1);\n const velocityPressure = Math.min(1, Math.max(0.1, 1 - velocity * 0.02));\n const finalPressure = (pressure + velocityPressure) * 0.5;\n \n points.push([x, y, finalPressure]);\n currentStroke.points = points;\n currentStroke.draw();\n \n lastPoint = [x, y, finalPressure];\n lastTime = currentTime;\n }\n } else {\n lastPoint = [x, y, pressure];\n lastTime = currentTime;\n }\n \n // Check for frame containment while drawing (but don't apply clipping yet)\n shapes.forEach(frame => {\n if (frame.shapeName === 'frame') {\n if (frame.isShapeInFrame(currentStroke)) {\n frame.highlightFrame();\n hoveredFrameStroke = frame;\n } else if (hoveredFrameStroke === frame) {\n frame.removeHighlight();\n hoveredFrameStroke = null;\n }\n }\n });\n } else if (isDraggingStroke && currentShape && currentShape.isSelected) {\n const dx = x - startX;\n const dy = y - startY;\n currentShape.move(dx, dy);\n startX = x;\n startY = y;\n\n // Frame containment update (must live here where isDraggingStroke is in scope)\n if (!currentShape.isBeingMovedByFrame) {\n updateFrameContainmentForStroke(currentShape);\n }\n\n // Update arrows attached to this shape\n currentShape.updateAttachedArrows();\n\n // Snap guides\n if (window.__sketchStoreApi && window.__sketchStoreApi.getState().snapToObjects) {\n const snap = calculateSnap(currentShape, e.shiftKey, e.clientX, e.clientY);\n if (snap.dx || snap.dy) {\n currentShape.move(snap.dx, snap.dy);\n }\n } else {\n clearSnapGuides();\n }\n } else if (isResizingStroke && currentShape && currentShape.isSelected) {\n currentShape.updatePosition(resizingAnchorIndex, x, y);\n } else if (isRotatingStroke && currentShape && currentShape.isSelected) {\n const centerX = currentShape.boundingBox.x + currentShape.boundingBox.width / 2;\n const centerY = currentShape.boundingBox.y + currentShape.boundingBox.height / 2;\n const currentMouseAngle = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI;\n const angleDiff = currentMouseAngle - startRotationMouseAngle;\n currentShape.rotate(startShapeRotation + angleDiff);\n currentShape.draw();\n }\n}\n\nfunction handleMouseUp(e) {\n if (isDrawingStroke) {\n isDrawingStroke = false;\n lastPoint = null;\n \n // Final smoothing pass after drawing is complete\n if (currentStroke && currentStroke.points.length >= 2) {\n currentStroke.draw(); // Redraw with final smoothing\n pushCreateAction(currentStroke);\n\n // Check for frame containment and track attachment\n const finalFrame = hoveredFrameStroke;\n if (finalFrame) {\n finalFrame.addShapeToFrame(currentStroke);\n // Track the attachment for undo\n pushFrameAttachmentAction(finalFrame, currentStroke, 'attach', null);\n }\n\n // Auto-select the drawn stroke and switch to selection tool\n const drawnShape = currentStroke;\n if (window.__sketchStoreApi) window.__sketchStoreApi.setActiveTool('select', { afterDraw: true });\n currentShape = drawnShape;\n currentShape.selectStroke();\n } else if (currentStroke) {\n // Remove strokes that are too small\n shapes.pop();\n if (currentStroke.group.parentNode) {\n currentStroke.group.parentNode.removeChild(currentStroke.group);\n }\n }\n\n // Clear frame highlighting\n if (hoveredFrameStroke) {\n hoveredFrameStroke.removeHighlight();\n hoveredFrameStroke = null;\n }\n\n currentStroke = null;\n }\n \n if ((isDraggingStroke || isResizingStroke || isRotatingStroke) && dragOldPosStroke && currentShape) {\n const newPos = cloneStrokeData(currentShape);\n const stateChanged = \n JSON.stringify(dragOldPosStroke.points) !== JSON.stringify(newPos.points) ||\n dragOldPosStroke.rotation !== newPos.rotation;\n \n const oldPos = {\n ...dragOldPosStroke,\n parentFrame: draggedShapeInitialFrameStroke\n };\n // Issue #34 bug #2: for drag, hoveredFrameStroke is the actual\n // destination \u2014 currentShape.parentFrame at this point is still\n // the OLD frame. Resize / rotate don't track hover, fall back to\n // the shape's own parent.\n const newPosForUndo = {\n ...newPos,\n parentFrame: isDraggingStroke\n ? (hoveredFrameStroke || null)\n : currentShape.parentFrame,\n };\n \n const frameChanged = oldPos.parentFrame !== newPosForUndo.parentFrame;\n \n if (stateChanged || frameChanged) {\n pushTransformAction(currentShape, oldPos, newPosForUndo);\n }\n \n // Handle frame containment changes after drag\n if (isDraggingStroke) {\n const finalFrame = hoveredFrameStroke;\n \n // If shape moved to a different frame\n if (draggedShapeInitialFrameStroke !== finalFrame) {\n // Remove from initial frame\n if (draggedShapeInitialFrameStroke) {\n draggedShapeInitialFrameStroke.removeShapeFromFrame(currentShape);\n }\n \n // Add to new frame\n if (finalFrame) {\n finalFrame.addShapeToFrame(currentShape);\n }\n \n // Track the frame change for undo\n if (frameChanged) {\n pushFrameAttachmentAction(finalFrame || draggedShapeInitialFrameStroke, currentShape, \n finalFrame ? 'attach' : 'detach', draggedShapeInitialFrameStroke);\n }\n } else if (draggedShapeInitialFrameStroke) {\n // Shape stayed in same frame, restore clipping\n draggedShapeInitialFrameStroke.restoreToFrame(currentShape);\n }\n }\n \n dragOldPosStroke = null;\n draggedShapeInitialFrameStroke = null;\n }\n \n // Clear frame highlighting\n if (hoveredFrameStroke) {\n hoveredFrameStroke.removeHighlight();\n hoveredFrameStroke = null;\n }\n \n // Bake accumulated move offset into point coordinates\n if (currentShape && typeof currentShape.finalizeMove === 'function') {\n currentShape.finalizeMove();\n }\n clearSnapGuides();\n isDraggingStroke = false;\n isResizingStroke = false;\n isRotatingStroke = false;\n resizingAnchorIndex = null;\n startRotationMouseAngle = null;\n startShapeRotation = null;\n svg.style.cursor = 'default';\n}\n\n// Color and thickness selection\nstrokeColors.forEach(span => {\n span.addEventListener(\"click\", (event) => {\n strokeColors.forEach(el => el.classList.remove(\"selected\"));\n span.classList.add(\"selected\");\n \n if (currentShape instanceof FreehandStroke && currentShape.isSelected) {\n const oldOptions = {...currentShape.options};\n currentShape.options.stroke = span.getAttribute(\"data-id\");\n currentShape.draw();\n pushOptionsChangeAction(currentShape, oldOptions);\n } else {\n strokeColor = span.getAttribute(\"data-id\");\n }\n });\n});\n\nstrokeThicknesses.forEach(span => {\n span.addEventListener(\"click\", (event) => {\n strokeThicknesses.forEach(el => el.classList.remove(\"selected\"));\n span.classList.add(\"selected\");\n \n if (currentShape instanceof FreehandStroke && currentShape.isSelected) {\n const oldOptions = {...currentShape.options};\n currentShape.options.strokeWidth = parseInt(span.getAttribute(\"data-id\"));\n currentShape.draw();\n pushOptionsChangeAction(currentShape, oldOptions);\n } else {\n strokeThickness = parseInt(span.getAttribute(\"data-id\"));\n }\n });\n});\n\n\nstrokeStyles.forEach(span => {\n span.addEventListener(\"click\", () => {\n strokeStyles.forEach(el => el.classList.remove(\"selected\"));\n span.classList.add(\"selected\");\n const val = span.getAttribute(\"data-id\");\n if (currentShape instanceof FreehandStroke && currentShape.isSelected) {\n const oldOptions = {...currentShape.options};\n currentShape.options.strokeStyle = val;\n currentShape.draw();\n pushOptionsChangeAction(currentShape, oldOptions);\n } else {\n strokeStyleValue = val;\n }\n });\n});\n\nstrokeTapers.forEach(span => {\n span.addEventListener(\"click\", () => {\n strokeTapers.forEach(el => el.classList.remove(\"selected\"));\n span.classList.add(\"selected\");\n const val = parseFloat(span.getAttribute(\"data-id\"));\n if (currentShape instanceof FreehandStroke && currentShape.isSelected) {\n const oldOptions = {...currentShape.options};\n currentShape.options.thinning = val;\n currentShape.draw();\n pushOptionsChangeAction(currentShape, oldOptions);\n } else {\n strokeThinning = val;\n }\n });\n});\n\nstrokeRoughnesses.forEach(span => {\n span.addEventListener(\"click\", () => {\n strokeRoughnesses.forEach(el => el.classList.remove(\"selected\"));\n span.classList.add(\"selected\");\n const val = span.getAttribute(\"data-id\");\n if (currentShape instanceof FreehandStroke && currentShape.isSelected) {\n const oldOptions = {...currentShape.options};\n currentShape.options.roughness = val;\n currentShape.draw();\n pushOptionsChangeAction(currentShape, oldOptions);\n } else {\n strokeRoughnessValue = val;\n }\n });\n});\n\ndocument.getElementById(\"strokeOpacity\")?.addEventListener(\"mousedown\", (event) => {\n isdraggingOpacity = true;\n});\n\ndocument.getElementById(\"strokeOpacity\")?.addEventListener(\"mousemove\", (event) => {\n if(isdraggingOpacity) \n {\n const slider = document.getElementById(\"strokeOpacity\");\n const rect = slider.getBoundingClientRect();\n const mouseX = event.clientX - rect.left;\n const percent = Math.max(0, Math.min(100, (mouseX / rect.width) * 100));\n document.getElementById(\"opacityContainerValue\").textContent = percent.toFixed(0);\n const opacity = percent / 100; \n if (currentShape instanceof FreehandStroke && currentShape.isSelected) {\n const oldOptions = {...currentShape.options};\n currentShape.options.strokeOpacity = opacity; \n currentShape.draw();\n pushOptionsChangeAction(currentShape, oldOptions);\n } else {\n strokeOpacity = opacity; \n }\n }\n});\n\ndocument.getElementById(\"strokeOpacity\")?.addEventListener(\"mouseup\", (event) => {\n isdraggingOpacity = false;\n});\n\nfunction cloneOptions(options) {\n return JSON.parse(JSON.stringify(options));\n}\n\nfunction cloneStrokeData(stroke) {\n return {\n points: JSON.parse(JSON.stringify(stroke.points)),\n rotation: stroke.rotation,\n options: cloneOptions(stroke.options)\n };\n}\n\n// Event listeners\n// svg.addEventListener('pointerdown', handleMouseDown);\n// svg.addEventListener('pointermove', handleMouseMove);\n// svg.addEventListener('pointerup', handleMouseUp);\n\n// Bridge freehand tool settings to React sidebar\nwindow.freehandToolSettings = {\n get strokeColor() { return strokeColor; },\n set strokeColor(v) { strokeColor = v; },\n get strokeWidth() { return strokeThickness; },\n set strokeWidth(v) { strokeThickness = v; },\n get strokeStyle() { return strokeStyleValue; },\n set strokeStyle(v) { strokeStyleValue = v; },\n get thinning() { return strokeThinning; },\n set thinning(v) { strokeThinning = v; },\n get roughness() { return strokeRoughnessValue; },\n set roughness(v) { strokeRoughnessValue = v; },\n get opacity() { return strokeOpacity; },\n set opacity(v) { strokeOpacity = v; },\n};\nwindow.updateSelectedFreehandStyle = function(changes) {\n if (currentShape && currentShape.shapeName === 'freehandStroke' && currentShape.isSelected) {\n if (changes.stroke !== undefined) { strokeColor = changes.stroke; currentShape.options.stroke = changes.stroke; }\n if (changes.strokeWidth !== undefined) { strokeThickness = changes.strokeWidth; currentShape.options.strokeWidth = changes.strokeWidth; }\n if (changes.thinning !== undefined) { strokeThinning = changes.thinning; currentShape.options.thinning = changes.thinning; }\n if (changes.roughness !== undefined) { strokeRoughnessValue = changes.roughness; currentShape.options.roughness = changes.roughness; }\n if (changes.opacity !== undefined) { strokeOpacity = changes.opacity; currentShape.options.strokeOpacity = changes.opacity; }\n currentShape.draw();\n } else {\n if (changes.stroke !== undefined) strokeColor = changes.stroke;\n if (changes.strokeWidth !== undefined) strokeThickness = changes.strokeWidth;\n if (changes.thinning !== undefined) strokeThinning = changes.thinning;\n if (changes.roughness !== undefined) strokeRoughnessValue = changes.roughness;\n if (changes.opacity !== undefined) strokeOpacity = changes.opacity;\n }\n};\n\n// Safety net: if mouseup fires outside the SVG canvas (e.g. on toolbar/overlay),\n// ensure we stop drawing so the stroke doesn't continue when pointer re-enters.\nwindow.addEventListener('pointerup', () => {\n if (isDrawingStroke) {\n isDrawingStroke = false;\n lastPoint = null;\n if (currentStroke && currentStroke.points && currentStroke.points.length >= 2) {\n currentStroke.draw();\n }\n currentStroke = null;\n }\n});\n\n// Also listen for visibility change (e.g. alt-tab while drawing)\ndocument.addEventListener('visibilitychange', () => {\n if (document.hidden && isDrawingStroke) {\n isDrawingStroke = false;\n lastPoint = null;\n currentStroke = null;\n }\n});\n\nexport\n{\n handleMouseDown as handleFreehandMouseDown,\n handleMouseMove as handleFreehandMouseMove,\n handleMouseUp as handleFreehandMouseUp,\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;AAMA,SAAS,iBAAiB;AAAE,MAAI,OAAO,aAAa,YAAa,QAAO;AAA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