@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
package/esm/externals.js
ADDED
@@ -0,0 +1,113 @@
|
|
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
|
+
var __read = (this && this.__read) || function (o, n) {
|
13
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
14
|
+
if (!m) return o;
|
15
|
+
var i = m.call(o), r, ar = [], e;
|
16
|
+
try {
|
17
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
18
|
+
}
|
19
|
+
catch (error) { e = { error: error }; }
|
20
|
+
finally {
|
21
|
+
try {
|
22
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
23
|
+
}
|
24
|
+
finally { if (e) throw e.error; }
|
25
|
+
}
|
26
|
+
return ar;
|
27
|
+
};
|
28
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
29
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
30
|
+
if (ar || !(i in from)) {
|
31
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
32
|
+
ar[i] = from[i];
|
33
|
+
}
|
34
|
+
}
|
35
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
36
|
+
};
|
37
|
+
import { isArr } from '@mdesignable/shared';
|
38
|
+
import { untracked } from '@formily/reactive';
|
39
|
+
import { DEFAULT_DRIVERS, DEFAULT_EFFECTS, DEFAULT_SHORTCUTS } from './presets';
|
40
|
+
import { Engine, TreeNode } from './models';
|
41
|
+
import { mergeLocales } from './internals';
|
42
|
+
export var isBehaviorHost = function (val) {
|
43
|
+
return (val === null || val === void 0 ? void 0 : val.Behavior) && isBehaviorList(val.Behavior);
|
44
|
+
};
|
45
|
+
export var isBehaviorList = function (val) {
|
46
|
+
return Array.isArray(val) && val.every(isBehavior);
|
47
|
+
};
|
48
|
+
export var isBehavior = function (val) {
|
49
|
+
return (val === null || val === void 0 ? void 0 : val.name) ||
|
50
|
+
(val === null || val === void 0 ? void 0 : val.selector) ||
|
51
|
+
(val === null || val === void 0 ? void 0 : val.extends) ||
|
52
|
+
(val === null || val === void 0 ? void 0 : val.designerProps) ||
|
53
|
+
(val === null || val === void 0 ? void 0 : val.designerLocales);
|
54
|
+
};
|
55
|
+
export var isResourceHost = function (val) {
|
56
|
+
return (val === null || val === void 0 ? void 0 : val.Resource) && isResourceList(val.Resource);
|
57
|
+
};
|
58
|
+
export var isResourceList = function (val) {
|
59
|
+
return Array.isArray(val) && val.every(isResource);
|
60
|
+
};
|
61
|
+
export var isResource = function (val) {
|
62
|
+
return (val === null || val === void 0 ? void 0 : val.node) && !!val.node.isSourceNode && val.node instanceof TreeNode;
|
63
|
+
};
|
64
|
+
export var createLocales = function () {
|
65
|
+
var packages = [];
|
66
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
67
|
+
packages[_i] = arguments[_i];
|
68
|
+
}
|
69
|
+
var results = {};
|
70
|
+
packages.forEach(function (locales) {
|
71
|
+
mergeLocales(results, locales);
|
72
|
+
});
|
73
|
+
return results;
|
74
|
+
};
|
75
|
+
export var createBehavior = function () {
|
76
|
+
var behaviors = [];
|
77
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
78
|
+
behaviors[_i] = arguments[_i];
|
79
|
+
}
|
80
|
+
return behaviors.reduce(function (buf, behavior) {
|
81
|
+
if (isArr(behavior))
|
82
|
+
return buf.concat(createBehavior.apply(void 0, __spreadArray([], __read(behavior), false)));
|
83
|
+
var selector = (behavior || {}).selector;
|
84
|
+
if (!selector)
|
85
|
+
return buf;
|
86
|
+
if (typeof selector === 'string') {
|
87
|
+
behavior.selector = function (node) { return node.componentName === selector; };
|
88
|
+
}
|
89
|
+
return buf.concat(behavior);
|
90
|
+
}, []);
|
91
|
+
};
|
92
|
+
export var createResource = function () {
|
93
|
+
var sources = [];
|
94
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
95
|
+
sources[_i] = arguments[_i];
|
96
|
+
}
|
97
|
+
return sources.reduce(function (buf, source) {
|
98
|
+
return buf.concat(__assign(__assign({}, source), { node: new TreeNode({
|
99
|
+
componentName: '$$ResourceNode$$',
|
100
|
+
isSourceNode: true,
|
101
|
+
children: source.elements || [],
|
102
|
+
}) }));
|
103
|
+
}, []);
|
104
|
+
};
|
105
|
+
export var createDesigner = function (props) {
|
106
|
+
if (props === void 0) { props = {}; }
|
107
|
+
var drivers = props.drivers || [];
|
108
|
+
var effects = props.effects || [];
|
109
|
+
var shortcuts = props.shortcuts || [];
|
110
|
+
return untracked(function () {
|
111
|
+
return new Engine(__assign(__assign({}, props), { effects: __spreadArray(__spreadArray([], __read(effects), false), __read(DEFAULT_EFFECTS), false), drivers: __spreadArray(__spreadArray([], __read(drivers), false), __read(DEFAULT_DRIVERS), false), shortcuts: __spreadArray(__spreadArray([], __read(shortcuts), false), __read(DEFAULT_SHORTCUTS), false) }));
|
112
|
+
});
|
113
|
+
};
|
package/esm/index.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export * from './exports';
|
package/esm/index.js
ADDED
@@ -0,0 +1,24 @@
|
|
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
|
+
var _a;
|
13
|
+
import * as Core from './exports';
|
14
|
+
export * from './exports';
|
15
|
+
import { globalThisPolyfill } from '@mdesignable/shared';
|
16
|
+
if ((_a = globalThisPolyfill === null || globalThisPolyfill === void 0 ? void 0 : globalThisPolyfill['Designable']) === null || _a === void 0 ? void 0 : _a['Core']) {
|
17
|
+
if (module.exports) {
|
18
|
+
module.exports = __assign({ __esModule: true }, globalThisPolyfill['Designable']['Core']);
|
19
|
+
}
|
20
|
+
}
|
21
|
+
else {
|
22
|
+
globalThisPolyfill['Designable'] = globalThisPolyfill['Designable'] || {};
|
23
|
+
globalThisPolyfill['Designable'].Core = Core;
|
24
|
+
}
|
package/esm/internals.js
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
import { each, isPlainObj } from '@mdesignable/shared';
|
2
|
+
import { globalThisPolyfill } from '@mdesignable/shared';
|
3
|
+
export var lowerSnake = function (str) {
|
4
|
+
return String(str).replace(/\s+/g, '_').toLocaleLowerCase();
|
5
|
+
};
|
6
|
+
export var mergeLocales = function (target, source) {
|
7
|
+
if (isPlainObj(target) && isPlainObj(source)) {
|
8
|
+
each(source, function (value, key) {
|
9
|
+
var token = lowerSnake(key);
|
10
|
+
var messages = mergeLocales(target[key] || target[token], value);
|
11
|
+
target[token] = messages;
|
12
|
+
});
|
13
|
+
return target;
|
14
|
+
}
|
15
|
+
else if (isPlainObj(source)) {
|
16
|
+
var result_1 = Array.isArray(source) ? [] : {};
|
17
|
+
each(source, function (value, key) {
|
18
|
+
var messages = mergeLocales(undefined, value);
|
19
|
+
result_1[lowerSnake(key)] = messages;
|
20
|
+
});
|
21
|
+
return result_1;
|
22
|
+
}
|
23
|
+
return source;
|
24
|
+
};
|
25
|
+
export var getBrowserLanguage = function () {
|
26
|
+
var _a;
|
27
|
+
/* istanbul ignore next */
|
28
|
+
if (!globalThisPolyfill.navigator) {
|
29
|
+
return 'en';
|
30
|
+
}
|
31
|
+
return (globalThisPolyfill.navigator['browserlanguage'] ||
|
32
|
+
((_a = globalThisPolyfill.navigator) === null || _a === void 0 ? void 0 : _a.language) ||
|
33
|
+
'en');
|
34
|
+
};
|
@@ -0,0 +1,60 @@
|
|
1
|
+
import { Engine } from './Engine';
|
2
|
+
export declare enum CursorStatus {
|
3
|
+
Normal = "NORMAL",
|
4
|
+
DragStart = "DRAG_START",
|
5
|
+
Dragging = "DRAGGING",
|
6
|
+
DragStop = "DRAG_STOP"
|
7
|
+
}
|
8
|
+
export declare enum CursorDragType {
|
9
|
+
Move = "MOVE",
|
10
|
+
Resize = "RESIZE",
|
11
|
+
Rotate = "ROTATE",
|
12
|
+
Scale = "SCALE",
|
13
|
+
Translate = "TRANSLATE",
|
14
|
+
Round = "ROUND"
|
15
|
+
}
|
16
|
+
export declare enum CursorType {
|
17
|
+
Normal = "NORMAL",
|
18
|
+
Selection = "SELECTION",
|
19
|
+
Sketch = "SKETCH"
|
20
|
+
}
|
21
|
+
export interface ICursorPosition {
|
22
|
+
pageX?: number;
|
23
|
+
pageY?: number;
|
24
|
+
clientX?: number;
|
25
|
+
clientY?: number;
|
26
|
+
topPageX?: number;
|
27
|
+
topPageY?: number;
|
28
|
+
topClientX?: number;
|
29
|
+
topClientY?: number;
|
30
|
+
}
|
31
|
+
export interface ICursor {
|
32
|
+
status?: CursorStatus;
|
33
|
+
position?: ICursorPosition;
|
34
|
+
dragStartPosition?: ICursorPosition;
|
35
|
+
dragEndPosition?: ICursorPosition;
|
36
|
+
view?: Window;
|
37
|
+
}
|
38
|
+
export declare class Cursor {
|
39
|
+
engine: Engine;
|
40
|
+
type: CursorType | string;
|
41
|
+
dragType: CursorDragType | string;
|
42
|
+
status: CursorStatus;
|
43
|
+
position: ICursorPosition;
|
44
|
+
dragStartPosition: ICursorPosition;
|
45
|
+
dragEndPosition: ICursorPosition;
|
46
|
+
dragAtomDelta: ICursorPosition;
|
47
|
+
dragStartToCurrentDelta: ICursorPosition;
|
48
|
+
dragStartToEndDelta: ICursorPosition;
|
49
|
+
view: Window;
|
50
|
+
constructor(engine: Engine);
|
51
|
+
makeObservable(): void;
|
52
|
+
get speed(): number;
|
53
|
+
setStatus(status: CursorStatus): void;
|
54
|
+
setType(type: CursorType | string): void;
|
55
|
+
setDragType(type: CursorDragType | string): void;
|
56
|
+
setStyle(style: string): void;
|
57
|
+
setPosition(position?: ICursorPosition): void;
|
58
|
+
setDragStartPosition(position?: ICursorPosition): void;
|
59
|
+
setDragEndPosition(position?: ICursorPosition): void;
|
60
|
+
}
|
@@ -0,0 +1,151 @@
|
|
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 { action, define, observable } from '@formily/reactive';
|
13
|
+
import { globalThisPolyfill, isValidNumber } from '@mdesignable/shared';
|
14
|
+
export var CursorStatus;
|
15
|
+
(function (CursorStatus) {
|
16
|
+
CursorStatus["Normal"] = "NORMAL";
|
17
|
+
CursorStatus["DragStart"] = "DRAG_START";
|
18
|
+
CursorStatus["Dragging"] = "DRAGGING";
|
19
|
+
CursorStatus["DragStop"] = "DRAG_STOP";
|
20
|
+
})(CursorStatus || (CursorStatus = {}));
|
21
|
+
export var CursorDragType;
|
22
|
+
(function (CursorDragType) {
|
23
|
+
CursorDragType["Move"] = "MOVE";
|
24
|
+
CursorDragType["Resize"] = "RESIZE";
|
25
|
+
CursorDragType["Rotate"] = "ROTATE";
|
26
|
+
CursorDragType["Scale"] = "SCALE";
|
27
|
+
CursorDragType["Translate"] = "TRANSLATE";
|
28
|
+
CursorDragType["Round"] = "ROUND";
|
29
|
+
})(CursorDragType || (CursorDragType = {}));
|
30
|
+
export var CursorType;
|
31
|
+
(function (CursorType) {
|
32
|
+
CursorType["Normal"] = "NORMAL";
|
33
|
+
CursorType["Selection"] = "SELECTION";
|
34
|
+
CursorType["Sketch"] = "SKETCH";
|
35
|
+
})(CursorType || (CursorType = {}));
|
36
|
+
var DEFAULT_POSITION = {
|
37
|
+
pageX: 0,
|
38
|
+
pageY: 0,
|
39
|
+
clientX: 0,
|
40
|
+
clientY: 0,
|
41
|
+
topPageX: 0,
|
42
|
+
topPageY: 0,
|
43
|
+
topClientX: 0,
|
44
|
+
topClientY: 0,
|
45
|
+
};
|
46
|
+
var setCursorStyle = function (contentWindow, style) {
|
47
|
+
var _a, _b, _c, _d;
|
48
|
+
var currentRoot = (_b = (_a = document === null || document === void 0 ? void 0 : document.getElementsByTagName) === null || _a === void 0 ? void 0 : _a.call(document, 'html')) === null || _b === void 0 ? void 0 : _b[0];
|
49
|
+
var root = (_d = (_c = contentWindow === null || contentWindow === void 0 ? void 0 : contentWindow.document) === null || _c === void 0 ? void 0 : _c.getElementsByTagName('html')) === null || _d === void 0 ? void 0 : _d[0];
|
50
|
+
if (root && root.style.cursor !== style) {
|
51
|
+
root.style.cursor = style;
|
52
|
+
}
|
53
|
+
if (currentRoot && currentRoot.style.cursor !== style) {
|
54
|
+
currentRoot.style.cursor = style;
|
55
|
+
}
|
56
|
+
};
|
57
|
+
var calcPositionDelta = function (end, start) {
|
58
|
+
return Object.keys(end || {}).reduce(function (buf, key) {
|
59
|
+
if (isValidNumber(end === null || end === void 0 ? void 0 : end[key]) && isValidNumber(start === null || start === void 0 ? void 0 : start[key])) {
|
60
|
+
buf[key] = end[key] - start[key];
|
61
|
+
}
|
62
|
+
else {
|
63
|
+
buf[key] = end[key];
|
64
|
+
}
|
65
|
+
return buf;
|
66
|
+
}, {});
|
67
|
+
};
|
68
|
+
var Cursor = /** @class */ (function () {
|
69
|
+
function Cursor(engine) {
|
70
|
+
this.type = CursorType.Normal;
|
71
|
+
this.dragType = CursorDragType.Move;
|
72
|
+
this.status = CursorStatus.Normal;
|
73
|
+
this.position = DEFAULT_POSITION;
|
74
|
+
this.dragAtomDelta = DEFAULT_POSITION;
|
75
|
+
this.dragStartToCurrentDelta = DEFAULT_POSITION;
|
76
|
+
this.dragStartToEndDelta = DEFAULT_POSITION;
|
77
|
+
this.view = globalThisPolyfill;
|
78
|
+
this.engine = engine;
|
79
|
+
this.makeObservable();
|
80
|
+
}
|
81
|
+
Cursor.prototype.makeObservable = function () {
|
82
|
+
define(this, {
|
83
|
+
type: observable.ref,
|
84
|
+
dragType: observable.ref,
|
85
|
+
status: observable.ref,
|
86
|
+
position: observable.ref,
|
87
|
+
dragStartPosition: observable.ref,
|
88
|
+
dragEndPosition: observable.ref,
|
89
|
+
dragAtomDelta: observable.ref,
|
90
|
+
dragStartToCurrentDelta: observable.ref,
|
91
|
+
dragStartToEndDelta: observable.ref,
|
92
|
+
view: observable.ref,
|
93
|
+
setStyle: action,
|
94
|
+
setPosition: action,
|
95
|
+
setStatus: action,
|
96
|
+
setType: action,
|
97
|
+
});
|
98
|
+
};
|
99
|
+
Object.defineProperty(Cursor.prototype, "speed", {
|
100
|
+
get: function () {
|
101
|
+
return Math.sqrt(Math.pow(this.dragAtomDelta.clientX, 2) +
|
102
|
+
Math.pow(this.dragAtomDelta.clientY, 2));
|
103
|
+
},
|
104
|
+
enumerable: false,
|
105
|
+
configurable: true
|
106
|
+
});
|
107
|
+
Cursor.prototype.setStatus = function (status) {
|
108
|
+
this.status = status;
|
109
|
+
};
|
110
|
+
Cursor.prototype.setType = function (type) {
|
111
|
+
this.type = type;
|
112
|
+
};
|
113
|
+
Cursor.prototype.setDragType = function (type) {
|
114
|
+
this.dragType = type;
|
115
|
+
};
|
116
|
+
Cursor.prototype.setStyle = function (style) {
|
117
|
+
this.engine.workbench.eachWorkspace(function (workspace) {
|
118
|
+
setCursorStyle(workspace.viewport.contentWindow, style);
|
119
|
+
});
|
120
|
+
};
|
121
|
+
Cursor.prototype.setPosition = function (position) {
|
122
|
+
this.dragAtomDelta = calcPositionDelta(this.position, position);
|
123
|
+
this.position = __assign({}, position);
|
124
|
+
if (this.status === CursorStatus.Dragging) {
|
125
|
+
this.dragStartToCurrentDelta = calcPositionDelta(this.position, this.dragStartPosition);
|
126
|
+
}
|
127
|
+
};
|
128
|
+
Cursor.prototype.setDragStartPosition = function (position) {
|
129
|
+
if (position) {
|
130
|
+
this.dragStartPosition = __assign({}, position);
|
131
|
+
}
|
132
|
+
else {
|
133
|
+
this.dragStartPosition = null;
|
134
|
+
this.dragStartToCurrentDelta = DEFAULT_POSITION;
|
135
|
+
}
|
136
|
+
};
|
137
|
+
Cursor.prototype.setDragEndPosition = function (position) {
|
138
|
+
if (!this.dragStartPosition)
|
139
|
+
return;
|
140
|
+
if (position) {
|
141
|
+
this.dragEndPosition = __assign({}, position);
|
142
|
+
this.dragStartToEndDelta = calcPositionDelta(this.dragStartPosition, this.dragEndPosition);
|
143
|
+
}
|
144
|
+
else {
|
145
|
+
this.dragEndPosition = null;
|
146
|
+
this.dragStartToEndDelta = DEFAULT_POSITION;
|
147
|
+
}
|
148
|
+
};
|
149
|
+
return Cursor;
|
150
|
+
}());
|
151
|
+
export { Cursor };
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { IEngineProps } from '../types';
|
2
|
+
import { ITreeNode, TreeNode } from './TreeNode';
|
3
|
+
import { Workbench } from './Workbench';
|
4
|
+
import { Cursor } from './Cursor';
|
5
|
+
import { Keyboard } from './Keyboard';
|
6
|
+
import { Screen } from './Screen';
|
7
|
+
import { Event } from '@mdesignable/shared';
|
8
|
+
/**
|
9
|
+
* 设计器引擎
|
10
|
+
*/
|
11
|
+
export declare class Engine extends Event {
|
12
|
+
id: string;
|
13
|
+
props: IEngineProps<Engine>;
|
14
|
+
cursor: Cursor;
|
15
|
+
workbench: Workbench;
|
16
|
+
keyboard: Keyboard;
|
17
|
+
screen: Screen;
|
18
|
+
constructor(props: IEngineProps<Engine>);
|
19
|
+
init(): void;
|
20
|
+
setCurrentTree(tree?: ITreeNode): void;
|
21
|
+
getCurrentTree(): TreeNode;
|
22
|
+
getAllSelectedNodes(): TreeNode[];
|
23
|
+
findNodeById(id: string): TreeNode;
|
24
|
+
findMovingNodes(): TreeNode[];
|
25
|
+
createNode(node: ITreeNode, parent?: TreeNode): TreeNode;
|
26
|
+
mount(): void;
|
27
|
+
unmount(): void;
|
28
|
+
static defaultProps: IEngineProps<Engine>;
|
29
|
+
}
|
@@ -0,0 +1,112 @@
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
2
|
+
var extendStatics = function (d, b) {
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
6
|
+
return extendStatics(d, b);
|
7
|
+
};
|
8
|
+
return function (d, b) {
|
9
|
+
if (typeof b !== "function" && b !== null)
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
11
|
+
extendStatics(d, b);
|
12
|
+
function __() { this.constructor = d; }
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
14
|
+
};
|
15
|
+
})();
|
16
|
+
var __assign = (this && this.__assign) || function () {
|
17
|
+
__assign = Object.assign || function(t) {
|
18
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
19
|
+
s = arguments[i];
|
20
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
21
|
+
t[p] = s[p];
|
22
|
+
}
|
23
|
+
return t;
|
24
|
+
};
|
25
|
+
return __assign.apply(this, arguments);
|
26
|
+
};
|
27
|
+
import { TreeNode } from './TreeNode';
|
28
|
+
import { Workbench } from './Workbench';
|
29
|
+
import { Cursor } from './Cursor';
|
30
|
+
import { Keyboard } from './Keyboard';
|
31
|
+
import { Screen, ScreenType } from './Screen';
|
32
|
+
import { Event, uid, globalThisPolyfill } from '@mdesignable/shared';
|
33
|
+
/**
|
34
|
+
* 设计器引擎
|
35
|
+
*/
|
36
|
+
var Engine = /** @class */ (function (_super) {
|
37
|
+
__extends(Engine, _super);
|
38
|
+
function Engine(props) {
|
39
|
+
var _this = _super.call(this, props) || this;
|
40
|
+
_this.props = __assign(__assign({}, Engine.defaultProps), props);
|
41
|
+
_this.init();
|
42
|
+
_this.id = uid();
|
43
|
+
return _this;
|
44
|
+
}
|
45
|
+
Engine.prototype.init = function () {
|
46
|
+
this.workbench = new Workbench(this);
|
47
|
+
this.screen = new Screen(this);
|
48
|
+
this.cursor = new Cursor(this);
|
49
|
+
this.keyboard = new Keyboard(this);
|
50
|
+
};
|
51
|
+
Engine.prototype.setCurrentTree = function (tree) {
|
52
|
+
if (this.workbench.currentWorkspace) {
|
53
|
+
this.workbench.currentWorkspace.operation.tree.from(tree);
|
54
|
+
}
|
55
|
+
};
|
56
|
+
Engine.prototype.getCurrentTree = function () {
|
57
|
+
var _a, _b, _c;
|
58
|
+
return (_c = (_b = (_a = this.workbench) === null || _a === void 0 ? void 0 : _a.currentWorkspace) === null || _b === void 0 ? void 0 : _b.operation) === null || _c === void 0 ? void 0 : _c.tree;
|
59
|
+
};
|
60
|
+
Engine.prototype.getAllSelectedNodes = function () {
|
61
|
+
var results = [];
|
62
|
+
for (var i = 0; i < this.workbench.workspaces.length; i++) {
|
63
|
+
var workspace = this.workbench.workspaces[i];
|
64
|
+
results = results.concat(workspace.operation.selection.selectedNodes);
|
65
|
+
}
|
66
|
+
return results;
|
67
|
+
};
|
68
|
+
Engine.prototype.findNodeById = function (id) {
|
69
|
+
return TreeNode.findById(id);
|
70
|
+
};
|
71
|
+
Engine.prototype.findMovingNodes = function () {
|
72
|
+
var results = [];
|
73
|
+
this.workbench.eachWorkspace(function (workspace) {
|
74
|
+
var _a;
|
75
|
+
(_a = workspace.operation.moveHelper.dragNodes) === null || _a === void 0 ? void 0 : _a.forEach(function (node) {
|
76
|
+
if (!results.includes(node)) {
|
77
|
+
results.push(node);
|
78
|
+
}
|
79
|
+
});
|
80
|
+
});
|
81
|
+
return results;
|
82
|
+
};
|
83
|
+
Engine.prototype.createNode = function (node, parent) {
|
84
|
+
return new TreeNode(node, parent);
|
85
|
+
};
|
86
|
+
Engine.prototype.mount = function () {
|
87
|
+
this.attachEvents(globalThisPolyfill);
|
88
|
+
};
|
89
|
+
Engine.prototype.unmount = function () {
|
90
|
+
this.detachEvents();
|
91
|
+
};
|
92
|
+
Engine.defaultProps = {
|
93
|
+
shortcuts: [],
|
94
|
+
effects: [],
|
95
|
+
drivers: [],
|
96
|
+
rootComponentName: 'Root',
|
97
|
+
sourceIdAttrName: 'data-designer-source-id',
|
98
|
+
nodeIdAttrName: 'data-designer-node-id',
|
99
|
+
contentEditableAttrName: 'data-content-editable',
|
100
|
+
contentEditableNodeIdAttrName: 'data-content-editable-node-id',
|
101
|
+
clickStopPropagationAttrName: 'data-click-stop-propagation',
|
102
|
+
nodeSelectionIdAttrName: 'data-designer-node-helpers-id',
|
103
|
+
nodeDragHandlerAttrName: 'data-designer-node-drag-handler',
|
104
|
+
screenResizeHandlerAttrName: 'data-designer-screen-resize-handler',
|
105
|
+
nodeResizeHandlerAttrName: 'data-designer-node-resize-handler',
|
106
|
+
outlineNodeIdAttrName: 'data-designer-outline-node-id',
|
107
|
+
nodeTranslateAttrName: 'data-designer-node-translate-handler',
|
108
|
+
defaultScreenType: ScreenType.PC,
|
109
|
+
};
|
110
|
+
return Engine;
|
111
|
+
}(Event));
|
112
|
+
export { Engine };
|
@@ -0,0 +1,34 @@
|
|
1
|
+
export interface IHistoryProps<T> {
|
2
|
+
onPush?: (item: T) => void;
|
3
|
+
onRedo?: (item: T) => void;
|
4
|
+
onUndo?: (item: T) => void;
|
5
|
+
onGoto?: (item: T) => void;
|
6
|
+
}
|
7
|
+
export interface HistoryItem<T> {
|
8
|
+
data: T;
|
9
|
+
type?: string;
|
10
|
+
timestamp: number;
|
11
|
+
}
|
12
|
+
export interface ISerializable {
|
13
|
+
from(json: any): void;
|
14
|
+
serialize(): any;
|
15
|
+
}
|
16
|
+
export declare class History<T extends ISerializable = any> {
|
17
|
+
context: ISerializable;
|
18
|
+
props: IHistoryProps<HistoryItem<T>>;
|
19
|
+
current: number;
|
20
|
+
history: HistoryItem<T>[];
|
21
|
+
updateTimer: any;
|
22
|
+
maxSize: number;
|
23
|
+
locking: boolean;
|
24
|
+
constructor(context: T, props?: IHistoryProps<HistoryItem<T>>);
|
25
|
+
makeObservable(): void;
|
26
|
+
list(): HistoryItem<T>[];
|
27
|
+
push(type?: string): void;
|
28
|
+
get allowUndo(): boolean;
|
29
|
+
get allowRedo(): boolean;
|
30
|
+
redo(): void;
|
31
|
+
undo(): void;
|
32
|
+
goTo(index: number): void;
|
33
|
+
clear(): void;
|
34
|
+
}
|
@@ -0,0 +1,110 @@
|
|
1
|
+
import { define, observable, action } from '@formily/reactive';
|
2
|
+
var History = /** @class */ (function () {
|
3
|
+
function History(context, props) {
|
4
|
+
this.current = 0;
|
5
|
+
this.history = [];
|
6
|
+
this.updateTimer = null;
|
7
|
+
this.maxSize = 100;
|
8
|
+
this.locking = false;
|
9
|
+
this.context = context;
|
10
|
+
this.props = props;
|
11
|
+
this.push();
|
12
|
+
this.makeObservable();
|
13
|
+
}
|
14
|
+
History.prototype.makeObservable = function () {
|
15
|
+
define(this, {
|
16
|
+
current: observable.ref,
|
17
|
+
history: observable.shallow,
|
18
|
+
push: action,
|
19
|
+
undo: action,
|
20
|
+
redo: action,
|
21
|
+
goTo: action,
|
22
|
+
clear: action,
|
23
|
+
});
|
24
|
+
};
|
25
|
+
History.prototype.list = function () {
|
26
|
+
return this.history;
|
27
|
+
};
|
28
|
+
History.prototype.push = function (type) {
|
29
|
+
var _a;
|
30
|
+
if (this.locking)
|
31
|
+
return;
|
32
|
+
if (this.current < this.history.length - 1) {
|
33
|
+
this.history = this.history.slice(0, this.current + 1);
|
34
|
+
}
|
35
|
+
var item = {
|
36
|
+
data: this.context.serialize(),
|
37
|
+
timestamp: Date.now(),
|
38
|
+
type: type,
|
39
|
+
};
|
40
|
+
this.current = this.history.length;
|
41
|
+
this.history.push(item);
|
42
|
+
var overSizeCount = this.history.length - this.maxSize;
|
43
|
+
if (overSizeCount > 0) {
|
44
|
+
this.history.splice(0, overSizeCount);
|
45
|
+
this.current = this.history.length - 1;
|
46
|
+
}
|
47
|
+
if ((_a = this.props) === null || _a === void 0 ? void 0 : _a.onPush) {
|
48
|
+
this.props.onPush(item);
|
49
|
+
}
|
50
|
+
};
|
51
|
+
Object.defineProperty(History.prototype, "allowUndo", {
|
52
|
+
get: function () {
|
53
|
+
return this.history.length > 0 && this.current - 1 >= 0;
|
54
|
+
},
|
55
|
+
enumerable: false,
|
56
|
+
configurable: true
|
57
|
+
});
|
58
|
+
Object.defineProperty(History.prototype, "allowRedo", {
|
59
|
+
get: function () {
|
60
|
+
return this.history.length > this.current + 1;
|
61
|
+
},
|
62
|
+
enumerable: false,
|
63
|
+
configurable: true
|
64
|
+
});
|
65
|
+
History.prototype.redo = function () {
|
66
|
+
var _a;
|
67
|
+
if (this.allowRedo) {
|
68
|
+
var item = this.history[this.current + 1];
|
69
|
+
this.locking = true;
|
70
|
+
this.context.from(item.data);
|
71
|
+
this.locking = false;
|
72
|
+
this.current++;
|
73
|
+
if ((_a = this.props) === null || _a === void 0 ? void 0 : _a.onRedo) {
|
74
|
+
this.props.onRedo(item);
|
75
|
+
}
|
76
|
+
}
|
77
|
+
};
|
78
|
+
History.prototype.undo = function () {
|
79
|
+
var _a;
|
80
|
+
if (this.allowUndo) {
|
81
|
+
var item = this.history[this.current - 1];
|
82
|
+
this.locking = true;
|
83
|
+
this.context.from(item.data);
|
84
|
+
this.locking = false;
|
85
|
+
this.current--;
|
86
|
+
if ((_a = this.props) === null || _a === void 0 ? void 0 : _a.onUndo) {
|
87
|
+
this.props.onUndo(item);
|
88
|
+
}
|
89
|
+
}
|
90
|
+
};
|
91
|
+
History.prototype.goTo = function (index) {
|
92
|
+
var _a;
|
93
|
+
var item = this.history[index];
|
94
|
+
if (item) {
|
95
|
+
this.locking = true;
|
96
|
+
this.context.from(item.data);
|
97
|
+
this.locking = false;
|
98
|
+
this.current = index;
|
99
|
+
if ((_a = this.props) === null || _a === void 0 ? void 0 : _a.onGoto) {
|
100
|
+
this.props.onGoto(item);
|
101
|
+
}
|
102
|
+
}
|
103
|
+
};
|
104
|
+
History.prototype.clear = function () {
|
105
|
+
this.history = [];
|
106
|
+
this.current = 0;
|
107
|
+
};
|
108
|
+
return History;
|
109
|
+
}());
|
110
|
+
export { History };
|