@dou-ui/flow 0.1.0-alpha.1 → 0.1.0-alpha.11
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/collaboration/index.js +76 -5
- package/dist/collaboration/index.js.map +1 -1
- package/dist/comments.js +245 -0
- package/dist/comments.js.map +1 -0
- package/dist/components/default-node2.js.map +1 -1
- package/dist/components/flow-comments.js +6 -0
- package/dist/components/flow-comments.js.map +1 -0
- package/dist/components/flow-comments.vue_vue_type_script_setup_true_lang.js +205 -0
- package/dist/components/flow-comments.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/port.js +7 -0
- package/dist/components/port.js.map +1 -0
- package/dist/context.js.map +1 -1
- package/dist/core/edge-types.js +107 -3
- package/dist/core/edge-types.js.map +1 -1
- package/dist/core/extension.js.map +1 -1
- package/dist/core/history.js +26 -0
- package/dist/core/history.js.map +1 -1
- package/dist/core/model.js.map +1 -1
- package/dist/core/node-types.js +35 -1
- package/dist/core/node-types.js.map +1 -1
- package/dist/core/transaction.js +112 -15
- package/dist/core/transaction.js.map +1 -1
- package/dist/document.js +1 -1
- package/dist/export/render.js +78 -0
- package/dist/export/render.js.map +1 -0
- package/dist/flow-editor.js.map +1 -1
- package/dist/flow-editor.vue_vue_type_script_setup_true_lang.js +454 -36
- package/dist/flow-editor.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/kit.js +1 -1
- package/dist/locale.js +24 -9
- package/dist/locale.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/style.js +2 -1
- package/dist/types/collaboration/index.d.ts +32 -4
- package/dist/types/comments.d.ts +73 -0
- package/dist/types/components/default-node.d.ts +1 -1
- package/dist/types/components/flow-comments.vue.d.ts +35 -0
- package/dist/types/components/port.d.ts +7 -0
- package/dist/types/context.d.ts +54 -1
- package/dist/types/core/extension.d.ts +2 -1
- package/dist/types/core/history.d.ts +10 -0
- package/dist/types/core/menu.d.ts +5 -0
- package/dist/types/core/model.d.ts +19 -0
- package/dist/types/core/node-types.d.ts +16 -2
- package/dist/types/core/transaction.d.ts +23 -1
- package/dist/types/export/render.d.ts +27 -0
- package/dist/types/flow-editor.vue.d.ts +11 -0
- package/dist/types/index.d.ts +36 -9
- package/dist/types/locale.d.ts +13 -3
- package/dist/types/whiteboard/image.d.ts +8 -0
- package/dist/types/whiteboard/index.d.ts +1 -1
- package/dist/types/whiteboard/kit.d.ts +7 -1
- package/dist/types/whiteboard/model.d.ts +2 -11
- package/dist/types/whiteboard/state.d.ts +5 -1
- package/dist/whiteboard/board-node.js.map +1 -1
- package/dist/whiteboard/board-node.vue_vue_type_script_setup_true_lang.js +3 -3
- package/dist/whiteboard/board-node.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/whiteboard/connector.js +5 -10
- package/dist/whiteboard/connector.js.map +1 -1
- package/dist/whiteboard/image.js +17 -6
- package/dist/whiteboard/image.js.map +1 -1
- package/dist/whiteboard/kit.js +64 -8
- package/dist/whiteboard/kit.js.map +1 -1
- package/dist/whiteboard/model.js +4 -31
- package/dist/whiteboard/model.js.map +1 -1
- package/dist/whiteboard/state.js +6 -1
- package/dist/whiteboard/state.js.map +1 -1
- package/dist/whiteboard/whiteboard-toolbar.js.map +1 -1
- package/dist/whiteboard/whiteboard-toolbar.vue_vue_type_script_setup_true_lang.js +14 -7
- package/dist/whiteboard/whiteboard-toolbar.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { flowEditorKey } from "./context.js";
|
|
2
|
-
import { boundsOf, clampPan, intersects, intersectsTurned, rectFrom, snapBox } from "./core/geometry.js";
|
|
3
|
-
import { labelOf, nodeBounds, portsOf, resizeOf } from "./core/node-types.js";
|
|
2
|
+
import { boundsOf, clampPan, intersects, intersectsTurned, rectFrom, snapBox, turn } from "./core/geometry.js";
|
|
3
|
+
import { labelOf, nodeBounds, portSide, portsOf, resizeOf, warnUnknownNodeType } from "./core/node-types.js";
|
|
4
4
|
import node_view_default from "./components/node-view.js";
|
|
5
5
|
import flow_menu_default from "./components/flow-menu.js";
|
|
6
|
+
import { format, useFlowMessages } from "./locale.js";
|
|
7
|
+
import flow_comments_default from "./components/flow-comments.js";
|
|
8
|
+
import { resolveFlowExtensions } from "./core/extension.js";
|
|
9
|
+
import { useFlowComments } from "./comments.js";
|
|
6
10
|
import flow_quick_add_default from "./components/flow-quick-add.js";
|
|
7
11
|
import flow_toolbar_default from "./components/flow-toolbar.js";
|
|
8
12
|
import { drawTools } from "./export/context.js";
|
|
@@ -13,8 +17,6 @@ import { canJoin, displacedEdges, joinRefusal, primaryType, typesMatch } from ".
|
|
|
13
17
|
import { FlowTransaction } from "./core/transaction.js";
|
|
14
18
|
import { FlowHistory } from "./core/history.js";
|
|
15
19
|
import { flowOrder } from "./core/order.js";
|
|
16
|
-
import { resolveFlowExtensions } from "./core/extension.js";
|
|
17
|
-
import { format, useFlowMessages } from "./locale.js";
|
|
18
20
|
import { flowKit } from "./kit.js";
|
|
19
21
|
import { readClipboard, writeClipboard } from "./core/clipboard.js";
|
|
20
22
|
import { createId, emptyDocument, emptySelection } from "./core/model.js";
|
|
@@ -93,12 +95,23 @@ var FIT_PADDING = 40;
|
|
|
93
95
|
* that; what still doesn't fit starts at the top left, to be panned to.
|
|
94
96
|
*/
|
|
95
97
|
var PANEL_GAP = 16;
|
|
98
|
+
var TIDY_NEAR = 24;
|
|
96
99
|
var FIELDS = "input, textarea, [contenteditable]:not([contenteditable=\"false\"]), [data-dou-nodrag]";
|
|
97
100
|
var MAGNET = 24;
|
|
98
101
|
var FIND_INSET = 12;
|
|
99
102
|
var DRAW_MARGIN = 200;
|
|
100
103
|
/** The part of the canvas that is drawn: the view and a margin around it. */
|
|
101
104
|
var TINY = .2;
|
|
105
|
+
var EDGE_LABEL_HALF = 10;
|
|
106
|
+
/** How far above an edge's label its marker sits, in screen px; a finger's target adds 8 (style.css). */
|
|
107
|
+
var EDGE_MARKER_LIFT = 14;
|
|
108
|
+
/** A marker's size, and how far apart two markers' middles keep, so a finger's 40px targets don't overlap. */
|
|
109
|
+
var MARKER_SIZE = 24;
|
|
110
|
+
var MARKER_GAP = 32;
|
|
111
|
+
/**
|
|
112
|
+
* A marker's middle, in px within the editor: a node's sits off its top
|
|
113
|
+
* right corner, a pin's bottom left corner is on its point (style.css).
|
|
114
|
+
*/
|
|
102
115
|
var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
103
116
|
name: "DouFlowEditor",
|
|
104
117
|
__name: "flow-editor",
|
|
@@ -136,8 +149,19 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
136
149
|
portTypes: {},
|
|
137
150
|
acyclic: { type: Boolean },
|
|
138
151
|
canConnect: {},
|
|
152
|
+
bordered: {
|
|
153
|
+
type: Boolean,
|
|
154
|
+
default: true
|
|
155
|
+
},
|
|
139
156
|
ariaLabel: {},
|
|
140
|
-
messages: {}
|
|
157
|
+
messages: {},
|
|
158
|
+
comments: { default: void 0 },
|
|
159
|
+
author: { default: void 0 },
|
|
160
|
+
activeComment: { default: void 0 },
|
|
161
|
+
commentable: {
|
|
162
|
+
type: Boolean,
|
|
163
|
+
default: true
|
|
164
|
+
}
|
|
141
165
|
}, {
|
|
142
166
|
"modelValue": { default: emptyDocument },
|
|
143
167
|
"modelModifiers": {},
|
|
@@ -153,6 +177,9 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
153
177
|
emits: /*@__PURE__*/ mergeModels([
|
|
154
178
|
"transaction",
|
|
155
179
|
"transactionCancel",
|
|
180
|
+
"update:comments",
|
|
181
|
+
"update:activeComment",
|
|
182
|
+
"commentAction",
|
|
156
183
|
"nodeClick",
|
|
157
184
|
"nodeDblclick",
|
|
158
185
|
"nodeContextmenu",
|
|
@@ -191,7 +218,20 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
191
218
|
/** The axis that levels two ports on this side. */
|
|
192
219
|
const level = (side) => side === "left" || side === "right" ? "y" : "x";
|
|
193
220
|
const same = (a, b) => a.length === b.length && a.every((id, i) => id === b[i]);
|
|
194
|
-
const
|
|
221
|
+
const { comments, extension: commentsExtension, anchors: getCommentAnchors, anchorOf: commentAnchorOf } = useFlowComments({
|
|
222
|
+
props,
|
|
223
|
+
emit,
|
|
224
|
+
doc,
|
|
225
|
+
selection,
|
|
226
|
+
messages,
|
|
227
|
+
transact,
|
|
228
|
+
carry: (on, patch) => !customHistory && history.carry(on, patch),
|
|
229
|
+
shownOn: (on) => commentSpots.value.find((spot) => spot.key === spotKey(on))?.threads
|
|
230
|
+
});
|
|
231
|
+
const resolved = computed(() => {
|
|
232
|
+
const own = props.extensions ?? flowKit();
|
|
233
|
+
return resolveFlowExtensions(comments.enabled.value ? [...own, commentsExtension] : own);
|
|
234
|
+
});
|
|
195
235
|
const types = computed(() => {
|
|
196
236
|
const map = new Map(resolved.value.nodeTypes);
|
|
197
237
|
for (const spec of props.nodeTypes ?? []) map.set(spec.type, spec);
|
|
@@ -209,6 +249,9 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
209
249
|
/** The type of edges without one: the prop, else the extensions', else bezier. */
|
|
210
250
|
const defaultEdgeType = computed(() => props.edgeType ?? resolved.value.edgeType ?? "bezier");
|
|
211
251
|
const edgeTypeOf = (type) => edgeTypes.value.get(type ?? defaultEdgeType.value) ?? edgeTypes.value.get(defaultEdgeType.value) ?? bezierEdge;
|
|
252
|
+
if (process.env.NODE_ENV !== "production") watch(() => [doc.value.nodes, types.value], ([nodes, map]) => {
|
|
253
|
+
for (const node of nodes) if (node.type && !map.has(node.type)) warnUnknownNodeType(node.type);
|
|
254
|
+
}, { immediate: true });
|
|
212
255
|
const specOf = (node) => types.value.get(node.type ?? "default") ?? types.value.get("default") ?? defaultNode;
|
|
213
256
|
/** Each node's ports by id, worked out once per change rather than per edge. */
|
|
214
257
|
const portsByNode = computed(() => {
|
|
@@ -515,9 +558,14 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
515
558
|
const out = [];
|
|
516
559
|
const edges = doc.value.edges;
|
|
517
560
|
edges.length;
|
|
518
|
-
|
|
561
|
+
const tweening = tween.value !== null;
|
|
562
|
+
for (let edge of toRaw(edges)) {
|
|
519
563
|
const from = edgeEnd(edge.source);
|
|
520
564
|
const to = edgeEnd(edge.target);
|
|
565
|
+
if (edge.points && (tweening || from !== edge.source || to !== edge.target)) edge = {
|
|
566
|
+
...edge,
|
|
567
|
+
points: void 0
|
|
568
|
+
};
|
|
521
569
|
if (from.node === to.node && (from !== edge.source || to !== edge.target)) continue;
|
|
522
570
|
const source = nodeById.value.get(from.node);
|
|
523
571
|
const target = nodeById.value.get(to.node);
|
|
@@ -525,14 +573,22 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
525
573
|
const a = anchor(source, from.port, "source");
|
|
526
574
|
const b = anchor(target, to.port, "target");
|
|
527
575
|
if (!a || !b) continue;
|
|
576
|
+
const xs = [a.x, b.x];
|
|
577
|
+
const ys = [a.y, b.y];
|
|
578
|
+
for (const p of edge.points ?? []) {
|
|
579
|
+
xs.push(p.x);
|
|
580
|
+
ys.push(p.y);
|
|
581
|
+
}
|
|
582
|
+
const x = Math.min(...xs);
|
|
583
|
+
const y = Math.min(...ys);
|
|
528
584
|
out.push({
|
|
529
585
|
edge,
|
|
530
586
|
route: edgeTypeOf(edge.type).route(a, b, edge),
|
|
531
587
|
box: {
|
|
532
|
-
x:
|
|
533
|
-
y:
|
|
534
|
-
width: Math.
|
|
535
|
-
height: Math.
|
|
588
|
+
x: x - EDGE_REACH,
|
|
589
|
+
y: y - EDGE_REACH,
|
|
590
|
+
width: Math.max(...xs) - x + 160,
|
|
591
|
+
height: Math.max(...ys) - y + 160
|
|
536
592
|
},
|
|
537
593
|
style: edgeStyle(edge)
|
|
538
594
|
});
|
|
@@ -748,10 +804,11 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
748
804
|
}
|
|
749
805
|
/** Point on the screen relative to the editor's top left corner. */
|
|
750
806
|
function local(clientX, clientY) {
|
|
751
|
-
const
|
|
807
|
+
const el = root.value;
|
|
808
|
+
const rect = el.getBoundingClientRect();
|
|
752
809
|
return {
|
|
753
|
-
x: clientX - rect.left,
|
|
754
|
-
y: clientY - rect.top
|
|
810
|
+
x: clientX - rect.left - el.clientLeft,
|
|
811
|
+
y: clientY - rect.top - el.clientTop
|
|
755
812
|
};
|
|
756
813
|
}
|
|
757
814
|
function toCanvas(point) {
|
|
@@ -801,7 +858,7 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
801
858
|
left: FIT_PADDING,
|
|
802
859
|
right: FIT_PADDING
|
|
803
860
|
};
|
|
804
|
-
for (const panel of root.value.querySelectorAll(".dou-flow-editor__panels > :not(.dou-flow-toolbar)")) {
|
|
861
|
+
for (const panel of root.value.querySelectorAll(".dou-flow-editor__panels > :not(.dou-flow-toolbar, .dou-flow-editor__comments, .dou-flow-editor__comment-card)")) {
|
|
805
862
|
const rect = panel.getBoundingClientRect();
|
|
806
863
|
if (!rect.height) continue;
|
|
807
864
|
const upper = rect.top + rect.height / 2 < box.top + box.height / 2;
|
|
@@ -832,7 +889,7 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
832
889
|
zoom
|
|
833
890
|
}, animate);
|
|
834
891
|
}
|
|
835
|
-
/**
|
|
892
|
+
/** How near a note on a board is to a node, in px, to move along with it when tidying. */
|
|
836
893
|
const TIDY_GAP = {
|
|
837
894
|
horizontal: {
|
|
838
895
|
rank: 80,
|
|
@@ -844,6 +901,50 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
844
901
|
}
|
|
845
902
|
};
|
|
846
903
|
/**
|
|
904
|
+
* Which way tidying runs: the flow's `direction`, unless most edges between
|
|
905
|
+
* nodes with `ports: 'sides'` leave their nodes by the other
|
|
906
|
+
* sides, e.g. a whiteboard drawn top to bottom. Laying that out the other
|
|
907
|
+
* way would undo how it was drawn. Fixed ports say nothing about it.
|
|
908
|
+
*/
|
|
909
|
+
function tidiesVertically(blocks, blockOf) {
|
|
910
|
+
const vertical = props.direction === "vertical";
|
|
911
|
+
let along = 0;
|
|
912
|
+
let across = 0;
|
|
913
|
+
for (const edge of doc.value.edges) {
|
|
914
|
+
const from = blockOf(edge.source.node);
|
|
915
|
+
const to = blockOf(edge.target.node);
|
|
916
|
+
if (!from || !to || from === to || !blocks.has(from) || !blocks.has(to)) continue;
|
|
917
|
+
const port = portSpec(edge.source);
|
|
918
|
+
const node = nodeById.value.get(edge.source.node);
|
|
919
|
+
if (!port || !node || specOf(node).ports !== "sides" || specOf(node).rotation?.(node)) continue;
|
|
920
|
+
const side = portSide(port);
|
|
921
|
+
if ((side === "top" || side === "bottom") === vertical) along++;
|
|
922
|
+
else across++;
|
|
923
|
+
}
|
|
924
|
+
return across > along ? !vertical : vertical;
|
|
925
|
+
}
|
|
926
|
+
const OPPOSITE = {
|
|
927
|
+
top: "bottom",
|
|
928
|
+
bottom: "top",
|
|
929
|
+
left: "right",
|
|
930
|
+
right: "left"
|
|
931
|
+
};
|
|
932
|
+
/**
|
|
933
|
+
* The port an edge end moves to when tidying, on a node whose ports are
|
|
934
|
+
* `ports: 'sides'`: on the side facing the other end along the flow.
|
|
935
|
+
*/
|
|
936
|
+
function anchorFor(end, kind, side) {
|
|
937
|
+
const node = nodeById.value.get(end.node);
|
|
938
|
+
if (!node) return void 0;
|
|
939
|
+
const spec = specOf(node);
|
|
940
|
+
if (spec.ports !== "sides" || spec.rotation?.(node)) return void 0;
|
|
941
|
+
const port = portsOf(spec, node).find((p) => p.kind === kind && portSide(p) === side);
|
|
942
|
+
return port && port.id !== end.port ? {
|
|
943
|
+
...end,
|
|
944
|
+
port: port.id
|
|
945
|
+
} : void 0;
|
|
946
|
+
}
|
|
947
|
+
/**
|
|
847
948
|
* Lays the given nodes, or the selected ones when two or more are selected,
|
|
848
949
|
* or all, out in ranks along their edges in the flow's `direction`, as one
|
|
849
950
|
* undo step. The group keeps its top left corner; locked nodes stay put.
|
|
@@ -858,12 +959,26 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
858
959
|
return at;
|
|
859
960
|
};
|
|
860
961
|
const blocks = new Set([...chosen].flatMap((id) => blockOf(id) ?? []));
|
|
861
|
-
const
|
|
962
|
+
const board = [...blocks].some((id) => {
|
|
963
|
+
const node = nodeById.value.get(id);
|
|
964
|
+
return node && specOf(node).ports === "sides";
|
|
965
|
+
});
|
|
966
|
+
const linked = /* @__PURE__ */ new Set();
|
|
967
|
+
if (board) for (const edge of doc.value.edges) {
|
|
968
|
+
const a = blockOf(edge.source.node);
|
|
969
|
+
const b = blockOf(edge.target.node);
|
|
970
|
+
if (!a || !b || a === b || !blocks.has(a) || !blocks.has(b)) continue;
|
|
971
|
+
linked.add(a);
|
|
972
|
+
linked.add(b);
|
|
973
|
+
}
|
|
974
|
+
const loose = board ? doc.value.nodes.filter((n) => blocks.has(n.id) && !linked.has(n.id)) : [];
|
|
975
|
+
const nodes = doc.value.nodes.filter((node) => blocks.has(node.id) && (!board || linked.has(node.id)));
|
|
862
976
|
const bounds = boundsOf(nodes.map(rectOf));
|
|
863
977
|
if (!bounds || nodes.length < 2) return;
|
|
864
|
-
const vertical =
|
|
978
|
+
const vertical = tidiesVertically(blocks, blockOf);
|
|
865
979
|
const gap = TIDY_GAP[vertical ? "vertical" : "horizontal"];
|
|
866
980
|
const across = vertical ? ["top", "bottom"] : ["left", "right"];
|
|
981
|
+
const anchors = /* @__PURE__ */ new Map();
|
|
867
982
|
const layout = layoutGraph(nodes.map((node) => {
|
|
868
983
|
const m = metrics.get(node.id);
|
|
869
984
|
const { width, height } = rectOf(node);
|
|
@@ -872,6 +987,8 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
872
987
|
offset = vertical ? port.x : port.y;
|
|
873
988
|
break;
|
|
874
989
|
}
|
|
990
|
+
offset = Math.round(offset);
|
|
991
|
+
anchors.set(node.id, offset);
|
|
875
992
|
return {
|
|
876
993
|
id: node.id,
|
|
877
994
|
width,
|
|
@@ -886,11 +1003,12 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
886
1003
|
to
|
|
887
1004
|
}] : [];
|
|
888
1005
|
}), {
|
|
889
|
-
direction:
|
|
1006
|
+
direction: vertical ? "vertical" : "horizontal",
|
|
890
1007
|
rankGap: gap.rank,
|
|
891
1008
|
laneGap: gap.row,
|
|
892
1009
|
equalWidth: false,
|
|
893
|
-
grid: props.grid || 8
|
|
1010
|
+
grid: props.grid || 8,
|
|
1011
|
+
straightChains: true
|
|
894
1012
|
});
|
|
895
1013
|
const snap = (v) => props.grid ? Math.round(v / props.grid) * props.grid : Math.round(v);
|
|
896
1014
|
const origin = {
|
|
@@ -905,15 +1023,112 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
905
1023
|
for (const node of nodes) {
|
|
906
1024
|
const placed = layout.nodes.get(node.id);
|
|
907
1025
|
if (!placed || node.locked) continue;
|
|
908
|
-
const
|
|
909
|
-
|
|
1026
|
+
const offset = anchors.get(node.id) ?? 0;
|
|
1027
|
+
const to = vertical ? {
|
|
1028
|
+
x: origin.x + snap(placed.x + offset) - offset,
|
|
910
1029
|
y: origin.y + snap(placed.y)
|
|
1030
|
+
} : {
|
|
1031
|
+
x: origin.x + snap(placed.x),
|
|
1032
|
+
y: origin.y + snap(placed.y + offset) - offset
|
|
911
1033
|
};
|
|
912
1034
|
if (to.x !== node.x || to.y !== node.y) moved.set(node.id, to);
|
|
913
1035
|
}
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
1036
|
+
for (const note of loose) {
|
|
1037
|
+
if (note.locked) continue;
|
|
1038
|
+
const rect = rectOf(note);
|
|
1039
|
+
let host;
|
|
1040
|
+
let best = Infinity;
|
|
1041
|
+
for (const node of nodes) {
|
|
1042
|
+
const other = rectOf(node);
|
|
1043
|
+
const apart = Math.max(other.x - (rect.x + rect.width), rect.x - (other.x + other.width), other.y - (rect.y + rect.height), rect.y - (other.y + other.height), 0);
|
|
1044
|
+
if (apart > TIDY_NEAR) continue;
|
|
1045
|
+
const score = apart * 1e6 + Math.hypot(other.x + other.width / 2 - (rect.x + rect.width / 2), other.y + other.height / 2 - (rect.y + rect.height / 2));
|
|
1046
|
+
if (score < best) {
|
|
1047
|
+
best = score;
|
|
1048
|
+
host = node;
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
const to = host && moved.get(host.id);
|
|
1052
|
+
if (!host || !to) continue;
|
|
1053
|
+
from.set(note.id, {
|
|
1054
|
+
x: note.x,
|
|
1055
|
+
y: note.y
|
|
1056
|
+
});
|
|
1057
|
+
moved.set(note.id, {
|
|
1058
|
+
x: note.x + to.x - host.x,
|
|
1059
|
+
y: note.y + to.y - host.y
|
|
1060
|
+
});
|
|
1061
|
+
}
|
|
1062
|
+
const through = new Map(layout.edges.map((e) => [`${e.from}\u0000${e.to}`, e.points]));
|
|
1063
|
+
const locked = new Set(nodes.filter((node) => node.locked).map((node) => node.id));
|
|
1064
|
+
const routes = /* @__PURE__ */ new Map();
|
|
1065
|
+
const pairs = /* @__PURE__ */ new Map();
|
|
1066
|
+
for (const edge of doc.value.edges) {
|
|
1067
|
+
const a = edge.source.node;
|
|
1068
|
+
const b = edge.target.node;
|
|
1069
|
+
if (!blocks.has(a) || !blocks.has(b)) continue;
|
|
1070
|
+
const key = `${a}\u0000${b}`;
|
|
1071
|
+
pairs.set(key, [...pairs.get(key) ?? [], edge]);
|
|
1072
|
+
}
|
|
1073
|
+
for (const [key, group] of pairs) {
|
|
1074
|
+
const [a, b] = key.split("\0");
|
|
1075
|
+
const points = locked.has(a) || locked.has(b) ? void 0 : through.get(key);
|
|
1076
|
+
group.forEach((edge, i) => {
|
|
1077
|
+
const off = (i - (group.length - 1) / 2) * (props.grid || 8);
|
|
1078
|
+
const next = points?.length ? points.map((p) => ({
|
|
1079
|
+
x: origin.x + snap(p.x) + (vertical ? off : 0),
|
|
1080
|
+
y: origin.y + snap(p.y) + (vertical ? 0 : off)
|
|
1081
|
+
})) : void 0;
|
|
1082
|
+
routes.set(edge.id, next);
|
|
1083
|
+
});
|
|
1084
|
+
}
|
|
1085
|
+
const rankOf = new Map(layout.ranks.flatMap((rank, i) => rank.map((id) => [id, i])));
|
|
1086
|
+
const centre = (id) => {
|
|
1087
|
+
const rect = rectOf(nodeById.value.get(id));
|
|
1088
|
+
const block = blockOf(id);
|
|
1089
|
+
const to = moved.get(block);
|
|
1090
|
+
const was = from.get(block);
|
|
1091
|
+
const dx = to ? to.x - was.x : 0;
|
|
1092
|
+
const dy = to ? to.y - was.y : 0;
|
|
1093
|
+
return {
|
|
1094
|
+
x: rect.x + dx + rect.width / 2,
|
|
1095
|
+
y: rect.y + dy + rect.height / 2
|
|
1096
|
+
};
|
|
1097
|
+
};
|
|
1098
|
+
const ends = /* @__PURE__ */ new Map();
|
|
1099
|
+
const joined = /* @__PURE__ */ new Set();
|
|
1100
|
+
for (const edge of doc.value.edges) {
|
|
1101
|
+
const a = blockOf(edge.source.node);
|
|
1102
|
+
const b = blockOf(edge.target.node);
|
|
1103
|
+
if (a && b) joined.add(`${a}\u0000${b}`);
|
|
1104
|
+
}
|
|
1105
|
+
const middle = (vertical ? origin.x + layout.width / 2 : origin.y + layout.height / 2) - .5;
|
|
1106
|
+
for (const edge of doc.value.edges) {
|
|
1107
|
+
const a = blockOf(edge.source.node);
|
|
1108
|
+
const b = blockOf(edge.target.node);
|
|
1109
|
+
if (!a || !b || a === b || !blocks.has(a) || !blocks.has(b)) continue;
|
|
1110
|
+
const s = centre(edge.source.node);
|
|
1111
|
+
const t = centre(edge.target.node);
|
|
1112
|
+
const along = !locked.has(a) && !locked.has(b) ? (rankOf.get(b) ?? 0) - (rankOf.get(a) ?? 0) : Math.round(vertical ? t.y - s.y : t.x - s.x);
|
|
1113
|
+
const aside = vertical ? t.x - s.x : t.y - s.y;
|
|
1114
|
+
const out = along ? vertical ? along > 0 ? "bottom" : "top" : along > 0 ? "right" : "left" : vertical ? aside >= 0 ? "right" : "left" : aside >= 0 ? "bottom" : "top";
|
|
1115
|
+
const round = along < 0 && (along < -1 || joined.has(`${b}\u0000${a}`));
|
|
1116
|
+
const outer = vertical ? (s.x + t.x) / 2 >= middle ? "right" : "left" : (s.y + t.y) / 2 >= middle ? "bottom" : "top";
|
|
1117
|
+
const source = anchorFor(edge.source, "output", round ? outer : out);
|
|
1118
|
+
const target = anchorFor(edge.target, "input", round ? outer : OPPOSITE[out]);
|
|
1119
|
+
if (source || target) ends.set(edge.id, {
|
|
1120
|
+
source: source ?? edge.source,
|
|
1121
|
+
target: target ?? edge.target
|
|
1122
|
+
});
|
|
1123
|
+
}
|
|
1124
|
+
const rerouted = ends.size > 0 || doc.value.edges.some((edge) => routes.has(edge.id) && JSON.stringify(routes.get(edge.id)) !== JSON.stringify(edge.points));
|
|
1125
|
+
if (!moved.size && !rerouted) return;
|
|
1126
|
+
const edgesBefore = new Map(doc.value.edges.map((e) => [e.id, e]));
|
|
1127
|
+
const count = (/* @__PURE__ */ new Set([...[...moved.keys()].filter((id) => !linked.size || linked.has(id)), ...[...ends].flatMap(([id, end]) => {
|
|
1128
|
+
const was = edgesBefore.get(id);
|
|
1129
|
+
return [...was?.source.port !== end.source.port ? [end.source.node] : [], ...was?.target.port !== end.target.port ? [end.target.node] : []];
|
|
1130
|
+
})])).size;
|
|
1131
|
+
for (const { id } of [...nodes, ...loose]) {
|
|
917
1132
|
const to = moved.get(id);
|
|
918
1133
|
if (!to) continue;
|
|
919
1134
|
const block = from.get(id);
|
|
@@ -932,12 +1147,17 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
932
1147
|
}
|
|
933
1148
|
transact((tr) => {
|
|
934
1149
|
for (const [id, to] of moved) tr.moveNode(id, to.x, to.y);
|
|
1150
|
+
for (const [id, end] of ends) tr.updateEdge(id, end);
|
|
1151
|
+
for (const [id, points] of routes) if (JSON.stringify(points) !== JSON.stringify(tr.getEdge(id)?.points)) tr.updateEdge(id, { points });
|
|
935
1152
|
});
|
|
936
1153
|
announce(format(messages.value.tidied, { count }));
|
|
937
1154
|
animateTidy(from, moved);
|
|
938
|
-
const after = boundsOf(nodes.map((node) => ({
|
|
1155
|
+
const after = boundsOf([...nodes, ...loose].map((node) => ({
|
|
939
1156
|
...rectOf(node),
|
|
940
|
-
...moved.get(node.id) ??
|
|
1157
|
+
...moved.get(node.id) ?? {
|
|
1158
|
+
x: node.x,
|
|
1159
|
+
y: node.y
|
|
1160
|
+
}
|
|
941
1161
|
})));
|
|
942
1162
|
const { x, y, zoom } = viewport.value;
|
|
943
1163
|
const { width, height } = size.value;
|
|
@@ -982,7 +1202,11 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
982
1202
|
/** Keeps a node in view, e.g. when it gets keyboard focus. */
|
|
983
1203
|
function reveal(id) {
|
|
984
1204
|
const rect = getNodeRect(id);
|
|
985
|
-
if (
|
|
1205
|
+
if (rect) revealRect(rect);
|
|
1206
|
+
}
|
|
1207
|
+
/** Pans the least that brings `rect`, in canvas coordinates, into view. */
|
|
1208
|
+
function revealRect(rect) {
|
|
1209
|
+
if (!root.value) return;
|
|
986
1210
|
const { x, y, zoom } = viewport.value;
|
|
987
1211
|
const pad = 16;
|
|
988
1212
|
const left = rect.x * zoom + x;
|
|
@@ -1098,7 +1322,7 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
1098
1322
|
}
|
|
1099
1323
|
if (event.button !== 0) return;
|
|
1100
1324
|
if (target.closest(".dou-flow-editor__label-input")) return;
|
|
1101
|
-
if (resolved.value.presses.length && !
|
|
1325
|
+
if (resolved.value.presses.length && !isInteractive(target)) {
|
|
1102
1326
|
const pressedId = target.closest("[data-node-id]")?.dataset.nodeId;
|
|
1103
1327
|
const press = {
|
|
1104
1328
|
point: toCanvas(client),
|
|
@@ -1946,6 +2170,8 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
1946
2170
|
x,
|
|
1947
2171
|
y,
|
|
1948
2172
|
locked: void 0,
|
|
2173
|
+
comments: void 0,
|
|
2174
|
+
commentPins: void 0,
|
|
1949
2175
|
parent: copied ?? containerAt(centre, containers)
|
|
1950
2176
|
};
|
|
1951
2177
|
});
|
|
@@ -1957,7 +2183,12 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
1957
2183
|
if (!source || !target) continue;
|
|
1958
2184
|
tr.addEdge({
|
|
1959
2185
|
...edge,
|
|
2186
|
+
points: edge.points?.map((p) => ({
|
|
2187
|
+
x: p.x + shift.x,
|
|
2188
|
+
y: p.y + shift.y
|
|
2189
|
+
})),
|
|
1960
2190
|
id: createId("e"),
|
|
2191
|
+
comments: void 0,
|
|
1961
2192
|
source: {
|
|
1962
2193
|
...edge.source,
|
|
1963
2194
|
node: source
|
|
@@ -2209,14 +2440,18 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
2209
2440
|
window.removeEventListener("pointerdown", onMenuPress, true);
|
|
2210
2441
|
window.removeEventListener("click", onMenuClick);
|
|
2211
2442
|
});
|
|
2443
|
+
/** The toolbar's groups with something in; while read-only, only what is offered then too, such as comments. */
|
|
2444
|
+
function offeredItems(lists, readonly) {
|
|
2445
|
+
return lists.map((list) => readonly ? list.filter((item) => item.showWhenReadonly) : list).filter((list) => list.length);
|
|
2446
|
+
}
|
|
2212
2447
|
const toolbarItems = computed(() => {
|
|
2213
|
-
if (
|
|
2448
|
+
if (gesture.value || keyLink.value || quickAdd.value) return [];
|
|
2214
2449
|
const nodes = selection.value.nodes.flatMap((id) => nodeById.value.get(id) ?? []);
|
|
2215
|
-
if (nodes.length) return resolved.value.toolbars.map((fn) => fn(context, nodes))
|
|
2450
|
+
if (nodes.length) return offeredItems(resolved.value.toolbars.map((fn) => fn(context, nodes)), props.readonly);
|
|
2216
2451
|
const ids = new Set(selection.value.edges);
|
|
2217
2452
|
const edges = doc.value.edges.filter((edge) => ids.has(edge.id));
|
|
2218
2453
|
if (!edges.length) return [];
|
|
2219
|
-
return resolved.value.edgeToolbars.map((fn) => fn(context, edges))
|
|
2454
|
+
return offeredItems(resolved.value.edgeToolbars.map((fn) => fn(context, edges)), props.readonly);
|
|
2220
2455
|
});
|
|
2221
2456
|
/** Where the toolbar floats: above the selected nodes, in screen px within the editor. */
|
|
2222
2457
|
const toolbarAnchor = computed(() => {
|
|
@@ -2247,9 +2482,12 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
2247
2482
|
height: bounds.height + reach * 2
|
|
2248
2483
|
};
|
|
2249
2484
|
const avoid = nodes.length ? void 0 : shownNodes.value.filter((node) => !hiddenIn.value.has(node.id) && !isContainer(node)).map((node) => rectOf(node)).filter((rect) => intersects(rect, band)).map(screen);
|
|
2485
|
+
const keys = /* @__PURE__ */ new Set([...nodes.map((id) => `n:${id}`), ...edges.map((id) => `e:${id}`)]);
|
|
2486
|
+
const marked = commentMarkers.value.filter((marker) => keys.has(marker.key));
|
|
2487
|
+
const top = Math.min(bounds.y * zoom + y, ...marked.map(markerTop));
|
|
2250
2488
|
return {
|
|
2251
2489
|
x: (bounds.x + bounds.width / 2) * zoom + x,
|
|
2252
|
-
top
|
|
2490
|
+
top,
|
|
2253
2491
|
bottom: (bounds.y + bounds.height) * zoom + y,
|
|
2254
2492
|
avoid
|
|
2255
2493
|
};
|
|
@@ -3157,7 +3395,8 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
3157
3395
|
"is-space": spaceHeld.value,
|
|
3158
3396
|
"is-dragging": !!dragging.value,
|
|
3159
3397
|
"is-connecting": !!connecting.value,
|
|
3160
|
-
"is-refused": !!connecting.value?.refused
|
|
3398
|
+
"is-refused": !!connecting.value?.refused,
|
|
3399
|
+
"is-bordered": props.bordered
|
|
3161
3400
|
}));
|
|
3162
3401
|
const context = {
|
|
3163
3402
|
exportSVG,
|
|
@@ -3182,6 +3421,8 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
3182
3421
|
portTypeOf,
|
|
3183
3422
|
colorOf,
|
|
3184
3423
|
getNodeRect,
|
|
3424
|
+
comment: (on, options) => comments.start(on, options?.focus ?? true),
|
|
3425
|
+
canComment: comments.writable,
|
|
3185
3426
|
tidy,
|
|
3186
3427
|
centerNode,
|
|
3187
3428
|
announce,
|
|
@@ -3371,6 +3612,170 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
3371
3612
|
...PNG_SOURCE
|
|
3372
3613
|
});
|
|
3373
3614
|
}
|
|
3615
|
+
/** Half an edge label's height, in canvas px. */
|
|
3616
|
+
const markerCenter = (marker) => marker.number !== void 0 ? {
|
|
3617
|
+
x: marker.x + MARKER_SIZE / 2,
|
|
3618
|
+
y: marker.y - MARKER_SIZE / 2
|
|
3619
|
+
} : "node" in marker.anchor ? {
|
|
3620
|
+
x: marker.x + 6 + MARKER_SIZE / 2,
|
|
3621
|
+
y: marker.y - 6 - MARKER_SIZE / 2
|
|
3622
|
+
} : {
|
|
3623
|
+
x: marker.x,
|
|
3624
|
+
y: marker.y
|
|
3625
|
+
};
|
|
3626
|
+
/** A marker's key: one per node and edge, and one per pin (`thread`; a pin being started has none). */
|
|
3627
|
+
const spotKey = (on, thread) => "edge" in on ? `e:${on.edge}` : on.at ? `p:${thread ?? ""}` : `n:${on.node}`;
|
|
3628
|
+
/** The top of a marker with a finger's target around it, in px within the editor. */
|
|
3629
|
+
const markerTop = (marker) => markerCenter(marker).y - MARKER_SIZE / 2 - 8 - (marker.lifted ? 8 : 0);
|
|
3630
|
+
/** Where a node or edge shows its comments: a collapsed container hiding it shows them instead. */
|
|
3631
|
+
function commentSpotOf(on) {
|
|
3632
|
+
const hidden = hiddenIn.value;
|
|
3633
|
+
if ("node" in on) {
|
|
3634
|
+
if (!nodeById.value.has(on.node)) return null;
|
|
3635
|
+
const outer = hidden.get(on.node);
|
|
3636
|
+
return outer ? { node: outer } : on;
|
|
3637
|
+
}
|
|
3638
|
+
if (edgeRouteById.value.has(on.edge)) return on;
|
|
3639
|
+
const edge = doc.value.edges.find((e) => e.id === on.edge);
|
|
3640
|
+
const outer = edge && (hidden.get(edge.source.node) ?? hidden.get(edge.target.node));
|
|
3641
|
+
return outer ? { node: outer } : null;
|
|
3642
|
+
}
|
|
3643
|
+
const edgeRouteById = computed(() => new Map(edgeRoutes.value.map((item) => [item.edge.id, item])));
|
|
3644
|
+
/**
|
|
3645
|
+
* The markers, in canvas px: one at the top right of each node and on each
|
|
3646
|
+
* edge's middle with open threads. Worked out as the document changes; the
|
|
3647
|
+
* view only moves them, below.
|
|
3648
|
+
*/
|
|
3649
|
+
const commentSpots = computed(() => {
|
|
3650
|
+
if (!comments.enabled.value) return [];
|
|
3651
|
+
const { nodes, edges, pins } = comments.openOn.value;
|
|
3652
|
+
const spots = /* @__PURE__ */ new Map();
|
|
3653
|
+
const add = (on, threads, extra = {}) => {
|
|
3654
|
+
const spot = commentSpotOf(on);
|
|
3655
|
+
if (!spot) return;
|
|
3656
|
+
const key = spotKey(spot, extra.thread);
|
|
3657
|
+
const had = spots.get(key);
|
|
3658
|
+
if (had) {
|
|
3659
|
+
for (const id of threads) if (!had.threads.includes(id)) had.threads.push(id);
|
|
3660
|
+
if (extra.pending) had.pending = true;
|
|
3661
|
+
return;
|
|
3662
|
+
}
|
|
3663
|
+
let at;
|
|
3664
|
+
let lift = 0;
|
|
3665
|
+
if ("node" in spot && spot.at) {
|
|
3666
|
+
const node = nodeById.value.get(spot.node);
|
|
3667
|
+
const rect = rectOf(node);
|
|
3668
|
+
const point = {
|
|
3669
|
+
x: rect.x + spot.at.x * rect.width,
|
|
3670
|
+
y: rect.y + spot.at.y * rect.height
|
|
3671
|
+
};
|
|
3672
|
+
const centre = {
|
|
3673
|
+
x: rect.x + rect.width / 2,
|
|
3674
|
+
y: rect.y + rect.height / 2
|
|
3675
|
+
};
|
|
3676
|
+
at = turn(point, centre, nodeRotation(node.id));
|
|
3677
|
+
} else if ("node" in spot) {
|
|
3678
|
+
const node = nodeById.value.get(spot.node);
|
|
3679
|
+
const box = nodeBounds(specOf(node), node, rectOf(node));
|
|
3680
|
+
at = {
|
|
3681
|
+
x: box.x + box.width,
|
|
3682
|
+
y: box.y
|
|
3683
|
+
};
|
|
3684
|
+
} else {
|
|
3685
|
+
const item = edgeRouteById.value.get(spot.edge);
|
|
3686
|
+
at = item.route.label;
|
|
3687
|
+
if (item.edge.label) {
|
|
3688
|
+
at = {
|
|
3689
|
+
x: at.x,
|
|
3690
|
+
y: at.y - EDGE_LABEL_HALF
|
|
3691
|
+
};
|
|
3692
|
+
lift = EDGE_MARKER_LIFT;
|
|
3693
|
+
}
|
|
3694
|
+
}
|
|
3695
|
+
spots.set(key, {
|
|
3696
|
+
key,
|
|
3697
|
+
anchor: spot,
|
|
3698
|
+
threads: [...threads],
|
|
3699
|
+
shown: [],
|
|
3700
|
+
pending: !!extra.pending,
|
|
3701
|
+
number: "node" in spot && spot.at ? extra.number ?? spot.number ?? 0 : void 0,
|
|
3702
|
+
node: "node" in spot ? nodeName(spot.node) : void 0,
|
|
3703
|
+
...at,
|
|
3704
|
+
lift
|
|
3705
|
+
});
|
|
3706
|
+
};
|
|
3707
|
+
for (const [id, threads] of nodes) add({ node: id }, threads);
|
|
3708
|
+
for (const pin of pins) add({
|
|
3709
|
+
node: pin.node,
|
|
3710
|
+
at: pin.at
|
|
3711
|
+
}, [pin.thread], {
|
|
3712
|
+
number: pin.number,
|
|
3713
|
+
thread: pin.thread
|
|
3714
|
+
});
|
|
3715
|
+
for (const [id, threads] of edges) add({ edge: id }, threads);
|
|
3716
|
+
const starting = comments.pending.value;
|
|
3717
|
+
if (starting) add(starting, [], { pending: true });
|
|
3718
|
+
const list = [...spots.values()];
|
|
3719
|
+
const active = comments.active.value;
|
|
3720
|
+
const where = active ? commentAnchorOf(active) : null;
|
|
3721
|
+
for (const spot of list) spot.shown = spot.threads;
|
|
3722
|
+
if (active && where) {
|
|
3723
|
+
const spot = commentSpotOf(where);
|
|
3724
|
+
const key = spot && spotKey(spot, active);
|
|
3725
|
+
const there = key && spots.get(key);
|
|
3726
|
+
if (there && !there.threads.includes(active)) there.shown = [...there.threads, active];
|
|
3727
|
+
else if (!there) {
|
|
3728
|
+
add(where, [], { thread: active });
|
|
3729
|
+
const added = key && spots.get(key);
|
|
3730
|
+
if (added) {
|
|
3731
|
+
added.shown = [active];
|
|
3732
|
+
list.push(added);
|
|
3733
|
+
}
|
|
3734
|
+
}
|
|
3735
|
+
}
|
|
3736
|
+
return list;
|
|
3737
|
+
});
|
|
3738
|
+
/**
|
|
3739
|
+
* The markers in px within the editor: only this follows the view as it
|
|
3740
|
+
* pans and zooms. An edge's marker that would sit on another one moves
|
|
3741
|
+
* aside, so each can be tapped.
|
|
3742
|
+
*/
|
|
3743
|
+
const commentMarkers = computed(() => {
|
|
3744
|
+
const { x: vx, y: vy, zoom } = viewport.value;
|
|
3745
|
+
const markers = commentSpots.value.map(({ x, y, lift, ...spot }) => ({
|
|
3746
|
+
...spot,
|
|
3747
|
+
x: x * zoom + vx,
|
|
3748
|
+
y: y * zoom + vy - lift,
|
|
3749
|
+
lifted: lift > 0
|
|
3750
|
+
}));
|
|
3751
|
+
const placed = markers.filter((marker) => "node" in marker.anchor).map(markerCenter);
|
|
3752
|
+
for (const marker of markers) {
|
|
3753
|
+
if ("node" in marker.anchor) continue;
|
|
3754
|
+
for (let tries = 0; tries < 8; tries++) {
|
|
3755
|
+
const other = placed.find((p) => Math.abs(p.x - marker.x) < MARKER_GAP && Math.abs(p.y - marker.y) < MARKER_GAP);
|
|
3756
|
+
if (!other) break;
|
|
3757
|
+
marker.x = other.x + (marker.x < other.x ? -32 : MARKER_GAP);
|
|
3758
|
+
}
|
|
3759
|
+
placed.push(markerCenter(marker));
|
|
3760
|
+
}
|
|
3761
|
+
return markers;
|
|
3762
|
+
});
|
|
3763
|
+
watch(() => props.activeComment, (id) => {
|
|
3764
|
+
const at = id && !comments.openedHere(id) ? commentAnchorOf(id) : null;
|
|
3765
|
+
const on = at && commentSpotOf(at);
|
|
3766
|
+
if (!on) return;
|
|
3767
|
+
if ("node" in on) return reveal(on.node);
|
|
3768
|
+
const label = edgeRouteById.value.get(on.edge)?.route.label;
|
|
3769
|
+
if (label) revealRect({
|
|
3770
|
+
x: label.x - 16,
|
|
3771
|
+
y: label.y - 16,
|
|
3772
|
+
width: 32,
|
|
3773
|
+
height: 32
|
|
3774
|
+
});
|
|
3775
|
+
});
|
|
3776
|
+
function restoreCommentFocus(on) {
|
|
3777
|
+
((on && "node" in on ? root.value?.querySelector(`[data-node-id="${CSS.escape(on.node)}"]`) : null) ?? root.value)?.focus({ preventScroll: true });
|
|
3778
|
+
}
|
|
3374
3779
|
__expose({
|
|
3375
3780
|
setViewport,
|
|
3376
3781
|
openSearch,
|
|
@@ -3399,6 +3804,8 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
3399
3804
|
return [...staleEdges.value];
|
|
3400
3805
|
},
|
|
3401
3806
|
removeStaleEdges,
|
|
3807
|
+
comment: (on, options) => comments.start(on, options?.focus ?? true),
|
|
3808
|
+
getCommentAnchors,
|
|
3402
3809
|
insertNode,
|
|
3403
3810
|
startInsertDrag,
|
|
3404
3811
|
editLabel,
|
|
@@ -3627,8 +4034,19 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
3627
4034
|
(openBlock(true), createElementBlock(Fragment, null, renderList(resolved.value.overlays, (overlay, i) => {
|
|
3628
4035
|
return openBlock(), createBlock(resolveDynamicComponent(overlay), { key: i });
|
|
3629
4036
|
}), 128)),
|
|
3630
|
-
|
|
4037
|
+
unref(comments).enabled.value ? (openBlock(), createBlock(flow_comments_default, {
|
|
3631
4038
|
key: 0,
|
|
4039
|
+
comments: unref(comments),
|
|
4040
|
+
markers: commentMarkers.value,
|
|
4041
|
+
messages: unref(messages),
|
|
4042
|
+
restore: restoreCommentFocus
|
|
4043
|
+
}, null, 8, [
|
|
4044
|
+
"comments",
|
|
4045
|
+
"markers",
|
|
4046
|
+
"messages"
|
|
4047
|
+
])) : createCommentVNode("", true),
|
|
4048
|
+
toolbarItems.value.length && toolbarAnchor.value ? (openBlock(), createBlock(flow_toolbar_default, {
|
|
4049
|
+
key: 1,
|
|
3632
4050
|
groups: toolbarItems.value,
|
|
3633
4051
|
anchor: toolbarAnchor.value,
|
|
3634
4052
|
size: size.value
|
|
@@ -3638,7 +4056,7 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
3638
4056
|
"size"
|
|
3639
4057
|
])) : createCommentVNode("", true),
|
|
3640
4058
|
findOpen.value ? (openBlock(), createElementBlock("div", {
|
|
3641
|
-
key:
|
|
4059
|
+
key: 2,
|
|
3642
4060
|
ref_key: "findBox",
|
|
3643
4061
|
ref: findBox,
|
|
3644
4062
|
class: "dou-flow-editor__find",
|