@dexhq/canvas 0.17.0 → 0.18.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 +31 -0
- package/app/canvas/canvas-commands.ts +2 -10
- package/app/canvas/canvas-context.tsx +11 -2
- package/app/canvas/canvas-document.ts +5 -1
- package/app/canvas/canvas-keys.ts +1 -1
- package/app/canvas/canvas-model.ts +195 -20
- package/app/canvas/canvas-scene.ts +176 -171
- package/app/canvas/canvas-ui.ts +4 -11
- package/app/canvas/canvas.css +159 -179
- package/app/canvas/change-pictures.tsx +156 -0
- package/app/canvas/comment-drafts.ts +31 -0
- package/app/canvas/comment-layer.tsx +125 -71
- package/app/canvas/comments.tsx +38 -2
- package/app/canvas/element-picker.ts +20 -0
- package/app/canvas/engine/canvas-gestures.ts +15 -3
- package/app/canvas/engine/canvas-store.ts +5 -0
- package/app/canvas/engine/canvas-view.tsx +22 -5
- package/app/canvas/find-bar.tsx +57 -41
- package/app/canvas/flow-canvas.tsx +147 -272
- package/app/canvas/frame-copies.ts +14 -17
- package/app/canvas/frame-drops.ts +15 -7
- package/app/canvas/frame-inspector.ts +192 -41
- package/app/canvas/frame-node.tsx +123 -75
- package/app/canvas/frame-resize.tsx +321 -83
- package/app/canvas/insert-hint.tsx +5 -15
- package/app/canvas/inspect-layer.tsx +73 -19
- package/app/canvas/label-action.tsx +13 -2
- package/app/canvas/layout.ts +233 -98
- package/app/canvas/live-page.ts +5 -0
- package/app/canvas/new-frame.ts +10 -25
- package/app/canvas/note-placing.ts +55 -84
- package/app/canvas/picked-box.tsx +5 -0
- package/app/canvas/picks-menu.tsx +3 -9
- package/app/canvas/readable-colour.ts +52 -0
- package/app/canvas/request-node.tsx +19 -10
- package/app/canvas/scrolling-page.ts +45 -0
- package/app/canvas/section-node.tsx +36 -53
- package/app/canvas/settle.ts +21 -0
- package/app/canvas/snapping.ts +96 -8
- package/app/canvas/spec-frame.tsx +8 -5
- package/app/canvas/spot-pins.tsx +15 -3
- package/app/canvas/stack-frame.tsx +13 -57
- package/app/canvas/stack-model.ts +5 -0
- package/app/canvas/stack-toggle.tsx +89 -0
- package/app/canvas/styles-layer.tsx +23 -43
- package/app/canvas/text-layer.tsx +26 -10
- package/app/canvas/thread-focus.tsx +18 -1
- package/app/canvas/tool-cursors.ts +2 -2
- package/app/canvas/toolbar-parts.tsx +48 -8
- package/app/canvas/toolbar.tsx +12 -10
- package/app/canvas/use-canvas-clipboard.tsx +13 -5
- package/app/canvas/use-reveal.ts +86 -0
- package/app/editor/extensions.ts +2 -0
- package/app/editor/line-break-caret.ts +57 -0
- package/app/git/branch-panel.tsx +61 -20
- package/app/i18n/locales/en/messages.po +64 -17
- package/app/i18n/locales/en/messages.ts +1 -1
- package/app/i18n/locales/pseudo/messages.po +64 -17
- package/app/i18n/locales/pseudo/messages.ts +1 -1
- package/app/icons/glyphs.tsx +2 -0
- package/app/live/studio-live.ts +29 -9
- package/app/pages/canvas.tsx +1 -1
- package/app/pages/commands-settings.tsx +70 -76
- package/app/pages/play-bar.tsx +6 -11
- package/app/pages/play.tsx +52 -33
- package/app/shell/feedback-form.tsx +29 -5
- package/app/ui/prompt-editor.tsx +2 -0
- package/app/ui/use-field-list.ts +90 -0
- package/dist/cli/commands/mcp.mjs +6 -4
- package/dist/cli/mcp-relay.mjs +10 -6
- package/dist/content/content.d.mts +26 -9
- package/dist/content/content.mjs +65 -8
- package/dist/content/screenshot.d.mts +2 -0
- package/dist/content/screenshot.mjs +3 -0
- package/dist/content/snapshot-client.d.mts +2 -0
- package/dist/content/snapshot-client.mjs +12 -1
- package/dist/inspector.js +96 -19
- package/dist/paste/paste.d.mts +5 -0
- package/dist/paste/paste.mjs +7 -2
- package/dist/server/agent-tools.d.mts +1 -0
- package/dist/server/agent-tools.mjs +4 -3
- package/dist/server/change-picture-store.d.mts +13 -0
- package/dist/server/change-picture-store.mjs +42 -0
- package/dist/server/change-pictures.d.mts +25 -0
- package/dist/server/change-pictures.mjs +104 -0
- package/dist/server/close-check.d.mts +11 -0
- package/dist/server/close-check.mjs +37 -5
- package/dist/server/comments/agent-actions.d.mts +8 -4
- package/dist/server/comments/agent-actions.mjs +16 -7
- package/dist/server/comments/close-tools.mjs +7 -5
- package/dist/server/comments/files.d.mts +5 -1
- package/dist/server/comments/hand-out.d.mts +1 -1
- package/dist/server/comments/hand-out.mjs +4 -1
- package/dist/server/comments/push.d.mts +19 -10
- package/dist/server/comments/push.mjs +45 -30
- package/dist/server/comments/studio-files.d.mts +14 -1
- package/dist/server/comments/studio-files.mjs +44 -31
- package/dist/server/comments/tools.d.mts +1 -1
- package/dist/server/comments/workspace.mjs +1 -0
- package/dist/server/dev-server.mjs +34 -0
- package/dist/server/own-copies.mjs +4 -23
- package/dist/server/requests.mjs +57 -3
- package/dist/server/response-budget.d.mts +2 -1
- package/dist/server/response-budget.mjs +4 -3
- package/dist/server/roster.d.mts +19 -8
- package/dist/server/roster.mjs +50 -22
- package/dist/server/studio-for.d.mts +7 -0
- package/dist/server/studio-for.mjs +23 -7
- package/dist/server/thread-forms.d.mts +3 -0
- package/dist/server/thread-forms.mjs +21 -1
- package/dist/server/tools/place-frame.d.mts +1 -0
- package/dist/server/tools/place-frame.mjs +33 -9
- package/dist/server/tools/result.mjs +2 -2
- package/dist/server/tools/snapshot.d.mts +1 -1
- package/dist/server/tools/snapshot.mjs +2 -1
- package/dist/server/tools/studio-context.d.mts +2 -1
- package/dist/server/tools/studio-context.mjs +2 -1
- package/dist/server/tools/watch.mjs +29 -12
- package/dist/server/work-groups.mjs +1 -1
- package/dist/shared/canvas-core.d.mts +39 -5
- package/dist/shared/canvas-core.mjs +60 -15
- package/dist/shared/canvas-file.d.mts +7 -4
- package/dist/shared/change-pictures-core.d.mts +6 -0
- package/dist/shared/change-pictures-core.mjs +5 -0
- package/dist/shared/page-looks.d.mts +12 -0
- package/dist/shared/page-looks.mjs +49 -0
- package/dist/shared/snapshot-clipboard.d.mts +6 -0
- package/dist/shared/studio-routes.d.mts +11 -0
- package/extension/dist/manifest.json +1 -1
- package/extension/dist/picker.js +114 -108
- package/package.json +4 -3
- package/src/cli/commands/mcp.ts +18 -8
- package/src/cli/mcp-relay.ts +13 -6
- package/src/content/content.ts +90 -16
- package/src/content/screenshot.ts +9 -1
- package/src/content/snapshot-client.ts +17 -0
- package/src/paste/paste.ts +18 -1
- package/src/server/agent-tools.ts +5 -4
- package/src/server/change-picture-store.ts +71 -0
- package/src/server/change-pictures.ts +244 -0
- package/src/server/close-check.ts +69 -6
- package/src/server/comments/agent-actions.ts +51 -12
- package/src/server/comments/close-tools.ts +20 -10
- package/src/server/comments/files.ts +10 -2
- package/src/server/comments/hand-out.ts +2 -2
- package/src/server/comments/push.ts +94 -46
- package/src/server/comments/studio-files.ts +77 -46
- package/src/server/comments/workspace.ts +1 -0
- package/src/server/dev-server.ts +70 -0
- package/src/server/own-copies.ts +5 -33
- package/src/server/requests.ts +84 -4
- package/src/server/response-budget.ts +5 -3
- package/src/server/roster.ts +78 -28
- package/src/server/studio-for.ts +32 -7
- package/src/server/thread-forms.ts +41 -1
- package/src/server/tools/place-frame.ts +71 -14
- package/src/server/tools/result.ts +2 -2
- package/src/server/tools/snapshot.ts +2 -1
- package/src/server/tools/studio-context.ts +24 -14
- package/src/server/tools/watch.ts +38 -13
- package/src/server/work-groups.ts +1 -1
- package/src/shared/canvas-core.ts +119 -27
- package/src/shared/canvas-file.ts +7 -4
- package/src/shared/change-pictures-core.ts +8 -0
- package/src/shared/page-looks.ts +133 -0
- package/src/shared/snapshot-clipboard.ts +6 -0
- package/src/shared/studio-routes.ts +7 -1
- package/templates/agents/dex-worker.md +9 -7
- package/templates/feedback-workflow.md +1 -1
- package/templates/methods/review.md +7 -6
- package/templates/rules/canvas-frames.md +8 -7
- package/templates/rules/canvas.md +10 -8
- package/templates/rules/prototypes.md +5 -3
- package/app/canvas/stack-node.tsx +0 -100
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
isSlideFrame,
|
|
19
19
|
isWordsFrame,
|
|
20
20
|
} from "../../src/shared/canvas-core.ts";
|
|
21
|
-
import {
|
|
21
|
+
import { onStudioEvent } from "../live/studio-live";
|
|
22
22
|
import type { Prototype } from "../registry";
|
|
23
23
|
import type { Canvas, Frame } from "../types";
|
|
24
24
|
import { addToSpec } from "./add-to-spec";
|
|
@@ -28,7 +28,7 @@ import { type ScreenPoint, useCanvas } from "./canvas-context";
|
|
|
28
28
|
import { CanvasContextMenu } from "./canvas-context-menu";
|
|
29
29
|
import { canvasTakesWheel, lockInterfaceZoom } from "./canvas-input";
|
|
30
30
|
import { SoleSelection } from "./canvas-menus";
|
|
31
|
-
import { type Cell,
|
|
31
|
+
import { type Cell, sameCell } from "./canvas-model";
|
|
32
32
|
import {
|
|
33
33
|
type CanvasScene,
|
|
34
34
|
isFrameNode,
|
|
@@ -55,23 +55,25 @@ import {
|
|
|
55
55
|
framesDrop,
|
|
56
56
|
framesDropped,
|
|
57
57
|
} from "./frame-drops.ts";
|
|
58
|
-
import { FrameNode
|
|
58
|
+
import { FrameNode } from "./frame-node";
|
|
59
59
|
import { setPicturesZoom, useCanvasPictures } from "./frame-pictures";
|
|
60
|
+
import { ShowSnapGuides } from "./frame-resize";
|
|
60
61
|
import { frameSource } from "./frame-source";
|
|
61
62
|
import { InsertHint } from "./insert-hint";
|
|
62
|
-
import { type Box, type DropMark, type Gap,
|
|
63
|
+
import { type Box, type DropMark, type Gap, sectionNamesFit } from "./layout";
|
|
63
64
|
import { usePlaceHeader, usePlaceNote } from "./note-placing";
|
|
64
65
|
import { RequestNode } from "./request-node";
|
|
65
66
|
import { RowNode } from "./row-node";
|
|
66
67
|
import { useCanvasScene } from "./scene-context";
|
|
67
68
|
import { SectionNode, SectionSurface } from "./section-node";
|
|
69
|
+
import { settle } from "./settle";
|
|
68
70
|
import { snapBox, snapPlan, snapReach } from "./snapping";
|
|
69
71
|
import { SpotPins } from "./spot-pins";
|
|
70
72
|
import { StackFrame, StackScrim } from "./stack-frame";
|
|
71
|
-
import { StackNode, type StackNodeData } from "./stack-node";
|
|
72
73
|
import { storedViewport, storeViewport } from "./stored-viewport";
|
|
73
74
|
import { TeammatesOnCanvas, useShareCanvasPlace } from "./teammates-layer";
|
|
74
75
|
import { surfaceCursor } from "./tool-cursors";
|
|
76
|
+
import { useReveal } from "./use-reveal";
|
|
75
77
|
import { useSpecCopiesApart } from "./use-spec-copies";
|
|
76
78
|
|
|
77
79
|
/**
|
|
@@ -109,10 +111,6 @@ const renderItem = (item: CanvasViewItem<unknown>, selected: boolean) => {
|
|
|
109
111
|
return <RowNode data={node.data} />;
|
|
110
112
|
}
|
|
111
113
|
|
|
112
|
-
if (node.type === "stack") {
|
|
113
|
-
return <StackNode data={node.data} />;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
114
|
if (node.type === "request") {
|
|
117
115
|
return <RequestNode data={node.data} />;
|
|
118
116
|
}
|
|
@@ -126,7 +124,6 @@ const renderItem = (item: CanvasViewItem<unknown>, selected: boolean) => {
|
|
|
126
124
|
|
|
127
125
|
/** How far from the pointer a comment's card opens, as on a frame. */
|
|
128
126
|
const COMPOSER_OFFSET = 12;
|
|
129
|
-
const REVEAL_MIN_SIZE = { width: 800, height: 500 };
|
|
130
127
|
|
|
131
128
|
/**
|
|
132
129
|
* Asks for the pictures of the canvas's views while it is zoomed out, or
|
|
@@ -163,11 +160,6 @@ const CanvasPictures = ({
|
|
|
163
160
|
return null;
|
|
164
161
|
};
|
|
165
162
|
|
|
166
|
-
const centreOf = (node: CanvasViewItem) => ({
|
|
167
|
-
x: node.x + node.width / 2,
|
|
168
|
-
y: node.y + Math.min(node.height / 2, 400),
|
|
169
|
-
});
|
|
170
|
-
|
|
171
163
|
/**
|
|
172
164
|
* What shows while frames are dragged: where each was, and where they would
|
|
173
165
|
* drop, when that is somewhere else.
|
|
@@ -200,7 +192,7 @@ const GRIP_MAX = 120;
|
|
|
200
192
|
/**
|
|
201
193
|
* Where a drag drops is judged: across, where the pointer is; down, where
|
|
202
194
|
* the pointer is on the frame held, kept to the frame's upper part. A tall
|
|
203
|
-
* frame held low lands by its top, as
|
|
195
|
+
* frame held low lands by its top, as frames line up by their tops.
|
|
204
196
|
*/
|
|
205
197
|
const heldAt = (
|
|
206
198
|
box: { height: number; y: number },
|
|
@@ -215,37 +207,6 @@ const heldAt = (
|
|
|
215
207
|
),
|
|
216
208
|
});
|
|
217
209
|
|
|
218
|
-
/**
|
|
219
|
-
* Where a stack dragged by its handle would drop, and how that shows: judged
|
|
220
|
-
* by where its first frame is, the frame the stack lines up by, not by the
|
|
221
|
-
* handle above it.
|
|
222
|
-
*/
|
|
223
|
-
const stackDrop = (
|
|
224
|
-
scene: CanvasScene,
|
|
225
|
-
{ frames, row, section }: StackNodeData,
|
|
226
|
-
items: readonly CanvasViewItem<unknown>[],
|
|
227
|
-
pointer: { x: number; y: number }
|
|
228
|
-
): Omit<Drop, "origins"> => {
|
|
229
|
-
const keys = new Set(
|
|
230
|
-
frames.map((frame) => frameKey({ section, row, frame }))
|
|
231
|
-
);
|
|
232
|
-
|
|
233
|
-
const headKey = frameKey({ section, row, frame: frames[0] ?? "" });
|
|
234
|
-
const head = scene.frame(headKey);
|
|
235
|
-
const held = items.find((item) => item.id === headKey);
|
|
236
|
-
|
|
237
|
-
if (!(head && held)) {
|
|
238
|
-
return {};
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
const cell = scene.cellAt(heldAt(held, pointer), {
|
|
242
|
-
between: true,
|
|
243
|
-
moving: keys,
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
return { cell, mark: cell && scene.dropMark(cell, head, keys) };
|
|
247
|
-
};
|
|
248
|
-
|
|
249
210
|
/**
|
|
250
211
|
* Whether the frames dragged, by key, are all words (notes and specs), which
|
|
251
212
|
* drop by their own rules rather than onto a stack.
|
|
@@ -302,19 +263,6 @@ const slideAt = (
|
|
|
302
263
|
}
|
|
303
264
|
};
|
|
304
265
|
|
|
305
|
-
/** A stack dragged, in the cell it was dropped in: none, where it was. */
|
|
306
|
-
const droppedStack = (
|
|
307
|
-
canvas: Canvas,
|
|
308
|
-
{ frames, row, section }: StackNodeData,
|
|
309
|
-
target: Cell | undefined
|
|
310
|
-
): Canvas => {
|
|
311
|
-
const [first] = frames;
|
|
312
|
-
|
|
313
|
-
return target && first
|
|
314
|
-
? moveStack(canvas, { section, row, frame: first }, target).canvas
|
|
315
|
-
: canvas;
|
|
316
|
-
};
|
|
317
|
-
|
|
318
266
|
/**
|
|
319
267
|
* Frames each where it was let go, as frames of their own: with ⌥ (copy),
|
|
320
268
|
* a copy of each is, and the frames go back. None dropped leaves the canvas
|
|
@@ -356,14 +304,14 @@ const dropSections = (
|
|
|
356
304
|
};
|
|
357
305
|
|
|
358
306
|
/**
|
|
359
|
-
* Where a row
|
|
360
|
-
*
|
|
361
|
-
* where its middle is; a
|
|
362
|
-
*
|
|
307
|
+
* Where a row or a request held would drop, and how that shows; none for
|
|
308
|
+
* frames (framesDrop), a stack's among them. A row goes among its
|
|
309
|
+
* section's rows by where its middle is; a request in the cell the pointer
|
|
310
|
+
* is over, its own place marked.
|
|
363
311
|
*/
|
|
364
312
|
const heldDrop = (
|
|
365
313
|
scene: CanvasScene,
|
|
366
|
-
{
|
|
314
|
+
{ lead, pointer }: Drag<unknown>
|
|
367
315
|
): Partial<Drop> | undefined => {
|
|
368
316
|
const node = sceneItem(lead);
|
|
369
317
|
|
|
@@ -376,10 +324,6 @@ const heldDrop = (
|
|
|
376
324
|
return { cell, mark: cell && scene.dropMark(cell, lead) };
|
|
377
325
|
}
|
|
378
326
|
|
|
379
|
-
case "stack": {
|
|
380
|
-
return stackDrop(scene, node.data, items, pointer);
|
|
381
|
-
}
|
|
382
|
-
|
|
383
327
|
case "request": {
|
|
384
328
|
const { id } = node.data.thread;
|
|
385
329
|
const was = scene.layout.pending.get(id);
|
|
@@ -461,6 +405,13 @@ export const FlowCanvas = ({
|
|
|
461
405
|
useSpecCopiesApart();
|
|
462
406
|
const [drop, setDrop] = useState<Drop>();
|
|
463
407
|
const [guides, setGuides] = useState<readonly SnapGuide[]>(NO_GUIDES);
|
|
408
|
+
|
|
409
|
+
// The lines a drag or a resize lines up on, shown until it ends.
|
|
410
|
+
const showGuides = useCallback((shown: readonly SnapGuide[]) => {
|
|
411
|
+
const lined = shown.length > 0 ? shown : NO_GUIDES;
|
|
412
|
+
setGuides((current) => (sameGuides(current, lined) ? current : lined));
|
|
413
|
+
}, []);
|
|
414
|
+
|
|
464
415
|
const surface = useRef<HTMLDivElement>(null);
|
|
465
416
|
// oxlint-disable-next-line react/hook-use-state -- read once, as the canvas first shows; nothing sets it after
|
|
466
417
|
const [initialViewport] = useState(() => storedViewport(prototype.href));
|
|
@@ -468,21 +419,13 @@ export const FlowCanvas = ({
|
|
|
468
419
|
const { t } = useLingui();
|
|
469
420
|
useShareCanvasPlace(prototype.slug, selection, surface);
|
|
470
421
|
|
|
471
|
-
// A snapshot just captured
|
|
472
|
-
//
|
|
473
|
-
|
|
474
|
-
|
|
422
|
+
// A snapshot just captured, a frame an agent asked to show, or the frame
|
|
423
|
+
// Play was on: shown once its frame is on the canvas.
|
|
424
|
+
useReveal({ scene, showOthers, slug: prototype.slug });
|
|
425
|
+
// Asked to show the person a frame: a spec open full screen would hide it.
|
|
475
426
|
useEffect(
|
|
476
427
|
() =>
|
|
477
428
|
onStudioEvent((event) => {
|
|
478
|
-
const revealed = event.type === "captured" || event.type === "show";
|
|
479
|
-
|
|
480
|
-
if (revealed && event.slug === prototype.slug) {
|
|
481
|
-
setReveal(event.frame);
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
// Asked to show the person a frame: a spec open full screen would
|
|
485
|
-
// hide it.
|
|
486
429
|
if (event.type === "show" && event.slug === prototype.slug) {
|
|
487
430
|
ui.setFullScreenSpec();
|
|
488
431
|
}
|
|
@@ -502,50 +445,13 @@ export const FlowCanvas = ({
|
|
|
502
445
|
}
|
|
503
446
|
}, [interacting, setSelection]);
|
|
504
447
|
|
|
505
|
-
// The scene is laid out by the time this runs, and the canvas has taken
|
|
506
|
-
// its items: zoom as soon as the frame is in it. A teammate's, hidden
|
|
507
|
-
// while only yours shows, shows first: the next scene zooms.
|
|
508
|
-
useEffect(() => {
|
|
509
|
-
if (reveal && scene.hides(reveal)) {
|
|
510
|
-
showOthers();
|
|
511
|
-
|
|
512
|
-
return;
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
const box = reveal ? scene.frame(reveal) : undefined;
|
|
516
|
-
|
|
517
|
-
if (!box) {
|
|
518
|
-
return;
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
// Zoom to where the layout puts it, with room around a small one.
|
|
522
|
-
const width = Math.max(box.width, REVEAL_MIN_SIZE.width);
|
|
523
|
-
const height = Math.max(box.height, REVEAL_MIN_SIZE.height);
|
|
524
|
-
|
|
525
|
-
const shown = view.fitBounds(
|
|
526
|
-
{
|
|
527
|
-
x: box.x - (width - box.width) / 2,
|
|
528
|
-
y: box.y - (height - box.height) / 2,
|
|
529
|
-
width,
|
|
530
|
-
height,
|
|
531
|
-
},
|
|
532
|
-
{ padding: FIT_PADDING, duration: 300 }
|
|
533
|
-
);
|
|
534
|
-
|
|
535
|
-
// A canvas not yet on screen tries again with the next layout.
|
|
536
|
-
if (shown) {
|
|
537
|
-
clearReveal();
|
|
538
|
-
// oxlint-disable-next-line react/set-state-in-effect -- only the view, once laid out, knows the reveal is done
|
|
539
|
-
setReveal(undefined);
|
|
540
|
-
}
|
|
541
|
-
}, [view, scene, reveal, showOthers]);
|
|
542
|
-
|
|
543
448
|
// Labels drawn at a constant size read the zoom from a CSS variable, and
|
|
544
449
|
// every one of them restyles when it changes. A pan leaves it as it was;
|
|
545
450
|
// a pinch moves it in steps too small to see, and exactly once it ends.
|
|
546
451
|
const zoomShown = useRef<number>(undefined);
|
|
547
|
-
// Section names are sized in rem, so
|
|
548
|
-
// follows the root font: read once, as the canvas
|
|
452
|
+
// Section names are sized in rem, so the zoom where they stop fitting
|
|
453
|
+
// above their sections follows the root font: read once, as the canvas
|
|
454
|
+
// first shows.
|
|
549
455
|
const remPx = useRef<number>(undefined);
|
|
550
456
|
|
|
551
457
|
const setZoom = useCallback((zoom: number, exact: boolean) => {
|
|
@@ -564,13 +470,13 @@ export const FlowCanvas = ({
|
|
|
564
470
|
// oxlint-disable-next-line unicorn/prefer-number-coercion -- the number off the front of "16px"
|
|
565
471
|
Number.parseFloat(getComputedStyle(document.documentElement).fontSize) ||
|
|
566
472
|
DEFAULT_REM_PX;
|
|
567
|
-
const nameDrop = sectionNameDrop(zoom, remPx.current);
|
|
568
473
|
element.dataset.pictures = String(setPicturesZoom(zoom));
|
|
569
474
|
element.style.setProperty("--zoom", String(zoom));
|
|
570
|
-
element.style.setProperty("--studio-section-name-drop", `${nameDrop}px`);
|
|
571
475
|
element.dataset.far = String(zoom < FAR_ZOOM);
|
|
572
476
|
element.dataset.small = String(zoom < SMALL_ZOOM);
|
|
573
|
-
element.dataset.sectionNames =
|
|
477
|
+
element.dataset.sectionNames = sectionNamesFit(zoom, remPx.current)
|
|
478
|
+
? "fit"
|
|
479
|
+
: "overlap";
|
|
574
480
|
}, []);
|
|
575
481
|
|
|
576
482
|
useEffect(() => {
|
|
@@ -634,35 +540,6 @@ export const FlowCanvas = ({
|
|
|
634
540
|
[openCanvasMenu, scene, selection, setSelection]
|
|
635
541
|
);
|
|
636
542
|
|
|
637
|
-
/** Whether an item is a section header, which is never in a section. */
|
|
638
|
-
const isHeader = useCallback(
|
|
639
|
-
(id: string) => {
|
|
640
|
-
const placed = scene.frame(id);
|
|
641
|
-
|
|
642
|
-
return placed !== undefined && isHeaderFrame(placed.frame);
|
|
643
|
-
},
|
|
644
|
-
[scene]
|
|
645
|
-
);
|
|
646
|
-
|
|
647
|
-
/**
|
|
648
|
-
* Frames dropped away from the sections stay where they are put, each a
|
|
649
|
-
* frame of its own: a frame of its own held outside every section, or a
|
|
650
|
-
* frame of a section held out of reach of every section. A section header
|
|
651
|
-
* always stands on its own, wherever it is let go.
|
|
652
|
-
*/
|
|
653
|
-
const dropsFree = useCallback(
|
|
654
|
-
(lead: CanvasViewItem<unknown>) => {
|
|
655
|
-
if (isHeader(lead.id)) {
|
|
656
|
-
return true;
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
return scene.isOwnFrame(lead.id)
|
|
660
|
-
? !scene.flowAt(centreOf(lead))
|
|
661
|
-
: !scene.nearFlow(lead);
|
|
662
|
-
},
|
|
663
|
-
[isHeader, scene]
|
|
664
|
-
);
|
|
665
|
-
|
|
666
543
|
/**
|
|
667
544
|
* How far a drag moves to line up with what is near: within a few pixels
|
|
668
545
|
* on screen, at any zoom. Never so far that a frame dropped away from the
|
|
@@ -678,7 +555,7 @@ export const FlowCanvas = ({
|
|
|
678
555
|
// the sections, and not going into a slide with ⌥.
|
|
679
556
|
const framesFree =
|
|
680
557
|
isFrameNode(drag.lead.id) &&
|
|
681
|
-
dropsFree(drag.lead) &&
|
|
558
|
+
scene.dropsFree(drag.lead, drag.pointer) &&
|
|
682
559
|
!(drag.copy && slideAt(scene, drag.pointer, frames));
|
|
683
560
|
|
|
684
561
|
const plan = snapPlan(scene, drag, framesFree);
|
|
@@ -696,9 +573,13 @@ export const FlowCanvas = ({
|
|
|
696
573
|
y: drag.lead.y + by.y,
|
|
697
574
|
};
|
|
698
575
|
|
|
699
|
-
|
|
576
|
+
const pointer = { x: drag.pointer.x + by.x, y: drag.pointer.y + by.y };
|
|
577
|
+
|
|
578
|
+
return isSectionNode(lead.id) || scene.dropsFree(lead, pointer)
|
|
579
|
+
? snap
|
|
580
|
+
: undefined;
|
|
700
581
|
},
|
|
701
|
-
[scene
|
|
582
|
+
[scene]
|
|
702
583
|
);
|
|
703
584
|
|
|
704
585
|
// While frames are dragged, each one's place stays marked where it was,
|
|
@@ -708,8 +589,7 @@ export const FlowCanvas = ({
|
|
|
708
589
|
(drag: Drag<unknown>) => {
|
|
709
590
|
const { copy, lead, items, pointer } = drag;
|
|
710
591
|
// The lines snapDrag lined the drag up on show.
|
|
711
|
-
|
|
712
|
-
setGuides((current) => (sameGuides(current, lined) ? current : lined));
|
|
592
|
+
showGuides(drag.guides);
|
|
713
593
|
|
|
714
594
|
if (isSectionNode(lead.id)) {
|
|
715
595
|
return;
|
|
@@ -739,7 +619,7 @@ export const FlowCanvas = ({
|
|
|
739
619
|
return;
|
|
740
620
|
}
|
|
741
621
|
|
|
742
|
-
if (dropsFree(lead)) {
|
|
622
|
+
if (scene.dropsFree(lead, pointer)) {
|
|
743
623
|
show({ origins });
|
|
744
624
|
|
|
745
625
|
return;
|
|
@@ -758,7 +638,7 @@ export const FlowCanvas = ({
|
|
|
758
638
|
}),
|
|
759
639
|
});
|
|
760
640
|
},
|
|
761
|
-
[scene,
|
|
641
|
+
[scene, showGuides]
|
|
762
642
|
);
|
|
763
643
|
|
|
764
644
|
/**
|
|
@@ -819,7 +699,7 @@ export const FlowCanvas = ({
|
|
|
819
699
|
const onDragEnd = useCallback(
|
|
820
700
|
({ copy, lead: dropped, items, pointer }: Drag<unknown>) => {
|
|
821
701
|
setDrop(undefined);
|
|
822
|
-
|
|
702
|
+
showGuides(NO_GUIDES);
|
|
823
703
|
// The frames ease into where the drop leaves them, and the ones that
|
|
824
704
|
// make room, to where they go.
|
|
825
705
|
settle(surface.current);
|
|
@@ -840,13 +720,6 @@ export const FlowCanvas = ({
|
|
|
840
720
|
return;
|
|
841
721
|
}
|
|
842
722
|
|
|
843
|
-
if (node.type === "stack") {
|
|
844
|
-
const target = stackDrop(scene, node.data, items, pointer).cell;
|
|
845
|
-
apply((current) => droppedStack(current, node.data, target));
|
|
846
|
-
|
|
847
|
-
return;
|
|
848
|
-
}
|
|
849
|
-
|
|
850
723
|
if (node.type === "request") {
|
|
851
724
|
dropRequest(node.data.thread.id, heldAt(dropped, pointer), dropped);
|
|
852
725
|
|
|
@@ -860,29 +733,27 @@ export const FlowCanvas = ({
|
|
|
860
733
|
|
|
861
734
|
const dragged = framesDropped(items, copy).toSorted((a, b) => a.x - b.x);
|
|
862
735
|
|
|
863
|
-
const
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
const free = (current: Canvas, drops: FreeDrop[]) =>
|
|
867
|
-
droppedFree(current, drops, copy, me);
|
|
736
|
+
const lead = dragged.find((item) => item.id === node.id) ?? dragged[0];
|
|
737
|
+
const keys = dragged.map((item) => item.id);
|
|
868
738
|
|
|
869
|
-
//
|
|
870
|
-
//
|
|
871
|
-
|
|
872
|
-
const frames = dragged.filter((item) => !isHeader(item.id));
|
|
873
|
-
const lead = frames.find((item) => item.id === node.id) ?? frames[0];
|
|
874
|
-
const keys = frames.map((item) => item.id);
|
|
875
|
-
|
|
876
|
-
// With ⌥, dropped on a slide, they go into it and stay where they were.
|
|
877
|
-
if (intoSlide(copy, keys, pointer)) {
|
|
739
|
+
// With ⌥, dropped on a slide, they go into it and stay where they were:
|
|
740
|
+
// a closed stack's whole cell.
|
|
741
|
+
if (intoSlide(copy, scene.carried(keys).flat(), pointer)) {
|
|
878
742
|
return;
|
|
879
743
|
}
|
|
880
744
|
|
|
881
745
|
// Away from the sections, each frame stays where it is dropped too.
|
|
882
|
-
if (!lead || dropsFree(lead)) {
|
|
883
|
-
const drops =
|
|
746
|
+
if (!lead || scene.dropsFree(lead, pointer)) {
|
|
747
|
+
const drops: FreeDrop[] = dragged.map((item) => ({
|
|
748
|
+
key: item.id,
|
|
749
|
+
at: { x: item.x, y: item.y },
|
|
750
|
+
}));
|
|
751
|
+
|
|
884
752
|
apply((current) =>
|
|
885
|
-
scene.keepSizes(
|
|
753
|
+
scene.keepSizes(
|
|
754
|
+
current,
|
|
755
|
+
droppedFree(placeSections(current), drops, copy, me)
|
|
756
|
+
)
|
|
886
757
|
);
|
|
887
758
|
|
|
888
759
|
return;
|
|
@@ -909,11 +780,9 @@ export const FlowCanvas = ({
|
|
|
909
780
|
// Filled by the drop as it runs, which apply does before it copies.
|
|
910
781
|
const touched = new Set<string>();
|
|
911
782
|
apply((current) => {
|
|
912
|
-
const freed = free(current, headers);
|
|
913
|
-
|
|
914
783
|
const placed = copy
|
|
915
|
-
? dropCopiesInFlow(
|
|
916
|
-
: scene.dropFrames(placeSections(
|
|
784
|
+
? dropCopiesInFlow(current, scene.carried(keys), lead.id, target)
|
|
785
|
+
: scene.dropFrames(placeSections(current), keys, lead.id, target);
|
|
917
786
|
|
|
918
787
|
for (const key of placed.keys) {
|
|
919
788
|
touched.add(key);
|
|
@@ -922,7 +791,7 @@ export const FlowCanvas = ({
|
|
|
922
791
|
return scene.keepSizes(current, placed.canvas);
|
|
923
792
|
}, touched);
|
|
924
793
|
},
|
|
925
|
-
[apply, intoSlide,
|
|
794
|
+
[apply, intoSlide, me, dropRequest, scene, showGuides]
|
|
926
795
|
);
|
|
927
796
|
|
|
928
797
|
// With the comment tool, a click on the empty canvas comments there: on
|
|
@@ -947,8 +816,8 @@ export const FlowCanvas = ({
|
|
|
947
816
|
return;
|
|
948
817
|
}
|
|
949
818
|
|
|
950
|
-
// With the Section header tool, a click
|
|
951
|
-
//
|
|
819
|
+
// With the Section header tool, a click places a header where the
|
|
820
|
+
// Text tool would place a note; one on a header writes in it.
|
|
952
821
|
if (ui.get().tool === "header" && editor.editable) {
|
|
953
822
|
const header = frameThere(scene, canvas, isHeaderFrame);
|
|
954
823
|
|
|
@@ -1028,90 +897,96 @@ export const FlowCanvas = ({
|
|
|
1028
897
|
|
|
1029
898
|
return (
|
|
1030
899
|
<SoleSelection.Provider value={sole}>
|
|
1031
|
-
<
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
defaultViewport={initialViewport}
|
|
1042
|
-
draggable={tool === "select"}
|
|
1043
|
-
dragWith={scene.dragWith}
|
|
1044
|
-
fitPadding={FIT_PADDING}
|
|
1045
|
-
hand={tool === "hand"}
|
|
1046
|
-
items={scene.items}
|
|
1047
|
-
marquee={tool === "select"}
|
|
1048
|
-
onContextMenu={openMenu}
|
|
1049
|
-
onDrag={onDrag}
|
|
1050
|
-
onDragEnd={onDragEnd}
|
|
1051
|
-
onMoveEnd={(viewport) => storeViewport(prototype.href, viewport)}
|
|
1052
|
-
onPaneClick={onPaneClick}
|
|
1053
|
-
onPaneContextMenu={openCanvasMenu}
|
|
1054
|
-
onSelectionChange={setSelection}
|
|
1055
|
-
panButtons={tool === "comment" || tool === "wireframe" ? [0, 1] : [1]}
|
|
1056
|
-
renderItem={renderItem}
|
|
1057
|
-
selectable={tool === "select"}
|
|
1058
|
-
selection={selection}
|
|
1059
|
-
snapDrag={snapDrag}
|
|
1060
|
-
takesWheel={canvasTakesWheel}
|
|
900
|
+
<ShowSnapGuides.Provider value={showGuides}>
|
|
901
|
+
<div
|
|
902
|
+
className="studio-canvas h-full w-full"
|
|
903
|
+
data-dragging={drop ? true : undefined}
|
|
904
|
+
data-tool={tool}
|
|
905
|
+
ref={surface}
|
|
906
|
+
// SAFETY: a custom property, which CSSProperties does not list.
|
|
907
|
+
style={
|
|
908
|
+
{ "--studio-tool-cursor": surfaceCursor(tool) } as CSSProperties
|
|
909
|
+
}
|
|
1061
910
|
>
|
|
1062
|
-
<
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
911
|
+
<CanvasView
|
|
912
|
+
aria-label={t`Canvas`}
|
|
913
|
+
defaultViewport={initialViewport}
|
|
914
|
+
draggable={tool === "select"}
|
|
915
|
+
dragWith={scene.dragWith}
|
|
916
|
+
fitPadding={FIT_PADDING}
|
|
917
|
+
hand={tool === "hand"}
|
|
918
|
+
items={scene.items}
|
|
919
|
+
marquee={tool === "select"}
|
|
920
|
+
onContextMenu={openMenu}
|
|
921
|
+
onDrag={onDrag}
|
|
922
|
+
onDragEnd={onDragEnd}
|
|
923
|
+
onMoveEnd={(viewport) => storeViewport(prototype.href, viewport)}
|
|
924
|
+
onPaneClick={onPaneClick}
|
|
925
|
+
onPaneContextMenu={openCanvasMenu}
|
|
926
|
+
onSelectionChange={setSelection}
|
|
927
|
+
panButtons={
|
|
928
|
+
tool === "comment" || tool === "wireframe" ? [0, 1] : [1]
|
|
929
|
+
}
|
|
930
|
+
renderItem={renderItem}
|
|
931
|
+
selectable={tool === "select"}
|
|
932
|
+
selection={selection}
|
|
933
|
+
snapDrag={snapDrag}
|
|
934
|
+
takesWheel={canvasTakesWheel}
|
|
935
|
+
>
|
|
936
|
+
<StackScrim />
|
|
937
|
+
<SpotPins />
|
|
938
|
+
<TeammatesOnCanvas slug={prototype.slug} />
|
|
939
|
+
{drop?.origins.map((box) => (
|
|
940
|
+
<div
|
|
941
|
+
className="studio-drag-origin"
|
|
942
|
+
key={`${box.x}/${box.y}`}
|
|
943
|
+
style={{
|
|
944
|
+
transform: `translate(${box.x}px, ${box.y}px)`,
|
|
945
|
+
width: box.width,
|
|
946
|
+
height: box.height,
|
|
947
|
+
}}
|
|
948
|
+
/>
|
|
949
|
+
))}
|
|
950
|
+
{drop?.mark ? <DropMarkBox mark={drop.mark} /> : null}
|
|
951
|
+
{guides.map((guide) => (
|
|
952
|
+
<SnapGuideLine guide={guide} key={`${guide.axis}/${guide.at}`} />
|
|
953
|
+
))}
|
|
954
|
+
{drop?.into ? (
|
|
955
|
+
<div
|
|
956
|
+
className="studio-drop"
|
|
957
|
+
data-kind="slide"
|
|
958
|
+
style={{
|
|
959
|
+
transform: `translate(${drop.into.x}px, ${drop.into.y}px)`,
|
|
960
|
+
width: drop.into.width,
|
|
961
|
+
height: drop.into.height,
|
|
962
|
+
}}
|
|
963
|
+
/>
|
|
964
|
+
) : null}
|
|
965
|
+
<InsertHint
|
|
966
|
+
enabled={editor.editable && tool === "select" && !drop}
|
|
967
|
+
minZoom={FAR_ZOOM}
|
|
968
|
+
skip={besideSole}
|
|
969
|
+
surface={surface}
|
|
1074
970
|
/>
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
{
|
|
1078
|
-
<
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
}
|
|
971
|
+
</CanvasView>
|
|
972
|
+
<CanvasPictures items={scene.items} prototype={prototype} />
|
|
973
|
+
{menu ? (
|
|
974
|
+
<FrameContextMenu
|
|
975
|
+
at={menu.at}
|
|
976
|
+
frames={menu.frames}
|
|
977
|
+
onClose={() => setMenu(undefined)}
|
|
978
|
+
/>
|
|
979
|
+
) : null}
|
|
980
|
+
<ExportDialogHost />
|
|
981
|
+
{canvasMenu ? (
|
|
982
|
+
<CanvasContextMenu
|
|
983
|
+
at={canvasMenu}
|
|
984
|
+
editable={editor.editable}
|
|
985
|
+
onClose={closeCanvasMenu}
|
|
1089
986
|
/>
|
|
1090
987
|
) : null}
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
minZoom={FAR_ZOOM}
|
|
1094
|
-
skip={besideSole}
|
|
1095
|
-
surface={surface}
|
|
1096
|
-
/>
|
|
1097
|
-
</CanvasView>
|
|
1098
|
-
<CanvasPictures items={scene.items} prototype={prototype} />
|
|
1099
|
-
{menu ? (
|
|
1100
|
-
<FrameContextMenu
|
|
1101
|
-
at={menu.at}
|
|
1102
|
-
frames={menu.frames}
|
|
1103
|
-
onClose={() => setMenu(undefined)}
|
|
1104
|
-
/>
|
|
1105
|
-
) : null}
|
|
1106
|
-
<ExportDialogHost />
|
|
1107
|
-
{canvasMenu ? (
|
|
1108
|
-
<CanvasContextMenu
|
|
1109
|
-
at={canvasMenu}
|
|
1110
|
-
editable={editor.editable}
|
|
1111
|
-
onClose={closeCanvasMenu}
|
|
1112
|
-
/>
|
|
1113
|
-
) : null}
|
|
1114
|
-
</div>
|
|
988
|
+
</div>
|
|
989
|
+
</ShowSnapGuides.Provider>
|
|
1115
990
|
</SoleSelection.Provider>
|
|
1116
991
|
);
|
|
1117
992
|
};
|