quoin-editor 2.0.4 → 2.1.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 (215) hide show
  1. package/CHANGELOG.md +110 -0
  2. package/MIGRATION.md +1 -1
  3. package/README.md +14 -13
  4. package/dist/ai.cjs +124 -94
  5. package/dist/ai.d.cts +7 -0
  6. package/dist/ai.d.ts +7 -0
  7. package/dist/ai.js +50 -20
  8. package/dist/ai.js.map +1 -1
  9. package/dist/catalogue.cjs +28 -26
  10. package/dist/catalogue.js +19 -17
  11. package/dist/catalogue.js.map +1 -1
  12. package/dist/{chunk-JGEDJYIV.cjs → chunk-2FUWXPPC.cjs} +92 -98
  13. package/dist/{chunk-NHNW5DK3.js → chunk-3F76QQ65.js} +6 -6
  14. package/dist/{chunk-NHNW5DK3.js.map → chunk-3F76QQ65.js.map} +1 -1
  15. package/dist/{chunk-DBOZFNWU.js → chunk-3QYFAAQR.js} +3 -3
  16. package/dist/{chunk-DBOZFNWU.js.map → chunk-3QYFAAQR.js.map} +1 -1
  17. package/dist/{chunk-I7X7B3WD.cjs → chunk-4JDRDPLC.cjs} +17 -8
  18. package/dist/{chunk-EBSDPHPS.cjs → chunk-4UFWFV43.cjs} +1060 -719
  19. package/dist/{chunk-LM3DHROX.cjs → chunk-5AUIA4B3.cjs} +2 -2
  20. package/dist/{chunk-3INFNIGN.cjs → chunk-5H3BB5VJ.cjs} +131 -78
  21. package/dist/{chunk-DJU25PFC.cjs → chunk-5L2NSIHZ.cjs} +11 -11
  22. package/dist/{chunk-W376L2GM.js → chunk-6Y7JAWYY.js} +8 -8
  23. package/dist/chunk-6Y7JAWYY.js.map +1 -0
  24. package/dist/{chunk-UDBLZILE.js → chunk-ATKDXQEY.js} +12 -7
  25. package/dist/{chunk-UDBLZILE.js.map → chunk-ATKDXQEY.js.map} +1 -1
  26. package/dist/{chunk-A2IQHMIH.js → chunk-BE2SYPK5.js} +49 -54
  27. package/dist/chunk-BE2SYPK5.js.map +1 -0
  28. package/dist/{chunk-PURYVDC3.cjs → chunk-CFICD2JP.cjs} +21 -16
  29. package/dist/{chunk-3HW3WRYC.cjs → chunk-CSIUXYRU.cjs} +2 -2
  30. package/dist/{chunk-N7BSFDDM.cjs → chunk-DBKL524I.cjs} +23 -23
  31. package/dist/{chunk-XE3IYW5B.js → chunk-DEFYFIWW.js} +90 -37
  32. package/dist/chunk-DEFYFIWW.js.map +1 -0
  33. package/dist/{chunk-7E43TURF.cjs → chunk-ECI3PSMS.cjs} +7 -7
  34. package/dist/{chunk-4G645EYO.js → chunk-F73QEF7E.js} +5 -5
  35. package/dist/{chunk-4G645EYO.js.map → chunk-F73QEF7E.js.map} +1 -1
  36. package/dist/{chunk-KHRVCTQQ.cjs → chunk-FUT7XLMP.cjs} +61 -74
  37. package/dist/{chunk-7J63427U.cjs → chunk-GQSBOBOM.cjs} +375 -320
  38. package/dist/{chunk-LU3T3JB4.js → chunk-HPNSQWRD.js} +15 -28
  39. package/dist/chunk-HPNSQWRD.js.map +1 -0
  40. package/dist/{chunk-7Y4B7NHO.js → chunk-I34BFOLL.js} +18 -11
  41. package/dist/chunk-I34BFOLL.js.map +1 -0
  42. package/dist/{chunk-AJT54OMZ.js → chunk-IFRXEFQH.js} +9 -15
  43. package/dist/chunk-IFRXEFQH.js.map +1 -0
  44. package/dist/{chunk-YYW33WUL.cjs → chunk-K3XWVRL4.cjs} +8 -8
  45. package/dist/{chunk-LSI4RMTY.js → chunk-L5L6YNLT.js} +3 -3
  46. package/dist/{chunk-LSI4RMTY.js.map → chunk-L5L6YNLT.js.map} +1 -1
  47. package/dist/{chunk-2BPXVQBP.js → chunk-MO4UMXMT.js} +238 -86
  48. package/dist/chunk-MO4UMXMT.js.map +1 -0
  49. package/dist/{chunk-2QKFRKOP.cjs → chunk-N25EH2GZ.cjs} +351 -205
  50. package/dist/{chunk-CSPCDVCT.js → chunk-NCV2ML25.js} +3 -3
  51. package/dist/{chunk-CSPCDVCT.js.map → chunk-NCV2ML25.js.map} +1 -1
  52. package/dist/{chunk-NUQ64S5B.cjs → chunk-OJSKSQTL.cjs} +26 -26
  53. package/dist/chunk-PIWMU4BV.js +9 -0
  54. package/dist/chunk-PIWMU4BV.js.map +1 -0
  55. package/dist/chunk-QFGWSFOI.cjs +10 -0
  56. package/dist/{chunk-GPTJYWGS.js → chunk-RNBLVGWY.js} +3 -3
  57. package/dist/{chunk-GPTJYWGS.js.map → chunk-RNBLVGWY.js.map} +1 -1
  58. package/dist/{chunk-5RBMZGKV.js → chunk-TL2MJOWM.js} +325 -57
  59. package/dist/chunk-TL2MJOWM.js.map +1 -0
  60. package/dist/{chunk-YEDPBYO5.cjs → chunk-UDQ52EEC.cjs} +4 -4
  61. package/dist/{chunk-EIWPJWY3.js → chunk-UE2NQPNG.js} +5 -5
  62. package/dist/{chunk-EIWPJWY3.js.map → chunk-UE2NQPNG.js.map} +1 -1
  63. package/dist/{chunk-BE2YHZXA.cjs → chunk-ULV3SCYP.cjs} +26 -15
  64. package/dist/{chunk-WDBFGX3U.cjs → chunk-VTTMJGWP.cjs} +72 -77
  65. package/dist/{chunk-556PFYES.js → chunk-WK4UGDZN.js} +290 -235
  66. package/dist/chunk-WK4UGDZN.js.map +1 -0
  67. package/dist/{chunk-JZF6UQH5.cjs → chunk-WMKA37NJ.cjs} +12 -12
  68. package/dist/{chunk-F2ZK6Z52.js → chunk-Y26F2X4E.js} +3 -3
  69. package/dist/{chunk-F2ZK6Z52.js.map → chunk-Y26F2X4E.js.map} +1 -1
  70. package/dist/{chunk-FK7EBZPX.cjs → chunk-Z5EEDCRI.cjs} +549 -276
  71. package/dist/{chunk-G6NBQYMM.js → chunk-ZGFZRVQA.js} +817 -478
  72. package/dist/chunk-ZGFZRVQA.js.map +1 -0
  73. package/dist/{chunk-QLVX7MPS.js → chunk-ZQF45LA4.js} +19 -8
  74. package/dist/chunk-ZQF45LA4.js.map +1 -0
  75. package/dist/comments.cjs +127 -65
  76. package/dist/comments.d.cts +35 -2
  77. package/dist/comments.d.ts +35 -2
  78. package/dist/comments.js +73 -12
  79. package/dist/comments.js.map +1 -1
  80. package/dist/{diagram-extension-22x_njXB.d.ts → diagram-extension-BMlh8GCw.d.ts} +1 -1
  81. package/dist/{diagram-extension-C_FSkoj9.d.cts → diagram-extension-gmndUpti.d.cts} +1 -1
  82. package/dist/diagram.cjs +10 -9
  83. package/dist/diagram.d.cts +2 -2
  84. package/dist/diagram.d.ts +2 -2
  85. package/dist/diagram.js +7 -6
  86. package/dist/diff.cjs +25 -25
  87. package/dist/diff.js +3 -3
  88. package/dist/docx.cjs +31 -30
  89. package/dist/docx.js +5 -4
  90. package/dist/docx.js.map +1 -1
  91. package/dist/embed.cjs +10 -9
  92. package/dist/embed.js +8 -7
  93. package/dist/{emoji-extension-Dk5IQLZf.d.cts → emoji-extension-DD9CQTQj.d.cts} +1 -1
  94. package/dist/{emoji-extension-C832oGeT.d.ts → emoji-extension-U_PWZ2fX.d.ts} +1 -1
  95. package/dist/emoji.cjs +10 -9
  96. package/dist/emoji.d.cts +2 -2
  97. package/dist/emoji.d.ts +2 -2
  98. package/dist/emoji.js +7 -6
  99. package/dist/engine.cjs +58 -58
  100. package/dist/engine.d.cts +3 -3
  101. package/dist/engine.d.ts +3 -3
  102. package/dist/engine.js +3 -3
  103. package/dist/{find-extension-DmK9_N81.d.ts → find-extension-BGlqooZi.d.ts} +1 -1
  104. package/dist/{find-extension-BfruAPLi.d.cts → find-extension-BPnAJ8bY.d.cts} +1 -1
  105. package/dist/find.cjs +11 -10
  106. package/dist/find.d.cts +1 -1
  107. package/dist/find.d.ts +1 -1
  108. package/dist/find.js +7 -6
  109. package/dist/headless.cjs +70 -69
  110. package/dist/headless.d.cts +33 -10
  111. package/dist/headless.d.ts +33 -10
  112. package/dist/headless.js +5 -4
  113. package/dist/highlight.cjs +7 -6
  114. package/dist/highlight.js +6 -5
  115. package/dist/highlight.js.map +1 -1
  116. package/dist/{index-3fYvwqUZ.d.cts → index-DN7vRKFw.d.cts} +1 -1
  117. package/dist/{index-CgxnzCO5.d.ts → index-DyIYI3PM.d.ts} +1 -1
  118. package/dist/index.cjs +82 -81
  119. package/dist/index.d.cts +19 -12
  120. package/dist/index.d.ts +19 -12
  121. package/dist/index.js +6 -5
  122. package/dist/{labels-CiCxj2jP.d.cts → labels-BJORhN93.d.ts} +10 -5
  123. package/dist/{labels-BhRJYo46.d.ts → labels-CVYJ2-1X.d.cts} +10 -5
  124. package/dist/locale-ar.cjs +10 -0
  125. package/dist/locale-ar.d.cts +1 -1
  126. package/dist/locale-ar.d.ts +1 -1
  127. package/dist/locale-ar.js +10 -0
  128. package/dist/locale-ar.js.map +1 -1
  129. package/dist/locale-de.cjs +4 -0
  130. package/dist/locale-de.d.cts +1 -1
  131. package/dist/locale-de.d.ts +1 -1
  132. package/dist/locale-de.js +4 -0
  133. package/dist/locale-de.js.map +1 -1
  134. package/dist/locale-es.cjs +4 -0
  135. package/dist/locale-es.d.cts +1 -1
  136. package/dist/locale-es.d.ts +1 -1
  137. package/dist/locale-es.js +4 -0
  138. package/dist/locale-es.js.map +1 -1
  139. package/dist/locale-fr.cjs +4 -0
  140. package/dist/locale-fr.d.cts +1 -1
  141. package/dist/locale-fr.d.ts +1 -1
  142. package/dist/locale-fr.js +4 -0
  143. package/dist/locale-fr.js.map +1 -1
  144. package/dist/locale-ja.cjs +4 -0
  145. package/dist/locale-ja.d.cts +1 -1
  146. package/dist/locale-ja.d.ts +1 -1
  147. package/dist/locale-ja.js +4 -0
  148. package/dist/locale-ja.js.map +1 -1
  149. package/dist/locale-pt.cjs +4 -0
  150. package/dist/locale-pt.d.cts +1 -1
  151. package/dist/locale-pt.d.ts +1 -1
  152. package/dist/locale-pt.js +4 -0
  153. package/dist/locale-pt.js.map +1 -1
  154. package/dist/locale-zh.cjs +4 -0
  155. package/dist/locale-zh.d.cts +1 -1
  156. package/dist/locale-zh.d.ts +1 -1
  157. package/dist/locale-zh.js +4 -0
  158. package/dist/locale-zh.js.map +1 -1
  159. package/dist/math.cjs +11 -10
  160. package/dist/math.js +9 -8
  161. package/dist/mention.cjs +11 -10
  162. package/dist/mention.js +9 -8
  163. package/dist/{node-reveal-DY6bimv3.d.cts → node-reveal-Be7Xa0BL.d.cts} +1 -1
  164. package/dist/{node-reveal-BnFcnHhz.d.ts → node-reveal-CftIEqF_.d.ts} +1 -1
  165. package/dist/palette-DuIFHYHc.d.cts +10 -0
  166. package/dist/palette-DuIFHYHc.d.ts +10 -0
  167. package/dist/presence.cjs +39 -38
  168. package/dist/presence.js +8 -7
  169. package/dist/presence.js.map +1 -1
  170. package/dist/source.cjs +10 -9
  171. package/dist/source.d.cts +1 -1
  172. package/dist/source.d.ts +1 -1
  173. package/dist/source.js +6 -5
  174. package/dist/source.js.map +1 -1
  175. package/dist/{stats-extension-Dmw0Ujxe.d.ts → stats-extension-Bbpr593p.d.ts} +1 -1
  176. package/dist/{stats-extension-D5HySF0a.d.cts → stats-extension-D7FaeydW.d.cts} +1 -1
  177. package/dist/stats.cjs +12 -10
  178. package/dist/stats.d.cts +2 -2
  179. package/dist/stats.d.ts +2 -2
  180. package/dist/stats.js +9 -7
  181. package/dist/styles.css +1 -1
  182. package/dist/{table-extension-7LkLNK6Q.d.cts → table-extension-DNijjmxV.d.cts} +1 -1
  183. package/dist/{table-extension-DEpV0DnP.d.ts → table-extension-Dp6FYGPh.d.ts} +1 -1
  184. package/dist/table.cjs +26 -25
  185. package/dist/table.d.cts +4 -3
  186. package/dist/table.d.ts +4 -3
  187. package/dist/table.js +7 -6
  188. package/dist/{toc-extension-Dvh37bWQ.d.cts → toc-extension-BGEVAmSY.d.cts} +1 -1
  189. package/dist/{toc-extension-SVckrFmb.d.ts → toc-extension-DZIe40eV.d.ts} +1 -1
  190. package/dist/toc.cjs +10 -9
  191. package/dist/toc.d.cts +2 -2
  192. package/dist/toc.d.ts +2 -2
  193. package/dist/toc.js +7 -6
  194. package/dist/{types-DMuuDBVh.d.ts → types-Byu2a9qk.d.ts} +6 -1
  195. package/dist/{types-Bzhq5AXj.d.cts → types-DdDlCyyZ.d.cts} +6 -1
  196. package/dist/view.cjs +4 -4
  197. package/dist/view.js +2 -2
  198. package/dist/yjs.cjs +121 -121
  199. package/dist/yjs.d.cts +2 -2
  200. package/dist/yjs.d.ts +2 -2
  201. package/dist/yjs.js +5 -5
  202. package/package.json +4 -3
  203. package/dist/chunk-2BPXVQBP.js.map +0 -1
  204. package/dist/chunk-556PFYES.js.map +0 -1
  205. package/dist/chunk-5RBMZGKV.js.map +0 -1
  206. package/dist/chunk-7Y4B7NHO.js.map +0 -1
  207. package/dist/chunk-A2IQHMIH.js.map +0 -1
  208. package/dist/chunk-AJT54OMZ.js.map +0 -1
  209. package/dist/chunk-G6NBQYMM.js.map +0 -1
  210. package/dist/chunk-LU3T3JB4.js.map +0 -1
  211. package/dist/chunk-QLVX7MPS.js.map +0 -1
  212. package/dist/chunk-W376L2GM.js.map +0 -1
  213. package/dist/chunk-XE3IYW5B.js.map +0 -1
  214. package/dist/palette-BrX-hEd-.d.cts +0 -4
  215. package/dist/palette-BrX-hEd-.d.ts +0 -4
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var chunkJZF6UQH5_cjs = require('./chunk-JZF6UQH5.cjs');
4
- var chunkYEDPBYO5_cjs = require('./chunk-YEDPBYO5.cjs');
5
- var chunkEBSDPHPS_cjs = require('./chunk-EBSDPHPS.cjs');
6
- var chunk2QKFRKOP_cjs = require('./chunk-2QKFRKOP.cjs');
3
+ var chunkWMKA37NJ_cjs = require('./chunk-WMKA37NJ.cjs');
4
+ var chunkUDQ52EEC_cjs = require('./chunk-UDQ52EEC.cjs');
5
+ var chunk4UFWFV43_cjs = require('./chunk-4UFWFV43.cjs');
6
+ var chunkN25EH2GZ_cjs = require('./chunk-N25EH2GZ.cjs');
7
7
  var chunkZWTIRGY5_cjs = require('./chunk-ZWTIRGY5.cjs');
8
8
  var chunkA6PGQVTR_cjs = require('./chunk-A6PGQVTR.cjs');
9
- var chunkFK7EBZPX_cjs = require('./chunk-FK7EBZPX.cjs');
10
- var chunkI7X7B3WD_cjs = require('./chunk-I7X7B3WD.cjs');
9
+ var chunkZ5EEDCRI_cjs = require('./chunk-Z5EEDCRI.cjs');
10
+ var chunk4JDRDPLC_cjs = require('./chunk-4JDRDPLC.cjs');
11
11
  var react = require('react');
12
12
  var jsxRuntime = require('react/jsx-runtime');
13
13
 
@@ -88,17 +88,17 @@ function MathOutput({ feature, latex, displayMode }) {
88
88
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "quoin-math-rendered", dangerouslySetInnerHTML: { __html: html } });
89
89
  }
90
90
  function MathBlock({ block, controller, feature }) {
91
- const readOnly = chunk2QKFRKOP_cjs.useReadOnly(controller);
91
+ const readOnly = chunkN25EH2GZ_cjs.useReadOnly(controller);
92
92
  const root = react.useRef(null);
93
93
  const blockId = block.id;
94
- const latex = chunkI7X7B3WD_cjs.str(block.attrs.latex);
94
+ const latex = chunk4JDRDPLC_cjs.str(block.attrs.latex);
95
95
  const keys = react.useMemo(
96
96
  () => ({ enter: () => openMath(controller, { kind: "block", block: blockId, latex }) }),
97
97
  [controller, blockId, latex]
98
98
  );
99
- chunkEBSDPHPS_cjs.useNodeKeys(controller, blockId, !readOnly, true, root, keys);
99
+ chunk4UFWFV43_cjs.useNodeKeys(controller, blockId, !readOnly, true, root, keys);
100
100
  const open = () => {
101
- chunkEBSDPHPS_cjs.selectNode(controller, blockId);
101
+ chunk4UFWFV43_cjs.selectNode(controller, blockId);
102
102
  keys.enter();
103
103
  };
104
104
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -124,36 +124,22 @@ function MathEditorPopover(props) {
124
124
  const { labels } = feature;
125
125
  const [draft, setDraft] = react.useState(latex);
126
126
  const fieldId = react.useId();
127
- const closed = react.useRef(false);
128
127
  const field = react.useRef(null);
129
128
  const saveButton = react.useRef(null);
130
- const finish = (store, refocus = false) => {
131
- if (closed.current) return false;
132
- closed.current = true;
133
- if (store && draft !== latex) onStore(draft, refocus);
134
- return true;
135
- };
136
- const latestFinish = react.useRef(finish);
137
- latestFinish.current = finish;
138
- react.useEffect(() => {
139
- closed.current = false;
140
- return () => void latestFinish.current(true);
141
- }, []);
142
- const close = (store, refocus = true) => {
143
- if (!refocus) controller.readSelectionFromDom();
144
- if (!finish(store, refocus)) return;
145
- onClose();
146
- if (refocus) onReturn();
147
- };
129
+ const { close } = chunk4UFWFV43_cjs.useClosing(controller, {
130
+ store: (refocus) => draft !== latex && onStore(draft, refocus),
131
+ onClose,
132
+ onReturn
133
+ });
148
134
  const content = react.useRef(null);
149
135
  const ownerDocument = react.useCallback(() => controller.root?.ownerDocument ?? document, [controller]);
150
- chunkEBSDPHPS_cjs.useOutsidePress(content, ownerDocument, () => close(true, false));
136
+ chunk4UFWFV43_cjs.useOutsidePress(content, ownerDocument, () => close(true, false));
151
137
  const save = (event) => {
152
138
  event.preventDefault();
153
139
  close(true);
154
140
  };
155
141
  const onKeyDown = (event) => {
156
- if (chunk2QKFRKOP_cjs.isComposingKey(controller, event.nativeEvent) || event.altKey) return;
142
+ if (chunkN25EH2GZ_cjs.isComposingKey(controller, event.nativeEvent) || event.altKey) return;
157
143
  const fromField = event.target === field.current;
158
144
  if (event.key === "Enter" && fromField && !event.shiftKey) {
159
145
  const mod = withMod(event, controller.isMac);
@@ -168,7 +154,7 @@ function MathEditorPopover(props) {
168
154
  }
169
155
  };
170
156
  return /* @__PURE__ */ jsxRuntime.jsxs(
171
- chunkEBSDPHPS_cjs.Popover,
157
+ chunk4UFWFV43_cjs.Popover,
172
158
  {
173
159
  open: true,
174
160
  modal: false,
@@ -176,9 +162,9 @@ function MathEditorPopover(props) {
176
162
  if (!open) close(true, false);
177
163
  },
178
164
  children: [
179
- /* @__PURE__ */ jsxRuntime.jsx(chunkEBSDPHPS_cjs.PopoverAnchor, { virtualRef: anchor }),
165
+ /* @__PURE__ */ jsxRuntime.jsx(chunk4UFWFV43_cjs.PopoverAnchor, { virtualRef: anchor }),
180
166
  /* @__PURE__ */ jsxRuntime.jsx(
181
- chunkEBSDPHPS_cjs.PopoverContent,
167
+ chunk4UFWFV43_cjs.PopoverContent,
182
168
  {
183
169
  ref: content,
184
170
  "aria-label": labels.editEquation,
@@ -191,12 +177,12 @@ function MathEditorPopover(props) {
191
177
  field.current?.focus();
192
178
  field.current?.setSelectionRange(end, end);
193
179
  },
194
- onCloseAutoFocus: chunkEBSDPHPS_cjs.preventDefault,
180
+ onCloseAutoFocus: chunk4UFWFV43_cjs.preventDefault,
195
181
  onEscapeKeyDown: (event) => {
196
182
  event.preventDefault();
197
- if (!chunk2QKFRKOP_cjs.isComposingKey(controller, event)) close(false);
183
+ if (!chunkN25EH2GZ_cjs.isComposingKey(controller, event)) close(false);
198
184
  },
199
- ...chunkEBSDPHPS_cjs.bubblePart(controller),
185
+ ...chunk4UFWFV43_cjs.bubblePart(controller),
200
186
  children: /* @__PURE__ */ jsxRuntime.jsxs("form", { noValidate: true, className: "quoin-math-editor", onSubmit: save, onKeyDown, children: [
201
187
  /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: fieldId, className: "text-sm font-medium", children: labels.latex }),
202
188
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -216,7 +202,7 @@ function MathEditorPopover(props) {
216
202
  }
217
203
  ),
218
204
  /* @__PURE__ */ jsxRuntime.jsx("div", { role: "group", "aria-label": labels.preview, className: "quoin-math-preview", children: /* @__PURE__ */ jsxRuntime.jsx(MathOutput, { feature, latex: draft, displayMode }) }),
219
- /* @__PURE__ */ jsxRuntime.jsx(chunkEBSDPHPS_cjs.Button, { ref: saveButton, type: "submit", size: "sm", children: labels.save })
205
+ /* @__PURE__ */ jsxRuntime.jsx(chunk4UFWFV43_cjs.Button, { ref: saveButton, type: "submit", size: "sm", children: labels.save })
220
206
  ] })
221
207
  }
222
208
  )
@@ -232,52 +218,53 @@ function write(controller, tr, refocus) {
232
218
  else controller.editor.dispatch(tr);
233
219
  }
234
220
  function targetAtom(state, target) {
235
- const node = chunkJZF6UQH5_cjs.atomAt(state, target, MATH_ATOMS);
221
+ const node = chunkWMKA37NJ_cjs.atomAt(state, target, MATH_ATOMS);
236
222
  return node !== null && (node.attrs.latex ?? "") === target.latex ? node : null;
237
223
  }
238
224
  function targetBlockThere(state, target) {
239
- const block = chunkI7X7B3WD_cjs.blockById(state.doc, target.block);
240
- return block?.type === "MATH" && chunkI7X7B3WD_cjs.str(block.attrs.latex) === target.latex;
225
+ const block = chunk4JDRDPLC_cjs.blockById(state.doc, target.block);
226
+ return block?.type === "MATH" && chunk4JDRDPLC_cjs.str(block.attrs.latex) === target.latex;
241
227
  }
242
228
  function targetLineThere(state, target) {
243
- const inline = chunkI7X7B3WD_cjs.blockById(state.doc, target.block)?.regions[target.region];
244
- return inline !== void 0 && chunkI7X7B3WD_cjs.inlineText(inline) === target.text;
229
+ const inline = chunk4JDRDPLC_cjs.blockById(state.doc, target.block)?.regions[target.region];
230
+ return inline !== void 0 && chunk4JDRDPLC_cjs.inlineText(inline) === target.text;
245
231
  }
246
232
  function storeBlockLatex(controller, target, latex, refocus) {
247
233
  const { state } = controller.editor;
248
234
  if (!targetBlockThere(state, target)) return;
249
- write(controller, new chunkFK7EBZPX_cjs.Transaction(state).step(chunkFK7EBZPX_cjs.setAttrsStep(target.block, { latex })), refocus);
235
+ write(controller, new chunkZ5EEDCRI_cjs.Transaction(state).step(chunkZ5EEDCRI_cjs.setAttrsStep(target.block, { latex })), refocus);
250
236
  }
251
237
  function storeAtomLatex(controller, target, latex, refocus) {
252
238
  const { state } = controller.editor;
253
239
  const node = targetAtom(state, target);
254
240
  if (node === null) return;
255
241
  const { block, region, offset } = target;
256
- const formula = latex === "" ? [] : [chunkI7X7B3WD_cjs.atom("math", { ...node.attrs, latex }, node.marks)];
257
- const tr = new chunkFK7EBZPX_cjs.Transaction(state).step(chunkFK7EBZPX_cjs.replaceInlineStep(block, region, offset, offset + 1, formula));
242
+ const formula = latex === "" ? [] : [chunk4JDRDPLC_cjs.atom("math", { ...node.attrs, latex }, node.marks)];
243
+ const tr = new chunkZ5EEDCRI_cjs.Transaction(state).step(chunkZ5EEDCRI_cjs.replaceInlineStep(block, region, offset, offset + 1, formula));
258
244
  write(controller, tr, refocus);
259
245
  }
260
246
  function insertFormula(controller, target, latex, refocus) {
261
247
  const { state } = controller.editor;
262
248
  if (latex === "" || !targetLineThere(state, target)) return;
263
249
  const { block, region, offset } = target;
264
- const formula = chunkI7X7B3WD_cjs.atom("math", { latex }, chunkFK7EBZPX_cjs.caretMarks(state.doc, state.schema, state.storedMarks, target));
265
- write(controller, new chunkFK7EBZPX_cjs.Transaction(state).step(chunkFK7EBZPX_cjs.replaceInlineStep(block, region, offset, offset, [formula])), refocus);
250
+ const formula = chunk4JDRDPLC_cjs.atom("math", { latex }, chunkZ5EEDCRI_cjs.caretMarks(state.doc, state.schema, state.storedMarks, target));
251
+ write(controller, new chunkZ5EEDCRI_cjs.Transaction(state).step(chunkZ5EEDCRI_cjs.replaceInlineStep(block, region, offset, offset, [formula])), refocus);
266
252
  }
267
253
  function useMathAtomOpening(controller, editable) {
268
254
  react.useEffect(() => {
269
255
  const root = controller.root;
270
256
  if (!editable || root === null) return;
271
257
  const intercept = (event) => {
272
- if (!chunkJZF6UQH5_cjs.plainEnter(event) || chunk2QKFRKOP_cjs.isComposingKey(controller, event)) return false;
273
- const place = chunkJZF6UQH5_cjs.selectedAtom(controller.editor.state, MATH_ATOMS);
258
+ if (!chunkWMKA37NJ_cjs.plainEnter(event) || chunkN25EH2GZ_cjs.isComposingKey(controller, event)) return false;
259
+ const place = chunkWMKA37NJ_cjs.selectedAtom(controller.editor.state, MATH_ATOMS);
274
260
  if (place === null) return false;
275
261
  event.preventDefault();
276
262
  openMath(controller, atomTarget(place));
277
263
  return true;
278
264
  };
279
265
  const onClick = (event) => {
280
- const place = event.shiftKey ? null : chunkJZF6UQH5_cjs.atomAtTarget(controller, event.target, MATH_ATOMS);
266
+ const once = !event.shiftKey && event.detail <= 1;
267
+ const place = once ? chunkWMKA37NJ_cjs.atomAtTarget(controller, event.target, MATH_ATOMS) : null;
281
268
  if (place !== null) openMath(controller, atomTarget(place));
282
269
  };
283
270
  controller.keyInterceptors.add(intercept);
@@ -293,14 +280,14 @@ function isThere(state, target) {
293
280
  return target.kind === "atom" ? targetAtom(state, target) !== null : targetLineThere(state, target);
294
281
  }
295
282
  function MathEditorOverlay({ controller, feature }) {
296
- const readOnly = chunk2QKFRKOP_cjs.useReadOnly(controller);
283
+ const readOnly = chunkN25EH2GZ_cjs.useReadOnly(controller);
297
284
  const target = useMathTarget(controller);
298
- const there = chunk2QKFRKOP_cjs.useEditorState(
285
+ const there = chunkN25EH2GZ_cjs.useEditorState(
299
286
  controller,
300
287
  react.useCallback((state) => target !== null && isThere(state, target), [target])
301
288
  );
302
289
  useMathAtomOpening(controller, !readOnly);
303
- chunkJZF6UQH5_cjs.useSelectionOutOfAtoms(controller, MATH_ATOMS, !readOnly);
290
+ chunkWMKA37NJ_cjs.useSelectionOutOfAtoms(controller, MATH_ATOMS, !readOnly);
304
291
  const shown = target !== null && there && !readOnly;
305
292
  react.useEffect(() => {
306
293
  if (target !== null && !shown) openMath(controller, null);
@@ -309,7 +296,7 @@ function MathEditorOverlay({ controller, feature }) {
309
296
  return target.kind === "block" ? /* @__PURE__ */ jsxRuntime.jsx(BlockMathEditor, { controller, feature, target }, JSON.stringify(target)) : /* @__PURE__ */ jsxRuntime.jsx(InlineMathEditor, { controller, feature, target }, JSON.stringify(target));
310
297
  }
311
298
  function BlockMathEditor({ controller, feature, target }) {
312
- const anchor = chunkEBSDPHPS_cjs.usePartAnchor(controller, target.block, ".quoin-math");
299
+ const anchor = chunk4UFWFV43_cjs.usePartAnchor(controller, target.block, ".quoin-math");
313
300
  return /* @__PURE__ */ jsxRuntime.jsx(
314
301
  MathEditorPopover,
315
302
  {
@@ -321,7 +308,7 @@ function BlockMathEditor({ controller, feature, target }) {
321
308
  displayMode: true,
322
309
  onStore: (next, refocus) => storeBlockLatex(controller, target, next, refocus),
323
310
  onClose: () => openMath(controller, null),
324
- onReturn: () => chunkEBSDPHPS_cjs.focusNode(controller, target.block)
311
+ onReturn: () => chunk4UFWFV43_cjs.focusNode(controller, target.block)
325
312
  }
326
313
  );
327
314
  }
@@ -332,7 +319,7 @@ function InlineMathEditor({ controller, feature, target }) {
332
319
  () => ({ block, region, from: offset, to: editing ? offset + 1 : offset }),
333
320
  [block, region, offset, editing]
334
321
  );
335
- const { anchor, side } = chunkEBSDPHPS_cjs.useRangeAnchor(controller, range);
322
+ const { anchor, side } = chunk4UFWFV43_cjs.useRangeAnchor(controller, range);
336
323
  const kept = react.useRef(editing);
337
324
  const onStore = (latex, refocus) => {
338
325
  kept.current = latex !== "";
@@ -382,10 +369,10 @@ function scannedLine(inline) {
382
369
  let marks = [];
383
370
  let start = 0;
384
371
  for (const node of inline) {
385
- if (!chunkI7X7B3WD_cjs.sameMarkSet(marks, node.marks)) push(OPAQUE, null);
372
+ if (!chunk4JDRDPLC_cjs.sameMarkSet(marks, node.marks)) push(OPAQUE, null);
386
373
  marks = node.marks;
387
374
  if (node.kind === "atom") push(OPAQUE, null);
388
- else for (let i = 0; i < node.text.length; i++) push(chunkI7X7B3WD_cjs.hasMark(marks, "code") ? OPAQUE : node.text[i], start + i);
375
+ else for (let i = 0; i < node.text.length; i++) push(chunk4JDRDPLC_cjs.hasMark(marks, "code") ? OPAQUE : node.text[i], start + i);
389
376
  start += node.kind === "atom" ? 1 : node.text.length;
390
377
  }
391
378
  if (marks.length > 0) push(OPAQUE, null);
@@ -397,10 +384,10 @@ function mathOpening(src, close) {
397
384
  const at = src.indexOf("$", pos);
398
385
  if (at < 0 || at >= close) return -1;
399
386
  if (src[at + 1] === "$") {
400
- pos = chunkI7X7B3WD_cjs.dollarRunEnd(src, at);
387
+ pos = chunk4JDRDPLC_cjs.dollarRunEnd(src, at);
401
388
  continue;
402
389
  }
403
- const end = chunkYEDPBYO5_cjs.escaped(src, at) || !chunkI7X7B3WD_cjs.opensMath(src, at) ? -1 : chunkI7X7B3WD_cjs.findMathClose(src, at + 2);
390
+ const end = chunkUDQ52EEC_cjs.escaped(src, at) || !chunk4JDRDPLC_cjs.opensMath(src, at) ? -1 : chunk4JDRDPLC_cjs.findMathClose(src, at + 2);
404
391
  if (end === close) return at;
405
392
  pos = end < 0 ? at + 1 : end + 1;
406
393
  }
@@ -410,14 +397,14 @@ var inlineMathRule = {
410
397
  match: /\$$/,
411
398
  handler(state, _match, range) {
412
399
  const { block, region, to } = range;
413
- const inline = chunkFK7EBZPX_cjs.regionInline(state, range);
400
+ const inline = chunkZ5EEDCRI_cjs.regionInline(state, range);
414
401
  const { src, offsets } = scannedLine(inline);
415
402
  const close = offsets.indexOf(to - 1);
416
403
  const open = close < 0 ? -1 : mathOpening(src, close);
417
404
  if (open < 0 || offsets.slice(open, close + 1).includes(null)) return null;
418
405
  const from = offsets[open];
419
- const formula = chunkI7X7B3WD_cjs.atom("math", { latex: chunkI7X7B3WD_cjs.mathLatex(src, open, close) }, chunkI7X7B3WD_cjs.sliceInline(inline, from, from + 1)[0].marks);
420
- return new chunkFK7EBZPX_cjs.Transaction(state).step(chunkFK7EBZPX_cjs.replaceInlineStep(block, region, from, to, [formula])).setSelection(chunkFK7EBZPX_cjs.textSelection({ block, region, offset: from + 1 }));
406
+ const formula = chunk4JDRDPLC_cjs.atom("math", { latex: chunk4JDRDPLC_cjs.mathLatex(src, open, close) }, chunk4JDRDPLC_cjs.sliceInline(inline, from, from + 1)[0].marks);
407
+ return new chunkZ5EEDCRI_cjs.Transaction(state).step(chunkZ5EEDCRI_cjs.replaceInlineStep(block, region, from, to, [formula])).setSelection(chunkZ5EEDCRI_cjs.textSelection({ block, region, offset: from + 1 }));
421
408
  }
422
409
  };
423
410
 
@@ -426,8 +413,8 @@ var KEYWORDS = ["math", "latex", "formula", "katex"];
426
413
  function caretInCode({ doc, selection }) {
427
414
  if (selection?.kind !== "text") return false;
428
415
  const { block, region, offset } = selection.head;
429
- const inline = chunkI7X7B3WD_cjs.blockById(doc, block)?.regions[region] ?? [];
430
- return chunkI7X7B3WD_cjs.hasMark(chunkI7X7B3WD_cjs.marksAt(inline, offset, () => true), "code");
416
+ const inline = chunk4JDRDPLC_cjs.blockById(doc, block)?.regions[region] ?? [];
417
+ return chunk4JDRDPLC_cjs.hasMark(chunk4JDRDPLC_cjs.marksAt(inline, offset, () => true), "code");
431
418
  }
432
419
  var mathSlashItems = (labels) => [
433
420
  {
@@ -435,22 +422,22 @@ var mathSlashItems = (labels) => [
435
422
  title: labels.blockEquation,
436
423
  description: labels.blockEquationDescription,
437
424
  group: "advanced",
438
- icon: chunkEBSDPHPS_cjs.Sigma,
425
+ icon: chunk4UFWFV43_cjs.Sigma,
439
426
  keywords: [...KEYWORDS, "$$"],
440
- command: () => chunkEBSDPHPS_cjs.insertBlockToWrite({ type: "MATH", attrs: { latex: "" } }, true)
427
+ command: () => chunk4UFWFV43_cjs.insertBlockToWrite({ type: "MATH", attrs: { latex: "" } }, true)
441
428
  },
442
429
  {
443
430
  id: "inline-equation",
444
431
  title: labels.inlineEquation,
445
432
  description: labels.inlineEquationDescription,
446
433
  group: "advanced",
447
- icon: chunkEBSDPHPS_cjs.Radical,
434
+ icon: chunk4UFWFV43_cjs.Radical,
448
435
  keywords: [...KEYWORDS, "$"],
449
436
  available: (state) => !caretInCode(state),
450
437
  run({ controller, range }) {
451
- const inline = chunkI7X7B3WD_cjs.blockById(controller.editor.state.doc, range.block)?.regions[range.region] ?? [];
438
+ const inline = chunk4JDRDPLC_cjs.blockById(controller.editor.state.doc, range.block)?.regions[range.region] ?? [];
452
439
  const { block, region, from } = range;
453
- openMath(controller, { kind: "insert", block, region, offset: from, text: chunkI7X7B3WD_cjs.inlineText(inline) });
440
+ openMath(controller, { kind: "insert", block, region, offset: from, text: chunk4JDRDPLC_cjs.inlineText(inline) });
454
441
  }
455
442
  }
456
443
  ];
@@ -466,12 +453,12 @@ function mathExtension(options = {}) {
466
453
  render: { atoms: { math: inlineMathRenderer(feature) } },
467
454
  overlays: [EditorOverlay]
468
455
  };
469
- return chunkFK7EBZPX_cjs.defineExtension({
456
+ return chunkZ5EEDCRI_cjs.defineExtension({
470
457
  name: "math",
471
458
  priority: ABOVE_CORE_KEYS,
472
459
  inputRules: [inlineMathRule],
473
- keymap: chunkJZF6UQH5_cjs.atomKeymap(MATH_ATOMS),
474
- decorations: chunkJZF6UQH5_cjs.selectedAtomDecorations(MATH_ATOMS),
460
+ keymap: chunkWMKA37NJ_cjs.atomKeymap(MATH_ATOMS),
461
+ decorations: chunkWMKA37NJ_cjs.selectedAtomDecorations(MATH_ATOMS),
475
462
  ui
476
463
  });
477
464
  }