@logicflow/core 2.0.6 → 2.0.8
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 +3 -19
- package/CHANGELOG.md +31 -0
- package/__tests__/algorithm/egde.test.ts +36 -23
- package/dist/index.css +3 -0
- package/es/algorithm/edge.js +3 -5
- package/es/constant/index.d.ts +4 -0
- package/es/constant/index.js +4 -0
- package/es/event/eventArgs.d.ts +40 -30
- package/es/index.css +3 -0
- package/es/model/GraphModel.d.ts +13 -3
- package/es/model/GraphModel.js +54 -3
- package/es/model/edge/BaseEdgeModel.d.ts +1 -0
- package/es/model/edge/LineEdgeModel.d.ts +2 -0
- package/es/model/edge/LineEdgeModel.js +8 -0
- package/es/model/edge/PolylineEdgeModel.d.ts +1 -0
- package/es/model/edge/PolylineEdgeModel.js +4 -3
- package/es/model/node/BaseNodeModel.d.ts +2 -2
- package/es/model/node/BaseNodeModel.js +1 -1
- package/es/model/node/HtmlNodeModel.d.ts +2 -2
- package/es/model/node/TextNodeModel.d.ts +2 -2
- package/es/style/index.css +3 -0
- package/es/style/index.less +5 -0
- package/es/style/raw.d.ts +1 -1
- package/es/style/raw.js +1 -1
- package/es/util/drag.d.ts +1 -0
- package/es/util/drag.js +11 -0
- package/es/view/Anchor.js +6 -8
- package/es/view/Control.js +1 -1
- package/es/view/Graph.js +3 -15
- package/es/view/behavior/dnd.js +1 -0
- package/es/view/edge/BaseEdge.d.ts +5 -1
- package/es/view/edge/BaseEdge.js +20 -5
- package/es/view/node/BaseNode.d.ts +2 -0
- package/es/view/node/BaseNode.js +13 -1
- package/es/view/overlay/BackgroundOverlay.d.ts +4 -14
- package/es/view/overlay/BackgroundOverlay.js +12 -1
- package/es/view/overlay/Grid.d.ts +4 -3
- package/es/view/overlay/Grid.js +8 -31
- package/es/view/overlay/getTransformHoc.d.ts +1 -1
- package/es/view/text/BaseText.js +1 -1
- package/lib/algorithm/edge.js +3 -5
- package/lib/constant/index.d.ts +4 -0
- package/lib/constant/index.js +4 -0
- package/lib/event/eventArgs.d.ts +40 -30
- package/lib/index.css +3 -0
- package/lib/model/GraphModel.d.ts +13 -3
- package/lib/model/GraphModel.js +53 -2
- package/lib/model/edge/BaseEdgeModel.d.ts +1 -0
- package/lib/model/edge/LineEdgeModel.d.ts +2 -0
- package/lib/model/edge/LineEdgeModel.js +8 -0
- package/lib/model/edge/PolylineEdgeModel.d.ts +1 -0
- package/lib/model/edge/PolylineEdgeModel.js +4 -3
- package/lib/model/node/BaseNodeModel.d.ts +2 -2
- package/lib/model/node/BaseNodeModel.js +1 -1
- package/lib/model/node/HtmlNodeModel.d.ts +2 -2
- package/lib/model/node/TextNodeModel.d.ts +2 -2
- package/lib/style/index.css +3 -0
- package/lib/style/index.less +5 -0
- package/lib/style/raw.d.ts +1 -1
- package/lib/style/raw.js +1 -1
- package/lib/util/drag.d.ts +1 -0
- package/lib/util/drag.js +11 -0
- package/lib/view/Anchor.js +6 -8
- package/lib/view/Control.js +1 -1
- package/lib/view/Graph.js +3 -15
- package/lib/view/behavior/dnd.js +1 -0
- package/lib/view/edge/BaseEdge.d.ts +5 -1
- package/lib/view/edge/BaseEdge.js +20 -5
- package/lib/view/node/BaseNode.d.ts +2 -0
- package/lib/view/node/BaseNode.js +13 -1
- package/lib/view/overlay/BackgroundOverlay.d.ts +4 -14
- package/lib/view/overlay/BackgroundOverlay.js +12 -1
- package/lib/view/overlay/Grid.d.ts +4 -3
- package/lib/view/overlay/Grid.js +8 -31
- package/lib/view/overlay/getTransformHoc.d.ts +1 -1
- package/lib/view/text/BaseText.js +1 -1
- package/package.json +1 -1
- package/src/LogicFlow.tsx +6 -0
- package/src/algorithm/edge.ts +3 -5
- package/src/algorithm/outline.ts +1 -1
- package/src/constant/index.ts +4 -0
- package/src/event/eventArgs.ts +50 -30
- package/src/model/GraphModel.ts +122 -3
- package/src/model/edge/BaseEdgeModel.ts +1 -0
- package/src/model/edge/LineEdgeModel.ts +8 -0
- package/src/model/edge/PolylineEdgeModel.ts +5 -3
- package/src/model/node/BaseNodeModel.ts +1 -1
- package/src/model/node/HtmlNodeModel.ts +1 -1
- package/src/style/index.less +5 -0
- package/src/style/raw.ts +3 -0
- package/src/util/drag.ts +12 -0
- package/src/view/Anchor.tsx +7 -8
- package/src/view/Control.tsx +1 -1
- package/src/view/Graph.tsx +5 -7
- package/src/view/behavior/dnd.ts +1 -0
- package/src/view/edge/BaseEdge.tsx +24 -3
- package/src/view/node/BaseNode.tsx +17 -1
- package/src/view/overlay/BackgroundOverlay.tsx +11 -16
- package/src/view/overlay/Grid.tsx +13 -9
- package/src/view/overlay/OutlineOverlay.tsx +1 -1
- package/src/view/text/BaseText.tsx +1 -1
- package/stats.html +1 -1
- package/dist/index.min.js +0 -2
- package/dist/index.min.js.map +0 -1
|
@@ -24,8 +24,8 @@ export declare class TextNodeModel<P extends ITextNodeProperties = ITextNodeProp
|
|
|
24
24
|
fontSize: number;
|
|
25
25
|
textWidth?: number | undefined;
|
|
26
26
|
lineHeight?: number | undefined;
|
|
27
|
-
textAnchor?: "
|
|
28
|
-
dominantBaseline?: "middle" | "
|
|
27
|
+
textAnchor?: "start" | "end" | "middle" | undefined;
|
|
28
|
+
dominantBaseline?: "middle" | "auto" | "text-bottom" | "alphabetic" | "ideographic" | "central" | "mathematical" | "hanging" | "text-top" | undefined;
|
|
29
29
|
overflowMode?: "default" | "autoWrap" | "ellipsis" | undefined;
|
|
30
30
|
wrapPadding?: string | undefined;
|
|
31
31
|
};
|
package/es/style/index.css
CHANGED
package/es/style/index.less
CHANGED
package/es/style/raw.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Auto generated file, do not modify it!
|
|
3
3
|
*/
|
|
4
|
-
export declare const content = ".lf-graph {\n position: relative;\n z-index: 0;\n width: 100%;\n height: 100%;\n background: #fff;\n user-select: none;\n}\n.lf-element-text {\n cursor: text;\n}\n.lf-text-disabled {\n pointer-events: none;\n}\n.lf-text-draggable {\n cursor: move;\n}\n.lf-node-anchor {\n cursor: crosshair;\n}\n.lf-node-anchor-hover {\n visibility: hidden;\n}\n.lf-anchor:hover .lf-node-anchor-hover {\n visibility: visible;\n}\n.lf-edge.pointer-none {\n pointer-events: none;\n}\n.lf-edge-append {\n cursor: pointer;\n}\n.lf-edge-animation {\n stroke-dashoffset: 100%;\n animation: lf_animate_dash 5s linear infinite;\n}\n@keyframes lf_animate_dash {\n to {\n stroke-dashoffset: 0;\n }\n}\n/* node */\n.lf-node-not-allow {\n cursor: not-allowed;\n}\n.lf-polyline-append-ns-resize {\n cursor: ns-resize;\n}\n.lf-polyline-append-ew-resize {\n cursor: ew-resize;\n}\n.lf-dragging {\n cursor: move;\n}\n.lf-dragging .lf-element-text {\n cursor: move;\n}\n.lf-draggable {\n cursor: default;\n}\n.lf-bezier-adjust-anchor {\n cursor: pointer;\n}\n/* background */\n.lf-background,\n.lf-grid {\n position: absolute;\n inset: 0;\n z-index: -1;\n}\n.lf-background-area {\n width: 100%;\n height: 100%;\n}\n/* html-overlay */\n.lf-html-overlay {\n position: absolute;\n inset: 0;\n z-index: 1;\n overflow: hidden;\n user-select: none;\n pointer-events: none;\n}\n.lf-html-overlay__transform > * {\n pointer-events: all;\n}\n.lf-text-editable {\n pointer-events: all;\n}\n.lf-text-input {\n position: absolute;\n box-sizing: border-box;\n min-width: 100px;\n min-height: 20px;\n padding: 5px;\n line-height: 1.2;\n white-space: pre;\n text-align: center;\n background: #fff;\n border: 1px solid #edefed;\n border-radius: 3px;\n outline: none;\n transform: translate(-50%, -50%);\n resize: none;\n}\n.lf-get-text-height {\n display: inline-block;\n box-sizing: border-box;\n word-break: break-all;\n /* \u4E3A\u4E86\u8DDF\u8F93\u5165\u6548\u679C\u4FDD\u6301\u4E00\u81F4\uFF0C\u8BBE\u7F6E\u900F\u660E\u8FB9\u6846\u5360\u4F4D */\n border: 1px solid transparent;\n}\n.lf-node-text-auto-wrap {\n display: flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n /* border: 1px solid transparent; */\n}\n.lf-node-text-auto-wrap-content {\n width: 100%;\n line-height: 1.2;\n text-align: center;\n word-break: break-all;\n background: transparent;\n}\n.lf-node-text-ellipsis-content {\n width: 100%;\n line-height: 1.2;\n white-space: nowrap;\n text-align: center;\n background: transparent;\n /* overflow: hidden;\n text-overflow: ellipsis; */\n}\n.lf-node-text-ellipsis-content > div {\n overflow: hidden;\n text-overflow: ellipsis;\n}\n/* tool-overlay */\n.lf-tool-overlay {\n position: absolute;\n inset: 0;\n z-index: 2;\n overflow: hidden;\n pointer-events: none;\n}\n.lf-tool-overlay > * {\n pointer-events: all;\n}\n/* modification-overlay */\n.modification-overlay {\n position: absolute;\n inset: 0;\n z-index: 1;\n overflow: hidden;\n pointer-events: none;\n}\n.modification-overlay > * {\n pointer-events: all;\n}\n.lf-outline,\n.lf-snapline {\n pointer-events: none;\n}\n.lf-keyboard-tips {\n float: right;\n}\n.lf-node-select-decorate {\n position: absolute;\n border: 1px dashed #343435;\n transform: translate(-50%, -50%);\n pointer-events: none;\n}\n.lf-multiple-select {\n position: absolute;\n border: 2px dashed #187dffcc;\n box-shadow: 0 0 3px 0 #187dff80;\n cursor: move;\n}\n.lf-edge-adjust-point {\n cursor: move;\n}\n.lf-rotate-control {\n cursor: grabbing;\n}\n.lf-resize-control-nw {\n cursor: nw-resize;\n}\n.lf-resize-control-n {\n cursor: n-resize;\n}\n.lf-resize-control-ne {\n cursor: ne-resize;\n}\n.lf-resize-control-e {\n cursor: e-resize;\n}\n.lf-resize-control-se {\n cursor: se-resize;\n}\n.lf-resize-control-s {\n cursor: s-resize;\n}\n.lf-resize-control-sw {\n cursor: sw-resize;\n}\n.lf-resize-control-w {\n cursor: w-resize;\n}\n";
|
|
4
|
+
export declare const content = ".lf-graph {\n position: relative;\n z-index: 0;\n width: 100%;\n height: 100%;\n background: #fff;\n user-select: none;\n}\n.lf-element-text {\n cursor: text;\n}\n.lf-text-disabled {\n pointer-events: none;\n}\n.lf-text-draggable {\n cursor: move;\n}\n*:focus {\n outline: none;\n}\n.lf-node-anchor {\n cursor: crosshair;\n}\n.lf-node-anchor-hover {\n visibility: hidden;\n}\n.lf-anchor:hover .lf-node-anchor-hover {\n visibility: visible;\n}\n.lf-edge.pointer-none {\n pointer-events: none;\n}\n.lf-edge-append {\n cursor: pointer;\n}\n.lf-edge-animation {\n stroke-dashoffset: 100%;\n animation: lf_animate_dash 5s linear infinite;\n}\n@keyframes lf_animate_dash {\n to {\n stroke-dashoffset: 0;\n }\n}\n/* node */\n.lf-node-not-allow {\n cursor: not-allowed;\n}\n.lf-polyline-append-ns-resize {\n cursor: ns-resize;\n}\n.lf-polyline-append-ew-resize {\n cursor: ew-resize;\n}\n.lf-dragging {\n cursor: move;\n}\n.lf-dragging .lf-element-text {\n cursor: move;\n}\n.lf-draggable {\n cursor: default;\n}\n.lf-bezier-adjust-anchor {\n cursor: pointer;\n}\n/* background */\n.lf-background,\n.lf-grid {\n position: absolute;\n inset: 0;\n z-index: -1;\n}\n.lf-background-area {\n width: 100%;\n height: 100%;\n}\n/* html-overlay */\n.lf-html-overlay {\n position: absolute;\n inset: 0;\n z-index: 1;\n overflow: hidden;\n user-select: none;\n pointer-events: none;\n}\n.lf-html-overlay__transform > * {\n pointer-events: all;\n}\n.lf-text-editable {\n pointer-events: all;\n}\n.lf-text-input {\n position: absolute;\n box-sizing: border-box;\n min-width: 100px;\n min-height: 20px;\n padding: 5px;\n line-height: 1.2;\n white-space: pre;\n text-align: center;\n background: #fff;\n border: 1px solid #edefed;\n border-radius: 3px;\n outline: none;\n transform: translate(-50%, -50%);\n resize: none;\n}\n.lf-get-text-height {\n display: inline-block;\n box-sizing: border-box;\n word-break: break-all;\n /* \u4E3A\u4E86\u8DDF\u8F93\u5165\u6548\u679C\u4FDD\u6301\u4E00\u81F4\uFF0C\u8BBE\u7F6E\u900F\u660E\u8FB9\u6846\u5360\u4F4D */\n border: 1px solid transparent;\n}\n.lf-node-text-auto-wrap {\n display: flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n /* border: 1px solid transparent; */\n}\n.lf-node-text-auto-wrap-content {\n width: 100%;\n line-height: 1.2;\n text-align: center;\n word-break: break-all;\n background: transparent;\n}\n.lf-node-text-ellipsis-content {\n width: 100%;\n line-height: 1.2;\n white-space: nowrap;\n text-align: center;\n background: transparent;\n /* overflow: hidden;\n text-overflow: ellipsis; */\n}\n.lf-node-text-ellipsis-content > div {\n overflow: hidden;\n text-overflow: ellipsis;\n}\n/* tool-overlay */\n.lf-tool-overlay {\n position: absolute;\n inset: 0;\n z-index: 2;\n overflow: hidden;\n pointer-events: none;\n}\n.lf-tool-overlay > * {\n pointer-events: all;\n}\n/* modification-overlay */\n.modification-overlay {\n position: absolute;\n inset: 0;\n z-index: 1;\n overflow: hidden;\n pointer-events: none;\n}\n.modification-overlay > * {\n pointer-events: all;\n}\n.lf-outline,\n.lf-snapline {\n pointer-events: none;\n}\n.lf-keyboard-tips {\n float: right;\n}\n.lf-node-select-decorate {\n position: absolute;\n border: 1px dashed #343435;\n transform: translate(-50%, -50%);\n pointer-events: none;\n}\n.lf-multiple-select {\n position: absolute;\n border: 2px dashed #187dffcc;\n box-shadow: 0 0 3px 0 #187dff80;\n cursor: move;\n}\n.lf-edge-adjust-point {\n cursor: move;\n}\n.lf-rotate-control {\n cursor: grabbing;\n}\n.lf-resize-control-nw {\n cursor: nw-resize;\n}\n.lf-resize-control-n {\n cursor: n-resize;\n}\n.lf-resize-control-ne {\n cursor: ne-resize;\n}\n.lf-resize-control-e {\n cursor: e-resize;\n}\n.lf-resize-control-se {\n cursor: se-resize;\n}\n.lf-resize-control-s {\n cursor: s-resize;\n}\n.lf-resize-control-sw {\n cursor: sw-resize;\n}\n.lf-resize-control-w {\n cursor: w-resize;\n}\n";
|
package/es/style/raw.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Auto generated file, do not modify it!
|
|
4
4
|
*/
|
|
5
|
-
export var content = ".lf-graph {\n position: relative;\n z-index: 0;\n width: 100%;\n height: 100%;\n background: #fff;\n user-select: none;\n}\n.lf-element-text {\n cursor: text;\n}\n.lf-text-disabled {\n pointer-events: none;\n}\n.lf-text-draggable {\n cursor: move;\n}\n.lf-node-anchor {\n cursor: crosshair;\n}\n.lf-node-anchor-hover {\n visibility: hidden;\n}\n.lf-anchor:hover .lf-node-anchor-hover {\n visibility: visible;\n}\n.lf-edge.pointer-none {\n pointer-events: none;\n}\n.lf-edge-append {\n cursor: pointer;\n}\n.lf-edge-animation {\n stroke-dashoffset: 100%;\n animation: lf_animate_dash 5s linear infinite;\n}\n@keyframes lf_animate_dash {\n to {\n stroke-dashoffset: 0;\n }\n}\n/* node */\n.lf-node-not-allow {\n cursor: not-allowed;\n}\n.lf-polyline-append-ns-resize {\n cursor: ns-resize;\n}\n.lf-polyline-append-ew-resize {\n cursor: ew-resize;\n}\n.lf-dragging {\n cursor: move;\n}\n.lf-dragging .lf-element-text {\n cursor: move;\n}\n.lf-draggable {\n cursor: default;\n}\n.lf-bezier-adjust-anchor {\n cursor: pointer;\n}\n/* background */\n.lf-background,\n.lf-grid {\n position: absolute;\n inset: 0;\n z-index: -1;\n}\n.lf-background-area {\n width: 100%;\n height: 100%;\n}\n/* html-overlay */\n.lf-html-overlay {\n position: absolute;\n inset: 0;\n z-index: 1;\n overflow: hidden;\n user-select: none;\n pointer-events: none;\n}\n.lf-html-overlay__transform > * {\n pointer-events: all;\n}\n.lf-text-editable {\n pointer-events: all;\n}\n.lf-text-input {\n position: absolute;\n box-sizing: border-box;\n min-width: 100px;\n min-height: 20px;\n padding: 5px;\n line-height: 1.2;\n white-space: pre;\n text-align: center;\n background: #fff;\n border: 1px solid #edefed;\n border-radius: 3px;\n outline: none;\n transform: translate(-50%, -50%);\n resize: none;\n}\n.lf-get-text-height {\n display: inline-block;\n box-sizing: border-box;\n word-break: break-all;\n /* \u4E3A\u4E86\u8DDF\u8F93\u5165\u6548\u679C\u4FDD\u6301\u4E00\u81F4\uFF0C\u8BBE\u7F6E\u900F\u660E\u8FB9\u6846\u5360\u4F4D */\n border: 1px solid transparent;\n}\n.lf-node-text-auto-wrap {\n display: flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n /* border: 1px solid transparent; */\n}\n.lf-node-text-auto-wrap-content {\n width: 100%;\n line-height: 1.2;\n text-align: center;\n word-break: break-all;\n background: transparent;\n}\n.lf-node-text-ellipsis-content {\n width: 100%;\n line-height: 1.2;\n white-space: nowrap;\n text-align: center;\n background: transparent;\n /* overflow: hidden;\n text-overflow: ellipsis; */\n}\n.lf-node-text-ellipsis-content > div {\n overflow: hidden;\n text-overflow: ellipsis;\n}\n/* tool-overlay */\n.lf-tool-overlay {\n position: absolute;\n inset: 0;\n z-index: 2;\n overflow: hidden;\n pointer-events: none;\n}\n.lf-tool-overlay > * {\n pointer-events: all;\n}\n/* modification-overlay */\n.modification-overlay {\n position: absolute;\n inset: 0;\n z-index: 1;\n overflow: hidden;\n pointer-events: none;\n}\n.modification-overlay > * {\n pointer-events: all;\n}\n.lf-outline,\n.lf-snapline {\n pointer-events: none;\n}\n.lf-keyboard-tips {\n float: right;\n}\n.lf-node-select-decorate {\n position: absolute;\n border: 1px dashed #343435;\n transform: translate(-50%, -50%);\n pointer-events: none;\n}\n.lf-multiple-select {\n position: absolute;\n border: 2px dashed #187dffcc;\n box-shadow: 0 0 3px 0 #187dff80;\n cursor: move;\n}\n.lf-edge-adjust-point {\n cursor: move;\n}\n.lf-rotate-control {\n cursor: grabbing;\n}\n.lf-resize-control-nw {\n cursor: nw-resize;\n}\n.lf-resize-control-n {\n cursor: n-resize;\n}\n.lf-resize-control-ne {\n cursor: ne-resize;\n}\n.lf-resize-control-e {\n cursor: e-resize;\n}\n.lf-resize-control-se {\n cursor: se-resize;\n}\n.lf-resize-control-s {\n cursor: s-resize;\n}\n.lf-resize-control-sw {\n cursor: sw-resize;\n}\n.lf-resize-control-w {\n cursor: w-resize;\n}\n";
|
|
5
|
+
export var content = ".lf-graph {\n position: relative;\n z-index: 0;\n width: 100%;\n height: 100%;\n background: #fff;\n user-select: none;\n}\n.lf-element-text {\n cursor: text;\n}\n.lf-text-disabled {\n pointer-events: none;\n}\n.lf-text-draggable {\n cursor: move;\n}\n*:focus {\n outline: none;\n}\n.lf-node-anchor {\n cursor: crosshair;\n}\n.lf-node-anchor-hover {\n visibility: hidden;\n}\n.lf-anchor:hover .lf-node-anchor-hover {\n visibility: visible;\n}\n.lf-edge.pointer-none {\n pointer-events: none;\n}\n.lf-edge-append {\n cursor: pointer;\n}\n.lf-edge-animation {\n stroke-dashoffset: 100%;\n animation: lf_animate_dash 5s linear infinite;\n}\n@keyframes lf_animate_dash {\n to {\n stroke-dashoffset: 0;\n }\n}\n/* node */\n.lf-node-not-allow {\n cursor: not-allowed;\n}\n.lf-polyline-append-ns-resize {\n cursor: ns-resize;\n}\n.lf-polyline-append-ew-resize {\n cursor: ew-resize;\n}\n.lf-dragging {\n cursor: move;\n}\n.lf-dragging .lf-element-text {\n cursor: move;\n}\n.lf-draggable {\n cursor: default;\n}\n.lf-bezier-adjust-anchor {\n cursor: pointer;\n}\n/* background */\n.lf-background,\n.lf-grid {\n position: absolute;\n inset: 0;\n z-index: -1;\n}\n.lf-background-area {\n width: 100%;\n height: 100%;\n}\n/* html-overlay */\n.lf-html-overlay {\n position: absolute;\n inset: 0;\n z-index: 1;\n overflow: hidden;\n user-select: none;\n pointer-events: none;\n}\n.lf-html-overlay__transform > * {\n pointer-events: all;\n}\n.lf-text-editable {\n pointer-events: all;\n}\n.lf-text-input {\n position: absolute;\n box-sizing: border-box;\n min-width: 100px;\n min-height: 20px;\n padding: 5px;\n line-height: 1.2;\n white-space: pre;\n text-align: center;\n background: #fff;\n border: 1px solid #edefed;\n border-radius: 3px;\n outline: none;\n transform: translate(-50%, -50%);\n resize: none;\n}\n.lf-get-text-height {\n display: inline-block;\n box-sizing: border-box;\n word-break: break-all;\n /* \u4E3A\u4E86\u8DDF\u8F93\u5165\u6548\u679C\u4FDD\u6301\u4E00\u81F4\uFF0C\u8BBE\u7F6E\u900F\u660E\u8FB9\u6846\u5360\u4F4D */\n border: 1px solid transparent;\n}\n.lf-node-text-auto-wrap {\n display: flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n /* border: 1px solid transparent; */\n}\n.lf-node-text-auto-wrap-content {\n width: 100%;\n line-height: 1.2;\n text-align: center;\n word-break: break-all;\n background: transparent;\n}\n.lf-node-text-ellipsis-content {\n width: 100%;\n line-height: 1.2;\n white-space: nowrap;\n text-align: center;\n background: transparent;\n /* overflow: hidden;\n text-overflow: ellipsis; */\n}\n.lf-node-text-ellipsis-content > div {\n overflow: hidden;\n text-overflow: ellipsis;\n}\n/* tool-overlay */\n.lf-tool-overlay {\n position: absolute;\n inset: 0;\n z-index: 2;\n overflow: hidden;\n pointer-events: none;\n}\n.lf-tool-overlay > * {\n pointer-events: all;\n}\n/* modification-overlay */\n.modification-overlay {\n position: absolute;\n inset: 0;\n z-index: 1;\n overflow: hidden;\n pointer-events: none;\n}\n.modification-overlay > * {\n pointer-events: all;\n}\n.lf-outline,\n.lf-snapline {\n pointer-events: none;\n}\n.lf-keyboard-tips {\n float: right;\n}\n.lf-node-select-decorate {\n position: absolute;\n border: 1px dashed #343435;\n transform: translate(-50%, -50%);\n pointer-events: none;\n}\n.lf-multiple-select {\n position: absolute;\n border: 2px dashed #187dffcc;\n box-shadow: 0 0 3px 0 #187dff80;\n cursor: move;\n}\n.lf-edge-adjust-point {\n cursor: move;\n}\n.lf-rotate-control {\n cursor: grabbing;\n}\n.lf-resize-control-nw {\n cursor: nw-resize;\n}\n.lf-resize-control-n {\n cursor: n-resize;\n}\n.lf-resize-control-ne {\n cursor: ne-resize;\n}\n.lf-resize-control-e {\n cursor: e-resize;\n}\n.lf-resize-control-se {\n cursor: se-resize;\n}\n.lf-resize-control-s {\n cursor: s-resize;\n}\n.lf-resize-control-sw {\n cursor: sw-resize;\n}\n.lf-resize-control-w {\n cursor: w-resize;\n}\n";
|
package/es/util/drag.d.ts
CHANGED
package/es/util/drag.js
CHANGED
|
@@ -121,6 +121,17 @@ var StepDrag = /** @class */ (function () {
|
|
|
121
121
|
_this.onDragEnd({ event: undefined });
|
|
122
122
|
_this.isDragging = false;
|
|
123
123
|
};
|
|
124
|
+
this.destroy = function () {
|
|
125
|
+
if (_this.isStartDragging) {
|
|
126
|
+
// https://github.com/didi/LogicFlow/issues/1934
|
|
127
|
+
// https://github.com/didi/LogicFlow/issues/1926
|
|
128
|
+
// cancelDrag()->onDragEnd()->updateEdgePointByAnchors()触发线的重新计算
|
|
129
|
+
// 我们的本意是为了防止mousemove和mouseup没有及时被移除
|
|
130
|
+
// 因此这里增加if(this.isStartDragging)的判断,isStartDragging=true代表没有触发handleMouseUp(),此时监听还没被移除
|
|
131
|
+
// 在拖拽情况下(isStartDragging=true),此时注册了监听,在组件突然销毁时,强制触发cancelDrag进行监听事件的移除
|
|
132
|
+
_this.cancelDrag();
|
|
133
|
+
}
|
|
134
|
+
};
|
|
124
135
|
this.onDragStart = onDragStart;
|
|
125
136
|
this.onDragging = onDragging;
|
|
126
137
|
this.onDragEnd = onDragEnd;
|
package/es/view/Anchor.js
CHANGED
|
@@ -139,14 +139,12 @@ var Anchor = /** @class */ (function (_super) {
|
|
|
139
139
|
_this.sourceRuleResults.clear();
|
|
140
140
|
_this.targetRuleResults.clear();
|
|
141
141
|
var _b = _this.props, graphModel = _b.graphModel, nodeModel = _b.nodeModel, anchorData = _b.anchorData;
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
});
|
|
149
|
-
}
|
|
142
|
+
graphModel.eventCenter.emit(EventType.ANCHOR_DRAGEND, {
|
|
143
|
+
data: anchorData,
|
|
144
|
+
e: event,
|
|
145
|
+
nodeModel: nodeModel,
|
|
146
|
+
edgeModel: edgeModel !== null && edgeModel !== void 0 ? edgeModel : undefined,
|
|
147
|
+
});
|
|
150
148
|
};
|
|
151
149
|
_this.checkEnd = function (event) {
|
|
152
150
|
var _a;
|
package/es/view/Control.js
CHANGED
|
@@ -316,7 +316,7 @@ var ResizeControl = /** @class */ (function (_super) {
|
|
|
316
316
|
return _this;
|
|
317
317
|
}
|
|
318
318
|
ResizeControl.prototype.componentWillUnmount = function () {
|
|
319
|
-
this.dragHandler.
|
|
319
|
+
this.dragHandler.destroy();
|
|
320
320
|
};
|
|
321
321
|
ResizeControl.prototype.render = function () {
|
|
322
322
|
var _a = this.props, x = _a.x, y = _a.y, direction = _a.direction, model = _a.model;
|
package/es/view/Graph.js
CHANGED
|
@@ -13,17 +13,6 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
13
13
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
14
|
};
|
|
15
15
|
})();
|
|
16
|
-
var __assign = (this && this.__assign) || function () {
|
|
17
|
-
__assign = Object.assign || function(t) {
|
|
18
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
19
|
-
s = arguments[i];
|
|
20
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
21
|
-
t[p] = s[p];
|
|
22
|
-
}
|
|
23
|
-
return t;
|
|
24
|
-
};
|
|
25
|
-
return __assign.apply(this, arguments);
|
|
26
|
-
};
|
|
27
16
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
28
17
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
29
18
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -102,12 +91,11 @@ var Graph = /** @class */ (function (_super) {
|
|
|
102
91
|
if (options.height) {
|
|
103
92
|
style.height = "".concat(graphModel.height, "px");
|
|
104
93
|
}
|
|
105
|
-
var
|
|
106
|
-
var fakeNode = graphModel.fakeNode, editConfigModel = graphModel.editConfigModel;
|
|
94
|
+
var fakeNode = graphModel.fakeNode, editConfigModel = graphModel.editConfigModel, background = graphModel.background;
|
|
107
95
|
var adjustEdge = editConfigModel.adjustEdge;
|
|
108
|
-
return (_jsxs("div", { className: "lf-graph", "flow-id": graphModel.flowId, children: [_jsxs(CanvasOverlay, { graphModel: graphModel, dnd: dnd, children: [_jsx("g", { className: "lf-base", children: map(graphModel.sortElements, function (nodeModel) {
|
|
96
|
+
return (_jsxs("div", { className: "lf-graph", "flow-id": graphModel.flowId, style: style, children: [_jsxs(CanvasOverlay, { graphModel: graphModel, dnd: dnd, children: [_jsx("g", { className: "lf-base", children: map(graphModel.sortElements, function (nodeModel) {
|
|
109
97
|
return _this.getComponent(nodeModel, graphModel);
|
|
110
|
-
}) }), fakeNode ? this.getComponent(fakeNode, graphModel) : ''] }), _jsxs(ModificationOverlay, { graphModel: graphModel, children: [_jsx(OutlineOverlay, { graphModel: graphModel }), adjustEdge ? _jsx(BezierAdjustOverlay, { graphModel: graphModel }) : '', options.snapline !== false ? (_jsx(SnaplineOverlay, { snaplineModel: snaplineModel })) : ('')] }), _jsx(ToolOverlay, { graphModel: graphModel, tool: tool }),
|
|
98
|
+
}) }), fakeNode ? this.getComponent(fakeNode, graphModel) : ''] }), _jsxs(ModificationOverlay, { graphModel: graphModel, children: [_jsx(OutlineOverlay, { graphModel: graphModel }), adjustEdge ? _jsx(BezierAdjustOverlay, { graphModel: graphModel }) : '', options.snapline !== false ? (_jsx(SnaplineOverlay, { snaplineModel: snaplineModel })) : ('')] }), _jsx(ToolOverlay, { graphModel: graphModel, tool: tool }), background && _jsx(BackgroundOverlay, { background: background }), _jsx(Grid, { graphModel: graphModel })] }));
|
|
111
99
|
};
|
|
112
100
|
Graph = __decorate([
|
|
113
101
|
observer
|
package/es/view/behavior/dnd.js
CHANGED
|
@@ -13,6 +13,7 @@ export type IEdgeState = {
|
|
|
13
13
|
export declare abstract class BaseEdge<P extends IProps> extends Component<P, IEdgeState> {
|
|
14
14
|
static isObserved: boolean;
|
|
15
15
|
static extendsKey?: string;
|
|
16
|
+
mouseUpDrag?: boolean;
|
|
16
17
|
startTime?: number;
|
|
17
18
|
contextMenuTime?: number;
|
|
18
19
|
clickTimer?: number;
|
|
@@ -127,10 +128,13 @@ export declare abstract class BaseEdge<P extends IProps> extends Component<P, IE
|
|
|
127
128
|
* 不支持重写
|
|
128
129
|
*/
|
|
129
130
|
handleMouseDown: (e: MouseEvent) => void;
|
|
131
|
+
handleMouseUp: () => void;
|
|
130
132
|
/**
|
|
131
133
|
* 不支持重写
|
|
132
134
|
*/
|
|
133
|
-
|
|
135
|
+
handleClick: (e: MouseEvent) => void;
|
|
136
|
+
handleFocus: () => void;
|
|
137
|
+
handleBlur: () => void;
|
|
134
138
|
/**
|
|
135
139
|
* @overridable 支持重写, 此方法为获取边的形状,如果需要自定义边的形状,请重写此方法。
|
|
136
140
|
* @example https://docs.logic-flow.cn/docs/#/zh/guide/basic/edge?id=%e5%9f%ba%e4%ba%8e-react-%e7%bb%84%e4%bb%b6%e8%87%aa%e5%ae%9a%e4%b9%89%e8%be%b9
|
package/es/view/edge/BaseEdge.js
CHANGED
|
@@ -123,15 +123,18 @@ var BaseEdge = /** @class */ (function (_super) {
|
|
|
123
123
|
e.stopPropagation();
|
|
124
124
|
_this.startTime = new Date().getTime();
|
|
125
125
|
};
|
|
126
|
+
_this.handleMouseUp = function () {
|
|
127
|
+
var model = _this.props.model;
|
|
128
|
+
_this.mouseUpDrag = model.isDragging;
|
|
129
|
+
};
|
|
126
130
|
/**
|
|
127
131
|
* 不支持重写
|
|
128
132
|
*/
|
|
129
|
-
_this.
|
|
133
|
+
_this.handleClick = function (e) {
|
|
130
134
|
if (!_this.startTime)
|
|
131
135
|
return;
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
return; // 事件大于200ms,认为是拖拽。
|
|
136
|
+
if (_this.mouseUpDrag)
|
|
137
|
+
return; // 如果是拖拽,不触发click事件。
|
|
135
138
|
var isRightClick = e.button === 2;
|
|
136
139
|
if (isRightClick)
|
|
137
140
|
return;
|
|
@@ -191,6 +194,18 @@ var BaseEdge = /** @class */ (function (_super) {
|
|
|
191
194
|
graphModel.selectEdgeById(model.id, isMultipleSelect(e, editConfigModel));
|
|
192
195
|
_this.toFront();
|
|
193
196
|
};
|
|
197
|
+
_this.handleFocus = function () {
|
|
198
|
+
var _a = _this.props, model = _a.model, graphModel = _a.graphModel;
|
|
199
|
+
graphModel.eventCenter.emit(EventType.EDGE_FOCUS, {
|
|
200
|
+
data: model.getData(),
|
|
201
|
+
});
|
|
202
|
+
};
|
|
203
|
+
_this.handleBlur = function () {
|
|
204
|
+
var _a = _this.props, model = _a.model, graphModel = _a.graphModel;
|
|
205
|
+
graphModel.eventCenter.emit(EventType.EDGE_BLUR, {
|
|
206
|
+
data: model.getData(),
|
|
207
|
+
});
|
|
208
|
+
};
|
|
194
209
|
return _this;
|
|
195
210
|
}
|
|
196
211
|
/**
|
|
@@ -379,7 +394,7 @@ var BaseEdge = /** @class */ (function (_super) {
|
|
|
379
394
|
isSelected && 'lf-edge-selected',
|
|
380
395
|
]
|
|
381
396
|
.filter(Boolean)
|
|
382
|
-
.join(' '), onMouseDown: this.handleMouseDown, onMouseUp: this.handleMouseUp, onContextMenu: this.handleContextMenu, onMouseOver: this.setHoverOn, onMouseEnter: this.setHoverOn, onMouseLeave: this.setHoverOff, children: [this.getShape(), this.getAppend(), this.getText(), this.getArrow()] }), isShowAdjustPoint && isSelected ? this.getAdjustPoints() : ''] }));
|
|
397
|
+
.join(' '), onMouseDown: this.handleMouseDown, onMouseUp: this.handleMouseUp, onClick: this.handleClick, onContextMenu: this.handleContextMenu, onMouseOver: this.setHoverOn, onMouseEnter: this.setHoverOn, onMouseLeave: this.setHoverOff, onFocus: this.handleFocus, onBlur: this.handleBlur, children: [this.getShape(), this.getAppend(), this.getText(), this.getArrow()] }), isShowAdjustPoint && isSelected ? this.getAdjustPoints() : ''] }));
|
|
383
398
|
};
|
|
384
399
|
BaseEdge.isObserved = false;
|
|
385
400
|
return BaseEdge;
|
|
@@ -38,6 +38,8 @@ export declare abstract class BaseNode<P extends IProps = IProps> extends Compon
|
|
|
38
38
|
handleClick: (e: MouseEvent) => void;
|
|
39
39
|
handleContextMenu: (ev: MouseEvent) => void;
|
|
40
40
|
handleMouseDown: (ev: MouseEvent) => void;
|
|
41
|
+
handleFocus: () => void;
|
|
42
|
+
handleBlur: () => void;
|
|
41
43
|
setHoverOn: (ev: MouseEvent) => void;
|
|
42
44
|
setHoverOff: (ev: MouseEvent) => void;
|
|
43
45
|
/**
|
package/es/view/node/BaseNode.js
CHANGED
|
@@ -258,6 +258,18 @@ var BaseNode = /** @class */ (function (_super) {
|
|
|
258
258
|
_this.stepDrag && _this.stepDrag.handleMouseDown(ev);
|
|
259
259
|
}
|
|
260
260
|
};
|
|
261
|
+
_this.handleFocus = function () {
|
|
262
|
+
var _a = _this.props, model = _a.model, graphModel = _a.graphModel;
|
|
263
|
+
graphModel.eventCenter.emit(EventType.NODE_FOCUS, {
|
|
264
|
+
data: model.getData(),
|
|
265
|
+
});
|
|
266
|
+
};
|
|
267
|
+
_this.handleBlur = function () {
|
|
268
|
+
var _a = _this.props, model = _a.model, graphModel = _a.graphModel;
|
|
269
|
+
graphModel.eventCenter.emit(EventType.NODE_BLUR, {
|
|
270
|
+
data: model.getData(),
|
|
271
|
+
});
|
|
272
|
+
};
|
|
261
273
|
// 因为自定义节点的时候,可能会基于hover状态自定义不同的样式。
|
|
262
274
|
_this.setHoverOn = function (ev) {
|
|
263
275
|
var _a = _this.props, model = _a.model, graphModel = _a.graphModel;
|
|
@@ -417,7 +429,7 @@ var BaseNode = /** @class */ (function (_super) {
|
|
|
417
429
|
if (adjustNodePosition && draggable) {
|
|
418
430
|
this.stepDrag.setStep(gridSize * SCALE_X);
|
|
419
431
|
}
|
|
420
|
-
nodeShape = (_jsx("g", __assign({ className: "".concat(this.getStateClassName(), " ").concat(className), onMouseDown: this.handleMouseDown, onMouseUp: this.handleMouseUp, onClick: this.handleClick, onMouseEnter: this.setHoverOn, onMouseOver: this.setHoverOn, onMouseLeave: this.setHoverOff, onMouseOut: this.onMouseOut, onContextMenu: this.handleContextMenu }, restAttributes, { children: nodeShapeInner })));
|
|
432
|
+
nodeShape = (_jsx("g", __assign({ className: "".concat(this.getStateClassName(), " ").concat(className), onMouseDown: this.handleMouseDown, onMouseUp: this.handleMouseUp, onClick: this.handleClick, onMouseEnter: this.setHoverOn, onMouseOver: this.setHoverOn, onMouseLeave: this.setHoverOff, onMouseOut: this.onMouseOut, onContextMenu: this.handleContextMenu, onFocus: this.handleFocus, onBlur: this.handleBlur }, restAttributes, { children: nodeShapeInner })));
|
|
421
433
|
}
|
|
422
434
|
return nodeShape;
|
|
423
435
|
};
|
|
@@ -1,26 +1,16 @@
|
|
|
1
1
|
import { Component } from 'preact/compat';
|
|
2
|
+
import { Options as LFOptions } from '../../options';
|
|
2
3
|
/**
|
|
3
4
|
* 背景配置, 支持css属性配置
|
|
4
5
|
* https://developer.mozilla.org/zh-CN/docs/Web/CSS/background
|
|
5
6
|
* @example
|
|
6
7
|
* {
|
|
7
|
-
*
|
|
8
|
-
|
|
8
|
+
* backgroundImage: "url('./img/grid.svg')",
|
|
9
|
+
backgroundRepeat: 'repeat',
|
|
9
10
|
* }
|
|
10
11
|
*/
|
|
11
|
-
export type BackgroundConfig = {
|
|
12
|
-
/**
|
|
13
|
-
* 背景图片地址
|
|
14
|
-
*/
|
|
15
|
-
backgroundImage?: string;
|
|
16
|
-
/**
|
|
17
|
-
* 是否重复
|
|
18
|
-
*/
|
|
19
|
-
backgroundRepeat?: string;
|
|
20
|
-
[key: string]: any;
|
|
21
|
-
};
|
|
22
12
|
type IProps = {
|
|
23
|
-
background: BackgroundConfig;
|
|
13
|
+
background: boolean | LFOptions.BackgroundConfig;
|
|
24
14
|
};
|
|
25
15
|
export declare class BackgroundOverlay extends Component<IProps> {
|
|
26
16
|
render(): import("preact/compat").JSX.Element;
|
|
@@ -13,8 +13,16 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
13
13
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
14
|
};
|
|
15
15
|
})();
|
|
16
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
17
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
18
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
19
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
20
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
21
|
+
};
|
|
16
22
|
import { jsx as _jsx } from "preact/jsx-runtime";
|
|
17
23
|
import { Component } from 'preact/compat';
|
|
24
|
+
import { isObject } from 'lodash-es';
|
|
25
|
+
import { observer } from '../..';
|
|
18
26
|
var BackgroundOverlay = /** @class */ (function (_super) {
|
|
19
27
|
__extends(BackgroundOverlay, _super);
|
|
20
28
|
function BackgroundOverlay() {
|
|
@@ -22,8 +30,11 @@ var BackgroundOverlay = /** @class */ (function (_super) {
|
|
|
22
30
|
}
|
|
23
31
|
BackgroundOverlay.prototype.render = function () {
|
|
24
32
|
var background = this.props.background;
|
|
25
|
-
return (_jsx("div", { className: "lf-background", children: _jsx("div", { style: background, className: "lf-background-area" }) }));
|
|
33
|
+
return (_jsx("div", { className: "lf-background", children: _jsx("div", { style: isObject(background) ? background : {}, className: "lf-background-area" }) }));
|
|
26
34
|
};
|
|
35
|
+
BackgroundOverlay = __decorate([
|
|
36
|
+
observer
|
|
37
|
+
], BackgroundOverlay);
|
|
27
38
|
return BackgroundOverlay;
|
|
28
39
|
}(Component));
|
|
29
40
|
export { BackgroundOverlay };
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Component } from 'preact/compat';
|
|
2
2
|
import { GraphModel } from '../../model';
|
|
3
|
-
|
|
4
|
-
type IProps = GridOptions & {
|
|
3
|
+
type IProps = {
|
|
5
4
|
graphModel: GraphModel;
|
|
6
5
|
};
|
|
7
6
|
export declare class Grid extends Component<IProps> {
|
|
7
|
+
gridOptions: Grid.GridOptions;
|
|
8
8
|
readonly id: string;
|
|
9
|
+
constructor(props: IProps);
|
|
9
10
|
renderDot(): import("preact/compat").JSX.Element;
|
|
10
11
|
renderMesh(): import("preact/compat").JSX.Element;
|
|
11
12
|
render(): import("preact/compat").JSX.Element;
|
|
@@ -30,7 +31,7 @@ export declare namespace Grid {
|
|
|
30
31
|
/**
|
|
31
32
|
* 网格的颜色
|
|
32
33
|
*/
|
|
33
|
-
color
|
|
34
|
+
color?: string;
|
|
34
35
|
/**
|
|
35
36
|
* 网格的宽度
|
|
36
37
|
* - 对于 `dot` 点状网格,表示点的大小
|
package/es/view/overlay/Grid.js
CHANGED
|
@@ -19,31 +19,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
19
19
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
20
20
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
21
21
|
};
|
|
22
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
23
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
24
|
-
if (!m) return o;
|
|
25
|
-
var i = m.call(o), r, ar = [], e;
|
|
26
|
-
try {
|
|
27
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
28
|
-
}
|
|
29
|
-
catch (error) { e = { error: error }; }
|
|
30
|
-
finally {
|
|
31
|
-
try {
|
|
32
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
33
|
-
}
|
|
34
|
-
finally { if (e) throw e.error; }
|
|
35
|
-
}
|
|
36
|
-
return ar;
|
|
37
|
-
};
|
|
38
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
39
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
40
|
-
if (ar || !(i in from)) {
|
|
41
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
42
|
-
ar[i] = from[i];
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
|
-
};
|
|
47
22
|
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
48
23
|
import { Component } from 'preact/compat';
|
|
49
24
|
import { cloneDeep, assign } from 'lodash-es';
|
|
@@ -52,14 +27,15 @@ import { createUuid } from '../../util';
|
|
|
52
27
|
import { DEFAULT_GRID_SIZE } from '../../constant';
|
|
53
28
|
var Grid = /** @class */ (function (_super) {
|
|
54
29
|
__extends(Grid, _super);
|
|
55
|
-
function Grid() {
|
|
56
|
-
var _this = _super.
|
|
30
|
+
function Grid(props) {
|
|
31
|
+
var _this = _super.call(this, props) || this;
|
|
57
32
|
_this.id = createUuid();
|
|
33
|
+
_this.gridOptions = _this.props.graphModel.grid;
|
|
58
34
|
return _this;
|
|
59
35
|
}
|
|
60
36
|
// 网格类型为点状
|
|
61
37
|
Grid.prototype.renderDot = function () {
|
|
62
|
-
var _a = this.
|
|
38
|
+
var _a = this.gridOptions, config = _a.config, _b = _a.size, size = _b === void 0 ? 1 : _b, visible = _a.visible;
|
|
63
39
|
var _c = config !== null && config !== void 0 ? config : {}, color = _c.color, _d = _c.thickness, thickness = _d === void 0 ? 2 : _d;
|
|
64
40
|
// 对于点状网格,点的半径不能大于网格大小的四分之一
|
|
65
41
|
var radius = Math.min(Math.max(2, thickness), size / 4);
|
|
@@ -69,16 +45,17 @@ var Grid = /** @class */ (function (_super) {
|
|
|
69
45
|
// 网格类型为交叉线
|
|
70
46
|
// todo: 采用背景缩放的方式,实现更好的体验
|
|
71
47
|
Grid.prototype.renderMesh = function () {
|
|
72
|
-
var _a = this.
|
|
48
|
+
var _a = this.gridOptions, config = _a.config, _b = _a.size, size = _b === void 0 ? 1 : _b, visible = _a.visible;
|
|
73
49
|
var _c = config !== null && config !== void 0 ? config : {}, color = _c.color, _d = _c.thickness, thickness = _d === void 0 ? 1 : _d;
|
|
74
50
|
// 对于交叉线网格,线的宽度不能大于网格大小的一半
|
|
75
51
|
var strokeWidth = Math.min(Math.max(1, thickness), size / 2);
|
|
76
52
|
var d = "M 0 0 H ".concat(size, " V ").concat(size, " H 0 Z");
|
|
77
53
|
var opacity = visible ? 1 : 0;
|
|
78
|
-
return (_jsx("path", { d: d, stroke: color, strokeWidth: strokeWidth, opacity: opacity, fill: "transparent" }));
|
|
54
|
+
return (_jsx("path", { d: d, stroke: color, strokeWidth: strokeWidth / 2, opacity: opacity, fill: "transparent" }));
|
|
79
55
|
};
|
|
80
56
|
Grid.prototype.render = function () {
|
|
81
|
-
var
|
|
57
|
+
var transformModel = this.props.graphModel.transformModel;
|
|
58
|
+
var _a = this.gridOptions, type = _a.type, _b = _a.size, size = _b === void 0 ? 1 : _b;
|
|
82
59
|
var SCALE_X = transformModel.SCALE_X, SKEW_Y = transformModel.SKEW_Y, SKEW_X = transformModel.SKEW_X, SCALE_Y = transformModel.SCALE_Y, TRANSLATE_X = transformModel.TRANSLATE_X, TRANSLATE_Y = transformModel.TRANSLATE_Y;
|
|
83
60
|
var matrixString = [
|
|
84
61
|
SCALE_X,
|
|
@@ -25,7 +25,7 @@ export declare function getTransform<P>(WrappedComponent: ComponentType<P>): {
|
|
|
25
25
|
props: import("preact").RenderableProps<IProps & P, any>;
|
|
26
26
|
context: any;
|
|
27
27
|
base?: Element | Text | undefined;
|
|
28
|
-
setState<K extends never>(state:
|
|
28
|
+
setState<K extends never>(state: ((prevState: Readonly<{}>, props: Readonly<IProps & P>) => Pick<{}, K> | Partial<{}> | null) | Pick<{}, K> | Partial<{}> | null, callback?: (() => void) | undefined): void;
|
|
29
29
|
forceUpdate(callback?: (() => void) | undefined): void;
|
|
30
30
|
};
|
|
31
31
|
displayName?: string | undefined;
|
package/es/view/text/BaseText.js
CHANGED
|
@@ -61,7 +61,7 @@ var BaseText = /** @class */ (function (_super) {
|
|
|
61
61
|
_this.onDragging = function (_a) {
|
|
62
62
|
var deltaX = _a.deltaX, deltaY = _a.deltaY;
|
|
63
63
|
var _b = _this.props, model = _b.model, transformModel = _b.graphModel.transformModel;
|
|
64
|
-
if (deltaX
|
|
64
|
+
if (deltaX || deltaY) {
|
|
65
65
|
var _c = __read(transformModel.fixDeltaXY(deltaX, deltaY), 2), curDeltaX = _c[0], curDeltaY = _c[1];
|
|
66
66
|
model.moveText(curDeltaX, curDeltaY);
|
|
67
67
|
}
|
package/lib/algorithm/edge.js
CHANGED
|
@@ -52,10 +52,8 @@ var isInSegment = function (point, start, end) {
|
|
|
52
52
|
var endX = end.x, endY = end.y;
|
|
53
53
|
var k = (endY - startY) / (endX - startX);
|
|
54
54
|
var b = startY - k * startX;
|
|
55
|
-
return (x >= startX &&
|
|
56
|
-
|
|
57
|
-
y
|
|
58
|
-
y <= endY &&
|
|
59
|
-
Math.abs(y - k * x + b) < Number.EPSILON);
|
|
55
|
+
return (((x >= startX && x <= endX) || (x <= startX && x >= endX)) &&
|
|
56
|
+
((y >= startY && y <= endY) || (y <= startY && y >= endY)) &&
|
|
57
|
+
Math.abs(y - k * x - b) < Number.EPSILON);
|
|
60
58
|
};
|
|
61
59
|
exports.isInSegment = isInSegment;
|
package/lib/constant/index.d.ts
CHANGED
|
@@ -49,12 +49,16 @@ export declare enum EventType {
|
|
|
49
49
|
NODE_CONTEXTMENU = "node:contextmenu",
|
|
50
50
|
NODE_ROTATE = "node:rotate",
|
|
51
51
|
NODE_RESIZE = "node:resize",
|
|
52
|
+
NODE_FOCUS = "node:focus",
|
|
53
|
+
NODE_BLUR = "node:blur",
|
|
52
54
|
NODE_PROPERTIES_CHANGE = "node:properties-change",
|
|
53
55
|
NODE_PROPERTIES_DELETE = "node:properties-delete",
|
|
54
56
|
EDGE_ADD = "edge:add",
|
|
55
57
|
EDGE_DELETE = "edge:delete",
|
|
56
58
|
EDGE_CLICK = "edge:click",
|
|
57
59
|
EDGE_DBCLICK = "edge:dbclick",
|
|
60
|
+
EDGE_FOCUS = "edge:focus",
|
|
61
|
+
EDGE_BLUR = "edge:blur",
|
|
58
62
|
EDGE_MOUSEENTER = "edge:mouseenter",
|
|
59
63
|
EDGE_MOUSELEAVE = "edge:mouseleave",
|
|
60
64
|
EDGE_CONTEXTMENU = "edge:contextmenu",
|
package/lib/constant/index.js
CHANGED
|
@@ -57,6 +57,8 @@ var EventType;
|
|
|
57
57
|
EventType["NODE_CONTEXTMENU"] = "node:contextmenu";
|
|
58
58
|
EventType["NODE_ROTATE"] = "node:rotate";
|
|
59
59
|
EventType["NODE_RESIZE"] = "node:resize";
|
|
60
|
+
EventType["NODE_FOCUS"] = "node:focus";
|
|
61
|
+
EventType["NODE_BLUR"] = "node:blur";
|
|
60
62
|
// 节点 properties 变化事件
|
|
61
63
|
EventType["NODE_PROPERTIES_CHANGE"] = "node:properties-change";
|
|
62
64
|
EventType["NODE_PROPERTIES_DELETE"] = "node:properties-delete";
|
|
@@ -65,6 +67,8 @@ var EventType;
|
|
|
65
67
|
EventType["EDGE_DELETE"] = "edge:delete";
|
|
66
68
|
EventType["EDGE_CLICK"] = "edge:click";
|
|
67
69
|
EventType["EDGE_DBCLICK"] = "edge:dbclick";
|
|
70
|
+
EventType["EDGE_FOCUS"] = "edge:focus";
|
|
71
|
+
EventType["EDGE_BLUR"] = "edge:blur";
|
|
68
72
|
EventType["EDGE_MOUSEENTER"] = "edge:mouseenter";
|
|
69
73
|
EventType["EDGE_MOUSELEAVE"] = "edge:mouseleave";
|
|
70
74
|
EventType["EDGE_CONTEXTMENU"] = "edge:contextmenu";
|