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.
- package/CHANGELOG.md +110 -0
- package/MIGRATION.md +1 -1
- package/README.md +14 -13
- package/dist/ai.cjs +124 -94
- package/dist/ai.d.cts +7 -0
- package/dist/ai.d.ts +7 -0
- package/dist/ai.js +50 -20
- package/dist/ai.js.map +1 -1
- package/dist/catalogue.cjs +28 -26
- package/dist/catalogue.js +19 -17
- package/dist/catalogue.js.map +1 -1
- package/dist/{chunk-JGEDJYIV.cjs → chunk-2FUWXPPC.cjs} +92 -98
- package/dist/{chunk-NHNW5DK3.js → chunk-3F76QQ65.js} +6 -6
- package/dist/{chunk-NHNW5DK3.js.map → chunk-3F76QQ65.js.map} +1 -1
- package/dist/{chunk-DBOZFNWU.js → chunk-3QYFAAQR.js} +3 -3
- package/dist/{chunk-DBOZFNWU.js.map → chunk-3QYFAAQR.js.map} +1 -1
- package/dist/{chunk-I7X7B3WD.cjs → chunk-4JDRDPLC.cjs} +17 -8
- package/dist/{chunk-EBSDPHPS.cjs → chunk-4UFWFV43.cjs} +1060 -719
- package/dist/{chunk-LM3DHROX.cjs → chunk-5AUIA4B3.cjs} +2 -2
- package/dist/{chunk-3INFNIGN.cjs → chunk-5H3BB5VJ.cjs} +131 -78
- package/dist/{chunk-DJU25PFC.cjs → chunk-5L2NSIHZ.cjs} +11 -11
- package/dist/{chunk-W376L2GM.js → chunk-6Y7JAWYY.js} +8 -8
- package/dist/chunk-6Y7JAWYY.js.map +1 -0
- package/dist/{chunk-UDBLZILE.js → chunk-ATKDXQEY.js} +12 -7
- package/dist/{chunk-UDBLZILE.js.map → chunk-ATKDXQEY.js.map} +1 -1
- package/dist/{chunk-A2IQHMIH.js → chunk-BE2SYPK5.js} +49 -54
- package/dist/chunk-BE2SYPK5.js.map +1 -0
- package/dist/{chunk-PURYVDC3.cjs → chunk-CFICD2JP.cjs} +21 -16
- package/dist/{chunk-3HW3WRYC.cjs → chunk-CSIUXYRU.cjs} +2 -2
- package/dist/{chunk-N7BSFDDM.cjs → chunk-DBKL524I.cjs} +23 -23
- package/dist/{chunk-XE3IYW5B.js → chunk-DEFYFIWW.js} +90 -37
- package/dist/chunk-DEFYFIWW.js.map +1 -0
- package/dist/{chunk-7E43TURF.cjs → chunk-ECI3PSMS.cjs} +7 -7
- package/dist/{chunk-4G645EYO.js → chunk-F73QEF7E.js} +5 -5
- package/dist/{chunk-4G645EYO.js.map → chunk-F73QEF7E.js.map} +1 -1
- package/dist/{chunk-KHRVCTQQ.cjs → chunk-FUT7XLMP.cjs} +61 -74
- package/dist/{chunk-7J63427U.cjs → chunk-GQSBOBOM.cjs} +375 -320
- package/dist/{chunk-LU3T3JB4.js → chunk-HPNSQWRD.js} +15 -28
- package/dist/chunk-HPNSQWRD.js.map +1 -0
- package/dist/{chunk-7Y4B7NHO.js → chunk-I34BFOLL.js} +18 -11
- package/dist/chunk-I34BFOLL.js.map +1 -0
- package/dist/{chunk-AJT54OMZ.js → chunk-IFRXEFQH.js} +9 -15
- package/dist/chunk-IFRXEFQH.js.map +1 -0
- package/dist/{chunk-YYW33WUL.cjs → chunk-K3XWVRL4.cjs} +8 -8
- package/dist/{chunk-LSI4RMTY.js → chunk-L5L6YNLT.js} +3 -3
- package/dist/{chunk-LSI4RMTY.js.map → chunk-L5L6YNLT.js.map} +1 -1
- package/dist/{chunk-2BPXVQBP.js → chunk-MO4UMXMT.js} +238 -86
- package/dist/chunk-MO4UMXMT.js.map +1 -0
- package/dist/{chunk-2QKFRKOP.cjs → chunk-N25EH2GZ.cjs} +351 -205
- package/dist/{chunk-CSPCDVCT.js → chunk-NCV2ML25.js} +3 -3
- package/dist/{chunk-CSPCDVCT.js.map → chunk-NCV2ML25.js.map} +1 -1
- package/dist/{chunk-NUQ64S5B.cjs → chunk-OJSKSQTL.cjs} +26 -26
- package/dist/chunk-PIWMU4BV.js +9 -0
- package/dist/chunk-PIWMU4BV.js.map +1 -0
- package/dist/chunk-QFGWSFOI.cjs +10 -0
- package/dist/{chunk-GPTJYWGS.js → chunk-RNBLVGWY.js} +3 -3
- package/dist/{chunk-GPTJYWGS.js.map → chunk-RNBLVGWY.js.map} +1 -1
- package/dist/{chunk-5RBMZGKV.js → chunk-TL2MJOWM.js} +325 -57
- package/dist/chunk-TL2MJOWM.js.map +1 -0
- package/dist/{chunk-YEDPBYO5.cjs → chunk-UDQ52EEC.cjs} +4 -4
- package/dist/{chunk-EIWPJWY3.js → chunk-UE2NQPNG.js} +5 -5
- package/dist/{chunk-EIWPJWY3.js.map → chunk-UE2NQPNG.js.map} +1 -1
- package/dist/{chunk-BE2YHZXA.cjs → chunk-ULV3SCYP.cjs} +26 -15
- package/dist/{chunk-WDBFGX3U.cjs → chunk-VTTMJGWP.cjs} +72 -77
- package/dist/{chunk-556PFYES.js → chunk-WK4UGDZN.js} +290 -235
- package/dist/chunk-WK4UGDZN.js.map +1 -0
- package/dist/{chunk-JZF6UQH5.cjs → chunk-WMKA37NJ.cjs} +12 -12
- package/dist/{chunk-F2ZK6Z52.js → chunk-Y26F2X4E.js} +3 -3
- package/dist/{chunk-F2ZK6Z52.js.map → chunk-Y26F2X4E.js.map} +1 -1
- package/dist/{chunk-FK7EBZPX.cjs → chunk-Z5EEDCRI.cjs} +549 -276
- package/dist/{chunk-G6NBQYMM.js → chunk-ZGFZRVQA.js} +817 -478
- package/dist/chunk-ZGFZRVQA.js.map +1 -0
- package/dist/{chunk-QLVX7MPS.js → chunk-ZQF45LA4.js} +19 -8
- package/dist/chunk-ZQF45LA4.js.map +1 -0
- package/dist/comments.cjs +127 -65
- package/dist/comments.d.cts +35 -2
- package/dist/comments.d.ts +35 -2
- package/dist/comments.js +73 -12
- package/dist/comments.js.map +1 -1
- package/dist/{diagram-extension-22x_njXB.d.ts → diagram-extension-BMlh8GCw.d.ts} +1 -1
- package/dist/{diagram-extension-C_FSkoj9.d.cts → diagram-extension-gmndUpti.d.cts} +1 -1
- package/dist/diagram.cjs +10 -9
- package/dist/diagram.d.cts +2 -2
- package/dist/diagram.d.ts +2 -2
- package/dist/diagram.js +7 -6
- package/dist/diff.cjs +25 -25
- package/dist/diff.js +3 -3
- package/dist/docx.cjs +31 -30
- package/dist/docx.js +5 -4
- package/dist/docx.js.map +1 -1
- package/dist/embed.cjs +10 -9
- package/dist/embed.js +8 -7
- package/dist/{emoji-extension-Dk5IQLZf.d.cts → emoji-extension-DD9CQTQj.d.cts} +1 -1
- package/dist/{emoji-extension-C832oGeT.d.ts → emoji-extension-U_PWZ2fX.d.ts} +1 -1
- package/dist/emoji.cjs +10 -9
- package/dist/emoji.d.cts +2 -2
- package/dist/emoji.d.ts +2 -2
- package/dist/emoji.js +7 -6
- package/dist/engine.cjs +58 -58
- package/dist/engine.d.cts +3 -3
- package/dist/engine.d.ts +3 -3
- package/dist/engine.js +3 -3
- package/dist/{find-extension-DmK9_N81.d.ts → find-extension-BGlqooZi.d.ts} +1 -1
- package/dist/{find-extension-BfruAPLi.d.cts → find-extension-BPnAJ8bY.d.cts} +1 -1
- package/dist/find.cjs +11 -10
- package/dist/find.d.cts +1 -1
- package/dist/find.d.ts +1 -1
- package/dist/find.js +7 -6
- package/dist/headless.cjs +70 -69
- package/dist/headless.d.cts +33 -10
- package/dist/headless.d.ts +33 -10
- package/dist/headless.js +5 -4
- package/dist/highlight.cjs +7 -6
- package/dist/highlight.js +6 -5
- package/dist/highlight.js.map +1 -1
- package/dist/{index-3fYvwqUZ.d.cts → index-DN7vRKFw.d.cts} +1 -1
- package/dist/{index-CgxnzCO5.d.ts → index-DyIYI3PM.d.ts} +1 -1
- package/dist/index.cjs +82 -81
- package/dist/index.d.cts +19 -12
- package/dist/index.d.ts +19 -12
- package/dist/index.js +6 -5
- package/dist/{labels-CiCxj2jP.d.cts → labels-BJORhN93.d.ts} +10 -5
- package/dist/{labels-BhRJYo46.d.ts → labels-CVYJ2-1X.d.cts} +10 -5
- package/dist/locale-ar.cjs +10 -0
- package/dist/locale-ar.d.cts +1 -1
- package/dist/locale-ar.d.ts +1 -1
- package/dist/locale-ar.js +10 -0
- package/dist/locale-ar.js.map +1 -1
- package/dist/locale-de.cjs +4 -0
- package/dist/locale-de.d.cts +1 -1
- package/dist/locale-de.d.ts +1 -1
- package/dist/locale-de.js +4 -0
- package/dist/locale-de.js.map +1 -1
- package/dist/locale-es.cjs +4 -0
- package/dist/locale-es.d.cts +1 -1
- package/dist/locale-es.d.ts +1 -1
- package/dist/locale-es.js +4 -0
- package/dist/locale-es.js.map +1 -1
- package/dist/locale-fr.cjs +4 -0
- package/dist/locale-fr.d.cts +1 -1
- package/dist/locale-fr.d.ts +1 -1
- package/dist/locale-fr.js +4 -0
- package/dist/locale-fr.js.map +1 -1
- package/dist/locale-ja.cjs +4 -0
- package/dist/locale-ja.d.cts +1 -1
- package/dist/locale-ja.d.ts +1 -1
- package/dist/locale-ja.js +4 -0
- package/dist/locale-ja.js.map +1 -1
- package/dist/locale-pt.cjs +4 -0
- package/dist/locale-pt.d.cts +1 -1
- package/dist/locale-pt.d.ts +1 -1
- package/dist/locale-pt.js +4 -0
- package/dist/locale-pt.js.map +1 -1
- package/dist/locale-zh.cjs +4 -0
- package/dist/locale-zh.d.cts +1 -1
- package/dist/locale-zh.d.ts +1 -1
- package/dist/locale-zh.js +4 -0
- package/dist/locale-zh.js.map +1 -1
- package/dist/math.cjs +11 -10
- package/dist/math.js +9 -8
- package/dist/mention.cjs +11 -10
- package/dist/mention.js +9 -8
- package/dist/{node-reveal-DY6bimv3.d.cts → node-reveal-Be7Xa0BL.d.cts} +1 -1
- package/dist/{node-reveal-BnFcnHhz.d.ts → node-reveal-CftIEqF_.d.ts} +1 -1
- package/dist/palette-DuIFHYHc.d.cts +10 -0
- package/dist/palette-DuIFHYHc.d.ts +10 -0
- package/dist/presence.cjs +39 -38
- package/dist/presence.js +8 -7
- package/dist/presence.js.map +1 -1
- package/dist/source.cjs +10 -9
- package/dist/source.d.cts +1 -1
- package/dist/source.d.ts +1 -1
- package/dist/source.js +6 -5
- package/dist/source.js.map +1 -1
- package/dist/{stats-extension-Dmw0Ujxe.d.ts → stats-extension-Bbpr593p.d.ts} +1 -1
- package/dist/{stats-extension-D5HySF0a.d.cts → stats-extension-D7FaeydW.d.cts} +1 -1
- package/dist/stats.cjs +12 -10
- package/dist/stats.d.cts +2 -2
- package/dist/stats.d.ts +2 -2
- package/dist/stats.js +9 -7
- package/dist/styles.css +1 -1
- package/dist/{table-extension-7LkLNK6Q.d.cts → table-extension-DNijjmxV.d.cts} +1 -1
- package/dist/{table-extension-DEpV0DnP.d.ts → table-extension-Dp6FYGPh.d.ts} +1 -1
- package/dist/table.cjs +26 -25
- package/dist/table.d.cts +4 -3
- package/dist/table.d.ts +4 -3
- package/dist/table.js +7 -6
- package/dist/{toc-extension-Dvh37bWQ.d.cts → toc-extension-BGEVAmSY.d.cts} +1 -1
- package/dist/{toc-extension-SVckrFmb.d.ts → toc-extension-DZIe40eV.d.ts} +1 -1
- package/dist/toc.cjs +10 -9
- package/dist/toc.d.cts +2 -2
- package/dist/toc.d.ts +2 -2
- package/dist/toc.js +7 -6
- package/dist/{types-DMuuDBVh.d.ts → types-Byu2a9qk.d.ts} +6 -1
- package/dist/{types-Bzhq5AXj.d.cts → types-DdDlCyyZ.d.cts} +6 -1
- package/dist/view.cjs +4 -4
- package/dist/view.js +2 -2
- package/dist/yjs.cjs +121 -121
- package/dist/yjs.d.cts +2 -2
- package/dist/yjs.d.ts +2 -2
- package/dist/yjs.js +5 -5
- package/package.json +4 -3
- package/dist/chunk-2BPXVQBP.js.map +0 -1
- package/dist/chunk-556PFYES.js.map +0 -1
- package/dist/chunk-5RBMZGKV.js.map +0 -1
- package/dist/chunk-7Y4B7NHO.js.map +0 -1
- package/dist/chunk-A2IQHMIH.js.map +0 -1
- package/dist/chunk-AJT54OMZ.js.map +0 -1
- package/dist/chunk-G6NBQYMM.js.map +0 -1
- package/dist/chunk-LU3T3JB4.js.map +0 -1
- package/dist/chunk-QLVX7MPS.js.map +0 -1
- package/dist/chunk-W376L2GM.js.map +0 -1
- package/dist/chunk-XE3IYW5B.js.map +0 -1
- package/dist/palette-BrX-hEd-.d.cts +0 -4
- package/dist/palette-BrX-hEd-.d.ts +0 -4
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
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
|
|
10
|
-
var
|
|
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 =
|
|
91
|
+
const readOnly = chunkN25EH2GZ_cjs.useReadOnly(controller);
|
|
92
92
|
const root = react.useRef(null);
|
|
93
93
|
const blockId = block.id;
|
|
94
|
-
const 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
|
-
|
|
99
|
+
chunk4UFWFV43_cjs.useNodeKeys(controller, blockId, !readOnly, true, root, keys);
|
|
100
100
|
const open = () => {
|
|
101
|
-
|
|
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
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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
|
-
|
|
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 (
|
|
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
|
-
|
|
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(
|
|
165
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunk4UFWFV43_cjs.PopoverAnchor, { virtualRef: anchor }),
|
|
180
166
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
181
|
-
|
|
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:
|
|
180
|
+
onCloseAutoFocus: chunk4UFWFV43_cjs.preventDefault,
|
|
195
181
|
onEscapeKeyDown: (event) => {
|
|
196
182
|
event.preventDefault();
|
|
197
|
-
if (!
|
|
183
|
+
if (!chunkN25EH2GZ_cjs.isComposingKey(controller, event)) close(false);
|
|
198
184
|
},
|
|
199
|
-
...
|
|
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(
|
|
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 =
|
|
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 =
|
|
240
|
-
return block?.type === "MATH" &&
|
|
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 =
|
|
244
|
-
return inline !== void 0 &&
|
|
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
|
|
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 === "" ? [] : [
|
|
257
|
-
const tr = new
|
|
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 =
|
|
265
|
-
write(controller, new
|
|
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 (!
|
|
273
|
-
const place =
|
|
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
|
|
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 =
|
|
283
|
+
const readOnly = chunkN25EH2GZ_cjs.useReadOnly(controller);
|
|
297
284
|
const target = useMathTarget(controller);
|
|
298
|
-
const there =
|
|
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
|
-
|
|
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 =
|
|
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: () =>
|
|
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 } =
|
|
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 (!
|
|
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(
|
|
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 =
|
|
387
|
+
pos = chunk4JDRDPLC_cjs.dollarRunEnd(src, at);
|
|
401
388
|
continue;
|
|
402
389
|
}
|
|
403
|
-
const end =
|
|
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 =
|
|
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 =
|
|
420
|
-
return new
|
|
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 =
|
|
430
|
-
return
|
|
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:
|
|
425
|
+
icon: chunk4UFWFV43_cjs.Sigma,
|
|
439
426
|
keywords: [...KEYWORDS, "$$"],
|
|
440
|
-
command: () =>
|
|
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:
|
|
434
|
+
icon: chunk4UFWFV43_cjs.Radical,
|
|
448
435
|
keywords: [...KEYWORDS, "$"],
|
|
449
436
|
available: (state) => !caretInCode(state),
|
|
450
437
|
run({ controller, range }) {
|
|
451
|
-
const inline =
|
|
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:
|
|
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
|
|
456
|
+
return chunkZ5EEDCRI_cjs.defineExtension({
|
|
470
457
|
name: "math",
|
|
471
458
|
priority: ABOVE_CORE_KEYS,
|
|
472
459
|
inputRules: [inlineMathRule],
|
|
473
|
-
keymap:
|
|
474
|
-
decorations:
|
|
460
|
+
keymap: chunkWMKA37NJ_cjs.atomKeymap(MATH_ATOMS),
|
|
461
|
+
decorations: chunkWMKA37NJ_cjs.selectedAtomDecorations(MATH_ATOMS),
|
|
475
462
|
ui
|
|
476
463
|
});
|
|
477
464
|
}
|