@dou-ui/flow 0.1.0-alpha.2 → 0.1.0-alpha.4
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/comments.js +177 -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 +184 -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/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 +8 -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 +276 -23
- package/dist/flow-editor.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/kit.js +1 -1
- package/dist/locale.js +15 -9
- package/dist/locale.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/style.js +1 -1
- package/dist/types/comments.d.ts +55 -0
- package/dist/types/components/default-node.d.ts +1 -1
- package/dist/types/components/flow-comments.vue.d.ts +28 -0
- package/dist/types/components/port.d.ts +7 -0
- package/dist/types/context.d.ts +37 -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 +13 -0
- package/dist/types/core/node-types.d.ts +2 -0
- 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 +35 -8
- package/dist/types/locale.d.ts +7 -3
- 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 +1 -1
- package/dist/whiteboard/kit.js +1 -1
- package/package.json +3 -3
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { flowEditorKey } from "./context.js";
|
|
2
2
|
import { boundsOf, clampPan, intersects, intersectsTurned, rectFrom, snapBox } from "./core/geometry.js";
|
|
3
|
-
import { labelOf, nodeBounds, portsOf, resizeOf } from "./core/node-types.js";
|
|
3
|
+
import { labelOf, nodeBounds, 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";
|
|
@@ -99,6 +101,13 @@ var FIND_INSET = 12;
|
|
|
99
101
|
var DRAW_MARGIN = 200;
|
|
100
102
|
/** The part of the canvas that is drawn: the view and a margin around it. */
|
|
101
103
|
var TINY = .2;
|
|
104
|
+
var EDGE_LABEL_HALF = 10;
|
|
105
|
+
/** How far above an edge's label its marker sits, in screen px; a finger's target adds 8 (style.css). */
|
|
106
|
+
var EDGE_MARKER_LIFT = 14;
|
|
107
|
+
/** A marker's size, and how far apart two markers' middles keep, so a finger's 40px targets don't overlap. */
|
|
108
|
+
var MARKER_SIZE = 24;
|
|
109
|
+
var MARKER_GAP = 32;
|
|
110
|
+
/** A marker's middle, in px within the editor: a node's sits off its top right corner (style.css). */
|
|
102
111
|
var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
103
112
|
name: "DouFlowEditor",
|
|
104
113
|
__name: "flow-editor",
|
|
@@ -136,8 +145,19 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
136
145
|
portTypes: {},
|
|
137
146
|
acyclic: { type: Boolean },
|
|
138
147
|
canConnect: {},
|
|
148
|
+
bordered: {
|
|
149
|
+
type: Boolean,
|
|
150
|
+
default: true
|
|
151
|
+
},
|
|
139
152
|
ariaLabel: {},
|
|
140
|
-
messages: {}
|
|
153
|
+
messages: {},
|
|
154
|
+
comments: { default: void 0 },
|
|
155
|
+
author: { default: void 0 },
|
|
156
|
+
activeComment: { default: void 0 },
|
|
157
|
+
commentable: {
|
|
158
|
+
type: Boolean,
|
|
159
|
+
default: true
|
|
160
|
+
}
|
|
141
161
|
}, {
|
|
142
162
|
"modelValue": { default: emptyDocument },
|
|
143
163
|
"modelModifiers": {},
|
|
@@ -153,6 +173,9 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
153
173
|
emits: /*@__PURE__*/ mergeModels([
|
|
154
174
|
"transaction",
|
|
155
175
|
"transactionCancel",
|
|
176
|
+
"update:comments",
|
|
177
|
+
"update:activeComment",
|
|
178
|
+
"commentAction",
|
|
156
179
|
"nodeClick",
|
|
157
180
|
"nodeDblclick",
|
|
158
181
|
"nodeContextmenu",
|
|
@@ -191,7 +214,20 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
191
214
|
/** The axis that levels two ports on this side. */
|
|
192
215
|
const level = (side) => side === "left" || side === "right" ? "y" : "x";
|
|
193
216
|
const same = (a, b) => a.length === b.length && a.every((id, i) => id === b[i]);
|
|
194
|
-
const
|
|
217
|
+
const { comments, extension: commentsExtension, anchors: getCommentAnchors, anchorOf: commentAnchorOf } = useFlowComments({
|
|
218
|
+
props,
|
|
219
|
+
emit,
|
|
220
|
+
doc,
|
|
221
|
+
selection,
|
|
222
|
+
messages,
|
|
223
|
+
transact,
|
|
224
|
+
carry: (on, patch) => !customHistory && history.carry(on, patch),
|
|
225
|
+
shownOn: (on) => commentSpots.value.find((spot) => spot.key === ("node" in on ? `n:${on.node}` : `e:${on.edge}`))?.threads
|
|
226
|
+
});
|
|
227
|
+
const resolved = computed(() => {
|
|
228
|
+
const own = props.extensions ?? flowKit();
|
|
229
|
+
return resolveFlowExtensions(comments.enabled.value ? [...own, commentsExtension] : own);
|
|
230
|
+
});
|
|
195
231
|
const types = computed(() => {
|
|
196
232
|
const map = new Map(resolved.value.nodeTypes);
|
|
197
233
|
for (const spec of props.nodeTypes ?? []) map.set(spec.type, spec);
|
|
@@ -209,6 +245,9 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
209
245
|
/** The type of edges without one: the prop, else the extensions', else bezier. */
|
|
210
246
|
const defaultEdgeType = computed(() => props.edgeType ?? resolved.value.edgeType ?? "bezier");
|
|
211
247
|
const edgeTypeOf = (type) => edgeTypes.value.get(type ?? defaultEdgeType.value) ?? edgeTypes.value.get(defaultEdgeType.value) ?? bezierEdge;
|
|
248
|
+
if (process.env.NODE_ENV !== "production") watch(() => [doc.value.nodes, types.value], ([nodes, map]) => {
|
|
249
|
+
for (const node of nodes) if (node.type && !map.has(node.type)) warnUnknownNodeType(node.type);
|
|
250
|
+
}, { immediate: true });
|
|
212
251
|
const specOf = (node) => types.value.get(node.type ?? "default") ?? types.value.get("default") ?? defaultNode;
|
|
213
252
|
/** Each node's ports by id, worked out once per change rather than per edge. */
|
|
214
253
|
const portsByNode = computed(() => {
|
|
@@ -515,9 +554,14 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
515
554
|
const out = [];
|
|
516
555
|
const edges = doc.value.edges;
|
|
517
556
|
edges.length;
|
|
518
|
-
|
|
557
|
+
const tweening = tween.value !== null;
|
|
558
|
+
for (let edge of toRaw(edges)) {
|
|
519
559
|
const from = edgeEnd(edge.source);
|
|
520
560
|
const to = edgeEnd(edge.target);
|
|
561
|
+
if (edge.points && (tweening || from !== edge.source || to !== edge.target)) edge = {
|
|
562
|
+
...edge,
|
|
563
|
+
points: void 0
|
|
564
|
+
};
|
|
521
565
|
if (from.node === to.node && (from !== edge.source || to !== edge.target)) continue;
|
|
522
566
|
const source = nodeById.value.get(from.node);
|
|
523
567
|
const target = nodeById.value.get(to.node);
|
|
@@ -525,14 +569,22 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
525
569
|
const a = anchor(source, from.port, "source");
|
|
526
570
|
const b = anchor(target, to.port, "target");
|
|
527
571
|
if (!a || !b) continue;
|
|
572
|
+
const xs = [a.x, b.x];
|
|
573
|
+
const ys = [a.y, b.y];
|
|
574
|
+
for (const p of edge.points ?? []) {
|
|
575
|
+
xs.push(p.x);
|
|
576
|
+
ys.push(p.y);
|
|
577
|
+
}
|
|
578
|
+
const x = Math.min(...xs);
|
|
579
|
+
const y = Math.min(...ys);
|
|
528
580
|
out.push({
|
|
529
581
|
edge,
|
|
530
582
|
route: edgeTypeOf(edge.type).route(a, b, edge),
|
|
531
583
|
box: {
|
|
532
|
-
x:
|
|
533
|
-
y:
|
|
534
|
-
width: Math.
|
|
535
|
-
height: Math.
|
|
584
|
+
x: x - EDGE_REACH,
|
|
585
|
+
y: y - EDGE_REACH,
|
|
586
|
+
width: Math.max(...xs) - x + 160,
|
|
587
|
+
height: Math.max(...ys) - y + 160
|
|
536
588
|
},
|
|
537
589
|
style: edgeStyle(edge)
|
|
538
590
|
});
|
|
@@ -801,7 +853,7 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
801
853
|
left: FIT_PADDING,
|
|
802
854
|
right: FIT_PADDING
|
|
803
855
|
};
|
|
804
|
-
for (const panel of root.value.querySelectorAll(".dou-flow-editor__panels > :not(.dou-flow-toolbar)")) {
|
|
856
|
+
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
857
|
const rect = panel.getBoundingClientRect();
|
|
806
858
|
if (!rect.height) continue;
|
|
807
859
|
const upper = rect.top + rect.height / 2 < box.top + box.height / 2;
|
|
@@ -864,6 +916,7 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
864
916
|
const vertical = props.direction === "vertical";
|
|
865
917
|
const gap = TIDY_GAP[vertical ? "vertical" : "horizontal"];
|
|
866
918
|
const across = vertical ? ["top", "bottom"] : ["left", "right"];
|
|
919
|
+
const anchors = /* @__PURE__ */ new Map();
|
|
867
920
|
const layout = layoutGraph(nodes.map((node) => {
|
|
868
921
|
const m = metrics.get(node.id);
|
|
869
922
|
const { width, height } = rectOf(node);
|
|
@@ -872,6 +925,8 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
872
925
|
offset = vertical ? port.x : port.y;
|
|
873
926
|
break;
|
|
874
927
|
}
|
|
928
|
+
offset = Math.round(offset);
|
|
929
|
+
anchors.set(node.id, offset);
|
|
875
930
|
return {
|
|
876
931
|
id: node.id,
|
|
877
932
|
width,
|
|
@@ -890,7 +945,8 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
890
945
|
rankGap: gap.rank,
|
|
891
946
|
laneGap: gap.row,
|
|
892
947
|
equalWidth: false,
|
|
893
|
-
grid: props.grid || 8
|
|
948
|
+
grid: props.grid || 8,
|
|
949
|
+
straightChains: true
|
|
894
950
|
});
|
|
895
951
|
const snap = (v) => props.grid ? Math.round(v / props.grid) * props.grid : Math.round(v);
|
|
896
952
|
const origin = {
|
|
@@ -905,13 +961,41 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
905
961
|
for (const node of nodes) {
|
|
906
962
|
const placed = layout.nodes.get(node.id);
|
|
907
963
|
if (!placed || node.locked) continue;
|
|
908
|
-
const
|
|
909
|
-
|
|
964
|
+
const offset = anchors.get(node.id) ?? 0;
|
|
965
|
+
const to = vertical ? {
|
|
966
|
+
x: origin.x + snap(placed.x + offset) - offset,
|
|
910
967
|
y: origin.y + snap(placed.y)
|
|
968
|
+
} : {
|
|
969
|
+
x: origin.x + snap(placed.x),
|
|
970
|
+
y: origin.y + snap(placed.y + offset) - offset
|
|
911
971
|
};
|
|
912
972
|
if (to.x !== node.x || to.y !== node.y) moved.set(node.id, to);
|
|
913
973
|
}
|
|
914
|
-
|
|
974
|
+
const through = new Map(layout.edges.map((e) => [`${e.from}\u0000${e.to}`, e.points]));
|
|
975
|
+
const locked = new Set(nodes.filter((node) => node.locked).map((node) => node.id));
|
|
976
|
+
const routes = /* @__PURE__ */ new Map();
|
|
977
|
+
const pairs = /* @__PURE__ */ new Map();
|
|
978
|
+
for (const edge of doc.value.edges) {
|
|
979
|
+
const a = edge.source.node;
|
|
980
|
+
const b = edge.target.node;
|
|
981
|
+
if (!blocks.has(a) || !blocks.has(b)) continue;
|
|
982
|
+
const key = `${a}\u0000${b}`;
|
|
983
|
+
pairs.set(key, [...pairs.get(key) ?? [], edge]);
|
|
984
|
+
}
|
|
985
|
+
for (const [key, group] of pairs) {
|
|
986
|
+
const [a, b] = key.split("\0");
|
|
987
|
+
const points = locked.has(a) || locked.has(b) ? void 0 : through.get(key);
|
|
988
|
+
group.forEach((edge, i) => {
|
|
989
|
+
const off = (i - (group.length - 1) / 2) * (props.grid || 8);
|
|
990
|
+
const next = points?.length ? points.map((p) => ({
|
|
991
|
+
x: origin.x + snap(p.x) + (vertical ? off : 0),
|
|
992
|
+
y: origin.y + snap(p.y) + (vertical ? 0 : off)
|
|
993
|
+
})) : void 0;
|
|
994
|
+
routes.set(edge.id, next);
|
|
995
|
+
});
|
|
996
|
+
}
|
|
997
|
+
const rerouted = doc.value.edges.some((edge) => routes.has(edge.id) && JSON.stringify(routes.get(edge.id)) !== JSON.stringify(edge.points));
|
|
998
|
+
if (!moved.size && !rerouted) return;
|
|
915
999
|
const count = moved.size;
|
|
916
1000
|
for (const { id } of nodes) {
|
|
917
1001
|
const to = moved.get(id);
|
|
@@ -932,6 +1016,7 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
932
1016
|
}
|
|
933
1017
|
transact((tr) => {
|
|
934
1018
|
for (const [id, to] of moved) tr.moveNode(id, to.x, to.y);
|
|
1019
|
+
for (const [id, points] of routes) if (JSON.stringify(points) !== JSON.stringify(tr.getEdge(id)?.points)) tr.updateEdge(id, { points });
|
|
935
1020
|
});
|
|
936
1021
|
announce(format(messages.value.tidied, { count }));
|
|
937
1022
|
animateTidy(from, moved);
|
|
@@ -982,7 +1067,11 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
982
1067
|
/** Keeps a node in view, e.g. when it gets keyboard focus. */
|
|
983
1068
|
function reveal(id) {
|
|
984
1069
|
const rect = getNodeRect(id);
|
|
985
|
-
if (
|
|
1070
|
+
if (rect) revealRect(rect);
|
|
1071
|
+
}
|
|
1072
|
+
/** Pans the least that brings `rect`, in canvas coordinates, into view. */
|
|
1073
|
+
function revealRect(rect) {
|
|
1074
|
+
if (!root.value) return;
|
|
986
1075
|
const { x, y, zoom } = viewport.value;
|
|
987
1076
|
const pad = 16;
|
|
988
1077
|
const left = rect.x * zoom + x;
|
|
@@ -1946,6 +2035,7 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
1946
2035
|
x,
|
|
1947
2036
|
y,
|
|
1948
2037
|
locked: void 0,
|
|
2038
|
+
comments: void 0,
|
|
1949
2039
|
parent: copied ?? containerAt(centre, containers)
|
|
1950
2040
|
};
|
|
1951
2041
|
});
|
|
@@ -1957,7 +2047,12 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
1957
2047
|
if (!source || !target) continue;
|
|
1958
2048
|
tr.addEdge({
|
|
1959
2049
|
...edge,
|
|
2050
|
+
points: edge.points?.map((p) => ({
|
|
2051
|
+
x: p.x + shift.x,
|
|
2052
|
+
y: p.y + shift.y
|
|
2053
|
+
})),
|
|
1960
2054
|
id: createId("e"),
|
|
2055
|
+
comments: void 0,
|
|
1961
2056
|
source: {
|
|
1962
2057
|
...edge.source,
|
|
1963
2058
|
node: source
|
|
@@ -2209,14 +2304,18 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
2209
2304
|
window.removeEventListener("pointerdown", onMenuPress, true);
|
|
2210
2305
|
window.removeEventListener("click", onMenuClick);
|
|
2211
2306
|
});
|
|
2307
|
+
/** The toolbar's groups with something in; while read-only, only what is offered then too, such as comments. */
|
|
2308
|
+
function offeredItems(lists, readonly) {
|
|
2309
|
+
return lists.map((list) => readonly ? list.filter((item) => item.showWhenReadonly) : list).filter((list) => list.length);
|
|
2310
|
+
}
|
|
2212
2311
|
const toolbarItems = computed(() => {
|
|
2213
|
-
if (
|
|
2312
|
+
if (gesture.value || keyLink.value || quickAdd.value) return [];
|
|
2214
2313
|
const nodes = selection.value.nodes.flatMap((id) => nodeById.value.get(id) ?? []);
|
|
2215
|
-
if (nodes.length) return resolved.value.toolbars.map((fn) => fn(context, nodes))
|
|
2314
|
+
if (nodes.length) return offeredItems(resolved.value.toolbars.map((fn) => fn(context, nodes)), props.readonly);
|
|
2216
2315
|
const ids = new Set(selection.value.edges);
|
|
2217
2316
|
const edges = doc.value.edges.filter((edge) => ids.has(edge.id));
|
|
2218
2317
|
if (!edges.length) return [];
|
|
2219
|
-
return resolved.value.edgeToolbars.map((fn) => fn(context, edges))
|
|
2318
|
+
return offeredItems(resolved.value.edgeToolbars.map((fn) => fn(context, edges)), props.readonly);
|
|
2220
2319
|
});
|
|
2221
2320
|
/** Where the toolbar floats: above the selected nodes, in screen px within the editor. */
|
|
2222
2321
|
const toolbarAnchor = computed(() => {
|
|
@@ -2247,9 +2346,12 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
2247
2346
|
height: bounds.height + reach * 2
|
|
2248
2347
|
};
|
|
2249
2348
|
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);
|
|
2349
|
+
const keys = /* @__PURE__ */ new Set([...nodes.map((id) => `n:${id}`), ...edges.map((id) => `e:${id}`)]);
|
|
2350
|
+
const marked = commentMarkers.value.filter((marker) => keys.has(marker.key));
|
|
2351
|
+
const top = Math.min(bounds.y * zoom + y, ...marked.map(markerTop));
|
|
2250
2352
|
return {
|
|
2251
2353
|
x: (bounds.x + bounds.width / 2) * zoom + x,
|
|
2252
|
-
top
|
|
2354
|
+
top,
|
|
2253
2355
|
bottom: (bounds.y + bounds.height) * zoom + y,
|
|
2254
2356
|
avoid
|
|
2255
2357
|
};
|
|
@@ -3157,7 +3259,8 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
3157
3259
|
"is-space": spaceHeld.value,
|
|
3158
3260
|
"is-dragging": !!dragging.value,
|
|
3159
3261
|
"is-connecting": !!connecting.value,
|
|
3160
|
-
"is-refused": !!connecting.value?.refused
|
|
3262
|
+
"is-refused": !!connecting.value?.refused,
|
|
3263
|
+
"is-bordered": props.bordered
|
|
3161
3264
|
}));
|
|
3162
3265
|
const context = {
|
|
3163
3266
|
exportSVG,
|
|
@@ -3371,6 +3474,143 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
3371
3474
|
...PNG_SOURCE
|
|
3372
3475
|
});
|
|
3373
3476
|
}
|
|
3477
|
+
/** Half an edge label's height, in canvas px. */
|
|
3478
|
+
const markerCenter = (marker) => "node" in marker.anchor ? {
|
|
3479
|
+
x: marker.x + 6 + MARKER_SIZE / 2,
|
|
3480
|
+
y: marker.y - 6 - MARKER_SIZE / 2
|
|
3481
|
+
} : {
|
|
3482
|
+
x: marker.x,
|
|
3483
|
+
y: marker.y
|
|
3484
|
+
};
|
|
3485
|
+
/** The top of a marker with a finger's target around it, in px within the editor. */
|
|
3486
|
+
const markerTop = (marker) => markerCenter(marker).y - MARKER_SIZE / 2 - 8 - (marker.lifted ? 8 : 0);
|
|
3487
|
+
/** Where a node or edge shows its comments: a collapsed container hiding it shows them instead. */
|
|
3488
|
+
function commentSpotOf(on) {
|
|
3489
|
+
const hidden = hiddenIn.value;
|
|
3490
|
+
if ("node" in on) {
|
|
3491
|
+
if (!nodeById.value.has(on.node)) return null;
|
|
3492
|
+
return { node: hidden.get(on.node) ?? on.node };
|
|
3493
|
+
}
|
|
3494
|
+
if (edgeRouteById.value.has(on.edge)) return on;
|
|
3495
|
+
const edge = doc.value.edges.find((e) => e.id === on.edge);
|
|
3496
|
+
const outer = edge && (hidden.get(edge.source.node) ?? hidden.get(edge.target.node));
|
|
3497
|
+
return outer ? { node: outer } : null;
|
|
3498
|
+
}
|
|
3499
|
+
const edgeRouteById = computed(() => new Map(edgeRoutes.value.map((item) => [item.edge.id, item])));
|
|
3500
|
+
/**
|
|
3501
|
+
* The markers, in canvas px: one at the top right of each node and on each
|
|
3502
|
+
* edge's middle with open threads. Worked out as the document changes; the
|
|
3503
|
+
* view only moves them, below.
|
|
3504
|
+
*/
|
|
3505
|
+
const commentSpots = computed(() => {
|
|
3506
|
+
if (!comments.enabled.value) return [];
|
|
3507
|
+
const { nodes, edges } = comments.openOn.value;
|
|
3508
|
+
const spots = /* @__PURE__ */ new Map();
|
|
3509
|
+
const add = (on, threads, extra = {}) => {
|
|
3510
|
+
const spot = commentSpotOf(on);
|
|
3511
|
+
if (!spot) return;
|
|
3512
|
+
const key = "node" in spot ? `n:${spot.node}` : `e:${spot.edge}`;
|
|
3513
|
+
const had = spots.get(key);
|
|
3514
|
+
if (had) {
|
|
3515
|
+
for (const id of threads) if (!had.threads.includes(id)) had.threads.push(id);
|
|
3516
|
+
if (extra.pending) had.pending = true;
|
|
3517
|
+
return;
|
|
3518
|
+
}
|
|
3519
|
+
let at;
|
|
3520
|
+
let lift = 0;
|
|
3521
|
+
if ("node" in spot) {
|
|
3522
|
+
const node = nodeById.value.get(spot.node);
|
|
3523
|
+
const box = nodeBounds(specOf(node), node, rectOf(node));
|
|
3524
|
+
at = {
|
|
3525
|
+
x: box.x + box.width,
|
|
3526
|
+
y: box.y
|
|
3527
|
+
};
|
|
3528
|
+
} else {
|
|
3529
|
+
const item = edgeRouteById.value.get(spot.edge);
|
|
3530
|
+
at = item.route.label;
|
|
3531
|
+
if (item.edge.label) {
|
|
3532
|
+
at = {
|
|
3533
|
+
x: at.x,
|
|
3534
|
+
y: at.y - EDGE_LABEL_HALF
|
|
3535
|
+
};
|
|
3536
|
+
lift = EDGE_MARKER_LIFT;
|
|
3537
|
+
}
|
|
3538
|
+
}
|
|
3539
|
+
spots.set(key, {
|
|
3540
|
+
key,
|
|
3541
|
+
anchor: spot,
|
|
3542
|
+
threads: [...threads],
|
|
3543
|
+
shown: [],
|
|
3544
|
+
pending: !!extra.pending,
|
|
3545
|
+
...at,
|
|
3546
|
+
lift
|
|
3547
|
+
});
|
|
3548
|
+
};
|
|
3549
|
+
for (const [id, threads] of nodes) add({ node: id }, threads);
|
|
3550
|
+
for (const [id, threads] of edges) add({ edge: id }, threads);
|
|
3551
|
+
const starting = comments.pending.value;
|
|
3552
|
+
if (starting) add(starting, [], { pending: true });
|
|
3553
|
+
const list = [...spots.values()];
|
|
3554
|
+
const active = comments.active.value;
|
|
3555
|
+
const where = active ? commentAnchorOf(active) : null;
|
|
3556
|
+
for (const spot of list) spot.shown = spot.threads;
|
|
3557
|
+
if (active && where) {
|
|
3558
|
+
const spot = commentSpotOf(where);
|
|
3559
|
+
const key = spot && ("node" in spot ? `n:${spot.node}` : `e:${spot.edge}`);
|
|
3560
|
+
const there = key && spots.get(key);
|
|
3561
|
+
if (there && !there.threads.includes(active)) there.shown = [...there.threads, active];
|
|
3562
|
+
else if (!there) {
|
|
3563
|
+
add(where, []);
|
|
3564
|
+
const added = key && spots.get(key);
|
|
3565
|
+
if (added) {
|
|
3566
|
+
added.shown = [active];
|
|
3567
|
+
list.push(added);
|
|
3568
|
+
}
|
|
3569
|
+
}
|
|
3570
|
+
}
|
|
3571
|
+
return list;
|
|
3572
|
+
});
|
|
3573
|
+
/**
|
|
3574
|
+
* The markers in px within the editor: only this follows the view as it
|
|
3575
|
+
* pans and zooms. An edge's marker that would sit on another one moves
|
|
3576
|
+
* aside, so each can be tapped.
|
|
3577
|
+
*/
|
|
3578
|
+
const commentMarkers = computed(() => {
|
|
3579
|
+
const { x: vx, y: vy, zoom } = viewport.value;
|
|
3580
|
+
const markers = commentSpots.value.map(({ x, y, lift, ...spot }) => ({
|
|
3581
|
+
...spot,
|
|
3582
|
+
x: x * zoom + vx,
|
|
3583
|
+
y: y * zoom + vy - lift,
|
|
3584
|
+
lifted: lift > 0
|
|
3585
|
+
}));
|
|
3586
|
+
const placed = markers.filter((marker) => "node" in marker.anchor).map(markerCenter);
|
|
3587
|
+
for (const marker of markers) {
|
|
3588
|
+
if ("node" in marker.anchor) continue;
|
|
3589
|
+
for (let tries = 0; tries < 8; tries++) {
|
|
3590
|
+
const other = placed.find((p) => Math.abs(p.x - marker.x) < MARKER_GAP && Math.abs(p.y - marker.y) < MARKER_GAP);
|
|
3591
|
+
if (!other) break;
|
|
3592
|
+
marker.x = other.x + (marker.x < other.x ? -32 : MARKER_GAP);
|
|
3593
|
+
}
|
|
3594
|
+
placed.push(markerCenter(marker));
|
|
3595
|
+
}
|
|
3596
|
+
return markers;
|
|
3597
|
+
});
|
|
3598
|
+
watch(() => props.activeComment, (id) => {
|
|
3599
|
+
const at = id && !comments.openedHere(id) ? commentAnchorOf(id) : null;
|
|
3600
|
+
const on = at && commentSpotOf(at);
|
|
3601
|
+
if (!on) return;
|
|
3602
|
+
if ("node" in on) return reveal(on.node);
|
|
3603
|
+
const label = edgeRouteById.value.get(on.edge)?.route.label;
|
|
3604
|
+
if (label) revealRect({
|
|
3605
|
+
x: label.x - 16,
|
|
3606
|
+
y: label.y - 16,
|
|
3607
|
+
width: 32,
|
|
3608
|
+
height: 32
|
|
3609
|
+
});
|
|
3610
|
+
});
|
|
3611
|
+
function restoreCommentFocus(on) {
|
|
3612
|
+
((on && "node" in on ? root.value?.querySelector(`[data-node-id="${CSS.escape(on.node)}"]`) : null) ?? root.value)?.focus({ preventScroll: true });
|
|
3613
|
+
}
|
|
3374
3614
|
__expose({
|
|
3375
3615
|
setViewport,
|
|
3376
3616
|
openSearch,
|
|
@@ -3399,6 +3639,8 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
3399
3639
|
return [...staleEdges.value];
|
|
3400
3640
|
},
|
|
3401
3641
|
removeStaleEdges,
|
|
3642
|
+
comment: (on) => comments.start(on),
|
|
3643
|
+
getCommentAnchors,
|
|
3402
3644
|
insertNode,
|
|
3403
3645
|
startInsertDrag,
|
|
3404
3646
|
editLabel,
|
|
@@ -3627,8 +3869,19 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
3627
3869
|
(openBlock(true), createElementBlock(Fragment, null, renderList(resolved.value.overlays, (overlay, i) => {
|
|
3628
3870
|
return openBlock(), createBlock(resolveDynamicComponent(overlay), { key: i });
|
|
3629
3871
|
}), 128)),
|
|
3630
|
-
|
|
3872
|
+
unref(comments).enabled.value ? (openBlock(), createBlock(flow_comments_default, {
|
|
3631
3873
|
key: 0,
|
|
3874
|
+
comments: unref(comments),
|
|
3875
|
+
markers: commentMarkers.value,
|
|
3876
|
+
messages: unref(messages),
|
|
3877
|
+
restore: restoreCommentFocus
|
|
3878
|
+
}, null, 8, [
|
|
3879
|
+
"comments",
|
|
3880
|
+
"markers",
|
|
3881
|
+
"messages"
|
|
3882
|
+
])) : createCommentVNode("", true),
|
|
3883
|
+
toolbarItems.value.length && toolbarAnchor.value ? (openBlock(), createBlock(flow_toolbar_default, {
|
|
3884
|
+
key: 1,
|
|
3632
3885
|
groups: toolbarItems.value,
|
|
3633
3886
|
anchor: toolbarAnchor.value,
|
|
3634
3887
|
size: size.value
|
|
@@ -3638,7 +3891,7 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
3638
3891
|
"size"
|
|
3639
3892
|
])) : createCommentVNode("", true),
|
|
3640
3893
|
findOpen.value ? (openBlock(), createElementBlock("div", {
|
|
3641
|
-
key:
|
|
3894
|
+
key: 2,
|
|
3642
3895
|
ref_key: "findBox",
|
|
3643
3896
|
ref: findBox,
|
|
3644
3897
|
class: "dou-flow-editor__find",
|