docblocks-react-ui 0.30.0 → 0.31.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/CHANGELOG.md +48 -0
- package/dist/{Editor-CkiRKR-B.mjs → Editor-CAU0NkdR.mjs} +619 -155
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/mermaid/index.mjs +1 -1
- package/dist/styles.css +6 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,53 @@
|
|
|
1
1
|
# docblocks-react-ui
|
|
2
2
|
|
|
3
|
+
## 0.31.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 957bb52: The connectors bend: the line's toolbar adds a waypoint at the route's
|
|
8
|
+
middle segment, the waypoint's dot drags the route's corner (one
|
|
9
|
+
`updateBlock` on the release — the endpoints stay the block refs, the route
|
|
10
|
+
re-derives through the stored points), and the dot's double-click removes
|
|
11
|
+
the point (an empty route drops the attr). The route stands the stored
|
|
12
|
+
`points`, so it persists over the wire, the reload and the undo.
|
|
13
|
+
- 858d145: The canvas containers read as one visual language: the group box stands the
|
|
14
|
+
frame's own ring token and the ring's width, so a container's border is a
|
|
15
|
+
single 2 px muted line (previously a 1 px table line on the group and a
|
|
16
|
+
fainter one on the frame — both lost among brightly stroked figures at a
|
|
17
|
+
low zoom). The title chips carry the same resting border. Rendering only:
|
|
18
|
+
the document data is untouched.
|
|
19
|
+
- ef0baf9: The canvas's floating toolbars stay inside the canvas's visible area: the
|
|
20
|
+
shape, canvas-text and container toolbars flip below the box when the box
|
|
21
|
+
stands too close to the canvas's top edge (the above-the-box stand left the
|
|
22
|
+
canvas and landed under the consumer's header, where no press reached it)
|
|
23
|
+
and clamp inside the canvas's width. The toolbars themselves render
|
|
24
|
+
unpositioned — the canvas view owns their placement.
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- f555207: The canvas marquee no longer takes a container's box for its contents: a
|
|
29
|
+
container or frame is swept by the marquee's border band only (its interior
|
|
30
|
+
stands transparent, the press hit's parity), so a rubber band drawn inside
|
|
31
|
+
a frame takes the figures it crosses; a container whose members stand in
|
|
32
|
+
the marquee yields to them.
|
|
33
|
+
- c07c522: The link popover opens at the selection without moving the document: the
|
|
34
|
+
popover's box stands at the anchor from its first frame (it no longer lays
|
|
35
|
+
out at the editor content's end, where the native focus scroll pulled the
|
|
36
|
+
whole page) and the address input takes the focus without scrolling. A long
|
|
37
|
+
article keeps the reader's position over the open.
|
|
38
|
+
- 4e35a36: The link popover's close restores the text selection: the address input's
|
|
39
|
+
focus collapsed the browser selection, so the Escape (and every other close
|
|
40
|
+
of the popover) left the reader without the highlight and without the copy
|
|
41
|
+
payload. The close now re-seats the DOM selection from the editor's own
|
|
42
|
+
selection, and the focus park takes no scroll.
|
|
43
|
+
- 63474c0: The paste's caret-block tail keeps its run structure: a paste into the
|
|
44
|
+
middle of a line re-inserts the text after the caret with its marks
|
|
45
|
+
(`link`, `bold`, `italic`, …), so the tail no longer degrades to plain
|
|
46
|
+
text. Both paste branches (the plain-text markdown materialization and the
|
|
47
|
+
rich html one) read the tail's runs before the caret block is split and
|
|
48
|
+
re-insert them through the per-run insertion; the single transaction and
|
|
49
|
+
the single undo step stand.
|
|
50
|
+
|
|
3
51
|
## 0.30.0
|
|
4
52
|
|
|
5
53
|
### Minor Changes
|
|
@@ -347,6 +347,8 @@ const INIT_OPTIONS = {
|
|
|
347
347
|
"straight": "Straight line",
|
|
348
348
|
"orthogonal": "Orthogonal line",
|
|
349
349
|
"curved": "Curved line",
|
|
350
|
+
"bend": "Add bend point",
|
|
351
|
+
"bendTitle": "Add a bend point (drag it to bend the line; double-click it to remove)",
|
|
350
352
|
"lineColor": "Line color",
|
|
351
353
|
"lineWidth": "Line width",
|
|
352
354
|
"lineWidthTitle": "Line width (1–4 px)",
|
|
@@ -942,6 +944,8 @@ const INIT_OPTIONS = {
|
|
|
942
944
|
"straight": "Прямая линия",
|
|
943
945
|
"orthogonal": "Ортогональная линия",
|
|
944
946
|
"curved": "Кривая линия",
|
|
947
|
+
"bend": "Добавить точку изгиба",
|
|
948
|
+
"bendTitle": "Добавить точку изгиба (перетащите её, чтобы согнуть линию; двойной клик удаляет)",
|
|
945
949
|
"lineColor": "Цвет линии",
|
|
946
950
|
"lineWidth": "Толщина линии",
|
|
947
951
|
"lineWidthTitle": "Толщина линии (1–4 px)",
|
|
@@ -3647,6 +3651,34 @@ function User(props) {
|
|
|
3647
3651
|
})]
|
|
3648
3652
|
});
|
|
3649
3653
|
}
|
|
3654
|
+
// src/shared/ui/icons/Waypoints.tsx
|
|
3655
|
+
function Waypoints(props) {
|
|
3656
|
+
return /* @__PURE__ */ jsxs("svg", {
|
|
3657
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3658
|
+
width: 24,
|
|
3659
|
+
height: 24,
|
|
3660
|
+
viewBox: "0 0 24 24",
|
|
3661
|
+
fill: "none",
|
|
3662
|
+
stroke: "currentColor",
|
|
3663
|
+
strokeWidth: 2,
|
|
3664
|
+
strokeLinecap: "round",
|
|
3665
|
+
strokeLinejoin: "round",
|
|
3666
|
+
...props,
|
|
3667
|
+
children: [
|
|
3668
|
+
/* @__PURE__ */ jsx("path", { d: "M4 20h4l4-8 4-8h4" }),
|
|
3669
|
+
/* @__PURE__ */ jsx("circle", {
|
|
3670
|
+
cx: "4",
|
|
3671
|
+
cy: "20",
|
|
3672
|
+
r: "2"
|
|
3673
|
+
}),
|
|
3674
|
+
/* @__PURE__ */ jsx("circle", {
|
|
3675
|
+
cx: "20",
|
|
3676
|
+
cy: "4",
|
|
3677
|
+
r: "2"
|
|
3678
|
+
})
|
|
3679
|
+
]
|
|
3680
|
+
});
|
|
3681
|
+
}
|
|
3650
3682
|
// src/shared/ui/icons/Zap.tsx
|
|
3651
3683
|
function Zap(props) {
|
|
3652
3684
|
return /* @__PURE__ */ jsx("svg", {
|
|
@@ -15424,6 +15456,30 @@ function connectorMidpoint(connectorId, childIds, blocks, previews) {
|
|
|
15424
15456
|
}
|
|
15425
15457
|
return connectorPathPoints(startDraw, endDraw, attrs.variant ?? "straight", obstacleBoxes).mid;
|
|
15426
15458
|
}
|
|
15459
|
+
/**
|
|
15460
|
+
* The connector's STORED waypoints (the bend dots' stand): the attrs'
|
|
15461
|
+
* `points` in the route's own order, the in-flight waypoint drag's point
|
|
15462
|
+
* substituted at its index (the dot follows the handle — the release
|
|
15463
|
+
* commits the same position). The surface-local px (the line's own space).
|
|
15464
|
+
*/
|
|
15465
|
+
function connectorWaypointPoints(block, previews) {
|
|
15466
|
+
if (block === void 0 || block.type !== "connector" || block.attrs === void 0) return [];
|
|
15467
|
+
const drag = previews?.endpointDrag ?? null;
|
|
15468
|
+
const preview = previews?.endpointPreview ?? null;
|
|
15469
|
+
if (drag === null || drag.which !== "waypoint" || preview === null || drag.index === void 0) return (block.attrs.points ?? []).map(([x, y]) => ({
|
|
15470
|
+
x,
|
|
15471
|
+
y
|
|
15472
|
+
}));
|
|
15473
|
+
const index = drag.index;
|
|
15474
|
+
const live = preview.point;
|
|
15475
|
+
return (block.attrs.points ?? []).map(([x, y], i) => i === index ? {
|
|
15476
|
+
x: live.x,
|
|
15477
|
+
y: live.y
|
|
15478
|
+
} : {
|
|
15479
|
+
x,
|
|
15480
|
+
y
|
|
15481
|
+
});
|
|
15482
|
+
}
|
|
15427
15483
|
// src/canvas/geometry/utils/frame-window.ts
|
|
15428
15484
|
/**
|
|
15429
15485
|
* The window's offset: the box-local position of the surface's world
|
|
@@ -16632,6 +16688,159 @@ function createShapeSessions(store, doc) {
|
|
|
16632
16688
|
cancelResize
|
|
16633
16689
|
};
|
|
16634
16690
|
}
|
|
16691
|
+
// src/canvas/viewport/session-waypoint.ts
|
|
16692
|
+
/** The round point (the 2-decimal stand — the endpoints' own). */
|
|
16693
|
+
function rounded(point) {
|
|
16694
|
+
return [Number(point.x.toFixed(2)), Number(point.y.toFixed(2))];
|
|
16695
|
+
}
|
|
16696
|
+
/** The connector's session commands (the route's write / the drag / the
|
|
16697
|
+
* midpoint's add / the point's removal). */
|
|
16698
|
+
function createWaypointSessions(store, doc) {
|
|
16699
|
+
const waypointRef = { current: null };
|
|
16700
|
+
/** The connector's stored waypoints (the surface-local px). */
|
|
16701
|
+
const pointsOf = (connectorId) => {
|
|
16702
|
+
const block = doc.getBlock(connectorId);
|
|
16703
|
+
if (block === null || block.type !== "connector") return [];
|
|
16704
|
+
return (block.attrs?.points ?? []).map(([x, y]) => [x, y]);
|
|
16705
|
+
};
|
|
16706
|
+
const writePoints = (connectorId, points) => {
|
|
16707
|
+
const block = doc.getBlock(connectorId);
|
|
16708
|
+
if (block === null || block.type !== "connector") return;
|
|
16709
|
+
try {
|
|
16710
|
+
doc.transact(() => {
|
|
16711
|
+
if (points.length === 0) doc.removeBlockAttr(connectorId, "points");
|
|
16712
|
+
else doc.updateBlock(connectorId, { points });
|
|
16713
|
+
});
|
|
16714
|
+
} catch {}
|
|
16715
|
+
};
|
|
16716
|
+
const beginConnectorWaypoint = (connectorId, index, pointer, startClientX, startClientY) => {
|
|
16717
|
+
const state = store.getState();
|
|
16718
|
+
const block = doc.getBlock(connectorId);
|
|
16719
|
+
if (block === null || block.type !== "connector") return;
|
|
16720
|
+
const stored = pointsOf(connectorId)[index];
|
|
16721
|
+
if (stored === void 0) return;
|
|
16722
|
+
const canvas = screenToCanvas(pointer, state.zoom, state.pan);
|
|
16723
|
+
waypointRef.current = {
|
|
16724
|
+
connectorId,
|
|
16725
|
+
index,
|
|
16726
|
+
startClientX,
|
|
16727
|
+
startClientY,
|
|
16728
|
+
dragging: false,
|
|
16729
|
+
point: canvas
|
|
16730
|
+
};
|
|
16731
|
+
state.setConnectorEndpoint({
|
|
16732
|
+
connectorId,
|
|
16733
|
+
which: "waypoint",
|
|
16734
|
+
index
|
|
16735
|
+
});
|
|
16736
|
+
state.setConnectorEndpointPreview({
|
|
16737
|
+
point: {
|
|
16738
|
+
x: stored[0],
|
|
16739
|
+
y: stored[1]
|
|
16740
|
+
},
|
|
16741
|
+
snap: null
|
|
16742
|
+
});
|
|
16743
|
+
};
|
|
16744
|
+
const moveConnectorWaypoint = (pointer) => {
|
|
16745
|
+
const session = waypointRef.current;
|
|
16746
|
+
if (session === null) return;
|
|
16747
|
+
const state = store.getState();
|
|
16748
|
+
session.dragging = true;
|
|
16749
|
+
const point = screenToCanvas(pointer, state.zoom, state.pan);
|
|
16750
|
+
session.point = point;
|
|
16751
|
+
state.setConnectorEndpointPreview({
|
|
16752
|
+
point,
|
|
16753
|
+
snap: null
|
|
16754
|
+
});
|
|
16755
|
+
};
|
|
16756
|
+
const endConnectorWaypoint = (releaseClientX, releaseClientY) => {
|
|
16757
|
+
const session = waypointRef.current;
|
|
16758
|
+
waypointRef.current = null;
|
|
16759
|
+
const state = store.getState();
|
|
16760
|
+
state.setConnectorEndpoint(null);
|
|
16761
|
+
state.setConnectorEndpointPreview(null);
|
|
16762
|
+
if (session === null || !session.dragging) return;
|
|
16763
|
+
if (releaseClientX !== void 0 && releaseClientY !== void 0 && Math.hypot(releaseClientX - session.startClientX, releaseClientY - session.startClientY) < 3) return;
|
|
16764
|
+
const points = pointsOf(session.connectorId);
|
|
16765
|
+
if (points[session.index] === void 0) return;
|
|
16766
|
+
points[session.index] = rounded(session.point);
|
|
16767
|
+
writePoints(session.connectorId, points);
|
|
16768
|
+
};
|
|
16769
|
+
const cancelConnectorWaypoint = () => {
|
|
16770
|
+
waypointRef.current = null;
|
|
16771
|
+
const state = store.getState();
|
|
16772
|
+
state.setConnectorEndpoint(null);
|
|
16773
|
+
state.setConnectorEndpointPreview(null);
|
|
16774
|
+
};
|
|
16775
|
+
/**
|
|
16776
|
+
* Adds a waypoint at the ROUTE's middle segment's midpoint: the polyline
|
|
16777
|
+
* through the resolved endpoints and the stored waypoints (the geometry's
|
|
16778
|
+
* own route), the longest-middle segment's middle point (the odd count
|
|
16779
|
+
* stands the exact middle, the even count the later's one). The new point
|
|
16780
|
+
* lands between that segment's ends (the route's order).
|
|
16781
|
+
*/
|
|
16782
|
+
const addConnectorWaypoint = (connectorId) => {
|
|
16783
|
+
const block = doc.getBlock(connectorId);
|
|
16784
|
+
if (block === null || block.type !== "connector" || block.attrs === void 0) return;
|
|
16785
|
+
const surfaceId = findParentSurface(doc, connectorId);
|
|
16786
|
+
if (surfaceId === null) return;
|
|
16787
|
+
const children = doc.getChildren(surfaceId);
|
|
16788
|
+
const blocks = {};
|
|
16789
|
+
for (const childId of children) {
|
|
16790
|
+
const child = doc.getBlock(childId);
|
|
16791
|
+
if (child !== null) blocks[childId] = child;
|
|
16792
|
+
}
|
|
16793
|
+
const attrs = block.attrs;
|
|
16794
|
+
const start = endpointPointOf(attrs.start, children, blocks, {
|
|
16795
|
+
x: 0,
|
|
16796
|
+
y: 0
|
|
16797
|
+
});
|
|
16798
|
+
const end = start !== null ? endpointPointOf(attrs.end, children, blocks, {
|
|
16799
|
+
x: start.x,
|
|
16800
|
+
y: start.y
|
|
16801
|
+
}) : null;
|
|
16802
|
+
if (start === null || end === null) return;
|
|
16803
|
+
const points = pointsOf(connectorId);
|
|
16804
|
+
const route = [
|
|
16805
|
+
{
|
|
16806
|
+
x: start.x,
|
|
16807
|
+
y: start.y
|
|
16808
|
+
},
|
|
16809
|
+
...points.map(([x, y]) => ({
|
|
16810
|
+
x,
|
|
16811
|
+
y
|
|
16812
|
+
})),
|
|
16813
|
+
{
|
|
16814
|
+
x: end.x,
|
|
16815
|
+
y: end.y
|
|
16816
|
+
}
|
|
16817
|
+
];
|
|
16818
|
+
const segment = Math.floor((route.length - 1) / 2);
|
|
16819
|
+
const from = route[segment];
|
|
16820
|
+
const to = route[segment + 1];
|
|
16821
|
+
if (from === void 0 || to === void 0) return;
|
|
16822
|
+
const middle = {
|
|
16823
|
+
x: (from.x + to.x) / 2,
|
|
16824
|
+
y: (from.y + to.y) / 2
|
|
16825
|
+
};
|
|
16826
|
+
points.splice(segment, 0, rounded(middle));
|
|
16827
|
+
writePoints(connectorId, points);
|
|
16828
|
+
};
|
|
16829
|
+
const removeConnectorWaypoint = (connectorId, index) => {
|
|
16830
|
+
const points = pointsOf(connectorId);
|
|
16831
|
+
if (points[index] === void 0) return;
|
|
16832
|
+
points.splice(index, 1);
|
|
16833
|
+
writePoints(connectorId, points);
|
|
16834
|
+
};
|
|
16835
|
+
return {
|
|
16836
|
+
beginConnectorWaypoint,
|
|
16837
|
+
moveConnectorWaypoint,
|
|
16838
|
+
endConnectorWaypoint,
|
|
16839
|
+
cancelConnectorWaypoint,
|
|
16840
|
+
addConnectorWaypoint,
|
|
16841
|
+
removeConnectorWaypoint
|
|
16842
|
+
};
|
|
16843
|
+
}
|
|
16635
16844
|
// src/canvas/viewport/zoom.ts
|
|
16636
16845
|
/**
|
|
16637
16846
|
* The canvas viewport's zoom math: the stop grid's nearest-stop index, the
|
|
@@ -16710,6 +16919,7 @@ function createCanvasViewportCommands(store, doc) {
|
|
|
16710
16919
|
return {
|
|
16711
16920
|
...createShapeSessions(store, doc),
|
|
16712
16921
|
...createConnectorSessions(store, doc, standPoint),
|
|
16922
|
+
...createWaypointSessions(store, doc),
|
|
16713
16923
|
...createPlaceCommands(store, doc),
|
|
16714
16924
|
stepZoom: step,
|
|
16715
16925
|
zoomAt,
|
|
@@ -22905,6 +23115,23 @@ function insertRuns(doc, blockId, from, runs) {
|
|
|
22905
23115
|
}
|
|
22906
23116
|
return pos;
|
|
22907
23117
|
}
|
|
23118
|
+
/** The runs' slice from `offset` to the content's end (the marks stand). */
|
|
23119
|
+
function sliceRuns(runs, offset) {
|
|
23120
|
+
const sliced = [];
|
|
23121
|
+
let pos = 0;
|
|
23122
|
+
for (const run of runs) {
|
|
23123
|
+
const end = pos + run.text.length;
|
|
23124
|
+
if (end > offset) {
|
|
23125
|
+
const text = run.text.slice(Math.max(0, offset - pos));
|
|
23126
|
+
if (text !== "") sliced.push({
|
|
23127
|
+
text,
|
|
23128
|
+
marks: run.marks
|
|
23129
|
+
});
|
|
23130
|
+
}
|
|
23131
|
+
pos = end;
|
|
23132
|
+
}
|
|
23133
|
+
return sliced;
|
|
23134
|
+
}
|
|
22908
23135
|
/** The typed insertion (the core's attrs are required per type; the content
|
|
22909
23136
|
* runs are inserted at the fresh block). */
|
|
22910
23137
|
function insertNative(doc, m, parent, after, indent) {
|
|
@@ -23072,7 +23299,8 @@ function insertTable(doc, m, parent, after, indent) {
|
|
|
23072
23299
|
* first pasted block merges into it (the same text type — the block's own
|
|
23073
23300
|
* type and attrs stand) or follows it, the text after the original caret
|
|
23074
23301
|
* (the suffix) lands in the last pasted text block (a trailing paragraph
|
|
23075
|
-
* when the last block is not text)
|
|
23302
|
+
* when the last block is not text) with its own run structure — the marks
|
|
23303
|
+
* over the tail stand. An empty caret block converts in place
|
|
23076
23304
|
* to the first pasted block. Every block the target parent does not accept
|
|
23077
23305
|
* is demoted (the list/quote → paragraph; the table → one paragraph per
|
|
23078
23306
|
* row, the cells joined by ` | `) — the paste never throws on legitimate
|
|
@@ -23091,6 +23319,7 @@ function materializePaste(doc, seatId, from, to, parsed, opts) {
|
|
|
23091
23319
|
const seatText = doc.getText(seatId);
|
|
23092
23320
|
const prefix = seatText.slice(0, from);
|
|
23093
23321
|
const suffix = seatText.slice(to);
|
|
23322
|
+
const suffixRuns = sliceRuns(doc.getRuns(seatId), to);
|
|
23094
23323
|
const seatIndent = indentOf$2(doc, seatId);
|
|
23095
23324
|
const eligible = (type) => {
|
|
23096
23325
|
if (parent === null) return true;
|
|
@@ -23178,14 +23407,12 @@ function materializePaste(doc, seatId, from, to, parsed, opts) {
|
|
|
23178
23407
|
}
|
|
23179
23408
|
landingOffset = lastTextLen;
|
|
23180
23409
|
if (suffix !== "") {
|
|
23181
|
-
if (lastTextId !== null && lastTextType === "paragraph")
|
|
23182
|
-
|
|
23183
|
-
lastTextLen += suffix.length;
|
|
23184
|
-
} else {
|
|
23410
|
+
if (lastTextId !== null && lastTextType === "paragraph") lastTextLen = insertRuns(doc, lastTextId, lastTextLen, suffixRuns);
|
|
23411
|
+
else {
|
|
23185
23412
|
const indent = clamp(material[material.length - 1].indent, prevIndent);
|
|
23186
23413
|
prevId = insertBlockWithIndent(doc, "paragraph", parentId, prevId, indent);
|
|
23187
23414
|
prevIndent = indent;
|
|
23188
|
-
doc
|
|
23415
|
+
insertRuns(doc, prevId, 0, suffixRuns);
|
|
23189
23416
|
}
|
|
23190
23417
|
}
|
|
23191
23418
|
const sequenceNow = doc.getChildren(parentId);
|
|
@@ -25500,7 +25727,7 @@ function LinkPopover({ rootRef, state, onClose }) {
|
|
|
25500
25727
|
useLayoutEffect(() => {
|
|
25501
25728
|
const input = inputRef.current;
|
|
25502
25729
|
if (input === null) return;
|
|
25503
|
-
input.focus();
|
|
25730
|
+
input.focus({ preventScroll: true });
|
|
25504
25731
|
input.select();
|
|
25505
25732
|
}, []);
|
|
25506
25733
|
useLayoutEffect(() => {
|
|
@@ -25557,7 +25784,11 @@ function LinkPopover({ rootRef, state, onClose }) {
|
|
|
25557
25784
|
"data-slot": "docblocks/link-popover",
|
|
25558
25785
|
"aria-label": t("link.aria"),
|
|
25559
25786
|
className: cn("absolute z-modal rounded-md border border-border bg-popover p-2 text-popover-foreground shadow-md", position === null && "opacity-0"),
|
|
25560
|
-
style: position === null ? {
|
|
25787
|
+
style: position === null ? {
|
|
25788
|
+
width: POPOVER_WIDTH_PX,
|
|
25789
|
+
left: state.anchor.x,
|
|
25790
|
+
top: state.anchor.y + ANCHOR_OFFSET_PX
|
|
25791
|
+
} : {
|
|
25561
25792
|
width: POPOVER_WIDTH_PX,
|
|
25562
25793
|
left: position.left,
|
|
25563
25794
|
top: position.top
|
|
@@ -25723,7 +25954,11 @@ function useLinkPopover(rootRef) {
|
|
|
25723
25954
|
if (!parkFocusRef.current) return;
|
|
25724
25955
|
parkFocusRef.current = false;
|
|
25725
25956
|
const active = document.activeElement;
|
|
25726
|
-
if (active === null || active === document.body)
|
|
25957
|
+
if (active === null || active === document.body) {
|
|
25958
|
+
rootRef.current?.focus({ preventScroll: true });
|
|
25959
|
+
const view = selectionRef.view;
|
|
25960
|
+
if (view !== null) reseatHistorySelection(doc, view, rootRef.current ?? document);
|
|
25961
|
+
}
|
|
25727
25962
|
});
|
|
25728
25963
|
const open = useCallback((anchor, opts) => {
|
|
25729
25964
|
setMenu(null);
|
|
@@ -27219,8 +27454,13 @@ function connectorLineGeometryOf(connectorId, block, childIds, blocks, session)
|
|
|
27219
27454
|
};
|
|
27220
27455
|
const startPoly = polyPoint(attrs.start, startDraw, startBox, "start");
|
|
27221
27456
|
const endPoly = polyPoint(attrs.end, endDraw, endBox, "end");
|
|
27457
|
+
const points = (attrs.points ?? []).map(([x, y], index) => {
|
|
27458
|
+
if (!dragging || endpointDrag === null || endpointDrag.which !== "waypoint") return [x, y];
|
|
27459
|
+
if (endpointDrag.index !== index || endpointPreview === null) return [x, y];
|
|
27460
|
+
return [endpointPreview.point.x, endpointPreview.point.y];
|
|
27461
|
+
});
|
|
27222
27462
|
return {
|
|
27223
|
-
path:
|
|
27463
|
+
path: points.length > 0 ? `M ${startPoly.x} ${startPoly.y} L ${points.map(([x, y]) => `${x} ${y}`).join(" L ")} L ${endPoly.x} ${endPoly.y}` : legacy ? connectorPath(startBox, endBox, attrs.variant ?? "straight").d : connectorPathPoints(startDraw, endDraw, attrs.variant ?? "straight", obstacleBoxes).d,
|
|
27224
27464
|
startDraw,
|
|
27225
27465
|
endDraw,
|
|
27226
27466
|
dragging
|
|
@@ -27611,7 +27851,7 @@ function FrameBlock({ id, selected = false, chipMode }) {
|
|
|
27611
27851
|
"data-slot": "docblocks/frame-boundary",
|
|
27612
27852
|
className: "absolute inset-0 rounded-(--docblocks-radius)",
|
|
27613
27853
|
style: {
|
|
27614
|
-
boxShadow: `inset 0 0 0
|
|
27854
|
+
boxShadow: `inset 0 0 0 var(--docblocks-canvas-group-border-width) ${selected ? selectedColor : "var(--docblocks-canvas-group-border-color)"}`,
|
|
27615
27855
|
outline: selected ? `var(--docblocks-canvas-selection-border-width) solid ${selectedColor}` : void 0,
|
|
27616
27856
|
outlineOffset: 1
|
|
27617
27857
|
}
|
|
@@ -27699,7 +27939,7 @@ function GroupBlock({ id, block, selected, chipMode }) {
|
|
|
27699
27939
|
className: "absolute rounded-(--docblocks-radius)",
|
|
27700
27940
|
style: {
|
|
27701
27941
|
inset: 0,
|
|
27702
|
-
boxShadow: `inset 0 0 0
|
|
27942
|
+
boxShadow: `inset 0 0 0 var(--docblocks-canvas-group-border-width) ${selected ? selectedColor : "var(--docblocks-canvas-group-border-color)"}`,
|
|
27703
27943
|
outline: selected ? `1px solid ${selectedColor}` : void 0,
|
|
27704
27944
|
outlineOffset: 1
|
|
27705
27945
|
}
|
|
@@ -27758,7 +27998,7 @@ function GroupBlock({ id, block, selected, chipMode }) {
|
|
|
27758
27998
|
selected,
|
|
27759
27999
|
slot: "group",
|
|
27760
28000
|
ariaLabel: t("titleChip.containerTitle"),
|
|
27761
|
-
restBorderColor: "var(--docblocks-
|
|
28001
|
+
restBorderColor: "var(--docblocks-canvas-group-border-color)",
|
|
27762
28002
|
interactive: chipMode !== "inert"
|
|
27763
28003
|
})
|
|
27764
28004
|
]
|
|
@@ -28403,6 +28643,25 @@ function remapEndpoint(ref, copySet, idMap, dx, dy, toward, resolve) {
|
|
|
28403
28643
|
}
|
|
28404
28644
|
return { ...ref };
|
|
28405
28645
|
}
|
|
28646
|
+
// src/canvas/ConnectorBendButton.tsx
|
|
28647
|
+
/**
|
|
28648
|
+
* The line's bend-point action (the connector toolbar's button): one press
|
|
28649
|
+
* adds a waypoint at the route's middle segment's middle — the waypoint's
|
|
28650
|
+
* dot then drags the route's corner (the dot's double-click removes the
|
|
28651
|
+
* point).
|
|
28652
|
+
*/
|
|
28653
|
+
function ConnectorBendButton({ onPress }) {
|
|
28654
|
+
const { t } = useTranslation("canvas");
|
|
28655
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
28656
|
+
variant: "ghost",
|
|
28657
|
+
size: "icon",
|
|
28658
|
+
"data-slot": "docblocks/connector-toolbar-bend",
|
|
28659
|
+
"aria-label": t("connector.bend"),
|
|
28660
|
+
title: t("connector.bendTitle"),
|
|
28661
|
+
onClick: onPress,
|
|
28662
|
+
children: /* @__PURE__ */ jsx(Waypoints, { className: "size-4" })
|
|
28663
|
+
});
|
|
28664
|
+
}
|
|
28406
28665
|
// src/canvas/ZOrderMenu.tsx
|
|
28407
28666
|
/**
|
|
28408
28667
|
* The canvas figure's z-order menu (the explicit zIndex): the
|
|
@@ -28718,7 +28977,7 @@ const ARROW_HEADS = [
|
|
|
28718
28977
|
icon: /* @__PURE__ */ jsx(Minus, { className: "size-4" })
|
|
28719
28978
|
}
|
|
28720
28979
|
];
|
|
28721
|
-
function ConnectorToolbar({ id, variant, strokeColor, strokeWidth, strokeStyle, arrowHead, arrowStart, zStand, style }) {
|
|
28980
|
+
function ConnectorToolbar({ id, variant, strokeColor, strokeWidth, strokeStyle, arrowHead, arrowStart, zStand, style, onAddWaypoint }) {
|
|
28722
28981
|
const { t } = useTranslation("canvas");
|
|
28723
28982
|
const { doc } = useEditorContext();
|
|
28724
28983
|
const [openSection, setOpenSection] = useState(null);
|
|
@@ -28816,6 +29075,7 @@ function ConnectorToolbar({ id, variant, strokeColor, strokeWidth, strokeStyle,
|
|
|
28816
29075
|
option("straight", "connector.straight", /* @__PURE__ */ jsx(Diagonal, { className: "size-4" })),
|
|
28817
29076
|
option("orthogonal", "connector.orthogonal", /* @__PURE__ */ jsx(Elbow, { className: "size-4" })),
|
|
28818
29077
|
option("curved", "connector.curved", /* @__PURE__ */ jsx(Curve, { className: "size-4" })),
|
|
29078
|
+
onAddWaypoint !== void 0 && /* @__PURE__ */ jsx(ConnectorBendButton, { onPress: onAddWaypoint }),
|
|
28819
29079
|
/* @__PURE__ */ jsx(Separator, {
|
|
28820
29080
|
orientation: "vertical",
|
|
28821
29081
|
className: "h-5"
|
|
@@ -29306,9 +29566,10 @@ function ShapeTextControls({ slotPrefix, sizeListId, fontFamily, textColor, text
|
|
|
29306
29566
|
* position / count over the surface's canvas elements). Each apply is one
|
|
29307
29567
|
* `updateBlock` in one transact (one undo step, one wire update). The
|
|
29308
29568
|
* toolbar is canvas chrome (its own pointers; a press on it starts no
|
|
29309
|
-
* canvas session).
|
|
29569
|
+
* canvas session). The canvas view places it over the box's top edge
|
|
29570
|
+
* (flipped below the box near the canvas's top edge).
|
|
29310
29571
|
*/
|
|
29311
|
-
function CanvasTextToolbar({ id, fontFamily, textColor, textStyle, fontSize, textAlign, zStand, style }) {
|
|
29572
|
+
function CanvasTextToolbar({ id, fontFamily, textColor, textStyle, fontSize, textAlign, zStand, style = {} }) {
|
|
29312
29573
|
const { t } = useTranslation("canvas");
|
|
29313
29574
|
const { doc } = useEditorContext();
|
|
29314
29575
|
const [textColorOpen, setTextColorOpen] = useState(false);
|
|
@@ -29328,11 +29589,7 @@ function CanvasTextToolbar({ id, fontFamily, textColor, textStyle, fontSize, tex
|
|
|
29328
29589
|
};
|
|
29329
29590
|
return /* @__PURE__ */ jsx("div", {
|
|
29330
29591
|
"data-slot": "docblocks/canvas-chrome",
|
|
29331
|
-
|
|
29332
|
-
style: {
|
|
29333
|
-
...style,
|
|
29334
|
-
transform: "translate(-50%, -100%)"
|
|
29335
|
-
},
|
|
29592
|
+
style,
|
|
29336
29593
|
onMouseDown: onToolbarBodyMouseDown,
|
|
29337
29594
|
children: /* @__PURE__ */ jsxs("div", {
|
|
29338
29595
|
"data-slot": "docblocks/canvas-text-toolbar",
|
|
@@ -29378,9 +29635,11 @@ function CanvasTextToolbar({ id, fontFamily, textColor, textStyle, fontSize, tex
|
|
|
29378
29635
|
* reorder picks — one `setZOrder` each). Each apply is one `updateBlock`
|
|
29379
29636
|
* in one transact (one undo step, one wire update). The
|
|
29380
29637
|
* toolbar is canvas chrome (its own pointers; a press on it starts no
|
|
29381
|
-
* canvas session).
|
|
29638
|
+
* canvas session). The canvas view places it over the box's top edge
|
|
29639
|
+
* (flipped below the box near the canvas's top edge — the placement is
|
|
29640
|
+
* the anchor's).
|
|
29382
29641
|
*/
|
|
29383
|
-
function ShapeToolbar({ id, fill, stroke, strokeWidth, strokeStyle, variant, text, fontSize, fontFamily, textColor, textStyle, textAlign, zStand, style }) {
|
|
29642
|
+
function ShapeToolbar({ id, fill, stroke, strokeWidth, strokeStyle, variant, text, fontSize, fontFamily, textColor, textStyle, textAlign, zStand, style = {} }) {
|
|
29384
29643
|
const { t } = useTranslation("canvas");
|
|
29385
29644
|
const { doc } = useEditorContext();
|
|
29386
29645
|
const textEdit = useCanvasTextEdit();
|
|
@@ -29423,11 +29682,7 @@ function ShapeToolbar({ id, fill, stroke, strokeWidth, strokeStyle, variant, tex
|
|
|
29423
29682
|
const beginTextEdit = () => textEdit?.setEditingId(id);
|
|
29424
29683
|
return /* @__PURE__ */ jsx("div", {
|
|
29425
29684
|
"data-slot": "docblocks/canvas-chrome",
|
|
29426
|
-
|
|
29427
|
-
style: {
|
|
29428
|
-
...style,
|
|
29429
|
-
transform: "translate(-50%, -100%)"
|
|
29430
|
-
},
|
|
29685
|
+
style,
|
|
29431
29686
|
onMouseDown: onToolbarBodyMouseDown,
|
|
29432
29687
|
children: /* @__PURE__ */ jsxs("div", {
|
|
29433
29688
|
"data-slot": "docblocks/shape-toolbar",
|
|
@@ -29568,18 +29823,15 @@ function ShapeToolbar({ id, fill, stroke, strokeWidth, strokeStyle, variant, tex
|
|
|
29568
29823
|
* their own (the group's border / the frame's boundary stand the fixed's
|
|
29569
29824
|
* stand), so the z-order's menu is the toolbar's whole content. The toolbar
|
|
29570
29825
|
* is canvas chrome (its own pointers; a press on it starts no canvas
|
|
29571
|
-
* session).
|
|
29826
|
+
* session). The canvas view places it over the box's top edge (the
|
|
29827
|
+
* shape toolbar's placement's stand).
|
|
29572
29828
|
*/
|
|
29573
|
-
function ZOrderToolbar({ id, kind, zStand, style }) {
|
|
29829
|
+
function ZOrderToolbar({ id, kind, zStand, style = {} }) {
|
|
29574
29830
|
const { t } = useTranslation("canvas");
|
|
29575
29831
|
const label = kind === "frame" ? t("arrange.frame") : t("arrange.container");
|
|
29576
29832
|
return /* @__PURE__ */ jsx("div", {
|
|
29577
29833
|
"data-slot": "docblocks/canvas-chrome",
|
|
29578
|
-
|
|
29579
|
-
style: {
|
|
29580
|
-
...style,
|
|
29581
|
-
transform: "translate(-50%, -100%)"
|
|
29582
|
-
},
|
|
29834
|
+
style,
|
|
29583
29835
|
onMouseDown: onToolbarBodyMouseDown,
|
|
29584
29836
|
children: /* @__PURE__ */ jsx("div", {
|
|
29585
29837
|
"data-slot": "docblocks/z-order-toolbar",
|
|
@@ -30208,7 +30460,7 @@ function FramePageWindow({ id, frameId, surfaceId, referenced }) {
|
|
|
30208
30460
|
style: {
|
|
30209
30461
|
width: winW,
|
|
30210
30462
|
height: winH,
|
|
30211
|
-
boxShadow: "inset 0 0 0
|
|
30463
|
+
boxShadow: "inset 0 0 0 var(--docblocks-canvas-group-border-width) var(--docblocks-canvas-group-border-color)"
|
|
30212
30464
|
},
|
|
30213
30465
|
children: /* @__PURE__ */ jsx("div", {
|
|
30214
30466
|
className: "absolute top-0 left-0 origin-top-left",
|
|
@@ -33955,6 +34207,124 @@ function CanvasOverlays({ viewport, previewFrom, previewEnd, previewSnap, hoverS
|
|
|
33955
34207
|
})
|
|
33956
34208
|
] });
|
|
33957
34209
|
}
|
|
34210
|
+
// src/canvas/canvas-view/CanvasWaypointHandles.tsx
|
|
34211
|
+
/**
|
|
34212
|
+
* The selected line's waypoint dots (the bend points): the screen-space
|
|
34213
|
+
* stand over the route at any zoom (the line's own options toolbar sits
|
|
34214
|
+
* above them, z-60). The dot's press opens the waypoint's drag (the
|
|
34215
|
+
* container keeps the pointer, the release commits the point); the dot's
|
|
34216
|
+
* double-click stands the point's removal — the drag's pointer capture
|
|
34217
|
+
* retargets the double-click to the canvas container, so the removal
|
|
34218
|
+
* stands in the content's double-click handler (the point's element is
|
|
34219
|
+
* the read there).
|
|
34220
|
+
*/
|
|
34221
|
+
function CanvasWaypointHandles({ connectorId, points, screenOf, onPress }) {
|
|
34222
|
+
if (points.length === 0) return null;
|
|
34223
|
+
return /* @__PURE__ */ jsx("div", {
|
|
34224
|
+
"data-slot": "docblocks/connector-waypoints",
|
|
34225
|
+
className: "pointer-events-none absolute inset-0 z-50",
|
|
34226
|
+
children: points.map((point, index) => {
|
|
34227
|
+
const screen = screenOf(point);
|
|
34228
|
+
return /* @__PURE__ */ jsxs("svg", {
|
|
34229
|
+
"data-connector-waypoint": index,
|
|
34230
|
+
"data-connector-waypoint-id": connectorId,
|
|
34231
|
+
width: 16,
|
|
34232
|
+
height: 16,
|
|
34233
|
+
style: {
|
|
34234
|
+
position: "absolute",
|
|
34235
|
+
left: `calc(50% + ${screen.x}px - 8px)`,
|
|
34236
|
+
top: `calc(50% + ${screen.y}px - 8px)`
|
|
34237
|
+
},
|
|
34238
|
+
children: [/* @__PURE__ */ jsx("circle", {
|
|
34239
|
+
cx: 8,
|
|
34240
|
+
cy: 8,
|
|
34241
|
+
r: 8,
|
|
34242
|
+
fill: "transparent",
|
|
34243
|
+
pointerEvents: "all",
|
|
34244
|
+
className: "cursor-grab",
|
|
34245
|
+
onPointerDown: (event) => onPress(connectorId, index, event)
|
|
34246
|
+
}), /* @__PURE__ */ jsx("circle", {
|
|
34247
|
+
cx: 8,
|
|
34248
|
+
cy: 8,
|
|
34249
|
+
r: 4,
|
|
34250
|
+
fill: SURFACE_BG,
|
|
34251
|
+
strokeWidth: 1.5,
|
|
34252
|
+
pointerEvents: "none",
|
|
34253
|
+
className: "stroke-(--docblocks-canvas-selected-stroke)"
|
|
34254
|
+
})]
|
|
34255
|
+
}, `${index}-${point.x}-${point.y}`);
|
|
34256
|
+
})
|
|
34257
|
+
});
|
|
34258
|
+
}
|
|
34259
|
+
// src/canvas/canvas-view/CanvasConnectorChrome.tsx
|
|
34260
|
+
function CanvasConnectorChrome({ viewport, blocks, target, handles, onEndpointPress, onWaypointPress, onAddWaypoint }) {
|
|
34261
|
+
const mid = canvasToScreen(target.mid, viewport.zoom, viewport.pan);
|
|
34262
|
+
const waypointPoints = connectorWaypointPoints(blocks[target.id], {
|
|
34263
|
+
movePreview: viewport.movePreview,
|
|
34264
|
+
resizePreview: viewport.resizePreview,
|
|
34265
|
+
endpointDrag: viewport.connectorEndpoint,
|
|
34266
|
+
endpointPreview: viewport.connectorEndpointPreview
|
|
34267
|
+
});
|
|
34268
|
+
const screenOf = (point) => canvasToScreen(point, viewport.zoom, viewport.pan);
|
|
34269
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
34270
|
+
/* @__PURE__ */ jsx(ConnectorToolbar, {
|
|
34271
|
+
id: target.id,
|
|
34272
|
+
variant: target.variant,
|
|
34273
|
+
strokeColor: target.strokeColor,
|
|
34274
|
+
strokeWidth: target.strokeWidth,
|
|
34275
|
+
strokeStyle: target.strokeStyle,
|
|
34276
|
+
arrowHead: target.arrowHead,
|
|
34277
|
+
arrowStart: target.arrowStart,
|
|
34278
|
+
zStand: target.zStand,
|
|
34279
|
+
onAddWaypoint,
|
|
34280
|
+
style: {
|
|
34281
|
+
left: `calc(50% + ${mid.x}px)`,
|
|
34282
|
+
top: `calc(50% + ${mid.y - 48}px)`
|
|
34283
|
+
}
|
|
34284
|
+
}),
|
|
34285
|
+
handles !== null && /* @__PURE__ */ jsx("div", {
|
|
34286
|
+
"data-slot": "docblocks/connector-handles",
|
|
34287
|
+
className: "pointer-events-none absolute inset-0 z-50",
|
|
34288
|
+
children: ["start", "end"].map((which) => {
|
|
34289
|
+
const point = screenOf(handles[which]);
|
|
34290
|
+
return /* @__PURE__ */ jsxs("svg", {
|
|
34291
|
+
"data-connector-endpoint": which,
|
|
34292
|
+
"data-connector-endpoint-id": target.id,
|
|
34293
|
+
width: 16,
|
|
34294
|
+
height: 16,
|
|
34295
|
+
style: {
|
|
34296
|
+
position: "absolute",
|
|
34297
|
+
left: `calc(50% + ${point.x}px - 8px)`,
|
|
34298
|
+
top: `calc(50% + ${point.y}px - 8px)`
|
|
34299
|
+
},
|
|
34300
|
+
children: [/* @__PURE__ */ jsx("circle", {
|
|
34301
|
+
cx: 8,
|
|
34302
|
+
cy: 8,
|
|
34303
|
+
r: 8,
|
|
34304
|
+
fill: "transparent",
|
|
34305
|
+
pointerEvents: "all",
|
|
34306
|
+
className: "cursor-grab",
|
|
34307
|
+
onPointerDown: (event) => onEndpointPress(which, event)
|
|
34308
|
+
}), /* @__PURE__ */ jsx("circle", {
|
|
34309
|
+
cx: 8,
|
|
34310
|
+
cy: 8,
|
|
34311
|
+
r: 4,
|
|
34312
|
+
fill: "var(--docblocks-canvas-surface-background, var(--card, #ffffff))",
|
|
34313
|
+
strokeWidth: 1.5,
|
|
34314
|
+
pointerEvents: "none",
|
|
34315
|
+
className: "stroke-(--docblocks-canvas-selected-stroke)"
|
|
34316
|
+
})]
|
|
34317
|
+
}, which);
|
|
34318
|
+
})
|
|
34319
|
+
}),
|
|
34320
|
+
/* @__PURE__ */ jsx(CanvasWaypointHandles, {
|
|
34321
|
+
connectorId: target.id,
|
|
34322
|
+
points: waypointPoints,
|
|
34323
|
+
screenOf,
|
|
34324
|
+
onPress: onWaypointPress
|
|
34325
|
+
})
|
|
34326
|
+
] });
|
|
34327
|
+
}
|
|
33958
34328
|
// src/canvas/canvas-view/CanvasCycleIndicator.tsx
|
|
33959
34329
|
/** The drill-down's `i / N` indicator: the small chip at the click point
|
|
33960
34330
|
* that names the selected candidate's position in the stack and the stack's
|
|
@@ -34108,12 +34478,81 @@ function CanvasTitleChips({ surfaces, blocks, visibleIds, selection, viewport, v
|
|
|
34108
34478
|
selected,
|
|
34109
34479
|
slot: block.type,
|
|
34110
34480
|
ariaLabel: block.type === "group" ? t("titleChip.containerTitle") : t("titleChip.frameTitle"),
|
|
34111
|
-
restBorderColor:
|
|
34481
|
+
restBorderColor: "var(--docblocks-canvas-group-border-color)",
|
|
34112
34482
|
interactive: !viewMode
|
|
34113
34483
|
})
|
|
34114
34484
|
}, `${surfaceId}-${childId}`);
|
|
34115
34485
|
})) });
|
|
34116
34486
|
}
|
|
34487
|
+
const ABOVE_TRANSFORM = "translate(-50%, -100%)";
|
|
34488
|
+
const BELOW_TRANSFORM = "translate(-50%, 0)";
|
|
34489
|
+
/**
|
|
34490
|
+
* The toolbar's placement: above the box's top edge when the toolbar's own
|
|
34491
|
+
* height fits between the box and the canvas's top edge, below the box's
|
|
34492
|
+
* bottom edge otherwise (clamped into the canvas's vertical band when the
|
|
34493
|
+
* flipped stand overflows it). The horizontal center clamps into the
|
|
34494
|
+
* canvas's width.
|
|
34495
|
+
*/
|
|
34496
|
+
function placeToolbar(centerX, boxTop, boxBottom, container, toolbar) {
|
|
34497
|
+
const measured = toolbar.height > 0;
|
|
34498
|
+
const containerTop = -container.height / 2;
|
|
34499
|
+
const containerBottom = container.height / 2;
|
|
34500
|
+
const fitsAbove = !measured || boxTop - 48 - toolbar.height >= containerTop;
|
|
34501
|
+
let top;
|
|
34502
|
+
let transform;
|
|
34503
|
+
if (fitsAbove) {
|
|
34504
|
+
top = boxTop - 48;
|
|
34505
|
+
transform = ABOVE_TRANSFORM;
|
|
34506
|
+
} else {
|
|
34507
|
+
top = boxBottom + 8;
|
|
34508
|
+
transform = BELOW_TRANSFORM;
|
|
34509
|
+
if (top + toolbar.height > containerBottom) top = containerBottom - toolbar.height;
|
|
34510
|
+
}
|
|
34511
|
+
const halfWidth = toolbar.width / 2;
|
|
34512
|
+
return {
|
|
34513
|
+
left: measured && container.width > toolbar.width ? Math.min(Math.max(centerX, -container.width / 2 + halfWidth), container.width / 2 - halfWidth) : centerX,
|
|
34514
|
+
top,
|
|
34515
|
+
transform
|
|
34516
|
+
};
|
|
34517
|
+
}
|
|
34518
|
+
// src/canvas/canvas-view/CanvasToolbarAnchor.tsx
|
|
34519
|
+
const EMPTY_SIZE = {
|
|
34520
|
+
width: 0,
|
|
34521
|
+
height: 0
|
|
34522
|
+
};
|
|
34523
|
+
function CanvasToolbarAnchor({ centerX, boxTop, boxBottom, container, children }) {
|
|
34524
|
+
const ref = useRef(null);
|
|
34525
|
+
const [size, setSize] = useState(EMPTY_SIZE);
|
|
34526
|
+
useLayoutEffect(() => {
|
|
34527
|
+
const element = ref.current;
|
|
34528
|
+
if (element === null) return;
|
|
34529
|
+
const measure = () => {
|
|
34530
|
+
const next = {
|
|
34531
|
+
width: element.offsetWidth,
|
|
34532
|
+
height: element.offsetHeight
|
|
34533
|
+
};
|
|
34534
|
+
setSize((prev) => prev.width === next.width && prev.height === next.height ? prev : next);
|
|
34535
|
+
};
|
|
34536
|
+
measure();
|
|
34537
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
34538
|
+
const observer = new ResizeObserver(measure);
|
|
34539
|
+
observer.observe(element);
|
|
34540
|
+
return () => observer.disconnect();
|
|
34541
|
+
}, []);
|
|
34542
|
+
const placement = placeToolbar(centerX, boxTop, boxBottom, container, size);
|
|
34543
|
+
const style = {
|
|
34544
|
+
left: `calc(50% + ${placement.left}px)`,
|
|
34545
|
+
top: `calc(50% + ${placement.top}px)`,
|
|
34546
|
+
transform: placement.transform
|
|
34547
|
+
};
|
|
34548
|
+
return /* @__PURE__ */ jsx("div", {
|
|
34549
|
+
ref,
|
|
34550
|
+
"data-slot": "docblocks/canvas-toolbar-anchor",
|
|
34551
|
+
className: "absolute z-50",
|
|
34552
|
+
style,
|
|
34553
|
+
children
|
|
34554
|
+
});
|
|
34555
|
+
}
|
|
34117
34556
|
// src/canvas/canvas-view/ZoomControls.tsx
|
|
34118
34557
|
/** The canvas zoom controls (the floating chrome, top-right): the fit / zoom-out /
|
|
34119
34558
|
* current / zoom-in buttons. The zoom stands in the view state only — no
|
|
@@ -34169,12 +34608,36 @@ const ZoomControls = memo(function ZoomControls({ zoom, onStep, onReset, onFit }
|
|
|
34169
34608
|
});
|
|
34170
34609
|
}, (prev, next) => prev.zoom === next.zoom && prev.onStep === next.onStep && prev.onFit === next.onFit);
|
|
34171
34610
|
// src/canvas/canvas-view/CanvasScreenChrome.tsx
|
|
34172
|
-
function CanvasScreenChrome({ viewport, blocks, surfaces, culling, selection, viewMode, targets, onChipPress, onChipDoubleClick,
|
|
34611
|
+
function CanvasScreenChrome({ containerSize, viewport, blocks, surfaces, culling, selection, viewMode, targets, onChipPress, onChipDoubleClick, beginEndpointDrag, beginWaypointDrag, addConnectorWaypoint, onResetZoom, onFit }) {
|
|
34173
34612
|
const { multiSelectionBox, handleTarget, displayBox, connectorToolbarTarget, selectedConnectorHandles, shapeToolbarTarget, textToolbarTarget, arrangeToolbarTarget } = targets;
|
|
34174
|
-
const
|
|
34613
|
+
const boxTop = (box) => canvasToScreen({
|
|
34614
|
+
x: box.x,
|
|
34615
|
+
y: box.y
|
|
34616
|
+
}, viewport.zoom, viewport.pan).y - box.h / 2 * viewport.zoom;
|
|
34617
|
+
const boxBottom = (box) => canvasToScreen({
|
|
34618
|
+
x: box.x,
|
|
34619
|
+
y: box.y
|
|
34620
|
+
}, viewport.zoom, viewport.pan).y + box.h / 2 * viewport.zoom;
|
|
34621
|
+
const connectorId = connectorToolbarTarget?.id ?? null;
|
|
34622
|
+
const onEndpointPress = (which, event) => {
|
|
34623
|
+
if (connectorId === null) return;
|
|
34624
|
+
event.stopPropagation();
|
|
34625
|
+
event.preventDefault();
|
|
34626
|
+
beginEndpointDrag(connectorId, which, event.pointerId, event.clientX, event.clientY);
|
|
34627
|
+
};
|
|
34628
|
+
const onWaypointPress = (id, index, event) => {
|
|
34629
|
+
event.stopPropagation();
|
|
34630
|
+
event.preventDefault();
|
|
34631
|
+
beginWaypointDrag(id, index, event.pointerId, event.clientX, event.clientY);
|
|
34632
|
+
};
|
|
34633
|
+
const onAddWaypoint = () => {
|
|
34634
|
+
if (connectorId === null) return;
|
|
34635
|
+
addConnectorWaypoint(connectorId);
|
|
34636
|
+
};
|
|
34637
|
+
const boxCenterX = (box) => canvasToScreen({
|
|
34175
34638
|
x: box.x,
|
|
34176
34639
|
y: box.y
|
|
34177
|
-
}, viewport.zoom, viewport.pan).
|
|
34640
|
+
}, viewport.zoom, viewport.pan).x;
|
|
34178
34641
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
34179
34642
|
/* @__PURE__ */ jsx(CanvasSelectionOverlay, {
|
|
34180
34643
|
viewport,
|
|
@@ -34204,104 +34667,61 @@ function CanvasScreenChrome({ viewport, blocks, surfaces, culling, selection, vi
|
|
|
34204
34667
|
style
|
|
34205
34668
|
}, handleId))
|
|
34206
34669
|
}),
|
|
34207
|
-
connectorToolbarTarget !== null && /* @__PURE__ */ jsx(
|
|
34208
|
-
|
|
34209
|
-
|
|
34210
|
-
|
|
34211
|
-
|
|
34212
|
-
|
|
34213
|
-
|
|
34214
|
-
|
|
34215
|
-
zStand: connectorToolbarTarget.zStand,
|
|
34216
|
-
style: {
|
|
34217
|
-
left: `calc(50% + ${canvasToScreen(connectorToolbarTarget.mid, viewport.zoom, viewport.pan).x}px)`,
|
|
34218
|
-
top: `calc(50% + ${canvasToScreen(connectorToolbarTarget.mid, viewport.zoom, viewport.pan).y - 48}px)`
|
|
34219
|
-
}
|
|
34670
|
+
connectorToolbarTarget !== null && /* @__PURE__ */ jsx(CanvasConnectorChrome, {
|
|
34671
|
+
viewport,
|
|
34672
|
+
blocks,
|
|
34673
|
+
target: connectorToolbarTarget,
|
|
34674
|
+
handles: selectedConnectorHandles,
|
|
34675
|
+
onEndpointPress,
|
|
34676
|
+
onWaypointPress,
|
|
34677
|
+
onAddWaypoint
|
|
34220
34678
|
}),
|
|
34221
|
-
|
|
34222
|
-
|
|
34223
|
-
|
|
34224
|
-
|
|
34225
|
-
|
|
34226
|
-
|
|
34227
|
-
|
|
34228
|
-
|
|
34229
|
-
|
|
34230
|
-
|
|
34231
|
-
|
|
34232
|
-
|
|
34233
|
-
|
|
34234
|
-
|
|
34235
|
-
|
|
34236
|
-
|
|
34237
|
-
|
|
34238
|
-
|
|
34239
|
-
|
|
34240
|
-
fill: "transparent",
|
|
34241
|
-
pointerEvents: "all",
|
|
34242
|
-
className: "cursor-grab",
|
|
34243
|
-
onPointerDown: onEndpointPointerDown(which)
|
|
34244
|
-
}), /* @__PURE__ */ jsx("circle", {
|
|
34245
|
-
cx: 8,
|
|
34246
|
-
cy: 8,
|
|
34247
|
-
r: 4,
|
|
34248
|
-
fill: "var(--docblocks-canvas-surface-background, var(--card, #ffffff))",
|
|
34249
|
-
strokeWidth: 1.5,
|
|
34250
|
-
pointerEvents: "none",
|
|
34251
|
-
className: "stroke-(--docblocks-canvas-selected-stroke)"
|
|
34252
|
-
})]
|
|
34253
|
-
}, which);
|
|
34679
|
+
shapeToolbarTarget !== null && displayBox !== null && /* @__PURE__ */ jsx(CanvasToolbarAnchor, {
|
|
34680
|
+
centerX: boxCenterX(displayBox),
|
|
34681
|
+
boxTop: boxTop(displayBox),
|
|
34682
|
+
boxBottom: boxBottom(displayBox),
|
|
34683
|
+
container: containerSize,
|
|
34684
|
+
children: /* @__PURE__ */ jsx(ShapeToolbar, {
|
|
34685
|
+
id: shapeToolbarTarget.id,
|
|
34686
|
+
fill: shapeToolbarTarget.fill,
|
|
34687
|
+
stroke: shapeToolbarTarget.stroke,
|
|
34688
|
+
strokeWidth: shapeToolbarTarget.strokeWidth,
|
|
34689
|
+
strokeStyle: shapeToolbarTarget.strokeStyle,
|
|
34690
|
+
variant: shapeToolbarTarget.variant,
|
|
34691
|
+
text: shapeToolbarTarget.text,
|
|
34692
|
+
fontSize: shapeToolbarTarget.fontSize,
|
|
34693
|
+
fontFamily: shapeToolbarTarget.fontFamily,
|
|
34694
|
+
textColor: shapeToolbarTarget.textColor,
|
|
34695
|
+
textStyle: shapeToolbarTarget.textStyle,
|
|
34696
|
+
textAlign: shapeToolbarTarget.textAlign,
|
|
34697
|
+
zStand: shapeToolbarTarget.zStand
|
|
34254
34698
|
})
|
|
34255
34699
|
}),
|
|
34256
|
-
|
|
34257
|
-
|
|
34258
|
-
|
|
34259
|
-
|
|
34260
|
-
|
|
34261
|
-
|
|
34262
|
-
|
|
34263
|
-
|
|
34264
|
-
|
|
34265
|
-
|
|
34266
|
-
|
|
34267
|
-
|
|
34268
|
-
|
|
34269
|
-
|
|
34270
|
-
style: {
|
|
34271
|
-
left: `calc(50% + ${canvasToScreen({
|
|
34272
|
-
x: displayBox.x,
|
|
34273
|
-
y: displayBox.y
|
|
34274
|
-
}, viewport.zoom, viewport.pan).x}px)`,
|
|
34275
|
-
top: `calc(50% + ${toolbarTop(displayBox)}px)`
|
|
34276
|
-
}
|
|
34277
|
-
}),
|
|
34278
|
-
textToolbarTarget !== null && displayBox !== null && /* @__PURE__ */ jsx(CanvasTextToolbar, {
|
|
34279
|
-
id: textToolbarTarget.id,
|
|
34280
|
-
fontFamily: textToolbarTarget.fontFamily,
|
|
34281
|
-
textColor: textToolbarTarget.textColor,
|
|
34282
|
-
textStyle: textToolbarTarget.textStyle,
|
|
34283
|
-
fontSize: textToolbarTarget.fontSize,
|
|
34284
|
-
textAlign: textToolbarTarget.textAlign,
|
|
34285
|
-
zStand: textToolbarTarget.zStand,
|
|
34286
|
-
style: {
|
|
34287
|
-
left: `calc(50% + ${canvasToScreen({
|
|
34288
|
-
x: displayBox.x,
|
|
34289
|
-
y: displayBox.y
|
|
34290
|
-
}, viewport.zoom, viewport.pan).x}px)`,
|
|
34291
|
-
top: `calc(50% + ${toolbarTop(displayBox)}px)`
|
|
34292
|
-
}
|
|
34700
|
+
textToolbarTarget !== null && displayBox !== null && /* @__PURE__ */ jsx(CanvasToolbarAnchor, {
|
|
34701
|
+
centerX: boxCenterX(displayBox),
|
|
34702
|
+
boxTop: boxTop(displayBox),
|
|
34703
|
+
boxBottom: boxBottom(displayBox),
|
|
34704
|
+
container: containerSize,
|
|
34705
|
+
children: /* @__PURE__ */ jsx(CanvasTextToolbar, {
|
|
34706
|
+
id: textToolbarTarget.id,
|
|
34707
|
+
fontFamily: textToolbarTarget.fontFamily,
|
|
34708
|
+
textColor: textToolbarTarget.textColor,
|
|
34709
|
+
textStyle: textToolbarTarget.textStyle,
|
|
34710
|
+
fontSize: textToolbarTarget.fontSize,
|
|
34711
|
+
textAlign: textToolbarTarget.textAlign,
|
|
34712
|
+
zStand: textToolbarTarget.zStand
|
|
34713
|
+
})
|
|
34293
34714
|
}),
|
|
34294
|
-
arrangeToolbarTarget !== null && displayBox !== null && /* @__PURE__ */ jsx(
|
|
34295
|
-
|
|
34296
|
-
|
|
34297
|
-
|
|
34298
|
-
|
|
34299
|
-
|
|
34300
|
-
|
|
34301
|
-
|
|
34302
|
-
|
|
34303
|
-
|
|
34304
|
-
}
|
|
34715
|
+
arrangeToolbarTarget !== null && displayBox !== null && /* @__PURE__ */ jsx(CanvasToolbarAnchor, {
|
|
34716
|
+
centerX: boxCenterX(displayBox),
|
|
34717
|
+
boxTop: boxTop(displayBox),
|
|
34718
|
+
boxBottom: boxBottom(displayBox),
|
|
34719
|
+
container: containerSize,
|
|
34720
|
+
children: /* @__PURE__ */ jsx(ZOrderToolbar, {
|
|
34721
|
+
id: arrangeToolbarTarget.id,
|
|
34722
|
+
kind: arrangeToolbarTarget.kind,
|
|
34723
|
+
zStand: arrangeToolbarTarget.zStand
|
|
34724
|
+
})
|
|
34305
34725
|
}),
|
|
34306
34726
|
/* @__PURE__ */ jsx(ZoomControls, {
|
|
34307
34727
|
zoom: viewport.zoom,
|
|
@@ -34395,15 +34815,9 @@ function ConnectorLabelEdit({ id, mid, stroke, width, lineStyle, label, onClose
|
|
|
34395
34815
|
* previews) + the screen-space chrome over the world (the marquee, the
|
|
34396
34816
|
* handles, the toolbars, the dock). The body (CanvasView) stands the
|
|
34397
34817
|
* session's hooks + the target's reads; this component is the paint. */
|
|
34398
|
-
function CanvasSurface({ containerRef, cursor, viewport, handlers, pageContext, pageChildren, pageCardSelected, pageCardDisplayStyle, surfaces, culling, storeSelection, blocks, viewMode, targets, beginEndpointDrag, onResetZoom, onFit }) {
|
|
34818
|
+
function CanvasSurface({ containerRef, containerSize, cursor, viewport, handlers, pageContext, pageChildren, pageCardSelected, pageCardDisplayStyle, surfaces, culling, storeSelection, blocks, viewMode, targets, beginEndpointDrag, beginWaypointDrag, addConnectorWaypoint, onResetZoom, onFit }) {
|
|
34399
34819
|
const { t } = useTranslation("canvas");
|
|
34400
34820
|
const { handleTarget, displayBox, multiSelectionBox, shapeToolbarTarget, textToolbarTarget, arrangeToolbarTarget, connectorToolbarTarget, connectorLabelTarget, selectedConnectorHandles, previewFrom, previewSnap, previewEnd, hoverSnapPoint } = targets;
|
|
34401
|
-
const onEndpointPointerDown = (which) => (event) => {
|
|
34402
|
-
if (connectorToolbarTarget === null) return;
|
|
34403
|
-
event.stopPropagation();
|
|
34404
|
-
event.preventDefault();
|
|
34405
|
-
beginEndpointDrag(connectorToolbarTarget.id, which, event.pointerId, event.clientX, event.clientY);
|
|
34406
|
-
};
|
|
34407
34821
|
return /* @__PURE__ */ jsxs("div", {
|
|
34408
34822
|
"data-slot": "docblocks/canvas-view",
|
|
34409
34823
|
ref: containerRef,
|
|
@@ -34479,6 +34893,7 @@ function CanvasSurface({ containerRef, cursor, viewport, handlers, pageContext,
|
|
|
34479
34893
|
})
|
|
34480
34894
|
]
|
|
34481
34895
|
}), /* @__PURE__ */ jsx(CanvasScreenChrome, {
|
|
34896
|
+
containerSize,
|
|
34482
34897
|
viewport,
|
|
34483
34898
|
blocks,
|
|
34484
34899
|
surfaces,
|
|
@@ -34497,7 +34912,9 @@ function CanvasSurface({ containerRef, cursor, viewport, handlers, pageContext,
|
|
|
34497
34912
|
textToolbarTarget,
|
|
34498
34913
|
arrangeToolbarTarget
|
|
34499
34914
|
},
|
|
34500
|
-
|
|
34915
|
+
beginEndpointDrag,
|
|
34916
|
+
beginWaypointDrag,
|
|
34917
|
+
addConnectorWaypoint,
|
|
34501
34918
|
onResetZoom,
|
|
34502
34919
|
onFit
|
|
34503
34920
|
})]
|
|
@@ -34663,8 +35080,7 @@ function computeCulling(visible, surfaces, blocks, keep) {
|
|
|
34663
35080
|
* the surfaces' children's memo holds), the fresh set over the content's
|
|
34664
35081
|
* change (an item enters / leaves the viewport band).
|
|
34665
35082
|
*/
|
|
34666
|
-
function useCanvasCulling(
|
|
34667
|
-
const size = useContainerSize(containerRef);
|
|
35083
|
+
function useCanvasCulling(size, viewport, surfaces, blocks) {
|
|
34668
35084
|
const measured = size.width > 0 && size.height > 0 ? size : FALLBACK_SIZE;
|
|
34669
35085
|
const visible = visibleWorldRectOf(viewport.zoom, viewport.pan, measured, 300);
|
|
34670
35086
|
const cacheRef = useRef(null);
|
|
@@ -34831,7 +35247,8 @@ function handleCanvasEscape({ viewport, selection, doc, sessionRef }) {
|
|
|
34831
35247
|
return "stop";
|
|
34832
35248
|
}
|
|
34833
35249
|
if (viewport.connectorEndpoint !== null) {
|
|
34834
|
-
viewport.
|
|
35250
|
+
if (viewport.connectorEndpoint.which === "waypoint") viewport.cancelConnectorWaypoint();
|
|
35251
|
+
else viewport.cancelConnectorEndpoint();
|
|
34835
35252
|
return "stop";
|
|
34836
35253
|
}
|
|
34837
35254
|
if (viewport.resizePreview !== null) {
|
|
@@ -35554,6 +35971,16 @@ function chipDoubleClick(ctx, id, event) {
|
|
|
35554
35971
|
function createContentDoubleClick(ctx) {
|
|
35555
35972
|
return (event) => {
|
|
35556
35973
|
if (ctx.viewMode) return;
|
|
35974
|
+
const waypointDot = pointElementOf(event) instanceof Element ? pointElementOf(event).closest("[data-connector-waypoint]") : null;
|
|
35975
|
+
if (waypointDot !== null) {
|
|
35976
|
+
const connectorId = waypointDot.getAttribute("data-connector-waypoint-id");
|
|
35977
|
+
const index = Number(waypointDot.getAttribute("data-connector-waypoint"));
|
|
35978
|
+
if (connectorId !== null && Number.isInteger(index)) {
|
|
35979
|
+
event.preventDefault();
|
|
35980
|
+
ctx.viewport.removeConnectorWaypoint(connectorId, index);
|
|
35981
|
+
return;
|
|
35982
|
+
}
|
|
35983
|
+
}
|
|
35557
35984
|
if (event.altKey) return;
|
|
35558
35985
|
const touchStep = ctx.viewport.cycleIndicator;
|
|
35559
35986
|
if (touchStep !== null && ctx.viewport.cycle?.pointerType === "touch") {
|
|
@@ -35930,6 +36357,19 @@ function beginEndpointDrag(ctx, connectorId, which, pointerId, clientX, clientY)
|
|
|
35930
36357
|
y: clientY - rect.top - rect.height / 2
|
|
35931
36358
|
}, clientX, clientY);
|
|
35932
36359
|
}
|
|
36360
|
+
/** The waypoint handle's press (the selected line's bend dot): the endpoint
|
|
36361
|
+
* handle's contract — the container keeps the pointer, the release reads the
|
|
36362
|
+
* session. */
|
|
36363
|
+
function beginWaypointDrag(ctx, connectorId, index, pointerId, clientX, clientY) {
|
|
36364
|
+
const container = ctx.containerRef.current;
|
|
36365
|
+
if (container === null) return;
|
|
36366
|
+
container.setPointerCapture?.(pointerId);
|
|
36367
|
+
const rect = container.getBoundingClientRect();
|
|
36368
|
+
ctx.viewport.beginConnectorWaypoint(connectorId, index, {
|
|
36369
|
+
x: clientX - rect.left - rect.width / 2,
|
|
36370
|
+
y: clientY - rect.top - rect.height / 2
|
|
36371
|
+
}, clientX, clientY);
|
|
36372
|
+
}
|
|
35933
36373
|
/** The pen's press: the live stroke's begin (the first point is the press's canvas point). */
|
|
35934
36374
|
function penPress(ctx, event, point) {
|
|
35935
36375
|
if (ctx.viewport.activeTool !== "pen") return false;
|
|
@@ -36021,6 +36461,14 @@ function panPress(ctx, event) {
|
|
|
36021
36461
|
return true;
|
|
36022
36462
|
}
|
|
36023
36463
|
// src/canvas/canvas-view/canvas-session-release.ts
|
|
36464
|
+
/** Whether the marquee's rect reaches the container's border band: the
|
|
36465
|
+
* box's own rect minus the inset band (the press hit's parity — a
|
|
36466
|
+
* container's interior stands transparent to what lies beneath, so a
|
|
36467
|
+
* marquee drawn in the interior selects the contents, never the box). */
|
|
36468
|
+
function sweepsBorderBand(rect, box) {
|
|
36469
|
+
if (!rectsIntersect(rect, box)) return false;
|
|
36470
|
+
return !(rect.left >= box.left + 6 && rect.left + rect.width <= box.left + box.width - 6 && rect.top >= box.top + 6 && rect.top + rect.height <= box.top + box.height - 6);
|
|
36471
|
+
}
|
|
36024
36472
|
/** The release handlers (the pointerup's commits + the session's drop + the pointer cancel). The OS / browser takeover (a pointer cancel, a lost capture, a button-less move over a surviving session) drops every in-flight session: the move's preview would otherwise stand until the next release, and that release would commit a stale setGeometry. The no-session calls are no-ops (the state stays, no re-render). */
|
|
36025
36473
|
function createReleaseHandlers(ctx) {
|
|
36026
36474
|
const dropCanvasSessions = () => {
|
|
@@ -36032,6 +36480,7 @@ function createReleaseHandlers(ctx) {
|
|
|
36032
36480
|
ctx.viewport.cancelMove();
|
|
36033
36481
|
ctx.viewport.cancelResize();
|
|
36034
36482
|
ctx.viewport.cancelConnectorEndpoint();
|
|
36483
|
+
ctx.viewport.cancelConnectorWaypoint();
|
|
36035
36484
|
ctx.viewport.setMarquee(null);
|
|
36036
36485
|
ctx.viewport.setPenPoints([]);
|
|
36037
36486
|
};
|
|
@@ -36039,7 +36488,8 @@ function createReleaseHandlers(ctx) {
|
|
|
36039
36488
|
ctx.cardPressRef.current = false;
|
|
36040
36489
|
if (ctx.viewport.connectorEndpoint !== null) {
|
|
36041
36490
|
ctx.cycleStepRef.current = null;
|
|
36042
|
-
ctx.viewport.
|
|
36491
|
+
if (ctx.viewport.connectorEndpoint.which === "waypoint") ctx.viewport.endConnectorWaypoint(event.clientX, event.clientY);
|
|
36492
|
+
else ctx.viewport.endConnectorEndpoint(event.clientX, event.clientY);
|
|
36043
36493
|
return;
|
|
36044
36494
|
}
|
|
36045
36495
|
if (ctx.viewport.activeTool === "connector" && (ctx.viewport.pendingConnector !== null || ctx.viewport.pendingFree !== null)) {
|
|
@@ -36114,26 +36564,32 @@ function createReleaseHandlers(ctx) {
|
|
|
36114
36564
|
const id = el.getAttribute("data-block-id");
|
|
36115
36565
|
if (id === null || ctx.blocks[id]?.type === "connector") continue;
|
|
36116
36566
|
const box = el.getBoundingClientRect();
|
|
36117
|
-
|
|
36567
|
+
const itemRect = {
|
|
36118
36568
|
left: box.left - containerRect.left - center.x,
|
|
36119
36569
|
top: box.top - containerRect.top - center.y,
|
|
36120
36570
|
width: box.width,
|
|
36121
36571
|
height: box.height
|
|
36122
|
-
}
|
|
36572
|
+
};
|
|
36573
|
+
const type = ctx.blocks[id]?.type;
|
|
36574
|
+
if (type === "group" || type === "frame" ? sweepsBorderBand(rect, itemRect) : rectsIntersect(rect, itemRect)) ids.push(id);
|
|
36123
36575
|
}
|
|
36576
|
+
const swept = new Set(ids);
|
|
36577
|
+
const picked = ids.filter((id) => {
|
|
36578
|
+
return !(ctx.blocks[id]?.type === "group" ? ctx.blocks[id]?.attrs?.members ?? [] : []).some((member) => member !== id && swept.has(member));
|
|
36579
|
+
});
|
|
36124
36580
|
if (additive) {
|
|
36125
36581
|
const sel = ctx.selection.view?.get();
|
|
36126
36582
|
const base = sel?.kind === "blocks" ? sel.ids : [];
|
|
36127
|
-
const merged = [...base, ...
|
|
36583
|
+
const merged = [...base, ...picked.filter((id) => !base.includes(id))];
|
|
36128
36584
|
ctx.selection.view?.set(merged.length > 0 ? {
|
|
36129
36585
|
kind: "blocks",
|
|
36130
36586
|
ids: merged,
|
|
36131
36587
|
anchorId: base.length > 0 && sel?.kind === "blocks" ? sel.anchorId : merged[0]
|
|
36132
36588
|
} : { kind: "none" });
|
|
36133
|
-
} else ctx.selection.view?.set(
|
|
36589
|
+
} else ctx.selection.view?.set(picked.length > 0 ? {
|
|
36134
36590
|
kind: "blocks",
|
|
36135
|
-
ids,
|
|
36136
|
-
anchorId:
|
|
36591
|
+
ids: picked,
|
|
36592
|
+
anchorId: picked[0]
|
|
36137
36593
|
} : { kind: "none" });
|
|
36138
36594
|
ctx.containerRef.current?.focus();
|
|
36139
36595
|
}
|
|
@@ -36191,7 +36647,10 @@ function useCanvasSessions(deps) {
|
|
|
36191
36647
|
}
|
|
36192
36648
|
ctx.viewport.moveDrag(event.clientX, event.clientY);
|
|
36193
36649
|
ctx.viewport.resizeDrag(event.clientX, event.clientY, event.shiftKey);
|
|
36194
|
-
if (ctx.viewport.connectorEndpoint !== null)
|
|
36650
|
+
if (ctx.viewport.connectorEndpoint !== null) {
|
|
36651
|
+
if (ctx.viewport.connectorEndpoint.which === "waypoint") ctx.viewport.moveConnectorWaypoint(ctx.centerRelativePoint(event));
|
|
36652
|
+
else ctx.viewport.moveConnectorEndpoint(ctx.centerRelativePoint(event));
|
|
36653
|
+
}
|
|
36195
36654
|
const session = ctx.sessionRef.current;
|
|
36196
36655
|
if (session === null) return;
|
|
36197
36656
|
const point = ctx.centerRelativePoint(event);
|
|
@@ -36230,6 +36689,7 @@ function useCanvasSessions(deps) {
|
|
|
36230
36689
|
onPointerCancel,
|
|
36231
36690
|
dropCanvasSessions,
|
|
36232
36691
|
beginEndpointDrag: (connectorId, which, pointerId, clientX, clientY) => beginEndpointDrag(ctx, connectorId, which, pointerId, clientX, clientY),
|
|
36692
|
+
beginWaypointDrag: (connectorId, index, pointerId, clientX, clientY) => beginWaypointDrag(ctx, connectorId, index, pointerId, clientX, clientY),
|
|
36233
36693
|
onContentDoubleClick,
|
|
36234
36694
|
onChipPress: (id, event) => chipPress(ctx, event, id),
|
|
36235
36695
|
onChipDoubleClick: (id, event) => chipDoubleClick(ctx, id, event)
|
|
@@ -36532,10 +36992,11 @@ function CanvasView() {
|
|
|
36532
36992
|
viewport,
|
|
36533
36993
|
rootBlockId
|
|
36534
36994
|
});
|
|
36535
|
-
const
|
|
36995
|
+
const containerSize = useContainerSize(containerRef);
|
|
36996
|
+
const culling = useCanvasCulling(containerSize, viewport, surfaces, blocks);
|
|
36536
36997
|
if (root === void 0) return null;
|
|
36537
36998
|
const isEditingSurface = (target) => target instanceof Element && target.closest("[contenteditable=\"true\"], input, textarea") !== null;
|
|
36538
|
-
const { onPointerDown, onPointerMove, onPointerUp, onMouseDown, onPointerCancel, dropCanvasSessions, beginEndpointDrag, onContentDoubleClick, onChipPress, onChipDoubleClick } = useCanvasSessions({
|
|
36999
|
+
const { onPointerDown, onPointerMove, onPointerUp, onMouseDown, onPointerCancel, dropCanvasSessions, beginEndpointDrag, beginWaypointDrag, onContentDoubleClick, onChipPress, onChipDoubleClick } = useCanvasSessions({
|
|
36539
37000
|
containerRef,
|
|
36540
37001
|
sessionRef,
|
|
36541
37002
|
lastPointerRef,
|
|
@@ -36578,6 +37039,7 @@ function CanvasView() {
|
|
|
36578
37039
|
setCanvasTextEditingId: viewport.setCanvasTextEditing,
|
|
36579
37040
|
children: /* @__PURE__ */ jsx(CanvasSurface, {
|
|
36580
37041
|
containerRef,
|
|
37042
|
+
containerSize,
|
|
36581
37043
|
cursor,
|
|
36582
37044
|
viewport,
|
|
36583
37045
|
handlers: {
|
|
@@ -36618,6 +37080,8 @@ function CanvasView() {
|
|
|
36618
37080
|
hoverSnapPoint
|
|
36619
37081
|
},
|
|
36620
37082
|
beginEndpointDrag,
|
|
37083
|
+
beginWaypointDrag,
|
|
37084
|
+
addConnectorWaypoint: viewport.addConnectorWaypoint,
|
|
36621
37085
|
onResetZoom: () => viewport.setZoom(1),
|
|
36622
37086
|
onFit
|
|
36623
37087
|
})
|
package/dist/index.d.mts
CHANGED
|
@@ -404,14 +404,14 @@ declare function Alert({ className, variant, ...props }: React$1.ComponentProps<
|
|
|
404
404
|
declare function AlertTitle({ className, ...props }: React$1.ComponentProps<"div">): React$1.JSX.Element;
|
|
405
405
|
declare function AlertDescription({ className, ...props }: React$1.ComponentProps<"div">): React$1.JSX.Element;
|
|
406
406
|
declare const badgeVariants: (props?: ({
|
|
407
|
-
variant?: "
|
|
407
|
+
variant?: "custom" | "default" | "secondary" | "destructive" | "outline" | null | undefined;
|
|
408
408
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
409
409
|
declare function Badge({ className, variant, asChild, ...props }: React$1.ComponentProps<"span"> & VariantProps<typeof badgeVariants> & {
|
|
410
410
|
asChild?: boolean;
|
|
411
411
|
}): React$1.JSX.Element;
|
|
412
412
|
declare function BareSelect({ className, children, ...props }: React$1.ComponentProps<"select">): React$1.JSX.Element;
|
|
413
413
|
declare const buttonVariants: (props?: ({
|
|
414
|
-
variant?: "default" | "
|
|
414
|
+
variant?: "default" | "secondary" | "destructive" | "outline" | "ghost" | "link" | null | undefined;
|
|
415
415
|
size?: "default" | "sm" | "lg" | "icon" | "xl" | null | undefined;
|
|
416
416
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
417
417
|
declare function Button({ className, variant, size, asChild, type, ...props }: React$1.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as DropdownMenuShortcut, $t as useText, A as Select, At as columnAnnotation, B as Label, Bt as CardDescription, C as cellValueEqual, Ct as isBridgeErrorCode, D as filterIsComplete, Dt as conditionMatches, E as emptyFilter, Et as ENUM_OPTION_NAME_COLUMN, F as SelectScrollDownButton, Ft as BookOpen, G as DropdownMenuContent, Gt as badgeVariants, H as Input, Ht as CardHeader, I as SelectScrollUpButton, It as Skeleton, J as DropdownMenuLabel, Jt as useMeta, K as DropdownMenuGroup, Kt as useBlock, L as SelectSeparator, Lt as Card, M as SelectGroup, Mt as Pen, N as SelectItem, Nt as Eye, O as SegmentSelector, Ot as parseCellValue, P as SelectLabel, Q as DropdownMenuSeparator, Qt as useSelectionView, R as SelectTrigger, Rt as CardAction, S as useDatabaseTable, St as isBridgeError, T as FilterBuilder, Tt as ENUM_OPTION_COLOR_COLUMN, U as DropdownMenu, Ut as CardTitle, V as InlineEditInput, Vt as CardFooter, W as DropdownMenuCheckboxItem, Wt as Badge, X as DropdownMenuRadioGroup, Xt as usePresenceSharing, Y as DropdownMenuPortal, Yt as usePresence, Z as DropdownMenuRadioItem, Zt as useSelection, _ as mapFrontmatter, _t as PROTOCOL_VERSION, a as DEFAULT_EMBED_SANDBOX, at as Popover, b as renderRuns, bt as BRIDGE_ERROR_CODES, c as SHAPE_FONT_OPTIONS, ct as PopoverDescription, d as FORMAT_PALETTE, dt as PopoverTrigger, en as DocblocksI18nProvider, et as DropdownMenuSub, ft as Checkbox, g as parseFrontmatter, gt as BASELINE_CAPABILITIES, h as mdToBlocks, ht as AlertTitle, i as useEditorContext, in as buttonVariants, it as Separator, j as SelectContent, k as ScrollArea, kt as TEXT_TYPES, l as SHAPE_FONT_STACKS, lt as PopoverHeader, m as insertNative, mt as AlertDescription, n as useCoverAverageColor, nn as EditorErrorBoundary, nt as DropdownMenuSubTrigger, ot as PopoverAnchor, p as htmlToBlocks, pt as Alert, q as DropdownMenuItem, qt as useDoc, r as EditorProvider, rn as Button, rt as DropdownMenuTrigger, st as PopoverContent, t as Editor, tn as createMemoryBlobStore, tt as DropdownMenuSubContent, ut as PopoverTitle, v as markToggleAction, vt as isDatabaseBridge, w as newMutationContext, wt as toBridgeError, x as GridBody, xt as BridgeError, yt as validateProtocolDescriptor, z as SelectValue, zt as CardContent } from "./Editor-
|
|
1
|
+
import { $ as DropdownMenuShortcut, $t as useText, A as Select, At as columnAnnotation, B as Label, Bt as CardDescription, C as cellValueEqual, Ct as isBridgeErrorCode, D as filterIsComplete, Dt as conditionMatches, E as emptyFilter, Et as ENUM_OPTION_NAME_COLUMN, F as SelectScrollDownButton, Ft as BookOpen, G as DropdownMenuContent, Gt as badgeVariants, H as Input, Ht as CardHeader, I as SelectScrollUpButton, It as Skeleton, J as DropdownMenuLabel, Jt as useMeta, K as DropdownMenuGroup, Kt as useBlock, L as SelectSeparator, Lt as Card, M as SelectGroup, Mt as Pen, N as SelectItem, Nt as Eye, O as SegmentSelector, Ot as parseCellValue, P as SelectLabel, Q as DropdownMenuSeparator, Qt as useSelectionView, R as SelectTrigger, Rt as CardAction, S as useDatabaseTable, St as isBridgeError, T as FilterBuilder, Tt as ENUM_OPTION_COLOR_COLUMN, U as DropdownMenu, Ut as CardTitle, V as InlineEditInput, Vt as CardFooter, W as DropdownMenuCheckboxItem, Wt as Badge, X as DropdownMenuRadioGroup, Xt as usePresenceSharing, Y as DropdownMenuPortal, Yt as usePresence, Z as DropdownMenuRadioItem, Zt as useSelection, _ as mapFrontmatter, _t as PROTOCOL_VERSION, a as DEFAULT_EMBED_SANDBOX, at as Popover, b as renderRuns, bt as BRIDGE_ERROR_CODES, c as SHAPE_FONT_OPTIONS, ct as PopoverDescription, d as FORMAT_PALETTE, dt as PopoverTrigger, en as DocblocksI18nProvider, et as DropdownMenuSub, ft as Checkbox, g as parseFrontmatter, gt as BASELINE_CAPABILITIES, h as mdToBlocks, ht as AlertTitle, i as useEditorContext, in as buttonVariants, it as Separator, j as SelectContent, k as ScrollArea, kt as TEXT_TYPES, l as SHAPE_FONT_STACKS, lt as PopoverHeader, m as insertNative, mt as AlertDescription, n as useCoverAverageColor, nn as EditorErrorBoundary, nt as DropdownMenuSubTrigger, ot as PopoverAnchor, p as htmlToBlocks, pt as Alert, q as DropdownMenuItem, qt as useDoc, r as EditorProvider, rn as Button, rt as DropdownMenuTrigger, st as PopoverContent, t as Editor, tn as createMemoryBlobStore, tt as DropdownMenuSubContent, ut as PopoverTitle, v as markToggleAction, vt as isDatabaseBridge, w as newMutationContext, wt as toBridgeError, x as GridBody, xt as BridgeError, yt as validateProtocolDescriptor, z as SelectValue, zt as CardContent } from "./Editor-CAU0NkdR.mjs";
|
|
2
2
|
import { useTranslation } from "react-i18next";
|
|
3
3
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4
4
|
import { C as UnknownSlashCommandError, S as UnhandledValueError, _ as CanvasPasteError, b as HookMisuseError, g as BlobNotFoundError, s as preventDefault, v as DocBlocksUiError, w as cn, x as PdfFetchError, y as EditorProviderError } from "./constants-CBPODzZc.mjs";
|
package/dist/mermaid/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { It as Skeleton, Nt as Eye, O as SegmentSelector, Pt as CodeXml, f as textOf, ht as AlertTitle, i as useEditorContext, jt as RotateCcw, mt as AlertDescription, o as childrenSlot, pt as Alert, rn as Button, s as CodeHeader, u as TextBlock, y as INLINE_CODE_CLASS } from "../Editor-
|
|
1
|
+
import { It as Skeleton, Nt as Eye, O as SegmentSelector, Pt as CodeXml, f as textOf, ht as AlertTitle, i as useEditorContext, jt as RotateCcw, mt as AlertDescription, o as childrenSlot, pt as Alert, rn as Button, s as CodeHeader, u as TextBlock, y as INLINE_CODE_CLASS } from "../Editor-CAU0NkdR.mjs";
|
|
2
2
|
import mermaid from "mermaid";
|
|
3
3
|
import { useTranslation } from "react-i18next";
|
|
4
4
|
import { useEffect, useRef, useState } from "react";
|
package/dist/styles.css
CHANGED
|
@@ -3945,10 +3945,12 @@
|
|
|
3945
3945
|
/* The connect indicator (the endpoint drag's port snap: the badge's
|
|
3946
3946
|
green + the snapped port dot). */
|
|
3947
3947
|
--docblocks-canvas-connect-color: #16a34a;
|
|
3948
|
-
/* The canvas
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3948
|
+
/* The canvas container's resting outline (the group / the frame box):
|
|
3949
|
+
the muted line, strong enough to read over brightly stroked figures
|
|
3950
|
+
at a low zoom. Declared once, theme-independent (the color-mix
|
|
3951
|
+
follows the theme flip); the width stands the box's ring. */
|
|
3952
|
+
--docblocks-canvas-group-border-color: color-mix(in srgb, var(--muted-foreground, #afb8c1) 85%, transparent);
|
|
3953
|
+
--docblocks-canvas-group-border-width: 2px;
|
|
3952
3954
|
|
|
3953
3955
|
/* The floating format toolbar (the selection's formatting layer). */
|
|
3954
3956
|
--docblocks-formatbar-background: var(--popover, #ffffff);
|
package/package.json
CHANGED