@mdesignable/core 1.0.0-beta.64
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/LICENSE.md +20 -0
- package/README.md +1 -0
- package/dist/designable.core.umd.production.js +10 -0
- package/dist/designable.core.umd.production.min.js +23505 -0
- package/esm/drivers/DragDropDriver.d.ts +14 -0
- package/esm/drivers/DragDropDriver.js +157 -0
- package/esm/drivers/KeyboardDriver.d.ts +7 -0
- package/esm/drivers/KeyboardDriver.js +90 -0
- package/esm/drivers/MouseClickDriver.d.ts +8 -0
- package/esm/drivers/MouseClickDriver.js +95 -0
- package/esm/drivers/MouseMoveDriver.d.ts +8 -0
- package/esm/drivers/MouseMoveDriver.js +75 -0
- package/esm/drivers/ViewportResizeDriver.d.ts +10 -0
- package/esm/drivers/ViewportResizeDriver.js +95 -0
- package/esm/drivers/ViewportScrollDriver.d.ts +8 -0
- package/esm/drivers/ViewportScrollDriver.js +74 -0
- package/esm/drivers/index.d.ts +6 -0
- package/esm/drivers/index.js +6 -0
- package/esm/effects/index.d.ts +11 -0
- package/esm/effects/index.js +11 -0
- package/esm/effects/useAutoScrollEffect.d.ts +2 -0
- package/esm/effects/useAutoScrollEffect.js +65 -0
- package/esm/effects/useContentEditableEffect.d.ts +2 -0
- package/esm/effects/useContentEditableEffect.js +167 -0
- package/esm/effects/useCursorEffect.d.ts +2 -0
- package/esm/effects/useCursorEffect.js +55 -0
- package/esm/effects/useDragDropEffect.d.ts +2 -0
- package/esm/effects/useDragDropEffect.js +168 -0
- package/esm/effects/useFreeSelectionEffect.d.ts +2 -0
- package/esm/effects/useFreeSelectionEffect.js +59 -0
- package/esm/effects/useKeyboardEffect.d.ts +2 -0
- package/esm/effects/useKeyboardEffect.js +17 -0
- package/esm/effects/useResizeEffect.d.ts +2 -0
- package/esm/effects/useResizeEffect.js +80 -0
- package/esm/effects/useSelectionEffect.d.ts +2 -0
- package/esm/effects/useSelectionEffect.js +68 -0
- package/esm/effects/useTranslateEffect.d.ts +2 -0
- package/esm/effects/useTranslateEffect.js +58 -0
- package/esm/effects/useViewportEffect.d.ts +2 -0
- package/esm/effects/useViewportEffect.js +31 -0
- package/esm/effects/useWorkspaceEffect.d.ts +2 -0
- package/esm/effects/useWorkspaceEffect.js +29 -0
- package/esm/events/cursor/AbstractCursorEvent.d.ts +21 -0
- package/esm/events/cursor/AbstractCursorEvent.js +40 -0
- package/esm/events/cursor/DragMoveEvent.d.ts +5 -0
- package/esm/events/cursor/DragMoveEvent.js +51 -0
- package/esm/events/cursor/DragStartEvent.d.ts +5 -0
- package/esm/events/cursor/DragStartEvent.js +51 -0
- package/esm/events/cursor/DragStopEvent.d.ts +5 -0
- package/esm/events/cursor/DragStopEvent.js +51 -0
- package/esm/events/cursor/MouseClickEvent.d.ts +8 -0
- package/esm/events/cursor/MouseClickEvent.js +61 -0
- package/esm/events/cursor/MouseMoveEvent.d.ts +5 -0
- package/esm/events/cursor/MouseMoveEvent.js +51 -0
- package/esm/events/cursor/index.d.ts +5 -0
- package/esm/events/cursor/index.js +5 -0
- package/esm/events/history/AbstractHistoryEvent.d.ts +6 -0
- package/esm/events/history/AbstractHistoryEvent.js +7 -0
- package/esm/events/history/HistoryGotoEvent.d.ts +5 -0
- package/esm/events/history/HistoryGotoEvent.js +51 -0
- package/esm/events/history/HistoryPushEvent.d.ts +5 -0
- package/esm/events/history/HistoryPushEvent.js +51 -0
- package/esm/events/history/HistoryRedoEvent.d.ts +5 -0
- package/esm/events/history/HistoryRedoEvent.js +51 -0
- package/esm/events/history/HistoryUndoEvent.d.ts +5 -0
- package/esm/events/history/HistoryUndoEvent.js +51 -0
- package/esm/events/history/index.d.ts +4 -0
- package/esm/events/history/index.js +4 -0
- package/esm/events/index.d.ts +6 -0
- package/esm/events/index.js +6 -0
- package/esm/events/keyboard/AbstractKeyboardEvent.d.ts +15 -0
- package/esm/events/keyboard/AbstractKeyboardEvent.js +61 -0
- package/esm/events/keyboard/KeyDownEvent.d.ts +5 -0
- package/esm/events/keyboard/KeyDownEvent.js +51 -0
- package/esm/events/keyboard/KeyUpEvent.d.ts +5 -0
- package/esm/events/keyboard/KeyUpEvent.js +51 -0
- package/esm/events/keyboard/index.d.ts +2 -0
- package/esm/events/keyboard/index.js +2 -0
- package/esm/events/mutation/AbstractMutationNodeEvent.d.ts +13 -0
- package/esm/events/mutation/AbstractMutationNodeEvent.js +7 -0
- package/esm/events/mutation/AppendNodeEvent.d.ts +5 -0
- package/esm/events/mutation/AppendNodeEvent.js +51 -0
- package/esm/events/mutation/CloneNodeEvent.d.ts +5 -0
- package/esm/events/mutation/CloneNodeEvent.js +51 -0
- package/esm/events/mutation/DragNodeEvent.d.ts +5 -0
- package/esm/events/mutation/DragNodeEvent.js +51 -0
- package/esm/events/mutation/DropNodeEvent.d.ts +5 -0
- package/esm/events/mutation/DropNodeEvent.js +51 -0
- package/esm/events/mutation/FromNodeEvent.d.ts +13 -0
- package/esm/events/mutation/FromNodeEvent.js +8 -0
- package/esm/events/mutation/HoverNodeEvent.d.ts +5 -0
- package/esm/events/mutation/HoverNodeEvent.js +51 -0
- package/esm/events/mutation/InsertAfterEvent.d.ts +5 -0
- package/esm/events/mutation/InsertAfterEvent.js +51 -0
- package/esm/events/mutation/InsertBeforeEvent.d.ts +5 -0
- package/esm/events/mutation/InsertBeforeEvent.js +51 -0
- package/esm/events/mutation/InsertChildrenEvent.d.ts +5 -0
- package/esm/events/mutation/InsertChildrenEvent.js +51 -0
- package/esm/events/mutation/PrependNodeEvent.d.ts +5 -0
- package/esm/events/mutation/PrependNodeEvent.js +51 -0
- package/esm/events/mutation/RemoveNodeEvent.d.ts +5 -0
- package/esm/events/mutation/RemoveNodeEvent.js +51 -0
- package/esm/events/mutation/SelectNodeEvent.d.ts +5 -0
- package/esm/events/mutation/SelectNodeEvent.js +51 -0
- package/esm/events/mutation/UnSelectNodeEvent.d.ts +5 -0
- package/esm/events/mutation/UnSelectNodeEvent.js +51 -0
- package/esm/events/mutation/UpdateChildrenEvent.d.ts +5 -0
- package/esm/events/mutation/UpdateChildrenEvent.js +51 -0
- package/esm/events/mutation/UpdateNodePropsEvent.d.ts +5 -0
- package/esm/events/mutation/UpdateNodePropsEvent.js +51 -0
- package/esm/events/mutation/UserSelectNodeEvent.d.ts +5 -0
- package/esm/events/mutation/UserSelectNodeEvent.js +51 -0
- package/esm/events/mutation/WrapNodeEvent.d.ts +5 -0
- package/esm/events/mutation/WrapNodeEvent.js +51 -0
- package/esm/events/mutation/index.d.ts +16 -0
- package/esm/events/mutation/index.js +16 -0
- package/esm/events/viewport/AbstractViewportEvent.d.ts +16 -0
- package/esm/events/viewport/AbstractViewportEvent.js +17 -0
- package/esm/events/viewport/ViewportResizeEvent.d.ts +5 -0
- package/esm/events/viewport/ViewportResizeEvent.js +51 -0
- package/esm/events/viewport/ViewportScrollEvent.d.ts +5 -0
- package/esm/events/viewport/ViewportScrollEvent.js +51 -0
- package/esm/events/viewport/index.d.ts +2 -0
- package/esm/events/viewport/index.js +2 -0
- package/esm/events/workbench/AbstractWorkspaceEvent.d.ts +7 -0
- package/esm/events/workbench/AbstractWorkspaceEvent.js +7 -0
- package/esm/events/workbench/AddWorkspaceEvent.d.ts +5 -0
- package/esm/events/workbench/AddWorkspaceEvent.js +51 -0
- package/esm/events/workbench/RemoveWorkspaceEvent.d.ts +5 -0
- package/esm/events/workbench/RemoveWorkspaceEvent.js +51 -0
- package/esm/events/workbench/SwitchWorkspaceEvent.d.ts +5 -0
- package/esm/events/workbench/SwitchWorkspaceEvent.js +51 -0
- package/esm/events/workbench/index.d.ts +3 -0
- package/esm/events/workbench/index.js +3 -0
- package/esm/exports.d.ts +5 -0
- package/esm/exports.js +5 -0
- package/esm/externals.d.ts +12 -0
- package/esm/externals.js +113 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.js +24 -0
- package/esm/internals.d.ts +3 -0
- package/esm/internals.js +34 -0
- package/esm/models/Cursor.d.ts +60 -0
- package/esm/models/Cursor.js +151 -0
- package/esm/models/Engine.d.ts +29 -0
- package/esm/models/Engine.js +112 -0
- package/esm/models/History.d.ts +34 -0
- package/esm/models/History.js +110 -0
- package/esm/models/Hover.d.ts +14 -0
- package/esm/models/Hover.js +38 -0
- package/esm/models/Keyboard.d.ts +29 -0
- package/esm/models/Keyboard.js +126 -0
- package/esm/models/MoveHelper.d.ts +66 -0
- package/esm/models/MoveHelper.js +363 -0
- package/esm/models/Operation.d.ts +29 -0
- package/esm/models/Operation.js +75 -0
- package/esm/models/Screen.d.ts +31 -0
- package/esm/models/Screen.js +73 -0
- package/esm/models/Selection.d.ts +29 -0
- package/esm/models/Selection.js +192 -0
- package/esm/models/Shortcut.d.ts +20 -0
- package/esm/models/Shortcut.js +69 -0
- package/esm/models/SnapLine.d.ts +27 -0
- package/esm/models/SnapLine.js +141 -0
- package/esm/models/SpaceBlock.d.ts +40 -0
- package/esm/models/SpaceBlock.js +171 -0
- package/esm/models/TransformHelper.d.ts +80 -0
- package/esm/models/TransformHelper.js +601 -0
- package/esm/models/TreeNode.d.ts +115 -0
- package/esm/models/TreeNode.js +932 -0
- package/esm/models/Viewport.d.ts +90 -0
- package/esm/models/Viewport.js +474 -0
- package/esm/models/Workbench.d.ts +23 -0
- package/esm/models/Workbench.js +98 -0
- package/esm/models/Workspace.d.ts +41 -0
- package/esm/models/Workspace.js +95 -0
- package/esm/models/index.d.ts +13 -0
- package/esm/models/index.js +13 -0
- package/esm/presets.d.ts +4 -0
- package/esm/presets.js +38 -0
- package/esm/registry.d.ts +16 -0
- package/esm/registry.js +123 -0
- package/esm/shortcuts/CursorSwitch.d.ts +2 -0
- package/esm/shortcuts/CursorSwitch.js +10 -0
- package/esm/shortcuts/MultiSelection.d.ts +5 -0
- package/esm/shortcuts/MultiSelection.js +27 -0
- package/esm/shortcuts/NodeMutation.d.ts +7 -0
- package/esm/shortcuts/NodeMutation.js +40 -0
- package/esm/shortcuts/QuickSelection.d.ts +3 -0
- package/esm/shortcuts/QuickSelection.js +85 -0
- package/esm/shortcuts/UndoRedo.d.ts +3 -0
- package/esm/shortcuts/UndoRedo.js +27 -0
- package/esm/shortcuts/index.d.ts +5 -0
- package/esm/shortcuts/index.js +5 -0
- package/esm/types.d.ts +131 -0
- package/esm/types.js +1 -0
- package/lib/drivers/DragDropDriver.d.ts +14 -0
- package/lib/drivers/DragDropDriver.js +160 -0
- package/lib/drivers/KeyboardDriver.d.ts +7 -0
- package/lib/drivers/KeyboardDriver.js +93 -0
- package/lib/drivers/MouseClickDriver.d.ts +8 -0
- package/lib/drivers/MouseClickDriver.js +98 -0
- package/lib/drivers/MouseMoveDriver.d.ts +8 -0
- package/lib/drivers/MouseMoveDriver.js +78 -0
- package/lib/drivers/ViewportResizeDriver.d.ts +10 -0
- package/lib/drivers/ViewportResizeDriver.js +98 -0
- package/lib/drivers/ViewportScrollDriver.d.ts +8 -0
- package/lib/drivers/ViewportScrollDriver.js +77 -0
- package/lib/drivers/index.d.ts +6 -0
- package/lib/drivers/index.js +22 -0
- package/lib/effects/index.d.ts +11 -0
- package/lib/effects/index.js +27 -0
- package/lib/effects/useAutoScrollEffect.d.ts +2 -0
- package/lib/effects/useAutoScrollEffect.js +69 -0
- package/lib/effects/useContentEditableEffect.d.ts +2 -0
- package/lib/effects/useContentEditableEffect.js +171 -0
- package/lib/effects/useCursorEffect.d.ts +2 -0
- package/lib/effects/useCursorEffect.js +59 -0
- package/lib/effects/useDragDropEffect.d.ts +2 -0
- package/lib/effects/useDragDropEffect.js +172 -0
- package/lib/effects/useFreeSelectionEffect.d.ts +2 -0
- package/lib/effects/useFreeSelectionEffect.js +63 -0
- package/lib/effects/useKeyboardEffect.d.ts +2 -0
- package/lib/effects/useKeyboardEffect.js +21 -0
- package/lib/effects/useResizeEffect.d.ts +2 -0
- package/lib/effects/useResizeEffect.js +84 -0
- package/lib/effects/useSelectionEffect.d.ts +2 -0
- package/lib/effects/useSelectionEffect.js +72 -0
- package/lib/effects/useTranslateEffect.d.ts +2 -0
- package/lib/effects/useTranslateEffect.js +62 -0
- package/lib/effects/useViewportEffect.d.ts +2 -0
- package/lib/effects/useViewportEffect.js +35 -0
- package/lib/effects/useWorkspaceEffect.d.ts +2 -0
- package/lib/effects/useWorkspaceEffect.js +33 -0
- package/lib/events/cursor/AbstractCursorEvent.d.ts +21 -0
- package/lib/events/cursor/AbstractCursorEvent.js +43 -0
- package/lib/events/cursor/DragMoveEvent.d.ts +5 -0
- package/lib/events/cursor/DragMoveEvent.js +54 -0
- package/lib/events/cursor/DragStartEvent.d.ts +5 -0
- package/lib/events/cursor/DragStartEvent.js +54 -0
- package/lib/events/cursor/DragStopEvent.d.ts +5 -0
- package/lib/events/cursor/DragStopEvent.js +54 -0
- package/lib/events/cursor/MouseClickEvent.d.ts +8 -0
- package/lib/events/cursor/MouseClickEvent.js +64 -0
- package/lib/events/cursor/MouseMoveEvent.d.ts +5 -0
- package/lib/events/cursor/MouseMoveEvent.js +54 -0
- package/lib/events/cursor/index.d.ts +5 -0
- package/lib/events/cursor/index.js +21 -0
- package/lib/events/history/AbstractHistoryEvent.d.ts +6 -0
- package/lib/events/history/AbstractHistoryEvent.js +10 -0
- package/lib/events/history/HistoryGotoEvent.d.ts +5 -0
- package/lib/events/history/HistoryGotoEvent.js +54 -0
- package/lib/events/history/HistoryPushEvent.d.ts +5 -0
- package/lib/events/history/HistoryPushEvent.js +54 -0
- package/lib/events/history/HistoryRedoEvent.d.ts +5 -0
- package/lib/events/history/HistoryRedoEvent.js +54 -0
- package/lib/events/history/HistoryUndoEvent.d.ts +5 -0
- package/lib/events/history/HistoryUndoEvent.js +54 -0
- package/lib/events/history/index.d.ts +4 -0
- package/lib/events/history/index.js +20 -0
- package/lib/events/index.d.ts +6 -0
- package/lib/events/index.js +22 -0
- package/lib/events/keyboard/AbstractKeyboardEvent.d.ts +15 -0
- package/lib/events/keyboard/AbstractKeyboardEvent.js +64 -0
- package/lib/events/keyboard/KeyDownEvent.d.ts +5 -0
- package/lib/events/keyboard/KeyDownEvent.js +54 -0
- package/lib/events/keyboard/KeyUpEvent.d.ts +5 -0
- package/lib/events/keyboard/KeyUpEvent.js +54 -0
- package/lib/events/keyboard/index.d.ts +2 -0
- package/lib/events/keyboard/index.js +18 -0
- package/lib/events/mutation/AbstractMutationNodeEvent.d.ts +13 -0
- package/lib/events/mutation/AbstractMutationNodeEvent.js +10 -0
- package/lib/events/mutation/AppendNodeEvent.d.ts +5 -0
- package/lib/events/mutation/AppendNodeEvent.js +54 -0
- package/lib/events/mutation/CloneNodeEvent.d.ts +5 -0
- package/lib/events/mutation/CloneNodeEvent.js +54 -0
- package/lib/events/mutation/DragNodeEvent.d.ts +5 -0
- package/lib/events/mutation/DragNodeEvent.js +54 -0
- package/lib/events/mutation/DropNodeEvent.d.ts +5 -0
- package/lib/events/mutation/DropNodeEvent.js +54 -0
- package/lib/events/mutation/FromNodeEvent.d.ts +13 -0
- package/lib/events/mutation/FromNodeEvent.js +11 -0
- package/lib/events/mutation/HoverNodeEvent.d.ts +5 -0
- package/lib/events/mutation/HoverNodeEvent.js +54 -0
- package/lib/events/mutation/InsertAfterEvent.d.ts +5 -0
- package/lib/events/mutation/InsertAfterEvent.js +54 -0
- package/lib/events/mutation/InsertBeforeEvent.d.ts +5 -0
- package/lib/events/mutation/InsertBeforeEvent.js +54 -0
- package/lib/events/mutation/InsertChildrenEvent.d.ts +5 -0
- package/lib/events/mutation/InsertChildrenEvent.js +54 -0
- package/lib/events/mutation/PrependNodeEvent.d.ts +5 -0
- package/lib/events/mutation/PrependNodeEvent.js +54 -0
- package/lib/events/mutation/RemoveNodeEvent.d.ts +5 -0
- package/lib/events/mutation/RemoveNodeEvent.js +54 -0
- package/lib/events/mutation/SelectNodeEvent.d.ts +5 -0
- package/lib/events/mutation/SelectNodeEvent.js +54 -0
- package/lib/events/mutation/UnSelectNodeEvent.d.ts +5 -0
- package/lib/events/mutation/UnSelectNodeEvent.js +54 -0
- package/lib/events/mutation/UpdateChildrenEvent.d.ts +5 -0
- package/lib/events/mutation/UpdateChildrenEvent.js +54 -0
- package/lib/events/mutation/UpdateNodePropsEvent.d.ts +5 -0
- package/lib/events/mutation/UpdateNodePropsEvent.js +54 -0
- package/lib/events/mutation/UserSelectNodeEvent.d.ts +5 -0
- package/lib/events/mutation/UserSelectNodeEvent.js +54 -0
- package/lib/events/mutation/WrapNodeEvent.d.ts +5 -0
- package/lib/events/mutation/WrapNodeEvent.js +54 -0
- package/lib/events/mutation/index.d.ts +16 -0
- package/lib/events/mutation/index.js +32 -0
- package/lib/events/viewport/AbstractViewportEvent.d.ts +16 -0
- package/lib/events/viewport/AbstractViewportEvent.js +20 -0
- package/lib/events/viewport/ViewportResizeEvent.d.ts +5 -0
- package/lib/events/viewport/ViewportResizeEvent.js +54 -0
- package/lib/events/viewport/ViewportScrollEvent.d.ts +5 -0
- package/lib/events/viewport/ViewportScrollEvent.js +54 -0
- package/lib/events/viewport/index.d.ts +2 -0
- package/lib/events/viewport/index.js +18 -0
- package/lib/events/workbench/AbstractWorkspaceEvent.d.ts +7 -0
- package/lib/events/workbench/AbstractWorkspaceEvent.js +10 -0
- package/lib/events/workbench/AddWorkspaceEvent.d.ts +5 -0
- package/lib/events/workbench/AddWorkspaceEvent.js +54 -0
- package/lib/events/workbench/RemoveWorkspaceEvent.d.ts +5 -0
- package/lib/events/workbench/RemoveWorkspaceEvent.js +54 -0
- package/lib/events/workbench/SwitchWorkspaceEvent.d.ts +5 -0
- package/lib/events/workbench/SwitchWorkspaceEvent.js +54 -0
- package/lib/events/workbench/index.d.ts +3 -0
- package/lib/events/workbench/index.js +19 -0
- package/lib/exports.d.ts +5 -0
- package/lib/exports.js +21 -0
- package/lib/externals.d.ts +12 -0
- package/lib/externals.js +126 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +52 -0
- package/lib/internals.d.ts +3 -0
- package/lib/internals.js +40 -0
- package/lib/models/Cursor.d.ts +60 -0
- package/lib/models/Cursor.js +154 -0
- package/lib/models/Engine.d.ts +29 -0
- package/lib/models/Engine.js +115 -0
- package/lib/models/History.d.ts +34 -0
- package/lib/models/History.js +113 -0
- package/lib/models/Hover.d.ts +14 -0
- package/lib/models/Hover.js +41 -0
- package/lib/models/Keyboard.d.ts +29 -0
- package/lib/models/Keyboard.js +129 -0
- package/lib/models/MoveHelper.d.ts +66 -0
- package/lib/models/MoveHelper.js +366 -0
- package/lib/models/Operation.d.ts +29 -0
- package/lib/models/Operation.js +78 -0
- package/lib/models/Screen.d.ts +31 -0
- package/lib/models/Screen.js +76 -0
- package/lib/models/Selection.d.ts +29 -0
- package/lib/models/Selection.js +195 -0
- package/lib/models/Shortcut.d.ts +20 -0
- package/lib/models/Shortcut.js +72 -0
- package/lib/models/SnapLine.d.ts +27 -0
- package/lib/models/SnapLine.js +144 -0
- package/lib/models/SpaceBlock.d.ts +40 -0
- package/lib/models/SpaceBlock.js +174 -0
- package/lib/models/TransformHelper.d.ts +80 -0
- package/lib/models/TransformHelper.js +604 -0
- package/lib/models/TreeNode.d.ts +115 -0
- package/lib/models/TreeNode.js +935 -0
- package/lib/models/Viewport.d.ts +90 -0
- package/lib/models/Viewport.js +477 -0
- package/lib/models/Workbench.d.ts +23 -0
- package/lib/models/Workbench.js +101 -0
- package/lib/models/Workspace.d.ts +41 -0
- package/lib/models/Workspace.js +98 -0
- package/lib/models/index.d.ts +13 -0
- package/lib/models/index.js +29 -0
- package/lib/presets.d.ts +4 -0
- package/lib/presets.js +41 -0
- package/lib/registry.d.ts +16 -0
- package/lib/registry.js +126 -0
- package/lib/shortcuts/CursorSwitch.d.ts +2 -0
- package/lib/shortcuts/CursorSwitch.js +13 -0
- package/lib/shortcuts/MultiSelection.d.ts +5 -0
- package/lib/shortcuts/MultiSelection.js +30 -0
- package/lib/shortcuts/NodeMutation.d.ts +7 -0
- package/lib/shortcuts/NodeMutation.js +43 -0
- package/lib/shortcuts/QuickSelection.d.ts +3 -0
- package/lib/shortcuts/QuickSelection.js +88 -0
- package/lib/shortcuts/UndoRedo.d.ts +3 -0
- package/lib/shortcuts/UndoRedo.js +30 -0
- package/lib/shortcuts/index.d.ts +5 -0
- package/lib/shortcuts/index.js +21 -0
- package/lib/types.d.ts +131 -0
- package/lib/types.js +2 -0
- package/package.json +49 -0
@@ -0,0 +1,75 @@
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
2
|
+
__assign = Object.assign || function(t) {
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
4
|
+
s = arguments[i];
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
6
|
+
t[p] = s[p];
|
7
|
+
}
|
8
|
+
return t;
|
9
|
+
};
|
10
|
+
return __assign.apply(this, arguments);
|
11
|
+
};
|
12
|
+
import { TreeNode } from './TreeNode';
|
13
|
+
import { Selection } from './Selection';
|
14
|
+
import { Hover } from './Hover';
|
15
|
+
import { TransformHelper } from './TransformHelper';
|
16
|
+
import { MoveHelper } from './MoveHelper';
|
17
|
+
import { cancelIdle, isFn, requestIdle, } from '@mdesignable/shared';
|
18
|
+
var Operation = /** @class */ (function () {
|
19
|
+
function Operation(workspace) {
|
20
|
+
this.requests = {
|
21
|
+
snapshot: null,
|
22
|
+
};
|
23
|
+
this.engine = workspace.engine;
|
24
|
+
this.workspace = workspace;
|
25
|
+
this.tree = new TreeNode(__assign(__assign({ componentName: this.engine.props.rootComponentName }, this.engine.props.defaultComponentTree), { operation: this }));
|
26
|
+
this.hover = new Hover({
|
27
|
+
operation: this,
|
28
|
+
});
|
29
|
+
this.selection = new Selection({
|
30
|
+
operation: this,
|
31
|
+
});
|
32
|
+
this.moveHelper = new MoveHelper({
|
33
|
+
operation: this,
|
34
|
+
});
|
35
|
+
this.transformHelper = new TransformHelper({
|
36
|
+
operation: this,
|
37
|
+
});
|
38
|
+
this.selection.select(this.tree);
|
39
|
+
}
|
40
|
+
Operation.prototype.dispatch = function (event, callback) {
|
41
|
+
if (this.workspace.dispatch(event) === false)
|
42
|
+
return;
|
43
|
+
if (isFn(callback))
|
44
|
+
return callback();
|
45
|
+
};
|
46
|
+
Operation.prototype.snapshot = function (type) {
|
47
|
+
var _this = this;
|
48
|
+
cancelIdle(this.requests.snapshot);
|
49
|
+
if (!this.workspace ||
|
50
|
+
!this.workspace.history ||
|
51
|
+
this.workspace.history.locking)
|
52
|
+
return;
|
53
|
+
this.requests.snapshot = requestIdle(function () {
|
54
|
+
_this.workspace.history.push(type);
|
55
|
+
});
|
56
|
+
};
|
57
|
+
Operation.prototype.from = function (operation) {
|
58
|
+
if (!operation)
|
59
|
+
return;
|
60
|
+
if (operation.tree) {
|
61
|
+
this.tree.from(operation.tree);
|
62
|
+
}
|
63
|
+
if (operation.selected) {
|
64
|
+
this.selection.selected = operation.selected;
|
65
|
+
}
|
66
|
+
};
|
67
|
+
Operation.prototype.serialize = function () {
|
68
|
+
return {
|
69
|
+
tree: this.tree.serialize(),
|
70
|
+
selected: [this.tree.id],
|
71
|
+
};
|
72
|
+
};
|
73
|
+
return Operation;
|
74
|
+
}());
|
75
|
+
export { Operation };
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { Engine } from './Engine';
|
2
|
+
export declare enum ScreenType {
|
3
|
+
PC = "PC",
|
4
|
+
Responsive = "Responsive",
|
5
|
+
Mobile = "Mobile",
|
6
|
+
Sketch = "Sketch"
|
7
|
+
}
|
8
|
+
export declare enum ScreenStatus {
|
9
|
+
Normal = "Normal",
|
10
|
+
Resizing = "Resizing",
|
11
|
+
Zooming = "Zooming"
|
12
|
+
}
|
13
|
+
export declare class Screen {
|
14
|
+
type: ScreenType;
|
15
|
+
scale: number;
|
16
|
+
width: number | string;
|
17
|
+
height: number | string;
|
18
|
+
engine: Engine;
|
19
|
+
background: string;
|
20
|
+
flip: boolean;
|
21
|
+
status: ScreenStatus;
|
22
|
+
constructor(engine: Engine);
|
23
|
+
makeObservable(): void;
|
24
|
+
setStatus(status: ScreenStatus): void;
|
25
|
+
setType(type: ScreenType): void;
|
26
|
+
setScale(scale: number): void;
|
27
|
+
setSize(width?: number | string, height?: number | string): void;
|
28
|
+
resetSize(): void;
|
29
|
+
setBackground(background: string): void;
|
30
|
+
setFlip(flip: boolean): void;
|
31
|
+
}
|
@@ -0,0 +1,73 @@
|
|
1
|
+
import { action, define, observable } from '@formily/reactive';
|
2
|
+
export var ScreenType;
|
3
|
+
(function (ScreenType) {
|
4
|
+
ScreenType["PC"] = "PC";
|
5
|
+
ScreenType["Responsive"] = "Responsive";
|
6
|
+
ScreenType["Mobile"] = "Mobile";
|
7
|
+
ScreenType["Sketch"] = "Sketch";
|
8
|
+
})(ScreenType || (ScreenType = {}));
|
9
|
+
export var ScreenStatus;
|
10
|
+
(function (ScreenStatus) {
|
11
|
+
ScreenStatus["Normal"] = "Normal";
|
12
|
+
ScreenStatus["Resizing"] = "Resizing";
|
13
|
+
ScreenStatus["Zooming"] = "Zooming";
|
14
|
+
})(ScreenStatus || (ScreenStatus = {}));
|
15
|
+
var Screen = /** @class */ (function () {
|
16
|
+
function Screen(engine) {
|
17
|
+
this.scale = 1;
|
18
|
+
this.width = '100%';
|
19
|
+
this.height = '100%';
|
20
|
+
this.background = '';
|
21
|
+
this.flip = false;
|
22
|
+
this.status = ScreenStatus.Normal;
|
23
|
+
this.engine = engine;
|
24
|
+
this.type = engine.props.defaultScreenType;
|
25
|
+
this.makeObservable();
|
26
|
+
}
|
27
|
+
Screen.prototype.makeObservable = function () {
|
28
|
+
define(this, {
|
29
|
+
type: observable.ref,
|
30
|
+
scale: observable.ref,
|
31
|
+
width: observable.ref,
|
32
|
+
height: observable.ref,
|
33
|
+
status: observable.ref,
|
34
|
+
flip: observable.ref,
|
35
|
+
background: observable.ref,
|
36
|
+
setType: action,
|
37
|
+
setScale: action,
|
38
|
+
setSize: action,
|
39
|
+
resetSize: action,
|
40
|
+
setBackground: action,
|
41
|
+
setFlip: action,
|
42
|
+
});
|
43
|
+
};
|
44
|
+
Screen.prototype.setStatus = function (status) {
|
45
|
+
this.status = status;
|
46
|
+
};
|
47
|
+
Screen.prototype.setType = function (type) {
|
48
|
+
this.type = type;
|
49
|
+
};
|
50
|
+
Screen.prototype.setScale = function (scale) {
|
51
|
+
this.scale = scale;
|
52
|
+
};
|
53
|
+
Screen.prototype.setSize = function (width, height) {
|
54
|
+
if (width) {
|
55
|
+
this.width = width;
|
56
|
+
}
|
57
|
+
if (height) {
|
58
|
+
this.height = height;
|
59
|
+
}
|
60
|
+
};
|
61
|
+
Screen.prototype.resetSize = function () {
|
62
|
+
this.width = '100%';
|
63
|
+
this.height = '100%';
|
64
|
+
};
|
65
|
+
Screen.prototype.setBackground = function (background) {
|
66
|
+
this.background = background;
|
67
|
+
};
|
68
|
+
Screen.prototype.setFlip = function (flip) {
|
69
|
+
this.flip = flip;
|
70
|
+
};
|
71
|
+
return Screen;
|
72
|
+
}());
|
73
|
+
export { Screen };
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { Operation } from './Operation';
|
2
|
+
import { SelectNodeEvent } from '../events';
|
3
|
+
import { TreeNode } from './TreeNode';
|
4
|
+
export interface ISelection {
|
5
|
+
selected?: string[];
|
6
|
+
operation?: Operation;
|
7
|
+
}
|
8
|
+
export declare class Selection {
|
9
|
+
operation: Operation;
|
10
|
+
selected: string[];
|
11
|
+
indexes: Record<string, boolean>;
|
12
|
+
constructor(props?: ISelection);
|
13
|
+
makeObservable(): void;
|
14
|
+
trigger(type?: typeof SelectNodeEvent): unknown;
|
15
|
+
select(id: string | TreeNode): void;
|
16
|
+
safeSelect(id: string | TreeNode): void;
|
17
|
+
mapIds(ids: any): any[];
|
18
|
+
batchSelect(ids: string[] | TreeNode[]): void;
|
19
|
+
batchSafeSelect(ids: string[] | TreeNode[]): void;
|
20
|
+
get selectedNodes(): TreeNode[];
|
21
|
+
get first(): string;
|
22
|
+
get last(): string;
|
23
|
+
get length(): number;
|
24
|
+
add(...ids: string[] | TreeNode[]): void;
|
25
|
+
crossAddTo(node: TreeNode): void;
|
26
|
+
remove(...ids: string[] | TreeNode[]): void;
|
27
|
+
has(...ids: string[] | TreeNode[]): any;
|
28
|
+
clear(): void;
|
29
|
+
}
|
@@ -0,0 +1,192 @@
|
|
1
|
+
import { observable, define, action } from '@formily/reactive';
|
2
|
+
import { SelectNodeEvent, UnSelectNodeEvent } from '../events';
|
3
|
+
import { isStr, isArr } from '@mdesignable/shared';
|
4
|
+
var Selection = /** @class */ (function () {
|
5
|
+
function Selection(props) {
|
6
|
+
this.selected = [];
|
7
|
+
this.indexes = {};
|
8
|
+
if (props.selected) {
|
9
|
+
this.selected = props.selected;
|
10
|
+
}
|
11
|
+
if (props.operation) {
|
12
|
+
this.operation = props.operation;
|
13
|
+
}
|
14
|
+
this.makeObservable();
|
15
|
+
}
|
16
|
+
Selection.prototype.makeObservable = function () {
|
17
|
+
define(this, {
|
18
|
+
selected: observable,
|
19
|
+
select: action,
|
20
|
+
batchSelect: action,
|
21
|
+
add: action,
|
22
|
+
remove: action,
|
23
|
+
clear: action,
|
24
|
+
crossAddTo: action,
|
25
|
+
});
|
26
|
+
};
|
27
|
+
Selection.prototype.trigger = function (type) {
|
28
|
+
if (type === void 0) { type = SelectNodeEvent; }
|
29
|
+
return this.operation.dispatch(new type({
|
30
|
+
target: this.operation.tree,
|
31
|
+
source: this.selectedNodes,
|
32
|
+
}));
|
33
|
+
};
|
34
|
+
Selection.prototype.select = function (id) {
|
35
|
+
var _a;
|
36
|
+
if (isStr(id)) {
|
37
|
+
if (this.selected.length === 1 && this.selected.includes(id)) {
|
38
|
+
this.trigger(SelectNodeEvent);
|
39
|
+
return;
|
40
|
+
}
|
41
|
+
this.selected = [id];
|
42
|
+
this.indexes = (_a = {}, _a[id] = true, _a);
|
43
|
+
this.trigger(SelectNodeEvent);
|
44
|
+
}
|
45
|
+
else {
|
46
|
+
this.select(id === null || id === void 0 ? void 0 : id.id);
|
47
|
+
}
|
48
|
+
};
|
49
|
+
Selection.prototype.safeSelect = function (id) {
|
50
|
+
if (!id)
|
51
|
+
return;
|
52
|
+
this.select(id);
|
53
|
+
};
|
54
|
+
Selection.prototype.mapIds = function (ids) {
|
55
|
+
return isArr(ids)
|
56
|
+
? ids.map(function (node) { return (isStr(node) ? node : node === null || node === void 0 ? void 0 : node.id); })
|
57
|
+
: [];
|
58
|
+
};
|
59
|
+
Selection.prototype.batchSelect = function (ids) {
|
60
|
+
this.selected = this.mapIds(ids);
|
61
|
+
this.indexes = this.selected.reduce(function (buf, id) {
|
62
|
+
buf[id] = true;
|
63
|
+
return buf;
|
64
|
+
}, {});
|
65
|
+
this.trigger(SelectNodeEvent);
|
66
|
+
};
|
67
|
+
Selection.prototype.batchSafeSelect = function (ids) {
|
68
|
+
if (!(ids === null || ids === void 0 ? void 0 : ids.length))
|
69
|
+
return;
|
70
|
+
this.batchSelect(ids);
|
71
|
+
};
|
72
|
+
Object.defineProperty(Selection.prototype, "selectedNodes", {
|
73
|
+
get: function () {
|
74
|
+
var _this = this;
|
75
|
+
return this.selected.map(function (id) { return _this.operation.tree.findById(id); });
|
76
|
+
},
|
77
|
+
enumerable: false,
|
78
|
+
configurable: true
|
79
|
+
});
|
80
|
+
Object.defineProperty(Selection.prototype, "first", {
|
81
|
+
get: function () {
|
82
|
+
if (this.selected && this.selected.length)
|
83
|
+
return this.selected[0];
|
84
|
+
},
|
85
|
+
enumerable: false,
|
86
|
+
configurable: true
|
87
|
+
});
|
88
|
+
Object.defineProperty(Selection.prototype, "last", {
|
89
|
+
get: function () {
|
90
|
+
if (this.selected && this.selected.length)
|
91
|
+
return this.selected[this.selected.length - 1];
|
92
|
+
},
|
93
|
+
enumerable: false,
|
94
|
+
configurable: true
|
95
|
+
});
|
96
|
+
Object.defineProperty(Selection.prototype, "length", {
|
97
|
+
get: function () {
|
98
|
+
return this.selected.length;
|
99
|
+
},
|
100
|
+
enumerable: false,
|
101
|
+
configurable: true
|
102
|
+
});
|
103
|
+
Selection.prototype.add = function () {
|
104
|
+
var _this = this;
|
105
|
+
var ids = [];
|
106
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
107
|
+
ids[_i] = arguments[_i];
|
108
|
+
}
|
109
|
+
this.mapIds(ids).forEach(function (id) {
|
110
|
+
if (isStr(id)) {
|
111
|
+
if (!_this.selected.includes(id)) {
|
112
|
+
_this.selected.push(id);
|
113
|
+
_this.indexes[id] = true;
|
114
|
+
}
|
115
|
+
}
|
116
|
+
else {
|
117
|
+
_this.add(id === null || id === void 0 ? void 0 : id.id);
|
118
|
+
}
|
119
|
+
});
|
120
|
+
this.trigger();
|
121
|
+
};
|
122
|
+
Selection.prototype.crossAddTo = function (node) {
|
123
|
+
var _this = this;
|
124
|
+
if (node.parent) {
|
125
|
+
var selectedNodes = this.selectedNodes;
|
126
|
+
if (this.has(node)) {
|
127
|
+
this.remove(node);
|
128
|
+
}
|
129
|
+
else {
|
130
|
+
var minDistanceNode = selectedNodes.reduce(function (minDistanceNode, item) {
|
131
|
+
return item.distanceTo(node) < minDistanceNode.distanceTo(node)
|
132
|
+
? item
|
133
|
+
: minDistanceNode;
|
134
|
+
}, selectedNodes[0]);
|
135
|
+
if (minDistanceNode) {
|
136
|
+
var crossNodes = node.crossSiblings(minDistanceNode);
|
137
|
+
crossNodes.forEach(function (node) {
|
138
|
+
if (!_this.has(node.id)) {
|
139
|
+
_this.selected.push(node.id);
|
140
|
+
_this.indexes[node.id] = true;
|
141
|
+
}
|
142
|
+
});
|
143
|
+
}
|
144
|
+
if (!this.has(node.id)) {
|
145
|
+
this.selected.push(node.id);
|
146
|
+
this.indexes[node.id] = true;
|
147
|
+
}
|
148
|
+
}
|
149
|
+
}
|
150
|
+
};
|
151
|
+
Selection.prototype.remove = function () {
|
152
|
+
var _this = this;
|
153
|
+
var ids = [];
|
154
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
155
|
+
ids[_i] = arguments[_i];
|
156
|
+
}
|
157
|
+
this.mapIds(ids).forEach(function (id) {
|
158
|
+
if (isStr(id)) {
|
159
|
+
_this.selected = _this.selected.filter(function (item) { return item !== id; });
|
160
|
+
delete _this.indexes[id];
|
161
|
+
}
|
162
|
+
else {
|
163
|
+
_this.remove(id === null || id === void 0 ? void 0 : id.id);
|
164
|
+
}
|
165
|
+
});
|
166
|
+
this.trigger(UnSelectNodeEvent);
|
167
|
+
};
|
168
|
+
Selection.prototype.has = function () {
|
169
|
+
var _this = this;
|
170
|
+
var ids = [];
|
171
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
172
|
+
ids[_i] = arguments[_i];
|
173
|
+
}
|
174
|
+
return this.mapIds(ids).some(function (id) {
|
175
|
+
if (isStr(id)) {
|
176
|
+
return _this.indexes[id];
|
177
|
+
}
|
178
|
+
else {
|
179
|
+
if (!(id === null || id === void 0 ? void 0 : id.id))
|
180
|
+
return false;
|
181
|
+
return _this.has(id === null || id === void 0 ? void 0 : id.id);
|
182
|
+
}
|
183
|
+
});
|
184
|
+
};
|
185
|
+
Selection.prototype.clear = function () {
|
186
|
+
this.selected = [];
|
187
|
+
this.indexes = {};
|
188
|
+
this.trigger(UnSelectNodeEvent);
|
189
|
+
};
|
190
|
+
return Selection;
|
191
|
+
}());
|
192
|
+
export { Selection };
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { KeyCode } from '@mdesignable/shared';
|
2
|
+
import { IEngineContext } from '../types';
|
3
|
+
export { KeyCode };
|
4
|
+
export interface IShortcutProps {
|
5
|
+
codes?: KeyCode[] | KeyCode[][];
|
6
|
+
matcher?: (codes: KeyCode[]) => boolean;
|
7
|
+
handler?: (context: IEngineContext) => void;
|
8
|
+
}
|
9
|
+
export declare class Shortcut {
|
10
|
+
codes: KeyCode[][];
|
11
|
+
handler: (context: IEngineContext) => void;
|
12
|
+
matcher: (codes: KeyCode[]) => boolean;
|
13
|
+
constructor(props: IShortcutProps);
|
14
|
+
parseCodes(codes: Array<KeyCode | KeyCode[]>): KeyCode[][];
|
15
|
+
preventCodes(codes: KeyCode[]): boolean;
|
16
|
+
matched(matched: boolean, context: IEngineContext): boolean;
|
17
|
+
match(codes: KeyCode[], context: IEngineContext): boolean;
|
18
|
+
static matchCode: (code1: KeyCode, code2: KeyCode) => boolean;
|
19
|
+
static sortCodes: (codes: KeyCode[]) => KeyCode[];
|
20
|
+
}
|
@@ -0,0 +1,69 @@
|
|
1
|
+
import { isFn, KeyCode } from '@mdesignable/shared';
|
2
|
+
export { KeyCode };
|
3
|
+
var Shortcut = /** @class */ (function () {
|
4
|
+
function Shortcut(props) {
|
5
|
+
this.codes = this.parseCodes(props.codes);
|
6
|
+
this.handler = props.handler;
|
7
|
+
this.matcher = props.matcher;
|
8
|
+
}
|
9
|
+
Shortcut.prototype.parseCodes = function (codes) {
|
10
|
+
var results = [];
|
11
|
+
codes.forEach(function (code) {
|
12
|
+
if (Array.isArray(code)) {
|
13
|
+
results.push(code);
|
14
|
+
}
|
15
|
+
else {
|
16
|
+
results.push([code]);
|
17
|
+
}
|
18
|
+
});
|
19
|
+
return results;
|
20
|
+
};
|
21
|
+
Shortcut.prototype.preventCodes = function (codes) {
|
22
|
+
var _a;
|
23
|
+
if (this.codes.length) {
|
24
|
+
for (var i = 0; i < codes.length; i++) {
|
25
|
+
var sequence = (_a = this.codes[i]) !== null && _a !== void 0 ? _a : [];
|
26
|
+
for (var j = 0; j < sequence.length; j++) {
|
27
|
+
if (!Shortcut.matchCode(codes[j], sequence[j])) {
|
28
|
+
return false;
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}
|
32
|
+
return true;
|
33
|
+
}
|
34
|
+
return false;
|
35
|
+
};
|
36
|
+
Shortcut.prototype.matched = function (matched, context) {
|
37
|
+
if (isFn(this.handler) && matched) {
|
38
|
+
this.handler(context);
|
39
|
+
}
|
40
|
+
return matched;
|
41
|
+
};
|
42
|
+
Shortcut.prototype.match = function (codes, context) {
|
43
|
+
var _this = this;
|
44
|
+
return this.codes.some(function (sequence) {
|
45
|
+
var sortedSelf = Shortcut.sortCodes(sequence);
|
46
|
+
var sortedTarget = Shortcut.sortCodes(codes);
|
47
|
+
if (isFn(_this.matcher)) {
|
48
|
+
return _this.matched(_this.matcher(sortedTarget), context);
|
49
|
+
}
|
50
|
+
if (sortedTarget.length !== sortedSelf.length)
|
51
|
+
return _this.matched(false, context);
|
52
|
+
for (var i = 0; i < sortedSelf.length; i++) {
|
53
|
+
if (!Shortcut.matchCode(sortedTarget[i], sortedSelf[i])) {
|
54
|
+
return _this.matched(false, context);
|
55
|
+
}
|
56
|
+
}
|
57
|
+
return _this.matched(true, context);
|
58
|
+
});
|
59
|
+
};
|
60
|
+
Shortcut.matchCode = function (code1, code2) {
|
61
|
+
var _a, _b;
|
62
|
+
return ((_a = code1 === null || code1 === void 0 ? void 0 : code1.toLocaleLowerCase) === null || _a === void 0 ? void 0 : _a.call(code1)) === ((_b = code2 === null || code2 === void 0 ? void 0 : code2.toLocaleLowerCase) === null || _b === void 0 ? void 0 : _b.call(code2));
|
63
|
+
};
|
64
|
+
Shortcut.sortCodes = function (codes) {
|
65
|
+
return codes.map(function (code) { return code.toLocaleLowerCase(); }).sort();
|
66
|
+
};
|
67
|
+
return Shortcut;
|
68
|
+
}());
|
69
|
+
export { Shortcut };
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import { ILineSegment, IPoint, Rect } from '@mdesignable/shared';
|
2
|
+
import { TreeNode } from './TreeNode';
|
3
|
+
import { TransformHelper } from './TransformHelper';
|
4
|
+
export type ISnapLineType = 'ruler' | 'space-block' | 'normal';
|
5
|
+
export type ISnapLine = ILineSegment & {
|
6
|
+
type?: ISnapLineType;
|
7
|
+
distance?: number;
|
8
|
+
id?: string;
|
9
|
+
refer?: TreeNode;
|
10
|
+
};
|
11
|
+
export declare class SnapLine {
|
12
|
+
_id: string;
|
13
|
+
type: ISnapLineType;
|
14
|
+
distance: number;
|
15
|
+
refer: TreeNode;
|
16
|
+
start: IPoint;
|
17
|
+
end: IPoint;
|
18
|
+
helper: TransformHelper;
|
19
|
+
constructor(helper: TransformHelper, line: ISnapLine);
|
20
|
+
get id(): string;
|
21
|
+
get direction(): "v" | "h";
|
22
|
+
get closest(): boolean;
|
23
|
+
get rect(): Rect;
|
24
|
+
translate(node: TreeNode, translate: IPoint): void;
|
25
|
+
resize(node: TreeNode, rect: Rect): void;
|
26
|
+
snapEdge(rect: Rect): "ht" | "hc" | "hb" | "vl" | "vc" | "vr";
|
27
|
+
}
|
@@ -0,0 +1,141 @@
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
2
|
+
__assign = Object.assign || function(t) {
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
4
|
+
s = arguments[i];
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
6
|
+
t[p] = s[p];
|
7
|
+
}
|
8
|
+
return t;
|
9
|
+
};
|
10
|
+
return __assign.apply(this, arguments);
|
11
|
+
};
|
12
|
+
import { calcRectOfAxisLineSegment, calcOffsetOfSnapLineSegmentToEdge, } from '@mdesignable/shared';
|
13
|
+
import { TransformHelper } from './TransformHelper';
|
14
|
+
var SnapLine = /** @class */ (function () {
|
15
|
+
function SnapLine(helper, line) {
|
16
|
+
this.helper = helper;
|
17
|
+
this.type = line.type || 'normal';
|
18
|
+
this._id = line.id;
|
19
|
+
this.refer = line.refer;
|
20
|
+
this.start = __assign({}, line.start);
|
21
|
+
this.end = __assign({}, line.end);
|
22
|
+
this.distance = line.distance;
|
23
|
+
}
|
24
|
+
Object.defineProperty(SnapLine.prototype, "id", {
|
25
|
+
get: function () {
|
26
|
+
var _a;
|
27
|
+
return ((_a = this._id) !== null && _a !== void 0 ? _a : "".concat(this.start.x, "-").concat(this.start.y, "-").concat(this.end.x, "-").concat(this.end.y));
|
28
|
+
},
|
29
|
+
enumerable: false,
|
30
|
+
configurable: true
|
31
|
+
});
|
32
|
+
Object.defineProperty(SnapLine.prototype, "direction", {
|
33
|
+
get: function () {
|
34
|
+
var _a, _b;
|
35
|
+
if (((_a = this.start) === null || _a === void 0 ? void 0 : _a.x) === ((_b = this.end) === null || _b === void 0 ? void 0 : _b.x))
|
36
|
+
return 'v';
|
37
|
+
return 'h';
|
38
|
+
},
|
39
|
+
enumerable: false,
|
40
|
+
configurable: true
|
41
|
+
});
|
42
|
+
Object.defineProperty(SnapLine.prototype, "closest", {
|
43
|
+
get: function () {
|
44
|
+
return this.distance < TransformHelper.threshold;
|
45
|
+
},
|
46
|
+
enumerable: false,
|
47
|
+
configurable: true
|
48
|
+
});
|
49
|
+
Object.defineProperty(SnapLine.prototype, "rect", {
|
50
|
+
get: function () {
|
51
|
+
return calcRectOfAxisLineSegment(this);
|
52
|
+
},
|
53
|
+
enumerable: false,
|
54
|
+
configurable: true
|
55
|
+
});
|
56
|
+
SnapLine.prototype.translate = function (node, translate) {
|
57
|
+
if (!node || !(node === null || node === void 0 ? void 0 : node.parent))
|
58
|
+
return;
|
59
|
+
var parent = node.parent;
|
60
|
+
var dragNodeRect = node.getValidElementOffsetRect();
|
61
|
+
var parentRect = parent.getValidElementOffsetRect();
|
62
|
+
var edgeOffset = calcOffsetOfSnapLineSegmentToEdge(this, dragNodeRect);
|
63
|
+
if (this.direction === 'h') {
|
64
|
+
translate.y = this.start.y - parentRect.y - edgeOffset.y;
|
65
|
+
}
|
66
|
+
else {
|
67
|
+
translate.x = this.start.x - parentRect.x - edgeOffset.x;
|
68
|
+
}
|
69
|
+
};
|
70
|
+
SnapLine.prototype.resize = function (node, rect) {
|
71
|
+
if (!node || !(node === null || node === void 0 ? void 0 : node.parent))
|
72
|
+
return;
|
73
|
+
var parent = node.parent;
|
74
|
+
var dragNodeRect = node.getValidElementOffsetRect();
|
75
|
+
var parentRect = parent.getValidElementOffsetRect();
|
76
|
+
var edgeOffset = calcOffsetOfSnapLineSegmentToEdge(this, dragNodeRect);
|
77
|
+
var cursorRect = this.helper.cursorDragNodesRect;
|
78
|
+
var snapEdge = this.snapEdge(rect);
|
79
|
+
if (this.direction === 'h') {
|
80
|
+
var y = this.start.y - parentRect.y - edgeOffset.y;
|
81
|
+
switch (this.helper.direction) {
|
82
|
+
case 'left-top':
|
83
|
+
case 'center-top':
|
84
|
+
case 'right-top':
|
85
|
+
if (snapEdge !== 'ht')
|
86
|
+
return;
|
87
|
+
rect.y = y;
|
88
|
+
rect.height = cursorRect.bottom - y;
|
89
|
+
break;
|
90
|
+
case 'left-bottom':
|
91
|
+
case 'center-bottom':
|
92
|
+
case 'right-bottom':
|
93
|
+
if (snapEdge !== 'hb')
|
94
|
+
return;
|
95
|
+
rect.height = this.start.y - cursorRect.top;
|
96
|
+
break;
|
97
|
+
}
|
98
|
+
}
|
99
|
+
else {
|
100
|
+
var x = this.start.x - parentRect.x - edgeOffset.x;
|
101
|
+
switch (this.helper.direction) {
|
102
|
+
case 'left-top':
|
103
|
+
case 'left-bottom':
|
104
|
+
case 'left-center':
|
105
|
+
if (snapEdge !== 'vl')
|
106
|
+
return;
|
107
|
+
rect.x = x;
|
108
|
+
rect.width = cursorRect.right - x;
|
109
|
+
break;
|
110
|
+
case 'right-center':
|
111
|
+
case 'right-top':
|
112
|
+
case 'right-bottom':
|
113
|
+
if (snapEdge !== 'vr')
|
114
|
+
return;
|
115
|
+
rect.width = this.start.x - cursorRect.left;
|
116
|
+
break;
|
117
|
+
}
|
118
|
+
}
|
119
|
+
};
|
120
|
+
SnapLine.prototype.snapEdge = function (rect) {
|
121
|
+
var threshold = TransformHelper.threshold;
|
122
|
+
if (this.direction === 'h') {
|
123
|
+
if (Math.abs(this.start.y - rect.top) < threshold)
|
124
|
+
return 'ht';
|
125
|
+
if (Math.abs(this.start.y - (rect.top + rect.height / 2)) < threshold)
|
126
|
+
return 'hc';
|
127
|
+
if (Math.abs(this.start.y - rect.bottom) < threshold)
|
128
|
+
return 'hb';
|
129
|
+
}
|
130
|
+
else {
|
131
|
+
if (Math.abs(this.start.x - rect.left) < threshold)
|
132
|
+
return 'vl';
|
133
|
+
if (Math.abs(this.start.x - (rect.left + rect.width / 2)) < threshold)
|
134
|
+
return 'vc';
|
135
|
+
if (Math.abs(this.start.x - rect.right) < threshold)
|
136
|
+
return 'vr';
|
137
|
+
}
|
138
|
+
};
|
139
|
+
return SnapLine;
|
140
|
+
}());
|
141
|
+
export { SnapLine };
|