quoin-editor 1.7.0 → 2.0.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 (260) hide show
  1. package/CHANGELOG.md +21 -1
  2. package/MIGRATION.md +137 -23
  3. package/README.md +32 -11
  4. package/dist/ai-labels-BXX32H9a.d.cts +53 -0
  5. package/dist/ai-labels-BXX32H9a.d.ts +53 -0
  6. package/dist/ai.cjs +84 -86
  7. package/dist/ai.d.cts +4 -53
  8. package/dist/ai.d.ts +4 -53
  9. package/dist/ai.js +8 -10
  10. package/dist/ai.js.map +1 -1
  11. package/dist/catalogue.cjs +27 -26
  12. package/dist/catalogue.d.cts +10 -1
  13. package/dist/catalogue.d.ts +10 -1
  14. package/dist/catalogue.js +18 -17
  15. package/dist/catalogue.js.map +1 -1
  16. package/dist/{chunk-MNA7MBCH.js → chunk-2UKI26JA.js} +9 -11
  17. package/dist/chunk-2UKI26JA.js.map +1 -0
  18. package/dist/{chunk-MZXW2HXP.cjs → chunk-4PIJC4FD.cjs} +27 -29
  19. package/dist/{chunk-OS2O6IKX.js → chunk-5RBMZGKV.js} +4 -4
  20. package/dist/{chunk-OS2O6IKX.js.map → chunk-5RBMZGKV.js.map} +1 -1
  21. package/dist/{chunk-OJ4O6HWC.js → chunk-5X52BAZB.js} +10 -12
  22. package/dist/chunk-5X52BAZB.js.map +1 -0
  23. package/dist/{chunk-JY5VUHKN.cjs → chunk-5YAJZSTI.cjs} +28 -30
  24. package/dist/{chunk-YEFPH27F.cjs → chunk-66OPHDFA.cjs} +92 -94
  25. package/dist/{chunk-PWUFFHAQ.js → chunk-6BVE46K7.js} +8 -10
  26. package/dist/chunk-6BVE46K7.js.map +1 -0
  27. package/dist/{chunk-LKZJ2TDU.cjs → chunk-77CNOLHY.cjs} +10 -13
  28. package/dist/{chunk-4T4TJ2QS.cjs → chunk-7E43TURF.cjs} +7 -7
  29. package/dist/{chunk-BJTOLCRR.js → chunk-7Y4B7NHO.js} +2 -2
  30. package/dist/chunk-7Y4B7NHO.js.map +1 -0
  31. package/dist/{chunk-7GU25Z6L.js → chunk-B4VCDJSA.js} +9 -11
  32. package/dist/chunk-B4VCDJSA.js.map +1 -0
  33. package/dist/{chunk-QR2NIDUK.cjs → chunk-BYYCD54G.cjs} +2 -2
  34. package/dist/{chunk-6T5YGCZ5.cjs → chunk-CJVJNMOB.cjs} +302 -299
  35. package/dist/{chunk-CSKKSXCE.js → chunk-CSPCDVCT.js} +3 -3
  36. package/dist/{chunk-CSKKSXCE.js.map → chunk-CSPCDVCT.js.map} +1 -1
  37. package/dist/{chunk-BF7733XS.cjs → chunk-D6CIIWCU.cjs} +57 -59
  38. package/dist/{chunk-GHNQKJMD.js → chunk-DBOZFNWU.js} +3 -3
  39. package/dist/{chunk-GHNQKJMD.js.map → chunk-DBOZFNWU.js.map} +1 -1
  40. package/dist/{chunk-BM2GRZNM.cjs → chunk-DJU25PFC.cjs} +11 -11
  41. package/dist/chunk-DLQCTGC3.js +10 -0
  42. package/dist/chunk-DLQCTGC3.js.map +1 -0
  43. package/dist/{chunk-RQXJKJ5S.js → chunk-EU5IGKMP.js} +7 -10
  44. package/dist/chunk-EU5IGKMP.js.map +1 -0
  45. package/dist/{chunk-VZZPCYA3.cjs → chunk-FK7EBZPX.cjs} +226 -226
  46. package/dist/{chunk-BXSWZEA5.js → chunk-GPTJYWGS.js} +3 -3
  47. package/dist/{chunk-BXSWZEA5.js.map → chunk-GPTJYWGS.js.map} +1 -1
  48. package/dist/{chunk-I722LBD3.cjs → chunk-HOSDMHK6.cjs} +32 -34
  49. package/dist/{chunk-AZF7B2AE.cjs → chunk-IKZSCTRF.cjs} +11 -11
  50. package/dist/{chunk-R7MYG522.js → chunk-IW4TMECB.js} +3 -3
  51. package/dist/{chunk-R7MYG522.js.map → chunk-IW4TMECB.js.map} +1 -1
  52. package/dist/{chunk-PLUMKN4B.js → chunk-J2SVYBTC.js} +10 -12
  53. package/dist/chunk-J2SVYBTC.js.map +1 -0
  54. package/dist/{chunk-UZS3TW75.js → chunk-KQPZTSW3.js} +9 -11
  55. package/dist/chunk-KQPZTSW3.js.map +1 -0
  56. package/dist/{chunk-STKGRXSA.cjs → chunk-LEICOZYK.cjs} +15 -17
  57. package/dist/{chunk-H3C3MJW5.cjs → chunk-LM3DHROX.cjs} +2 -2
  58. package/dist/{chunk-AD3NY7NA.js → chunk-LSI4RMTY.js} +3 -3
  59. package/dist/{chunk-AD3NY7NA.js.map → chunk-LSI4RMTY.js.map} +1 -1
  60. package/dist/{chunk-QOIVLYMW.js → chunk-M77A3EGD.js} +5 -5
  61. package/dist/{chunk-QOIVLYMW.js.map → chunk-M77A3EGD.js.map} +1 -1
  62. package/dist/{chunk-5JEQZIRI.js → chunk-MAS4AEF4.js} +8 -10
  63. package/dist/chunk-MAS4AEF4.js.map +1 -0
  64. package/dist/{chunk-KDK2ATMB.cjs → chunk-NFO3W644.cjs} +51 -53
  65. package/dist/{chunk-XFEDJEJF.js → chunk-NL5J77VD.js} +204 -204
  66. package/dist/chunk-NL5J77VD.js.map +1 -0
  67. package/dist/{chunk-WN7BZDNH.cjs → chunk-PURYVDC3.cjs} +13 -13
  68. package/dist/{chunk-G25FMFEZ.js → chunk-UDBLZILE.js} +4 -4
  69. package/dist/{chunk-G25FMFEZ.js.map → chunk-UDBLZILE.js.map} +1 -1
  70. package/dist/{chunk-FNJOPGMN.cjs → chunk-V4WQG7FR.cjs} +116 -118
  71. package/dist/{chunk-IJKGF6SC.js → chunk-YABGWOAV.js} +8 -10
  72. package/dist/chunk-YABGWOAV.js.map +1 -0
  73. package/dist/{chunk-XZ4NC3Q7.cjs → chunk-YEDPBYO5.cjs} +4 -4
  74. package/dist/{chunk-QJ34MOFV.cjs → chunk-Z6LAARPB.cjs} +315 -320
  75. package/dist/{chunk-HSLOPJVT.js → chunk-ZN5DHNSL.js} +19 -16
  76. package/dist/chunk-ZN5DHNSL.js.map +1 -0
  77. package/dist/chunk-ZWTIRGY5.cjs +10 -0
  78. package/dist/comments-labels-DWqsSz8G.d.cts +30 -0
  79. package/dist/comments-labels-DWqsSz8G.d.ts +30 -0
  80. package/dist/comments.cjs +63 -65
  81. package/dist/comments.d.cts +4 -30
  82. package/dist/comments.d.ts +4 -30
  83. package/dist/comments.js +9 -11
  84. package/dist/comments.js.map +1 -1
  85. package/dist/{diagram-extension-Da7hp-tv.d.ts → diagram-extension-22x_njXB.d.ts} +4 -12
  86. package/dist/{diagram-extension-D573COJv.d.cts → diagram-extension-C_FSkoj9.d.cts} +4 -12
  87. package/dist/diagram-labels-Bi_jEZ8_.d.cts +11 -0
  88. package/dist/diagram-labels-Bi_jEZ8_.d.ts +11 -0
  89. package/dist/diagram.cjs +10 -9
  90. package/dist/diagram.d.cts +3 -2
  91. package/dist/diagram.d.ts +3 -2
  92. package/dist/diagram.js +7 -6
  93. package/dist/diff-labels-DWwg7N0n.d.cts +27 -0
  94. package/dist/diff-labels-DWwg7N0n.d.ts +27 -0
  95. package/dist/diff.cjs +27 -29
  96. package/dist/diff.d.cts +4 -27
  97. package/dist/diff.d.ts +4 -27
  98. package/dist/diff.js +5 -7
  99. package/dist/diff.js.map +1 -1
  100. package/dist/docx.cjs +30 -30
  101. package/dist/docx.js +3 -3
  102. package/dist/embed-labels-BiVa9HYl.d.cts +23 -0
  103. package/dist/embed-labels-BiVa9HYl.d.ts +23 -0
  104. package/dist/embed.cjs +10 -9
  105. package/dist/embed.d.cts +4 -23
  106. package/dist/embed.d.ts +4 -23
  107. package/dist/embed.js +8 -7
  108. package/dist/emoji-extension-C832oGeT.d.ts +16 -0
  109. package/dist/emoji-extension-Dk5IQLZf.d.cts +16 -0
  110. package/dist/{emoji-extension-gRKnbW8G.d.ts → emoji-labels-YwOms7ZJ.d.cts} +2 -15
  111. package/dist/{emoji-extension-C3o_Y5uC.d.cts → emoji-labels-YwOms7ZJ.d.ts} +2 -15
  112. package/dist/emoji.cjs +10 -9
  113. package/dist/emoji.d.cts +4 -3
  114. package/dist/emoji.d.ts +4 -3
  115. package/dist/emoji.js +7 -6
  116. package/dist/engine.cjs +58 -58
  117. package/dist/engine.d.cts +8 -7
  118. package/dist/engine.d.ts +8 -7
  119. package/dist/engine.js +3 -3
  120. package/dist/find-extension-BfruAPLi.d.cts +15 -0
  121. package/dist/find-extension-DmK9_N81.d.ts +15 -0
  122. package/dist/{find-extension-B_Ctrs6T.d.ts → find-labels-C4vs8Qe9.d.cts} +2 -14
  123. package/dist/{find-extension-BGGsJMu4.d.cts → find-labels-C4vs8Qe9.d.ts} +2 -14
  124. package/dist/find.cjs +11 -10
  125. package/dist/find.d.cts +2 -1
  126. package/dist/find.d.ts +2 -1
  127. package/dist/find.js +7 -6
  128. package/dist/headless.cjs +69 -89
  129. package/dist/headless.d.cts +21 -28
  130. package/dist/headless.d.ts +21 -28
  131. package/dist/headless.js +4 -4
  132. package/dist/highlight.cjs +7 -6
  133. package/dist/highlight.js +6 -5
  134. package/dist/highlight.js.map +1 -1
  135. package/dist/{index-CsG7OQoq.d.cts → index-3fYvwqUZ.d.cts} +1 -1
  136. package/dist/{index-h1llgZM-.d.ts → index-CgxnzCO5.d.ts} +1 -1
  137. package/dist/index.cjs +82 -101
  138. package/dist/index.d.cts +18 -185
  139. package/dist/index.d.ts +18 -185
  140. package/dist/index.js +6 -5
  141. package/dist/labels-BhRJYo46.d.ts +176 -0
  142. package/dist/labels-CiCxj2jP.d.cts +176 -0
  143. package/dist/locale-ar.cjs +565 -0
  144. package/dist/locale-ar.d.cts +63 -0
  145. package/dist/locale-ar.d.ts +63 -0
  146. package/dist/locale-ar.js +551 -0
  147. package/dist/locale-ar.js.map +1 -0
  148. package/dist/locale-de.cjs +510 -0
  149. package/dist/locale-de.d.cts +63 -0
  150. package/dist/locale-de.d.ts +63 -0
  151. package/dist/locale-de.js +496 -0
  152. package/dist/locale-de.js.map +1 -0
  153. package/dist/locale-es.cjs +510 -0
  154. package/dist/locale-es.d.cts +63 -0
  155. package/dist/locale-es.d.ts +63 -0
  156. package/dist/locale-es.js +496 -0
  157. package/dist/locale-es.js.map +1 -0
  158. package/dist/locale-fr.cjs +510 -0
  159. package/dist/locale-fr.d.cts +63 -0
  160. package/dist/locale-fr.d.ts +63 -0
  161. package/dist/locale-fr.js +496 -0
  162. package/dist/locale-fr.js.map +1 -0
  163. package/dist/locale-ja.cjs +505 -0
  164. package/dist/locale-ja.d.cts +63 -0
  165. package/dist/locale-ja.d.ts +63 -0
  166. package/dist/locale-ja.js +491 -0
  167. package/dist/locale-ja.js.map +1 -0
  168. package/dist/locale-pt.cjs +511 -0
  169. package/dist/locale-pt.d.cts +63 -0
  170. package/dist/locale-pt.d.ts +63 -0
  171. package/dist/locale-pt.js +497 -0
  172. package/dist/locale-pt.js.map +1 -0
  173. package/dist/locale-zh.cjs +505 -0
  174. package/dist/locale-zh.d.cts +63 -0
  175. package/dist/locale-zh.d.ts +63 -0
  176. package/dist/locale-zh.js +491 -0
  177. package/dist/locale-zh.js.map +1 -0
  178. package/dist/math-labels-DOf5KFxp.d.cts +24 -0
  179. package/dist/math-labels-DOf5KFxp.d.ts +24 -0
  180. package/dist/math.cjs +11 -10
  181. package/dist/math.d.cts +4 -24
  182. package/dist/math.d.ts +4 -24
  183. package/dist/math.js +9 -8
  184. package/dist/mention-labels-DIQy8LRT.d.cts +15 -0
  185. package/dist/mention-labels-DIQy8LRT.d.ts +15 -0
  186. package/dist/mention.cjs +11 -10
  187. package/dist/mention.d.cts +4 -15
  188. package/dist/mention.d.ts +4 -15
  189. package/dist/mention.js +9 -8
  190. package/dist/{view-controller-p-2x3J7Y.d.ts → node-reveal-BnFcnHhz.d.ts} +14 -14
  191. package/dist/{view-controller-BfVSNZYZ.d.cts → node-reveal-DY6bimv3.d.cts} +14 -14
  192. package/dist/palette-BrX-hEd-.d.cts +4 -0
  193. package/dist/palette-BrX-hEd-.d.ts +4 -0
  194. package/dist/presence-labels-DXVJLifl.d.cts +15 -0
  195. package/dist/presence-labels-DXVJLifl.d.ts +15 -0
  196. package/dist/presence.cjs +40 -42
  197. package/dist/presence.d.cts +4 -15
  198. package/dist/presence.d.ts +4 -15
  199. package/dist/presence.js +9 -11
  200. package/dist/presence.js.map +1 -1
  201. package/dist/source-labels-CeQDXsYZ.d.cts +9 -0
  202. package/dist/source-labels-CeQDXsYZ.d.ts +9 -0
  203. package/dist/source.cjs +11 -14
  204. package/dist/source.d.cts +5 -10
  205. package/dist/source.d.ts +5 -10
  206. package/dist/source.js +7 -10
  207. package/dist/source.js.map +1 -1
  208. package/dist/{stats-extension-oD6D1cYy.d.ts → stats-extension-D5HySF0a.d.cts} +4 -16
  209. package/dist/{stats-extension-XqOTvRaq.d.cts → stats-extension-Dmw0Ujxe.d.ts} +4 -16
  210. package/dist/stats-labels-W8gep51s.d.cts +15 -0
  211. package/dist/stats-labels-W8gep51s.d.ts +15 -0
  212. package/dist/stats.cjs +11 -10
  213. package/dist/stats.d.cts +3 -2
  214. package/dist/stats.d.ts +3 -2
  215. package/dist/stats.js +8 -7
  216. package/dist/styles.css +2 -2
  217. package/dist/table-extension-7LkLNK6Q.d.cts +15 -0
  218. package/dist/table-extension-DEpV0DnP.d.ts +15 -0
  219. package/dist/{table-extension-v6VB59bF.d.ts → table-labels-Dc-MzU3j.d.cts} +2 -14
  220. package/dist/{table-extension-BP47hHoz.d.cts → table-labels-Dc-MzU3j.d.ts} +2 -14
  221. package/dist/table.cjs +26 -25
  222. package/dist/table.d.cts +2 -1
  223. package/dist/table.d.ts +2 -1
  224. package/dist/table.js +7 -6
  225. package/dist/{to-html-1oD-CDle.d.cts → to-html-C19PbIzh.d.cts} +1 -0
  226. package/dist/{to-html-CLRBCX0I.d.ts → to-html-CogwrQer.d.ts} +1 -0
  227. package/dist/{to-markdown-CFPMbbiX.d.cts → to-markdown-C2w7Dzg8.d.cts} +1 -0
  228. package/dist/{to-markdown-BVOzhgVM.d.ts → to-markdown-DC1EUye5.d.ts} +1 -0
  229. package/dist/toc-extension-Dvh37bWQ.d.cts +15 -0
  230. package/dist/toc-extension-SVckrFmb.d.ts +15 -0
  231. package/dist/toc-labels-B2apPfXG.d.cts +14 -0
  232. package/dist/toc-labels-B2apPfXG.d.ts +14 -0
  233. package/dist/toc.cjs +10 -9
  234. package/dist/toc.d.cts +3 -2
  235. package/dist/toc.d.ts +3 -2
  236. package/dist/toc.js +7 -6
  237. package/dist/{types-DXF9p4qV.d.cts → types-Bzhq5AXj.d.cts} +1 -0
  238. package/dist/{types-BjLcmV00.d.ts → types-DMuuDBVh.d.ts} +1 -0
  239. package/dist/view.cjs +4 -4
  240. package/dist/view.js +2 -2
  241. package/dist/yjs.cjs +121 -121
  242. package/dist/yjs.d.cts +2 -2
  243. package/dist/yjs.d.ts +2 -2
  244. package/dist/yjs.js +5 -5
  245. package/package.json +71 -1
  246. package/dist/chunk-5JEQZIRI.js.map +0 -1
  247. package/dist/chunk-7GU25Z6L.js.map +0 -1
  248. package/dist/chunk-BJTOLCRR.js.map +0 -1
  249. package/dist/chunk-HSLOPJVT.js.map +0 -1
  250. package/dist/chunk-IJKGF6SC.js.map +0 -1
  251. package/dist/chunk-MNA7MBCH.js.map +0 -1
  252. package/dist/chunk-OJ4O6HWC.js.map +0 -1
  253. package/dist/chunk-PLUMKN4B.js.map +0 -1
  254. package/dist/chunk-PWUFFHAQ.js.map +0 -1
  255. package/dist/chunk-RQXJKJ5S.js.map +0 -1
  256. package/dist/chunk-UZS3TW75.js.map +0 -1
  257. package/dist/chunk-XFEDJEJF.js.map +0 -1
  258. package/dist/toc-extension-CI6jNOYl.d.cts +0 -26
  259. package/dist/toc-extension-CTHWjNJC.d.ts +0 -26
  260. /package/dist/{chunk-WZA5S5EJ.cjs → chunk-I7X7B3WD.cjs} +0 -0
package/dist/ai.cjs CHANGED
@@ -2,13 +2,14 @@
2
2
  'use strict';
3
3
 
4
4
  var chunkLE5XMIFJ_cjs = require('./chunk-LE5XMIFJ.cjs');
5
- var chunkQR2NIDUK_cjs = require('./chunk-QR2NIDUK.cjs');
6
- var chunk6T5YGCZ5_cjs = require('./chunk-6T5YGCZ5.cjs');
7
- var chunkQJ34MOFV_cjs = require('./chunk-QJ34MOFV.cjs');
5
+ var chunkBYYCD54G_cjs = require('./chunk-BYYCD54G.cjs');
6
+ var chunkCJVJNMOB_cjs = require('./chunk-CJVJNMOB.cjs');
7
+ var chunkZ6LAARPB_cjs = require('./chunk-Z6LAARPB.cjs');
8
+ var chunkZWTIRGY5_cjs = require('./chunk-ZWTIRGY5.cjs');
8
9
  require('./chunk-A6PGQVTR.cjs');
9
- var chunkVZZPCYA3_cjs = require('./chunk-VZZPCYA3.cjs');
10
- require('./chunk-BM2GRZNM.cjs');
11
- var chunkWZA5S5EJ_cjs = require('./chunk-WZA5S5EJ.cjs');
10
+ var chunkFK7EBZPX_cjs = require('./chunk-FK7EBZPX.cjs');
11
+ require('./chunk-DJU25PFC.cjs');
12
+ var chunkI7X7B3WD_cjs = require('./chunk-I7X7B3WD.cjs');
12
13
  var react = require('react');
13
14
  var jsxRuntime = require('react/jsx-runtime');
14
15
 
@@ -109,30 +110,30 @@ function closeStreaming(markdown) {
109
110
  // src/extensions/ai/ai-target.ts
110
111
  function targetOfBlocks(state, ids) {
111
112
  const { doc, schema } = state;
112
- const first = chunkWZA5S5EJ_cjs.blockById(doc, ids[0]);
113
- const last = chunkWZA5S5EJ_cjs.blockById(doc, ids[ids.length - 1]);
113
+ const first = chunkI7X7B3WD_cjs.blockById(doc, ids[0]);
114
+ const last = chunkI7X7B3WD_cjs.blockById(doc, ids[ids.length - 1]);
114
115
  if (first === void 0 || last === void 0) return null;
115
- const start = chunkVZZPCYA3_cjs.primaryRegion(schema, first);
116
- const end = chunkVZZPCYA3_cjs.primaryRegion(schema, last);
116
+ const start = chunkFK7EBZPX_cjs.primaryRegion(schema, first);
117
+ const end = chunkFK7EBZPX_cjs.primaryRegion(schema, last);
117
118
  if (start === null || end === null) return null;
118
119
  const from = { block: first.id, region: start, offset: 0 };
119
- return { from, to: { block: last.id, region: end, offset: chunkVZZPCYA3_cjs.regionLength(last, end) }, selected: ids.length > 1 };
120
+ return { from, to: { block: last.id, region: end, offset: chunkFK7EBZPX_cjs.regionLength(last, end) }, selected: ids.length > 1 };
120
121
  }
121
122
  function targetOfSelection(state) {
122
123
  const { doc, selection } = state;
123
124
  if (selection === null) return null;
124
- if (selection.kind !== "text") return targetOfBlocks(state, chunkVZZPCYA3_cjs.selectedBlockIds(doc, selection));
125
- const { from, to } = chunkVZZPCYA3_cjs.orderedRange(doc, selection.anchor, selection.head);
126
- if (chunkVZZPCYA3_cjs.comparePos(doc, from, to) !== 0) return { from, to, selected: true };
125
+ if (selection.kind !== "text") return targetOfBlocks(state, chunkFK7EBZPX_cjs.selectedBlockIds(doc, selection));
126
+ const { from, to } = chunkFK7EBZPX_cjs.orderedRange(doc, selection.anchor, selection.head);
127
+ if (chunkFK7EBZPX_cjs.comparePos(doc, from, to) !== 0) return { from, to, selected: true };
127
128
  const block = doc.blocks[doc.index.get(from.block)];
128
129
  const whole = { block: from.block, region: from.region };
129
- return { from: { ...whole, offset: 0 }, to: { ...whole, offset: chunkVZZPCYA3_cjs.regionLength(block, from.region) }, selected: false };
130
+ return { from: { ...whole, offset: 0 }, to: { ...whole, offset: chunkFK7EBZPX_cjs.regionLength(block, from.region) }, selected: false };
130
131
  }
131
132
  function nearestKept(tr, target) {
132
133
  const { doc } = tr.before;
133
134
  const first = doc.index.get(target.from.block) ?? 0;
134
135
  const last = doc.index.get(target.to.block) ?? first;
135
- const kept = (block) => block && chunkWZA5S5EJ_cjs.blockById(tr.doc, block.id);
136
+ const kept = (block) => block && chunkI7X7B3WD_cjs.blockById(tr.doc, block.id);
136
137
  for (let step = 1; first - step >= 0 || last + step < doc.blocks.length; step++) {
137
138
  const found = kept(doc.blocks[first - step]) ?? kept(doc.blocks[last + step]);
138
139
  if (found) return found;
@@ -141,10 +142,10 @@ function nearestKept(tr, target) {
141
142
  }
142
143
  function edgeOf(tr, target) {
143
144
  const point = tr.mapPos(target.from, -1);
144
- const block = chunkWZA5S5EJ_cjs.blockById(tr.doc, point.block) ?? nearestKept(tr, target);
145
+ const block = chunkI7X7B3WD_cjs.blockById(tr.doc, point.block) ?? nearestKept(tr, target);
145
146
  if (block === void 0) return null;
146
- const region = chunkVZZPCYA3_cjs.primaryRegion(tr.before.schema, block) ?? "";
147
- const length = region === "" ? 0 : chunkVZZPCYA3_cjs.regionLength(block, region);
147
+ const region = chunkFK7EBZPX_cjs.primaryRegion(tr.before.schema, block) ?? "";
148
+ const length = region === "" ? 0 : chunkFK7EBZPX_cjs.regionLength(block, region);
148
149
  const offset = block.id === point.block ? Math.min(point.offset, length) : length;
149
150
  const after = offset > 0 || length === 0;
150
151
  const at = { block: block.id, region, offset: after ? length : 0 };
@@ -156,29 +157,29 @@ function mapTarget(tr, target) {
156
157
  const from = tr.mapPos(target.from, inside);
157
158
  const mapped2 = tr.mapPos(target.to, -inside);
158
159
  if (!tr.doc.index.has(from.block) || !tr.doc.index.has(mapped2.block)) return edgeOf(tr, target);
159
- const to = chunkVZZPCYA3_cjs.comparePos(tr.doc, from, mapped2) > 0 ? from : mapped2;
160
+ const to = chunkFK7EBZPX_cjs.comparePos(tr.doc, from, mapped2) > 0 ? from : mapped2;
160
161
  return from === target.from && to === target.to ? target : { ...target, from, to };
161
162
  }
162
- var targetGone = (doc, target) => target.lost !== void 0 || target.selected && chunkVZZPCYA3_cjs.comparePos(doc, target.from, target.to) === 0;
163
+ var targetGone = (doc, target) => target.lost !== void 0 || target.selected && chunkFK7EBZPX_cjs.comparePos(doc, target.from, target.to) === 0;
163
164
  function targetRanges(state, { from, to }) {
164
165
  const { doc, schema } = state;
165
166
  const start = doc.index.get(from.block);
166
167
  const end = doc.index.get(to.block);
167
168
  return doc.blocks.slice(start, end + 1).flatMap((block, i) => {
168
- const region = i === 0 ? from.region : block.id === to.block ? to.region : chunkVZZPCYA3_cjs.primaryRegion(schema, block);
169
+ const region = i === 0 ? from.region : block.id === to.block ? to.region : chunkFK7EBZPX_cjs.primaryRegion(schema, block);
169
170
  if (region === null || !Object.hasOwn(block.regions, region)) return [];
170
171
  const left = i === 0 ? from.offset : 0;
171
- const right = block.id === to.block ? to.offset : chunkVZZPCYA3_cjs.regionLength(block, region);
172
+ const right = block.id === to.block ? to.offset : chunkFK7EBZPX_cjs.regionLength(block, region);
172
173
  return right > left ? [{ block: block.id, region, from: left, to: right }] : [];
173
174
  });
174
175
  }
175
176
 
176
177
  // src/extensions/ai/ai-plugin.ts
177
- var aiKey = chunkVZZPCYA3_cjs.createPluginKey("ai");
178
+ var aiKey = chunkFK7EBZPX_cjs.createPluginKey("ai");
178
179
  var AI = "ai";
179
180
  var IDLE = { target: null, menu: null, ghost: null, held: [] };
180
- var aiState = (state) => chunkVZZPCYA3_cjs.getPluginState(state, aiKey);
181
- var aiTransaction = (state, act2) => new chunkVZZPCYA3_cjs.Transaction(state).setMeta(AI, act2).setMeta("addToHistory", false);
181
+ var aiState = (state) => chunkFK7EBZPX_cjs.getPluginState(state, aiKey);
182
+ var aiTransaction = (state, act2) => new chunkFK7EBZPX_cjs.Transaction(state).setMeta(AI, act2).setMeta("addToHistory", false);
182
183
  function written(ghost, key, phase, output) {
183
184
  return ghost.key !== key ? ghost : { ...ghost, phase, output, shown: closeStreaming(output) };
184
185
  }
@@ -210,8 +211,8 @@ function caretBlock(state) {
210
211
  return selection?.kind === "text" ? selection.head.block : null;
211
212
  }
212
213
  function hasText(state, id) {
213
- const block = chunkWZA5S5EJ_cjs.blockById(state.doc, id);
214
- return block !== void 0 && Object.keys(block.regions).some((region) => chunkVZZPCYA3_cjs.regionLength(block, region) > 0);
214
+ const block = chunkI7X7B3WD_cjs.blockById(state.doc, id);
215
+ return block !== void 0 && Object.keys(block.regions).some((region) => chunkFK7EBZPX_cjs.regionLength(block, region) > 0);
215
216
  }
216
217
  function heldText(tr, value, before, after) {
217
218
  if (!tr.docChanged) return value.held;
@@ -309,13 +310,13 @@ function aroundSelection(text, start, end, limit = CONTEXT_LIMIT) {
309
310
  }
310
311
  var WHITESPACE_ENTITY = /(?<!\\)&#(32|9);/g;
311
312
  var plain = (markdown) => markdown.replace(WHITESPACE_ENTITY, (_, code) => code === "32" ? " " : " ");
312
- var markdownOf = (state, blocks) => chunkVZZPCYA3_cjs.toMarkdown(blocks, { schema: state.schema, comments: false });
313
+ var markdownOf = (state, blocks) => chunkFK7EBZPX_cjs.toMarkdown(blocks, { schema: state.schema, comments: false });
313
314
  function rangeMarkdown(state, from, to) {
314
- const slice = chunkVZZPCYA3_cjs.sliceFromSelection({ ...state, selection: chunkVZZPCYA3_cjs.textSelection(from, to) }, chunkWZA5S5EJ_cjs.createBlockCodec(state.schema));
315
+ const slice = chunkFK7EBZPX_cjs.sliceFromSelection({ ...state, selection: chunkFK7EBZPX_cjs.textSelection(from, to) }, chunkI7X7B3WD_cjs.createBlockCodec(state.schema));
315
316
  return slice === null ? "" : markdownOf(state, slice.blocks).replace(/\n$/, "");
316
317
  }
317
318
  function documentContext(state, target, selection) {
318
- const blocks = chunkWZA5S5EJ_cjs.createBlockCodec(state.schema).blocksFromDoc(state.doc);
319
+ const blocks = chunkI7X7B3WD_cjs.createBlockCodec(state.schema).blocksFromDoc(state.doc);
319
320
  const full = plain(markdownOf(state, blocks));
320
321
  if (full.length <= CONTEXT_LIMIT) return full;
321
322
  const index = state.doc.index.get(target.from.block) ?? 0;
@@ -376,7 +377,7 @@ async function read(editor, link, run, stream, request) {
376
377
  } catch (error) {
377
378
  if (!live()) return;
378
379
  end("error");
379
- link.report(chunk6T5YGCZ5_cjs.toError(error));
380
+ link.report(chunkCJVJNMOB_cjs.toError(error));
380
381
  }
381
382
  }
382
383
  function startStream(editor, link, stream, request, replace) {
@@ -473,7 +474,7 @@ function aiSlashItems(labels, stream) {
473
474
  title: labels.askAi,
474
475
  description: labels.askAiDescription,
475
476
  group: "ai",
476
- icon: chunk6T5YGCZ5_cjs.Sparkles,
477
+ icon: chunkCJVJNMOB_cjs.Sparkles,
477
478
  keywords: KEYWORDS,
478
479
  run: ({ controller }) => void openFor(controller)
479
480
  },
@@ -481,7 +482,7 @@ function aiSlashItems(labels, stream) {
481
482
  id: "ai-continue",
482
483
  title: labels.actions.continue,
483
484
  group: "ai",
484
- icon: chunk6T5YGCZ5_cjs.PenLine,
485
+ icon: chunkCJVJNMOB_cjs.PenLine,
485
486
  keywords: [...KEYWORDS, "continue"],
486
487
  run: ({ controller }) => {
487
488
  if (openFor(controller)) askFrom({ controller, stream}, "continue");
@@ -492,14 +493,14 @@ function aiSlashItems(labels, stream) {
492
493
  var aiBubbleItem = (labels) => ({
493
494
  id: "ai",
494
495
  title: labels.askAi,
495
- icon: chunk6T5YGCZ5_cjs.Sparkles,
496
+ icon: chunkCJVJNMOB_cjs.Sparkles,
496
497
  available: (state) => aiState(state).ghost === null,
497
498
  run: (controller) => void openFor(controller)
498
499
  });
499
500
  var aiBlockMenuItem = (labels) => ({
500
501
  id: "ai",
501
502
  label: labels.askAi,
502
- icon: chunk6T5YGCZ5_cjs.Sparkles,
503
+ icon: chunkCJVJNMOB_cjs.Sparkles,
503
504
  available: (state, blockIds) => targetOfBlocks(state, blockIds) !== null,
504
505
  run: (controller, blockIds) => {
505
506
  const target = targetOfBlocks(controller.editor.state, blockIds);
@@ -542,34 +543,31 @@ var englishAiLabels = {
542
543
  halted: (text) => `Stopped. AI response so far: ${text}`,
543
544
  targetGone: "The text this was for was removed, so Accept inserts it where that text was"
544
545
  };
545
- function resolveAiLabels(overrides) {
546
- const given = Object.entries(overrides ?? {}).filter(([, value]) => value !== void 0);
547
- return given.length === 0 ? englishAiLabels : { ...englishAiLabels, ...Object.fromEntries(given) };
548
- }
546
+ var resolveAiLabels = (overrides) => chunkZWTIRGY5_cjs.mergeLabels(englishAiLabels, overrides);
549
547
 
550
548
  // src/extensions/ai/ai-space.ts
551
549
  var openOnSpace = (state, dispatch) => {
552
550
  const { selection, doc } = state;
553
551
  const ai = aiState(state);
554
- if (selection?.kind !== "text" || !chunkVZZPCYA3_cjs.isCollapsed(selection) || ai.menu !== null || ai.ghost !== null) return false;
552
+ if (selection?.kind !== "text" || !chunkFK7EBZPX_cjs.isCollapsed(selection) || ai.menu !== null || ai.ghost !== null) return false;
555
553
  const { head } = selection;
556
554
  const block = doc.blocks[doc.index.get(head.block)];
557
555
  const paragraph = block.type === "MARKDOWN" && block.attrs.kind === "paragraph";
558
- if (!paragraph || chunkVZZPCYA3_cjs.regionLength(block, head.region) > 0 || ai.held.includes(block.id)) return false;
556
+ if (!paragraph || chunkFK7EBZPX_cjs.regionLength(block, head.region) > 0 || ai.held.includes(block.id)) return false;
559
557
  dispatch?.(aiTransaction(state, { type: "open", target: { from: head, to: head, selected: false }, fromSpace: true }));
560
558
  return true;
561
559
  };
562
560
 
563
561
  // src/extensions/ai/ai-accept.ts
564
- var isParagraph = (block) => block?.type === "MARKDOWN" && chunkWZA5S5EJ_cjs.parseLine(String(block.data.markdown ?? "")).kind === "paragraph";
562
+ var isParagraph = (block) => block?.type === "MARKDOWN" && chunkI7X7B3WD_cjs.parseLine(String(block.data.markdown ?? "")).kind === "paragraph";
565
563
  var DISCARD = { type: "discard" };
566
564
  function insertBeside(tr, schema, target, pieces, makeId) {
567
565
  const index = tr.doc.index.get(target.to.block);
568
- const at = target.lost?.after ? chunkVZZPCYA3_cjs.descendantsEnd(tr.doc, index) : index;
569
- const fresh = chunkVZZPCYA3_cjs.freshBlocks(pieces, tr.doc.blocks[index].indent, makeId);
570
- tr.step(chunkVZZPCYA3_cjs.insertBlocksStep(at, fresh));
571
- chunkVZZPCYA3_cjs.capIndents(tr, at, at + fresh.length);
572
- tr.setSelection(chunkVZZPCYA3_cjs.endOf(tr.doc, schema, fresh[fresh.length - 1].id));
566
+ const at = target.lost?.after ? chunkFK7EBZPX_cjs.descendantsEnd(tr.doc, index) : index;
567
+ const fresh = chunkFK7EBZPX_cjs.freshBlocks(pieces, tr.doc.blocks[index].indent, makeId);
568
+ tr.step(chunkFK7EBZPX_cjs.insertBlocksStep(at, fresh));
569
+ chunkFK7EBZPX_cjs.capIndents(tr, at, at + fresh.length);
570
+ tr.setSelection(chunkFK7EBZPX_cjs.endOf(tr.doc, schema, fresh[fresh.length - 1].id));
573
571
  }
574
572
  function acceptAnswer(editor) {
575
573
  const { state } = editor;
@@ -577,7 +575,7 @@ function acceptAnswer(editor) {
577
575
  if (target === null || ghost === null || ghost.phase === "streaming" || ghost.phase === "error") return null;
578
576
  const { codec } = editor;
579
577
  const makeId = codec.context.newId;
580
- const blocks = chunkWZA5S5EJ_cjs.fromMarkdown(ghost.output, { newId: makeId });
578
+ const blocks = chunkI7X7B3WD_cjs.fromMarkdown(ghost.output, { newId: makeId });
581
579
  const pieces = blocks.flatMap((block) => codec.toEngineBlocks(block));
582
580
  const tr = editor.createTransaction().setOrigin("ai").setMeta(AI, DISCARD);
583
581
  const gone = targetGone(state.doc, target);
@@ -587,12 +585,12 @@ function acceptAnswer(editor) {
587
585
  const { schema } = state;
588
586
  const open = { openStart: isParagraph(blocks[0]), openEnd: isParagraph(blocks[blocks.length - 1]) };
589
587
  if (ghost.replace || gone) {
590
- const caret = ghost.replace && !gone ? chunkVZZPCYA3_cjs.deleteRange(tr, schema, target.from, target.to, makeId) : target.to;
591
- chunkVZZPCYA3_cjs.pasteAtCaret(tr, schema, caret, open, pieces, makeId);
588
+ const caret = ghost.replace && !gone ? chunkFK7EBZPX_cjs.deleteRange(tr, schema, target.from, target.to, makeId) : target.to;
589
+ chunkFK7EBZPX_cjs.pasteAtCaret(tr, schema, caret, open, pieces, makeId);
592
590
  } else {
593
591
  const block = tr.doc.blocks[tr.doc.index.get(target.to.block)];
594
- const end = { ...target.to, offset: chunkVZZPCYA3_cjs.regionLength(block, target.to.region) };
595
- chunkVZZPCYA3_cjs.pasteAtCaret(tr, schema, end, { openStart: false, openEnd: false }, pieces, makeId);
592
+ const end = { ...target.to, offset: chunkFK7EBZPX_cjs.regionLength(block, target.to.region) };
593
+ chunkFK7EBZPX_cjs.pasteAtCaret(tr, schema, end, { openStart: false, openEnd: false }, pieces, makeId);
596
594
  }
597
595
  }
598
596
  editor.dispatch(tr);
@@ -607,12 +605,12 @@ function AiBar({ env, ghost, gone, barId }) {
607
605
  const [next, setNext] = react.useState("");
608
606
  const { phase } = ghost;
609
607
  const focusPrimary = () => content.current?.querySelector(`[${PRIMARY}]`)?.focus();
610
- chunkQJ34MOFV_cjs.useIsomorphicLayoutEffect(() => {
608
+ chunkZ6LAARPB_cjs.useIsomorphicLayoutEffect(() => {
611
609
  const active = content.current?.ownerDocument.activeElement;
612
610
  inside.current = active == null || active === active.ownerDocument.body;
613
611
  if (inside.current) focusPrimary();
614
612
  }, []);
615
- chunkQJ34MOFV_cjs.useIsomorphicLayoutEffect(() => {
613
+ chunkZ6LAARPB_cjs.useIsomorphicLayoutEffect(() => {
616
614
  const active = content.current?.ownerDocument.activeElement;
617
615
  if (inside.current && !content.current?.contains(active ?? null)) focusPrimary();
618
616
  }, [phase, ghost.key]);
@@ -660,21 +658,21 @@ function AiBar({ env, ghost, gone, barId }) {
660
658
  children: [
661
659
  phase === "streaming" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
662
660
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-muted-foreground", children: labels.writing }),
663
- /* @__PURE__ */ jsxRuntime.jsx(chunk6T5YGCZ5_cjs.Button, { ...primary, size: "sm", variant: "outline", onClick: () => stop(editor), children: labels.stop })
661
+ /* @__PURE__ */ jsxRuntime.jsx(chunkCJVJNMOB_cjs.Button, { ...primary, size: "sm", variant: "outline", onClick: () => stop(editor), children: labels.stop })
664
662
  ] }),
665
663
  phase === "error" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
666
664
  /* @__PURE__ */ jsxRuntime.jsx("p", { role: "alert", className: "text-sm text-destructive", children: labels.failed }),
667
- /* @__PURE__ */ jsxRuntime.jsx(chunk6T5YGCZ5_cjs.Button, { ...primary, size: "sm", onClick: () => retry(editor, stream), children: labels.retry }),
668
- /* @__PURE__ */ jsxRuntime.jsx(chunk6T5YGCZ5_cjs.Button, { size: "sm", variant: "ghost", onClick: onDiscard, children: labels.discard })
665
+ /* @__PURE__ */ jsxRuntime.jsx(chunkCJVJNMOB_cjs.Button, { ...primary, size: "sm", onClick: () => retry(editor, stream), children: labels.retry }),
666
+ /* @__PURE__ */ jsxRuntime.jsx(chunkCJVJNMOB_cjs.Button, { size: "sm", variant: "ghost", onClick: onDiscard, children: labels.discard })
669
667
  ] }),
670
668
  (phase === "done" || phase === "stopped") && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
671
669
  phase === "stopped" && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-muted-foreground", children: labels.stopped }),
672
670
  gone && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "w-full text-xs text-muted-foreground", children: labels.targetGone }),
673
- /* @__PURE__ */ jsxRuntime.jsx(chunk6T5YGCZ5_cjs.Button, { ...primary, size: "sm", onClick: onAccept, children: labels.accept }),
674
- /* @__PURE__ */ jsxRuntime.jsx(chunk6T5YGCZ5_cjs.Button, { size: "sm", variant: "ghost", onClick: onDiscard, children: labels.discard }),
675
- /* @__PURE__ */ jsxRuntime.jsx(chunk6T5YGCZ5_cjs.Button, { size: "sm", variant: "ghost", onClick: () => retry(editor, stream), children: labels.retry }),
671
+ /* @__PURE__ */ jsxRuntime.jsx(chunkCJVJNMOB_cjs.Button, { ...primary, size: "sm", onClick: onAccept, children: labels.accept }),
672
+ /* @__PURE__ */ jsxRuntime.jsx(chunkCJVJNMOB_cjs.Button, { size: "sm", variant: "ghost", onClick: onDiscard, children: labels.discard }),
673
+ /* @__PURE__ */ jsxRuntime.jsx(chunkCJVJNMOB_cjs.Button, { size: "sm", variant: "ghost", onClick: () => retry(editor, stream), children: labels.retry }),
676
674
  /* @__PURE__ */ jsxRuntime.jsx("form", { className: "w-full", onSubmit: onFollowUp, children: /* @__PURE__ */ jsxRuntime.jsx(
677
- chunk6T5YGCZ5_cjs.Input,
675
+ chunkCJVJNMOB_cjs.Input,
678
676
  {
679
677
  "aria-label": labels.followUp,
680
678
  placeholder: labels.followUp,
@@ -695,8 +693,8 @@ function AiBar({ env, ghost, gone, barId }) {
695
693
  var reader = null;
696
694
  function readerOf() {
697
695
  if (reader === null) {
698
- const schema = chunkWZA5S5EJ_cjs.createSchema();
699
- reader = { schema, codec: chunkWZA5S5EJ_cjs.createBlockCodec(schema) };
696
+ const schema = chunkI7X7B3WD_cjs.createSchema();
697
+ reader = { schema, codec: chunkI7X7B3WD_cjs.createBlockCodec(schema) };
700
698
  }
701
699
  return reader;
702
700
  }
@@ -704,16 +702,16 @@ function fillGhost(ghost, markdown) {
704
702
  const doc = ghost.ownerDocument;
705
703
  const { schema, codec } = readerOf();
706
704
  const drawn2 = [];
707
- for (const block of chunkWZA5S5EJ_cjs.fromMarkdown(markdown)) {
705
+ for (const block of chunkI7X7B3WD_cjs.fromMarkdown(markdown)) {
708
706
  for (const piece of codec.toEngineBlocks(block)) {
709
707
  const element = doc.createElement("div");
710
708
  element.className = "quoin-ai-ghost-block";
711
709
  element.dataset.kind = String(piece.attrs.kind ?? piece.type.toLowerCase());
712
710
  if (piece.attrs.level !== void 0) element.dataset.level = String(piece.attrs.level);
713
711
  if (piece.indent > 0) element.style.setProperty("--quoin-ai-indent", String(piece.indent));
714
- const region = chunkVZZPCYA3_cjs.primaryRegion(schema, piece);
715
- if (region === null) element.textContent = chunkVZZPCYA3_cjs.toPlainText([codec.toQuoin(piece)], { schema });
716
- else chunkQJ34MOFV_cjs.renderInline(element, piece.regions[region], []);
712
+ const region = chunkFK7EBZPX_cjs.primaryRegion(schema, piece);
713
+ if (region === null) element.textContent = chunkFK7EBZPX_cjs.toPlainText([codec.toQuoin(piece)], { schema });
714
+ else chunkZ6LAARPB_cjs.renderInline(element, piece.regions[region], []);
717
715
  drawn2.push(element);
718
716
  }
719
717
  }
@@ -790,7 +788,7 @@ function clipAside(layer, text, areas, scale) {
790
788
  function useGhostPlace(controller, layer, block, region) {
791
789
  const placeNow = react.useRef(() => {
792
790
  });
793
- chunkQJ34MOFV_cjs.useIsomorphicLayoutEffect(() => {
791
+ chunkZ6LAARPB_cjs.useIsomorphicLayoutEffect(() => {
794
792
  const root = controller.root;
795
793
  const element = layer.current;
796
794
  const view = root?.ownerDocument.defaultView;
@@ -829,7 +827,7 @@ function AiGhost({ env, ghost, target, gone, barId }) {
829
827
  const layer = react.useRef(null);
830
828
  const drawn2 = react.useRef(null);
831
829
  const place2 = useGhostPlace(env.controller, layer, target.to.block, target.to.region);
832
- chunkQJ34MOFV_cjs.useIsomorphicLayoutEffect(() => {
830
+ chunkZ6LAARPB_cjs.useIsomorphicLayoutEffect(() => {
833
831
  const element = drawn2.current;
834
832
  if (element === null) return;
835
833
  element.setAttribute("inert", "");
@@ -843,7 +841,7 @@ function AiGhost({ env, ghost, target, gone, barId }) {
843
841
  }
844
842
  function useTargetAnchor(controller, target) {
845
843
  const latest = react.useRef(target);
846
- chunkQJ34MOFV_cjs.useIsomorphicLayoutEffect(() => {
844
+ chunkZ6LAARPB_cjs.useIsomorphicLayoutEffect(() => {
847
845
  latest.current = target;
848
846
  });
849
847
  return react.useMemo(() => {
@@ -852,8 +850,8 @@ function useTargetAnchor(controller, target) {
852
850
  return { block: to.block, region: to.region, from: to.offset, to: to.offset };
853
851
  };
854
852
  return {
855
- current: chunk6T5YGCZ5_cjs.virtualAnchor(
856
- () => chunk6T5YGCZ5_cjs.rangeRect(controller, end()),
853
+ current: chunkCJVJNMOB_cjs.virtualAnchor(
854
+ () => chunkCJVJNMOB_cjs.rangeRect(controller, end()),
857
855
  () => controller.registry.get(end().block, end().region)
858
856
  )
859
857
  };
@@ -907,7 +905,7 @@ function AiMenu({ env, target, fromSpace }) {
907
905
  };
908
906
  const fieldLabel = asking === "tone" ? labels.tonePrompt : asking === "translate" ? labels.translatePrompt : labels.prompt;
909
907
  return /* @__PURE__ */ jsxRuntime.jsxs(
910
- chunk6T5YGCZ5_cjs.Popover,
908
+ chunkCJVJNMOB_cjs.Popover,
911
909
  {
912
910
  open: true,
913
911
  modal: false,
@@ -915,9 +913,9 @@ function AiMenu({ env, target, fromSpace }) {
915
913
  if (!next) closeMenu(controller.editor);
916
914
  },
917
915
  children: [
918
- /* @__PURE__ */ jsxRuntime.jsx(chunk6T5YGCZ5_cjs.PopoverAnchor, { virtualRef: anchor }),
916
+ /* @__PURE__ */ jsxRuntime.jsx(chunkCJVJNMOB_cjs.PopoverAnchor, { virtualRef: anchor }),
919
917
  /* @__PURE__ */ jsxRuntime.jsxs(
920
- chunk6T5YGCZ5_cjs.PopoverContent,
918
+ chunkCJVJNMOB_cjs.PopoverContent,
921
919
  {
922
920
  "aria-label": labels.askAi,
923
921
  side: "bottom",
@@ -934,7 +932,7 @@ function AiMenu({ env, target, fromSpace }) {
934
932
  },
935
933
  children: [
936
934
  /* @__PURE__ */ jsxRuntime.jsx(
937
- chunk6T5YGCZ5_cjs.Input,
935
+ chunkCJVJNMOB_cjs.Input,
938
936
  {
939
937
  ref: field,
940
938
  role: "combobox",
@@ -958,7 +956,7 @@ function AiMenu({ env, target, fromSpace }) {
958
956
  id: optionId(index),
959
957
  role: "option",
960
958
  "aria-selected": index === current,
961
- className: chunk6T5YGCZ5_cjs.cn(chunk6T5YGCZ5_cjs.MENU_ITEM, index === current && "bg-accent text-accent-foreground"),
959
+ className: chunkCJVJNMOB_cjs.cn(chunkCJVJNMOB_cjs.MENU_ITEM, index === current && "bg-accent text-accent-foreground"),
962
960
  onMouseDown: (event) => event.preventDefault(),
963
961
  onClick: () => choose(choice),
964
962
  children: choice.label
@@ -976,17 +974,17 @@ var goneOf = (state) => {
976
974
  const { target, ghost } = aiState(state);
977
975
  return target !== null && ghost !== null && targetGone(state.doc, target);
978
976
  };
979
- var plainText = (markdown) => chunkVZZPCYA3_cjs.toPlainText(chunkWZA5S5EJ_cjs.fromMarkdown(markdown));
977
+ var plainText = (markdown) => chunkFK7EBZPX_cjs.toPlainText(chunkI7X7B3WD_cjs.fromMarkdown(markdown));
980
978
  function AiOverlay({ controller, stream, labels }) {
981
- const { onError } = chunk6T5YGCZ5_cjs.useQuoin();
979
+ const { onError } = chunkCJVJNMOB_cjs.useQuoin();
982
980
  const link = linkOf(controller.editor);
983
- chunkQJ34MOFV_cjs.useIsomorphicLayoutEffect(() => {
981
+ chunkZ6LAARPB_cjs.useIsomorphicLayoutEffect(() => {
984
982
  link.report = onError;
985
983
  link.ended = (phase, output) => controller.announce((phase === "done" ? labels.written : labels.halted)(plainText(output)));
986
984
  }, [link, onError, controller, labels]);
987
- const value = chunkQJ34MOFV_cjs.useEditorState(controller, aiState);
988
- const gone = chunkQJ34MOFV_cjs.useEditorState(controller, goneOf);
989
- const readOnly = chunkQJ34MOFV_cjs.useReadOnly(controller);
985
+ const value = chunkZ6LAARPB_cjs.useEditorState(controller, aiState);
986
+ const gone = chunkZ6LAARPB_cjs.useEditorState(controller, goneOf);
987
+ const readOnly = chunkZ6LAARPB_cjs.useReadOnly(controller);
990
988
  const env = react.useMemo(() => ({ controller, stream, labels }), [controller, stream, labels]);
991
989
  const barId = react.useId();
992
990
  const showing = value.ghost !== null;
@@ -1005,7 +1003,7 @@ function AiOverlay({ controller, stream, labels }) {
1005
1003
  const root = controller.root;
1006
1004
  if (!root) return;
1007
1005
  let away = true;
1008
- return chunkQR2NIDUK_cjs.watchCanvasFocus(controller, root.ownerDocument, (inside, node) => {
1006
+ return chunkBYYCD54G_cjs.watchCanvasFocus(controller, root.ownerDocument, (inside, node) => {
1009
1007
  if (!inside) away = true;
1010
1008
  else if (root.contains(node)) {
1011
1009
  if (away) noteFocus(controller.editor);
@@ -1041,7 +1039,7 @@ function aiExtension(options) {
1041
1039
  blockMenuItems: [aiBlockMenuItem(labels)],
1042
1040
  overlays: [Overlay]
1043
1041
  };
1044
- return chunkVZZPCYA3_cjs.defineExtension({
1042
+ return chunkFK7EBZPX_cjs.defineExtension({
1045
1043
  name: "ai",
1046
1044
  plugins: [aiPlugin],
1047
1045
  decorations: aiDecorations,
package/dist/ai.d.cts CHANGED
@@ -1,57 +1,8 @@
1
1
  import { Extension } from './engine.cjs';
2
+ import { A as AiStream, a as AiLabels } from './ai-labels-BXX32H9a.cjs';
3
+ export { b as AiAction, c as AiRequest, e as englishAiLabels } from './ai-labels-BXX32H9a.cjs';
2
4
  import './types-CQ8Vw_7N.cjs';
3
5
 
4
- type AiAction = 'continue' | 'improve' | 'fix' | 'shorten' | 'lengthen' | 'simplify' | 'tone' | 'translate' | 'summarize' | 'explain' | 'custom';
5
- /** What the host is asked: `selection` and `context` are markdown, `language` the canvas's `lang` when it has one. */
6
- type AiRequest = {
7
- action: AiAction;
8
- prompt?: string;
9
- selection: string;
10
- context: string;
11
- language?: string;
12
- };
13
- /** The host's model, answering a request as markdown in chunks, and stopping when `signal` aborts. */
14
- type AiStream = (request: AiRequest, signal: AbortSignal) => AsyncIterable<string>;
15
-
16
- /** Every string AI actions show or speak. */
17
- type AiLabels = {
18
- /** The toolbar button, block menu item and slash command that open the AI menu. */
19
- askAi: string;
20
- /** What the slash command for the AI menu does. */
21
- askAiDescription: string;
22
- /** The name of each action in the AI menu; `custom` names the slash command group's own entry. */
23
- actions: Record<AiAction, string>;
24
- /** The name of the list of actions. */
25
- menu: string;
26
- /** The field the writer types a request in. */
27
- prompt: string;
28
- /** The field once Change tone is chosen. */
29
- tonePrompt: string;
30
- /** The field once Translate is chosen. */
31
- translatePrompt: string;
32
- /** The choice that sends what was typed as a request of its own. */
33
- ask(prompt: string): string;
34
- /** The name of the bar under the answer. */
35
- response: string;
36
- writing: string;
37
- stopped: string;
38
- stop: string;
39
- accept: string;
40
- discard: string;
41
- retry: string;
42
- /** The field for a further request about the answer. */
43
- followUp: string;
44
- /** Shown when the host's answer failed. */
45
- failed: string;
46
- /** Said once an answer is complete, given its text. */
47
- written(text: string): string;
48
- /** Said once an answer is stopped, given what it wrote. */
49
- halted(text: string): string;
50
- /** Shown when the text the answer was for was deleted meanwhile. */
51
- targetGone: string;
52
- };
53
- declare const englishAiLabels: AiLabels;
54
-
55
6
  type AiOptions = {
56
7
  /** The host's model: answers each request as markdown chunks, and stops when the signal aborts. */
57
8
  stream: AiStream;
@@ -65,5 +16,5 @@ type AiOptions = {
65
16
  */
66
17
  declare function aiExtension(options: AiOptions): Extension;
67
18
 
68
- export { aiExtension, englishAiLabels };
69
- export type { AiAction, AiLabels, AiOptions, AiRequest, AiStream };
19
+ export { AiLabels, AiStream, aiExtension };
20
+ export type { AiOptions };
package/dist/ai.d.ts CHANGED
@@ -1,57 +1,8 @@
1
1
  import { Extension } from './engine.js';
2
+ import { A as AiStream, a as AiLabels } from './ai-labels-BXX32H9a.js';
3
+ export { b as AiAction, c as AiRequest, e as englishAiLabels } from './ai-labels-BXX32H9a.js';
2
4
  import './types-CQ8Vw_7N.js';
3
5
 
4
- type AiAction = 'continue' | 'improve' | 'fix' | 'shorten' | 'lengthen' | 'simplify' | 'tone' | 'translate' | 'summarize' | 'explain' | 'custom';
5
- /** What the host is asked: `selection` and `context` are markdown, `language` the canvas's `lang` when it has one. */
6
- type AiRequest = {
7
- action: AiAction;
8
- prompt?: string;
9
- selection: string;
10
- context: string;
11
- language?: string;
12
- };
13
- /** The host's model, answering a request as markdown in chunks, and stopping when `signal` aborts. */
14
- type AiStream = (request: AiRequest, signal: AbortSignal) => AsyncIterable<string>;
15
-
16
- /** Every string AI actions show or speak. */
17
- type AiLabels = {
18
- /** The toolbar button, block menu item and slash command that open the AI menu. */
19
- askAi: string;
20
- /** What the slash command for the AI menu does. */
21
- askAiDescription: string;
22
- /** The name of each action in the AI menu; `custom` names the slash command group's own entry. */
23
- actions: Record<AiAction, string>;
24
- /** The name of the list of actions. */
25
- menu: string;
26
- /** The field the writer types a request in. */
27
- prompt: string;
28
- /** The field once Change tone is chosen. */
29
- tonePrompt: string;
30
- /** The field once Translate is chosen. */
31
- translatePrompt: string;
32
- /** The choice that sends what was typed as a request of its own. */
33
- ask(prompt: string): string;
34
- /** The name of the bar under the answer. */
35
- response: string;
36
- writing: string;
37
- stopped: string;
38
- stop: string;
39
- accept: string;
40
- discard: string;
41
- retry: string;
42
- /** The field for a further request about the answer. */
43
- followUp: string;
44
- /** Shown when the host's answer failed. */
45
- failed: string;
46
- /** Said once an answer is complete, given its text. */
47
- written(text: string): string;
48
- /** Said once an answer is stopped, given what it wrote. */
49
- halted(text: string): string;
50
- /** Shown when the text the answer was for was deleted meanwhile. */
51
- targetGone: string;
52
- };
53
- declare const englishAiLabels: AiLabels;
54
-
55
6
  type AiOptions = {
56
7
  /** The host's model: answers each request as markdown chunks, and stops when the signal aborts. */
57
8
  stream: AiStream;
@@ -65,5 +16,5 @@ type AiOptions = {
65
16
  */
66
17
  declare function aiExtension(options: AiOptions): Extension;
67
18
 
68
- export { aiExtension, englishAiLabels };
69
- export type { AiAction, AiLabels, AiOptions, AiRequest, AiStream };
19
+ export { AiLabels, AiStream, aiExtension };
20
+ export type { AiOptions };
package/dist/ai.js CHANGED
@@ -1,12 +1,13 @@
1
1
  'use client';
2
2
  import { clipBoxes } from './chunk-MQUCCSWG.js';
3
- import { watchCanvasFocus } from './chunk-R7MYG522.js';
4
- import { Sparkles, PenLine, useQuoin, Popover, PopoverAnchor, PopoverContent, Input, cn, MENU_ITEM, virtualAnchor, rangeRect, Button, toError } from './chunk-HSLOPJVT.js';
5
- import { useIsomorphicLayoutEffect, useEditorState, useReadOnly, renderInline } from './chunk-XFEDJEJF.js';
3
+ import { watchCanvasFocus } from './chunk-IW4TMECB.js';
4
+ import { Sparkles, PenLine, useQuoin, Popover, PopoverAnchor, PopoverContent, Input, cn, MENU_ITEM, virtualAnchor, rangeRect, Button, toError } from './chunk-ZN5DHNSL.js';
5
+ import { useIsomorphicLayoutEffect, useEditorState, useReadOnly, renderInline } from './chunk-NL5J77VD.js';
6
+ import { mergeLabels } from './chunk-DLQCTGC3.js';
6
7
  import './chunk-HDJ653LM.js';
7
- import { createPluginKey, defineExtension, isCollapsed, regionLength, primaryRegion, getPluginState, Transaction, toPlainText, selectedBlockIds, orderedRange, comparePos, sliceFromSelection, textSelection, deleteRange, pasteAtCaret, toMarkdown, descendantsEnd, freshBlocks, insertBlocksStep, capIndents, endOf } from './chunk-OS2O6IKX.js';
8
- import './chunk-CSKKSXCE.js';
9
- import { blockById, fromMarkdown, createSchema, createBlockCodec, parseLine } from './chunk-BJTOLCRR.js';
8
+ import { createPluginKey, defineExtension, isCollapsed, regionLength, primaryRegion, getPluginState, Transaction, toPlainText, selectedBlockIds, orderedRange, comparePos, sliceFromSelection, textSelection, deleteRange, pasteAtCaret, toMarkdown, descendantsEnd, freshBlocks, insertBlocksStep, capIndents, endOf } from './chunk-5RBMZGKV.js';
9
+ import './chunk-CSPCDVCT.js';
10
+ import { blockById, fromMarkdown, createSchema, createBlockCodec, parseLine } from './chunk-7Y4B7NHO.js';
10
11
  import { useMemo, useId, useEffect, useState, useRef, useCallback } from 'react';
11
12
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
12
13
 
@@ -540,10 +541,7 @@ var englishAiLabels = {
540
541
  halted: (text) => `Stopped. AI response so far: ${text}`,
541
542
  targetGone: "The text this was for was removed, so Accept inserts it where that text was"
542
543
  };
543
- function resolveAiLabels(overrides) {
544
- const given = Object.entries(overrides ?? {}).filter(([, value]) => value !== void 0);
545
- return given.length === 0 ? englishAiLabels : { ...englishAiLabels, ...Object.fromEntries(given) };
546
- }
544
+ var resolveAiLabels = (overrides) => mergeLabels(englishAiLabels, overrides);
547
545
 
548
546
  // src/extensions/ai/ai-space.ts
549
547
  var openOnSpace = (state, dispatch) => {