@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,80 @@
|
|
1
|
+
import { Point, IPoint, ISize, IRect, Rect } from '@mdesignable/shared';
|
2
|
+
import { SpaceBlock, AroundSpaceBlock } from './SpaceBlock';
|
3
|
+
import { Operation } from './Operation';
|
4
|
+
import { TreeNode } from './TreeNode';
|
5
|
+
import { SnapLine, ISnapLine } from './SnapLine';
|
6
|
+
export interface ITransformHelperProps {
|
7
|
+
operation: Operation;
|
8
|
+
}
|
9
|
+
export type TransformHelperType = 'translate' | 'resize' | 'rotate' | 'scale' | 'round';
|
10
|
+
export type ResizeDirection = 'left-top' | 'left-center' | 'left-bottom' | 'center-top' | 'center-bottom' | 'right-top' | 'right-bottom' | 'right-center' | (string & {});
|
11
|
+
export interface ITransformHelperDragStartProps {
|
12
|
+
type: TransformHelperType;
|
13
|
+
direction?: ResizeDirection;
|
14
|
+
dragNodes: TreeNode[];
|
15
|
+
}
|
16
|
+
export declare class TransformHelper {
|
17
|
+
operation: Operation;
|
18
|
+
type: TransformHelperType;
|
19
|
+
direction: ResizeDirection;
|
20
|
+
dragNodes: TreeNode[];
|
21
|
+
rulerSnapLines: SnapLine[];
|
22
|
+
aroundSnapLines: SnapLine[];
|
23
|
+
aroundSpaceBlocks: AroundSpaceBlock;
|
24
|
+
viewportRectsStore: Record<string, Rect>;
|
25
|
+
dragStartTranslateStore: Record<string, IPoint>;
|
26
|
+
dragStartSizeStore: Record<string, ISize>;
|
27
|
+
draggingNodesRect: Rect;
|
28
|
+
cacheDragNodesReact: Rect;
|
29
|
+
dragStartNodesRect: IRect;
|
30
|
+
snapping: boolean;
|
31
|
+
dragging: boolean;
|
32
|
+
snapped: boolean;
|
33
|
+
constructor(props: ITransformHelperProps);
|
34
|
+
get tree(): TreeNode;
|
35
|
+
get cursor(): import("./Cursor").Cursor;
|
36
|
+
get viewport(): import("./Viewport").Viewport;
|
37
|
+
get deltaX(): number;
|
38
|
+
get deltaY(): number;
|
39
|
+
get cursorPosition(): {
|
40
|
+
x: number;
|
41
|
+
y: number;
|
42
|
+
};
|
43
|
+
get cursorDragNodesRect(): Rect;
|
44
|
+
get cursorDragNodesEdgeLines(): import("@mdesignable/shared").IRectEdgeLines;
|
45
|
+
get dragNodesRect(): Rect;
|
46
|
+
get dragNodesEdgeLines(): import("@mdesignable/shared").IRectEdgeLines;
|
47
|
+
get cursorOffset(): Point;
|
48
|
+
get dragStartCursor(): {
|
49
|
+
x: number;
|
50
|
+
y: number;
|
51
|
+
};
|
52
|
+
get dragStartCursorOffset(): Point;
|
53
|
+
get closestSnapLines(): SnapLine[];
|
54
|
+
get closestSpaceBlocks(): SpaceBlock[];
|
55
|
+
get thresholdSnapLines(): SnapLine[];
|
56
|
+
get thresholdSpaceBlocks(): SpaceBlock[];
|
57
|
+
get measurerSpaceBlocks(): SpaceBlock[];
|
58
|
+
calcBaseTranslate(node: TreeNode): {
|
59
|
+
x: number;
|
60
|
+
y: number;
|
61
|
+
};
|
62
|
+
calcBaseResize(node: TreeNode): Rect;
|
63
|
+
calcDragStartStore(nodes?: TreeNode[]): void;
|
64
|
+
calcRulerSnapLines(dragNodesRect: IRect): SnapLine[];
|
65
|
+
calcAroundSnapLines(dragNodesRect: Rect): SnapLine[];
|
66
|
+
calcAroundSpaceBlocks(dragNodesRect: IRect): AroundSpaceBlock;
|
67
|
+
calcViewportNodes(): void;
|
68
|
+
getNodeRect(node: TreeNode): Rect;
|
69
|
+
eachViewportNodes(visitor: (node: TreeNode, rect: Rect) => void): void;
|
70
|
+
translate(node: TreeNode, handler: (translate: IPoint) => void): void;
|
71
|
+
resize(node: TreeNode, handler: (resize: IRect) => void): void;
|
72
|
+
findRulerSnapLine(id: string): SnapLine;
|
73
|
+
addRulerSnapLine(line: ISnapLine): void;
|
74
|
+
removeRulerSnapLine(id: string): void;
|
75
|
+
dragStart(props: ITransformHelperDragStartProps): void;
|
76
|
+
dragMove(): void;
|
77
|
+
dragEnd(): void;
|
78
|
+
makeObservable(): void;
|
79
|
+
static threshold: number;
|
80
|
+
}
|
@@ -0,0 +1,604 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
3
|
+
__assign = Object.assign || function(t) {
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
5
|
+
s = arguments[i];
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
7
|
+
t[p] = s[p];
|
8
|
+
}
|
9
|
+
return t;
|
10
|
+
};
|
11
|
+
return __assign.apply(this, arguments);
|
12
|
+
};
|
13
|
+
var __read = (this && this.__read) || function (o, n) {
|
14
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
15
|
+
if (!m) return o;
|
16
|
+
var i = m.call(o), r, ar = [], e;
|
17
|
+
try {
|
18
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
19
|
+
}
|
20
|
+
catch (error) { e = { error: error }; }
|
21
|
+
finally {
|
22
|
+
try {
|
23
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
24
|
+
}
|
25
|
+
finally { if (e) throw e.error; }
|
26
|
+
}
|
27
|
+
return ar;
|
28
|
+
};
|
29
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
30
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
31
|
+
if (ar || !(i in from)) {
|
32
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
33
|
+
ar[i] = from[i];
|
34
|
+
}
|
35
|
+
}
|
36
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
37
|
+
};
|
38
|
+
var __values = (this && this.__values) || function(o) {
|
39
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
40
|
+
if (m) return m.call(o);
|
41
|
+
if (o && typeof o.length === "number") return {
|
42
|
+
next: function () {
|
43
|
+
if (o && i >= o.length) o = void 0;
|
44
|
+
return { value: o && o[i++], done: !o };
|
45
|
+
}
|
46
|
+
};
|
47
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
48
|
+
};
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
50
|
+
exports.TransformHelper = void 0;
|
51
|
+
var shared_1 = require("@mdesignable/shared");
|
52
|
+
var reactive_1 = require("@formily/reactive");
|
53
|
+
var SpaceBlock_1 = require("./SpaceBlock");
|
54
|
+
var TreeNode_1 = require("./TreeNode");
|
55
|
+
var SnapLine_1 = require("./SnapLine");
|
56
|
+
var Cursor_1 = require("./Cursor");
|
57
|
+
var TransformHelper = /** @class */ (function () {
|
58
|
+
function TransformHelper(props) {
|
59
|
+
this.dragNodes = [];
|
60
|
+
this.rulerSnapLines = [];
|
61
|
+
this.aroundSnapLines = [];
|
62
|
+
this.aroundSpaceBlocks = null;
|
63
|
+
this.viewportRectsStore = {};
|
64
|
+
this.dragStartTranslateStore = {};
|
65
|
+
this.dragStartSizeStore = {};
|
66
|
+
this.dragStartNodesRect = null;
|
67
|
+
this.snapping = false;
|
68
|
+
this.dragging = false;
|
69
|
+
this.snapped = false;
|
70
|
+
this.operation = props.operation;
|
71
|
+
this.makeObservable();
|
72
|
+
}
|
73
|
+
Object.defineProperty(TransformHelper.prototype, "tree", {
|
74
|
+
get: function () {
|
75
|
+
return this.operation.tree;
|
76
|
+
},
|
77
|
+
enumerable: false,
|
78
|
+
configurable: true
|
79
|
+
});
|
80
|
+
Object.defineProperty(TransformHelper.prototype, "cursor", {
|
81
|
+
get: function () {
|
82
|
+
return this.operation.engine.cursor;
|
83
|
+
},
|
84
|
+
enumerable: false,
|
85
|
+
configurable: true
|
86
|
+
});
|
87
|
+
Object.defineProperty(TransformHelper.prototype, "viewport", {
|
88
|
+
get: function () {
|
89
|
+
return this.operation.workspace.viewport;
|
90
|
+
},
|
91
|
+
enumerable: false,
|
92
|
+
configurable: true
|
93
|
+
});
|
94
|
+
Object.defineProperty(TransformHelper.prototype, "deltaX", {
|
95
|
+
get: function () {
|
96
|
+
return this.cursor.dragStartToCurrentDelta.clientX;
|
97
|
+
},
|
98
|
+
enumerable: false,
|
99
|
+
configurable: true
|
100
|
+
});
|
101
|
+
Object.defineProperty(TransformHelper.prototype, "deltaY", {
|
102
|
+
get: function () {
|
103
|
+
return this.cursor.dragStartToCurrentDelta.clientY;
|
104
|
+
},
|
105
|
+
enumerable: false,
|
106
|
+
configurable: true
|
107
|
+
});
|
108
|
+
Object.defineProperty(TransformHelper.prototype, "cursorPosition", {
|
109
|
+
get: function () {
|
110
|
+
var position = this.cursor.position;
|
111
|
+
return this.operation.workspace.viewport.getOffsetPoint(new shared_1.Point(position.clientX, position.clientY));
|
112
|
+
},
|
113
|
+
enumerable: false,
|
114
|
+
configurable: true
|
115
|
+
});
|
116
|
+
Object.defineProperty(TransformHelper.prototype, "cursorDragNodesRect", {
|
117
|
+
get: function () {
|
118
|
+
if (this.type === 'translate') {
|
119
|
+
return new shared_1.Rect(this.cursorPosition.x - this.dragStartCursorOffset.x, this.cursorPosition.y - this.dragStartCursorOffset.y, this.dragNodesRect.width, this.dragNodesRect.height);
|
120
|
+
}
|
121
|
+
else if (this.type === 'resize') {
|
122
|
+
var dragNodesRect = this.dragStartNodesRect;
|
123
|
+
var deltaX = this.cursor.dragStartToCurrentDelta.clientX;
|
124
|
+
var deltaY = this.cursor.dragStartToCurrentDelta.clientY;
|
125
|
+
switch (this.direction) {
|
126
|
+
case 'left-top':
|
127
|
+
return new shared_1.Rect(this.cursorPosition.x - this.dragStartCursorOffset.x, this.cursorPosition.y - this.dragStartCursorOffset.y, dragNodesRect.width - deltaX, dragNodesRect.height - deltaY);
|
128
|
+
case 'left-center':
|
129
|
+
return new shared_1.Rect(this.cursorPosition.x - this.dragStartCursorOffset.x, dragNodesRect.y, dragNodesRect.width - deltaX, dragNodesRect.height);
|
130
|
+
case 'left-bottom':
|
131
|
+
return new shared_1.Rect(this.cursorPosition.x - this.dragStartCursorOffset.x, dragNodesRect.y, dragNodesRect.width - deltaX, dragNodesRect.height - deltaY);
|
132
|
+
case 'center-top':
|
133
|
+
return new shared_1.Rect(dragNodesRect.x, this.cursorPosition.y - this.dragStartCursorOffset.y, dragNodesRect.width, dragNodesRect.height - deltaY);
|
134
|
+
case 'center-bottom':
|
135
|
+
return new shared_1.Rect(dragNodesRect.x, dragNodesRect.y, dragNodesRect.width, dragNodesRect.height + deltaY);
|
136
|
+
case 'right-top':
|
137
|
+
return new shared_1.Rect(dragNodesRect.x, this.cursorPosition.y - this.dragStartCursorOffset.y, dragNodesRect.width + deltaX, dragNodesRect.height - deltaY);
|
138
|
+
case 'right-center':
|
139
|
+
return new shared_1.Rect(dragNodesRect.x, dragNodesRect.y, dragNodesRect.width + deltaX, dragNodesRect.height);
|
140
|
+
case 'right-bottom':
|
141
|
+
return new shared_1.Rect(dragNodesRect.x, dragNodesRect.y, dragNodesRect.width + deltaX, dragNodesRect.height - deltaY);
|
142
|
+
}
|
143
|
+
}
|
144
|
+
},
|
145
|
+
enumerable: false,
|
146
|
+
configurable: true
|
147
|
+
});
|
148
|
+
Object.defineProperty(TransformHelper.prototype, "cursorDragNodesEdgeLines", {
|
149
|
+
get: function () {
|
150
|
+
return (0, shared_1.calcEdgeLinesOfRect)(this.cursorDragNodesRect);
|
151
|
+
},
|
152
|
+
enumerable: false,
|
153
|
+
configurable: true
|
154
|
+
});
|
155
|
+
Object.defineProperty(TransformHelper.prototype, "dragNodesRect", {
|
156
|
+
get: function () {
|
157
|
+
if (this.draggingNodesRect)
|
158
|
+
return this.draggingNodesRect;
|
159
|
+
return (0, shared_1.calcBoundingRect)(this.dragNodes.map(function (node) { return node.getValidElementOffsetRect(); }));
|
160
|
+
},
|
161
|
+
enumerable: false,
|
162
|
+
configurable: true
|
163
|
+
});
|
164
|
+
Object.defineProperty(TransformHelper.prototype, "dragNodesEdgeLines", {
|
165
|
+
get: function () {
|
166
|
+
return (0, shared_1.calcEdgeLinesOfRect)(this.dragNodesRect);
|
167
|
+
},
|
168
|
+
enumerable: false,
|
169
|
+
configurable: true
|
170
|
+
});
|
171
|
+
Object.defineProperty(TransformHelper.prototype, "cursorOffset", {
|
172
|
+
get: function () {
|
173
|
+
return new shared_1.Point(this.cursorPosition.x - this.dragNodesRect.x, this.cursorPosition.y - this.dragNodesRect.y);
|
174
|
+
},
|
175
|
+
enumerable: false,
|
176
|
+
configurable: true
|
177
|
+
});
|
178
|
+
Object.defineProperty(TransformHelper.prototype, "dragStartCursor", {
|
179
|
+
get: function () {
|
180
|
+
var position = this.operation.engine.cursor.dragStartPosition;
|
181
|
+
return this.operation.workspace.viewport.getOffsetPoint(new shared_1.Point(position.clientX, position.clientY));
|
182
|
+
},
|
183
|
+
enumerable: false,
|
184
|
+
configurable: true
|
185
|
+
});
|
186
|
+
Object.defineProperty(TransformHelper.prototype, "dragStartCursorOffset", {
|
187
|
+
get: function () {
|
188
|
+
return new shared_1.Point(this.dragStartCursor.x - this.dragStartNodesRect.x, this.dragStartCursor.y - this.dragStartNodesRect.y);
|
189
|
+
},
|
190
|
+
enumerable: false,
|
191
|
+
configurable: true
|
192
|
+
});
|
193
|
+
Object.defineProperty(TransformHelper.prototype, "closestSnapLines", {
|
194
|
+
get: function () {
|
195
|
+
if (!this.dragging)
|
196
|
+
return [];
|
197
|
+
var results = [];
|
198
|
+
var cursorDragNodesEdgeLines = this.cursorDragNodesEdgeLines;
|
199
|
+
this.thresholdSnapLines.forEach(function (line) {
|
200
|
+
var distance = (0, shared_1.calcDistanceOfSnapLineToEdges)(line, cursorDragNodesEdgeLines);
|
201
|
+
if (distance < TransformHelper.threshold) {
|
202
|
+
var existed = results.findIndex(function (l) {
|
203
|
+
return l.distance > distance &&
|
204
|
+
l.distance > 0 &&
|
205
|
+
l.direction === line.direction;
|
206
|
+
});
|
207
|
+
if (existed > -1) {
|
208
|
+
results.splice(existed, 1);
|
209
|
+
}
|
210
|
+
results.push(line);
|
211
|
+
}
|
212
|
+
});
|
213
|
+
return results;
|
214
|
+
},
|
215
|
+
enumerable: false,
|
216
|
+
configurable: true
|
217
|
+
});
|
218
|
+
Object.defineProperty(TransformHelper.prototype, "closestSpaceBlocks", {
|
219
|
+
get: function () {
|
220
|
+
if (!this.dragging)
|
221
|
+
return [];
|
222
|
+
var cursorDragNodesEdgeLines = this.cursorDragNodesEdgeLines;
|
223
|
+
return this.thresholdSpaceBlocks.filter(function (block) {
|
224
|
+
var line = block.snapLine;
|
225
|
+
if (!line)
|
226
|
+
return false;
|
227
|
+
return ((0, shared_1.calcDistanceOfSnapLineToEdges)(line, cursorDragNodesEdgeLines) <
|
228
|
+
TransformHelper.threshold);
|
229
|
+
});
|
230
|
+
},
|
231
|
+
enumerable: false,
|
232
|
+
configurable: true
|
233
|
+
});
|
234
|
+
Object.defineProperty(TransformHelper.prototype, "thresholdSnapLines", {
|
235
|
+
get: function () {
|
236
|
+
if (!this.dragging)
|
237
|
+
return [];
|
238
|
+
var lines = [];
|
239
|
+
this.aroundSnapLines.forEach(function (line) {
|
240
|
+
lines.push(line);
|
241
|
+
});
|
242
|
+
this.rulerSnapLines.forEach(function (line) {
|
243
|
+
if (line.closest) {
|
244
|
+
lines.push(line);
|
245
|
+
}
|
246
|
+
});
|
247
|
+
for (var type in this.aroundSpaceBlocks) {
|
248
|
+
var block = this.aroundSpaceBlocks[type];
|
249
|
+
var line = block.snapLine;
|
250
|
+
if (line) {
|
251
|
+
lines.push(line);
|
252
|
+
}
|
253
|
+
}
|
254
|
+
return lines;
|
255
|
+
},
|
256
|
+
enumerable: false,
|
257
|
+
configurable: true
|
258
|
+
});
|
259
|
+
Object.defineProperty(TransformHelper.prototype, "thresholdSpaceBlocks", {
|
260
|
+
get: function () {
|
261
|
+
var results = [];
|
262
|
+
if (!this.dragging)
|
263
|
+
return [];
|
264
|
+
for (var type in this.aroundSpaceBlocks) {
|
265
|
+
var block = this.aroundSpaceBlocks[type];
|
266
|
+
if (!block.snapLine)
|
267
|
+
return [];
|
268
|
+
if (block.snapLine.distance !== 0)
|
269
|
+
return [];
|
270
|
+
if (block.isometrics.length) {
|
271
|
+
results.push(block);
|
272
|
+
results.push.apply(results, __spreadArray([], __read(block.isometrics), false));
|
273
|
+
}
|
274
|
+
}
|
275
|
+
return results;
|
276
|
+
},
|
277
|
+
enumerable: false,
|
278
|
+
configurable: true
|
279
|
+
});
|
280
|
+
Object.defineProperty(TransformHelper.prototype, "measurerSpaceBlocks", {
|
281
|
+
get: function () {
|
282
|
+
var results = [];
|
283
|
+
if (!this.dragging || !this.snapped)
|
284
|
+
return [];
|
285
|
+
for (var type in this.aroundSpaceBlocks) {
|
286
|
+
if (this.aroundSpaceBlocks[type])
|
287
|
+
results.push(this.aroundSpaceBlocks[type]);
|
288
|
+
}
|
289
|
+
return results;
|
290
|
+
},
|
291
|
+
enumerable: false,
|
292
|
+
configurable: true
|
293
|
+
});
|
294
|
+
TransformHelper.prototype.calcBaseTranslate = function (node) {
|
295
|
+
var _a;
|
296
|
+
var dragStartTranslate = (_a = this.dragStartTranslateStore[node.id]) !== null && _a !== void 0 ? _a : {
|
297
|
+
x: 0,
|
298
|
+
y: 0,
|
299
|
+
};
|
300
|
+
var x = dragStartTranslate.x + this.deltaX, y = dragStartTranslate.y + this.deltaY;
|
301
|
+
return { x: x, y: y };
|
302
|
+
};
|
303
|
+
TransformHelper.prototype.calcBaseResize = function (node) {
|
304
|
+
var _a, _b;
|
305
|
+
var deltaX = this.deltaX;
|
306
|
+
var deltaY = this.deltaY;
|
307
|
+
var dragStartTranslate = (_a = this.dragStartTranslateStore[node.id]) !== null && _a !== void 0 ? _a : {
|
308
|
+
x: 0,
|
309
|
+
y: 0,
|
310
|
+
};
|
311
|
+
var dragStartSize = (_b = this.dragStartSizeStore[node.id]) !== null && _b !== void 0 ? _b : {
|
312
|
+
width: 0,
|
313
|
+
height: 0,
|
314
|
+
};
|
315
|
+
switch (this.direction) {
|
316
|
+
case 'left-top':
|
317
|
+
return new shared_1.Rect(dragStartTranslate.x + deltaX, dragStartTranslate.y + deltaY, dragStartSize.width - deltaX, dragStartSize.height - deltaY);
|
318
|
+
case 'left-center':
|
319
|
+
return new shared_1.Rect(dragStartTranslate.x + deltaX, dragStartTranslate.y, dragStartSize.width - deltaX, dragStartSize.height);
|
320
|
+
case 'left-bottom':
|
321
|
+
return new shared_1.Rect(dragStartTranslate.x + deltaX, dragStartTranslate.y, dragStartSize.width - deltaX, dragStartSize.height + deltaY);
|
322
|
+
case 'center-bottom':
|
323
|
+
return new shared_1.Rect(dragStartTranslate.x, dragStartTranslate.y, dragStartSize.width, dragStartSize.height + deltaY);
|
324
|
+
case 'center-top':
|
325
|
+
return new shared_1.Rect(dragStartTranslate.x, dragStartTranslate.y + deltaY, dragStartSize.width, dragStartSize.height - deltaY);
|
326
|
+
case 'right-top':
|
327
|
+
return new shared_1.Rect(dragStartTranslate.x, dragStartTranslate.y + deltaY, dragStartSize.width + deltaX, dragStartSize.height - deltaY);
|
328
|
+
case 'right-bottom':
|
329
|
+
return new shared_1.Rect(dragStartTranslate.x, dragStartTranslate.y, dragStartSize.width + deltaX, dragStartSize.height + deltaY);
|
330
|
+
case 'right-center':
|
331
|
+
return new shared_1.Rect(dragStartTranslate.x, dragStartTranslate.y, dragStartSize.width + deltaX, dragStartSize.height);
|
332
|
+
}
|
333
|
+
};
|
334
|
+
TransformHelper.prototype.calcDragStartStore = function (nodes) {
|
335
|
+
var _this = this;
|
336
|
+
if (nodes === void 0) { nodes = []; }
|
337
|
+
this.dragStartNodesRect = this.dragNodesRect;
|
338
|
+
nodes.forEach(function (node) {
|
339
|
+
var element = node.getElement();
|
340
|
+
var rect = node.getElementOffsetRect();
|
341
|
+
_this.dragStartTranslateStore[node.id] = (0, shared_1.calcElementTranslate)(element);
|
342
|
+
_this.dragStartSizeStore[node.id] = {
|
343
|
+
width: rect.width,
|
344
|
+
height: rect.height,
|
345
|
+
};
|
346
|
+
});
|
347
|
+
};
|
348
|
+
TransformHelper.prototype.calcRulerSnapLines = function (dragNodesRect) {
|
349
|
+
var edgeLines = (0, shared_1.calcEdgeLinesOfRect)(dragNodesRect);
|
350
|
+
return this.rulerSnapLines.map(function (line) {
|
351
|
+
line.distance = (0, shared_1.calcDistanceOfSnapLineToEdges)(line, edgeLines);
|
352
|
+
return line;
|
353
|
+
});
|
354
|
+
};
|
355
|
+
TransformHelper.prototype.calcAroundSnapLines = function (dragNodesRect) {
|
356
|
+
var _this = this;
|
357
|
+
var results = [];
|
358
|
+
var edgeLines = (0, shared_1.calcEdgeLinesOfRect)(dragNodesRect);
|
359
|
+
this.eachViewportNodes(function (refer, referRect) {
|
360
|
+
if (_this.dragNodes.includes(refer))
|
361
|
+
return;
|
362
|
+
var referLines = (0, shared_1.calcEdgeLinesOfRect)(referRect);
|
363
|
+
var add = function (line) {
|
364
|
+
var _a = __read((0, shared_1.calcClosestEdges)(line, edgeLines), 2), distance = _a[0], edge = _a[1];
|
365
|
+
var combined = (0, shared_1.calcCombineSnapLineSegment)(line, edge);
|
366
|
+
if (distance < TransformHelper.threshold) {
|
367
|
+
if (_this.snapping && distance !== 0)
|
368
|
+
return;
|
369
|
+
var snapLine = new SnapLine_1.SnapLine(_this, __assign(__assign({}, combined), { distance: distance }));
|
370
|
+
var edge_1 = snapLine.snapEdge(dragNodesRect);
|
371
|
+
if (_this.type === 'translate') {
|
372
|
+
results.push(snapLine);
|
373
|
+
}
|
374
|
+
else if (edge_1 !== 'hc' && edge_1 !== 'vc') {
|
375
|
+
results.push(snapLine);
|
376
|
+
}
|
377
|
+
}
|
378
|
+
};
|
379
|
+
referLines.h.forEach(add);
|
380
|
+
referLines.v.forEach(add);
|
381
|
+
});
|
382
|
+
return results;
|
383
|
+
};
|
384
|
+
TransformHelper.prototype.calcAroundSpaceBlocks = function (dragNodesRect) {
|
385
|
+
var _this = this;
|
386
|
+
var closestSpaces = {};
|
387
|
+
this.eachViewportNodes(function (refer, referRect) {
|
388
|
+
if ((0, shared_1.isEqualRect)(dragNodesRect, referRect))
|
389
|
+
return;
|
390
|
+
var origin = (0, shared_1.calcSpaceBlockOfRect)(dragNodesRect, referRect);
|
391
|
+
if (origin) {
|
392
|
+
var spaceBlock = new SpaceBlock_1.SpaceBlock(_this, __assign({ refer: refer }, origin));
|
393
|
+
if (!closestSpaces[origin.type]) {
|
394
|
+
closestSpaces[origin.type] = spaceBlock;
|
395
|
+
}
|
396
|
+
else if (spaceBlock.distance < closestSpaces[origin.type].distance) {
|
397
|
+
closestSpaces[origin.type] = spaceBlock;
|
398
|
+
}
|
399
|
+
}
|
400
|
+
});
|
401
|
+
return closestSpaces;
|
402
|
+
};
|
403
|
+
TransformHelper.prototype.calcViewportNodes = function () {
|
404
|
+
var _this = this;
|
405
|
+
this.tree.eachTree(function (node) {
|
406
|
+
var topRect = node.getValidElementRect();
|
407
|
+
var offsetRect = node.getValidElementOffsetRect();
|
408
|
+
if (_this.dragNodes.includes(node))
|
409
|
+
return;
|
410
|
+
if (_this.viewport.isRectInViewport(topRect)) {
|
411
|
+
_this.viewportRectsStore[node.id] = offsetRect;
|
412
|
+
}
|
413
|
+
});
|
414
|
+
};
|
415
|
+
TransformHelper.prototype.getNodeRect = function (node) {
|
416
|
+
return this.viewportRectsStore[node.id];
|
417
|
+
};
|
418
|
+
TransformHelper.prototype.eachViewportNodes = function (visitor) {
|
419
|
+
for (var id in this.viewportRectsStore) {
|
420
|
+
visitor(this.tree.findById(id), this.viewportRectsStore[id]);
|
421
|
+
}
|
422
|
+
};
|
423
|
+
TransformHelper.prototype.translate = function (node, handler) {
|
424
|
+
var e_1, _a;
|
425
|
+
if (!this.dragging)
|
426
|
+
return;
|
427
|
+
var translate = this.calcBaseTranslate(node);
|
428
|
+
this.snapped = false;
|
429
|
+
this.snapping = false;
|
430
|
+
try {
|
431
|
+
for (var _b = __values(this.closestSnapLines), _c = _b.next(); !_c.done; _c = _b.next()) {
|
432
|
+
var line = _c.value;
|
433
|
+
line.translate(node, translate);
|
434
|
+
this.snapping = true;
|
435
|
+
this.snapped = true;
|
436
|
+
}
|
437
|
+
}
|
438
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
439
|
+
finally {
|
440
|
+
try {
|
441
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
442
|
+
}
|
443
|
+
finally { if (e_1) throw e_1.error; }
|
444
|
+
}
|
445
|
+
handler(translate);
|
446
|
+
if (this.snapping) {
|
447
|
+
this.dragMove();
|
448
|
+
this.snapping = false;
|
449
|
+
}
|
450
|
+
};
|
451
|
+
TransformHelper.prototype.resize = function (node, handler) {
|
452
|
+
var e_2, _a;
|
453
|
+
if (!this.dragging)
|
454
|
+
return;
|
455
|
+
var rect = this.calcBaseResize(node);
|
456
|
+
this.snapping = false;
|
457
|
+
this.snapping = false;
|
458
|
+
try {
|
459
|
+
for (var _b = __values(this.closestSnapLines), _c = _b.next(); !_c.done; _c = _b.next()) {
|
460
|
+
var line = _c.value;
|
461
|
+
line.resize(node, rect);
|
462
|
+
this.snapping = true;
|
463
|
+
this.snapped = true;
|
464
|
+
}
|
465
|
+
}
|
466
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
467
|
+
finally {
|
468
|
+
try {
|
469
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
470
|
+
}
|
471
|
+
finally { if (e_2) throw e_2.error; }
|
472
|
+
}
|
473
|
+
handler(rect);
|
474
|
+
if (this.snapping) {
|
475
|
+
this.dragMove();
|
476
|
+
this.snapping = false;
|
477
|
+
}
|
478
|
+
};
|
479
|
+
// rotate(node: TreeNode, handler: (rotate: number) => void) {}
|
480
|
+
// scale(node: TreeNode, handler: (scale: number) => void) {}
|
481
|
+
// round(node: TreeNode, handler: (round: number) => void) {}
|
482
|
+
TransformHelper.prototype.findRulerSnapLine = function (id) {
|
483
|
+
return this.rulerSnapLines.find(function (item) { return item.id === id; });
|
484
|
+
};
|
485
|
+
TransformHelper.prototype.addRulerSnapLine = function (line) {
|
486
|
+
if (!(0, shared_1.isLineSegment)(line))
|
487
|
+
return;
|
488
|
+
if (!this.findRulerSnapLine(line.id)) {
|
489
|
+
this.rulerSnapLines.push(new SnapLine_1.SnapLine(this, __assign(__assign({}, line), { type: 'ruler' })));
|
490
|
+
}
|
491
|
+
};
|
492
|
+
TransformHelper.prototype.removeRulerSnapLine = function (id) {
|
493
|
+
var matchedLineIndex = this.rulerSnapLines.findIndex(function (item) { return item.id === id; });
|
494
|
+
if (matchedLineIndex > -1) {
|
495
|
+
this.rulerSnapLines.splice(matchedLineIndex, 1);
|
496
|
+
}
|
497
|
+
};
|
498
|
+
TransformHelper.prototype.dragStart = function (props) {
|
499
|
+
var dragNodes = props === null || props === void 0 ? void 0 : props.dragNodes;
|
500
|
+
var type = props === null || props === void 0 ? void 0 : props.type;
|
501
|
+
var direction = props === null || props === void 0 ? void 0 : props.direction;
|
502
|
+
if (type === 'resize') {
|
503
|
+
var nodes = TreeNode_1.TreeNode.filterResizable(dragNodes);
|
504
|
+
if (nodes.length) {
|
505
|
+
this.dragging = true;
|
506
|
+
this.type = type;
|
507
|
+
this.direction = direction;
|
508
|
+
this.dragNodes = nodes;
|
509
|
+
this.calcDragStartStore(nodes);
|
510
|
+
this.cursor.setDragType(Cursor_1.CursorDragType.Resize);
|
511
|
+
}
|
512
|
+
}
|
513
|
+
else if (type === 'translate') {
|
514
|
+
var nodes = TreeNode_1.TreeNode.filterTranslatable(dragNodes);
|
515
|
+
if (nodes.length) {
|
516
|
+
this.dragging = true;
|
517
|
+
this.type = type;
|
518
|
+
this.direction = direction;
|
519
|
+
this.dragNodes = nodes;
|
520
|
+
this.calcDragStartStore(nodes);
|
521
|
+
this.cursor.setDragType(Cursor_1.CursorDragType.Translate);
|
522
|
+
}
|
523
|
+
}
|
524
|
+
else if (type === 'rotate') {
|
525
|
+
var nodes = TreeNode_1.TreeNode.filterRotatable(dragNodes);
|
526
|
+
if (nodes.length) {
|
527
|
+
this.dragging = true;
|
528
|
+
this.type = type;
|
529
|
+
this.dragNodes = nodes;
|
530
|
+
this.calcDragStartStore(nodes);
|
531
|
+
this.cursor.setDragType(Cursor_1.CursorDragType.Rotate);
|
532
|
+
}
|
533
|
+
}
|
534
|
+
else if (type === 'scale') {
|
535
|
+
var nodes = TreeNode_1.TreeNode.filterScalable(dragNodes);
|
536
|
+
if (nodes.length) {
|
537
|
+
this.dragging = true;
|
538
|
+
this.type = type;
|
539
|
+
this.dragNodes = nodes;
|
540
|
+
this.calcDragStartStore(nodes);
|
541
|
+
this.cursor.setDragType(Cursor_1.CursorDragType.Scale);
|
542
|
+
}
|
543
|
+
}
|
544
|
+
else if (type === 'round') {
|
545
|
+
var nodes = TreeNode_1.TreeNode.filterRoundable(dragNodes);
|
546
|
+
if (nodes.length) {
|
547
|
+
this.dragging = true;
|
548
|
+
this.type = type;
|
549
|
+
this.dragNodes = nodes;
|
550
|
+
this.calcDragStartStore(nodes);
|
551
|
+
this.cursor.setDragType(Cursor_1.CursorDragType.Round);
|
552
|
+
}
|
553
|
+
}
|
554
|
+
if (this.dragging) {
|
555
|
+
this.calcViewportNodes();
|
556
|
+
}
|
557
|
+
};
|
558
|
+
TransformHelper.prototype.dragMove = function () {
|
559
|
+
if (!this.dragging)
|
560
|
+
return;
|
561
|
+
this.draggingNodesRect = null;
|
562
|
+
this.draggingNodesRect = this.dragNodesRect;
|
563
|
+
this.rulerSnapLines = this.calcRulerSnapLines(this.dragNodesRect);
|
564
|
+
this.aroundSnapLines = this.calcAroundSnapLines(this.dragNodesRect);
|
565
|
+
this.aroundSpaceBlocks = this.calcAroundSpaceBlocks(this.dragNodesRect);
|
566
|
+
};
|
567
|
+
TransformHelper.prototype.dragEnd = function () {
|
568
|
+
this.dragging = false;
|
569
|
+
this.viewportRectsStore = {};
|
570
|
+
this.dragStartTranslateStore = {};
|
571
|
+
this.aroundSnapLines = [];
|
572
|
+
this.draggingNodesRect = null;
|
573
|
+
this.aroundSpaceBlocks = null;
|
574
|
+
this.dragStartNodesRect = null;
|
575
|
+
this.dragNodes = [];
|
576
|
+
this.cursor.setDragType(Cursor_1.CursorDragType.Move);
|
577
|
+
};
|
578
|
+
TransformHelper.prototype.makeObservable = function () {
|
579
|
+
(0, reactive_1.define)(this, {
|
580
|
+
snapped: reactive_1.observable.ref,
|
581
|
+
dragging: reactive_1.observable.ref,
|
582
|
+
snapping: reactive_1.observable.ref,
|
583
|
+
dragNodes: reactive_1.observable.ref,
|
584
|
+
aroundSnapLines: reactive_1.observable.ref,
|
585
|
+
aroundSpaceBlocks: reactive_1.observable.ref,
|
586
|
+
rulerSnapLines: reactive_1.observable.shallow,
|
587
|
+
closestSnapLines: reactive_1.observable.computed,
|
588
|
+
thresholdSnapLines: reactive_1.observable.computed,
|
589
|
+
thresholdSpaceBlocks: reactive_1.observable.computed,
|
590
|
+
measurerSpaceBlocks: reactive_1.observable.computed,
|
591
|
+
cursor: reactive_1.observable.computed,
|
592
|
+
cursorPosition: reactive_1.observable.computed,
|
593
|
+
cursorOffset: reactive_1.observable.computed,
|
594
|
+
dragStartCursor: reactive_1.observable.computed,
|
595
|
+
translate: reactive_1.action,
|
596
|
+
dragStart: reactive_1.action,
|
597
|
+
dragMove: reactive_1.action,
|
598
|
+
dragEnd: reactive_1.action,
|
599
|
+
});
|
600
|
+
};
|
601
|
+
TransformHelper.threshold = 6;
|
602
|
+
return TransformHelper;
|
603
|
+
}());
|
604
|
+
exports.TransformHelper = TransformHelper;
|