@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
|
@@ -42,6 +42,7 @@ import { mayEditSpec } from "../../src/shared/prototypes-core.ts";
|
|
|
42
42
|
import { fitOnPage } from "../../src/shared/sketch-core.ts";
|
|
43
43
|
import { isClosed } from "../../src/shared/threads-core.ts";
|
|
44
44
|
import { withBase } from "../base";
|
|
45
|
+
import { CAN_WRITE, type InstructionsState } from "../live/studio-api";
|
|
45
46
|
import {
|
|
46
47
|
agentNames,
|
|
47
48
|
type PresenceEntry,
|
|
@@ -59,17 +60,23 @@ import {
|
|
|
59
60
|
pinPoint,
|
|
60
61
|
threadsOn,
|
|
61
62
|
} from "./anchoring";
|
|
62
|
-
import {
|
|
63
|
-
|
|
63
|
+
import {
|
|
64
|
+
type CanvasContextValue,
|
|
65
|
+
type CanvasTool,
|
|
66
|
+
useCanvas,
|
|
67
|
+
} from "./canvas-context";
|
|
68
|
+
import { takeKeyboardFrom } from "./canvas-input";
|
|
64
69
|
import { AddBeside } from "./canvas-menus";
|
|
65
70
|
import {
|
|
66
71
|
type FrameAddress,
|
|
67
72
|
frameKey,
|
|
68
73
|
playFromHere,
|
|
69
74
|
removeFrames,
|
|
75
|
+
resizeFrame,
|
|
70
76
|
stepFrame,
|
|
71
77
|
updateFrame,
|
|
72
78
|
} from "./canvas-model";
|
|
79
|
+
import type { CanvasScene } from "./canvas-scene";
|
|
73
80
|
import {
|
|
74
81
|
activeThreadOf,
|
|
75
82
|
type CanvasUiState,
|
|
@@ -92,7 +99,7 @@ import {
|
|
|
92
99
|
useZoomedOut,
|
|
93
100
|
zoomedOutNow,
|
|
94
101
|
} from "./frame-pictures";
|
|
95
|
-
import { ResizeHandles, type Size } from "./frame-resize";
|
|
102
|
+
import { type Resized, ResizeHandles, type Size } from "./frame-resize";
|
|
96
103
|
import { atDevice, frameSource } from "./frame-source";
|
|
97
104
|
import { GridOverlay } from "./grid-overlay";
|
|
98
105
|
import { InspectLayer } from "./inspect-layer";
|
|
@@ -119,15 +126,19 @@ import {
|
|
|
119
126
|
} from "./page-heights";
|
|
120
127
|
import { boxKey, PickedBox } from "./picked-box";
|
|
121
128
|
import { useCanvasScene } from "./scene-context";
|
|
129
|
+
import { useScrollingPage } from "./scrolling-page";
|
|
130
|
+
import { settle } from "./settle";
|
|
122
131
|
import { SketchPage } from "./sketch-boxes";
|
|
123
132
|
import { SketchCopyOffer, SketchLayer } from "./sketch-layer";
|
|
124
133
|
import { surfaceAt } from "./sketch-model";
|
|
125
134
|
import { SlideContent } from "./slide-frame";
|
|
126
135
|
import { slideLayoutOf } from "./slide-page";
|
|
136
|
+
import { resizeTargets } from "./snapping";
|
|
127
137
|
import { SpecContent } from "./spec-frame";
|
|
128
138
|
import { specFilePath } from "./spec-full-screen";
|
|
129
139
|
import { useSpecMarks } from "./spec-threads";
|
|
130
140
|
import type { StackRole } from "./stack-frame";
|
|
141
|
+
import { StackToggle } from "./stack-toggle";
|
|
131
142
|
import { useStateOf } from "./state-store";
|
|
132
143
|
import { StylesLayer } from "./styles-layer";
|
|
133
144
|
import { TeammatesAtWork } from "./teammates-layer";
|
|
@@ -151,8 +162,8 @@ export interface FrameNodeData {
|
|
|
151
162
|
/** Its step in the section, counted from 1. */
|
|
152
163
|
step: number;
|
|
153
164
|
/**
|
|
154
|
-
* The frame's width from the layout: its own, or for a section header
|
|
155
|
-
*
|
|
165
|
+
* The frame's width from the layout: its own, or for a section header
|
|
166
|
+
* nobody resized, what it fills (layout.ts).
|
|
156
167
|
*/
|
|
157
168
|
width?: number;
|
|
158
169
|
}
|
|
@@ -176,21 +187,33 @@ const withControl = (
|
|
|
176
187
|
return Object.keys(next).length > 0 ? next : undefined;
|
|
177
188
|
};
|
|
178
189
|
|
|
179
|
-
/** The canvas saves as it goes, and says so only when it cannot. */
|
|
180
|
-
const ignoreState = () => undefined;
|
|
181
|
-
|
|
182
190
|
/**
|
|
183
191
|
* A document of the file's (docs/<name>.md), in the same editor as a spec:
|
|
184
192
|
* the team's, like the rest of its shared parts: written in place by anyone
|
|
185
193
|
* signed in, and read, commented on and suggested to by everyone else.
|
|
186
194
|
*/
|
|
187
|
-
const DocContent = ({
|
|
195
|
+
const DocContent = ({
|
|
196
|
+
frameKey: key,
|
|
197
|
+
name,
|
|
198
|
+
}: {
|
|
199
|
+
/** The frame it is in, by key: its page's scroll is kept for that frame. */
|
|
200
|
+
frameKey: string;
|
|
201
|
+
name: string;
|
|
202
|
+
}) => {
|
|
188
203
|
const { me, prototype } = useCanvas();
|
|
189
204
|
const doc = prototype.docs.find((entry) => entry.name === name);
|
|
190
205
|
const file = `docs/${name}.md`;
|
|
191
206
|
const marks = useSpecMarks(file);
|
|
192
|
-
|
|
193
|
-
|
|
207
|
+
// Its words are in once its editor has read them: at once where Dex
|
|
208
|
+
// cannot write, which shows them as the build has them.
|
|
209
|
+
const [loaded, setLoaded] = useState(!CAN_WRITE);
|
|
210
|
+
|
|
211
|
+
const onState = useCallback(
|
|
212
|
+
(state: InstructionsState) => setLoaded(state !== "loading"),
|
|
213
|
+
[]
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
const [, setPage] = useScrollingPage(key, loaded);
|
|
194
217
|
|
|
195
218
|
if (!doc) {
|
|
196
219
|
return (
|
|
@@ -201,14 +224,14 @@ const DocContent = ({ name }: { name: string }) => {
|
|
|
201
224
|
}
|
|
202
225
|
|
|
203
226
|
return (
|
|
204
|
-
<div className="h-full overflow-auto p-10" ref={
|
|
227
|
+
<div className="h-full overflow-auto p-10" data-frame-page="" ref={setPage}>
|
|
205
228
|
<Instructions
|
|
206
229
|
className="min-h-full"
|
|
207
230
|
fallback={doc.source}
|
|
208
231
|
inline
|
|
209
232
|
label={doc.title ?? name}
|
|
210
233
|
marks={marks}
|
|
211
|
-
onState={
|
|
234
|
+
onState={onState}
|
|
212
235
|
path={specFilePath(prototype, file)}
|
|
213
236
|
readOnly={!mayEditSpec(file, me)}
|
|
214
237
|
/>
|
|
@@ -357,6 +380,23 @@ const FrameOverlays = ({
|
|
|
357
380
|
);
|
|
358
381
|
};
|
|
359
382
|
|
|
383
|
+
const EDGE_SIDES = ["top", "right", "bottom", "left"] as const;
|
|
384
|
+
|
|
385
|
+
const FrameEdge = ({
|
|
386
|
+
source,
|
|
387
|
+
tool,
|
|
388
|
+
}: {
|
|
389
|
+
source: Pick<ReturnType<typeof frameSource>, "kind">;
|
|
390
|
+
tool: CanvasTool;
|
|
391
|
+
}) =>
|
|
392
|
+
tool === "select" && source.kind === "view" ? (
|
|
393
|
+
<div aria-hidden className="studio-frame-edge">
|
|
394
|
+
{EDGE_SIDES.map((side) => (
|
|
395
|
+
<div data-side={side} key={side} />
|
|
396
|
+
))}
|
|
397
|
+
</div>
|
|
398
|
+
) : null;
|
|
399
|
+
|
|
360
400
|
/**
|
|
361
401
|
* The states a view declared, as tabs under its frame: one click shows that
|
|
362
402
|
* state. With several controls, each is a row named after it.
|
|
@@ -417,6 +457,8 @@ const StateTabs = ({
|
|
|
417
457
|
*/
|
|
418
458
|
const MIN_LABEL_WIDTH = 360;
|
|
419
459
|
|
|
460
|
+
const NOT_MOVED = { x: 0, y: 0 } as const;
|
|
461
|
+
|
|
420
462
|
const labelWidth = (width: number) =>
|
|
421
463
|
Math.max(width, Math.min(MIN_LABEL_WIDTH, width + COLUMN_GAP - 16));
|
|
422
464
|
|
|
@@ -544,9 +586,11 @@ const FramePins = ({
|
|
|
544
586
|
{linkedOn.length > 0 ? <LinkedOutline boxes={linkedOn} /> : null}
|
|
545
587
|
{placed}
|
|
546
588
|
{agentPins}
|
|
589
|
+
{/* The pointer goes through to the comment tool under it, which keeps
|
|
590
|
+
what it is on while the comment is written. */}
|
|
547
591
|
{draftPoint ? (
|
|
548
592
|
<div
|
|
549
|
-
className="studio-screen absolute z-30 origin-top-left"
|
|
593
|
+
className="studio-screen pointer-events-none absolute z-30 origin-top-left"
|
|
550
594
|
// oxlint-disable-next-line shadcn/no-inline-styles -- computed at runtime: from the frame's size and the pins' and drop hint's places on it
|
|
551
595
|
style={{ left: draftPoint.x, top: draftPoint.y }}
|
|
552
596
|
>
|
|
@@ -567,17 +611,11 @@ const draftOn = (state: CanvasUiState, key: string) =>
|
|
|
567
611
|
/**
|
|
568
612
|
* The size a frame is set to, which resizing changes: a view's viewport's or
|
|
569
613
|
* its own, a doc's own or 640 by 900, a wireframe's page. A frame from a
|
|
570
|
-
* newer Dex has none: it cannot be shown, so it is not resized either.
|
|
571
|
-
* has a section header: it is as wide as the canvas's content and as tall as
|
|
572
|
-
* its words, whatever is done to it.
|
|
614
|
+
* newer Dex has none: it cannot be shown, so it is not resized either.
|
|
573
615
|
*/
|
|
574
616
|
const setSizeOf = (frame: Frame): Size | undefined => {
|
|
575
617
|
const it = kinded(frame);
|
|
576
618
|
|
|
577
|
-
if (isHeaderFrame(frame)) {
|
|
578
|
-
return;
|
|
579
|
-
}
|
|
580
|
-
|
|
581
619
|
switch (it.kind) {
|
|
582
620
|
case "view": {
|
|
583
621
|
return it.frame.size ?? VIEWPORTS[it.frame.viewport ?? "desktop"];
|
|
@@ -634,42 +672,34 @@ const namedOver = (frame: Frame) => {
|
|
|
634
672
|
return it.kind !== "spec" || isSlidePath(it.frame.spec);
|
|
635
673
|
};
|
|
636
674
|
|
|
675
|
+
/**
|
|
676
|
+
* The size a resize starts from: the size set for the frame. A spec's height
|
|
677
|
+
* is the one it shows (`shown`): its words', or less. A section header's
|
|
678
|
+
* width is the one it shows, what it fills until resized; never its height,
|
|
679
|
+
* which follows its words.
|
|
680
|
+
*/
|
|
681
|
+
export const resizeStart = (frame: Frame, shown: Size): Size | undefined => {
|
|
682
|
+
if (isHeaderFrame(frame)) {
|
|
683
|
+
return { ...frameSize(frame), width: shown.width };
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
const own = setSizeOf(frame);
|
|
687
|
+
|
|
688
|
+
return own && isSpecPage(frame) ? { ...own, height: shown.height } : own;
|
|
689
|
+
};
|
|
690
|
+
|
|
637
691
|
/** The size set for a frame and the size it shows, while resizing too. */
|
|
638
692
|
const useFrameSize = (frame: Frame, height?: number, width?: number) => {
|
|
639
693
|
const [draft, setDraft] = useState<Size>();
|
|
640
694
|
|
|
641
|
-
const
|
|
695
|
+
const size = {
|
|
642
696
|
...frameSize(frame),
|
|
643
697
|
...(height ? { height } : undefined),
|
|
644
698
|
...(width ? { width } : undefined),
|
|
645
699
|
};
|
|
646
700
|
|
|
647
|
-
|
|
648
|
-
const ownSize = setSizeOf(frame);
|
|
649
|
-
|
|
650
|
-
const setSize =
|
|
651
|
-
ownSize && isSpecPage(frame)
|
|
652
|
-
? { ...ownSize, height: laidOut.height }
|
|
653
|
-
: ownSize;
|
|
654
|
-
|
|
655
|
-
// A resize keeps its dragged size until the frame has its new one, in the
|
|
656
|
-
// same render, so the old size never shows between.
|
|
701
|
+
const setSize = resizeStart(frame, size);
|
|
657
702
|
const sizeKey = setSize ? `${setSize.width}x${setSize.height}` : "";
|
|
658
|
-
const [sizedAt, setSizedAt] = useState(sizeKey);
|
|
659
|
-
|
|
660
|
-
if (sizeKey !== sizedAt) {
|
|
661
|
-
setSizedAt(sizeKey);
|
|
662
|
-
setDraft(undefined);
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
// The whole page, or the size being dragged.
|
|
666
|
-
const size = draft
|
|
667
|
-
? {
|
|
668
|
-
width: draft.width,
|
|
669
|
-
height:
|
|
670
|
-
draft.height === setSize?.height ? laidOut.height : draft.height,
|
|
671
|
-
}
|
|
672
|
-
: laidOut;
|
|
673
703
|
|
|
674
704
|
return { draft, setDraft, setSize, size, sizeKey };
|
|
675
705
|
};
|
|
@@ -706,7 +736,8 @@ const resetOf = (devices: Devices, frame: Frame, size: Size) =>
|
|
|
706
736
|
* wireframe's page takes the size, its boxes moved onto it if they must be.
|
|
707
737
|
* A spec keeps a height only when made shorter than its words, so it
|
|
708
738
|
* scrolls; otherwise it stays as tall as they are, as they grow (`shown` is
|
|
709
|
-
* the size it showed, `words` its words' height).
|
|
739
|
+
* the size it showed, `words` its words' height). A section header keeps
|
|
740
|
+
* only its width: it is as tall as its words.
|
|
710
741
|
*/
|
|
711
742
|
const sizeChange = (
|
|
712
743
|
frame: Frame,
|
|
@@ -716,6 +747,10 @@ const sizeChange = (
|
|
|
716
747
|
) => {
|
|
717
748
|
const it = kinded(frame);
|
|
718
749
|
|
|
750
|
+
if (isHeaderFrame(frame)) {
|
|
751
|
+
return { size: { width: size.width } };
|
|
752
|
+
}
|
|
753
|
+
|
|
719
754
|
// A slide keeps the size it is given, both ways, as a screen does.
|
|
720
755
|
if (it.kind === "spec" && isSlidePath(it.frame.spec)) {
|
|
721
756
|
return { size };
|
|
@@ -755,28 +790,6 @@ const sizeChange = (
|
|
|
755
790
|
return isForDevice(frame) ? atDevice(size) : { size };
|
|
756
791
|
};
|
|
757
792
|
|
|
758
|
-
const SETTLE_MS = 320;
|
|
759
|
-
let settling: number | undefined;
|
|
760
|
-
|
|
761
|
-
/**
|
|
762
|
-
* Let the canvas ease into its next layout, once: a frame grows or shrinks to
|
|
763
|
-
* its new size and the frames around it make room, or dropped frames go to
|
|
764
|
-
* where the drop leaves them. Dragging stays immediate.
|
|
765
|
-
*/
|
|
766
|
-
export const settle = (from: Element | null) => {
|
|
767
|
-
const canvas = from?.closest<HTMLElement>(".studio-canvas");
|
|
768
|
-
|
|
769
|
-
if (!canvas) {
|
|
770
|
-
return;
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
canvas.dataset.settling = "true";
|
|
774
|
-
window.clearTimeout(settling);
|
|
775
|
-
settling = window.setTimeout(() => {
|
|
776
|
-
delete canvas.dataset.settling;
|
|
777
|
-
}, SETTLE_MS);
|
|
778
|
-
};
|
|
779
|
-
|
|
780
793
|
/**
|
|
781
794
|
* A selected frame's size: the device it is for, and its width and height to
|
|
782
795
|
* type. Enter saves and Escape lets go.
|
|
@@ -1030,6 +1043,7 @@ const FrameLabel = ({
|
|
|
1030
1043
|
selected,
|
|
1031
1044
|
slide = false,
|
|
1032
1045
|
source,
|
|
1046
|
+
stack,
|
|
1033
1047
|
width,
|
|
1034
1048
|
working,
|
|
1035
1049
|
}: {
|
|
@@ -1047,6 +1061,7 @@ const FrameLabel = ({
|
|
|
1047
1061
|
slide?: boolean;
|
|
1048
1062
|
selected: boolean;
|
|
1049
1063
|
source: ReturnType<typeof frameSource>;
|
|
1064
|
+
stack?: StackRole;
|
|
1050
1065
|
width: number;
|
|
1051
1066
|
working: PresenceEntry[];
|
|
1052
1067
|
}) => {
|
|
@@ -1067,6 +1082,7 @@ const FrameLabel = ({
|
|
|
1067
1082
|
{slide ? (
|
|
1068
1083
|
<Icon className="shrink-0" name="Presentation" size={13} />
|
|
1069
1084
|
) : null}
|
|
1085
|
+
{stack ? <StackToggle role={stack} title={source.title} /> : null}
|
|
1070
1086
|
{/* Stops the frame's double-click from taking over renaming. */}
|
|
1071
1087
|
<span
|
|
1072
1088
|
className={cn(
|
|
@@ -1392,7 +1408,7 @@ const FrameContent = ({
|
|
|
1392
1408
|
case "doc": {
|
|
1393
1409
|
return (
|
|
1394
1410
|
<div className={live ? "nodrag h-full" : "pointer-events-none h-full"}>
|
|
1395
|
-
<DocContent name={source.doc} />
|
|
1411
|
+
<DocContent frameKey={key} name={source.doc} />
|
|
1396
1412
|
</div>
|
|
1397
1413
|
);
|
|
1398
1414
|
}
|
|
@@ -1434,6 +1450,7 @@ const FrameContent = ({
|
|
|
1434
1450
|
|
|
1435
1451
|
return (
|
|
1436
1452
|
<SpecContent
|
|
1453
|
+
frameKey={key}
|
|
1437
1454
|
header={isHeaderFrame(frame)}
|
|
1438
1455
|
live={live}
|
|
1439
1456
|
note={isNotePath(source.spec)}
|
|
@@ -1498,6 +1515,14 @@ const paramsShown = (
|
|
|
1498
1515
|
localParams: Record<string, string>
|
|
1499
1516
|
): Record<string, string> => (view ? { ...view.params, ...localParams } : {});
|
|
1500
1517
|
|
|
1518
|
+
/**
|
|
1519
|
+
* Whether a frame is a section header on its own, across the canvas's
|
|
1520
|
+
* content: zoomed far out, its words sit left of it, where the canvas is
|
|
1521
|
+
* empty (canvas.css).
|
|
1522
|
+
*/
|
|
1523
|
+
const headerAlone = (scene: CanvasScene, frame: Frame, key: string) =>
|
|
1524
|
+
isHeaderFrame(frame) && scene.isOwnFrame(key);
|
|
1525
|
+
|
|
1501
1526
|
/** Whether a view or doc has a size of its own, which it can go back from. */
|
|
1502
1527
|
const hasOwnSize = (frame: Frame, view: ReturnType<typeof viewOf<Frame>>) =>
|
|
1503
1528
|
Boolean(
|
|
@@ -1592,12 +1617,16 @@ export const FrameNode = memo(
|
|
|
1592
1617
|
const canResize = Boolean(setSize && editor.editable);
|
|
1593
1618
|
const chooseDevice = deviceChooser(frame, address, editor.apply);
|
|
1594
1619
|
|
|
1595
|
-
const saveSize = (
|
|
1620
|
+
const saveSize = (
|
|
1621
|
+
next: Size,
|
|
1622
|
+
topLeftMovedBy: Resized["topLeftMovedBy"] = NOT_MOVED
|
|
1623
|
+
) =>
|
|
1596
1624
|
editor.apply((canvas) =>
|
|
1597
|
-
|
|
1625
|
+
resizeFrame(
|
|
1598
1626
|
canvas,
|
|
1599
1627
|
address,
|
|
1600
|
-
sizeChange(frame, next, setSize ?? next, wordsHeight.current)
|
|
1628
|
+
sizeChange(frame, next, setSize ?? next, wordsHeight.current),
|
|
1629
|
+
topLeftMovedBy
|
|
1601
1630
|
)
|
|
1602
1631
|
);
|
|
1603
1632
|
|
|
@@ -1617,6 +1646,18 @@ export const FrameNode = memo(
|
|
|
1617
1646
|
const leaveNote = useCallback(() => ui.setInteracting(undefined), [ui]);
|
|
1618
1647
|
const scene = useCanvasScene();
|
|
1619
1648
|
|
|
1649
|
+
const lineUp = () => {
|
|
1650
|
+
const placed = scene.frame(key);
|
|
1651
|
+
|
|
1652
|
+
return placed
|
|
1653
|
+
? {
|
|
1654
|
+
at: placed,
|
|
1655
|
+
keepsTopLeft: !scene.isOwnFrame(key),
|
|
1656
|
+
with: resizeTargets(scene.layout, key),
|
|
1657
|
+
}
|
|
1658
|
+
: undefined;
|
|
1659
|
+
};
|
|
1660
|
+
|
|
1620
1661
|
const dropEmptyNote = useCallback(
|
|
1621
1662
|
() =>
|
|
1622
1663
|
editor.apply((canvas) =>
|
|
@@ -1644,6 +1685,7 @@ export const FrameNode = memo(
|
|
|
1644
1685
|
data-changed={changesOutlined}
|
|
1645
1686
|
data-frame-key={key}
|
|
1646
1687
|
data-header={header}
|
|
1688
|
+
data-header-alone={headerAlone(scene, frame, key)}
|
|
1647
1689
|
data-interacting={live}
|
|
1648
1690
|
data-note={note}
|
|
1649
1691
|
data-picked={picks?.has(key) === true}
|
|
@@ -1666,6 +1708,7 @@ export const FrameNode = memo(
|
|
|
1666
1708
|
selected={Boolean(selected)}
|
|
1667
1709
|
slide={slide}
|
|
1668
1710
|
source={source}
|
|
1711
|
+
stack={data.stack}
|
|
1669
1712
|
width={size.width}
|
|
1670
1713
|
working={working}
|
|
1671
1714
|
/>
|
|
@@ -1721,11 +1764,16 @@ export const FrameNode = memo(
|
|
|
1721
1764
|
working={working.length > 0}
|
|
1722
1765
|
/>
|
|
1723
1766
|
</div>
|
|
1767
|
+
<FrameEdge source={source} tool={tool} />
|
|
1724
1768
|
{setSize && editor.editable && tool === "select" ? (
|
|
1725
1769
|
<ResizeHandles
|
|
1770
|
+
lineUp={lineUp}
|
|
1726
1771
|
onDraft={setDraft}
|
|
1727
1772
|
onReset={resettable ? resetSize : undefined}
|
|
1728
|
-
onResize={
|
|
1773
|
+
onResize={(resized) => {
|
|
1774
|
+
saveSize(resized.size, resized.topLeftMovedBy);
|
|
1775
|
+
}}
|
|
1776
|
+
shown={size}
|
|
1729
1777
|
size={setSize}
|
|
1730
1778
|
/>
|
|
1731
1779
|
) : null}
|