@elixpo/lixsketch 5.5.18 → 5.5.20
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-HI7TYROT.js → AIRenderer-SRF7LU5K.js} +13 -4
- package/dist/react/AIRenderer-SRF7LU5K.js.map +7 -0
- package/dist/react/Circle-6POZCUZD.js +9 -0
- package/dist/react/{CopyPaste-C2SHB7QD.js → CopyPaste-KJZ34MIP.js} +12 -11
- package/dist/react/{CopyPaste-C2SHB7QD.js.map → CopyPaste-KJZ34MIP.js.map} +1 -1
- package/dist/react/{EventDispatcher-ZCKWAHIX.js → EventDispatcher-XDRQS7BD.js} +14 -13
- package/dist/react/{EventDispatcher-ZCKWAHIX.js.map → EventDispatcher-XDRQS7BD.js.map} +1 -1
- package/dist/react/Frame-QLBAVLGW.js +11 -0
- package/dist/react/FreehandStroke-U6GYZOM4.js +9 -0
- package/dist/react/IconShape-32EYI2MA.js +10 -0
- package/dist/react/ImageShape-MYP2DVVH.js +10 -0
- package/dist/react/Line-FCCF2BOB.js +10 -0
- package/dist/react/{MermaidFlowchartRenderer-4YEMAYQC.js → MermaidFlowchartRenderer-PQEC4TMI.js} +3 -9
- package/dist/react/{MermaidFlowchartRenderer-4YEMAYQC.js.map → MermaidFlowchartRenderer-PQEC4TMI.js.map} +2 -2
- package/dist/react/{MermaidStructuredRenderer-H42SKKN2.js → MermaidStructuredRenderer-W7UKN7BM.js} +34 -18
- package/dist/react/MermaidStructuredRenderer-W7UKN7BM.js.map +7 -0
- package/dist/react/Rectangle-S7XUKWYD.js +9 -0
- package/dist/react/{SceneSerializer-IQGUAK45.js → SceneSerializer-VY3HY4PF.js} +29 -11
- package/dist/react/SceneSerializer-VY3HY4PF.js.map +7 -0
- package/dist/react/{Selection-XLRY6VYO.js → Selection-U2AR6NQS.js} +5 -4
- package/dist/react/{SketchEngine-RFEF27MN.js → SketchEngine-ZFYUTKET.js} +26 -26
- package/dist/react/TextShape-DY77FFI2.js +8 -0
- package/dist/react/{UndoRedo-M2JZUBKN.js → UndoRedo-BZ6W4QTV.js} +2 -2
- package/dist/react/{ZoomPan-NYPDJBD5.js → ZoomPan-FAWA5OPS.js} +5 -1
- package/dist/react/ZoomPan-FAWA5OPS.js.map +7 -0
- package/dist/react/{arrowTool-CWEMIRXK.js → arrowTool-LKFSZKXC.js} +3 -3
- package/dist/react/{chunk-X6AHYG5J.js → chunk-2I3GH65Z.js} +7 -3
- package/dist/react/chunk-2I3GH65Z.js.map +7 -0
- package/dist/react/{chunk-2OQXI7QB.js → chunk-2V7G2PLX.js} +3 -3
- package/dist/react/{chunk-IZ5OGWGW.js → chunk-6G3ITAS5.js} +2 -2
- package/dist/react/{chunk-LHRTXNVE.js → chunk-73VLPCBC.js} +8 -4
- package/dist/react/chunk-73VLPCBC.js.map +7 -0
- package/dist/react/{chunk-2AYTBFV5.js → chunk-75G7XSZU.js} +11 -2
- package/dist/react/chunk-75G7XSZU.js.map +7 -0
- package/dist/react/{chunk-IW2NRHNK.js → chunk-7VBI7S7T.js} +12 -3
- package/dist/react/chunk-7VBI7S7T.js.map +7 -0
- package/dist/react/{chunk-JQ3IRFDP.js → chunk-C62SXFBL.js} +2 -2
- package/dist/react/{chunk-6SFNWGGZ.js → chunk-C72OHQLE.js} +3 -3
- package/dist/react/{chunk-XCJOF6BM.js → chunk-FETTJLCV.js} +5 -1
- package/dist/react/chunk-FETTJLCV.js.map +7 -0
- package/dist/react/{chunk-QNSE5BAY.js → chunk-JOPQ27YH.js} +3 -3
- package/dist/react/{chunk-L5OARZJ7.js → chunk-MYYBFZD3.js} +15 -1
- package/dist/react/chunk-MYYBFZD3.js.map +7 -0
- package/dist/react/{chunk-BZE4CEBG.js → chunk-O64N5JPO.js} +2 -2
- package/dist/react/chunk-PAKA6HUX.js +59 -0
- package/dist/react/chunk-PAKA6HUX.js.map +7 -0
- package/dist/react/{chunk-62W6XTCZ.js → chunk-PGT3TJOW.js} +4 -2
- package/dist/react/{chunk-62W6XTCZ.js.map → chunk-PGT3TJOW.js.map} +2 -2
- package/dist/react/{chunk-HKYUJUD7.js → chunk-PXFPPO3R.js} +5 -1
- package/dist/react/chunk-PXFPPO3R.js.map +7 -0
- package/dist/react/{chunk-7DC26DDU.js → chunk-R5QXEVZ5.js} +7 -3
- package/dist/react/chunk-R5QXEVZ5.js.map +7 -0
- package/dist/react/{chunk-CB2RANCB.js → chunk-RFHMFWVR.js} +2 -2
- package/dist/react/{chunk-5QIT2WBE.js → chunk-SBSM3GQD.js} +23 -17
- package/dist/react/chunk-SBSM3GQD.js.map +7 -0
- package/dist/react/{chunk-N7NZLF6P.js → chunk-TKXKJNTX.js} +5 -1
- package/dist/react/chunk-TKXKJNTX.js.map +7 -0
- package/dist/react/{chunk-6PFXZKL2.js → chunk-UQBT7F4K.js} +2 -2
- package/dist/react/{chunk-I6HCCIXB.js → chunk-WEWMB35W.js} +3 -3
- package/dist/react/{circleTool-NUATSEI2.js → circleTool-RDOIMKKV.js} +4 -4
- package/dist/react/{codeTool-MHCB2FNB.js → codeTool-VBDB2ES6.js} +5 -4
- package/dist/react/{frameTool-PWVKKXSP.js → frameTool-Z5ZDCX6H.js} +4 -4
- package/dist/react/{freehandTool-SLYGASVP.js → freehandTool-AAQCTMVM.js} +4 -4
- package/dist/react/{iconTool-YD4GRXAP.js → iconTool-5WNDHI5T.js} +5 -4
- package/dist/react/{imageTool-WJVV4WI3.js → imageTool-ECPMT3BL.js} +5 -4
- package/dist/react/index.js +1282 -1295
- package/dist/react/index.js.map +4 -4
- package/dist/react/{lineTool-WNI5EMZ5.js → lineTool-XLOOZE3E.js} +4 -4
- package/dist/react/{rectangleTool-U7DZ6ZTA.js → rectangleTool-AEYDDJCA.js} +4 -4
- package/dist/react/{textTool-HY5NMM7H.js → textTool-5IJKTWVQ.js} +6 -5
- package/package.json +1 -1
- package/src/EngineShortcuts.js +28 -0
- package/src/core/AIRenderer.js +20 -8
- package/src/core/MermaidFlowchartRenderer.js +2 -9
- package/src/core/MermaidStructuredRenderer.js +44 -13
- package/src/core/SceneSerializer.js +22 -0
- package/src/core/ScreenSpaceControls.js +60 -0
- package/src/core/Selection.js +7 -0
- package/src/core/UndoRedo.js +22 -3
- package/src/core/ZoomPan.js +3 -0
- package/src/react/LixSketchCanvas.jsx +15 -19
- package/src/react/components/AppMenu.jsx +220 -198
- package/src/react/components/Footer.jsx +7 -7
- package/src/react/components/Toolbar.jsx +1 -1
- package/src/react/components/canvas/CanvasRulers.jsx +150 -0
- package/src/react/components/canvas/SVGCanvas.jsx +13 -0
- package/src/react/components/modals/CommandPalette.jsx +84 -29
- package/src/react/components/sidebars/IconSidebar.jsx +20 -9
- package/src/react/store/useSketchStore.js +38 -1
- package/src/react/store/useUIStore.js +10 -9
- package/src/shapes/Circle.js +2 -0
- package/src/shapes/Frame.js +8 -1
- package/src/shapes/FreehandStroke.js +2 -0
- package/src/shapes/Rectangle.js +2 -0
- package/src/shapes/TextShape.js +7 -1
- package/src/tools/codeTool.js +3 -2
- package/src/tools/iconTool.js +3 -1
- package/src/tools/imageTool.js +3 -1
- package/src/tools/textTool.js +27 -17
- package/dist/react/AIRenderer-HI7TYROT.js.map +0 -7
- package/dist/react/Circle-QQMKCKFR.js +0 -8
- package/dist/react/Frame-WPQZQLNT.js +0 -10
- package/dist/react/FreehandStroke-BOWDNAVC.js +0 -8
- package/dist/react/IconShape-KMIA6T2H.js +0 -10
- package/dist/react/ImageShape-CHHGBXUQ.js +0 -10
- package/dist/react/Line-2KOQEEGA.js +0 -10
- package/dist/react/MermaidStructuredRenderer-H42SKKN2.js.map +0 -7
- package/dist/react/Rectangle-MZ6ZB6KM.js +0 -8
- package/dist/react/SceneSerializer-IQGUAK45.js.map +0 -7
- package/dist/react/TextShape-QRDG4P7F.js +0 -8
- package/dist/react/ZoomPan-NYPDJBD5.js.map +0 -7
- package/dist/react/chunk-2AYTBFV5.js.map +0 -7
- package/dist/react/chunk-5QIT2WBE.js.map +0 -7
- package/dist/react/chunk-7DC26DDU.js.map +0 -7
- package/dist/react/chunk-HKYUJUD7.js.map +0 -7
- package/dist/react/chunk-IW2NRHNK.js.map +0 -7
- package/dist/react/chunk-L5OARZJ7.js.map +0 -7
- package/dist/react/chunk-LHRTXNVE.js.map +0 -7
- package/dist/react/chunk-N7NZLF6P.js.map +0 -7
- package/dist/react/chunk-X6AHYG5J.js.map +0 -7
- package/dist/react/chunk-XCJOF6BM.js.map +0 -7
- package/src/react/components/modals/HelpModal.jsx +0 -208
- package/src/react/components/modals/ShortcutsModal.jsx +0 -125
- /package/dist/react/{Circle-QQMKCKFR.js.map → Circle-6POZCUZD.js.map} +0 -0
- /package/dist/react/{Frame-WPQZQLNT.js.map → Frame-QLBAVLGW.js.map} +0 -0
- /package/dist/react/{FreehandStroke-BOWDNAVC.js.map → FreehandStroke-U6GYZOM4.js.map} +0 -0
- /package/dist/react/{IconShape-KMIA6T2H.js.map → IconShape-32EYI2MA.js.map} +0 -0
- /package/dist/react/{ImageShape-CHHGBXUQ.js.map → ImageShape-MYP2DVVH.js.map} +0 -0
- /package/dist/react/{Line-2KOQEEGA.js.map → Line-FCCF2BOB.js.map} +0 -0
- /package/dist/react/{Rectangle-MZ6ZB6KM.js.map → Rectangle-S7XUKWYD.js.map} +0 -0
- /package/dist/react/{Selection-XLRY6VYO.js.map → Selection-U2AR6NQS.js.map} +0 -0
- /package/dist/react/{SketchEngine-RFEF27MN.js.map → SketchEngine-ZFYUTKET.js.map} +0 -0
- /package/dist/react/{TextShape-QRDG4P7F.js.map → TextShape-DY77FFI2.js.map} +0 -0
- /package/dist/react/{UndoRedo-M2JZUBKN.js.map → UndoRedo-BZ6W4QTV.js.map} +0 -0
- /package/dist/react/{arrowTool-CWEMIRXK.js.map → arrowTool-LKFSZKXC.js.map} +0 -0
- /package/dist/react/{chunk-2OQXI7QB.js.map → chunk-2V7G2PLX.js.map} +0 -0
- /package/dist/react/{chunk-IZ5OGWGW.js.map → chunk-6G3ITAS5.js.map} +0 -0
- /package/dist/react/{chunk-JQ3IRFDP.js.map → chunk-C62SXFBL.js.map} +0 -0
- /package/dist/react/{chunk-6SFNWGGZ.js.map → chunk-C72OHQLE.js.map} +0 -0
- /package/dist/react/{chunk-QNSE5BAY.js.map → chunk-JOPQ27YH.js.map} +0 -0
- /package/dist/react/{chunk-BZE4CEBG.js.map → chunk-O64N5JPO.js.map} +0 -0
- /package/dist/react/{chunk-CB2RANCB.js.map → chunk-RFHMFWVR.js.map} +0 -0
- /package/dist/react/{chunk-6PFXZKL2.js.map → chunk-UQBT7F4K.js.map} +0 -0
- /package/dist/react/{chunk-I6HCCIXB.js.map → chunk-WEWMB35W.js.map} +0 -0
- /package/dist/react/{circleTool-NUATSEI2.js.map → circleTool-RDOIMKKV.js.map} +0 -0
- /package/dist/react/{codeTool-MHCB2FNB.js.map → codeTool-VBDB2ES6.js.map} +0 -0
- /package/dist/react/{frameTool-PWVKKXSP.js.map → frameTool-Z5ZDCX6H.js.map} +0 -0
- /package/dist/react/{freehandTool-SLYGASVP.js.map → freehandTool-AAQCTMVM.js.map} +0 -0
- /package/dist/react/{iconTool-YD4GRXAP.js.map → iconTool-5WNDHI5T.js.map} +0 -0
- /package/dist/react/{imageTool-WJVV4WI3.js.map → imageTool-ECPMT3BL.js.map} +0 -0
- /package/dist/react/{lineTool-WNI5EMZ5.js.map → lineTool-XLOOZE3E.js.map} +0 -0
- /package/dist/react/{rectangleTool-U7DZ6ZTA.js.map → rectangleTool-AEYDDJCA.js.map} +0 -0
- /package/dist/react/{textTool-HY5NMM7H.js.map → textTool-5IJKTWVQ.js.map} +0 -0
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/core/EventDispatcher.js"],
|
|
4
4
|
"sourcesContent": ["/* eslint-disable */\n// Event dispatcher - extracted from eventListeners.js\n// Central event routing for all tools\n\nimport { handleMouseDownRect, handleMouseMoveRect, handleMouseUpRect } from '../tools/rectangleTool.js';\nimport { handleMouseDownArrow, handleMouseMoveArrow, handleMouseUpArrow } from '../tools/arrowTool.js';\nimport { handleMouseDownCircle, handleMouseMoveCircle, handleMouseUpCircle } from '../tools/circleTool.js';\nimport { handleMouseUpImage, handleMouseDownImage, handleMouseMoveImage } from '../tools/imageTool.js';\nimport { handleMouseDownLine, handleMouseMoveLine, handleMouseUpLine } from '../tools/lineTool.js';\nimport { handleFreehandMouseDown, handleFreehandMouseMove, handleFreehandMouseUp } from '../tools/freehandTool.js';\nimport { handleTextMouseDown, handleTextMouseMove, handleTextMouseUp, enterEditMode } from '../tools/textTool.js';\nimport { handleMouseDownFrame, handleMouseMoveFrame, handleMouseUpFrame } from '../tools/frameTool.js';\nimport { handleMultiSelectionMouseDown, handleMultiSelectionMouseMove, handleMultiSelectionMouseUp, removeMultiSelectionRect, multiSelection, isMultiSelecting} from './Selection.js';\nimport { handleMouseDownIcon, handleMouseMoveIcon, handleMouseUpIcon } from '../tools/iconTool.js';\nimport { handleCodeMouseDown, handleCodeMouseMove, handleCodeMouseUp } from '../tools/codeTool.js';\n\n// === Auto-scroll when dragging near viewport edges ===\nconst EDGE_THRESHOLD = 40; // px from edge to start scrolling\nconst SCROLL_SPEED = 8; // base px per frame (scaled by zoom)\nlet _autoScrollRAF = null;\n\nfunction _autoScroll(e) {\n if (!(e.buttons & 1)) { _stopAutoScroll(); return; } // no primary button\n if (typeof currentViewBox === 'undefined' || typeof currentZoom === 'undefined') return;\n if (typeof isPanning !== 'undefined' && isPanning) return; // don't fight pan tool\n if (typeof isPanningToolActive !== 'undefined' && isPanningToolActive) return;\n\n const rect = svg.getBoundingClientRect();\n const mx = e.clientX - rect.left;\n const my = e.clientY - rect.top;\n\n let dx = 0, dy = 0;\n if (mx < EDGE_THRESHOLD) dx = -SCROLL_SPEED * (1 - mx / EDGE_THRESHOLD);\n else if (mx > rect.width - EDGE_THRESHOLD) dx = SCROLL_SPEED * (1 - (rect.width - mx) / EDGE_THRESHOLD);\n if (my < EDGE_THRESHOLD) dy = -SCROLL_SPEED * (1 - my / EDGE_THRESHOLD);\n else if (my > rect.height - EDGE_THRESHOLD) dy = SCROLL_SPEED * (1 - (rect.height - my) / EDGE_THRESHOLD);\n\n // Also scroll when cursor is outside the canvas entirely\n if (e.clientX < rect.left) dx = -SCROLL_SPEED;\n else if (e.clientX > rect.right) dx = SCROLL_SPEED;\n if (e.clientY < rect.top) dy = -SCROLL_SPEED;\n else if (e.clientY > rect.bottom) dy = SCROLL_SPEED;\n\n if (dx === 0 && dy === 0) { _stopAutoScroll(); return; }\n\n // Scale speed inversely with zoom so scrolling feels consistent\n const scale = 1 / currentZoom;\n currentViewBox.x += dx * scale;\n currentViewBox.y += dy * scale;\n svg.setAttribute('viewBox', `${currentViewBox.x} ${currentViewBox.y} ${currentViewBox.width} ${currentViewBox.height}`);\n if (typeof freehandCanvas !== 'undefined' && freehandCanvas !== svg) {\n freehandCanvas.setAttribute('viewBox', `${currentViewBox.x} ${currentViewBox.y} ${currentViewBox.width} ${currentViewBox.height}`);\n }\n}\n\nfunction _startAutoScroll() {\n if (_autoScrollRAF) return;\n const tick = () => {\n if (_lastDragEvent) _autoScroll(_lastDragEvent);\n _autoScrollRAF = requestAnimationFrame(tick);\n };\n _autoScrollRAF = requestAnimationFrame(tick);\n}\n\nfunction _stopAutoScroll() {\n if (_autoScrollRAF) {\n cancelAnimationFrame(_autoScrollRAF);\n _autoScrollRAF = null;\n }\n _lastDragEvent = null;\n}\n\nlet _lastDragEvent = null;\nlet _documentDragActive = false;\n\nfunction _onDocumentDragMove(e) {\n _lastDragEvent = e;\n // Clamp mouse coordinates to SVG bounds before forwarding to tool handlers,\n // so getSVGCoordsFromMouse doesn't produce extreme values when cursor is outside.\n const rect = svg.getBoundingClientRect();\n const clampedX = Math.max(rect.left, Math.min(rect.right, e.clientX));\n const clampedY = Math.max(rect.top, Math.min(rect.bottom, e.clientY));\n const clampedEvent = new PointerEvent(e.type, {\n clientX: clampedX,\n clientY: clampedY,\n buttons: e.buttons,\n button: e.button,\n ctrlKey: e.ctrlKey,\n shiftKey: e.shiftKey,\n altKey: e.altKey,\n metaKey: e.metaKey,\n });\n handleMainMouseMove(clampedEvent);\n}\n\nfunction _onDocumentDragUp(e) {\n _stopAutoScroll();\n document.removeEventListener('pointermove', _onDocumentDragMove);\n document.removeEventListener('pointerup', _onDocumentDragUp);\n _documentDragActive = false;\n // Finalize the operation\n handleMainMouseUp(e);\n}\n\nconst handleMainMouseDown = (e) => {\n if (!e.target) return;\n // Middle / right mouse buttons are reserved for panning and the\n // browser context menu; they should NOT trigger tool actions or the\n // multi-selection rectangle. Without this guard, middle-click-drag\n // simultaneously pans (handled in ZoomPan) and starts a selection\n // marquee.\n if (e.button === 1 || e.button === 2) return;\n // Safety: remove any stray selection rectangle from a previous interrupted drag\n removeMultiSelectionRect();\n\n // For non-selection tools: deselect everything when clicking on empty canvas\n // (Selection tool handles its own deselection in handleMultiSelectionMouseDown)\n if (!isSelectionToolActive) {\n // Clear multi-selection for any tool switch\n if (multiSelection.selectedShapes.size > 0) {\n multiSelection.clearSelection();\n }\n // Deselect current individual shape when starting a new tool action\n if (currentShape && typeof currentShape.removeSelection === 'function') {\n currentShape.removeSelection();\n currentShape = null;\n }\n if (typeof disableAllSideBars === 'function') {\n disableAllSideBars();\n }\n }\n\n if (isSquareToolActive) {\n handleMouseDownRect(e);\n } else if (isArrowToolActive) {\n handleMouseDownArrow(e);\n } else if (isCircleToolActive) {\n handleMouseDownCircle(e);\n } else if (isImageToolActive) {\n handleMouseDownImage(e);\n } \n else if (isLineToolActive) {\n handleMouseDownLine(e);\n }\n else if (isPaintToolActive) {\n handleFreehandMouseDown(e);\n }\n else if (isTextToolActive) {\n // Text tool handles both text and code shapes based on target and mode\n const targetCodeGroup = e.target.closest('g[data-type=\"code-group\"]');\n const targetTextGroup = e.target.closest('g[data-type=\"text-group\"]');\n if (targetCodeGroup && !targetTextGroup) {\n handleCodeMouseDown(e);\n } else if (isTextInCodeMode && !targetTextGroup && !targetCodeGroup) {\n handleCodeMouseDown(e);\n } else {\n handleTextMouseDown(e);\n }\n }\n else if (isFrameToolActive) {\n handleMouseDownFrame(e);\n }\n else if (isIconToolActive) {\n handleMouseDownIcon(e);\n }\n else if (isSelectionToolActive) {\n // Try multi-selection first when selection tool is active\n if (handleMultiSelectionMouseDown(e)) {\n return; // Multi-selection handled the event\n }\n\n // Remember previous shape to detect deselection\n const prevShape = currentShape;\n let handled = false;\n\n // If multi-selection didn't handle it, proceed with shape-specific selection\n if (currentShape?.shapeName === 'rectangle') {\n handleMouseDownRect(e);\n handled = true;\n } else if (currentShape?.shapeName === 'arrow') {\n handleMouseDownArrow(e);\n handled = true;\n } else if (currentShape?.shapeName === 'circle') {\n handleMouseDownCircle(e);\n handled = true;\n } else if (currentShape?.shapeName === 'image') {\n handleMouseDownImage(e);\n handled = true;\n }\n else if (currentShape?.shapeName === 'line') {\n handleMouseDownLine(e);\n handled = true;\n }\n else if (currentShape?.shapeName === 'freehandStroke') {\n handleFreehandMouseDown(e);\n handled = true;\n }\n else if (currentShape?.shapeName === 'text') {\n handleTextMouseDown(e);\n handled = true;\n }\n else if (currentShape?.shapeName === 'frame') {\n handleMouseDownFrame(e);\n handled = true;\n }\n else if (currentShape?.shapeName === 'icon') {\n handleMouseDownIcon(e);\n handled = true;\n }\n else if( currentShape?.shapeName === 'code') {\n handleCodeMouseDown(e);\n handled = true;\n }\n\n // If the handler deselected (currentShape cleared) but didn't select something new,\n // fall through to try all handlers so clicking another shape type works\n if (handled && prevShape && !currentShape) {\n handled = false;\n }\n\n if (!handled) {\n const originalCurrentShape = currentShape;\n handleMouseDownRect(e);\n if (currentShape && currentShape !== originalCurrentShape) return;\n handleMouseDownCircle(e);\n if (currentShape && currentShape !== originalCurrentShape) return;\n handleMouseDownArrow(e);\n if (currentShape && currentShape !== originalCurrentShape) return;\n handleMouseDownImage(e);\n if (currentShape && currentShape !== originalCurrentShape) return;\n handleMouseDownLine(e);\n if (currentShape && currentShape !== originalCurrentShape) return;\n handleFreehandMouseDown(e);\n if (currentShape && currentShape !== originalCurrentShape) return;\n handleTextMouseDown(e);\n if (currentShape && currentShape !== originalCurrentShape) return;\n handleMouseDownFrame(e);\n if (currentShape && currentShape !== originalCurrentShape) return;\n handleMouseDownIcon(e);\n if (currentShape && currentShape !== originalCurrentShape) return;\n handleCodeMouseDown(e);\n if (currentShape && currentShape !== originalCurrentShape) return;\n if (currentShape === originalCurrentShape) {\n if (currentShape) {\n currentShape.removeSelection();\n currentShape = null;\n }\n }\n }\n }\n};\n\nconst handleMainMouseMove = (e) => {\n // Auto-scroll when dragging near/past viewport edges (checked first so early returns don't skip it)\n if (e.buttons & 1) {\n _lastDragEvent = e;\n _startAutoScroll();\n } else {\n _stopAutoScroll();\n }\n\n if (isSquareToolActive) {\n handleMouseMoveRect(e);\n } else if (isArrowToolActive) {\n handleMouseMoveArrow(e);\n } else if (isCircleToolActive) {\n handleMouseMoveCircle(e);\n } else if (isImageToolActive) {\n handleMouseMoveImage(e);\n } \n else if (isLineToolActive) {\n handleMouseMoveLine(e);\n }\n else if (isPaintToolActive) {\n handleFreehandMouseMove(e);\n }\n else if (isTextToolActive) {\n handleTextMouseMove(e);\n handleCodeMouseMove(e);\n }\n else if (isFrameToolActive) {\n handleMouseMoveFrame(e);\n }\n else if (isIconToolActive) {\n handleMouseMoveIcon(e);\n }\n else if (isSelectionToolActive) {\n // Handle multi-selection operations first - these take priority\n if (isMultiSelecting || multiSelection.isDragging || multiSelection.isResizing || multiSelection.isRotating) {\n if (handleMultiSelectionMouseMove(e)) {\n return; // Multi-selection handled the event\n }\n }\n \n // Shape-specific mouse move handling\n if (currentShape?.shapeName === 'rectangle') {\n handleMouseMoveRect(e);\n } else if (currentShape?.shapeName === 'arrow') {\n handleMouseMoveArrow(e);\n } else if (currentShape?.shapeName === 'circle') {\n handleMouseMoveCircle(e);\n } else if (currentShape?.shapeName === 'image') {\n handleMouseMoveImage(e);\n } \n else if (currentShape?.shapeName === 'line') {\n handleMouseMoveLine(e);\n }\n else if (currentShape?.shapeName === 'freehandStroke') {\n handleFreehandMouseMove(e);\n }\n else if (currentShape?.shapeName === 'text') {\n handleTextMouseMove(e);\n }\n else if (currentShape?.shapeName === 'frame') {\n handleMouseMoveFrame(e);\n }\n else if (currentShape?.shapeName === 'icon') {\n handleMouseMoveIcon(e);\n }\n else if (currentShape?.shapeName === 'code') {\n handleCodeMouseMove(e);\n }\n\n else {\n // Try multi-selection mouse move for cursor updates\n if (handleMultiSelectionMouseMove(e)) {\n return;\n }\n \n handleMouseMoveRect(e);\n handleMouseMoveArrow(e);\n handleMouseMoveCircle(e);\n handleMouseMoveImage(e);\n handleMouseMoveLine(e);\n handleFreehandMouseMove(e);\n handleTextMouseMove(e);\n handleMouseMoveFrame(e);\n handleMouseMoveIcon(e);\n handleCodeMouseMove(e);\n }\n }\n};\n\nconst handleMainMouseUp = (e) => {\n _stopAutoScroll();\n if (isSquareToolActive) {\n handleMouseUpRect(e);\n } else if (isArrowToolActive) {\n handleMouseUpArrow(e);\n } else if (isCircleToolActive) {\n handleMouseUpCircle(e);\n } else if (isImageToolActive) {\n handleMouseUpImage(e);\n } \n else if (isLineToolActive) { \n handleMouseUpLine(e);\n }\n else if (isPaintToolActive) {\n handleFreehandMouseUp(e);\n }\n else if (isTextToolActive) {\n handleTextMouseUp(e);\n handleCodeMouseUp(e);\n }\n else if (isFrameToolActive) {\n handleMouseUpFrame(e);\n }\n else if (isIconToolActive) {\n handleMouseUpIcon(e);\n }\n\n else if (isSelectionToolActive) {\n // Always try multi-selection cleanup first\n if (isMultiSelecting || multiSelection.isDragging || multiSelection.isResizing || multiSelection.isRotating) {\n handleMultiSelectionMouseUp(e);\n return;\n }\n\n // Shape-specific mouse up handling\n if (currentShape?.shapeName === 'rectangle') {\n handleMouseUpRect(e);\n } else if (currentShape?.shapeName === 'arrow') {\n handleMouseUpArrow(e);\n } else if (currentShape?.shapeName === 'circle') {\n handleMouseUpCircle(e);\n } else if (currentShape?.shapeName === 'image') {\n handleMouseUpImage(e);\n }\n else if (currentShape?.shapeName === 'line') {\n handleMouseUpLine(e);\n }\n else if (currentShape?.shapeName === 'freehandStroke') {\n handleFreehandMouseUp(e);\n }\n else if (currentShape?.shapeName === 'text') {\n handleTextMouseUp(e);\n }\n else if (currentShape?.shapeName === 'frame') {\n handleMouseUpFrame(e);\n }\n else if (currentShape?.shapeName === 'icon') {\n handleMouseUpIcon(e);\n }\n else if (currentShape?.shapeName === 'code') {\n handleCodeMouseUp(e);\n }\n\n else {\n handleMultiSelectionMouseUp(e);\n handleMouseUpRect(e);\n handleMouseUpArrow(e);\n handleMouseUpCircle(e);\n handleMouseUpImage(e);\n handleMouseUpLine(e);\n handleFreehandMouseUp(e);\n handleTextMouseUp(e);\n handleMouseUpFrame(e);\n handleMouseUpIcon(e);\n handleCodeMouseUp(e);\n }\n }\n};\n\nconst handleMainMouseLeave = (e) => {\n // If the user is still holding the primary button (dragging outside the canvas),\n // keep auto-scrolling and don't finalize the operation yet.\n if (e.buttons & 1) {\n _lastDragEvent = e;\n _startAutoScroll();\n\n // Listen on document to continue receiving move events outside the SVG\n if (!_documentDragActive) {\n _documentDragActive = true;\n document.addEventListener('pointermove', _onDocumentDragMove);\n document.addEventListener('pointerup', _onDocumentDragUp);\n }\n return;\n }\n\n // Stop all active drawing tools when pointer leaves the canvas\n\n // Fire mouseUp for whichever tool is active to finalize/cancel the operation\n handleMainMouseUp(e);\n\n // Always clean up any stray selection rectangle when pointer leaves canvas\n removeMultiSelectionRect();\n\n // Eraser: force cleanup any lingering trail\n if (typeof window.forceCleanupEraserTrail === 'function') {\n window.forceCleanupEraserTrail();\n }\n\n // Laser: stop drawing and fade out active laser (globals from laserTool.js)\n if (typeof isDrawing !== 'undefined' && isDrawing) {\n isDrawing = false;\n if (typeof lasers !== 'undefined' && lasers.length > 0 && typeof fadeLaserTrail === 'function') {\n const lastLaser = lasers[lasers.length - 1];\n fadeLaserTrail(lastLaser);\n }\n }\n};\n\nlet _boundSvg = null;\n\nfunction _onMouseEnter(e) {\n // Cursor re-entered the SVG \u2014 stop document-level tracking, SVG handles events again\n if (_documentDragActive) {\n document.removeEventListener('pointermove', _onDocumentDragMove);\n document.removeEventListener('pointerup', _onDocumentDragUp);\n _documentDragActive = false;\n }\n}\n\nconst handleMainDblClick = (e) => {\n if (!e.target) return;\n // Double-click on a text group from any tool: enter text edit mode\n const targetTextGroup = e.target.closest('g[data-type=\"text-group\"]');\n if (targetTextGroup) {\n e.stopPropagation();\n enterEditMode(targetTextGroup);\n }\n};\n\nfunction initEventDispatcher(svgEl) {\n if (_boundSvg) cleanupEventDispatcher();\n const target = svgEl || svg;\n target.addEventListener('pointerdown', handleMainMouseDown);\n target.addEventListener('pointermove', handleMainMouseMove);\n target.addEventListener('pointerup', handleMainMouseUp);\n target.addEventListener('pointerleave', handleMainMouseLeave);\n target.addEventListener('pointerenter', _onMouseEnter);\n target.addEventListener('dblclick', handleMainDblClick);\n _boundSvg = target;\n}\n\nfunction cleanupEventDispatcher() {\n _stopAutoScroll();\n if (_documentDragActive) {\n document.removeEventListener('pointermove', _onDocumentDragMove);\n document.removeEventListener('pointerup', _onDocumentDragUp);\n _documentDragActive = false;\n }\n if (_boundSvg) {\n _boundSvg.removeEventListener('pointerdown', handleMainMouseDown);\n _boundSvg.removeEventListener('pointermove', handleMainMouseMove);\n _boundSvg.removeEventListener('pointerup', handleMainMouseUp);\n _boundSvg.removeEventListener('pointerleave', handleMainMouseLeave);\n _boundSvg.removeEventListener('pointerenter', _onMouseEnter);\n _boundSvg.removeEventListener('dblclick', handleMainDblClick);\n _boundSvg = null;\n }\n}\n\n// Auto-init if svg is already available (first load)\nif (typeof svg !== 'undefined' && svg) {\n initEventDispatcher(svg);\n}\n\nexport { handleMainMouseDown, handleMainMouseMove, handleMainMouseUp, handleMainMouseLeave, initEventDispatcher, cleanupEventDispatcher };\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAU,oBAAoB,gBAAgB,aAAa;AAC3D,cAAU,oBAAoB,YAAY,kBAAkB;AAC5D,gBAAY;AAAA,EAChB;AACJ;AAGA,IAAI,OAAO,QAAQ,eAAe,KAAK;AACnC,sBAAoB,GAAG;AAC3B;",
|
|
6
6
|
"names": ["handleMouseDown", "handleMouseMove", "handleMouseUp"]
|
|
7
7
|
}
|
package/dist/react/{MermaidFlowchartRenderer-4YEMAYQC.js → MermaidFlowchartRenderer-PQEC4TMI.js}
RENAMED
|
@@ -224,8 +224,8 @@ function renderFlowchartSVG(diagram, opts = {}) {
|
|
|
224
224
|
svg += `<rect x="${d.x}" y="${d.y}" width="${d.w}" height="${d.h}" rx="${3 * scale}" fill="${nFill}" stroke="${nStroke}" stroke-width="${nStrokeWidth}" />`;
|
|
225
225
|
}
|
|
226
226
|
if (n.label) {
|
|
227
|
-
|
|
228
|
-
|
|
227
|
+
const hasSolidFill = nFill && nFill !== "transparent" && nFill !== "none";
|
|
228
|
+
const labelFill = n.labelColor || (hasSolidFill ? getContrastColor(nFill) : THEME.nodeText);
|
|
229
229
|
const labelLines = n.label.split("\n");
|
|
230
230
|
if (labelLines.length === 1) {
|
|
231
231
|
svg += `<text x="${d.cx}" y="${d.cy}" text-anchor="middle" dominant-baseline="central" fill="${labelFill}" font-size="${fontSize}" font-family="${FONT_FAMILY}" font-weight="500">${escapeXml(n.label)}</text>`;
|
|
@@ -269,12 +269,6 @@ function getEdgePoint(node, target) {
|
|
|
269
269
|
if (dx > 0) return { x: node.x + node.w, y: node.cy };
|
|
270
270
|
return { x: node.x, y: node.cy };
|
|
271
271
|
}
|
|
272
|
-
function isColorTooDark(hex) {
|
|
273
|
-
if (!hex || hex === "transparent" || hex === "none") return false;
|
|
274
|
-
const rgb = parseColor(hex);
|
|
275
|
-
if (!rgb) return false;
|
|
276
|
-
return 0.299 * rgb.r + 0.587 * rgb.g + 0.114 * rgb.b < 80;
|
|
277
|
-
}
|
|
278
272
|
function parseColor(hex) {
|
|
279
273
|
if (!hex || hex === "transparent" || hex === "none") return null;
|
|
280
274
|
let c = hex.replace("#", "");
|
|
@@ -436,4 +430,4 @@ export {
|
|
|
436
430
|
renderFlowchartPreviewSVG,
|
|
437
431
|
renderFlowchartSVG
|
|
438
432
|
};
|
|
439
|
-
//# sourceMappingURL=MermaidFlowchartRenderer-
|
|
433
|
+
//# sourceMappingURL=MermaidFlowchartRenderer-PQEC4TMI.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/core/MermaidFlowchartRenderer.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable */\n/**\n * MermaidFlowchartRenderer - Renders parsed flowchart diagrams as high-quality SVG.\n *\n * One renderer for both preview and canvas \u2014 ensures they always match.\n * Supports: rectangle [], rounded rectangle (), circle (()), diamond/rhombus {},\n * directed/undirected edges with labels, subgraphs, all directions (TD/TB/LR/RL/BT).\n *\n * Dark theme matching the app aesthetic.\n */\n\n// Layout constants\nconst NODE_W = 150;\nconst NODE_H = 50;\nconst H_SPACING = 200;\nconst V_SPACING = 120;\nconst SIDE_MARGIN = 50;\nconst TOP_MARGIN = 40;\nconst FONT_FAMILY = 'lixFont, sans-serif';\n\n// Issue #38 follow-up: theme-aware stroke / fill. Resolved at draw time\n// so a single render call uses whichever palette is active.\nfunction isThemeDark() {\n if (typeof document === 'undefined') return true;\n return !!(document.body && document.body.classList.contains('theme-dark'));\n}\nfunction nodeStrokeColor() { return isThemeDark() ? '#fff' : '#1a1a2e'; }\nfunction edgeStrokeColor() { return isThemeDark() ? '#888' : '#444'; }\n\nconst DARK_THEME = {\n bg: '#1e1e28',\n nodeBg: 'transparent',\n nodeStroke: '#9090c0',\n nodeText: '#e0e0e0',\n edgeStroke: '#888',\n edgeText: '#a0a0b0',\n subgraphBg: 'rgba(80,80,120,0.08)',\n subgraphBorder: '#555',\n subgraphLabel: '#888',\n};\n\nconst LIGHT_THEME = {\n bg: '#fbfaf6',\n nodeBg: '#f5f2ea',\n nodeStroke: '#6e746c',\n nodeText: '#343832',\n edgeStroke: '#6e746c',\n edgeText: '#4f554e',\n subgraphBg: 'rgba(117, 135, 119, 0.06)',\n subgraphBorder: '#aaa99f',\n subgraphLabel: '#666b64',\n};\n\nfunction previewTheme() { return isThemeDark() ? DARK_THEME : LIGHT_THEME; }\n\nfunction escapeXml(str) {\n return String(str)\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"');\n}\n\nfunction measureText(text, fontSize) {\n return text.length * fontSize * 0.55;\n}\n\n/**\n * Render a parsed flowchart diagram to SVG markup.\n *\n * @param {Object} diagram - Parsed from parseMermaid()\n * @param {Object} opts - { width?, height?, fitToContent? }\n * @returns {string} SVG markup string\n */\nexport function renderFlowchartSVG(diagram, opts = {}) {\n if (!diagram || !diagram.nodes || diagram.nodes.length === 0) return '';\n\n const THEME = previewTheme();\n\n const nodes = diagram.nodes;\n const edges = diagram.edges || [];\n const subgraphs = diagram.subgraphs || [];\n const direction = diagram.direction || 'TD';\n\n // Compute bounds of laid-out nodes\n let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;\n nodes.forEach(n => {\n const nw = n.width || NODE_W;\n const nh = n.height || NODE_H;\n minX = Math.min(minX, n.x);\n minY = Math.min(minY, n.y);\n maxX = Math.max(maxX, n.x + nw);\n maxY = Math.max(maxY, n.y + nh);\n });\n\n const dw = maxX - minX || 1;\n const dh = maxY - minY || 1;\n\n // If fitToContent or explicit size, scale to fit\n const targetW = opts.width || dw + SIDE_MARGIN * 2;\n const targetH = opts.height || dh + TOP_MARGIN * 2;\n\n let scale, offX, offY;\n if (opts.width || opts.height) {\n const pad = 40;\n scale = Math.min(\n (targetW - pad * 2) / dw,\n (targetH - pad * 2) / dh,\n 1.8\n );\n offX = (targetW - dw * scale) / 2 - minX * scale;\n offY = (targetH - dh * scale) / 2 - minY * scale;\n } else {\n scale = 1;\n offX = SIDE_MARGIN - minX;\n offY = TOP_MARGIN - minY;\n }\n\n const totalWidth = opts.width || Math.round(dw * scale + SIDE_MARGIN * 2);\n const totalHeight = opts.height || Math.round(dh * scale + TOP_MARGIN * 2);\n\n // Build node lookup for edge rendering\n const nodeById = new Map();\n nodes.forEach(n => {\n const nw = (n.width || NODE_W) * scale;\n const nh = (n.height || NODE_H) * scale;\n const nx = n.x * scale + offX;\n const ny = n.y * scale + offY;\n nodeById.set(n.id, {\n x: nx, y: ny, w: nw, h: nh,\n cx: nx + nw / 2, cy: ny + nh / 2,\n type: n.type, label: n.label,\n fill: n.fill, stroke: n.stroke, strokeWidth: n.strokeWidth,\n });\n });\n\n let svg = '';\n const defs = [];\n\n // Arrow markers (normal, dotted, thick)\n defs.push(`<marker id=\"fc-arrow\" markerWidth=\"10\" markerHeight=\"7\" refX=\"9\" refY=\"3.5\" orient=\"auto\">\n <path d=\"M1,1 L9,3.5 L1,6\" fill=\"none\" stroke=\"${THEME.edgeStroke}\" stroke-width=\"1.5\" stroke-linejoin=\"round\" />\n </marker>`);\n defs.push(`<marker id=\"fc-arrow-thick\" markerWidth=\"12\" markerHeight=\"9\" refX=\"11\" refY=\"4.5\" orient=\"auto\">\n <path d=\"M1,1 L11,4.5 L1,8\" fill=\"none\" stroke=\"${THEME.edgeStroke}\" stroke-width=\"2\" stroke-linejoin=\"round\" />\n </marker>`);\n\n // Background\n svg += `<rect x=\"0\" y=\"0\" width=\"${totalWidth}\" height=\"${totalHeight}\" fill=\"${THEME.bg}\" rx=\"8\" />`;\n\n // --- Subgraphs (rendered first, behind everything) ---\n for (const sg of subgraphs) {\n if (!sg.nodes || sg.nodes.length === 0) continue;\n\n let sgMinX = Infinity, sgMinY = Infinity, sgMaxX = -Infinity, sgMaxY = -Infinity;\n let hasNodes = false;\n for (const nid of sg.nodes) {\n const nd = nodeById.get(nid);\n if (!nd) continue;\n hasNodes = true;\n sgMinX = Math.min(sgMinX, nd.x);\n sgMinY = Math.min(sgMinY, nd.y);\n sgMaxX = Math.max(sgMaxX, nd.x + nd.w);\n sgMaxY = Math.max(sgMaxY, nd.y + nd.h);\n }\n if (!hasNodes) continue;\n\n const sgPad = 20 * scale;\n const sgX = sgMinX - sgPad;\n const sgY = sgMinY - sgPad - 16 * scale;\n const sgW = (sgMaxX - sgMinX) + sgPad * 2;\n const sgH = (sgMaxY - sgMinY) + sgPad * 2 + 16 * scale;\n\n svg += `<g data-fc-type=\"subgraph\" data-fc-id=\"${escapeXml(sg.id)}\">`;\n svg += `<rect x=\"${sgX}\" y=\"${sgY}\" width=\"${sgW}\" height=\"${sgH}\" rx=\"6\" fill=\"${THEME.subgraphBg}\" stroke=\"${THEME.subgraphBorder}\" stroke-width=\"1\" stroke-dasharray=\"4 2\" />`;\n if (sg.label) {\n svg += `<text x=\"${sgX + 8}\" y=\"${sgY + 14}\" fill=\"${THEME.subgraphLabel}\" font-size=\"${Math.max(9, 11 * scale)}\" font-family=\"${FONT_FAMILY}\">${escapeXml(sg.label)}</text>`;\n }\n svg += `</g>`;\n }\n\n // --- Edges ---\n edges.forEach(e => {\n const f = nodeById.get(e.from);\n const t = nodeById.get(e.to);\n if (!f || !t) return;\n\n const directed = e.directed !== false;\n const edgeStyle = e.style || 'normal';\n let strokeW, dashArr, markerRef;\n if (edgeStyle === 'thick') {\n strokeW = 3;\n dashArr = '';\n markerRef = directed ? ' marker-end=\"url(#fc-arrow-thick)\"' : '';\n } else if (edgeStyle === 'dotted') {\n strokeW = 1.5;\n dashArr = ' stroke-dasharray=\"5 3\"';\n markerRef = directed ? ' marker-end=\"url(#fc-arrow)\"' : '';\n } else {\n strokeW = 1.5;\n dashArr = '';\n markerRef = directed ? ' marker-end=\"url(#fc-arrow)\"' : '';\n }\n const eStroke = e.stroke || THEME.edgeStroke;\n\n // Compute connection points\n const sp = getEdgePoint(f, t);\n const ep = getEdgePoint(t, f);\n\n // Determine if we should curve\n const dx = t.cx - f.cx;\n const dy = t.cy - f.cy;\n const dist = Math.sqrt(dx * dx + dy * dy);\n let mx = (sp.x + ep.x) / 2;\n let my = (sp.y + ep.y) / 2;\n\n svg += `<g data-fc-type=\"edge\" data-fc-from=\"${escapeXml(e.from)}\" data-fc-to=\"${escapeXml(e.to)}\">`;\n\n if (dist > 0 && Math.abs(dy) > 15 && Math.abs(dx) > 15) {\n // Curved edge\n const perpX = -dy / dist;\n const perpY = dx / dist;\n const curveAmt = dist * 0.12;\n const cpx = mx + perpX * curveAmt;\n const cpy = my + perpY * curveAmt;\n mx = 0.25 * sp.x + 0.5 * cpx + 0.25 * ep.x;\n my = 0.25 * sp.y + 0.5 * cpy + 0.25 * ep.y;\n svg += `<path d=\"M ${sp.x} ${sp.y} Q ${cpx} ${cpy} ${ep.x} ${ep.y}\" fill=\"none\" stroke=\"${eStroke}\" stroke-width=\"${strokeW}\"${dashArr}${markerRef} />`;\n } else {\n svg += `<line x1=\"${sp.x}\" y1=\"${sp.y}\" x2=\"${ep.x}\" y2=\"${ep.y}\" stroke=\"${eStroke}\" stroke-width=\"${strokeW}\"${dashArr}${markerRef} />`;\n }\n\n // Edge label (supports multi-line via \\n)\n if (e.label) {\n const labelFontSize = Math.max(8, 10 * scale);\n const labelLines = e.label.split('\\n');\n const maxLineW = Math.max(...labelLines.map(l => measureText(l, labelFontSize)));\n const labelW = maxLineW + 12;\n const labelH = labelLines.length * (labelFontSize + 3) + 6;\n svg += `<rect x=\"${mx - labelW / 2}\" y=\"${my - labelH / 2}\" width=\"${labelW}\" height=\"${labelH}\" rx=\"3\" fill=\"${THEME.bg}\" opacity=\"0.85\" />`;\n if (labelLines.length === 1) {\n svg += `<text x=\"${mx}\" y=\"${my + 1}\" text-anchor=\"middle\" dominant-baseline=\"central\" fill=\"${THEME.edgeText}\" font-size=\"${labelFontSize}\" font-family=\"${FONT_FAMILY}\">${escapeXml(e.label)}</text>`;\n } else {\n const startY = my - ((labelLines.length - 1) * (labelFontSize + 3)) / 2;\n svg += `<text x=\"${mx}\" text-anchor=\"middle\" fill=\"${THEME.edgeText}\" font-size=\"${labelFontSize}\" font-family=\"${FONT_FAMILY}\">`;\n labelLines.forEach((ln, idx) => {\n svg += `<tspan x=\"${mx}\" dy=\"${idx === 0 ? 0 : labelFontSize + 3}\" y=\"${idx === 0 ? startY : ''}\">${escapeXml(ln)}</tspan>`;\n });\n svg += `</text>`;\n }\n }\n\n svg += `</g>`;\n });\n\n // --- Nodes ---\n nodes.forEach(n => {\n const d = nodeById.get(n.id);\n if (!d) return;\n\n const nStroke = n.stroke || THEME.nodeStroke;\n const nFill = n.fill || THEME.nodeBg;\n const nStrokeWidth = n.strokeWidth || 1.8;\n const fontSize = Math.max(9, Math.min(13, 12 * scale));\n\n svg += `<g data-fc-type=\"node\" data-fc-id=\"${escapeXml(n.id)}\">`;\n\n if (n.type === 'circle') {\n const r = Math.min(d.w, d.h) / 2;\n svg += `<circle cx=\"${d.cx}\" cy=\"${d.cy}\" r=\"${r}\" fill=\"${nFill}\" stroke=\"${nStroke}\" stroke-width=\"${nStrokeWidth}\" />`;\n } else if (n.type === 'diamond') {\n const hw = d.w / 2 * 0.85;\n const hh = d.h / 2 * 0.85;\n svg += `<polygon points=\"${d.cx},${d.cy - hh} ${d.cx + hw},${d.cy} ${d.cx},${d.cy + hh} ${d.cx - hw},${d.cy}\" fill=\"${nFill}\" stroke=\"${nStroke}\" stroke-width=\"${nStrokeWidth}\" />`;\n } else if (n.type === 'asymmetric') {\n // Flag/asymmetric shape: pointed left, flat right\n const notchX = d.x + 15 * scale;\n svg += `<polygon points=\"${d.x},${d.y} ${d.x + d.w},${d.y} ${d.x + d.w},${d.y + d.h} ${d.x},${d.y + d.h} ${notchX},${d.cy}\" fill=\"${nFill}\" stroke=\"${nStroke}\" stroke-width=\"${nStrokeWidth}\" />`;\n } else if (n.type === 'roundrect') {\n svg += `<rect x=\"${d.x}\" y=\"${d.y}\" width=\"${d.w}\" height=\"${d.h}\" rx=\"${12 * scale}\" fill=\"${nFill}\" stroke=\"${nStroke}\" stroke-width=\"${nStrokeWidth}\" />`;\n } else {\n svg += `<rect x=\"${d.x}\" y=\"${d.y}\" width=\"${d.w}\" height=\"${d.h}\" rx=\"${3 * scale}\" fill=\"${nFill}\" stroke=\"${nStroke}\" stroke-width=\"${nStrokeWidth}\" />`;\n }\n\n // Node label (supports multi-line via \\n)\n if (n.label) {\n let labelFill = nFill && nFill !== 'transparent' && nFill !== THEME.nodeBg ? getContrastColor(nFill) : nStroke;\n if (isColorTooDark(labelFill)) labelFill = '#d0d0d0';\n\n const labelLines = n.label.split('\\n');\n if (labelLines.length === 1) {\n svg += `<text x=\"${d.cx}\" y=\"${d.cy}\" text-anchor=\"middle\" dominant-baseline=\"central\" fill=\"${labelFill}\" font-size=\"${fontSize}\" font-family=\"${FONT_FAMILY}\" font-weight=\"500\">${escapeXml(n.label)}</text>`;\n } else {\n const lineH = fontSize + 3;\n const startY = d.cy - ((labelLines.length - 1) * lineH) / 2;\n svg += `<text text-anchor=\"middle\" fill=\"${labelFill}\" font-size=\"${fontSize}\" font-family=\"${FONT_FAMILY}\" font-weight=\"500\">`;\n labelLines.forEach((ln, idx) => {\n svg += `<tspan x=\"${d.cx}\" y=\"${startY + idx * lineH}\">${escapeXml(ln)}</tspan>`;\n });\n svg += `</text>`;\n }\n }\n\n svg += `</g>`;\n });\n\n // Build final SVG\n const defsStr = defs.length > 0 ? `<defs>${defs.join('')}</defs>` : '';\n return `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${totalWidth}\" height=\"${totalHeight}\" viewBox=\"0 0 ${totalWidth} ${totalHeight}\">${defsStr}${svg}</svg>`;\n}\n\n/**\n * Get the connection point on a node's boundary toward another node.\n */\nfunction getEdgePoint(node, target) {\n const dx = target.cx - node.cx;\n const dy = target.cy - node.cy;\n\n if (node.type === 'circle') {\n const r = Math.min(node.w, node.h) / 2;\n const dist = Math.sqrt(dx * dx + dy * dy) || 1;\n return { x: node.cx + (dx / dist) * r, y: node.cy + (dy / dist) * r };\n }\n\n if (node.type === 'diamond') {\n // Diamond edge intersection\n const hw = node.w / 2 * 0.85;\n const hh = node.h / 2 * 0.85;\n const adx = Math.abs(dx) || 0.001;\n const ady = Math.abs(dy) || 0.001;\n const t = Math.min(hw / adx, hh / ady);\n return { x: node.cx + dx * t * 0.95, y: node.cy + dy * t * 0.95 };\n }\n\n // Rectangle / rounded rect / asymmetric - exit from edges\n const hw = node.w / 2;\n const hh = node.h / 2;\n\n if (Math.abs(dx) < 0.001 || Math.abs(dy) * hw > Math.abs(dx) * hh) {\n if (dy > 0) return { x: node.cx, y: node.y + node.h };\n return { x: node.cx, y: node.y };\n }\n if (dx > 0) return { x: node.x + node.w, y: node.cy };\n return { x: node.x, y: node.cy };\n}\n\nfunction isColorTooDark(hex) {\n if (!hex || hex === 'transparent' || hex === 'none') return false;\n const rgb = parseColor(hex);\n if (!rgb) return false;\n return (0.299 * rgb.r + 0.587 * rgb.g + 0.114 * rgb.b) < 80;\n}\n\nfunction parseColor(hex) {\n if (!hex || hex === 'transparent' || hex === 'none') return null;\n let c = hex.replace('#', '');\n // Support 3-char shorthand (#9f6 \u2192 #99ff66)\n if (c.length === 3) c = c[0] + c[0] + c[1] + c[1] + c[2] + c[2];\n if (c.length < 6) return null;\n return {\n r: parseInt(c.substring(0, 2), 16),\n g: parseInt(c.substring(2, 4), 16),\n b: parseInt(c.substring(4, 6), 16),\n };\n}\n\nfunction getLuminance(hex) {\n const rgb = parseColor(hex);\n if (!rgb) return 0;\n return 0.299 * rgb.r + 0.587 * rgb.g + 0.114 * rgb.b;\n}\n\nfunction getContrastColor(bgHex) {\n // Pick dark or light text based on background luminance\n return getLuminance(bgHex) > 140 ? '#1a1a2e' : '#f0f0f0';\n}\n\n/**\n * Generate preview SVG for the modal.\n */\nexport function renderFlowchartPreviewSVG(diagram) {\n return renderFlowchartSVG(diagram, { width: 600, height: 450 });\n}\n\n/**\n * Render a flowchart diagram onto the canvas as a real engine `Frame`\n * containing independent shapes \u2014 Rectangle nodes (with embedded labels)\n * joined by Arrow edges. Each child is fully independent for click /\n * drag / resize / colour-change, exactly like a user-drawn shape; the\n * Frame's `_diagramType` marker means deleting it pulls every child with\n * it (so the diagram behaves as one logical unit when you're done with\n * it) \u2014 see Frame.destroy().\n *\n * Issue #34 bug #3 (follow-up to #22 phase 5): drops the shared `groupId`\n * glue that made selecting one shape select the whole diagram; the Frame\n * is the explicit container instead.\n */\nexport function renderFlowchartOnCanvas(diagram) {\n if (!diagram || !diagram.nodes || diagram.nodes.length === 0) return false;\n if (!window.svg || !window.Rectangle || !window.Frame) {\n console.error('[FlowchartRenderer] Engine not initialized');\n return false;\n }\n\n const nodes = diagram.nodes;\n const edges = diagram.edges || [];\n\n // Diagram bounds (in the renderer's natural coordinate space)\n let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;\n nodes.forEach((n) => {\n const nw = n.width || 140;\n const nh = n.height || 60;\n minX = Math.min(minX, n.x);\n minY = Math.min(minY, n.y);\n maxX = Math.max(maxX, n.x + nw);\n maxY = Math.max(maxY, n.y + nh);\n });\n const dw = (maxX - minX) || 1;\n const dh = (maxY - minY) || 1;\n\n // Center on the current viewport\n const vb = window.currentViewBox || { x: 0, y: 0, width: window.innerWidth, height: window.innerHeight };\n const vcx = vb.x + vb.width / 2;\n const vcy = vb.y + vb.height / 2;\n const ox = vcx - dw / 2 - minX;\n const oy = vcy - dh / 2 - minY;\n\n // \u2500\u2500 Wrapper frame \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n // Created up-front so we can call addShapeToFrame as each child is\n // built. _diagramType marks it so Frame.destroy() takes the children\n // along on delete (issue #34 bug #3).\n //\n // PADDING bumped from 40 \u2192 90 so edge labels, rotated diamond nodes,\n // and arrow heads near the diagram boundary stay inside the frame\n // instead of getting clipped at the corners.\n const PADDING = 90;\n const frameTitle = diagram.title || 'Mermaid diagram';\n const frame = new window.Frame(\n vcx - dw / 2 - PADDING,\n vcy - dh / 2 - PADDING,\n dw + PADDING * 2,\n dh + PADDING * 2,\n {\n stroke: '#888',\n strokeWidth: 1,\n fill: 'transparent',\n opacity: 0.7,\n frameName: frameTitle,\n }\n );\n frame._diagramType = 'mermaid-flowchart';\n window.shapes.push(frame);\n if (window.pushCreateAction) window.pushCreateAction(frame);\n\n const nodeMap = new Map(); // id \u2192 shape\n\n // \u2500\u2500 Nodes \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n for (const n of nodes) {\n const nw = n.width || 140;\n const nh = n.height || 60;\n const nx = n.x + ox;\n const ny = n.y + oy;\n const cx = nx + nw / 2;\n const cy = ny + nh / 2;\n\n const opts = {\n stroke: n.stroke || nodeStrokeColor(),\n strokeWidth: n.strokeWidth ?? 1.5,\n fill: n.fill || 'transparent',\n fillStyle: n.fill && n.fill !== 'transparent' ? 'solid' : 'none',\n roughness: 1,\n label: n.label || '',\n labelColor: n.labelColor || (n.fill && n.fill !== 'transparent' ? getContrastColor(n.fill) : nodeStrokeColor()),\n };\n\n let shape = null;\n try {\n if (n.type === 'circle' && window.Circle) {\n shape = new window.Circle(cx, cy, nw / 2, nh / 2, opts);\n } else if (n.type === 'diamond') {\n const sz = Math.max(nw, nh) * 0.75;\n shape = new window.Rectangle(cx - sz / 2, cy - sz / 2, sz, sz, opts);\n shape.rotation = 45;\n if (typeof shape.draw === 'function') shape.draw();\n } else if (n.type === 'roundrect') {\n shape = new window.Rectangle(nx, ny, nw, nh, { ...opts, cornerRadius: Math.min(nw, nh) * 0.2 });\n } else {\n shape = new window.Rectangle(nx, ny, nw, nh, opts);\n }\n } catch (err) {\n console.warn('[FlowchartRenderer] Node creation failed:', n.id, err);\n continue;\n }\n if (!shape) continue;\n\n window.shapes.push(shape);\n if (window.pushCreateAction) window.pushCreateAction(shape);\n frame.addShapeToFrame(shape);\n\n nodeMap.set(n.id, { shape, x: nx, y: ny, width: nw, height: nh, centerX: cx, centerY: cy });\n }\n\n // \u2500\u2500 Edges \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n for (const e of edges) {\n const fromNode = nodeMap.get(e.from);\n const toNode = nodeMap.get(e.to);\n if (!fromNode || !toNode) continue;\n\n // Connect from the source center to the target center \u2014 autoAttach\n // will snap each endpoint to the appropriate edge of the shape.\n const sp = { x: fromNode.centerX, y: fromNode.centerY };\n const ep = { x: toNode.centerX, y: toNode.centerY };\n\n const directed = e.directed !== false;\n const style = e.style || 'normal';\n const isThick = style === 'thick';\n const isDotted = style === 'dotted';\n\n const opts = {\n stroke: e.stroke || edgeStrokeColor(),\n strokeWidth: isThick ? 3 : 1.5,\n roughness: 1,\n strokeDasharray: isDotted ? '5 3' : '',\n label: e.label || '',\n labelColor: e.labelColor || edgeStrokeColor(),\n };\n\n let connector = null;\n try {\n if (directed && window.Arrow) {\n connector = new window.Arrow(sp, ep, opts);\n } else if (window.Line) {\n connector = new window.Line(sp, ep, opts);\n } else if (window.Arrow) {\n connector = new window.Arrow(sp, ep, opts);\n }\n } catch (err) {\n console.warn('[FlowchartRenderer] Edge creation failed:', e, err);\n continue;\n }\n if (!connector) continue;\n\n window.shapes.push(connector);\n if (window.pushCreateAction) window.pushCreateAction(connector);\n frame.addShapeToFrame(connector);\n\n // Wire arrow endpoints into the source/target shapes so moving a\n // node drags its connections along. window.__autoAttach is set up\n // by AIRenderer.initAIRenderer() during engine init.\n if (directed && connector.shapeName === 'arrow' && typeof window.__autoAttach === 'function') {\n try {\n window.__autoAttach(connector, fromNode.shape, true, sp);\n window.__autoAttach(connector, toNode.shape, false, ep);\n } catch (err) {\n console.warn('[FlowchartRenderer] autoAttach failed:', err);\n }\n }\n }\n\n // Select the first node so the user has feedback that something\n // landed. Selecting a child (not the frame) reinforces the\n // \"independent shapes inside a frame\" model.\n const first = nodeMap.values().next().value;\n if (first) {\n window.currentShape = first.shape;\n if (typeof first.shape.selectShape === 'function') first.shape.selectShape();\n }\n\n return true;\n}\n"],
|
|
5
|
-
"mappings": ";;;AAYA,IAAM,SAAS;AACf,IAAM,SAAS;AAGf,IAAM,cAAc;AACpB,IAAM,aAAa;AACnB,IAAM,cAAc;AAIpB,SAAS,cAAc;AACnB,MAAI,OAAO,aAAa,YAAa,QAAO;AAC5C,SAAO,CAAC,EAAE,SAAS,QAAQ,SAAS,KAAK,UAAU,SAAS,YAAY;AAC5E;AACA,SAAS,kBAAkB;AAAE,SAAO,YAAY,IAAI,SAAS;AAAW;AACxE,SAAS,kBAAkB;AAAE,SAAO,YAAY,IAAI,SAAS;AAAQ;AAErE,IAAM,aAAa;AAAA,EACf,IAAI;AAAA,EACJ,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,eAAe;AACnB;AAEA,IAAM,cAAc;AAAA,EAChB,IAAI;AAAA,EACJ,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,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AE;AACtC,MAAI,OAAO;AACP,WAAO,eAAe,MAAM;AAC5B,QAAI,OAAO,MAAM,MAAM,gBAAgB,WAAY,OAAM,MAAM,YAAY;AAAA,EAC/E;AAEA,SAAO;AACX;",
|
|
4
|
+
"sourcesContent": ["/* eslint-disable */\n/**\n * MermaidFlowchartRenderer - Renders parsed flowchart diagrams as high-quality SVG.\n *\n * One renderer for both preview and canvas \u2014 ensures they always match.\n * Supports: rectangle [], rounded rectangle (), circle (()), diamond/rhombus {},\n * directed/undirected edges with labels, subgraphs, all directions (TD/TB/LR/RL/BT).\n *\n * Dark theme matching the app aesthetic.\n */\n\n// Layout constants\nconst NODE_W = 150;\nconst NODE_H = 50;\nconst H_SPACING = 200;\nconst V_SPACING = 120;\nconst SIDE_MARGIN = 50;\nconst TOP_MARGIN = 40;\nconst FONT_FAMILY = 'lixFont, sans-serif';\n\n// Issue #38 follow-up: theme-aware stroke / fill. Resolved at draw time\n// so a single render call uses whichever palette is active.\nfunction isThemeDark() {\n if (typeof document === 'undefined') return true;\n return !!(document.body && document.body.classList.contains('theme-dark'));\n}\nfunction nodeStrokeColor() { return isThemeDark() ? '#fff' : '#1a1a2e'; }\nfunction edgeStrokeColor() { return isThemeDark() ? '#888' : '#444'; }\n\nconst DARK_THEME = {\n bg: '#1e1e28',\n nodeBg: 'transparent',\n nodeStroke: '#9090c0',\n nodeText: '#e0e0e0',\n edgeStroke: '#888',\n edgeText: '#a0a0b0',\n subgraphBg: 'rgba(80,80,120,0.08)',\n subgraphBorder: '#555',\n subgraphLabel: '#888',\n};\n\nconst LIGHT_THEME = {\n bg: '#fbfaf6',\n nodeBg: '#f5f2ea',\n nodeStroke: '#6e746c',\n nodeText: '#343832',\n edgeStroke: '#6e746c',\n edgeText: '#4f554e',\n subgraphBg: 'rgba(117, 135, 119, 0.06)',\n subgraphBorder: '#aaa99f',\n subgraphLabel: '#666b64',\n};\n\nfunction previewTheme() { return isThemeDark() ? DARK_THEME : LIGHT_THEME; }\n\nfunction escapeXml(str) {\n return String(str)\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"');\n}\n\nfunction measureText(text, fontSize) {\n return text.length * fontSize * 0.55;\n}\n\n/**\n * Render a parsed flowchart diagram to SVG markup.\n *\n * @param {Object} diagram - Parsed from parseMermaid()\n * @param {Object} opts - { width?, height?, fitToContent? }\n * @returns {string} SVG markup string\n */\nexport function renderFlowchartSVG(diagram, opts = {}) {\n if (!diagram || !diagram.nodes || diagram.nodes.length === 0) return '';\n\n const THEME = previewTheme();\n\n const nodes = diagram.nodes;\n const edges = diagram.edges || [];\n const subgraphs = diagram.subgraphs || [];\n const direction = diagram.direction || 'TD';\n\n // Compute bounds of laid-out nodes\n let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;\n nodes.forEach(n => {\n const nw = n.width || NODE_W;\n const nh = n.height || NODE_H;\n minX = Math.min(minX, n.x);\n minY = Math.min(minY, n.y);\n maxX = Math.max(maxX, n.x + nw);\n maxY = Math.max(maxY, n.y + nh);\n });\n\n const dw = maxX - minX || 1;\n const dh = maxY - minY || 1;\n\n // If fitToContent or explicit size, scale to fit\n const targetW = opts.width || dw + SIDE_MARGIN * 2;\n const targetH = opts.height || dh + TOP_MARGIN * 2;\n\n let scale, offX, offY;\n if (opts.width || opts.height) {\n const pad = 40;\n scale = Math.min(\n (targetW - pad * 2) / dw,\n (targetH - pad * 2) / dh,\n 1.8\n );\n offX = (targetW - dw * scale) / 2 - minX * scale;\n offY = (targetH - dh * scale) / 2 - minY * scale;\n } else {\n scale = 1;\n offX = SIDE_MARGIN - minX;\n offY = TOP_MARGIN - minY;\n }\n\n const totalWidth = opts.width || Math.round(dw * scale + SIDE_MARGIN * 2);\n const totalHeight = opts.height || Math.round(dh * scale + TOP_MARGIN * 2);\n\n // Build node lookup for edge rendering\n const nodeById = new Map();\n nodes.forEach(n => {\n const nw = (n.width || NODE_W) * scale;\n const nh = (n.height || NODE_H) * scale;\n const nx = n.x * scale + offX;\n const ny = n.y * scale + offY;\n nodeById.set(n.id, {\n x: nx, y: ny, w: nw, h: nh,\n cx: nx + nw / 2, cy: ny + nh / 2,\n type: n.type, label: n.label,\n fill: n.fill, stroke: n.stroke, strokeWidth: n.strokeWidth,\n });\n });\n\n let svg = '';\n const defs = [];\n\n // Arrow markers (normal, dotted, thick)\n defs.push(`<marker id=\"fc-arrow\" markerWidth=\"10\" markerHeight=\"7\" refX=\"9\" refY=\"3.5\" orient=\"auto\">\n <path d=\"M1,1 L9,3.5 L1,6\" fill=\"none\" stroke=\"${THEME.edgeStroke}\" stroke-width=\"1.5\" stroke-linejoin=\"round\" />\n </marker>`);\n defs.push(`<marker id=\"fc-arrow-thick\" markerWidth=\"12\" markerHeight=\"9\" refX=\"11\" refY=\"4.5\" orient=\"auto\">\n <path d=\"M1,1 L11,4.5 L1,8\" fill=\"none\" stroke=\"${THEME.edgeStroke}\" stroke-width=\"2\" stroke-linejoin=\"round\" />\n </marker>`);\n\n // Background\n svg += `<rect x=\"0\" y=\"0\" width=\"${totalWidth}\" height=\"${totalHeight}\" fill=\"${THEME.bg}\" rx=\"8\" />`;\n\n // --- Subgraphs (rendered first, behind everything) ---\n for (const sg of subgraphs) {\n if (!sg.nodes || sg.nodes.length === 0) continue;\n\n let sgMinX = Infinity, sgMinY = Infinity, sgMaxX = -Infinity, sgMaxY = -Infinity;\n let hasNodes = false;\n for (const nid of sg.nodes) {\n const nd = nodeById.get(nid);\n if (!nd) continue;\n hasNodes = true;\n sgMinX = Math.min(sgMinX, nd.x);\n sgMinY = Math.min(sgMinY, nd.y);\n sgMaxX = Math.max(sgMaxX, nd.x + nd.w);\n sgMaxY = Math.max(sgMaxY, nd.y + nd.h);\n }\n if (!hasNodes) continue;\n\n const sgPad = 20 * scale;\n const sgX = sgMinX - sgPad;\n const sgY = sgMinY - sgPad - 16 * scale;\n const sgW = (sgMaxX - sgMinX) + sgPad * 2;\n const sgH = (sgMaxY - sgMinY) + sgPad * 2 + 16 * scale;\n\n svg += `<g data-fc-type=\"subgraph\" data-fc-id=\"${escapeXml(sg.id)}\">`;\n svg += `<rect x=\"${sgX}\" y=\"${sgY}\" width=\"${sgW}\" height=\"${sgH}\" rx=\"6\" fill=\"${THEME.subgraphBg}\" stroke=\"${THEME.subgraphBorder}\" stroke-width=\"1\" stroke-dasharray=\"4 2\" />`;\n if (sg.label) {\n svg += `<text x=\"${sgX + 8}\" y=\"${sgY + 14}\" fill=\"${THEME.subgraphLabel}\" font-size=\"${Math.max(9, 11 * scale)}\" font-family=\"${FONT_FAMILY}\">${escapeXml(sg.label)}</text>`;\n }\n svg += `</g>`;\n }\n\n // --- Edges ---\n edges.forEach(e => {\n const f = nodeById.get(e.from);\n const t = nodeById.get(e.to);\n if (!f || !t) return;\n\n const directed = e.directed !== false;\n const edgeStyle = e.style || 'normal';\n let strokeW, dashArr, markerRef;\n if (edgeStyle === 'thick') {\n strokeW = 3;\n dashArr = '';\n markerRef = directed ? ' marker-end=\"url(#fc-arrow-thick)\"' : '';\n } else if (edgeStyle === 'dotted') {\n strokeW = 1.5;\n dashArr = ' stroke-dasharray=\"5 3\"';\n markerRef = directed ? ' marker-end=\"url(#fc-arrow)\"' : '';\n } else {\n strokeW = 1.5;\n dashArr = '';\n markerRef = directed ? ' marker-end=\"url(#fc-arrow)\"' : '';\n }\n const eStroke = e.stroke || THEME.edgeStroke;\n\n // Compute connection points\n const sp = getEdgePoint(f, t);\n const ep = getEdgePoint(t, f);\n\n // Determine if we should curve\n const dx = t.cx - f.cx;\n const dy = t.cy - f.cy;\n const dist = Math.sqrt(dx * dx + dy * dy);\n let mx = (sp.x + ep.x) / 2;\n let my = (sp.y + ep.y) / 2;\n\n svg += `<g data-fc-type=\"edge\" data-fc-from=\"${escapeXml(e.from)}\" data-fc-to=\"${escapeXml(e.to)}\">`;\n\n if (dist > 0 && Math.abs(dy) > 15 && Math.abs(dx) > 15) {\n // Curved edge\n const perpX = -dy / dist;\n const perpY = dx / dist;\n const curveAmt = dist * 0.12;\n const cpx = mx + perpX * curveAmt;\n const cpy = my + perpY * curveAmt;\n mx = 0.25 * sp.x + 0.5 * cpx + 0.25 * ep.x;\n my = 0.25 * sp.y + 0.5 * cpy + 0.25 * ep.y;\n svg += `<path d=\"M ${sp.x} ${sp.y} Q ${cpx} ${cpy} ${ep.x} ${ep.y}\" fill=\"none\" stroke=\"${eStroke}\" stroke-width=\"${strokeW}\"${dashArr}${markerRef} />`;\n } else {\n svg += `<line x1=\"${sp.x}\" y1=\"${sp.y}\" x2=\"${ep.x}\" y2=\"${ep.y}\" stroke=\"${eStroke}\" stroke-width=\"${strokeW}\"${dashArr}${markerRef} />`;\n }\n\n // Edge label (supports multi-line via \\n)\n if (e.label) {\n const labelFontSize = Math.max(8, 10 * scale);\n const labelLines = e.label.split('\\n');\n const maxLineW = Math.max(...labelLines.map(l => measureText(l, labelFontSize)));\n const labelW = maxLineW + 12;\n const labelH = labelLines.length * (labelFontSize + 3) + 6;\n svg += `<rect x=\"${mx - labelW / 2}\" y=\"${my - labelH / 2}\" width=\"${labelW}\" height=\"${labelH}\" rx=\"3\" fill=\"${THEME.bg}\" opacity=\"0.85\" />`;\n if (labelLines.length === 1) {\n svg += `<text x=\"${mx}\" y=\"${my + 1}\" text-anchor=\"middle\" dominant-baseline=\"central\" fill=\"${THEME.edgeText}\" font-size=\"${labelFontSize}\" font-family=\"${FONT_FAMILY}\">${escapeXml(e.label)}</text>`;\n } else {\n const startY = my - ((labelLines.length - 1) * (labelFontSize + 3)) / 2;\n svg += `<text x=\"${mx}\" text-anchor=\"middle\" fill=\"${THEME.edgeText}\" font-size=\"${labelFontSize}\" font-family=\"${FONT_FAMILY}\">`;\n labelLines.forEach((ln, idx) => {\n svg += `<tspan x=\"${mx}\" dy=\"${idx === 0 ? 0 : labelFontSize + 3}\" y=\"${idx === 0 ? startY : ''}\">${escapeXml(ln)}</tspan>`;\n });\n svg += `</text>`;\n }\n }\n\n svg += `</g>`;\n });\n\n // --- Nodes ---\n nodes.forEach(n => {\n const d = nodeById.get(n.id);\n if (!d) return;\n\n const nStroke = n.stroke || THEME.nodeStroke;\n const nFill = n.fill || THEME.nodeBg;\n const nStrokeWidth = n.strokeWidth || 1.8;\n const fontSize = Math.max(9, Math.min(13, 12 * scale));\n\n svg += `<g data-fc-type=\"node\" data-fc-id=\"${escapeXml(n.id)}\">`;\n\n if (n.type === 'circle') {\n const r = Math.min(d.w, d.h) / 2;\n svg += `<circle cx=\"${d.cx}\" cy=\"${d.cy}\" r=\"${r}\" fill=\"${nFill}\" stroke=\"${nStroke}\" stroke-width=\"${nStrokeWidth}\" />`;\n } else if (n.type === 'diamond') {\n const hw = d.w / 2 * 0.85;\n const hh = d.h / 2 * 0.85;\n svg += `<polygon points=\"${d.cx},${d.cy - hh} ${d.cx + hw},${d.cy} ${d.cx},${d.cy + hh} ${d.cx - hw},${d.cy}\" fill=\"${nFill}\" stroke=\"${nStroke}\" stroke-width=\"${nStrokeWidth}\" />`;\n } else if (n.type === 'asymmetric') {\n // Flag/asymmetric shape: pointed left, flat right\n const notchX = d.x + 15 * scale;\n svg += `<polygon points=\"${d.x},${d.y} ${d.x + d.w},${d.y} ${d.x + d.w},${d.y + d.h} ${d.x},${d.y + d.h} ${notchX},${d.cy}\" fill=\"${nFill}\" stroke=\"${nStroke}\" stroke-width=\"${nStrokeWidth}\" />`;\n } else if (n.type === 'roundrect') {\n svg += `<rect x=\"${d.x}\" y=\"${d.y}\" width=\"${d.w}\" height=\"${d.h}\" rx=\"${12 * scale}\" fill=\"${nFill}\" stroke=\"${nStroke}\" stroke-width=\"${nStrokeWidth}\" />`;\n } else {\n svg += `<rect x=\"${d.x}\" y=\"${d.y}\" width=\"${d.w}\" height=\"${d.h}\" rx=\"${3 * scale}\" fill=\"${nFill}\" stroke=\"${nStroke}\" stroke-width=\"${nStrokeWidth}\" />`;\n }\n\n // Node label (supports multi-line via \\n)\n if (n.label) {\n const hasSolidFill = nFill && nFill !== 'transparent' && nFill !== 'none';\n const labelFill = n.labelColor || (hasSolidFill ? getContrastColor(nFill) : THEME.nodeText);\n\n const labelLines = n.label.split('\\n');\n if (labelLines.length === 1) {\n svg += `<text x=\"${d.cx}\" y=\"${d.cy}\" text-anchor=\"middle\" dominant-baseline=\"central\" fill=\"${labelFill}\" font-size=\"${fontSize}\" font-family=\"${FONT_FAMILY}\" font-weight=\"500\">${escapeXml(n.label)}</text>`;\n } else {\n const lineH = fontSize + 3;\n const startY = d.cy - ((labelLines.length - 1) * lineH) / 2;\n svg += `<text text-anchor=\"middle\" fill=\"${labelFill}\" font-size=\"${fontSize}\" font-family=\"${FONT_FAMILY}\" font-weight=\"500\">`;\n labelLines.forEach((ln, idx) => {\n svg += `<tspan x=\"${d.cx}\" y=\"${startY + idx * lineH}\">${escapeXml(ln)}</tspan>`;\n });\n svg += `</text>`;\n }\n }\n\n svg += `</g>`;\n });\n\n // Build final SVG\n const defsStr = defs.length > 0 ? `<defs>${defs.join('')}</defs>` : '';\n return `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${totalWidth}\" height=\"${totalHeight}\" viewBox=\"0 0 ${totalWidth} ${totalHeight}\">${defsStr}${svg}</svg>`;\n}\n\n/**\n * Get the connection point on a node's boundary toward another node.\n */\nfunction getEdgePoint(node, target) {\n const dx = target.cx - node.cx;\n const dy = target.cy - node.cy;\n\n if (node.type === 'circle') {\n const r = Math.min(node.w, node.h) / 2;\n const dist = Math.sqrt(dx * dx + dy * dy) || 1;\n return { x: node.cx + (dx / dist) * r, y: node.cy + (dy / dist) * r };\n }\n\n if (node.type === 'diamond') {\n // Diamond edge intersection\n const hw = node.w / 2 * 0.85;\n const hh = node.h / 2 * 0.85;\n const adx = Math.abs(dx) || 0.001;\n const ady = Math.abs(dy) || 0.001;\n const t = Math.min(hw / adx, hh / ady);\n return { x: node.cx + dx * t * 0.95, y: node.cy + dy * t * 0.95 };\n }\n\n // Rectangle / rounded rect / asymmetric - exit from edges\n const hw = node.w / 2;\n const hh = node.h / 2;\n\n if (Math.abs(dx) < 0.001 || Math.abs(dy) * hw > Math.abs(dx) * hh) {\n if (dy > 0) return { x: node.cx, y: node.y + node.h };\n return { x: node.cx, y: node.y };\n }\n if (dx > 0) return { x: node.x + node.w, y: node.cy };\n return { x: node.x, y: node.cy };\n}\n\nfunction parseColor(hex) {\n if (!hex || hex === 'transparent' || hex === 'none') return null;\n let c = hex.replace('#', '');\n // Support 3-char shorthand (#9f6 \u2192 #99ff66)\n if (c.length === 3) c = c[0] + c[0] + c[1] + c[1] + c[2] + c[2];\n if (c.length < 6) return null;\n return {\n r: parseInt(c.substring(0, 2), 16),\n g: parseInt(c.substring(2, 4), 16),\n b: parseInt(c.substring(4, 6), 16),\n };\n}\n\nfunction getLuminance(hex) {\n const rgb = parseColor(hex);\n if (!rgb) return 0;\n return 0.299 * rgb.r + 0.587 * rgb.g + 0.114 * rgb.b;\n}\n\nfunction getContrastColor(bgHex) {\n // Pick dark or light text based on background luminance\n return getLuminance(bgHex) > 140 ? '#1a1a2e' : '#f0f0f0';\n}\n\n/**\n * Generate preview SVG for the modal.\n */\nexport function renderFlowchartPreviewSVG(diagram) {\n return renderFlowchartSVG(diagram, { width: 600, height: 450 });\n}\n\n/**\n * Render a flowchart diagram onto the canvas as a real engine `Frame`\n * containing independent shapes \u2014 Rectangle nodes (with embedded labels)\n * joined by Arrow edges. Each child is fully independent for click /\n * drag / resize / colour-change, exactly like a user-drawn shape; the\n * Frame's `_diagramType` marker means deleting it pulls every child with\n * it (so the diagram behaves as one logical unit when you're done with\n * it) \u2014 see Frame.destroy().\n *\n * Issue #34 bug #3 (follow-up to #22 phase 5): drops the shared `groupId`\n * glue that made selecting one shape select the whole diagram; the Frame\n * is the explicit container instead.\n */\nexport function renderFlowchartOnCanvas(diagram) {\n if (!diagram || !diagram.nodes || diagram.nodes.length === 0) return false;\n if (!window.svg || !window.Rectangle || !window.Frame) {\n console.error('[FlowchartRenderer] Engine not initialized');\n return false;\n }\n\n const nodes = diagram.nodes;\n const edges = diagram.edges || [];\n\n // Diagram bounds (in the renderer's natural coordinate space)\n let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;\n nodes.forEach((n) => {\n const nw = n.width || 140;\n const nh = n.height || 60;\n minX = Math.min(minX, n.x);\n minY = Math.min(minY, n.y);\n maxX = Math.max(maxX, n.x + nw);\n maxY = Math.max(maxY, n.y + nh);\n });\n const dw = (maxX - minX) || 1;\n const dh = (maxY - minY) || 1;\n\n // Center on the current viewport\n const vb = window.currentViewBox || { x: 0, y: 0, width: window.innerWidth, height: window.innerHeight };\n const vcx = vb.x + vb.width / 2;\n const vcy = vb.y + vb.height / 2;\n const ox = vcx - dw / 2 - minX;\n const oy = vcy - dh / 2 - minY;\n\n // \u2500\u2500 Wrapper frame \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n // Created up-front so we can call addShapeToFrame as each child is\n // built. _diagramType marks it so Frame.destroy() takes the children\n // along on delete (issue #34 bug #3).\n //\n // PADDING bumped from 40 \u2192 90 so edge labels, rotated diamond nodes,\n // and arrow heads near the diagram boundary stay inside the frame\n // instead of getting clipped at the corners.\n const PADDING = 90;\n const frameTitle = diagram.title || 'Mermaid diagram';\n const frame = new window.Frame(\n vcx - dw / 2 - PADDING,\n vcy - dh / 2 - PADDING,\n dw + PADDING * 2,\n dh + PADDING * 2,\n {\n stroke: '#888',\n strokeWidth: 1,\n fill: 'transparent',\n opacity: 0.7,\n frameName: frameTitle,\n }\n );\n frame._diagramType = 'mermaid-flowchart';\n window.shapes.push(frame);\n if (window.pushCreateAction) window.pushCreateAction(frame);\n\n const nodeMap = new Map(); // id \u2192 shape\n\n // \u2500\u2500 Nodes \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n for (const n of nodes) {\n const nw = n.width || 140;\n const nh = n.height || 60;\n const nx = n.x + ox;\n const ny = n.y + oy;\n const cx = nx + nw / 2;\n const cy = ny + nh / 2;\n\n const opts = {\n stroke: n.stroke || nodeStrokeColor(),\n strokeWidth: n.strokeWidth ?? 1.5,\n fill: n.fill || 'transparent',\n fillStyle: n.fill && n.fill !== 'transparent' ? 'solid' : 'none',\n roughness: 1,\n label: n.label || '',\n labelColor: n.labelColor || (n.fill && n.fill !== 'transparent' ? getContrastColor(n.fill) : nodeStrokeColor()),\n };\n\n let shape = null;\n try {\n if (n.type === 'circle' && window.Circle) {\n shape = new window.Circle(cx, cy, nw / 2, nh / 2, opts);\n } else if (n.type === 'diamond') {\n const sz = Math.max(nw, nh) * 0.75;\n shape = new window.Rectangle(cx - sz / 2, cy - sz / 2, sz, sz, opts);\n shape.rotation = 45;\n if (typeof shape.draw === 'function') shape.draw();\n } else if (n.type === 'roundrect') {\n shape = new window.Rectangle(nx, ny, nw, nh, { ...opts, cornerRadius: Math.min(nw, nh) * 0.2 });\n } else {\n shape = new window.Rectangle(nx, ny, nw, nh, opts);\n }\n } catch (err) {\n console.warn('[FlowchartRenderer] Node creation failed:', n.id, err);\n continue;\n }\n if (!shape) continue;\n\n window.shapes.push(shape);\n if (window.pushCreateAction) window.pushCreateAction(shape);\n frame.addShapeToFrame(shape);\n\n nodeMap.set(n.id, { shape, x: nx, y: ny, width: nw, height: nh, centerX: cx, centerY: cy });\n }\n\n // \u2500\u2500 Edges \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n for (const e of edges) {\n const fromNode = nodeMap.get(e.from);\n const toNode = nodeMap.get(e.to);\n if (!fromNode || !toNode) continue;\n\n // Connect from the source center to the target center \u2014 autoAttach\n // will snap each endpoint to the appropriate edge of the shape.\n const sp = { x: fromNode.centerX, y: fromNode.centerY };\n const ep = { x: toNode.centerX, y: toNode.centerY };\n\n const directed = e.directed !== false;\n const style = e.style || 'normal';\n const isThick = style === 'thick';\n const isDotted = style === 'dotted';\n\n const opts = {\n stroke: e.stroke || edgeStrokeColor(),\n strokeWidth: isThick ? 3 : 1.5,\n roughness: 1,\n strokeDasharray: isDotted ? '5 3' : '',\n label: e.label || '',\n labelColor: e.labelColor || edgeStrokeColor(),\n };\n\n let connector = null;\n try {\n if (directed && window.Arrow) {\n connector = new window.Arrow(sp, ep, opts);\n } else if (window.Line) {\n connector = new window.Line(sp, ep, opts);\n } else if (window.Arrow) {\n connector = new window.Arrow(sp, ep, opts);\n }\n } catch (err) {\n console.warn('[FlowchartRenderer] Edge creation failed:', e, err);\n continue;\n }\n if (!connector) continue;\n\n window.shapes.push(connector);\n if (window.pushCreateAction) window.pushCreateAction(connector);\n frame.addShapeToFrame(connector);\n\n // Wire arrow endpoints into the source/target shapes so moving a\n // node drags its connections along. window.__autoAttach is set up\n // by AIRenderer.initAIRenderer() during engine init.\n if (directed && connector.shapeName === 'arrow' && typeof window.__autoAttach === 'function') {\n try {\n window.__autoAttach(connector, fromNode.shape, true, sp);\n window.__autoAttach(connector, toNode.shape, false, ep);\n } catch (err) {\n console.warn('[FlowchartRenderer] autoAttach failed:', err);\n }\n }\n }\n\n // Select the first node so the user has feedback that something\n // landed. Selecting a child (not the frame) reinforces the\n // \"independent shapes inside a frame\" model.\n const first = nodeMap.values().next().value;\n if (first) {\n window.currentShape = first.shape;\n if (typeof first.shape.selectShape === 'function') first.shape.selectShape();\n }\n\n return true;\n}\n"],
|
|
5
|
+
"mappings": ";;;AAYA,IAAM,SAAS;AACf,IAAM,SAAS;AAGf,IAAM,cAAc;AACpB,IAAM,aAAa;AACnB,IAAM,cAAc;AAIpB,SAAS,cAAc;AACnB,MAAI,OAAO,aAAa,YAAa,QAAO;AAC5C,SAAO,CAAC,EAAE,SAAS,QAAQ,SAAS,KAAK,UAAU,SAAS,YAAY;AAC5E;AACA,SAAS,kBAAkB;AAAE,SAAO,YAAY,IAAI,SAAS;AAAW;AACxE,SAAS,kBAAkB;AAAE,SAAO,YAAY,IAAI,SAAS;AAAQ;AAErE,IAAM,aAAa;AAAA,EACf,IAAI;AAAA,EACJ,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,eAAe;AACnB;AAEA,IAAM,cAAc;AAAA,EAChB,IAAI;AAAA,EACJ,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,eAAe;AACnB;AAEA,SAAS,eAAe;AAAE,SAAO,YAAY,IAAI,aAAa;AAAa;AAE3E,SAAS,UAAU,KAAK;AACpB,SAAO,OAAO,GAAG,EACZ,QAAQ,MAAM,OAAO,EACrB,QAAQ,MAAM,MAAM,EACpB,QAAQ,MAAM,MAAM,EACpB,QAAQ,MAAM,QAAQ;AAC/B;AAEA,SAAS,YAAY,MAAM,UAAU;AACjC,SAAO,KAAK,SAAS,WAAW;AACpC;AASO,SAAS,mBAAmB,SAAS,OAAO,CAAC,GA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MAC5C,WAAW,OAAO,OAAO;AACrB,oBAAY,IAAI,OAAO,MAAM,IAAI,IAAI,IAAI;AAAA,MAC7C;AAAA,IACJ,SAAS,KAAK;AACV,cAAQ,KAAK,6CAA6C,GAAG,GAAG;AAChE;AAAA,IACJ;AACA,QAAI,CAAC,UAAW;AAEhB,WAAO,OAAO,KAAK,SAAS;AAC5B,QAAI,OAAO,iBAAkB,QAAO,iBAAiB,SAAS;AAC9D,UAAM,gBAAgB,SAAS;AAK/B,QAAI,YAAY,UAAU,cAAc,WAAW,OAAO,OAAO,iBAAiB,YAAY;AAC1F,UAAI;AACA,eAAO,aAAa,WAAW,SAAS,OAAO,MAAM,EAAE;AACvD,eAAO,aAAa,WAAW,OAAO,OAAO,OAAO,EAAE;AAAA,MAC1D,SAAS,KAAK;AACV,gBAAQ,KAAK,0CAA0C,GAAG;AAAA,MAC9D;AAAA,IACJ;AAAA,EACJ;AAKA,QAAM,QAAQ,QAAQ,OAAO,EAAE,KAAK,EAAE;AACtC,MAAI,OAAO;AACP,WAAO,eAAe,MAAM;AAC5B,QAAI,OAAO,MAAM,MAAM,gBAAgB,WAAY,OAAM,MAAM,YAAY;AAAA,EAC/E;AAEA,SAAO;AACX;",
|
|
6
6
|
"names": ["hw", "hh"]
|
|
7
7
|
}
|
package/dist/react/{MermaidStructuredRenderer-H42SKKN2.js → MermaidStructuredRenderer-W7UKN7BM.js}
RENAMED
|
@@ -174,6 +174,11 @@ function parseChartDiagram(src) {
|
|
|
174
174
|
if (!categories.length) categories = Array.from({ length: maxItems }, (_, index) => String(index + 1));
|
|
175
175
|
return series.length ? { type: "chart", kind: "xy", title, categories, series } : null;
|
|
176
176
|
}
|
|
177
|
+
function renderedSeries(chart) {
|
|
178
|
+
if (chart?.kind !== "xy") return chart?.series || [];
|
|
179
|
+
const bars = chart.series.filter((series) => series.kind === "bar");
|
|
180
|
+
return bars.length ? bars : chart.series.filter((series) => series.kind === "line");
|
|
181
|
+
}
|
|
177
182
|
function renderChartPreviewSVG(chart) {
|
|
178
183
|
if (!chart?.series?.length) return "";
|
|
179
184
|
const TK = theme();
|
|
@@ -208,7 +213,8 @@ function renderChartPreviewSVG(chart) {
|
|
|
208
213
|
const top = 60;
|
|
209
214
|
const plotWidth = 580;
|
|
210
215
|
const plotHeight = 300;
|
|
211
|
-
const
|
|
216
|
+
const seriesToRender = renderedSeries(chart);
|
|
217
|
+
const values = seriesToRender.flatMap((series) => series.values);
|
|
212
218
|
const maximum = Math.max(1, ...values.map(Math.abs));
|
|
213
219
|
const categoryCount = Math.max(1, chart.categories.length);
|
|
214
220
|
const slot = plotWidth / categoryCount;
|
|
@@ -217,14 +223,14 @@ function renderChartPreviewSVG(chart) {
|
|
|
217
223
|
chart.categories.forEach((category, index) => {
|
|
218
224
|
content += `<text x="${left + slot * (index + 0.5)}" y="${top + plotHeight + 24}" text-anchor="middle" fill="${TK.text}" font-size="11" font-family="lixFont">${escapeXml(category)}</text>`;
|
|
219
225
|
});
|
|
220
|
-
|
|
226
|
+
seriesToRender.forEach((series, seriesIndex) => {
|
|
221
227
|
const color = PALETTE[seriesIndex % PALETTE.length];
|
|
222
228
|
if (series.kind === "line") {
|
|
223
229
|
const points = series.values.map((value, index) => `${left + slot * (index + 0.5)},${top + plotHeight - Math.abs(value) / maximum * plotHeight}`).join(" ");
|
|
224
230
|
content += `<polyline points="${points}" fill="none" stroke="${color.stroke}" stroke-width="3"/>`;
|
|
225
231
|
series.values.forEach((value, index) => content += `<circle cx="${left + slot * (index + 0.5)}" cy="${top + plotHeight - Math.abs(value) / maximum * plotHeight}" r="5" fill="${color.fill}" stroke="${color.stroke}" stroke-width="2"/>`);
|
|
226
232
|
} else {
|
|
227
|
-
const barWidth = Math.max(12, slot * 0.7 /
|
|
233
|
+
const barWidth = Math.max(12, slot * 0.7 / seriesToRender.length);
|
|
228
234
|
series.values.forEach((value, index) => {
|
|
229
235
|
const barHeight = Math.abs(value) / maximum * plotHeight;
|
|
230
236
|
const x = left + slot * index + slot * 0.15 + seriesIndex * barWidth;
|
|
@@ -241,7 +247,7 @@ function push(shape, frame) {
|
|
|
241
247
|
if (frame?.addShapeToFrame) frame.addShapeToFrame(shape);
|
|
242
248
|
return shape;
|
|
243
249
|
}
|
|
244
|
-
function pushText(text, x, y, fontSize, fill, frame) {
|
|
250
|
+
function pushText(text, x, y, fontSize, fill, frame, textAnchor = "start") {
|
|
245
251
|
if (!window.TextShape || !window.svg) return null;
|
|
246
252
|
const group = document.createElementNS(NS, "g");
|
|
247
253
|
group.setAttribute("data-type", "text-group");
|
|
@@ -252,6 +258,7 @@ function pushText(text, x, y, fontSize, fill, frame) {
|
|
|
252
258
|
element.setAttribute("x", 0);
|
|
253
259
|
element.setAttribute("y", 0);
|
|
254
260
|
element.setAttribute("dominant-baseline", "central");
|
|
261
|
+
element.setAttribute("text-anchor", textAnchor);
|
|
255
262
|
element.setAttribute("fill", fill);
|
|
256
263
|
element.setAttribute("font-size", fontSize);
|
|
257
264
|
element.setAttribute("font-family", "lixFont, sans-serif");
|
|
@@ -274,7 +281,8 @@ function createFrame(x, y, width, height, name, type) {
|
|
|
274
281
|
strokeWidth: 1,
|
|
275
282
|
fill: "transparent",
|
|
276
283
|
opacity: 0.75,
|
|
277
|
-
frameName: name
|
|
284
|
+
frameName: name,
|
|
285
|
+
labelColor: TK.text
|
|
278
286
|
});
|
|
279
287
|
frame._diagramType = type;
|
|
280
288
|
push(frame);
|
|
@@ -388,12 +396,22 @@ function renderChartOnCanvas(chart) {
|
|
|
388
396
|
const top = origin.y + 65;
|
|
389
397
|
const plotWidth = 580;
|
|
390
398
|
const plotHeight = 300;
|
|
391
|
-
const
|
|
399
|
+
const seriesToRender = renderedSeries(chart);
|
|
400
|
+
const values = seriesToRender.flatMap((series) => series.values);
|
|
392
401
|
const maximum = Math.max(1, ...values.map(Math.abs));
|
|
393
402
|
const slot = plotWidth / Math.max(1, chart.categories.length);
|
|
394
403
|
push(new window.Line({ x: left, y: top }, { x: left, y: top + plotHeight }, { stroke: TK.line, strokeWidth: 1.5, roughness: 0 }), frame);
|
|
395
404
|
push(new window.Line({ x: left, y: top + plotHeight }, { x: left + plotWidth, y: top + plotHeight }, { stroke: TK.line, strokeWidth: 1.5, roughness: 0 }), frame);
|
|
396
|
-
chart.
|
|
405
|
+
chart.categories.forEach((category, index) => pushText(
|
|
406
|
+
category,
|
|
407
|
+
left + slot * (index + 0.5),
|
|
408
|
+
top + plotHeight + 24,
|
|
409
|
+
11,
|
|
410
|
+
TK.text,
|
|
411
|
+
frame,
|
|
412
|
+
"middle"
|
|
413
|
+
));
|
|
414
|
+
seriesToRender.forEach((series, seriesIndex) => {
|
|
397
415
|
const color = PALETTE[seriesIndex % PALETTE.length];
|
|
398
416
|
if (series.kind === "line") {
|
|
399
417
|
const linePoints = series.values.map((value, index) => {
|
|
@@ -403,10 +421,8 @@ function renderChartOnCanvas(chart) {
|
|
|
403
421
|
strokeWidth: 2,
|
|
404
422
|
fill: color.fill,
|
|
405
423
|
fillStyle: "solid",
|
|
406
|
-
roughness: 0
|
|
407
|
-
|
|
408
|
-
labelColor: contrastText(color.fill),
|
|
409
|
-
labelFontSize: 9
|
|
424
|
+
roughness: 0,
|
|
425
|
+
disableMultiStroke: true
|
|
410
426
|
}), frame);
|
|
411
427
|
return [point.x, point.y, 0.5];
|
|
412
428
|
});
|
|
@@ -420,7 +436,7 @@ function renderChartOnCanvas(chart) {
|
|
|
420
436
|
}), frame);
|
|
421
437
|
}
|
|
422
438
|
} else {
|
|
423
|
-
const barWidth = Math.max(18, slot * 0.7 /
|
|
439
|
+
const barWidth = Math.max(18, slot * 0.7 / seriesToRender.length);
|
|
424
440
|
series.values.forEach((value, index) => {
|
|
425
441
|
const barHeight = Math.max(8, Math.abs(value) / maximum * plotHeight);
|
|
426
442
|
const x = left + slot * index + slot * 0.15 + seriesIndex * barWidth;
|
|
@@ -429,12 +445,12 @@ function renderChartOnCanvas(chart) {
|
|
|
429
445
|
strokeWidth: 1.5,
|
|
430
446
|
fill: color.fill,
|
|
431
447
|
fillStyle: "solid",
|
|
432
|
-
roughness: 0
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
labelFontSize: 11
|
|
448
|
+
roughness: 0,
|
|
449
|
+
disableMultiStroke: true,
|
|
450
|
+
disableMultiStrokeFill: true,
|
|
451
|
+
preserveVertices: true
|
|
437
452
|
}), frame);
|
|
453
|
+
pushText(String(value), x + barWidth / 2, top + plotHeight - barHeight - 7, 10, TK.text, frame, "middle");
|
|
438
454
|
});
|
|
439
455
|
}
|
|
440
456
|
});
|
|
@@ -508,4 +524,4 @@ export {
|
|
|
508
524
|
renderEROnCanvas,
|
|
509
525
|
renderERPreviewSVG
|
|
510
526
|
};
|
|
511
|
-
//# sourceMappingURL=MermaidStructuredRenderer-
|
|
527
|
+
//# sourceMappingURL=MermaidStructuredRenderer-W7UKN7BM.js.map
|