@elixpo/lixsketch 5.5.2 → 5.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react/{EventDispatcher-SRFH6LQZ.js → EventDispatcher-RTXLMHPL.js} +2 -2
- package/dist/react/{SketchEngine-4WSPTHZ3.js → SketchEngine-DWDJP2BB.js} +3 -3
- package/dist/react/{chunk-JJCJNLNN.js → chunk-TUMWA4YF.js} +114 -29
- package/dist/react/chunk-TUMWA4YF.js.map +7 -0
- package/dist/react/index.js +1 -1
- package/dist/react/{textTool-M7S6F3VC.js → textTool-QVKV45VD.js} +2 -2
- package/package.json +1 -1
- package/src/tools/textTool.js +169 -42
- package/dist/react/chunk-JJCJNLNN.js.map +0 -7
- /package/dist/react/{EventDispatcher-SRFH6LQZ.js.map → EventDispatcher-RTXLMHPL.js.map} +0 -0
- /package/dist/react/{SketchEngine-4WSPTHZ3.js.map → SketchEngine-DWDJP2BB.js.map} +0 -0
- /package/dist/react/{textTool-M7S6F3VC.js.map → textTool-QVKV45VD.js.map} +0 -0
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
handleTextMouseDown,
|
|
5
5
|
handleTextMouseMove,
|
|
6
6
|
handleTextMouseUp
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-TUMWA4YF.js";
|
|
8
8
|
import {
|
|
9
9
|
handleCodeMouseDown,
|
|
10
10
|
handleCodeMouseMove,
|
|
@@ -460,4 +460,4 @@ export {
|
|
|
460
460
|
handleMainMouseUp,
|
|
461
461
|
initEventDispatcher
|
|
462
462
|
};
|
|
463
|
-
//# sourceMappingURL=EventDispatcher-
|
|
463
|
+
//# sourceMappingURL=EventDispatcher-RTXLMHPL.js.map
|
|
@@ -209,7 +209,7 @@ var SketchEngine = class {
|
|
|
209
209
|
import("./circleTool-NUATSEI2.js"),
|
|
210
210
|
import("./arrowTool-CWEMIRXK.js"),
|
|
211
211
|
import("./lineTool-WNI5EMZ5.js"),
|
|
212
|
-
import("./textTool-
|
|
212
|
+
import("./textTool-QVKV45VD.js"),
|
|
213
213
|
import("./codeTool-MHCB2FNB.js"),
|
|
214
214
|
import("./imageTool-D5R4XGEU.js"),
|
|
215
215
|
import("./iconTool-GPZ7O7NH.js"),
|
|
@@ -238,7 +238,7 @@ var SketchEngine = class {
|
|
|
238
238
|
resizeShapes,
|
|
239
239
|
resizeCode
|
|
240
240
|
] = await Promise.all([
|
|
241
|
-
import("./EventDispatcher-
|
|
241
|
+
import("./EventDispatcher-RTXLMHPL.js"),
|
|
242
242
|
import("./UndoRedo-M2JZUBKN.js"),
|
|
243
243
|
import("./Selection-VVUHY5YJ.js"),
|
|
244
244
|
import("./ZoomPan-U3TXC5AJ.js"),
|
|
@@ -410,4 +410,4 @@ export {
|
|
|
410
410
|
SketchEngine,
|
|
411
411
|
SketchEngine_default as default
|
|
412
412
|
};
|
|
413
|
-
//# sourceMappingURL=SketchEngine-
|
|
413
|
+
//# sourceMappingURL=SketchEngine-DWDJP2BB.js.map
|
|
@@ -115,7 +115,7 @@ function addText(event) {
|
|
|
115
115
|
textElement.setAttribute("cursor", "default");
|
|
116
116
|
textElement.setAttribute("white-space", "pre");
|
|
117
117
|
textElement.setAttribute("dominant-baseline", "hanging");
|
|
118
|
-
textElement.setAttribute("pointer-events", "
|
|
118
|
+
textElement.setAttribute("pointer-events", "painted");
|
|
119
119
|
textElement.textContent = "";
|
|
120
120
|
gElement.setAttribute("data-x", x);
|
|
121
121
|
gElement.setAttribute("data-y", y);
|
|
@@ -157,16 +157,19 @@ function makeTextEditable(textElement, groupElement) {
|
|
|
157
157
|
let input = document.createElement("textarea");
|
|
158
158
|
input.className = "svg-text-editor";
|
|
159
159
|
let textContent = "";
|
|
160
|
-
const
|
|
161
|
-
if (
|
|
162
|
-
|
|
163
|
-
textContent += tspan.textContent.replace(/ /g, "\xA0");
|
|
164
|
-
if (index < tspans.length - 1) {
|
|
165
|
-
textContent += "\n";
|
|
166
|
-
}
|
|
167
|
-
});
|
|
160
|
+
const storedSource = textElement.getAttribute("data-wrap-source");
|
|
161
|
+
if (storedSource !== null && storedSource !== "") {
|
|
162
|
+
textContent = storedSource.replace(/ /g, "\xA0");
|
|
168
163
|
} else {
|
|
169
|
-
|
|
164
|
+
const tspans = textElement.querySelectorAll("tspan");
|
|
165
|
+
if (tspans.length > 0) {
|
|
166
|
+
tspans.forEach((tspan, index) => {
|
|
167
|
+
textContent += tspan.textContent.replace(/ /g, "\xA0");
|
|
168
|
+
if (index < tspans.length - 1) textContent += "\n";
|
|
169
|
+
});
|
|
170
|
+
} else {
|
|
171
|
+
textContent = textElement.textContent.replace(/ /g, "\xA0");
|
|
172
|
+
}
|
|
170
173
|
}
|
|
171
174
|
input.value = textContent;
|
|
172
175
|
input.style.position = "absolute";
|
|
@@ -211,7 +214,8 @@ function makeTextEditable(textElement, groupElement) {
|
|
|
211
214
|
input.style.lineHeight = "1.2em";
|
|
212
215
|
input.style.textAlign = currentAnchor === "middle" ? "center" : currentAnchor === "end" ? "right" : "left";
|
|
213
216
|
input.style.backgroundColor = "transparent";
|
|
214
|
-
|
|
217
|
+
const _isDark = typeof document !== "undefined" && document.body && document.body.classList.contains("theme-dark");
|
|
218
|
+
input.style.border = _isDark ? "1px dashed rgba(255,255,255,0.55)" : "1px dashed rgba(40,40,60,0.45)";
|
|
215
219
|
input.style.borderRadius = "3px";
|
|
216
220
|
input.style.outline = "none";
|
|
217
221
|
document.body.appendChild(input);
|
|
@@ -269,6 +273,64 @@ function makeTextEditable(textElement, groupElement) {
|
|
|
269
273
|
if (textEl) textEl.setAttribute("cursor", "text");
|
|
270
274
|
groupElement.style.display = "none";
|
|
271
275
|
}
|
|
276
|
+
function measureSegment(text, refTextElement) {
|
|
277
|
+
if (!text) return 0;
|
|
278
|
+
const NS = "http://www.w3.org/2000/svg";
|
|
279
|
+
const probe = document.createElementNS(NS, "tspan");
|
|
280
|
+
probe.textContent = text;
|
|
281
|
+
refTextElement.appendChild(probe);
|
|
282
|
+
let width = 0;
|
|
283
|
+
try {
|
|
284
|
+
width = probe.getComputedTextLength();
|
|
285
|
+
} catch {
|
|
286
|
+
}
|
|
287
|
+
refTextElement.removeChild(probe);
|
|
288
|
+
return width;
|
|
289
|
+
}
|
|
290
|
+
function paintTextContent(textElement, source, wrapWidth) {
|
|
291
|
+
while (textElement.firstChild) textElement.removeChild(textElement.firstChild);
|
|
292
|
+
const x = textElement.getAttribute("x") || 0;
|
|
293
|
+
const NS = "http://www.w3.org/2000/svg";
|
|
294
|
+
const paragraphs = (source || "").split("\n");
|
|
295
|
+
const finalLines = [];
|
|
296
|
+
for (const paragraph of paragraphs) {
|
|
297
|
+
const para = paragraph.replace(/ /g, " ");
|
|
298
|
+
if (!wrapWidth || wrapWidth <= 0) {
|
|
299
|
+
finalLines.push(para || " ");
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
const words = para.split(/(\s+)/);
|
|
303
|
+
let cur = "";
|
|
304
|
+
for (const token of words) {
|
|
305
|
+
const candidate = cur + token;
|
|
306
|
+
if (measureSegment(candidate, textElement) > wrapWidth && cur.trim().length > 0) {
|
|
307
|
+
finalLines.push(cur);
|
|
308
|
+
cur = token.replace(/^\s+/, "");
|
|
309
|
+
} else {
|
|
310
|
+
cur = candidate;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
finalLines.push(cur.length ? cur : " ");
|
|
314
|
+
}
|
|
315
|
+
finalLines.forEach((line, i) => {
|
|
316
|
+
const tspan = document.createElementNS(NS, "tspan");
|
|
317
|
+
tspan.setAttribute("x", x);
|
|
318
|
+
tspan.setAttribute("dy", i === 0 ? "0" : "1.2em");
|
|
319
|
+
tspan.textContent = line.length ? line : " ";
|
|
320
|
+
textElement.appendChild(tspan);
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
function getWrapSource(textElement) {
|
|
324
|
+
const stored = textElement.getAttribute("data-wrap-source");
|
|
325
|
+
if (stored !== null && stored !== "") return stored;
|
|
326
|
+
const tspans = textElement.querySelectorAll("tspan");
|
|
327
|
+
if (tspans.length === 0) return textElement.textContent || "";
|
|
328
|
+
return Array.from(tspans).map((t) => (t.textContent || "").replace(/ /g, " ")).join("\n");
|
|
329
|
+
}
|
|
330
|
+
function getWrapWidth(textElement) {
|
|
331
|
+
const v = parseFloat(textElement.getAttribute("data-wrap-width") || "");
|
|
332
|
+
return Number.isFinite(v) && v > 0 ? v : 0;
|
|
333
|
+
}
|
|
272
334
|
function renderText(input, textElement, deleteIfEmpty = false) {
|
|
273
335
|
if (!input || !document.body.contains(input)) {
|
|
274
336
|
return;
|
|
@@ -312,21 +374,9 @@ function renderText(input, textElement, deleteIfEmpty = false) {
|
|
|
312
374
|
removeSelectionFeedback();
|
|
313
375
|
}
|
|
314
376
|
} else {
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
const lines = text.split("\n");
|
|
319
|
-
const x = textElement.getAttribute("x") || 0;
|
|
320
|
-
lines.forEach((line, index) => {
|
|
321
|
-
let tspan = document.createElementNS(
|
|
322
|
-
"http://www.w3.org/2000/svg",
|
|
323
|
-
"tspan"
|
|
324
|
-
);
|
|
325
|
-
tspan.setAttribute("x", x);
|
|
326
|
-
tspan.setAttribute("dy", index === 0 ? "0" : "1.2em");
|
|
327
|
-
tspan.textContent = line.replace(/\u00A0/g, " ") || " ";
|
|
328
|
-
textElement.appendChild(tspan);
|
|
329
|
-
});
|
|
377
|
+
const cleanSource = text.replace(/\u00A0/g, " ");
|
|
378
|
+
textElement.setAttribute("data-wrap-source", cleanSource);
|
|
379
|
+
paintTextContent(textElement, cleanSource, getWrapWidth(textElement));
|
|
330
380
|
gElement.style.display = "block";
|
|
331
381
|
updateAttachedArrows(gElement);
|
|
332
382
|
if (selectedElement === gElement) {
|
|
@@ -377,7 +427,9 @@ function createSelectionFeedback(groupElement) {
|
|
|
377
427
|
{ name: "nw", x: selX, y: selY, cursor: "nwse-resize" },
|
|
378
428
|
{ name: "ne", x: selX + selWidth, y: selY, cursor: "nesw-resize" },
|
|
379
429
|
{ name: "sw", x: selX, y: selY + selHeight, cursor: "nesw-resize" },
|
|
380
|
-
{ name: "se", x: selX + selWidth, y: selY + selHeight, cursor: "nwse-resize" }
|
|
430
|
+
{ name: "se", x: selX + selWidth, y: selY + selHeight, cursor: "nwse-resize" },
|
|
431
|
+
{ name: "e", x: selX + selWidth, y: selY + selHeight / 2, cursor: "ew-resize" },
|
|
432
|
+
{ name: "w", x: selX, y: selY + selHeight / 2, cursor: "ew-resize" }
|
|
381
433
|
];
|
|
382
434
|
resizeHandles = {};
|
|
383
435
|
handlesData.forEach((handle) => {
|
|
@@ -464,7 +516,11 @@ function updateSelectionFeedback() {
|
|
|
464
516
|
{ name: "nw", x: selX, y: selY },
|
|
465
517
|
{ name: "ne", x: selX + selWidth, y: selY },
|
|
466
518
|
{ name: "sw", x: selX, y: selY + selHeight },
|
|
467
|
-
{ name: "se", x: selX + selWidth, y: selY + selHeight }
|
|
519
|
+
{ name: "se", x: selX + selWidth, y: selY + selHeight },
|
|
520
|
+
// Issue #48 bug #5: keep E/W midpoint handles aligned with the
|
|
521
|
+
// resize so they follow the box as it scales.
|
|
522
|
+
{ name: "e", x: selX + selWidth, y: selY + selHeight / 2 },
|
|
523
|
+
{ name: "w", x: selX, y: selY + selHeight / 2 }
|
|
468
524
|
];
|
|
469
525
|
handlesData.forEach((handle) => {
|
|
470
526
|
const handleRect = resizeHandles[handle.name];
|
|
@@ -686,6 +742,7 @@ var handleMouseMove = (event) => {
|
|
|
686
742
|
const startWidth = startBBox.width;
|
|
687
743
|
const startHeight = startBBox.height;
|
|
688
744
|
let anchorX, anchorY;
|
|
745
|
+
const isEdgeWidth = currentResizeHandle === "e" || currentResizeHandle === "w";
|
|
689
746
|
switch (currentResizeHandle) {
|
|
690
747
|
case "nw":
|
|
691
748
|
anchorX = startX + startWidth;
|
|
@@ -703,6 +760,26 @@ var handleMouseMove = (event) => {
|
|
|
703
760
|
anchorX = startX;
|
|
704
761
|
anchorY = startY;
|
|
705
762
|
break;
|
|
763
|
+
case "e":
|
|
764
|
+
anchorX = startX;
|
|
765
|
+
anchorY = startY + startHeight / 2;
|
|
766
|
+
break;
|
|
767
|
+
case "w":
|
|
768
|
+
anchorX = startX + startWidth;
|
|
769
|
+
anchorY = startY + startHeight / 2;
|
|
770
|
+
break;
|
|
771
|
+
}
|
|
772
|
+
if (isEdgeWidth) {
|
|
773
|
+
const newWrap = Math.abs(currentPoint.x - anchorX);
|
|
774
|
+
const minWrap = startFontSize * 2;
|
|
775
|
+
const clampedWrap = Math.max(minWrap, newWrap);
|
|
776
|
+
textElement.setAttribute("data-wrap-width", String(clampedWrap));
|
|
777
|
+
const source = getWrapSource(textElement);
|
|
778
|
+
paintTextContent(textElement, source, clampedWrap);
|
|
779
|
+
if (typeof updateSelectionFeedback === "function") {
|
|
780
|
+
setTimeout(updateSelectionFeedback, 0);
|
|
781
|
+
}
|
|
782
|
+
return;
|
|
706
783
|
}
|
|
707
784
|
const newWidth = Math.abs(currentPoint.x - anchorX);
|
|
708
785
|
const newHeight = Math.abs(currentPoint.y - anchorY);
|
|
@@ -733,6 +810,14 @@ var handleMouseMove = (event) => {
|
|
|
733
810
|
newAnchorX = currentBBox.x;
|
|
734
811
|
newAnchorY = currentBBox.y;
|
|
735
812
|
break;
|
|
813
|
+
case "e":
|
|
814
|
+
newAnchorX = currentBBox.x;
|
|
815
|
+
newAnchorY = currentBBox.y + currentBBox.height / 2;
|
|
816
|
+
break;
|
|
817
|
+
case "w":
|
|
818
|
+
newAnchorX = currentBBox.x + currentBBox.width;
|
|
819
|
+
newAnchorY = currentBBox.y + currentBBox.height / 2;
|
|
820
|
+
break;
|
|
736
821
|
}
|
|
737
822
|
const deltaX = anchorX - newAnchorX;
|
|
738
823
|
const deltaY = anchorY - newAnchorY;
|
|
@@ -1487,4 +1572,4 @@ export {
|
|
|
1487
1572
|
handleTextMouseUp,
|
|
1488
1573
|
updateCodeToggleForShape
|
|
1489
1574
|
};
|
|
1490
|
-
//# sourceMappingURL=chunk-
|
|
1575
|
+
//# sourceMappingURL=chunk-TUMWA4YF.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/tools/textTool.js"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable */\n// Text tool event handlers - extracted from writeText.js\nimport {\n pushCreateAction,\n pushDeleteAction,\n pushDeleteActionWithAttachments,\n pushTransformAction,\n pushOptionsChangeAction,\n pushFrameAttachmentAction,\n setTextReferences,\n updateSelectedElement\n} from '../core/UndoRedo.js';\nimport { cleanupAttachments, updateAttachedArrows } from './arrowTool.js';\n\nfunction getThemeStroke() { if (typeof document === \"undefined\") return \"#fff\"; return document.body && document.body.classList.contains(\"theme-dark\") ? \"#fff\" : \"#1a1a2e\"; }\nimport {\n addCodeBlock,\n wrapCodeElement,\n selectCodeBlock,\n deselectCodeBlock,\n applySyntaxHighlightingToSVG,\n createHighlightedSVGText,\n updateCodeBackground,\n extractTextFromCodeElement,\n setCodeLanguage,\n getCodeLanguage,\n getSelectedCodeBlock\n} from './codeTool.js';\n\nlet textSize = \"30px\";\nlet textFont = \"lixFont\";\nlet textColor = null;\nlet textAlign = \"left\";\n\nlet textColorOptions = document.querySelectorAll(\".textColorSpan\");\nlet textFontOptions = document.querySelectorAll(\".textFontSpan\");\nlet textSizeOptions = document.querySelectorAll(\".textSizeSpan\");\nlet textAlignOptions = document.querySelectorAll(\".textAlignSpan\");\n\nlet selectedElement = null;\nlet selectionBox = null;\nlet resizeHandles = {};\nlet dragOffsetX, dragOffsetY;\nlet isDragging = false;\nlet isResizing = false;\nlet currentResizeHandle = null;\nlet startBBox = null;\nlet startFontSize = null;\nlet startPoint = null;\nlet isRotating = false;\nlet rotationStartAngle = 0;\nlet rotationStartTransform = null;\nlet initialHandlePosRelGroup = null;\nlet initialGroupTx = 0;\nlet initialGroupTy = 0;\nlet initialInverseScreenCTM = null;\n\n// Frame attachment variables\nlet draggedShapeInitialFrameText = null;\nlet hoveredFrameText = null;\n\nsetTextReferences(selectedElement, updateSelectionFeedback, svg);\n\n\nfunction switchToSelectionTool() {\n if (window.__sketchStoreApi) {\n window.__sketchStoreApi.setActiveTool('select', { afterDraw: true });\n } else {\n window.isSelectionToolActive = true;\n }\n}\n\n\n// Convert group element to our TextShape class\nfunction wrapTextElement(groupElement) {\n const textShape = new TextShape(groupElement);\n return textShape;\n}\n\nfunction getSVGCoordinates(event, element = svg) {\n if (!svg || !svg.createSVGPoint) {\n console.error(\"SVG element or createSVGPoint method not available.\");\n return { x: 0, y: 0 };\n }\n let pt = svg.createSVGPoint();\n pt.x = event.clientX;\n pt.y = event.clientY;\n\n try {\n let screenCTM = (element && typeof element.getScreenCTM === 'function' && element.getScreenCTM()) || svg.getScreenCTM();\n if (!screenCTM) {\n console.error(\"Could not get Screen CTM.\");\n return { x: event.clientX, y: event.clientY };\n }\n let svgPoint = pt.matrixTransform(screenCTM.inverse());\n return {\n x: svgPoint.x,\n y: svgPoint.y,\n };\n } catch (error) {\n console.error(\"Error getting SVG coordinates:\", error);\n return { x: event.clientX, y: event.clientY };\n }\n}\n\nfunction addText(event) {\n let { x, y } = getSVGCoordinates(event);\n\n let gElement = document.createElementNS(\"http://www.w3.org/2000/svg\", \"g\");\n gElement.setAttribute(\"data-type\", \"text-group\");\n gElement.setAttribute(\"transform\", `translate(${x}, ${y})`);\n\n let textElement = document.createElementNS(\n \"http://www.w3.org/2000/svg\",\n \"text\"\n );\n let textAlignElement = \"start\";\n if (textAlign === \"center\") textAlignElement = \"middle\";\n else if (textAlign === \"right\") textAlignElement = \"end\";\n\n textElement.setAttribute(\"x\", 0);\n textElement.setAttribute(\"y\", 0);\n textElement.setAttribute(\"fill\", textColor ?? getThemeStroke());\n textElement.setAttribute(\"font-size\", textSize);\n textElement.setAttribute(\"font-family\", textFont);\n textElement.setAttribute(\"text-anchor\", textAlignElement);\n textElement.setAttribute(\"cursor\", \"default\");\n textElement.setAttribute(\"white-space\", \"pre\");\n textElement.setAttribute(\"dominant-baseline\", \"hanging\");\n // Issue #48 bugs #1 / #3: reverted the previous `bounding-box` hit\n // area (introduced for #34 #5b) \u2014 extending the text's hit zone to\n // its full bbox meant the negative space between glyphs and around\n // the text was stealing clicks from shapes drawn ON TOP of the text\n // (drag a rect over text \u2192 text intercepts; select text then click a\n // different shape elsewhere \u2192 click lands in text's invisible bbox\n // and the text stays selected). Default `painted` only fires on\n // glyph pixels, which restores the expected pass-through. Trade-off:\n // empty-padding clicks no longer select the text \u2014 the user has to\n // click on the letters.\n textElement.setAttribute(\"pointer-events\", \"painted\");\n textElement.textContent = \"\";\n\n gElement.setAttribute(\"data-x\", x);\n gElement.setAttribute(\"data-y\", y);\n textElement.setAttribute(\"data-initial-size\", textSize);\n textElement.setAttribute(\"data-initial-font\", textFont);\n textElement.setAttribute(\"data-initial-color\", textColor ?? getThemeStroke());\n textElement.setAttribute(\"data-initial-align\", textAlign);\n textElement.setAttribute(\"data-type\", \"text\");\n gElement.appendChild(textElement);\n svg.appendChild(gElement);\n \n // Attach ID to both group and text element\n const shapeID = `text-${String(Date.now()).slice(0, 8)}-${Math.floor(Math.random() * 10000)}`;\n gElement.setAttribute('id', shapeID);\n textElement.setAttribute('id', `${shapeID}-text`);\n \n // Create TextShape wrapper for frame functionality\n const textShape = wrapTextElement(gElement);\n \n // Add to shapes array for arrow attachment and frame functionality\n if (typeof shapes !== 'undefined' && Array.isArray(shapes)) {\n shapes.push(textShape);\n }\n \n pushCreateAction({\n type: 'text',\n element: textShape,\n shapeName: 'text'\n });\n\n // Check if text was created inside a frame and add it\n if (typeof shapes !== 'undefined' && Array.isArray(shapes)) {\n shapes.forEach(shape => {\n if (shape.shapeName === 'frame' && shape.isShapeInFrame(textShape)) {\n shape.addShapeToFrame(textShape);\n }\n });\n }\n\n makeTextEditable(textElement, gElement);\n}\n\nfunction makeTextEditable(textElement, groupElement) {\n\n if (document.querySelector(\"textarea.svg-text-editor\")) {\n return;\n }\n\n if (selectedElement) {\n deselectElement();\n }\n\n let input = document.createElement(\"textarea\");\n input.className = \"svg-text-editor\";\n\n // Issue #48 phase D follow-up: prefer the persisted `data-wrap-\n // source` when present so re-opening the editor shows the user's\n // original line breaks instead of the auto-wrap output. Falls back\n // to tspan-concatenation for legacy text shapes.\n let textContent = '';\n const storedSource = textElement.getAttribute('data-wrap-source');\n if (storedSource !== null && storedSource !== '') {\n textContent = storedSource.replace(/ /g, '\\u00A0');\n } else {\n const tspans = textElement.querySelectorAll('tspan');\n if (tspans.length > 0) {\n tspans.forEach((tspan, index) => {\n textContent += tspan.textContent.replace(/ /g, '\\u00A0');\n if (index < tspans.length - 1) textContent += '\\n';\n });\n } else {\n textContent = textElement.textContent.replace(/ /g, '\\u00A0');\n }\n }\n\n input.value = textContent;\n input.style.position = \"absolute\";\n input.style.outline = \"none\";\n input.style.padding = \"1px\";\n input.style.margin = \"0\";\n input.style.boxSizing = \"border-box\";\n input.style.overflow = \"hidden\";\n input.style.resize = \"none\";\n input.style.whiteSpace = \"pre-wrap\";\n input.style.minHeight = \"1.2em\";\n input.style.zIndex = \"10000\";\n\n const svgRect = svg.getBoundingClientRect();\n\n // Use the group element's own screenCTM which includes group transform + SVG viewBox transform\n const textBBox = textElement.getBBox();\n let pt = svg.createSVGPoint();\n pt.x = textBBox.x;\n pt.y = textBBox.y;\n\n const groupCTM = groupElement.getScreenCTM() || svg.getScreenCTM();\n let screenPt = pt.matrixTransform(groupCTM);\n\n input.style.left = `${screenPt.x}px`;\n input.style.top = `${screenPt.y}px`;\n\n const svgZoomFactor = svg.getScreenCTM() ? svg.getScreenCTM().a : 1;\n const screenWidth = textBBox.width * svgZoomFactor;\n\n input.style.width = \"auto\";\n input.style.height = \"auto\";\n\n const currentFontSize = textElement.getAttribute(\"font-size\") || \"30px\";\n const currentFontFamily = textElement.getAttribute(\"font-family\") || \"lixFont\";\n const currentFill = textElement.getAttribute(\"fill\") || \"#fff\";\n const currentAnchor = textElement.getAttribute(\"text-anchor\") || \"start\";\n // Scale font-size by zoom so the textarea matches what the user sees on canvas\n const rawSize = parseFloat(currentFontSize) || 30;\n const scaledFontSize = `${rawSize * svgZoomFactor}px`;\n\n input.style.minWidth = \"150px\";\n input.style.minHeight = \"1.5em\";\n input.style.width = \"auto\";\n input.style.height = \"auto\";\n input.style.overflow = \"visible\";\n input.style.whiteSpace = \"pre-wrap\";\n input.style.wordBreak = \"break-word\";\n input.style.fontSize = scaledFontSize;\n input.style.fontFamily = currentFontFamily;\n input.style.color = currentFill;\n input.style.lineHeight = \"1.2em\";\n input.style.textAlign = currentAnchor === \"middle\" ? \"center\" : currentAnchor === \"end\" ? \"right\" : \"left\";\n input.style.backgroundColor = \"transparent\";\n // Issue #34 bug #5a + #48 bug #2: dashed creation outline that grows\n // with the text. Originally `rgba(255,255,255,0.55)` \u2014 invisible on\n // the new light canvas. Read the active theme so the dashes stay\n // visible in both modes.\n const _isDark = typeof document !== 'undefined'\n && document.body\n && document.body.classList.contains('theme-dark');\n input.style.border = _isDark\n ? \"1px dashed rgba(255,255,255,0.55)\"\n : \"1px dashed rgba(40,40,60,0.45)\";\n input.style.borderRadius = \"3px\";\n input.style.outline = \"none\";\n document.body.appendChild(input);\n\n const adjustHeight = () => {\n input.style.height = 'auto';\n input.style.height = input.scrollHeight + 'px';\n const maxHeight = svgRect.height - (screenPt.y);\n if (input.scrollHeight > maxHeight) {\n input.style.height = maxHeight + 'px';\n input.style.overflowY = 'auto';\n } else {\n input.style.overflowY = 'hidden';\n }\n };\n\n const adjustWidth = () => {\n input.style.width = 'auto';\n const maxWidth = svgRect.width - (screenPt.x);\n const contentWidth = Math.max(input.scrollWidth, 150);\n if (contentWidth > maxWidth) {\n input.style.width = maxWidth + 'px';\n input.style.overflowX = 'auto';\n } else {\n input.style.width = contentWidth + 'px';\n input.style.overflowX = 'hidden';\n }\n };\n adjustHeight();\n adjustWidth();\n\n setTimeout(() => {\n input.focus();\n input.select();\n }, 50);\n\n input.addEventListener('input', adjustHeight);\n input.addEventListener('input', adjustWidth);\n\n input.addEventListener(\"keydown\", function (e) {\n if (e.key === \"Enter\" && !e.shiftKey) {\n e.preventDefault();\n renderText(input, textElement, true);\n } else if (e.key === \"Escape\") {\n e.preventDefault();\n renderText(input, textElement, true);\n }\n });\n\n input.originalTextElement = textElement;\n input.textGroup = groupElement;\n\n const handleClickOutside = (event) => {\n if (!input.contains(event.target)) {\n renderText(input, textElement, true);\n document.removeEventListener('pointerdown', handleClickOutside, true);\n }\n };\n document.addEventListener('pointerdown', handleClickOutside, true);\n input.handleClickOutside = handleClickOutside;\n\n // Set text cursor on the element during edit mode\n const textEl = groupElement.querySelector('text');\n if (textEl) textEl.setAttribute(\"cursor\", \"text\");\n\n groupElement.style.display = \"none\";\n}\n\n/**\n * Issue #48 phase D follow-up: true text wrapping driven by E/W width.\n *\n * `paint(textElement, source, wrapWidth)` renders the user-typed `source`\n * string into tspans, soft-wrapping any line that exceeds `wrapWidth`\n * pixels (in SVG units). `wrapWidth = null | 0` falls back to the old\n * \"explicit newlines only\" behaviour so existing text shapes that have\n * never been width-resized look identical.\n *\n * The raw `source` is persisted on the element as `data-wrap-source`\n * so subsequent edits (textarea re-open) and serialisation can rebuild\n * the original content even after auto-wrap inserted line breaks.\n */\nfunction measureSegment(text, refTextElement) {\n if (!text) return 0;\n const NS = 'http://www.w3.org/2000/svg';\n const probe = document.createElementNS(NS, 'tspan');\n probe.textContent = text;\n refTextElement.appendChild(probe);\n let width = 0;\n try { width = probe.getComputedTextLength(); } catch {}\n refTextElement.removeChild(probe);\n return width;\n}\n\nfunction paintTextContent(textElement, source, wrapWidth) {\n while (textElement.firstChild) textElement.removeChild(textElement.firstChild);\n const x = textElement.getAttribute('x') || 0;\n const NS = 'http://www.w3.org/2000/svg';\n const paragraphs = (source || '').split('\\n');\n const finalLines = [];\n\n for (const paragraph of paragraphs) {\n const para = paragraph.replace(/\u00A0/g, ' ');\n if (!wrapWidth || wrapWidth <= 0) {\n finalLines.push(para || ' ');\n continue;\n }\n // Word-wrap the paragraph against wrapWidth.\n const words = para.split(/(\\s+)/); // keep separators so spacing survives\n let cur = '';\n for (const token of words) {\n const candidate = cur + token;\n if (measureSegment(candidate, textElement) > wrapWidth && cur.trim().length > 0) {\n finalLines.push(cur);\n cur = token.replace(/^\\s+/, ''); // drop the leading break-space\n } else {\n cur = candidate;\n }\n }\n finalLines.push(cur.length ? cur : ' ');\n }\n\n finalLines.forEach((line, i) => {\n const tspan = document.createElementNS(NS, 'tspan');\n tspan.setAttribute('x', x);\n tspan.setAttribute('dy', i === 0 ? '0' : '1.2em');\n tspan.textContent = line.length ? line : ' ';\n textElement.appendChild(tspan);\n });\n}\n\nfunction getWrapSource(textElement) {\n const stored = textElement.getAttribute('data-wrap-source');\n if (stored !== null && stored !== '') return stored;\n // Fallback: rebuild from existing tspans (legacy text shapes without\n // the attribute). Join each tspan as a paragraph.\n const tspans = textElement.querySelectorAll('tspan');\n if (tspans.length === 0) return textElement.textContent || '';\n return Array.from(tspans).map((t) => (t.textContent || '').replace(/\u00A0/g, ' ')).join('\\n');\n}\n\nfunction getWrapWidth(textElement) {\n const v = parseFloat(textElement.getAttribute('data-wrap-width') || '');\n return Number.isFinite(v) && v > 0 ? v : 0;\n}\n\nfunction renderText(input, textElement, deleteIfEmpty = false) {\n if (!input || !document.body.contains(input)) {\n return;\n }\n\n const text = input.value || \"\";\n const gElement = input.textGroup;\n\n if (input.handleClickOutside) {\n document.removeEventListener('pointerdown', input.handleClickOutside, true);\n }\n\n document.body.removeChild(input);\n\n // Reset cursor back to default after edit mode ends\n if (textElement) textElement.setAttribute(\"cursor\", \"default\");\n\n if (!gElement || !textElement) {\n return;\n }\n\n if (!gElement.parentNode) {\n if (selectedElement === gElement) {\n deselectElement();\n }\n return;\n }\n\n if (deleteIfEmpty && text.trim() === \"\") {\n // Find the TextShape wrapper\n let textShape = null;\n if (typeof shapes !== 'undefined' && Array.isArray(shapes)) {\n textShape = shapes.find(shape => shape.shapeName === 'text' && shape.group === gElement);\n if (textShape) {\n const idx = shapes.indexOf(textShape);\n if (idx !== -1) shapes.splice(idx, 1);\n }\n }\n\n // Use enhanced delete action for text with arrow attachments\n pushDeleteActionWithAttachments({\n type: 'text',\n element: textShape || gElement,\n shapeName: 'text'\n });\n\n // Clean up any arrow attachments before deleting\n if (typeof cleanupAttachments === 'function') {\n cleanupAttachments(gElement);\n }\n\n svg.removeChild(gElement);\n if (selectedElement === gElement) {\n selectedElement = null;\n removeSelectionFeedback();\n }\n } else {\n // Persist the raw editor content so future E/W resizes can re-wrap\n // from the user's original line breaks instead of the auto-inserted\n // ones. Then call the shared paint helper \\u2014 it falls back to the\n // legacy \"explicit newlines only\" path when no wrap-width is set.\n const cleanSource = text.replace(/\\u00A0/g, ' ');\n textElement.setAttribute('data-wrap-source', cleanSource);\n paintTextContent(textElement, cleanSource, getWrapWidth(textElement));\n\n gElement.style.display = 'block';\n\n // Update attached arrows after text content change\n updateAttachedArrows(gElement);\n\n if (selectedElement === gElement) {\n setTimeout(updateSelectionFeedback, 0);\n }\n }\n\n // After rendering text, switch to selection tool and auto-select\n if (gElement.parentNode) {\n switchToSelectionTool();\n // Defer selection so the tool switch (async React state) completes first\n requestAnimationFrame(() => selectElement(gElement));\n }\n}\n\nfunction createSelectionFeedback(groupElement) {\n if (!groupElement) return;\n removeSelectionFeedback();\n\n const textElement = groupElement.querySelector('text');\n if (!textElement) {\n return;\n }\n\n const bbox = textElement.getBBox();\n\n const zoom = window.currentZoom || 1;\n const padding = 8 / zoom;\n const handleSize = 10 / zoom;\n const handleOffset = handleSize / 2;\n const anchorStrokeWidth = 2;\n\n const selX = bbox.x - padding;\n const selY = bbox.y - padding;\n const selWidth = bbox.width + 2 * padding;\n const selHeight = bbox.height + 2 * padding;\n\n const outlinePoints = [\n [selX, selY],\n [selX + selWidth, selY],\n [selX + selWidth, selY + selHeight],\n [selX, selY + selHeight],\n [selX, selY]\n ];\n\n const pointsAttr = outlinePoints.map(p => p.join(',')).join(' ');\n selectionBox = document.createElementNS(\"http://www.w3.org/2000/svg\", \"polyline\");\n selectionBox.setAttribute(\"class\", \"selection-box\");\n selectionBox.setAttribute(\"points\", pointsAttr);\n selectionBox.setAttribute(\"fill\", \"none\");\n selectionBox.setAttribute(\"stroke\", \"#5B57D1\");\n selectionBox.setAttribute(\"stroke-width\", \"1.5\");\n selectionBox.setAttribute(\"stroke-dasharray\", `${4 / zoom} ${2 / zoom}`);\n selectionBox.setAttribute(\"vector-effect\", \"non-scaling-stroke\");\n selectionBox.setAttribute(\"pointer-events\", \"none\");\n groupElement.appendChild(selectionBox);\n\n // Issue #48 bug #5 + phase D follow-up: E/W midpoint anchors drive\n // TRUE word-wrap. Dragging E/W sets `data-wrap-width` on the text\n // element; the paint helper re-flows tspans so the text wraps into\n // multiple lines. Corner anchors keep their font-size scaling\n // behaviour.\n const handlesData = [\n { name: 'nw', x: selX, y: selY, cursor: 'nwse-resize' },\n { name: 'ne', x: selX + selWidth, y: selY, cursor: 'nesw-resize' },\n { name: 'sw', x: selX, y: selY + selHeight, cursor: 'nesw-resize' },\n { name: 'se', x: selX + selWidth, y: selY + selHeight, cursor: 'nwse-resize' },\n { name: 'e', x: selX + selWidth, y: selY + selHeight / 2, cursor: 'ew-resize' },\n { name: 'w', x: selX, y: selY + selHeight / 2, cursor: 'ew-resize' },\n ];\n\n resizeHandles = {};\n handlesData.forEach(handle => {\n const handleRect = document.createElementNS(\"http://www.w3.org/2000/svg\", \"rect\");\n handleRect.setAttribute(\"class\", `resize-handle resize-handle-${handle.name}`);\n handleRect.setAttribute(\"x\", handle.x - handleOffset);\n handleRect.setAttribute(\"y\", handle.y - handleOffset);\n handleRect.setAttribute(\"width\", handleSize);\n handleRect.setAttribute(\"height\", handleSize);\n handleRect.setAttribute(\"fill\", \"#121212\");\n handleRect.setAttribute(\"stroke\", \"#5B57D1\");\n handleRect.setAttribute(\"stroke-width\", anchorStrokeWidth);\n handleRect.setAttribute(\"vector-effect\", \"non-scaling-stroke\");\n handleRect.style.cursor = handle.cursor;\n handleRect.setAttribute(\"data-anchor\", handle.name);\n groupElement.appendChild(handleRect);\n resizeHandles[handle.name] = handleRect;\n\n handleRect.addEventListener('pointerdown', (e) => {\n if (window.isSelectionToolActive) {\n e.stopPropagation();\n startResize(e, handle.name);\n }\n });\n });\n\n const rotationAnchorPos = { x: selX + selWidth / 2, y: selY - 30 };\n const rotationAnchor = document.createElementNS('http://www.w3.org/2000/svg', 'circle');\n rotationAnchor.setAttribute('cx', rotationAnchorPos.x);\n rotationAnchor.setAttribute('cy', rotationAnchorPos.y);\n rotationAnchor.setAttribute('r', 8);\n rotationAnchor.setAttribute('class', 'rotate-anchor');\n rotationAnchor.setAttribute('fill', '#121212');\n rotationAnchor.setAttribute('stroke', '#5B57D1');\n rotationAnchor.setAttribute('stroke-width', anchorStrokeWidth);\n rotationAnchor.setAttribute('vector-effect', 'non-scaling-stroke');\n rotationAnchor.style.cursor = 'grab';\n rotationAnchor.setAttribute('pointer-events', 'all');\n groupElement.appendChild(rotationAnchor);\n\n resizeHandles.rotate = rotationAnchor;\n\n rotationAnchor.addEventListener('pointerdown', (e) => {\n if (window.isSelectionToolActive) {\n e.stopPropagation();\n startRotation(e);\n }\n });\n\n rotationAnchor.addEventListener('mouseover', function() {\n if (!isResizing && !isDragging) {\n this.style.cursor = 'grab';\n }\n });\n\n rotationAnchor.addEventListener('mouseout', function() {\n if (!isResizing && !isDragging) {\n this.style.cursor = 'default';\n }\n });\n}\n\nfunction updateSelectionFeedback() {\n if (!selectedElement || !selectionBox) return;\n\n const textElement = selectedElement.querySelector('text');\n if (!textElement) return;\n\n const wasHidden = selectedElement.style.display === 'none';\n if (wasHidden) selectedElement.style.display = 'block';\n\n const bbox = textElement.getBBox();\n\n if (wasHidden) selectedElement.style.display = 'none';\n\n if (bbox.width === 0 && bbox.height === 0 && textElement.textContent.trim() !== \"\") {\n }\n\n const zoom2 = window.currentZoom || 1;\n const padding = 8 / zoom2;\n const handleSize = 10 / zoom2;\n const handleOffset = handleSize / 2;\n\n const selX = bbox.x - padding;\n const selY = bbox.y - padding;\n const selWidth = Math.max(bbox.width + 2 * padding, handleSize);\n const selHeight = Math.max(bbox.height + 2 * padding, handleSize);\n\n const outlinePoints = [\n [selX, selY],\n [selX + selWidth, selY],\n [selX + selWidth, selY + selHeight],\n [selX, selY + selHeight],\n [selX, selY]\n ];\n\n const pointsAttr = outlinePoints.map(p => p.join(',')).join(' ');\n selectionBox.setAttribute(\"points\", pointsAttr);\n\n const handlesData = [\n { name: 'nw', x: selX, y: selY },\n { name: 'ne', x: selX + selWidth, y: selY },\n { name: 'sw', x: selX, y: selY + selHeight },\n { name: 'se', x: selX + selWidth, y: selY + selHeight },\n // Issue #48 bug #5: keep E/W midpoint handles aligned with the\n // resize so they follow the box as it scales.\n { name: 'e', x: selX + selWidth, y: selY + selHeight / 2 },\n { name: 'w', x: selX, y: selY + selHeight / 2 },\n ];\n\n handlesData.forEach(handle => {\n const handleRect = resizeHandles[handle.name];\n if (handleRect) {\n handleRect.setAttribute(\"x\", handle.x - handleOffset);\n handleRect.setAttribute(\"y\", handle.y - handleOffset);\n }\n });\n\n const rotationAnchor = resizeHandles.rotate;\n if (rotationAnchor) {\n const rotationAnchorPos = { x: selX + selWidth / 2, y: selY - 30 };\n rotationAnchor.setAttribute('cx', rotationAnchorPos.x);\n rotationAnchor.setAttribute('cy', rotationAnchorPos.y);\n }\n}\n\nfunction startRotation(event) {\n if (!selectedElement || event.button !== 0) return;\n event.preventDefault();\n event.stopPropagation();\n\n isRotating = true;\n isDragging = false;\n isResizing = false;\n\n const textElement = selectedElement.querySelector('text');\n if (!textElement) return;\n\n const bbox = textElement.getBBox();\n const centerX = bbox.x + bbox.width / 2;\n const centerY = bbox.y + bbox.height / 2;\n\n const mousePos = getSVGCoordinates(event);\n\n let centerPoint = svg.createSVGPoint();\n centerPoint.x = centerX;\n centerPoint.y = centerY;\n\n const groupTransform = selectedElement.transform.baseVal.consolidate();\n if (groupTransform) {\n centerPoint = centerPoint.matrixTransform(groupTransform.matrix);\n }\n\n rotationStartAngle = Math.atan2(mousePos.y - centerPoint.y, mousePos.x - centerPoint.x) * 180 / Math.PI;\n\n const currentTransform = selectedElement.transform.baseVal.consolidate();\n rotationStartTransform = currentTransform ? currentTransform.matrix : svg.createSVGMatrix();\n\n svg.style.cursor = 'grabbing';\n\n window.addEventListener('pointermove', handleMouseMove);\n window.addEventListener('pointerup', handleMouseUp);\n}\n\nfunction removeSelectionFeedback(element) {\n const target = element || selectedElement;\n if (target) {\n target.querySelectorAll(\".selection-box, .resize-handle, .rotate-anchor\").forEach(el => el.remove());\n }\n // Also clean up any orphaned selection elements in all text groups\n svg.querySelectorAll('g[data-type=\"text-group\"] .selection-box, g[data-type=\"text-group\"] .resize-handle, g[data-type=\"text-group\"] .rotate-anchor').forEach(el => el.remove());\n\n selectionBox = null;\n resizeHandles = {};\n}\n\nfunction selectElement(groupElement) {\n if (!groupElement || !groupElement.parentNode) return;\n if (groupElement === selectedElement) return;\n\n deselectElement();\n selectedElement = groupElement;\n selectedElement.classList.add(\"selected\");\n createSelectionFeedback(selectedElement);\n\n updateSelectedElement(selectedElement);\n updateCodeToggleForShape('text');\n\n // Update global currentShape so EventDispatcher can route to other tools later\n if (typeof shapes !== 'undefined' && Array.isArray(shapes)) {\n const wrapper = shapes.find(s => s.element === groupElement || s.group === groupElement);\n if (wrapper) {\n currentShape = wrapper;\n }\n }\n\n // Show text property panel when text is selected\n if (window.__showSidebarForShape) window.__showSidebarForShape('text');\n}\n\nfunction deselectElement() {\n const activeEditor = document.querySelector(\"textarea.svg-text-editor\");\n if (activeEditor) {\n let textElement = activeEditor.originalTextElement;\n if (textElement) {\n renderText(activeEditor, textElement, true);\n } else if (document.body.contains(activeEditor)) {\n document.body.removeChild(activeEditor);\n }\n }\n\n if (selectedElement) {\n removeSelectionFeedback();\n selectedElement.classList.remove(\"selected\");\n selectedElement = null;\n\n updateSelectedElement(null);\n\n // Clear global currentShape if it was a text shape\n if (currentShape && (currentShape.shapeName === 'text' || currentShape.shapeName === 'code')) {\n currentShape = null;\n }\n\n // Hide text property panel if we're in selection mode (not text tool)\n if (isSelectionToolActive) {\n textSideBar.classList.add(\"hidden\");\n }\n }\n\n if (isRotating) {\n isRotating = false;\n rotationStartAngle = 0;\n rotationStartTransform = null;\n svg.style.cursor = 'default';\n\n window.removeEventListener('pointermove', handleMouseMove);\n window.removeEventListener('pointerup', handleMouseUp);\n }\n}\n\nfunction startDrag(event) {\n if (!selectedElement || event.button !== 0) return;\n\n if (event.target.closest('.resize-handle')) {\n return;\n }\n\n isDragging = true;\n isResizing = false;\n event.preventDefault();\n\n const currentTransform = selectedElement.transform.baseVal.consolidate();\n const initialTranslateX = currentTransform ? currentTransform.matrix.e : 0;\n const initialTranslateY = currentTransform ? currentTransform.matrix.f : 0;\n\n startPoint = getSVGCoordinates(event);\n\n dragOffsetX = startPoint.x - initialTranslateX;\n dragOffsetY = startPoint.y - initialTranslateY;\n\n // Find the TextShape wrapper for frame functionality\n let textShape = null;\n if (typeof shapes !== 'undefined' && Array.isArray(shapes)) {\n textShape = shapes.find(shape => shape.shapeName === 'text' && shape.group === selectedElement);\n }\n\n if (textShape) {\n // Store initial frame state\n draggedShapeInitialFrameText = textShape.parentFrame || null;\n \n // Temporarily remove from frame clipping if dragging\n if (textShape.parentFrame) {\n textShape.parentFrame.temporarilyRemoveFromFrame(textShape);\n }\n }\n\n svg.style.cursor = 'grabbing';\n\n svg.addEventListener('pointermove', handleMouseMove);\n svg.addEventListener('pointerup', handleMouseUp);\n}\n\nfunction startResize(event, anchor) {\n if (!selectedElement || event.button !== 0) return;\n event.preventDefault();\n event.stopPropagation();\n\n isResizing = true;\n isDragging = false;\n currentResizeHandle = anchor;\n\n const textElement = selectedElement.querySelector('text');\n if (!textElement) {\n isResizing = false;\n return;\n }\n\n startBBox = textElement.getBBox();\n startFontSize = parseFloat(textElement.getAttribute(\"font-size\") || 30);\n if (isNaN(startFontSize)) startFontSize = 30;\n\n startPoint = getSVGCoordinates(event, selectedElement);\n\n // Freeze the group's screen CTM at resize start so mouse\u2192local mapping stays stable\n const groupScreenCTM = selectedElement.getScreenCTM();\n initialInverseScreenCTM = groupScreenCTM ? groupScreenCTM.inverse() : null;\n\n const currentTransform = selectedElement.transform.baseVal.consolidate();\n initialGroupTx = currentTransform ? currentTransform.matrix.e : 0;\n initialGroupTy = currentTransform ? currentTransform.matrix.f : 0;\n\n const padding = 3;\n const startX = startBBox.x - padding;\n const startY = startBBox.y - padding;\n const startWidth = startBBox.width + 2 * padding;\n const startHeight = startBBox.height + 2 * padding;\n\n let hx = startX;\n let hy = startY;\n if (anchor.includes('e')) { hx = startX + startWidth; }\n if (anchor.includes('s')) { hy = startY + startHeight; }\n initialHandlePosRelGroup = { x: hx, y: hy };\n\n svg.style.cursor = resizeHandles[anchor]?.style.cursor || 'default';\n\n svg.addEventListener('pointermove', handleMouseMove);\n svg.addEventListener('pointerup', handleMouseUp);\n}\n\n\nconst handleMouseMove = (event) => {\n if (!selectedElement) return;\n event.preventDefault();\n\n // Keep lastMousePos in screen coordinates for other functions\n const svgRect = svg.getBoundingClientRect();\n lastMousePos = {\n x: event.clientX - svgRect.left, \n y: event.clientY - svgRect.top\n };\n\n if (isDragging) {\n const currentPoint = getSVGCoordinates(event);\n const newTranslateX = currentPoint.x - dragOffsetX;\n const newTranslateY = currentPoint.y - dragOffsetY;\n\n const currentTransform = selectedElement.transform.baseVal.consolidate();\n if (currentTransform) {\n const matrix = currentTransform.matrix;\n const angle = Math.atan2(matrix.b, matrix.a) * 180 / Math.PI;\n\n const textElement = selectedElement.querySelector('text');\n if (textElement) {\n const bbox = textElement.getBBox();\n const centerX = bbox.x + bbox.width / 2;\n const centerY = bbox.y + bbox.height / 2;\n\n selectedElement.setAttribute('transform',\n `translate(${newTranslateX}, ${newTranslateY}) rotate(${angle}, ${centerX}, ${centerY})`\n );\n } else {\n selectedElement.setAttribute('transform', `translate(${newTranslateX}, ${newTranslateY})`);\n }\n } else {\n selectedElement.setAttribute('transform', `translate(${newTranslateX}, ${newTranslateY})`);\n }\n\n // Update frame containment for TextShape wrapper\n if (typeof shapes !== 'undefined' && Array.isArray(shapes)) {\n const textShape = shapes.find(shape => shape.shapeName === 'text' && shape.group === selectedElement);\n if (textShape) {\n textShape.updateFrameContainment();\n }\n }\n\n // Update attached arrows during dragging\n updateAttachedArrows(selectedElement);\n\n } else if (isResizing) {\n const textElement = selectedElement.querySelector('text');\n if (!textElement || !startBBox || startFontSize === null || !startPoint || !initialHandlePosRelGroup) return;\n\n // Use the frozen initial CTM so the mapping doesn't shift as we change the group transform\n let currentPoint;\n if (initialInverseScreenCTM) {\n const pt = svg.createSVGPoint();\n pt.x = event.clientX;\n pt.y = event.clientY;\n currentPoint = pt.matrixTransform(initialInverseScreenCTM);\n } else {\n currentPoint = getSVGCoordinates(event, selectedElement);\n }\n\n const startX = startBBox.x;\n const startY = startBBox.y;\n const startWidth = startBBox.width;\n const startHeight = startBBox.height;\n\n let anchorX, anchorY;\n const isEdgeWidth = currentResizeHandle === 'e' || currentResizeHandle === 'w';\n\n switch (currentResizeHandle) {\n case 'nw':\n anchorX = startX + startWidth;\n anchorY = startY + startHeight;\n break;\n case 'ne':\n anchorX = startX;\n anchorY = startY + startHeight;\n break;\n case 'sw':\n anchorX = startX + startWidth;\n anchorY = startY;\n break;\n case 'se':\n anchorX = startX;\n anchorY = startY;\n break;\n case 'e':\n anchorX = startX;\n anchorY = startY + startHeight / 2;\n break;\n case 'w':\n anchorX = startX + startWidth;\n anchorY = startY + startHeight / 2;\n break;\n }\n\n // Issue #48 phase D follow-up: E/W now drives TRUE word-wrap.\n // The drag distance becomes the wrap-width target; we re-paint\n // the text with the new width and short-circuit the font-size\n // scaling path that the corners use.\n if (isEdgeWidth) {\n const newWrap = Math.abs(currentPoint.x - anchorX);\n const minWrap = startFontSize * 2; // at least ~one short word wide\n const clampedWrap = Math.max(minWrap, newWrap);\n textElement.setAttribute('data-wrap-width', String(clampedWrap));\n const source = getWrapSource(textElement);\n paintTextContent(textElement, source, clampedWrap);\n if (typeof updateSelectionFeedback === 'function') {\n setTimeout(updateSelectionFeedback, 0);\n }\n return;\n }\n\n const newWidth = Math.abs(currentPoint.x - anchorX);\n const newHeight = Math.abs(currentPoint.y - anchorY);\n const chosenScale = newHeight / startHeight;\n\n const minScale = 0.1;\n const maxScale = 10.0;\n const clampedScale = Math.max(minScale, Math.min(chosenScale, maxScale));\n\n const newFontSize = startFontSize * clampedScale;\n const minFontSize = 5;\n const finalFontSize = Math.max(newFontSize, minFontSize);\n\n textElement.setAttribute(\"font-size\", `${finalFontSize}px`);\n\n const currentBBox = textElement.getBBox();\n\n let newAnchorX, newAnchorY;\n\n switch (currentResizeHandle) {\n case 'nw':\n newAnchorX = currentBBox.x + currentBBox.width;\n newAnchorY = currentBBox.y + currentBBox.height;\n break;\n case 'ne':\n newAnchorX = currentBBox.x;\n newAnchorY = currentBBox.y + currentBBox.height;\n break;\n case 'sw':\n newAnchorX = currentBBox.x + currentBBox.width;\n newAnchorY = currentBBox.y;\n break;\n case 'se':\n newAnchorX = currentBBox.x;\n newAnchorY = currentBBox.y;\n break;\n case 'e':\n newAnchorX = currentBBox.x;\n newAnchorY = currentBBox.y + currentBBox.height / 2;\n break;\n case 'w':\n newAnchorX = currentBBox.x + currentBBox.width;\n newAnchorY = currentBBox.y + currentBBox.height / 2;\n break;\n }\n\n const deltaX = anchorX - newAnchorX;\n const deltaY = anchorY - newAnchorY;\n\n const currentTransform = selectedElement.transform.baseVal.consolidate();\n if (currentTransform) {\n const matrix = currentTransform.matrix;\n const angle = Math.atan2(matrix.b, matrix.a) * 180 / Math.PI;\n\n const newGroupTx = initialGroupTx + deltaX;\n const newGroupTy = initialGroupTy + deltaY;\n\n const centerX = currentBBox.x + currentBBox.width / 2;\n const centerY = currentBBox.y + currentBBox.height / 2;\n\n selectedElement.setAttribute('transform',\n `translate(${newGroupTx}, ${newGroupTy}) rotate(${angle}, ${centerX}, ${centerY})`\n );\n } else {\n const newGroupTx = initialGroupTx + deltaX;\n const newGroupTy = initialGroupTy + deltaY;\n selectedElement.setAttribute('transform', `translate(${newGroupTx}, ${newGroupTy})`);\n }\n\n // Update attached arrows during resizing\n updateAttachedArrows(selectedElement);\n\n clearTimeout(selectedElement.updateFeedbackTimeout);\n selectedElement.updateFeedbackTimeout = setTimeout(() => {\n updateSelectionFeedback();\n delete selectedElement.updateFeedbackTimeout;\n }, 0);\n\n } else if (isRotating) {\n const textElement = selectedElement.querySelector('text');\n if (!textElement) return;\n\n const bbox = textElement.getBBox();\n const centerX = bbox.x + bbox.width / 2;\n const centerY = bbox.y + bbox.height / 2;\n\n const mousePos = getSVGCoordinates(event);\n\n let centerPoint = svg.createSVGPoint();\n centerPoint.x = centerX;\n centerPoint.y = centerY;\n\n const groupTransform = selectedElement.transform.baseVal.consolidate();\n if (groupTransform) {\n centerPoint = centerPoint.matrixTransform(groupTransform.matrix);\n }\n\n const currentAngle = Math.atan2(mousePos.y - centerPoint.y, mousePos.x - centerPoint.x) * 180 / Math.PI;\n\n const rotationDiff = currentAngle - rotationStartAngle;\n\n const newTransform = `translate(${rotationStartTransform.e}, ${rotationStartTransform.f}) rotate(${rotationDiff}, ${centerX}, ${centerY})`;\n selectedElement.setAttribute('transform', newTransform);\n\n // Update attached arrows during rotation\n updateAttachedArrows(selectedElement);\n\n updateSelectionFeedback();\n }\n};\n\n\n\nconst handleMouseUp = (event) => {\n if (event.button !== 0) return;\n\n if (isDragging && selectedElement) {\n const currentTransform = selectedElement.transform.baseVal.consolidate();\n if (currentTransform) {\n const finalTranslateX = currentTransform.matrix.e;\n const finalTranslateY = currentTransform.matrix.f;\n\n const initialX = parseFloat(selectedElement.getAttribute(\"data-x\")) || 0;\n const initialY = parseFloat(selectedElement.getAttribute(\"data-y\")) || 0;\n\n // Find the TextShape wrapper for frame tracking\n let textShape = null;\n if (typeof shapes !== 'undefined' && Array.isArray(shapes)) {\n textShape = shapes.find(shape => shape.shapeName === 'text' && shape.group === selectedElement);\n }\n\n // Add frame information for undo tracking\n const oldPosWithFrame = {\n x: initialX,\n y: initialY,\n rotation: extractRotationFromTransform(selectedElement) || 0,\n parentFrame: draggedShapeInitialFrameText\n };\n // Issue #34 bug #2: hoveredFrameText is the actual destination\n // tracked during drag \u2014 textShape.parentFrame is still the OLD\n // frame at this point.\n const newPosWithFrame = {\n x: finalTranslateX,\n y: finalTranslateY,\n rotation: extractRotationFromTransform(selectedElement) || 0,\n parentFrame: hoveredFrameText || null,\n };\n\n const stateChanged = initialX !== finalTranslateX || initialY !== finalTranslateY;\n const frameChanged = oldPosWithFrame.parentFrame !== newPosWithFrame.parentFrame;\n\n if (stateChanged || frameChanged) {\n pushTransformAction(\n {\n type: 'text',\n element: selectedElement,\n shapeName: 'text'\n },\n oldPosWithFrame,\n newPosWithFrame\n );\n }\n\n // Handle frame containment changes after drag\n if (textShape) {\n const finalFrame = hoveredFrameText;\n \n // If shape moved to a different frame\n if (draggedShapeInitialFrameText !== finalFrame) {\n // Remove from initial frame\n if (draggedShapeInitialFrameText) {\n draggedShapeInitialFrameText.removeShapeFromFrame(textShape);\n }\n \n // Add to new frame\n if (finalFrame) {\n finalFrame.addShapeToFrame(textShape);\n }\n \n // Track the frame change for undo\n if (frameChanged) {\n pushFrameAttachmentAction(finalFrame || draggedShapeInitialFrameText, textShape, \n finalFrame ? 'attach' : 'detach', draggedShapeInitialFrameText);\n }\n } else if (draggedShapeInitialFrameText) {\n // Shape stayed in same frame, restore clipping\n draggedShapeInitialFrameText.restoreToFrame(textShape);\n }\n }\n\n selectedElement.setAttribute(\"data-x\", finalTranslateX);\n selectedElement.setAttribute(\"data-y\", finalTranslateY);\n }\n\n draggedShapeInitialFrameText = null;\n\n } else if (isResizing && selectedElement) {\n const textElement = selectedElement.querySelector('text');\n if (textElement) {\n const finalFontSize = textElement.getAttribute(\"font-size\");\n const initialFontSize = startFontSize;\n\n const currentTransform = selectedElement.transform.baseVal.consolidate();\n if (currentTransform && initialFontSize !== parseFloat(finalFontSize)) {\n const finalTranslateX = currentTransform.matrix.e;\n const finalTranslateY = currentTransform.matrix.f;\n\n pushTransformAction(\n {\n type: 'text',\n element: selectedElement,\n shapeName: 'text'\n },\n {\n x: initialGroupTx,\n y: initialGroupTy,\n fontSize: initialFontSize,\n rotation: extractRotationFromTransform(selectedElement) || 0\n },\n {\n x: finalTranslateX,\n y: finalTranslateY,\n fontSize: parseFloat(finalFontSize),\n rotation: extractRotationFromTransform(selectedElement) || 0\n }\n );\n\n selectedElement.setAttribute(\"data-x\", finalTranslateX);\n selectedElement.setAttribute(\"data-y\", finalTranslateY);\n }\n\n clearTimeout(selectedElement.updateFeedbackTimeout);\n updateSelectionFeedback();\n }\n } else if (isRotating && selectedElement) {\n const currentTransform = selectedElement.transform.baseVal.consolidate();\n if (currentTransform && rotationStartTransform) {\n const initialRotation = Math.atan2(rotationStartTransform.b, rotationStartTransform.a) * 180 / Math.PI;\n const finalRotation = extractRotationFromTransform(selectedElement) || 0;\n\n if (Math.abs(initialRotation - finalRotation) > 1) {\n pushTransformAction(\n {\n type: 'text',\n element: selectedElement,\n shapeName: 'text'\n },\n {\n x: rotationStartTransform.e,\n y: rotationStartTransform.f,\n rotation: initialRotation\n },\n {\n x: currentTransform.matrix.e,\n y: currentTransform.matrix.f,\n rotation: finalRotation\n }\n );\n }\n\n }\n updateSelectionFeedback();\n }\n\n // Clear frame highlighting\n if (hoveredFrameText) {\n hoveredFrameText.removeHighlight();\n hoveredFrameText = null;\n }\n\n isDragging = false;\n isResizing = false;\n isRotating = false;\n currentResizeHandle = null;\n startPoint = null;\n startBBox = null;\n startFontSize = null;\n dragOffsetX = undefined;\n dragOffsetY = undefined;\n initialHandlePosRelGroup = null;\n initialGroupTx = 0;\n initialGroupTy = 0;\n rotationStartAngle = 0;\n rotationStartTransform = null;\n\n // Restore cursor based on context - keep pointer if over selected text\n svg.style.cursor = isSelectionToolActive ? 'default' : (isTextToolActive ? 'text' : 'default');\n\n // Ensure selection feedback is refreshed after transforms\n if (selectedElement) {\n setTimeout(updateSelectionFeedback, 0);\n }\n\n svg.removeEventListener('pointermove', handleMouseMove);\n svg.removeEventListener('pointerup', handleMouseUp);\n window.removeEventListener('pointermove', handleMouseMove);\n window.removeEventListener('pointerup', handleMouseUp);\n};\n\nfunction extractRotationFromTransform(element) {\n const currentTransform = element.transform.baseVal.consolidate();\n if (currentTransform) {\n const matrix = currentTransform.matrix;\n return Math.atan2(matrix.b, matrix.a) * 180 / Math.PI;\n }\n return 0;\n}\n\n// EXPORTED EVENT HANDLERS\nconst handleTextMouseDown = function (e) {\n if (!e.target) return;\n const activeEditor = document.querySelector(\"textarea.svg-text-editor\");\n if (activeEditor && activeEditor.contains(e.target)) {\n return;\n }\n if (activeEditor && !activeEditor.contains(e.target)) {\n let textElement = activeEditor.originalTextElement;\n if (textElement) {\n // renderText switches to selection tool and auto-selects the text as a side effect.\n // Return early so we don't continue with stale tool state.\n renderText(activeEditor, textElement, true);\n return;\n } else if (document.body.contains(activeEditor)){\n document.body.removeChild(activeEditor);\n }\n }\n\n const targetGroup = e.target.closest('g[data-type=\"text-group\"]');\n\n if (isSelectionToolActive && e.button === 0) {\n if (targetGroup) {\n if (e.target.closest('.resize-handle')) {\n return;\n }\n\n // Double-click on selected text: enter edit mode\n if (e.detail >= 2 && targetGroup === selectedElement) {\n enterEditMode(targetGroup);\n e.stopPropagation();\n return;\n }\n\n if (targetGroup === selectedElement) {\n startDrag(e);\n } else {\n selectElement(targetGroup);\n startDrag(e);\n }\n } else {\n deselectElement();\n }\n\n } else if (isTextToolActive && e.button === 0) {\n if (targetGroup) {\n // Double-click: enter edit mode\n if (e.detail >= 2) {\n let textEl = targetGroup.querySelector('text');\n if (textEl) {\n makeTextEditable(textEl, targetGroup);\n e.stopPropagation();\n return;\n }\n }\n // Single-click: select and drag (same as selection tool behavior)\n if (targetGroup === selectedElement) {\n startDrag(e);\n } else {\n selectElement(targetGroup);\n startDrag(e);\n }\n } else {\n deselectElement();\n addText(e);\n }\n }\n};\n\nfunction enterEditMode(groupElement) {\n const textEl = groupElement.querySelector('text');\n if (!textEl) return;\n\n // Switch to text tool with property panel (go through store to clear other flags)\n if (window.__sketchStoreApi) {\n window.__sketchStoreApi.setActiveTool('text');\n } else {\n window.isTextToolActive = true;\n window.isSelectionToolActive = false;\n }\n toolExtraPopup();\n\n // Deselect (removes selection feedback) then open editor\n deselectElement();\n makeTextEditable(textEl, groupElement);\n}\n\nconst handleTextMouseMove = function (e) {\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 // Handle cursor changes for text tool\n if (isTextToolActive) {\n const targetGroup = e.target?.closest?.('g[data-type=\"text-group\"]');\n if (targetGroup) {\n svg.style.cursor = 'pointer';\n } else {\n svg.style.cursor = 'crosshair';\n }\n } else if (isSelectionToolActive) {\n const targetGroup = e.target?.closest?.('g[data-type=\"text-group\"]');\n if (targetGroup) {\n svg.style.cursor = 'default';\n }\n }\n\n // Check for frame containment while creating text\n if (isTextToolActive && !isDragging && !isResizing && !isRotating) {\n // Get current mouse position for frame highlighting preview\n const { x, y } = getSVGCoordinates(e);\n \n // Create temporary text bounds for frame checking\n const tempTextBounds = {\n x: x - 50,\n y: y - 20,\n width: 100,\n height: 40\n };\n \n if (typeof shapes !== 'undefined' && Array.isArray(shapes)) {\n shapes.forEach(frame => {\n if (frame.shapeName === 'frame') {\n if (frame.isShapeInFrame(tempTextBounds)) {\n frame.highlightFrame();\n hoveredFrameText = frame;\n } else if (hoveredFrameText === frame) {\n frame.removeHighlight();\n hoveredFrameText = null;\n }\n }\n });\n }\n }\n};\n\nconst handleTextMouseUp = function (e) {\n // Clear frame highlighting when done with text tool operations\n if (hoveredFrameText) {\n hoveredFrameText.removeHighlight();\n hoveredFrameText = null;\n }\n};\n\n// updateAttachedArrows is imported from drawArrow.js\n\n\ntextColorOptions.forEach((span) => {\n span.addEventListener(\"click\", (event) => {\n event.stopPropagation();\n textColorOptions.forEach((el) => el.classList.remove(\"selected\"));\n span.classList.add(\"selected\");\n\n const newColor = span.getAttribute(\"data-id\");\n const oldColor = textColor;\n textColor = newColor;\n\n if (selectedElement) {\n const textElement = selectedElement.querySelector('text');\n if (textElement) {\n const currentColor = textElement.getAttribute('fill');\n\n if (currentColor !== newColor) {\n pushOptionsChangeAction(\n {\n type: 'text',\n element: selectedElement,\n shapeName: 'text'\n },\n {\n color: currentColor,\n font: textElement.getAttribute('font-family'),\n size: textElement.getAttribute('font-size'),\n align: textElement.getAttribute('text-anchor')\n },\n {\n color: newColor,\n font: textElement.getAttribute('font-family'),\n size: textElement.getAttribute('font-size'),\n align: textElement.getAttribute('text-anchor')\n }\n );\n }\n\n textElement.setAttribute('fill', newColor);\n }\n }\n });\n});\n\ntextFontOptions.forEach((span) => {\n span.addEventListener(\"click\", (event) => {\n event.stopPropagation();\n textFontOptions.forEach((el) => el.classList.remove(\"selected\"));\n span.classList.add(\"selected\");\n\n const newFont = span.getAttribute(\"data-id\");\n const oldFont = textFont;\n textFont = newFont;\n\n if (selectedElement) {\n const textElement = selectedElement.querySelector('text');\n if (textElement) {\n const currentFont = textElement.getAttribute('font-family');\n\n if (currentFont !== newFont) {\n pushOptionsChangeAction(\n {\n type: 'text',\n element: selectedElement,\n shapeName: 'text'\n },\n {\n color: textElement.getAttribute('fill'),\n font: currentFont,\n size: textElement.getAttribute('font-size'),\n align: textElement.getAttribute('text-anchor')\n },\n {\n color: textElement.getAttribute('fill'),\n font: newFont,\n size: textElement.getAttribute('font-size'),\n align: textElement.getAttribute('text-anchor')\n }\n );\n }\n\n textElement.setAttribute('font-family', newFont);\n setTimeout(updateSelectionFeedback, 0);\n }\n }\n });\n});\n\ntextSizeOptions.forEach((span) => {\n span.addEventListener(\"click\", (event) => {\n event.stopPropagation();\n textSizeOptions.forEach((el) => el.classList.remove(\"selected\"));\n span.classList.add(\"selected\");\n\n const newSize = span.getAttribute(\"data-id\") + \"px\";\n const oldSize = textSize;\n textSize = newSize;\n\n if (selectedElement) {\n const textElement = selectedElement.querySelector('text');\n if (textElement) {\n const currentSize = textElement.getAttribute('font-size');\n\n if (currentSize !== newSize) {\n pushOptionsChangeAction(\n {\n type: 'text',\n element: selectedElement,\n shapeName: 'text'\n },\n {\n color: textElement.getAttribute('fill'),\n font: textElement.getAttribute('font-family'),\n size: currentSize,\n align: textElement.getAttribute('text-anchor')\n },\n {\n color: textElement.getAttribute('fill'),\n font: textElement.getAttribute('font-family'),\n size: newSize,\n align: textElement.getAttribute('text-anchor')\n }\n );\n }\n\n textElement.setAttribute('font-size', newSize);\n setTimeout(updateSelectionFeedback, 0);\n }\n }\n });\n});\n\ntextAlignOptions.forEach((span) => {\n span.addEventListener(\"click\", (event) => {\n event.stopPropagation();\n textAlignOptions.forEach((el) => el.classList.remove(\"selected\"));\n span.classList.add(\"selected\");\n\n const newAlign = span.getAttribute(\"data-id\");\n const oldAlign = textAlign;\n textAlign = newAlign;\n\n if (selectedElement) {\n const textElement = selectedElement.querySelector('text');\n if (textElement) {\n const currentAnchor = textElement.getAttribute('text-anchor');\n let newAnchor = 'start';\n if (newAlign === 'center') newAnchor = 'middle';\n else if (newAlign === 'right') newAnchor = 'end';\n\n if (currentAnchor !== newAnchor) {\n pushOptionsChangeAction(\n {\n type: 'text',\n element: selectedElement,\n shapeName: 'text'\n },\n {\n color: textElement.getAttribute('fill'),\n font: textElement.getAttribute('font-family'),\n size: textElement.getAttribute('font-size'),\n align: currentAnchor\n },\n {\n color: textElement.getAttribute('fill'),\n font: textElement.getAttribute('font-family'),\n size: textElement.getAttribute('font-size'),\n align: newAnchor\n }\n );\n }\n\n textElement.setAttribute('text-anchor', newAnchor);\n setTimeout(updateSelectionFeedback, 0);\n }\n }\n });\n});\n\n\n// --- Code/Text Toggle Handler ---\nconst textCodeOptions = document.querySelectorAll(\".textCodeSpan\");\nconst languageSelector = document.getElementById(\"textLanguageSelector\");\nconst codeLanguageSelect = document.getElementById(\"codeLanguageSelect\");\n\ntextCodeOptions.forEach((span) => {\n span.addEventListener(\"click\", (event) => {\n event.stopPropagation();\n textCodeOptions.forEach((el) => el.classList.remove(\"selected\"));\n span.classList.add(\"selected\");\n\n const isCodeMode = span.getAttribute(\"data-id\") === \"true\";\n isTextInCodeMode = isCodeMode;\n\n // Show/hide language selector\n if (languageSelector) {\n languageSelector.classList.toggle(\"hidden\", !isCodeMode);\n }\n\n // Update tool flags\n if (isTextToolActive) {\n isCodeToolActive = isCodeMode;\n }\n\n // If a shape is selected, convert it\n if (isCodeMode && selectedElement) {\n // Convert text \u2192 code\n convertTextToCode(selectedElement);\n } else if (!isCodeMode && getSelectedCodeBlock()) {\n // Convert code \u2192 text\n convertCodeToText(getSelectedCodeBlock());\n }\n });\n});\n\n// Language selector handler\nif (codeLanguageSelect) {\n codeLanguageSelect.addEventListener(\"change\", (event) => {\n const lang = event.target.value;\n setCodeLanguage(lang);\n\n // If a code block is selected, re-highlight it with the new language\n const selectedCode = getSelectedCodeBlock();\n if (selectedCode) {\n const codeElement = selectedCode.querySelector('text');\n if (codeElement) {\n codeElement.setAttribute(\"data-language\", lang);\n // Re-render with new language highlighting\n const content = extractTextFromCodeElement(codeElement);\n while (codeElement.firstChild) {\n codeElement.removeChild(codeElement.firstChild);\n }\n const highlighted = applySyntaxHighlightingToSVG(content, lang);\n createHighlightedSVGText(highlighted, codeElement);\n updateCodeBackground(selectedCode, codeElement);\n }\n }\n });\n}\n\nfunction convertTextToCode(textGroupElement) {\n const textElement = textGroupElement.querySelector('text');\n if (!textElement) return;\n\n // Get text content\n let textContent = \"\";\n const tspans = textElement.querySelectorAll('tspan');\n if (tspans.length > 0) {\n tspans.forEach((tspan, index) => {\n textContent += tspan.textContent;\n if (index < tspans.length - 1) textContent += \"\\n\";\n });\n } else {\n textContent = textElement.textContent || \"\";\n }\n\n // Get position from transform\n const currentTransform = textGroupElement.transform.baseVal.consolidate();\n const tx = currentTransform ? currentTransform.matrix.e : 0;\n const ty = currentTransform ? currentTransform.matrix.f : 0;\n const fontSize = textElement.getAttribute('font-size') || \"25px\";\n const color = textElement.getAttribute('fill') || \"#fff\";\n\n // Find and remove old TextShape from shapes array\n let oldTextShape = null;\n if (typeof shapes !== 'undefined' && Array.isArray(shapes)) {\n oldTextShape = shapes.find(s => s.shapeName === 'text' && s.group === textGroupElement);\n if (oldTextShape) {\n const idx = shapes.indexOf(oldTextShape);\n if (idx !== -1) shapes.splice(idx, 1);\n }\n }\n\n // Deselect current text\n deselectElement();\n\n // Remove old text group from SVG\n if (textGroupElement.parentNode) {\n textGroupElement.parentNode.removeChild(textGroupElement);\n }\n\n // Create new code block\n const gElement = document.createElementNS(\"http://www.w3.org/2000/svg\", \"g\");\n gElement.setAttribute(\"data-type\", \"code-group\");\n gElement.setAttribute(\"transform\", `translate(${tx}, ${ty})`);\n\n const backgroundRect = document.createElementNS(\"http://www.w3.org/2000/svg\", \"rect\");\n backgroundRect.setAttribute(\"class\", \"code-background\");\n backgroundRect.setAttribute(\"x\", -10);\n backgroundRect.setAttribute(\"y\", -10);\n backgroundRect.setAttribute(\"width\", 300);\n backgroundRect.setAttribute(\"height\", 60);\n backgroundRect.setAttribute(\"fill\", \"#161b22\");\n backgroundRect.setAttribute(\"stroke\", \"#30363d\");\n backgroundRect.setAttribute(\"stroke-width\", \"1\");\n backgroundRect.setAttribute(\"rx\", \"6\");\n backgroundRect.setAttribute(\"ry\", \"6\");\n gElement.appendChild(backgroundRect);\n\n const codeElement = document.createElementNS(\"http://www.w3.org/2000/svg\", \"text\");\n codeElement.setAttribute(\"x\", 0);\n codeElement.setAttribute(\"y\", 0);\n codeElement.setAttribute(\"fill\", color);\n codeElement.setAttribute(\"font-size\", fontSize);\n codeElement.setAttribute(\"font-family\", \"lixCode\");\n codeElement.setAttribute(\"text-anchor\", \"start\");\n codeElement.setAttribute(\"cursor\", \"default\");\n codeElement.setAttribute(\"white-space\", \"pre\");\n codeElement.setAttribute(\"dominant-baseline\", \"hanging\");\n codeElement.setAttribute(\"data-language\", getCodeLanguage());\n codeElement.setAttribute(\"data-type\", \"code\");\n\n const shapeID = `code-${String(Date.now()).slice(0, 8)}-${Math.floor(Math.random() * 10000)}`;\n gElement.setAttribute(\"id\", shapeID);\n gElement.setAttribute(\"data-x\", tx);\n gElement.setAttribute(\"data-y\", ty);\n codeElement.setAttribute(\"id\", `${shapeID}-code`);\n gElement.appendChild(codeElement);\n svg.appendChild(gElement);\n\n // Apply syntax highlighting and add content\n if (textContent.trim()) {\n const lang = getCodeLanguage();\n const highlighted = applySyntaxHighlightingToSVG(textContent, lang);\n createHighlightedSVGText(highlighted, codeElement);\n updateCodeBackground(gElement, codeElement);\n }\n\n // Create CodeShape wrapper\n const codeShape = wrapCodeElement(gElement);\n if (typeof shapes !== 'undefined' && Array.isArray(shapes)) {\n shapes.push(codeShape);\n }\n\n // Push undo action for mode conversion\n pushModeConvertAction(oldTextShape, textGroupElement, 'text', codeShape, gElement, 'code');\n\n // Select the new code block\n selectCodeBlock(gElement);\n}\n\nfunction convertCodeToText(codeGroupElement) {\n const codeElement = codeGroupElement.querySelector('text');\n if (!codeElement) return;\n\n // Get text content\n const textContent = extractTextFromCodeElement(codeElement);\n\n // Get position from transform\n const currentTransform = codeGroupElement.transform.baseVal.consolidate();\n const tx = currentTransform ? currentTransform.matrix.e : 0;\n const ty = currentTransform ? currentTransform.matrix.f : 0;\n const fontSize = codeElement.getAttribute('font-size') || \"30px\";\n const color = codeElement.getAttribute('fill') || \"#fff\";\n\n // Find and remove old CodeShape from shapes array\n let oldCodeShape = null;\n if (typeof shapes !== 'undefined' && Array.isArray(shapes)) {\n oldCodeShape = shapes.find(s => s.shapeName === 'code' && s.group === codeGroupElement);\n if (oldCodeShape) {\n const idx = shapes.indexOf(oldCodeShape);\n if (idx !== -1) shapes.splice(idx, 1);\n }\n }\n\n // Deselect current code block\n deselectCodeBlock();\n\n // Remove old code group from SVG\n if (codeGroupElement.parentNode) {\n codeGroupElement.parentNode.removeChild(codeGroupElement);\n }\n\n // Create new text shape\n const gElement = document.createElementNS(\"http://www.w3.org/2000/svg\", \"g\");\n gElement.setAttribute(\"data-type\", \"text-group\");\n gElement.setAttribute(\"transform\", `translate(${tx}, ${ty})`);\n\n const textElement = document.createElementNS(\"http://www.w3.org/2000/svg\", \"text\");\n textElement.setAttribute(\"x\", 0);\n textElement.setAttribute(\"y\", 0);\n textElement.setAttribute(\"fill\", color);\n textElement.setAttribute(\"font-size\", fontSize);\n textElement.setAttribute(\"font-family\", textFont);\n textElement.setAttribute(\"text-anchor\", \"start\");\n textElement.setAttribute(\"cursor\", \"default\");\n textElement.setAttribute(\"white-space\", \"pre\");\n textElement.setAttribute(\"dominant-baseline\", \"hanging\");\n textElement.setAttribute(\"data-type\", \"text\");\n\n const shapeID = `text-${String(Date.now()).slice(0, 8)}-${Math.floor(Math.random() * 10000)}`;\n gElement.setAttribute(\"id\", shapeID);\n gElement.setAttribute(\"data-x\", tx);\n gElement.setAttribute(\"data-y\", ty);\n textElement.setAttribute(\"id\", `${shapeID}-text`);\n gElement.appendChild(textElement);\n svg.appendChild(gElement);\n\n // Add text content as tspans\n if (textContent.trim()) {\n const lines = textContent.split(\"\\n\");\n const x = textElement.getAttribute(\"x\") || 0;\n lines.forEach((line, index) => {\n const tspan = document.createElementNS(\"http://www.w3.org/2000/svg\", \"tspan\");\n tspan.setAttribute(\"x\", x);\n tspan.setAttribute(\"dy\", index === 0 ? \"0\" : \"1.2em\");\n tspan.textContent = line || \" \";\n textElement.appendChild(tspan);\n });\n }\n\n // Create TextShape wrapper\n const textShape = wrapTextElement(gElement);\n if (typeof shapes !== 'undefined' && Array.isArray(shapes)) {\n shapes.push(textShape);\n }\n\n // Push undo action for mode conversion\n pushModeConvertAction(oldCodeShape, codeGroupElement, 'code', textShape, gElement, 'text');\n\n // Select the new text shape\n selectElement(gElement);\n}\n\nfunction pushModeConvertAction(oldShape, oldElement, oldType, newShape, newElement, newType) {\n pushCreateAction({\n type: 'modeConvert',\n oldShape: oldShape,\n oldElement: oldElement,\n oldType: oldType,\n newShape: newShape,\n newElement: newElement,\n newType: newType,\n element: newShape,\n shapeName: newType\n });\n}\n\n// Update toggle state when a shape is selected\nfunction updateCodeToggleForShape(shapeName) {\n const isCode = shapeName === 'code';\n textCodeOptions.forEach(el => el.classList.remove(\"selected\"));\n textCodeOptions.forEach(el => {\n if ((el.getAttribute(\"data-id\") === \"true\") === isCode) {\n el.classList.add(\"selected\");\n }\n });\n if (languageSelector) {\n languageSelector.classList.toggle(\"hidden\", !isCode);\n }\n // Update the language dropdown to match the selected code block\n if (isCode && codeLanguageSelect) {\n const selectedCode = getSelectedCodeBlock();\n if (selectedCode) {\n const codeEl = selectedCode.querySelector('text');\n const lang = codeEl?.getAttribute(\"data-language\") || \"auto\";\n codeLanguageSelect.value = lang;\n }\n }\n}\n\n// React sidebar bridge \u2014 update currently selected text/code shape\nwindow.updateSelectedTextStyle = function(changes) {\n const el = selectedElement || (window.currentShape && window.currentShape.shapeName === 'text' ? window.currentShape.group : null);\n if (!el) return;\n const textElement = el.querySelector('text');\n if (!textElement) return;\n\n if (changes.color) {\n textElement.setAttribute('fill', changes.color);\n textColor = changes.color;\n }\n if (changes.font) {\n textElement.setAttribute('font-family', changes.font);\n textFont = changes.font;\n }\n if (changes.fontSize) {\n textElement.setAttribute('font-size', changes.fontSize);\n textSize = changes.fontSize;\n }\n};\n\n// Expose select/deselect for external callers (Selection.js, TextShape.selectShape)\nwindow.__deselectTextElement = deselectElement;\nwindow.__selectTextElement = selectElement;\n\n// React sidebar bridge \u2014 text \u2194 code conversion\nwindow.__convertTextToCode = function() {\n if (selectedElement && selectedElement.getAttribute('data-type') === 'text-group') {\n convertTextToCode(selectedElement);\n }\n};\nwindow.__convertCodeToText = function() {\n // Try codeTool's selectedCodeBlock first, then check textTool's selectedElement\n let codeBlock = getSelectedCodeBlock();\n if (!codeBlock && selectedElement && selectedElement.getAttribute('data-type') === 'code-group') {\n codeBlock = selectedElement;\n }\n if (codeBlock) {\n convertCodeToText(codeBlock);\n }\n};\nwindow.__setCodeLanguage = function(lang) {\n setCodeLanguage(lang);\n // Re-highlight selected code block with new language\n const selectedCode = getSelectedCodeBlock();\n if (selectedCode) {\n const codeElement = selectedCode.querySelector('text');\n if (codeElement) {\n codeElement.setAttribute('data-language', lang);\n const textContent = extractTextFromCodeElement(codeElement);\n // Clear and re-highlight\n while (codeElement.firstChild) codeElement.removeChild(codeElement.firstChild);\n const highlighted = applySyntaxHighlightingToSVG(textContent, lang);\n createHighlightedSVGText(highlighted, codeElement);\n updateCodeBackground(selectedCode, codeElement);\n }\n }\n};\n\nexport { handleTextMouseDown, handleTextMouseMove, handleTextMouseUp, updateCodeToggleForShape, deselectElement as deselectTextElement, enterEditMode };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,SAAS,iBAAiB;AAAE,MAAI,OAAO,aAAa,YAAa,QAAO;AAAQ,SAAO,SAAS,QAAQ,SAAS,KAAK,UAAU,SAAS,YAAY,IAAI,SAAS;AAAW;AAe7K,IAAI,WAAW;AACf,IAAI,WAAW;AACf,IAAI,YAAY;AAChB,IAAI,YAAY;AAEhB,IAAI,mBAAmB,SAAS,iBAAiB,gBAAgB;AACjE,IAAI,kBAAkB,SAAS,iBAAiB,eAAe;AAC/D,IAAI,kBAAkB,SAAS,iBAAiB,eAAe;AAC/D,IAAI,mBAAmB,SAAS,iBAAiB,gBAAgB;AAEjE,IAAI,kBAAkB;AACtB,IAAI,eAAe;AACnB,IAAI,gBAAgB,CAAC;AACrB,IAAI;AAAJ,IAAiB;AACjB,IAAI,aAAa;AACjB,IAAI,aAAa;AACjB,IAAI,sBAAsB;AAC1B,IAAI,YAAY;AAChB,IAAI,gBAAgB;AACpB,IAAI,aAAa;AACjB,IAAI,aAAa;AACjB,IAAI,qBAAqB;AACzB,IAAI,yBAAyB;AAC7B,IAAI,2BAA2B;AAC/B,IAAI,iBAAiB;AACrB,IAAI,iBA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;AAAA,EAC/B;AACJ;AACA,OAAO,oBAAoB,SAAS,MAAM;AACtC,kBAAgB,IAAI;AAEpB,QAAM,eAAe,qBAAqB;AAC1C,MAAI,cAAc;AACd,UAAM,cAAc,aAAa,cAAc,MAAM;AACrD,QAAI,aAAa;AACb,kBAAY,aAAa,iBAAiB,IAAI;AAC9C,YAAM,cAAc,2BAA2B,WAAW;AAE1D,aAAO,YAAY,WAAY,aAAY,YAAY,YAAY,UAAU;AAC7E,YAAM,cAAc,6BAA6B,aAAa,IAAI;AAClE,+BAAyB,aAAa,WAAW;AACjD,2BAAqB,cAAc,WAAW;AAAA,IAClD;AAAA,EACJ;AACJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/react/index.js
CHANGED
|
@@ -427,7 +427,7 @@ function useSketchEngine(svgRef, ready = true) {
|
|
|
427
427
|
setZoom: (zoom) => useSketchStore_default.setState({ zoom }),
|
|
428
428
|
getState: () => useSketchStore_default.getState()
|
|
429
429
|
};
|
|
430
|
-
const { SketchEngine } = await import("./SketchEngine-
|
|
430
|
+
const { SketchEngine } = await import("./SketchEngine-DWDJP2BB.js");
|
|
431
431
|
if (cancelled) return;
|
|
432
432
|
const engine = new SketchEngine(svgRef.current);
|
|
433
433
|
await engine.init();
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
handleTextMouseMove,
|
|
7
7
|
handleTextMouseUp,
|
|
8
8
|
updateCodeToggleForShape
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-TUMWA4YF.js";
|
|
10
10
|
import "./chunk-LHRTXNVE.js";
|
|
11
11
|
import "./chunk-BZE4CEBG.js";
|
|
12
12
|
import "./chunk-L5OARZJ7.js";
|
|
@@ -18,4 +18,4 @@ export {
|
|
|
18
18
|
handleTextMouseUp,
|
|
19
19
|
updateCodeToggleForShape
|
|
20
20
|
};
|
|
21
|
-
//# sourceMappingURL=textTool-
|
|
21
|
+
//# sourceMappingURL=textTool-QVKV45VD.js.map
|
package/package.json
CHANGED
package/src/tools/textTool.js
CHANGED
|
@@ -127,13 +127,17 @@ function addText(event) {
|
|
|
127
127
|
textElement.setAttribute("cursor", "default");
|
|
128
128
|
textElement.setAttribute("white-space", "pre");
|
|
129
129
|
textElement.setAttribute("dominant-baseline", "hanging");
|
|
130
|
-
// Issue #
|
|
131
|
-
//
|
|
132
|
-
//
|
|
133
|
-
//
|
|
134
|
-
//
|
|
135
|
-
//
|
|
136
|
-
|
|
130
|
+
// Issue #48 bugs #1 / #3: reverted the previous `bounding-box` hit
|
|
131
|
+
// area (introduced for #34 #5b) — extending the text's hit zone to
|
|
132
|
+
// its full bbox meant the negative space between glyphs and around
|
|
133
|
+
// the text was stealing clicks from shapes drawn ON TOP of the text
|
|
134
|
+
// (drag a rect over text → text intercepts; select text then click a
|
|
135
|
+
// different shape elsewhere → click lands in text's invisible bbox
|
|
136
|
+
// and the text stays selected). Default `painted` only fires on
|
|
137
|
+
// glyph pixels, which restores the expected pass-through. Trade-off:
|
|
138
|
+
// empty-padding clicks no longer select the text — the user has to
|
|
139
|
+
// click on the letters.
|
|
140
|
+
textElement.setAttribute("pointer-events", "painted");
|
|
137
141
|
textElement.textContent = "";
|
|
138
142
|
|
|
139
143
|
gElement.setAttribute("data-x", x);
|
|
@@ -190,17 +194,24 @@ function makeTextEditable(textElement, groupElement) {
|
|
|
190
194
|
let input = document.createElement("textarea");
|
|
191
195
|
input.className = "svg-text-editor";
|
|
192
196
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
});
|
|
197
|
+
// Issue #48 phase D follow-up: prefer the persisted `data-wrap-
|
|
198
|
+
// source` when present so re-opening the editor shows the user's
|
|
199
|
+
// original line breaks instead of the auto-wrap output. Falls back
|
|
200
|
+
// to tspan-concatenation for legacy text shapes.
|
|
201
|
+
let textContent = '';
|
|
202
|
+
const storedSource = textElement.getAttribute('data-wrap-source');
|
|
203
|
+
if (storedSource !== null && storedSource !== '') {
|
|
204
|
+
textContent = storedSource.replace(/ /g, '\u00A0');
|
|
202
205
|
} else {
|
|
203
|
-
|
|
206
|
+
const tspans = textElement.querySelectorAll('tspan');
|
|
207
|
+
if (tspans.length > 0) {
|
|
208
|
+
tspans.forEach((tspan, index) => {
|
|
209
|
+
textContent += tspan.textContent.replace(/ /g, '\u00A0');
|
|
210
|
+
if (index < tspans.length - 1) textContent += '\n';
|
|
211
|
+
});
|
|
212
|
+
} else {
|
|
213
|
+
textContent = textElement.textContent.replace(/ /g, '\u00A0');
|
|
214
|
+
}
|
|
204
215
|
}
|
|
205
216
|
|
|
206
217
|
input.value = textContent;
|
|
@@ -256,11 +267,16 @@ function makeTextEditable(textElement, groupElement) {
|
|
|
256
267
|
input.style.lineHeight = "1.2em";
|
|
257
268
|
input.style.textAlign = currentAnchor === "middle" ? "center" : currentAnchor === "end" ? "right" : "left";
|
|
258
269
|
input.style.backgroundColor = "transparent";
|
|
259
|
-
// Issue #34 bug #5a: dashed creation outline that grows
|
|
260
|
-
//
|
|
261
|
-
//
|
|
262
|
-
//
|
|
263
|
-
|
|
270
|
+
// Issue #34 bug #5a + #48 bug #2: dashed creation outline that grows
|
|
271
|
+
// with the text. Originally `rgba(255,255,255,0.55)` — invisible on
|
|
272
|
+
// the new light canvas. Read the active theme so the dashes stay
|
|
273
|
+
// visible in both modes.
|
|
274
|
+
const _isDark = typeof document !== 'undefined'
|
|
275
|
+
&& document.body
|
|
276
|
+
&& document.body.classList.contains('theme-dark');
|
|
277
|
+
input.style.border = _isDark
|
|
278
|
+
? "1px dashed rgba(255,255,255,0.55)"
|
|
279
|
+
: "1px dashed rgba(40,40,60,0.45)";
|
|
264
280
|
input.style.borderRadius = "3px";
|
|
265
281
|
input.style.outline = "none";
|
|
266
282
|
document.body.appendChild(input);
|
|
@@ -329,6 +345,83 @@ function makeTextEditable(textElement, groupElement) {
|
|
|
329
345
|
groupElement.style.display = "none";
|
|
330
346
|
}
|
|
331
347
|
|
|
348
|
+
/**
|
|
349
|
+
* Issue #48 phase D follow-up: true text wrapping driven by E/W width.
|
|
350
|
+
*
|
|
351
|
+
* `paint(textElement, source, wrapWidth)` renders the user-typed `source`
|
|
352
|
+
* string into tspans, soft-wrapping any line that exceeds `wrapWidth`
|
|
353
|
+
* pixels (in SVG units). `wrapWidth = null | 0` falls back to the old
|
|
354
|
+
* "explicit newlines only" behaviour so existing text shapes that have
|
|
355
|
+
* never been width-resized look identical.
|
|
356
|
+
*
|
|
357
|
+
* The raw `source` is persisted on the element as `data-wrap-source`
|
|
358
|
+
* so subsequent edits (textarea re-open) and serialisation can rebuild
|
|
359
|
+
* the original content even after auto-wrap inserted line breaks.
|
|
360
|
+
*/
|
|
361
|
+
function measureSegment(text, refTextElement) {
|
|
362
|
+
if (!text) return 0;
|
|
363
|
+
const NS = 'http://www.w3.org/2000/svg';
|
|
364
|
+
const probe = document.createElementNS(NS, 'tspan');
|
|
365
|
+
probe.textContent = text;
|
|
366
|
+
refTextElement.appendChild(probe);
|
|
367
|
+
let width = 0;
|
|
368
|
+
try { width = probe.getComputedTextLength(); } catch {}
|
|
369
|
+
refTextElement.removeChild(probe);
|
|
370
|
+
return width;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
function paintTextContent(textElement, source, wrapWidth) {
|
|
374
|
+
while (textElement.firstChild) textElement.removeChild(textElement.firstChild);
|
|
375
|
+
const x = textElement.getAttribute('x') || 0;
|
|
376
|
+
const NS = 'http://www.w3.org/2000/svg';
|
|
377
|
+
const paragraphs = (source || '').split('\n');
|
|
378
|
+
const finalLines = [];
|
|
379
|
+
|
|
380
|
+
for (const paragraph of paragraphs) {
|
|
381
|
+
const para = paragraph.replace(/ /g, ' ');
|
|
382
|
+
if (!wrapWidth || wrapWidth <= 0) {
|
|
383
|
+
finalLines.push(para || ' ');
|
|
384
|
+
continue;
|
|
385
|
+
}
|
|
386
|
+
// Word-wrap the paragraph against wrapWidth.
|
|
387
|
+
const words = para.split(/(\s+)/); // keep separators so spacing survives
|
|
388
|
+
let cur = '';
|
|
389
|
+
for (const token of words) {
|
|
390
|
+
const candidate = cur + token;
|
|
391
|
+
if (measureSegment(candidate, textElement) > wrapWidth && cur.trim().length > 0) {
|
|
392
|
+
finalLines.push(cur);
|
|
393
|
+
cur = token.replace(/^\s+/, ''); // drop the leading break-space
|
|
394
|
+
} else {
|
|
395
|
+
cur = candidate;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
finalLines.push(cur.length ? cur : ' ');
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
finalLines.forEach((line, i) => {
|
|
402
|
+
const tspan = document.createElementNS(NS, 'tspan');
|
|
403
|
+
tspan.setAttribute('x', x);
|
|
404
|
+
tspan.setAttribute('dy', i === 0 ? '0' : '1.2em');
|
|
405
|
+
tspan.textContent = line.length ? line : ' ';
|
|
406
|
+
textElement.appendChild(tspan);
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
function getWrapSource(textElement) {
|
|
411
|
+
const stored = textElement.getAttribute('data-wrap-source');
|
|
412
|
+
if (stored !== null && stored !== '') return stored;
|
|
413
|
+
// Fallback: rebuild from existing tspans (legacy text shapes without
|
|
414
|
+
// the attribute). Join each tspan as a paragraph.
|
|
415
|
+
const tspans = textElement.querySelectorAll('tspan');
|
|
416
|
+
if (tspans.length === 0) return textElement.textContent || '';
|
|
417
|
+
return Array.from(tspans).map((t) => (t.textContent || '').replace(/ /g, ' ')).join('\n');
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
function getWrapWidth(textElement) {
|
|
421
|
+
const v = parseFloat(textElement.getAttribute('data-wrap-width') || '');
|
|
422
|
+
return Number.isFinite(v) && v > 0 ? v : 0;
|
|
423
|
+
}
|
|
424
|
+
|
|
332
425
|
function renderText(input, textElement, deleteIfEmpty = false) {
|
|
333
426
|
if (!input || !document.body.contains(input)) {
|
|
334
427
|
return;
|
|
@@ -386,23 +479,13 @@ function renderText(input, textElement, deleteIfEmpty = false) {
|
|
|
386
479
|
removeSelectionFeedback();
|
|
387
480
|
}
|
|
388
481
|
} else {
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
const
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
lines.forEach((line, index) => {
|
|
397
|
-
let tspan = document.createElementNS(
|
|
398
|
-
"http://www.w3.org/2000/svg",
|
|
399
|
-
"tspan"
|
|
400
|
-
);
|
|
401
|
-
tspan.setAttribute("x", x);
|
|
402
|
-
tspan.setAttribute("dy", index === 0 ? "0" : "1.2em");
|
|
403
|
-
tspan.textContent = line.replace(/\u00A0/g, ' ') || " ";
|
|
404
|
-
textElement.appendChild(tspan);
|
|
405
|
-
});
|
|
482
|
+
// Persist the raw editor content so future E/W resizes can re-wrap
|
|
483
|
+
// from the user's original line breaks instead of the auto-inserted
|
|
484
|
+
// ones. Then call the shared paint helper \u2014 it falls back to the
|
|
485
|
+
// legacy "explicit newlines only" path when no wrap-width is set.
|
|
486
|
+
const cleanSource = text.replace(/\u00A0/g, ' ');
|
|
487
|
+
textElement.setAttribute('data-wrap-source', cleanSource);
|
|
488
|
+
paintTextContent(textElement, cleanSource, getWrapWidth(textElement));
|
|
406
489
|
|
|
407
490
|
gElement.style.display = 'block';
|
|
408
491
|
|
|
@@ -464,11 +547,18 @@ function createSelectionFeedback(groupElement) {
|
|
|
464
547
|
selectionBox.setAttribute("pointer-events", "none");
|
|
465
548
|
groupElement.appendChild(selectionBox);
|
|
466
549
|
|
|
550
|
+
// Issue #48 bug #5 + phase D follow-up: E/W midpoint anchors drive
|
|
551
|
+
// TRUE word-wrap. Dragging E/W sets `data-wrap-width` on the text
|
|
552
|
+
// element; the paint helper re-flows tspans so the text wraps into
|
|
553
|
+
// multiple lines. Corner anchors keep their font-size scaling
|
|
554
|
+
// behaviour.
|
|
467
555
|
const handlesData = [
|
|
468
556
|
{ name: 'nw', x: selX, y: selY, cursor: 'nwse-resize' },
|
|
469
557
|
{ name: 'ne', x: selX + selWidth, y: selY, cursor: 'nesw-resize' },
|
|
470
558
|
{ name: 'sw', x: selX, y: selY + selHeight, cursor: 'nesw-resize' },
|
|
471
|
-
{ name: 'se', x: selX + selWidth, y: selY + selHeight, cursor: 'nwse-resize' }
|
|
559
|
+
{ name: 'se', x: selX + selWidth, y: selY + selHeight, cursor: 'nwse-resize' },
|
|
560
|
+
{ name: 'e', x: selX + selWidth, y: selY + selHeight / 2, cursor: 'ew-resize' },
|
|
561
|
+
{ name: 'w', x: selX, y: selY + selHeight / 2, cursor: 'ew-resize' },
|
|
472
562
|
];
|
|
473
563
|
|
|
474
564
|
resizeHandles = {};
|
|
@@ -573,7 +663,11 @@ function updateSelectionFeedback() {
|
|
|
573
663
|
{ name: 'nw', x: selX, y: selY },
|
|
574
664
|
{ name: 'ne', x: selX + selWidth, y: selY },
|
|
575
665
|
{ name: 'sw', x: selX, y: selY + selHeight },
|
|
576
|
-
{ name: 'se', x: selX + selWidth, y: selY + selHeight }
|
|
666
|
+
{ name: 'se', x: selX + selWidth, y: selY + selHeight },
|
|
667
|
+
// Issue #48 bug #5: keep E/W midpoint handles aligned with the
|
|
668
|
+
// resize so they follow the box as it scales.
|
|
669
|
+
{ name: 'e', x: selX + selWidth, y: selY + selHeight / 2 },
|
|
670
|
+
{ name: 'w', x: selX, y: selY + selHeight / 2 },
|
|
577
671
|
];
|
|
578
672
|
|
|
579
673
|
handlesData.forEach(handle => {
|
|
@@ -865,6 +959,7 @@ const handleMouseMove = (event) => {
|
|
|
865
959
|
const startHeight = startBBox.height;
|
|
866
960
|
|
|
867
961
|
let anchorX, anchorY;
|
|
962
|
+
const isEdgeWidth = currentResizeHandle === 'e' || currentResizeHandle === 'w';
|
|
868
963
|
|
|
869
964
|
switch (currentResizeHandle) {
|
|
870
965
|
case 'nw':
|
|
@@ -883,11 +978,35 @@ const handleMouseMove = (event) => {
|
|
|
883
978
|
anchorX = startX;
|
|
884
979
|
anchorY = startY;
|
|
885
980
|
break;
|
|
981
|
+
case 'e':
|
|
982
|
+
anchorX = startX;
|
|
983
|
+
anchorY = startY + startHeight / 2;
|
|
984
|
+
break;
|
|
985
|
+
case 'w':
|
|
986
|
+
anchorX = startX + startWidth;
|
|
987
|
+
anchorY = startY + startHeight / 2;
|
|
988
|
+
break;
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
// Issue #48 phase D follow-up: E/W now drives TRUE word-wrap.
|
|
992
|
+
// The drag distance becomes the wrap-width target; we re-paint
|
|
993
|
+
// the text with the new width and short-circuit the font-size
|
|
994
|
+
// scaling path that the corners use.
|
|
995
|
+
if (isEdgeWidth) {
|
|
996
|
+
const newWrap = Math.abs(currentPoint.x - anchorX);
|
|
997
|
+
const minWrap = startFontSize * 2; // at least ~one short word wide
|
|
998
|
+
const clampedWrap = Math.max(minWrap, newWrap);
|
|
999
|
+
textElement.setAttribute('data-wrap-width', String(clampedWrap));
|
|
1000
|
+
const source = getWrapSource(textElement);
|
|
1001
|
+
paintTextContent(textElement, source, clampedWrap);
|
|
1002
|
+
if (typeof updateSelectionFeedback === 'function') {
|
|
1003
|
+
setTimeout(updateSelectionFeedback, 0);
|
|
1004
|
+
}
|
|
1005
|
+
return;
|
|
886
1006
|
}
|
|
887
1007
|
|
|
888
1008
|
const newWidth = Math.abs(currentPoint.x - anchorX);
|
|
889
1009
|
const newHeight = Math.abs(currentPoint.y - anchorY);
|
|
890
|
-
|
|
891
1010
|
const chosenScale = newHeight / startHeight;
|
|
892
1011
|
|
|
893
1012
|
const minScale = 0.1;
|
|
@@ -921,6 +1040,14 @@ const handleMouseMove = (event) => {
|
|
|
921
1040
|
newAnchorX = currentBBox.x;
|
|
922
1041
|
newAnchorY = currentBBox.y;
|
|
923
1042
|
break;
|
|
1043
|
+
case 'e':
|
|
1044
|
+
newAnchorX = currentBBox.x;
|
|
1045
|
+
newAnchorY = currentBBox.y + currentBBox.height / 2;
|
|
1046
|
+
break;
|
|
1047
|
+
case 'w':
|
|
1048
|
+
newAnchorX = currentBBox.x + currentBBox.width;
|
|
1049
|
+
newAnchorY = currentBBox.y + currentBBox.height / 2;
|
|
1050
|
+
break;
|
|
924
1051
|
}
|
|
925
1052
|
|
|
926
1053
|
const deltaX = anchorX - newAnchorX;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/tools/textTool.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable */\n// Text tool event handlers - extracted from writeText.js\nimport {\n pushCreateAction,\n pushDeleteAction,\n pushDeleteActionWithAttachments,\n pushTransformAction,\n pushOptionsChangeAction,\n pushFrameAttachmentAction,\n setTextReferences,\n updateSelectedElement\n} from '../core/UndoRedo.js';\nimport { cleanupAttachments, updateAttachedArrows } from './arrowTool.js';\n\nfunction getThemeStroke() { if (typeof document === \"undefined\") return \"#fff\"; return document.body && document.body.classList.contains(\"theme-dark\") ? \"#fff\" : \"#1a1a2e\"; }\nimport {\n addCodeBlock,\n wrapCodeElement,\n selectCodeBlock,\n deselectCodeBlock,\n applySyntaxHighlightingToSVG,\n createHighlightedSVGText,\n updateCodeBackground,\n extractTextFromCodeElement,\n setCodeLanguage,\n getCodeLanguage,\n getSelectedCodeBlock\n} from './codeTool.js';\n\nlet textSize = \"30px\";\nlet textFont = \"lixFont\";\nlet textColor = null;\nlet textAlign = \"left\";\n\nlet textColorOptions = document.querySelectorAll(\".textColorSpan\");\nlet textFontOptions = document.querySelectorAll(\".textFontSpan\");\nlet textSizeOptions = document.querySelectorAll(\".textSizeSpan\");\nlet textAlignOptions = document.querySelectorAll(\".textAlignSpan\");\n\nlet selectedElement = null;\nlet selectionBox = null;\nlet resizeHandles = {};\nlet dragOffsetX, dragOffsetY;\nlet isDragging = false;\nlet isResizing = false;\nlet currentResizeHandle = null;\nlet startBBox = null;\nlet startFontSize = null;\nlet startPoint = null;\nlet isRotating = false;\nlet rotationStartAngle = 0;\nlet rotationStartTransform = null;\nlet initialHandlePosRelGroup = null;\nlet initialGroupTx = 0;\nlet initialGroupTy = 0;\nlet initialInverseScreenCTM = null;\n\n// Frame attachment variables\nlet draggedShapeInitialFrameText = null;\nlet hoveredFrameText = null;\n\nsetTextReferences(selectedElement, updateSelectionFeedback, svg);\n\n\nfunction switchToSelectionTool() {\n if (window.__sketchStoreApi) {\n window.__sketchStoreApi.setActiveTool('select', { afterDraw: true });\n } else {\n window.isSelectionToolActive = true;\n }\n}\n\n\n// Convert group element to our TextShape class\nfunction wrapTextElement(groupElement) {\n const textShape = new TextShape(groupElement);\n return textShape;\n}\n\nfunction getSVGCoordinates(event, element = svg) {\n if (!svg || !svg.createSVGPoint) {\n console.error(\"SVG element or createSVGPoint method not available.\");\n return { x: 0, y: 0 };\n }\n let pt = svg.createSVGPoint();\n pt.x = event.clientX;\n pt.y = event.clientY;\n\n try {\n let screenCTM = (element && typeof element.getScreenCTM === 'function' && element.getScreenCTM()) || svg.getScreenCTM();\n if (!screenCTM) {\n console.error(\"Could not get Screen CTM.\");\n return { x: event.clientX, y: event.clientY };\n }\n let svgPoint = pt.matrixTransform(screenCTM.inverse());\n return {\n x: svgPoint.x,\n y: svgPoint.y,\n };\n } catch (error) {\n console.error(\"Error getting SVG coordinates:\", error);\n return { x: event.clientX, y: event.clientY };\n }\n}\n\nfunction addText(event) {\n let { x, y } = getSVGCoordinates(event);\n\n let gElement = document.createElementNS(\"http://www.w3.org/2000/svg\", \"g\");\n gElement.setAttribute(\"data-type\", \"text-group\");\n gElement.setAttribute(\"transform\", `translate(${x}, ${y})`);\n\n let textElement = document.createElementNS(\n \"http://www.w3.org/2000/svg\",\n \"text\"\n );\n let textAlignElement = \"start\";\n if (textAlign === \"center\") textAlignElement = \"middle\";\n else if (textAlign === \"right\") textAlignElement = \"end\";\n\n textElement.setAttribute(\"x\", 0);\n textElement.setAttribute(\"y\", 0);\n textElement.setAttribute(\"fill\", textColor ?? getThemeStroke());\n textElement.setAttribute(\"font-size\", textSize);\n textElement.setAttribute(\"font-family\", textFont);\n textElement.setAttribute(\"text-anchor\", textAlignElement);\n textElement.setAttribute(\"cursor\", \"default\");\n textElement.setAttribute(\"white-space\", \"pre\");\n textElement.setAttribute(\"dominant-baseline\", \"hanging\");\n // Issue #34 bug #5b: SVG <text> only fires pointer events on the\n // painted glyphs by default \u2014 so a click between letters or in the\n // padding around the text never bubbles to the <g> and the selection\n // tool can't pick the shape up. `bounding-box` extends the hit area\n // to the entire bounding box (SVG 2; supported in Chromium/WebKit/\n // Firefox), which is what every other shape tool relies on.\n textElement.setAttribute(\"pointer-events\", \"bounding-box\");\n textElement.textContent = \"\";\n\n gElement.setAttribute(\"data-x\", x);\n gElement.setAttribute(\"data-y\", y);\n textElement.setAttribute(\"data-initial-size\", textSize);\n textElement.setAttribute(\"data-initial-font\", textFont);\n textElement.setAttribute(\"data-initial-color\", textColor ?? getThemeStroke());\n textElement.setAttribute(\"data-initial-align\", textAlign);\n textElement.setAttribute(\"data-type\", \"text\");\n gElement.appendChild(textElement);\n svg.appendChild(gElement);\n \n // Attach ID to both group and text element\n const shapeID = `text-${String(Date.now()).slice(0, 8)}-${Math.floor(Math.random() * 10000)}`;\n gElement.setAttribute('id', shapeID);\n textElement.setAttribute('id', `${shapeID}-text`);\n \n // Create TextShape wrapper for frame functionality\n const textShape = wrapTextElement(gElement);\n \n // Add to shapes array for arrow attachment and frame functionality\n if (typeof shapes !== 'undefined' && Array.isArray(shapes)) {\n shapes.push(textShape);\n }\n \n pushCreateAction({\n type: 'text',\n element: textShape,\n shapeName: 'text'\n });\n\n // Check if text was created inside a frame and add it\n if (typeof shapes !== 'undefined' && Array.isArray(shapes)) {\n shapes.forEach(shape => {\n if (shape.shapeName === 'frame' && shape.isShapeInFrame(textShape)) {\n shape.addShapeToFrame(textShape);\n }\n });\n }\n\n makeTextEditable(textElement, gElement);\n}\n\nfunction makeTextEditable(textElement, groupElement) {\n\n if (document.querySelector(\"textarea.svg-text-editor\")) {\n return;\n }\n\n if (selectedElement) {\n deselectElement();\n }\n\n let input = document.createElement(\"textarea\");\n input.className = \"svg-text-editor\";\n\n let textContent = \"\";\n const tspans = textElement.querySelectorAll('tspan');\n if (tspans.length > 0) {\n tspans.forEach((tspan, index) => {\n textContent += tspan.textContent.replace(/ /g, '\\u00A0');\n if (index < tspans.length - 1) {\n textContent += \"\\n\";\n }\n });\n } else {\n textContent = textElement.textContent.replace(/ /g, '\\u00A0');\n }\n\n input.value = textContent;\n input.style.position = \"absolute\";\n input.style.outline = \"none\";\n input.style.padding = \"1px\";\n input.style.margin = \"0\";\n input.style.boxSizing = \"border-box\";\n input.style.overflow = \"hidden\";\n input.style.resize = \"none\";\n input.style.whiteSpace = \"pre-wrap\";\n input.style.minHeight = \"1.2em\";\n input.style.zIndex = \"10000\";\n\n const svgRect = svg.getBoundingClientRect();\n\n // Use the group element's own screenCTM which includes group transform + SVG viewBox transform\n const textBBox = textElement.getBBox();\n let pt = svg.createSVGPoint();\n pt.x = textBBox.x;\n pt.y = textBBox.y;\n\n const groupCTM = groupElement.getScreenCTM() || svg.getScreenCTM();\n let screenPt = pt.matrixTransform(groupCTM);\n\n input.style.left = `${screenPt.x}px`;\n input.style.top = `${screenPt.y}px`;\n\n const svgZoomFactor = svg.getScreenCTM() ? svg.getScreenCTM().a : 1;\n const screenWidth = textBBox.width * svgZoomFactor;\n\n input.style.width = \"auto\";\n input.style.height = \"auto\";\n\n const currentFontSize = textElement.getAttribute(\"font-size\") || \"30px\";\n const currentFontFamily = textElement.getAttribute(\"font-family\") || \"lixFont\";\n const currentFill = textElement.getAttribute(\"fill\") || \"#fff\";\n const currentAnchor = textElement.getAttribute(\"text-anchor\") || \"start\";\n // Scale font-size by zoom so the textarea matches what the user sees on canvas\n const rawSize = parseFloat(currentFontSize) || 30;\n const scaledFontSize = `${rawSize * svgZoomFactor}px`;\n\n input.style.minWidth = \"150px\";\n input.style.minHeight = \"1.5em\";\n input.style.width = \"auto\";\n input.style.height = \"auto\";\n input.style.overflow = \"visible\";\n input.style.whiteSpace = \"pre-wrap\";\n input.style.wordBreak = \"break-word\";\n input.style.fontSize = scaledFontSize;\n input.style.fontFamily = currentFontFamily;\n input.style.color = currentFill;\n input.style.lineHeight = \"1.2em\";\n input.style.textAlign = currentAnchor === \"middle\" ? \"center\" : currentAnchor === \"end\" ? \"right\" : \"left\";\n input.style.backgroundColor = \"transparent\";\n // Issue #34 bug #5a: dashed creation outline that grows with the\n // text \u2014 same visual cue the frame tool uses while drawing. Inset\n // padding-box border so the dashes follow the textarea size as the\n // user types instead of clipping behind the glyphs.\n input.style.border = \"1px dashed rgba(255,255,255,0.55)\";\n input.style.borderRadius = \"3px\";\n input.style.outline = \"none\";\n document.body.appendChild(input);\n\n const adjustHeight = () => {\n input.style.height = 'auto';\n input.style.height = input.scrollHeight + 'px';\n const maxHeight = svgRect.height - (screenPt.y);\n if (input.scrollHeight > maxHeight) {\n input.style.height = maxHeight + 'px';\n input.style.overflowY = 'auto';\n } else {\n input.style.overflowY = 'hidden';\n }\n };\n\n const adjustWidth = () => {\n input.style.width = 'auto';\n const maxWidth = svgRect.width - (screenPt.x);\n const contentWidth = Math.max(input.scrollWidth, 150);\n if (contentWidth > maxWidth) {\n input.style.width = maxWidth + 'px';\n input.style.overflowX = 'auto';\n } else {\n input.style.width = contentWidth + 'px';\n input.style.overflowX = 'hidden';\n }\n };\n adjustHeight();\n adjustWidth();\n\n setTimeout(() => {\n input.focus();\n input.select();\n }, 50);\n\n input.addEventListener('input', adjustHeight);\n input.addEventListener('input', adjustWidth);\n\n input.addEventListener(\"keydown\", function (e) {\n if (e.key === \"Enter\" && !e.shiftKey) {\n e.preventDefault();\n renderText(input, textElement, true);\n } else if (e.key === \"Escape\") {\n e.preventDefault();\n renderText(input, textElement, true);\n }\n });\n\n input.originalTextElement = textElement;\n input.textGroup = groupElement;\n\n const handleClickOutside = (event) => {\n if (!input.contains(event.target)) {\n renderText(input, textElement, true);\n document.removeEventListener('pointerdown', handleClickOutside, true);\n }\n };\n document.addEventListener('pointerdown', handleClickOutside, true);\n input.handleClickOutside = handleClickOutside;\n\n // Set text cursor on the element during edit mode\n const textEl = groupElement.querySelector('text');\n if (textEl) textEl.setAttribute(\"cursor\", \"text\");\n\n groupElement.style.display = \"none\";\n}\n\nfunction renderText(input, textElement, deleteIfEmpty = false) {\n if (!input || !document.body.contains(input)) {\n return;\n }\n\n const text = input.value || \"\";\n const gElement = input.textGroup;\n\n if (input.handleClickOutside) {\n document.removeEventListener('pointerdown', input.handleClickOutside, true);\n }\n\n document.body.removeChild(input);\n\n // Reset cursor back to default after edit mode ends\n if (textElement) textElement.setAttribute(\"cursor\", \"default\");\n\n if (!gElement || !textElement) {\n return;\n }\n\n if (!gElement.parentNode) {\n if (selectedElement === gElement) {\n deselectElement();\n }\n return;\n }\n\n if (deleteIfEmpty && text.trim() === \"\") {\n // Find the TextShape wrapper\n let textShape = null;\n if (typeof shapes !== 'undefined' && Array.isArray(shapes)) {\n textShape = shapes.find(shape => shape.shapeName === 'text' && shape.group === gElement);\n if (textShape) {\n const idx = shapes.indexOf(textShape);\n if (idx !== -1) shapes.splice(idx, 1);\n }\n }\n\n // Use enhanced delete action for text with arrow attachments\n pushDeleteActionWithAttachments({\n type: 'text',\n element: textShape || gElement,\n shapeName: 'text'\n });\n\n // Clean up any arrow attachments before deleting\n if (typeof cleanupAttachments === 'function') {\n cleanupAttachments(gElement);\n }\n\n svg.removeChild(gElement);\n if (selectedElement === gElement) {\n selectedElement = null;\n removeSelectionFeedback();\n }\n } else {\n while (textElement.firstChild) {\n textElement.removeChild(textElement.firstChild);\n }\n\n const lines = text.split(\"\\n\");\n const x = textElement.getAttribute(\"x\") || 0;\n\n lines.forEach((line, index) => {\n let tspan = document.createElementNS(\n \"http://www.w3.org/2000/svg\",\n \"tspan\"\n );\n tspan.setAttribute(\"x\", x);\n tspan.setAttribute(\"dy\", index === 0 ? \"0\" : \"1.2em\");\n tspan.textContent = line.replace(/\\u00A0/g, ' ') || \" \";\n textElement.appendChild(tspan);\n });\n\n gElement.style.display = 'block';\n\n // Update attached arrows after text content change\n updateAttachedArrows(gElement);\n\n if (selectedElement === gElement) {\n setTimeout(updateSelectionFeedback, 0);\n }\n }\n\n // After rendering text, switch to selection tool and auto-select\n if (gElement.parentNode) {\n switchToSelectionTool();\n // Defer selection so the tool switch (async React state) completes first\n requestAnimationFrame(() => selectElement(gElement));\n }\n}\n\nfunction createSelectionFeedback(groupElement) {\n if (!groupElement) return;\n removeSelectionFeedback();\n\n const textElement = groupElement.querySelector('text');\n if (!textElement) {\n return;\n }\n\n const bbox = textElement.getBBox();\n\n const zoom = window.currentZoom || 1;\n const padding = 8 / zoom;\n const handleSize = 10 / zoom;\n const handleOffset = handleSize / 2;\n const anchorStrokeWidth = 2;\n\n const selX = bbox.x - padding;\n const selY = bbox.y - padding;\n const selWidth = bbox.width + 2 * padding;\n const selHeight = bbox.height + 2 * padding;\n\n const outlinePoints = [\n [selX, selY],\n [selX + selWidth, selY],\n [selX + selWidth, selY + selHeight],\n [selX, selY + selHeight],\n [selX, selY]\n ];\n\n const pointsAttr = outlinePoints.map(p => p.join(',')).join(' ');\n selectionBox = document.createElementNS(\"http://www.w3.org/2000/svg\", \"polyline\");\n selectionBox.setAttribute(\"class\", \"selection-box\");\n selectionBox.setAttribute(\"points\", pointsAttr);\n selectionBox.setAttribute(\"fill\", \"none\");\n selectionBox.setAttribute(\"stroke\", \"#5B57D1\");\n selectionBox.setAttribute(\"stroke-width\", \"1.5\");\n selectionBox.setAttribute(\"stroke-dasharray\", `${4 / zoom} ${2 / zoom}`);\n selectionBox.setAttribute(\"vector-effect\", \"non-scaling-stroke\");\n selectionBox.setAttribute(\"pointer-events\", \"none\");\n groupElement.appendChild(selectionBox);\n\n const handlesData = [\n { name: 'nw', x: selX, y: selY, cursor: 'nwse-resize' },\n { name: 'ne', x: selX + selWidth, y: selY, cursor: 'nesw-resize' },\n { name: 'sw', x: selX, y: selY + selHeight, cursor: 'nesw-resize' },\n { name: 'se', x: selX + selWidth, y: selY + selHeight, cursor: 'nwse-resize' }\n ];\n\n resizeHandles = {};\n handlesData.forEach(handle => {\n const handleRect = document.createElementNS(\"http://www.w3.org/2000/svg\", \"rect\");\n handleRect.setAttribute(\"class\", `resize-handle resize-handle-${handle.name}`);\n handleRect.setAttribute(\"x\", handle.x - handleOffset);\n handleRect.setAttribute(\"y\", handle.y - handleOffset);\n handleRect.setAttribute(\"width\", handleSize);\n handleRect.setAttribute(\"height\", handleSize);\n handleRect.setAttribute(\"fill\", \"#121212\");\n handleRect.setAttribute(\"stroke\", \"#5B57D1\");\n handleRect.setAttribute(\"stroke-width\", anchorStrokeWidth);\n handleRect.setAttribute(\"vector-effect\", \"non-scaling-stroke\");\n handleRect.style.cursor = handle.cursor;\n handleRect.setAttribute(\"data-anchor\", handle.name);\n groupElement.appendChild(handleRect);\n resizeHandles[handle.name] = handleRect;\n\n handleRect.addEventListener('pointerdown', (e) => {\n if (window.isSelectionToolActive) {\n e.stopPropagation();\n startResize(e, handle.name);\n }\n });\n });\n\n const rotationAnchorPos = { x: selX + selWidth / 2, y: selY - 30 };\n const rotationAnchor = document.createElementNS('http://www.w3.org/2000/svg', 'circle');\n rotationAnchor.setAttribute('cx', rotationAnchorPos.x);\n rotationAnchor.setAttribute('cy', rotationAnchorPos.y);\n rotationAnchor.setAttribute('r', 8);\n rotationAnchor.setAttribute('class', 'rotate-anchor');\n rotationAnchor.setAttribute('fill', '#121212');\n rotationAnchor.setAttribute('stroke', '#5B57D1');\n rotationAnchor.setAttribute('stroke-width', anchorStrokeWidth);\n rotationAnchor.setAttribute('vector-effect', 'non-scaling-stroke');\n rotationAnchor.style.cursor = 'grab';\n rotationAnchor.setAttribute('pointer-events', 'all');\n groupElement.appendChild(rotationAnchor);\n\n resizeHandles.rotate = rotationAnchor;\n\n rotationAnchor.addEventListener('pointerdown', (e) => {\n if (window.isSelectionToolActive) {\n e.stopPropagation();\n startRotation(e);\n }\n });\n\n rotationAnchor.addEventListener('mouseover', function() {\n if (!isResizing && !isDragging) {\n this.style.cursor = 'grab';\n }\n });\n\n rotationAnchor.addEventListener('mouseout', function() {\n if (!isResizing && !isDragging) {\n this.style.cursor = 'default';\n }\n });\n}\n\nfunction updateSelectionFeedback() {\n if (!selectedElement || !selectionBox) return;\n\n const textElement = selectedElement.querySelector('text');\n if (!textElement) return;\n\n const wasHidden = selectedElement.style.display === 'none';\n if (wasHidden) selectedElement.style.display = 'block';\n\n const bbox = textElement.getBBox();\n\n if (wasHidden) selectedElement.style.display = 'none';\n\n if (bbox.width === 0 && bbox.height === 0 && textElement.textContent.trim() !== \"\") {\n }\n\n const zoom2 = window.currentZoom || 1;\n const padding = 8 / zoom2;\n const handleSize = 10 / zoom2;\n const handleOffset = handleSize / 2;\n\n const selX = bbox.x - padding;\n const selY = bbox.y - padding;\n const selWidth = Math.max(bbox.width + 2 * padding, handleSize);\n const selHeight = Math.max(bbox.height + 2 * padding, handleSize);\n\n const outlinePoints = [\n [selX, selY],\n [selX + selWidth, selY],\n [selX + selWidth, selY + selHeight],\n [selX, selY + selHeight],\n [selX, selY]\n ];\n\n const pointsAttr = outlinePoints.map(p => p.join(',')).join(' ');\n selectionBox.setAttribute(\"points\", pointsAttr);\n\n const handlesData = [\n { name: 'nw', x: selX, y: selY },\n { name: 'ne', x: selX + selWidth, y: selY },\n { name: 'sw', x: selX, y: selY + selHeight },\n { name: 'se', x: selX + selWidth, y: selY + selHeight }\n ];\n\n handlesData.forEach(handle => {\n const handleRect = resizeHandles[handle.name];\n if (handleRect) {\n handleRect.setAttribute(\"x\", handle.x - handleOffset);\n handleRect.setAttribute(\"y\", handle.y - handleOffset);\n }\n });\n\n const rotationAnchor = resizeHandles.rotate;\n if (rotationAnchor) {\n const rotationAnchorPos = { x: selX + selWidth / 2, y: selY - 30 };\n rotationAnchor.setAttribute('cx', rotationAnchorPos.x);\n rotationAnchor.setAttribute('cy', rotationAnchorPos.y);\n }\n}\n\nfunction startRotation(event) {\n if (!selectedElement || event.button !== 0) return;\n event.preventDefault();\n event.stopPropagation();\n\n isRotating = true;\n isDragging = false;\n isResizing = false;\n\n const textElement = selectedElement.querySelector('text');\n if (!textElement) return;\n\n const bbox = textElement.getBBox();\n const centerX = bbox.x + bbox.width / 2;\n const centerY = bbox.y + bbox.height / 2;\n\n const mousePos = getSVGCoordinates(event);\n\n let centerPoint = svg.createSVGPoint();\n centerPoint.x = centerX;\n centerPoint.y = centerY;\n\n const groupTransform = selectedElement.transform.baseVal.consolidate();\n if (groupTransform) {\n centerPoint = centerPoint.matrixTransform(groupTransform.matrix);\n }\n\n rotationStartAngle = Math.atan2(mousePos.y - centerPoint.y, mousePos.x - centerPoint.x) * 180 / Math.PI;\n\n const currentTransform = selectedElement.transform.baseVal.consolidate();\n rotationStartTransform = currentTransform ? currentTransform.matrix : svg.createSVGMatrix();\n\n svg.style.cursor = 'grabbing';\n\n window.addEventListener('pointermove', handleMouseMove);\n window.addEventListener('pointerup', handleMouseUp);\n}\n\nfunction removeSelectionFeedback(element) {\n const target = element || selectedElement;\n if (target) {\n target.querySelectorAll(\".selection-box, .resize-handle, .rotate-anchor\").forEach(el => el.remove());\n }\n // Also clean up any orphaned selection elements in all text groups\n svg.querySelectorAll('g[data-type=\"text-group\"] .selection-box, g[data-type=\"text-group\"] .resize-handle, g[data-type=\"text-group\"] .rotate-anchor').forEach(el => el.remove());\n\n selectionBox = null;\n resizeHandles = {};\n}\n\nfunction selectElement(groupElement) {\n if (!groupElement || !groupElement.parentNode) return;\n if (groupElement === selectedElement) return;\n\n deselectElement();\n selectedElement = groupElement;\n selectedElement.classList.add(\"selected\");\n createSelectionFeedback(selectedElement);\n\n updateSelectedElement(selectedElement);\n updateCodeToggleForShape('text');\n\n // Update global currentShape so EventDispatcher can route to other tools later\n if (typeof shapes !== 'undefined' && Array.isArray(shapes)) {\n const wrapper = shapes.find(s => s.element === groupElement || s.group === groupElement);\n if (wrapper) {\n currentShape = wrapper;\n }\n }\n\n // Show text property panel when text is selected\n if (window.__showSidebarForShape) window.__showSidebarForShape('text');\n}\n\nfunction deselectElement() {\n const activeEditor = document.querySelector(\"textarea.svg-text-editor\");\n if (activeEditor) {\n let textElement = activeEditor.originalTextElement;\n if (textElement) {\n renderText(activeEditor, textElement, true);\n } else if (document.body.contains(activeEditor)) {\n document.body.removeChild(activeEditor);\n }\n }\n\n if (selectedElement) {\n removeSelectionFeedback();\n selectedElement.classList.remove(\"selected\");\n selectedElement = null;\n\n updateSelectedElement(null);\n\n // Clear global currentShape if it was a text shape\n if (currentShape && (currentShape.shapeName === 'text' || currentShape.shapeName === 'code')) {\n currentShape = null;\n }\n\n // Hide text property panel if we're in selection mode (not text tool)\n if (isSelectionToolActive) {\n textSideBar.classList.add(\"hidden\");\n }\n }\n\n if (isRotating) {\n isRotating = false;\n rotationStartAngle = 0;\n rotationStartTransform = null;\n svg.style.cursor = 'default';\n\n window.removeEventListener('pointermove', handleMouseMove);\n window.removeEventListener('pointerup', handleMouseUp);\n }\n}\n\nfunction startDrag(event) {\n if (!selectedElement || event.button !== 0) return;\n\n if (event.target.closest('.resize-handle')) {\n return;\n }\n\n isDragging = true;\n isResizing = false;\n event.preventDefault();\n\n const currentTransform = selectedElement.transform.baseVal.consolidate();\n const initialTranslateX = currentTransform ? currentTransform.matrix.e : 0;\n const initialTranslateY = currentTransform ? currentTransform.matrix.f : 0;\n\n startPoint = getSVGCoordinates(event);\n\n dragOffsetX = startPoint.x - initialTranslateX;\n dragOffsetY = startPoint.y - initialTranslateY;\n\n // Find the TextShape wrapper for frame functionality\n let textShape = null;\n if (typeof shapes !== 'undefined' && Array.isArray(shapes)) {\n textShape = shapes.find(shape => shape.shapeName === 'text' && shape.group === selectedElement);\n }\n\n if (textShape) {\n // Store initial frame state\n draggedShapeInitialFrameText = textShape.parentFrame || null;\n \n // Temporarily remove from frame clipping if dragging\n if (textShape.parentFrame) {\n textShape.parentFrame.temporarilyRemoveFromFrame(textShape);\n }\n }\n\n svg.style.cursor = 'grabbing';\n\n svg.addEventListener('pointermove', handleMouseMove);\n svg.addEventListener('pointerup', handleMouseUp);\n}\n\nfunction startResize(event, anchor) {\n if (!selectedElement || event.button !== 0) return;\n event.preventDefault();\n event.stopPropagation();\n\n isResizing = true;\n isDragging = false;\n currentResizeHandle = anchor;\n\n const textElement = selectedElement.querySelector('text');\n if (!textElement) {\n isResizing = false;\n return;\n }\n\n startBBox = textElement.getBBox();\n startFontSize = parseFloat(textElement.getAttribute(\"font-size\") || 30);\n if (isNaN(startFontSize)) startFontSize = 30;\n\n startPoint = getSVGCoordinates(event, selectedElement);\n\n // Freeze the group's screen CTM at resize start so mouse\u2192local mapping stays stable\n const groupScreenCTM = selectedElement.getScreenCTM();\n initialInverseScreenCTM = groupScreenCTM ? groupScreenCTM.inverse() : null;\n\n const currentTransform = selectedElement.transform.baseVal.consolidate();\n initialGroupTx = currentTransform ? currentTransform.matrix.e : 0;\n initialGroupTy = currentTransform ? currentTransform.matrix.f : 0;\n\n const padding = 3;\n const startX = startBBox.x - padding;\n const startY = startBBox.y - padding;\n const startWidth = startBBox.width + 2 * padding;\n const startHeight = startBBox.height + 2 * padding;\n\n let hx = startX;\n let hy = startY;\n if (anchor.includes('e')) { hx = startX + startWidth; }\n if (anchor.includes('s')) { hy = startY + startHeight; }\n initialHandlePosRelGroup = { x: hx, y: hy };\n\n svg.style.cursor = resizeHandles[anchor]?.style.cursor || 'default';\n\n svg.addEventListener('pointermove', handleMouseMove);\n svg.addEventListener('pointerup', handleMouseUp);\n}\n\n\nconst handleMouseMove = (event) => {\n if (!selectedElement) return;\n event.preventDefault();\n\n // Keep lastMousePos in screen coordinates for other functions\n const svgRect = svg.getBoundingClientRect();\n lastMousePos = {\n x: event.clientX - svgRect.left, \n y: event.clientY - svgRect.top\n };\n\n if (isDragging) {\n const currentPoint = getSVGCoordinates(event);\n const newTranslateX = currentPoint.x - dragOffsetX;\n const newTranslateY = currentPoint.y - dragOffsetY;\n\n const currentTransform = selectedElement.transform.baseVal.consolidate();\n if (currentTransform) {\n const matrix = currentTransform.matrix;\n const angle = Math.atan2(matrix.b, matrix.a) * 180 / Math.PI;\n\n const textElement = selectedElement.querySelector('text');\n if (textElement) {\n const bbox = textElement.getBBox();\n const centerX = bbox.x + bbox.width / 2;\n const centerY = bbox.y + bbox.height / 2;\n\n selectedElement.setAttribute('transform',\n `translate(${newTranslateX}, ${newTranslateY}) rotate(${angle}, ${centerX}, ${centerY})`\n );\n } else {\n selectedElement.setAttribute('transform', `translate(${newTranslateX}, ${newTranslateY})`);\n }\n } else {\n selectedElement.setAttribute('transform', `translate(${newTranslateX}, ${newTranslateY})`);\n }\n\n // Update frame containment for TextShape wrapper\n if (typeof shapes !== 'undefined' && Array.isArray(shapes)) {\n const textShape = shapes.find(shape => shape.shapeName === 'text' && shape.group === selectedElement);\n if (textShape) {\n textShape.updateFrameContainment();\n }\n }\n\n // Update attached arrows during dragging\n updateAttachedArrows(selectedElement);\n\n } else if (isResizing) {\n const textElement = selectedElement.querySelector('text');\n if (!textElement || !startBBox || startFontSize === null || !startPoint || !initialHandlePosRelGroup) return;\n\n // Use the frozen initial CTM so the mapping doesn't shift as we change the group transform\n let currentPoint;\n if (initialInverseScreenCTM) {\n const pt = svg.createSVGPoint();\n pt.x = event.clientX;\n pt.y = event.clientY;\n currentPoint = pt.matrixTransform(initialInverseScreenCTM);\n } else {\n currentPoint = getSVGCoordinates(event, selectedElement);\n }\n\n const startX = startBBox.x;\n const startY = startBBox.y;\n const startWidth = startBBox.width;\n const startHeight = startBBox.height;\n\n let anchorX, anchorY;\n\n switch (currentResizeHandle) {\n case 'nw':\n anchorX = startX + startWidth;\n anchorY = startY + startHeight;\n break;\n case 'ne':\n anchorX = startX;\n anchorY = startY + startHeight;\n break;\n case 'sw':\n anchorX = startX + startWidth;\n anchorY = startY;\n break;\n case 'se':\n anchorX = startX;\n anchorY = startY;\n break;\n }\n\n const newWidth = Math.abs(currentPoint.x - anchorX);\n const newHeight = Math.abs(currentPoint.y - anchorY);\n\n const chosenScale = newHeight / startHeight;\n\n const minScale = 0.1;\n const maxScale = 10.0;\n const clampedScale = Math.max(minScale, Math.min(chosenScale, maxScale));\n\n const newFontSize = startFontSize * clampedScale;\n const minFontSize = 5;\n const finalFontSize = Math.max(newFontSize, minFontSize);\n\n textElement.setAttribute(\"font-size\", `${finalFontSize}px`);\n\n const currentBBox = textElement.getBBox();\n\n let newAnchorX, newAnchorY;\n\n switch (currentResizeHandle) {\n case 'nw':\n newAnchorX = currentBBox.x + currentBBox.width;\n newAnchorY = currentBBox.y + currentBBox.height;\n break;\n case 'ne':\n newAnchorX = currentBBox.x;\n newAnchorY = currentBBox.y + currentBBox.height;\n break;\n case 'sw':\n newAnchorX = currentBBox.x + currentBBox.width;\n newAnchorY = currentBBox.y;\n break;\n case 'se':\n newAnchorX = currentBBox.x;\n newAnchorY = currentBBox.y;\n break;\n }\n\n const deltaX = anchorX - newAnchorX;\n const deltaY = anchorY - newAnchorY;\n\n const currentTransform = selectedElement.transform.baseVal.consolidate();\n if (currentTransform) {\n const matrix = currentTransform.matrix;\n const angle = Math.atan2(matrix.b, matrix.a) * 180 / Math.PI;\n\n const newGroupTx = initialGroupTx + deltaX;\n const newGroupTy = initialGroupTy + deltaY;\n\n const centerX = currentBBox.x + currentBBox.width / 2;\n const centerY = currentBBox.y + currentBBox.height / 2;\n\n selectedElement.setAttribute('transform',\n `translate(${newGroupTx}, ${newGroupTy}) rotate(${angle}, ${centerX}, ${centerY})`\n );\n } else {\n const newGroupTx = initialGroupTx + deltaX;\n const newGroupTy = initialGroupTy + deltaY;\n selectedElement.setAttribute('transform', `translate(${newGroupTx}, ${newGroupTy})`);\n }\n\n // Update attached arrows during resizing\n updateAttachedArrows(selectedElement);\n\n clearTimeout(selectedElement.updateFeedbackTimeout);\n selectedElement.updateFeedbackTimeout = setTimeout(() => {\n updateSelectionFeedback();\n delete selectedElement.updateFeedbackTimeout;\n }, 0);\n\n } else if (isRotating) {\n const textElement = selectedElement.querySelector('text');\n if (!textElement) return;\n\n const bbox = textElement.getBBox();\n const centerX = bbox.x + bbox.width / 2;\n const centerY = bbox.y + bbox.height / 2;\n\n const mousePos = getSVGCoordinates(event);\n\n let centerPoint = svg.createSVGPoint();\n centerPoint.x = centerX;\n centerPoint.y = centerY;\n\n const groupTransform = selectedElement.transform.baseVal.consolidate();\n if (groupTransform) {\n centerPoint = centerPoint.matrixTransform(groupTransform.matrix);\n }\n\n const currentAngle = Math.atan2(mousePos.y - centerPoint.y, mousePos.x - centerPoint.x) * 180 / Math.PI;\n\n const rotationDiff = currentAngle - rotationStartAngle;\n\n const newTransform = `translate(${rotationStartTransform.e}, ${rotationStartTransform.f}) rotate(${rotationDiff}, ${centerX}, ${centerY})`;\n selectedElement.setAttribute('transform', newTransform);\n\n // Update attached arrows during rotation\n updateAttachedArrows(selectedElement);\n\n updateSelectionFeedback();\n }\n};\n\n\n\nconst handleMouseUp = (event) => {\n if (event.button !== 0) return;\n\n if (isDragging && selectedElement) {\n const currentTransform = selectedElement.transform.baseVal.consolidate();\n if (currentTransform) {\n const finalTranslateX = currentTransform.matrix.e;\n const finalTranslateY = currentTransform.matrix.f;\n\n const initialX = parseFloat(selectedElement.getAttribute(\"data-x\")) || 0;\n const initialY = parseFloat(selectedElement.getAttribute(\"data-y\")) || 0;\n\n // Find the TextShape wrapper for frame tracking\n let textShape = null;\n if (typeof shapes !== 'undefined' && Array.isArray(shapes)) {\n textShape = shapes.find(shape => shape.shapeName === 'text' && shape.group === selectedElement);\n }\n\n // Add frame information for undo tracking\n const oldPosWithFrame = {\n x: initialX,\n y: initialY,\n rotation: extractRotationFromTransform(selectedElement) || 0,\n parentFrame: draggedShapeInitialFrameText\n };\n // Issue #34 bug #2: hoveredFrameText is the actual destination\n // tracked during drag \u2014 textShape.parentFrame is still the OLD\n // frame at this point.\n const newPosWithFrame = {\n x: finalTranslateX,\n y: finalTranslateY,\n rotation: extractRotationFromTransform(selectedElement) || 0,\n parentFrame: hoveredFrameText || null,\n };\n\n const stateChanged = initialX !== finalTranslateX || initialY !== finalTranslateY;\n const frameChanged = oldPosWithFrame.parentFrame !== newPosWithFrame.parentFrame;\n\n if (stateChanged || frameChanged) {\n pushTransformAction(\n {\n type: 'text',\n element: selectedElement,\n shapeName: 'text'\n },\n oldPosWithFrame,\n newPosWithFrame\n );\n }\n\n // Handle frame containment changes after drag\n if (textShape) {\n const finalFrame = hoveredFrameText;\n \n // If shape moved to a different frame\n if (draggedShapeInitialFrameText !== finalFrame) {\n // Remove from initial frame\n if (draggedShapeInitialFrameText) {\n draggedShapeInitialFrameText.removeShapeFromFrame(textShape);\n }\n \n // Add to new frame\n if (finalFrame) {\n finalFrame.addShapeToFrame(textShape);\n }\n \n // Track the frame change for undo\n if (frameChanged) {\n pushFrameAttachmentAction(finalFrame || draggedShapeInitialFrameText, textShape, \n finalFrame ? 'attach' : 'detach', draggedShapeInitialFrameText);\n }\n } else if (draggedShapeInitialFrameText) {\n // Shape stayed in same frame, restore clipping\n draggedShapeInitialFrameText.restoreToFrame(textShape);\n }\n }\n\n selectedElement.setAttribute(\"data-x\", finalTranslateX);\n selectedElement.setAttribute(\"data-y\", finalTranslateY);\n }\n\n draggedShapeInitialFrameText = null;\n\n } else if (isResizing && selectedElement) {\n const textElement = selectedElement.querySelector('text');\n if (textElement) {\n const finalFontSize = textElement.getAttribute(\"font-size\");\n const initialFontSize = startFontSize;\n\n const currentTransform = selectedElement.transform.baseVal.consolidate();\n if (currentTransform && initialFontSize !== parseFloat(finalFontSize)) {\n const finalTranslateX = currentTransform.matrix.e;\n const finalTranslateY = currentTransform.matrix.f;\n\n pushTransformAction(\n {\n type: 'text',\n element: selectedElement,\n shapeName: 'text'\n },\n {\n x: initialGroupTx,\n y: initialGroupTy,\n fontSize: initialFontSize,\n rotation: extractRotationFromTransform(selectedElement) || 0\n },\n {\n x: finalTranslateX,\n y: finalTranslateY,\n fontSize: parseFloat(finalFontSize),\n rotation: extractRotationFromTransform(selectedElement) || 0\n }\n );\n\n selectedElement.setAttribute(\"data-x\", finalTranslateX);\n selectedElement.setAttribute(\"data-y\", finalTranslateY);\n }\n\n clearTimeout(selectedElement.updateFeedbackTimeout);\n updateSelectionFeedback();\n }\n } else if (isRotating && selectedElement) {\n const currentTransform = selectedElement.transform.baseVal.consolidate();\n if (currentTransform && rotationStartTransform) {\n const initialRotation = Math.atan2(rotationStartTransform.b, rotationStartTransform.a) * 180 / Math.PI;\n const finalRotation = extractRotationFromTransform(selectedElement) || 0;\n\n if (Math.abs(initialRotation - finalRotation) > 1) {\n pushTransformAction(\n {\n type: 'text',\n element: selectedElement,\n shapeName: 'text'\n },\n {\n x: rotationStartTransform.e,\n y: rotationStartTransform.f,\n rotation: initialRotation\n },\n {\n x: currentTransform.matrix.e,\n y: currentTransform.matrix.f,\n rotation: finalRotation\n }\n );\n }\n\n }\n updateSelectionFeedback();\n }\n\n // Clear frame highlighting\n if (hoveredFrameText) {\n hoveredFrameText.removeHighlight();\n hoveredFrameText = null;\n }\n\n isDragging = false;\n isResizing = false;\n isRotating = false;\n currentResizeHandle = null;\n startPoint = null;\n startBBox = null;\n startFontSize = null;\n dragOffsetX = undefined;\n dragOffsetY = undefined;\n initialHandlePosRelGroup = null;\n initialGroupTx = 0;\n initialGroupTy = 0;\n rotationStartAngle = 0;\n rotationStartTransform = null;\n\n // Restore cursor based on context - keep pointer if over selected text\n svg.style.cursor = isSelectionToolActive ? 'default' : (isTextToolActive ? 'text' : 'default');\n\n // Ensure selection feedback is refreshed after transforms\n if (selectedElement) {\n setTimeout(updateSelectionFeedback, 0);\n }\n\n svg.removeEventListener('pointermove', handleMouseMove);\n svg.removeEventListener('pointerup', handleMouseUp);\n window.removeEventListener('pointermove', handleMouseMove);\n window.removeEventListener('pointerup', handleMouseUp);\n};\n\nfunction extractRotationFromTransform(element) {\n const currentTransform = element.transform.baseVal.consolidate();\n if (currentTransform) {\n const matrix = currentTransform.matrix;\n return Math.atan2(matrix.b, matrix.a) * 180 / Math.PI;\n }\n return 0;\n}\n\n// EXPORTED EVENT HANDLERS\nconst handleTextMouseDown = function (e) {\n if (!e.target) return;\n const activeEditor = document.querySelector(\"textarea.svg-text-editor\");\n if (activeEditor && activeEditor.contains(e.target)) {\n return;\n }\n if (activeEditor && !activeEditor.contains(e.target)) {\n let textElement = activeEditor.originalTextElement;\n if (textElement) {\n // renderText switches to selection tool and auto-selects the text as a side effect.\n // Return early so we don't continue with stale tool state.\n renderText(activeEditor, textElement, true);\n return;\n } else if (document.body.contains(activeEditor)){\n document.body.removeChild(activeEditor);\n }\n }\n\n const targetGroup = e.target.closest('g[data-type=\"text-group\"]');\n\n if (isSelectionToolActive && e.button === 0) {\n if (targetGroup) {\n if (e.target.closest('.resize-handle')) {\n return;\n }\n\n // Double-click on selected text: enter edit mode\n if (e.detail >= 2 && targetGroup === selectedElement) {\n enterEditMode(targetGroup);\n e.stopPropagation();\n return;\n }\n\n if (targetGroup === selectedElement) {\n startDrag(e);\n } else {\n selectElement(targetGroup);\n startDrag(e);\n }\n } else {\n deselectElement();\n }\n\n } else if (isTextToolActive && e.button === 0) {\n if (targetGroup) {\n // Double-click: enter edit mode\n if (e.detail >= 2) {\n let textEl = targetGroup.querySelector('text');\n if (textEl) {\n makeTextEditable(textEl, targetGroup);\n e.stopPropagation();\n return;\n }\n }\n // Single-click: select and drag (same as selection tool behavior)\n if (targetGroup === selectedElement) {\n startDrag(e);\n } else {\n selectElement(targetGroup);\n startDrag(e);\n }\n } else {\n deselectElement();\n addText(e);\n }\n }\n};\n\nfunction enterEditMode(groupElement) {\n const textEl = groupElement.querySelector('text');\n if (!textEl) return;\n\n // Switch to text tool with property panel (go through store to clear other flags)\n if (window.__sketchStoreApi) {\n window.__sketchStoreApi.setActiveTool('text');\n } else {\n window.isTextToolActive = true;\n window.isSelectionToolActive = false;\n }\n toolExtraPopup();\n\n // Deselect (removes selection feedback) then open editor\n deselectElement();\n makeTextEditable(textEl, groupElement);\n}\n\nconst handleTextMouseMove = function (e) {\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 // Handle cursor changes for text tool\n if (isTextToolActive) {\n const targetGroup = e.target?.closest?.('g[data-type=\"text-group\"]');\n if (targetGroup) {\n svg.style.cursor = 'pointer';\n } else {\n svg.style.cursor = 'crosshair';\n }\n } else if (isSelectionToolActive) {\n const targetGroup = e.target?.closest?.('g[data-type=\"text-group\"]');\n if (targetGroup) {\n svg.style.cursor = 'default';\n }\n }\n\n // Check for frame containment while creating text\n if (isTextToolActive && !isDragging && !isResizing && !isRotating) {\n // Get current mouse position for frame highlighting preview\n const { x, y } = getSVGCoordinates(e);\n \n // Create temporary text bounds for frame checking\n const tempTextBounds = {\n x: x - 50,\n y: y - 20,\n width: 100,\n height: 40\n };\n \n if (typeof shapes !== 'undefined' && Array.isArray(shapes)) {\n shapes.forEach(frame => {\n if (frame.shapeName === 'frame') {\n if (frame.isShapeInFrame(tempTextBounds)) {\n frame.highlightFrame();\n hoveredFrameText = frame;\n } else if (hoveredFrameText === frame) {\n frame.removeHighlight();\n hoveredFrameText = null;\n }\n }\n });\n }\n }\n};\n\nconst handleTextMouseUp = function (e) {\n // Clear frame highlighting when done with text tool operations\n if (hoveredFrameText) {\n hoveredFrameText.removeHighlight();\n hoveredFrameText = null;\n }\n};\n\n// updateAttachedArrows is imported from drawArrow.js\n\n\ntextColorOptions.forEach((span) => {\n span.addEventListener(\"click\", (event) => {\n event.stopPropagation();\n textColorOptions.forEach((el) => el.classList.remove(\"selected\"));\n span.classList.add(\"selected\");\n\n const newColor = span.getAttribute(\"data-id\");\n const oldColor = textColor;\n textColor = newColor;\n\n if (selectedElement) {\n const textElement = selectedElement.querySelector('text');\n if (textElement) {\n const currentColor = textElement.getAttribute('fill');\n\n if (currentColor !== newColor) {\n pushOptionsChangeAction(\n {\n type: 'text',\n element: selectedElement,\n shapeName: 'text'\n },\n {\n color: currentColor,\n font: textElement.getAttribute('font-family'),\n size: textElement.getAttribute('font-size'),\n align: textElement.getAttribute('text-anchor')\n },\n {\n color: newColor,\n font: textElement.getAttribute('font-family'),\n size: textElement.getAttribute('font-size'),\n align: textElement.getAttribute('text-anchor')\n }\n );\n }\n\n textElement.setAttribute('fill', newColor);\n }\n }\n });\n});\n\ntextFontOptions.forEach((span) => {\n span.addEventListener(\"click\", (event) => {\n event.stopPropagation();\n textFontOptions.forEach((el) => el.classList.remove(\"selected\"));\n span.classList.add(\"selected\");\n\n const newFont = span.getAttribute(\"data-id\");\n const oldFont = textFont;\n textFont = newFont;\n\n if (selectedElement) {\n const textElement = selectedElement.querySelector('text');\n if (textElement) {\n const currentFont = textElement.getAttribute('font-family');\n\n if (currentFont !== newFont) {\n pushOptionsChangeAction(\n {\n type: 'text',\n element: selectedElement,\n shapeName: 'text'\n },\n {\n color: textElement.getAttribute('fill'),\n font: currentFont,\n size: textElement.getAttribute('font-size'),\n align: textElement.getAttribute('text-anchor')\n },\n {\n color: textElement.getAttribute('fill'),\n font: newFont,\n size: textElement.getAttribute('font-size'),\n align: textElement.getAttribute('text-anchor')\n }\n );\n }\n\n textElement.setAttribute('font-family', newFont);\n setTimeout(updateSelectionFeedback, 0);\n }\n }\n });\n});\n\ntextSizeOptions.forEach((span) => {\n span.addEventListener(\"click\", (event) => {\n event.stopPropagation();\n textSizeOptions.forEach((el) => el.classList.remove(\"selected\"));\n span.classList.add(\"selected\");\n\n const newSize = span.getAttribute(\"data-id\") + \"px\";\n const oldSize = textSize;\n textSize = newSize;\n\n if (selectedElement) {\n const textElement = selectedElement.querySelector('text');\n if (textElement) {\n const currentSize = textElement.getAttribute('font-size');\n\n if (currentSize !== newSize) {\n pushOptionsChangeAction(\n {\n type: 'text',\n element: selectedElement,\n shapeName: 'text'\n },\n {\n color: textElement.getAttribute('fill'),\n font: textElement.getAttribute('font-family'),\n size: currentSize,\n align: textElement.getAttribute('text-anchor')\n },\n {\n color: textElement.getAttribute('fill'),\n font: textElement.getAttribute('font-family'),\n size: newSize,\n align: textElement.getAttribute('text-anchor')\n }\n );\n }\n\n textElement.setAttribute('font-size', newSize);\n setTimeout(updateSelectionFeedback, 0);\n }\n }\n });\n});\n\ntextAlignOptions.forEach((span) => {\n span.addEventListener(\"click\", (event) => {\n event.stopPropagation();\n textAlignOptions.forEach((el) => el.classList.remove(\"selected\"));\n span.classList.add(\"selected\");\n\n const newAlign = span.getAttribute(\"data-id\");\n const oldAlign = textAlign;\n textAlign = newAlign;\n\n if (selectedElement) {\n const textElement = selectedElement.querySelector('text');\n if (textElement) {\n const currentAnchor = textElement.getAttribute('text-anchor');\n let newAnchor = 'start';\n if (newAlign === 'center') newAnchor = 'middle';\n else if (newAlign === 'right') newAnchor = 'end';\n\n if (currentAnchor !== newAnchor) {\n pushOptionsChangeAction(\n {\n type: 'text',\n element: selectedElement,\n shapeName: 'text'\n },\n {\n color: textElement.getAttribute('fill'),\n font: textElement.getAttribute('font-family'),\n size: textElement.getAttribute('font-size'),\n align: currentAnchor\n },\n {\n color: textElement.getAttribute('fill'),\n font: textElement.getAttribute('font-family'),\n size: textElement.getAttribute('font-size'),\n align: newAnchor\n }\n );\n }\n\n textElement.setAttribute('text-anchor', newAnchor);\n setTimeout(updateSelectionFeedback, 0);\n }\n }\n });\n});\n\n\n// --- Code/Text Toggle Handler ---\nconst textCodeOptions = document.querySelectorAll(\".textCodeSpan\");\nconst languageSelector = document.getElementById(\"textLanguageSelector\");\nconst codeLanguageSelect = document.getElementById(\"codeLanguageSelect\");\n\ntextCodeOptions.forEach((span) => {\n span.addEventListener(\"click\", (event) => {\n event.stopPropagation();\n textCodeOptions.forEach((el) => el.classList.remove(\"selected\"));\n span.classList.add(\"selected\");\n\n const isCodeMode = span.getAttribute(\"data-id\") === \"true\";\n isTextInCodeMode = isCodeMode;\n\n // Show/hide language selector\n if (languageSelector) {\n languageSelector.classList.toggle(\"hidden\", !isCodeMode);\n }\n\n // Update tool flags\n if (isTextToolActive) {\n isCodeToolActive = isCodeMode;\n }\n\n // If a shape is selected, convert it\n if (isCodeMode && selectedElement) {\n // Convert text \u2192 code\n convertTextToCode(selectedElement);\n } else if (!isCodeMode && getSelectedCodeBlock()) {\n // Convert code \u2192 text\n convertCodeToText(getSelectedCodeBlock());\n }\n });\n});\n\n// Language selector handler\nif (codeLanguageSelect) {\n codeLanguageSelect.addEventListener(\"change\", (event) => {\n const lang = event.target.value;\n setCodeLanguage(lang);\n\n // If a code block is selected, re-highlight it with the new language\n const selectedCode = getSelectedCodeBlock();\n if (selectedCode) {\n const codeElement = selectedCode.querySelector('text');\n if (codeElement) {\n codeElement.setAttribute(\"data-language\", lang);\n // Re-render with new language highlighting\n const content = extractTextFromCodeElement(codeElement);\n while (codeElement.firstChild) {\n codeElement.removeChild(codeElement.firstChild);\n }\n const highlighted = applySyntaxHighlightingToSVG(content, lang);\n createHighlightedSVGText(highlighted, codeElement);\n updateCodeBackground(selectedCode, codeElement);\n }\n }\n });\n}\n\nfunction convertTextToCode(textGroupElement) {\n const textElement = textGroupElement.querySelector('text');\n if (!textElement) return;\n\n // Get text content\n let textContent = \"\";\n const tspans = textElement.querySelectorAll('tspan');\n if (tspans.length > 0) {\n tspans.forEach((tspan, index) => {\n textContent += tspan.textContent;\n if (index < tspans.length - 1) textContent += \"\\n\";\n });\n } else {\n textContent = textElement.textContent || \"\";\n }\n\n // Get position from transform\n const currentTransform = textGroupElement.transform.baseVal.consolidate();\n const tx = currentTransform ? currentTransform.matrix.e : 0;\n const ty = currentTransform ? currentTransform.matrix.f : 0;\n const fontSize = textElement.getAttribute('font-size') || \"25px\";\n const color = textElement.getAttribute('fill') || \"#fff\";\n\n // Find and remove old TextShape from shapes array\n let oldTextShape = null;\n if (typeof shapes !== 'undefined' && Array.isArray(shapes)) {\n oldTextShape = shapes.find(s => s.shapeName === 'text' && s.group === textGroupElement);\n if (oldTextShape) {\n const idx = shapes.indexOf(oldTextShape);\n if (idx !== -1) shapes.splice(idx, 1);\n }\n }\n\n // Deselect current text\n deselectElement();\n\n // Remove old text group from SVG\n if (textGroupElement.parentNode) {\n textGroupElement.parentNode.removeChild(textGroupElement);\n }\n\n // Create new code block\n const gElement = document.createElementNS(\"http://www.w3.org/2000/svg\", \"g\");\n gElement.setAttribute(\"data-type\", \"code-group\");\n gElement.setAttribute(\"transform\", `translate(${tx}, ${ty})`);\n\n const backgroundRect = document.createElementNS(\"http://www.w3.org/2000/svg\", \"rect\");\n backgroundRect.setAttribute(\"class\", \"code-background\");\n backgroundRect.setAttribute(\"x\", -10);\n backgroundRect.setAttribute(\"y\", -10);\n backgroundRect.setAttribute(\"width\", 300);\n backgroundRect.setAttribute(\"height\", 60);\n backgroundRect.setAttribute(\"fill\", \"#161b22\");\n backgroundRect.setAttribute(\"stroke\", \"#30363d\");\n backgroundRect.setAttribute(\"stroke-width\", \"1\");\n backgroundRect.setAttribute(\"rx\", \"6\");\n backgroundRect.setAttribute(\"ry\", \"6\");\n gElement.appendChild(backgroundRect);\n\n const codeElement = document.createElementNS(\"http://www.w3.org/2000/svg\", \"text\");\n codeElement.setAttribute(\"x\", 0);\n codeElement.setAttribute(\"y\", 0);\n codeElement.setAttribute(\"fill\", color);\n codeElement.setAttribute(\"font-size\", fontSize);\n codeElement.setAttribute(\"font-family\", \"lixCode\");\n codeElement.setAttribute(\"text-anchor\", \"start\");\n codeElement.setAttribute(\"cursor\", \"default\");\n codeElement.setAttribute(\"white-space\", \"pre\");\n codeElement.setAttribute(\"dominant-baseline\", \"hanging\");\n codeElement.setAttribute(\"data-language\", getCodeLanguage());\n codeElement.setAttribute(\"data-type\", \"code\");\n\n const shapeID = `code-${String(Date.now()).slice(0, 8)}-${Math.floor(Math.random() * 10000)}`;\n gElement.setAttribute(\"id\", shapeID);\n gElement.setAttribute(\"data-x\", tx);\n gElement.setAttribute(\"data-y\", ty);\n codeElement.setAttribute(\"id\", `${shapeID}-code`);\n gElement.appendChild(codeElement);\n svg.appendChild(gElement);\n\n // Apply syntax highlighting and add content\n if (textContent.trim()) {\n const lang = getCodeLanguage();\n const highlighted = applySyntaxHighlightingToSVG(textContent, lang);\n createHighlightedSVGText(highlighted, codeElement);\n updateCodeBackground(gElement, codeElement);\n }\n\n // Create CodeShape wrapper\n const codeShape = wrapCodeElement(gElement);\n if (typeof shapes !== 'undefined' && Array.isArray(shapes)) {\n shapes.push(codeShape);\n }\n\n // Push undo action for mode conversion\n pushModeConvertAction(oldTextShape, textGroupElement, 'text', codeShape, gElement, 'code');\n\n // Select the new code block\n selectCodeBlock(gElement);\n}\n\nfunction convertCodeToText(codeGroupElement) {\n const codeElement = codeGroupElement.querySelector('text');\n if (!codeElement) return;\n\n // Get text content\n const textContent = extractTextFromCodeElement(codeElement);\n\n // Get position from transform\n const currentTransform = codeGroupElement.transform.baseVal.consolidate();\n const tx = currentTransform ? currentTransform.matrix.e : 0;\n const ty = currentTransform ? currentTransform.matrix.f : 0;\n const fontSize = codeElement.getAttribute('font-size') || \"30px\";\n const color = codeElement.getAttribute('fill') || \"#fff\";\n\n // Find and remove old CodeShape from shapes array\n let oldCodeShape = null;\n if (typeof shapes !== 'undefined' && Array.isArray(shapes)) {\n oldCodeShape = shapes.find(s => s.shapeName === 'code' && s.group === codeGroupElement);\n if (oldCodeShape) {\n const idx = shapes.indexOf(oldCodeShape);\n if (idx !== -1) shapes.splice(idx, 1);\n }\n }\n\n // Deselect current code block\n deselectCodeBlock();\n\n // Remove old code group from SVG\n if (codeGroupElement.parentNode) {\n codeGroupElement.parentNode.removeChild(codeGroupElement);\n }\n\n // Create new text shape\n const gElement = document.createElementNS(\"http://www.w3.org/2000/svg\", \"g\");\n gElement.setAttribute(\"data-type\", \"text-group\");\n gElement.setAttribute(\"transform\", `translate(${tx}, ${ty})`);\n\n const textElement = document.createElementNS(\"http://www.w3.org/2000/svg\", \"text\");\n textElement.setAttribute(\"x\", 0);\n textElement.setAttribute(\"y\", 0);\n textElement.setAttribute(\"fill\", color);\n textElement.setAttribute(\"font-size\", fontSize);\n textElement.setAttribute(\"font-family\", textFont);\n textElement.setAttribute(\"text-anchor\", \"start\");\n textElement.setAttribute(\"cursor\", \"default\");\n textElement.setAttribute(\"white-space\", \"pre\");\n textElement.setAttribute(\"dominant-baseline\", \"hanging\");\n textElement.setAttribute(\"data-type\", \"text\");\n\n const shapeID = `text-${String(Date.now()).slice(0, 8)}-${Math.floor(Math.random() * 10000)}`;\n gElement.setAttribute(\"id\", shapeID);\n gElement.setAttribute(\"data-x\", tx);\n gElement.setAttribute(\"data-y\", ty);\n textElement.setAttribute(\"id\", `${shapeID}-text`);\n gElement.appendChild(textElement);\n svg.appendChild(gElement);\n\n // Add text content as tspans\n if (textContent.trim()) {\n const lines = textContent.split(\"\\n\");\n const x = textElement.getAttribute(\"x\") || 0;\n lines.forEach((line, index) => {\n const tspan = document.createElementNS(\"http://www.w3.org/2000/svg\", \"tspan\");\n tspan.setAttribute(\"x\", x);\n tspan.setAttribute(\"dy\", index === 0 ? \"0\" : \"1.2em\");\n tspan.textContent = line || \" \";\n textElement.appendChild(tspan);\n });\n }\n\n // Create TextShape wrapper\n const textShape = wrapTextElement(gElement);\n if (typeof shapes !== 'undefined' && Array.isArray(shapes)) {\n shapes.push(textShape);\n }\n\n // Push undo action for mode conversion\n pushModeConvertAction(oldCodeShape, codeGroupElement, 'code', textShape, gElement, 'text');\n\n // Select the new text shape\n selectElement(gElement);\n}\n\nfunction pushModeConvertAction(oldShape, oldElement, oldType, newShape, newElement, newType) {\n pushCreateAction({\n type: 'modeConvert',\n oldShape: oldShape,\n oldElement: oldElement,\n oldType: oldType,\n newShape: newShape,\n newElement: newElement,\n newType: newType,\n element: newShape,\n shapeName: newType\n });\n}\n\n// Update toggle state when a shape is selected\nfunction updateCodeToggleForShape(shapeName) {\n const isCode = shapeName === 'code';\n textCodeOptions.forEach(el => el.classList.remove(\"selected\"));\n textCodeOptions.forEach(el => {\n if ((el.getAttribute(\"data-id\") === \"true\") === isCode) {\n el.classList.add(\"selected\");\n }\n });\n if (languageSelector) {\n languageSelector.classList.toggle(\"hidden\", !isCode);\n }\n // Update the language dropdown to match the selected code block\n if (isCode && codeLanguageSelect) {\n const selectedCode = getSelectedCodeBlock();\n if (selectedCode) {\n const codeEl = selectedCode.querySelector('text');\n const lang = codeEl?.getAttribute(\"data-language\") || \"auto\";\n codeLanguageSelect.value = lang;\n }\n }\n}\n\n// React sidebar bridge \u2014 update currently selected text/code shape\nwindow.updateSelectedTextStyle = function(changes) {\n const el = selectedElement || (window.currentShape && window.currentShape.shapeName === 'text' ? window.currentShape.group : null);\n if (!el) return;\n const textElement = el.querySelector('text');\n if (!textElement) return;\n\n if (changes.color) {\n textElement.setAttribute('fill', changes.color);\n textColor = changes.color;\n }\n if (changes.font) {\n textElement.setAttribute('font-family', changes.font);\n textFont = changes.font;\n }\n if (changes.fontSize) {\n textElement.setAttribute('font-size', changes.fontSize);\n textSize = changes.fontSize;\n }\n};\n\n// Expose select/deselect for external callers (Selection.js, TextShape.selectShape)\nwindow.__deselectTextElement = deselectElement;\nwindow.__selectTextElement = selectElement;\n\n// React sidebar bridge \u2014 text \u2194 code conversion\nwindow.__convertTextToCode = function() {\n if (selectedElement && selectedElement.getAttribute('data-type') === 'text-group') {\n convertTextToCode(selectedElement);\n }\n};\nwindow.__convertCodeToText = function() {\n // Try codeTool's selectedCodeBlock first, then check textTool's selectedElement\n let codeBlock = getSelectedCodeBlock();\n if (!codeBlock && selectedElement && selectedElement.getAttribute('data-type') === 'code-group') {\n codeBlock = selectedElement;\n }\n if (codeBlock) {\n convertCodeToText(codeBlock);\n }\n};\nwindow.__setCodeLanguage = function(lang) {\n setCodeLanguage(lang);\n // Re-highlight selected code block with new language\n const selectedCode = getSelectedCodeBlock();\n if (selectedCode) {\n const codeElement = selectedCode.querySelector('text');\n if (codeElement) {\n codeElement.setAttribute('data-language', lang);\n const textContent = extractTextFromCodeElement(codeElement);\n // Clear and re-highlight\n while (codeElement.firstChild) codeElement.removeChild(codeElement.firstChild);\n const highlighted = applySyntaxHighlightingToSVG(textContent, lang);\n createHighlightedSVGText(highlighted, codeElement);\n updateCodeBackground(selectedCode, codeElement);\n }\n }\n};\n\nexport { handleTextMouseDown, handleTextMouseMove, handleTextMouseUp, updateCodeToggleForShape, deselectElement as deselectTextElement, enterEditMode };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,SAAS,iBAAiB;AAAE,MAAI,OAAO,aAAa,YAAa,QAAO;AAAQ,SAAO,SAAS,QAAQ,SAAS,KAAK,UAAU,SAAS,YAAY,IAAI,SAAS;AAAW;AAe7K,IAAI,WAAW;AACf,IAAI,WAAW;AACf,IAAI,YAAY;AAChB,IAAI,YAAY;AAEhB,IAAI,mBAAmB,SAAS,iBAAiB,gBAAgB;AACjE,IAAI,kBAAkB,SAAS,iBAAiB,eAAe;AAC/D,IAAI,kBAAkB,SAAS,iBAAiB,eAAe;AAC/D,IAAI,mBAAmB,SAAS,iBAAiB,gBAAgB;AAEjE,IAAI,kBAAkB;AACtB,IAAI,eAAe;AACnB,IAAI,gBAAgB,CAAC;AACrB,IAAI;AAAJ,IAAiB;AACjB,IAAI,aAAa;AACjB,IAAI,aAAa;AACjB,IAAI,sBAAsB;AAC1B,IAAI,YAAY;AAChB,IAAI,gBAAgB;AACpB,IAAI,aAAa;AACjB,IAAI,aAAa;AACjB,IAAI,qBAAqB;AACzB,IAAI,yBAAyB;AAC7B,IAAI,2BAA2B;AAC/B,IAAI,iBAAiB;AACrB,IAAI,iBAAiB;AACrB,IAAI,0BAA0B;AAG9B,IAAI,+BAA+B;AACnC,IAAI,mBAAmB;AAEvB,kBAAkB,iBAAiB,yBAAyB,GAAG;AAG/D,SAAS,wBAAwB;AAC7B,MAAI,OAAO,kBAAkB;AACzB,WAAO,iBAAiB,cAAc,UAAU,EAAE,WAAW,KAAK,CAAC;AAAA,EACvE,OAAO;AACH,WAAO,wBAAwB;AAAA,EACnC;AACJ;AAIA,SAAS,gBAAgB,cAAc;AACnC,QAAM,YAAY,IAAI,UAAU,YAAY;AAC5C,SAAO;AACX;AA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