@logicflow/core 2.0.0-beta.0 → 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 +16 -22
- package/__tests__/bugs/1545-spec.test.ts +19 -15
- package/__tests__/util/edge.test.ts +57 -57
- package/dist/index.min.js +32 -0
- package/dist/index.min.js.map +1 -0
- 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 +11 -14
- package/es/options.js +3 -42
- 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 +45 -5
- 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/Grid.d.ts +35 -20
- package/es/view/overlay/Grid.js +35 -26
- package/es/view/overlay/Grid.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 +11 -14
- package/lib/options.js +3 -42
- 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 +44 -4
- 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/Grid.d.ts +35 -20
- package/lib/view/overlay/Grid.js +35 -26
- package/lib/view/overlay/Grid.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 +5 -4
- 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 +105 -42
- 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 +18 -53
- 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 +23 -6
- 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/Grid.tsx +75 -53
- 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/dist/index.js +0 -26
- package/dist/index.js.map +0 -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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { action, computed, isObservable, observable, toJS } from 'mobx'
|
|
2
|
-
import { assign, cloneDeep, has, isNil, mapKeys } from 'lodash-es'
|
|
2
|
+
import { assign, cloneDeep, has, isNil, mapKeys, isUndefined } from 'lodash-es'
|
|
3
3
|
import { GraphModel, Model } from '..'
|
|
4
4
|
import LogicFlow from '../../LogicFlow'
|
|
5
5
|
import {
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
EventType,
|
|
18
18
|
ModelType,
|
|
19
19
|
OverlapMode,
|
|
20
|
+
TextMode,
|
|
20
21
|
} from '../../constant'
|
|
21
22
|
import { ResizeControl } from '../../view/Control'
|
|
22
23
|
import AnchorConfig = Model.AnchorConfig
|
|
@@ -26,26 +27,30 @@ import NodeConfig = LogicFlow.NodeConfig
|
|
|
26
27
|
import NodeData = LogicFlow.NodeData
|
|
27
28
|
import Point = LogicFlow.Point
|
|
28
29
|
import CommonTheme = LogicFlow.CommonTheme
|
|
30
|
+
import PropertiesType = LogicFlow.PropertiesType
|
|
29
31
|
|
|
30
32
|
import ResizeInfo = ResizeControl.ResizeInfo
|
|
31
33
|
import ResizeNodeData = ResizeControl.ResizeNodeData
|
|
32
34
|
import PCTResizeParams = ResizeControl.PCTResizeParams
|
|
33
35
|
|
|
34
|
-
export interface IBaseNodeModel extends
|
|
36
|
+
export interface IBaseNodeModel<P extends PropertiesType>
|
|
37
|
+
extends Model.BaseModel<P> {
|
|
35
38
|
/**
|
|
36
39
|
* model基础类型,固定为node
|
|
37
40
|
*/
|
|
38
41
|
readonly BaseType: ElementType.NODE
|
|
42
|
+
properties: P
|
|
39
43
|
|
|
40
44
|
isDragging: boolean
|
|
41
45
|
isShowAnchor: boolean
|
|
42
46
|
getNodeStyle: () => CommonTheme
|
|
43
47
|
getTextStyle: () => LogicFlow.TextNodeTheme
|
|
44
|
-
|
|
45
48
|
setIsShowAnchor: (isShowAnchor: boolean) => void
|
|
46
49
|
}
|
|
47
50
|
|
|
48
|
-
export class BaseNodeModel
|
|
51
|
+
export class BaseNodeModel<P extends PropertiesType = PropertiesType>
|
|
52
|
+
implements IBaseNodeModel<P>
|
|
53
|
+
{
|
|
49
54
|
readonly BaseType = ElementType.NODE
|
|
50
55
|
static BaseType: ElementType = ElementType.NODE
|
|
51
56
|
|
|
@@ -54,6 +59,7 @@ export class BaseNodeModel implements IBaseNodeModel {
|
|
|
54
59
|
@observable readonly type = ''
|
|
55
60
|
@observable x = 0
|
|
56
61
|
@observable y = 0
|
|
62
|
+
@observable textMode = TextMode.TEXT
|
|
57
63
|
@observable text: TextConfig = {
|
|
58
64
|
value: '',
|
|
59
65
|
x: 0,
|
|
@@ -61,7 +67,7 @@ export class BaseNodeModel implements IBaseNodeModel {
|
|
|
61
67
|
draggable: false,
|
|
62
68
|
editable: true,
|
|
63
69
|
}
|
|
64
|
-
@observable properties:
|
|
70
|
+
@observable properties: P
|
|
65
71
|
// 形状属性
|
|
66
72
|
@observable private _width = 100
|
|
67
73
|
public get width() {
|
|
@@ -100,8 +106,9 @@ export class BaseNodeModel implements IBaseNodeModel {
|
|
|
100
106
|
@observable isHittable = true // 细粒度控制节点是否对用户操作进行反应
|
|
101
107
|
@observable draggable = true
|
|
102
108
|
@observable visible = true
|
|
103
|
-
|
|
104
|
-
@observable
|
|
109
|
+
|
|
110
|
+
@observable rotatable = true // 节点可旋转
|
|
111
|
+
@observable resizable = true // 节点可缩放
|
|
105
112
|
|
|
106
113
|
// 其它属性
|
|
107
114
|
graphModel: GraphModel
|
|
@@ -137,9 +144,9 @@ export class BaseNodeModel implements IBaseNodeModel {
|
|
|
137
144
|
hasSetSourceRules = false; // 用来限制rules的重复值
|
|
138
145
|
[propName: string]: any // 支持用户自定义属性
|
|
139
146
|
|
|
140
|
-
constructor(data: NodeConfig
|
|
147
|
+
constructor(data: NodeConfig<P>, graphModel: GraphModel) {
|
|
141
148
|
this.graphModel = graphModel
|
|
142
|
-
this.properties = data.properties
|
|
149
|
+
this.properties = data.properties ?? ({} as P)
|
|
143
150
|
|
|
144
151
|
this.initNodeData(data)
|
|
145
152
|
this.setAttributes()
|
|
@@ -168,9 +175,9 @@ export class BaseNodeModel implements IBaseNodeModel {
|
|
|
168
175
|
/**
|
|
169
176
|
* @overridable 可以重写
|
|
170
177
|
* 初始化节点数据
|
|
171
|
-
* initNodeData和setAttributes的区别在于
|
|
172
|
-
* initNodeData只在节点初始化的时候调用,用于初始化节点的所有属性。
|
|
173
|
-
* setAttributes除了初始化调用外,还会在properties发生变化了调用。
|
|
178
|
+
* initNodeData 和 setAttributes 的区别在于
|
|
179
|
+
* initNodeData 只在节点初始化的时候调用,用于初始化节点的所有属性。
|
|
180
|
+
* setAttributes 除了初始化调用外,还会在 properties 发生变化了调用。
|
|
174
181
|
*/
|
|
175
182
|
public initNodeData(data: NodeConfig) {
|
|
176
183
|
if (!data.properties) {
|
|
@@ -186,7 +193,10 @@ export class BaseNodeModel implements IBaseNodeModel {
|
|
|
186
193
|
}
|
|
187
194
|
|
|
188
195
|
this.formatText(data)
|
|
189
|
-
|
|
196
|
+
// 在下面又将 NodeConfig 中的数据赋值给了 this,应该会触发 setAttributes,确认是否符合预期
|
|
197
|
+
// TODO: 确认 constructor 中赋值 properties 是否必要,此处将 NodeConfig 中所有属性赋值给 this,包括 rotate、rotatable,resizable 等
|
|
198
|
+
assign(this, pickNodeConfig(data))
|
|
199
|
+
|
|
190
200
|
const { overlapMode } = this.graphModel
|
|
191
201
|
if (overlapMode === OverlapMode.INCREASE) {
|
|
192
202
|
this.zIndex = data.zIndex || getZIndex()
|
|
@@ -215,31 +225,46 @@ export class BaseNodeModel implements IBaseNodeModel {
|
|
|
215
225
|
return null
|
|
216
226
|
}
|
|
217
227
|
|
|
228
|
+
/**
|
|
229
|
+
* 设置当前元素的文本模式
|
|
230
|
+
* @param mode
|
|
231
|
+
*/
|
|
232
|
+
@action setTextMode(mode: TextMode) {
|
|
233
|
+
this.textMode = mode
|
|
234
|
+
}
|
|
235
|
+
|
|
218
236
|
/**
|
|
219
237
|
* 始化文本属性
|
|
220
238
|
*/
|
|
221
239
|
private formatText(data: NodeConfig): void {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
if (typeof
|
|
232
|
-
|
|
233
|
-
value: data.text,
|
|
234
|
-
x: data.x,
|
|
235
|
-
y: data.y,
|
|
236
|
-
draggable: false,
|
|
237
|
-
editable: true,
|
|
238
|
-
}
|
|
240
|
+
const { x, y, text } = data
|
|
241
|
+
let textConfig: TextConfig = {
|
|
242
|
+
value: '',
|
|
243
|
+
x,
|
|
244
|
+
y,
|
|
245
|
+
draggable: false,
|
|
246
|
+
editable: true,
|
|
247
|
+
}
|
|
248
|
+
if (text) {
|
|
249
|
+
if (typeof text === 'string') {
|
|
250
|
+
textConfig.value = text
|
|
239
251
|
} else {
|
|
240
|
-
|
|
252
|
+
textConfig = {
|
|
253
|
+
...textConfig,
|
|
254
|
+
x: text.x ?? x,
|
|
255
|
+
y: text.y ?? y,
|
|
256
|
+
value: text.value ?? '',
|
|
257
|
+
}
|
|
258
|
+
if (!isUndefined(text.draggable)) {
|
|
259
|
+
textConfig.draggable = text.draggable
|
|
260
|
+
}
|
|
261
|
+
if (!isUndefined(text.editable)) {
|
|
262
|
+
textConfig.draggable = text.draggable
|
|
263
|
+
}
|
|
241
264
|
}
|
|
242
265
|
}
|
|
266
|
+
|
|
267
|
+
data.text = textConfig
|
|
243
268
|
}
|
|
244
269
|
|
|
245
270
|
/**
|
|
@@ -257,7 +282,6 @@ export class BaseNodeModel implements IBaseNodeModel {
|
|
|
257
282
|
width,
|
|
258
283
|
height,
|
|
259
284
|
})
|
|
260
|
-
|
|
261
285
|
return this.getData()
|
|
262
286
|
}
|
|
263
287
|
|
|
@@ -343,7 +367,11 @@ export class BaseNodeModel implements IBaseNodeModel {
|
|
|
343
367
|
getTextStyle() {
|
|
344
368
|
// 透传 nodeText
|
|
345
369
|
const { nodeText } = this.graphModel.theme
|
|
346
|
-
|
|
370
|
+
const { textStyle = {} } = this.properties
|
|
371
|
+
return {
|
|
372
|
+
...cloneDeep(nodeText),
|
|
373
|
+
...cloneDeep(textStyle),
|
|
374
|
+
}
|
|
347
375
|
}
|
|
348
376
|
|
|
349
377
|
/**
|
|
@@ -576,10 +604,10 @@ export class BaseNodeModel implements IBaseNodeModel {
|
|
|
576
604
|
*/
|
|
577
605
|
public getBounds(): Model.BoxBoundsPoint {
|
|
578
606
|
return {
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
607
|
+
minX: this.x - this.width / 2,
|
|
608
|
+
minY: this.y - this.height / 2,
|
|
609
|
+
maxX: this.x + this.width / 2,
|
|
610
|
+
maxY: this.y + this.height / 2,
|
|
583
611
|
}
|
|
584
612
|
}
|
|
585
613
|
|
|
@@ -683,12 +711,9 @@ export class BaseNodeModel implements IBaseNodeModel {
|
|
|
683
711
|
@action moveTo(x: number, y: number, isIgnoreRule = false): boolean {
|
|
684
712
|
const deltaX = x - this.x
|
|
685
713
|
const deltaY = y - this.y
|
|
686
|
-
if (!isIgnoreRule && !this.isAllowMoveNode(deltaX, deltaY))
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
if (this.text) {
|
|
690
|
-
this.text && this.moveText(deltaX, deltaY)
|
|
691
|
-
}
|
|
714
|
+
if (!isIgnoreRule && !this.isAllowMoveNode(deltaX, deltaY)) return false
|
|
715
|
+
|
|
716
|
+
this.text && this.moveText(deltaX, deltaY)
|
|
692
717
|
this.x = x
|
|
693
718
|
this.y = y
|
|
694
719
|
return true
|
|
@@ -725,12 +750,12 @@ export class BaseNodeModel implements IBaseNodeModel {
|
|
|
725
750
|
this.isShowAnchor = flag
|
|
726
751
|
}
|
|
727
752
|
|
|
728
|
-
@action
|
|
729
|
-
this.
|
|
753
|
+
@action setRotatable(flag = true): void {
|
|
754
|
+
this.rotatable = flag
|
|
730
755
|
}
|
|
731
756
|
|
|
732
|
-
@action
|
|
733
|
-
this.
|
|
757
|
+
@action setResizable(flag = true): void {
|
|
758
|
+
this.resizable = flag
|
|
734
759
|
}
|
|
735
760
|
|
|
736
761
|
@action setHitable(flag = true): void {
|
|
@@ -18,9 +18,11 @@ export type ICircleNodeProperties = {
|
|
|
18
18
|
[key: string]: any
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
export class CircleNodeModel
|
|
21
|
+
export class CircleNodeModel<
|
|
22
|
+
P extends ICircleNodeProperties = ICircleNodeProperties,
|
|
23
|
+
> extends BaseNodeModel<P> {
|
|
22
24
|
modelType = ModelType.CIRCLE_NODE
|
|
23
|
-
@observable properties: ICircleNodeProperties = {}
|
|
25
|
+
// @observable properties: ICircleNodeProperties = {}
|
|
24
26
|
@observable r = 50
|
|
25
27
|
|
|
26
28
|
@computed get width(): number {
|
|
@@ -31,9 +33,9 @@ export class CircleNodeModel extends BaseNodeModel {
|
|
|
31
33
|
return this.r * 2
|
|
32
34
|
}
|
|
33
35
|
|
|
34
|
-
constructor(data: NodeConfig
|
|
36
|
+
constructor(data: NodeConfig<P>, graphModel: GraphModel) {
|
|
35
37
|
super(data, graphModel)
|
|
36
|
-
this.properties = data.properties || {}
|
|
38
|
+
// this.properties = data.properties || {}
|
|
37
39
|
|
|
38
40
|
this.setAttributes()
|
|
39
41
|
}
|
|
@@ -54,11 +56,11 @@ export class CircleNodeModel extends BaseNodeModel {
|
|
|
54
56
|
theme: { circle },
|
|
55
57
|
},
|
|
56
58
|
} = this
|
|
57
|
-
const { style: customStyle } = this.properties
|
|
59
|
+
const { style: customStyle = {} } = this.properties
|
|
58
60
|
return {
|
|
59
61
|
...style,
|
|
60
|
-
...(customStyle ?? {}),
|
|
61
62
|
...cloneDeep(circle),
|
|
63
|
+
...cloneDeep(customStyle),
|
|
62
64
|
}
|
|
63
65
|
}
|
|
64
66
|
|
|
@@ -81,7 +83,6 @@ export class CircleNodeModel extends BaseNodeModel {
|
|
|
81
83
|
this.setProperties({
|
|
82
84
|
r: width,
|
|
83
85
|
})
|
|
84
|
-
|
|
85
86
|
return this.getData()
|
|
86
87
|
}
|
|
87
88
|
}
|
|
@@ -18,18 +18,20 @@ export type IDiamondNodeProperties = {
|
|
|
18
18
|
style?: LogicFlow.CommonTheme
|
|
19
19
|
textStyle?: LogicFlow.CommonTheme
|
|
20
20
|
|
|
21
|
-
[key: string]:
|
|
21
|
+
[key: string]: unknown
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
export class DiamondNodeModel
|
|
24
|
+
export class DiamondNodeModel<
|
|
25
|
+
P extends IDiamondNodeProperties = IDiamondNodeProperties,
|
|
26
|
+
> extends BaseNodeModel<P> {
|
|
25
27
|
modelType = ModelType.DIAMOND_NODE
|
|
26
28
|
@observable rx = 30
|
|
27
29
|
@observable ry = 50
|
|
28
|
-
@observable properties: IDiamondNodeProperties = {}
|
|
30
|
+
// @observable properties: IDiamondNodeProperties = {}
|
|
29
31
|
|
|
30
|
-
constructor(data: NodeConfig
|
|
32
|
+
constructor(data: NodeConfig<P>, graphModel: GraphModel) {
|
|
31
33
|
super(data, graphModel)
|
|
32
|
-
this.properties = data.properties || {}
|
|
34
|
+
// this.properties = data.properties || {}
|
|
33
35
|
|
|
34
36
|
this.setAttributes()
|
|
35
37
|
}
|
|
@@ -53,9 +55,11 @@ export class DiamondNodeModel extends BaseNodeModel {
|
|
|
53
55
|
theme: { diamond },
|
|
54
56
|
},
|
|
55
57
|
} = this
|
|
58
|
+
const { style: customStyle = {} } = this.properties
|
|
56
59
|
return {
|
|
57
60
|
...style,
|
|
58
61
|
...cloneDeep(diamond),
|
|
62
|
+
...cloneDeep(customStyle),
|
|
59
63
|
}
|
|
60
64
|
}
|
|
61
65
|
|
|
@@ -120,7 +124,6 @@ export class DiamondNodeModel extends BaseNodeModel {
|
|
|
120
124
|
rx: width,
|
|
121
125
|
ry: height,
|
|
122
126
|
})
|
|
123
|
-
|
|
124
127
|
return this.getData()
|
|
125
128
|
}
|
|
126
129
|
}
|
|
@@ -16,18 +16,20 @@ export type IEllipseNodeProperties = {
|
|
|
16
16
|
style?: LogicFlow.CommonTheme
|
|
17
17
|
textStyle?: LogicFlow.CommonTheme
|
|
18
18
|
|
|
19
|
-
[key: string]:
|
|
19
|
+
[key: string]: unknown
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export class EllipseNodeModel
|
|
22
|
+
export class EllipseNodeModel<
|
|
23
|
+
P extends IEllipseNodeProperties = IEllipseNodeProperties,
|
|
24
|
+
> extends BaseNodeModel<P> {
|
|
23
25
|
modelType = ModelType.ELLIPSE_NODE
|
|
24
26
|
@observable rx = 30
|
|
25
27
|
@observable ry = 45
|
|
26
|
-
@observable properties: IEllipseNodeProperties = {}
|
|
28
|
+
// @observable properties: IEllipseNodeProperties = {}
|
|
27
29
|
|
|
28
|
-
constructor(data: NodeConfig
|
|
30
|
+
constructor(data: NodeConfig<P>, graphModel: GraphModel) {
|
|
29
31
|
super(data, graphModel)
|
|
30
|
-
this.properties = data.properties || {}
|
|
32
|
+
// this.properties = data.properties || {}
|
|
31
33
|
|
|
32
34
|
this.setAttributes()
|
|
33
35
|
}
|
|
@@ -51,9 +53,11 @@ export class EllipseNodeModel extends BaseNodeModel {
|
|
|
51
53
|
theme: { ellipse },
|
|
52
54
|
},
|
|
53
55
|
} = this
|
|
56
|
+
const { style: customStyle = {} } = this.properties
|
|
54
57
|
return {
|
|
55
58
|
...style,
|
|
56
59
|
...cloneDeep(ellipse),
|
|
60
|
+
...cloneDeep(customStyle),
|
|
57
61
|
}
|
|
58
62
|
}
|
|
59
63
|
|
|
@@ -86,7 +90,6 @@ export class EllipseNodeModel extends BaseNodeModel {
|
|
|
86
90
|
rx: width,
|
|
87
91
|
ry: height,
|
|
88
92
|
})
|
|
89
|
-
|
|
90
93
|
return this.getData()
|
|
91
94
|
}
|
|
92
95
|
}
|
|
@@ -3,26 +3,27 @@ import { Model } from '../BaseModel'
|
|
|
3
3
|
import { ModelType } from '../../constant'
|
|
4
4
|
|
|
5
5
|
import AnchorConfig = Model.AnchorConfig
|
|
6
|
-
import { observable } from 'mobx'
|
|
7
6
|
import LogicFlow from '../../LogicFlow'
|
|
8
7
|
import GraphModel from '../GraphModel'
|
|
9
8
|
|
|
10
|
-
export type
|
|
9
|
+
export type IHtmlNodeProperties = {
|
|
11
10
|
width?: number
|
|
12
11
|
height?: number
|
|
13
12
|
style?: LogicFlow.CommonTheme
|
|
14
13
|
textStyle?: LogicFlow.CommonTheme
|
|
15
14
|
|
|
16
|
-
[key: string]:
|
|
15
|
+
[key: string]: unknown
|
|
17
16
|
}
|
|
18
17
|
|
|
19
|
-
export class HtmlNodeModel
|
|
18
|
+
export class HtmlNodeModel<
|
|
19
|
+
P extends IHtmlNodeProperties = IHtmlNodeProperties,
|
|
20
|
+
> extends BaseNodeModel<P> {
|
|
20
21
|
modelType = ModelType.HTML_NODE
|
|
21
|
-
@observable properties:
|
|
22
|
+
// @observable properties: IHtmlNodeProperties = {}
|
|
22
23
|
|
|
23
|
-
constructor(data: LogicFlow.NodeConfig
|
|
24
|
+
constructor(data: LogicFlow.NodeConfig<P>, graphModel: GraphModel) {
|
|
24
25
|
super(data, graphModel)
|
|
25
|
-
this.properties = data.properties || {}
|
|
26
|
+
// this.properties = data.properties || {}
|
|
26
27
|
|
|
27
28
|
this.setAttributes()
|
|
28
29
|
}
|
|
@@ -19,10 +19,12 @@ export type IPolygonNodeProperties = {
|
|
|
19
19
|
style?: LogicFlow.CommonTheme
|
|
20
20
|
textStyle?: LogicFlow.CommonTheme
|
|
21
21
|
|
|
22
|
-
[key: string]:
|
|
22
|
+
[key: string]: unknown
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export class PolygonNodeModel
|
|
25
|
+
export class PolygonNodeModel<
|
|
26
|
+
P extends IPolygonNodeProperties = IPolygonNodeProperties,
|
|
27
|
+
> extends BaseNodeModel<P> {
|
|
26
28
|
modelType = ModelType.POLYGON_NODE
|
|
27
29
|
@observable points: PointTuple[] = [
|
|
28
30
|
[50, 0],
|
|
@@ -36,11 +38,11 @@ export class PolygonNodeModel extends BaseNodeModel {
|
|
|
36
38
|
// [10, 78],
|
|
37
39
|
// [160, 198], // 五角星
|
|
38
40
|
]
|
|
39
|
-
@observable properties: IPolygonNodeProperties = {}
|
|
41
|
+
// @observable properties: IPolygonNodeProperties = {}
|
|
40
42
|
|
|
41
|
-
constructor(data: NodeConfig
|
|
43
|
+
constructor(data: NodeConfig<P>, graphModel: GraphModel) {
|
|
42
44
|
super(data, graphModel)
|
|
43
|
-
this.properties = data.properties || {}
|
|
45
|
+
// this.properties = data.properties || {}
|
|
44
46
|
|
|
45
47
|
this.setAttributes()
|
|
46
48
|
}
|
|
@@ -66,11 +68,11 @@ export class PolygonNodeModel extends BaseNodeModel {
|
|
|
66
68
|
theme: { polygon },
|
|
67
69
|
},
|
|
68
70
|
} = this
|
|
69
|
-
const { style: customStyle } = this.properties
|
|
71
|
+
const { style: customStyle = {} } = this.properties
|
|
70
72
|
return {
|
|
71
73
|
...style,
|
|
72
74
|
...cloneDeep(polygon),
|
|
73
|
-
...
|
|
75
|
+
...cloneDeep(customStyle),
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
78
|
|
|
@@ -5,33 +5,40 @@ import GraphModel from '../GraphModel'
|
|
|
5
5
|
import LogicFlow from '../../LogicFlow'
|
|
6
6
|
import { ModelType } from '../../constant'
|
|
7
7
|
|
|
8
|
-
export type
|
|
8
|
+
export type IRectNodeProperties = {
|
|
9
9
|
width?: number
|
|
10
10
|
height?: number
|
|
11
|
+
radius?: number
|
|
11
12
|
style?: LogicFlow.CommonTheme
|
|
12
13
|
textStyle?: LogicFlow.CommonTheme
|
|
13
14
|
|
|
14
|
-
[key: string]:
|
|
15
|
+
[key: string]: unknown
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
export class RectNodeModel
|
|
18
|
+
export class RectNodeModel<
|
|
19
|
+
P extends IRectNodeProperties = IRectNodeProperties,
|
|
20
|
+
> extends BaseNodeModel<P> {
|
|
18
21
|
modelType = ModelType.RECT_NODE
|
|
19
22
|
@observable radius = 0
|
|
20
|
-
@observable properties:
|
|
23
|
+
// @observable properties: P
|
|
21
24
|
|
|
22
|
-
constructor(data: LogicFlow.NodeConfig
|
|
25
|
+
constructor(data: LogicFlow.NodeConfig<P>, graphModel: GraphModel) {
|
|
23
26
|
super(data, graphModel)
|
|
24
|
-
this.properties = data.properties || {}
|
|
25
27
|
|
|
28
|
+
// TODO:类字段初始化会覆盖 super、setAttributes 中设置的属性
|
|
29
|
+
// this.properties = data.properties || {}
|
|
30
|
+
// TODO: bug here, 上面更新 properties 会触发 setAttributes,下面再主动调用,会导致触发两次
|
|
26
31
|
this.setAttributes()
|
|
27
32
|
}
|
|
28
33
|
|
|
29
34
|
setAttributes() {
|
|
30
35
|
super.setAttributes()
|
|
31
36
|
|
|
32
|
-
const { width, height } = this.properties
|
|
37
|
+
const { width, height, radius } = this.properties
|
|
33
38
|
if (width) this.width = width
|
|
34
39
|
if (height) this.height = height
|
|
40
|
+
// 矩形特有
|
|
41
|
+
if (radius) this.radius = radius
|
|
35
42
|
}
|
|
36
43
|
|
|
37
44
|
getDefaultAnchor() {
|
|
@@ -43,13 +50,14 @@ export class RectNodeModel extends BaseNodeModel {
|
|
|
43
50
|
{ x: x - width / 2, y, id: `${this.id}_3` },
|
|
44
51
|
]
|
|
45
52
|
}
|
|
46
|
-
|
|
47
53
|
getNodeStyle() {
|
|
48
54
|
const style = super.getNodeStyle()
|
|
49
55
|
const { rect } = this.graphModel.theme
|
|
56
|
+
const { style: customStyle = {} } = this.properties
|
|
50
57
|
return {
|
|
51
58
|
...style,
|
|
52
59
|
...cloneDeep(rect),
|
|
60
|
+
...cloneDeep(customStyle),
|
|
53
61
|
}
|
|
54
62
|
}
|
|
55
63
|
}
|
|
@@ -3,18 +3,31 @@ import { computed } from 'mobx'
|
|
|
3
3
|
import BaseNodeModel from './BaseNodeModel'
|
|
4
4
|
import { ModelType } from '../../constant'
|
|
5
5
|
import { getSvgTextWidthHeight } from '../../util'
|
|
6
|
+
import LogicFlow from '../../LogicFlow'
|
|
6
7
|
|
|
7
|
-
export
|
|
8
|
+
export type ITextNodeProperties = {
|
|
9
|
+
style?: LogicFlow.CommonTheme
|
|
10
|
+
textStyle?: LogicFlow.CommonTheme
|
|
11
|
+
|
|
12
|
+
[key: string]: unknown
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class TextNodeModel<
|
|
16
|
+
P extends ITextNodeProperties = ITextNodeProperties,
|
|
17
|
+
> extends BaseNodeModel<P> {
|
|
8
18
|
modelType = ModelType.TEXT_NODE
|
|
9
19
|
|
|
10
20
|
getTextStyle() {
|
|
11
21
|
const style = super.getTextStyle()
|
|
12
22
|
const { text } = this.graphModel.theme
|
|
23
|
+
const { textStyle } = this.properties
|
|
13
24
|
return {
|
|
14
25
|
...style,
|
|
15
26
|
...cloneDeep(text),
|
|
27
|
+
...cloneDeep(textStyle),
|
|
16
28
|
}
|
|
17
29
|
}
|
|
30
|
+
|
|
18
31
|
@computed get width(): number {
|
|
19
32
|
const rows = String(this.text.value).split(/[\r\n]/g)
|
|
20
33
|
const { fontSize } = this.getTextStyle()
|
package/src/options.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { assign } from 'lodash-es'
|
|
2
2
|
import { createElement as h } from 'preact/compat'
|
|
3
3
|
import LogicFlow from './LogicFlow'
|
|
4
|
-
import { GraphModel } from './model'
|
|
5
4
|
import { KeyboardDef } from './keyboard'
|
|
6
|
-
import {
|
|
5
|
+
import { OverlapMode, TextMode } from './constant'
|
|
6
|
+
import { Grid } from './view/overlay'
|
|
7
|
+
|
|
8
|
+
import GridOptions = Grid.GridOptions
|
|
7
9
|
|
|
8
10
|
export namespace Options {
|
|
9
11
|
import NodeData = LogicFlow.NodeData
|
|
10
12
|
import EdgeData = LogicFlow.EdgeData
|
|
11
|
-
import ExtensionConstructor = LogicFlow.ExtensionConstructor
|
|
12
13
|
import GraphData = LogicFlow.GraphData
|
|
14
|
+
import ExtensionType = LogicFlow.ExtensionType
|
|
13
15
|
export type EdgeType = 'line' | 'polyline' | 'bezier' | string
|
|
14
16
|
export type BackgroundConfig = {
|
|
15
17
|
// 背景图片地址
|
|
@@ -25,19 +27,6 @@ export namespace Options {
|
|
|
25
27
|
// TODO: 根据具体情况添加各种自定义样式
|
|
26
28
|
[key: string]: any
|
|
27
29
|
}
|
|
28
|
-
export type GridOptions = {
|
|
29
|
-
// 网格格子间距
|
|
30
|
-
size?: number
|
|
31
|
-
// 网格是否可见
|
|
32
|
-
visible?: boolean
|
|
33
|
-
graphModel?: GraphModel
|
|
34
|
-
// 网格类型
|
|
35
|
-
type?: 'dot' | 'mesh'
|
|
36
|
-
config?: {
|
|
37
|
-
color: string
|
|
38
|
-
thickness?: number
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
30
|
|
|
42
31
|
export type AnimationConfig = {
|
|
43
32
|
node: boolean
|
|
@@ -68,6 +57,9 @@ export namespace Options {
|
|
|
68
57
|
width?: number
|
|
69
58
|
height?: number
|
|
70
59
|
background?: false | BackgroundConfig
|
|
60
|
+
/**
|
|
61
|
+
* Grid 网格配置
|
|
62
|
+
*/
|
|
71
63
|
grid?: number | boolean | GridOptions
|
|
72
64
|
|
|
73
65
|
partial?: boolean
|
|
@@ -76,10 +68,15 @@ export namespace Options {
|
|
|
76
68
|
edgeType?: EdgeType
|
|
77
69
|
adjustEdge?: boolean
|
|
78
70
|
|
|
71
|
+
// 元素文本类型:text or label
|
|
72
|
+
textMode?: TextMode
|
|
73
|
+
edgeTextMode?: TextMode
|
|
74
|
+
nodeTextMode?: TextMode
|
|
75
|
+
|
|
79
76
|
allowRotate?: boolean // 允许节点旋转
|
|
80
77
|
allowResize?: boolean // 是否允许缩放
|
|
81
78
|
|
|
82
|
-
isSilentMode?: boolean
|
|
79
|
+
isSilentMode?: boolean // 是否为静默模式:可以简单理解为“只读”模式,这种模式下,画布中的节点和边不可移动,不可进行文案修改,没有锚点。
|
|
83
80
|
stopScrollGraph?: boolean
|
|
84
81
|
stopZoomGraph?: boolean
|
|
85
82
|
stopMoveGraph?:
|
|
@@ -96,7 +93,7 @@ export namespace Options {
|
|
|
96
93
|
guards?: GuardsConfig
|
|
97
94
|
overlapMode?: OverlapMode
|
|
98
95
|
|
|
99
|
-
plugins?:
|
|
96
|
+
plugins?: ExtensionType[]
|
|
100
97
|
pluginsOptions?: Record<string, any>
|
|
101
98
|
disabledPlugins?: string[]
|
|
102
99
|
disabledTools?: string[]
|
|
@@ -117,47 +114,15 @@ export namespace Options {
|
|
|
117
114
|
|
|
118
115
|
export namespace Options {
|
|
119
116
|
export function get(options: Partial<Manual>) {
|
|
120
|
-
const {
|
|
117
|
+
const { ...others } = options
|
|
121
118
|
const container = options.container
|
|
122
|
-
if (container
|
|
123
|
-
if (options.width == null) {
|
|
124
|
-
others.width = container.clientWidth
|
|
125
|
-
}
|
|
126
|
-
if (options.height == null) {
|
|
127
|
-
others.height = container.clientHeight
|
|
128
|
-
}
|
|
129
|
-
} else {
|
|
119
|
+
if (!container) {
|
|
130
120
|
throw new Error(
|
|
131
121
|
'Ensure the container of LogicFlow is specified and valid.',
|
|
132
122
|
)
|
|
133
123
|
}
|
|
134
124
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
const defaultGrid: GridOptions = {
|
|
138
|
-
size: DEFAULT_GRID_SIZE,
|
|
139
|
-
type: 'dot',
|
|
140
|
-
visible: true,
|
|
141
|
-
config: {
|
|
142
|
-
color: '#ababab',
|
|
143
|
-
thickness: 1,
|
|
144
|
-
},
|
|
145
|
-
}
|
|
146
|
-
if (typeof grid === 'number') {
|
|
147
|
-
result.grid = {
|
|
148
|
-
...defaultGrid,
|
|
149
|
-
size: grid,
|
|
150
|
-
}
|
|
151
|
-
} else if (typeof grid === 'boolean') {
|
|
152
|
-
result.grid = {
|
|
153
|
-
...defaultGrid,
|
|
154
|
-
visible: grid,
|
|
155
|
-
}
|
|
156
|
-
} else {
|
|
157
|
-
result.grid = { ...defaultGrid, ...grid }
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
return result
|
|
125
|
+
return assign({}, defaults, others) as Options.Definition
|
|
161
126
|
}
|
|
162
127
|
}
|
|
163
128
|
|