@logicflow/core 2.0.0-beta.1 → 2.0.0-beta.10
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/.turbo/turbo-build$colon$dev.log +2 -2
- package/.turbo/turbo-build.log +9 -9
- package/__tests__/bugs/1545-spec.test.ts +19 -15
- package/__tests__/util/edge.test.ts +57 -57
- package/dist/index.min.js +9 -3
- package/es/LogicFlow.d.ts +88 -40
- package/es/LogicFlow.js +38 -33
- package/es/LogicFlow.js.map +1 -1
- package/es/algorithm/edge.js.map +1 -1
- package/es/algorithm/index.d.ts +2 -0
- package/es/algorithm/index.js +2 -0
- package/es/algorithm/index.js.map +1 -1
- package/es/algorithm/outline.d.ts +1 -1
- package/es/common/drag.d.ts +51 -0
- package/es/common/drag.js +145 -0
- package/es/common/drag.js.map +1 -0
- package/es/common/history.d.ts +28 -0
- package/es/common/history.js +92 -0
- package/es/common/history.js.map +1 -0
- package/es/common/index.d.ts +5 -0
- package/es/common/index.js +6 -0
- package/es/common/index.js.map +1 -0
- package/es/common/keyboard.d.ts +34 -0
- package/es/common/keyboard.js +80 -0
- package/es/common/keyboard.js.map +1 -0
- package/es/common/matrix.d.ts +30 -0
- package/es/common/matrix.js +155 -0
- package/es/common/matrix.js.map +1 -0
- package/es/common/vector.d.ts +23 -0
- package/es/common/vector.js +97 -0
- package/es/common/vector.js.map +1 -0
- package/es/constant/index.d.ts +39 -2
- package/es/constant/index.js +41 -1
- package/es/constant/index.js.map +1 -1
- package/es/event/eventArgs.d.ts +103 -25
- package/es/event/eventEmitter.d.ts +2 -2
- package/es/event/eventEmitter.js +0 -1
- package/es/event/eventEmitter.js.map +1 -1
- package/es/index.d.ts +6 -1
- package/es/index.js +6 -1
- package/es/index.js.map +1 -1
- package/es/keyboard/index.d.ts +1 -0
- package/es/keyboard/index.js +1 -0
- package/es/keyboard/index.js.map +1 -1
- package/es/keyboard/shortcut.d.ts +8 -0
- package/es/keyboard/shortcut.js +70 -8
- package/es/keyboard/shortcut.js.map +1 -1
- package/es/model/BaseModel.d.ts +16 -7
- package/es/model/EditConfigModel.d.ts +97 -36
- package/es/model/EditConfigModel.js +169 -82
- package/es/model/EditConfigModel.js.map +1 -1
- package/es/model/GraphModel.d.ts +36 -14
- package/es/model/GraphModel.js +60 -10
- package/es/model/GraphModel.js.map +1 -1
- package/es/model/SnaplineModel.d.ts +2 -0
- package/es/model/TransformModel.js +1 -1
- package/es/model/TransformModel.js.map +1 -1
- package/es/model/edge/BaseEdgeModel.d.ts +21 -17
- package/es/model/edge/BaseEdgeModel.js +64 -42
- package/es/model/edge/BaseEdgeModel.js.map +1 -1
- package/es/model/edge/BezierEdgeModel.d.ts +5 -3
- package/es/model/edge/BezierEdgeModel.js +7 -3
- package/es/model/edge/BezierEdgeModel.js.map +1 -1
- package/es/model/edge/LineEdgeModel.d.ts +2 -0
- package/es/model/edge/LineEdgeModel.js +2 -1
- package/es/model/edge/LineEdgeModel.js.map +1 -1
- package/es/model/edge/PolylineEdgeModel.d.ts +5 -3
- package/es/model/edge/PolylineEdgeModel.js +22 -15
- package/es/model/edge/PolylineEdgeModel.js.map +1 -1
- package/es/model/node/BaseNodeModel.d.ts +42 -14
- package/es/model/node/BaseNodeModel.js +62 -48
- package/es/model/node/BaseNodeModel.js.map +1 -1
- package/es/model/node/CircleNodeModel.d.ts +4 -3
- package/es/model/node/CircleNodeModel.js +4 -7
- package/es/model/node/CircleNodeModel.js.map +1 -1
- package/es/model/node/DiamondNodeModel.d.ts +5 -4
- package/es/model/node/DiamondNodeModel.js +4 -6
- package/es/model/node/DiamondNodeModel.js.map +1 -1
- package/es/model/node/EllipseNodeModel.d.ts +5 -4
- package/es/model/node/EllipseNodeModel.js +4 -6
- package/es/model/node/EllipseNodeModel.js.map +1 -1
- package/es/model/node/HtmlNodeModel.d.ts +4 -5
- package/es/model/node/HtmlNodeModel.js +2 -12
- package/es/model/node/HtmlNodeModel.js.map +1 -1
- package/es/model/node/PolygonNodeModel.d.ts +5 -4
- package/es/model/node/PolygonNodeModel.js +4 -7
- package/es/model/node/PolygonNodeModel.js.map +1 -1
- package/es/model/node/RectNodeModel.d.ts +7 -5
- package/es/model/node/RectNodeModel.js +10 -7
- package/es/model/node/RectNodeModel.js.map +1 -1
- package/es/model/node/TextNodeModel.d.ts +17 -9
- package/es/model/node/TextNodeModel.js +2 -1
- package/es/model/node/TextNodeModel.js.map +1 -1
- package/es/options.d.ts +6 -3
- package/es/options.js +2 -11
- package/es/options.js.map +1 -1
- package/es/tool/MultipleSelectTool.d.ts +1 -1
- package/es/tool/MultipleSelectTool.js +5 -5
- package/es/tool/MultipleSelectTool.js.map +1 -1
- package/es/tool/TextEditTool.d.ts +3 -3
- package/es/tool/TextEditTool.js +2 -2
- package/es/tool/TextEditTool.js.map +1 -1
- package/es/tool/index.d.ts +24 -2
- package/es/tool/index.js +82 -2
- package/es/tool/index.js.map +1 -1
- package/es/util/drag.d.ts +5 -5
- package/es/util/drag.js +3 -1
- package/es/util/drag.js.map +1 -1
- package/es/util/edge.d.ts +9 -2
- package/es/util/edge.js +23 -12
- package/es/util/edge.js.map +1 -1
- package/es/util/index.d.ts +1 -0
- package/es/util/index.js +1 -0
- package/es/util/index.js.map +1 -1
- package/es/util/node.d.ts +8 -7
- package/es/util/node.js +26 -7
- package/es/util/node.js.map +1 -1
- package/es/util/resize.d.ts +32 -0
- package/es/util/resize.js +197 -0
- package/es/util/resize.js.map +1 -0
- package/es/view/Anchor.d.ts +6 -7
- package/es/view/Anchor.js +6 -3
- package/es/view/Anchor.js.map +1 -1
- package/es/view/Control.d.ts +1 -1
- package/es/view/Control.js +88 -39
- package/es/view/Control.js.map +1 -1
- package/es/view/Graph.d.ts +5 -1
- package/es/view/Graph.js +43 -3
- package/es/view/Graph.js.map +1 -1
- package/es/view/Rotate.js +2 -1
- package/es/view/Rotate.js.map +1 -1
- package/es/view/behavior/index.d.ts +2 -0
- package/es/view/behavior/index.js +3 -0
- package/es/view/behavior/index.js.map +1 -0
- package/es/view/behavior/snapline.d.ts +3 -0
- package/es/{tool → view/behavior}/snapline.js +0 -1
- package/es/view/behavior/snapline.js.map +1 -0
- package/es/view/edge/AdjustPoint.js +12 -23
- package/es/view/edge/AdjustPoint.js.map +1 -1
- package/es/view/edge/BaseEdge.d.ts +2 -2
- package/es/view/edge/BaseEdge.js +30 -22
- package/es/view/edge/BaseEdge.js.map +1 -1
- package/es/view/node/BaseNode.d.ts +4 -4
- package/es/view/node/BaseNode.js +33 -24
- package/es/view/node/BaseNode.js.map +1 -1
- package/es/view/node/CircleNode.d.ts +1 -1
- package/es/view/node/CircleNode.js.map +1 -1
- package/es/view/node/DiamondNode.d.ts +1 -1
- package/es/view/node/DiamondNode.js.map +1 -1
- package/es/view/node/EllipseNode.d.ts +1 -1
- package/es/view/node/EllipseNode.js.map +1 -1
- package/es/view/node/HtmlNode.d.ts +1 -1
- package/es/view/node/HtmlNode.js +2 -2
- package/es/view/node/HtmlNode.js.map +1 -1
- package/es/view/node/PolygonNode.d.ts +1 -1
- package/es/view/node/PolygonNode.js.map +1 -1
- package/es/view/node/RectNode.d.ts +1 -1
- package/es/view/node/RectNode.js.map +1 -1
- package/es/view/node/TextNode.d.ts +1 -1
- package/es/view/node/TextNode.js +1 -1
- package/es/view/node/TextNode.js.map +1 -1
- package/es/view/overlay/CanvasOverlay.js +5 -4
- package/es/view/overlay/CanvasOverlay.js.map +1 -1
- package/es/view/overlay/ToolOverlay.d.ts +1 -1
- package/es/view/overlay/ToolOverlay.js +1 -1
- package/es/view/overlay/ToolOverlay.js.map +1 -1
- package/es/view/shape/Circle.d.ts +9 -1
- package/es/view/shape/Circle.js +5 -5
- package/es/view/shape/Circle.js.map +1 -1
- package/es/view/shape/Ellipse.d.ts +10 -1
- package/es/view/shape/Ellipse.js +5 -5
- package/es/view/shape/Ellipse.js.map +1 -1
- package/es/view/shape/Line.d.ts +14 -1
- package/es/view/shape/Line.js +5 -7
- package/es/view/shape/Line.js.map +1 -1
- package/es/view/shape/Path.d.ts +3 -2
- package/es/view/shape/Path.js +3 -3
- package/es/view/shape/Path.js.map +1 -1
- package/es/view/shape/Polygon.d.ts +5 -3
- package/es/view/shape/Polygon.js +6 -6
- package/es/view/shape/Polygon.js.map +1 -1
- package/es/view/shape/Polyline.d.ts +7 -1
- package/es/view/shape/Polyline.js +8 -6
- package/es/view/shape/Polyline.js.map +1 -1
- package/es/view/shape/Rect.d.ts +11 -13
- package/es/view/shape/Rect.js +6 -9
- package/es/view/shape/Rect.js.map +1 -1
- package/es/view/shape/Text.d.ts +19 -1
- package/es/view/shape/Text.js +28 -21
- package/es/view/shape/Text.js.map +1 -1
- package/es/view/text/BaseText.d.ts +12 -15
- package/es/view/text/BaseText.js +43 -29
- package/es/view/text/BaseText.js.map +1 -1
- package/es/view/text/LineText.d.ts +19 -7
- package/es/view/text/LineText.js +62 -54
- package/es/view/text/LineText.js.map +1 -1
- package/lib/LogicFlow.d.ts +88 -40
- package/lib/LogicFlow.js +40 -35
- package/lib/LogicFlow.js.map +1 -1
- package/lib/algorithm/edge.js.map +1 -1
- package/lib/algorithm/index.d.ts +2 -0
- package/lib/algorithm/index.js +17 -1
- package/lib/algorithm/index.js.map +1 -1
- package/lib/algorithm/outline.d.ts +1 -1
- package/lib/common/drag.d.ts +51 -0
- package/lib/common/drag.js +148 -0
- package/lib/common/drag.js.map +1 -0
- package/lib/common/history.d.ts +28 -0
- package/lib/common/history.js +95 -0
- package/lib/common/history.js.map +1 -0
- package/lib/common/index.d.ts +5 -0
- package/lib/common/index.js +22 -0
- package/lib/common/index.js.map +1 -0
- package/lib/common/keyboard.d.ts +34 -0
- package/lib/common/keyboard.js +86 -0
- package/lib/common/keyboard.js.map +1 -0
- package/lib/common/matrix.d.ts +30 -0
- package/lib/common/matrix.js +158 -0
- package/lib/common/matrix.js.map +1 -0
- package/lib/common/vector.d.ts +23 -0
- package/lib/common/vector.js +101 -0
- package/lib/common/vector.js.map +1 -0
- package/lib/constant/index.d.ts +39 -2
- package/lib/constant/index.js +42 -2
- package/lib/constant/index.js.map +1 -1
- package/lib/event/eventArgs.d.ts +103 -25
- package/lib/event/eventEmitter.d.ts +2 -2
- package/lib/event/eventEmitter.js +0 -1
- package/lib/event/eventEmitter.js.map +1 -1
- package/lib/index.d.ts +6 -1
- package/lib/index.js +7 -2
- package/lib/index.js.map +1 -1
- package/lib/keyboard/index.d.ts +1 -0
- package/lib/keyboard/index.js +15 -0
- package/lib/keyboard/index.js.map +1 -1
- package/lib/keyboard/shortcut.d.ts +8 -0
- package/lib/keyboard/shortcut.js +75 -9
- package/lib/keyboard/shortcut.js.map +1 -1
- package/lib/model/BaseModel.d.ts +16 -7
- package/lib/model/EditConfigModel.d.ts +97 -36
- package/lib/model/EditConfigModel.js +168 -81
- package/lib/model/EditConfigModel.js.map +1 -1
- package/lib/model/GraphModel.d.ts +36 -14
- package/lib/model/GraphModel.js +59 -9
- package/lib/model/GraphModel.js.map +1 -1
- package/lib/model/SnaplineModel.d.ts +2 -0
- package/lib/model/TransformModel.js +1 -1
- package/lib/model/TransformModel.js.map +1 -1
- package/lib/model/edge/BaseEdgeModel.d.ts +21 -17
- package/lib/model/edge/BaseEdgeModel.js +61 -39
- package/lib/model/edge/BaseEdgeModel.js.map +1 -1
- package/lib/model/edge/BezierEdgeModel.d.ts +5 -3
- package/lib/model/edge/BezierEdgeModel.js +6 -2
- package/lib/model/edge/BezierEdgeModel.js.map +1 -1
- package/lib/model/edge/LineEdgeModel.d.ts +2 -0
- package/lib/model/edge/LineEdgeModel.js +2 -1
- package/lib/model/edge/LineEdgeModel.js.map +1 -1
- package/lib/model/edge/PolylineEdgeModel.d.ts +5 -3
- package/lib/model/edge/PolylineEdgeModel.js +21 -14
- package/lib/model/edge/PolylineEdgeModel.js.map +1 -1
- package/lib/model/node/BaseNodeModel.d.ts +42 -14
- package/lib/model/node/BaseNodeModel.js +60 -46
- package/lib/model/node/BaseNodeModel.js.map +1 -1
- package/lib/model/node/CircleNodeModel.d.ts +4 -3
- package/lib/model/node/CircleNodeModel.js +4 -7
- package/lib/model/node/CircleNodeModel.js.map +1 -1
- package/lib/model/node/DiamondNodeModel.d.ts +5 -4
- package/lib/model/node/DiamondNodeModel.js +4 -6
- package/lib/model/node/DiamondNodeModel.js.map +1 -1
- package/lib/model/node/EllipseNodeModel.d.ts +5 -4
- package/lib/model/node/EllipseNodeModel.js +4 -6
- package/lib/model/node/EllipseNodeModel.js.map +1 -1
- package/lib/model/node/HtmlNodeModel.d.ts +4 -5
- package/lib/model/node/HtmlNodeModel.js +2 -12
- package/lib/model/node/HtmlNodeModel.js.map +1 -1
- package/lib/model/node/PolygonNodeModel.d.ts +5 -4
- package/lib/model/node/PolygonNodeModel.js +4 -7
- package/lib/model/node/PolygonNodeModel.js.map +1 -1
- package/lib/model/node/RectNodeModel.d.ts +7 -5
- package/lib/model/node/RectNodeModel.js +10 -7
- package/lib/model/node/RectNodeModel.js.map +1 -1
- package/lib/model/node/TextNodeModel.d.ts +17 -9
- package/lib/model/node/TextNodeModel.js +2 -1
- package/lib/model/node/TextNodeModel.js.map +1 -1
- package/lib/options.d.ts +6 -3
- package/lib/options.js +2 -11
- package/lib/options.js.map +1 -1
- package/lib/tool/MultipleSelectTool.d.ts +1 -1
- package/lib/tool/MultipleSelectTool.js +5 -5
- package/lib/tool/MultipleSelectTool.js.map +1 -1
- package/lib/tool/TextEditTool.d.ts +3 -3
- package/lib/tool/TextEditTool.js +4 -4
- package/lib/tool/TextEditTool.js.map +1 -1
- package/lib/tool/index.d.ts +24 -2
- package/lib/tool/index.js +85 -15
- package/lib/tool/index.js.map +1 -1
- package/lib/util/drag.d.ts +5 -5
- package/lib/util/drag.js +3 -1
- package/lib/util/drag.js.map +1 -1
- package/lib/util/edge.d.ts +9 -2
- package/lib/util/edge.js +27 -15
- package/lib/util/edge.js.map +1 -1
- package/lib/util/index.d.ts +1 -0
- package/lib/util/index.js +1 -0
- package/lib/util/index.js.map +1 -1
- package/lib/util/node.d.ts +8 -7
- package/lib/util/node.js +28 -9
- package/lib/util/node.js.map +1 -1
- package/lib/util/resize.d.ts +32 -0
- package/lib/util/resize.js +204 -0
- package/lib/util/resize.js.map +1 -0
- package/lib/view/Anchor.d.ts +6 -7
- package/lib/view/Anchor.js +5 -2
- package/lib/view/Anchor.js.map +1 -1
- package/lib/view/Control.d.ts +1 -1
- package/lib/view/Control.js +87 -38
- package/lib/view/Control.js.map +1 -1
- package/lib/view/Graph.d.ts +5 -1
- package/lib/view/Graph.js +42 -2
- package/lib/view/Graph.js.map +1 -1
- package/lib/view/Rotate.js +2 -1
- package/lib/view/Rotate.js.map +1 -1
- package/lib/view/behavior/index.d.ts +2 -0
- package/lib/view/behavior/index.js +19 -0
- package/lib/view/behavior/index.js.map +1 -0
- package/lib/view/behavior/snapline.d.ts +3 -0
- package/lib/{tool → view/behavior}/snapline.js +0 -1
- package/lib/view/behavior/snapline.js.map +1 -0
- package/lib/view/edge/AdjustPoint.js +11 -22
- package/lib/view/edge/AdjustPoint.js.map +1 -1
- package/lib/view/edge/BaseEdge.d.ts +2 -2
- package/lib/view/edge/BaseEdge.js +29 -21
- package/lib/view/edge/BaseEdge.js.map +1 -1
- package/lib/view/node/BaseNode.d.ts +4 -4
- package/lib/view/node/BaseNode.js +32 -23
- package/lib/view/node/BaseNode.js.map +1 -1
- package/lib/view/node/CircleNode.d.ts +1 -1
- package/lib/view/node/CircleNode.js.map +1 -1
- package/lib/view/node/DiamondNode.d.ts +1 -1
- package/lib/view/node/DiamondNode.js.map +1 -1
- package/lib/view/node/EllipseNode.d.ts +1 -1
- package/lib/view/node/EllipseNode.js.map +1 -1
- package/lib/view/node/HtmlNode.d.ts +1 -1
- package/lib/view/node/HtmlNode.js +2 -2
- package/lib/view/node/HtmlNode.js.map +1 -1
- package/lib/view/node/PolygonNode.d.ts +1 -1
- package/lib/view/node/PolygonNode.js.map +1 -1
- package/lib/view/node/RectNode.d.ts +1 -1
- package/lib/view/node/RectNode.js.map +1 -1
- package/lib/view/node/TextNode.d.ts +1 -1
- package/lib/view/node/TextNode.js +1 -1
- package/lib/view/node/TextNode.js.map +1 -1
- package/lib/view/overlay/CanvasOverlay.js +5 -4
- package/lib/view/overlay/CanvasOverlay.js.map +1 -1
- package/lib/view/overlay/ToolOverlay.d.ts +1 -1
- package/lib/view/overlay/ToolOverlay.js +1 -1
- package/lib/view/overlay/ToolOverlay.js.map +1 -1
- package/lib/view/shape/Circle.d.ts +9 -1
- package/lib/view/shape/Circle.js +5 -5
- package/lib/view/shape/Circle.js.map +1 -1
- package/lib/view/shape/Ellipse.d.ts +10 -1
- package/lib/view/shape/Ellipse.js +5 -5
- package/lib/view/shape/Ellipse.js.map +1 -1
- package/lib/view/shape/Line.d.ts +14 -1
- package/lib/view/shape/Line.js +5 -7
- package/lib/view/shape/Line.js.map +1 -1
- package/lib/view/shape/Path.d.ts +3 -2
- package/lib/view/shape/Path.js +3 -3
- package/lib/view/shape/Path.js.map +1 -1
- package/lib/view/shape/Polygon.d.ts +5 -3
- package/lib/view/shape/Polygon.js +6 -6
- package/lib/view/shape/Polygon.js.map +1 -1
- package/lib/view/shape/Polyline.d.ts +7 -1
- package/lib/view/shape/Polyline.js +8 -6
- package/lib/view/shape/Polyline.js.map +1 -1
- package/lib/view/shape/Rect.d.ts +11 -13
- package/lib/view/shape/Rect.js +6 -9
- package/lib/view/shape/Rect.js.map +1 -1
- package/lib/view/shape/Text.d.ts +19 -1
- package/lib/view/shape/Text.js +29 -21
- package/lib/view/shape/Text.js.map +1 -1
- package/lib/view/text/BaseText.d.ts +12 -15
- package/lib/view/text/BaseText.js +46 -29
- package/lib/view/text/BaseText.js.map +1 -1
- package/lib/view/text/LineText.d.ts +19 -7
- package/lib/view/text/LineText.js +62 -57
- package/lib/view/text/LineText.js.map +1 -1
- package/package.json +2 -1
- package/src/LogicFlow.tsx +163 -79
- package/src/algorithm/edge.ts +1 -0
- package/src/algorithm/index.ts +2 -0
- package/src/algorithm/outline.ts +2 -2
- package/src/common/drag.ts +219 -0
- package/src/common/history.ts +108 -0
- package/src/common/index.ts +6 -0
- package/src/common/keyboard.ts +108 -0
- package/src/common/matrix.ts +122 -0
- package/src/common/vector.ts +93 -0
- package/src/constant/index.ts +43 -1
- package/src/event/eventArgs.ts +173 -34
- package/src/event/eventEmitter.ts +2 -3
- package/src/index.ts +6 -1
- package/src/keyboard/index.ts +2 -0
- package/src/keyboard/shortcut.ts +79 -8
- package/src/model/BaseModel.ts +18 -7
- package/src/model/EditConfigModel.ts +209 -97
- package/src/model/GraphModel.ts +64 -9
- package/src/model/TransformModel.ts +1 -1
- package/src/model/edge/BaseEdgeModel.ts +75 -44
- package/src/model/edge/BezierEdgeModel.ts +7 -6
- package/src/model/edge/LineEdgeModel.ts +2 -0
- package/src/model/edge/PolylineEdgeModel.ts +24 -18
- package/src/model/node/BaseNodeModel.ts +72 -47
- package/src/model/node/CircleNodeModel.ts +8 -7
- package/src/model/node/DiamondNodeModel.ts +9 -6
- package/src/model/node/EllipseNodeModel.ts +9 -6
- package/src/model/node/HtmlNodeModel.ts +8 -7
- package/src/model/node/PolygonNodeModel.ts +9 -7
- package/src/model/node/RectNodeModel.ts +16 -8
- package/src/model/node/TextNodeModel.ts +14 -1
- package/src/options.ts +11 -15
- package/src/tool/MultipleSelectTool.tsx +6 -6
- package/src/tool/TextEditTool.tsx +3 -3
- package/src/tool/index.ts +96 -2
- package/src/util/drag.ts +22 -6
- package/src/util/edge.ts +39 -13
- package/src/util/index.ts +1 -0
- package/src/util/node.ts +36 -13
- package/src/util/resize.ts +286 -0
- package/src/view/Anchor.tsx +7 -5
- package/src/view/Control.tsx +93 -62
- package/src/view/Graph.tsx +21 -4
- package/src/view/Rotate.tsx +2 -1
- package/src/view/behavior/index.ts +2 -0
- package/src/{tool → view/behavior}/snapline.ts +3 -4
- package/src/view/edge/AdjustPoint.tsx +35 -49
- package/src/view/edge/BaseEdge.tsx +65 -45
- package/src/view/node/BaseNode.tsx +55 -28
- package/src/view/node/CircleNode.tsx +3 -1
- package/src/view/node/DiamondNode.tsx +3 -1
- package/src/view/node/EllipseNode.tsx +3 -1
- package/src/view/node/HtmlNode.tsx +5 -3
- package/src/view/node/PolygonNode.tsx +3 -1
- package/src/view/node/RectNode.tsx +3 -1
- package/src/view/node/TextNode.tsx +4 -2
- package/src/view/overlay/CanvasOverlay.tsx +5 -4
- package/src/view/overlay/ToolOverlay.tsx +1 -1
- package/src/view/shape/Circle.tsx +21 -7
- package/src/view/shape/Ellipse.tsx +20 -6
- package/src/view/shape/Line.tsx +24 -9
- package/src/view/shape/Path.tsx +9 -6
- package/src/view/shape/Polygon.tsx +13 -10
- package/src/view/shape/Polyline.tsx +20 -8
- package/src/view/shape/Rect.tsx +19 -19
- package/src/view/shape/Text.tsx +64 -33
- package/src/view/text/BaseText.tsx +76 -42
- package/src/view/text/LineText.tsx +94 -80
- package/tsconfig.json +1 -1
- package/es/tool/snapline.d.ts +0 -3
- package/es/tool/snapline.js.map +0 -1
- package/es/tool/tool.d.ts +0 -22
- package/es/tool/tool.js +0 -43
- package/es/tool/tool.js.map +0 -1
- package/lib/tool/snapline.d.ts +0 -3
- package/lib/tool/snapline.js.map +0 -1
- package/lib/tool/tool.d.ts +0 -22
- package/lib/tool/tool.js +0 -49
- package/lib/tool/tool.js.map +0 -1
- package/src/tool/tool.ts +0 -66
package/src/view/shape/Rect.tsx
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createElement as h } from 'preact/compat'
|
|
2
|
+
import { forEach, toPairs } from 'lodash-es'
|
|
3
|
+
import LogicFlow from '../..'
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
export type IRectProps = {
|
|
6
|
+
x: number
|
|
7
|
+
y: number
|
|
8
|
+
width: number
|
|
9
|
+
height: number
|
|
7
10
|
className?: string
|
|
8
|
-
radius?:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
radius?: LogicFlow.NumberOrPercent
|
|
12
|
+
[key: string]: any
|
|
13
|
+
}
|
|
11
14
|
|
|
12
|
-
export function Rect(props: IRectProps) {
|
|
13
|
-
const { x, y, width, height, className, radius } = props
|
|
15
|
+
export function Rect(props: IRectProps): h.JSX.Element {
|
|
16
|
+
const { x, y, width, height, className, strokeWidth, radius = 0 } = props
|
|
14
17
|
|
|
15
18
|
const leftTopX = x - width / 2
|
|
16
19
|
const leftTopY = y - height / 2
|
|
17
20
|
const attrs: Record<string, any> = {}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (
|
|
21
|
+
attrs['stroke-width'] = strokeWidth
|
|
22
|
+
forEach(toPairs(props), ([k, v]: [k: string, v: any]) => {
|
|
23
|
+
if (typeof v !== 'object') {
|
|
21
24
|
attrs[k] = v
|
|
22
25
|
}
|
|
23
26
|
})
|
|
@@ -25,20 +28,17 @@ export function Rect(props: IRectProps) {
|
|
|
25
28
|
if (className) {
|
|
26
29
|
attrs.className = `lf-basic-shape ${className}`
|
|
27
30
|
} else {
|
|
28
|
-
attrs.className = 'lf-shape'
|
|
31
|
+
attrs.className = 'lf-basic-shape'
|
|
29
32
|
}
|
|
33
|
+
|
|
30
34
|
if (radius) {
|
|
31
35
|
attrs.rx = radius
|
|
32
36
|
attrs.ry = radius
|
|
33
37
|
}
|
|
34
38
|
attrs.x = leftTopX
|
|
35
39
|
attrs.y = leftTopY
|
|
36
|
-
return <rect {...attrs} />
|
|
37
|
-
}
|
|
38
40
|
|
|
39
|
-
|
|
40
|
-
className: '',
|
|
41
|
-
radius: '',
|
|
41
|
+
return <rect {...attrs} />
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
export default Rect
|
package/src/view/shape/Text.tsx
CHANGED
|
@@ -1,37 +1,63 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createElement as h } from 'preact/compat'
|
|
2
|
+
import { BaseNodeModel, BaseEdgeModel } from '../../model'
|
|
2
3
|
import { ElementType, ModelType } from '../../constant'
|
|
4
|
+
import { getHtmlTextHeight } from '../../util'
|
|
5
|
+
import { forEach, toPairs } from 'lodash-es'
|
|
6
|
+
|
|
7
|
+
export type ITextProps = {
|
|
8
|
+
x: number
|
|
9
|
+
y: number
|
|
10
|
+
value: string
|
|
11
|
+
fontSize?: number
|
|
12
|
+
fill?: string
|
|
13
|
+
overflowMode?: 'default' | 'autoWrap' | 'ellipsis'
|
|
14
|
+
textWidth?: number
|
|
15
|
+
lineHeight?: number
|
|
16
|
+
fontFamily?: string | null
|
|
17
|
+
wrapPadding?: string | number | null
|
|
18
|
+
model: BaseNodeModel | BaseEdgeModel
|
|
19
|
+
[key: string]: any
|
|
20
|
+
}
|
|
21
|
+
export type ForeignObjectPropsType =
|
|
22
|
+
'string | number | SignalLike<string | number | undefined> | undefined'
|
|
3
23
|
|
|
4
|
-
export function Text(props) {
|
|
24
|
+
export function Text(props: ITextProps): h.JSX.Element | null {
|
|
5
25
|
const {
|
|
6
26
|
x = 0,
|
|
7
27
|
y = 0,
|
|
8
28
|
value,
|
|
9
|
-
fontSize,
|
|
29
|
+
fontSize = 12,
|
|
10
30
|
fill = 'currentColor',
|
|
11
31
|
overflowMode = 'default',
|
|
12
|
-
textWidth
|
|
32
|
+
// TODO: 确认该 textWidth 为 '' 时跟设置什么值一致
|
|
33
|
+
textWidth = undefined,
|
|
13
34
|
model,
|
|
14
35
|
} = props
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
'dominant-baseline': 'middle',
|
|
36
|
+
|
|
37
|
+
const attrs: Record<string, any> = {
|
|
18
38
|
x,
|
|
19
39
|
y,
|
|
20
40
|
fill,
|
|
41
|
+
fontSize,
|
|
42
|
+
textAnchor: 'middle',
|
|
43
|
+
dominantBaseline: 'central',
|
|
21
44
|
// ...props,
|
|
22
45
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (
|
|
46
|
+
|
|
47
|
+
forEach(toPairs(props), ([k, v]: [k: string, v: any]) => {
|
|
48
|
+
if (typeof v !== 'object') {
|
|
26
49
|
attrs[k] = v
|
|
27
50
|
}
|
|
28
51
|
})
|
|
52
|
+
|
|
29
53
|
if (value) {
|
|
30
|
-
// String(value)
|
|
54
|
+
// String(value),兼容纯数字的文案
|
|
55
|
+
// TODO: 将 value 转为纯文本,移除其中 \n \r 等特殊字符,看是否应该丰富该功能
|
|
31
56
|
const rows = String(value).split(/[\r\n]/g)
|
|
32
57
|
const rowsLength = rows.length
|
|
58
|
+
|
|
33
59
|
if (overflowMode !== 'default') {
|
|
34
|
-
//
|
|
60
|
+
// 非文本节点设置了自动换行,或者边设置了自动换行并且设置了 textWidth
|
|
35
61
|
const { BaseType, modelType } = model
|
|
36
62
|
if (
|
|
37
63
|
(BaseType === ElementType.NODE && modelType !== ModelType.TEXT_NODE) ||
|
|
@@ -40,11 +66,12 @@ export function Text(props) {
|
|
|
40
66
|
return renderHtmlText(props)
|
|
41
67
|
}
|
|
42
68
|
}
|
|
69
|
+
|
|
43
70
|
if (rowsLength > 1) {
|
|
44
|
-
const tSpans = rows.map((row,
|
|
45
|
-
// 保证文字居中,文字Y轴偏移为当前行数对应中心行数的偏移行 * 行高
|
|
46
|
-
const
|
|
47
|
-
const offsetY = (
|
|
71
|
+
const tSpans = rows.map((row, idx) => {
|
|
72
|
+
// 保证文字居中,文字 Y 轴偏移为当前行数对应中心行数的偏移行 * 行高
|
|
73
|
+
const tSpanLineHeight = fontSize + 2
|
|
74
|
+
const offsetY = (idx - (rowsLength - 1) / 2) * tSpanLineHeight
|
|
48
75
|
return (
|
|
49
76
|
<tspan className="lf-text-tspan" x={x} y={y + offsetY}>
|
|
50
77
|
{row}
|
|
@@ -55,24 +82,26 @@ export function Text(props) {
|
|
|
55
82
|
}
|
|
56
83
|
return <text {...attrs}>{value}</text>
|
|
57
84
|
}
|
|
58
|
-
|
|
59
85
|
return null
|
|
60
86
|
}
|
|
61
87
|
|
|
62
|
-
function renderHtmlText(props) {
|
|
88
|
+
export function renderHtmlText(props: ITextProps): h.JSX.Element {
|
|
63
89
|
const {
|
|
90
|
+
x,
|
|
91
|
+
y,
|
|
64
92
|
value,
|
|
65
|
-
fontSize,
|
|
66
93
|
model,
|
|
67
|
-
|
|
94
|
+
textWidth,
|
|
95
|
+
fontSize = 12,
|
|
68
96
|
lineHeight,
|
|
97
|
+
fontFamily = '',
|
|
69
98
|
wrapPadding = '0, 0',
|
|
70
99
|
overflowMode,
|
|
71
|
-
x,
|
|
72
|
-
y,
|
|
73
100
|
} = props
|
|
74
|
-
|
|
75
|
-
const
|
|
101
|
+
|
|
102
|
+
const { width, height, textHeight } = model
|
|
103
|
+
// TODO: 设置文本宽度为 textWidth 或 节点的宽度
|
|
104
|
+
const textRealWidth: number = textWidth || (width as number)
|
|
76
105
|
const rows = String(value).split(/[\r\n]/g)
|
|
77
106
|
const rowsLength = rows.length
|
|
78
107
|
const textRealHeight = getHtmlTextHeight({
|
|
@@ -87,17 +116,20 @@ function renderHtmlText(props) {
|
|
|
87
116
|
rowsLength,
|
|
88
117
|
className: 'lf-get-text-height',
|
|
89
118
|
})
|
|
119
|
+
|
|
90
120
|
// 当文字超过边框时,取文字高度的实际值,也就是文字可以超过边框
|
|
91
|
-
let foreignObjectHeight =
|
|
92
|
-
|
|
93
|
-
//
|
|
121
|
+
let foreignObjectHeight: number =
|
|
122
|
+
(height as number) > textRealHeight ? (height as number) : textRealHeight
|
|
123
|
+
// 如果设置了文本高度,取设置的高度
|
|
94
124
|
if (textHeight) {
|
|
95
|
-
foreignObjectHeight = textHeight
|
|
125
|
+
foreignObjectHeight = textHeight as number
|
|
96
126
|
}
|
|
127
|
+
|
|
97
128
|
const isEllipsis = overflowMode === 'ellipsis'
|
|
98
129
|
if (isEllipsis) {
|
|
99
130
|
foreignObjectHeight = fontSize + 2
|
|
100
131
|
}
|
|
132
|
+
|
|
101
133
|
return (
|
|
102
134
|
<g>
|
|
103
135
|
<foreignObject
|
|
@@ -105,6 +137,7 @@ function renderHtmlText(props) {
|
|
|
105
137
|
height={foreignObjectHeight}
|
|
106
138
|
x={x - textRealWidth / 2}
|
|
107
139
|
y={y - foreignObjectHeight / 2}
|
|
140
|
+
style={{ overflow: 'visible', textAlign: 'left' }}
|
|
108
141
|
>
|
|
109
142
|
<div
|
|
110
143
|
className="lf-node-text-auto-wrap"
|
|
@@ -121,12 +154,10 @@ function renderHtmlText(props) {
|
|
|
121
154
|
: 'lf-node-text-auto-wrap-content'
|
|
122
155
|
}
|
|
123
156
|
title={isEllipsis ? rows.join('') : ''}
|
|
124
|
-
style={{
|
|
125
|
-
...props,
|
|
126
|
-
}}
|
|
157
|
+
style={{ ...(props as h.JSX.CSSProperties) }}
|
|
127
158
|
>
|
|
128
|
-
{rows.map((
|
|
129
|
-
<div className="lf-node-text--auto-wrap-inner">{
|
|
159
|
+
{rows.map((row) => (
|
|
160
|
+
<div className="lf-node-text--auto-wrap-inner">{row}</div>
|
|
130
161
|
))}
|
|
131
162
|
</div>
|
|
132
163
|
</div>
|
|
@@ -1,91 +1,125 @@
|
|
|
1
|
-
import
|
|
1
|
+
import classNames from 'classnames'
|
|
2
|
+
import { createElement as h, Component } from 'preact/compat'
|
|
3
|
+
import { ElementState, EventType } from '../../constant'
|
|
4
|
+
import { GraphModel, BaseNodeModel, BaseEdgeModel } from '../../model'
|
|
2
5
|
import { Text } from '../shape'
|
|
3
|
-
import { StepDrag } from '../../util'
|
|
4
|
-
import { ElementState } from '../../constant'
|
|
5
|
-
import { GraphModel, Model } from '../../model'
|
|
6
|
+
import { IDragParams, StepDrag } from '../../util'
|
|
6
7
|
|
|
7
|
-
type
|
|
8
|
-
model:
|
|
8
|
+
export type IBaseTextProps = {
|
|
9
|
+
model: BaseNodeModel | BaseEdgeModel
|
|
9
10
|
graphModel: GraphModel
|
|
10
11
|
draggable: boolean
|
|
11
12
|
editable: boolean
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
+
|
|
15
|
+
export type IBaseTextState = {
|
|
14
16
|
isHovered: boolean
|
|
15
17
|
}
|
|
16
18
|
|
|
17
|
-
export class BaseText
|
|
18
|
-
|
|
19
|
+
export class BaseText<
|
|
20
|
+
P extends IBaseTextProps,
|
|
21
|
+
S extends IBaseTextState,
|
|
22
|
+
> extends Component<P, S> {
|
|
23
|
+
stepperDrag: StepDrag
|
|
19
24
|
|
|
20
|
-
constructor(
|
|
25
|
+
constructor(props: P) {
|
|
21
26
|
super()
|
|
22
|
-
const { draggable } =
|
|
23
|
-
|
|
27
|
+
const { draggable } = props
|
|
28
|
+
// TODO: 确认为什么不在 new 的时候传入 model,而在下面使用的时候赋值
|
|
29
|
+
this.stepperDrag = new StepDrag({
|
|
24
30
|
onDragging: this.onDragging,
|
|
25
31
|
step: 1,
|
|
32
|
+
// model,
|
|
33
|
+
eventType: 'TEXT',
|
|
26
34
|
isStopPropagation: draggable,
|
|
27
35
|
})
|
|
28
36
|
}
|
|
29
37
|
|
|
30
38
|
getShape(): h.JSX.Element | null {
|
|
31
39
|
const { model, graphModel } = this.props
|
|
32
|
-
const { text } = model
|
|
33
40
|
const { editConfigModel } = graphModel
|
|
34
|
-
const {
|
|
41
|
+
const {
|
|
42
|
+
text: { value, x, y, editable, draggable },
|
|
43
|
+
} = model
|
|
35
44
|
const attr = {
|
|
36
45
|
x,
|
|
37
46
|
y,
|
|
38
47
|
className: '',
|
|
39
48
|
value,
|
|
40
49
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
} else {
|
|
46
|
-
|
|
47
|
-
}
|
|
50
|
+
// DONE: 代码优化,看是否可以引入 classnames
|
|
51
|
+
// TODO: 确认下面逻辑是否正确,确认正确后删除下面注释
|
|
52
|
+
// if (editable) {
|
|
53
|
+
// attr.className = 'lf-element-text';
|
|
54
|
+
// } else if (draggable || editConfigModel.nodeTextDraggable) {
|
|
55
|
+
// attr.className = 'lf-text-draggable';
|
|
56
|
+
// } else {
|
|
57
|
+
// attr.className = 'lf-text-disabled';
|
|
58
|
+
// }
|
|
48
59
|
const style = model.getTextStyle()
|
|
49
|
-
|
|
60
|
+
const isDraggable = editConfigModel.nodeTextDraggable || draggable
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<Text
|
|
64
|
+
{...attr}
|
|
65
|
+
{...style}
|
|
66
|
+
className={classNames({
|
|
67
|
+
'lf-element-text': editable,
|
|
68
|
+
'lf-text-draggable': !editable && isDraggable,
|
|
69
|
+
'lf-text-disabled': !editable && !isDraggable,
|
|
70
|
+
})}
|
|
71
|
+
model={model}
|
|
72
|
+
/>
|
|
73
|
+
)
|
|
50
74
|
}
|
|
51
75
|
|
|
52
|
-
|
|
76
|
+
mouseDownHandler = (e: MouseEvent) => {
|
|
77
|
+
const { draggable, model, graphModel } = this.props
|
|
78
|
+
const {
|
|
79
|
+
editConfigModel: { nodeTextDraggable },
|
|
80
|
+
} = graphModel
|
|
81
|
+
|
|
82
|
+
if (draggable ?? nodeTextDraggable) {
|
|
83
|
+
this.stepperDrag.model = model
|
|
84
|
+
this.stepperDrag.handleMouseDown(e)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
onDragging = ({ deltaX, deltaY }: IDragParams) => {
|
|
53
89
|
const {
|
|
54
90
|
model,
|
|
55
91
|
graphModel: { transformModel },
|
|
56
92
|
} = this.props
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
// 静默模式下,双击不更改状态,不可编辑
|
|
62
|
-
const { editable } = this.props
|
|
63
|
-
if (editable) {
|
|
64
|
-
const { model } = this.props
|
|
65
|
-
model.setElementState(ElementState.TEXT_EDIT)
|
|
93
|
+
|
|
94
|
+
if (deltaX && deltaY) {
|
|
95
|
+
const [curDeltaX, curDeltaY] = transformModel.fixDeltaXY(deltaX, deltaY)
|
|
96
|
+
model.moveText(curDeltaX, curDeltaY)
|
|
66
97
|
}
|
|
67
98
|
}
|
|
68
|
-
|
|
99
|
+
|
|
100
|
+
dbClickHandler = () => {
|
|
101
|
+
// 静默模式下,双击不更改状态,不可编辑
|
|
69
102
|
const {
|
|
70
|
-
|
|
103
|
+
editable,
|
|
104
|
+
graphModel: { eventCenter },
|
|
71
105
|
model,
|
|
72
|
-
graphModel: {
|
|
73
|
-
editConfigModel: { nodeTextDraggable },
|
|
74
|
-
},
|
|
75
106
|
} = this.props
|
|
76
|
-
if (
|
|
77
|
-
|
|
78
|
-
this.stepDrag.handleMouseDown(ev)
|
|
107
|
+
if (editable) {
|
|
108
|
+
model.setElementState(ElementState.TEXT_EDIT)
|
|
79
109
|
}
|
|
110
|
+
eventCenter.emit(EventType.TEXT_DBCLICK, {
|
|
111
|
+
data: model.text,
|
|
112
|
+
model,
|
|
113
|
+
})
|
|
80
114
|
}
|
|
81
115
|
|
|
82
|
-
render() {
|
|
116
|
+
render(): h.JSX.Element | undefined {
|
|
83
117
|
const {
|
|
84
118
|
model: { text },
|
|
85
119
|
} = this.props
|
|
86
120
|
if (text) {
|
|
87
121
|
return (
|
|
88
|
-
<g onMouseDown={this.
|
|
122
|
+
<g onMouseDown={this.mouseDownHandler} onDblClick={this.dbClickHandler}>
|
|
89
123
|
{this.getShape()}
|
|
90
124
|
</g>
|
|
91
125
|
)
|
|
@@ -1,40 +1,62 @@
|
|
|
1
|
-
import
|
|
2
|
-
import Rect from '
|
|
3
|
-
import BaseText from '
|
|
4
|
-
import { BaseEdgeModel } from '../../model'
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { createElement as h } from 'preact/compat'
|
|
2
|
+
import { Text, ITextProps, Rect, IRectProps } from '..'
|
|
3
|
+
import { BaseText } from '.'
|
|
4
|
+
import { BaseEdgeModel, GraphModel } from '../../model'
|
|
5
|
+
import { getHtmlTextHeight, getSvgTextSize } from '../../util'
|
|
6
|
+
|
|
7
|
+
export type ILineTextProps = {
|
|
8
|
+
model: BaseEdgeModel
|
|
9
|
+
graphModel: GraphModel
|
|
10
|
+
draggable: boolean
|
|
11
|
+
editable: boolean
|
|
12
|
+
[key: string]: unknown
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type ILineTextState = {
|
|
16
|
+
isHovered: boolean
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export class LineText extends BaseText<ILineTextProps, ILineTextState> {
|
|
20
|
+
constructor(props: ILineTextProps) {
|
|
21
|
+
super(props)
|
|
14
22
|
this.state = {
|
|
15
23
|
isHovered: false,
|
|
16
24
|
}
|
|
17
25
|
}
|
|
18
26
|
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
// Hover 状态相关
|
|
28
|
+
setHoverOn = () => {
|
|
29
|
+
this.setState({
|
|
30
|
+
isHovered: true,
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
setHoverOff = () => {
|
|
34
|
+
this.setState({
|
|
35
|
+
isHovered: false,
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
getBackground(): h.JSX.Element | null {
|
|
40
|
+
const { isHovered } = this.state
|
|
41
|
+
const { model } = this.props
|
|
42
|
+
const { text } = model
|
|
21
43
|
const style = model.getTextStyle()
|
|
22
|
-
|
|
44
|
+
|
|
23
45
|
let backgroundStyle = style.background || {}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
backgroundStyle = { ...backgroundStyle, ...style?.hover.background }
|
|
46
|
+
if (isHovered && style.hover && style.hover.background) {
|
|
47
|
+
backgroundStyle = { ...backgroundStyle, ...style.hover.background }
|
|
27
48
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const {
|
|
33
|
-
|
|
34
|
-
const rows = String(value).split(/[\r\n]/g)
|
|
35
|
-
// 计算行数
|
|
49
|
+
|
|
50
|
+
// 当存在文本并且文本背景不为透明时,计算背景框
|
|
51
|
+
if (text?.value && backgroundStyle?.fill !== 'transparent') {
|
|
52
|
+
const { fontSize, textWidth, lineHeight, overflowMode } = style
|
|
53
|
+
const { wrapPadding } = backgroundStyle
|
|
54
|
+
const rows = text?.value.split(/[\r\n]/g)
|
|
36
55
|
const rowsLength = rows.length
|
|
37
|
-
|
|
56
|
+
|
|
57
|
+
let { x, y } = text
|
|
58
|
+
let rectAttr: unknown = {}
|
|
59
|
+
|
|
38
60
|
if (overflowMode === 'autoWrap' && textWidth) {
|
|
39
61
|
const textHeight = getHtmlTextHeight({
|
|
40
62
|
rows,
|
|
@@ -47,30 +69,18 @@ export class LineText extends BaseText {
|
|
|
47
69
|
rowsLength,
|
|
48
70
|
className: 'lf-get-text-height',
|
|
49
71
|
})
|
|
72
|
+
|
|
50
73
|
rectAttr = {
|
|
51
74
|
...backgroundStyle,
|
|
52
|
-
x
|
|
53
|
-
y
|
|
75
|
+
x,
|
|
76
|
+
y,
|
|
54
77
|
width: textWidth,
|
|
55
78
|
height: textHeight,
|
|
56
79
|
}
|
|
57
80
|
} else {
|
|
58
|
-
//
|
|
59
|
-
|
|
60
|
-
rows
|
|
61
|
-
rows.forEach((item) => {
|
|
62
|
-
const rowByteLength = getBytesLength(item)
|
|
63
|
-
longestBytes =
|
|
64
|
-
rowByteLength > longestBytes ? rowByteLength : longestBytes
|
|
65
|
-
})
|
|
66
|
-
// 背景框宽度,最长一行字节数/2 * fontsize + 2
|
|
67
|
-
// 背景框宽度, 行数 * fontsize + 2
|
|
68
|
-
let { width, height } = getSvgTextWidthHeight({
|
|
69
|
-
rows,
|
|
70
|
-
fontSize,
|
|
71
|
-
rowsLength,
|
|
72
|
-
})
|
|
73
|
-
|
|
81
|
+
// 背景框宽度,最长一行字节数 / 2 * fontSize + 2
|
|
82
|
+
// 背景框宽度,行数 * fontSize + 2
|
|
83
|
+
let { width, height } = getSvgTextSize({ rows, rowsLength, fontSize })
|
|
74
84
|
if (overflowMode === 'ellipsis') {
|
|
75
85
|
// https://github.com/didi/LogicFlow/issues/1151
|
|
76
86
|
// 边上的文字过长(使用"ellipsis"模式)出现省略号,背景也需要进行宽度的重新计算
|
|
@@ -78,30 +88,38 @@ export class LineText extends BaseText {
|
|
|
78
88
|
// 跟Text.tsx保持同样的计算逻辑(overflowMode === 'ellipsis')
|
|
79
89
|
// Text.tsx使用textRealWidth=textWidth || width
|
|
80
90
|
// Text.tsx使用foreignObjectHeight = fontSize + 2;
|
|
81
|
-
width = textWidth
|
|
91
|
+
width = textWidth
|
|
82
92
|
height = fontSize + 2
|
|
83
93
|
}
|
|
84
94
|
|
|
85
|
-
// 根据设置的padding调整width, height, x, y的值
|
|
95
|
+
// 根据设置的 padding 调整 width, height, x, y 的值
|
|
96
|
+
// TODO: 下面方法感觉可以提取成工具方法
|
|
86
97
|
if (typeof backgroundStyle.wrapPadding === 'string') {
|
|
87
|
-
let
|
|
98
|
+
let padding = backgroundStyle.wrapPadding
|
|
88
99
|
.split(',')
|
|
89
100
|
.filter((padding) => padding.trim())
|
|
90
101
|
.map((padding) => parseFloat(padding.trim()))
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
} else if (
|
|
97
|
-
|
|
102
|
+
|
|
103
|
+
if (padding.length > 0 && padding.length <= 4) {
|
|
104
|
+
if (padding.length === 1) {
|
|
105
|
+
const [allSides] = padding
|
|
106
|
+
padding = [allSides, allSides, allSides, allSides]
|
|
107
|
+
} else if (padding.length === 2) {
|
|
108
|
+
const [vertical, horizontal] = padding
|
|
109
|
+
padding = [vertical, horizontal, vertical, horizontal]
|
|
110
|
+
} else if (padding.length === 3) {
|
|
111
|
+
const [top, horizontal, bottom] = padding
|
|
112
|
+
padding = [top, horizontal, bottom, horizontal]
|
|
98
113
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
114
|
+
|
|
115
|
+
const [top, right, bottom, left] = padding
|
|
116
|
+
width += right + left
|
|
117
|
+
height += top + bottom
|
|
118
|
+
x = x + (right - left) / 2
|
|
119
|
+
y = y + (bottom - top) / 2
|
|
103
120
|
}
|
|
104
121
|
}
|
|
122
|
+
|
|
105
123
|
rectAttr = {
|
|
106
124
|
...backgroundStyle,
|
|
107
125
|
x: x - 1,
|
|
@@ -110,42 +128,38 @@ export class LineText extends BaseText {
|
|
|
110
128
|
height,
|
|
111
129
|
}
|
|
112
130
|
}
|
|
113
|
-
|
|
131
|
+
|
|
132
|
+
return <Rect {...(rectAttr as IRectProps)} />
|
|
114
133
|
}
|
|
115
|
-
}
|
|
116
134
|
|
|
117
|
-
|
|
118
|
-
this.setState({
|
|
119
|
-
isHovered: true,
|
|
120
|
-
})
|
|
121
|
-
}
|
|
122
|
-
setHoverOFF = () => {
|
|
123
|
-
this.setState({
|
|
124
|
-
isHovered: false,
|
|
125
|
-
})
|
|
135
|
+
return null
|
|
126
136
|
}
|
|
127
137
|
|
|
128
|
-
getShape() {
|
|
138
|
+
getShape(): h.JSX.Element | null {
|
|
129
139
|
const { model } = this.props
|
|
130
|
-
const {
|
|
131
|
-
|
|
140
|
+
const {
|
|
141
|
+
text: { x, y, value },
|
|
142
|
+
} = model
|
|
132
143
|
if (!value) return null
|
|
144
|
+
|
|
133
145
|
const style = model.getTextStyle()
|
|
134
|
-
const
|
|
146
|
+
const attrs: ITextProps = {
|
|
135
147
|
x,
|
|
136
148
|
y,
|
|
137
|
-
className: 'lf-element-text',
|
|
138
149
|
value,
|
|
139
|
-
|
|
150
|
+
model,
|
|
151
|
+
className: 'lf-element-text',
|
|
152
|
+
...style, // 透传 edgeText 属性,如:color, fontSize, fontWeight, fontFamily, textAnchor 等
|
|
140
153
|
}
|
|
154
|
+
|
|
141
155
|
return (
|
|
142
156
|
<g
|
|
143
157
|
className="lf-line-text"
|
|
144
|
-
onMouseEnter={this.
|
|
145
|
-
onMouseLeave={this.
|
|
158
|
+
onMouseEnter={this.setHoverOn}
|
|
159
|
+
onMouseLeave={this.setHoverOff}
|
|
146
160
|
>
|
|
147
161
|
{this.getBackground()}
|
|
148
|
-
<Text {...
|
|
162
|
+
<Text {...attrs} />
|
|
149
163
|
</g>
|
|
150
164
|
)
|
|
151
165
|
}
|
package/tsconfig.json
CHANGED
package/es/tool/snapline.d.ts
DELETED
package/es/tool/snapline.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"snapline.js","sourceRoot":"","sources":["../../src/tool/snapline.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,QAAQ,CACtB,WAAyB,EACzB,aAA4B;IAE5B,eAAe;IACf,WAAW,CAAC,EAAE,CAAC,gBAAgB,EAAE,UAAC,EAAa;YAAX,IAAI,UAAA;QACtC,+BAA+B;QAC/B,aAAa,CAAC,eAAe,CAAC,IAAI,CAAC,CAAA;IACrC,CAAC,CAAC,CAAA;IACF,gBAAgB;IAChB,WAAW,CAAC,EAAE,CAAC,cAAc,EAAE;QAC7B,aAAa,CAAC,aAAa,EAAE,CAAA;IAC/B,CAAC,CAAC,CAAA;AACJ,CAAC"}
|