@open-document/core 0.10.0 → 0.11.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.
@@ -2,11 +2,20 @@ import {
2
2
  Bold,
3
3
  Check,
4
4
  Code,
5
+ Copy,
6
+ Heading,
7
+ Image,
5
8
  Italic,
6
9
  Link2,
7
- Loader2,
10
+ List,
11
+ Lock,
8
12
  MessageSquarePlus,
13
+ Pencil,
14
+ Pilcrow,
9
15
  RemoveFormatting,
16
+ Square,
17
+ Table,
18
+ Type,
10
19
  Unlink,
11
20
  X,
12
21
  } from 'lucide-react';
@@ -23,10 +32,12 @@ import { createPortal } from 'react-dom';
23
32
  import { isSafeHref } from '../../lib/href';
24
33
  import { useT } from '../../lib/i18n';
25
34
  import { candidateLocs, formatLocs } from '../../lib/inspector/fiber';
35
+ import type { StyleInfo } from '../../lib/inspector/format';
26
36
  import {
27
37
  cleanRun,
28
38
  cleanSegments,
29
39
  clearFormatting,
40
+ EDITING_ATTR,
30
41
  focusAt,
31
42
  hasMark,
32
43
  hrefOf,
@@ -55,7 +66,10 @@ import {
55
66
  } from '../../lib/inspector/inline-edit';
56
67
  import { PROP_ATTR } from '../../lib/source-loc';
57
68
  import { useHistory } from '../history-provider';
69
+ import { CollapsibleSection, Section } from '../panel/fields';
58
70
  import { PanelIconButton, PanelShell } from '../panel/panel-shell';
71
+ import { FormatSection } from './format-section';
72
+ import { elementsAt, styleKey, useStyleEdits } from './use-style-edits';
59
73
 
60
74
  type TextPart =
61
75
  | { kind: 'text'; index: number; value: string; formattable?: true; segments?: Segment[] }
@@ -133,10 +147,11 @@ const DOUBLE_CLICK_MS = 600;
133
147
  // Same visual language as open-slide's inspector: dashed on hover, solid on
134
148
  // selection, both in the same blue. Unsaved text keeps a dashed frame after the
135
149
  // cursor leaves it, so a change that exists only on screen never looks saved.
136
- const FRAME_STYLE: Record<'hover' | 'selected' | 'pending', CSSProperties> = {
150
+ const FRAME_STYLE: Record<'hover' | 'selected' | 'pending' | 'twin', CSSProperties> = {
137
151
  hover: { outline: '1.5px dashed #3b82f6', background: 'rgba(59,130,246,0.05)' },
138
152
  selected: { outline: '2px solid #3b82f6', background: 'rgba(59,130,246,0.1)' },
139
153
  pending: { outline: '1.5px dashed #3b82f6', outlineOffset: 2 },
154
+ twin: { outline: '1px solid rgba(59,130,246,0.55)', background: 'rgba(59,130,246,0.05)' },
140
155
  };
141
156
 
142
157
  // Past this, a reload that should have replaced a saved element is not coming
@@ -159,6 +174,24 @@ function targetFrom(el: Element | null): InspectorTarget | null {
159
174
  return { line, column, anchor: host, tag: host.tagName.toLowerCase(), ...(prop ? { prop } : {}) };
160
175
  }
161
176
 
177
+ /** What the panel's header calls the selected element — by role, not by tag. */
178
+ function kindOf(tag: string): { label: string; vars?: Record<string, number>; icon: typeof Type } {
179
+ const level = /^h([1-6])$/.exec(tag)?.[1];
180
+ if (level) return { label: 'Heading {level}', vars: { level: Number(level) }, icon: Heading };
181
+ if (tag === 'p' || tag === 'blockquote') return { label: 'Paragraph', icon: Pilcrow };
182
+ if (tag === 'li' || tag === 'ul' || tag === 'ol') return { label: 'List', icon: List };
183
+ if (tag === 'td' || tag === 'th' || tag === 'table' || tag === 'tr') {
184
+ return { label: 'Table', icon: Table };
185
+ }
186
+ if (tag === 'img' || tag === 'svg' || tag === 'figure') return { label: 'Image', icon: Image };
187
+ if (
188
+ ['span', 'strong', 'em', 'b', 'i', 'a', 'code', 'small', 'figcaption', 'label'].includes(tag)
189
+ ) {
190
+ return { label: 'Text', icon: Type };
191
+ }
192
+ return { label: 'Box', icon: Square };
193
+ }
194
+
162
195
  type Rect = { left: number; top: number; width: number; height: number };
163
196
 
164
197
  function sameRect(a: Rect | null, b: Rect) {
@@ -178,7 +211,7 @@ function Frame({
178
211
  }: {
179
212
  anchor: HTMLElement | null;
180
213
  container: HTMLElement;
181
- variant: 'hover' | 'selected' | 'pending';
214
+ variant: 'hover' | 'selected' | 'pending' | 'twin';
182
215
  }) {
183
216
  const [rect, setRect] = useState<Rect | null>(null);
184
217
 
@@ -239,9 +272,9 @@ const TOOL_CLASS =
239
272
 
240
273
  /**
241
274
  * Inline formatting, floating over the text being edited: emphasis, code,
242
- * links, and a way to take them off. Size, colour and alignment are not here
243
- * on purpose — they belong to the document's design system, and a one-off
244
- * inline style would quietly fork it.
275
+ * links, and a way to take them off. Size, colour and alignment are the
276
+ * element panel's, which offers the document's design tokens before a
277
+ * one-off value — here they would style a few words and quietly fork it.
245
278
  */
246
279
  function TextToolbar({
247
280
  anchor,
@@ -532,8 +565,10 @@ type Props = {
532
565
  docId: string;
533
566
  /** The scroll container the pages live in. */
534
567
  containerRef: React.RefObject<HTMLDivElement | null>;
535
- /** The design panel shares the right dock and wins it while open. */
568
+ /** The design panel shares the right dock; the panel opened last holds it. */
536
569
  panelHidden: boolean;
570
+ /** An element was picked on the page — the dock should show its panel. */
571
+ onPick: () => void;
537
572
  /** The save card is showing, so the hint underneath it steps aside. */
538
573
  quiet: boolean;
539
574
  onExit: () => void;
@@ -547,6 +582,7 @@ export function Inspector({
547
582
  docId,
548
583
  containerRef,
549
584
  panelHidden,
585
+ onPick,
550
586
  quiet,
551
587
  onExit,
552
588
  exitRef,
@@ -585,9 +621,25 @@ export function Inspector({
585
621
  const entriesRef = useRef(new Map<HTMLElement, Entry>());
586
622
  const sessionStartRef = useRef<Segment[][]>([]);
587
623
  const firstClickRef = useRef<{ anchor: HTMLElement; at: At; time: number } | null>(null);
624
+ const onPickRef = useRef(onPick);
625
+ onPickRef.current = onPick;
588
626
 
589
627
  useLayoutEffect(() => setContainer(containerRef.current), [containerRef]);
590
628
 
629
+ const {
630
+ count: styleCount,
631
+ edits: styleEdits,
632
+ change: changeStyle,
633
+ pendingFor,
634
+ discard: discardStyles,
635
+ forget: forgetStyles,
636
+ revert: revertStyles,
637
+ repaint: repaintStyles,
638
+ } = useStyleEdits(container);
639
+ const [styleInfo, setStyleInfo] = useState<{ anchor: HTMLElement; value: StyleInfo } | null>(
640
+ null,
641
+ );
642
+
591
643
  const insideChrome = useCallback(
592
644
  (node: EventTarget | null) =>
593
645
  (panelRef.current?.contains(node as Node) ?? false) ||
@@ -698,10 +750,11 @@ export function Inspector({
698
750
 
699
751
  const discard = useCallback(() => {
700
752
  for (const entry of [...entriesRef.current.values()]) drop(entry);
753
+ discardStyles();
701
754
  setActive(null);
702
755
  refresh();
703
756
  setStatus(t('Discarded unsaved edits'));
704
- }, [drop, refresh, t]);
757
+ }, [drop, refresh, discardStyles, t]);
705
758
 
706
759
  /**
707
760
  * Leaves the clone in place until hot reload has replaced what it covers —
@@ -845,23 +898,42 @@ export function Inspector({
845
898
  owners.push(entry);
846
899
  }
847
900
  }
848
- if (edits.length === 0) return { ok: true };
901
+ const styles = styleEdits();
902
+ if (edits.length === 0 && styles.length === 0) return { ok: true };
849
903
 
850
904
  setBusy(true);
851
905
  try {
852
- const res = await fetch('/__edit/texts', {
906
+ // Text and style go in one request, so the file is read, spliced and
907
+ // written once — two requests would each start from the file before
908
+ // the other, and the second would put back what the first changed.
909
+ const res = await fetch('/__edit/batch', {
853
910
  method: 'PUT',
854
911
  headers: { 'content-type': 'application/json' },
855
- body: JSON.stringify({ docId, edits }),
912
+ body: JSON.stringify({
913
+ docId,
914
+ texts: edits,
915
+ styles: styles.map(({ line, column, tag, changes, expected }) => ({
916
+ line,
917
+ column,
918
+ tag,
919
+ changes,
920
+ expected,
921
+ })),
922
+ }),
856
923
  });
857
- const body = (await res.json()) as { results?: Outcome[]; error?: string };
858
- if (!res.ok || !body.results) {
924
+ const body = (await res.json()) as {
925
+ texts?: Outcome[];
926
+ styles?: Outcome[];
927
+ error?: string;
928
+ };
929
+ if (!res.ok || !body.texts || !body.styles) {
859
930
  const error = body.error ?? t('Save failed');
860
931
  setStatus(error);
861
932
  return { ok: false, error };
862
933
  }
863
- const results = body.results;
864
- const failures = results.filter(
934
+ const results = body.texts;
935
+ const styleResults = body.styles;
936
+ const failures = [...results, ...styleResults].filter(
865
937
  (result): result is Extract<Outcome, { ok: false }> => !result.ok,
866
938
  );
867
939
  for (const entry of new Set(owners)) {
@@ -869,6 +941,9 @@ export function Inspector({
869
941
  if (wrote) settle(entry);
870
942
  else drop(entry);
871
943
  }
944
+ const keys = styles.map(styleKey);
945
+ forgetStyles(keys.filter((_, at) => styleResults[at]?.ok));
946
+ revertStyles(keys.filter((_, at) => !styleResults[at]?.ok));
872
947
  refresh();
873
948
  setSelected(null);
874
949
  if (failures.length === 0) {
@@ -877,7 +952,7 @@ export function Inspector({
877
952
  }
878
953
  const error = t('{failed} of {total} not saved — {reason}', {
879
954
  failed: failures.length,
880
- total: edits.length,
955
+ total: edits.length + styles.length,
881
956
  reason: failures[0]?.error ?? t('refused'),
882
957
  });
883
958
  setStatus(error);
@@ -888,7 +963,7 @@ export function Inspector({
888
963
  } finally {
889
964
  setBusy(false);
890
965
  }
891
- }, [active, docId, drop, finish, refresh, settle, t]);
966
+ }, [active, docId, drop, finish, refresh, settle, styleEdits, forgetStyles, revertStyles, t]);
892
967
 
893
968
  const leave = useCallback(async () => {
894
969
  if ((await save()).ok) onExit();
@@ -903,9 +978,10 @@ export function Inspector({
903
978
  };
904
979
  }, [exitRef, leave, controlsRef, save, discard]);
905
980
 
981
+ const pendingCount = pending.length + styleCount;
906
982
  useEffect(() => {
907
- onPendingChange(pending.length);
908
- }, [pending.length, onPendingChange]);
983
+ onPendingChange(pendingCount);
984
+ }, [pendingCount, onPendingChange]);
909
985
  useEffect(() => () => onPendingChange(0), [onPendingChange]);
910
986
 
911
987
  // Leaving edit mode any other way — a route change, closing the tab — drops
@@ -919,11 +995,11 @@ export function Inspector({
919
995
  }, []);
920
996
 
921
997
  useEffect(() => {
922
- if (pending.length === 0) return;
998
+ if (pendingCount === 0) return;
923
999
  const onBeforeUnload = (e: BeforeUnloadEvent) => e.preventDefault();
924
1000
  window.addEventListener('beforeunload', onBeforeUnload);
925
1001
  return () => window.removeEventListener('beforeunload', onBeforeUnload);
926
- }, [pending.length]);
1002
+ }, [pendingCount]);
927
1003
 
928
1004
  // An external write — an agent, the design panel, another save — reloads the
929
1005
  // document and replaces elements, clones and all. When the element at the
@@ -986,6 +1062,7 @@ export function Inspector({
986
1062
  }
987
1063
  }
988
1064
  if (replaced) refresh();
1065
+ repaintStyles();
989
1066
  if (lost > 0) {
990
1067
  setStatus(
991
1068
  lost > 1
@@ -1019,7 +1096,7 @@ export function Inspector({
1019
1096
  });
1020
1097
  observer.observe(container, { childList: true, subtree: true });
1021
1098
  return () => observer.disconnect();
1022
- }, [container, refresh, t]);
1099
+ }, [container, refresh, repaintStyles, t]);
1023
1100
 
1024
1101
  useEffect(() => {
1025
1102
  if (!container) return;
@@ -1036,6 +1113,7 @@ export function Inspector({
1036
1113
  if (entry) {
1037
1114
  const owner = targetFrom(entry.anchor);
1038
1115
  if (owner) setSelected((prev) => (prev?.anchor === owner.anchor ? prev : owner));
1116
+ onPickRef.current();
1039
1117
  if (active !== entry) {
1040
1118
  begin(entry.anchor, atIn(entry.editor.clone, e.clientX, e.clientY), false);
1041
1119
  }
@@ -1063,6 +1141,7 @@ export function Inspector({
1063
1141
  target.anchor.scrollIntoView({ block: 'center', behavior: 'smooth' });
1064
1142
  }
1065
1143
  setSelected((prev) => (prev?.anchor === target.anchor ? prev : target));
1144
+ onPickRef.current();
1066
1145
  setStatus(null);
1067
1146
  setNote('');
1068
1147
  };
@@ -1084,6 +1163,7 @@ export function Inspector({
1084
1163
  if (!target?.anchor.contains(e.target as Node)) return;
1085
1164
  e.preventDefault();
1086
1165
  setSelected((prev) => (prev?.anchor === target.anchor ? prev : target));
1166
+ onPickRef.current();
1087
1167
  setWantEdit({
1088
1168
  anchor: target.anchor,
1089
1169
  at: atIn(target.anchor, e.clientX, e.clientY),
@@ -1314,6 +1394,40 @@ export function Inspector({
1314
1394
  };
1315
1395
  }, [selected, docId, t]);
1316
1396
 
1397
+ // The Format section reads the element's own `style` from source: the page
1398
+ // shows the value, only source can say whether it is a token, a shared
1399
+ // style object's, or code.
1400
+ useEffect(() => {
1401
+ if (!selected) return;
1402
+ let cancelled = false;
1403
+ const params = new URLSearchParams({
1404
+ docId,
1405
+ line: String(selected.line),
1406
+ column: String(selected.column),
1407
+ tag: selected.tag,
1408
+ });
1409
+ fetch(`/__edit/style?${params}`)
1410
+ .then((res) => res.json())
1411
+ .then((body: StyleInfo & { error?: string }) => {
1412
+ if (cancelled) return;
1413
+ setStyleInfo({
1414
+ anchor: selected.anchor,
1415
+ value: body.error ? { editable: false, reason: body.error } : body,
1416
+ });
1417
+ })
1418
+ .catch(() => {
1419
+ if (!cancelled) {
1420
+ setStyleInfo({
1421
+ anchor: selected.anchor,
1422
+ value: { editable: false, reason: 'could not read source' },
1423
+ });
1424
+ }
1425
+ });
1426
+ return () => {
1427
+ cancelled = true;
1428
+ };
1429
+ }, [selected, docId]);
1430
+
1317
1431
  useEffect(() => {
1318
1432
  if (!wantEdit || !target || selected?.anchor !== wantEdit.anchor) return;
1319
1433
  setWantEdit(null);
@@ -1351,6 +1465,27 @@ export function Inspector({
1351
1465
  }
1352
1466
  };
1353
1467
 
1468
+ const kind = kindOf(selected?.tag ?? '');
1469
+ const editingHere = active !== null && active.anchor === selected?.anchor;
1470
+ const startEdit = () => {
1471
+ if (!selected) return;
1472
+ if (entriesRef.current.has(selected.anchor)) begin(selected.anchor, null, false);
1473
+ else setWantEdit({ anchor: selected.anchor, at: null, selectWord: false });
1474
+ };
1475
+ // Every other element the selected one's source prints — a `.map()` row, a
1476
+ // block split across pages. A style change lands on all of them, so the
1477
+ // page shows them before it happens rather than the panel saying so.
1478
+ const twins =
1479
+ container && selected
1480
+ ? elementsAt(container, selected).filter(
1481
+ (el) => el !== selected.anchor && !el.hasAttribute(EDITING_ATTR),
1482
+ )
1483
+ : [];
1484
+ const KindIcon = kind.icon;
1485
+ const loc = selected
1486
+ ? `${target?.line ?? selected.line}:${target?.column ?? selected.column}`
1487
+ : '';
1488
+
1354
1489
  const visible = (anchor: HTMLElement | null | undefined) =>
1355
1490
  anchor ? (entriesRef.current.get(anchor)?.editor.clone ?? anchor) : null;
1356
1491
  const selectedEl = visible(selected?.anchor);
@@ -1379,6 +1514,10 @@ export function Inspector({
1379
1514
  container={container}
1380
1515
  variant="hover"
1381
1516
  />
1517
+ {twins.map((twin, at) => (
1518
+ // biome-ignore lint/suspicious/noArrayIndexKey: twins share one loc; order is stable
1519
+ <Frame key={at} anchor={twin} container={container} variant="twin" />
1520
+ ))}
1382
1521
  <Frame anchor={selectedEl} container={container} variant="selected" />
1383
1522
  </div>
1384
1523
  {/* Only while there is something to act on: a row of disabled
@@ -1416,10 +1555,20 @@ export function Inspector({
1416
1555
  label={t('Element')}
1417
1556
  panelRef={panelRef}
1418
1557
  header={
1419
- <span className="truncate font-mono text-[11px] text-muted-foreground">
1420
- &lt;{selected.tag}&gt; · {target?.line ?? selected.line}:
1421
- {target?.column ?? selected.column}
1422
- </span>
1558
+ <>
1559
+ <KindIcon aria-hidden className="size-3.5 flex-none text-muted-foreground" />
1560
+ <span className="truncate font-medium text-xs">{t(kind.label, kind.vars)}</span>
1561
+ {twins.length > 0 && (
1562
+ <span
1563
+ title={t('{count} elements print from this line of source', {
1564
+ count: twins.length + 1,
1565
+ })}
1566
+ className="flex flex-none items-center gap-1 rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground"
1567
+ >
1568
+ <Copy aria-hidden className="size-3" />×{twins.length + 1}
1569
+ </span>
1570
+ )}
1571
+ </>
1423
1572
  }
1424
1573
  actions={
1425
1574
  <PanelIconButton label={t('Close')} onClick={() => setSelected(null)}>
@@ -1427,36 +1576,75 @@ export function Inspector({
1427
1576
  </PanelIconButton>
1428
1577
  }
1429
1578
  >
1430
- <div className="min-h-0 flex-1 overflow-y-auto p-3">
1431
- <span className="block text-[10px] text-muted-foreground uppercase tracking-wider">
1432
- {t('Text')}
1433
- </span>
1579
+ <FormatSection
1580
+ // A new element is a new set of fields: a half-typed number must
1581
+ // not commit onto whatever is selected next.
1582
+ key={`${selected.line}:${selected.column}`}
1583
+ anchor={selected.anchor}
1584
+ info={styleInfo?.anchor === selected.anchor ? styleInfo.value : null}
1585
+ pending={pendingFor(selected)}
1586
+ onChange={(prop, value, shown) => changeStyle(selected, prop, value, shown)}
1587
+ />
1588
+ <Section
1589
+ title={t('Text')}
1590
+ action={
1591
+ editingHere ? (
1592
+ <PanelIconButton label={t('Done')} onClick={() => active && finish(active, false)}>
1593
+ <Check className="size-3.5" />
1594
+ </PanelIconButton>
1595
+ ) : null
1596
+ }
1597
+ >
1434
1598
  {target === null ? (
1435
- <div className="grid h-16 place-items-center">
1436
- <Loader2 className="size-3.5 animate-spin text-muted-foreground" />
1599
+ <div className="h-0.5 overflow-hidden rounded bg-muted">
1600
+ <div className="h-full w-1/3 animate-pulse bg-foreground/20" />
1437
1601
  </div>
1438
- ) : target.editable ? (
1439
- <p className="mt-1 text-[11px] text-muted-foreground leading-relaxed">
1440
- {active?.anchor === selected.anchor
1441
- ? t(
1442
- 'Editing on the page. Enter keeps the change, Shift+Enter starts a new line, Esc reverts it.',
1443
- )
1444
- : t(
1445
- 'Double-click the text on the page, or press Enter, to edit it where it is printed.',
1446
- )}
1447
- {target.parts.some((part) => part.kind === 'markup') &&
1448
- ` ${t('Inline markup stays as written.')}`}
1449
- </p>
1450
1602
  ) : (
1451
- <p className="mt-1 rounded border border-border bg-muted px-2 py-1.5 text-[11px] text-muted-foreground">
1452
- {target.reason ? t(target.reason) : t('Not editable here.')}
1453
- </p>
1603
+ // The words themselves, as the way in: clicking them opens them
1604
+ // on the page. Markup the editor leaves alone reads as a chip.
1605
+ <button
1606
+ type="button"
1607
+ disabled={!target.editable}
1608
+ aria-pressed={editingHere}
1609
+ aria-label={target.editable ? t('Edit on page') : undefined}
1610
+ title={
1611
+ target.editable
1612
+ ? `${t('Edit on page')} (Enter)`
1613
+ : target.reason
1614
+ ? t(target.reason)
1615
+ : t('Not editable here.')
1616
+ }
1617
+ onClick={startEdit}
1618
+ className="group relative block max-h-28 w-full overflow-hidden rounded border border-border px-2 py-1.5 pr-7 text-left text-xs leading-relaxed transition-colors hover:border-foreground/40 focus-visible:outline-2 focus-visible:outline-foreground/60 disabled:cursor-not-allowed disabled:text-muted-foreground disabled:hover:border-border aria-pressed:border-foreground/60 aria-pressed:bg-accent/50"
1619
+ >
1620
+ {editingHere && active
1621
+ ? shownText(active.editor.clone)
1622
+ : target.parts.map((part, at) =>
1623
+ part.kind === 'text' ? (
1624
+ // biome-ignore lint/suspicious/noArrayIndexKey: parts are positional
1625
+ <span key={at}>{part.value}</span>
1626
+ ) : (
1627
+ <span
1628
+ // biome-ignore lint/suspicious/noArrayIndexKey: parts are positional
1629
+ key={at}
1630
+ className="mx-0.5 rounded bg-muted px-1 font-mono text-[10px] text-muted-foreground"
1631
+ >
1632
+ {part.label}
1633
+ </span>
1634
+ ),
1635
+ )}
1636
+ <span
1637
+ aria-hidden
1638
+ className="absolute top-1.5 right-1.5 flex text-muted-foreground opacity-60 transition-opacity group-hover:opacity-100 group-disabled:opacity-60"
1639
+ >
1640
+ {target.editable ? <Pencil className="size-3" /> : <Lock className="size-3" />}
1641
+ </span>
1642
+ </button>
1454
1643
  )}
1455
-
1456
- <span className="mt-4 block text-[10px] text-muted-foreground uppercase tracking-wider">
1457
- {t('Comment for the agent')}
1458
- </span>
1644
+ </Section>
1645
+ <CollapsibleSection title={t('Comment for the agent')}>
1459
1646
  <textarea
1647
+ aria-label={t('Comment for the agent')}
1460
1648
  value={note}
1461
1649
  onChange={(e) => setNote(e.target.value)}
1462
1650
  onKeyDown={(e) => {
@@ -1464,20 +1652,26 @@ export function Inspector({
1464
1652
  }}
1465
1653
  rows={3}
1466
1654
  placeholder={t('make this bold, shorten to one line…')}
1467
- className="mt-1 w-full resize-y rounded border border-border bg-transparent px-2 py-1.5 text-xs outline-none placeholder:text-muted-foreground/60 focus:border-foreground/40"
1655
+ className="w-full resize-y rounded border border-border bg-transparent px-2 py-1.5 text-xs outline-none placeholder:text-muted-foreground/60 focus:border-foreground/40"
1468
1656
  />
1469
1657
  <button
1470
1658
  type="button"
1471
1659
  onClick={saveComment}
1472
1660
  disabled={busy || note.trim() === ''}
1473
- className="mt-1.5 flex w-full items-center justify-center gap-1.5 rounded border border-border px-2 py-1.5 text-xs transition-colors hover:bg-accent disabled:opacity-50"
1661
+ className="flex h-8 w-full items-center justify-center gap-1.5 rounded border border-border px-2 text-xs transition-colors hover:bg-accent disabled:opacity-50"
1474
1662
  >
1475
1663
  <MessageSquarePlus className="size-3" />
1476
1664
  {t('Mark comment')}
1477
1665
  </button>
1478
-
1479
- {status && <p className="mt-2 text-[11px] text-muted-foreground">{status}</p>}
1480
- </div>
1666
+ </CollapsibleSection>
1667
+ <CollapsibleSection title={t('Source')} summary={loc}>
1668
+ <dl className="grid grid-cols-[64px_1fr] gap-x-2 gap-y-1.5 text-[11px]">
1669
+ <dt className="text-muted-foreground">{t('Element')}</dt>
1670
+ <dd className="font-mono">&lt;{selected.tag}&gt;</dd>
1671
+ <dt className="text-muted-foreground">{t('Location')}</dt>
1672
+ <dd className="font-mono">{loc}</dd>
1673
+ </dl>
1674
+ </CollapsibleSection>
1481
1675
  </PanelShell>
1482
1676
  )}
1483
1677
  </>