@antv/g6 5.0.0-beta.31 → 5.0.0-beta.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/g6.min.js +2 -2
- package/dist/lib/behaviors/brush-select.d.ts +104 -0
- package/dist/lib/behaviors/click-element.d.ts +77 -0
- package/dist/lib/behaviors/collapse-expand.d.ts +4 -5
- package/dist/lib/behaviors/create-edge.d.ts +55 -0
- package/dist/lib/behaviors/drag-canvas.d.ts +6 -6
- package/dist/lib/behaviors/drag-element-force.d.ts +14 -0
- package/dist/lib/behaviors/drag-element.d.ts +17 -14
- package/dist/lib/behaviors/focus-element.d.ts +4 -3
- package/dist/lib/behaviors/hover-element.d.ts +4 -5
- package/dist/lib/behaviors/index.d.ts +10 -0
- package/dist/lib/behaviors/lasso-select.d.ts +20 -0
- package/dist/lib/behaviors/types.d.ts +1 -0
- package/dist/lib/behaviors/zoom-canvas.d.ts +7 -6
- package/dist/lib/constants/change.d.ts +1 -1
- package/dist/lib/constants/events/graph.d.ts +9 -15
- package/dist/lib/constants/index.d.ts +1 -0
- package/dist/lib/constants/registry.d.ts +22 -0
- package/dist/lib/elements/combos/base-combo.d.ts +64 -6
- package/dist/lib/elements/combos/circle.d.ts +8 -12
- package/dist/lib/elements/combos/rect.d.ts +5 -9
- package/dist/lib/elements/edges/base-edge.d.ts +85 -10
- package/dist/lib/elements/edges/cubic-horizontal.d.ts +2 -2
- package/dist/lib/elements/edges/cubic-vertical.d.ts +2 -2
- package/dist/lib/elements/edges/cubic.d.ts +2 -2
- package/dist/lib/elements/edges/polyline.d.ts +2 -2
- package/dist/lib/elements/edges/quadratic.d.ts +2 -2
- package/dist/lib/elements/nodes/base-node.d.ts +125 -13
- package/dist/lib/elements/nodes/circle.d.ts +5 -8
- package/dist/lib/elements/nodes/diamond.d.ts +2 -4
- package/dist/lib/elements/nodes/ellipse.d.ts +5 -8
- package/dist/lib/elements/nodes/hexagon.d.ts +6 -9
- package/dist/lib/elements/nodes/image.d.ts +9 -11
- package/dist/lib/elements/nodes/polygon.d.ts +9 -8
- package/dist/lib/elements/nodes/rect.d.ts +2 -3
- package/dist/lib/elements/nodes/star.d.ts +7 -10
- package/dist/lib/elements/nodes/triangle.d.ts +7 -10
- package/dist/lib/exports.d.ts +18 -14
- package/dist/lib/layouts/index.d.ts +1 -1
- package/dist/lib/layouts/types.d.ts +6 -6
- package/dist/lib/palettes/index.d.ts +1 -0
- package/dist/lib/plugins/camera-setting.d.ts +95 -0
- package/dist/lib/plugins/contextmenu.d.ts +8 -5
- package/dist/lib/plugins/history/events.d.ts +21 -0
- package/dist/lib/plugins/history/index.d.ts +82 -0
- package/dist/lib/plugins/history/utils.d.ts +31 -0
- package/dist/lib/plugins/hull/index.d.ts +59 -0
- package/dist/lib/plugins/hull/shape.d.ts +49 -0
- package/dist/lib/plugins/hull/util.d.ts +12 -0
- package/dist/lib/plugins/index.d.ts +8 -0
- package/dist/lib/plugins/legend.d.ts +49 -0
- package/dist/lib/plugins/tooltip.d.ts +12 -10
- package/dist/lib/registry/extension/index.d.ts +3 -3
- package/dist/lib/registry/index.d.ts +6 -4
- package/dist/lib/registry/types.d.ts +4 -6
- package/dist/lib/runtime/batch.d.ts +11 -0
- package/dist/lib/runtime/behavior.d.ts +1 -1
- package/dist/lib/runtime/canvas.d.ts +15 -4
- package/dist/lib/runtime/data.d.ts +4 -4
- package/dist/lib/runtime/element.d.ts +6 -23
- package/dist/lib/runtime/graph.d.ts +71 -6
- package/dist/lib/runtime/layout.d.ts +5 -11
- package/dist/lib/runtime/plugin.d.ts +2 -1
- package/dist/lib/runtime/transform.d.ts +11 -0
- package/dist/lib/runtime/types.d.ts +14 -0
- package/dist/lib/spec/index.d.ts +1 -0
- package/dist/lib/spec/spec.d.ts +7 -0
- package/dist/lib/spec/transform.d.ts +12 -0
- package/dist/lib/transforms/arrange-draw-order.d.ts +10 -0
- package/dist/lib/transforms/base-transform.d.ts +7 -0
- package/dist/lib/transforms/collapse-expand-combo.d.ts +10 -0
- package/dist/lib/transforms/index.d.ts +6 -0
- package/dist/lib/transforms/process-parallel-edges.d.ts +84 -0
- package/dist/lib/transforms/types.d.ts +20 -0
- package/dist/lib/transforms/update-related-edge.d.ts +9 -0
- package/dist/lib/types/canvas.d.ts +1 -1
- package/dist/lib/types/change.d.ts +27 -10
- package/dist/lib/types/element.d.ts +6 -140
- package/dist/lib/types/event.d.ts +42 -7
- package/dist/lib/types/index.d.ts +0 -1
- package/dist/lib/types/node.d.ts +3 -3
- package/dist/lib/types/point.d.ts +1 -0
- package/dist/lib/utils/animation.d.ts +1 -1
- package/dist/lib/utils/bbox.d.ts +1 -1
- package/dist/lib/utils/behaviors/brush.d.ts +19 -0
- package/dist/lib/utils/behaviors/lasso.d.ts +13 -0
- package/dist/lib/utils/behaviors/utils.d.ts +21 -0
- package/dist/lib/utils/change.d.ts +9 -1
- package/dist/lib/utils/combo.d.ts +5 -4
- package/dist/lib/utils/edge.d.ts +11 -0
- package/dist/lib/utils/element.d.ts +19 -11
- package/dist/lib/utils/event/events.d.ts +9 -14
- package/dist/lib/utils/extension.d.ts +1 -1
- package/dist/lib/utils/id.d.ts +3 -8
- package/dist/lib/utils/line.d.ts +21 -0
- package/dist/lib/utils/path.d.ts +35 -0
- package/dist/lib/utils/point.d.ts +74 -20
- package/dist/lib/utils/polygon.d.ts +17 -0
- package/dist/lib/utils/position.d.ts +14 -1
- package/dist/lib/utils/prefix.d.ts +1 -1
- package/dist/lib/utils/shortcut.d.ts +11 -0
- package/dist/lib/utils/vector.d.ts +3 -2
- package/esm/behaviors/brush-select.d.ts +104 -0
- package/esm/behaviors/brush-select.js +199 -0
- package/esm/behaviors/brush-select.js.map +1 -0
- package/esm/behaviors/click-element.d.ts +77 -0
- package/esm/behaviors/click-element.js +108 -0
- package/esm/behaviors/click-element.js.map +1 -0
- package/esm/behaviors/collapse-expand.d.ts +4 -5
- package/esm/behaviors/collapse-expand.js +8 -4
- package/esm/behaviors/collapse-expand.js.map +1 -1
- package/esm/behaviors/create-edge.d.ts +55 -0
- package/esm/behaviors/create-edge.js +141 -0
- package/esm/behaviors/create-edge.js.map +1 -0
- package/esm/behaviors/drag-canvas.d.ts +6 -6
- package/esm/behaviors/drag-canvas.js +15 -7
- package/esm/behaviors/drag-canvas.js.map +1 -1
- package/esm/behaviors/drag-element-force.d.ts +14 -0
- package/esm/behaviors/drag-element-force.js +55 -0
- package/esm/behaviors/drag-element-force.js.map +1 -0
- package/esm/behaviors/drag-element.d.ts +17 -14
- package/esm/behaviors/drag-element.js +17 -9
- package/esm/behaviors/drag-element.js.map +1 -1
- package/esm/behaviors/focus-element.d.ts +4 -3
- package/esm/behaviors/focus-element.js.map +1 -1
- package/esm/behaviors/hover-element.d.ts +4 -5
- package/esm/behaviors/hover-element.js +2 -2
- package/esm/behaviors/hover-element.js.map +1 -1
- package/esm/behaviors/index.d.ts +10 -0
- package/esm/behaviors/index.js +5 -0
- package/esm/behaviors/index.js.map +1 -1
- package/esm/behaviors/lasso-select.d.ts +20 -0
- package/esm/behaviors/lasso-select.js +79 -0
- package/esm/behaviors/lasso-select.js.map +1 -0
- package/esm/behaviors/types.d.ts +1 -0
- package/esm/behaviors/zoom-canvas.d.ts +7 -6
- package/esm/behaviors/zoom-canvas.js +6 -2
- package/esm/behaviors/zoom-canvas.js.map +1 -1
- package/esm/constants/change.d.ts +1 -1
- package/esm/constants/change.js +12 -12
- package/esm/constants/change.js.map +1 -1
- package/esm/constants/events/graph.d.ts +9 -15
- package/esm/constants/events/graph.js +8 -16
- package/esm/constants/events/graph.js.map +1 -1
- package/esm/constants/index.d.ts +1 -0
- package/esm/constants/index.js +1 -0
- package/esm/constants/index.js.map +1 -1
- package/esm/constants/registry.d.ts +22 -0
- package/esm/constants/registry.js +24 -0
- package/esm/constants/registry.js.map +1 -0
- package/esm/elements/combos/base-combo.d.ts +64 -6
- package/esm/elements/combos/base-combo.js +21 -0
- package/esm/elements/combos/base-combo.js.map +1 -1
- package/esm/elements/combos/circle.d.ts +8 -12
- package/esm/elements/combos/circle.js.map +1 -1
- package/esm/elements/combos/rect.d.ts +5 -9
- package/esm/elements/combos/rect.js.map +1 -1
- package/esm/elements/edges/base-edge.d.ts +85 -10
- package/esm/elements/edges/base-edge.js +21 -0
- package/esm/elements/edges/base-edge.js.map +1 -1
- package/esm/elements/edges/cubic-horizontal.d.ts +2 -2
- package/esm/elements/edges/cubic-vertical.d.ts +2 -2
- package/esm/elements/edges/cubic.d.ts +2 -2
- package/esm/elements/edges/polyline.d.ts +2 -2
- package/esm/elements/edges/quadratic.d.ts +2 -2
- package/esm/elements/nodes/base-node.d.ts +125 -13
- package/esm/elements/nodes/base-node.js +25 -1
- package/esm/elements/nodes/base-node.js.map +1 -1
- package/esm/elements/nodes/circle.d.ts +5 -8
- package/esm/elements/nodes/circle.js.map +1 -1
- package/esm/elements/nodes/diamond.d.ts +2 -4
- package/esm/elements/nodes/diamond.js +2 -2
- package/esm/elements/nodes/diamond.js.map +1 -1
- package/esm/elements/nodes/ellipse.d.ts +5 -8
- package/esm/elements/nodes/ellipse.js +1 -1
- package/esm/elements/nodes/ellipse.js.map +1 -1
- package/esm/elements/nodes/hexagon.d.ts +6 -9
- package/esm/elements/nodes/hexagon.js.map +1 -1
- package/esm/elements/nodes/image.d.ts +9 -11
- package/esm/elements/nodes/image.js.map +1 -1
- package/esm/elements/nodes/polygon.d.ts +9 -8
- package/esm/elements/nodes/polygon.js +4 -1
- package/esm/elements/nodes/polygon.js.map +1 -1
- package/esm/elements/nodes/rect.d.ts +2 -3
- package/esm/elements/nodes/rect.js.map +1 -1
- package/esm/elements/nodes/star.d.ts +7 -10
- package/esm/elements/nodes/star.js.map +1 -1
- package/esm/elements/nodes/triangle.d.ts +7 -10
- package/esm/elements/nodes/triangle.js.map +1 -1
- package/esm/exports.d.ts +18 -14
- package/esm/exports.js +8 -6
- package/esm/exports.js.map +1 -1
- package/esm/layouts/index.d.ts +1 -1
- package/esm/layouts/index.js +1 -1
- package/esm/layouts/index.js.map +1 -1
- package/esm/layouts/types.d.ts +6 -6
- package/esm/palettes/index.d.ts +1 -0
- package/esm/palettes/index.js +12 -0
- package/esm/palettes/index.js.map +1 -1
- package/esm/plugins/camera-setting.d.ts +95 -0
- package/esm/plugins/camera-setting.js +65 -0
- package/esm/plugins/camera-setting.js.map +1 -0
- package/esm/plugins/contextmenu.d.ts +8 -5
- package/esm/plugins/contextmenu.js.map +1 -1
- package/esm/plugins/history/events.d.ts +21 -0
- package/esm/plugins/history/events.js +16 -0
- package/esm/plugins/history/events.js.map +1 -0
- package/esm/plugins/history/index.d.ts +82 -0
- package/esm/plugins/history/index.js +168 -0
- package/esm/plugins/history/index.js.map +1 -0
- package/esm/plugins/history/utils.d.ts +31 -0
- package/esm/plugins/history/utils.js +79 -0
- package/esm/plugins/history/utils.js.map +1 -0
- package/esm/plugins/hull/index.d.ts +59 -0
- package/esm/plugins/hull/index.js +107 -0
- package/esm/plugins/hull/index.js.map +1 -0
- package/esm/plugins/hull/shape.d.ts +49 -0
- package/esm/plugins/hull/shape.js +35 -0
- package/esm/plugins/hull/shape.js.map +1 -0
- package/esm/plugins/hull/util.d.ts +12 -0
- package/esm/plugins/hull/util.js +203 -0
- package/esm/plugins/hull/util.js.map +1 -0
- package/esm/plugins/index.d.ts +8 -0
- package/esm/plugins/index.js +4 -0
- package/esm/plugins/index.js.map +1 -1
- package/esm/plugins/legend.d.ts +49 -0
- package/esm/plugins/legend.js +267 -0
- package/esm/plugins/legend.js.map +1 -0
- package/esm/plugins/tooltip.d.ts +12 -10
- package/esm/plugins/tooltip.js +0 -1
- package/esm/plugins/tooltip.js.map +1 -1
- package/esm/preset.js +2 -5
- package/esm/preset.js.map +1 -1
- package/esm/registry/build-in.js +21 -4
- package/esm/registry/build-in.js.map +1 -1
- package/esm/registry/extension/index.d.ts +3 -3
- package/esm/registry/extension/index.js.map +1 -1
- package/esm/registry/index.d.ts +6 -4
- package/esm/registry/index.js +1 -0
- package/esm/registry/index.js.map +1 -1
- package/esm/registry/types.d.ts +4 -6
- package/esm/runtime/batch.d.ts +11 -0
- package/esm/runtime/batch.js +31 -0
- package/esm/runtime/batch.js.map +1 -0
- package/esm/runtime/behavior.d.ts +1 -1
- package/esm/runtime/behavior.js +3 -2
- package/esm/runtime/behavior.js.map +1 -1
- package/esm/runtime/canvas.d.ts +15 -4
- package/esm/runtime/canvas.js +103 -41
- package/esm/runtime/canvas.js.map +1 -1
- package/esm/runtime/data.d.ts +4 -4
- package/esm/runtime/data.js +23 -25
- package/esm/runtime/data.js.map +1 -1
- package/esm/runtime/element.d.ts +6 -23
- package/esm/runtime/element.js +48 -150
- package/esm/runtime/element.js.map +1 -1
- package/esm/runtime/graph.d.ts +71 -6
- package/esm/runtime/graph.js +105 -10
- package/esm/runtime/graph.js.map +1 -1
- package/esm/runtime/layout.d.ts +5 -11
- package/esm/runtime/layout.js +29 -75
- package/esm/runtime/layout.js.map +1 -1
- package/esm/runtime/plugin.d.ts +2 -1
- package/esm/runtime/plugin.js +3 -0
- package/esm/runtime/plugin.js.map +1 -1
- package/esm/runtime/transform.d.ts +11 -0
- package/esm/runtime/transform.js +20 -0
- package/esm/runtime/transform.js.map +1 -0
- package/esm/runtime/types.d.ts +14 -0
- package/esm/spec/index.d.ts +1 -0
- package/esm/spec/spec.d.ts +7 -0
- package/esm/spec/transform.d.ts +12 -0
- package/esm/spec/transform.js +2 -0
- package/esm/spec/transform.js.map +1 -0
- package/esm/themes/base.js +9 -1
- package/esm/themes/base.js.map +1 -1
- package/esm/transforms/arrange-draw-order.d.ts +10 -0
- package/esm/transforms/arrange-draw-order.js +27 -0
- package/esm/transforms/arrange-draw-order.js.map +1 -0
- package/esm/transforms/base-transform.d.ts +7 -0
- package/esm/transforms/base-transform.js +7 -0
- package/esm/transforms/base-transform.js.map +1 -0
- package/esm/transforms/collapse-expand-combo.d.ts +10 -0
- package/esm/transforms/collapse-expand-combo.js +82 -0
- package/esm/transforms/collapse-expand-combo.js.map +1 -0
- package/esm/transforms/index.d.ts +6 -0
- package/esm/transforms/index.js +6 -0
- package/esm/transforms/index.js.map +1 -0
- package/esm/transforms/process-parallel-edges.d.ts +84 -0
- package/esm/transforms/process-parallel-edges.js +215 -0
- package/esm/transforms/process-parallel-edges.js.map +1 -0
- package/esm/transforms/types.d.ts +20 -0
- package/esm/transforms/types.js +11 -0
- package/esm/transforms/types.js.map +1 -0
- package/esm/transforms/update-related-edge.d.ts +9 -0
- package/esm/transforms/update-related-edge.js +20 -0
- package/esm/transforms/update-related-edge.js.map +1 -0
- package/esm/types/canvas.d.ts +1 -1
- package/esm/types/change.d.ts +27 -10
- package/esm/types/element.d.ts +6 -140
- package/esm/types/event.d.ts +42 -7
- package/esm/types/index.d.ts +0 -1
- package/esm/types/node.d.ts +3 -3
- package/esm/types/point.d.ts +1 -0
- package/esm/utils/animation.d.ts +1 -1
- package/esm/utils/animation.js +6 -0
- package/esm/utils/animation.js.map +1 -1
- package/esm/utils/bbox.d.ts +1 -1
- package/esm/utils/behaviors/brush.d.ts +19 -0
- package/esm/utils/behaviors/brush.js +25 -0
- package/esm/utils/behaviors/brush.js.map +1 -0
- package/esm/utils/behaviors/lasso.d.ts +13 -0
- package/esm/utils/behaviors/lasso.js +112 -0
- package/esm/utils/behaviors/lasso.js.map +1 -0
- package/esm/utils/behaviors/utils.d.ts +21 -0
- package/esm/utils/behaviors/utils.js +42 -0
- package/esm/utils/behaviors/utils.js.map +1 -0
- package/esm/utils/change.d.ts +9 -1
- package/esm/utils/change.js +28 -0
- package/esm/utils/change.js.map +1 -1
- package/esm/utils/combo.d.ts +5 -4
- package/esm/utils/combo.js.map +1 -1
- package/esm/utils/edge.d.ts +11 -0
- package/esm/utils/edge.js +1 -1
- package/esm/utils/edge.js.map +1 -1
- package/esm/utils/element.d.ts +19 -11
- package/esm/utils/element.js +19 -9
- package/esm/utils/element.js.map +1 -1
- package/esm/utils/event/events.d.ts +9 -14
- package/esm/utils/event/events.js +3 -8
- package/esm/utils/event/events.js.map +1 -1
- package/esm/utils/extension.d.ts +1 -1
- package/esm/utils/extension.js.map +1 -1
- package/esm/utils/id.d.ts +3 -8
- package/esm/utils/id.js +8 -2
- package/esm/utils/id.js.map +1 -1
- package/esm/utils/line.d.ts +21 -0
- package/esm/utils/line.js +41 -0
- package/esm/utils/line.js.map +1 -0
- package/esm/utils/path.d.ts +35 -0
- package/esm/utils/path.js +143 -0
- package/esm/utils/path.js.map +1 -0
- package/esm/utils/point.d.ts +74 -20
- package/esm/utils/point.js +168 -44
- package/esm/utils/point.js.map +1 -1
- package/esm/utils/polygon.d.ts +17 -0
- package/esm/utils/polygon.js +62 -0
- package/esm/utils/polygon.js.map +1 -0
- package/esm/utils/position.d.ts +14 -1
- package/esm/utils/position.js +16 -0
- package/esm/utils/position.js.map +1 -1
- package/esm/utils/prefix.d.ts +1 -1
- package/esm/utils/prefix.js.map +1 -1
- package/esm/utils/shortcut.d.ts +11 -0
- package/esm/utils/shortcut.js +37 -5
- package/esm/utils/shortcut.js.map +1 -1
- package/esm/utils/style.js.map +1 -1
- package/esm/utils/vector.d.ts +3 -2
- package/esm/utils/vector.js +10 -3
- package/esm/utils/vector.js.map +1 -1
- package/lib/behaviors/brush-select.d.ts +104 -0
- package/lib/behaviors/brush-select.js +203 -0
- package/lib/behaviors/brush-select.js.map +1 -0
- package/lib/behaviors/click-element.d.ts +77 -0
- package/lib/behaviors/click-element.js +112 -0
- package/lib/behaviors/click-element.js.map +1 -0
- package/lib/behaviors/collapse-expand.d.ts +4 -5
- package/lib/behaviors/collapse-expand.js +8 -4
- package/lib/behaviors/collapse-expand.js.map +1 -1
- package/lib/behaviors/create-edge.d.ts +55 -0
- package/lib/behaviors/create-edge.js +145 -0
- package/lib/behaviors/create-edge.js.map +1 -0
- package/lib/behaviors/drag-canvas.d.ts +6 -6
- package/lib/behaviors/drag-canvas.js +15 -7
- package/lib/behaviors/drag-canvas.js.map +1 -1
- package/lib/behaviors/drag-element-force.d.ts +14 -0
- package/lib/behaviors/drag-element-force.js +59 -0
- package/lib/behaviors/drag-element-force.js.map +1 -0
- package/lib/behaviors/drag-element.d.ts +17 -14
- package/lib/behaviors/drag-element.js +17 -9
- package/lib/behaviors/drag-element.js.map +1 -1
- package/lib/behaviors/focus-element.d.ts +4 -3
- package/lib/behaviors/focus-element.js.map +1 -1
- package/lib/behaviors/hover-element.d.ts +4 -5
- package/lib/behaviors/hover-element.js +1 -1
- package/lib/behaviors/hover-element.js.map +1 -1
- package/lib/behaviors/index.d.ts +10 -0
- package/lib/behaviors/index.js +11 -1
- package/lib/behaviors/index.js.map +1 -1
- package/lib/behaviors/lasso-select.d.ts +20 -0
- package/lib/behaviors/lasso-select.js +83 -0
- package/lib/behaviors/lasso-select.js.map +1 -0
- package/lib/behaviors/types.d.ts +1 -0
- package/lib/behaviors/zoom-canvas.d.ts +7 -6
- package/lib/behaviors/zoom-canvas.js +6 -2
- package/lib/behaviors/zoom-canvas.js.map +1 -1
- package/lib/constants/change.d.ts +1 -1
- package/lib/constants/change.js +13 -13
- package/lib/constants/change.js.map +1 -1
- package/lib/constants/events/graph.d.ts +9 -15
- package/lib/constants/events/graph.js +9 -17
- package/lib/constants/events/graph.js.map +1 -1
- package/lib/constants/index.d.ts +1 -0
- package/lib/constants/index.js +1 -0
- package/lib/constants/index.js.map +1 -1
- package/lib/constants/registry.d.ts +22 -0
- package/lib/constants/registry.js +27 -0
- package/lib/constants/registry.js.map +1 -0
- package/lib/elements/combos/base-combo.d.ts +64 -6
- package/lib/elements/combos/base-combo.js +21 -0
- package/lib/elements/combos/base-combo.js.map +1 -1
- package/lib/elements/combos/circle.d.ts +8 -12
- package/lib/elements/combos/circle.js.map +1 -1
- package/lib/elements/combos/rect.d.ts +5 -9
- package/lib/elements/combos/rect.js.map +1 -1
- package/lib/elements/edges/base-edge.d.ts +85 -10
- package/lib/elements/edges/base-edge.js +21 -0
- package/lib/elements/edges/base-edge.js.map +1 -1
- package/lib/elements/edges/cubic-horizontal.d.ts +2 -2
- package/lib/elements/edges/cubic-vertical.d.ts +2 -2
- package/lib/elements/edges/cubic.d.ts +2 -2
- package/lib/elements/edges/polyline.d.ts +2 -2
- package/lib/elements/edges/quadratic.d.ts +2 -2
- package/lib/elements/nodes/base-node.d.ts +125 -13
- package/lib/elements/nodes/base-node.js +25 -1
- package/lib/elements/nodes/base-node.js.map +1 -1
- package/lib/elements/nodes/circle.d.ts +5 -8
- package/lib/elements/nodes/circle.js.map +1 -1
- package/lib/elements/nodes/diamond.d.ts +2 -4
- package/lib/elements/nodes/diamond.js +2 -2
- package/lib/elements/nodes/diamond.js.map +1 -1
- package/lib/elements/nodes/ellipse.d.ts +5 -8
- package/lib/elements/nodes/ellipse.js +1 -1
- package/lib/elements/nodes/ellipse.js.map +1 -1
- package/lib/elements/nodes/hexagon.d.ts +6 -9
- package/lib/elements/nodes/hexagon.js.map +1 -1
- package/lib/elements/nodes/image.d.ts +9 -11
- package/lib/elements/nodes/image.js.map +1 -1
- package/lib/elements/nodes/polygon.d.ts +9 -8
- package/lib/elements/nodes/polygon.js +4 -1
- package/lib/elements/nodes/polygon.js.map +1 -1
- package/lib/elements/nodes/rect.d.ts +2 -3
- package/lib/elements/nodes/rect.js.map +1 -1
- package/lib/elements/nodes/star.d.ts +7 -10
- package/lib/elements/nodes/star.js.map +1 -1
- package/lib/elements/nodes/triangle.d.ts +7 -10
- package/lib/elements/nodes/triangle.js.map +1 -1
- package/lib/exports.d.ts +18 -14
- package/lib/exports.js +26 -1
- package/lib/exports.js.map +1 -1
- package/lib/layouts/index.d.ts +1 -1
- package/lib/layouts/index.js +2 -1
- package/lib/layouts/index.js.map +1 -1
- package/lib/layouts/types.d.ts +6 -6
- package/lib/palettes/index.d.ts +1 -0
- package/lib/palettes/index.js +13 -1
- package/lib/palettes/index.js.map +1 -1
- package/lib/plugins/camera-setting.d.ts +95 -0
- package/lib/plugins/camera-setting.js +69 -0
- package/lib/plugins/camera-setting.js.map +1 -0
- package/lib/plugins/contextmenu.d.ts +8 -5
- package/lib/plugins/contextmenu.js.map +1 -1
- package/lib/plugins/history/events.d.ts +21 -0
- package/lib/plugins/history/events.js +19 -0
- package/lib/plugins/history/events.js.map +1 -0
- package/lib/plugins/history/index.d.ts +82 -0
- package/lib/plugins/history/index.js +175 -0
- package/lib/plugins/history/index.js.map +1 -0
- package/lib/plugins/history/utils.d.ts +31 -0
- package/lib/plugins/history/utils.js +84 -0
- package/lib/plugins/history/utils.js.map +1 -0
- package/lib/plugins/hull/index.d.ts +59 -0
- package/lib/plugins/hull/index.js +114 -0
- package/lib/plugins/hull/index.js.map +1 -0
- package/lib/plugins/hull/shape.d.ts +49 -0
- package/lib/plugins/hull/shape.js +39 -0
- package/lib/plugins/hull/shape.js.map +1 -0
- package/lib/plugins/hull/util.d.ts +12 -0
- package/lib/plugins/hull/util.js +207 -0
- package/lib/plugins/hull/util.js.map +1 -0
- package/lib/plugins/index.d.ts +8 -0
- package/lib/plugins/index.js +9 -1
- package/lib/plugins/index.js.map +1 -1
- package/lib/plugins/legend.d.ts +49 -0
- package/lib/plugins/legend.js +271 -0
- package/lib/plugins/legend.js.map +1 -0
- package/lib/plugins/tooltip.d.ts +12 -10
- package/lib/plugins/tooltip.js +0 -1
- package/lib/plugins/tooltip.js.map +1 -1
- package/lib/preset.js +2 -5
- package/lib/preset.js.map +1 -1
- package/lib/registry/build-in.js +17 -0
- package/lib/registry/build-in.js.map +1 -1
- package/lib/registry/extension/index.d.ts +3 -3
- package/lib/registry/extension/index.js.map +1 -1
- package/lib/registry/index.d.ts +6 -4
- package/lib/registry/index.js +1 -0
- package/lib/registry/index.js.map +1 -1
- package/lib/registry/types.d.ts +4 -6
- package/lib/runtime/batch.d.ts +11 -0
- package/lib/runtime/batch.js +35 -0
- package/lib/runtime/batch.js.map +1 -0
- package/lib/runtime/behavior.d.ts +1 -1
- package/lib/runtime/behavior.js +3 -2
- package/lib/runtime/behavior.js.map +1 -1
- package/lib/runtime/canvas.d.ts +15 -4
- package/lib/runtime/canvas.js +101 -39
- package/lib/runtime/canvas.js.map +1 -1
- package/lib/runtime/data.d.ts +4 -4
- package/lib/runtime/data.js +22 -24
- package/lib/runtime/data.js.map +1 -1
- package/lib/runtime/element.d.ts +6 -23
- package/lib/runtime/element.js +47 -149
- package/lib/runtime/element.js.map +1 -1
- package/lib/runtime/graph.d.ts +71 -6
- package/lib/runtime/graph.js +104 -9
- package/lib/runtime/graph.js.map +1 -1
- package/lib/runtime/layout.d.ts +5 -11
- package/lib/runtime/layout.js +27 -73
- package/lib/runtime/layout.js.map +1 -1
- package/lib/runtime/plugin.d.ts +2 -1
- package/lib/runtime/plugin.js +3 -0
- package/lib/runtime/plugin.js.map +1 -1
- package/lib/runtime/transform.d.ts +11 -0
- package/lib/runtime/transform.js +24 -0
- package/lib/runtime/transform.js.map +1 -0
- package/lib/runtime/types.d.ts +14 -0
- package/lib/spec/index.d.ts +1 -0
- package/lib/spec/spec.d.ts +7 -0
- package/lib/spec/transform.d.ts +12 -0
- package/lib/{types/behavior.js → spec/transform.js} +1 -1
- package/lib/spec/transform.js.map +1 -0
- package/lib/themes/base.js +9 -1
- package/lib/themes/base.js.map +1 -1
- package/lib/transforms/arrange-draw-order.d.ts +10 -0
- package/lib/transforms/arrange-draw-order.js +31 -0
- package/lib/transforms/arrange-draw-order.js.map +1 -0
- package/lib/transforms/base-transform.d.ts +7 -0
- package/lib/transforms/base-transform.js +11 -0
- package/lib/transforms/base-transform.js.map +1 -0
- package/lib/transforms/collapse-expand-combo.d.ts +10 -0
- package/lib/transforms/collapse-expand-combo.js +86 -0
- package/lib/transforms/collapse-expand-combo.js.map +1 -0
- package/lib/transforms/index.d.ts +6 -0
- package/lib/transforms/index.js +14 -0
- package/lib/transforms/index.js.map +1 -0
- package/lib/transforms/process-parallel-edges.d.ts +84 -0
- package/lib/transforms/process-parallel-edges.js +222 -0
- package/lib/transforms/process-parallel-edges.js.map +1 -0
- package/lib/transforms/types.d.ts +20 -0
- package/lib/transforms/types.js +15 -0
- package/lib/transforms/types.js.map +1 -0
- package/lib/transforms/update-related-edge.d.ts +9 -0
- package/lib/transforms/update-related-edge.js +24 -0
- package/lib/transforms/update-related-edge.js.map +1 -0
- package/lib/types/canvas.d.ts +1 -1
- package/lib/types/change.d.ts +27 -10
- package/lib/types/element.d.ts +6 -140
- package/lib/types/event.d.ts +42 -7
- package/lib/types/index.d.ts +0 -1
- package/lib/types/node.d.ts +3 -3
- package/lib/types/point.d.ts +1 -0
- package/lib/utils/animation.d.ts +1 -1
- package/lib/utils/animation.js +6 -0
- package/lib/utils/animation.js.map +1 -1
- package/lib/utils/bbox.d.ts +1 -1
- package/lib/utils/behaviors/brush.d.ts +19 -0
- package/lib/utils/behaviors/brush.js +30 -0
- package/lib/utils/behaviors/brush.js.map +1 -0
- package/lib/utils/behaviors/lasso.d.ts +13 -0
- package/lib/utils/behaviors/lasso.js +116 -0
- package/lib/utils/behaviors/lasso.js.map +1 -0
- package/lib/utils/behaviors/utils.d.ts +21 -0
- package/lib/utils/behaviors/utils.js +47 -0
- package/lib/utils/behaviors/utils.js.map +1 -0
- package/lib/utils/change.d.ts +9 -1
- package/lib/utils/change.js +30 -1
- package/lib/utils/change.js.map +1 -1
- package/lib/utils/combo.d.ts +5 -4
- package/lib/utils/combo.js.map +1 -1
- package/lib/utils/edge.d.ts +11 -0
- package/lib/utils/edge.js +2 -1
- package/lib/utils/edge.js.map +1 -1
- package/lib/utils/element.d.ts +19 -11
- package/lib/utils/element.js +21 -10
- package/lib/utils/element.js.map +1 -1
- package/lib/utils/event/events.d.ts +9 -14
- package/lib/utils/event/events.js +4 -10
- package/lib/utils/event/events.js.map +1 -1
- package/lib/utils/extension.d.ts +1 -1
- package/lib/utils/extension.js.map +1 -1
- package/lib/utils/id.d.ts +3 -8
- package/lib/utils/id.js +10 -4
- package/lib/utils/id.js.map +1 -1
- package/lib/utils/line.d.ts +21 -0
- package/lib/utils/line.js +46 -0
- package/lib/utils/line.js.map +1 -0
- package/lib/utils/path.d.ts +35 -0
- package/lib/utils/path.js +150 -0
- package/lib/utils/path.js.map +1 -0
- package/lib/utils/point.d.ts +74 -20
- package/lib/utils/point.js +178 -48
- package/lib/utils/point.js.map +1 -1
- package/lib/utils/polygon.d.ts +17 -0
- package/lib/utils/polygon.js +66 -0
- package/lib/utils/polygon.js.map +1 -0
- package/lib/utils/position.d.ts +14 -1
- package/lib/utils/position.js +18 -1
- package/lib/utils/position.js.map +1 -1
- package/lib/utils/prefix.d.ts +1 -1
- package/lib/utils/prefix.js.map +1 -1
- package/lib/utils/shortcut.d.ts +11 -0
- package/lib/utils/shortcut.js +36 -4
- package/lib/utils/shortcut.js.map +1 -1
- package/lib/utils/style.js.map +1 -1
- package/lib/utils/vector.d.ts +3 -2
- package/lib/utils/vector.js +10 -3
- package/lib/utils/vector.js.map +1 -1
- package/package.json +6 -7
- package/src/behaviors/brush-select.ts +306 -0
- package/src/behaviors/click-element.ts +182 -0
- package/src/behaviors/collapse-expand.ts +13 -11
- package/src/behaviors/create-edge.ts +206 -0
- package/src/behaviors/drag-canvas.ts +22 -14
- package/src/behaviors/drag-element-force.ts +70 -0
- package/src/behaviors/drag-element.ts +32 -25
- package/src/behaviors/focus-element.ts +7 -6
- package/src/behaviors/hover-element.ts +16 -13
- package/src/behaviors/index.ts +10 -0
- package/src/behaviors/lasso-select.ts +103 -0
- package/src/behaviors/types.ts +2 -0
- package/src/behaviors/zoom-canvas.ts +14 -9
- package/src/constants/change.ts +1 -1
- package/src/constants/events/graph.ts +8 -16
- package/src/constants/index.ts +1 -0
- package/src/constants/registry.ts +22 -0
- package/src/elements/combos/base-combo.ts +83 -10
- package/src/elements/combos/circle.ts +8 -11
- package/src/elements/combos/rect.ts +5 -8
- package/src/elements/edges/base-edge.ts +95 -14
- package/src/elements/edges/cubic-horizontal.ts +2 -2
- package/src/elements/edges/cubic-vertical.ts +2 -2
- package/src/elements/edges/cubic.ts +2 -2
- package/src/elements/edges/polyline.ts +2 -2
- package/src/elements/edges/quadratic.ts +2 -2
- package/src/elements/nodes/base-node.ts +140 -20
- package/src/elements/nodes/circle.ts +5 -7
- package/src/elements/nodes/diamond.ts +4 -6
- package/src/elements/nodes/ellipse.ts +6 -8
- package/src/elements/nodes/hexagon.ts +7 -9
- package/src/elements/nodes/image.ts +12 -13
- package/src/elements/nodes/polygon.ts +17 -11
- package/src/elements/nodes/rect.ts +3 -4
- package/src/elements/nodes/star.ts +9 -11
- package/src/elements/nodes/triangle.ts +7 -9
- package/src/exports.ts +57 -12
- package/src/layouts/index.ts +1 -0
- package/src/layouts/types.ts +7 -5
- package/src/palettes/index.ts +13 -0
- package/src/plugins/camera-setting.ts +153 -0
- package/src/plugins/contextmenu.ts +10 -7
- package/src/plugins/history/events.ts +25 -0
- package/src/plugins/history/index.ts +222 -0
- package/src/plugins/history/utils.ts +98 -0
- package/src/plugins/hull/index.ts +149 -0
- package/src/plugins/hull/shape.ts +96 -0
- package/src/plugins/hull/util.ts +222 -0
- package/src/plugins/index.ts +8 -0
- package/src/plugins/legend.ts +321 -0
- package/src/plugins/tooltip.ts +16 -15
- package/src/preset.ts +2 -6
- package/src/registry/build-in.ts +33 -3
- package/src/registry/extension/index.ts +5 -5
- package/src/registry/index.ts +11 -4
- package/src/registry/types.ts +2 -7
- package/src/runtime/batch.ts +38 -0
- package/src/runtime/behavior.ts +4 -3
- package/src/runtime/canvas.ts +130 -52
- package/src/runtime/data.ts +31 -36
- package/src/runtime/element.ts +78 -185
- package/src/runtime/graph.ts +121 -15
- package/src/runtime/layout.ts +48 -79
- package/src/runtime/plugin.ts +5 -1
- package/src/runtime/transform.ts +27 -0
- package/src/runtime/types.ts +14 -0
- package/src/spec/index.ts +1 -0
- package/src/spec/spec.ts +7 -0
- package/src/spec/transform.ts +15 -0
- package/src/themes/base.ts +9 -1
- package/src/transforms/arrange-draw-order.ts +36 -0
- package/src/transforms/base-transform.ts +11 -0
- package/src/transforms/collapse-expand-combo.ts +87 -0
- package/src/transforms/index.ts +7 -0
- package/src/transforms/process-parallel-edges.ts +286 -0
- package/src/transforms/types.ts +23 -0
- package/src/transforms/update-related-edge.ts +28 -0
- package/src/types/canvas.ts +1 -1
- package/src/types/change.ts +28 -10
- package/src/types/element.ts +6 -147
- package/src/types/event.ts +62 -7
- package/src/types/index.ts +0 -1
- package/src/types/node.ts +3 -3
- package/src/types/point.ts +1 -0
- package/src/utils/animation.ts +6 -0
- package/src/utils/bbox.ts +1 -1
- package/src/utils/behaviors/brush.ts +29 -0
- package/src/utils/behaviors/lasso.ts +127 -0
- package/src/utils/behaviors/utils.ts +47 -0
- package/src/utils/change.ts +42 -1
- package/src/utils/combo.ts +6 -5
- package/src/utils/edge.ts +6 -1
- package/src/utils/element.ts +22 -11
- package/src/utils/event/events.ts +18 -18
- package/src/utils/extension.ts +1 -1
- package/src/utils/id.ts +11 -2
- package/src/utils/line.ts +50 -0
- package/src/utils/path.ts +153 -0
- package/src/utils/point.ts +190 -51
- package/src/utils/polygon.ts +72 -0
- package/src/utils/position.ts +18 -1
- package/src/utils/prefix.ts +1 -1
- package/src/utils/shortcut.ts +41 -5
- package/src/utils/style.ts +1 -1
- package/src/utils/vector.ts +10 -3
- package/dist/lib/types/behavior.d.ts +0 -5
- package/esm/elements/types.d.ts +0 -0
- package/esm/elements/types.js +0 -15
- package/esm/elements/types.js.map +0 -1
- package/esm/types/behavior.d.ts +0 -5
- package/esm/types/behavior.js +0 -2
- package/esm/types/behavior.js.map +0 -1
- package/lib/elements/types.d.ts +0 -0
- package/lib/elements/types.js +0 -15
- package/lib/elements/types.js.map +0 -1
- package/lib/types/behavior.d.ts +0 -5
- package/lib/types/behavior.js.map +0 -1
- package/src/elements/types.ts +0 -21
- package/src/types/behavior.ts +0 -6
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { GraphEvent } from '../constants';
|
|
2
|
+
import type { RuntimeContext } from '../runtime/types';
|
|
3
|
+
import type { BasePluginOptions } from './base-plugin';
|
|
4
|
+
import { BasePlugin } from './base-plugin';
|
|
5
|
+
|
|
6
|
+
export interface CameraSettingOptions extends BasePluginOptions {
|
|
7
|
+
/**
|
|
8
|
+
* <zh/> 投影模式,透视投影仅在 3D 场景下有效
|
|
9
|
+
*
|
|
10
|
+
* <en/> Projection mode, perspective projection is only valid in 3D scenes
|
|
11
|
+
*/
|
|
12
|
+
projectionMode?: 'perspective' | 'orthographic';
|
|
13
|
+
/**
|
|
14
|
+
* <zh/> 相机类型
|
|
15
|
+
* - orbiting: 固定视点,改变相机位置
|
|
16
|
+
* - exploring: 类似 orbiting,但允许相机在北极和南极之间旋转
|
|
17
|
+
* - tracking: 固定相机位置,改变视点
|
|
18
|
+
*
|
|
19
|
+
* <en/> Camera type
|
|
20
|
+
* - orbiting: Fixed viewpoint, change camera position
|
|
21
|
+
* - exploring: Similar to orbiting, but allows the camera to rotate between the North Pole and the South Pole
|
|
22
|
+
* - tracking: Fixed camera position, change viewpoint
|
|
23
|
+
*/
|
|
24
|
+
cameraType?: 'orbiting' | 'exploring' | 'tracking';
|
|
25
|
+
/**
|
|
26
|
+
* <zh/> 近平面位置
|
|
27
|
+
*
|
|
28
|
+
* <en/> The position of the near plane
|
|
29
|
+
*/
|
|
30
|
+
near?: number;
|
|
31
|
+
/**
|
|
32
|
+
* <zh/> 远平面位置
|
|
33
|
+
*
|
|
34
|
+
* <en/> The position of the far plane
|
|
35
|
+
*/
|
|
36
|
+
far?: number;
|
|
37
|
+
/**
|
|
38
|
+
* <zh/> 相机视角,仅在透视相机下有效
|
|
39
|
+
*
|
|
40
|
+
* <en/> Camera field of view, only valid in perspective camera
|
|
41
|
+
*/
|
|
42
|
+
fov?: number;
|
|
43
|
+
/**
|
|
44
|
+
* <zh/> 相机视口宽高比,仅在透视相机下有效。设置为 'auto' 时,会自动根据画布宽高比设置
|
|
45
|
+
*
|
|
46
|
+
* <en/> Camera viewport aspect ratio, only valid in perspective camera. When set to 'auto', it will be automatically set according to the canvas aspect ratio
|
|
47
|
+
*/
|
|
48
|
+
aspect?: number | 'auto';
|
|
49
|
+
/**
|
|
50
|
+
* <zh/> 相机距离目标的距离,默认为 500
|
|
51
|
+
*
|
|
52
|
+
* <en/> The distance from the camera to the target, default is 100.
|
|
53
|
+
*/
|
|
54
|
+
distance?: number;
|
|
55
|
+
/**
|
|
56
|
+
* <zh/> 最小视距
|
|
57
|
+
*
|
|
58
|
+
* <en/> Minimum distance
|
|
59
|
+
*/
|
|
60
|
+
minDistance?: number;
|
|
61
|
+
/**
|
|
62
|
+
* <zh/> 最大视距
|
|
63
|
+
*
|
|
64
|
+
* <en/> Maximum distance
|
|
65
|
+
*/
|
|
66
|
+
maxDistance?: number;
|
|
67
|
+
/**
|
|
68
|
+
* <zh/> 滚转角
|
|
69
|
+
*
|
|
70
|
+
* <en/> Roll
|
|
71
|
+
*/
|
|
72
|
+
roll?: number;
|
|
73
|
+
/**
|
|
74
|
+
* <zh/> 仰角
|
|
75
|
+
*
|
|
76
|
+
* <en/> Elevation
|
|
77
|
+
*/
|
|
78
|
+
elevation?: number;
|
|
79
|
+
/**
|
|
80
|
+
* <zh/> 方位角
|
|
81
|
+
*
|
|
82
|
+
* <en/> Azimuth
|
|
83
|
+
*/
|
|
84
|
+
azimuth?: number;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* <zh/> 配置相机参数
|
|
89
|
+
*
|
|
90
|
+
* <en/> Configure camera parameters
|
|
91
|
+
*/
|
|
92
|
+
export class CameraSetting extends BasePlugin<CameraSettingOptions> {
|
|
93
|
+
constructor(context: RuntimeContext, options: CameraSettingOptions) {
|
|
94
|
+
super(context, options);
|
|
95
|
+
this.bindEvents();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
public update(options: Partial<CameraSettingOptions>): void {
|
|
99
|
+
this.setOptions(options);
|
|
100
|
+
super.update(options);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
private bindEvents() {
|
|
104
|
+
this.context.graph.once(GraphEvent.BEFORE_DRAW, () => this.setOptions(this.options));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
private setOptions = (options: Partial<CameraSettingOptions>) => {
|
|
108
|
+
const caller = {
|
|
109
|
+
cameraType: 'setType',
|
|
110
|
+
near: 'setNear',
|
|
111
|
+
far: 'setFar',
|
|
112
|
+
fov: 'setFov',
|
|
113
|
+
aspect: 'setAspect',
|
|
114
|
+
// 确保 projectionMode 在 near/far/fov/aspect 之后设置
|
|
115
|
+
// Ensure that projectionMode is set after near/far/fov/aspect
|
|
116
|
+
projectionMode: 'setProjectionMode',
|
|
117
|
+
distance: 'setDistance',
|
|
118
|
+
minDistance: 'setMinDistance',
|
|
119
|
+
maxDistance: 'setMaxDistance',
|
|
120
|
+
roll: 'setRoll',
|
|
121
|
+
elevation: 'setElevation',
|
|
122
|
+
azimuth: 'setAzimuth',
|
|
123
|
+
} as const;
|
|
124
|
+
|
|
125
|
+
const valueMapper = <T extends keyof CameraSettingOptions>(key: T, value: CameraSettingOptions[T]) => {
|
|
126
|
+
switch (key) {
|
|
127
|
+
case 'projectionMode':
|
|
128
|
+
return value === 'perspective' ? 1 : 0;
|
|
129
|
+
case 'cameraType':
|
|
130
|
+
return { orbiting: 0, exploring: 1, tracking: 2 }[value];
|
|
131
|
+
case 'aspect':
|
|
132
|
+
if (typeof value === 'number') return value;
|
|
133
|
+
return this.getCanvasAspect();
|
|
134
|
+
default:
|
|
135
|
+
return value;
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
Object.entries(caller).forEach(([key, method]) => {
|
|
140
|
+
const value = options[key];
|
|
141
|
+
if (value !== undefined) {
|
|
142
|
+
const actualValue = valueMapper(key, value);
|
|
143
|
+
// @ts-expect-error incorrect ts type check
|
|
144
|
+
this.context.canvas.getCamera()[method](actualValue);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
private getCanvasAspect() {
|
|
150
|
+
const [width, height] = this.context.viewport!.getCanvasSize();
|
|
151
|
+
return width / height;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { RuntimeContext } from '../runtime/types';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Element } from '../types';
|
|
3
|
+
import type { IPointerEvent } from '../types/event';
|
|
3
4
|
import type { Item } from '../utils/contextmenu';
|
|
4
5
|
import { CONTEXTMENU_CSS, getContentFromItems } from '../utils/contextmenu';
|
|
5
6
|
import { createPluginContainer, insertDOM } from '../utils/dom';
|
|
@@ -35,12 +36,12 @@ export type ContextmenuOptions = BasePluginOptions & {
|
|
|
35
36
|
* <zh/> 返回菜单的项目列表,支持 `Promise` 类型的返回值。是 `getContent` 的快捷配置。
|
|
36
37
|
* <en/> Return the list of menu items, support the `Promise` type return value. It is a shortcut configuration of `getContent`.
|
|
37
38
|
*/
|
|
38
|
-
getItems?: (event:
|
|
39
|
+
getItems?: (event: IElementEvent) => Item[] | Promise<Item[]>;
|
|
39
40
|
/**
|
|
40
41
|
* <zh/> 返回菜单的内容,支持 `Promise` 类型的返回值,也可以使用 `getItems` 来快捷配置。
|
|
41
42
|
* <en/> Return the content of menu, support the `Promise` type return value, you can also use `getItems` for shortcut configuration.
|
|
42
43
|
*/
|
|
43
|
-
getContent?: (event:
|
|
44
|
+
getContent?: (event: IElementEvent) => HTMLElement | string | Promise<HTMLElement | string>;
|
|
44
45
|
/**
|
|
45
46
|
* <zh/> Loading 时候的菜单内容,用于 getContent 返回 Promise 的时候。
|
|
46
47
|
* <en/> The menu content when loading is used when getContent returns a Promise.
|
|
@@ -50,7 +51,7 @@ export type ContextmenuOptions = BasePluginOptions & {
|
|
|
50
51
|
* <zh/> 插件是否可用,通过参数来判断是否支持右键菜单,默认全部可用。
|
|
51
52
|
* <en/> Whether the plugin is available, determine whether the right-click menu is supported through parameters, The default is all available.
|
|
52
53
|
*/
|
|
53
|
-
enable?: boolean | ((event:
|
|
54
|
+
enable?: boolean | ((event: IElementEvent) => boolean);
|
|
54
55
|
};
|
|
55
56
|
|
|
56
57
|
/**
|
|
@@ -86,7 +87,7 @@ export class Contextmenu extends BasePlugin<ContextmenuOptions> {
|
|
|
86
87
|
* <en/> Display the right-click menu based on the incoming element.
|
|
87
88
|
* @param e - 事件
|
|
88
89
|
*/
|
|
89
|
-
public async showContextmenu(e:
|
|
90
|
+
public async showContextmenu(e: IElementEvent) {
|
|
90
91
|
const { enable, offset } = this.options;
|
|
91
92
|
|
|
92
93
|
if ((typeof enable === 'function' && !enable(e)) || !enable) {
|
|
@@ -139,7 +140,7 @@ export class Contextmenu extends BasePlugin<ContextmenuOptions> {
|
|
|
139
140
|
this.$element.remove();
|
|
140
141
|
}
|
|
141
142
|
|
|
142
|
-
private async getDOMContent(e:
|
|
143
|
+
private async getDOMContent(e: IElementEvent) {
|
|
143
144
|
const { getContent, getItems } = this.options;
|
|
144
145
|
|
|
145
146
|
if (getItems) {
|
|
@@ -172,7 +173,7 @@ export class Contextmenu extends BasePlugin<ContextmenuOptions> {
|
|
|
172
173
|
document.removeEventListener('click', this.onMenuItemClick);
|
|
173
174
|
}
|
|
174
175
|
|
|
175
|
-
private onTriggerEvent = (e:
|
|
176
|
+
private onTriggerEvent = (e: IElementEvent) => {
|
|
176
177
|
// `contextmenu` 事件默认会触发浏览器的右键菜单,需要阻止默认事件
|
|
177
178
|
// `click` 事件不需要阻止默认事件
|
|
178
179
|
e.preventDefault?.();
|
|
@@ -196,3 +197,5 @@ export class Contextmenu extends BasePlugin<ContextmenuOptions> {
|
|
|
196
197
|
}
|
|
197
198
|
};
|
|
198
199
|
}
|
|
200
|
+
|
|
201
|
+
type IElementEvent = IPointerEvent<Element>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Loosen } from '../../types';
|
|
2
|
+
import type { Command } from './utils';
|
|
3
|
+
|
|
4
|
+
export interface IHistoryEvent {
|
|
5
|
+
cmd?: Command | null;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type HistoryEventHandler = (e: IHistoryEvent) => void;
|
|
9
|
+
|
|
10
|
+
export enum HistoryEvent {
|
|
11
|
+
/** <zh/> 当命令被撤销时 | <en/> When the command is undone */
|
|
12
|
+
UNDO = 'undo',
|
|
13
|
+
/** <zh/> 当命令被重做时 | <en/> When the command is redone */
|
|
14
|
+
REDO = 'redo',
|
|
15
|
+
/** <zh/> 当命令被取消时 | <en/> When the command is canceled */
|
|
16
|
+
CANCEL = 'cancel',
|
|
17
|
+
/** <zh/> 当命令被添加到队列时 | <en/> When the command is added */
|
|
18
|
+
ADD = 'add',
|
|
19
|
+
/** <zh/> 当历史队列被清空时 | <en/> When the command queue is cleared */
|
|
20
|
+
CLEAR = 'clear',
|
|
21
|
+
/** <zh/> 当历史队列发生变化时 | <en/> When the command queue changes */
|
|
22
|
+
CHANGE = 'change',
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type HistoryEventName = Loosen<HistoryEvent>;
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import EventEmitter from '@antv/event-emitter';
|
|
2
|
+
import { GraphEvent } from '../../constants';
|
|
3
|
+
import type { RuntimeContext } from '../../runtime/types';
|
|
4
|
+
import { DataChange } from '../../types';
|
|
5
|
+
import type { GraphLifeCycleEvent } from '../../utils/event';
|
|
6
|
+
import { idsOf } from '../../utils/id';
|
|
7
|
+
import type { BasePluginOptions } from '../base-plugin';
|
|
8
|
+
import { BasePlugin } from '../base-plugin';
|
|
9
|
+
import type { HistoryEventHandler, HistoryEventName } from './events';
|
|
10
|
+
import { HistoryEvent } from './events';
|
|
11
|
+
import type { Command } from './utils';
|
|
12
|
+
import { parseCommand } from './utils';
|
|
13
|
+
|
|
14
|
+
export interface HistoryOptions extends BasePluginOptions {
|
|
15
|
+
/**
|
|
16
|
+
* <zh/> 最多记录该数据长度的历史记录,默认为 0 表示不做限制
|
|
17
|
+
*/
|
|
18
|
+
stackSize?: number;
|
|
19
|
+
/**
|
|
20
|
+
* <zh/> 当一个命令被添加到 Undo/Redo 队列前被调用,如果该方法返回 false,那么这个命令将不会被添加到队列中。revert 为 true 时表示撤销操作,为 false 时表示重做操作
|
|
21
|
+
*
|
|
22
|
+
* <en/> Called before a command is added to the Undo/Redo queue. If this method returns false, the command will not be added to the queue. revert is true for undo operations and false for redo operations
|
|
23
|
+
*/
|
|
24
|
+
beforeAddCommand?: (cmd: Command, revert?: boolean) => boolean | void;
|
|
25
|
+
/**
|
|
26
|
+
* <zh/> 当一个命令被添加到 Undo/Redo 队列后被调用。revert 为 true 时表示撤销操作,为 false 时表示重做操作
|
|
27
|
+
*
|
|
28
|
+
* <en/> Called after a command is added to the Undo/Redo queue. revert is true for undo operations and false for redo operations
|
|
29
|
+
*/
|
|
30
|
+
afterAddCommand?: (cmd: Command, revert?: boolean) => void;
|
|
31
|
+
/**
|
|
32
|
+
* <zh/> 执行命令时的回调函数
|
|
33
|
+
*
|
|
34
|
+
* <en/> Callback function when executing a command
|
|
35
|
+
*/
|
|
36
|
+
executeCommand?: (cmd: Command) => void;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export class History extends BasePlugin<HistoryOptions> {
|
|
40
|
+
static defaultOptions: Partial<HistoryOptions> = {
|
|
41
|
+
stackSize: 0,
|
|
42
|
+
};
|
|
43
|
+
private emitter: EventEmitter;
|
|
44
|
+
private batchChanges: DataChange[][] | null = null;
|
|
45
|
+
private batchAnimation = false;
|
|
46
|
+
public undoStack: Command[] = [];
|
|
47
|
+
public redoStack: Command[] = [];
|
|
48
|
+
private isFirstDraw = true;
|
|
49
|
+
private freezed = false;
|
|
50
|
+
|
|
51
|
+
constructor(context: RuntimeContext, options: HistoryOptions) {
|
|
52
|
+
super(context, Object.assign({}, History.defaultOptions, options));
|
|
53
|
+
|
|
54
|
+
this.emitter = new EventEmitter();
|
|
55
|
+
|
|
56
|
+
const { graph } = this.context;
|
|
57
|
+
graph.on(GraphEvent.AFTER_DRAW, this.addCommand);
|
|
58
|
+
graph.on(GraphEvent.BATCH_START, this.initBatchCommand);
|
|
59
|
+
graph.on(GraphEvent.BATCH_END, this.addCommand);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* <zh/> 是否可以执行撤销操作
|
|
64
|
+
* <en/> Whether undo can be done
|
|
65
|
+
* @returns <zh/> 是否可以执行撤销操作 | <en/> Whether undo can be done
|
|
66
|
+
*/
|
|
67
|
+
public canUndo = () => {
|
|
68
|
+
return this.undoStack.length > 0;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* <zh/> 是否可以执行重做操作
|
|
73
|
+
* <en/> Whether redo can be done
|
|
74
|
+
* @returns <zh/> 是否可以执行重做操作 | <en/> Whether redo can be done
|
|
75
|
+
*/
|
|
76
|
+
public canRedo = () => {
|
|
77
|
+
return this.redoStack.length > 0;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* <zh/> 执行撤销
|
|
82
|
+
* <en/> Execute undo
|
|
83
|
+
* @returns <zh/> 返回当前实例 | <en/> Return the current instance
|
|
84
|
+
*/
|
|
85
|
+
public undo = () => {
|
|
86
|
+
const cmd = this.undoStack.pop();
|
|
87
|
+
if (cmd) {
|
|
88
|
+
this.executeCommand(cmd);
|
|
89
|
+
this.options.beforeAddCommand?.(cmd, false);
|
|
90
|
+
this.redoStack.push(cmd);
|
|
91
|
+
this.options.afterAddCommand?.(cmd, false);
|
|
92
|
+
this.notify(HistoryEvent.UNDO, cmd);
|
|
93
|
+
}
|
|
94
|
+
return this;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* <zh/> 执行重做
|
|
99
|
+
* <en/> Execute redo
|
|
100
|
+
* @returns <zh/> 返回当前实例 | <en/> Return the current instance
|
|
101
|
+
*/
|
|
102
|
+
public redo = () => {
|
|
103
|
+
const cmd = this.redoStack.pop();
|
|
104
|
+
if (cmd) {
|
|
105
|
+
this.executeCommand(cmd, false);
|
|
106
|
+
this.undoStackPush(cmd);
|
|
107
|
+
this.notify(HistoryEvent.REDO, cmd);
|
|
108
|
+
}
|
|
109
|
+
return this;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* <zh/> 执行撤销且不计入历史记录
|
|
114
|
+
* <en/> Execute undo and do not record in history
|
|
115
|
+
* @returns <zh/> 返回当前实例 | <en/> Return the current instance
|
|
116
|
+
*/
|
|
117
|
+
public undoAndCancel = () => {
|
|
118
|
+
const cmd = this.undoStack.pop();
|
|
119
|
+
if (cmd) {
|
|
120
|
+
this.executeCommand(cmd, false);
|
|
121
|
+
this.redoStack = [];
|
|
122
|
+
this.notify(HistoryEvent.CANCEL, cmd);
|
|
123
|
+
}
|
|
124
|
+
return this;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
private executeCommand = (cmd: Command, revert = true) => {
|
|
128
|
+
this.freezed = true;
|
|
129
|
+
|
|
130
|
+
this.options.executeCommand?.(cmd);
|
|
131
|
+
|
|
132
|
+
const values = revert ? cmd.original : cmd.current;
|
|
133
|
+
this.context.graph.addData(values.add);
|
|
134
|
+
this.context.graph.updateData(values.update);
|
|
135
|
+
this.context.graph.removeData(idsOf(values.remove, false));
|
|
136
|
+
this.context.element?.draw({ silence: true, animation: cmd.animation });
|
|
137
|
+
|
|
138
|
+
this.freezed = false;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
private addCommand = (event: GraphLifeCycleEvent) => {
|
|
142
|
+
if (this.isFirstDraw) {
|
|
143
|
+
this.isFirstDraw = false;
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (this.freezed) return;
|
|
148
|
+
|
|
149
|
+
if (event.type === GraphEvent.AFTER_DRAW) {
|
|
150
|
+
const { dataChanges = [], animation = true } = (event as GraphLifeCycleEvent).data;
|
|
151
|
+
|
|
152
|
+
if (this.context.batch?.isBatching) {
|
|
153
|
+
if (!this.batchChanges) return;
|
|
154
|
+
this.batchChanges.push(dataChanges);
|
|
155
|
+
this.batchAnimation &&= animation;
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
this.batchChanges = [dataChanges];
|
|
159
|
+
this.batchAnimation = animation;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
this.undoStackPush(parseCommand(this.batchChanges!.flat(), this.batchAnimation, this.context));
|
|
163
|
+
this.notify(HistoryEvent.ADD, this.undoStack[this.undoStack.length - 1]);
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
private initBatchCommand = (event: GraphLifeCycleEvent) => {
|
|
167
|
+
const { initiate } = event.data;
|
|
168
|
+
this.batchAnimation = false;
|
|
169
|
+
if (initiate) {
|
|
170
|
+
this.batchChanges = [];
|
|
171
|
+
} else {
|
|
172
|
+
const cmd = this.undoStack.pop();
|
|
173
|
+
if (!cmd) this.batchChanges = null;
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
private undoStackPush(cmd: Command): void {
|
|
178
|
+
const { stackSize } = this.options;
|
|
179
|
+
|
|
180
|
+
if (stackSize !== 0 && this.undoStack.length >= stackSize) {
|
|
181
|
+
this.undoStack.shift();
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
this.options.beforeAddCommand?.(cmd, true);
|
|
185
|
+
this.undoStack.push(cmd);
|
|
186
|
+
this.options.afterAddCommand?.(cmd, true);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* <zh/> 清空历史记录
|
|
191
|
+
* <en/> Clear history
|
|
192
|
+
*/
|
|
193
|
+
public clear(): void {
|
|
194
|
+
this.undoStack = [];
|
|
195
|
+
this.redoStack = [];
|
|
196
|
+
this.batchChanges = null;
|
|
197
|
+
this.batchAnimation = false;
|
|
198
|
+
this.notify(HistoryEvent.CLEAR, null);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
protected notify(event: HistoryEventName, cmd: Command | null) {
|
|
202
|
+
this.emitter.emit(event, { cmd });
|
|
203
|
+
this.emitter.emit(HistoryEvent.CHANGE, { cmd });
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
public on(event: HistoryEventName, handler: HistoryEventHandler): void {
|
|
207
|
+
this.emitter.on(event, handler);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
public destroy(): void {
|
|
211
|
+
const { graph } = this.context;
|
|
212
|
+
graph.off(GraphEvent.AFTER_DRAW, this.addCommand);
|
|
213
|
+
graph.off(GraphEvent.BATCH_START, this.initBatchCommand);
|
|
214
|
+
graph.off(GraphEvent.BATCH_END, this.addCommand);
|
|
215
|
+
|
|
216
|
+
this.emitter.off();
|
|
217
|
+
|
|
218
|
+
super.destroy();
|
|
219
|
+
this.undoStack = [];
|
|
220
|
+
this.redoStack = [];
|
|
221
|
+
}
|
|
222
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { isObject } from '@antv/util';
|
|
2
|
+
import type { RuntimeContext } from '../../runtime/types';
|
|
3
|
+
import type { GraphData } from '../../spec';
|
|
4
|
+
import type { DataChange, DataChanges, ElementDatum } from '../../types';
|
|
5
|
+
import { inferDefaultValue } from '../../utils/animation';
|
|
6
|
+
import { groupByChangeType, reduceDataChanges } from '../../utils/change';
|
|
7
|
+
import { idOf } from '../../utils/id';
|
|
8
|
+
|
|
9
|
+
export type Command = {
|
|
10
|
+
current: CommandData;
|
|
11
|
+
original: CommandData;
|
|
12
|
+
animation: boolean;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type CommandData = {
|
|
16
|
+
add: GraphData;
|
|
17
|
+
update: GraphData;
|
|
18
|
+
remove: GraphData;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* <zh/> 对齐两个对象的字段。若目标对象缺少字段,则会添加默认值。
|
|
23
|
+
*
|
|
24
|
+
* <en/> Align the fields of two objects. If the target object lacks fields, default values will be added.
|
|
25
|
+
* @param refObject - <zh/> 参考对象 | <en/> Reference object
|
|
26
|
+
* @param targetObject - <zh/> 目标对象 | <en/> Target object
|
|
27
|
+
*/
|
|
28
|
+
export function alignFields(refObject: Record<string, any>, targetObject: Record<string, any>) {
|
|
29
|
+
for (const key in refObject) {
|
|
30
|
+
if (isObject(refObject[key]) && !Array.isArray(refObject[key]) && refObject[key] !== null) {
|
|
31
|
+
if (!targetObject[key]) targetObject[key] = {};
|
|
32
|
+
alignFields(refObject[key], targetObject[key]);
|
|
33
|
+
} else if (!targetObject[key]) {
|
|
34
|
+
targetObject[key] = inferDefaultValue(key);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* <zh/> 解析数据变更为历史记录命令
|
|
41
|
+
*
|
|
42
|
+
* <en/> Parse data changes into history commands
|
|
43
|
+
* @param changes - <zh/> 数据变更 | <en/> Data changes
|
|
44
|
+
* @param animation - <zh/> 是否开启动画 | <en/> Whether to enable animation
|
|
45
|
+
* @param context - <zh/> 运行时上下文 | <en/> Runtime context
|
|
46
|
+
* @returns <zh/> 历史记录命令 | <en/> History command
|
|
47
|
+
*/
|
|
48
|
+
export function parseCommand(changes: DataChange[], animation = false, context?: RuntimeContext): Command {
|
|
49
|
+
const cmd = {
|
|
50
|
+
animation,
|
|
51
|
+
current: { add: {}, update: {}, remove: {} },
|
|
52
|
+
original: { add: {}, update: {}, remove: {} },
|
|
53
|
+
} as Command;
|
|
54
|
+
|
|
55
|
+
const { add, update, remove } = groupByChangeType(reduceDataChanges(changes));
|
|
56
|
+
|
|
57
|
+
(['nodes', 'edges', 'combos'] as const).forEach((category) => {
|
|
58
|
+
if (update[category]) {
|
|
59
|
+
update[category].forEach((item: DataChanges['update'][typeof category][number]) => {
|
|
60
|
+
const newValue = { ...item.value };
|
|
61
|
+
let newOriginal = { ...item.original };
|
|
62
|
+
if (context) {
|
|
63
|
+
// 特殊处理:获取元素原始 color
|
|
64
|
+
const itemType = context.graph.getElementType(idOf(item.original));
|
|
65
|
+
const { color } = context.element!.getElementComputedStyle(itemType, item.original);
|
|
66
|
+
newOriginal = { ...item.original, style: { color, ...item.original.style } } as ElementDatum;
|
|
67
|
+
}
|
|
68
|
+
alignFields(newValue, newOriginal);
|
|
69
|
+
cmd.current.update[category] ||= [];
|
|
70
|
+
(cmd.current.update[category] as ElementDatum[]).push(newValue);
|
|
71
|
+
cmd.original.update[category] ||= [];
|
|
72
|
+
(cmd.original.update[category] as ElementDatum[]).push(newOriginal);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (add[category]) {
|
|
77
|
+
add[category].forEach((item: DataChanges['add'][typeof category][number]) => {
|
|
78
|
+
const newValue = { ...item.value };
|
|
79
|
+
cmd.current.add[category] ||= [];
|
|
80
|
+
(cmd.current.add[category] as ElementDatum[]).push(newValue);
|
|
81
|
+
cmd.original.remove[category] ||= [];
|
|
82
|
+
(cmd.original.remove[category] as ElementDatum[]).push(newValue);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (remove[category]) {
|
|
87
|
+
remove[category].forEach((item: DataChanges['remove'][typeof category][number]) => {
|
|
88
|
+
const newValue = { ...item.value };
|
|
89
|
+
cmd.current.remove[category] ||= [];
|
|
90
|
+
(cmd.current.remove[category] as ElementDatum[]).push(newValue);
|
|
91
|
+
cmd.original.add[category] ||= [];
|
|
92
|
+
(cmd.original.add[category] as ElementDatum[]).push(newValue);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
return cmd;
|
|
98
|
+
}
|