@likec4/diagram 1.56.0 → 1.58.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/LikeC4Diagram.js +3 -1
- package/dist/LikeC4View.js +47 -55
- package/dist/adhoc-editor/EditorPanel.d.ts +1 -1
- package/dist/adhoc-editor/ElementsTree.d.ts +1 -1
- package/dist/adhoc-editor/ElementsTree.js +2 -6
- package/dist/adhoc-editor/LikeC4AdHocViewEditor.d.ts +1 -1
- package/dist/adhoc-editor/components/Tree.d.ts +5 -5
- package/dist/adhoc-editor/state/ActorProvider.d.ts +1 -1
- package/dist/adhoc-editor/state/panel.d.ts +1 -1
- package/dist/adhoc-editor/viewrules/ViewRulesPanel.d.ts +1 -1
- package/dist/base/BaseXYFlow.d.ts +1 -1
- package/dist/base-primitives/Markdown.d.ts +1 -1
- package/dist/base-primitives/NodeHandles.d.ts +1 -1
- package/dist/base-primitives/compound/CompoundActionButton.d.ts +1 -1
- package/dist/base-primitives/compound/CompoundDetailsButton.d.ts +1 -1
- package/dist/base-primitives/compound/CompoundNodeContainer.d.ts +1 -1
- package/dist/base-primitives/compound/CompoundTitle.d.ts +1 -1
- package/dist/base-primitives/compound/actionbtns.css.d.ts +1 -1
- package/dist/base-primitives/edge/EdgeActionButton.d.ts +1 -1
- package/dist/base-primitives/edge/EdgeContainer.d.ts +1 -1
- package/dist/base-primitives/edge/EdgeLabelContainer.d.ts +1 -1
- package/dist/base-primitives/edge/EdgeMarkers.d.ts +8 -8
- package/dist/base-primitives/element/ElementActionButtons.d.ts +1 -1
- package/dist/base-primitives/element/ElementData.d.ts +2 -2
- package/dist/base-primitives/element/ElementDetailsButton.d.ts +1 -1
- package/dist/base-primitives/element/ElementShape.d.ts +1 -1
- package/dist/base-primitives/element/ElementTags.d.ts +1 -1
- package/dist/base-primitives/element/ElementTags.js +1 -3
- package/dist/components/ErrorFallback.d.ts +2 -2
- package/dist/components/NavigationPanel.d.ts +2 -2
- package/dist/components/PortalToContainer.d.ts +1 -1
- package/dist/components/RootContainer.d.ts +1 -1
- package/dist/components/RootContainer.js +19 -18
- package/dist/components/SearchControl.d.ts +2 -2
- package/dist/components/ViewNotFound.d.ts +2 -2
- package/dist/context/CurrentViewModelProvider.d.ts +1 -1
- package/dist/context/DefaultMantineProvider.d.ts +1 -1
- package/dist/context/DiagramEventHandlers.d.ts +1 -1
- package/dist/context/DiagramFeatures.d.ts +1 -1
- package/dist/context/DiagramFeatures.js +5 -0
- package/dist/context/EnsureMantine.d.ts +1 -1
- package/dist/context/FramerMotionConfig.d.ts +3 -3
- package/dist/context/FramerMotionConfig.js +2 -2
- package/dist/context/IconRenderer.d.ts +2 -2
- package/dist/context/IconRenderer.js +32 -12
- package/dist/context/LikeC4ModelContext.d.ts +1 -1
- package/dist/context/RootContainerContext.d.ts +10 -17
- package/dist/context/RootContainerContext.js +1 -13
- package/dist/context/ShadowRootContext.d.ts +3 -0
- package/dist/context/ShadowRootContext.js +5 -0
- package/dist/context/TagStylesContext.d.ts +2 -1
- package/dist/context/TagStylesContext.js +5 -7
- package/dist/custom/index.d.ts +1 -1
- package/dist/custom/index.js +1 -2
- package/dist/editor/LikeC4EditorCallbacks.d.ts +5 -0
- package/dist/editor/LikeC4EditorProvider.d.ts +2 -2
- package/dist/editor/actor/actions.d.ts +174 -0
- package/dist/editor/actor/actions.js +188 -0
- package/dist/editor/{hotkeyActor.d.ts → actor/hotkey.d.ts} +2 -2
- package/dist/editor/{hotkeyActor.js → actor/hotkey.js} +11 -4
- package/dist/editor/{editorActor.states.d.ts → actor/machine.d.ts} +5 -3
- package/dist/editor/actor/machine.js +23 -0
- package/dist/editor/actor/setup.d.ts +55 -0
- package/dist/editor/{editorActor.setup.js → actor/setup.js} +14 -10
- package/dist/editor/actor/state.editor.d.ts +147 -0
- package/dist/editor/actor/state.editor.js +56 -0
- package/dist/editor/actor/state.sync-queue.d.ts +612 -0
- package/dist/editor/actor/state.sync-queue.js +272 -0
- package/dist/editor/actor/types.d.ts +64 -0
- package/dist/editor/actor/types.js +5 -0
- package/dist/editor/applyChangesToManualLayout.js +1 -1
- package/dist/editor/index.d.ts +2 -1
- package/dist/editor/useEditorActorLogic.d.ts +8 -2
- package/dist/editor/useEditorActorLogic.js +39 -7
- package/dist/hooks/useDiagram.js +6 -1
- package/dist/hooks/useDiagramCompareLayout.js +1 -1
- package/dist/hooks/useEditorActor.d.ts +9 -0
- package/dist/hooks/useEditorActor.js +27 -0
- package/dist/hooks/useLikeC4ElementsTree.d.ts +3 -2
- package/dist/hooks/useLikeC4ElementsTree.js +3 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -1
- package/dist/likec4diagram/DiagramUI.d.ts +1 -1
- package/dist/likec4diagram/DiagramUI.js +8 -4
- package/dist/likec4diagram/DiagramXYFlow.js +26 -14
- package/dist/likec4diagram/custom/edges/EdgeDrifts.d.ts +1 -1
- package/dist/likec4diagram/custom/edges/RelationshipEdge.js +127 -14
- package/dist/likec4diagram/custom/edges/SequenceStepEdge.d.ts +1 -1
- package/dist/likec4diagram/custom/edges/edges.css.d.ts +1 -0
- package/dist/likec4diagram/custom/edges/edges.css.js +5 -1
- package/dist/likec4diagram/custom/nodes/CompoundActions.d.ts +1 -1
- package/dist/likec4diagram/custom/nodes/ElementActions.d.ts +2 -2
- package/dist/likec4diagram/custom/nodes/NodeDrifts.d.ts +1 -1
- package/dist/likec4diagram/custom/nodes/NodeNotes.d.ts +1 -1
- package/dist/likec4diagram/custom/nodes/SequenceActorNode.d.ts +2 -2
- package/dist/likec4diagram/custom/nodes/nodes.d.ts +7 -7
- package/dist/likec4diagram/custom/nodes/toolbar/ColorButton.d.ts +3 -3
- package/dist/likec4diagram/custom/nodes/toolbar/CompoundToolbar.d.ts +2 -2
- package/dist/likec4diagram/custom/nodes/toolbar/ElementToolbar.d.ts +2 -2
- package/dist/likec4diagram/custom/nodes/toolbar/Toolbar.d.ts +1 -1
- package/dist/likec4diagram/custom/nodes/toolbar/_shared.d.ts +3 -3
- package/dist/likec4diagram/relationship-popover/RelationshipPopover.d.ts +1 -1
- package/dist/likec4diagram/relationship-popover/components.d.ts +2 -2
- package/dist/likec4diagram/state/DiagramActorProvider.d.ts +1 -1
- package/dist/likec4diagram/state/aligners.js +3 -0
- package/dist/likec4diagram/state/assign.js +1 -1
- package/dist/likec4diagram/state/createViewChange.js +1 -0
- package/dist/likec4diagram/state/diagram-api.d.ts +16 -0
- package/dist/likec4diagram/state/diagram-api.js +13 -7
- package/dist/likec4diagram/state/machine.actions.js +10 -10
- package/dist/likec4diagram/state/machine.d.ts +1 -1
- package/dist/likec4diagram/state/machine.setup.js +1 -1
- package/dist/likec4diagram/state/types.d.ts +1 -1
- package/dist/likec4diagram/state/utils.d.ts +1 -1
- package/dist/likec4diagram/types.d.ts +2 -0
- package/dist/likec4diagram/ui/LayoutDriftFrame.d.ts +1 -1
- package/dist/likec4diagram/ui/notation/NotationPanel.d.ts +1 -1
- package/dist/likec4diagram/useLayoutConstraints.js +2 -0
- package/dist/likec4diagram/xyflow-diagram/diagram-view.js +4 -2
- package/dist/likec4diagram/xyflow-sequence/sequence-layout.js +1 -0
- package/dist/navigationpanel/NavigationPanel.d.ts +1 -1
- package/dist/navigationpanel/NavigationPanelControls.d.ts +1 -1
- package/dist/navigationpanel/NavigationPanelDropdown.d.ts +1 -1
- package/dist/navigationpanel/NavigationPanelDropdown.js +2 -2
- package/dist/navigationpanel/_common.d.ts +2 -2
- package/dist/navigationpanel/comparepanel/CompareActionsMenu.d.ts +1 -1
- package/dist/navigationpanel/comparepanel/ComparePanel.d.ts +1 -1
- package/dist/navigationpanel/comparepanel/ComparePanelControls.d.ts +1 -1
- package/dist/navigationpanel/comparepanel/DriftsSummary.d.ts +1 -1
- package/dist/navigationpanel/comparepanel/LayoutTypeSwitcher.d.ts +1 -1
- package/dist/navigationpanel/controls/DetailsControls.d.ts +1 -1
- package/dist/navigationpanel/controls/LayoutWarning.d.ts +1 -1
- package/dist/navigationpanel/controls/LogoButton.d.ts +1 -1
- package/dist/navigationpanel/controls/NavigationButtons.d.ts +1 -1
- package/dist/navigationpanel/controls/OpenSource.d.ts +1 -1
- package/dist/navigationpanel/controls/SearchControl.d.ts +1 -1
- package/dist/navigationpanel/controls/ToggleReadonly.d.ts +1 -1
- package/dist/navigationpanel/controls/ToggleReadonly.js +4 -2
- package/dist/navigationpanel/editorpanel/ApplySemanticLayout.d.ts +4 -0
- package/dist/navigationpanel/editorpanel/ApplySemanticLayout.js +36 -0
- package/dist/navigationpanel/editorpanel/CenterCamera.d.ts +1 -1
- package/dist/navigationpanel/editorpanel/ChangeAutoLayoutButton.d.ts +1 -1
- package/dist/navigationpanel/editorpanel/EditorPanel.d.ts +1 -1
- package/dist/navigationpanel/editorpanel/EditorPanel.js +45 -33
- package/dist/navigationpanel/editorpanel/ManualLayoutToolsButton.d.ts +1 -1
- package/dist/navigationpanel/editorpanel/ToggleReadonly.d.ts +1 -1
- package/dist/navigationpanel/styles.css.d.ts +1 -1
- package/dist/navigationpanel/walkthrough/ActiveWalkthroughControls.d.ts +1 -1
- package/dist/navigationpanel/walkthrough/DynamicViewControls.d.ts +62 -62
- package/dist/navigationpanel/walkthrough/WalkthroughPanel.d.ts +1 -1
- package/dist/overlays/Overlays.d.ts +1 -1
- package/dist/overlays/element-details/ElementDetails.d.ts +1 -1
- package/dist/overlays/element-details/ElementDetailsCard.d.ts +1 -1
- package/dist/overlays/element-details/MetadataValue.d.ts +2 -2
- package/dist/overlays/element-details/TabPanelRelationships.d.ts +1 -1
- package/dist/overlays/element-details/TabPanelStructure.d.ts +2 -2
- package/dist/overlays/overlay/Overlay.d.ts +16 -0
- package/dist/overlays/overlay/Overlay.js +50 -52
- package/dist/overlays/overlaysActor.js +28 -27
- package/dist/overlays/relationship-details/RelationshipDetails.d.ts +1 -1
- package/dist/overlays/relationship-details/SelectEdge.d.ts +1 -1
- package/dist/overlays/relationship-details/custom/ElementActions.d.ts +1 -1
- package/dist/overlays/relationship-details/custom/nodeTypes.d.ts +4 -5
- package/dist/overlays/relationship-details/custom/nodeTypes.js +25 -24
- package/dist/overlays/relationships-browser/RelationshipsBrowser.d.ts +1 -1
- package/dist/overlays/relationships-browser/SelectElement.d.ts +1 -1
- package/dist/overlays/relationships-browser/SelectElement.js +2 -2
- package/dist/overlays/relationships-browser/custom/ElementActions.d.ts +1 -1
- package/dist/overlays/relationships-browser/custom/EmptyNode.d.ts +1 -1
- package/dist/overlays/relationships-browser/custom/nodeTypes.d.ts +4 -4
- package/dist/projects-overview/ProjectsOverview.d.ts +1 -1
- package/dist/projects-overview/custom/nodeTypes.d.ts +1 -1
- package/dist/projects-overview/panel/ProjectsOverviewPanel.d.ts +1 -1
- package/dist/search/Search.d.ts +6 -3
- package/dist/search/Search.js +60 -71
- package/dist/search/XStateSearchAdapter.d.ts +1 -1
- package/dist/search/components/ElementsColumn.d.ts +1 -1
- package/dist/search/components/ElementsColumn.js +12 -8
- package/dist/search/components/PickView.d.ts +1 -1
- package/dist/search/components/SearchByTags.d.ts +1 -1
- package/dist/search/components/SearchInput.d.ts +1 -1
- package/dist/search/components/ViewsColum.d.ts +3 -3
- package/dist/search/components/_shared.css.d.ts +1 -1
- package/dist/search/searchActor.js +30 -26
- package/dist/shadowroot/ShadowRoot.d.ts +6 -6
- package/dist/shadowroot/ShadowRoot.js +68 -23
- package/dist/shadowroot/index.d.ts +1 -0
- package/dist/shadowroot/styles.d.ts +13 -0
- package/dist/shadowroot/styles.js +60 -0
- package/dist/styles2.js +1 -1
- package/package.json +33 -40
- package/panda.buildinfo.json +19 -22
- package/src/styles-font.css +114 -0
- package/src/styles-min.css +2 -0
- package/src/styles-xyflow.css +1 -0
- package/src/styles.css +3 -0
- package/styles-min.css +1 -1
- package/styles-xyflow.css +1 -1
- package/styles.css +1 -1
- package/dist/bundle/index.d.ts +0 -1
- package/dist/editor/editorActor.actions.d.ts +0 -153
- package/dist/editor/editorActor.actions.js +0 -133
- package/dist/editor/editorActor.setup.d.ts +0 -84
- package/dist/editor/editorActor.states.js +0 -219
- package/dist/hooks/useOverlaysActor.js +0 -11
- package/dist/hooks/useSearchActor.js +0 -11
- package/dist/shadowroot/styles.css.d.ts +0 -4
- package/dist/shadowroot/styles.css.js +0 -62
|
@@ -2,13 +2,12 @@ import "../_virtual/_rolldown/runtime.js";
|
|
|
2
2
|
import { useCallbackRef as useCallbackRef$1 } from "../hooks/useCallbackRef.js";
|
|
3
3
|
import { depsShallowEqual, useUpdateEffect as useUpdateEffect$1 } from "../hooks/useUpdateEffect.js";
|
|
4
4
|
import { BaseXYFlow } from "../base/BaseXYFlow.js";
|
|
5
|
-
import {
|
|
5
|
+
import { useRootContainer } from "../context/RootContainerContext.js";
|
|
6
6
|
import { useDiagramEventHandlers } from "../context/DiagramEventHandlers.js";
|
|
7
7
|
import { useDiagram } from "../hooks/safeContext.js";
|
|
8
8
|
import { selectDiagramActor, useDiagramSnapshot } from "../hooks/useDiagram.js";
|
|
9
9
|
import { viewBounds } from "./state/utils.js";
|
|
10
10
|
import { deriveToggledFeatures } from "./state/machine.setup.js";
|
|
11
|
-
import { memoNode } from "../base-primitives/memoNode.js";
|
|
12
11
|
import { BuiltinEdges, BuiltinNodes } from "./custom/index.js";
|
|
13
12
|
import { useLayoutConstraints } from "./useLayoutConstraints.js";
|
|
14
13
|
import { cx } from "@likec4/styles/css";
|
|
@@ -23,13 +22,13 @@ var edgeTypes = {
|
|
|
23
22
|
"seq-step": BuiltinEdges.SequenceStepEdge
|
|
24
23
|
};
|
|
25
24
|
var builtinNodes = {
|
|
26
|
-
element:
|
|
27
|
-
deployment:
|
|
28
|
-
"compound-element":
|
|
29
|
-
"compound-deployment":
|
|
30
|
-
"view-group":
|
|
31
|
-
"seq-actor":
|
|
32
|
-
"seq-parallel":
|
|
25
|
+
element: BuiltinNodes.ElementNode,
|
|
26
|
+
deployment: BuiltinNodes.DeploymentNode,
|
|
27
|
+
"compound-element": BuiltinNodes.CompoundElementNode,
|
|
28
|
+
"compound-deployment": BuiltinNodes.CompoundDeploymentNode,
|
|
29
|
+
"view-group": BuiltinNodes.ViewGroupNode,
|
|
30
|
+
"seq-actor": BuiltinNodes.SequenceActorNode,
|
|
31
|
+
"seq-parallel": BuiltinNodes.SequenceParallelArea
|
|
33
32
|
};
|
|
34
33
|
function prepareNodeTypes(nodeTypes) {
|
|
35
34
|
if (!nodeTypes || isEmpty(nodeTypes)) return builtinNodes;
|
|
@@ -53,8 +52,10 @@ var viewportToTopLeft = (ctx) => {
|
|
|
53
52
|
};
|
|
54
53
|
var selectXYProps = selectDiagramActor(({ context: ctx, children }) => {
|
|
55
54
|
const { enableReadOnly } = deriveToggledFeatures(ctx);
|
|
56
|
-
const
|
|
57
|
-
|
|
55
|
+
const editorSnapshot = enableReadOnly ? null : children.editor?.getSnapshot();
|
|
56
|
+
const isNotEditingEdge = enableReadOnly || editorSnapshot?.context.editing?.subject !== "edge";
|
|
57
|
+
const isEditorBusy = editorSnapshot?.hasTag("busy") ?? false;
|
|
58
|
+
let nodesDraggable = !enableReadOnly && ctx.nodesDraggable && !isEditorBusy;
|
|
58
59
|
if (ctx.dynamicViewVariant === "sequence" && ctx.view._type === "dynamic") nodesDraggable = false;
|
|
59
60
|
return {
|
|
60
61
|
enableReadOnly,
|
|
@@ -64,7 +65,7 @@ var selectXYProps = selectDiagramActor(({ context: ctx, children }) => {
|
|
|
64
65
|
pannable: ctx.pannable,
|
|
65
66
|
zoomable: ctx.zoomable,
|
|
66
67
|
nodesDraggable,
|
|
67
|
-
nodesSelectable: ctx.nodesSelectable && isNotEditingEdge,
|
|
68
|
+
nodesSelectable: ctx.nodesSelectable && isNotEditingEdge && !isEditorBusy,
|
|
68
69
|
fitViewPadding: ctx.fitViewPadding,
|
|
69
70
|
enableFitView: ctx.features.enableFitView,
|
|
70
71
|
...!ctx.features.enableFitView && { viewport: viewportToTopLeft(ctx) }
|
|
@@ -74,9 +75,10 @@ function LikeC4DiagramXYFlow({ background = "dots", reactFlowProps = {}, childre
|
|
|
74
75
|
const diagram = useDiagram();
|
|
75
76
|
let { enableReadOnly, initialized, nodes, edges, enableFitView, nodesDraggable, nodesSelectable, ...props } = useDiagramSnapshot(selectXYProps);
|
|
76
77
|
const { onNodeContextMenu, onCanvasContextMenu, onEdgeContextMenu, onNodeClick, onEdgeClick, onCanvasClick, onCanvasDblClick } = useDiagramEventHandlers();
|
|
77
|
-
const
|
|
78
|
+
const { reducedGraphics, $panning } = useRootContainer();
|
|
79
|
+
const isReducedGraphics = reducedGraphics;
|
|
78
80
|
const layoutConstraints = useLayoutConstraints();
|
|
79
|
-
const $isPanning =
|
|
81
|
+
const $isPanning = $panning;
|
|
80
82
|
const isPanning = useTimeout(() => {
|
|
81
83
|
$isPanning.set(true);
|
|
82
84
|
}, isReducedGraphics ? 200 : 800);
|
|
@@ -128,6 +130,7 @@ function LikeC4DiagramXYFlow({ background = "dots", reactFlowProps = {}, childre
|
|
|
128
130
|
background: initialized ? background : "transparent",
|
|
129
131
|
fitView: false,
|
|
130
132
|
onNodeClick: useCallbackRef$1((e, node) => {
|
|
133
|
+
if (e.isPropagationStopped()) return;
|
|
131
134
|
e.stopPropagation();
|
|
132
135
|
diagram.send({
|
|
133
136
|
type: "xyflow.nodeClick",
|
|
@@ -136,6 +139,7 @@ function LikeC4DiagramXYFlow({ background = "dots", reactFlowProps = {}, childre
|
|
|
136
139
|
onNodeClick?.(diagram.findDiagramNode(node.id), e);
|
|
137
140
|
}),
|
|
138
141
|
onEdgeClick: useCallbackRef$1((e, edge) => {
|
|
142
|
+
if (e.isPropagationStopped()) return;
|
|
139
143
|
e.stopPropagation();
|
|
140
144
|
diagram.send({
|
|
141
145
|
type: "xyflow.edgeClick",
|
|
@@ -144,12 +148,20 @@ function LikeC4DiagramXYFlow({ background = "dots", reactFlowProps = {}, childre
|
|
|
144
148
|
onEdgeClick?.(diagram.findDiagramEdge(edge.id), e);
|
|
145
149
|
}),
|
|
146
150
|
onEdgeDoubleClick: useCallbackRef$1((e, edge) => {
|
|
151
|
+
if (e.isPropagationStopped()) return;
|
|
147
152
|
e.stopPropagation();
|
|
148
153
|
diagram.send({
|
|
149
154
|
type: "xyflow.edgeDoubleClick",
|
|
150
155
|
edge
|
|
151
156
|
});
|
|
152
157
|
}),
|
|
158
|
+
onDelete: useCallbackRef$1(({ nodes, edges }) => {
|
|
159
|
+
diagram.editorActor().send({
|
|
160
|
+
type: "delete.nodes-edges",
|
|
161
|
+
nodeIds: nodes.map((node) => node.data.id),
|
|
162
|
+
edgeIds: edges.map((edge) => edge.data.id)
|
|
163
|
+
});
|
|
164
|
+
}),
|
|
153
165
|
onPaneClick: useCallbackRef$1((e) => {
|
|
154
166
|
e.stopPropagation();
|
|
155
167
|
diagram.send({ type: "xyflow.paneClick" });
|
|
@@ -3,4 +3,4 @@ export type EdgeDriftsProps = {
|
|
|
3
3
|
edgeProps: Types.EdgeProps;
|
|
4
4
|
svgPath: string;
|
|
5
5
|
};
|
|
6
|
-
export declare function EdgeDrifts({ edgeProps: { data }, svgPath, }: EdgeDriftsProps): import("react
|
|
6
|
+
export declare function EdgeDrifts({ edgeProps: { data }, svgPath, }: EdgeDriftsProps): import("react").JSX.Element | null;
|
|
@@ -13,7 +13,7 @@ import { EdgeLabelContainer } from "../../../base-primitives/edge/EdgeLabelConta
|
|
|
13
13
|
import { EdgePath } from "../../../base-primitives/edge/EdgePath.js";
|
|
14
14
|
import { memoEdge } from "../../../base-primitives/memoEdge.js";
|
|
15
15
|
import { EdgeDrifts } from "./EdgeDrifts.js";
|
|
16
|
-
import { controlPoint, controlPointsContainer } from "./edges.css.js";
|
|
16
|
+
import { controlPoint, controlPointsContainer, labelDraggable } from "./edges.css.js";
|
|
17
17
|
import { useControlPoints } from "./useControlPoints.js";
|
|
18
18
|
import { useRelationshipEdgePath } from "./useRelationshipEdgePath.js";
|
|
19
19
|
import { css, cx } from "@likec4/styles/css";
|
|
@@ -33,7 +33,11 @@ var RelationshipEdge = memoEdge((props) => {
|
|
|
33
33
|
const [isControlPointDragging, setIsControlPointDragging] = useState(false);
|
|
34
34
|
const isControlPointDraggingRef = useRef(isControlPointDragging);
|
|
35
35
|
isControlPointDraggingRef.current = isControlPointDragging;
|
|
36
|
+
const [isLabelDragging, setIsLabelDragging] = useState(false);
|
|
37
|
+
const isLabelDraggingRef = useRef(isLabelDragging);
|
|
38
|
+
isLabelDraggingRef.current = isLabelDragging;
|
|
36
39
|
const xyflow = useXYFlow();
|
|
40
|
+
const xyflowStore = useXYStoreApi();
|
|
37
41
|
const diagram = useDiagram();
|
|
38
42
|
const { enableNavigateTo, enableReadOnly, enableCompareWithLatest } = useEnabledFeatures();
|
|
39
43
|
const enabledEditing = !enableReadOnly;
|
|
@@ -52,32 +56,58 @@ var RelationshipEdge = memoEdge((props) => {
|
|
|
52
56
|
y: labelXY?.y ?? labelY
|
|
53
57
|
}, isSamePoint);
|
|
54
58
|
useUpdateEffect$1(() => {
|
|
55
|
-
if (isControlPointDraggingRef.current) return;
|
|
59
|
+
if (isControlPointDraggingRef.current || isLabelDraggingRef.current) return;
|
|
56
60
|
setLabelPos({
|
|
57
61
|
x: labelX,
|
|
58
62
|
y: labelY
|
|
59
63
|
});
|
|
60
64
|
}, [labelX, labelY]);
|
|
61
65
|
const svgPathRef = useRef(null);
|
|
66
|
+
const labelOffsetRef = useRef({
|
|
67
|
+
x: 0,
|
|
68
|
+
y: 0
|
|
69
|
+
});
|
|
70
|
+
const captureLabelOffset = useCallbackRef(() => {
|
|
71
|
+
const path = svgPathRef.current;
|
|
72
|
+
if (data.isLabelCustomized && path && labelBBox) {
|
|
73
|
+
const center = getEdgeCenter(path);
|
|
74
|
+
labelOffsetRef.current = {
|
|
75
|
+
x: labelBBox.x - center.x,
|
|
76
|
+
y: labelBBox.y - center.y
|
|
77
|
+
};
|
|
78
|
+
} else labelOffsetRef.current = {
|
|
79
|
+
x: 0,
|
|
80
|
+
y: 0
|
|
81
|
+
};
|
|
82
|
+
});
|
|
62
83
|
useRafEffect(() => {
|
|
63
84
|
const path = svgPathRef.current;
|
|
64
85
|
if (!path || !isControlPointDragging) return;
|
|
65
|
-
|
|
86
|
+
const center = getEdgeCenter(path);
|
|
87
|
+
const offset = labelOffsetRef.current;
|
|
88
|
+
setLabelPos({
|
|
89
|
+
x: center.x + offset.x,
|
|
90
|
+
y: center.y + offset.y
|
|
91
|
+
});
|
|
66
92
|
}, [edgePath, isControlPointDragging]);
|
|
67
93
|
const updateEdgeData = useCallbackRef((controlPoints) => {
|
|
68
|
-
const
|
|
69
|
-
if (
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
94
|
+
const center = labelBBox && svgPathRef.current ? getEdgeCenter(svgPathRef.current) : null;
|
|
95
|
+
if (center) {
|
|
96
|
+
const offset = labelOffsetRef.current;
|
|
97
|
+
diagram.updateEdgeData(id, {
|
|
98
|
+
controlPoints,
|
|
99
|
+
labelBBox: {
|
|
100
|
+
...labelBBox,
|
|
101
|
+
x: center.x + offset.x,
|
|
102
|
+
y: center.y + offset.y
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
} else diagram.updateEdgeData(id, { controlPoints });
|
|
77
106
|
diagram.stopEditing(true);
|
|
78
107
|
setIsControlPointDragging(false);
|
|
79
108
|
});
|
|
80
109
|
const onControlPointerStartMove = useCallbackRef(() => {
|
|
110
|
+
captureLabelOffset();
|
|
81
111
|
diagram.startEditing("edge");
|
|
82
112
|
setIsControlPointDragging(true);
|
|
83
113
|
});
|
|
@@ -92,6 +122,7 @@ var RelationshipEdge = memoEdge((props) => {
|
|
|
92
122
|
});
|
|
93
123
|
});
|
|
94
124
|
const onControlPointerDelete = useCallbackRef((points) => {
|
|
125
|
+
captureLabelOffset();
|
|
95
126
|
diagram.startEditing("edge");
|
|
96
127
|
setIsControlPointDragging(true);
|
|
97
128
|
setControlPoints(points);
|
|
@@ -115,6 +146,86 @@ var RelationshipEdge = memoEdge((props) => {
|
|
|
115
146
|
diagram.updateEdgeData(id, { controlPoints: newControlPoints });
|
|
116
147
|
diagram.stopEditing(true);
|
|
117
148
|
});
|
|
149
|
+
const updateLabelPosition = useCallbackRef((pos) => {
|
|
150
|
+
if (labelBBox) diagram.updateEdgeData(id, {
|
|
151
|
+
labelBBox: {
|
|
152
|
+
...labelBBox,
|
|
153
|
+
x: pos.x,
|
|
154
|
+
y: pos.y
|
|
155
|
+
},
|
|
156
|
+
isLabelCustomized: true
|
|
157
|
+
});
|
|
158
|
+
diagram.stopEditing(true);
|
|
159
|
+
setIsLabelDragging(false);
|
|
160
|
+
});
|
|
161
|
+
/**
|
|
162
|
+
* Handle pointer down on the edge label to drag it to a custom position.
|
|
163
|
+
* Mirrors the control-point LMB drag.
|
|
164
|
+
*/
|
|
165
|
+
const onLabelPointerDown = useCallbackRef((e) => {
|
|
166
|
+
if (e.pointerType !== "mouse" || e.button !== 0 || !labelBBox || isControlPointDraggingRef.current) return;
|
|
167
|
+
const { domNode, edges, addSelectedEdges, unselectNodesAndEdges } = xyflowStore.getState();
|
|
168
|
+
if (!domNode) return;
|
|
169
|
+
e.stopPropagation();
|
|
170
|
+
if (!selected) {
|
|
171
|
+
unselectNodesAndEdges({ edges: edges.filter((ed) => ed.selected && ed.id !== id) });
|
|
172
|
+
addSelectedEdges([id]);
|
|
173
|
+
}
|
|
174
|
+
let hasMoved = false;
|
|
175
|
+
const initialPoint = {
|
|
176
|
+
x: e.clientX,
|
|
177
|
+
y: e.clientY
|
|
178
|
+
};
|
|
179
|
+
const clientPoint = { ...initialPoint };
|
|
180
|
+
const flowStart = xyflow.screenToFlowPosition(initialPoint, { snapToGrid: false });
|
|
181
|
+
const grab = {
|
|
182
|
+
x: flowStart.x - labelBBox.x,
|
|
183
|
+
y: flowStart.y - labelBBox.y
|
|
184
|
+
};
|
|
185
|
+
let pos = {
|
|
186
|
+
x: labelBBox.x,
|
|
187
|
+
y: labelBBox.y
|
|
188
|
+
};
|
|
189
|
+
let animationFrameId = null;
|
|
190
|
+
const onPointerMove = (ev) => {
|
|
191
|
+
clientPoint.x = ev.clientX;
|
|
192
|
+
clientPoint.y = ev.clientY;
|
|
193
|
+
if (!isSamePoint(initialPoint, clientPoint)) {
|
|
194
|
+
if (!hasMoved) {
|
|
195
|
+
hasMoved = true;
|
|
196
|
+
diagram.startEditing("edge");
|
|
197
|
+
setIsLabelDragging(true);
|
|
198
|
+
}
|
|
199
|
+
animationFrameId ??= requestAnimationFrame(() => {
|
|
200
|
+
animationFrameId = null;
|
|
201
|
+
const { x, y } = xyflow.screenToFlowPosition(clientPoint, { snapToGrid: false });
|
|
202
|
+
pos = {
|
|
203
|
+
x: Math.round(x - grab.x),
|
|
204
|
+
y: Math.round(y - grab.y)
|
|
205
|
+
};
|
|
206
|
+
setLabelPos(pos);
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
ev.stopPropagation();
|
|
210
|
+
};
|
|
211
|
+
const onPointerUp = (ev) => {
|
|
212
|
+
ev.stopPropagation();
|
|
213
|
+
domNode.removeEventListener("pointermove", onPointerMove, { capture: true });
|
|
214
|
+
if (animationFrameId !== null) cancelAnimationFrame(animationFrameId);
|
|
215
|
+
if (hasMoved) {
|
|
216
|
+
domNode.addEventListener("click", stopAndPrevent, {
|
|
217
|
+
capture: true,
|
|
218
|
+
once: true
|
|
219
|
+
});
|
|
220
|
+
updateLabelPosition(pos);
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
domNode.addEventListener("pointermove", onPointerMove, { capture: true });
|
|
224
|
+
domNode.addEventListener("pointerup", onPointerUp, {
|
|
225
|
+
once: true,
|
|
226
|
+
capture: true
|
|
227
|
+
});
|
|
228
|
+
});
|
|
118
229
|
if (isControlPointDragging && !props.data.hovered) props = {
|
|
119
230
|
...props,
|
|
120
231
|
data: {
|
|
@@ -139,12 +250,14 @@ var RelationshipEdge = memoEdge((props) => {
|
|
|
139
250
|
}),
|
|
140
251
|
labelBBox && /* @__PURE__ */ jsx(EdgeLabelContainer, {
|
|
141
252
|
edgeProps: props,
|
|
142
|
-
labelPosition: isControlPointDragging ? labelPos : {
|
|
253
|
+
labelPosition: isControlPointDragging || isLabelDragging ? labelPos : {
|
|
143
254
|
x: labelX,
|
|
144
255
|
y: labelY
|
|
145
256
|
},
|
|
257
|
+
...enabledEditing && { onPointerDown: onLabelPointerDown },
|
|
146
258
|
children: /* @__PURE__ */ jsx(EdgeLabel, {
|
|
147
|
-
pointerEvents:
|
|
259
|
+
pointerEvents: "all",
|
|
260
|
+
className: enabledEditing ? labelDraggable : void 0,
|
|
148
261
|
edgeProps: props,
|
|
149
262
|
children: navigateTo && /* @__PURE__ */ jsx(EdgeActionButton, { onClick: (e) => {
|
|
150
263
|
e.stopPropagation();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Types } from '../../types';
|
|
2
|
-
export declare function SequenceStepEdge(props: Types.EdgeProps<'seq-step'>): import("react
|
|
2
|
+
export declare function SequenceStepEdge(props: Types.EdgeProps<'seq-step'>): import("react").JSX.Element;
|
|
@@ -12,6 +12,10 @@ var controlPointsContainer = css({
|
|
|
12
12
|
},
|
|
13
13
|
zIndex: "[100]"
|
|
14
14
|
});
|
|
15
|
+
var labelDraggable = css({
|
|
16
|
+
cursor: "grab!",
|
|
17
|
+
_active: { cursor: "grabbing!" }
|
|
18
|
+
});
|
|
15
19
|
var controlPoint = css({
|
|
16
20
|
fill: `[var(--xy-edge-stroke)]`,
|
|
17
21
|
stroke: `transparent`,
|
|
@@ -41,4 +45,4 @@ var controlPoint = css({
|
|
|
41
45
|
_groupActive: { cursor: "grabbing" }
|
|
42
46
|
});
|
|
43
47
|
//#endregion
|
|
44
|
-
export { controlPoint, controlPointsContainer };
|
|
48
|
+
export { controlPoint, controlPointsContainer, labelDraggable };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Types } from '../../types';
|
|
2
2
|
type CompoundActionsProps = Types.NodeProps<'compound-deployment' | 'compound-element'>;
|
|
3
|
-
export declare const CompoundActions: (props: CompoundActionsProps) => import("react
|
|
3
|
+
export declare const CompoundActions: (props: CompoundActionsProps) => import("react").JSX.Element | null;
|
|
4
4
|
export {};
|
|
@@ -53,7 +53,7 @@ export type ElementActionsProps = SimplifyDeep<{
|
|
|
53
53
|
* />
|
|
54
54
|
* ```
|
|
55
55
|
*/
|
|
56
|
-
export declare function ElementActions({ extraButtons, ...props }: ElementActionsProps): import("react
|
|
56
|
+
export declare function ElementActions({ extraButtons, ...props }: ElementActionsProps): import("react").JSX.Element;
|
|
57
57
|
export type DeploymentElementActionsProps = SimplifyDeep<{
|
|
58
58
|
selected?: boolean;
|
|
59
59
|
data: Pick<Types.DeploymentElementNodeData, 'id' | 'modelFqn' | 'navigateTo'> & BaseNodeData;
|
|
@@ -83,5 +83,5 @@ export type DeploymentElementActionsProps = SimplifyDeep<{
|
|
|
83
83
|
* />
|
|
84
84
|
* ```
|
|
85
85
|
*/
|
|
86
|
-
export declare const DeploymentElementActions: ({ extraButtons, ...props }: DeploymentElementActionsProps) => import("react
|
|
86
|
+
export declare const DeploymentElementActions: ({ extraButtons, ...props }: DeploymentElementActionsProps) => import("react").JSX.Element;
|
|
87
87
|
export {};
|
|
@@ -2,4 +2,4 @@ import { Types } from '../../types';
|
|
|
2
2
|
export type NodeDriftsProps = {
|
|
3
3
|
nodeProps: Types.NodeProps;
|
|
4
4
|
};
|
|
5
|
-
export declare function NodeDrifts({ nodeProps: { data }, }: NodeDriftsProps): import("react
|
|
5
|
+
export declare function NodeDrifts({ nodeProps: { data }, }: NodeDriftsProps): import("react").JSX.Element | null;
|
|
@@ -2,5 +2,5 @@ import { BaseNodePropsWithData } from '../../../base/types';
|
|
|
2
2
|
import { Types } from '../../types';
|
|
3
3
|
type RequiredData = Pick<Types.NodeData, 'id' | 'notes' | 'width' | 'height' | 'x' | 'y'>;
|
|
4
4
|
export type NodeNotesProps = BaseNodePropsWithData<RequiredData>;
|
|
5
|
-
export declare function NodeNotes({ data }: NodeNotesProps): import("react
|
|
5
|
+
export declare function NodeNotes({ data }: NodeNotesProps): import("react").JSX.Element | null;
|
|
6
6
|
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Types } from '../../types';
|
|
2
|
-
export declare function SequenceActorNode(props: Types.NodeProps<'seq-actor'>): import("react
|
|
3
|
-
export declare function SequenceParallelArea(props: Types.NodeProps<'seq-parallel'>): import("react
|
|
2
|
+
export declare function SequenceActorNode(props: Types.NodeProps<'seq-actor'>): import("react").JSX.Element;
|
|
3
|
+
export declare function SequenceParallelArea(props: Types.NodeProps<'seq-parallel'>): import("react").JSX.Element;
|
|
@@ -7,13 +7,13 @@ export declare function ElementDetailsButtonWithHandler(props: {
|
|
|
7
7
|
data: BaseNodeData & {
|
|
8
8
|
modelFqn?: Fqn | null | undefined;
|
|
9
9
|
};
|
|
10
|
-
}): import("react
|
|
11
|
-
export declare function CompoundDetailsButtonWithHandler(props: Types.NodeProps<'compound-deployment' | 'compound-element'>): import("react
|
|
10
|
+
}): import("react").JSX.Element | null;
|
|
11
|
+
export declare function CompoundDetailsButtonWithHandler(props: Types.NodeProps<'compound-deployment' | 'compound-element'>): import("react").JSX.Element | null;
|
|
12
12
|
/**
|
|
13
13
|
* Renders an element node.
|
|
14
14
|
*/
|
|
15
|
-
export declare function ElementNode(props: Types.NodeProps<'element'>): import("react
|
|
16
|
-
export declare function DeploymentNode(props: Types.NodeProps<'deployment'>): import("react
|
|
17
|
-
export declare function CompoundElementNode(props: Types.NodeProps<'compound-element'>): import("react
|
|
18
|
-
export declare function CompoundDeploymentNode(props: Types.NodeProps<'compound-deployment'>): import("react
|
|
19
|
-
export declare function ViewGroupNode(props: Types.NodeProps<'view-group'>): import("react
|
|
15
|
+
export declare function ElementNode(props: Types.NodeProps<'element'>): import("react").JSX.Element;
|
|
16
|
+
export declare function DeploymentNode(props: Types.NodeProps<'deployment'>): import("react").JSX.Element;
|
|
17
|
+
export declare function CompoundElementNode(props: Types.NodeProps<'compound-element'>): import("react").JSX.Element;
|
|
18
|
+
export declare function CompoundDeploymentNode(props: Types.NodeProps<'compound-deployment'>): import("react").JSX.Element;
|
|
19
|
+
export declare function ViewGroupNode(props: Types.NodeProps<'view-group'>): import("react").JSX.Element;
|
|
@@ -8,15 +8,15 @@ type ColorButtonProps = Omit<PopoverProps, 'onChange'> & {
|
|
|
8
8
|
onColorPreview: (color: ThemeColor | null) => void;
|
|
9
9
|
onChange: OnStyleChange;
|
|
10
10
|
};
|
|
11
|
-
export declare function ColorButton({ elementColor, elementOpacity, onColorPreview, isOpacityEditable, onChange, ...props }: ColorButtonProps): import("react
|
|
11
|
+
export declare function ColorButton({ elementColor, elementOpacity, onColorPreview, isOpacityEditable, onChange, ...props }: ColorButtonProps): import("react").JSX.Element;
|
|
12
12
|
export declare function ColorSwatches({ theme, elementColor, onColorPreview, onChange, }: {
|
|
13
13
|
theme: LikeC4Theme;
|
|
14
14
|
elementColor: ThemeColor;
|
|
15
15
|
onColorPreview: (color: ThemeColor | null) => void;
|
|
16
16
|
onChange: (color: ThemeColor) => void;
|
|
17
|
-
}): import("react
|
|
17
|
+
}): import("react").JSX.Element;
|
|
18
18
|
export declare function OpacityOption({ elementOpacity, onOpacityChange, }: {
|
|
19
19
|
elementOpacity: number | undefined;
|
|
20
20
|
onOpacityChange: (opacity: number) => void;
|
|
21
|
-
}): import("react
|
|
21
|
+
}): import("react").JSX.Element;
|
|
22
22
|
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Types } from '../../../types';
|
|
2
|
-
export declare function CompoundElementToolbar(props: Types.NodeProps<'compound-element'>): import("react
|
|
3
|
-
export declare function CompoundDeploymentToolbar(props: Types.NodeProps<'compound-deployment'>): import("react
|
|
2
|
+
export declare function CompoundElementToolbar(props: Types.NodeProps<'compound-element'>): import("react").JSX.Element;
|
|
3
|
+
export declare function CompoundDeploymentToolbar(props: Types.NodeProps<'compound-deployment'>): import("react").JSX.Element;
|
|
@@ -4,5 +4,5 @@ export declare function ElementToolbar(props: Types.NodeProps<'element' | 'seq-a
|
|
|
4
4
|
data: {
|
|
5
5
|
modelFqn: Fqn;
|
|
6
6
|
};
|
|
7
|
-
}): import("react
|
|
8
|
-
export declare function DeploymentElementToolbar(props: Types.NodeProps<'deployment'>): import("react
|
|
7
|
+
}): import("react").JSX.Element;
|
|
8
|
+
export declare function DeploymentElementToolbar(props: Types.NodeProps<'deployment'>): import("react").JSX.Element;
|
|
@@ -5,4 +5,4 @@ export type ToolbarProps = Omit<NodeToolbarProps, 'title'> & {
|
|
|
5
5
|
nodeProps: BaseNodeProps;
|
|
6
6
|
title: ReactNode;
|
|
7
7
|
};
|
|
8
|
-
export declare function Toolbar({ title, children, nodeProps, ...props }: ToolbarProps): import("react
|
|
8
|
+
export declare function Toolbar({ title, children, nodeProps, ...props }: ToolbarProps): import("react").JSX.Element | null;
|
|
@@ -6,13 +6,13 @@ import { TooltipProps, PlaceholderPolymorphicProps } from '@mantine/core';
|
|
|
6
6
|
export declare const Tooltip: NamedExoticComponent< TooltipProps & RefAttributes<HTMLDivElement> & PlaceholderPolymorphicProps>;
|
|
7
7
|
export declare function BrowseRelationshipsButton({ fqn }: {
|
|
8
8
|
fqn: Fqn;
|
|
9
|
-
}): import("react
|
|
9
|
+
}): import("react").JSX.Element;
|
|
10
10
|
export declare function GoToSourceButton(props: MergeExclusive<{
|
|
11
11
|
elementId: Fqn;
|
|
12
12
|
}, {
|
|
13
13
|
deploymentId: DeploymentFqn;
|
|
14
|
-
}>): import("react
|
|
14
|
+
}>): import("react").JSX.Element | null;
|
|
15
15
|
export declare function BorderStyleOption({ elementBorderStyle, onChange, }: {
|
|
16
16
|
elementBorderStyle: BorderStyle | undefined;
|
|
17
17
|
onChange: OnStyleChange;
|
|
18
|
-
}): import("react
|
|
18
|
+
}): import("react").JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { MemoExoticComponent } from 'react';
|
|
2
|
-
export declare const RelationshipPopover: MemoExoticComponent<() => import("react
|
|
2
|
+
export declare const RelationshipPopover: MemoExoticComponent<() => import("react").JSX.Element | null>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Color } from '@likec4/core/types';
|
|
2
2
|
import { PropsWithChildren } from 'react';
|
|
3
|
-
import { StyledComponent } from '
|
|
3
|
+
import { StyledComponent } from '../../../styled-system';
|
|
4
4
|
export declare const Endpoint: ({ children, likec4color }: PropsWithChildren<{
|
|
5
5
|
likec4color: Color;
|
|
6
|
-
}>) => import("react
|
|
6
|
+
}>) => import("react").JSX.Element;
|
|
7
7
|
export declare const RelationshipTitle: StyledComponent<"div", {}>;
|
|
@@ -11,4 +11,4 @@ export declare function DiagramActorProvider({ id, view, zoomable, pannable, nod
|
|
|
11
11
|
fitViewPadding: ViewPaddings;
|
|
12
12
|
where?: WhereOperator | null;
|
|
13
13
|
dynamicViewVariant?: DynamicViewDisplayVariant | undefined;
|
|
14
|
-
}>): import("react
|
|
14
|
+
}>): import("react").JSX.Element;
|
|
@@ -5,6 +5,9 @@ import { getNodeDimensions } from "@xyflow/system";
|
|
|
5
5
|
//#region src/likec4diagram/state/aligners.ts
|
|
6
6
|
var Aligner = class {};
|
|
7
7
|
var LinearAligner = class extends Aligner {
|
|
8
|
+
getEdgePosition;
|
|
9
|
+
computePosition;
|
|
10
|
+
propertyToEdit;
|
|
8
11
|
alignTo;
|
|
9
12
|
constructor(getEdgePosition, computePosition, propertyToEdit) {
|
|
10
13
|
super();
|
|
@@ -86,7 +86,7 @@ function resetEdgeControlPoints(nodeLookup, edge) {
|
|
|
86
86
|
if (source === target) {
|
|
87
87
|
const loopSize = 80;
|
|
88
88
|
const centerOfTopBoundary = vector(0, source.height || 0).multiply(-.5).add(sourceCenter);
|
|
89
|
-
return [centerOfTopBoundary.add(vector(-
|
|
89
|
+
return [centerOfTopBoundary.add(vector(-80 / 2.5, -80)).round().toObject(), centerOfTopBoundary.add(vector(loopSize / 2.5, -80)).round().toObject()];
|
|
90
90
|
}
|
|
91
91
|
const sourceToTargetVector = targetCenter.subtract(sourceCenter);
|
|
92
92
|
const sourceBorderPoint = getBorderPointOnVector(source, sourceCenter, sourceToTargetVector);
|
|
@@ -50,6 +50,7 @@ function createViewChange(parentContext) {
|
|
|
50
50
|
height: Math.round(data.labelBBox.height)
|
|
51
51
|
};
|
|
52
52
|
else _updated.labelBBox = null;
|
|
53
|
+
if (data.isLabelCustomized !== void 0) _updated.isLabelCustomized = data.isLabelCustomized;
|
|
53
54
|
if (hasAtLeast(controlPoints, 1)) _updated.controlPoints = map(controlPoints, (v) => ({
|
|
54
55
|
x: Math.round(v.x),
|
|
55
56
|
y: Math.round(v.y)
|
|
@@ -2,8 +2,10 @@ import { DynamicViewDisplayVariant, NodeNotation as ElementNotation, ViewChange
|
|
|
2
2
|
import { RefObject } from 'react';
|
|
3
3
|
import { PartialDeep } from 'type-fest';
|
|
4
4
|
import { FeatureName } from '../../context/DiagramFeatures';
|
|
5
|
+
import { EditorActorRef } from '../../editor/actor/machine';
|
|
5
6
|
import { OpenSourceParams } from '../../LikeC4Diagram.props';
|
|
6
7
|
import { OverlaysActorRef } from '../../overlays/overlaysActor';
|
|
8
|
+
import { SearchActorRef } from '../../search/searchActor';
|
|
7
9
|
import { Types } from '../types';
|
|
8
10
|
import { AlignmentMode } from './aligners';
|
|
9
11
|
import { DiagramActorRef, DiagramContext, DiagramEvents } from './types';
|
|
@@ -27,7 +29,21 @@ export interface DiagramApi<A extends Any = Unknown> {
|
|
|
27
29
|
* @warning Do not use in render phase
|
|
28
30
|
*/
|
|
29
31
|
readonly currentView: t.DiagramView<A>;
|
|
32
|
+
/**
|
|
33
|
+
* Editor actor reference
|
|
34
|
+
* @warning Do not use in render phase
|
|
35
|
+
*/
|
|
36
|
+
editorActor(): EditorActorRef;
|
|
37
|
+
/**
|
|
38
|
+
* Overlays actor reference
|
|
39
|
+
* @warning Do not use in render phase
|
|
40
|
+
*/
|
|
30
41
|
overlays(): OverlaysActorRef;
|
|
42
|
+
/**
|
|
43
|
+
* Search actor reference
|
|
44
|
+
* @warning Do not use in render phase
|
|
45
|
+
*/
|
|
46
|
+
searchActor(): SearchActorRef;
|
|
31
47
|
/**
|
|
32
48
|
* Send event to diagram actor
|
|
33
49
|
*/
|
|
@@ -8,8 +8,17 @@ function makeDiagramApi(actorRef) {
|
|
|
8
8
|
get actor() {
|
|
9
9
|
return actorRef.current;
|
|
10
10
|
},
|
|
11
|
+
editorActor() {
|
|
12
|
+
const editorActor = typedSystem(actorRef.current.system).editorActorRef;
|
|
13
|
+
return nonNullable(editorActor, "Editor actor not found in actor system");
|
|
14
|
+
},
|
|
11
15
|
overlays() {
|
|
12
|
-
|
|
16
|
+
const overlaysActor = typedSystem(actorRef.current.system).overlaysActorRef;
|
|
17
|
+
return nonNullable(overlaysActor, "Overlays actor not found in actor system");
|
|
18
|
+
},
|
|
19
|
+
searchActor() {
|
|
20
|
+
const searchActor = typedSystem(actorRef.current.system).searchActorRef;
|
|
21
|
+
return nonNullable(searchActor, "Search actor not found in actor system");
|
|
13
22
|
},
|
|
14
23
|
send: (event) => actorRef.current.send(event),
|
|
15
24
|
navigateTo: (viewId, fromNode, focusOnElement) => {
|
|
@@ -79,22 +88,19 @@ function makeDiagramApi(actorRef) {
|
|
|
79
88
|
const editorActor = typedSystem(actorRef.current.system).editorActorRef;
|
|
80
89
|
invariant(editorActor, "No editor actor found in diagram actor system");
|
|
81
90
|
editorActor.send({
|
|
82
|
-
type: "edit.start",
|
|
91
|
+
type: "edit.move.start",
|
|
83
92
|
subject
|
|
84
93
|
});
|
|
85
94
|
},
|
|
86
95
|
stopEditing: (wasChanged = false) => {
|
|
87
96
|
const editorActor = typedSystem(actorRef.current.system).editorActorRef;
|
|
88
97
|
invariant(editorActor, "No editor actor found in diagram actor system");
|
|
89
|
-
editorActor.send({
|
|
90
|
-
type: "edit.finish",
|
|
91
|
-
wasChanged
|
|
92
|
-
});
|
|
98
|
+
editorActor.send({ type: wasChanged ? "edit.move.end" : "edit.move.cancel" });
|
|
93
99
|
},
|
|
94
100
|
undoEditing: () => {
|
|
95
101
|
const editorActor = typedSystem(actorRef.current.system).editorActorRef;
|
|
96
102
|
invariant(editorActor, "No editor actor found in diagram actor system");
|
|
97
|
-
const hasUndo = editorActor.getSnapshot().context.history
|
|
103
|
+
const hasUndo = editorActor.getSnapshot().context.history !== null;
|
|
98
104
|
if (hasUndo) editorActor.send({ type: "undo" });
|
|
99
105
|
return hasUndo;
|
|
100
106
|
},
|