quoin-editor 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (209) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/dist/ai.cjs +135 -94
  3. package/dist/ai.cjs.map +1 -1
  4. package/dist/ai.d.cts +1 -1
  5. package/dist/ai.d.ts +1 -1
  6. package/dist/ai.js +62 -21
  7. package/dist/ai.js.map +1 -1
  8. package/dist/catalogue.cjs +25 -25
  9. package/dist/catalogue.d.cts +6 -6
  10. package/dist/catalogue.d.ts +6 -6
  11. package/dist/catalogue.js +17 -17
  12. package/dist/{chunk-MQ2XQ4MX.js → chunk-26Q4LSIU.js} +6 -6
  13. package/dist/chunk-26Q4LSIU.js.map +1 -0
  14. package/dist/{chunk-AEJXZBVR.cjs → chunk-56C7GCKO.cjs} +110 -103
  15. package/dist/chunk-56C7GCKO.cjs.map +1 -0
  16. package/dist/{chunk-GTTPVJSD.cjs → chunk-5M4QG3ZC.cjs} +262 -245
  17. package/dist/chunk-5M4QG3ZC.cjs.map +1 -0
  18. package/dist/{chunk-2VDK27IF.cjs → chunk-5R3ISX4A.cjs} +312 -335
  19. package/dist/chunk-5R3ISX4A.cjs.map +1 -0
  20. package/dist/{chunk-LCQSG4M6.js → chunk-62WKUAQY.js} +18 -18
  21. package/dist/{chunk-LCQSG4M6.js.map → chunk-62WKUAQY.js.map} +1 -1
  22. package/dist/{chunk-NOKWNK2O.js → chunk-6LMS5J3Y.js} +3 -2
  23. package/dist/{chunk-HELJTLNC.cjs → chunk-6PKVJZQV.cjs} +12 -12
  24. package/dist/chunk-6PKVJZQV.cjs.map +1 -0
  25. package/dist/chunk-6YSGUAVW.js +376 -0
  26. package/dist/chunk-6YSGUAVW.js.map +1 -0
  27. package/dist/{chunk-CDELOHDY.cjs → chunk-75C6PX2L.cjs} +23 -23
  28. package/dist/{chunk-CDELOHDY.cjs.map → chunk-75C6PX2L.cjs.map} +1 -1
  29. package/dist/{chunk-T7SW6OWV.js → chunk-A4IJSJKL.js} +5 -5
  30. package/dist/{chunk-ND5XJVK2.cjs → chunk-BTBHHBVR.cjs} +19 -19
  31. package/dist/{chunk-ND5XJVK2.cjs.map → chunk-BTBHHBVR.cjs.map} +1 -1
  32. package/dist/{chunk-WXMYDXPN.cjs → chunk-CLTHD5GO.cjs} +4 -3
  33. package/dist/chunk-CLTHD5GO.cjs.map +1 -0
  34. package/dist/{chunk-OMOBMXD5.cjs → chunk-EH5KXQXY.cjs} +7 -2
  35. package/dist/chunk-EH5KXQXY.cjs.map +1 -0
  36. package/dist/{chunk-WQHV3MRE.cjs → chunk-ESMAW4NK.cjs} +12 -12
  37. package/dist/{chunk-WQHV3MRE.cjs.map → chunk-ESMAW4NK.cjs.map} +1 -1
  38. package/dist/{chunk-SLVDAHHK.cjs → chunk-EYFCOV3T.cjs} +5 -5
  39. package/dist/{chunk-SLVDAHHK.cjs.map → chunk-EYFCOV3T.cjs.map} +1 -1
  40. package/dist/{chunk-5DNCCN6X.cjs → chunk-F5V3IEEE.cjs} +27 -27
  41. package/dist/{chunk-5DNCCN6X.cjs.map → chunk-F5V3IEEE.cjs.map} +1 -1
  42. package/dist/{chunk-PMWCQSQX.js → chunk-GPIDU3GN.js} +5 -5
  43. package/dist/{chunk-PZ4GT5JO.cjs → chunk-HOIDJEVI.cjs} +316 -300
  44. package/dist/chunk-HOIDJEVI.cjs.map +1 -0
  45. package/dist/{chunk-RDG4VI6E.cjs → chunk-JJ3RASQS.cjs} +90 -90
  46. package/dist/{chunk-RDG4VI6E.cjs.map → chunk-JJ3RASQS.cjs.map} +1 -1
  47. package/dist/{chunk-ZGZEJCRV.js → chunk-LE3F7WIP.js} +23 -46
  48. package/dist/chunk-LE3F7WIP.js.map +1 -0
  49. package/dist/chunk-LE5XMIFJ.cjs +14 -0
  50. package/dist/chunk-LE5XMIFJ.cjs.map +1 -0
  51. package/dist/{chunk-POBM7MGR.js → chunk-LMAEPFTX.js} +2 -2
  52. package/dist/{chunk-ZHOSSWUM.js → chunk-LV6EYPJO.js} +4 -3
  53. package/dist/chunk-LV6EYPJO.js.map +1 -0
  54. package/dist/chunk-MLRAVUFG.cjs +376 -0
  55. package/dist/chunk-MLRAVUFG.cjs.map +1 -0
  56. package/dist/chunk-MQUCCSWG.js +14 -0
  57. package/dist/chunk-MQUCCSWG.js.map +1 -0
  58. package/dist/{chunk-XEBWC7ZL.js → chunk-O4Z2WMFF.js} +7 -2
  59. package/dist/chunk-O4Z2WMFF.js.map +1 -0
  60. package/dist/{chunk-K574XHMM.js → chunk-OCCKQHCY.js} +2 -2
  61. package/dist/{chunk-SG37UBDO.js → chunk-PGSS4IOS.js} +7 -7
  62. package/dist/{chunk-RUDWMKYX.js → chunk-PIWRSX7U.js} +8 -8
  63. package/dist/{chunk-PWUEPDA3.cjs → chunk-PX6LZMH4.cjs} +44 -44
  64. package/dist/{chunk-PWUEPDA3.cjs.map → chunk-PX6LZMH4.cjs.map} +1 -1
  65. package/dist/{chunk-JDPTZUBW.js → chunk-QXG3HWDS.js} +4 -4
  66. package/dist/{chunk-NNDYYEW5.js → chunk-RQW3P3GH.js} +5 -5
  67. package/dist/{chunk-ZS2WA357.js → chunk-SSIRYUCK.js} +144 -127
  68. package/dist/chunk-SSIRYUCK.js.map +1 -0
  69. package/dist/{chunk-47MLKSI2.js → chunk-UBNG5YCG.js} +6 -6
  70. package/dist/{chunk-KXOBZGQO.js → chunk-UCXLRRWY.js} +21 -14
  71. package/dist/chunk-UCXLRRWY.js.map +1 -0
  72. package/dist/{chunk-EL2OEJQC.cjs → chunk-UDAVVEFC.cjs} +56 -56
  73. package/dist/{chunk-EL2OEJQC.cjs.map → chunk-UDAVVEFC.cjs.map} +1 -1
  74. package/dist/{chunk-HJIQT3S5.js → chunk-UPSLDTLT.js} +100 -84
  75. package/dist/chunk-UPSLDTLT.js.map +1 -0
  76. package/dist/{chunk-GLLXHMH2.cjs → chunk-UWNZG2SD.cjs} +3 -3
  77. package/dist/{chunk-GLLXHMH2.cjs.map → chunk-UWNZG2SD.cjs.map} +1 -1
  78. package/dist/{chunk-HZSSEYJS.cjs → chunk-V3KLMSRO.cjs} +30 -30
  79. package/dist/{chunk-HZSSEYJS.cjs.map → chunk-V3KLMSRO.cjs.map} +1 -1
  80. package/dist/{chunk-ZC24WB7Y.cjs → chunk-VACTAZWS.cjs} +14 -14
  81. package/dist/{chunk-ZC24WB7Y.cjs.map → chunk-VACTAZWS.cjs.map} +1 -1
  82. package/dist/{chunk-KAVU6T6J.js → chunk-WMN6566P.js} +5 -5
  83. package/dist/{chunk-2QCRZ7OL.cjs → chunk-XX5FTPJR.cjs} +12 -11
  84. package/dist/{chunk-2QCRZ7OL.cjs.map → chunk-XX5FTPJR.cjs.map} +1 -1
  85. package/dist/comments.cjs +113 -98
  86. package/dist/comments.cjs.map +1 -1
  87. package/dist/comments.d.cts +6 -1
  88. package/dist/comments.d.ts +6 -1
  89. package/dist/comments.js +32 -17
  90. package/dist/comments.js.map +1 -1
  91. package/dist/diff.cjs +43 -40
  92. package/dist/diff.cjs.map +1 -1
  93. package/dist/diff.js +16 -13
  94. package/dist/diff.js.map +1 -1
  95. package/dist/docx.cjs +60 -40
  96. package/dist/docx.cjs.map +1 -1
  97. package/dist/docx.d.cts +6 -0
  98. package/dist/docx.d.ts +6 -0
  99. package/dist/docx.js +32 -12
  100. package/dist/docx.js.map +1 -1
  101. package/dist/embed.cjs +9 -9
  102. package/dist/embed.d.cts +1 -1
  103. package/dist/embed.d.ts +1 -1
  104. package/dist/embed.js +8 -8
  105. package/dist/{emoji-extension-DpQ43HjE.d.ts → emoji-extension-CmPlRssm.d.ts} +1 -1
  106. package/dist/{emoji-extension-C12gDPm6.d.cts → emoji-extension-zJ6F7hW8.d.cts} +1 -1
  107. package/dist/emoji.cjs +8 -8
  108. package/dist/emoji.d.cts +3 -3
  109. package/dist/emoji.d.ts +3 -3
  110. package/dist/emoji.js +7 -7
  111. package/dist/engine.cjs +4 -4
  112. package/dist/engine.d.cts +2 -2
  113. package/dist/engine.d.ts +2 -2
  114. package/dist/engine.js +3 -3
  115. package/dist/{find-extension-_sbZEt3R.d.cts → find-extension-BcRyE9K4.d.cts} +1 -1
  116. package/dist/{find-extension-DKqLLSuP.d.ts → find-extension-CmFehyul.d.ts} +1 -1
  117. package/dist/find.cjs +8 -8
  118. package/dist/find.d.cts +2 -2
  119. package/dist/find.d.ts +2 -2
  120. package/dist/find.js +7 -7
  121. package/dist/headless.cjs +5 -5
  122. package/dist/headless.d.cts +4 -4
  123. package/dist/headless.d.ts +4 -4
  124. package/dist/headless.js +4 -4
  125. package/dist/{index-CgD72kHB.d.cts → index-CFPmCee4.d.cts} +5 -2
  126. package/dist/{index-DNYbTK3w.d.ts → index-DiCGV60d.d.ts} +5 -2
  127. package/dist/index.cjs +7 -7
  128. package/dist/index.d.cts +4 -4
  129. package/dist/index.d.ts +4 -4
  130. package/dist/index.js +6 -6
  131. package/dist/math.cjs +10 -10
  132. package/dist/math.d.cts +1 -1
  133. package/dist/math.d.ts +1 -1
  134. package/dist/math.js +9 -9
  135. package/dist/mention.cjs +10 -10
  136. package/dist/mention.d.cts +1 -1
  137. package/dist/mention.d.ts +1 -1
  138. package/dist/mention.js +9 -9
  139. package/dist/presence.cjs +96 -99
  140. package/dist/presence.cjs.map +1 -1
  141. package/dist/presence.d.cts +2 -2
  142. package/dist/presence.d.ts +2 -2
  143. package/dist/presence.js +64 -67
  144. package/dist/presence.js.map +1 -1
  145. package/dist/{stats-extension-Bly88uio.d.ts → stats-extension-DisOEbbI.d.ts} +1 -1
  146. package/dist/{stats-extension-CJPijvUb.d.cts → stats-extension-Dt1lgP3m.d.cts} +1 -1
  147. package/dist/stats.cjs +9 -9
  148. package/dist/stats.d.cts +3 -3
  149. package/dist/stats.d.ts +3 -3
  150. package/dist/stats.js +8 -8
  151. package/dist/styles.css +1 -1
  152. package/dist/{table-extension-Dzf4k6hI.d.ts → table-extension-BTMJnT7J.d.ts} +1 -1
  153. package/dist/{table-extension-BTLxFy2S.d.cts → table-extension-DxZz3jqp.d.cts} +1 -1
  154. package/dist/table.cjs +8 -8
  155. package/dist/table.d.cts +2 -2
  156. package/dist/table.d.ts +2 -2
  157. package/dist/table.js +7 -7
  158. package/dist/{toc-extension-DWm5alVj.d.ts → toc-extension-CR9U-l6j.d.ts} +1 -1
  159. package/dist/{toc-extension-B3-s6h2x.d.cts → toc-extension-DGHywOBv.d.cts} +1 -1
  160. package/dist/toc.cjs +8 -8
  161. package/dist/toc.d.cts +2 -2
  162. package/dist/toc.d.ts +2 -2
  163. package/dist/toc.js +7 -7
  164. package/dist/{types-a1CRBlEh.d.ts → types-C6_QkXzy.d.ts} +1 -9
  165. package/dist/{types-Cz7XJLaK.d.cts → types-CJ7Gq3GX.d.cts} +1 -9
  166. package/dist/{view-controller-DSHw0ltQ.d.cts → view-controller-BD1KwYfE.d.cts} +6 -19
  167. package/dist/{view-controller-UbpzblGl.d.ts → view-controller-y4cb60ue.d.ts} +6 -19
  168. package/dist/view.cjs +6 -6
  169. package/dist/view.js +3 -3
  170. package/dist/yjs.cjs +234 -396
  171. package/dist/yjs.cjs.map +1 -1
  172. package/dist/yjs.d.cts +3 -3
  173. package/dist/yjs.d.ts +3 -3
  174. package/dist/yjs.js +126 -288
  175. package/dist/yjs.js.map +1 -1
  176. package/package.json +1 -1
  177. package/dist/chunk-2VDK27IF.cjs.map +0 -1
  178. package/dist/chunk-AEJXZBVR.cjs.map +0 -1
  179. package/dist/chunk-E75EHRPA.cjs +0 -175
  180. package/dist/chunk-E75EHRPA.cjs.map +0 -1
  181. package/dist/chunk-GTTPVJSD.cjs.map +0 -1
  182. package/dist/chunk-HELJTLNC.cjs.map +0 -1
  183. package/dist/chunk-HJIQT3S5.js.map +0 -1
  184. package/dist/chunk-JEIFJHEI.js +0 -14
  185. package/dist/chunk-JEIFJHEI.js.map +0 -1
  186. package/dist/chunk-KXOBZGQO.js.map +0 -1
  187. package/dist/chunk-MQ2XQ4MX.js.map +0 -1
  188. package/dist/chunk-OMOBMXD5.cjs.map +0 -1
  189. package/dist/chunk-PZ4GT5JO.cjs.map +0 -1
  190. package/dist/chunk-QAW5NH6S.cjs +0 -14
  191. package/dist/chunk-QAW5NH6S.cjs.map +0 -1
  192. package/dist/chunk-TC4DARU2.js +0 -175
  193. package/dist/chunk-TC4DARU2.js.map +0 -1
  194. package/dist/chunk-WXMYDXPN.cjs.map +0 -1
  195. package/dist/chunk-XEBWC7ZL.js.map +0 -1
  196. package/dist/chunk-ZGZEJCRV.js.map +0 -1
  197. package/dist/chunk-ZHOSSWUM.js.map +0 -1
  198. package/dist/chunk-ZS2WA357.js.map +0 -1
  199. /package/dist/{chunk-NOKWNK2O.js.map → chunk-6LMS5J3Y.js.map} +0 -0
  200. /package/dist/{chunk-T7SW6OWV.js.map → chunk-A4IJSJKL.js.map} +0 -0
  201. /package/dist/{chunk-PMWCQSQX.js.map → chunk-GPIDU3GN.js.map} +0 -0
  202. /package/dist/{chunk-POBM7MGR.js.map → chunk-LMAEPFTX.js.map} +0 -0
  203. /package/dist/{chunk-K574XHMM.js.map → chunk-OCCKQHCY.js.map} +0 -0
  204. /package/dist/{chunk-SG37UBDO.js.map → chunk-PGSS4IOS.js.map} +0 -0
  205. /package/dist/{chunk-RUDWMKYX.js.map → chunk-PIWRSX7U.js.map} +0 -0
  206. /package/dist/{chunk-JDPTZUBW.js.map → chunk-QXG3HWDS.js.map} +0 -0
  207. /package/dist/{chunk-NNDYYEW5.js.map → chunk-RQW3P3GH.js.map} +0 -0
  208. /package/dist/{chunk-47MLKSI2.js.map → chunk-UBNG5YCG.js.map} +0 -0
  209. /package/dist/{chunk-KAVU6T6J.js.map → chunk-WMN6566P.js.map} +0 -0
@@ -41,7 +41,7 @@ import {
41
41
  toggleTask,
42
42
  undo,
43
43
  undoInputRule
44
- } from "./chunk-HJIQT3S5.js";
44
+ } from "./chunk-UPSLDTLT.js";
45
45
  import {
46
46
  alignOrUndefined,
47
47
  blockById,
@@ -61,7 +61,7 @@ import {
61
61
  sanitizeHref,
62
62
  sliceInline,
63
63
  writtenAttrs
64
- } from "./chunk-LCQSG4M6.js";
64
+ } from "./chunk-62WKUAQY.js";
65
65
 
66
66
  // src/view/react/use-editor-state.ts
67
67
  import { useCallback, useRef, useSyncExternalStore } from "react";
@@ -610,6 +610,15 @@ function writeSelection(registry, selection, domSelection, blockElement) {
610
610
  return true;
611
611
  }
612
612
 
613
+ // src/view/dom/listen.ts
614
+ function listen(target, handlers, options) {
615
+ const entries = Object.entries(handlers);
616
+ for (const [type, handler] of entries) target.addEventListener(type, handler, options);
617
+ return () => {
618
+ for (const [type, handler] of entries) target.removeEventListener(type, handler, options);
619
+ };
620
+ }
621
+
613
622
  // src/view/navigation/node-entry.ts
614
623
  var NODE_ENTRY = "data-quoin-node-entry";
615
624
  var entersAsNode = (controller, block) => controller.blockElement(block)?.querySelector(`[${NODE_ENTRY}]`) != null;
@@ -829,6 +838,8 @@ function createCrossBlockPointer(controller) {
829
838
  const doc = root.ownerDocument;
830
839
  const view = doc.defaultView;
831
840
  let press = null;
841
+ let unfollow = () => {
842
+ };
832
843
  let last = { x: 0, y: 0 };
833
844
  let preventMouseDown = false;
834
845
  const scroll = createAutoScroll(root, () => follow(last.x, last.y));
@@ -863,10 +874,7 @@ function createCrossBlockPointer(controller) {
863
874
  else if (press?.kind === "blocks") followBlocks(press, x, y);
864
875
  }
865
876
  function release() {
866
- doc.removeEventListener("pointermove", onPointerMove);
867
- doc.removeEventListener("pointerup", end);
868
- doc.removeEventListener("pointercancel", end);
869
- view.removeEventListener("blur", end);
877
+ unfollow();
870
878
  scroll.stop();
871
879
  press = null;
872
880
  const dragged = controller.dragging;
@@ -912,21 +920,21 @@ function createCrossBlockPointer(controller) {
912
920
  } else {
913
921
  return;
914
922
  }
915
- doc.addEventListener("pointermove", onPointerMove);
916
- doc.addEventListener("pointerup", end);
917
- doc.addEventListener("pointercancel", end);
918
- view.addEventListener("blur", end);
923
+ const unfollowDocument = listen(doc, { pointermove: onPointerMove, pointerup: end, pointercancel: end });
924
+ const unfollowView = listen(view, { blur: end });
925
+ unfollow = () => {
926
+ unfollowDocument();
927
+ unfollowView();
928
+ };
919
929
  }
920
930
  function onMouseDown(event) {
921
931
  if (preventMouseDown) event.preventDefault();
922
932
  preventMouseDown = false;
923
933
  }
924
- root.addEventListener("pointerdown", onPointerDown);
925
- root.addEventListener("mousedown", onMouseDown);
934
+ const unlisten = listen(root, { pointerdown: onPointerDown, mousedown: onMouseDown });
926
935
  return () => {
927
936
  release();
928
- root.removeEventListener("pointerdown", onPointerDown);
929
- root.removeEventListener("mousedown", onMouseDown);
937
+ unlisten();
930
938
  };
931
939
  }
932
940
  };
@@ -1098,19 +1106,27 @@ var nodeOf = (selection) => selection?.kind === "node" ? selection.block : null;
1098
1106
  function createNodeReveal(element) {
1099
1107
  let shown = null;
1100
1108
  let pressed = null;
1109
+ let owed = null;
1101
1110
  return {
1102
1111
  pressed(block) {
1103
1112
  pressed = block;
1104
1113
  },
1105
1114
  follow(selection) {
1106
- if (nodeOf(selection) !== shown) shown = null;
1115
+ const block = nodeOf(selection);
1116
+ if (block !== shown) shown = null;
1117
+ if (block !== owed) owed = null;
1107
1118
  },
1108
1119
  settle(selection) {
1109
- shown = nodeOf(selection);
1120
+ const block = nodeOf(selection);
1121
+ if (block !== shown) owed = block;
1122
+ shown = block;
1110
1123
  },
1111
- show(selection) {
1124
+ show(selection, local) {
1112
1125
  const block = nodeOf(selection);
1113
- if (block !== null && block !== shown && block !== pressed) element(block)?.scrollIntoView({ block: "nearest" });
1126
+ if (block !== null && block !== pressed && (block !== shown || local && block === owed)) {
1127
+ element(block)?.scrollIntoView({ block: "nearest" });
1128
+ }
1129
+ if (local) owed = null;
1114
1130
  shown = block;
1115
1131
  pressed = null;
1116
1132
  }
@@ -1458,7 +1474,7 @@ function handleDrop(controller, event) {
1458
1474
  return;
1459
1475
  }
1460
1476
  const pos = dropPos(controller, event.clientX, event.clientY);
1461
- if (pos) dispatchSelection(controller, textSelection(pos));
1477
+ if (pos) controller.dispatch(controller.editor.createTransaction().setSelection(textSelection(pos)).setOrigin("drop"));
1462
1478
  pasteTransfer(controller, dataTransfer);
1463
1479
  }
1464
1480
  function handleDragOver(event) {
@@ -1811,7 +1827,7 @@ function targetAt(controller, node) {
1811
1827
  }
1812
1828
  function elementOf(controller, target) {
1813
1829
  if (target === EMPTY_HOST) return controller.emptyHost ?? void 0;
1814
- return target === null ? void 0 : controller.registry.get(target.block, target.region);
1830
+ return target ? controller.registry.get(target.block, target.region) : void 0;
1815
1831
  }
1816
1832
  function createCompositionHandlers(controller) {
1817
1833
  let active = false;
@@ -2286,11 +2302,13 @@ function attachInput(controller, root) {
2286
2302
  else composition.end(event);
2287
2303
  };
2288
2304
  const detachClipboard = attachClipboard(controller, root, catchUp);
2289
- root.addEventListener("keydown", onKeyDown);
2290
- root.addEventListener("beforeinput", onBeforeInput);
2291
- root.addEventListener("input", onInput);
2292
- root.addEventListener("compositionstart", onCompositionStart);
2293
- root.addEventListener("compositionend", onCompositionEnd);
2305
+ const unlisten = listen(root, {
2306
+ keydown: onKeyDown,
2307
+ beforeinput: onBeforeInput,
2308
+ input: onInput,
2309
+ compositionstart: onCompositionStart,
2310
+ compositionend: onCompositionEnd
2311
+ });
2294
2312
  function observe(host) {
2295
2313
  if (!observed.has(host)) observed.set(host, fallback.observe(host));
2296
2314
  }
@@ -2306,11 +2324,7 @@ function attachInput(controller, root) {
2306
2324
  composition.release();
2307
2325
  sinkComposition.release();
2308
2326
  detachClipboard();
2309
- root.removeEventListener("keydown", onKeyDown);
2310
- root.removeEventListener("beforeinput", onBeforeInput);
2311
- root.removeEventListener("input", onInput);
2312
- root.removeEventListener("compositionstart", onCompositionStart);
2313
- root.removeEventListener("compositionend", onCompositionEnd);
2327
+ unlisten();
2314
2328
  for (const stop of observed.values()) stop();
2315
2329
  observed.clear();
2316
2330
  }
@@ -2332,13 +2346,11 @@ function watchFocusReturn(root, handlers) {
2332
2346
  const onFocusOut = (event) => {
2333
2347
  if (!root.contains(event.relatedTarget)) pressed = false;
2334
2348
  };
2335
- root.addEventListener("pointerdown", onPointerDown, true);
2336
- root.addEventListener("focusin", onFocusIn);
2337
- root.addEventListener("focusout", onFocusOut);
2349
+ const unlistenPress = listen(root, { pointerdown: onPointerDown }, true);
2350
+ const unlistenFocus = listen(root, { focusin: onFocusIn, focusout: onFocusOut });
2338
2351
  return () => {
2339
- root.removeEventListener("pointerdown", onPointerDown, true);
2340
- root.removeEventListener("focusin", onFocusIn);
2341
- root.removeEventListener("focusout", onFocusOut);
2352
+ unlistenPress();
2353
+ unlistenFocus();
2342
2354
  };
2343
2355
  }
2344
2356
 
@@ -2409,7 +2421,7 @@ function movedSelection(controller, doc, model) {
2409
2421
  const selection = readSelection(controller.registry, doc.getSelection(), (node) => controller.blockAt(node));
2410
2422
  return selection === null || sameSelection(selection, model) ? null : selection;
2411
2423
  }
2412
- function writeModelSelection(controller, doc, moved) {
2424
+ function writeModelSelection(controller, doc, moved, local) {
2413
2425
  const domSelection = doc?.getSelection();
2414
2426
  if (focusingSink(controller) || controller.composingKey !== null || !doc || !domSelection || !ownsFocus(controller, doc)) {
2415
2427
  return;
@@ -2419,7 +2431,7 @@ function writeModelSelection(controller, doc, moved) {
2419
2431
  if (heldBySink(selection) && controller.sink !== null) focusSink(controller);
2420
2432
  else if (selection?.kind === "blocks") domSelection.removeAllRanges();
2421
2433
  else writeSelection(controller.registry, selection, domSelection, (id) => controller.blockElement(id));
2422
- controller.nodeReveal.show(selection);
2434
+ controller.nodeReveal.show(selection, local);
2423
2435
  if (!samePoints(before, selectionPoints(domSelection))) moved();
2424
2436
  }
2425
2437
 
@@ -2428,102 +2440,105 @@ var runNow = (fn) => fn();
2428
2440
  var ViewController = class {
2429
2441
  editor;
2430
2442
  registry = createHostRegistry((element) => {
2431
- this.binding?.input.observe(element);
2432
- this.drawn.syncTabStop();
2443
+ this.#binding?.input.observe(element);
2444
+ this.#drawn.syncTabStop();
2433
2445
  return () => {
2434
- this.binding?.input.unobserve(element);
2435
- this.drawn.syncTabStop();
2446
+ this.#binding?.input.unobserve(element);
2447
+ this.#drawn.syncTabStop();
2436
2448
  };
2437
2449
  });
2438
2450
  keyInterceptors = /* @__PURE__ */ new Set();
2439
2451
  nodeReveal = createNodeReveal((id) => this.blockElement(id));
2440
- announcer = createAnnouncer(() => this.said);
2452
+ announcer = createAnnouncer(() => this.#said);
2441
2453
  isMac;
2442
2454
  onFiles;
2443
2455
  goalX = null;
2444
2456
  nativeVerticalMove = false;
2445
2457
  dragging = false;
2446
2458
  composingKey = null;
2447
- flush;
2448
- hosts;
2449
- drawn = createDrawnElements(this.registry, () => this.editor.state);
2450
- cross = createCrossMode(this);
2451
- outside = createOutsideChanges(
2452
- () => hasFocus(this, this.ownerDocument()),
2453
- (model) => movedSelection(this, this.ownerDocument(), model)
2459
+ #flush;
2460
+ #hosts;
2461
+ #drawn = createDrawnElements(this.registry, () => this.editor.state);
2462
+ #cross = createCrossMode(this);
2463
+ #outside = createOutsideChanges(
2464
+ () => hasFocus(this, this.#ownerDocument()),
2465
+ (model) => movedSelection(this, this.#ownerDocument(), model)
2454
2466
  );
2455
- binding = null;
2456
- quiet = false;
2457
- said;
2458
- detachRoot = null;
2459
- readOnlyState;
2467
+ #binding = null;
2468
+ #quiet = false;
2469
+ #loud = false;
2470
+ #said;
2471
+ #detachRoot = null;
2472
+ #readOnlyState;
2460
2473
  constructor(options) {
2461
2474
  this.editor = options.editor;
2462
2475
  options.editor.subscribe((state, tr) => {
2463
- if (tr?.origin !== "remote") this.said = state;
2476
+ if (tr?.origin !== "remote") this.#said = state;
2464
2477
  });
2465
- this.flush = options.flush ?? runNow;
2478
+ this.#flush = options.flush ?? runNow;
2466
2479
  this.onFiles = options.onFiles;
2467
2480
  this.isMac = options.isMac ?? detectMac();
2468
2481
  const decorationsOf = (block, region) => this.decorationsFor(block, region);
2469
- this.hosts = createHostRenderer(options.editor, options.render, decorationsOf, (host) => this.binding?.input.drain(host));
2470
- this.readOnlyState = createReadOnly(this.registry, options.readOnly ?? false);
2482
+ const drain = (element) => this.#binding?.input.drain(element);
2483
+ this.#hosts = createHostRenderer(options.editor, options.render, decorationsOf, drain);
2484
+ this.#readOnlyState = createReadOnly(this.registry, options.readOnly ?? false);
2471
2485
  }
2472
2486
  get root() {
2473
- return this.binding?.root ?? null;
2487
+ return this.#binding?.root ?? null;
2474
2488
  }
2475
2489
  get readOnly() {
2476
- return this.readOnlyState.current();
2490
+ return this.#readOnlyState.current();
2477
2491
  }
2478
2492
  get sink() {
2479
- return this.drawn.sink;
2493
+ return this.#drawn.sink;
2480
2494
  }
2481
2495
  get emptyHost() {
2482
- return this.drawn.emptyHost;
2496
+ return this.#drawn.emptyHost;
2483
2497
  }
2484
2498
  attach(root) {
2485
- this.detachRoot?.();
2486
- const binding = bindRoot(this, root, this.cross, (_, tr) => {
2487
- this.quiet ||= tr?.origin === "remote";
2488
- this.outside.committed(tr);
2499
+ this.#detachRoot?.();
2500
+ const binding = bindRoot(this, root, this.#cross, (_, tr) => {
2501
+ this.#quiet ||= tr?.origin === "remote" && tr.docChanged;
2502
+ this.#loud ||= tr?.origin !== "remote";
2503
+ this.#outside.committed(tr);
2489
2504
  this.nodeReveal.follow(this.editor.state.selection);
2490
- this.drawn.syncTabStop();
2491
- this.cross.syncLater();
2505
+ this.#drawn.syncTabStop();
2506
+ this.#cross.syncLater();
2492
2507
  });
2493
2508
  const unmount = this.editor.mount();
2494
2509
  const detach = () => {
2495
2510
  unmount();
2496
2511
  binding.detach();
2497
- if (this.detachRoot !== detach) return;
2498
- this.detachRoot = null;
2499
- this.binding = null;
2512
+ if (this.#detachRoot !== detach) return;
2513
+ this.#detachRoot = null;
2514
+ this.#binding = null;
2500
2515
  };
2501
- this.binding = binding;
2502
- this.detachRoot = detach;
2503
- this.drawn.syncTabStop();
2516
+ this.#binding = binding;
2517
+ this.#detachRoot = detach;
2518
+ this.#drawn.syncTabStop();
2504
2519
  return detach;
2505
2520
  }
2506
2521
  registerBlockElement(id, element) {
2507
- return this.drawn.registerBlock(id, element);
2522
+ return this.#drawn.registerBlock(id, element);
2508
2523
  }
2509
2524
  blockElement(id) {
2510
- return this.drawn.block(id);
2525
+ return this.#drawn.block(id);
2511
2526
  }
2512
2527
  blockAt(node) {
2513
- return this.drawn.blockAt(node);
2528
+ return this.#drawn.blockAt(node);
2514
2529
  }
2515
2530
  registerSink(element) {
2516
- return this.drawn.registerSink(element);
2531
+ return this.#drawn.registerSink(element);
2517
2532
  }
2518
2533
  // An empty document draws one host that stands for a paragraph not created yet, so it belongs to no block.
2519
2534
  registerEmptyHost(element) {
2520
- return this.drawn.registerEmptyHost(element);
2535
+ return this.#drawn.registerEmptyHost(element);
2521
2536
  }
2522
2537
  isEditorElement(element) {
2523
- return this.drawn.isEditorElement(element);
2538
+ return this.#drawn.isEditorElement(element);
2524
2539
  }
2525
2540
  decorationsFor(block, region) {
2526
- return hostDecorations(this.editor, block, region, this.cross.mode);
2541
+ return hostDecorations(this.editor, block, region, this.#cross.mode);
2527
2542
  }
2528
2543
  dispatch(tr) {
2529
2544
  this.edit(() => {
@@ -2536,34 +2551,35 @@ var ViewController = class {
2536
2551
  // open a popover that takes it.
2537
2552
  edit(change) {
2538
2553
  const before = this.editor.state;
2539
- const doc = this.ownerDocument();
2554
+ const doc = this.#ownerDocument();
2540
2555
  const focused = hasFocus(this, doc);
2541
2556
  let handled = false;
2542
- this.flush(
2543
- () => this.outside.inside(() => {
2557
+ this.#flush(
2558
+ () => this.#outside.inside(() => {
2544
2559
  handled = change();
2545
2560
  })
2546
2561
  );
2547
2562
  if (this.editor.state === before) return handled;
2548
2563
  if (this.editor.state.doc !== before.doc) this.goalX = null;
2549
2564
  this.refreshHosts();
2550
- this.cross.sync();
2551
- if (focused && doc !== null && ownsFocus(this, doc)) this.keepFocus();
2552
- this.syncSelectionToDom();
2565
+ this.#cross.sync();
2566
+ if (focused && doc !== null && ownsFocus(this, doc)) this.#keepFocus();
2567
+ this.syncSelectionToDom(true);
2553
2568
  return handled;
2554
2569
  }
2555
2570
  // A change made outside edit() reaches the hosts when React draws them, so the selection is written back once that
2556
- // has happened, and focus follows a host the change replaced. A collaborator's change scrolls nothing doing so.
2571
+ // has happened, and focus follows a host the change replaced. A render of collaborators' changes alone, or of one
2572
+ // that changed the document, scrolls nothing doing so; a caret move of theirs leaves the rest to scroll as it would.
2557
2573
  afterRender() {
2558
- const { quiet } = this;
2559
- this.quiet = false;
2560
- const doc = this.ownerDocument();
2561
- const moved = this.outside.takeMoved();
2562
- if (!this.outside.takeFocused() || !doc || !ownsFocus(this, doc)) return;
2563
- if (moved) this.selectFromDom(moved);
2564
- this.cross.sync();
2574
+ const quiet = this.#quiet || !this.#loud;
2575
+ this.#quiet = this.#loud = false;
2576
+ const doc = this.#ownerDocument();
2577
+ const moved = this.#outside.takeMoved();
2578
+ if (!this.#outside.takeFocused() || !doc || !ownsFocus(this, doc)) return;
2579
+ if (moved) this.#selectFromDom(moved);
2580
+ this.#cross.sync();
2565
2581
  const follow = () => {
2566
- this.keepFocus(quiet);
2582
+ this.#keepFocus(quiet);
2567
2583
  this.syncSelectionToDom();
2568
2584
  };
2569
2585
  if (!quiet) return follow();
@@ -2572,7 +2588,7 @@ var ViewController = class {
2572
2588
  }
2573
2589
  refreshHosts() {
2574
2590
  for (const host of this.registry.all()) {
2575
- if (!this.isComposing(host)) this.hosts.renderIfChanged(host);
2591
+ if (!this.#isComposing(host)) this.#hosts.renderIfChanged(host);
2576
2592
  }
2577
2593
  }
2578
2594
  run(command) {
@@ -2587,63 +2603,63 @@ var ViewController = class {
2587
2603
  renderHost(block, region) {
2588
2604
  const element = this.registry.get(block, region);
2589
2605
  const host = element && { block, region, element };
2590
- if (!host || this.isComposing(host) || !this.hosts.render(host)) return;
2606
+ if (!host || this.#isComposing(host) || !this.#hosts.render(host)) return;
2591
2607
  const inSelection = element.contains(this.domSelection()?.focusNode ?? null);
2592
2608
  if (inSelection && hasFocus(this, element.ownerDocument)) this.syncSelectionToDom();
2593
2609
  }
2594
2610
  domSelection() {
2595
- return this.ownerDocument()?.getSelection() ?? null;
2611
+ return this.#ownerDocument()?.getSelection() ?? null;
2596
2612
  }
2597
- syncSelectionToDom() {
2598
- writeModelSelection(this, this.ownerDocument(), () => this.binding?.selectionSync.suppressNext());
2613
+ syncSelectionToDom(local) {
2614
+ writeModelSelection(this, this.#ownerDocument(), () => this.#binding?.selectionSync.suppressNext(), local);
2599
2615
  }
2600
2616
  // A pointer drag across hosts sets the model selection itself, while the browser keeps extending its own. Leaving
2601
2617
  // cross mode re-renders the hosts that drew it as decorations, which can remove the node holding the caret, so the
2602
2618
  // selection is written back.
2603
2619
  readSelectionFromDom() {
2604
- const selection = movedSelection(this, this.ownerDocument(), this.editor.state.selection);
2620
+ const selection = movedSelection(this, this.#ownerDocument(), this.editor.state.selection);
2605
2621
  if (selection === null) return;
2606
- const wasCross = this.cross.active;
2622
+ const wasCross = this.#cross.active;
2607
2623
  if (!this.nativeVerticalMove) this.goalX = null;
2608
- this.flush(() => this.selectFromDom(selection));
2609
- this.cross.sync();
2610
- if (!wasCross && !this.cross.active) return;
2611
- this.keepFocus();
2624
+ this.#flush(() => this.#selectFromDom(selection));
2625
+ this.#cross.sync();
2626
+ if (!wasCross && !this.#cross.active) return;
2627
+ this.#keepFocus();
2612
2628
  this.syncSelectionToDom();
2613
2629
  }
2614
2630
  focus(target) {
2615
2631
  const { editor } = this;
2616
2632
  const selection = focusTarget(editor.state, target);
2617
2633
  if (selection !== null && !sameSelection(selection, editor.state.selection)) dispatchSelection(this, selection);
2618
- this.takeFocus();
2634
+ this.#takeFocus();
2619
2635
  this.syncSelectionToDom();
2620
2636
  }
2621
2637
  setReadOnly(readOnly) {
2622
- this.readOnlyState.set(readOnly);
2638
+ this.#readOnlyState.set(readOnly);
2623
2639
  }
2624
2640
  subscribeReadOnly(listener) {
2625
- return this.readOnlyState.subscribe(listener);
2641
+ return this.#readOnlyState.subscribe(listener);
2626
2642
  }
2627
2643
  destroy() {
2628
- this.detachRoot?.();
2644
+ this.#detachRoot?.();
2629
2645
  }
2630
- selectFromDom(selection) {
2646
+ #selectFromDom(selection) {
2631
2647
  const { editor } = this;
2632
- this.outside.inside(() => editor.dispatch(editor.createTransaction().setSelection(selection).setOrigin("input")));
2648
+ this.#outside.inside(() => editor.dispatch(editor.createTransaction().setSelection(selection).setOrigin("input")));
2633
2649
  }
2634
- isComposing(host) {
2650
+ #isComposing(host) {
2635
2651
  return this.composingKey !== null && hostKey(host.block, host.region) === this.composingKey;
2636
2652
  }
2637
- ownerDocument() {
2638
- return (this.binding?.root ?? this.registry.all().next().value?.element)?.ownerDocument ?? null;
2653
+ #ownerDocument() {
2654
+ return (this.#binding?.root ?? this.registry.all().next().value?.element)?.ownerDocument ?? null;
2639
2655
  }
2640
2656
  // React replaces a host whose block changes kind, which drops focus, and Firefox does not move focus into another
2641
2657
  // host when a script selects inside it.
2642
- keepFocus(preventScroll) {
2643
- if (this.composingKey === null) this.takeFocus(preventScroll);
2658
+ #keepFocus(preventScroll) {
2659
+ if (this.composingKey === null) this.#takeFocus(preventScroll);
2644
2660
  }
2645
- takeFocus(preventScroll) {
2646
- const element = this.drawn.focusElement();
2661
+ #takeFocus(preventScroll) {
2662
+ const element = this.#drawn.focusElement();
2647
2663
  if (!element || element.ownerDocument.activeElement === element) return;
2648
2664
  if (element === this.sink) focusSink(this);
2649
2665
  else element.focus({ preventScroll });
@@ -2722,7 +2738,7 @@ function SelectionSink({ label = "Selected content", blockLabel }) {
2722
2738
  );
2723
2739
  useIsomorphicLayoutEffect(() => {
2724
2740
  const sink = ref.current;
2725
- return sink === null ? void 0 : controller.registerSink(sink);
2741
+ return sink ? controller.registerSink(sink) : void 0;
2726
2742
  }, [controller]);
2727
2743
  return /* @__PURE__ */ jsx(
2728
2744
  "div",
@@ -2780,7 +2796,7 @@ function EditableRegion({ block, region, label, id, placeholder, className }) {
2780
2796
  const { inline, decorations, placeholder: shown } = useEditorState(controller, select, samePainted);
2781
2797
  useIsomorphicLayoutEffect(() => {
2782
2798
  const host = ref.current;
2783
- return host === null ? void 0 : controller.registry.register(block, region, host);
2799
+ return host ? controller.registry.register(block, region, host) : void 0;
2784
2800
  }, [controller, block, region]);
2785
2801
  useIsomorphicLayoutEffect(() => {
2786
2802
  controller.renderHost(block, region);
@@ -3051,7 +3067,7 @@ var BlockShell = memo(function BlockShell2({ block, renderers }) {
3051
3067
  const hidden = status === "hidden";
3052
3068
  useIsomorphicLayoutEffect(() => {
3053
3069
  const element = ref.current;
3054
- return hidden || element === null ? void 0 : controller.registerBlockElement(block.id, element);
3070
+ return hidden || !element ? void 0 : controller.registerBlockElement(block.id, element);
3055
3071
  }, [controller, block.id, hidden]);
3056
3072
  if (hidden) return null;
3057
3073
  const Renderer = rendererFor(renderers, block.type);
@@ -3214,7 +3230,7 @@ function EditorView({
3214
3230
  const blockIdScope = useId();
3215
3231
  const blocks = useEditorState(controller, (state) => state.doc.blocks);
3216
3232
  const shells = useBlockElements(blocks, renderers);
3217
- useIsomorphicLayoutEffect(() => root.current === null ? void 0 : controller.attach(root.current), [controller]);
3233
+ useIsomorphicLayoutEffect(() => root.current ? controller.attach(root.current) : void 0, [controller]);
3218
3234
  return /* @__PURE__ */ jsx13(QuoinEditorContext.Provider, { value: controller, children: /* @__PURE__ */ jsxs3(
3219
3235
  "div",
3220
3236
  {
@@ -3224,7 +3240,7 @@ function EditorView({
3224
3240
  role: "group",
3225
3241
  "aria-label": label,
3226
3242
  "aria-describedby": hintId,
3227
- onFocus: (event) => focusOwners.set(event.target, controller),
3243
+ onFocusCapture: (event) => focusOwners.set(event.target, controller),
3228
3244
  children: [
3229
3245
  /* @__PURE__ */ jsx13(BlockDomIdScope.Provider, { value: blockIdScope, children: /* @__PURE__ */ jsx13(UnsupportedBlockLabel.Provider, { value: unsupportedBlockLabel, children: /* @__PURE__ */ jsx13(BlockPlaceholderContext.Provider, { value: blockPlaceholder, children: blocks.length === 0 ? /* @__PURE__ */ jsx13(EmptyDocumentHost, { placeholder, label: paragraphLabel }) : shells }) }) }),
3230
3246
  children,
@@ -3262,6 +3278,7 @@ export {
3262
3278
  NATIVE_INTERACTION,
3263
3279
  useIsomorphicLayoutEffect,
3264
3280
  onBlock,
3281
+ listen,
3265
3282
  createAutoScroll,
3266
3283
  hostKey,
3267
3284
  regionInline,
@@ -3283,4 +3300,4 @@ export {
3283
3300
  BlockShell,
3284
3301
  EditorView
3285
3302
  };
3286
- //# sourceMappingURL=chunk-ZS2WA357.js.map
3303
+ //# sourceMappingURL=chunk-SSIRYUCK.js.map