quoin-editor 1.0.0 → 1.0.2

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 (213) hide show
  1. package/CHANGELOG.md +58 -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-ND5XJVK2.cjs → chunk-4SLJNZSM.cjs} +27 -23
  13. package/dist/chunk-4SLJNZSM.cjs.map +1 -0
  14. package/dist/{chunk-LCQSG4M6.js → chunk-4XFXB37X.js} +22 -18
  15. package/dist/chunk-4XFXB37X.js.map +1 -0
  16. package/dist/{chunk-AEJXZBVR.cjs → chunk-5MAYUGTE.cjs} +110 -103
  17. package/dist/chunk-5MAYUGTE.cjs.map +1 -0
  18. package/dist/{chunk-JDPTZUBW.js → chunk-623AOJM2.js} +4 -4
  19. package/dist/chunk-6NULZPVC.js +374 -0
  20. package/dist/chunk-6NULZPVC.js.map +1 -0
  21. package/dist/{chunk-2QCRZ7OL.cjs → chunk-6V6GGBDK.cjs} +12 -11
  22. package/dist/{chunk-2QCRZ7OL.cjs.map → chunk-6V6GGBDK.cjs.map} +1 -1
  23. package/dist/{chunk-WXMYDXPN.cjs → chunk-73653CJ4.cjs} +4 -3
  24. package/dist/chunk-73653CJ4.cjs.map +1 -0
  25. package/dist/{chunk-47MLKSI2.js → chunk-ADSJ42DO.js} +6 -6
  26. package/dist/{chunk-PWUEPDA3.cjs → chunk-AUOEM3SF.cjs} +44 -44
  27. package/dist/{chunk-PWUEPDA3.cjs.map → chunk-AUOEM3SF.cjs.map} +1 -1
  28. package/dist/{chunk-WQHV3MRE.cjs → chunk-BQANU5BH.cjs} +12 -12
  29. package/dist/{chunk-WQHV3MRE.cjs.map → chunk-BQANU5BH.cjs.map} +1 -1
  30. package/dist/{chunk-KXOBZGQO.js → chunk-C23RQVRK.js} +21 -14
  31. package/dist/chunk-C23RQVRK.js.map +1 -0
  32. package/dist/{chunk-2VDK27IF.cjs → chunk-CW3AFJBR.cjs} +312 -342
  33. package/dist/chunk-CW3AFJBR.cjs.map +1 -0
  34. package/dist/{chunk-MQ2XQ4MX.js → chunk-DUE3HCZD.js} +6 -6
  35. package/dist/chunk-DUE3HCZD.js.map +1 -0
  36. package/dist/{chunk-OMOBMXD5.cjs → chunk-EH5KXQXY.cjs} +7 -2
  37. package/dist/chunk-EH5KXQXY.cjs.map +1 -0
  38. package/dist/{chunk-ZS2WA357.js → chunk-EPARJI4V.js} +147 -129
  39. package/dist/chunk-EPARJI4V.js.map +1 -0
  40. package/dist/{chunk-HZSSEYJS.cjs → chunk-FDRUAL3Z.cjs} +30 -30
  41. package/dist/{chunk-HZSSEYJS.cjs.map → chunk-FDRUAL3Z.cjs.map} +1 -1
  42. package/dist/{chunk-T7SW6OWV.js → chunk-IQBMAE3F.js} +5 -5
  43. package/dist/{chunk-RUDWMKYX.js → chunk-JHQUHFLX.js} +8 -8
  44. package/dist/{chunk-HELJTLNC.cjs → chunk-KUYZMSMF.cjs} +12 -12
  45. package/dist/chunk-KUYZMSMF.cjs.map +1 -0
  46. package/dist/chunk-LE5XMIFJ.cjs +14 -0
  47. package/dist/chunk-LE5XMIFJ.cjs.map +1 -0
  48. package/dist/{chunk-EL2OEJQC.cjs → chunk-LLTEGXWZ.cjs} +56 -56
  49. package/dist/{chunk-EL2OEJQC.cjs.map → chunk-LLTEGXWZ.cjs.map} +1 -1
  50. package/dist/chunk-MQUCCSWG.js +14 -0
  51. package/dist/chunk-MQUCCSWG.js.map +1 -0
  52. package/dist/{chunk-NNDYYEW5.js → chunk-N4FGA3H4.js} +5 -5
  53. package/dist/{chunk-ZHOSSWUM.js → chunk-NEZJ7ZP5.js} +4 -3
  54. package/dist/chunk-NEZJ7ZP5.js.map +1 -0
  55. package/dist/{chunk-XEBWC7ZL.js → chunk-O4Z2WMFF.js} +7 -2
  56. package/dist/chunk-O4Z2WMFF.js.map +1 -0
  57. package/dist/{chunk-HJIQT3S5.js → chunk-OBMBSU2S.js} +100 -84
  58. package/dist/chunk-OBMBSU2S.js.map +1 -0
  59. package/dist/{chunk-KAVU6T6J.js → chunk-OSHZQR3W.js} +5 -5
  60. package/dist/{chunk-GTTPVJSD.cjs → chunk-P6KYXFZC.cjs} +265 -247
  61. package/dist/chunk-P6KYXFZC.cjs.map +1 -0
  62. package/dist/{chunk-CDELOHDY.cjs → chunk-R2BLBV43.cjs} +23 -23
  63. package/dist/{chunk-CDELOHDY.cjs.map → chunk-R2BLBV43.cjs.map} +1 -1
  64. package/dist/{chunk-NOKWNK2O.js → chunk-RJRX34BZ.js} +3 -2
  65. package/dist/{chunk-ZGZEJCRV.js → chunk-T43RZTUT.js} +166 -196
  66. package/dist/chunk-T43RZTUT.js.map +1 -0
  67. package/dist/chunk-TLGX43P6.cjs +374 -0
  68. package/dist/chunk-TLGX43P6.cjs.map +1 -0
  69. package/dist/{chunk-POBM7MGR.js → chunk-U3LOLYAU.js} +2 -2
  70. package/dist/{chunk-RDG4VI6E.cjs → chunk-UEKXVCKC.cjs} +103 -93
  71. package/dist/chunk-UEKXVCKC.cjs.map +1 -0
  72. package/dist/{chunk-PMWCQSQX.js → chunk-VCLL5C7J.js} +5 -5
  73. package/dist/{chunk-SG37UBDO.js → chunk-VRS6WCEK.js} +20 -10
  74. package/dist/chunk-VRS6WCEK.js.map +1 -0
  75. package/dist/{chunk-ZC24WB7Y.cjs → chunk-WEYDDIBQ.cjs} +14 -14
  76. package/dist/{chunk-ZC24WB7Y.cjs.map → chunk-WEYDDIBQ.cjs.map} +1 -1
  77. package/dist/{chunk-5DNCCN6X.cjs → chunk-X4HDKFW5.cjs} +27 -27
  78. package/dist/{chunk-5DNCCN6X.cjs.map → chunk-X4HDKFW5.cjs.map} +1 -1
  79. package/dist/{chunk-SLVDAHHK.cjs → chunk-X4P4TQXH.cjs} +5 -5
  80. package/dist/{chunk-SLVDAHHK.cjs.map → chunk-X4P4TQXH.cjs.map} +1 -1
  81. package/dist/{chunk-GLLXHMH2.cjs → chunk-XA3UEJIW.cjs} +3 -3
  82. package/dist/{chunk-GLLXHMH2.cjs.map → chunk-XA3UEJIW.cjs.map} +1 -1
  83. package/dist/{chunk-K574XHMM.js → chunk-YBMUEEM5.js} +2 -2
  84. package/dist/{chunk-PZ4GT5JO.cjs → chunk-ZKVOS57Q.cjs} +316 -300
  85. package/dist/chunk-ZKVOS57Q.cjs.map +1 -0
  86. package/dist/comments.cjs +113 -98
  87. package/dist/comments.cjs.map +1 -1
  88. package/dist/comments.d.cts +6 -1
  89. package/dist/comments.d.ts +6 -1
  90. package/dist/comments.js +32 -17
  91. package/dist/comments.js.map +1 -1
  92. package/dist/diff.cjs +44 -40
  93. package/dist/diff.cjs.map +1 -1
  94. package/dist/diff.js +17 -13
  95. package/dist/diff.js.map +1 -1
  96. package/dist/docx.cjs +60 -40
  97. package/dist/docx.cjs.map +1 -1
  98. package/dist/docx.d.cts +6 -0
  99. package/dist/docx.d.ts +6 -0
  100. package/dist/docx.js +32 -12
  101. package/dist/docx.js.map +1 -1
  102. package/dist/embed.cjs +9 -9
  103. package/dist/embed.d.cts +1 -1
  104. package/dist/embed.d.ts +1 -1
  105. package/dist/embed.js +8 -8
  106. package/dist/{emoji-extension-DpQ43HjE.d.ts → emoji-extension-CmPlRssm.d.ts} +1 -1
  107. package/dist/{emoji-extension-C12gDPm6.d.cts → emoji-extension-zJ6F7hW8.d.cts} +1 -1
  108. package/dist/emoji.cjs +8 -8
  109. package/dist/emoji.d.cts +3 -3
  110. package/dist/emoji.d.ts +3 -3
  111. package/dist/emoji.js +7 -7
  112. package/dist/engine.cjs +4 -4
  113. package/dist/engine.d.cts +2 -2
  114. package/dist/engine.d.ts +2 -2
  115. package/dist/engine.js +3 -3
  116. package/dist/{find-extension-_sbZEt3R.d.cts → find-extension-BcRyE9K4.d.cts} +1 -1
  117. package/dist/{find-extension-DKqLLSuP.d.ts → find-extension-CmFehyul.d.ts} +1 -1
  118. package/dist/find.cjs +8 -8
  119. package/dist/find.d.cts +2 -2
  120. package/dist/find.d.ts +2 -2
  121. package/dist/find.js +7 -7
  122. package/dist/headless.cjs +5 -5
  123. package/dist/headless.d.cts +4 -4
  124. package/dist/headless.d.ts +4 -4
  125. package/dist/headless.js +4 -4
  126. package/dist/{index-CgD72kHB.d.cts → index-CFPmCee4.d.cts} +5 -2
  127. package/dist/{index-DNYbTK3w.d.ts → index-DiCGV60d.d.ts} +5 -2
  128. package/dist/index.cjs +7 -7
  129. package/dist/index.d.cts +4 -4
  130. package/dist/index.d.ts +4 -4
  131. package/dist/index.js +6 -6
  132. package/dist/math.cjs +10 -10
  133. package/dist/math.d.cts +1 -1
  134. package/dist/math.d.ts +1 -1
  135. package/dist/math.js +9 -9
  136. package/dist/mention.cjs +10 -10
  137. package/dist/mention.d.cts +1 -1
  138. package/dist/mention.d.ts +1 -1
  139. package/dist/mention.js +9 -9
  140. package/dist/presence.cjs +98 -104
  141. package/dist/presence.cjs.map +1 -1
  142. package/dist/presence.d.cts +2 -2
  143. package/dist/presence.d.ts +2 -2
  144. package/dist/presence.js +66 -72
  145. package/dist/presence.js.map +1 -1
  146. package/dist/{stats-extension-Bly88uio.d.ts → stats-extension-DisOEbbI.d.ts} +1 -1
  147. package/dist/{stats-extension-CJPijvUb.d.cts → stats-extension-Dt1lgP3m.d.cts} +1 -1
  148. package/dist/stats.cjs +9 -9
  149. package/dist/stats.d.cts +3 -3
  150. package/dist/stats.d.ts +3 -3
  151. package/dist/stats.js +8 -8
  152. package/dist/styles.css +1 -1
  153. package/dist/{table-extension-Dzf4k6hI.d.ts → table-extension-BTMJnT7J.d.ts} +1 -1
  154. package/dist/{table-extension-BTLxFy2S.d.cts → table-extension-DxZz3jqp.d.cts} +1 -1
  155. package/dist/table.cjs +8 -8
  156. package/dist/table.d.cts +2 -2
  157. package/dist/table.d.ts +2 -2
  158. package/dist/table.js +7 -7
  159. package/dist/{toc-extension-DWm5alVj.d.ts → toc-extension-CR9U-l6j.d.ts} +1 -1
  160. package/dist/{toc-extension-B3-s6h2x.d.cts → toc-extension-DGHywOBv.d.cts} +1 -1
  161. package/dist/toc.cjs +8 -8
  162. package/dist/toc.d.cts +2 -2
  163. package/dist/toc.d.ts +2 -2
  164. package/dist/toc.js +7 -7
  165. package/dist/{types-a1CRBlEh.d.ts → types-C6_QkXzy.d.ts} +1 -9
  166. package/dist/{types-Cz7XJLaK.d.cts → types-CJ7Gq3GX.d.cts} +1 -9
  167. package/dist/{view-controller-DSHw0ltQ.d.cts → view-controller-BD1KwYfE.d.cts} +6 -19
  168. package/dist/{view-controller-UbpzblGl.d.ts → view-controller-y4cb60ue.d.ts} +6 -19
  169. package/dist/view.cjs +6 -6
  170. package/dist/view.js +3 -3
  171. package/dist/yjs.cjs +302 -412
  172. package/dist/yjs.cjs.map +1 -1
  173. package/dist/yjs.d.cts +3 -3
  174. package/dist/yjs.d.ts +3 -3
  175. package/dist/yjs.js +211 -321
  176. package/dist/yjs.js.map +1 -1
  177. package/package.json +1 -1
  178. package/dist/chunk-2VDK27IF.cjs.map +0 -1
  179. package/dist/chunk-AEJXZBVR.cjs.map +0 -1
  180. package/dist/chunk-E75EHRPA.cjs +0 -175
  181. package/dist/chunk-E75EHRPA.cjs.map +0 -1
  182. package/dist/chunk-GTTPVJSD.cjs.map +0 -1
  183. package/dist/chunk-HELJTLNC.cjs.map +0 -1
  184. package/dist/chunk-HJIQT3S5.js.map +0 -1
  185. package/dist/chunk-JEIFJHEI.js +0 -14
  186. package/dist/chunk-JEIFJHEI.js.map +0 -1
  187. package/dist/chunk-KXOBZGQO.js.map +0 -1
  188. package/dist/chunk-LCQSG4M6.js.map +0 -1
  189. package/dist/chunk-MQ2XQ4MX.js.map +0 -1
  190. package/dist/chunk-ND5XJVK2.cjs.map +0 -1
  191. package/dist/chunk-OMOBMXD5.cjs.map +0 -1
  192. package/dist/chunk-PZ4GT5JO.cjs.map +0 -1
  193. package/dist/chunk-QAW5NH6S.cjs +0 -14
  194. package/dist/chunk-QAW5NH6S.cjs.map +0 -1
  195. package/dist/chunk-RDG4VI6E.cjs.map +0 -1
  196. package/dist/chunk-SG37UBDO.js.map +0 -1
  197. package/dist/chunk-TC4DARU2.js +0 -175
  198. package/dist/chunk-TC4DARU2.js.map +0 -1
  199. package/dist/chunk-WXMYDXPN.cjs.map +0 -1
  200. package/dist/chunk-XEBWC7ZL.js.map +0 -1
  201. package/dist/chunk-ZGZEJCRV.js.map +0 -1
  202. package/dist/chunk-ZHOSSWUM.js.map +0 -1
  203. package/dist/chunk-ZS2WA357.js.map +0 -1
  204. /package/dist/{chunk-JDPTZUBW.js.map → chunk-623AOJM2.js.map} +0 -0
  205. /package/dist/{chunk-47MLKSI2.js.map → chunk-ADSJ42DO.js.map} +0 -0
  206. /package/dist/{chunk-T7SW6OWV.js.map → chunk-IQBMAE3F.js.map} +0 -0
  207. /package/dist/{chunk-RUDWMKYX.js.map → chunk-JHQUHFLX.js.map} +0 -0
  208. /package/dist/{chunk-NNDYYEW5.js.map → chunk-N4FGA3H4.js.map} +0 -0
  209. /package/dist/{chunk-KAVU6T6J.js.map → chunk-OSHZQR3W.js.map} +0 -0
  210. /package/dist/{chunk-NOKWNK2O.js.map → chunk-RJRX34BZ.js.map} +0 -0
  211. /package/dist/{chunk-POBM7MGR.js.map → chunk-U3LOLYAU.js.map} +0 -0
  212. /package/dist/{chunk-PMWCQSQX.js.map → chunk-VCLL5C7J.js.map} +0 -0
  213. /package/dist/{chunk-K574XHMM.js.map → chunk-YBMUEEM5.js.map} +0 -0
package/dist/comments.cjs CHANGED
@@ -1,10 +1,10 @@
1
1
  'use client';"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }"use client";
2
2
 
3
3
 
4
- var _chunkGLLXHMH2cjs = require('./chunk-GLLXHMH2.cjs');
4
+ var _chunkXA3UEJIWcjs = require('./chunk-XA3UEJIW.cjs');
5
5
 
6
6
 
7
- var _chunkWXMYDXPNcjs = require('./chunk-WXMYDXPN.cjs');
7
+ var _chunk73653CJ4cjs = require('./chunk-73653CJ4.cjs');
8
8
 
9
9
 
10
10
 
@@ -16,13 +16,13 @@ var _chunkWXMYDXPNcjs = require('./chunk-WXMYDXPN.cjs');
16
16
 
17
17
 
18
18
 
19
- var _chunk2VDK27IFcjs = require('./chunk-2VDK27IF.cjs');
19
+ var _chunkCW3AFJBRcjs = require('./chunk-CW3AFJBR.cjs');
20
20
 
21
21
 
22
22
 
23
23
 
24
- var _chunkGTTPVJSDcjs = require('./chunk-GTTPVJSD.cjs');
25
- require('./chunk-OMOBMXD5.cjs');
24
+ var _chunkP6KYXFZCcjs = require('./chunk-P6KYXFZC.cjs');
25
+ require('./chunk-EH5KXQXY.cjs');
26
26
 
27
27
 
28
28
 
@@ -35,16 +35,15 @@ require('./chunk-OMOBMXD5.cjs');
35
35
 
36
36
 
37
37
 
38
+ var _chunkZKVOS57Qcjs = require('./chunk-ZKVOS57Q.cjs');
39
+ require('./chunk-6V6GGBDK.cjs');
38
40
 
39
- var _chunkPZ4GT5JOcjs = require('./chunk-PZ4GT5JO.cjs');
40
- require('./chunk-2QCRZ7OL.cjs');
41
41
 
42
42
 
43
43
 
44
44
 
45
45
 
46
-
47
- var _chunkND5XJVK2cjs = require('./chunk-ND5XJVK2.cjs');
46
+ var _chunk4SLJNZSMcjs = require('./chunk-4SLJNZSM.cjs');
48
47
 
49
48
  // src/extensions/comments/comments-extension.tsx
50
49
  var _lucidereact = require('lucide-react');
@@ -55,7 +54,7 @@ function addRegion(anchors, block, region, inline2) {
55
54
  let position = 0;
56
55
  for (const node of inline2) {
57
56
  const from = position;
58
- position += _chunkND5XJVK2cjs.nodeLength.call(void 0, node);
57
+ position += _chunk4SLJNZSMcjs.nodeLength.call(void 0, node);
59
58
  for (const id of idsOf(node)) {
60
59
  const ranges = _nullishCoalesce(anchors.get(id), () => ( []));
61
60
  const last = ranges[ranges.length - 1];
@@ -82,25 +81,25 @@ function commentAnchors(doc) {
82
81
  var atomLabel = (node) => node.kind === "atom" ? _nullishCoalesce(node.attrs.label, () => ( "")) : "";
83
82
  function anchorText(doc, ranges) {
84
83
  return ranges.map(({ block, region, from, to }) => {
85
- const inline2 = _nullishCoalesce(_optionalChain([_chunkND5XJVK2cjs.blockById.call(void 0, doc, block), 'optionalAccess', _8 => _8.regions, 'access', _9 => _9[region]]), () => ( []));
86
- return _chunkND5XJVK2cjs.inlineText.call(void 0, _chunkND5XJVK2cjs.sliceInline.call(void 0, inline2, from, to), atomLabel);
84
+ const inline2 = _nullishCoalesce(_optionalChain([_chunk4SLJNZSMcjs.blockById.call(void 0, doc, block), 'optionalAccess', _8 => _8.regions, 'access', _9 => _9[region]]), () => ( []));
85
+ return _chunk4SLJNZSMcjs.inlineText.call(void 0, _chunk4SLJNZSMcjs.sliceInline.call(void 0, inline2, from, to), atomLabel);
87
86
  }).join(" ");
88
87
  }
89
88
  function commentIdsAt(doc, { block, region, offset }) {
90
- const inline2 = _nullishCoalesce(_optionalChain([_chunkND5XJVK2cjs.blockById.call(void 0, doc, block), 'optionalAccess', _10 => _10.regions, 'access', _11 => _11[region]]), () => ( []));
89
+ const inline2 = _nullishCoalesce(_optionalChain([_chunk4SLJNZSMcjs.blockById.call(void 0, doc, block), 'optionalAccess', _10 => _10.regions, 'access', _11 => _11[region]]), () => ( []));
91
90
  const ids = /* @__PURE__ */ new Set();
92
91
  let position = 0;
93
92
  for (const node of inline2) {
94
- const end = position + _chunkND5XJVK2cjs.nodeLength.call(void 0, node);
93
+ const end = position + _chunk4SLJNZSMcjs.nodeLength.call(void 0, node);
95
94
  if (position <= offset && offset <= end && end > position) idsOf(node).forEach((id) => ids.add(id));
96
95
  position = end;
97
96
  }
98
97
  return [...ids].sort();
99
98
  }
100
99
  function threadRemoval(state, id) {
101
- const tr = new (0, _chunkPZ4GT5JOcjs.Transaction)(state).setOrigin("command");
100
+ const tr = new (0, _chunkZKVOS57Qcjs.Transaction)(state).setOrigin("command");
102
101
  for (const { block, region, from, to } of _nullishCoalesce(commentAnchors(state.doc).get(id), () => ( []))) {
103
- tr.step(_chunkPZ4GT5JOcjs.removeMarkStep.call(void 0, block, region, from, to, { type: "comment", attrs: { id } }));
102
+ tr.step(_chunkZKVOS57Qcjs.removeMarkStep.call(void 0, block, region, from, to, { type: "comment", attrs: { id } }));
104
103
  }
105
104
  return tr;
106
105
  }
@@ -111,14 +110,14 @@ function mapPendingRanges(tr, ranges, state) {
111
110
  const from = tr.mapPos({ block: range.block, region: range.region, offset: range.from }, 1);
112
111
  const to = tr.mapPos({ block: range.block, region: range.region, offset: range.to }, -1);
113
112
  const { index } = state.doc;
114
- if (!index.has(from.block) || !index.has(to.block) || _chunkPZ4GT5JOcjs.comparePos.call(void 0, state.doc, from, to) >= 0) return [];
115
- return _chunkPZ4GT5JOcjs.markRanges.call(void 0, { ...state, selection: _chunkPZ4GT5JOcjs.textSelection.call(void 0, from, to) });
113
+ if (!index.has(from.block) || !index.has(to.block) || _chunkZKVOS57Qcjs.comparePos.call(void 0, state.doc, from, to) >= 0) return [];
114
+ return _chunkZKVOS57Qcjs.markRanges.call(void 0, { ...state, selection: _chunkZKVOS57Qcjs.textSelection.call(void 0, from, to) });
116
115
  });
117
116
  }
118
117
 
119
118
  // src/extensions/comments/comments-plugin.ts
120
- var isEnded = (ended, id, current) => ended.some((thread) => thread.id === id && thread.seen === current);
121
- var commentsKey = _chunkPZ4GT5JOcjs.createPluginKey.call(void 0, "comments");
119
+ var isEnded = (ended, id, current) => ended.some((thread) => thread.id === id && _optionalChain([thread, 'access', _12 => _12.seen, 'optionalAccess', _13 => _13.resolved]) === _optionalChain([current, 'optionalAccess', _14 => _14.resolved]));
120
+ var commentsKey = _chunkZKVOS57Qcjs.createPluginKey.call(void 0, "comments");
122
121
  var COMMENTS = "comments";
123
122
  var IDLE = { pending: [], active: null, open: null, ended: [] };
124
123
  function act(value, action) {
@@ -138,10 +137,12 @@ function act(value, action) {
138
137
  return value.open === null ? value : { ...value, active: null, open: null };
139
138
  case "forget": {
140
139
  const active = value.active === action.id ? null : value.active;
141
- const open = _optionalChain([value, 'access', _12 => _12.open, 'optionalAccess', _13 => _13.ids, 'access', _14 => _14.includes, 'call', _15 => _15(action.id)]) ? null : value.open;
140
+ const open = _optionalChain([value, 'access', _15 => _15.open, 'optionalAccess', _16 => _16.ids, 'access', _17 => _17.includes, 'call', _18 => _18(action.id)]) ? null : value.open;
142
141
  const ended = [...value.ended.filter(({ id }) => id !== action.id), { id: action.id, seen: action.seen }];
143
142
  return { ...value, active, open, ended };
144
143
  }
144
+ case "caught":
145
+ return { ...value, ended: action.kept };
145
146
  }
146
147
  }
147
148
  function afterEdit(tr, value, state) {
@@ -149,11 +150,13 @@ function afterEdit(tr, value, state) {
149
150
  const pending = value.pending.map((anchor) => ({ ...anchor, ranges: mapPendingRanges(tr, anchor.ranges, state) }));
150
151
  return { ...value, pending };
151
152
  }
153
+ var WRITER_MOVES = ["input", "history", "drop"];
152
154
  function afterMove(tr, value, state) {
153
155
  const { open } = value;
154
- if (open === null || open.focus || !tr.selectionSet || _chunkPZ4GT5JOcjs.foreignOrigins.includes(tr.origin)) return value;
155
- const anchors = commentAnchors(state.doc);
156
- return open.ids.some((id) => anchors.has(id)) ? value : { ...value, active: null, open: null };
156
+ if (open === null || open.focus || !tr.selectionSet || !WRITER_MOVES.includes(tr.origin)) return value;
157
+ const { selection } = state;
158
+ const here = _optionalChain([selection, 'optionalAccess', _19 => _19.kind]) === "text" ? commentIdsAt(state.doc, selection.head) : [];
159
+ return open.ids.some((id) => here.includes(id)) ? value : { ...value, active: null, open: null };
157
160
  }
158
161
  var commentsPlugin = {
159
162
  key: commentsKey,
@@ -167,26 +170,26 @@ var commentsPlugin = {
167
170
 
168
171
  // src/extensions/comments/comment-create.ts
169
172
  var nextKey = 0;
170
- var hasCommentableText = (state) => _optionalChain([state, 'access', _16 => _16.selection, 'optionalAccess', _17 => _17.kind]) === "text" && _chunkPZ4GT5JOcjs.markRanges.call(void 0, state).length > 0;
173
+ var hasCommentableText = (state) => _optionalChain([state, 'access', _20 => _20.selection, 'optionalAccess', _21 => _21.kind]) === "text" && _chunkZKVOS57Qcjs.markRanges.call(void 0, state).length > 0;
171
174
  var requestComment = (state, dispatch) => {
172
175
  const { selection } = state;
173
- if (_optionalChain([selection, 'optionalAccess', _18 => _18.kind]) !== "text" || _chunkPZ4GT5JOcjs.getPluginState.call(void 0, state, commentsKey).pending.length > 0) return false;
174
- const ranges = _chunkPZ4GT5JOcjs.markRanges.call(void 0, state);
176
+ if (_optionalChain([selection, 'optionalAccess', _22 => _22.kind]) !== "text" || _chunkZKVOS57Qcjs.getPluginState.call(void 0, state, commentsKey).pending.length > 0) return false;
177
+ const ranges = _chunkZKVOS57Qcjs.markRanges.call(void 0, state);
175
178
  if (ranges.length === 0) return false;
176
179
  if (dispatch === void 0) return true;
177
180
  const pending = { key: ++nextKey, ranges, selection };
178
181
  const action = { type: "pending", pending };
179
- dispatch(new (0, _chunkPZ4GT5JOcjs.Transaction)(state).setMeta(COMMENTS, action).setMeta("addToHistory", false));
182
+ dispatch(new (0, _chunkZKVOS57Qcjs.Transaction)(state).setMeta(COMMENTS, action).setMeta("addToHistory", false));
180
183
  return true;
181
184
  };
182
185
  function settledTransaction(editor, key, id) {
183
- const pending = _chunkPZ4GT5JOcjs.getPluginState.call(void 0, editor.state, commentsKey).pending.find((anchor) => anchor.key === key);
186
+ const pending = _chunkZKVOS57Qcjs.getPluginState.call(void 0, editor.state, commentsKey).pending.find((anchor) => anchor.key === key);
184
187
  const tr = editor.createTransaction().setOrigin("command");
185
- const ranges = id === null ? [] : _nullishCoalesce(_optionalChain([pending, 'optionalAccess', _19 => _19.ranges]), () => ( []));
188
+ const ranges = id === null ? [] : _nullishCoalesce(_optionalChain([pending, 'optionalAccess', _23 => _23.ranges]), () => ( []));
186
189
  for (const { block, region, from, to } of ranges) {
187
- tr.step(_chunkPZ4GT5JOcjs.addMarkStep.call(void 0, block, region, from, to, { type: "comment", attrs: { id } }));
190
+ tr.step(_chunkZKVOS57Qcjs.addMarkStep.call(void 0, block, region, from, to, { type: "comment", attrs: { id } }));
188
191
  }
189
- const untouched = pending !== void 0 && _chunkPZ4GT5JOcjs.sameSelection.call(void 0, editor.state.selection, pending.selection);
192
+ const untouched = pending !== void 0 && _chunkZKVOS57Qcjs.sameSelection.call(void 0, editor.state.selection, pending.selection);
190
193
  const open = id !== null && ranges.length > 0 && untouched ? { ids: [id], focus: true } : void 0;
191
194
  const action = { type: "settled", key, open };
192
195
  return tr.setMeta(COMMENTS, action);
@@ -197,7 +200,7 @@ function create(editor, pending, onCreate, link) {
197
200
  if (link.mounts === 0) return;
198
201
  const tr = settledTransaction(editor, pending.key, id);
199
202
  editor.dispatch(tr);
200
- if (id === null) link.report(_chunk2VDK27IFcjs.toError.call(void 0, error));
203
+ if (id === null) link.report(_chunkCW3AFJBRcjs.toError.call(void 0, error));
201
204
  else if (!tr.docChanged) link.report(new Error(`Comment thread ${id} has no text: it was deleted meanwhile`));
202
205
  };
203
206
  new Promise((resolve) => resolve(onCreate(input))).then(
@@ -207,30 +210,30 @@ function create(editor, pending, onCreate, link) {
207
210
  }
208
211
  function watchCreates(editor, onCreate, link) {
209
212
  return editor.subscribe((_, tr) => {
210
- const action = _optionalChain([tr, 'optionalAccess', _20 => _20.getMeta, 'call', _21 => _21(COMMENTS)]);
211
- if (_optionalChain([action, 'optionalAccess', _22 => _22.type]) === "pending") create(editor, action.pending, onCreate, link);
213
+ const action = _optionalChain([tr, 'optionalAccess', _24 => _24.getMeta, 'call', _25 => _25(COMMENTS)]);
214
+ if (_optionalChain([action, 'optionalAccess', _26 => _26.type]) === "pending") create(editor, action.pending, onCreate, link);
212
215
  });
213
216
  }
214
217
 
215
218
  // src/extensions/comments/comment-open.ts
216
219
  function openIds(state, threads, ids) {
217
- const { ended } = _chunkPZ4GT5JOcjs.getPluginState.call(void 0, state, commentsKey);
220
+ const { ended } = _chunkZKVOS57Qcjs.getPluginState.call(void 0, state, commentsKey);
218
221
  return ids.filter((id) => {
219
222
  const thread = threads.find(id);
220
- return _optionalChain([thread, 'optionalAccess', _23 => _23.resolved]) === false && !isEnded(ended, id, thread);
223
+ return _optionalChain([thread, 'optionalAccess', _27 => _27.resolved]) === false && !isEnded(ended, id, thread);
221
224
  });
222
225
  }
223
226
  function commentsTransaction(state, action) {
224
- return new (0, _chunkPZ4GT5JOcjs.Transaction)(state).setMeta(COMMENTS, action).setMeta("addToHistory", false);
227
+ return new (0, _chunkZKVOS57Qcjs.Transaction)(state).setMeta(COMMENTS, action).setMeta("addToHistory", false);
225
228
  }
226
229
  function commentCommand(threads) {
227
230
  return (state, dispatch) => {
228
231
  if (requestComment(state, dispatch)) return true;
229
232
  const { selection } = state;
230
- if (_optionalChain([selection, 'optionalAccess', _24 => _24.kind]) !== "text" || !_chunkPZ4GT5JOcjs.isCollapsed.call(void 0, selection)) return false;
233
+ if (_optionalChain([selection, 'optionalAccess', _28 => _28.kind]) !== "text" || !_chunkZKVOS57Qcjs.isCollapsed.call(void 0, selection)) return false;
231
234
  const ids = openIds(state, threads, commentIdsAt(state.doc, selection.head));
232
235
  if (ids.length === 0) return false;
233
- _optionalChain([dispatch, 'optionalCall', _25 => _25(commentsTransaction(state, { type: "open", open: { ids, focus: true } }))]);
236
+ _optionalChain([dispatch, 'optionalCall', _29 => _29(commentsTransaction(state, { type: "open", open: { ids, focus: true } }))]);
234
237
  return true;
235
238
  };
236
239
  }
@@ -309,9 +312,9 @@ function place(controller, box, gap) {
309
312
  root.style.setProperty(HEIGHT, `${bottom}px`);
310
313
  }
311
314
  function useBlockAligned(controller, box, gap, key) {
312
- _chunkGTTPVJSDcjs.useIsomorphicLayoutEffect.call(void 0, () => {
315
+ _chunkP6KYXFZCcjs.useIsomorphicLayoutEffect.call(void 0, () => {
313
316
  const element = box.current;
314
- const view = _optionalChain([element, 'optionalAccess', _26 => _26.ownerDocument, 'access', _27 => _27.defaultView]);
317
+ const view = _optionalChain([element, 'optionalAccess', _30 => _30.ownerDocument, 'access', _31 => _31.defaultView]);
315
318
  if (!element || !view) return void 0;
316
319
  const update = () => place(controller, element, gap);
317
320
  update();
@@ -328,7 +331,7 @@ function useBlockAligned(controller, box, gap, key) {
328
331
  view.cancelAnimationFrame(frame);
329
332
  unsubscribe();
330
333
  observer.disconnect();
331
- _optionalChain([element, 'access', _28 => _28.parentElement, 'optionalAccess', _29 => _29.style, 'access', _30 => _30.removeProperty, 'call', _31 => _31(HEIGHT)]);
334
+ _optionalChain([element, 'access', _32 => _32.parentElement, 'optionalAccess', _33 => _33.style, 'access', _34 => _34.removeProperty, 'call', _35 => _35(HEIGHT)]);
332
335
  };
333
336
  }, [controller, box, gap, key]);
334
337
  }
@@ -339,7 +342,7 @@ var GAP = 4;
339
342
  function groupsOf(entries) {
340
343
  const groups = /* @__PURE__ */ new Map();
341
344
  for (const { thread, ranges } of entries) {
342
- const block = _nullishCoalesce(_optionalChain([ranges, 'access', _32 => _32[0], 'optionalAccess', _33 => _33.block]), () => ( ""));
345
+ const block = _nullishCoalesce(_optionalChain([ranges, 'access', _36 => _36[0], 'optionalAccess', _37 => _37.block]), () => ( ""));
343
346
  groups.set(block, [..._nullishCoalesce(groups.get(block), () => ( [])), thread.id]);
344
347
  }
345
348
  const removed = groups.get("");
@@ -356,7 +359,7 @@ function CommentMarkers({ env, box, entries, onOpen }) {
356
359
  "data-rail-item": "",
357
360
  "data-block": block,
358
361
  "aria-label": env.labels.showComments(ids.length),
359
- className: _chunk2VDK27IFcjs.cn.call(void 0, "quoin-comments-marker", _chunk2VDK27IFcjs.FOCUS_RING),
362
+ className: _chunkCW3AFJBRcjs.cn.call(void 0, "quoin-comments-marker", _chunkCW3AFJBRcjs.FOCUS_RING),
360
363
  onClick: (event) => onOpen(ids[0], event.currentTarget),
361
364
  children: [
362
365
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.MessageSquare, { "aria-hidden": "true" }),
@@ -379,13 +382,13 @@ async function called(link, call) {
379
382
  await call();
380
383
  return true;
381
384
  } catch (error) {
382
- link.report(_chunk2VDK27IFcjs.toError.call(void 0, error));
385
+ link.report(_chunkCW3AFJBRcjs.toError.call(void 0, error));
383
386
  return false;
384
387
  }
385
388
  }
386
389
  async function endThread(editor, link, call, id, threads) {
387
390
  if (!await called(link, () => call(id)) || link.mounts === 0) return false;
388
- const action = { type: "forget", id, seen: _optionalChain([threads, 'optionalAccess', _34 => _34.find, 'call', _35 => _35(id)]) };
391
+ const action = { type: "forget", id, seen: _optionalChain([threads, 'optionalAccess', _38 => _38.find, 'call', _39 => _39(id)]) };
389
392
  editor.dispatch(threadRemoval(editor.state, id).setMeta(COMMENTS, action));
390
393
  return true;
391
394
  }
@@ -396,9 +399,9 @@ function sendReply(link, call, id, body) {
396
399
  // src/extensions/comments/CommentAvatar.tsx
397
400
 
398
401
 
399
- var initials = (name) => name.trim().split(/\s+/).slice(0, 2).map((word) => _nullishCoalesce(_optionalChain([Array, 'access', _36 => _36.from, 'call', _37 => _37(word), 'access', _38 => _38[0], 'optionalAccess', _39 => _39.toUpperCase, 'call', _40 => _40()]), () => ( ""))).join("");
402
+ var initials = (name) => name.trim().split(/\s+/).slice(0, 2).map((word) => _nullishCoalesce(_optionalChain([Array, 'access', _40 => _40.from, 'call', _41 => _41(word), 'access', _42 => _42[0], 'optionalAccess', _43 => _43.toUpperCase, 'call', _44 => _44()]), () => ( ""))).join("");
400
403
  function CommentAvatar({ author }) {
401
- const picture = _chunkGLLXHMH2cjs.webAddress.call(void 0, author.avatarUrl);
404
+ const picture = _chunkXA3UEJIWcjs.webAddress.call(void 0, author.avatarUrl);
402
405
  const [failed, setFailed] = _react.useState.call(void 0, null);
403
406
  if (picture !== null && picture !== failed) {
404
407
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
@@ -484,7 +487,7 @@ function ReplyBox({ env, threadId, first }) {
484
487
  }
485
488
  ),
486
489
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
487
- _chunk2VDK27IFcjs.Button,
490
+ _chunkCW3AFJBRcjs.Button,
488
491
  {
489
492
  type: "submit",
490
493
  variant: "ghost",
@@ -501,7 +504,7 @@ function ReplyBox({ env, threadId, first }) {
501
504
 
502
505
  function ThreadView({ env, id, thread, onEnded }) {
503
506
  const { controller, host, labels, link } = env;
504
- const readOnly = _chunkGTTPVJSDcjs.useReadOnly.call(void 0, controller);
507
+ const readOnly = _chunkP6KYXFZCcjs.useReadOnly.call(void 0, controller);
505
508
  const [busy, setBusy] = _react.useState.call(void 0, false);
506
509
  const alive = _react.useRef.call(void 0, true);
507
510
  const root = _react.useRef.call(void 0, null);
@@ -511,14 +514,14 @@ function ThreadView({ env, id, thread, onEnded }) {
511
514
  alive.current = false;
512
515
  };
513
516
  }, []);
514
- const comments = _nullishCoalesce(_optionalChain([thread, 'optionalAccess', _41 => _41.comments]), () => ( []));
517
+ const comments = _nullishCoalesce(_optionalChain([thread, 'optionalAccess', _45 => _45.comments]), () => ( []));
515
518
  const end = async (call) => {
516
519
  if (busy) return;
517
520
  setBusy(true);
518
521
  const ended = await endThread(controller.editor, link, call, id, host.threads);
519
522
  if (alive.current) setBusy(false);
520
523
  const active = document.activeElement;
521
- const stayed = active === null || active === document.body || _optionalChain([root, 'access', _42 => _42.current, 'optionalAccess', _43 => _43.contains, 'call', _44 => _44(active)]) === true;
524
+ const stayed = active === null || active === document.body || _optionalChain([root, 'access', _46 => _46.current, 'optionalAccess', _47 => _47.contains, 'call', _48 => _48(active)]) === true;
522
525
  if (ended && stayed) onEnded();
523
526
  };
524
527
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ref: root, className: "flex flex-col gap-3", children: [
@@ -526,7 +529,7 @@ function ThreadView({ env, id, thread, onEnded }) {
526
529
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ReplyBox, { env, threadId: id, first: comments.length === 0 }),
527
530
  !readOnly && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-end gap-1", children: [
528
531
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
529
- _chunk2VDK27IFcjs.Button,
532
+ _chunkCW3AFJBRcjs.Button,
530
533
  {
531
534
  type: "button",
532
535
  variant: "ghost",
@@ -537,7 +540,7 @@ function ThreadView({ env, id, thread, onEnded }) {
537
540
  }
538
541
  ),
539
542
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
540
- _chunk2VDK27IFcjs.Button,
543
+ _chunkCW3AFJBRcjs.Button,
541
544
  {
542
545
  type: "button",
543
546
  variant: "ghost",
@@ -560,7 +563,7 @@ function ThreadCard({ env, entry, active, expanded, onToggle }) {
560
563
  const [first] = thread.comments;
561
564
  const removed = ranges.length === 0;
562
565
  const backToHeader = () => {
563
- if (_optionalChain([header, 'access', _45 => _45.current, 'optionalAccess', _46 => _46.isConnected])) header.current.focus();
566
+ if (_optionalChain([header, 'access', _49 => _49.current, 'optionalAccess', _50 => _50.isConnected])) header.current.focus();
564
567
  else controller.focus();
565
568
  };
566
569
  const onKeyDown = (event) => {
@@ -568,7 +571,7 @@ function ThreadCard({ env, entry, active, expanded, onToggle }) {
568
571
  event.preventDefault();
569
572
  event.stopPropagation();
570
573
  onToggle(null);
571
- _optionalChain([header, 'access', _47 => _47.current, 'optionalAccess', _48 => _48.focus, 'call', _49 => _49()]);
574
+ _optionalChain([header, 'access', _51 => _51.current, 'optionalAccess', _52 => _52.focus, 'call', _53 => _53()]);
572
575
  };
573
576
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "quoin-comments-card", "data-active": active || void 0, onKeyDown, children: [
574
577
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
@@ -577,7 +580,7 @@ function ThreadCard({ env, entry, active, expanded, onToggle }) {
577
580
  ref: header,
578
581
  type: "button",
579
582
  "aria-expanded": expanded,
580
- className: _chunk2VDK27IFcjs.cn.call(void 0, "flex w-full flex-col items-start gap-1 rounded-sm text-start", _chunk2VDK27IFcjs.FOCUS_RING),
583
+ className: _chunkCW3AFJBRcjs.cn.call(void 0, "flex w-full flex-col items-start gap-1 rounded-sm text-start", _chunkCW3AFJBRcjs.FOCUS_RING),
581
584
  onClick: () => onToggle(expanded ? null : thread.id),
582
585
  children: [
583
586
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: removed ? "text-xs text-muted-foreground italic" : "quoin-comments-quote", children: removed ? labels.textRemoved : anchorText2 }),
@@ -597,10 +600,10 @@ function ThreadCard({ env, entry, active, expanded, onToggle }) {
597
600
  // src/extensions/comments/CommentsRail.tsx
598
601
 
599
602
  var GAP2 = 8;
600
- var layoutKey = (entries, value) => `${value.active} ${value.open !== null} ${entries.map(({ thread, ranges }) => `${thread.id}:${_optionalChain([ranges, 'access', _50 => _50[0], 'optionalAccess', _51 => _51.block])}`)}`;
603
+ var layoutKey = (entries, value) => `${value.active} ${value.open !== null} ${entries.map(({ thread, ranges }) => `${thread.id}:${_optionalChain([ranges, 'access', _54 => _54[0], 'optionalAccess', _55 => _55.block])}`)}`;
601
604
  function CommentsRail({ env, box, entries, value, onToggle }) {
602
605
  useBlockAligned(env.controller, box, GAP2, layoutKey(entries, value));
603
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ref: box, className: "quoin-comments-rail", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { "aria-label": env.labels.comments, children: entries.map((entry) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "li", { "data-rail-item": "", "data-block": _nullishCoalesce(_optionalChain([entry, 'access', _52 => _52.ranges, 'access', _53 => _53[0], 'optionalAccess', _54 => _54.block]), () => ( "")), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
606
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ref: box, className: "quoin-comments-rail", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { "aria-label": env.labels.comments, children: entries.map((entry) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "li", { "data-rail-item": "", "data-block": _nullishCoalesce(_optionalChain([entry, 'access', _56 => _56.ranges, 'access', _57 => _57[0], 'optionalAccess', _58 => _58.block]), () => ( "")), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
604
607
  ThreadCard,
605
608
  {
606
609
  env,
@@ -622,7 +625,7 @@ function CommentsSheet({ env, entries, value, onToggle, onClose, returnFocus })
622
625
  const content = _react.useRef.call(void 0, null);
623
626
  const outside = _react.useRef.call(void 0, false);
624
627
  const focusOpened = (event) => {
625
- const opened = _optionalChain([content, 'access', _55 => _55.current, 'optionalAccess', _56 => _56.querySelector, 'call', _57 => _57('[aria-expanded="true"]')]);
628
+ const opened = _optionalChain([content, 'access', _59 => _59.current, 'optionalAccess', _60 => _60.querySelector, 'call', _61 => _61('[aria-expanded="true"]')]);
626
629
  if (!opened) return;
627
630
  event.preventDefault();
628
631
  opened.focus();
@@ -652,7 +655,7 @@ function CommentsSheet({ env, entries, value, onToggle, onClose, returnFocus })
652
655
  children: [
653
656
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center justify-between gap-2", children: [
654
657
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogPrimitive.Title, { className: "text-sm font-semibold", children: labels.comments }),
655
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogPrimitive.Close, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2VDK27IFcjs.Button, { type: "button", variant: "ghost", size: "icon-sm", "aria-label": labels.close, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.XIcon, {}) }) })
658
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogPrimitive.Close, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkCW3AFJBRcjs.Button, { type: "button", variant: "ghost", size: "icon-sm", "aria-label": labels.close, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.XIcon, {}) }) })
656
659
  ] }),
657
660
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { "aria-label": labels.comments, className: "flex flex-col gap-2", children: entries.map((entry) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "li", { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
658
661
  ThreadCard,
@@ -679,7 +682,7 @@ function railEntries(doc, threads, ended = []) {
679
682
  const ranges = _nullishCoalesce(anchors.get(thread.id), () => ( NONE));
680
683
  return { thread, ranges, anchorText: anchorText(doc, ranges) };
681
684
  });
682
- const place2 = ({ ranges: [first] }) => first === void 0 ? [Infinity, 0] : [_chunkND5XJVK2cjs.indexOfBlock.call(void 0, doc, first.block), first.from];
685
+ const place2 = ({ ranges: [first] }) => first === void 0 ? [Infinity, 0] : [_chunk4SLJNZSMcjs.indexOfBlock.call(void 0, doc, first.block), first.from];
683
686
  return entries.map((entry, order) => ({ entry, order, at: place2(entry) })).sort((a, b) => a.at[0] - b.at[0] || a.at[1] - b.at[1] || a.order - b.order).map(({ entry }) => entry);
684
687
  }
685
688
 
@@ -707,23 +710,23 @@ function ThreadChooser({ env, choices, onChoose }) {
707
710
 
708
711
  var docOf = (state) => state.doc;
709
712
  function focusIsOurs(controller, content) {
710
- const active = _nullishCoalesce(_optionalChain([content, 'optionalAccess', _58 => _58.ownerDocument, 'access', _59 => _59.activeElement]), () => ( null));
711
- return active === null || active === active.ownerDocument.body || _chunkWXMYDXPNcjs.ownsNode.call(void 0, controller, active);
713
+ const active = _nullishCoalesce(_optionalChain([content, 'optionalAccess', _62 => _62.ownerDocument, 'access', _63 => _63.activeElement]), () => ( null));
714
+ return active === null || active === active.ownerDocument.body || _chunk73653CJ4cjs.ownsNode.call(void 0, controller, active);
712
715
  }
713
716
  function ThreadPopover({ env, open, threads, onChoose, onClose }) {
714
717
  const { controller, labels } = env;
715
- const doc = _chunkGTTPVJSDcjs.useEditorState.call(void 0, controller, docOf);
718
+ const doc = _chunkP6KYXFZCcjs.useEditorState.call(void 0, controller, docOf);
716
719
  const anchors = commentAnchors(doc);
717
720
  const { ids } = open;
718
- const first = ids.map((id) => _optionalChain([anchors, 'access', _60 => _60.get, 'call', _61 => _61(id), 'optionalAccess', _62 => _62[0]])).find(Boolean);
721
+ const first = ids.map((id) => _optionalChain([anchors, 'access', _64 => _64.get, 'call', _65 => _65(id), 'optionalAccess', _66 => _66[0]])).find(Boolean);
719
722
  const latest = _react.useRef.call(void 0, first);
720
- _chunkGTTPVJSDcjs.useIsomorphicLayoutEffect.call(void 0, () => {
723
+ _chunkP6KYXFZCcjs.useIsomorphicLayoutEffect.call(void 0, () => {
721
724
  if (first) latest.current = first;
722
725
  });
723
726
  const anchor = _react.useMemo.call(void 0,
724
727
  () => ({
725
- current: _chunk2VDK27IFcjs.virtualAnchor.call(void 0,
726
- () => latest.current ? _chunk2VDK27IFcjs.rangeRect.call(void 0, controller, latest.current) : null,
728
+ current: _chunkCW3AFJBRcjs.virtualAnchor.call(void 0,
729
+ () => latest.current ? _chunkCW3AFJBRcjs.rangeRect.call(void 0, controller, latest.current) : null,
727
730
  () => latest.current && controller.registry.get(latest.current.block, latest.current.region)
728
731
  )
729
732
  }),
@@ -731,12 +734,12 @@ function ThreadPopover({ env, open, threads, onChoose, onClose }) {
731
734
  );
732
735
  const content = _react.useRef.call(void 0, null);
733
736
  const focusField = () => {
734
- const target = _optionalChain([content, 'access', _63 => _63.current, 'optionalAccess', _64 => _64.querySelector, 'call', _65 => _65(`[${REPLY_FIELD}], button`)]);
735
- if (focusIsOurs(controller, content.current) && !_optionalChain([content, 'access', _66 => _66.current, 'optionalAccess', _67 => _67.contains, 'call', _68 => _68(content.current.ownerDocument.activeElement)])) {
736
- _optionalChain([target, 'optionalAccess', _69 => _69.focus, 'call', _70 => _70()]);
737
+ const target = _optionalChain([content, 'access', _67 => _67.current, 'optionalAccess', _68 => _68.querySelector, 'call', _69 => _69(`[${REPLY_FIELD}], button`)]);
738
+ if (focusIsOurs(controller, content.current) && !_optionalChain([content, 'access', _70 => _70.current, 'optionalAccess', _71 => _71.contains, 'call', _72 => _72(content.current.ownerDocument.activeElement)])) {
739
+ _optionalChain([target, 'optionalAccess', _73 => _73.focus, 'call', _74 => _74()]);
737
740
  }
738
741
  };
739
- _chunkGTTPVJSDcjs.useIsomorphicLayoutEffect.call(void 0, () => {
742
+ _chunkP6KYXFZCcjs.useIsomorphicLayoutEffect.call(void 0, () => {
740
743
  if (open.focus) focusField();
741
744
  }, [open]);
742
745
  if (first === void 0 && latest.current === void 0) return null;
@@ -751,13 +754,13 @@ function ThreadPopover({ env, open, threads, onChoose, onClose }) {
751
754
  const onEscape = (event) => {
752
755
  event.preventDefault();
753
756
  event.stopPropagation();
754
- const inside = _nullishCoalesce(_optionalChain([content, 'access', _71 => _71.current, 'optionalAccess', _72 => _72.contains, 'call', _73 => _73(content.current.ownerDocument.activeElement)]), () => ( false));
757
+ const inside = _nullishCoalesce(_optionalChain([content, 'access', _75 => _75.current, 'optionalAccess', _76 => _76.contains, 'call', _77 => _77(content.current.ownerDocument.activeElement)]), () => ( false));
755
758
  onClose();
756
759
  if (inside) backToText();
757
760
  };
758
- const choices = ids.map((id) => ({ id, anchorText: textOf(id), preview: _nullishCoalesce(_optionalChain([threads, 'access', _74 => _74.find, 'call', _75 => _75(id), 'optionalAccess', _76 => _76.comments, 'access', _77 => _77[0], 'optionalAccess', _78 => _78.body]), () => ( "")) }));
761
+ const choices = ids.map((id) => ({ id, anchorText: textOf(id), preview: _nullishCoalesce(_optionalChain([threads, 'access', _78 => _78.find, 'call', _79 => _79(id), 'optionalAccess', _80 => _80.comments, 'access', _81 => _81[0], 'optionalAccess', _82 => _82.body]), () => ( "")) }));
759
762
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
760
- _chunk2VDK27IFcjs.Popover,
763
+ _chunkCW3AFJBRcjs.Popover,
761
764
  {
762
765
  open: true,
763
766
  modal: false,
@@ -765,9 +768,9 @@ function ThreadPopover({ env, open, threads, onChoose, onClose }) {
765
768
  if (!next) onClose();
766
769
  },
767
770
  children: [
768
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2VDK27IFcjs.PopoverAnchor, { virtualRef: anchor }),
771
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkCW3AFJBRcjs.PopoverAnchor, { virtualRef: anchor }),
769
772
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
770
- _chunk2VDK27IFcjs.PopoverContent,
773
+ _chunkCW3AFJBRcjs.PopoverContent,
771
774
  {
772
775
  ref: content,
773
776
  "aria-label": gone ? labels.textRemoved : single ? labels.thread(textOf(ids[0])) : labels.threadsHere,
@@ -797,7 +800,7 @@ function idsUnder(root, target) {
797
800
  while (element !== null && root.contains(element)) {
798
801
  const id = element.getAttribute("data-comment");
799
802
  if (id) ids.push(id);
800
- element = _nullishCoalesce(_optionalChain([element, 'access', _79 => _79.parentElement, 'optionalAccess', _80 => _80.closest, 'call', _81 => _81("[data-comment]")]), () => ( null));
803
+ element = _nullishCoalesce(_optionalChain([element, 'access', _83 => _83.parentElement, 'optionalAccess', _84 => _84.closest, 'call', _85 => _85("[data-comment]")]), () => ( null));
801
804
  }
802
805
  return ids;
803
806
  }
@@ -805,7 +808,7 @@ function useAnchorClicks(controller, threads) {
805
808
  _react.useEffect.call(void 0, () => {
806
809
  const onClick = (event) => {
807
810
  const root = controller.root;
808
- if (root === null || event.defaultPrevented || !_optionalChain([root, 'access', _82 => _82.ownerDocument, 'access', _83 => _83.getSelection, 'call', _84 => _84(), 'optionalAccess', _85 => _85.isCollapsed])) return;
811
+ if (root === null || event.defaultPrevented || !_optionalChain([root, 'access', _86 => _86.ownerDocument, 'access', _87 => _87.getSelection, 'call', _88 => _88(), 'optionalAccess', _89 => _89.isCollapsed])) return;
809
812
  const { editor } = controller;
810
813
  const ids = openIds(editor.state, threads, idsUnder(root, event.target));
811
814
  if (ids.length === 0) return;
@@ -819,10 +822,10 @@ function useAnchorClicks(controller, threads) {
819
822
  // src/extensions/comments/use-canvas-wide.ts
820
823
 
821
824
  var WIDE_CANVAS = 800;
822
- function useCanvasWide(box) {
823
- const [wide, setWide] = _react.useState.call(void 0, false);
824
- _chunkGTTPVJSDcjs.useIsomorphicLayoutEffect.call(void 0, () => {
825
- const canvas = _optionalChain([box, 'access', _86 => _86.current, 'optionalAccess', _87 => _87.parentElement]);
825
+ function useCanvasWide(box, initial) {
826
+ const [wide, setWide] = _react.useState.call(void 0, initial);
827
+ _chunkP6KYXFZCcjs.useIsomorphicLayoutEffect.call(void 0, () => {
828
+ const canvas = _optionalChain([box, 'access', _90 => _90.current, 'optionalAccess', _91 => _91.parentElement]);
826
829
  if (!canvas) return void 0;
827
830
  const measure = () => setWide(canvas.offsetWidth >= WIDE_CANVAS);
828
831
  measure();
@@ -841,21 +844,21 @@ function useThreads(threads) {
841
844
 
842
845
  // src/extensions/comments/CommentsOverlay.tsx
843
846
 
844
- var commentsOf = (state) => _chunkPZ4GT5JOcjs.getPluginState.call(void 0, state, commentsKey);
847
+ var commentsOf = (state) => _chunkZKVOS57Qcjs.getPluginState.call(void 0, state, commentsKey);
845
848
  var docOf2 = (state) => state.doc;
846
849
  function CommentsOverlay({ controller, host, labels }) {
847
- const { onError } = _chunk2VDK27IFcjs.useQuoin.call(void 0, );
850
+ const { onError } = _chunkCW3AFJBRcjs.useQuoin.call(void 0, );
848
851
  const link = linkOf(controller.editor);
849
- _chunkGTTPVJSDcjs.useIsomorphicLayoutEffect.call(void 0, () => {
852
+ _chunkP6KYXFZCcjs.useIsomorphicLayoutEffect.call(void 0, () => {
850
853
  link.report = onError;
851
854
  }, [link, onError]);
852
855
  useAnchorClicks(controller, host.threads);
853
856
  const threads = useThreads(host.threads);
854
- const value = _chunkGTTPVJSDcjs.useEditorState.call(void 0, controller, commentsOf);
855
- const doc = _chunkGTTPVJSDcjs.useEditorState.call(void 0, controller, docOf2);
857
+ const value = _chunkP6KYXFZCcjs.useEditorState.call(void 0, controller, commentsOf);
858
+ const doc = _chunkP6KYXFZCcjs.useEditorState.call(void 0, controller, docOf2);
856
859
  const entries = _react.useMemo.call(void 0, () => railEntries(doc, threads, value.ended), [doc, threads, value.ended]);
857
860
  const box = _react.useRef.call(void 0, null);
858
- const wide = useCanvasWide(box);
861
+ const wide = useCanvasWide(box, host.initialLayout === "wide");
859
862
  const [sheet, setSheet] = _react.useState.call(void 0, false);
860
863
  const opener = _react.useRef.call(void 0, null);
861
864
  _react.useEffect.call(void 0, () => {
@@ -873,7 +876,7 @@ function CommentsOverlay({ controller, host, labels }) {
873
876
  setSheet(true);
874
877
  };
875
878
  const returnFocus = () => {
876
- if (_optionalChain([opener, 'access', _88 => _88.current, 'optionalAccess', _89 => _89.isConnected])) opener.current.focus();
879
+ if (_optionalChain([opener, 'access', _92 => _92.current, 'optionalAccess', _93 => _93.isConnected])) opener.current.focus();
877
880
  else controller.focus();
878
881
  };
879
882
  const closeSheet = () => {
@@ -912,15 +915,24 @@ var ACTIVE = { class: "quoin-comment-active" };
912
915
  var inline = (ranges, attrs) => ranges.map((range) => ({ kind: "inline", ...range, attrs }));
913
916
  var drawn = /* @__PURE__ */ new WeakMap();
914
917
  function commentsDecorations(state) {
915
- const value = _chunkPZ4GT5JOcjs.getPluginState.call(void 0, state, commentsKey);
918
+ const value = _chunkZKVOS57Qcjs.getPluginState.call(void 0, state, commentsKey);
916
919
  const last = drawn.get(value);
917
- if (_optionalChain([last, 'optionalAccess', _90 => _90.doc]) === state.doc) return last.decorations;
920
+ if (_optionalChain([last, 'optionalAccess', _94 => _94.doc]) === state.doc) return last.decorations;
918
921
  const active = value.active === null ? [] : _nullishCoalesce(commentAnchors(state.doc).get(value.active), () => ( []));
919
922
  const decorations = [...value.pending.flatMap(({ ranges }) => inline(ranges, PENDING)), ...inline(active, ACTIVE)];
920
923
  drawn.set(value, { doc: state.doc, decorations });
921
924
  return decorations;
922
925
  }
923
926
 
927
+ // src/extensions/comments/watch-ended.ts
928
+ function watchEnded(editor, threads) {
929
+ return threads.subscribe(() => {
930
+ const { ended } = _chunkZKVOS57Qcjs.getPluginState.call(void 0, editor.state, commentsKey);
931
+ const kept = ended.filter(({ id }) => isEnded(ended, id, threads.find(id)));
932
+ if (kept.length < ended.length) editor.dispatch(commentsTransaction(editor.state, { type: "caught", kept }));
933
+ });
934
+ }
935
+
924
936
  // src/extensions/comments/comments-extension.tsx
925
937
 
926
938
  var commentItem = (labels) => ({
@@ -928,7 +940,7 @@ var commentItem = (labels) => ({
928
940
  title: labels.comment,
929
941
  icon: _lucidereact.MessageSquarePlus,
930
942
  shortcut: "Mod-Alt-m",
931
- available: (state) => hasCommentableText(state) && _chunkPZ4GT5JOcjs.getPluginState.call(void 0, state, commentsKey).pending.length === 0,
943
+ available: (state) => hasCommentableText(state) && _chunkZKVOS57Qcjs.getPluginState.call(void 0, state, commentsKey).pending.length === 0,
932
944
  // Focus goes back to the text first: the button leaves the toolbar while the thread is being asked for.
933
945
  run: (controller) => {
934
946
  controller.focus();
@@ -942,7 +954,7 @@ function commentsExtension(options) {
942
954
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CommentsOverlay, { controller, host, labels });
943
955
  }
944
956
  const ui = { bubbleItems: [commentItem(labels)], overlays: [Overlay] };
945
- return _chunkPZ4GT5JOcjs.defineExtension.call(void 0, {
957
+ return _chunkZKVOS57Qcjs.defineExtension.call(void 0, {
946
958
  name: "comments",
947
959
  plugins: [commentsPlugin],
948
960
  decorations: commentsDecorations,
@@ -950,10 +962,13 @@ function commentsExtension(options) {
950
962
  // One watcher per editor however many views mount it at once, so the host is asked once per thread.
951
963
  onMount(editor) {
952
964
  const link = linkOf(editor);
953
- if (link.mounts++ === 0) link.stopWatching = watchCreates(editor, host.onCreate, link);
965
+ if (link.mounts++ === 0) {
966
+ const stops = [watchCreates(editor, host.onCreate, link), watchEnded(editor, host.threads)];
967
+ link.stopWatching = () => stops.forEach((stop) => stop());
968
+ }
954
969
  return () => {
955
970
  if (--link.mounts > 0) return;
956
- _optionalChain([link, 'access', _91 => _91.stopWatching, 'optionalCall', _92 => _92()]);
971
+ _optionalChain([link, 'access', _95 => _95.stopWatching, 'optionalCall', _96 => _96()]);
957
972
  link.stopWatching = null;
958
973
  };
959
974
  },