@likec4/diagram 1.45.0 → 1.46.2
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/bundle/index.js +2488 -1959
- package/dist/LikeC4Diagram.d.ts +1 -1
- package/dist/LikeC4Diagram.js +8 -7
- package/dist/LikeC4Diagram.props.d.ts +4 -12
- package/dist/LikeC4ProjectsProvider.js +8 -4
- package/dist/LikeC4View.js +1 -5
- package/dist/ReactLikeC4.d.ts +1 -4
- package/dist/StaticLikeC4Diagram.js +0 -2
- package/dist/base-primitives/NodeHandles.d.ts +2 -1
- package/dist/base-primitives/NodeHandles.js +22 -18
- package/dist/base-primitives/compound/CompoundActionButton.js +1 -1
- package/dist/base-primitives/compound/CompoundDetailsButton.js +1 -1
- package/dist/base-primitives/edge/EdgeActionButton.js +1 -1
- package/dist/base-primitives/edge/EdgeContainer.d.ts +1 -1
- package/dist/base-primitives/edge/EdgeContainer.js +2 -3
- package/dist/base-primitives/edge/EdgeLabel.js +16 -16
- package/dist/base-primitives/edge/EdgeLabelContainer.d.ts +1 -1
- package/dist/base-primitives/edge/EdgeLabelContainer.js +5 -4
- package/dist/base-primitives/edge/EdgePath.js +13 -18
- package/dist/base-primitives/element/ElementActionButtons.js +1 -1
- package/dist/base-primitives/element/ElementDetailsButton.js +1 -1
- package/dist/base-primitives/memoNode.js +1 -1
- package/dist/components/ErrorFallback.js +1 -1
- package/dist/components/Link.js +2 -2
- package/dist/context/DiagramEventHandlers.js +0 -1
- package/dist/context/DiagramFeatures.d.ts +1 -1
- package/dist/context/DiagramFeatures.js +1 -0
- package/dist/context/EnsureMantine.js +2 -1
- package/dist/context/IconRenderer.js +6 -6
- package/dist/editor/LikeC4EditorProvider.d.ts +22 -0
- package/dist/editor/LikeC4EditorProvider.js +12 -0
- package/dist/editor/__tests__/fixture.d.ts +205 -0
- package/dist/editor/applyChangesToManualLayout.d.ts +8 -0
- package/dist/editor/applyChangesToManualLayout.js +182 -0
- package/dist/editor/editorActor.actions.d.ts +201 -0
- package/dist/editor/editorActor.actions.js +149 -0
- package/dist/editor/editorActor.d.ts +653 -0
- package/dist/editor/editorActor.js +324 -0
- package/dist/editor/hotkeyActor.d.ts +7 -0
- package/dist/editor/hotkeyActor.js +19 -0
- package/dist/editor/index.d.ts +3 -2
- package/dist/editor/useEditorActorLogic.d.ts +565 -0
- package/dist/editor/useEditorActorLogic.js +54 -0
- package/dist/hooks/safeContext.d.ts +3 -2
- package/dist/hooks/safeContext.js +7 -4
- package/dist/hooks/useDiagram.d.ts +4 -2
- package/dist/hooks/useDiagram.js +19 -8
- package/dist/hooks/useDiagramCompareLayout.d.ts +8 -0
- package/dist/hooks/useDiagramCompareLayout.js +22 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/likec4diagram/DiagramXYFlow.js +1 -2
- package/dist/likec4diagram/custom/edges/EdgeDrifts.js +1 -5
- package/dist/likec4diagram/custom/edges/RelationshipEdge.js +74 -48
- package/dist/likec4diagram/custom/edges/edges.css.d.ts +0 -1
- package/dist/likec4diagram/custom/edges/edges.css.js +30 -24
- package/dist/likec4diagram/custom/edges/useControlPoints.js +2 -2
- package/dist/likec4diagram/custom/nodes/ElementActions.js +2 -2
- package/dist/likec4diagram/custom/nodes/NodeDrifts.js +4 -9
- package/dist/likec4diagram/custom/nodes/nodes.js +3 -6
- package/dist/likec4diagram/custom/nodes/toolbar/ElementToolbar.js +2 -2
- package/dist/likec4diagram/custom/nodes/toolbar/_shared.js +2 -2
- package/dist/likec4diagram/relationship-popover/RelationshipPopover.js +127 -14
- package/dist/likec4diagram/state/DiagramActorProvider.js +63 -71
- package/dist/likec4diagram/state/assign.d.ts +4 -1
- package/dist/likec4diagram/state/assign.js +11 -8
- package/dist/likec4diagram/state/createViewChange.js +13 -9
- package/dist/likec4diagram/state/diagram-api.d.ts +20 -2
- package/dist/likec4diagram/state/diagram-api.js +58 -44
- package/dist/likec4diagram/state/hotkeyActor.d.ts +1 -1
- package/dist/likec4diagram/state/hotkeyActor.js +12 -0
- package/dist/likec4diagram/state/machine.actions.d.ts +774 -195
- package/dist/likec4diagram/state/machine.actions.js +185 -74
- package/dist/likec4diagram/state/machine.actions.layout.d.ts +93 -31
- package/dist/likec4diagram/state/machine.actions.layout.js +16 -4
- package/dist/likec4diagram/state/machine.d.ts +5 -4
- package/dist/likec4diagram/state/machine.js +11 -6
- package/dist/likec4diagram/state/machine.setup.d.ts +20 -9
- package/dist/likec4diagram/state/machine.setup.js +18 -3
- package/dist/likec4diagram/state/machine.state.initializing.d.ts +34 -18
- package/dist/likec4diagram/state/machine.state.initializing.js +10 -10
- package/dist/likec4diagram/state/machine.state.navigating.js +28 -9
- package/dist/likec4diagram/state/machine.state.ready.d.ts +1368 -434
- package/dist/likec4diagram/state/machine.state.ready.focused.d.ts +363 -39
- package/dist/likec4diagram/state/machine.state.ready.focused.js +17 -4
- package/dist/likec4diagram/state/machine.state.ready.idle.d.ts +104 -38
- package/dist/likec4diagram/state/machine.state.ready.idle.js +14 -5
- package/dist/likec4diagram/state/machine.state.ready.js +13 -90
- package/dist/likec4diagram/state/machine.state.ready.printing.d.ts +18 -6
- package/dist/likec4diagram/state/machine.state.ready.walkthrough.d.ts +204 -31
- package/dist/likec4diagram/state/machine.state.ready.walkthrough.js +14 -1
- package/dist/likec4diagram/state/types.d.ts +6 -2
- package/dist/likec4diagram/state/utils.d.ts +33 -7
- package/dist/likec4diagram/state/utils.js +23 -7
- package/dist/likec4diagram/ui/notation/NotationPanel.js +3 -3
- package/dist/likec4diagram/useLayoutConstraints.js +5 -9
- package/dist/navigationpanel/NavigationPanel.js +6 -9
- package/dist/navigationpanel/NavigationPanelDropdown.js +7 -7
- package/dist/navigationpanel/_common.js +1 -1
- package/dist/navigationpanel/comparepanel/CompareActionsMenu.d.ts +3 -1
- package/dist/navigationpanel/comparepanel/CompareActionsMenu.js +40 -14
- package/dist/navigationpanel/comparepanel/ComparePanelControls.js +6 -4
- package/dist/navigationpanel/comparepanel/LayoutTypeSwitcher.js +2 -2
- package/dist/navigationpanel/controls/DetailsControls.js +2 -2
- package/dist/navigationpanel/controls/LayoutWarning.js +2 -1
- package/dist/navigationpanel/controls/NavigationButtons.js +2 -2
- package/dist/navigationpanel/controls/OpenSource.js +1 -1
- package/dist/navigationpanel/controls/SearchControl.js +2 -2
- package/dist/navigationpanel/controls/ToggleReadonly.js +25 -17
- package/dist/navigationpanel/dropdown/ProjectsMenu.js +1 -1
- package/dist/navigationpanel/editorpanel/CenterCamera.js +1 -1
- package/dist/navigationpanel/editorpanel/ChangeAutoLayoutButton.js +1 -1
- package/dist/navigationpanel/editorpanel/ManualLayoutToolsButton.js +9 -9
- package/dist/navigationpanel/editorpanel/ToggleReadonly.js +1 -1
- package/dist/navigationpanel/walkthrough/ActiveWalkthroughControls.js +3 -3
- package/dist/navigationpanel/walkthrough/DynamicViewControls.d.ts +66 -66
- package/dist/navigationpanel/walkthrough/DynamicViewControls.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/createReactComponent.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/defaultAttributes.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconAlertTriangle.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowDownRight.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowLeft.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowRight.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconBolt.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconBrowser.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconCheck.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronDown.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronLeft.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronRight.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconCopy.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconCylinder.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconDeviceMobile.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconDirectionSignFilled.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconExternalLink.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconFileSymlink.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconFocusCentered.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconFolderFilled.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconHelpCircle.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconId.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconInfoCircle.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignBottom.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignCenter.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignLeft.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignMiddle.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignRight.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignTop.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutBoardSplit.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutCollage.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutDashboard.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconLink.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconLock.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconLockOpen2.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconPlayerPlayFilled.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconPlayerSkipBackFilled.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconPlayerSkipForwardFilled.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconPlayerStopFilled.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconRectangularPrism.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconReorder.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconRouteOff.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconSearch.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconSelector.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconStack2.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconStarFilled.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconTarget.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconTransform.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconUser.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconX.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconZoomScan.js +1 -1
- package/dist/overlays/Overlays.js +23 -11
- package/dist/overlays/element-details/ElementDetailsCard.css.js +8 -11
- package/dist/overlays/element-details/ElementDetailsCard.js +4 -4
- package/dist/overlays/element-details/MetadataValue.js +4 -6
- package/dist/overlays/element-details/TabPanelDeployments.js +3 -3
- package/dist/overlays/element-details/TabPanelRelationships.js +12 -7
- package/dist/overlays/element-details/TabPanelStructure.js +1 -1
- package/dist/overlays/overlaysActor.js +6 -5
- package/dist/overlays/relationship-details/RelationshipDetails.js +3 -3
- package/dist/overlays/relationship-details/SelectEdge.js +2 -2
- package/dist/overlays/relationship-details/custom/ElementActions.js +3 -3
- package/dist/overlays/relationships-browser/RelationshipsBrowser.js +3 -3
- package/dist/overlays/relationships-browser/SelectElement.js +2 -2
- package/dist/overlays/relationships-browser/custom/ElementActions.js +3 -3
- package/dist/search/components/ElementsColumn.js +16 -11
- package/dist/search/components/PickView.js +3 -1
- package/dist/search/components/SearchByTags.js +1 -1
- package/dist/search/components/SearchInput.js +1 -1
- package/dist/search/components/ViewsColum.d.ts +3 -1
- package/dist/search/components/ViewsColum.js +14 -9
- package/dist/search/components/utils.d.ts +6 -0
- package/dist/search/components/utils.js +4 -1
- package/dist/shadowroot/styles.css.js +6 -1
- package/dist/styles.css2.js +1 -1
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/xyflow.d.ts +2 -3
- package/dist/utils/xyflow.js +9 -8
- package/package.json +22 -22
- package/panda.buildinfo.json +61 -80
- package/styles-min.css +1 -1
- package/styles.css +1 -1
- package/dist/base-primitives/edge/edge.css.d.ts +0 -4
- package/dist/base-primitives/edge/edge.css.js +0 -71
- package/dist/editor/LikeC4EditorContext.d.ts +0 -21
- package/dist/likec4diagram/state/syncManualLayoutActor.d.ts +0 -46
- package/dist/likec4diagram/state/syncManualLayoutActor.js +0 -309
- package/dist/utils/vector.d.ts +0 -86
- package/dist/utils/vector.js +0 -127
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import { find } from 'remeda';
|
|
2
|
+
import { setup, assign, fromPromise, enqueueActions, sendTo, log } from 'xstate';
|
|
3
|
+
import { cancelSync, stopHotkey, undo, markHistoryAsSynched, reschedule, isLayoutChange, withoutSnapshotChanges, addSnapshotToPendingChanges, ensureHotKey, pushHistory, saveStateBeforeEdit, stopEditing, startEditing } from './editorActor.actions.js';
|
|
4
|
+
import { hotkeyActorLogic } from './hotkeyActor.js';
|
|
5
|
+
|
|
6
|
+
const applyLatest = fromPromise(
|
|
7
|
+
() => {
|
|
8
|
+
throw new Error("Not implemented");
|
|
9
|
+
}
|
|
10
|
+
);
|
|
11
|
+
const executeChange = fromPromise(
|
|
12
|
+
() => {
|
|
13
|
+
throw new Error("Not implemented");
|
|
14
|
+
}
|
|
15
|
+
);
|
|
16
|
+
const diagramActorRef = function(params) {
|
|
17
|
+
return params.system.get("diagram");
|
|
18
|
+
};
|
|
19
|
+
const machine = setup({
|
|
20
|
+
types: {
|
|
21
|
+
context: {},
|
|
22
|
+
events: {},
|
|
23
|
+
emitted: {},
|
|
24
|
+
input: {},
|
|
25
|
+
children: {},
|
|
26
|
+
tags: {}
|
|
27
|
+
},
|
|
28
|
+
delays: {
|
|
29
|
+
"350ms": 350,
|
|
30
|
+
"waitBeforeSync": 2e3
|
|
31
|
+
},
|
|
32
|
+
actors: {
|
|
33
|
+
applyLatest,
|
|
34
|
+
executeChange,
|
|
35
|
+
hotkey: hotkeyActorLogic
|
|
36
|
+
},
|
|
37
|
+
guards: {
|
|
38
|
+
"has pending": ({ context }) => context.pendingChanges.length > 0,
|
|
39
|
+
"can undo": ({ context }) => context.history.length > 0
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
const to = {
|
|
43
|
+
idle: { target: "#idle" },
|
|
44
|
+
editing: { target: "#editing" },
|
|
45
|
+
afterEdit: { target: "#afterEdit" },
|
|
46
|
+
pending: { target: "#pending" },
|
|
47
|
+
applyLatestToManual: { target: "#applyLatestToManual" },
|
|
48
|
+
executeChanges: { target: "#executeChanges" }
|
|
49
|
+
};
|
|
50
|
+
const idle = machine.createStateConfig({
|
|
51
|
+
id: "idle",
|
|
52
|
+
on: {
|
|
53
|
+
"sync": {
|
|
54
|
+
...to.pending
|
|
55
|
+
},
|
|
56
|
+
"edit.start": {
|
|
57
|
+
...to.editing
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
const editing = machine.createStateConfig({
|
|
62
|
+
id: "editing",
|
|
63
|
+
tags: "pending",
|
|
64
|
+
entry: [
|
|
65
|
+
startEditing(),
|
|
66
|
+
cancelSync()
|
|
67
|
+
],
|
|
68
|
+
on: {
|
|
69
|
+
change: {
|
|
70
|
+
actions: stopEditing(),
|
|
71
|
+
...to.executeChanges
|
|
72
|
+
},
|
|
73
|
+
"edit.finish": {
|
|
74
|
+
actions: stopEditing(),
|
|
75
|
+
...to.afterEdit
|
|
76
|
+
},
|
|
77
|
+
"undo": {
|
|
78
|
+
actions: stopEditing(),
|
|
79
|
+
...to.idle
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
const pending = machine.createStateConfig({
|
|
84
|
+
id: "pending",
|
|
85
|
+
tags: ["pending"],
|
|
86
|
+
entry: ensureHotKey(),
|
|
87
|
+
on: {
|
|
88
|
+
"sync": {
|
|
89
|
+
reenter: true,
|
|
90
|
+
...to.pending
|
|
91
|
+
},
|
|
92
|
+
"edit.start": {
|
|
93
|
+
// this allows to return back from editing in afterEdit state
|
|
94
|
+
actions: [
|
|
95
|
+
addSnapshotToPendingChanges()
|
|
96
|
+
],
|
|
97
|
+
...to.editing
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
after: {
|
|
101
|
+
"waitBeforeSync": {
|
|
102
|
+
actions: [
|
|
103
|
+
addSnapshotToPendingChanges()
|
|
104
|
+
],
|
|
105
|
+
...to.executeChanges
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
const afterEdit = machine.createStateConfig({
|
|
110
|
+
id: "afterEdit",
|
|
111
|
+
always: [
|
|
112
|
+
{ guard: "has pending", ...to.pending },
|
|
113
|
+
{ ...to.idle }
|
|
114
|
+
]
|
|
115
|
+
});
|
|
116
|
+
const applyLatestToManual = machine.createStateConfig({
|
|
117
|
+
id: "applyLatestToManual",
|
|
118
|
+
entry: [
|
|
119
|
+
cancelSync(),
|
|
120
|
+
saveStateBeforeEdit()
|
|
121
|
+
],
|
|
122
|
+
initial: "call",
|
|
123
|
+
on: {
|
|
124
|
+
// catch all events
|
|
125
|
+
"*": {
|
|
126
|
+
actions: [
|
|
127
|
+
log(({ event }) => `applyLatestToManual received unexpected event: ${event.type}`),
|
|
128
|
+
reschedule(350)
|
|
129
|
+
]
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
states: {
|
|
133
|
+
// Fetch latest and manual layouts
|
|
134
|
+
// Apply changes, send update to diagram
|
|
135
|
+
call: {
|
|
136
|
+
invoke: {
|
|
137
|
+
src: "applyLatest",
|
|
138
|
+
input: ({ context }) => {
|
|
139
|
+
const current = context.beforeEditing?.change.layout;
|
|
140
|
+
return {
|
|
141
|
+
current: current && current._layout === "manual" ? current : void 0,
|
|
142
|
+
viewId: context.viewId
|
|
143
|
+
};
|
|
144
|
+
},
|
|
145
|
+
onDone: {
|
|
146
|
+
actions: sendTo(
|
|
147
|
+
diagramActorRef,
|
|
148
|
+
({ event }) => ({
|
|
149
|
+
type: "update.view",
|
|
150
|
+
view: event.output.updated
|
|
151
|
+
}),
|
|
152
|
+
{ delay: 10 }
|
|
153
|
+
),
|
|
154
|
+
target: "wait"
|
|
155
|
+
},
|
|
156
|
+
onError: {
|
|
157
|
+
actions: [
|
|
158
|
+
assign({
|
|
159
|
+
beforeEditing: null,
|
|
160
|
+
pendingChanges: []
|
|
161
|
+
}),
|
|
162
|
+
({ event }) => {
|
|
163
|
+
console.error(event.error);
|
|
164
|
+
}
|
|
165
|
+
],
|
|
166
|
+
...to.idle
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
// Now we wait 350ms, take new snapshot and send save-view-snapshot
|
|
171
|
+
wait: {
|
|
172
|
+
entry: pushHistory(),
|
|
173
|
+
after: {
|
|
174
|
+
"350ms": {
|
|
175
|
+
actions: [
|
|
176
|
+
addSnapshotToPendingChanges(),
|
|
177
|
+
ensureHotKey()
|
|
178
|
+
],
|
|
179
|
+
...to.executeChanges
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
const executeChanges = machine.createStateConfig({
|
|
186
|
+
id: "executeChanges",
|
|
187
|
+
entry: [
|
|
188
|
+
assign(({ event, context }) => {
|
|
189
|
+
if (event.type === "change") {
|
|
190
|
+
if (isLayoutChange(event.change)) {
|
|
191
|
+
return {
|
|
192
|
+
pendingChanges: [
|
|
193
|
+
...withoutSnapshotChanges(context.pendingChanges),
|
|
194
|
+
event.change
|
|
195
|
+
]
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
if (!context.pendingChanges.includes(event.change)) {
|
|
199
|
+
return {
|
|
200
|
+
pendingChanges: [
|
|
201
|
+
...context.pendingChanges,
|
|
202
|
+
event.change
|
|
203
|
+
]
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return {};
|
|
208
|
+
}),
|
|
209
|
+
cancelSync()
|
|
210
|
+
],
|
|
211
|
+
invoke: {
|
|
212
|
+
src: "executeChange",
|
|
213
|
+
input: ({ context }) => ({
|
|
214
|
+
changes: context.pendingChanges,
|
|
215
|
+
viewId: context.viewId
|
|
216
|
+
}),
|
|
217
|
+
onDone: {
|
|
218
|
+
actions: enqueueActions(({ context, enqueue }) => {
|
|
219
|
+
const snapshot = find(context.pendingChanges, (c) => c.op === "save-view-snapshot");
|
|
220
|
+
if (snapshot) {
|
|
221
|
+
enqueue.sendTo(
|
|
222
|
+
diagramActorRef,
|
|
223
|
+
{
|
|
224
|
+
type: "update.view-bounds",
|
|
225
|
+
bounds: snapshot.layout.bounds
|
|
226
|
+
}
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
enqueue.assign({
|
|
230
|
+
pendingChanges: []
|
|
231
|
+
});
|
|
232
|
+
}),
|
|
233
|
+
...to.idle
|
|
234
|
+
},
|
|
235
|
+
onError: {
|
|
236
|
+
actions: ({ event }) => {
|
|
237
|
+
console.error(event.error);
|
|
238
|
+
},
|
|
239
|
+
...to.afterEdit
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
on: {
|
|
243
|
+
"*": {
|
|
244
|
+
actions: reschedule()
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
const _editorActorLogic = machine.createMachine({
|
|
249
|
+
id: "editor",
|
|
250
|
+
context: ({ input }) => ({
|
|
251
|
+
viewId: input.viewId,
|
|
252
|
+
beforeEditing: null,
|
|
253
|
+
editing: null,
|
|
254
|
+
pendingChanges: [],
|
|
255
|
+
history: []
|
|
256
|
+
}),
|
|
257
|
+
initial: "idle",
|
|
258
|
+
// TODO: listen to diagram actor, if switches to "sequence" dynamic view, cancel editing
|
|
259
|
+
// entry: ({ self, system }) => {
|
|
260
|
+
// // let previous = ''
|
|
261
|
+
// // const a = (self._parent as DiagramMachineRef).subscribe({
|
|
262
|
+
// // next({ context }) {
|
|
263
|
+
// // const current = context.view._type === 'dynamic' ? context.dynamicViewVariant
|
|
264
|
+
// // },
|
|
265
|
+
// // })
|
|
266
|
+
// const s = self.subscribe({
|
|
267
|
+
// complete: () => {
|
|
268
|
+
// console.log('editor actor completed')
|
|
269
|
+
// s.unsubscribe()
|
|
270
|
+
// },
|
|
271
|
+
// })
|
|
272
|
+
// },
|
|
273
|
+
states: {
|
|
274
|
+
idle,
|
|
275
|
+
editing,
|
|
276
|
+
pending,
|
|
277
|
+
afterEdit,
|
|
278
|
+
applyLatestToManual,
|
|
279
|
+
executeChanges
|
|
280
|
+
},
|
|
281
|
+
on: {
|
|
282
|
+
cancel: {
|
|
283
|
+
actions: [
|
|
284
|
+
cancelSync(),
|
|
285
|
+
assign({
|
|
286
|
+
editing: null,
|
|
287
|
+
beforeEditing: null,
|
|
288
|
+
pendingChanges: []
|
|
289
|
+
})
|
|
290
|
+
],
|
|
291
|
+
...to.idle
|
|
292
|
+
},
|
|
293
|
+
synced: {
|
|
294
|
+
actions: markHistoryAsSynched()
|
|
295
|
+
},
|
|
296
|
+
undo: {
|
|
297
|
+
guard: "can undo",
|
|
298
|
+
actions: undo(),
|
|
299
|
+
...to.idle
|
|
300
|
+
},
|
|
301
|
+
change: {
|
|
302
|
+
...to.executeChanges
|
|
303
|
+
},
|
|
304
|
+
"applyLatestToManual": {
|
|
305
|
+
...to.applyLatestToManual
|
|
306
|
+
},
|
|
307
|
+
reset: {
|
|
308
|
+
actions: [
|
|
309
|
+
cancelSync(),
|
|
310
|
+
assign({
|
|
311
|
+
history: [],
|
|
312
|
+
editing: null,
|
|
313
|
+
beforeEditing: null,
|
|
314
|
+
pendingChanges: []
|
|
315
|
+
}),
|
|
316
|
+
stopHotkey()
|
|
317
|
+
],
|
|
318
|
+
...to.idle
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
const editorActorLogic = _editorActorLogic;
|
|
323
|
+
|
|
324
|
+
export { editorActorLogic, machine };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AnyEventObject, CallbackActorLogic, NonReducibleUnknown } from 'xstate';
|
|
2
|
+
export type HotKeyEvent = {
|
|
3
|
+
type: 'undo';
|
|
4
|
+
};
|
|
5
|
+
export interface HotkeyActorLogic extends CallbackActorLogic<AnyEventObject, NonReducibleUnknown, HotKeyEvent> {
|
|
6
|
+
}
|
|
7
|
+
export declare const hotkeyActorLogic: HotkeyActorLogic;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getHotkeyHandler } from '@mantine/hooks';
|
|
2
|
+
import { fromCallback } from 'xstate';
|
|
3
|
+
|
|
4
|
+
const hotkeyActorLogic = fromCallback(({ sendBack }) => {
|
|
5
|
+
const ctrlZHandler = getHotkeyHandler([
|
|
6
|
+
["mod + z", (event) => {
|
|
7
|
+
event.stopPropagation();
|
|
8
|
+
sendBack({ type: "undo" });
|
|
9
|
+
}, {
|
|
10
|
+
preventDefault: true
|
|
11
|
+
}]
|
|
12
|
+
]);
|
|
13
|
+
document.body.addEventListener("keydown", ctrlZHandler, { capture: true });
|
|
14
|
+
return () => {
|
|
15
|
+
document.body.removeEventListener("keydown", ctrlZHandler, { capture: true });
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export { hotkeyActorLogic };
|
package/dist/editor/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export { EnsureEditorContext,
|
|
2
|
-
export type {
|
|
1
|
+
export { EnsureEditorContext, LikeC4EditorProvider, useOptionalLikeC4EditorPort, } from './LikeC4EditorProvider';
|
|
2
|
+
export type { LikeC4EditorPort } from './LikeC4EditorProvider';
|
|
3
|
+
export type * from './editorActor';
|