@1agh/maude 1.7.1 → 1.9.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/apps/studio/acp/bridge.ts +15 -2
- package/apps/studio/acp/login-state.ts +1 -0
- package/apps/studio/acp/probe.ts +52 -1
- package/apps/studio/api.ts +431 -39
- package/apps/studio/asset-upload.ts +174 -0
- package/apps/studio/assets-s3.ts +37 -2
- package/apps/studio/bin/_curl-local.mjs +7 -0
- package/apps/studio/bin/_pdf-playwright.mjs +22 -1
- package/apps/studio/bin/_png-playwright.mjs +20 -1
- package/apps/studio/bin/_region.mjs +92 -0
- package/apps/studio/bin/annotate.mjs +16 -7
- package/apps/studio/bin/read-annotations.mjs +62 -4
- package/apps/studio/canvas-build.ts +59 -4
- package/apps/studio/canvas-lib.tsx +48 -1
- package/apps/studio/canvas-shell.tsx +28 -4
- package/apps/studio/client/app.jsx +441 -15903
- package/apps/studio/client/canvas-url.js +9 -0
- package/apps/studio/client/dialogs/asset-picker.jsx +331 -0
- package/apps/studio/client/dialogs/command-palette.jsx +112 -0
- package/apps/studio/client/dialogs/export-dialog.jsx +782 -0
- package/apps/studio/client/dialogs/help-modal.jsx +324 -0
- package/apps/studio/client/dialogs/shortcuts-overlay.jsx +144 -0
- package/apps/studio/client/embed-view.jsx +284 -0
- package/apps/studio/client/embed.js +101 -0
- package/apps/studio/client/export-center.jsx +2 -0
- package/apps/studio/client/github.js +36 -3
- package/apps/studio/client/hooks/use-canvas-bridge.jsx +2150 -0
- package/apps/studio/client/hooks/use-git-actions.jsx +236 -0
- package/apps/studio/client/hooks/use-keyboard-shortcuts.jsx +297 -0
- package/apps/studio/client/hooks/use-palette-and-panels.jsx +474 -0
- package/apps/studio/client/hooks/use-photo-and-timeline.jsx +901 -0
- package/apps/studio/client/hooks/use-project-data.jsx +90 -0
- package/apps/studio/client/hooks/use-shell-core.jsx +1212 -0
- package/apps/studio/client/hooks/use-tabs.jsx +723 -0
- package/apps/studio/client/hooks/use-web-socket.jsx +13 -0
- package/apps/studio/client/inspector/artboard-knobs.jsx +456 -0
- package/apps/studio/client/inspector/color-picker.jsx +196 -0
- package/apps/studio/client/inspector/color.js +92 -0
- package/apps/studio/client/inspector/css-knobs.jsx +1720 -0
- package/apps/studio/client/inspector/css-vocab.jsx +131 -0
- package/apps/studio/client/inspector/ds-tokens.js +90 -0
- package/apps/studio/client/inspector/grid-tracks-editor.jsx +97 -0
- package/apps/studio/client/inspector/inspect-computed.jsx +68 -0
- package/apps/studio/client/inspector/inspector-panel.jsx +769 -0
- package/apps/studio/client/inspector/layers.jsx +322 -0
- package/apps/studio/client/inspector/selection.js +65 -0
- package/apps/studio/client/inspector/token-popover.jsx +301 -0
- package/apps/studio/client/menus/menubar.jsx +856 -0
- package/apps/studio/client/report-bug.jsx +8 -2
- package/apps/studio/client/selection-scope.js +40 -0
- package/apps/studio/client/shell/banners.jsx +272 -0
- package/apps/studio/client/shell/collapsed-rail.jsx +23 -0
- package/apps/studio/client/shell/comments-panel.jsx +177 -0
- package/apps/studio/client/shell/constants.js +60 -0
- package/apps/studio/client/shell/dock.jsx +131 -0
- package/apps/studio/client/shell/icons.jsx +370 -0
- package/apps/studio/client/shell/status-bar.jsx +215 -0
- package/apps/studio/client/shell/util.js +332 -0
- package/apps/studio/client/shell/viewport.jsx +254 -0
- package/apps/studio/client/system/system-view.jsx +255 -0
- package/apps/studio/client/tree/tree.jsx +1243 -0
- package/apps/studio/comments-overlay.tsx +6 -4
- package/apps/studio/config.schema.json +5 -0
- package/apps/studio/context.ts +20 -0
- package/apps/studio/dist/client.bundle.js +2728 -2728
- package/apps/studio/dist/comment-mount.js +2 -2
- package/apps/studio/embed-origins.ts +52 -0
- package/apps/studio/export-dialog.tsx +55 -3
- package/apps/studio/exporters/_browser-bundles.ts +21 -2
- package/apps/studio/exporters/format-scopes.ts +11 -3
- package/apps/studio/exporters/index.ts +17 -2
- package/apps/studio/exporters/jobs.ts +91 -23
- package/apps/studio/exporters/pdf.ts +10 -2
- package/apps/studio/exporters/png.ts +10 -2
- package/apps/studio/exporters/scope.ts +89 -15
- package/apps/studio/format.ts +296 -0
- package/apps/studio/generation/runtime-probe.ts +1 -1
- package/apps/studio/git/service.ts +1 -0
- package/apps/studio/http.ts +399 -36
- package/apps/studio/input-router.tsx +7 -1
- package/apps/studio/path-containment.ts +72 -0
- package/apps/studio/paths.ts +14 -1
- package/apps/studio/read-only-mode.ts +53 -0
- package/apps/studio/server.ts +123 -25
- package/apps/studio/sync/accepted-link.ts +6 -0
- package/apps/studio/sync/agent.ts +9 -1
- package/apps/studio/sync/cold-start-apply.ts +29 -4
- package/apps/studio/sync/cold-start.ts +78 -0
- package/apps/studio/sync/file-plane.ts +61 -1
- package/apps/studio/sync/format-sync.ts +160 -0
- package/apps/studio/sync/index.ts +208 -23
- package/apps/studio/sync/journal-client.ts +25 -5
- package/apps/studio/sync/migrate-seed.ts +8 -1
- package/apps/studio/sync/park.ts +39 -0
- package/apps/studio/sync/presentation.ts +9 -3
- package/apps/studio/sync/status.ts +2 -0
- package/apps/studio/sync/transaction-client.ts +130 -13
- package/apps/studio/sync/writer-registry.ts +5 -0
- package/apps/studio/ui-prefs.ts +95 -10
- package/apps/studio/use-canvas-media-drop.tsx +8 -28
- package/apps/studio/whats-new.json +36 -0
- package/apps/studio/ws.ts +19 -4
- package/cli/bin/claude-design-server.mjs +0 -0
- package/cli/commands/design.mjs +9 -2
- package/cli/commands/hub-workspace.mjs +25 -0
- package/cli/lib/workspace-plan.mjs +51 -0
- package/package.json +11 -9
- package/plugins/design/templates/_shell.html +58 -0
|
@@ -0,0 +1,769 @@
|
|
|
1
|
+
// inspector/inspector-panel.jsx — moved verbatim out of client/app.jsx (Maude v2 plan V2-0.2, move-only split).
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { CssKnobs, trackRecordableWrite } from './css-knobs.jsx';
|
|
5
|
+
import { LAYER_VOID_TAGS, LayerRow } from './layers.jsx';
|
|
6
|
+
import { Kbd, StIcon } from '../shell/icons.jsx';
|
|
7
|
+
import { PhotoKnobs } from '../photo-knobs.jsx';
|
|
8
|
+
import { ColorPicker } from './color-picker.jsx';
|
|
9
|
+
import { InspectComputed } from './inspect-computed.jsx';
|
|
10
|
+
import { ArtboardKnobs, resolveArtboardIdFromSelection } from './artboard-knobs.jsx';
|
|
11
|
+
|
|
12
|
+
// feature-photo-editor (Task 13/14) — derive the content-addressed photo asset a
|
|
13
|
+
// DOM selection points at (an artboard `<img src="assets/<sha8>.<ext>">`). Prefers
|
|
14
|
+
// the `photoAsset` the resolver stamped (dom-selection.ts), falling back to a scan
|
|
15
|
+
// of the selection's src/html for a selection that reached the panel via a code
|
|
16
|
+
// path predating that field. Returns null for a non-photo element.
|
|
17
|
+
export const PHOTO_ASSET_RE = /assets\/[0-9a-f]{8}\.[a-z0-9]+/i;
|
|
18
|
+
|
|
19
|
+
// Simplifier fix (review fan-out, 2026-07-21) — reuse PHOTO_ASSET_RE's own
|
|
20
|
+
// source for the global-match variant instead of re-inlining the pattern, so
|
|
21
|
+
// the two can never drift apart (e.g. an extension-charset fix landing in one
|
|
22
|
+
// and not the other).
|
|
23
|
+
export const PHOTO_ASSET_RE_G = new RegExp(PHOTO_ASSET_RE.source, 'gi');
|
|
24
|
+
|
|
25
|
+
export function photoAssetOfSelection(el) {
|
|
26
|
+
if (!el || Array.isArray(el)) return null;
|
|
27
|
+
if (el.photoAsset) return el.photoAsset;
|
|
28
|
+
const html = el.html || '';
|
|
29
|
+
// feature-4 regression fix (2026-07-20) — the select tool's bare click now
|
|
30
|
+
// picks the TOP-LEVEL container, so a photo selection often arrives as the
|
|
31
|
+
// WRAPPER around the <img>, not the <img> itself. When the selection's
|
|
32
|
+
// subtree contains EXACTLY ONE content-addressed image, offer the Photo tab
|
|
33
|
+
// for it (ambiguous multi-photo containers stay photo-less — drill/⌘-click
|
|
34
|
+
// to pick one).
|
|
35
|
+
if ((el.tag || '').toLowerCase() !== 'img') {
|
|
36
|
+
const imgs = [...new Set(html.match(PHOTO_ASSET_RE_G) || [])];
|
|
37
|
+
const tagged = [...new Set([...html.matchAll(/data-photo-asset="([^"]+)"/g)].map((m) => m[1]))];
|
|
38
|
+
if (tagged.length === 1) return tagged[0];
|
|
39
|
+
if (tagged.length === 0 && imgs.length === 1 && /<img/i.test(html)) return imgs[0];
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
// Once an edit is baked, the element's LIVE src is a `data:` URL (canvas-lib's
|
|
43
|
+
// PhotoPreviewBridge swaps it in directly) — it never matches PHOTO_ASSET_RE,
|
|
44
|
+
// so a REPLAYED/serialized selection (a WS resync, or the persisted
|
|
45
|
+
// `_active.json` restored on boot) that arrives without the dedicated
|
|
46
|
+
// `photoAsset` field would otherwise permanently lose the Photo tab for any
|
|
47
|
+
// already-edited photo. The element still carries the `data-photo-asset` tag
|
|
48
|
+
// the bridge stamped, and that DOES survive into an outerHTML snapshot — check
|
|
49
|
+
// it before falling back to the plain assets/<sha8> src scan.
|
|
50
|
+
const tagged = /data-photo-asset="([^"]+)"/.exec(html);
|
|
51
|
+
if (tagged) return tagged[1];
|
|
52
|
+
const m = PHOTO_ASSET_RE.exec(`${el.attrs?.src || ''} ${html}`);
|
|
53
|
+
return m ? m[0] : null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function InspectorPanel({
|
|
57
|
+
/** E4 — `inspector-panel` / `layers-panel`, so one parity spec can assert
|
|
58
|
+
* both shells show them. Undefined elsewhere; the attribute simply absent. */
|
|
59
|
+
testId,
|
|
60
|
+
selected,
|
|
61
|
+
onClose,
|
|
62
|
+
layersTree,
|
|
63
|
+
// feature-4 T7a — { [cdId]: { component, root, usages } } for purple rows.
|
|
64
|
+
componentMap,
|
|
65
|
+
// feature-4 T7b — locked layer keys (`"<id>:<index>"`) + toggle.
|
|
66
|
+
lockedKeys,
|
|
67
|
+
onToggleLock,
|
|
68
|
+
// feature-4 detach-component — clone-definition detach for a shared instance.
|
|
69
|
+
onDetachInstance,
|
|
70
|
+
canvasFile,
|
|
71
|
+
onSelectLayer,
|
|
72
|
+
onHoverLayer,
|
|
73
|
+
onReorderLayer,
|
|
74
|
+
layersBusyRef,
|
|
75
|
+
cfg,
|
|
76
|
+
onOptimistic,
|
|
77
|
+
onRecordEdit,
|
|
78
|
+
onReplaceMedia,
|
|
79
|
+
onResizeArtboard,
|
|
80
|
+
onSetArtboardHug,
|
|
81
|
+
onSetArtboardStyle,
|
|
82
|
+
onSetArtboardKind,
|
|
83
|
+
onSetArtboardPrint,
|
|
84
|
+
onDuplicateArtboard,
|
|
85
|
+
onUndoRedo,
|
|
86
|
+
editScope,
|
|
87
|
+
tab: tabProp,
|
|
88
|
+
onTabChange,
|
|
89
|
+
width,
|
|
90
|
+
resizing,
|
|
91
|
+
// feature-photo-editor (Task 13/15) — the Photo tab + its live-preview /
|
|
92
|
+
// bg-removal / undo channels. `photoSel` is the annotation-image target
|
|
93
|
+
// (threaded up separately since the annotation model has no DOM selection);
|
|
94
|
+
// an artboard `<img>` target is derived from `selected` instead.
|
|
95
|
+
photoSel,
|
|
96
|
+
photoRev,
|
|
97
|
+
onPhotoEdit,
|
|
98
|
+
onPhotoRemoveBackground,
|
|
99
|
+
onPhotoRecordEdit,
|
|
100
|
+
onPhotoUndoRedo,
|
|
101
|
+
// feature-configurable-panel-docking — when true this instance IS the standalone
|
|
102
|
+
// Layers panel: it forces the Layers view and hides the tab bar (the tab strip
|
|
103
|
+
// lives on the dock slot instead). `hideLayersTab` drops the inline Layers tab
|
|
104
|
+
// when Layers has been split into its own panel.
|
|
105
|
+
layersOnly = false,
|
|
106
|
+
hideLayersTab = false,
|
|
107
|
+
// DDR-171 — CSS-panel vocabulary mode ('advanced' | 'designer'), owned by App
|
|
108
|
+
// (single source of truth shared with Settings → Appearance).
|
|
109
|
+
cpMode,
|
|
110
|
+
onSetCpMode,
|
|
111
|
+
}) {
|
|
112
|
+
// Tab is controllable from the parent (the guided tour drives it to 'css' /
|
|
113
|
+
// 'layers' so a spotlight step lands on a real row) but falls back to local
|
|
114
|
+
// state for normal use. A user click both updates local state and notifies the
|
|
115
|
+
// parent, so the two stay in lockstep whichever owns it.
|
|
116
|
+
const [tabState, setTabState] = useState('inspect');
|
|
117
|
+
const tab = layersOnly ? 'layers' : (tabProp ?? tabState);
|
|
118
|
+
const setTab = (t) => {
|
|
119
|
+
setTabState(t);
|
|
120
|
+
onTabChange?.(t);
|
|
121
|
+
};
|
|
122
|
+
const [collapsed, setCollapsed] = useState(() => new Set());
|
|
123
|
+
// Phase 12.3 (W3.1) — per-layer visibility toggle. Persists via /_api/edit-css
|
|
124
|
+
// (property 'display', mirroring CssKnobs' commit/reset) and is undoable via
|
|
125
|
+
// the same edit-source command (see the undo/redo coverage RCA:
|
|
126
|
+
// .ai/logs/rca/issue-undo-redo-coverage-gaps.md). Keyed by `${id}:${index}`;
|
|
127
|
+
// holds only OPTIMISTIC overrides (either direction) over the tree-reported
|
|
128
|
+
// `node.hidden` (the authoritative source value) so a first render of an
|
|
129
|
+
// already-hidden element shows the correct eye-icon state without a click.
|
|
130
|
+
const [hiddenOverride, setHiddenOverride] = useState(() => new Map());
|
|
131
|
+
// feature-4 T7 — auto-reveal the selected row: expand any collapsed ancestor
|
|
132
|
+
// group + scroll it into view, so a canvas selection is never hidden behind a
|
|
133
|
+
// collapsed wrapper (a Figma layers-panel expectation). Runs whenever the
|
|
134
|
+
// selection or the (HMR-refreshed) tree changes.
|
|
135
|
+
useEffect(() => {
|
|
136
|
+
const sel = Array.isArray(selected) ? selected[0] : selected;
|
|
137
|
+
const selId = sel?.id;
|
|
138
|
+
if (!selId || !layersTree?.nodes) return;
|
|
139
|
+
const selIdx = sel.index;
|
|
140
|
+
let matchedKey = null;
|
|
141
|
+
const ancestorKeys = [];
|
|
142
|
+
(function find(nodes, trail) {
|
|
143
|
+
for (const n of nodes || []) {
|
|
144
|
+
const k = `${n.id}:${n.index}`;
|
|
145
|
+
if (!n.synthetic && n.id === selId && (selIdx == null || n.index === selIdx)) {
|
|
146
|
+
matchedKey = k;
|
|
147
|
+
ancestorKeys.push(...trail);
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
if (n.children && n.children.length && find(n.children, [...trail, k])) return true;
|
|
151
|
+
}
|
|
152
|
+
return false;
|
|
153
|
+
})(layersTree.nodes, []);
|
|
154
|
+
if (!matchedKey) return;
|
|
155
|
+
if (ancestorKeys.length) {
|
|
156
|
+
setCollapsed((prev) => {
|
|
157
|
+
let changed = false;
|
|
158
|
+
const next = new Set(prev);
|
|
159
|
+
for (const k of ancestorKeys) if (next.delete(k)) changed = true;
|
|
160
|
+
return changed ? next : prev;
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
requestAnimationFrame(() => {
|
|
164
|
+
try {
|
|
165
|
+
document
|
|
166
|
+
.querySelector(`.st-layer--row[data-layer-key="${matchedKey}"]`)
|
|
167
|
+
?.scrollIntoView({ block: 'nearest' });
|
|
168
|
+
} catch {
|
|
169
|
+
/* selector edge case — non-fatal */
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}, [selected, layersTree]);
|
|
173
|
+
const isNodeHidden = (node) => {
|
|
174
|
+
const key = `${node.id}:${node.index}`;
|
|
175
|
+
return hiddenOverride.has(key) ? hiddenOverride.get(key) : !!node.hidden;
|
|
176
|
+
};
|
|
177
|
+
// Phase 12.1 (DDR-138) — drag-to-reorder state (lifted so every row sees the
|
|
178
|
+
// same drop target) + an aria-live announcement for keyboard moves.
|
|
179
|
+
const [dragState, setDragState] = useState(null);
|
|
180
|
+
const [reorderMsg, setReorderMsg] = useState('');
|
|
181
|
+
// feature-4 T7c — Layers-panel rename: writes `data-dc-element` (the label's
|
|
182
|
+
// top-priority source in `layerLabel`) via the existing /_api/edit-attr lane
|
|
183
|
+
// + records undo through the same source-edit channel CssKnobs uses. The
|
|
184
|
+
// HMR reload re-posts the tree with the new label.
|
|
185
|
+
const renameLayer = (node, value) => {
|
|
186
|
+
if (!canvasFile || !node?.id) return;
|
|
187
|
+
trackRecordableWrite(fetch('/_api/edit-attr', {
|
|
188
|
+
method: 'POST',
|
|
189
|
+
headers: { 'content-type': 'application/json' },
|
|
190
|
+
body: JSON.stringify({ canvas: canvasFile, id: node.id, attr: 'data-dc-element', value }),
|
|
191
|
+
})
|
|
192
|
+
.then((r) => r.json().catch(() => ({})))
|
|
193
|
+
.then((j) => {
|
|
194
|
+
if (!j.ok) return;
|
|
195
|
+
onRecordEdit?.({
|
|
196
|
+
op: 'attr',
|
|
197
|
+
canvas: canvasFile,
|
|
198
|
+
id: node.id,
|
|
199
|
+
key: 'data-dc-element',
|
|
200
|
+
before: node.dcElement ?? null,
|
|
201
|
+
after: value,
|
|
202
|
+
});
|
|
203
|
+
})
|
|
204
|
+
.catch(() => {}));
|
|
205
|
+
};
|
|
206
|
+
const handleReorder = onReorderLayer
|
|
207
|
+
? (dragged, ref, position) => {
|
|
208
|
+
// Gate keyboard + drop moves while a prior reorder is still landing — the
|
|
209
|
+
// write churns positional ids, so acting on the stale tree would misfire.
|
|
210
|
+
if (layersBusyRef?.current) return;
|
|
211
|
+
// feature-4 T7 — a synthetic group row (unstamped wrapper) has no
|
|
212
|
+
// data-cd-id to address in source, so it can be neither dragged nor a
|
|
213
|
+
// drop target. Abort silently rather than post an unresolvable refId
|
|
214
|
+
// that would optimistically move then revert (a visible flicker).
|
|
215
|
+
if (dragged?.synthetic || ref?.synthetic) return;
|
|
216
|
+
const verb =
|
|
217
|
+
position === 'before'
|
|
218
|
+
? `before ${ref.label}`
|
|
219
|
+
: position === 'after'
|
|
220
|
+
? `after ${ref.label}`
|
|
221
|
+
: `into ${ref.label}`;
|
|
222
|
+
setReorderMsg(`Moved ${dragged.label} ${verb}`);
|
|
223
|
+
// Pass occurrence indices so a reused-component instance maps to its
|
|
224
|
+
// parent <Component> usage server-side (same-id instances are distinct).
|
|
225
|
+
onReorderLayer(dragged.id, ref.id, position, {
|
|
226
|
+
idIndex: dragged.index,
|
|
227
|
+
refIndex: ref.index,
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
: undefined;
|
|
231
|
+
// Flatten the VISIBLE tree (respecting collapse) with each node's depth,
|
|
232
|
+
// parent, siblings, and index — the basis for keyboard nav + moves.
|
|
233
|
+
const flattenVisibleLayers = () => {
|
|
234
|
+
const flat = [];
|
|
235
|
+
(function walk(nodes, depth, parentNode) {
|
|
236
|
+
(nodes || []).forEach((n, i) => {
|
|
237
|
+
flat.push({ node: n, depth, parentNode, siblings: nodes, pos: i });
|
|
238
|
+
if (n.children && n.children.length && !collapsed.has(`${n.id}:${n.index}`))
|
|
239
|
+
walk(n.children, depth + 1, n);
|
|
240
|
+
});
|
|
241
|
+
})(layersTree?.nodes, 0, null);
|
|
242
|
+
return flat;
|
|
243
|
+
};
|
|
244
|
+
// The keyboard cursor is the SELECTED element (NOT DOM focus, which the HMR
|
|
245
|
+
// re-render churns). ↑/↓ move the selection through the flattened tree;
|
|
246
|
+
// Alt+↑/↓ reorder within the parent; Alt+Shift+↑/↓ reorder across the parent
|
|
247
|
+
// boundary (out at first/last, into an adjacent open container). After a move
|
|
248
|
+
// the reorder re-selects the moved element (movedId), so the cursor follows
|
|
249
|
+
// and the next press keeps working — the fix for "Alt+arrow works once".
|
|
250
|
+
const onTreeKeyDown = (e) => {
|
|
251
|
+
if (e.key !== 'ArrowUp' && e.key !== 'ArrowDown') return;
|
|
252
|
+
if (!el) return;
|
|
253
|
+
const flat = flattenVisibleLayers();
|
|
254
|
+
const i = flat.findIndex((f) => f.node.id === el.id && f.node.index === el.index);
|
|
255
|
+
if (i < 0) return;
|
|
256
|
+
const dir = e.key === 'ArrowDown' ? 1 : -1;
|
|
257
|
+
const cur = flat[i];
|
|
258
|
+
if (!e.altKey) {
|
|
259
|
+
const t = flat[i + dir];
|
|
260
|
+
if (t) {
|
|
261
|
+
e.preventDefault();
|
|
262
|
+
onSelectLayer?.(t.node);
|
|
263
|
+
}
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
if (!handleReorder || !Array.isArray(cur.siblings)) return;
|
|
267
|
+
e.preventDefault();
|
|
268
|
+
const expanded = (n) =>
|
|
269
|
+
n && n.children && n.children.length && !collapsed.has(`${n.id}:${n.index}`);
|
|
270
|
+
if (!e.shiftKey) {
|
|
271
|
+
// Within-parent reorder; stop at the first/last sibling.
|
|
272
|
+
if (dir < 0 && cur.pos > 0) handleReorder(cur.node, cur.siblings[cur.pos - 1], 'before');
|
|
273
|
+
else if (dir > 0 && cur.pos < cur.siblings.length - 1)
|
|
274
|
+
handleReorder(cur.node, cur.siblings[cur.pos + 1], 'after');
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
// Cross-parent reorder (flattened traversal).
|
|
278
|
+
if (dir > 0) {
|
|
279
|
+
const next = cur.siblings[cur.pos + 1];
|
|
280
|
+
if (next) handleReorder(cur.node, next, expanded(next) ? 'inside-start' : 'after');
|
|
281
|
+
else if (cur.parentNode) handleReorder(cur.node, cur.parentNode, 'after');
|
|
282
|
+
} else {
|
|
283
|
+
const prev = cur.siblings[cur.pos - 1];
|
|
284
|
+
if (prev) handleReorder(cur.node, prev, expanded(prev) ? 'inside-end' : 'before');
|
|
285
|
+
else if (cur.parentNode) handleReorder(cur.node, cur.parentNode, 'before');
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
// Pointer-based drag-to-reorder in the Layers tree — same model as the
|
|
289
|
+
// in-canvas drag: the row FLOATS with the cursor (transform, slot reserved), a
|
|
290
|
+
// blue divider (or nest ring) marks the drop, and the move commits only on
|
|
291
|
+
// release. Same-origin shell, so it's all local (no dgn bus).
|
|
292
|
+
const layerDragRef = useRef(null);
|
|
293
|
+
const layerTreeRef = useRef(null);
|
|
294
|
+
const startLayerDrag = (e, node, key) => {
|
|
295
|
+
if (!handleReorder || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
|
|
296
|
+
if (layersBusyRef?.current) return; // a prior reorder is still landing (ids churning)
|
|
297
|
+
const startX = e.clientX;
|
|
298
|
+
const startY = e.clientY;
|
|
299
|
+
// Forbid dropping a node into itself or its own subtree.
|
|
300
|
+
const forbidden = new Set([key]);
|
|
301
|
+
(function walk(n) {
|
|
302
|
+
(n.children || []).forEach((c) => {
|
|
303
|
+
forbidden.add(`${c.id}:${c.index}`);
|
|
304
|
+
walk(c);
|
|
305
|
+
});
|
|
306
|
+
})(node);
|
|
307
|
+
// Flatten the VISIBLE tree (respecting collapse) with depth. The drop is
|
|
308
|
+
// computed dnd-kit-tree style: a GAP between rows + a DEPTH from the pointer's
|
|
309
|
+
// X — so you can nest into any container (even an empty one) and the divider
|
|
310
|
+
// INDENTS to show it's going into that nested list (Figma-style).
|
|
311
|
+
const INDENT = 14;
|
|
312
|
+
const BASE = 6;
|
|
313
|
+
const flat = [];
|
|
314
|
+
(function walk(nodes, depth) {
|
|
315
|
+
(nodes || []).forEach((n) => {
|
|
316
|
+
const k = `${n.id}:${n.index}`;
|
|
317
|
+
flat.push({ node: n, key: k, id: n.id, depth, tag: n.tag });
|
|
318
|
+
if (n.children && n.children.length && !collapsed.has(k)) walk(n.children, depth + 1);
|
|
319
|
+
});
|
|
320
|
+
})(layersTree?.nodes, 0);
|
|
321
|
+
const flatByKey = new Map(flat.map((it) => [it.key, it]));
|
|
322
|
+
let started = false;
|
|
323
|
+
const onMove = (ev) => {
|
|
324
|
+
if (!started) {
|
|
325
|
+
if (Math.hypot(ev.clientX - startX, ev.clientY - startY) < 4) return;
|
|
326
|
+
started = true;
|
|
327
|
+
}
|
|
328
|
+
const dx = ev.clientX - startX;
|
|
329
|
+
const dy = ev.clientY - startY;
|
|
330
|
+
let target = null;
|
|
331
|
+
// Visible rows in DOM (== flat) order, minus the dragged one (its rect is
|
|
332
|
+
// floated, so it's meaningless for gap math).
|
|
333
|
+
const rows = [].slice
|
|
334
|
+
.call(document.querySelectorAll('.st-layer--row[data-layer-key]'))
|
|
335
|
+
.map((el) => ({ rect: el.getBoundingClientRect(), it: flatByKey.get(el.getAttribute('data-layer-key')) }))
|
|
336
|
+
.filter((r) => r.it && r.it.key !== key);
|
|
337
|
+
if (rows.length) {
|
|
338
|
+
const rowLeft = rows[0].rect.left;
|
|
339
|
+
const rowRight = rows[0].rect.right;
|
|
340
|
+
// Gap = index of the first row whose vertical midpoint is below the pointer.
|
|
341
|
+
let gap = rows.length;
|
|
342
|
+
for (let i = 0; i < rows.length; i++) {
|
|
343
|
+
if (ev.clientY < rows[i].rect.top + rows[i].rect.height / 2) {
|
|
344
|
+
gap = i;
|
|
345
|
+
break;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
const prev = rows[gap - 1]?.it || null;
|
|
349
|
+
const nextIt = rows[gap]?.it || null;
|
|
350
|
+
// Depth from pointer X. Clamp between the row below (min) and one level
|
|
351
|
+
// under the row above (max, if it can hold children).
|
|
352
|
+
const raw = Math.round((ev.clientX - rowLeft - BASE) / INDENT);
|
|
353
|
+
const maxDepth = prev ? prev.depth + (LAYER_VOID_TAGS.has(prev.tag) ? 0 : 1) : 0;
|
|
354
|
+
const minDepth = nextIt ? nextIt.depth : 0;
|
|
355
|
+
const depth = Math.max(minDepth, Math.min(raw, maxDepth));
|
|
356
|
+
// Resolve (prev, depth) → { refId, position, refNode, targetDepth }.
|
|
357
|
+
let refIt = null;
|
|
358
|
+
let position = 'before';
|
|
359
|
+
let targetDepth = 0;
|
|
360
|
+
if (!prev) {
|
|
361
|
+
if (nextIt) {
|
|
362
|
+
refIt = nextIt;
|
|
363
|
+
position = 'before';
|
|
364
|
+
targetDepth = nextIt.depth;
|
|
365
|
+
}
|
|
366
|
+
} else if (depth > prev.depth) {
|
|
367
|
+
refIt = prev; // nest as prev's FIRST child
|
|
368
|
+
position = 'inside-start';
|
|
369
|
+
targetDepth = prev.depth + 1;
|
|
370
|
+
} else if (depth === prev.depth) {
|
|
371
|
+
refIt = prev;
|
|
372
|
+
position = 'after';
|
|
373
|
+
targetDepth = prev.depth;
|
|
374
|
+
} else {
|
|
375
|
+
for (let i = gap - 1; i >= 0; i--) {
|
|
376
|
+
if (rows[i].it.depth === depth) {
|
|
377
|
+
refIt = rows[i].it;
|
|
378
|
+
break;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
if (!refIt) refIt = prev;
|
|
382
|
+
position = 'after';
|
|
383
|
+
targetDepth = depth;
|
|
384
|
+
}
|
|
385
|
+
// Guard: no self, no dragged-subtree, no repeated (list) target.
|
|
386
|
+
// forbidden already holds the dragged node's own key + its subtree, so a
|
|
387
|
+
// different INSTANCE of the same reused component (same id, other key) is
|
|
388
|
+
// still a valid target.
|
|
389
|
+
if (refIt && refIt.key !== key && !forbidden.has(refIt.key)) {
|
|
390
|
+
const y = prev ? rows[gap - 1].rect.bottom : rows[0].rect.top;
|
|
391
|
+
const left = rowLeft + BASE + targetDepth * INDENT;
|
|
392
|
+
target = { refId: refIt.id, position, node: refIt.node, y, left, w: Math.max(24, rowRight - left) };
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
const next = { key, node, dx, dy, target };
|
|
396
|
+
layerDragRef.current = next;
|
|
397
|
+
setDragState(next);
|
|
398
|
+
};
|
|
399
|
+
const teardown = () => {
|
|
400
|
+
window.removeEventListener('pointermove', onMove);
|
|
401
|
+
window.removeEventListener('pointerup', onUp);
|
|
402
|
+
window.removeEventListener('keydown', onKey, true);
|
|
403
|
+
};
|
|
404
|
+
// Swallow the click that trails a drag so it doesn't also select a row.
|
|
405
|
+
const suppressClick = () => {
|
|
406
|
+
const sup = (ce) => {
|
|
407
|
+
ce.preventDefault();
|
|
408
|
+
ce.stopImmediatePropagation();
|
|
409
|
+
document.removeEventListener('click', sup, true);
|
|
410
|
+
};
|
|
411
|
+
document.addEventListener('click', sup, true);
|
|
412
|
+
setTimeout(() => document.removeEventListener('click', sup, true), 300);
|
|
413
|
+
};
|
|
414
|
+
const onUp = () => {
|
|
415
|
+
teardown();
|
|
416
|
+
const d = layerDragRef.current;
|
|
417
|
+
layerDragRef.current = null;
|
|
418
|
+
setDragState(null);
|
|
419
|
+
if (started && d?.target) {
|
|
420
|
+
suppressClick();
|
|
421
|
+
handleReorder(d.node, d.target.node, d.target.position);
|
|
422
|
+
}
|
|
423
|
+
};
|
|
424
|
+
// Esc — abort the drag: the row snaps back, nothing commits.
|
|
425
|
+
const onKey = (ke) => {
|
|
426
|
+
if (ke.key !== 'Escape') return;
|
|
427
|
+
ke.preventDefault();
|
|
428
|
+
ke.stopImmediatePropagation();
|
|
429
|
+
teardown();
|
|
430
|
+
layerDragRef.current = null;
|
|
431
|
+
setDragState(null);
|
|
432
|
+
if (started) suppressClick();
|
|
433
|
+
};
|
|
434
|
+
window.addEventListener('pointermove', onMove);
|
|
435
|
+
window.addEventListener('pointerup', onUp);
|
|
436
|
+
window.addEventListener('keydown', onKey, true);
|
|
437
|
+
};
|
|
438
|
+
const toggleCollapse = (key) =>
|
|
439
|
+
setCollapsed((prev) => {
|
|
440
|
+
const next = new Set(prev);
|
|
441
|
+
if (next.has(key)) next.delete(key);
|
|
442
|
+
else next.add(key);
|
|
443
|
+
return next;
|
|
444
|
+
});
|
|
445
|
+
const toggleVisibility = (node) => {
|
|
446
|
+
const key = `${node.id}:${node.index}`;
|
|
447
|
+
const wasHidden = isNodeHidden(node);
|
|
448
|
+
const willHide = !wasHidden;
|
|
449
|
+
setHiddenOverride((prev) => new Map(prev).set(key, willHide));
|
|
450
|
+
onOptimistic?.({
|
|
451
|
+
id: node.id,
|
|
452
|
+
artboardId: layersTree?.artboardId ?? null,
|
|
453
|
+
index: node.index,
|
|
454
|
+
prop: 'display',
|
|
455
|
+
value: willHide ? 'none' : null,
|
|
456
|
+
});
|
|
457
|
+
if (!canvasFile || !node.id) return;
|
|
458
|
+
fetch('/_api/edit-css', {
|
|
459
|
+
method: 'POST',
|
|
460
|
+
headers: { 'content-type': 'application/json' },
|
|
461
|
+
body: JSON.stringify(
|
|
462
|
+
willHide
|
|
463
|
+
? { canvas: canvasFile, id: node.id, property: 'display', value: 'none' }
|
|
464
|
+
: { canvas: canvasFile, id: node.id, property: 'display', reset: true }
|
|
465
|
+
),
|
|
466
|
+
}).catch(() => {});
|
|
467
|
+
// Record onto the canvas undo stack (Cmd+Z), same as any other inline CSS
|
|
468
|
+
// edit — fire-and-forget alongside the POST above, mirroring CssKnobs'
|
|
469
|
+
// commit()/reset() (which don't gate the record on the fetch resolving).
|
|
470
|
+
onRecordEdit?.({
|
|
471
|
+
op: 'css',
|
|
472
|
+
canvas: canvasFile,
|
|
473
|
+
id: node.id,
|
|
474
|
+
key: 'display',
|
|
475
|
+
before: wasHidden ? 'none' : null,
|
|
476
|
+
after: willHide ? 'none' : null,
|
|
477
|
+
});
|
|
478
|
+
};
|
|
479
|
+
// `selected` may be a single element, an array (multi-select), or null.
|
|
480
|
+
const el = Array.isArray(selected) ? selected[0] : selected;
|
|
481
|
+
// feature-photo-editor (Task 13) — resolve the Photo-tab target. Priority: an
|
|
482
|
+
// annotation-image threaded up (`photoSel`, no DOM selection) → a Photo-ONLY
|
|
483
|
+
// panel; else a content-addressed artboard `<img>` selection → Photo alongside
|
|
484
|
+
// the normal tabs.
|
|
485
|
+
const photoTarget = photoSel
|
|
486
|
+
? { asset: photoSel.asset, kind: 'annotation-image' }
|
|
487
|
+
: (() => {
|
|
488
|
+
const a = photoAssetOfSelection(el);
|
|
489
|
+
return a ? { asset: a, kind: 'artboard-img' } : null;
|
|
490
|
+
})();
|
|
491
|
+
const photoOnly = photoTarget?.kind === 'annotation-image';
|
|
492
|
+
// Cmd+Z / Cmd+Shift+Z (or Cmd+Y) while focus is still inside a Photo-tab
|
|
493
|
+
// slider — mirrors `onKnobKeyDown` above for the same reason: the window-
|
|
494
|
+
// level shortcut listener bails out whenever `document.activeElement` is an
|
|
495
|
+
// `<input>` (native text-undo would otherwise win), so a commit-then-Cmd+Z
|
|
496
|
+
// with the slider still focused needs its own forwarder here.
|
|
497
|
+
const onPhotoKnobKeyDown = (e) => {
|
|
498
|
+
if (!(e.metaKey || e.ctrlKey) || e.altKey) return;
|
|
499
|
+
const k = e.key.toLowerCase();
|
|
500
|
+
if (k === 'z') {
|
|
501
|
+
e.preventDefault();
|
|
502
|
+
onPhotoUndoRedo?.(e.shiftKey ? 'redo' : 'undo');
|
|
503
|
+
} else if (k === 'y') {
|
|
504
|
+
e.preventDefault();
|
|
505
|
+
onPhotoUndoRedo?.('redo');
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
// An annotation-image has no element tabs; force Photo. Otherwise honor the
|
|
509
|
+
// requested tab, but drop off a stale 'photo' tab when the new selection isn't
|
|
510
|
+
// photo-eligible — onto CSS, the editing tab a fresh selection opens on (Stage
|
|
511
|
+
// C). Landing on read-only Inspect meant that after touching a sticker, the
|
|
512
|
+
// next element you clicked showed facts instead of the controls to change it.
|
|
513
|
+
const effTab = photoOnly ? 'photo' : tab === 'photo' && !photoTarget ? 'css' : tab;
|
|
514
|
+
const tabBtn = (id, label, icon) => (
|
|
515
|
+
<button
|
|
516
|
+
type="button"
|
|
517
|
+
className={'st-rp-tab' + (effTab === id ? ' is-active' : '')}
|
|
518
|
+
onClick={() => setTab(id)}
|
|
519
|
+
>
|
|
520
|
+
<StIcon name={icon} size={14} />
|
|
521
|
+
{label}
|
|
522
|
+
</button>
|
|
523
|
+
);
|
|
524
|
+
const b = el?.bounds || null;
|
|
525
|
+
return (
|
|
526
|
+
<aside
|
|
527
|
+
className={'st-rpanel' + (resizing ? ' is-resizing' : '')}
|
|
528
|
+
style={width ? { width, flexBasis: width } : undefined}
|
|
529
|
+
aria-label="Inspector"
|
|
530
|
+
data-tour="inspector"
|
|
531
|
+
data-testid={testId}
|
|
532
|
+
>
|
|
533
|
+
<div
|
|
534
|
+
className="st-rp-tabs"
|
|
535
|
+
data-tour="inspector-tabs"
|
|
536
|
+
style={layersOnly ? { display: 'none' } : undefined}
|
|
537
|
+
>
|
|
538
|
+
{photoOnly ? (
|
|
539
|
+
tabBtn('photo', 'Photo', 'image')
|
|
540
|
+
) : (
|
|
541
|
+
<>
|
|
542
|
+
{tabBtn('inspect', 'Inspect', 'sliders')}
|
|
543
|
+
{!hideLayersTab && tabBtn('layers', 'Layers', 'layers')}
|
|
544
|
+
{tabBtn('css', 'CSS', 'code')}
|
|
545
|
+
{photoTarget ? tabBtn('photo', 'Photo', 'image') : null}
|
|
546
|
+
</>
|
|
547
|
+
)}
|
|
548
|
+
<button
|
|
549
|
+
type="button"
|
|
550
|
+
className="st-iconbtn"
|
|
551
|
+
aria-label="Close inspector"
|
|
552
|
+
style={{ marginLeft: 'auto' }}
|
|
553
|
+
onClick={onClose}
|
|
554
|
+
>
|
|
555
|
+
<StIcon name="x" size={14} />
|
|
556
|
+
</button>
|
|
557
|
+
</div>
|
|
558
|
+
{/* Stage H (INV-3) — edit-scope strip: is an edit local to this element or
|
|
559
|
+
shared across N rendered places? Visible across every tab so it's never
|
|
560
|
+
a surprise. Only for a single element selection with a resolved verdict. */}
|
|
561
|
+
{el?.id && !(Array.isArray(selected) && selected.length > 1) && editScope ? (
|
|
562
|
+
<div
|
|
563
|
+
className={`st-scope st-scope--${editScope.scope}`}
|
|
564
|
+
title={
|
|
565
|
+
editScope.scope === 'shared'
|
|
566
|
+
? `Editing this element's style changes ${editScope.affects} place${
|
|
567
|
+
editScope.affects === 1 ? '' : 's'
|
|
568
|
+
}${
|
|
569
|
+
editScope.componentName ? ` (component ${editScope.componentName})` : ''
|
|
570
|
+
}. Move/resize a whole instance to keep it local.`
|
|
571
|
+
: 'This edit affects only this element.'
|
|
572
|
+
}
|
|
573
|
+
>
|
|
574
|
+
<span className="st-scope-dot" aria-hidden="true" />
|
|
575
|
+
{editScope.scope === 'shared'
|
|
576
|
+
? `Shared${editScope.componentName ? ` · ${editScope.componentName}` : ''} · edits ${
|
|
577
|
+
editScope.affects
|
|
578
|
+
} place${editScope.affects === 1 ? '' : 's'}`
|
|
579
|
+
: 'Local · this element only'}
|
|
580
|
+
{/* feature-4 detach-component (2026-07-19) — make THIS instance its
|
|
581
|
+
own single-usage component so edits (incl. absolute positions)
|
|
582
|
+
stay local per artboard. */}
|
|
583
|
+
{editScope.scope === 'shared' && onDetachInstance ? (
|
|
584
|
+
<button
|
|
585
|
+
type="button"
|
|
586
|
+
className="st-scope-detach"
|
|
587
|
+
title="Clone this component for this instance only — edits stop affecting the other places"
|
|
588
|
+
onClick={() => onDetachInstance(el.id, el.index)}
|
|
589
|
+
>
|
|
590
|
+
Detach
|
|
591
|
+
</button>
|
|
592
|
+
) : null}
|
|
593
|
+
</div>
|
|
594
|
+
) : null}
|
|
595
|
+
<div className="st-rp-body">
|
|
596
|
+
{effTab === 'photo' && photoTarget ? (
|
|
597
|
+
<div onKeyDown={onPhotoKnobKeyDown}>
|
|
598
|
+
<PhotoKnobs
|
|
599
|
+
key={`${photoTarget.asset}:${photoRev ?? 0}`}
|
|
600
|
+
asset={photoTarget.asset}
|
|
601
|
+
ColorPicker={ColorPicker}
|
|
602
|
+
StIcon={StIcon}
|
|
603
|
+
onEdit={(edit) => onPhotoEdit?.(photoTarget.asset, edit)}
|
|
604
|
+
onRemoveBackground={onPhotoRemoveBackground}
|
|
605
|
+
onRecordEdit={(before, after) => onPhotoRecordEdit?.(photoTarget.asset, before, after)}
|
|
606
|
+
/>
|
|
607
|
+
</div>
|
|
608
|
+
) : !el && !(effTab === 'layers' && layersTree?.nodes?.length) ? (
|
|
609
|
+
<div className="st-rp-empty">
|
|
610
|
+
{/* <p> wrapper — st-rp-empty is a flex column, bare text nodes +
|
|
611
|
+
kbd would stack as stretched flex items. */}
|
|
612
|
+
<p>
|
|
613
|
+
Press <Kbd>V</Kbd>, then click an element to select it — or <Kbd>⌘</Kbd>-click
|
|
614
|
+
straight from Browse.
|
|
615
|
+
</p>
|
|
616
|
+
</div>
|
|
617
|
+
) : el && effTab === 'inspect' ? (
|
|
618
|
+
<>
|
|
619
|
+
<div className="st-rp-hd">{el.selector || el.tag || 'element'}</div>
|
|
620
|
+
<div className="st-insp-row">
|
|
621
|
+
<span className="st-insp-label">Pos</span>
|
|
622
|
+
<div className="st-insp-fields">
|
|
623
|
+
<span className="st-fmini">
|
|
624
|
+
<span className="st-mtag">X</span>
|
|
625
|
+
<input value={b ? Math.round(b.x) : '—'} readOnly aria-label="x position" />
|
|
626
|
+
</span>
|
|
627
|
+
<span className="st-fmini">
|
|
628
|
+
<span className="st-mtag">Y</span>
|
|
629
|
+
<input value={b ? Math.round(b.y) : '—'} readOnly aria-label="y position" />
|
|
630
|
+
</span>
|
|
631
|
+
</div>
|
|
632
|
+
</div>
|
|
633
|
+
<div className="st-insp-row">
|
|
634
|
+
<span className="st-insp-label">Size</span>
|
|
635
|
+
<div className="st-insp-fields">
|
|
636
|
+
<span className="st-fmini">
|
|
637
|
+
<span className="st-mtag">W</span>
|
|
638
|
+
<input value={b ? Math.round(b.w) : '—'} readOnly aria-label="width" />
|
|
639
|
+
</span>
|
|
640
|
+
<span className="st-fmini">
|
|
641
|
+
<span className="st-mtag">H</span>
|
|
642
|
+
<input value={b ? Math.round(b.h) : '—'} readOnly aria-label="height" />
|
|
643
|
+
</span>
|
|
644
|
+
</div>
|
|
645
|
+
</div>
|
|
646
|
+
<div className="st-insp-row">
|
|
647
|
+
<span className="st-insp-label">Tag</span>
|
|
648
|
+
<div className="st-insp-fields">
|
|
649
|
+
<span className="st-mono" style={{ fontSize: 11, color: 'var(--fg-0)' }}>
|
|
650
|
+
{el.tag || '—'}
|
|
651
|
+
</span>
|
|
652
|
+
</div>
|
|
653
|
+
</div>
|
|
654
|
+
{el.classes ? (
|
|
655
|
+
<div className="st-insp-row">
|
|
656
|
+
<span className="st-insp-label">Class</span>
|
|
657
|
+
<div className="st-insp-fields">
|
|
658
|
+
<span className="st-mono" style={{ fontSize: 11, color: 'var(--fg-1)' }}>
|
|
659
|
+
{el.classes}
|
|
660
|
+
</span>
|
|
661
|
+
</div>
|
|
662
|
+
</div>
|
|
663
|
+
) : null}
|
|
664
|
+
<InspectComputed el={el} />
|
|
665
|
+
</>
|
|
666
|
+
) : effTab === 'layers' ? (
|
|
667
|
+
<>
|
|
668
|
+
<div className="st-rp-hd">Layers{layersTree?.nodes?.length ? '' : ' · ancestry'}</div>
|
|
669
|
+
{layersTree?.nodes?.length ? (
|
|
670
|
+
<>
|
|
671
|
+
{handleReorder ? (
|
|
672
|
+
<div className="st-rp-hint" aria-hidden="true">
|
|
673
|
+
Drag or ↑/↓ select · Alt+↑/↓ move · Alt+Shift+↑/↓ move across
|
|
674
|
+
</div>
|
|
675
|
+
) : null}
|
|
676
|
+
{/* Keyboard nav/move handled at the container (tabIndex=0), driven
|
|
677
|
+
by the SELECTION not row focus — survives the HMR re-render. */}
|
|
678
|
+
<div
|
|
679
|
+
role="tree"
|
|
680
|
+
aria-label="Artboard layers"
|
|
681
|
+
tabIndex={0}
|
|
682
|
+
ref={layerTreeRef}
|
|
683
|
+
onKeyDown={onTreeKeyDown}
|
|
684
|
+
>
|
|
685
|
+
{layersTree.nodes.map((n, ni) => (
|
|
686
|
+
<LayerRow
|
|
687
|
+
key={`${n.id}:${n.index}`}
|
|
688
|
+
node={n}
|
|
689
|
+
depth={0}
|
|
690
|
+
selectedId={el?.id}
|
|
691
|
+
selectedIndex={el?.index}
|
|
692
|
+
collapsed={collapsed}
|
|
693
|
+
hiddenOverride={hiddenOverride}
|
|
694
|
+
onToggle={toggleCollapse}
|
|
695
|
+
onSelect={(node) => {
|
|
696
|
+
onSelectLayer?.(node);
|
|
697
|
+
layerTreeRef.current?.focus();
|
|
698
|
+
}}
|
|
699
|
+
onHover={(node) => onHoverLayer?.(node)}
|
|
700
|
+
onToggleVisibility={toggleVisibility}
|
|
701
|
+
onReorder={handleReorder}
|
|
702
|
+
onRowPointerDown={startLayerDrag}
|
|
703
|
+
dragState={dragState}
|
|
704
|
+
componentMap={componentMap}
|
|
705
|
+
lockedKeys={lockedKeys}
|
|
706
|
+
onToggleLock={onToggleLock}
|
|
707
|
+
onRename={renameLayer}
|
|
708
|
+
/>
|
|
709
|
+
))}
|
|
710
|
+
</div>
|
|
711
|
+
{dragState?.target ? (
|
|
712
|
+
<div
|
|
713
|
+
className="st-layer-divider"
|
|
714
|
+
aria-hidden="true"
|
|
715
|
+
style={{
|
|
716
|
+
left: dragState.target.left,
|
|
717
|
+
top: dragState.target.y - 1,
|
|
718
|
+
width: dragState.target.w,
|
|
719
|
+
}}
|
|
720
|
+
/>
|
|
721
|
+
) : null}
|
|
722
|
+
<div className="sr-only" role="status" aria-live="polite">
|
|
723
|
+
{reorderMsg}
|
|
724
|
+
</div>
|
|
725
|
+
</>
|
|
726
|
+
) : el && Array.isArray(el.dom_path) && el.dom_path.length ? (
|
|
727
|
+
el.dom_path.map((node, i) => (
|
|
728
|
+
<div
|
|
729
|
+
key={i}
|
|
730
|
+
className={'st-layer' + (i === el.dom_path.length - 1 ? ' is-sel' : '')}
|
|
731
|
+
style={{ paddingLeft: 8 + i * 12 }}
|
|
732
|
+
>
|
|
733
|
+
<StIcon name="square" size={13} />
|
|
734
|
+
{node}
|
|
735
|
+
</div>
|
|
736
|
+
))
|
|
737
|
+
) : (
|
|
738
|
+
<div className="st-rp-empty">
|
|
739
|
+
Select an element (⌘-click in the canvas) to see its layer tree.
|
|
740
|
+
</div>
|
|
741
|
+
)}
|
|
742
|
+
</>
|
|
743
|
+
) : !el.id && resolveArtboardIdFromSelection(el) ? (
|
|
744
|
+
<ArtboardKnobs
|
|
745
|
+
el={el}
|
|
746
|
+
cfg={cfg}
|
|
747
|
+
onResizeArtboard={onResizeArtboard}
|
|
748
|
+
onSetArtboardHug={onSetArtboardHug}
|
|
749
|
+
onSetArtboardStyle={onSetArtboardStyle}
|
|
750
|
+
onSetArtboardKind={onSetArtboardKind}
|
|
751
|
+
onSetArtboardPrint={onSetArtboardPrint}
|
|
752
|
+
onDuplicateArtboard={onDuplicateArtboard}
|
|
753
|
+
/>
|
|
754
|
+
) : (
|
|
755
|
+
<CssKnobs
|
|
756
|
+
el={el}
|
|
757
|
+
cfg={cfg}
|
|
758
|
+
onOptimistic={onOptimistic}
|
|
759
|
+
onRecordEdit={onRecordEdit}
|
|
760
|
+
onReplaceMedia={onReplaceMedia}
|
|
761
|
+
onUndoRedo={onUndoRedo}
|
|
762
|
+
mode={cpMode}
|
|
763
|
+
onSetMode={onSetCpMode}
|
|
764
|
+
/>
|
|
765
|
+
)}
|
|
766
|
+
</div>
|
|
767
|
+
</aside>
|
|
768
|
+
);
|
|
769
|
+
}
|