@elixpo/lixsketch 5.4.7 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react/AIRenderer-M4LMJ66J.js +1105 -0
- package/dist/react/AIRenderer-M4LMJ66J.js.map +7 -0
- package/dist/react/Arrow-BJDAXPMH.js +8 -0
- package/dist/react/Arrow-BJDAXPMH.js.map +7 -0
- package/dist/react/Circle-KPG7TKIX.js +8 -0
- package/dist/react/Circle-KPG7TKIX.js.map +7 -0
- package/dist/react/CodeShape-K4DIZAIV.js +8 -0
- package/dist/react/CodeShape-K4DIZAIV.js.map +7 -0
- package/dist/react/CopyPaste-4CKJRHJ3.js +569 -0
- package/dist/react/CopyPaste-4CKJRHJ3.js.map +7 -0
- package/dist/react/EraserTrail-PA6IQLQN.js +20 -0
- package/dist/react/EraserTrail-PA6IQLQN.js.map +7 -0
- package/dist/react/EventDispatcher-SRFH6LQZ.js +463 -0
- package/dist/react/EventDispatcher-SRFH6LQZ.js.map +7 -0
- package/dist/react/Frame-6UR5XPAX.js +10 -0
- package/dist/react/Frame-6UR5XPAX.js.map +7 -0
- package/dist/react/FreehandStroke-CK24NUT3.js +8 -0
- package/dist/react/FreehandStroke-CK24NUT3.js.map +7 -0
- package/dist/react/GraphEngine-QE5B2PMR.js +340 -0
- package/dist/react/GraphEngine-QE5B2PMR.js.map +7 -0
- package/dist/react/GraphMathParser-2WMTY4IE.js +10 -0
- package/dist/react/GraphMathParser-2WMTY4IE.js.map +7 -0
- package/dist/react/IconShape-KMIA6T2H.js +10 -0
- package/dist/react/IconShape-KMIA6T2H.js.map +7 -0
- package/dist/react/ImageShape-CHHGBXUQ.js +10 -0
- package/dist/react/ImageShape-CHHGBXUQ.js.map +7 -0
- package/dist/react/LayerOrder-XCHF4MSS.js +66 -0
- package/dist/react/LayerOrder-XCHF4MSS.js.map +7 -0
- package/dist/react/Line-2KOQEEGA.js +10 -0
- package/dist/react/Line-2KOQEEGA.js.map +7 -0
- package/dist/react/LixScriptParser-JYWJX375.js +1033 -0
- package/dist/react/LixScriptParser-JYWJX375.js.map +7 -0
- package/dist/react/MermaidFlowchartRenderer-4QBAZ5MB.js +412 -0
- package/dist/react/MermaidFlowchartRenderer-4QBAZ5MB.js.map +7 -0
- package/dist/react/MermaidSequenceParser-UKG2NSZY.js +8 -0
- package/dist/react/MermaidSequenceParser-UKG2NSZY.js.map +7 -0
- package/dist/react/MermaidSequenceRenderer-HPLHY5II.js +387 -0
- package/dist/react/MermaidSequenceRenderer-HPLHY5II.js.map +7 -0
- package/dist/react/Rectangle-6FE7RN6W.js +8 -0
- package/dist/react/Rectangle-6FE7RN6W.js.map +7 -0
- package/dist/react/ResizeCode-WAMDTKSW.js +2 -0
- package/dist/react/ResizeCode-WAMDTKSW.js.map +7 -0
- package/dist/react/ResizeShapes-LKEQTITP.js +250 -0
- package/dist/react/ResizeShapes-LKEQTITP.js.map +7 -0
- package/dist/react/SceneSerializer-4U4B24JM.js +739 -0
- package/dist/react/SceneSerializer-4U4B24JM.js.map +7 -0
- package/dist/react/Selection-VVUHY5YJ.js +34 -0
- package/dist/react/Selection-VVUHY5YJ.js.map +7 -0
- package/dist/react/SketchEngine-YA4RG3KX.js +413 -0
- package/dist/react/SketchEngine-YA4RG3KX.js.map +7 -0
- package/dist/react/TextShape-54ZJ66E3.js +8 -0
- package/dist/react/TextShape-54ZJ66E3.js.map +7 -0
- package/dist/react/UndoRedo-M2JZUBKN.js +30 -0
- package/dist/react/UndoRedo-M2JZUBKN.js.map +7 -0
- package/dist/react/ZoomPan-U3TXC5AJ.js +186 -0
- package/dist/react/ZoomPan-U3TXC5AJ.js.map +7 -0
- package/dist/react/arrowTool-CWEMIRXK.js +17 -0
- package/dist/react/arrowTool-CWEMIRXK.js.map +7 -0
- package/dist/react/boxicons-5JNJQPUP.woff +0 -0
- package/dist/react/boxicons-6NVWQSCQ.eot +0 -0
- package/dist/react/boxicons-AQ5N6WP7.woff2 +0 -0
- package/dist/react/boxicons-GDR4JU3X.ttf +0 -0
- package/dist/react/boxicons-NNFHLMOR.svg +1660 -0
- package/dist/react/chunk-2OQXI7QB.js +564 -0
- package/dist/react/chunk-2OQXI7QB.js.map +7 -0
- package/dist/react/chunk-5OUBTHHO.js +187 -0
- package/dist/react/chunk-5OUBTHHO.js.map +7 -0
- package/dist/react/chunk-6PFXZKL2.js +628 -0
- package/dist/react/chunk-6PFXZKL2.js.map +7 -0
- package/dist/react/chunk-6SFNWGGZ.js +453 -0
- package/dist/react/chunk-6SFNWGGZ.js.map +7 -0
- package/dist/react/chunk-7TZSIR6V.js +210 -0
- package/dist/react/chunk-7TZSIR6V.js.map +7 -0
- package/dist/react/chunk-AJAZC37E.js +662 -0
- package/dist/react/chunk-AJAZC37E.js.map +7 -0
- package/dist/react/chunk-BU4D2WYQ.js +1213 -0
- package/dist/react/chunk-BU4D2WYQ.js.map +7 -0
- package/dist/react/chunk-BZE4CEBG.js +747 -0
- package/dist/react/chunk-BZE4CEBG.js.map +7 -0
- package/dist/react/chunk-CB2RANCB.js +212 -0
- package/dist/react/chunk-CB2RANCB.js.map +7 -0
- package/dist/react/chunk-DNAG7ML6.js +128 -0
- package/dist/react/chunk-DNAG7ML6.js.map +7 -0
- package/dist/react/chunk-HZWLPXFN.js +198 -0
- package/dist/react/chunk-HZWLPXFN.js.map +7 -0
- package/dist/react/chunk-I6HCCIXB.js +572 -0
- package/dist/react/chunk-I6HCCIXB.js.map +7 -0
- package/dist/react/chunk-IZ5OGWGW.js +235 -0
- package/dist/react/chunk-IZ5OGWGW.js.map +7 -0
- package/dist/react/chunk-JJCJNLNN.js +1490 -0
- package/dist/react/chunk-JJCJNLNN.js.map +7 -0
- package/dist/react/chunk-JQ3IRFDP.js +222 -0
- package/dist/react/chunk-JQ3IRFDP.js.map +7 -0
- package/dist/react/chunk-L5OARZJ7.js +1134 -0
- package/dist/react/chunk-L5OARZJ7.js.map +7 -0
- package/dist/react/chunk-LHRTXNVE.js +1600 -0
- package/dist/react/chunk-LHRTXNVE.js.map +7 -0
- package/dist/react/chunk-Q2GA4MBZ.js +1653 -0
- package/dist/react/chunk-Q2GA4MBZ.js.map +7 -0
- package/dist/react/chunk-QNSE5BAY.js +519 -0
- package/dist/react/chunk-QNSE5BAY.js.map +7 -0
- package/dist/react/chunk-QXFBG7OM.js +191 -0
- package/dist/react/chunk-QXFBG7OM.js.map +7 -0
- package/dist/react/chunk-T6ZVV5ZO.js +714 -0
- package/dist/react/chunk-T6ZVV5ZO.js.map +7 -0
- package/dist/react/chunk-URB6MY46.js +974 -0
- package/dist/react/chunk-URB6MY46.js.map +7 -0
- package/dist/react/chunk-VN62KLOC.js +931 -0
- package/dist/react/chunk-VN62KLOC.js.map +7 -0
- package/dist/react/chunk-VQVEPJSA.js +158 -0
- package/dist/react/chunk-VQVEPJSA.js.map +7 -0
- package/dist/react/chunk-XISEAGBV.js +1632 -0
- package/dist/react/chunk-XISEAGBV.js.map +7 -0
- package/dist/react/chunk-YKJUBFHE.js +575 -0
- package/dist/react/chunk-YKJUBFHE.js.map +7 -0
- package/dist/react/circleTool-NUATSEI2.js +14 -0
- package/dist/react/circleTool-NUATSEI2.js.map +7 -0
- package/dist/react/codeTool-MHCB2FNB.js +38 -0
- package/dist/react/codeTool-MHCB2FNB.js.map +7 -0
- package/dist/react/eraserTool-2GS2LQCS.js +103 -0
- package/dist/react/eraserTool-2GS2LQCS.js.map +7 -0
- package/dist/react/frameTool-PWVKKXSP.js +14 -0
- package/dist/react/frameTool-PWVKKXSP.js.map +7 -0
- package/dist/react/freehandTool-SLYGASVP.js +14 -0
- package/dist/react/freehandTool-SLYGASVP.js.map +7 -0
- package/dist/react/iconTool-GPZ7O7NH.js +18 -0
- package/dist/react/iconTool-GPZ7O7NH.js.map +7 -0
- package/dist/react/imageTool-D5R4XGEU.js +15 -0
- package/dist/react/imageTool-D5R4XGEU.js.map +7 -0
- package/dist/react/index.js +5342 -0
- package/dist/react/index.js.map +7 -0
- package/dist/react/laserTool-XVMV63AV.js +239 -0
- package/dist/react/laserTool-XVMV63AV.js.map +7 -0
- package/dist/react/lineTool-WNI5EMZ5.js +14 -0
- package/dist/react/lineTool-WNI5EMZ5.js.map +7 -0
- package/dist/react/lixCode-OJMVUXXI.ttf +0 -0
- package/dist/react/lixDefault-JEAPAUJL.ttf +0 -0
- package/dist/react/lixFancy-BPXYM5CQ.ttf +0 -0
- package/dist/react/lixFont-CPKEUDVM.woff2 +0 -0
- package/dist/react/rectangleTool-U7DZ6ZTA.js +14 -0
- package/dist/react/rectangleTool-U7DZ6ZTA.js.map +7 -0
- package/dist/react/styles.css +6627 -0
- package/dist/react/textTool-M7S6F3VC.js +21 -0
- package/dist/react/textTool-M7S6F3VC.js.map +7 -0
- package/package.json +39 -5
- package/src/EngineShortcuts.js +83 -27
- package/src/core/AIRenderer.js +30 -18
- package/src/core/GraphEngine.js +64 -41
- package/src/core/MermaidFlowchartRenderer.js +153 -88
- package/src/core/MermaidSequenceRenderer.js +168 -93
- package/src/core/SceneSerializer.js +86 -2
- package/src/core/Selection.js +119 -19
- package/src/core/UndoRedo.js +82 -15
- package/src/core/ZoomPan.js +15 -5
- package/src/index.js +14 -1
- package/src/react/LixSketchCanvas.jsx +347 -0
- package/src/react/components/AppMenu.jsx +475 -0
- package/src/react/components/Footer.jsx +85 -0
- package/src/react/components/Toolbar.jsx +140 -0
- package/src/react/components/canvas/CanvasLoadingOverlay.jsx +76 -0
- package/src/react/components/canvas/ContextMenu.jsx +466 -0
- package/src/react/components/canvas/FindBar.jsx +177 -0
- package/src/react/components/canvas/ImageSourcePicker.jsx +133 -0
- package/src/react/components/canvas/MultiSelectActions.jsx +120 -0
- package/src/react/components/canvas/SVGCanvas.jsx +145 -0
- package/src/react/components/canvas/SaveStatusIndicator.jsx +29 -0
- package/src/react/components/modals/CanvasPropertiesModal.jsx +358 -0
- package/src/react/components/modals/CommandPalette.jsx +307 -0
- package/src/react/components/modals/ExportImageModal.jsx +287 -0
- package/src/react/components/modals/GraphModal.jsx +174 -0
- package/src/react/components/modals/HelpModal.jsx +208 -0
- package/src/react/components/modals/LixScriptModal.jsx +130 -0
- package/src/react/components/modals/ShortcutsModal.jsx +125 -0
- package/src/react/components/sidebars/ArrowSidebar.jsx +173 -0
- package/src/react/components/sidebars/CircleSidebar.jsx +134 -0
- package/src/react/components/sidebars/FrameSidebar.jsx +263 -0
- package/src/react/components/sidebars/IconSidebar.jsx +279 -0
- package/src/react/components/sidebars/ImageSidebar.jsx +69 -0
- package/src/react/components/sidebars/LineSidebar.jsx +109 -0
- package/src/react/components/sidebars/PaintbrushSidebar.jsx +119 -0
- package/src/react/components/sidebars/RectangleSidebar.jsx +165 -0
- package/src/react/components/sidebars/ShapeSidebar.jsx +130 -0
- package/src/react/components/sidebars/TextSidebar.jsx +174 -0
- package/src/react/hooks/inertStores.js +58 -0
- package/src/react/hooks/useSketchEngine.js +76 -0
- package/src/react/hooks/useTranslation.js +92 -0
- package/src/react/index.js +41 -0
- package/src/react/store/useSketchStore.js +234 -0
- package/src/react/store/useUIStore.js +196 -0
- package/src/react/styles/arrowSidebar.css +263 -0
- package/src/react/styles/canvasStroke.css +47 -0
- package/src/react/styles/canvasTools.css +769 -0
- package/src/react/styles/circleSidebar.css +206 -0
- package/src/react/styles/fonts/fonts.css +29 -0
- package/src/react/styles/fonts/lixCode.ttf +0 -0
- package/src/react/styles/fonts/lixDefault.ttf +0 -0
- package/src/react/styles/fonts/lixDocs.ttf +0 -0
- package/src/react/styles/fonts/lixFancy.ttf +0 -0
- package/src/react/styles/fonts/lixFont.woff2 +0 -0
- package/src/react/styles/lineSidebar.css +207 -0
- package/src/react/styles/paintbrushSidebar.css +247 -0
- package/src/react/styles/squareSidebar.css +206 -0
- package/src/react/styles/writeText.css +149 -0
- package/src/react/styles.css +175 -0
- package/src/react/toolsEnum.js +20 -0
- package/src/react/utils/toast.js +18 -0
- package/src/shapes/Frame.js +7 -1
- package/src/shapes/Line.js +11 -5
- package/src/tools/arrowTool.js +30 -4
- package/src/tools/circleTool.js +33 -9
- package/src/tools/codeTool.js +5 -3
- package/src/tools/frameTool.js +47 -7
- package/src/tools/freehandTool.js +12 -4
- package/src/tools/iconTool.js +7 -1
- package/src/tools/imageTool.js +7 -1
- package/src/tools/lineTool.js +27 -3
- package/src/tools/rectangleTool.js +45 -8
- package/src/tools/textTool.js +23 -6
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
getCurrentSelectedElement,
|
|
4
|
+
pushCreateAction,
|
|
5
|
+
pushCreateActionWithAttachments,
|
|
6
|
+
pushDeleteAction,
|
|
7
|
+
pushDeleteActionWithAttachments,
|
|
8
|
+
pushFrameAttachmentAction,
|
|
9
|
+
pushOptionsChangeAction,
|
|
10
|
+
pushTransformAction,
|
|
11
|
+
redo,
|
|
12
|
+
setTextReferences,
|
|
13
|
+
undo,
|
|
14
|
+
updateSelectedElement
|
|
15
|
+
} from "./chunk-L5OARZJ7.js";
|
|
16
|
+
export {
|
|
17
|
+
getCurrentSelectedElement,
|
|
18
|
+
pushCreateAction,
|
|
19
|
+
pushCreateActionWithAttachments,
|
|
20
|
+
pushDeleteAction,
|
|
21
|
+
pushDeleteActionWithAttachments,
|
|
22
|
+
pushFrameAttachmentAction,
|
|
23
|
+
pushOptionsChangeAction,
|
|
24
|
+
pushTransformAction,
|
|
25
|
+
redo,
|
|
26
|
+
setTextReferences,
|
|
27
|
+
undo,
|
|
28
|
+
updateSelectedElement
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=UndoRedo-M2JZUBKN.js.map
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/core/ZoomPan.js
|
|
4
|
+
var scrollRate = 50;
|
|
5
|
+
function updateZoomDisplay() {
|
|
6
|
+
zoomPercentSpan.innerText = Math.round(currentZoom * 100) + "%";
|
|
7
|
+
}
|
|
8
|
+
function updateViewBox(anchorX = null, anchorY = null) {
|
|
9
|
+
const width = window.innerWidth;
|
|
10
|
+
const height = window.innerHeight;
|
|
11
|
+
const scaledWidth = width / currentZoom;
|
|
12
|
+
const scaledHeight = height / currentZoom;
|
|
13
|
+
let centerX, centerY;
|
|
14
|
+
if (anchorX === null || anchorY === null) {
|
|
15
|
+
centerX = currentViewBox.x + currentViewBox.width / 2;
|
|
16
|
+
centerY = currentViewBox.y + currentViewBox.height / 2;
|
|
17
|
+
} else {
|
|
18
|
+
centerX = anchorX;
|
|
19
|
+
centerY = anchorY;
|
|
20
|
+
}
|
|
21
|
+
const viewBoxX = centerX - scaledWidth / 2;
|
|
22
|
+
const viewBoxY = centerY - scaledHeight / 2;
|
|
23
|
+
freehandCanvas.setAttribute(
|
|
24
|
+
"viewBox",
|
|
25
|
+
`${viewBoxX} ${viewBoxY} ${scaledWidth} ${scaledHeight}`
|
|
26
|
+
);
|
|
27
|
+
currentViewBox.x = viewBoxX;
|
|
28
|
+
currentViewBox.y = viewBoxY;
|
|
29
|
+
currentViewBox.width = scaledWidth;
|
|
30
|
+
currentViewBox.height = scaledHeight;
|
|
31
|
+
}
|
|
32
|
+
zoomInBtn.addEventListener("click", function() {
|
|
33
|
+
currentZoom *= 1.1;
|
|
34
|
+
if (currentZoom > maxScale) currentZoom = maxScale;
|
|
35
|
+
updateViewBox();
|
|
36
|
+
updateZoomDisplay();
|
|
37
|
+
});
|
|
38
|
+
zoomOutBtn.addEventListener("click", function() {
|
|
39
|
+
currentZoom /= 1.1;
|
|
40
|
+
if (currentZoom < minScale) currentZoom = minScale;
|
|
41
|
+
updateViewBox();
|
|
42
|
+
updateZoomDisplay();
|
|
43
|
+
});
|
|
44
|
+
window.zoomFromCenter = function(direction) {
|
|
45
|
+
if (direction > 0) {
|
|
46
|
+
currentZoom *= 1.1;
|
|
47
|
+
if (currentZoom > maxScale) currentZoom = maxScale;
|
|
48
|
+
} else {
|
|
49
|
+
currentZoom /= 1.1;
|
|
50
|
+
if (currentZoom < minScale) currentZoom = minScale;
|
|
51
|
+
}
|
|
52
|
+
updateViewBox();
|
|
53
|
+
updateZoomDisplay();
|
|
54
|
+
if (window.__sketchStoreApi && window.__sketchStoreApi.setZoom) {
|
|
55
|
+
window.__sketchStoreApi.setZoom(currentZoom);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
window.zoomReset = function() {
|
|
59
|
+
const cx = currentViewBox.x + currentViewBox.width / 2;
|
|
60
|
+
const cy = currentViewBox.y + currentViewBox.height / 2;
|
|
61
|
+
currentZoom = 1;
|
|
62
|
+
const rect = freehandCanvas.getBoundingClientRect();
|
|
63
|
+
const vbW = rect.width || window.innerWidth;
|
|
64
|
+
const vbH = rect.height || window.innerHeight;
|
|
65
|
+
currentViewBox.x = cx - vbW / 2;
|
|
66
|
+
currentViewBox.y = cy - vbH / 2;
|
|
67
|
+
currentViewBox.width = vbW;
|
|
68
|
+
currentViewBox.height = vbH;
|
|
69
|
+
freehandCanvas.setAttribute(
|
|
70
|
+
"viewBox",
|
|
71
|
+
`${currentViewBox.x} ${currentViewBox.y} ${vbW} ${vbH}`
|
|
72
|
+
);
|
|
73
|
+
updateZoomDisplay();
|
|
74
|
+
if (window.__sketchStoreApi && window.__sketchStoreApi.setZoom) {
|
|
75
|
+
window.__sketchStoreApi.setZoom(1);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
freehandCanvas.addEventListener("wheel", function(e) {
|
|
79
|
+
if (!e.ctrlKey) return;
|
|
80
|
+
e.preventDefault();
|
|
81
|
+
const delta = e.deltaY > 0 ? -0.1 : 0.1;
|
|
82
|
+
let newZoom = currentZoom + delta;
|
|
83
|
+
if (newZoom < minScale) newZoom = minScale;
|
|
84
|
+
if (newZoom > maxScale) newZoom = maxScale;
|
|
85
|
+
const rect = freehandCanvas.getBoundingClientRect();
|
|
86
|
+
const mouseX = e.clientX - rect.left;
|
|
87
|
+
const mouseY = e.clientY - rect.top;
|
|
88
|
+
const mouseFracX = mouseX / rect.width;
|
|
89
|
+
const mouseFracY = mouseY / rect.height;
|
|
90
|
+
const anchorViewBoxX = currentViewBox.x + mouseFracX * currentViewBox.width;
|
|
91
|
+
const anchorViewBoxY = currentViewBox.y + mouseFracY * currentViewBox.height;
|
|
92
|
+
const newViewBoxWidth = rect.width / newZoom;
|
|
93
|
+
const newViewBoxHeight = rect.height / newZoom;
|
|
94
|
+
const newViewBoxX = anchorViewBoxX - mouseFracX * newViewBoxWidth;
|
|
95
|
+
const newViewBoxY = anchorViewBoxY - mouseFracY * newViewBoxHeight;
|
|
96
|
+
freehandCanvas.setAttribute(
|
|
97
|
+
"viewBox",
|
|
98
|
+
`${newViewBoxX} ${newViewBoxY} ${newViewBoxWidth} ${newViewBoxHeight}`
|
|
99
|
+
);
|
|
100
|
+
currentZoom = newZoom;
|
|
101
|
+
currentViewBox = {
|
|
102
|
+
x: newViewBoxX,
|
|
103
|
+
y: newViewBoxY,
|
|
104
|
+
width: newViewBoxWidth,
|
|
105
|
+
height: newViewBoxHeight
|
|
106
|
+
};
|
|
107
|
+
updateZoomDisplay();
|
|
108
|
+
if (window.__sketchStoreApi && window.__sketchStoreApi.setZoom) {
|
|
109
|
+
window.__sketchStoreApi.setZoom(currentZoom);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
var isMiddleMousePanning = false;
|
|
113
|
+
freehandCanvas.addEventListener("mousedown", function(e) {
|
|
114
|
+
if (e.button === 1) {
|
|
115
|
+
e.preventDefault();
|
|
116
|
+
isMiddleMousePanning = true;
|
|
117
|
+
isPanning = true;
|
|
118
|
+
startCanvasX = e.clientX;
|
|
119
|
+
startCanvasY = e.clientY;
|
|
120
|
+
panStart = { x: e.clientX, y: e.clientY };
|
|
121
|
+
freehandCanvas.style.cursor = "grabbing";
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
if (isPanningToolActive) {
|
|
125
|
+
isPanning = true;
|
|
126
|
+
startCanvasX = e.clientX;
|
|
127
|
+
startCanvasY = e.clientY;
|
|
128
|
+
panStart = { x: e.clientX, y: e.clientY };
|
|
129
|
+
freehandCanvas.style.cursor = "grabbing";
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
freehandCanvas.addEventListener("mousemove", (e) => {
|
|
133
|
+
if (!isPanning) return;
|
|
134
|
+
const dx = e.clientX - panStart.x;
|
|
135
|
+
const dy = e.clientY - panStart.y;
|
|
136
|
+
const dxViewBox = dx / currentZoom;
|
|
137
|
+
const dyViewBox = dy / currentZoom;
|
|
138
|
+
currentViewBox.x -= dxViewBox;
|
|
139
|
+
currentViewBox.y -= dyViewBox;
|
|
140
|
+
freehandCanvas.setAttribute(
|
|
141
|
+
"viewBox",
|
|
142
|
+
`${currentViewBox.x} ${currentViewBox.y} ${currentViewBox.width} ${currentViewBox.height}`
|
|
143
|
+
);
|
|
144
|
+
panStart = { x: e.clientX, y: e.clientY };
|
|
145
|
+
});
|
|
146
|
+
freehandCanvas.addEventListener("mouseup", (e) => {
|
|
147
|
+
if (isMiddleMousePanning) {
|
|
148
|
+
isMiddleMousePanning = false;
|
|
149
|
+
isPanning = false;
|
|
150
|
+
freehandCanvas.style.cursor = "";
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (isPanningToolActive) {
|
|
154
|
+
isPanning = false;
|
|
155
|
+
freehandCanvas.style.cursor = "grab";
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
freehandCanvas.addEventListener("mouseleave", () => {
|
|
159
|
+
if (isMiddleMousePanning) {
|
|
160
|
+
isMiddleMousePanning = false;
|
|
161
|
+
isPanning = false;
|
|
162
|
+
freehandCanvas.style.cursor = "";
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (isPanningToolActive) {
|
|
166
|
+
isPanning = false;
|
|
167
|
+
freehandCanvas.style.cursor = "grab";
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
freehandCanvas.addEventListener("auxclick", (e) => {
|
|
171
|
+
if (e.button === 1) e.preventDefault();
|
|
172
|
+
});
|
|
173
|
+
svg.addEventListener("wheel", (e) => {
|
|
174
|
+
e.preventDefault();
|
|
175
|
+
if (e.ctrlKey) return;
|
|
176
|
+
if (e.shiftKey) {
|
|
177
|
+
currentViewBox.x += e.deltaY > 0 ? scrollRate : -scrollRate;
|
|
178
|
+
} else {
|
|
179
|
+
currentViewBox.y += e.deltaY > 0 ? scrollRate : -scrollRate;
|
|
180
|
+
}
|
|
181
|
+
svg.setAttribute(
|
|
182
|
+
"viewBox",
|
|
183
|
+
`${currentViewBox.x} ${currentViewBox.y} ${currentViewBox.width} ${currentViewBox.height}`
|
|
184
|
+
);
|
|
185
|
+
});
|
|
186
|
+
//# sourceMappingURL=ZoomPan-U3TXC5AJ.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/core/ZoomPan.js"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable */\n// Zoom and Pan controls - combined from zoomFunction.js + panCanvas.js\n// Depends on globals: svg, freehandCanvas, currentZoom, currentViewBox, isPanningToolActive, isPanning\n// Depends on globals: minScale, maxScale, zoomInBtn, zoomOutBtn, zoomPercentSpan, panStart, startCanvasX, startCanvasY\n\n// === Zoom Functions ===\nlet currentY = 0;\nconst scrollRate = 50;\n\nfunction updateZoomDisplay() {\n zoomPercentSpan.innerText = Math.round(currentZoom * 100) + \"%\";\n}\n\nfunction updateViewBox(anchorX = null, anchorY = null) {\n const width = window.innerWidth;\n const height = window.innerHeight;\n const scaledWidth = width / currentZoom;\n const scaledHeight = height / currentZoom;\n\n let centerX, centerY;\n\n if (anchorX === null || anchorY === null) {\n centerX = currentViewBox.x + (currentViewBox.width / 2);\n centerY = currentViewBox.y + (currentViewBox.height / 2);\n } else {\n\n centerX = anchorX;\n centerY = anchorY;\n }\n\n const viewBoxX = centerX - (scaledWidth / 2);\n const viewBoxY = centerY - (scaledHeight / 2);\n\n freehandCanvas.setAttribute(\n \"viewBox\",\n `${viewBoxX} ${viewBoxY} ${scaledWidth} ${scaledHeight}`\n );\n\n currentViewBox.x = viewBoxX;\n currentViewBox.y = viewBoxY;\n currentViewBox.width = scaledWidth;\n currentViewBox.height = scaledHeight;\n}\n\nzoomInBtn.addEventListener(\"click\", function() {\n currentZoom *= 1.1;\n if (currentZoom > maxScale) currentZoom = maxScale;\n updateViewBox();\n updateZoomDisplay();\n});\n\nzoomOutBtn.addEventListener(\"click\", function() {\n currentZoom /= 1.1;\n if (currentZoom < minScale) currentZoom = minScale;\n updateViewBox();\n updateZoomDisplay();\n});\n\n// Exposed for React Footer buttons \u2014 zoom from center of canvas\nwindow.zoomFromCenter = function(direction) {\n if (direction > 0) {\n currentZoom *= 1.1;\n if (currentZoom > maxScale) currentZoom = maxScale;\n } else {\n currentZoom /= 1.1;\n if (currentZoom < minScale) currentZoom = minScale;\n }\n updateViewBox(); // null anchors = zoom from center\n updateZoomDisplay();\n // Sync React zoom state\n if (window.__sketchStoreApi && window.__sketchStoreApi.setZoom) {\n window.__sketchStoreApi.setZoom(currentZoom);\n }\n};\n\nwindow.zoomReset = function() {\n // Issue #24 bug #5: reset zoom in place around the current viewport\n // centre \u2014 do NOT recenter to (0, 0). Recentering used to make whatever\n // the user had on screen vanish until they panned back to it.\n const cx = currentViewBox.x + currentViewBox.width / 2;\n const cy = currentViewBox.y + currentViewBox.height / 2;\n\n currentZoom = 1;\n const rect = freehandCanvas.getBoundingClientRect();\n const vbW = rect.width || window.innerWidth;\n const vbH = rect.height || window.innerHeight;\n\n currentViewBox.x = cx - vbW / 2;\n currentViewBox.y = cy - vbH / 2;\n currentViewBox.width = vbW;\n currentViewBox.height = vbH;\n freehandCanvas.setAttribute(\n \"viewBox\",\n `${currentViewBox.x} ${currentViewBox.y} ${vbW} ${vbH}`\n );\n updateZoomDisplay();\n if (window.__sketchStoreApi && window.__sketchStoreApi.setZoom) {\n window.__sketchStoreApi.setZoom(1);\n }\n};\n\nfreehandCanvas.addEventListener(\"wheel\", function(e) {\n if (!e.ctrlKey) return;\n e.preventDefault();\n\n // Determine the zoom delta\n const delta = e.deltaY > 0 ? -0.1 : 0.1;\n let newZoom = currentZoom + delta;\n if (newZoom < minScale) newZoom = minScale;\n if (newZoom > maxScale) newZoom = maxScale;\n\n // Get canvas bounding rect \u2014 this MUST be the SVG element's actual\n // size, not the window's. In split mode the canvas pane is narrower\n // than the viewport; using window.innerWidth here would produce a\n // viewBox aspect that doesn't match the element, and (with\n // preserveAspectRatio=\"none\" on the host) the content gets stretched\n // / squeezed on every zoom step.\n const rect = freehandCanvas.getBoundingClientRect();\n\n // Calculate mouse position relative to the canvas in pixels\n const mouseX = e.clientX - rect.left;\n const mouseY = e.clientY - rect.top;\n\n // Determine what fraction of the canvas the mouse is at\n const mouseFracX = mouseX / rect.width;\n const mouseFracY = mouseY / rect.height;\n\n // Compute the current viewBox coordinate under the mouse.\n // currentViewBox.width and .height represent the current viewBox dimensions.\n const anchorViewBoxX = currentViewBox.x + mouseFracX * currentViewBox.width;\n const anchorViewBoxY = currentViewBox.y + mouseFracY * currentViewBox.height;\n\n // New viewBox dimensions sized to the *element*, scaled by the new\n // zoom. This keeps the viewBox aspect ratio matching the element so\n // shapes stay undistorted.\n const newViewBoxWidth = rect.width / newZoom;\n const newViewBoxHeight = rect.height / newZoom;\n \n // Compute the new viewBox's x and y so that the anchor remains at the same screen fraction.\n // That means:\n // newViewBox.x + mouseFracX * newViewBoxWidth === anchorViewBoxX\n // Solve for newViewBox.x:\n const newViewBoxX = anchorViewBoxX - mouseFracX * newViewBoxWidth;\n const newViewBoxY = anchorViewBoxY - mouseFracY * newViewBoxHeight;\n \n // Update the viewBox attribute with the new values.\n freehandCanvas.setAttribute(\n \"viewBox\",\n `${newViewBoxX} ${newViewBoxY} ${newViewBoxWidth} ${newViewBoxHeight}`\n );\n \n // Update our state\n currentZoom = newZoom;\n currentViewBox = {\n x: newViewBoxX,\n y: newViewBoxY,\n width: newViewBoxWidth,\n height: newViewBoxHeight\n };\n\n updateZoomDisplay();\n // Sync React zoom state\n if (window.__sketchStoreApi && window.__sketchStoreApi.setZoom) {\n window.__sketchStoreApi.setZoom(currentZoom);\n }\n});\n\n// Function to resize the canvas to fill the screen (initial setup)\nfunction resizeCanvas() {\n const width = window.innerWidth;\n const height = window.innerHeight;\n\n freehandCanvas.style.width = `${width}px`;\n freehandCanvas.style.height = `${height}px`;\n\n // Set initial viewBox based on initial zoom\n updateViewBox(); // Initial center anchor\n}\n\n\n\nlet isMiddleMousePanning = false;\n\nfreehandCanvas.addEventListener(\"mousedown\", function (e) {\n // Middle mouse button panning\n if (e.button === 1) {\n e.preventDefault();\n isMiddleMousePanning = true;\n isPanning = true;\n startCanvasX = e.clientX;\n startCanvasY = e.clientY;\n panStart = { x: e.clientX, y: e.clientY };\n freehandCanvas.style.cursor = 'grabbing';\n return;\n }\n if (isPanningToolActive) {\n isPanning = true;\n startCanvasX = e.clientX;\n startCanvasY = e.clientY;\n panStart = { x: e.clientX, y: e.clientY };\n freehandCanvas.style.cursor = 'grabbing';\n }\n});\n\nfreehandCanvas.addEventListener(\"mousemove\", (e) => {\n if (!isPanning) return;\n\n const dx = e.clientX - panStart.x;\n const dy = e.clientY - panStart.y;\n const dxViewBox = dx / currentZoom;\n const dyViewBox = dy / currentZoom;\n\n currentViewBox.x -= dxViewBox;\n currentViewBox.y -= dyViewBox;\n\n freehandCanvas.setAttribute(\n \"viewBox\",\n `${currentViewBox.x} ${currentViewBox.y} ${currentViewBox.width} ${currentViewBox.height}`\n );\n\n panStart = { x: e.clientX, y: e.clientY };\n});\n\nfreehandCanvas.addEventListener(\"mouseup\", (e) => {\n if (isMiddleMousePanning) {\n isMiddleMousePanning = false;\n isPanning = false;\n freehandCanvas.style.cursor = '';\n return;\n }\n if(isPanningToolActive)\n {\n isPanning = false;\n freehandCanvas.style.cursor = 'grab';\n }\n});\n\nfreehandCanvas.addEventListener(\"mouseleave\", () => {\n if (isMiddleMousePanning) {\n isMiddleMousePanning = false;\n isPanning = false;\n freehandCanvas.style.cursor = '';\n return;\n }\n if(isPanningToolActive)\n {\n isPanning = false;\n freehandCanvas.style.cursor = 'grab';\n }\n});\n\n// Prevent default middle-click auto-scroll behavior\nfreehandCanvas.addEventListener(\"auxclick\", (e) => {\n if (e.button === 1) e.preventDefault();\n});\n\n\nsvg.addEventListener(\"wheel\", (e) => {\n e.preventDefault();\n if (e.ctrlKey) return; // Ignore zoom gestures\n\n if (e.shiftKey) {\n // Pan sideways when Shift is held\n currentViewBox.x += e.deltaY > 0 ? scrollRate : -scrollRate;\n } else {\n // Pan vertically\n currentViewBox.y += e.deltaY > 0 ? scrollRate : -scrollRate;\n }\n\n svg.setAttribute(\n \"viewBox\",\n `${currentViewBox.x} ${currentViewBox.y} ${currentViewBox.width} ${currentViewBox.height}`\n );\n});\n"],
|
|
5
|
+
"mappings": ";;;AAOA,IAAM,aAAa;AAEnB,SAAS,oBAAoB;AAC3B,kBAAgB,YAAY,KAAK,MAAM,cAAc,GAAG,IAAI;AAC9D;AAEA,SAAS,cAAc,UAAU,MAAM,UAAU,MAAM;AACrD,QAAM,QAAQ,OAAO;AACrB,QAAM,SAAS,OAAO;AACtB,QAAM,cAAc,QAAQ;AAC5B,QAAM,eAAe,SAAS;AAE9B,MAAI,SAAS;AAEb,MAAI,YAAY,QAAQ,YAAY,MAAM;AACxC,cAAU,eAAe,IAAK,eAAe,QAAQ;AACrD,cAAU,eAAe,IAAK,eAAe,SAAS;AAAA,EACxD,OAAO;AAEL,cAAU;AACV,cAAU;AAAA,EACZ;AAEA,QAAM,WAAW,UAAW,cAAc;AAC1C,QAAM,WAAW,UAAW,eAAe;AAE3C,iBAAe;AAAA,IACb;AAAA,IACA,GAAG,QAAQ,IAAI,QAAQ,IAAI,WAAW,IAAI,YAAY;AAAA,EACxD;AAEA,iBAAe,IAAI;AACnB,iBAAe,IAAI;AACnB,iBAAe,QAAQ;AACvB,iBAAe,SAAS;AAC1B;AAEA,UAAU,iBAAiB,SAAS,WAAW;AAC7C,iBAAe;AACf,MAAI,cAAc,S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
|
|
7
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
cleanupAttachments,
|
|
4
|
+
handleMouseDown,
|
|
5
|
+
handleMouseMove,
|
|
6
|
+
handleMouseUp,
|
|
7
|
+
updateAttachedArrows
|
|
8
|
+
} from "./chunk-BZE4CEBG.js";
|
|
9
|
+
import "./chunk-L5OARZJ7.js";
|
|
10
|
+
export {
|
|
11
|
+
cleanupAttachments,
|
|
12
|
+
handleMouseDown as handleMouseDownArrow,
|
|
13
|
+
handleMouseMove as handleMouseMoveArrow,
|
|
14
|
+
handleMouseUp as handleMouseUpArrow,
|
|
15
|
+
updateAttachedArrows
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=arrowTool-CWEMIRXK.js.map
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|