@estiva-app/ui 0.91.2 → 0.92.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.
Files changed (100) hide show
  1. package/dist/AppProvider.d.ts +7 -3
  2. package/dist/AppProvider.d.ts.map +1 -1
  3. package/dist/AttachedCard.d.ts +5 -1
  4. package/dist/AttachedCard.d.ts.map +1 -1
  5. package/dist/BlockNodes.d.ts +14 -1
  6. package/dist/BlockNodes.d.ts.map +1 -1
  7. package/dist/CommentBox.d.ts +9 -2
  8. package/dist/CommentBox.d.ts.map +1 -1
  9. package/dist/ComposerTriggers.d.ts +11 -2
  10. package/dist/ComposerTriggers.d.ts.map +1 -1
  11. package/dist/DocumentEditor.d.ts.map +1 -1
  12. package/dist/LinkCard.d.ts.map +1 -1
  13. package/dist/LinkChip.d.ts.map +1 -1
  14. package/dist/LinkChips.d.ts +2 -1
  15. package/dist/LinkChips.d.ts.map +1 -1
  16. package/dist/LinkParts.d.ts +6 -1
  17. package/dist/LinkParts.d.ts.map +1 -1
  18. package/dist/LinkPlaces.d.ts +7 -0
  19. package/dist/LinkPlaces.d.ts.map +1 -1
  20. package/dist/LinkRow.d.ts +29 -6
  21. package/dist/LinkRow.d.ts.map +1 -1
  22. package/dist/PartCard.d.ts +9 -2
  23. package/dist/PartCard.d.ts.map +1 -1
  24. package/dist/ReferenceCards.d.ts +9 -39
  25. package/dist/ReferenceCards.d.ts.map +1 -1
  26. package/dist/ReferenceMenu.d.ts.map +1 -1
  27. package/dist/editor.d.ts +1 -1
  28. package/dist/editor.d.ts.map +1 -1
  29. package/dist/editor.js +204 -183
  30. package/dist/editor.js.map +3 -3
  31. package/dist/index.d.ts +2 -2
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +165 -50
  34. package/dist/index.js.map +3 -3
  35. package/dist/linked.d.ts +48 -3
  36. package/dist/linked.d.ts.map +1 -1
  37. package/dist/linked.examples.d.ts +6 -0
  38. package/dist/linked.examples.d.ts.map +1 -1
  39. package/dist/linkedFrom.d.ts +7 -3
  40. package/dist/linkedFrom.d.ts.map +1 -1
  41. package/package.json +1 -1
  42. package/registry.json +53 -56
  43. package/src/AppProvider.mdx +7 -5
  44. package/src/AppProvider.test.tsx +15 -1
  45. package/src/AppProvider.tsx +13 -4
  46. package/src/AttachedCard.mdx +2 -1
  47. package/src/AttachedCard.test.tsx +28 -0
  48. package/src/AttachedCard.tsx +12 -2
  49. package/src/BlockNodes.mdx +8 -1
  50. package/src/BlockNodes.tsx +98 -11
  51. package/src/CommentBox.mdx +8 -2
  52. package/src/CommentBox.stories.tsx +28 -1
  53. package/src/CommentBox.test.tsx +64 -1
  54. package/src/CommentBox.tsx +44 -5
  55. package/src/ComposerTriggers.mdx +1 -0
  56. package/src/ComposerTriggers.tsx +34 -15
  57. package/src/DocumentEditor.mdx +1 -1
  58. package/src/DocumentEditor.stories.tsx +2 -2
  59. package/src/DocumentEditor.test.tsx +37 -7
  60. package/src/DocumentEditor.tsx +2 -1
  61. package/src/LinkCard.mdx +9 -5
  62. package/src/LinkCard.stories.tsx +17 -2
  63. package/src/LinkCard.test.tsx +21 -0
  64. package/src/LinkCard.tsx +35 -16
  65. package/src/LinkChip.mdx +6 -1
  66. package/src/LinkChip.stories.tsx +7 -1
  67. package/src/LinkChip.test.tsx +12 -0
  68. package/src/LinkChip.tsx +6 -2
  69. package/src/LinkChips.mdx +4 -3
  70. package/src/LinkChips.stories.tsx +2 -2
  71. package/src/LinkChips.test.tsx +1 -2
  72. package/src/LinkChips.ts +2 -1
  73. package/src/LinkParts.mdx +3 -2
  74. package/src/LinkParts.stories.tsx +8 -0
  75. package/src/LinkParts.tsx +40 -6
  76. package/src/LinkPlaces.mdx +3 -0
  77. package/src/LinkPlaces.ts +19 -0
  78. package/src/LinkRow.mdx +8 -2
  79. package/src/LinkRow.stories.tsx +14 -2
  80. package/src/LinkRow.test.tsx +31 -1
  81. package/src/LinkRow.tsx +69 -25
  82. package/src/PartCard.mdx +9 -1
  83. package/src/PartCard.stories.tsx +9 -0
  84. package/src/PartCard.test.tsx +13 -0
  85. package/src/PartCard.tsx +19 -5
  86. package/src/ReferenceCards.test.tsx +4 -35
  87. package/src/ReferenceCards.ts +10 -119
  88. package/src/ReferenceMenu.mdx +6 -4
  89. package/src/ReferenceMenu.test.tsx +67 -5
  90. package/src/ReferenceMenu.tsx +18 -7
  91. package/src/editor.ts +0 -3
  92. package/src/index.ts +4 -1
  93. package/src/linked.examples.ts +6 -0
  94. package/src/linked.test.ts +35 -1
  95. package/src/linked.ts +108 -3
  96. package/src/linkedFrom.test.tsx +42 -2
  97. package/src/linkedFrom.ts +15 -7
  98. package/src/registry/registry.test.ts +25 -6
  99. package/src/ReferenceCards.mdx +0 -86
  100. package/src/ReferenceCards.stories.tsx +0 -66
package/dist/editor.js CHANGED
@@ -298,18 +298,19 @@ function SelectionToolbar({ editor, marks = ["bold", "italic", "underline"], lin
298
298
  }
299
299
 
300
300
  // src/CommentBox.tsx
301
- import { Fragment as Fragment2, useCallback as useCallback4, useEffect as useEffect4, useLayoutEffect, useRef as useRef3, useState as useState4 } from "react";
302
- import { Extension as Extension11 } from "@tiptap/core";
301
+ import { Fragment as Fragment2, useCallback as useCallback4, useEffect as useEffect4, useLayoutEffect, useRef as useRef3, useState as useState3 } from "react";
302
+ import { Extension as Extension10, nodePasteRule } from "@tiptap/core";
303
303
  import { Editor } from "@tiptap/react";
304
304
  import { IconLock, IconPaperclip, IconSquareRounded } from "@tabler/icons-react";
305
305
  import { AttachedCard } from "@estiva-app/ui";
306
306
  import { AttachmentCard } from "@estiva-app/ui";
307
307
 
308
308
  // src/BlockNodes.tsx
309
- import { Extension as Extension6, InputRule, Node as Node2 } from "@tiptap/core";
309
+ import { Extension as Extension5, InputRule, Node as Node2 } from "@tiptap/core";
310
310
  import { DOMSerializer } from "@tiptap/pm/model";
311
- import { Plugin as Plugin6, PluginKey as PluginKey6 } from "@tiptap/pm/state";
311
+ import { Plugin as Plugin5, PluginKey as PluginKey5 } from "@tiptap/pm/state";
312
312
  import { Mapping, ReplaceAroundStep } from "@tiptap/pm/transform";
313
+ import { Decoration as Decoration3, DecorationSet as DecorationSet3 } from "@tiptap/pm/view";
313
314
  import { NodeViewWrapper, ReactNodeViewRenderer, ReactRenderer as ReactRenderer2 } from "@tiptap/react";
314
315
  import { Checkbox } from "@estiva-app/ui";
315
316
  import { calloutLook } from "@estiva-app/ui";
@@ -318,6 +319,7 @@ import { calloutLook } from "@estiva-app/ui";
318
319
  import { Extension as Extension2 } from "@tiptap/core";
319
320
  import { Plugin as Plugin2, PluginKey as PluginKey2 } from "@tiptap/pm/state";
320
321
  import { Decoration as Decoration2, DecorationSet as DecorationSet2 } from "@tiptap/pm/view";
322
+ import { thingKindOf } from "@estiva-app/ui";
321
323
  var CONTAINERS = /* @__PURE__ */ new Set(["bulletList", "orderedList", "listItem"]);
322
324
  var BECH32 = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
323
325
  function bech32Words(text) {
@@ -354,6 +356,15 @@ function naddrKind(naddr) {
354
356
  return null;
355
357
  }
356
358
  var FOLDER = 39e3;
359
+ var PAGE = 30842;
360
+ function linkedKindOfReference(uri) {
361
+ const bare = uri.toLowerCase().replace(/^nostr:/, "");
362
+ if (bare.startsWith("nevent1") || bare.startsWith("note1")) return "message";
363
+ if (!bare.startsWith("naddr1")) return void 0;
364
+ const kind = naddrKind(bare);
365
+ if (kind === null) return void 0;
366
+ return kind === PAGE ? "page" : thingKindOf(kind);
367
+ }
357
368
  function staysChip(uri) {
358
369
  const bare = uri.toLowerCase().replace(/^nostr:/, "");
359
370
  if (bare.startsWith("npub1") || bare.startsWith("nprofile1")) return true;
@@ -425,10 +436,10 @@ var LinkPlaces = Extension2.create({
425
436
  });
426
437
 
427
438
  // src/ReferenceMenu.tsx
428
- import { useCallback as useCallback2 } from "react";
429
- import { Extension as Extension5 } from "@tiptap/core";
439
+ import { useCallback as useCallback2, useEffect as useEffect2, useReducer } from "react";
440
+ import { Extension as Extension4 } from "@tiptap/core";
430
441
  import { useEditorState } from "@tiptap/react";
431
- import { NodeSelection as NodeSelection2, Plugin as Plugin5, PluginKey as PluginKey5, TextSelection } from "@tiptap/pm/state";
442
+ import { NodeSelection as NodeSelection2, Plugin as Plugin4, PluginKey as PluginKey4, TextSelection } from "@tiptap/pm/state";
432
443
  import { ReplaceStep } from "@tiptap/pm/transform";
433
444
  import { IconCheck, IconExternalLink } from "@tabler/icons-react";
434
445
 
@@ -584,10 +595,7 @@ import { MenuItem, MenuSection, MenuSeparator } from "@estiva-app/ui";
584
595
  import { Popover as Popover2 } from "@estiva-app/ui";
585
596
 
586
597
  // src/ReferenceCards.ts
587
- import { Extension as Extension4 } from "@tiptap/core";
588
- import { NodeSelection, Plugin as Plugin4, PluginKey as PluginKey4 } from "@tiptap/pm/state";
589
- import { Decoration as Decoration3, DecorationSet as DecorationSet3 } from "@tiptap/pm/view";
590
- import { useEffect as useEffect2, useState as useState2 } from "react";
598
+ import { NodeSelection } from "@tiptap/pm/state";
591
599
  function layoutOf(raw) {
592
600
  if (typeof raw !== "string" || raw === "" || raw === "none") return void 0;
593
601
  return raw === "detailed" ? "detailed" : "compact";
@@ -614,76 +622,6 @@ function referenceCardPlacements(doc2) {
614
622
  });
615
623
  return out;
616
624
  }
617
- var key3 = new PluginKey4("referenceCards");
618
- function elementFor(storage, slotKey) {
619
- let element = storage.elements.get(slotKey);
620
- if (!element) {
621
- element = document.createElement("div");
622
- element.setAttribute("data-reference-cards", slotKey);
623
- element.setAttribute("contenteditable", "false");
624
- storage.elements.set(slotKey, element);
625
- }
626
- return element;
627
- }
628
- function storageOf(editor) {
629
- return editor.storage.referenceCards;
630
- }
631
- var ReferenceCards = Extension4.create({
632
- name: "referenceCards",
633
- addStorage() {
634
- return { elements: /* @__PURE__ */ new Map() };
635
- },
636
- addProseMirrorPlugins() {
637
- const storage = this.storage;
638
- const decorate = (doc2) => DecorationSet3.create(
639
- doc2,
640
- referenceCardPlacements(doc2).map(
641
- (p) => Decoration3.widget(p.pos, () => elementFor(storage, p.key), {
642
- key: p.key,
643
- side: 1,
644
- ignoreSelection: true,
645
- // A click on a card is the card's, not a caret placement in the line.
646
- stopEvent: () => true
647
- })
648
- )
649
- );
650
- return [
651
- new Plugin4({
652
- key: key3,
653
- state: {
654
- init: (_, state) => decorate(state.doc),
655
- apply: (tr, set) => tr.docChanged ? decorate(tr.doc) : set
656
- },
657
- props: { decorations: (state) => key3.getState(state) }
658
- })
659
- ];
660
- }
661
- });
662
- function useReferenceCards(editor) {
663
- const [slots, setSlots] = useState2([]);
664
- useEffect2(() => {
665
- if (!editor) return;
666
- const storage = storageOf(editor);
667
- if (!storage) return;
668
- let last = "";
669
- const read = () => {
670
- if (editor.isDestroyed) return;
671
- const next = referenceCardPlacements(editor.state.doc).map((p) => ({ key: p.key, element: elementFor(storage, p.key), cards: p.cards }));
672
- const signature = JSON.stringify(next.map((s) => [s.key, s.cards]));
673
- if (signature === last) return;
674
- last = signature;
675
- const live = new Set(next.map((s) => s.key));
676
- for (const k of storage.elements.keys()) if (!live.has(k)) storage.elements.delete(k);
677
- setSlots(next);
678
- };
679
- read();
680
- editor.on("transaction", read);
681
- return () => {
682
- editor.off("transaction", read);
683
- };
684
- }, [editor]);
685
- return slots;
686
- }
687
625
  function referenceAtSelection(state) {
688
626
  const { selection } = state;
689
627
  let found = null;
@@ -727,7 +665,7 @@ function setReferenceCardAt(editor, pos, layout) {
727
665
 
728
666
  // src/ReferenceMenu.tsx
729
667
  import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
730
- var key4 = new PluginKey5("referenceMenu");
668
+ var key3 = new PluginKey4("referenceMenu");
731
669
  var SHOW_AS = [
732
670
  { as: "row", label: "Row" },
733
671
  { as: "card", label: "Card" }
@@ -741,8 +679,7 @@ function webHref(view, pos) {
741
679
  return typeof href === "string" && /^https?:\/\//i.test(href) ? href : "";
742
680
  }
743
681
  function rowsOf(view, pos) {
744
- const drawn = !!view.state.doc.nodeAt(pos)?.attrs.uri && !!view.someProp("nodeViews", (views) => views?.reference);
745
- const open = drawn || chipTarget(view, pos) || webHref(view, pos) ? ["open"] : [];
682
+ const open = chipTarget(view, pos) || webHref(view, pos) ? ["open"] : [];
746
683
  return linkPlaceAt(view.state.doc, pos) === "chip" ? open : [...open, ...SHOW_AS.map((show) => show.as)];
747
684
  }
748
685
  function chipAt(state, pos) {
@@ -772,7 +709,7 @@ function justPlaced(tr, state) {
772
709
  return pos;
773
710
  }
774
711
  function dispatchMenu(view, next) {
775
- view.dispatch(view.state.tr.setMeta(key4, next));
712
+ view.dispatch(view.state.tr.setMeta(key3, next));
776
713
  }
777
714
  var passing = false;
778
715
  function openChip(view, pos) {
@@ -795,31 +732,31 @@ function choose(editor, pos, row) {
795
732
  else if (row) setReferenceCardAt(editor, pos, row === "card" ? "detailed" : "none");
796
733
  }
797
734
  function isReferenceMenuOpen(state) {
798
- return !!key4.getState(state);
735
+ return !!key3.getState(state);
799
736
  }
800
737
  function referenceMenuClick(editor, pos) {
801
- if (passing || editor.isDestroyed || !editor.isEditable || key4.getState(editor.state) === void 0) return false;
738
+ if (passing || editor.isDestroyed || !editor.isEditable || key3.getState(editor.state) === void 0) return false;
802
739
  if (!chipAt(editor.state, pos) || rowsOf(editor.view, pos).length === 0) return false;
803
- editor.view.dispatch(caretAfter(editor.state, pos).setMeta(key4, { pos, active: -1 }));
740
+ editor.view.dispatch(caretAfter(editor.state, pos).setMeta(key3, { pos, active: -1 }));
804
741
  return true;
805
742
  }
806
743
  function caretAfter(state, pos) {
807
744
  const node = state.doc.nodeAt(pos);
808
745
  return state.tr.setSelection(TextSelection.create(state.doc, pos + (node?.nodeSize ?? 1)));
809
746
  }
810
- var ReferenceMenu = Extension5.create({
747
+ var ReferenceMenu = Extension4.create({
811
748
  name: "referenceMenu",
812
749
  // Before the editor's own keys, so Enter on a highlighted row is the row's, not a new line.
813
750
  priority: 1e3,
814
751
  addProseMirrorPlugins() {
815
752
  const editor = this.editor;
816
753
  return [
817
- new Plugin5({
818
- key: key4,
754
+ new Plugin4({
755
+ key: key3,
819
756
  state: {
820
757
  init: () => null,
821
758
  apply: (tr, value, before, after) => {
822
- const meta = tr.getMeta(key4);
759
+ const meta = tr.getMeta(key3);
823
760
  if (meta !== void 0) return meta;
824
761
  const placed = justPlaced(tr, after);
825
762
  if (placed !== null) return { pos: placed, active: -1 };
@@ -836,18 +773,18 @@ var ReferenceMenu = Extension5.create({
836
773
  handleDOMEvents: {
837
774
  // Focus gone, the keys no longer reach the menu, and a card chosen now would miss the save on leaving (code review).
838
775
  blur: (view) => {
839
- if (key4.getState(view.state)) dispatchMenu(view, null);
776
+ if (key3.getState(view.state)) dispatchMenu(view, null);
840
777
  return false;
841
778
  }
842
779
  },
843
780
  handleKeyDown: (view, event) => {
844
781
  if (event.shiftKey || event.ctrlKey || event.metaKey || event.altKey) return false;
845
- const open = key4.getState(view.state);
782
+ const open = key3.getState(view.state);
846
783
  if (!open) {
847
784
  const { selection } = view.state;
848
785
  if (event.key !== "Enter" || !view.editable || !(selection instanceof NodeSelection2) || selection.node.type.name !== "reference") return false;
849
786
  if (rowsOf(view, selection.from).length === 0) return false;
850
- view.dispatch(caretAfter(view.state, selection.from).setMeta(key4, { pos: selection.from, active: 0 }));
787
+ view.dispatch(caretAfter(view.state, selection.from).setMeta(key3, { pos: selection.from, active: 0 }));
851
788
  return true;
852
789
  }
853
790
  const rows = rowsOf(view, open.pos);
@@ -880,7 +817,7 @@ function ReferenceMenuView({ editor }) {
880
817
  editor,
881
818
  selector: ({ editor: ed }) => {
882
819
  if (!ed || ed.isDestroyed) return null;
883
- const open = key4.getState(ed.state);
820
+ const open = key3.getState(ed.state);
884
821
  if (!open) return null;
885
822
  if (!chipAt(ed.state, open.pos)) return null;
886
823
  return { pos: open.pos, active: open.active, shownAs: linkPlaceAt(ed.state.doc, open.pos) === "card" ? "card" : "row" };
@@ -896,6 +833,13 @@ function ReferenceMenuView({ editor }) {
896
833
  const live = shown && editor && !editor.isDestroyed ? editor : null;
897
834
  const dom = live && shown ? live.view.nodeDOM(shown.pos) : null;
898
835
  const anchor = dom instanceof HTMLElement ? dom : null;
836
+ const [, redraw] = useReducer((count) => count + 1, 0);
837
+ useEffect2(() => {
838
+ if (!anchor || typeof MutationObserver === "undefined") return;
839
+ const observer = new MutationObserver(redraw);
840
+ observer.observe(anchor, { childList: true, subtree: true, attributes: true, attributeFilter: ["href"] });
841
+ return () => observer.disconnect();
842
+ }, [anchor]);
899
843
  const rows = live && shown ? rowsOf(live.view, shown.pos) : [];
900
844
  const opens = rows[0] === "open";
901
845
  const showAs = rows.includes("card");
@@ -910,7 +854,7 @@ function ReferenceMenuView({ editor }) {
910
854
  anchor,
911
855
  open: !!shown && !!anchor && rows.length > 0,
912
856
  onOpenChange: (next) => {
913
- if (!next && editor && !editor.isDestroyed && key4.getState(editor.state)) dispatchMenu(editor.view, null);
857
+ if (!next && editor && !editor.isDestroyed && key3.getState(editor.state)) dispatchMenu(editor.view, null);
914
858
  },
915
859
  side: "bottom",
916
860
  align: "left",
@@ -1227,7 +1171,7 @@ function bringsInBlocks(transactions) {
1227
1171
  })
1228
1172
  );
1229
1173
  }
1230
- var BlockId = Extension6.create({
1174
+ var BlockId = Extension5.create({
1231
1175
  name: "blockId",
1232
1176
  onCreate() {
1233
1177
  const { state, view } = this.editor;
@@ -1239,8 +1183,8 @@ var BlockId = Extension6.create({
1239
1183
  },
1240
1184
  addProseMirrorPlugins() {
1241
1185
  return [
1242
- new Plugin6({
1243
- key: new PluginKey6("blockIdSplit"),
1186
+ new Plugin5({
1187
+ key: new PluginKey5("blockIdSplit"),
1244
1188
  appendTransaction: (transactions, old, state) => {
1245
1189
  if (!bringsInBlocks(transactions)) return null;
1246
1190
  const mapping = new Mapping();
@@ -1275,6 +1219,35 @@ var BlockId = Extension6.create({
1275
1219
  }
1276
1220
  });
1277
1221
  var webUrl = (raw) => raw && /^https?:\/\/\S+$/i.test(raw) ? raw : null;
1222
+ var CARD_CONTROLS = 'button, [role="combobox"]';
1223
+ var CARD_CLICKS = `a[href], input, select, ${CARD_CONTROLS}`;
1224
+ function keepCardPresses(element) {
1225
+ if (!element) return void 0;
1226
+ const keep = (event) => {
1227
+ if (event.target instanceof Element && event.target.closest(CARD_CONTROLS)) event.preventDefault();
1228
+ };
1229
+ element.addEventListener("mousedown", keep);
1230
+ return () => element.removeEventListener("mousedown", keep);
1231
+ }
1232
+ function caretLineReferences(state) {
1233
+ const { $head } = state.selection;
1234
+ const block = $head.parent;
1235
+ if (!block.isTextblock) return [];
1236
+ const start = $head.start();
1237
+ const at = $head.parentOffset;
1238
+ const lines = [{ from: 0, to: block.content.size, references: [] }];
1239
+ block.forEach((child, offset) => {
1240
+ const line = lines[lines.length - 1];
1241
+ if (child.type.name === "hardBreak") {
1242
+ line.to = offset;
1243
+ lines.push({ from: offset + child.nodeSize, to: block.content.size, references: [] });
1244
+ } else if (child.type.name === "reference") line.references.push({ pos: start + offset, size: child.nodeSize });
1245
+ });
1246
+ return lines.find((line) => at >= line.from && at <= line.to)?.references ?? [];
1247
+ }
1248
+ function onCaretLine(decorations) {
1249
+ return (decorations ?? []).some((decoration) => decoration.spec.caretLine === true);
1250
+ }
1278
1251
  var ReferenceNode = Node2.create({
1279
1252
  name: "reference",
1280
1253
  group: "inline",
@@ -1283,7 +1256,23 @@ var ReferenceNode = Node2.create({
1283
1256
  selectable: true,
1284
1257
  draggable: false,
1285
1258
  addOptions() {
1286
- return { view: null };
1259
+ return { view: null, editingLine: false };
1260
+ },
1261
+ addProseMirrorPlugins() {
1262
+ if (!this.options.editingLine) return [];
1263
+ const editor = this.editor;
1264
+ return [
1265
+ new Plugin5({
1266
+ key: new PluginKey5("referenceCaretLine"),
1267
+ props: {
1268
+ // Read on every update, a focus and a blur included (Tiptap sends a transaction for each), so it follows the caret.
1269
+ decorations: (state) => editor.isFocused && editor.isEditable ? DecorationSet3.create(
1270
+ state.doc,
1271
+ caretLineReferences(state).map(({ pos, size }) => Decoration3.node(pos, pos + size, {}, { caretLine: true }))
1272
+ ) : null
1273
+ }
1274
+ })
1275
+ ];
1287
1276
  },
1288
1277
  addAttributes() {
1289
1278
  return {
@@ -1312,32 +1301,40 @@ var ReferenceNode = Node2.create({
1312
1301
  addNodeView() {
1313
1302
  const View = this.options.view;
1314
1303
  if (!View) return null;
1304
+ const { editingLine } = this.options;
1315
1305
  return ReactNodeViewRenderer(({ node, editor, getPos, decorations }) => {
1316
1306
  const uri = String(node.attrs.uri ?? "");
1317
1307
  const href = typeof node.attrs.href === "string" && node.attrs.href ? node.attrs.href : void 0;
1318
1308
  const place2 = placeOf(decorations);
1309
+ const editing = editor.isEditable && (!editingLine || onCaretLine(decorations));
1319
1310
  return /* @__PURE__ */ jsx4(
1320
1311
  NodeViewWrapper,
1321
1312
  {
1322
1313
  as: "span",
1323
1314
  className: place2 === "chip" ? "inline" : "block w-full",
1315
+ ref: place2 === "card" ? keepCardPresses : void 0,
1324
1316
  onClickCapture: (event) => {
1325
1317
  const pos = getPos();
1326
1318
  if (typeof pos !== "number") return;
1327
1319
  const own = editor.view.nodeDOM(pos);
1328
1320
  if (!(event.target instanceof Element) || !own || !own.contains(event.target)) return;
1329
- if (place2 === "card" && event.target.closest('button, input, select, [role="combobox"]')) return;
1330
- if (!referenceMenuClick(editor, pos)) return;
1331
- event.preventDefault();
1332
- event.stopPropagation();
1321
+ if (place2 === "card" && event.target.closest(CARD_CLICKS)) return;
1322
+ if (referenceMenuClick(editor, pos)) {
1323
+ event.preventDefault();
1324
+ event.stopPropagation();
1325
+ return;
1326
+ }
1327
+ if (!editingLine && editor.isEditable && event.target.closest("a[href]")) event.preventDefault();
1333
1328
  },
1334
- children: uri ? /* @__PURE__ */ jsx4(View, { uri, ...href ? { href } : {}, place: place2, editing: editor.isEditable }) : /* @__PURE__ */ jsx4("span", { children: href })
1329
+ children: uri ? /* @__PURE__ */ jsx4(View, { uri, ...href ? { href } : {}, place: place2, editing }) : /* @__PURE__ */ jsx4("span", { children: href })
1335
1330
  }
1336
1331
  );
1337
1332
  }, {
1338
- // Words typed beside a link leave its node as it was, and Tiptap then skips the redraw; its place has changed (code review).
1333
+ // Words typed beside a link leave its node as it was, and Tiptap then skips the redraw; its place has changed (code
1334
+ // review), or the caret came onto its line or left it.
1339
1335
  update: ({ oldNode, newNode, oldDecorations, newDecorations, updateProps }) => {
1340
- if (oldNode !== newNode || placeOf(oldDecorations) !== placeOf(newDecorations)) updateProps();
1336
+ const moved = placeOf(oldDecorations) !== placeOf(newDecorations) || onCaretLine(oldDecorations) !== onCaretLine(newDecorations);
1337
+ if (oldNode !== newNode || moved) updateProps();
1341
1338
  return true;
1342
1339
  }
1343
1340
  });
@@ -1426,7 +1423,7 @@ function itemAtCaret(state) {
1426
1423
  if (item.type.name !== "listItem" || $from.index(-1) !== 0) return null;
1427
1424
  return { node: item, pos: $from.before(-1) };
1428
1425
  }
1429
- var sameAttrs = (a, b) => Object.keys({ ...a.attrs, ...b.attrs }).every((key5) => a.attrs[key5] === b.attrs[key5]);
1426
+ var sameAttrs = (a, b) => Object.keys({ ...a.attrs, ...b.attrs }).every((key4) => a.attrs[key4] === b.attrs[key4]);
1430
1427
  function listItemView(editor, node, view, getPos) {
1431
1428
  const toDOM = node.type.spec.toDOM;
1432
1429
  const { dom, contentDOM } = toDOM ? DOMSerializer.renderSpec(document, toDOM(node)) : { dom: document.createElement("li"), contentDOM: void 0 };
@@ -1477,7 +1474,7 @@ function listItemView(editor, node, view, getPos) {
1477
1474
  }
1478
1475
  };
1479
1476
  }
1480
- var Checklist = Extension6.create({
1477
+ var Checklist = Extension5.create({
1481
1478
  name: "checklist",
1482
1479
  // Before the list item's own Enter and Backspace.
1483
1480
  priority: 101,
@@ -1543,14 +1540,14 @@ var Checklist = Extension6.create({
1543
1540
  addProseMirrorPlugins() {
1544
1541
  const editor = this.editor;
1545
1542
  return [
1546
- new Plugin6({
1547
- key: new PluginKey6("checklist"),
1543
+ new Plugin5({
1544
+ key: new PluginKey5("checklist"),
1548
1545
  props: { nodeViews: { listItem: (node, view, getPos) => listItemView(editor, node, view, getPos) } }
1549
1546
  })
1550
1547
  ];
1551
1548
  }
1552
1549
  });
1553
- var Callout = Extension6.create({
1550
+ var Callout = Extension5.create({
1554
1551
  name: "callout",
1555
1552
  addGlobalAttributes() {
1556
1553
  return [
@@ -1575,8 +1572,8 @@ import { Card } from "@estiva-app/ui";
1575
1572
  import { cn as cn2 } from "@estiva-app/ui";
1576
1573
 
1577
1574
  // src/commentBoxFrame.tsx
1578
- import { useCallback as useCallback3, useEffect as useEffect3, useState as useState3 } from "react";
1579
- import { Extension as Extension7 } from "@tiptap/core";
1575
+ import { useCallback as useCallback3, useEffect as useEffect3, useState as useState2 } from "react";
1576
+ import { Extension as Extension6 } from "@tiptap/core";
1580
1577
  import { EditorContent } from "@tiptap/react";
1581
1578
  import { IconArrowUp } from "@tabler/icons-react";
1582
1579
  import { IconButton } from "@estiva-app/ui";
@@ -1595,7 +1592,7 @@ var WEB_LINK_CLASSES = `${LINK_UNDERLINE_CLASSES} before:content-[''] before:inl
1595
1592
  import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
1596
1593
  var COMPOSE_EDITOR_CLASSES = richTextClassName("default", "outline-none w-full bg-transparent min-h-[20px] [&>p+p]:-mt-1");
1597
1594
  var COMPOSE_SCROLL_CLASSES = { area: "-mr-3", viewport: "max-h-[50vh]", content: "pr-3" };
1598
- var ComposeKeys = Extension7.create({
1595
+ var ComposeKeys = Extension6.create({
1599
1596
  name: "composeKeys",
1600
1597
  addStorage() {
1601
1598
  return { send: null };
@@ -1645,7 +1642,7 @@ function BoxFrame({ editor, marked = false, selection, placeholder, empty = fals
1645
1642
  ] });
1646
1643
  }
1647
1644
  function SendBox({ editor, onSend, placeholder, tools, attachments, ready = false, holding = false, marked = false, selection, className }) {
1648
- const [empty, setEmpty] = useState3(true);
1645
+ const [empty, setEmpty] = useState2(true);
1649
1646
  const canSend = (!empty || ready) && !holding;
1650
1647
  const send = useCallback3(() => {
1651
1648
  if (!editor || holding || isEmptyDoc(editor) && !ready) return true;
@@ -1714,8 +1711,8 @@ function SendBox({ editor, onSend, placeholder, tools, attachments, ready = fals
1714
1711
  }
1715
1712
 
1716
1713
  // src/ComposerTriggers.tsx
1717
- import { Extension as Extension8 } from "@tiptap/core";
1718
- import { PluginKey as PluginKey7 } from "@tiptap/pm/state";
1714
+ import { Extension as Extension7 } from "@tiptap/core";
1715
+ import { PluginKey as PluginKey6 } from "@tiptap/pm/state";
1719
1716
  import Mention from "@tiptap/extension-mention";
1720
1717
  import Suggestion from "@tiptap/suggestion";
1721
1718
  import { NodeViewWrapper as NodeViewWrapper2, ReactNodeViewRenderer as ReactNodeViewRenderer2 } from "@tiptap/react";
@@ -1833,7 +1830,7 @@ function urgentPubkeys(editor) {
1833
1830
  });
1834
1831
  return urgent.length > 0 ? urgent : void 0;
1835
1832
  }
1836
- var PersonReference = Extension8.create({
1833
+ var PersonReference = Extension7.create({
1837
1834
  name: "personReference",
1838
1835
  addOptions() {
1839
1836
  return { people: () => [], uriOf: () => null, nodeName: "reference" };
@@ -1844,7 +1841,7 @@ var PersonReference = Extension8.create({
1844
1841
  Suggestion({
1845
1842
  editor: this.editor,
1846
1843
  char: "@",
1847
- pluginKey: new PluginKey7("personReference"),
1844
+ pluginKey: new PluginKey6("personReference"),
1848
1845
  ...listening("@"),
1849
1846
  // As `[`'s: only where the chip may go.
1850
1847
  allow: ({ state, range }) => {
@@ -1875,13 +1872,16 @@ function filterReferences(items, query) {
1875
1872
  return shown.slice(-REFERENCE_LIMIT);
1876
1873
  }
1877
1874
  var captionOf = (label, snippet) => snippet ? `${label}: ${snippet}` : label;
1875
+ function stayInDraft(event) {
1876
+ if (event.target instanceof Element && event.target.closest("a[href]")) event.preventDefault();
1877
+ }
1878
1878
  var CaptionedReference = Mention.extend({
1879
1879
  name: "captionedReference",
1880
1880
  group: "inline",
1881
1881
  inline: true,
1882
1882
  atom: true,
1883
1883
  addOptions() {
1884
- return { ...this.parent(), HTMLAttributes: {}, icon: null, iconFor: void 0, suggestion: { char: "\0", items: () => [] } };
1884
+ return { ...this.parent(), HTMLAttributes: {}, icon: null, iconFor: void 0, view: null, suggestion: { char: "\0", items: () => [] } };
1885
1885
  },
1886
1886
  addAttributes() {
1887
1887
  return {
@@ -1902,9 +1902,9 @@ var CaptionedReference = Mention.extend({
1902
1902
  return [{ tag: `span[data-${this.name.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)}]` }];
1903
1903
  },
1904
1904
  addNodeView() {
1905
- const { icon, iconFor } = this.options;
1905
+ const { icon, iconFor, view: View } = this.options;
1906
1906
  return ReactNodeViewRenderer2(
1907
- ({ node }) => (
1907
+ ({ node }) => View && node.attrs.uri ? /* @__PURE__ */ jsx6(NodeViewWrapper2, { as: "span", onClickCapture: stayInDraft, children: /* @__PURE__ */ jsx6(View, { uri: String(node.attrs.uri), place: "chip", editing: true }) }) : (
1908
1908
  // The caption is cut at 24ch, so the whole of it is on hover, in the package's tooltip (UIG-14) — as Peek's sent chip has it.
1909
1909
  /* @__PURE__ */ jsx6(NodeViewWrapper2, { as: "span", children: /* @__PURE__ */ jsx6(WithTooltip, { inline: true, label: captionOf(node.attrs.label, node.attrs.snippet), children: /* @__PURE__ */ jsxs4("span", { className: inlineChipClassName("neutral", "max-w-[24ch] cursor-default"), children: [
1910
1910
  /* @__PURE__ */ jsx6("span", { className: "flex items-center justify-center w-4 h-4 shrink-0 text-text-secondary", children: iconFor?.(node.attrs.uri ?? null) ?? icon }),
@@ -1941,7 +1941,7 @@ function referenceMenu({ ariaLabel, sectionLabel, icon, iconFor }) {
1941
1941
  };
1942
1942
  }
1943
1943
  var listed = (options, query) => options.sections ? options.sections(query).flatMap((section) => section.items.map((item) => ({ ...item, section: section.label }))) : filterReferences(options.items(), query);
1944
- var ReferenceTrigger = Extension8.create({
1944
+ var ReferenceTrigger = Extension7.create({
1945
1945
  name: "referenceTrigger",
1946
1946
  addOptions() {
1947
1947
  return { items: () => [], nodeName: "captionedReference", ariaLabel: "References", sectionLabel: "References", icon: null };
@@ -1952,7 +1952,7 @@ var ReferenceTrigger = Extension8.create({
1952
1952
  Suggestion({
1953
1953
  editor: this.editor,
1954
1954
  char: "[",
1955
- pluginKey: new PluginKey7("referenceTrigger"),
1955
+ pluginKey: new PluginKey6("referenceTrigger"),
1956
1956
  ...listening("]"),
1957
1957
  // As a mention's: only where the chip may go.
1958
1958
  allow: ({ state, range }) => {
@@ -2065,7 +2065,7 @@ function filterSlashSections(sections, query) {
2065
2065
  const q = query.toLowerCase();
2066
2066
  return sections.map((section) => ({ ...section, commands: q ? section.commands.filter((command) => matches(command, q)) : section.commands }));
2067
2067
  }
2068
- var SlashCommands = Extension8.create({
2068
+ var SlashCommands = Extension7.create({
2069
2069
  name: "slashCommands",
2070
2070
  addOptions() {
2071
2071
  return { sections: [formatSection()] };
@@ -2077,7 +2077,7 @@ var SlashCommands = Extension8.create({
2077
2077
  editor: this.editor,
2078
2078
  char: "/",
2079
2079
  startOfLine: false,
2080
- pluginKey: new PluginKey7("slashCommands"),
2080
+ pluginKey: new PluginKey6("slashCommands"),
2081
2081
  items: ({ query, editor }) => filterSlashSections(sections, query).flatMap(
2082
2082
  (section, at) => section.commands.filter((command) => offers(editor, command)).map((command) => ({ ...command, section: at }))
2083
2083
  ),
@@ -2103,20 +2103,21 @@ import { FieldLine } from "@estiva-app/ui";
2103
2103
  import { FilePicker } from "@estiva-app/ui";
2104
2104
  import { Kbd } from "@estiva-app/ui";
2105
2105
  import { inTheBox } from "@estiva-app/ui";
2106
+ import { LinkedIcon } from "@estiva-app/ui";
2106
2107
 
2107
2108
  // src/links.ts
2108
- import { Extension as Extension9 } from "@tiptap/core";
2109
- import { Plugin as Plugin7, PluginKey as PluginKey8, TextSelection as TextSelection2 } from "@tiptap/pm/state";
2109
+ import { Extension as Extension8 } from "@tiptap/core";
2110
+ import { Plugin as Plugin6, PluginKey as PluginKey7, TextSelection as TextSelection2 } from "@tiptap/pm/state";
2110
2111
  import { Decoration as Decoration4, DecorationSet as DecorationSet4 } from "@tiptap/pm/view";
2111
2112
  import StarterKit from "@tiptap/starter-kit";
2112
2113
  var LINK_ON_WORDS_TARGET = /^https?:\/\/[^\s)]+$/;
2113
- var PasteOverWords = Extension9.create({
2114
+ var PasteOverWords = Extension8.create({
2114
2115
  name: "commentBoxPasteOverWords",
2115
2116
  priority: 1001,
2116
2117
  addProseMirrorPlugins() {
2117
2118
  return [
2118
- new Plugin7({
2119
- key: new PluginKey8("commentBoxPasteOverWords"),
2119
+ new Plugin6({
2120
+ key: new PluginKey7("commentBoxPasteOverWords"),
2120
2121
  props: {
2121
2122
  handlePaste: (view, event) => {
2122
2123
  const url = (event.clipboardData?.getData("text/plain").trim() ?? "").replace(/[.,;:!?]+$/, "");
@@ -2169,12 +2170,12 @@ var LINK_CLASS = `text-info-default cursor-pointer ${WEB_LINK_CLASSES}`;
2169
2170
  var OPENABLE = /^(https?:\/\/|mailto:)/i;
2170
2171
  var LINK_MARK_ATTRIBUTES = { class: LINK_CLASS, "data-link-mark": "", target: "_blank", rel: "noopener noreferrer nofollow" };
2171
2172
  var LINK_TARGET = /\]\(([^\s)]+)\)$/;
2172
- var BareLinks = Extension9.create({
2173
+ var BareLinks = Extension8.create({
2173
2174
  name: "bareLinks",
2174
2175
  addProseMirrorPlugins() {
2175
2176
  return [
2176
- new Plugin7({
2177
- key: new PluginKey8("bareLinks"),
2177
+ new Plugin6({
2178
+ key: new PluginKey7("bareLinks"),
2178
2179
  props: {
2179
2180
  // The one way a click opens an address: a bare one's decoration, or, while editing, a link on words (read only,
2180
2181
  // the link is a plain anchor and opens itself). Only its own attributes are read — never a chip's — and only an
@@ -2210,8 +2211,8 @@ var BareLinks = Extension9.create({
2210
2211
  });
2211
2212
 
2212
2213
  // src/PastedImages.ts
2213
- import { Extension as Extension10 } from "@tiptap/core";
2214
- import { Plugin as Plugin8, PluginKey as PluginKey9 } from "@tiptap/pm/state";
2214
+ import { Extension as Extension9 } from "@tiptap/core";
2215
+ import { Plugin as Plugin7, PluginKey as PluginKey8 } from "@tiptap/pm/state";
2215
2216
  var IMAGE_EXTENSIONS = {
2216
2217
  "image/png": "png",
2217
2218
  "image/jpeg": "jpg",
@@ -2246,7 +2247,7 @@ function pastedImages(source, at = /* @__PURE__ */ new Date()) {
2246
2247
  (file) => hasUsableName(file.name) ? file : new File([file], pastedImageName(file.type, at, generated++), { type: file.type, lastModified: file.lastModified })
2247
2248
  );
2248
2249
  }
2249
- var PastedImages = Extension10.create({
2250
+ var PastedImages = Extension9.create({
2250
2251
  name: "pastedImages",
2251
2252
  addOptions() {
2252
2253
  return { onImages: () => false };
@@ -2254,8 +2255,8 @@ var PastedImages = Extension10.create({
2254
2255
  addProseMirrorPlugins() {
2255
2256
  const options = this.options;
2256
2257
  return [
2257
- new Plugin8({
2258
- key: new PluginKey9("pastedImages"),
2258
+ new Plugin7({
2259
+ key: new PluginKey8("pastedImages"),
2259
2260
  props: {
2260
2261
  handlePaste: (_view, event) => {
2261
2262
  const files = pastedImages(event.clipboardData);
@@ -2278,7 +2279,7 @@ var commentBoxRows = {
2278
2279
  urgent: { key: "insert-urgent", row: { label: "Urgent", shortcut: "!@" }, keywords: ["!@", "Urgent mention"], run: typeTrigger("!@") },
2279
2280
  reference: { key: "insert-reference", row: { label: "Reference", shortcut: "[" }, keywords: ["[", "Reference"], run: typeTrigger("[") }
2280
2281
  };
2281
- var BoxKeys = Extension11.create({
2282
+ var BoxKeys = Extension10.create({
2282
2283
  name: "commentBoxKeys",
2283
2284
  addOptions() {
2284
2285
  return { onEscape: () => false };
@@ -2294,10 +2295,29 @@ var BoxKeys = Extension11.create({
2294
2295
  var stillNamed = (removed, names) => [...removed].every((value) => names.includes(value)) ? removed : new Set([...removed].filter((value) => names.includes(value)));
2295
2296
  var SQUARE = /* @__PURE__ */ jsx7(IconSquareRounded, { size: 16, stroke: 1.5, className: "text-text-secondary" });
2296
2297
  var SMALL_SQUARE = /* @__PURE__ */ jsx7(IconSquareRounded, { size: 14, stroke: 1.5 });
2298
+ function kindIconOf(uri, size) {
2299
+ const kind = uri ? linkedKindOfReference(uri) : void 0;
2300
+ return kind ? /* @__PURE__ */ jsx7(LinkedIcon, { kind, size }) : void 0;
2301
+ }
2302
+ var PastedAddresses = Extension10.create({
2303
+ name: "pastedAddresses",
2304
+ addPasteRules() {
2305
+ const type = this.editor.schema.nodes.reference;
2306
+ if (!type) return [];
2307
+ return [
2308
+ nodePasteRule({
2309
+ find: /nostr:(?:naddr1|nevent1|note1)[023456789acdefghjklmnpqrstuvwxyz]+/g,
2310
+ type,
2311
+ getAttributes: (match) => ({ uri: match[0] })
2312
+ })
2313
+ ];
2314
+ }
2315
+ });
2297
2316
  var NO_EXTENSIONS = [];
2298
2317
  var sameApp = (a, b) => a.referenceView === b.referenceView && a.extensions.length === b.extensions.length && a.extensions.every((one, i) => one === b.extensions[i]);
2299
2318
  function boxExtensions(hold, app) {
2300
- const iconFor = (uri) => hold.current.referenceIcon?.(uri);
2319
+ const own = (uri, size) => hold.current.referenceIcon ? hold.current.referenceIcon(uri) : kindIconOf(uri, size);
2320
+ const iconFor = (uri) => own(uri, 16);
2301
2321
  return [
2302
2322
  // A link drawn as one, as in a document: it read as plain words in the box before (Katerina, 29 Oct).
2303
2323
  BoxKit.configure({ link: { openOnClick: false, HTMLAttributes: LINK_MARK_ATTRIBUTES } }),
@@ -2325,7 +2345,8 @@ function boxExtensions(hold, app) {
2325
2345
  return { ...parent, suggestion: { ...parent.suggestion, allow: () => !hold.current.edit } };
2326
2346
  }
2327
2347
  }).configure({ people: () => hold.current.people }),
2328
- CaptionedReference.configure({ icon: SMALL_SQUARE, iconFor }),
2348
+ // A `[` pick draws as the app draws every other link in the box (Katerina, 30 Oct: one chip look in every box).
2349
+ CaptionedReference.configure({ icon: SMALL_SQUARE, iconFor: (uri) => own(uri, 14), view: app.referenceView }),
2329
2350
  ReferenceTrigger.configure({
2330
2351
  items: () => [],
2331
2352
  sections: (query) => hold.current.references?.(query) ?? [],
@@ -2338,6 +2359,7 @@ function boxExtensions(hold, app) {
2338
2359
  }),
2339
2360
  SlashCommands.configure({ sections: hold.sections }),
2340
2361
  ReferenceNode.configure({ view: app.referenceView }),
2362
+ ...app.referenceView ? [PastedAddresses] : [],
2341
2363
  PastedImages.configure({ onImages: (files) => hold.current.attach(files) }),
2342
2364
  ...app.extensions
2343
2365
  ];
@@ -2368,7 +2390,7 @@ function keepCommentBoxWarm(app = {}) {
2368
2390
  function useBoxEditor(app, content, options) {
2369
2391
  const args = useRef3({ app, content, options });
2370
2392
  args.current = { app, content, options };
2371
- const [held, setHeld] = useState4(() => {
2393
+ const [held, setHeld] = useState3(() => {
2372
2394
  const fits = !content && spare && !spare.editor.isDestroyed && warmApp && sameApp(warmApp, app);
2373
2395
  const taken = fits ? spare : null;
2374
2396
  if (taken) {
@@ -2434,11 +2456,11 @@ function CommentBox({
2434
2456
  onEditor,
2435
2457
  className
2436
2458
  }) {
2437
- const [files, setFiles] = useState4(edit?.files ?? []);
2438
- const [sending, setSending] = useState4(false);
2439
- const [refused, setRefused] = useState4(edit?.refused ?? null);
2440
- const [reading, setReading] = useState4(void 0);
2441
- const [removed, setRemoved] = useState4(() => /* @__PURE__ */ new Set());
2459
+ const [files, setFiles] = useState3(edit?.files ?? []);
2460
+ const [sending, setSending] = useState3(false);
2461
+ const [refused, setRefused] = useState3(edit?.refused ?? null);
2462
+ const [reading, setReading] = useState3(void 0);
2463
+ const [removed, setRemoved] = useState3(() => /* @__PURE__ */ new Set());
2442
2464
  const picker = useRef3(null);
2443
2465
  const root = useRef3(null);
2444
2466
  const latest = useRef3({ edit, upload, draft, under });
@@ -2468,7 +2490,7 @@ function CommentBox({
2468
2490
  });
2469
2491
  hold.current = { edit, people, references, referencesChanged, referenceIcon, attach: attachFiles };
2470
2492
  hold.sections.splice(0, hold.sections.length, formatSection(code), ...rows.length > 0 ? [{ label: "Insert", commands: rows }] : []);
2471
- const [marking, setMarking] = useState4(false);
2493
+ const [marking, setMarking] = useState3(false);
2472
2494
  const markedBy = useRef3(marked);
2473
2495
  markedBy.current = marked;
2474
2496
  useLayoutEffect(() => {
@@ -2709,8 +2731,8 @@ function CommentBox({
2709
2731
  }
2710
2732
 
2711
2733
  // src/InlineText.tsx
2712
- import { useCallback as useCallback5, useEffect as useEffect5, useImperativeHandle as useImperativeHandle2, useRef as useRef4, useState as useState5 } from "react";
2713
- import { Extension as Extension12, Node as Node3 } from "@tiptap/core";
2734
+ import { useCallback as useCallback5, useEffect as useEffect5, useImperativeHandle as useImperativeHandle2, useRef as useRef4, useState as useState4 } from "react";
2735
+ import { Extension as Extension11, Node as Node3 } from "@tiptap/core";
2714
2736
  import { history, redo, undo } from "@tiptap/pm/history";
2715
2737
  import { EditorContent as EditorContent2, useEditor } from "@tiptap/react";
2716
2738
  import { cn as cn3 } from "@estiva-app/ui";
@@ -2730,7 +2752,7 @@ var Paragraph = Node3.create({
2730
2752
  renderHTML: () => ["p", 0]
2731
2753
  });
2732
2754
  var Text = Node3.create({ name: "text" });
2733
- var Undo = Extension12.create({
2755
+ var Undo = Extension11.create({
2734
2756
  name: "inlineTextUndo",
2735
2757
  addProseMirrorPlugins: () => [history()],
2736
2758
  addKeyboardShortcuts() {
@@ -2742,7 +2764,7 @@ var doc = (text) => ({ type: "doc", content: [{ type: "paragraph", content: text
2742
2764
  var oneLine = (text) => text.replace(/\s+/g, " ").trim();
2743
2765
  function InlineText({ value, placeholder, label, onCommit, onText, onEnter, variant = "title", clearable = false, readOnly = false, className, ref }) {
2744
2766
  const saved = useRef4(value);
2745
- const [empty, setEmpty] = useState5(!value);
2767
+ const [empty, setEmpty] = useState4(!value);
2746
2768
  const latest = useRef4({ onEnter, onText, onCommit, clearable, value });
2747
2769
  latest.current = { onEnter, onText, onCommit, clearable, value };
2748
2770
  const pending = useRef4(null);
@@ -2830,10 +2852,10 @@ function InlineText({ value, placeholder, label, onCommit, onText, onEnter, vari
2830
2852
  }
2831
2853
 
2832
2854
  // src/CommentHighlights.ts
2833
- import { Extension as Extension13 } from "@tiptap/core";
2834
- import { Plugin as Plugin9, PluginKey as PluginKey10 } from "@tiptap/pm/state";
2855
+ import { Extension as Extension12 } from "@tiptap/core";
2856
+ import { Plugin as Plugin8, PluginKey as PluginKey9 } from "@tiptap/pm/state";
2835
2857
  import { Decoration as Decoration5, DecorationSet as DecorationSet5 } from "@tiptap/pm/view";
2836
- var commentHighlightsKey = new PluginKey10("commentHighlights");
2858
+ var commentHighlightsKey = new PluginKey9("commentHighlights");
2837
2859
  var COMMENT_HIGHLIGHT_CLASSES = {
2838
2860
  rest: "cursor-pointer rounded-sm bg-warning-muted",
2839
2861
  active: "cursor-pointer rounded-sm bg-warning-muted underline decoration-warning-default decoration-2 underline-offset-4"
@@ -2952,7 +2974,7 @@ function placeOf2(doc2, anchor, places = placesIn(doc2)) {
2952
2974
  if (endAt === -1 || quote.end === "") return reworded;
2953
2975
  return { state: "resolved", from: a.starts[startAt], to: b.ends[endAt + quote.end.length - 1], words: true };
2954
2976
  }
2955
- var CommentHighlights = Extension13.create({
2977
+ var CommentHighlights = Extension12.create({
2956
2978
  name: "commentHighlights",
2957
2979
  addOptions() {
2958
2980
  return { onSelect: null };
@@ -2961,7 +2983,7 @@ var CommentHighlights = Extension13.create({
2961
2983
  const options = this.options;
2962
2984
  const editor = this.editor;
2963
2985
  return [
2964
- new Plugin9({
2986
+ new Plugin8({
2965
2987
  key: commentHighlightsKey,
2966
2988
  state: {
2967
2989
  init: () => ({ anchors: [], active: null }),
@@ -3112,9 +3134,9 @@ function anchorOfSelection(editor) {
3112
3134
  }
3113
3135
 
3114
3136
  // src/PastedMarkdown.ts
3115
- import { Extension as Extension14 } from "@tiptap/core";
3137
+ import { Extension as Extension13 } from "@tiptap/core";
3116
3138
  import { Slice } from "@tiptap/pm/model";
3117
- import { Plugin as Plugin10, PluginKey as PluginKey11 } from "@tiptap/pm/state";
3139
+ import { Plugin as Plugin9, PluginKey as PluginKey10 } from "@tiptap/pm/state";
3118
3140
  function inTableCell($context) {
3119
3141
  for (let depth = $context.depth; depth > 0; depth--) {
3120
3142
  const role = $context.node(depth).type.spec.tableRole;
@@ -3123,7 +3145,7 @@ function inTableCell($context) {
3123
3145
  return false;
3124
3146
  }
3125
3147
  var hasTable = (blocks) => blocks.some((block) => block.type === "table" || hasTable(block.content ?? []));
3126
- var PastedMarkdown = Extension14.create({
3148
+ var PastedMarkdown = Extension13.create({
3127
3149
  name: "pastedMarkdown",
3128
3150
  addOptions() {
3129
3151
  return { read: () => void 0 };
@@ -3131,8 +3153,8 @@ var PastedMarkdown = Extension14.create({
3131
3153
  addProseMirrorPlugins() {
3132
3154
  const options = this.options;
3133
3155
  return [
3134
- new Plugin10({
3135
- key: new PluginKey11("pastedMarkdown"),
3156
+ new Plugin9({
3157
+ key: new PluginKey10("pastedMarkdown"),
3136
3158
  props: {
3137
3159
  // Reached only for a text paste outside code; `plain` is the Shift paste.
3138
3160
  clipboardTextParser: (text, $context, plain, view) => {
@@ -3387,7 +3409,7 @@ function turnIntoRows(node, editor) {
3387
3409
  }
3388
3410
 
3389
3411
  // src/EditorTableControls.tsx
3390
- import { useCallback as useCallback6, useEffect as useEffect6, useRef as useRef5, useState as useState6 } from "react";
3412
+ import { useCallback as useCallback6, useEffect as useEffect6, useRef as useRef5, useState as useState5 } from "react";
3391
3413
  import { TextSelection as TextSelection3 } from "@tiptap/pm/state";
3392
3414
  import { addColumnAfter, addColumnBefore, addRowAfter, addRowBefore, deleteColumn, deleteRow, deleteTable, toggleHeader } from "@tiptap/pm/tables";
3393
3415
  import { IconCheck as IconCheck2, IconColumnInsertLeft, IconColumnInsertRight, IconGripHorizontal, IconGripVertical, IconPlus, IconRowInsertBottom, IconRowInsertTop, IconTableRow, IconTrash as IconTrash2 } from "@tabler/icons-react";
@@ -3446,8 +3468,8 @@ var keepFocus = (e) => e.preventDefault();
3446
3468
  var HANDLE_BOX = cn4(FLOATING_SURFACE_CLASSES, "shadow-none");
3447
3469
  function EditorTableControls({ editor, children, className }) {
3448
3470
  const frame = useRef5(null);
3449
- const [hovered, setHovered] = useState6(null);
3450
- const [menu, setMenu] = useState6(null);
3471
+ const [hovered, setHovered] = useState5(null);
3472
+ const [menu, setMenu] = useState5(null);
3451
3473
  const editable = !!editor && editor.isEditable;
3452
3474
  const follow = useCallback6(
3453
3475
  (target) => {
@@ -3546,7 +3568,7 @@ function EditorTableControls({ editor, children, className }) {
3546
3568
  }
3547
3569
 
3548
3570
  // src/DocumentEditor.tsx
3549
- import { useCallback as useCallback7, useEffect as useEffect7, useRef as useRef6, useState as useState7 } from "react";
3571
+ import { useCallback as useCallback7, useEffect as useEffect7, useRef as useRef6, useState as useState6 } from "react";
3550
3572
  import { TextSelection as TextSelection4 } from "@tiptap/pm/state";
3551
3573
  import { EditorContent as EditorContent3, useEditor as useEditor2, useEditorState as useEditorState2 } from "@tiptap/react";
3552
3574
  import { TableKit } from "@tiptap/extension-table";
@@ -3556,8 +3578,8 @@ import { FieldLine as FieldLine2 } from "@estiva-app/ui";
3556
3578
  import { FilePicker as FilePicker2 } from "@estiva-app/ui";
3557
3579
  import { richTextClassName as richTextClassName2 } from "@estiva-app/ui";
3558
3580
  import { Fragment as Fragment6, jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
3559
- function heldDocument(hold, key5) {
3560
- const text = hold && key5 ? hold.text(key5) : void 0;
3581
+ function heldDocument(hold, key4) {
3582
+ const text = hold && key4 ? hold.text(key4) : void 0;
3561
3583
  if (!text) return null;
3562
3584
  try {
3563
3585
  const doc2 = JSON.parse(text);
@@ -3592,21 +3614,21 @@ function DocumentEditor({
3592
3614
  onEditor,
3593
3615
  extensions = []
3594
3616
  }) {
3595
- const [failed, setFailed] = useState7(false);
3596
- const [focused, setFocused] = useState7(false);
3597
- const [uploadError, setUploadError] = useState7(null);
3617
+ const [failed, setFailed] = useState6(false);
3618
+ const [focused, setFocused] = useState6(false);
3619
+ const [uploadError, setUploadError] = useState6(null);
3598
3620
  const latest = useRef6({ value, format, codec, hold, references, mentions, upload, readMarkdown, onLeftUnsaved });
3599
3621
  useEffect7(() => {
3600
3622
  latest.current = { value, format, codec, hold, references, mentions, upload, readMarkdown, onLeftUnsaved };
3601
3623
  });
3602
3624
  const ended = () => latest.current.hold?.ended() ?? false;
3603
- const [base, setBase] = useState7(value);
3625
+ const [base, setBase] = useState6(value);
3604
3626
  const saved = useRef6(value);
3605
- const [superseded, setSuperseded] = useState7(null);
3627
+ const [superseded, setSuperseded] = useState6(null);
3606
3628
  const own = useRef6(/* @__PURE__ */ new Set());
3607
- const [saving, setSaving] = useState7(false);
3629
+ const [saving, setSaving] = useState6(false);
3608
3630
  const committing = useRef6(false);
3609
- const [held] = useState7(() => {
3631
+ const [held] = useState6(() => {
3610
3632
  const doc2 = heldDocument(hold, holdKey);
3611
3633
  try {
3612
3634
  return doc2 && codec.write(doc2).value !== value ? doc2 : null;
@@ -3614,7 +3636,7 @@ function DocumentEditor({
3614
3636
  return null;
3615
3637
  }
3616
3638
  });
3617
- const [restored, setRestored] = useState7(held !== null);
3639
+ const [restored, setRestored] = useState6(held !== null);
3618
3640
  const typed = useRef6(held);
3619
3641
  const again = useRef6(false);
3620
3642
  const left = useRef6(false);
@@ -3726,7 +3748,8 @@ function DocumentEditor({
3726
3748
  BlockId,
3727
3749
  Checklist,
3728
3750
  Callout,
3729
- ReferenceNode.configure({ view: referenceView ?? null }),
3751
+ // A link is being edited only while the caret is on its line: anywhere else on the page it previews on hover.
3752
+ ReferenceNode.configure({ view: referenceView ?? null, editingLine: true }),
3730
3753
  // A link's chip in a sentence, its row alone on its line, its card in the row's place (SPEC §13.3).
3731
3754
  LinkPlaces,
3732
3755
  // A click on a link offers Open, and alone on its line Show as Row or Card.
@@ -3908,7 +3931,6 @@ export {
3908
3931
  PastedMarkdown,
3909
3932
  PersonMention,
3910
3933
  PersonReference,
3911
- ReferenceCards,
3912
3934
  ReferenceMenu,
3913
3935
  ReferenceMenuView,
3914
3936
  ReferenceNode,
@@ -3964,7 +3986,6 @@ export {
3964
3986
  turnListInto,
3965
3987
  turnQuoteInto,
3966
3988
  typeTrigger,
3967
- urgentPubkeys,
3968
- useReferenceCards
3989
+ urgentPubkeys
3969
3990
  };
3970
3991
  //# sourceMappingURL=editor.js.map