@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
|
@@ -12,23 +12,34 @@ import {
|
|
|
12
12
|
describeElement,
|
|
13
13
|
type PickedElement,
|
|
14
14
|
pickedWith,
|
|
15
|
+
pointOnPage,
|
|
15
16
|
withBox,
|
|
16
17
|
} from "./element-picker";
|
|
17
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
chosenOnPage,
|
|
20
|
+
framePoint,
|
|
21
|
+
isWholeFrame,
|
|
22
|
+
useFrameInspector,
|
|
23
|
+
useInspectorKeys,
|
|
24
|
+
} from "./frame-inspector";
|
|
18
25
|
import { type LivePage, unscrolledPoint } from "./live-page";
|
|
26
|
+
import { FrameOutline } from "./picked-box";
|
|
19
27
|
import { toolCursor } from "./tool-cursors";
|
|
20
28
|
|
|
21
29
|
// Commenting on a frame: a layer over its page that outlines the element
|
|
22
|
-
// under the pointer. Click to comment on it
|
|
23
|
-
//
|
|
30
|
+
// under the pointer. Click to comment on it: it is chosen, and stays chosen
|
|
31
|
+
// if its card closes before the comment is posted, for Enter to comment on
|
|
32
|
+
// it again or another canvas tool to take up (frame-inspector.ts); an
|
|
33
|
+
// element chosen in another tool is chosen here. Shift-click adds elements
|
|
34
|
+
// to one comment (click without Shift, or drag, to write it); drag across an
|
|
24
35
|
// area to comment on everything in it. While an element is outlined, ↑ and
|
|
25
36
|
// ↓ step to its parent and back down, ← and → to its siblings, as in every
|
|
26
|
-
// tool that chooses an element
|
|
27
|
-
// ⇧Enter adds it, ⌥Enter opens the quick bar over it and
|
|
28
|
-
// on the whole frame (inspectorKey in canvas-keys.ts)
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
//
|
|
37
|
+
// tool that chooses an element, Enter comments on it (the one chosen, else
|
|
38
|
+
// the one outlined), ⇧Enter adds it, ⌥Enter opens the quick bar over it and
|
|
39
|
+
// ⌘Enter comments on the whole frame (inspectorKey in canvas-keys.ts).
|
|
40
|
+
// ⌥-click, or a right-click, opens the quick bar over the element instead,
|
|
41
|
+
// unless Settings turned it off: its commands run in one click
|
|
42
|
+
// (QuickCommands).
|
|
32
43
|
|
|
33
44
|
type Area = Point & { height: number; width: number };
|
|
34
45
|
|
|
@@ -58,9 +69,36 @@ const Outline = ({ box, picked }: { box: Area; picked?: boolean }) => (
|
|
|
58
69
|
/>
|
|
59
70
|
);
|
|
60
71
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
72
|
+
const ElementOrFrameOutline = ({
|
|
73
|
+
entry,
|
|
74
|
+
picked,
|
|
75
|
+
}: {
|
|
76
|
+
entry: PickedElement;
|
|
77
|
+
picked?: boolean;
|
|
78
|
+
}) =>
|
|
79
|
+
isWholeFrame(entry.element) ? (
|
|
80
|
+
<FrameOutline picked={picked} />
|
|
81
|
+
) : (
|
|
82
|
+
<Outline box={entry.box} picked={picked} />
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The outlines of what the pointer and the keys are on: the element chosen,
|
|
87
|
+
* tinted, and the one outlined.
|
|
88
|
+
*/
|
|
89
|
+
const ChosenAndOutlined = ({
|
|
90
|
+
chosen,
|
|
91
|
+
outlined,
|
|
92
|
+
}: {
|
|
93
|
+
chosen?: PickedElement;
|
|
94
|
+
outlined?: PickedElement;
|
|
95
|
+
}) => (
|
|
96
|
+
<>
|
|
97
|
+
{chosen ? <ElementOrFrameOutline entry={chosen} picked /> : null}
|
|
98
|
+
{outlined && outlined.element !== chosen?.element ? (
|
|
99
|
+
<ElementOrFrameOutline entry={outlined} />
|
|
100
|
+
) : null}
|
|
101
|
+
</>
|
|
64
102
|
);
|
|
65
103
|
|
|
66
104
|
export const CommentLayer = ({
|
|
@@ -78,11 +116,16 @@ export const CommentLayer = ({
|
|
|
78
116
|
// Settings can turn the quick bar off; until the commands load, it is on.
|
|
79
117
|
const quickBarOn = useLoadedCommands()?.switches.quickBar !== false;
|
|
80
118
|
const layer = useRef<HTMLDivElement>(null);
|
|
81
|
-
// The element outlined: under the pointer, or stepped to with the keys.
|
|
82
119
|
const inspecting = useFrameInspector(page);
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
120
|
+
// The element outlined: under the pointer, or stepped to with the keys.
|
|
121
|
+
const outlined = inspecting.current && withBox(inspecting.current);
|
|
122
|
+
|
|
123
|
+
// The element chosen, here or in another canvas tool.
|
|
124
|
+
const onPage = chosenOnPage(inspecting);
|
|
125
|
+
const chosen = onPage && withBox(onPage);
|
|
126
|
+
// What Enter comments on: what the keys step, as in Inspect styles.
|
|
127
|
+
const target = chosen ?? outlined;
|
|
128
|
+
const pressOpenedContextMenu = useRef(false);
|
|
86
129
|
const [picked, setPicked] = useState<PickedElement[]>([]);
|
|
87
130
|
const [press, setPress] = useState<{ at: Point; client: Point }>();
|
|
88
131
|
const [area, setArea] = useState<Area>();
|
|
@@ -120,16 +163,6 @@ export const CommentLayer = ({
|
|
|
120
163
|
return () => window.removeEventListener("keydown", onKey, true);
|
|
121
164
|
}, [picked.length]);
|
|
122
165
|
|
|
123
|
-
const pagePoint = (event: PointerEvent<HTMLElement>): Point => {
|
|
124
|
-
const rect = event.currentTarget.getBoundingClientRect();
|
|
125
|
-
const scale = rect.width / width;
|
|
126
|
-
|
|
127
|
-
return {
|
|
128
|
-
x: (event.clientX - rect.left) / scale,
|
|
129
|
-
y: (event.clientY - rect.top) / scale,
|
|
130
|
-
};
|
|
131
|
-
};
|
|
132
|
-
|
|
133
166
|
/** A point on the page, on screen. */
|
|
134
167
|
const screenPoint = (point: Point): Point => {
|
|
135
168
|
const rect = layer.current?.getBoundingClientRect();
|
|
@@ -152,7 +185,7 @@ export const CommentLayer = ({
|
|
|
152
185
|
// Kept as if nothing on the page were scrolled, so its pin scrolls with
|
|
153
186
|
// its element (spotOf).
|
|
154
187
|
const targetFor = (elements: PickedElement[], point: Point): ThreadTarget =>
|
|
155
|
-
view
|
|
188
|
+
view && !elements.some(({ element }) => isWholeFrame(element))
|
|
156
189
|
? elementTarget(
|
|
157
190
|
key,
|
|
158
191
|
view,
|
|
@@ -161,18 +194,44 @@ export const CommentLayer = ({
|
|
|
161
194
|
)
|
|
162
195
|
: frameTarget(key, frame);
|
|
163
196
|
|
|
197
|
+
/**
|
|
198
|
+
* The one element a comment is on is chosen, for if its card closes before
|
|
199
|
+
* it is posted. A comment on several lets go; one on the whole frame keeps
|
|
200
|
+
* what was. Posted, it lets go (letGo).
|
|
201
|
+
*/
|
|
202
|
+
const choose = (elements: PickedElement[]) => {
|
|
203
|
+
const [only, ...more] = elements;
|
|
204
|
+
|
|
205
|
+
if (only && more.length === 0) {
|
|
206
|
+
inspecting.choose(only.element);
|
|
207
|
+
} else if (only) {
|
|
208
|
+
inspecting.release();
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
/** A comment posted is done with: what it was on is chosen no longer. */
|
|
213
|
+
const letGo = () => inspecting.release();
|
|
214
|
+
|
|
215
|
+
const writingOn = (elements: PickedElement[], thread: ThreadTarget) => {
|
|
216
|
+
setWriting({
|
|
217
|
+
elements: thread.kind === "frame" ? [] : elements,
|
|
218
|
+
target: thread,
|
|
219
|
+
});
|
|
220
|
+
setPicked([]);
|
|
221
|
+
choose(elements);
|
|
222
|
+
};
|
|
223
|
+
|
|
164
224
|
const open = (
|
|
165
225
|
elements: PickedElement[],
|
|
166
226
|
thread: ThreadTarget,
|
|
167
227
|
screen: Point
|
|
168
228
|
) => {
|
|
169
|
-
compose(
|
|
170
|
-
|
|
171
|
-
top: screen.y + CARD_OFFSET,
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
inspecting.release();
|
|
229
|
+
compose(
|
|
230
|
+
thread,
|
|
231
|
+
{ left: screen.x + CARD_OFFSET, top: screen.y + CARD_OFFSET },
|
|
232
|
+
{ onPosted: letGo }
|
|
233
|
+
);
|
|
234
|
+
writingOn(elements, thread);
|
|
176
235
|
};
|
|
177
236
|
|
|
178
237
|
const write = (
|
|
@@ -208,10 +267,12 @@ export const CommentLayer = ({
|
|
|
208
267
|
|
|
209
268
|
const thread = targetFor(elements, point);
|
|
210
269
|
const at = screenPoint(point);
|
|
211
|
-
compose(
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
270
|
+
compose(
|
|
271
|
+
thread,
|
|
272
|
+
{ left: at.x, top: at.y },
|
|
273
|
+
{ onPosted: letGo, quick: true }
|
|
274
|
+
);
|
|
275
|
+
writingOn(elements, thread);
|
|
215
276
|
};
|
|
216
277
|
|
|
217
278
|
/** Shift-click: picks an element, or lets go of it if it was picked. */
|
|
@@ -222,9 +283,15 @@ export const CommentLayer = ({
|
|
|
222
283
|
: pickedWith(picked, [entry])
|
|
223
284
|
);
|
|
224
285
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
286
|
+
const toggleUnlessWholeFrame = (entry: PickedElement) => {
|
|
287
|
+
if (!isWholeFrame(entry.element)) {
|
|
288
|
+
toggle(entry);
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
/** On the element Enter is on, at its centre. */
|
|
293
|
+
const commentOn = (elements: PickedElement[], on: PickedElement) => {
|
|
294
|
+
const point = centreOf(on.box);
|
|
228
295
|
open(elements, targetFor(elements, point), screenPoint(point));
|
|
229
296
|
};
|
|
230
297
|
|
|
@@ -232,7 +299,7 @@ export const CommentLayer = ({
|
|
|
232
299
|
useInspectorKeys(
|
|
233
300
|
inspecting,
|
|
234
301
|
target && {
|
|
235
|
-
add: () =>
|
|
302
|
+
add: () => toggleUnlessWholeFrame(target),
|
|
236
303
|
choose: () => commentOn(pickedWith(picked, [target]), target),
|
|
237
304
|
commands: () =>
|
|
238
305
|
quickBarOn
|
|
@@ -243,25 +310,6 @@ export const CommentLayer = ({
|
|
|
243
310
|
}
|
|
244
311
|
);
|
|
245
312
|
|
|
246
|
-
// Whether ⌘ is held, from every key press and release, and let go of when
|
|
247
|
-
// the window loses the keyboard. A frame's page passes on no releases, so
|
|
248
|
-
// the pointer's moves correct it too (onPointerMove).
|
|
249
|
-
useEffect(() => {
|
|
250
|
-
const onModifier = (event: KeyboardEvent) =>
|
|
251
|
-
setWholeFrame(event.metaKey || event.ctrlKey);
|
|
252
|
-
|
|
253
|
-
const onBlur = () => setWholeFrame(false);
|
|
254
|
-
window.addEventListener("keydown", onModifier, true);
|
|
255
|
-
window.addEventListener("keyup", onModifier, true);
|
|
256
|
-
window.addEventListener("blur", onBlur);
|
|
257
|
-
|
|
258
|
-
return () => {
|
|
259
|
-
window.removeEventListener("keydown", onModifier, true);
|
|
260
|
-
window.removeEventListener("keyup", onModifier, true);
|
|
261
|
-
window.removeEventListener("blur", onBlur);
|
|
262
|
-
};
|
|
263
|
-
}, []);
|
|
264
|
-
|
|
265
313
|
// A right-click opens the quick bar, in place of the frame's menu. The
|
|
266
314
|
// canvas listens for it on its own element (engine/canvas-gestures.ts),
|
|
267
315
|
// before React hears of it, so the layer listens on its own first. Runs
|
|
@@ -289,6 +337,7 @@ export const CommentLayer = ({
|
|
|
289
337
|
|
|
290
338
|
event.preventDefault();
|
|
291
339
|
event.stopPropagation();
|
|
340
|
+
pressOpenedContextMenu.current = true;
|
|
292
341
|
quickBar(pickedWith(picked, [clicked]));
|
|
293
342
|
};
|
|
294
343
|
|
|
@@ -302,11 +351,11 @@ export const CommentLayer = ({
|
|
|
302
351
|
setPress(undefined);
|
|
303
352
|
setArea(undefined);
|
|
304
353
|
|
|
305
|
-
if (!start) {
|
|
354
|
+
if (!start || pressOpenedContextMenu.current) {
|
|
306
355
|
return;
|
|
307
356
|
}
|
|
308
357
|
|
|
309
|
-
const point =
|
|
358
|
+
const point = framePoint(event, width);
|
|
310
359
|
|
|
311
360
|
if (area) {
|
|
312
361
|
const all = pickedWith(picked, page?.elementsIn(area) ?? []);
|
|
@@ -320,10 +369,11 @@ export const CommentLayer = ({
|
|
|
320
369
|
return;
|
|
321
370
|
}
|
|
322
371
|
|
|
323
|
-
const
|
|
372
|
+
const element = view ? inspecting.click(point) : undefined;
|
|
373
|
+
const clicked = element && withBox(element);
|
|
324
374
|
|
|
325
|
-
if (event.shiftKey && clicked
|
|
326
|
-
|
|
375
|
+
if (event.shiftKey && clicked) {
|
|
376
|
+
toggleUnlessWholeFrame(clicked);
|
|
327
377
|
|
|
328
378
|
return;
|
|
329
379
|
}
|
|
@@ -338,6 +388,8 @@ export const CommentLayer = ({
|
|
|
338
388
|
onClick={(event) => event.stopPropagation()}
|
|
339
389
|
onDoubleClick={(event) => event.stopPropagation()}
|
|
340
390
|
onPointerDown={(event) => {
|
|
391
|
+
pressOpenedContextMenu.current = false;
|
|
392
|
+
|
|
341
393
|
if (event.button !== 0) {
|
|
342
394
|
return;
|
|
343
395
|
}
|
|
@@ -345,14 +397,13 @@ export const CommentLayer = ({
|
|
|
345
397
|
event.stopPropagation();
|
|
346
398
|
event.currentTarget.setPointerCapture(event.pointerId);
|
|
347
399
|
setPress({
|
|
348
|
-
at:
|
|
400
|
+
at: pointOnPage(event, width),
|
|
349
401
|
client: { x: event.clientX, y: event.clientY },
|
|
350
402
|
});
|
|
351
403
|
}}
|
|
352
404
|
onPointerLeave={() => inspecting.hover()}
|
|
353
405
|
onPointerMove={(event) => {
|
|
354
|
-
|
|
355
|
-
const point = pagePoint(event);
|
|
406
|
+
const point = framePoint(event, width);
|
|
356
407
|
|
|
357
408
|
const moved =
|
|
358
409
|
press &&
|
|
@@ -391,8 +442,11 @@ export const CommentLayer = ({
|
|
|
391
442
|
picked
|
|
392
443
|
/>
|
|
393
444
|
))}
|
|
394
|
-
|
|
395
|
-
|
|
445
|
+
<ChosenAndOutlined
|
|
446
|
+
// A card open shows what it is written on instead.
|
|
447
|
+
chosen={writingOpen ? undefined : chosen}
|
|
448
|
+
outlined={outlined}
|
|
449
|
+
/>
|
|
396
450
|
{area ? (
|
|
397
451
|
<div
|
|
398
452
|
className="studio-pick-area"
|
package/app/canvas/comments.tsx
CHANGED
|
@@ -89,12 +89,14 @@ import {
|
|
|
89
89
|
useCanvasIfAny,
|
|
90
90
|
} from "./canvas-context";
|
|
91
91
|
import { threadItemId } from "./canvas-scene";
|
|
92
|
+
import { ChangePictures } from "./change-pictures";
|
|
92
93
|
import {
|
|
93
94
|
commandTrigger,
|
|
94
95
|
QuickCommands,
|
|
95
96
|
useCommands,
|
|
96
97
|
useQuickCommands,
|
|
97
98
|
} from "./command-menu";
|
|
99
|
+
import { draftKey, draftOf, keepDraft } from "./comment-drafts";
|
|
98
100
|
import { acceptRename } from "./flow-renames";
|
|
99
101
|
import { useFollowPin } from "./follow-pin";
|
|
100
102
|
import {
|
|
@@ -446,6 +448,7 @@ export const MessageInput = ({
|
|
|
446
448
|
initial = "",
|
|
447
449
|
label,
|
|
448
450
|
look = "box",
|
|
451
|
+
onEdit,
|
|
449
452
|
onSend,
|
|
450
453
|
placeholder,
|
|
451
454
|
sendLabel,
|
|
@@ -471,12 +474,20 @@ export const MessageInput = ({
|
|
|
471
474
|
* border (a reply under a thread).
|
|
472
475
|
*/
|
|
473
476
|
look?: MessageLook;
|
|
477
|
+
/** Each time its words are typed. */
|
|
478
|
+
onEdit?: (body: string) => void;
|
|
474
479
|
/** Resolves to false when nothing was sent, and the words stay. */
|
|
475
480
|
onSend: (body: string) => Promise<Sent> | Promise<void>;
|
|
476
481
|
placeholder: string;
|
|
477
482
|
sendLabel: string;
|
|
478
483
|
}) => {
|
|
479
484
|
const [body, setBody] = useState(initial);
|
|
485
|
+
|
|
486
|
+
const edit = (words: string) => {
|
|
487
|
+
setBody(words);
|
|
488
|
+
onEdit?.(words);
|
|
489
|
+
};
|
|
490
|
+
|
|
480
491
|
const { t } = useLingui();
|
|
481
492
|
const people = usePeople({ ask: true });
|
|
482
493
|
const frames = useFrames();
|
|
@@ -539,7 +550,7 @@ export const MessageInput = ({
|
|
|
539
550
|
autoFocus={autoFocus}
|
|
540
551
|
className={cn("max-h-40", MESSAGE_TEXT[look])}
|
|
541
552
|
label={label}
|
|
542
|
-
onChange={
|
|
553
|
+
onChange={edit}
|
|
543
554
|
onSubmit={send}
|
|
544
555
|
placeholder={placeholder}
|
|
545
556
|
triggers={triggers}
|
|
@@ -589,18 +600,23 @@ export const Composer = ({
|
|
|
589
600
|
anchor,
|
|
590
601
|
at,
|
|
591
602
|
onClose,
|
|
603
|
+
onPosted,
|
|
592
604
|
target,
|
|
593
605
|
threads,
|
|
594
606
|
}: {
|
|
595
607
|
anchor?: string;
|
|
596
608
|
at: ScreenPoint;
|
|
597
609
|
onClose: () => void;
|
|
610
|
+
/** Once it is posted, not when it closes otherwise. */
|
|
611
|
+
onPosted?: () => void;
|
|
598
612
|
target: ThreadTarget;
|
|
599
613
|
threads: ThreadsApi;
|
|
600
614
|
}) => {
|
|
601
615
|
const { t } = useLingui();
|
|
602
616
|
const request = target.kind === "view";
|
|
603
617
|
const [audience, setAudience] = useState<ThreadAudience>("agent");
|
|
618
|
+
// Its words are kept until posted, for the next card on the same thing.
|
|
619
|
+
const draft = draftKey(threads.slug, target);
|
|
604
620
|
// Commands are work for the agent: / names them only in a comment for it.
|
|
605
621
|
const [answer] = useCommands(!(request || GUEST_REVIEW));
|
|
606
622
|
|
|
@@ -630,8 +646,11 @@ export const Composer = ({
|
|
|
630
646
|
}
|
|
631
647
|
autoFocus
|
|
632
648
|
commands={commands}
|
|
649
|
+
initial={draftOf(draft)}
|
|
650
|
+
key={draft}
|
|
633
651
|
label={request ? t`Describe the view` : t`Comment`}
|
|
634
652
|
look="card"
|
|
653
|
+
onEdit={(body) => keepDraft(draft, body)}
|
|
635
654
|
onSend={async (body) => {
|
|
636
655
|
// A guest's comment always joins a review: they start one first.
|
|
637
656
|
if (GUEST_REVIEW && !(await askToReview(threads.slug))) {
|
|
@@ -639,6 +658,8 @@ export const Composer = ({
|
|
|
639
658
|
}
|
|
640
659
|
|
|
641
660
|
await threads.create(target, body, request ? "agent" : audience);
|
|
661
|
+
keepDraft(draft, "");
|
|
662
|
+
onPosted?.();
|
|
642
663
|
onClose();
|
|
643
664
|
}}
|
|
644
665
|
placeholder={placeholder}
|
|
@@ -1291,7 +1312,11 @@ export const ThreadMessages = ({
|
|
|
1291
1312
|
{...closing}
|
|
1292
1313
|
body={<ClosingLine body={closing.body} />}
|
|
1293
1314
|
status={i18n._(STATE_LABELS[closing.closed])}
|
|
1294
|
-
|
|
1315
|
+
>
|
|
1316
|
+
{closing.agent && closing.closed === "resolved" ? (
|
|
1317
|
+
<ChangePictures closedAt={closing.at} thread={thread.id} />
|
|
1318
|
+
) : null}
|
|
1319
|
+
</Entry>
|
|
1295
1320
|
) : null}
|
|
1296
1321
|
</ol>
|
|
1297
1322
|
</ThreadNumberProvider>
|
|
@@ -1959,6 +1984,8 @@ export type FloatingComment =
|
|
|
1959
1984
|
at: ScreenPoint;
|
|
1960
1985
|
/** The quick bar first, centred above `at`, then the composer. */
|
|
1961
1986
|
quick?: boolean;
|
|
1987
|
+
/** Once the comment is posted, not when its card closes otherwise. */
|
|
1988
|
+
onPosted?: () => void;
|
|
1962
1989
|
}
|
|
1963
1990
|
| {
|
|
1964
1991
|
kind: "thread";
|
|
@@ -1978,12 +2005,14 @@ const NO_CLOSE = () => undefined;
|
|
|
1978
2005
|
const QuickBar = ({
|
|
1979
2006
|
at,
|
|
1980
2007
|
onClose,
|
|
2008
|
+
onPosted,
|
|
1981
2009
|
target,
|
|
1982
2010
|
threads,
|
|
1983
2011
|
}: {
|
|
1984
2012
|
/** The top middle of what it is on, on screen. */
|
|
1985
2013
|
at: ScreenPoint;
|
|
1986
2014
|
onClose: () => void;
|
|
2015
|
+
onPosted?: () => void;
|
|
1987
2016
|
target: ThreadTarget;
|
|
1988
2017
|
threads: ThreadsApi;
|
|
1989
2018
|
}) => {
|
|
@@ -1993,6 +2022,7 @@ const QuickBar = ({
|
|
|
1993
2022
|
const run = useStudioAction(
|
|
1994
2023
|
async (command: Command) => {
|
|
1995
2024
|
await threads.create(target, `/${command.name}`, "agent");
|
|
2025
|
+
onPosted?.();
|
|
1996
2026
|
onClose();
|
|
1997
2027
|
},
|
|
1998
2028
|
{ fallback: msg`Not sent. Try again.` }
|
|
@@ -2009,6 +2039,7 @@ const QuickBar = ({
|
|
|
2009
2039
|
anchor={DRAFT_ANCHOR}
|
|
2010
2040
|
at={{ left: at.left - CARD_WIDTH / 2, top: at.top }}
|
|
2011
2041
|
onClose={onClose}
|
|
2042
|
+
onPosted={onPosted}
|
|
2012
2043
|
target={target}
|
|
2013
2044
|
threads={threads}
|
|
2014
2045
|
/>
|
|
@@ -2101,11 +2132,15 @@ export const FloatingCommentCard = ({
|
|
|
2101
2132
|
useHideCommentsKey();
|
|
2102
2133
|
const commentsView = useCommentsView();
|
|
2103
2134
|
|
|
2135
|
+
const handlePosted =
|
|
2136
|
+
floating?.kind === "compose" ? floating.onPosted : undefined;
|
|
2137
|
+
|
|
2104
2138
|
if (floating?.kind === "compose" && floating.quick) {
|
|
2105
2139
|
return (
|
|
2106
2140
|
<QuickBar
|
|
2107
2141
|
at={floating.at}
|
|
2108
2142
|
onClose={onClose}
|
|
2143
|
+
onPosted={handlePosted}
|
|
2109
2144
|
target={floating.target}
|
|
2110
2145
|
threads={threads}
|
|
2111
2146
|
/>
|
|
@@ -2118,6 +2153,7 @@ export const FloatingCommentCard = ({
|
|
|
2118
2153
|
anchor={DRAFT_ANCHOR}
|
|
2119
2154
|
at={floating.at}
|
|
2120
2155
|
onClose={onClose}
|
|
2156
|
+
onPosted={handlePosted}
|
|
2121
2157
|
target={floating.target}
|
|
2122
2158
|
threads={threads}
|
|
2123
2159
|
/>
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import {
|
|
6
6
|
type Anchor,
|
|
7
7
|
anchorOf,
|
|
8
|
+
elementsAtPoint,
|
|
8
9
|
find,
|
|
9
10
|
openersOf,
|
|
10
11
|
type Scope,
|
|
@@ -94,6 +95,25 @@ const passedOver = (
|
|
|
94
95
|
holds(element, x, y)
|
|
95
96
|
);
|
|
96
97
|
|
|
98
|
+
export function elementsAt(
|
|
99
|
+
page: Document | null | undefined,
|
|
100
|
+
x: number,
|
|
101
|
+
y: number
|
|
102
|
+
): Element[] {
|
|
103
|
+
if (!page) {
|
|
104
|
+
return [];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const under = elementsAtPoint(page, x, y);
|
|
108
|
+
|
|
109
|
+
return [
|
|
110
|
+
...under,
|
|
111
|
+
...passedOver(page, undefined, STAMPED, x, y).filter(
|
|
112
|
+
(element) => !under.includes(element)
|
|
113
|
+
),
|
|
114
|
+
];
|
|
115
|
+
}
|
|
116
|
+
|
|
97
117
|
/**
|
|
98
118
|
* The element at a point, for finding the design-system component there:
|
|
99
119
|
* as elementAt, but a stamped element that hit testing passes over is found
|
|
@@ -300,10 +300,21 @@ export class CanvasGestures {
|
|
|
300
300
|
const { selection } = this.props;
|
|
301
301
|
|
|
302
302
|
return selection.size > 1
|
|
303
|
-
? [...selection].flatMap((id) => this.
|
|
303
|
+
? [...selection].flatMap((id) => this.pickable(id) ?? [])
|
|
304
304
|
: [];
|
|
305
305
|
}
|
|
306
306
|
|
|
307
|
+
/**
|
|
308
|
+
* An item of the selection that is picked with it: one that can be
|
|
309
|
+
* picked. One that can't (a closed stack, whose click opens it) is never
|
|
310
|
+
* part of what a selection drags, even when Select All named it.
|
|
311
|
+
*/
|
|
312
|
+
private pickable(id: string) {
|
|
313
|
+
const item = this.item(id);
|
|
314
|
+
|
|
315
|
+
return item?.selectable === false ? undefined : item;
|
|
316
|
+
}
|
|
317
|
+
|
|
307
318
|
/** Whether a point on the page is within the box around the picked items. */
|
|
308
319
|
private inSelection(point: Point) {
|
|
309
320
|
const bounds = boundsOf(this.picked());
|
|
@@ -604,9 +615,10 @@ export class CanvasGestures {
|
|
|
604
615
|
this.select(picked);
|
|
605
616
|
}
|
|
606
617
|
|
|
618
|
+
// An item that can't be picked moves by itself, picked or not.
|
|
607
619
|
const ids = new Set(
|
|
608
|
-
picked.has(lead.id)
|
|
609
|
-
? [...picked].filter((id) => this.
|
|
620
|
+
picked.has(lead.id) && this.pickable(lead.id)
|
|
621
|
+
? [...picked].filter((id) => this.pickable(id)?.draggable)
|
|
610
622
|
: []
|
|
611
623
|
);
|
|
612
624
|
|
|
@@ -317,6 +317,11 @@ export class CanvasStore {
|
|
|
317
317
|
return true;
|
|
318
318
|
};
|
|
319
319
|
|
|
320
|
+
/** Whether any of `bounds` is on screen; none is before the canvas is. */
|
|
321
|
+
shows = (bounds: Rect) =>
|
|
322
|
+
this.screen.width > 0 &&
|
|
323
|
+
overlaps(visibleRect(this.viewport, this.screen), bounds);
|
|
324
|
+
|
|
320
325
|
/** Show every item, or the ones named; false when there is none to show. */
|
|
321
326
|
fitView = ({ nodes, ...options }: FitViewOptions = {}) => {
|
|
322
327
|
const items = nodes
|
|
@@ -33,6 +33,11 @@ export interface CanvasViewItem<Data = unknown> extends CanvasItem<Data> {
|
|
|
33
33
|
draggable?: boolean;
|
|
34
34
|
/** Moved by a drag; when set, only from within an element matching this. */
|
|
35
35
|
dragHandle?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Stays in its layer when selected, under what is drawn over it, rather
|
|
38
|
+
* than coming up over the rest (itemLayer).
|
|
39
|
+
*/
|
|
40
|
+
keepsLayer?: boolean;
|
|
36
41
|
/** Takes no pointer itself: what is under it gets the pointer. */
|
|
37
42
|
passThrough?: boolean;
|
|
38
43
|
selectable?: boolean;
|
|
@@ -135,6 +140,22 @@ export const useViewportValue = <T,>(select: (viewport: Viewport) => T): T => {
|
|
|
135
140
|
/** Selected items sit over the rest, their labels and pills too. */
|
|
136
141
|
const SELECTED_LIFT = 1000;
|
|
137
142
|
|
|
143
|
+
/**
|
|
144
|
+
* The layer an item is drawn in: its own, and while selected over the rest,
|
|
145
|
+
* unless it keeps its layer or is drawn under the rest. Of two in one layer,
|
|
146
|
+
* the later item is drawn over.
|
|
147
|
+
*/
|
|
148
|
+
export const itemLayer = (
|
|
149
|
+
item: Pick<CanvasViewItem, "keepsLayer" | "zIndex">,
|
|
150
|
+
selected: boolean
|
|
151
|
+
) => {
|
|
152
|
+
const layer = item.zIndex ?? 0;
|
|
153
|
+
|
|
154
|
+
return selected && !item.keepsLayer && layer >= 0
|
|
155
|
+
? layer + SELECTED_LIFT
|
|
156
|
+
: layer;
|
|
157
|
+
};
|
|
158
|
+
|
|
138
159
|
/**
|
|
139
160
|
* Where a click on the empty canvas landed: or, while items can't be picked,
|
|
140
161
|
* on an item away from its controls, which is the canvas there.
|
|
@@ -222,11 +243,7 @@ const ItemShell = memo(
|
|
|
222
243
|
}}
|
|
223
244
|
style={{
|
|
224
245
|
transform: `translate(${item.x}px, ${item.y}px)`,
|
|
225
|
-
|
|
226
|
-
// them.
|
|
227
|
-
zIndex:
|
|
228
|
-
(item.zIndex ?? 0) +
|
|
229
|
-
(selected && (item.zIndex ?? 0) >= 0 ? SELECTED_LIFT : 0),
|
|
246
|
+
zIndex: itemLayer(item, selected),
|
|
230
247
|
pointerEvents: item.passThrough ? "none" : undefined,
|
|
231
248
|
}}
|
|
232
249
|
>
|