@1agh/maude 1.6.13 → 1.7.1
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/apps/studio/annotations/ai-read.ts +3 -0
- package/apps/studio/annotations/ai-write.ts +15 -1
- package/apps/studio/annotations/lock.ts +174 -0
- package/apps/studio/annotations/migrate-v1.ts +1 -0
- package/apps/studio/annotations/registry.ts +3 -0
- package/apps/studio/annotations/v1-adapter.ts +1 -0
- package/apps/studio/annotations-context-toolbar.tsx +39 -0
- package/apps/studio/annotations-layer.tsx +167 -17
- package/apps/studio/annotations-model.ts +9 -0
- package/apps/studio/canvas-icons.tsx +18 -0
- package/apps/studio/dist/client.bundle.js +1 -1
- package/apps/studio/use-annotation-resize.tsx +4 -1
- package/apps/studio/whats-new.json +9 -0
- package/package.json +8 -8
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MAX_BOARD_BYTES, MAX_ELEMENTS } from './annotations/constants.ts';
|
|
2
|
+
import { guardLockedOps, isAllLocked, lockedStrokeIds } from './annotations/lock.ts';
|
|
2
3
|
import { v1ToV2 } from './annotations/migrate-v1.ts';
|
|
3
4
|
import { type Op as AnnotationOp, applyOps, diffToOps } from './annotations/ops.ts';
|
|
4
5
|
import { defOf } from './annotations/registry.ts';
|
|
@@ -678,6 +679,20 @@ function ensureAnnotStyles(): void {
|
|
|
678
679
|
// Strokes store — lifted out of the layer so the contextual toolbar (Phase 5.1
|
|
679
680
|
// Task 8) can mutate strokes without prop-drilling.
|
|
680
681
|
|
|
682
|
+
/** #137 — a copy of a locked element starts unlocked (duplicate / Alt+drag / paste). */
|
|
683
|
+
function unlockCopies<T extends { strokes: Stroke[]; newIds: string[] }>(res: T): T {
|
|
684
|
+
const fresh = new Set(res.newIds);
|
|
685
|
+
if (!res.strokes.some((s) => s.locked && fresh.has(s.id))) return res;
|
|
686
|
+
return {
|
|
687
|
+
...res,
|
|
688
|
+
strokes: res.strokes.map((s) => {
|
|
689
|
+
if (!s.locked || !fresh.has(s.id)) return s;
|
|
690
|
+
const { locked: _drop, ...rest } = s;
|
|
691
|
+
return rest as Stroke;
|
|
692
|
+
}),
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
|
|
681
696
|
export interface StrokesStoreValue {
|
|
682
697
|
strokes: Stroke[];
|
|
683
698
|
setStrokes: (next: Stroke[]) => void;
|
|
@@ -699,6 +714,8 @@ export interface StrokesStoreValue {
|
|
|
699
714
|
groupSelection: (ids: readonly string[]) => string[] | null;
|
|
700
715
|
/** Dissolve the outermost group of every selected stroke. */
|
|
701
716
|
ungroupSelection: (ids: readonly string[]) => void;
|
|
717
|
+
/** #137 — lock / unlock the (group-expanded) selection, as ONE undo record. */
|
|
718
|
+
setLocked: (ids: readonly string[], locked: boolean) => void;
|
|
702
719
|
/** Cmd+D / paste — clone with fresh ids; returns the clone ids to select. */
|
|
703
720
|
duplicateSelection: (ids: readonly string[], dx: number, dy: number) => string[];
|
|
704
721
|
/** Z-order — `]` `[` `Cmd+]` `Cmd+[`; group units move contiguously. */
|
|
@@ -1339,7 +1356,11 @@ export function AnnotationsLayer() {
|
|
|
1339
1356
|
const committed = board.committed;
|
|
1340
1357
|
const prevMap = strokesToElementMap(persist(prev), committed);
|
|
1341
1358
|
const nextMap = strokesToElementMap(persist(next), committed);
|
|
1342
|
-
|
|
1359
|
+
// #137 — the lock safety net: whatever tool produced this commit, a
|
|
1360
|
+
// locked element (as of `prevMap`) is not moved, resized, re-texted or
|
|
1361
|
+
// deleted. The board re-renders from the store, so a blocked change
|
|
1362
|
+
// snaps back on its own.
|
|
1363
|
+
const ops = guardLockedOps(prevMap, diffToOps(prevMap, nextMap)).ops;
|
|
1343
1364
|
// A text edit session's commit (Task 19): the board merges against what
|
|
1344
1365
|
// the session last SENT (its drafts), while undo goes back to the text
|
|
1345
1366
|
// before the edit. Drafts never reach undo.
|
|
@@ -1349,7 +1370,7 @@ export function AnnotationsLayer() {
|
|
|
1349
1370
|
sessionCommittedRef.current = true;
|
|
1350
1371
|
applyOpsLocal(aimCommitOps(ops, session));
|
|
1351
1372
|
const baseMap = strokesToElementMap(persist(withSlotText(prev, session)), committed);
|
|
1352
|
-
const redo = diffToOps(baseMap, nextMap);
|
|
1373
|
+
const redo = guardLockedOps(baseMap, diffToOps(baseMap, nextMap)).ops;
|
|
1353
1374
|
if (!redo.length) return;
|
|
1354
1375
|
// Undo MERGES back (not a strict inverse): a collaborator's typing
|
|
1355
1376
|
// that landed in the same text survives the undo of ours.
|
|
@@ -1400,8 +1421,17 @@ export function AnnotationsLayer() {
|
|
|
1400
1421
|
new Containment(strokesToElementMap(strokesRef.current, board.committed).values());
|
|
1401
1422
|
const withSubtree = (ids: readonly string[]) =>
|
|
1402
1423
|
expandForOp(ids, (x) => expandIdsToGroups(x, strokesRef.current), containmentNow());
|
|
1424
|
+
// #137 — what a delete may take: never a locked element, nor a section
|
|
1425
|
+
// holding one (its subtree would go with it).
|
|
1426
|
+
const deletable = (ids: readonly string[]): string[] => {
|
|
1427
|
+
const locked = lockedStrokeIds(strokesRef.current);
|
|
1428
|
+
if (!locked.size) return [...ids];
|
|
1429
|
+
return expandIdsToGroups(ids, strokesRef.current).filter(
|
|
1430
|
+
(id) => !locked.has(id) && !withSubtree([id]).some((x) => locked.has(x))
|
|
1431
|
+
);
|
|
1432
|
+
};
|
|
1403
1433
|
const deleteStrokes = (ids: string[]): void => {
|
|
1404
|
-
const set = new Set(withSubtree(ids));
|
|
1434
|
+
const set = new Set(withSubtree(deletable(ids)));
|
|
1405
1435
|
const prev = strokesRef.current;
|
|
1406
1436
|
const filtered = prev.filter(
|
|
1407
1437
|
(s) => !set.has(s.id) && !(s.tool === 'text' && s.anchorId != null && set.has(s.anchorId))
|
|
@@ -1418,6 +1448,11 @@ export function AnnotationsLayer() {
|
|
|
1418
1448
|
commitStrokes(prev, recomputeBoundArrows(normalizeGroups(filtered)));
|
|
1419
1449
|
};
|
|
1420
1450
|
const translateStrokes = (ids: string[], dx: number, dy: number): void => {
|
|
1451
|
+
// #137 — a selection holding a locked element doesn't move (as one unit).
|
|
1452
|
+
const locked = lockedStrokeIds(strokesRef.current);
|
|
1453
|
+
if (locked.size && expandIdsToGroups(ids, strokesRef.current).some((id) => locked.has(id))) {
|
|
1454
|
+
return;
|
|
1455
|
+
}
|
|
1421
1456
|
const set = new Set(withSubtree(ids));
|
|
1422
1457
|
const prev = strokesRef.current;
|
|
1423
1458
|
const next = recomputeBoundArrows(
|
|
@@ -1458,9 +1493,25 @@ export function AnnotationsLayer() {
|
|
|
1458
1493
|
if (strokesShallowEqual(prev, next)) return;
|
|
1459
1494
|
commitStrokes(prev, next, 'ungroup');
|
|
1460
1495
|
};
|
|
1496
|
+
const setLocked = (ids: readonly string[], locked: boolean): void => {
|
|
1497
|
+
const prev = strokesRef.current;
|
|
1498
|
+
const set = new Set(expandIdsToGroups(ids, prev));
|
|
1499
|
+
let touched = 0;
|
|
1500
|
+
const next = prev.map((s) => {
|
|
1501
|
+
// An anchored label follows its host's lock (the adapter derives it).
|
|
1502
|
+
if (!set.has(s.id) || (s.tool === 'text' && s.anchorId)) return s;
|
|
1503
|
+
if (!!s.locked === locked) return s;
|
|
1504
|
+
touched++;
|
|
1505
|
+
if (locked) return { ...s, locked: true } as Stroke;
|
|
1506
|
+
const { locked: _drop, ...rest } = s;
|
|
1507
|
+
return rest as Stroke;
|
|
1508
|
+
});
|
|
1509
|
+
if (!touched) return;
|
|
1510
|
+
commitStrokes(prev, next, locked ? 'lock' : 'unlock');
|
|
1511
|
+
};
|
|
1461
1512
|
const duplicateSelection = (ids: readonly string[], dx: number, dy: number): string[] => {
|
|
1462
1513
|
const prev = strokesRef.current;
|
|
1463
|
-
const res = duplicateStrokes(prev, withSubtree(ids), dx, dy);
|
|
1514
|
+
const res = unlockCopies(duplicateStrokes(prev, withSubtree(ids), dx, dy));
|
|
1464
1515
|
if (res.strokes.length === prev.length) return [];
|
|
1465
1516
|
const added = res.strokes.length - prev.length;
|
|
1466
1517
|
commitStrokes(prev, res.strokes, `duplicate ${added} stroke${added === 1 ? '' : 's'}`);
|
|
@@ -1528,6 +1579,7 @@ export function AnnotationsLayer() {
|
|
|
1528
1579
|
applyToStrokes,
|
|
1529
1580
|
groupSelection,
|
|
1530
1581
|
ungroupSelection,
|
|
1582
|
+
setLocked,
|
|
1531
1583
|
duplicateSelection,
|
|
1532
1584
|
reorderSelection,
|
|
1533
1585
|
alignSelection,
|
|
@@ -1923,9 +1975,10 @@ export function AnnotationsLayer() {
|
|
|
1923
1975
|
const zoom = vpRef.current?.zoom || 1;
|
|
1924
1976
|
const tol = 8 / zoom;
|
|
1925
1977
|
const prev = strokesRef.current;
|
|
1978
|
+
const locked = lockedStrokeIds(prev); // #137 — the eraser passes over a locked element
|
|
1926
1979
|
for (let i = prev.length - 1; i >= 0; i--) {
|
|
1927
1980
|
const candidate = prev[i];
|
|
1928
|
-
if (candidate && strokeHitTest(candidate, wx, wy, tol)) {
|
|
1981
|
+
if (candidate && !locked.has(candidate.id) && strokeHitTest(candidate, wx, wy, tol)) {
|
|
1929
1982
|
const removedId = candidate.id;
|
|
1930
1983
|
const next = prev
|
|
1931
1984
|
.slice(0, i)
|
|
@@ -2597,6 +2650,13 @@ export function AnnotationsLayer() {
|
|
|
2597
2650
|
) {
|
|
2598
2651
|
canvasEl.focus({ preventScroll: true });
|
|
2599
2652
|
}
|
|
2653
|
+
// #137 — a selection holding a locked element is selected but never
|
|
2654
|
+
// dragged (a group moves as one). Alt+drag still works: it drags
|
|
2655
|
+
// unlocked COPIES and leaves the originals where they are.
|
|
2656
|
+
if (!e.altKey) {
|
|
2657
|
+
const locked = lockedStrokeIds(strokesRef.current);
|
|
2658
|
+
if (locked.size && ids.some((id) => locked.has(id))) return { kind: 'locked' };
|
|
2659
|
+
}
|
|
2600
2660
|
// Capture a snapshot of all strokes at drag start. Every pointermove
|
|
2601
2661
|
// re-translates FROM the snapshot using the cumulative cursor delta
|
|
2602
2662
|
// (NOT a delta-from-last-frame mutation), so dragging back to origin
|
|
@@ -2617,7 +2677,7 @@ export function AnnotationsLayer() {
|
|
|
2617
2677
|
(x) => expandIdsToGroups(x, undoBase),
|
|
2618
2678
|
new Containment(strokesToElementMap(undoBase, board.committed).values())
|
|
2619
2679
|
);
|
|
2620
|
-
const res = duplicateStrokes(undoBase, subtree, 0, 0);
|
|
2680
|
+
const res = unlockCopies(duplicateStrokes(undoBase, subtree, 0, 0));
|
|
2621
2681
|
if (res.newIds.length) {
|
|
2622
2682
|
altDup = true;
|
|
2623
2683
|
dragSnapshot = res.strokes;
|
|
@@ -2788,8 +2848,11 @@ export function AnnotationsLayer() {
|
|
|
2788
2848
|
// Anchored text rides its host (selected with it); a section is taken
|
|
2789
2849
|
// only when the marquee encloses it (containment.ts marqueeHits).
|
|
2790
2850
|
const items: MarqueeItem[] = [];
|
|
2851
|
+
// #137 — a locked element (a big background, say) is never swept up.
|
|
2852
|
+
const locked = lockedStrokeIds(strokesStoreRef.current.strokes);
|
|
2791
2853
|
for (const s of strokesStoreRef.current.strokes) {
|
|
2792
2854
|
if (s.tool === 'text' && s.anchorId != null && s.anchorId !== '') continue;
|
|
2855
|
+
if (locked.has(s.id)) continue;
|
|
2793
2856
|
const bb = strokeBBox(s);
|
|
2794
2857
|
if (bb) items.push({ id: s.id, box: bb, container: s.tool === 'section' });
|
|
2795
2858
|
}
|
|
@@ -2956,6 +3019,13 @@ export function AnnotationsLayer() {
|
|
|
2956
3019
|
const id = node.getAttribute('data-id');
|
|
2957
3020
|
const t = node.getAttribute('data-tool');
|
|
2958
3021
|
if (!id) return;
|
|
3022
|
+
if (lockedStrokeIds(strokesRef.current).has(id)) {
|
|
3023
|
+
// #137 — no text edit while locked; still claimed so the canvas-shell
|
|
3024
|
+
// dblclick→fit() handler doesn't jump the view.
|
|
3025
|
+
e.preventDefault();
|
|
3026
|
+
e.stopPropagation();
|
|
3027
|
+
return;
|
|
3028
|
+
}
|
|
2959
3029
|
// FigJam v3 — double-click DEEP-SELECTS a group member (a single click
|
|
2960
3030
|
// selects the whole outermost group; Esc clears back out). The editor
|
|
2961
3031
|
// still opens below for text-bearing types — FigJam's enter-group-then-
|
|
@@ -3333,6 +3403,7 @@ export function AnnotationsLayer() {
|
|
|
3333
3403
|
const mine = validateElements(raw).elements.map((el) => {
|
|
3334
3404
|
const out: Record<string, unknown> = { ...el };
|
|
3335
3405
|
delete out.author;
|
|
3406
|
+
delete out.locked; // #137 — a pasted copy starts unlocked
|
|
3336
3407
|
if (author) out.author = author;
|
|
3337
3408
|
if (el.type === 'link' && typeof el.url === 'string') out.domain = linkDomain(el.url);
|
|
3338
3409
|
return out;
|
|
@@ -3474,6 +3545,14 @@ export function AnnotationsLayer() {
|
|
|
3474
3545
|
}
|
|
3475
3546
|
return;
|
|
3476
3547
|
}
|
|
3548
|
+
if (cmd && e.shiftKey && !e.altKey && k === 'l') {
|
|
3549
|
+
// #137 — ⌘⇧L toggles the lock (Figma / FigJam / Miro binding).
|
|
3550
|
+
if (sel.length === 0) return;
|
|
3551
|
+
e.preventDefault();
|
|
3552
|
+
e.stopImmediatePropagation();
|
|
3553
|
+
store.setLocked(sel, !isAllLocked(sel, store.strokes));
|
|
3554
|
+
return;
|
|
3555
|
+
}
|
|
3477
3556
|
if (cmd && !e.shiftKey && !e.altKey && k === 'd') {
|
|
3478
3557
|
if (sel.length === 0) return; // browser bookmark stays available
|
|
3479
3558
|
e.preventDefault();
|
|
@@ -3506,7 +3585,7 @@ export function AnnotationsLayer() {
|
|
|
3506
3585
|
if (e.key === 'Enter' && !cmd && !e.shiftKey && !e.altKey) {
|
|
3507
3586
|
if (sel.length !== 1) return;
|
|
3508
3587
|
const only = strokesRef.current.find((x) => x.id === sel[0]);
|
|
3509
|
-
if (!only) return;
|
|
3588
|
+
if (!only || only.locked) return; // #137 — no text edit while locked
|
|
3510
3589
|
if (
|
|
3511
3590
|
only.tool === 'rect' ||
|
|
3512
3591
|
only.tool === 'ellipse' ||
|
|
@@ -3835,6 +3914,8 @@ export function AnnotationsLayer() {
|
|
|
3835
3914
|
if (members) annotSel.replace(members);
|
|
3836
3915
|
} else if (action === 'ungroup') {
|
|
3837
3916
|
store.ungroupSelection(sel);
|
|
3917
|
+
} else if (action === 'lock' || action === 'unlock') {
|
|
3918
|
+
store.setLocked(sel, action === 'lock');
|
|
3838
3919
|
} else if (action === 'replace') {
|
|
3839
3920
|
// Stage F3 — "Replace…" on an ImageStroke/MediaRefStroke. The canvas
|
|
3840
3921
|
// REQUESTS (untrusted-origin postMessage, DDR-054); the main-origin shell
|
|
@@ -3923,6 +4004,12 @@ export function AnnotationsLayer() {
|
|
|
3923
4004
|
}
|
|
3924
4005
|
return out;
|
|
3925
4006
|
}, [annotSel, strokesById]);
|
|
4007
|
+
// #137 — any locked member pins the whole selection (it moves as one unit).
|
|
4008
|
+
const selectionLocked = useMemo(() => {
|
|
4009
|
+
if (!selectedStrokes.length) return false;
|
|
4010
|
+
const locked = lockedStrokeIds(strokes);
|
|
4011
|
+
return selectedStrokes.some((s) => locked.has(s.id));
|
|
4012
|
+
}, [selectedStrokes, strokes]);
|
|
3926
4013
|
|
|
3927
4014
|
return (
|
|
3928
4015
|
<AnnotationPipelineContext.Provider value={pipeline}>
|
|
@@ -3943,6 +4030,7 @@ export function AnnotationsLayer() {
|
|
|
3943
4030
|
anchorsById={anchorsById}
|
|
3944
4031
|
selectMode={tool === 'move'}
|
|
3945
4032
|
selectedStrokes={selectedStrokes}
|
|
4033
|
+
selectionLocked={selectionLocked}
|
|
3946
4034
|
marquee={marquee}
|
|
3947
4035
|
snapGuides={snapGuides}
|
|
3948
4036
|
bindHintId={bindHintId}
|
|
@@ -3982,6 +4070,7 @@ export function AnnotationsLayer() {
|
|
|
3982
4070
|
pos={ctxMenu}
|
|
3983
4071
|
selCount={annotSel.selectedIds.length}
|
|
3984
4072
|
canUngroup={selectedStrokes.some((s) => (s.groupIds?.length ?? 0) > 0)}
|
|
4073
|
+
allLocked={isAllLocked(annotSel.selectedIds, strokes)}
|
|
3985
4074
|
canReplace={
|
|
3986
4075
|
selectedStrokes.length === 1 &&
|
|
3987
4076
|
(selectedStrokes[0]?.tool === 'image' || selectedStrokes[0]?.tool === 'mediaref')
|
|
@@ -4111,6 +4200,7 @@ function AnnotationsSvg({
|
|
|
4111
4200
|
anchorsById,
|
|
4112
4201
|
selectMode,
|
|
4113
4202
|
selectedStrokes,
|
|
4203
|
+
selectionLocked,
|
|
4114
4204
|
marquee,
|
|
4115
4205
|
snapGuides,
|
|
4116
4206
|
bindHintId,
|
|
@@ -4144,6 +4234,8 @@ function AnnotationsSvg({
|
|
|
4144
4234
|
anchorsById: Map<string, AnchorHost>;
|
|
4145
4235
|
selectMode: boolean;
|
|
4146
4236
|
selectedStrokes: readonly Stroke[];
|
|
4237
|
+
/** #137 — a locked member pins the selection: no handles, a lock badge. */
|
|
4238
|
+
selectionLocked: boolean;
|
|
4147
4239
|
marquee: { ax: number; ay: number; bx: number; by: number } | null;
|
|
4148
4240
|
/** FigJam v3 — smart-guide lines painted while a drag is snapping. */
|
|
4149
4241
|
snapGuides: SnapGuide[] | null;
|
|
@@ -4290,7 +4382,14 @@ function AnnotationsSvg({
|
|
|
4290
4382
|
multi={selectedStrokes.length > 1}
|
|
4291
4383
|
/>
|
|
4292
4384
|
))}
|
|
4293
|
-
<AnnotGroupBbox
|
|
4385
|
+
<AnnotGroupBbox
|
|
4386
|
+
selectedStrokes={selectedStrokes}
|
|
4387
|
+
anchorsById={anchorsById}
|
|
4388
|
+
locked={selectionLocked}
|
|
4389
|
+
/>
|
|
4390
|
+
{selectionLocked ? (
|
|
4391
|
+
<LockBadge selectedStrokes={selectedStrokes} anchorsById={anchorsById} />
|
|
4392
|
+
) : null}
|
|
4294
4393
|
{marquee ? (
|
|
4295
4394
|
<rect
|
|
4296
4395
|
className="dc-annot-marquee"
|
|
@@ -4322,7 +4421,11 @@ function AnnotationsSvg({
|
|
|
4322
4421
|
<BindHintHalo strokes={strokes} bindHintId={bindHintId} />
|
|
4323
4422
|
{/* FigJam v3 — connection dots on a single selected bindable shape;
|
|
4324
4423
|
dragging one draws a bound connector (rendered below as a draft). */}
|
|
4325
|
-
{selectMode &&
|
|
4424
|
+
{selectMode &&
|
|
4425
|
+
!connDraft &&
|
|
4426
|
+
!selectionLocked &&
|
|
4427
|
+
selectedStrokes.length === 1 &&
|
|
4428
|
+
selectedStrokes[0] ? (
|
|
4326
4429
|
<ConnectorDots stroke={selectedStrokes[0]} />
|
|
4327
4430
|
) : null}
|
|
4328
4431
|
{connDraft ? (
|
|
@@ -4591,6 +4694,7 @@ function AnnotationContextMenu({
|
|
|
4591
4694
|
pos,
|
|
4592
4695
|
selCount,
|
|
4593
4696
|
canUngroup,
|
|
4697
|
+
allLocked,
|
|
4594
4698
|
canReplace,
|
|
4595
4699
|
canEditPhoto,
|
|
4596
4700
|
onAction,
|
|
@@ -4599,6 +4703,8 @@ function AnnotationContextMenu({
|
|
|
4599
4703
|
pos: { x: number; y: number };
|
|
4600
4704
|
selCount: number;
|
|
4601
4705
|
canUngroup: boolean;
|
|
4706
|
+
/** #137 — every selected element is locked: offer Unlock (a mixed selection offers Lock). */
|
|
4707
|
+
allLocked: boolean;
|
|
4602
4708
|
/** Stage F3 — exactly one ImageStroke/MediaRefStroke is selected. */
|
|
4603
4709
|
canReplace: boolean;
|
|
4604
4710
|
/** feature-photo-editor (Task 17) — exactly one content-addressed ImageStroke. */
|
|
@@ -4667,7 +4773,7 @@ function AnnotationContextMenu({
|
|
|
4667
4773
|
style={{ left: at.x, top: at.y }}
|
|
4668
4774
|
>
|
|
4669
4775
|
{item('copy', 'Copy', '⌘C')}
|
|
4670
|
-
{item('cut', 'Cut', '⌘X')}
|
|
4776
|
+
{item('cut', 'Cut', '⌘X', { disabled: allLocked })}
|
|
4671
4777
|
{item('paste', 'Paste', '⌘V')}
|
|
4672
4778
|
{item('duplicate', 'Duplicate', '⌘D')}
|
|
4673
4779
|
{canReplace ? item('replace', 'Replace…') : null}
|
|
@@ -4680,8 +4786,9 @@ function AnnotationContextMenu({
|
|
|
4680
4786
|
<div className="dc-menu-sep" aria-hidden="true" />
|
|
4681
4787
|
{item('group', 'Group selection', '⌘G', { disabled: selCount < 2 })}
|
|
4682
4788
|
{canUngroup ? item('ungroup', 'Ungroup', '⌘⇧G') : null}
|
|
4789
|
+
{allLocked ? item('unlock', 'Unlock', '⌘⇧L') : item('lock', 'Lock', '⌘⇧L')}
|
|
4683
4790
|
<div className="dc-menu-sep" aria-hidden="true" />
|
|
4684
|
-
{item('delete', 'Delete', '⌫', { destructive: true })}
|
|
4791
|
+
{item('delete', 'Delete', '⌫', { destructive: true, disabled: allLocked })}
|
|
4685
4792
|
</div>
|
|
4686
4793
|
);
|
|
4687
4794
|
}
|
|
@@ -4771,12 +4878,53 @@ function SelectionHalo({
|
|
|
4771
4878
|
|
|
4772
4879
|
// T17 — group bbox dashed rect for multi-stroke annotation selection. Mirrors
|
|
4773
4880
|
// the element-side GroupBbox idiom (1 px dashed accent + 6 × 6 corner handles).
|
|
4881
|
+
/**
|
|
4882
|
+
* #137 — a lock glyph at the selection's top-right corner: says why the
|
|
4883
|
+
* resize handles are missing. Counter-scaled to a constant screen size.
|
|
4884
|
+
*/
|
|
4885
|
+
function LockBadge({
|
|
4886
|
+
selectedStrokes,
|
|
4887
|
+
anchorsById,
|
|
4888
|
+
}: {
|
|
4889
|
+
selectedStrokes: readonly Stroke[];
|
|
4890
|
+
anchorsById: Map<string, AnchorHost>;
|
|
4891
|
+
}) {
|
|
4892
|
+
const zoom = useLiveViewport().zoom || 1;
|
|
4893
|
+
let xMax = Number.NEGATIVE_INFINITY;
|
|
4894
|
+
let yMin = Number.POSITIVE_INFINITY;
|
|
4895
|
+
for (const s of selectedStrokes) {
|
|
4896
|
+
const b = strokeBBox(s, anchorsById);
|
|
4897
|
+
if (!b) continue;
|
|
4898
|
+
xMax = Math.max(xMax, b.x + b.w);
|
|
4899
|
+
yMin = Math.min(yMin, b.y);
|
|
4900
|
+
}
|
|
4901
|
+
if (!Number.isFinite(xMax) || !Number.isFinite(yMin)) return null;
|
|
4902
|
+
const size = 16 / zoom;
|
|
4903
|
+
const pad = 4 / zoom;
|
|
4904
|
+
return (
|
|
4905
|
+
<g
|
|
4906
|
+
pointerEvents="none"
|
|
4907
|
+
data-testid="annot-lock-badge"
|
|
4908
|
+
transform={`translate(${xMax + pad} ${yMin - size - pad}) scale(${size / 24})`}
|
|
4909
|
+
>
|
|
4910
|
+
<rect x={-2} y={-2} width={28} height={28} rx={6} fill="var(--maude-hud-accent, #d63b1f)" />
|
|
4911
|
+
<g fill="none" stroke="#fff" strokeWidth={2.2} strokeLinecap="round" strokeLinejoin="round">
|
|
4912
|
+
<rect x="5" y="11" width="14" height="9" rx="2" />
|
|
4913
|
+
<path d="M8 11V8a4 4 0 018 0v3" />
|
|
4914
|
+
</g>
|
|
4915
|
+
</g>
|
|
4916
|
+
);
|
|
4917
|
+
}
|
|
4918
|
+
|
|
4774
4919
|
function AnnotGroupBbox({
|
|
4775
4920
|
selectedStrokes,
|
|
4776
4921
|
anchorsById,
|
|
4922
|
+
locked,
|
|
4777
4923
|
}: {
|
|
4778
4924
|
selectedStrokes: readonly Stroke[];
|
|
4779
4925
|
anchorsById: Map<string, AnchorHost>;
|
|
4926
|
+
/** #137 — a selection holding a locked element gets no resize corners. */
|
|
4927
|
+
locked?: boolean;
|
|
4780
4928
|
}) {
|
|
4781
4929
|
// Counter-scaled chrome — must hold a constant screen size while the world
|
|
4782
4930
|
// scales, so it needs the live zoom, not the settle-cadence published one.
|
|
@@ -4815,12 +4963,14 @@ function AnnotGroupBbox({
|
|
|
4815
4963
|
ne: 'nesw-resize',
|
|
4816
4964
|
sw: 'nesw-resize',
|
|
4817
4965
|
};
|
|
4818
|
-
const handles =
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4966
|
+
const handles = locked
|
|
4967
|
+
? []
|
|
4968
|
+
: [
|
|
4969
|
+
{ corner: 'nw', x: x - inset, y: y - inset },
|
|
4970
|
+
{ corner: 'ne', x: x + w - handle + inset, y: y - inset },
|
|
4971
|
+
{ corner: 'sw', x: x - inset, y: y + h - handle + inset },
|
|
4972
|
+
{ corner: 'se', x: x + w - handle + inset, y: y + h - handle + inset },
|
|
4973
|
+
];
|
|
4824
4974
|
return (
|
|
4825
4975
|
<g pointerEvents="none">
|
|
4826
4976
|
<rect
|
|
@@ -91,6 +91,13 @@ interface StrokeBase {
|
|
|
91
91
|
author?: 'ai';
|
|
92
92
|
authorName?: string;
|
|
93
93
|
authorId?: string;
|
|
94
|
+
/**
|
|
95
|
+
* Locked against accidental edits (#137): selectable, but not movable,
|
|
96
|
+
* resizable, deletable or text-editable from the UI. Absent = unlocked.
|
|
97
|
+
* A UX guard, not a permission — anyone can unlock. Serialized as
|
|
98
|
+
* `data-locked`.
|
|
99
|
+
*/
|
|
100
|
+
locked?: true;
|
|
94
101
|
/**
|
|
95
102
|
* FigJam v3 — rotation in degrees (clockwise) around the stroke's bbox
|
|
96
103
|
* center. Absent / 0 = axis-aligned (back-compat). Honoured by the box-
|
|
@@ -1027,6 +1034,7 @@ function rootExtraAttrs(s: Stroke): string {
|
|
|
1027
1034
|
extra += ` data-group-ids="${esc(s.groupIds.join(' '))}"`;
|
|
1028
1035
|
}
|
|
1029
1036
|
if (s.author === 'ai') extra += ' data-author="ai"';
|
|
1037
|
+
if (s.locked) extra += ' data-locked="1"';
|
|
1030
1038
|
// Phase 3 (whiteboard-improvements) — human author identity, independent of
|
|
1031
1039
|
// `data-author="ai"` (never both: a stroke is either agent- or human-drawn).
|
|
1032
1040
|
// escAttr (not esc) — these are attribute values, not element content; see
|
|
@@ -1446,6 +1454,7 @@ function readSharedAttrs(el: SvgElLike, s: Stroke): void {
|
|
|
1446
1454
|
if (ids.length) s.groupIds = ids;
|
|
1447
1455
|
}
|
|
1448
1456
|
if (el.getAttribute('data-author') === 'ai') s.author = 'ai';
|
|
1457
|
+
if (el.getAttribute('data-locked') === '1') s.locked = true;
|
|
1449
1458
|
const authorName = el.getAttribute('data-author-name');
|
|
1450
1459
|
if (authorName) {
|
|
1451
1460
|
const cleaned = sanitizeAuthorName(authorName);
|
|
@@ -614,6 +614,24 @@ export function IconGroup(props: IconProps) {
|
|
|
614
614
|
</Svg>
|
|
615
615
|
);
|
|
616
616
|
}
|
|
617
|
+
/** Lucide `lock` — #137 annotation lock. */
|
|
618
|
+
export function IconLock(props: IconProps) {
|
|
619
|
+
return (
|
|
620
|
+
<Svg {...props}>
|
|
621
|
+
<rect x="3" y="11" width="18" height="11" rx="2" />
|
|
622
|
+
<path d="M7 11V7a5 5 0 0110 0v4" />
|
|
623
|
+
</Svg>
|
|
624
|
+
);
|
|
625
|
+
}
|
|
626
|
+
/** Lucide `lock-open` — #137 annotation unlock. */
|
|
627
|
+
export function IconLockOpen(props: IconProps) {
|
|
628
|
+
return (
|
|
629
|
+
<Svg {...props}>
|
|
630
|
+
<rect x="3" y="11" width="18" height="11" rx="2" />
|
|
631
|
+
<path d="M7 11V7a5 5 0 019.9-1" />
|
|
632
|
+
</Svg>
|
|
633
|
+
);
|
|
634
|
+
}
|
|
617
635
|
export function IconUngroup(props: IconProps) {
|
|
618
636
|
return (
|
|
619
637
|
<Svg {...props}>
|