@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,235 @@
1
+ "use client";
2
+ import {
3
+ pushCreateAction,
4
+ pushDeleteAction,
5
+ pushTransformAction
6
+ } from "./chunk-L5OARZJ7.js";
7
+
8
+ // src/tools/frameTool.js
9
+ var currentFrame = null;
10
+ var isResizing = false;
11
+ var isDragging = false;
12
+ var activeAnchor = null;
13
+ var isDrawingFrame = false;
14
+ var frameStrokeColor = "#888";
15
+ var frameStrokeThickness = 2;
16
+ var frameFillColor = "transparent";
17
+ var frameOpacity = 1;
18
+ var startX;
19
+ var startY;
20
+ var dragOldPosFrame = null;
21
+ function getSVGCoordsFromMouse(e) {
22
+ const viewBox = svg.viewBox.baseVal;
23
+ const rect = svg.getBoundingClientRect();
24
+ const mouseX = e.clientX - rect.left;
25
+ const mouseY = e.clientY - rect.top;
26
+ const svgX = viewBox.x + mouseX / rect.width * viewBox.width;
27
+ const svgY = viewBox.y + mouseY / rect.height * viewBox.height;
28
+ return { x: svgX, y: svgY };
29
+ }
30
+ var handleMouseDown = (e) => {
31
+ if (!isFrameToolActive && !isSelectionToolActive) return;
32
+ const { x, y } = getSVGCoordsFromMouse(e);
33
+ if (isFrameToolActive) {
34
+ isDrawingFrame = true;
35
+ startX = x;
36
+ startY = y;
37
+ currentFrame = new Frame(x, y, 0, 0, {
38
+ stroke: frameStrokeColor,
39
+ strokeWidth: frameStrokeThickness,
40
+ fill: frameFillColor,
41
+ opacity: frameOpacity
42
+ });
43
+ shapes.push(currentFrame);
44
+ currentShape = currentFrame;
45
+ } else if (isSelectionToolActive) {
46
+ for (let i = shapes.length - 1; i >= 0; i--) {
47
+ if (shapes[i].shapeName === "frame" && shapes[i].contains(x, y)) {
48
+ const clickedFrame = shapes[i];
49
+ let clickedContainedShape = false;
50
+ if (clickedFrame.containedShapes && clickedFrame.containedShapes.length > 0) {
51
+ for (let j = clickedFrame.containedShapes.length - 1; j >= 0; j--) {
52
+ const inner = clickedFrame.containedShapes[j];
53
+ if (inner.contains && inner.contains(x, y)) {
54
+ clickedContainedShape = true;
55
+ break;
56
+ }
57
+ }
58
+ }
59
+ if (clickedContainedShape) {
60
+ if (currentShape && currentShape.shapeName === "frame" && typeof currentShape.removeSelection === "function") {
61
+ currentShape.removeSelection();
62
+ }
63
+ currentShape = null;
64
+ return;
65
+ }
66
+ if (currentShape && currentShape !== clickedFrame) {
67
+ currentShape.removeSelection();
68
+ }
69
+ currentShape = clickedFrame;
70
+ currentShape.selectFrame();
71
+ const anchorIndex = typeof currentShape.isNearAnchor === "function" ? currentShape.isNearAnchor(x, y) : null;
72
+ if (anchorIndex !== null) {
73
+ activeAnchor = anchorIndex;
74
+ isResizing = true;
75
+ } else {
76
+ isDragging = true;
77
+ startX = x;
78
+ startY = y;
79
+ dragOldPosFrame = {
80
+ x: currentShape.x,
81
+ y: currentShape.y,
82
+ width: currentShape.width,
83
+ height: currentShape.height,
84
+ rotation: currentShape.rotation
85
+ };
86
+ }
87
+ return;
88
+ }
89
+ }
90
+ if (currentShape && currentShape.shapeName === "frame") {
91
+ currentShape.removeSelection();
92
+ currentShape = null;
93
+ }
94
+ }
95
+ };
96
+ var handleMouseMove = (e) => {
97
+ const { x, y } = getSVGCoordsFromMouse(e);
98
+ if (isDrawingFrame && currentFrame) {
99
+ const width = Math.abs(x - startX);
100
+ const height = Math.abs(y - startY);
101
+ currentFrame.x = Math.min(startX, x);
102
+ currentFrame.y = Math.min(startY, y);
103
+ currentFrame.width = width;
104
+ currentFrame.height = height;
105
+ currentFrame.draw();
106
+ } else if (isDragging && currentShape && currentShape.shapeName === "frame") {
107
+ const dx = x - startX;
108
+ const dy = y - startY;
109
+ currentShape.move(dx, dy);
110
+ startX = x;
111
+ startY = y;
112
+ }
113
+ };
114
+ var handleMouseUp = (e) => {
115
+ if (isDrawingFrame && currentFrame) {
116
+ if (currentFrame.width < 10 || currentFrame.height < 10) {
117
+ currentFrame.destroy();
118
+ currentFrame = null;
119
+ currentShape = null;
120
+ } else {
121
+ pushCreateAction(currentFrame);
122
+ currentFrame.updateContainedShapes(true);
123
+ const placedFrame = currentFrame;
124
+ if (window.__sketchStoreApi) {
125
+ window.__sketchStoreApi.setActiveTool("select", { afterDraw: true });
126
+ } else {
127
+ window.isSelectionToolActive = true;
128
+ }
129
+ currentShape = placedFrame;
130
+ placedFrame.selectFrame();
131
+ }
132
+ isDrawingFrame = false;
133
+ }
134
+ if (isDragging && dragOldPosFrame && currentShape) {
135
+ const newPos = {
136
+ x: currentShape.x,
137
+ y: currentShape.y,
138
+ width: currentShape.width,
139
+ height: currentShape.height,
140
+ rotation: currentShape.rotation
141
+ };
142
+ pushTransformAction(currentShape, dragOldPosFrame, newPos);
143
+ dragOldPosFrame = null;
144
+ if (currentShape.shapeName === "frame") {
145
+ currentShape.updateClipPath();
146
+ }
147
+ }
148
+ if (!isDragging) {
149
+ shapes.forEach((shape) => {
150
+ if (shape.shapeName !== "frame" && !shape.parentFrame) {
151
+ shapes.forEach((frame) => {
152
+ if (frame.shapeName === "frame") {
153
+ if (frame.isShapeInFrame(shape)) {
154
+ frame.addShapeToFrame(shape);
155
+ }
156
+ }
157
+ });
158
+ }
159
+ });
160
+ }
161
+ isDrawingFrame = false;
162
+ isDragging = false;
163
+ isResizing = false;
164
+ activeAnchor = null;
165
+ svg.style.cursor = "default";
166
+ };
167
+ Frame.prototype.isNearAnchor = function(x, y) {
168
+ const anchorSize = 10 / currentZoom;
169
+ const anchorPositions = [
170
+ { x: this.x, y: this.y },
171
+ { x: this.x + this.width / 2, y: this.y },
172
+ { x: this.x + this.width, y: this.y },
173
+ { x: this.x + this.width, y: this.y + this.height / 2 },
174
+ { x: this.x + this.width, y: this.y + this.height },
175
+ { x: this.x + this.width / 2, y: this.y + this.height },
176
+ { x: this.x, y: this.y + this.height },
177
+ { x: this.x, y: this.y + this.height / 2 },
178
+ { x: this.x + this.width / 2, y: this.y - 30 / currentZoom }
179
+ // Rotation handle
180
+ ];
181
+ for (let i = 0; i < anchorPositions.length; i++) {
182
+ const pos = anchorPositions[i];
183
+ const distance = Math.sqrt((x - pos.x) ** 2 + (y - pos.y) ** 2);
184
+ if (distance <= anchorSize) {
185
+ return i;
186
+ }
187
+ }
188
+ return null;
189
+ };
190
+ function deleteCurrentFrame() {
191
+ if (currentShape && currentShape.shapeName === "frame") {
192
+ const frame = currentShape;
193
+ const isDiagramFrame = !!frame._diagramType;
194
+ let childSnapshot = null;
195
+ if (!isDiagramFrame) {
196
+ childSnapshot = [...frame.containedShapes || []];
197
+ for (const child of childSnapshot) {
198
+ if (!child || child === frame) continue;
199
+ const el = child.group || child.element;
200
+ if (el) {
201
+ if (frame.clipGroup && el.parentNode === frame.clipGroup) frame.clipGroup.removeChild(el);
202
+ if (window.svg && el.parentNode !== window.svg) window.svg.appendChild(el);
203
+ }
204
+ child.parentFrame = null;
205
+ delete child.isBeingMovedByFrame;
206
+ }
207
+ frame.containedShapes = [];
208
+ }
209
+ const idx = shapes.indexOf(frame);
210
+ if (idx !== -1) shapes.splice(idx, 1);
211
+ if (!isDiagramFrame) {
212
+ if (frame.group && frame.group.parentNode) frame.group.parentNode.removeChild(frame.group);
213
+ if (frame.clipGroup && frame.clipGroup.parentNode) frame.clipGroup.parentNode.removeChild(frame.clipGroup);
214
+ if (frame.clipPath && frame.clipPath.parentNode) frame.clipPath.parentNode.removeChild(frame.clipPath);
215
+ } else if (frame.group && frame.group.parentNode) {
216
+ frame.group.parentNode.removeChild(frame.group);
217
+ }
218
+ if (childSnapshot) pushDeleteAction(frame, { childSnapshot });
219
+ else pushDeleteAction(frame);
220
+ currentShape = null;
221
+ }
222
+ }
223
+ document.addEventListener("keydown", (e) => {
224
+ if (e.key === "Delete" && currentShape && currentShape.shapeName === "frame") {
225
+ deleteCurrentFrame();
226
+ }
227
+ });
228
+ window.Frame = Frame;
229
+
230
+ export {
231
+ handleMouseDown,
232
+ handleMouseMove,
233
+ handleMouseUp
234
+ };
235
+ //# sourceMappingURL=chunk-IZ5OGWGW.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/tools/frameTool.js"],
4
+ "sourcesContent": ["/* eslint-disable */\n// Frame tool event handlers - extracted from frameHolder.js\nimport { pushCreateAction, pushDeleteAction, pushTransformAction, pushFrameAttachmentAction } from '../core/UndoRedo.js';\nimport { updateAttachedArrows, cleanupAttachments } from './arrowTool.js';\n\nlet currentFrame = null;\nlet isResizing = false;\nlet isDragging = false;\nlet activeAnchor = null;\nlet isDrawingFrame = false;\nlet frameStrokeColor = \"#888\";\nlet frameStrokeThickness = 2;\nlet frameFillColor = \"transparent\";\nlet frameOpacity = 1;\nlet startX, startY;\nlet dragOldPosFrame = null;\n\nfunction getSVGCoordsFromMouse(e) {\n const viewBox = svg.viewBox.baseVal;\n const rect = svg.getBoundingClientRect();\n const mouseX = e.clientX - rect.left;\n const mouseY = e.clientY - rect.top;\n const svgX = viewBox.x + (mouseX / rect.width) * viewBox.width;\n const svgY = viewBox.y + (mouseY / rect.height) * viewBox.height;\n return { x: svgX, y: svgY };\n}\n\n\n// Event handlers for frame tool\nconst handleMouseDown = (e) => {\n if (!isFrameToolActive && !isSelectionToolActive) return;\n\n const { x, y } = getSVGCoordsFromMouse(e);\n\n if (isFrameToolActive) {\n isDrawingFrame = true;\n startX = x;\n startY = y;\n currentFrame = new Frame(x, y, 0, 0, {\n stroke: frameStrokeColor,\n strokeWidth: frameStrokeThickness,\n fill: frameFillColor,\n opacity: frameOpacity\n });\n shapes.push(currentFrame);\n currentShape = currentFrame;\n } else if (isSelectionToolActive) {\n // Handle frame selection \u2014 but first check if a contained shape was clicked\n for (let i = shapes.length - 1; i >= 0; i--) {\n if (shapes[i].shapeName === 'frame' && shapes[i].contains(x, y)) {\n const clickedFrame = shapes[i];\n\n // Check if click is on a shape inside this frame \u2014 let shape handlers deal with it\n let clickedContainedShape = false;\n if (clickedFrame.containedShapes && clickedFrame.containedShapes.length > 0) {\n for (let j = clickedFrame.containedShapes.length - 1; j >= 0; j--) {\n const inner = clickedFrame.containedShapes[j];\n if (inner.contains && inner.contains(x, y)) {\n clickedContainedShape = true;\n break;\n }\n }\n }\n // If a contained shape was clicked, don't select the frame \u2014\n // and crucially, clear `currentShape` so the EventDispatcher's\n // `if (handled && prevShape && !currentShape) handled=false` gate\n // triggers and the dispatcher falls through to shape-specific\n // handlers. Without this clear, the dispatcher returns with\n // `handled=true` and the child shape is never selected (Issue\n // #22, bug #2).\n if (clickedContainedShape) {\n if (currentShape && currentShape.shapeName === 'frame'\n && typeof currentShape.removeSelection === 'function') {\n currentShape.removeSelection();\n }\n currentShape = null;\n return;\n }\n\n if (currentShape && currentShape !== clickedFrame) {\n currentShape.removeSelection();\n }\n currentShape = clickedFrame;\n currentShape.selectFrame();\n\n // Check for anchor interaction\n const anchorIndex = typeof currentShape.isNearAnchor === 'function' ? currentShape.isNearAnchor(x, y) : null;\n if (anchorIndex !== null) {\n activeAnchor = anchorIndex;\n isResizing = true;\n } else {\n isDragging = true;\n startX = x;\n startY = y;\n dragOldPosFrame = {\n x: currentShape.x,\n y: currentShape.y,\n width: currentShape.width,\n height: currentShape.height,\n rotation: currentShape.rotation\n };\n }\n return;\n }\n }\n\n // If no frame was clicked, deselect current\n if (currentShape && currentShape.shapeName === 'frame') {\n currentShape.removeSelection();\n currentShape = null;\n }\n }\n};\n\n const handleMouseMove = (e) => {\n const { x, y } = getSVGCoordsFromMouse(e);\n\n if (isDrawingFrame && currentFrame) {\n const width = Math.abs(x - startX);\n const height = Math.abs(y - startY);\n currentFrame.x = Math.min(startX, x);\n currentFrame.y = Math.min(startY, y);\n currentFrame.width = width;\n currentFrame.height = height;\n currentFrame.draw();\n } else if (isDragging && currentShape && currentShape.shapeName === 'frame') {\n const dx = x - startX;\n const dy = y - startY;\n \n // Use the frame's move method which properly handles contained shapes\n currentShape.move(dx, dy);\n \n startX = x;\n startY = y;\n }\n};\n\n const handleMouseUp = (e) => {\n if (isDrawingFrame && currentFrame) {\n // Check if frame is too small\n if (currentFrame.width < 10 || currentFrame.height < 10) {\n currentFrame.destroy();\n currentFrame = null;\n currentShape = null;\n } else {\n pushCreateAction(currentFrame);\n // Check for shapes that should be contained in the new frame\n currentFrame.updateContainedShapes(true); // Apply clipping immediately for new frames\n\n // Auto-select the new frame and switch to selection tool\n const placedFrame = currentFrame;\n if (window.__sketchStoreApi) {\n window.__sketchStoreApi.setActiveTool('select', { afterDraw: true });\n } else {\n window.isSelectionToolActive = true;\n }\n currentShape = placedFrame;\n placedFrame.selectFrame();\n }\n isDrawingFrame = false;\n }\n\n if (isDragging && dragOldPosFrame && currentShape) {\n const newPos = {\n x: currentShape.x,\n y: currentShape.y,\n width: currentShape.width,\n height: currentShape.height,\n rotation: currentShape.rotation\n };\n pushTransformAction(currentShape, dragOldPosFrame, newPos);\n dragOldPosFrame = null;\n \n // Update frame containment after moving frame (but don't re-move contained shapes)\n if (currentShape.shapeName === 'frame') {\n currentShape.updateClipPath();\n }\n }\n\n // Only check frame containment for shapes that aren't already in frames\n if (!isDragging) {\n shapes.forEach(shape => {\n if (shape.shapeName !== 'frame' && !shape.parentFrame) {\n shapes.forEach(frame => {\n if (frame.shapeName === 'frame') {\n if (frame.isShapeInFrame(shape)) {\n frame.addShapeToFrame(shape);\n }\n }\n });\n }\n });\n }\n\n isDrawingFrame = false;\n isDragging = false;\n isResizing = false;\n activeAnchor = null;\n svg.style.cursor = 'default';\n};\n\nFrame.prototype.isNearAnchor = function(x, y) {\n const anchorSize = 10 / currentZoom;\n \n // Define anchor positions\n const anchorPositions = [\n { x: this.x, y: this.y },\n { x: this.x + this.width / 2, y: this.y },\n { x: this.x + this.width, y: this.y },\n { x: this.x + this.width, y: this.y + this.height / 2 },\n { x: this.x + this.width, y: this.y + this.height },\n { x: this.x + this.width / 2, y: this.y + this.height },\n { x: this.x, y: this.y + this.height },\n { x: this.x, y: this.y + this.height / 2 },\n { x: this.x + this.width / 2, y: this.y - 30 / currentZoom } // Rotation handle\n ];\n\n for (let i = 0; i < anchorPositions.length; i++) {\n const pos = anchorPositions[i];\n const distance = Math.sqrt((x - pos.x) ** 2 + (y - pos.y) ** 2);\n if (distance <= anchorSize) {\n return i;\n }\n }\n return null;\n};\n\n// Delete functionality\nfunction deleteCurrentFrame() {\n if (currentShape && currentShape.shapeName === 'frame') {\n const frame = currentShape;\n const isDiagramFrame = !!frame._diagramType;\n\n // Issue #24 bug #7: regular frame \u2192 orphan children + snapshot\n // (mirrors deleteSelectedShapes / EngineShortcuts).\n let childSnapshot = null;\n if (!isDiagramFrame) {\n childSnapshot = [...(frame.containedShapes || [])];\n for (const child of childSnapshot) {\n if (!child || child === frame) continue;\n const el = child.group || child.element;\n if (el) {\n if (frame.clipGroup && el.parentNode === frame.clipGroup) frame.clipGroup.removeChild(el);\n if (window.svg && el.parentNode !== window.svg) window.svg.appendChild(el);\n }\n child.parentFrame = null;\n delete child.isBeingMovedByFrame;\n }\n frame.containedShapes = [];\n }\n\n const idx = shapes.indexOf(frame);\n if (idx !== -1) shapes.splice(idx, 1);\n\n if (!isDiagramFrame) {\n if (frame.group && frame.group.parentNode) frame.group.parentNode.removeChild(frame.group);\n if (frame.clipGroup && frame.clipGroup.parentNode) frame.clipGroup.parentNode.removeChild(frame.clipGroup);\n if (frame.clipPath && frame.clipPath.parentNode) frame.clipPath.parentNode.removeChild(frame.clipPath);\n } else if (frame.group && frame.group.parentNode) {\n frame.group.parentNode.removeChild(frame.group);\n }\n\n if (childSnapshot) pushDeleteAction(frame, { childSnapshot });\n else pushDeleteAction(frame);\n currentShape = null;\n }\n}\n\ndocument.addEventListener('keydown', (e) => {\n if (e.key === 'Delete' && currentShape && currentShape.shapeName === 'frame') {\n deleteCurrentFrame();\n }\n});\n\nwindow.Frame = Frame;\n\nexport {\n handleMouseDown as handleMouseDownFrame,\n handleMouseMove as handleMouseMoveFrame,\n handleMouseUp as handleMouseUpFrame\n};"],
5
+ "mappings": ";;;;;;;;AAKA,IAAI,eAAe;AACnB,IAAI,aAAa;AACjB,IAAI,aAAa;AACjB,IAAI,eAAe;AACnB,IAAI,iBAAiB;AACrB,IAAI,mBAAmB;AACvB,IAAI,uBAAuB;AAC3B,IAAI,iBAAiB;AACrB,IAAI,eAAe;AACnB,IAAI;AAAJ,IAAY;AACZ,IAAI,kBAAkB;AAEtB,SAAS,sBAAsB,GAAG;AAC9B,QAAM,UAAU,IAAI,QAAQ;AAC5B,QAAM,OAAO,IAAI,sBAAsB;AACvC,QAAM,SAAS,EAAE,UAAU,KAAK;AAChC,QAAM,SAAS,EAAE,UAAU,KAAK;AAChC,QAAM,OAAO,QAAQ,IAAK,SAAS,KAAK,QAAS,QAAQ;AACzD,QAAM,OAAO,QAAQ,IAAK,SAAS,KAAK,SAAU,QAAQ;AAC1D,SAAO,EAAE,GAAG,MAAM,GAAG,KAAK;AAC9B;AAIA,IAAM,kBAAkB,CA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