@aiquants/markdown-explorer 0.22.0 → 0.24.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 +143 -0
- package/README.md +63 -17
- package/dist/{EditSurface-BesNcSQj.cjs → EditSurface-CRc4g0Qa.cjs} +5 -5
- package/dist/{EditSurface-DNjI8pV3.js → EditSurface-CcWEczj3.js} +333 -336
- package/dist/{ExplorerSplit-GUdzpDPg.js → ExplorerSplit-97SeIAOS.js} +81 -81
- package/dist/{ExplorerSplit-B4oNvydP.cjs → ExplorerSplit-ByxxXlgs.cjs} +1 -1
- package/dist/{MultiLayout-DtKChQ_s.cjs → MultiLayout-B_yMVDt_.cjs} +1 -1
- package/dist/{MultiLayout-BJ-s6AaD.js → MultiLayout-CnbuAlxd.js} +4 -4
- package/dist/{NativeScrollBar-D10fsk-7.js → NativeScrollBar-BXdaM3EA.js} +1 -1
- package/dist/{NativeScrollBar-DJKlPWvD.cjs → NativeScrollBar-D4a7fBOS.cjs} +1 -1
- package/dist/{TreeLayout-DQT5p2vI.js → TreeLayout-BIQBKAkV.js} +3 -3
- package/dist/{TreeLayout-C1mTmoPp.cjs → TreeLayout-C6QDpEBS.cjs} +1 -1
- package/dist/core/config.d.cts +13 -0
- package/dist/core/config.d.ts +13 -0
- package/dist/core/contracts.d.cts +29 -4
- package/dist/core/contracts.d.ts +29 -4
- package/dist/core/labels.d.cts +21 -0
- package/dist/core/labels.d.ts +21 -0
- package/dist/core/textEncoding.d.cts +4 -0
- package/dist/core/textEncoding.d.ts +4 -0
- package/dist/{dataRoute-CObbjNxG.js → dataRoute-BEvesOvN.js} +108 -99
- package/dist/dataRoute-Cv7fgCW7.cjs +1 -0
- package/dist/index-BwTVYkTR.cjs +13 -0
- package/dist/index-CeZDCyEl.js +4088 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +24 -23
- package/dist/location-CasigkBk.cjs +1 -0
- package/dist/location-gXXmC7CQ.js +643 -0
- package/dist/{merge-DauzoA2W.js → merge-DqjUgcV_.js} +1 -1
- package/dist/{merge-CTkzzHtn.cjs → merge-QLktbpZY.cjs} +1 -1
- package/dist/{sanitizePolicy-gEXeavb-.cjs → sanitizePolicy-CZwOaJ92.cjs} +1 -1
- package/dist/{sanitizePolicy-BWQtWhsL.js → sanitizePolicy-gVKBhabq.js} +1 -1
- package/dist/sanitizeWorker.cjs +1 -1
- package/dist/sanitizeWorker.js +1 -1
- package/dist/server/fileSystemSource.d.cts +1 -0
- package/dist/server/fileSystemSource.d.ts +1 -0
- package/dist/server/ports.d.cts +9 -1
- package/dist/server/ports.d.ts +9 -1
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +1 -0
- package/dist/server.d.ts +1 -0
- package/dist/server.js +852 -834
- package/dist/styles/markdown-explorer.css +1 -1
- package/dist/{useSplitPersistence-Cc4tDxB4.js → useSplitPersistence-BPNjvuJi.js} +1 -1
- package/dist/{useSplitPersistence-Ba-v64n-.cjs → useSplitPersistence-Bmpb2prR.cjs} +1 -1
- package/docs/behavior/dom-hooks.md +13 -6
- package/docs/behavior/layout.md +22 -8
- package/docs/behavior/localization.md +9 -5
- package/docs/behavior/security.md +6 -4
- package/docs/behavior/url-contract.md +2 -2
- package/package.json +5 -5
- package/dist/dataRoute-BONacTPi.cjs +0 -1
- package/dist/index-0pnuyLUO.js +0 -3662
- package/dist/index-T98wklgM.cjs +0 -13
- package/dist/location-B-m9scLf.js +0 -499
- package/dist/location-BVEN_Ihk.cjs +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { v as
|
|
1
|
+
import { jsx as R, jsxs as le } from "react/jsx-runtime";
|
|
2
|
+
import { useState as te, useRef as D, useLayoutEffect as B, useEffectEvent as ve, useEffect as Pe, useImperativeHandle as je, useMemo as J, startTransition as Ye, useCallback as X, useId as Je } from "react";
|
|
3
|
+
import { v as ne, g as me, h as Qe, u as se, i as Ze, l as et, j as tt, k as De, m as nt, n as rt, o as ot, p as it, E as lt, q as st, s as ct, t as at, w as we, x as be, A as ut, y as Ee, z as dt, B as ft, G as mt, H as pt } from "./index-CeZDCyEl.js";
|
|
4
4
|
import { fencedBodyAsRead as ht, planFencedBodyEdit as gt, fencedCodeLanguageOf as vt, SPREADSHEETS_LANGUAGE as wt, readFencedLine as bt, listItemWidthOn as Et, openingFenceOn as xt } from "@aiquants/markdown/code-blocks";
|
|
5
|
-
import { history as St, historyKeymap as yt, defaultKeymap as
|
|
6
|
-
import { markdown as
|
|
5
|
+
import { history as St, historyKeymap as yt, defaultKeymap as kt, historyField as Tt, redo as At, undo as It, isolateHistory as Lt } from "@codemirror/commands";
|
|
6
|
+
import { markdown as Ct, markdownLanguage as Ot } from "@codemirror/lang-markdown";
|
|
7
7
|
import { syntaxHighlighting as Mt, syntaxTreeAvailable as qt, HighlightStyle as Rt, ensureSyntaxTree as Be } from "@codemirror/language";
|
|
8
8
|
import { highlightSelectionMatches as _t, searchKeymap as Nt } from "@codemirror/search";
|
|
9
9
|
import { EditorState as Ve, EditorSelection as fe, StateField as Pt, RangeSetBuilder as Dt, MapMode as Bt } from "@codemirror/state";
|
|
@@ -11,13 +11,13 @@ import { EditorView as $, lineNumbers as Vt, highlightActiveLineGutter as Ht, dr
|
|
|
11
11
|
import { tags as N } from "@lezer/highlight";
|
|
12
12
|
import { MarkdownViewer as $t } from "@aiquants/markdown";
|
|
13
13
|
import { SOURCE_LINES_ATTRIBUTE as He, parseSourceLines as Kt } from "@aiquants/markdown/source-lines";
|
|
14
|
-
import { d as
|
|
15
|
-
import { H as Yt, c as Jt, M as Qt } from "./sanitizePolicy-
|
|
14
|
+
import { d as Xt, f as re, E as jt } from "./dataRoute-BEvesOvN.js";
|
|
15
|
+
import { H as Yt, c as Jt, M as Qt } from "./sanitizePolicy-gVKBhabq.js";
|
|
16
16
|
import Zt from "isomorphic-dompurify";
|
|
17
17
|
import { PanelGroup as en, Panel as xe, PanelResizeHandle as tn } from "@aiquants/resize-panels";
|
|
18
|
-
import { C as nn, F as rn, E as on, a as
|
|
19
|
-
import { u as cn, a as an } from "./useSplitPersistence-
|
|
20
|
-
const ze = { history:
|
|
18
|
+
import { C as nn, F as rn, E as on, a as ln, b as oe, d as sn } from "./location-gXXmC7CQ.js";
|
|
19
|
+
import { u as cn, a as an } from "./useSplitPersistence-BPNjvuJi.js";
|
|
20
|
+
const ze = { history: Tt }, un = Rt.define([
|
|
21
21
|
{ tag: [N.heading1, N.heading2, N.heading3, N.heading4, N.heading5, N.heading6, N.heading], color: "var(--aqmx-syntax-heading)", fontWeight: "700" },
|
|
22
22
|
{ tag: N.strong, fontWeight: "700" },
|
|
23
23
|
{ tag: N.emphasis, fontStyle: "italic" },
|
|
@@ -53,15 +53,15 @@ class hn extends Wt {
|
|
|
53
53
|
toDOM(t) {
|
|
54
54
|
const n = document.createElement("div");
|
|
55
55
|
n.setAttribute(Fe, String(this.index));
|
|
56
|
-
for (const [r,
|
|
56
|
+
for (const [r, l] of [
|
|
57
57
|
["ours", this.labels.useOurs],
|
|
58
58
|
["theirs", this.labels.useTheirs],
|
|
59
59
|
["both", this.labels.keepBoth]
|
|
60
60
|
]) {
|
|
61
61
|
const o = document.createElement("button");
|
|
62
|
-
o.type = "button", o.textContent =
|
|
63
|
-
const
|
|
64
|
-
|
|
62
|
+
o.type = "button", o.textContent = l, o.setAttribute("data-aqmx-conflict-choice", r), o.addEventListener("mousedown", (s) => s.preventDefault()), o.addEventListener("click", () => {
|
|
63
|
+
const s = ee(t.state.doc)[this.index];
|
|
64
|
+
s !== void 0 && (Ue(t, s, r), t.focus());
|
|
65
65
|
}), n.append(o);
|
|
66
66
|
}
|
|
67
67
|
return n;
|
|
@@ -70,14 +70,14 @@ class hn extends Wt {
|
|
|
70
70
|
return !0;
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
const ee = (e) =>
|
|
73
|
+
const ee = (e) => Qe(e.iterLines()), Se = (e, t) => {
|
|
74
74
|
const n = new Dt();
|
|
75
|
-
return ee(e).forEach((r,
|
|
75
|
+
return ee(e).forEach((r, l) => {
|
|
76
76
|
const o = e.line(r.start);
|
|
77
|
-
n.add(o.from, o.from, ce.widget({ widget: new hn(
|
|
78
|
-
for (let
|
|
79
|
-
const i = e.line(
|
|
80
|
-
n.add(i, i,
|
|
77
|
+
n.add(o.from, o.from, ce.widget({ widget: new hn(l, t), block: !0, side: -1 }));
|
|
78
|
+
for (let s = r.start; s <= r.end; s += 1) {
|
|
79
|
+
const i = e.line(s).from, d = s === r.start || s === r.separator || s === r.end ? fn : s < r.separator ? mn : pn;
|
|
80
|
+
n.add(i, i, d);
|
|
81
81
|
}
|
|
82
82
|
}), n.finish();
|
|
83
83
|
}, gn = (e) => Pt.define({
|
|
@@ -85,16 +85,16 @@ const ee = (e) => Ze(e.iterLines()), Se = (e, t) => {
|
|
|
85
85
|
update: (t, n) => n.docChanged ? Se(n.state.doc, e) : t,
|
|
86
86
|
provide: (t) => $.decorations.from(t)
|
|
87
87
|
}), Ue = (e, t, n) => {
|
|
88
|
-
const { doc: r } = e.state,
|
|
88
|
+
const { doc: r } = e.state, l = (y, c) => {
|
|
89
89
|
const w = [];
|
|
90
90
|
for (let u = y; u <= c; u += 1) w.push(r.line(u).text);
|
|
91
91
|
return w;
|
|
92
|
-
}, o =
|
|
93
|
-
let
|
|
94
|
-
i.length === 0 && (t.end < r.lines ?
|
|
92
|
+
}, o = l(t.start + 1, t.separator - 1), s = l(t.separator + 1, t.end - 1), i = n === "ours" ? o : n === "theirs" ? s : [...o, ...s];
|
|
93
|
+
let d = r.line(t.start).from, f = r.line(t.end).to;
|
|
94
|
+
i.length === 0 && (t.end < r.lines ? f += 1 : t.start > 1 && (d -= 1));
|
|
95
95
|
const p = i.join(`
|
|
96
96
|
`);
|
|
97
|
-
e.dispatch({ changes: { from:
|
|
97
|
+
e.dispatch({ changes: { from: d, to: f, insert: p }, selection: fe.cursor(d), scrollIntoView: !0, userEvent: "input.resolve" });
|
|
98
98
|
}, ye = "input.preview", vn = 20, wn = Gt.fromClass(
|
|
99
99
|
class {
|
|
100
100
|
constructor(e) {
|
|
@@ -126,60 +126,60 @@ const ee = (e) => Ze(e.iterLines()), Se = (e, t) => {
|
|
|
126
126
|
}
|
|
127
127
|
), bn = /`{3,}|~{3,}/u, Q = Object.freeze({ kind: "absent" }), ue = Object.freeze({ kind: "unreadable" }), En = (e, t, n) => {
|
|
128
128
|
const r = [];
|
|
129
|
-
for (let
|
|
130
|
-
(
|
|
131
|
-
const
|
|
132
|
-
const
|
|
133
|
-
return
|
|
129
|
+
for (let d = t.parent; d !== null; d = d.parent)
|
|
130
|
+
(d.name === "Blockquote" || d.name === "ListItem") && r.unshift(d);
|
|
131
|
+
const l = [], o = [], s = (d) => {
|
|
132
|
+
const f = o.indexOf(d);
|
|
133
|
+
return f === -1 ? o.length : f;
|
|
134
134
|
};
|
|
135
|
-
for (const
|
|
136
|
-
const
|
|
137
|
-
if (
|
|
138
|
-
const p = Et(e.line(
|
|
135
|
+
for (const d of r) {
|
|
136
|
+
const f = e.lineAt(d.from).number;
|
|
137
|
+
if (d.name === "ListItem") {
|
|
138
|
+
const p = Et(e.line(f).text, l, s(f));
|
|
139
139
|
if (p === null) return null;
|
|
140
|
-
|
|
140
|
+
l.push({ kind: "listItem", width: p });
|
|
141
141
|
} else
|
|
142
|
-
|
|
143
|
-
o.push(
|
|
142
|
+
l.push({ kind: "quote" });
|
|
143
|
+
o.push(f);
|
|
144
144
|
}
|
|
145
|
-
const i = xt(n.text,
|
|
146
|
-
return i === null ? null : { containers:
|
|
145
|
+
const i = xt(n.text, l, s(n.number));
|
|
146
|
+
return i === null ? null : { containers: l, ...i };
|
|
147
147
|
}, xn = (e, t) => {
|
|
148
148
|
const { doc: n } = e;
|
|
149
149
|
let r = n.lineAt(t).to;
|
|
150
150
|
for (; ; ) {
|
|
151
|
-
const
|
|
152
|
-
if (
|
|
153
|
-
const o =
|
|
154
|
-
if (o.name !== "CodeMark" ||
|
|
155
|
-
if (
|
|
156
|
-
r = Math.min(n.length,
|
|
151
|
+
const l = Be(e, r, Number.POSITIVE_INFINITY);
|
|
152
|
+
if (l === null) return null;
|
|
153
|
+
const o = l.resolveInner(t, 1), s = o.parent;
|
|
154
|
+
if (o.name !== "CodeMark" || s === null || s.name !== "FencedCode" || s.from !== o.from) return null;
|
|
155
|
+
if (s.to < r || r >= n.length) return s;
|
|
156
|
+
r = Math.min(n.length, s.to + Math.max(s.to - t, 1));
|
|
157
157
|
}
|
|
158
|
-
},
|
|
158
|
+
}, ke = (e, t) => {
|
|
159
159
|
const { doc: n } = e;
|
|
160
160
|
if (!Number.isInteger(t) || t < 1 || t > n.lines) return Q;
|
|
161
|
-
const r = n.line(t),
|
|
162
|
-
if (s === null) return Q;
|
|
163
|
-
const o = xn(e, r.from + s.index);
|
|
164
|
-
if (o === null) return Q;
|
|
165
|
-
const l = o.getChild("CodeInfo");
|
|
161
|
+
const r = n.line(t), l = bn.exec(r.text);
|
|
166
162
|
if (l === null) return Q;
|
|
167
|
-
const
|
|
163
|
+
const o = xn(e, r.from + l.index);
|
|
164
|
+
if (o === null) return Q;
|
|
165
|
+
const s = o.getChild("CodeInfo");
|
|
166
|
+
if (s === null) return Q;
|
|
167
|
+
const i = vt(n.sliceString(s.from, s.to));
|
|
168
168
|
if (i === null) return ue;
|
|
169
169
|
if (i !== wt) return Q;
|
|
170
|
-
const
|
|
171
|
-
if (
|
|
172
|
-
const [, ...
|
|
170
|
+
const d = En(n, o, r);
|
|
171
|
+
if (d === null) return ue;
|
|
172
|
+
const [, ...f] = o.getChildren("CodeMark"), p = f.at(-1), y = p === void 0 ? n.lineAt(o.to).number : n.lineAt(p.from).number - 1, c = [];
|
|
173
173
|
let w = "";
|
|
174
174
|
for (let u = t + 1; u <= y; u += 1) {
|
|
175
|
-
const m = n.line(u).text, g = bt(m,
|
|
175
|
+
const m = n.line(u).text, g = bt(m, d);
|
|
176
176
|
if (g === null) return ue;
|
|
177
177
|
c.push(m), w += u < n.lines ? `${g.content}
|
|
178
178
|
` : g.content;
|
|
179
179
|
}
|
|
180
|
-
return { kind: "found", firstLine: t + 1, lines: c, layout:
|
|
181
|
-
}, Sn = ({ parent: e, scroll: t, text: n, saved: r, labels:
|
|
182
|
-
let
|
|
180
|
+
return { kind: "found", firstLine: t + 1, lines: c, layout: d, body: w };
|
|
181
|
+
}, Sn = ({ parent: e, scroll: t, text: n, saved: r, labels: l, revisions: o, onChange: s, onGeometry: i, onSave: d }) => {
|
|
182
|
+
let f = !1;
|
|
183
183
|
const p = [
|
|
184
184
|
$.scrollHandler.of((u, m, g) => (yn(u, m.head, g, t), !0)),
|
|
185
185
|
Vt(),
|
|
@@ -189,34 +189,34 @@ const ee = (e) => Ze(e.iterLines()), Se = (e, t) => {
|
|
|
189
189
|
Ft(),
|
|
190
190
|
_t(),
|
|
191
191
|
$.lineWrapping,
|
|
192
|
-
|
|
192
|
+
Ct({ base: Ot }),
|
|
193
193
|
wn,
|
|
194
194
|
Mt(un),
|
|
195
|
-
gn(
|
|
195
|
+
gn(l),
|
|
196
196
|
Ut.of([
|
|
197
197
|
{
|
|
198
198
|
key: "Mod-s",
|
|
199
199
|
preventDefault: !0,
|
|
200
|
-
run: () => (
|
|
200
|
+
run: () => (d(), !0)
|
|
201
201
|
},
|
|
202
202
|
...Nt,
|
|
203
203
|
...yt,
|
|
204
|
-
...
|
|
204
|
+
...kt
|
|
205
205
|
]),
|
|
206
|
-
$.contentAttributes.of({ "aria-label":
|
|
206
|
+
$.contentAttributes.of({ "aria-label": l.editor, "aria-multiline": "true" }),
|
|
207
207
|
$.updateListener.of((u) => {
|
|
208
208
|
for (const m of u.transactions) m.docChanged && o.record(m.changes, m.newDoc);
|
|
209
|
-
u.docChanged &&
|
|
209
|
+
u.docChanged && s(u.transactions.every((m) => !m.docChanged || m.isUserEvent(ye))), (u.docChanged || u.heightChanged || u.geometryChanged) && i(u.docChanged && !f);
|
|
210
210
|
}),
|
|
211
211
|
dn
|
|
212
212
|
], y = An(r, p) ?? Ve.create({ doc: n, extensions: p }), c = new $({ state: y, parent: e });
|
|
213
213
|
o.mount(c.state.doc);
|
|
214
214
|
const w = (u) => {
|
|
215
|
-
|
|
215
|
+
f = !0;
|
|
216
216
|
try {
|
|
217
217
|
u();
|
|
218
218
|
} finally {
|
|
219
|
-
|
|
219
|
+
f = !1;
|
|
220
220
|
}
|
|
221
221
|
};
|
|
222
222
|
return {
|
|
@@ -232,9 +232,9 @@ const ee = (e) => Ze(e.iterLines()), Se = (e, t) => {
|
|
|
232
232
|
c.dispatch({ changes: { from: g, to: m.length - h, insert: u.slice(g, u.length - h) }, userEvent: "input.replace" });
|
|
233
233
|
},
|
|
234
234
|
replaceBody: (u, m, g, x) => {
|
|
235
|
-
const { doc: h } = c.state,
|
|
236
|
-
if (
|
|
237
|
-
const I =
|
|
235
|
+
const { doc: h } = c.state, k = o.lineOf(x, u);
|
|
236
|
+
if (k === null) return "changed";
|
|
237
|
+
const I = ke(c.state, k);
|
|
238
238
|
if (I.kind === "absent") return "changed";
|
|
239
239
|
if (I.kind === "unreadable") return "unwritable";
|
|
240
240
|
if (I.body !== ht(m, I.layout)) return "changed";
|
|
@@ -244,42 +244,42 @@ const ee = (e) => Ze(e.iterLines()), Se = (e, t) => {
|
|
|
244
244
|
const _ = (H) => {
|
|
245
245
|
const V = I.firstLine + H;
|
|
246
246
|
return V <= h.lines ? h.line(V).from : h.length;
|
|
247
|
-
},
|
|
247
|
+
}, O = _(A.from), P = `${O === h.length && h.sliceString(h.length - 1) !== `
|
|
248
248
|
` ? `
|
|
249
249
|
` : ""}${A.lines.map((H) => `${H}
|
|
250
250
|
`).join("")}`;
|
|
251
|
-
return w(() => c.dispatch({ changes: { from:
|
|
251
|
+
return w(() => c.dispatch({ changes: { from: O, to: _(A.to), insert: P }, userEvent: ye, annotations: Lt.of("full") })), "written";
|
|
252
252
|
},
|
|
253
253
|
readBody: (u, m) => {
|
|
254
254
|
const g = o.lineOf(m, u);
|
|
255
255
|
if (g === null) return null;
|
|
256
|
-
const x =
|
|
256
|
+
const x = ke(c.state, g);
|
|
257
257
|
return x.kind === "found" ? x.body : null;
|
|
258
258
|
},
|
|
259
259
|
undo: () => w(() => It(c)),
|
|
260
260
|
redo: () => w(() => At(c)),
|
|
261
261
|
reveal: ({ line: u, column: m }, g) => {
|
|
262
|
-
const { doc: x } = c.state, h = x.line(Math.min(Math.max(u, 1), x.lines)),
|
|
263
|
-
c.dispatch({ selection: fe.cursor(
|
|
262
|
+
const { doc: x } = c.state, h = x.line(Math.min(Math.max(u, 1), x.lines)), k = Math.min(h.from + m, h.to);
|
|
263
|
+
c.dispatch({ selection: fe.cursor(k), effects: Te(c, k, g, t) });
|
|
264
264
|
},
|
|
265
265
|
showLine: (u) => {
|
|
266
266
|
const { doc: m } = c.state, g = m.line(Math.min(Math.max(u, 1), m.lines)).from;
|
|
267
|
-
c.dispatch({ effects:
|
|
267
|
+
c.dispatch({ effects: Te(c, g, null, t) });
|
|
268
268
|
},
|
|
269
269
|
topLine: () => {
|
|
270
|
-
const u = t.scrollerOf(c.scrollDOM), m =
|
|
271
|
-
let
|
|
272
|
-
for (; h.lineAt(
|
|
273
|
-
const _ = c.lineBlockAt(
|
|
270
|
+
const u = t.scrollerOf(c.scrollDOM), m = ne(u, c.contentDOM), g = me(u) + u.clientHeight, { documentTop: x } = c, { doc: h } = c.state;
|
|
271
|
+
let k = c.lineBlockAtHeight(Math.max(m - x, 0));
|
|
272
|
+
for (; h.lineAt(k.from).text.trim() === "" && k.to < h.length; ) {
|
|
273
|
+
const _ = c.lineBlockAt(k.to + 1);
|
|
274
274
|
if (x + _.top >= g) break;
|
|
275
|
-
|
|
275
|
+
k = _;
|
|
276
276
|
}
|
|
277
|
-
const I = c.coordsAtPos(
|
|
278
|
-
return { line: c.state.doc.lineAt(
|
|
277
|
+
const I = c.coordsAtPos(k.from), A = I === null ? x + k.top : I.top;
|
|
278
|
+
return { line: c.state.doc.lineAt(k.from).number, clientTop: A, offset: A - m };
|
|
279
279
|
},
|
|
280
280
|
lineSpans: (u) => {
|
|
281
|
-
const m = c.scrollDOM, g = m.scrollTop + c.documentTop -
|
|
282
|
-
return u.map(({ first:
|
|
281
|
+
const m = c.scrollDOM, g = m.scrollTop + c.documentTop - ne(m, c.contentDOM), { doc: x } = c.state, h = (k) => x.line(Math.min(Math.max(k, 1), x.lines)).from;
|
|
282
|
+
return u.map(({ first: k, last: I }) => ({ top: g + c.lineBlockAt(h(k)).top, bottom: g + c.lineBlockAt(h(I)).bottom }));
|
|
283
283
|
},
|
|
284
284
|
scrollElement: c.scrollDOM,
|
|
285
285
|
focus: () => c.focus(),
|
|
@@ -291,49 +291,49 @@ const ee = (e) => Ze(e.iterLines()), Se = (e, t) => {
|
|
|
291
291
|
nextConflict: () => {
|
|
292
292
|
const u = ee(c.state.doc);
|
|
293
293
|
if (u[0] === void 0) return !1;
|
|
294
|
-
const g = c.state.doc.lineAt(c.state.selection.main.head).number, x = u.findIndex((A) => A.start > g), h = x < 0 ? 0 : x,
|
|
295
|
-
c.dispatch({ selection: fe.cursor(
|
|
294
|
+
const g = c.state.doc.lineAt(c.state.selection.main.head).number, x = u.findIndex((A) => A.start > g), h = x < 0 ? 0 : x, k = c.state.doc.line(u[h].start).from;
|
|
295
|
+
c.dispatch({ selection: fe.cursor(k), effects: $.scrollIntoView(k, { y: "center" }) });
|
|
296
296
|
const I = c.contentDOM.querySelector(`[${Fe}="${String(h)}"] button`);
|
|
297
297
|
return I instanceof HTMLElement ? I.focus({ preventScroll: !0 }) : c.focus(), !0;
|
|
298
298
|
},
|
|
299
299
|
save: () => c.state.toJSON(ze),
|
|
300
300
|
destroy: () => c.destroy()
|
|
301
301
|
};
|
|
302
|
-
},
|
|
303
|
-
const
|
|
302
|
+
}, Te = (e, t, n, r) => {
|
|
303
|
+
const l = r.scrollerOf(e.scrollDOM), o = (n === null ? ne(l, e.contentDOM) : n) - me(l);
|
|
304
304
|
return $.scrollIntoView(t, { y: "start", yMargin: o });
|
|
305
305
|
}, yn = (e, t, n, r) => {
|
|
306
|
-
const
|
|
307
|
-
let
|
|
306
|
+
const l = kn(e, t), o = r.scrollerOf(e.scrollDOM), s = me(o), i = ne(o, e.contentDOM), d = s + o.clientHeight;
|
|
307
|
+
let f = 0;
|
|
308
308
|
switch (n.y) {
|
|
309
309
|
case "start":
|
|
310
|
-
|
|
310
|
+
f = l.top - (s + n.yMargin);
|
|
311
311
|
break;
|
|
312
312
|
case "center":
|
|
313
|
-
|
|
313
|
+
f = (l.top + l.bottom) / 2 - (i + d) / 2;
|
|
314
314
|
break;
|
|
315
315
|
case "end":
|
|
316
|
-
|
|
316
|
+
f = l.bottom - (d - n.yMargin);
|
|
317
317
|
break;
|
|
318
318
|
default:
|
|
319
|
-
|
|
319
|
+
l.top < i + n.yMargin ? f = l.top - (i + n.yMargin) : l.bottom > d - n.yMargin && (f = Math.min(l.bottom - (d - n.yMargin), l.top - (i + n.yMargin)));
|
|
320
320
|
}
|
|
321
|
-
if (
|
|
322
|
-
const p =
|
|
321
|
+
if (f !== 0 && (o.scrollTop += f), n.y === "start") return;
|
|
322
|
+
const p = Tn(e, t);
|
|
323
323
|
p !== null && r.reveal(p);
|
|
324
|
-
},
|
|
324
|
+
}, kn = (e, t) => {
|
|
325
325
|
const { node: n, offset: r } = e.domAtPos(t);
|
|
326
326
|
if (n.nodeType === Node.TEXT_NODE) {
|
|
327
|
-
const
|
|
328
|
-
if (
|
|
329
|
-
|
|
330
|
-
const [i] =
|
|
327
|
+
const s = n.ownerDocument?.createRange();
|
|
328
|
+
if (s !== void 0) {
|
|
329
|
+
s.setStart(n, r), s.setEnd(n, r);
|
|
330
|
+
const [i] = s.getClientRects();
|
|
331
331
|
if (i !== void 0 && i.height > 0) return { top: i.top, bottom: i.bottom };
|
|
332
332
|
}
|
|
333
333
|
}
|
|
334
|
-
const
|
|
335
|
-
return { top: o, bottom: o +
|
|
336
|
-
},
|
|
334
|
+
const l = e.lineBlockAt(t), o = e.documentTop + l.top;
|
|
335
|
+
return { top: o, bottom: o + l.height };
|
|
336
|
+
}, Tn = (e, t) => {
|
|
337
337
|
const { node: n } = e.domAtPos(t);
|
|
338
338
|
for (let r = n instanceof Element ? n : n.parentElement; r !== null; r = r.parentElement)
|
|
339
339
|
if (r.parentElement === e.contentDOM) return r;
|
|
@@ -345,42 +345,42 @@ const ee = (e) => Ze(e.iterLines()), Se = (e, t) => {
|
|
|
345
345
|
} catch {
|
|
346
346
|
return null;
|
|
347
347
|
}
|
|
348
|
-
}, In = 610, Ln = 987, Ae = Object.freeze({ kind: "unavailable" }),
|
|
348
|
+
}, In = 610, Ln = 987, Ae = Object.freeze({ kind: "unavailable" }), Cn = "true", On = "false", Mn = (e) => e === Cn ? !0 : e === On ? !1 : null, qn = (e) => {
|
|
349
349
|
const t = new DOMParser().parseFromString(e, "text/html"), n = [];
|
|
350
350
|
for (const r of t.querySelectorAll("img[data-asset-src], a[data-doc-path]")) {
|
|
351
|
-
const
|
|
352
|
-
o !== null && n.push({ target: { kind:
|
|
351
|
+
const l = r.localName === "img", o = r.getAttribute(l ? "data-asset-src" : "data-doc-path");
|
|
352
|
+
o !== null && n.push({ target: { kind: l ? "asset" : "doc", path: o }, exists: Mn(r.getAttribute(l ? "data-asset-exists" : "data-doc-exists")) });
|
|
353
353
|
}
|
|
354
354
|
return n;
|
|
355
|
-
}, Rn = ({ path: e, instant: t, preview: n, initial: r, onView:
|
|
356
|
-
const o = new AbortController(),
|
|
357
|
-
let i = r,
|
|
355
|
+
}, Rn = ({ path: e, instant: t, preview: n, initial: r, onView: l }) => {
|
|
356
|
+
const o = new AbortController(), s = { asset: /* @__PURE__ */ new Map(), doc: /* @__PURE__ */ new Map() };
|
|
357
|
+
let i = r, d = null, f = !1, p = !1, y = null, c = null, w = [], u, m = !1, g, x = null;
|
|
358
358
|
const h = (v) => {
|
|
359
|
-
v.parsed === i.parsed && v.source === i.source && v.failure === i.failure && v.busy === i.busy && v.tier === i.tier || (i = v,
|
|
360
|
-
},
|
|
361
|
-
|
|
359
|
+
v.parsed === i.parsed && v.source === i.source && v.failure === i.failure && v.busy === i.busy && v.tier === i.tier || (i = v, l(v));
|
|
360
|
+
}, k = (v, S) => {
|
|
361
|
+
f || (f = !0, console.error(`[markdown-explorer] ${v}`, ...S === void 0 ? [] : [S]));
|
|
362
362
|
}, I = (v) => {
|
|
363
363
|
if (t !== null)
|
|
364
|
-
for (const { target: S, exists:
|
|
364
|
+
for (const { target: S, exists: C } of t.marksOf(v)) s[S.kind].set(S.path, C);
|
|
365
365
|
}, A = () => {
|
|
366
366
|
clearTimeout(g), g = void 0, x?.abort(), x = null;
|
|
367
367
|
}, _ = () => {
|
|
368
368
|
c = null, w = [], clearTimeout(u), u = void 0;
|
|
369
|
-
},
|
|
369
|
+
}, O = (v, S) => {
|
|
370
370
|
h({ ...i, failure: v, busy: !1, tier: S });
|
|
371
371
|
}, F = () => {
|
|
372
372
|
clearTimeout(u), u = w.length === 0 ? void 0 : setTimeout(H, Ln);
|
|
373
373
|
}, P = () => {
|
|
374
374
|
if (t === null || c === null) return;
|
|
375
|
-
const v = c, S = [],
|
|
375
|
+
const v = c, S = [], C = { asset: /* @__PURE__ */ new Set(), doc: /* @__PURE__ */ new Set() };
|
|
376
376
|
let G;
|
|
377
377
|
try {
|
|
378
378
|
G = t.sanitize(v.html, (E) => {
|
|
379
|
-
const
|
|
380
|
-
return
|
|
379
|
+
const M = s[E.kind].get(E.path);
|
|
380
|
+
return M === void 0 && !C[E.kind].has(E.path) && (C[E.kind].add(E.path), S.push(E)), M ?? void 0;
|
|
381
381
|
});
|
|
382
382
|
} catch (E) {
|
|
383
|
-
_(), E instanceof Yt ?
|
|
383
|
+
_(), E instanceof Yt ? O(re("too-large"), "instant") : (k("the draft sanitizer failed", E), O(re("failed"), "instant"));
|
|
384
384
|
return;
|
|
385
385
|
}
|
|
386
386
|
w = S;
|
|
@@ -393,7 +393,7 @@ const ee = (e) => Ze(e.iterLines()), Se = (e, t) => {
|
|
|
393
393
|
n(e, c.draft.text, o.signal).then((S) => {
|
|
394
394
|
if (m = !1, !(o.signal.aborted || !("kind" in S))) {
|
|
395
395
|
S.kind === "preview" && I(S.htmlContent);
|
|
396
|
-
for (const
|
|
396
|
+
for (const C of v) s[C.kind].has(C.path) || s[C.kind].set(C.path, null);
|
|
397
397
|
P();
|
|
398
398
|
}
|
|
399
399
|
});
|
|
@@ -401,36 +401,36 @@ const ee = (e) => Ze(e.iterLines()), Se = (e, t) => {
|
|
|
401
401
|
A(), _(), h({ ...i, busy: !0, tier: "server" });
|
|
402
402
|
const S = new AbortController();
|
|
403
403
|
x = S, g = setTimeout(() => {
|
|
404
|
-
g = void 0, n(e, v.text, S.signal).then((
|
|
405
|
-
if (!(S.signal.aborted || !("kind" in
|
|
406
|
-
if (x = null,
|
|
407
|
-
C
|
|
404
|
+
g = void 0, n(e, v.text, S.signal).then((C) => {
|
|
405
|
+
if (!(S.signal.aborted || !("kind" in C))) {
|
|
406
|
+
if (x = null, C.kind === "failure") {
|
|
407
|
+
O(C.failure, "server");
|
|
408
408
|
return;
|
|
409
409
|
}
|
|
410
|
-
I(
|
|
410
|
+
I(C.htmlContent), h({ parsed: { htmlContent: C.htmlContent, headings: C.headings }, source: v, failure: null, busy: !1, tier: "server" });
|
|
411
411
|
}
|
|
412
412
|
});
|
|
413
413
|
}, In);
|
|
414
414
|
}, a = async (v, S) => {
|
|
415
|
-
let
|
|
415
|
+
let C;
|
|
416
416
|
try {
|
|
417
|
-
|
|
417
|
+
C = await v.convert({ path: e, text: S }, o.signal);
|
|
418
418
|
} catch (b) {
|
|
419
|
-
return o.signal.aborted ||
|
|
419
|
+
return o.signal.aborted || k("the draft converter rejected a conversion, which its contract allows only once the signal aborted", b), Ae;
|
|
420
420
|
}
|
|
421
|
-
const G =
|
|
422
|
-
return G === null ?
|
|
423
|
-
},
|
|
421
|
+
const G = Xt(C);
|
|
422
|
+
return G === null ? C : (k(`the draft converter answered outside its contract: ${G}`), Ae);
|
|
423
|
+
}, T = (v, S) => {
|
|
424
424
|
switch (S.kind) {
|
|
425
425
|
case "preview":
|
|
426
|
-
if (A(), S.headings.length >
|
|
427
|
-
_(),
|
|
426
|
+
if (A(), S.headings.length > jt) {
|
|
427
|
+
_(), O(re("too-large"), "instant");
|
|
428
428
|
return;
|
|
429
429
|
}
|
|
430
|
-
c = { draft: v, html: S.htmlContent, headings: S.headings.map(({ text:
|
|
430
|
+
c = { draft: v, html: S.htmlContent, headings: S.headings.map(({ text: C, depth: G, id: b }) => ({ text: C, depth: G, id: b })) }, P();
|
|
431
431
|
return;
|
|
432
432
|
case "failure":
|
|
433
|
-
A(), _(),
|
|
433
|
+
A(), _(), O(re(S.failure.reason, S.failure.code), "instant");
|
|
434
434
|
return;
|
|
435
435
|
case "unavailable":
|
|
436
436
|
V(v);
|
|
@@ -442,9 +442,9 @@ const ee = (e) => Ze(e.iterLines()), Se = (e, t) => {
|
|
|
442
442
|
for (; y !== null && !o.signal.aborted; ) {
|
|
443
443
|
const S = y;
|
|
444
444
|
y = null;
|
|
445
|
-
const
|
|
445
|
+
const C = await a(v, S.text);
|
|
446
446
|
if (o.signal.aborted) return;
|
|
447
|
-
|
|
447
|
+
T(S, C);
|
|
448
448
|
}
|
|
449
449
|
} finally {
|
|
450
450
|
p = !1;
|
|
@@ -452,8 +452,8 @@ const ee = (e) => Ze(e.iterLines()), Se = (e, t) => {
|
|
|
452
452
|
};
|
|
453
453
|
return t !== null && t.seed !== null && I(t.seed), {
|
|
454
454
|
update: (v) => {
|
|
455
|
-
if (!(o.signal.aborted || v.text ===
|
|
456
|
-
if (
|
|
455
|
+
if (!(o.signal.aborted || v.text === d?.text)) {
|
|
456
|
+
if (d = v, clearTimeout(u), u = void 0, t === null) {
|
|
457
457
|
V(v);
|
|
458
458
|
return;
|
|
459
459
|
}
|
|
@@ -465,10 +465,10 @@ const ee = (e) => Ze(e.iterLines()), Se = (e, t) => {
|
|
|
465
465
|
}
|
|
466
466
|
};
|
|
467
467
|
}, _n = (e, t) => Jt(Zt(window), e, t, Qt), Nn = (e, t) => e.flatMap((n, r) => {
|
|
468
|
-
const
|
|
469
|
-
return
|
|
470
|
-
{ editor:
|
|
471
|
-
{ editor:
|
|
468
|
+
const l = t[r];
|
|
469
|
+
return l === void 0 ? [] : [
|
|
470
|
+
{ editor: l.top, preview: n.top },
|
|
471
|
+
{ editor: l.bottom, preview: n.bottom }
|
|
472
472
|
];
|
|
473
473
|
}), K = (e, t) => {
|
|
474
474
|
const n = e[t];
|
|
@@ -477,148 +477,148 @@ const ee = (e) => Ze(e.iterLines()), Se = (e, t) => {
|
|
|
477
477
|
}, Pn = (e) => {
|
|
478
478
|
const t = [];
|
|
479
479
|
for (const r of e) {
|
|
480
|
-
let
|
|
481
|
-
for (;
|
|
482
|
-
const
|
|
483
|
-
K(t,
|
|
480
|
+
let l = 0, o = t.length;
|
|
481
|
+
for (; l < o; ) {
|
|
482
|
+
const s = l + o >> 1;
|
|
483
|
+
K(t, s).pair.preview <= r.preview ? l = s + 1 : o = s;
|
|
484
484
|
}
|
|
485
|
-
t[
|
|
485
|
+
t[l] = { pair: r, before: l === 0 ? void 0 : K(t, l - 1) };
|
|
486
486
|
}
|
|
487
487
|
const n = [];
|
|
488
488
|
for (let r = t.at(-1); r !== void 0; r = r.before) n.push(r.pair);
|
|
489
489
|
return n.reverse();
|
|
490
490
|
}, Dn = (e, t) => {
|
|
491
|
-
const n = Math.max(t.editorMax, 0), r = Math.max(t.previewMax, 0),
|
|
491
|
+
const n = Math.max(t.editorMax, 0), r = Math.max(t.previewMax, 0), l = n - t.editorViewport, o = r - t.previewViewport, s = e.filter((f) => f.editor > 0 && f.editor < l && f.preview > 0 && f.preview < o).sort((f, p) => f.editor - p.editor || f.preview - p.preview);
|
|
492
492
|
let i = { editor: 0, preview: 0 };
|
|
493
|
-
const
|
|
494
|
-
for (const
|
|
495
|
-
|
|
496
|
-
return
|
|
497
|
-
toPreview: (
|
|
498
|
-
toEditor: (
|
|
493
|
+
const d = [i];
|
|
494
|
+
for (const f of Pn(s))
|
|
495
|
+
f.editor > i.editor && f.preview > i.preview && (d.push(f), i = f);
|
|
496
|
+
return d.push({ editor: n, preview: r }), {
|
|
497
|
+
toPreview: (f) => Ie(d, "editor", "preview", f),
|
|
498
|
+
toEditor: (f) => Ie(d, "preview", "editor", f)
|
|
499
499
|
};
|
|
500
500
|
}, Ie = (e, t, n, r) => {
|
|
501
|
-
const
|
|
502
|
-
if (Number.isNaN(r) || r <=
|
|
501
|
+
const l = K(e, 0), o = K(e, e.length - 1);
|
|
502
|
+
if (Number.isNaN(r) || r <= l[t]) return l[n];
|
|
503
503
|
if (r >= o[t]) return o[n];
|
|
504
|
-
let
|
|
505
|
-
for (; i -
|
|
506
|
-
const p =
|
|
507
|
-
K(e, p)[t] <= r ?
|
|
504
|
+
let s = 0, i = e.length - 1;
|
|
505
|
+
for (; i - s > 1; ) {
|
|
506
|
+
const p = s + i >> 1;
|
|
507
|
+
K(e, p)[t] <= r ? s = p : i = p;
|
|
508
508
|
}
|
|
509
|
-
const
|
|
510
|
-
return
|
|
511
|
-
}, Bn = 610, Le = 89,
|
|
512
|
-
let i = "editor",
|
|
509
|
+
const d = K(e, s), f = K(e, i);
|
|
510
|
+
return d[n] + (f[n] - d[n]) * (r - d[t]) / (f[t] - d[t]);
|
|
511
|
+
}, Bn = 610, Le = 89, Ce = 0.5, Vn = ({ editor: e, preview: t, previewBlocks: n, editorSpans: r, requestFrame: l, cancelFrame: o, now: s }) => {
|
|
512
|
+
let i = "editor", d = 0, f = null, p = null, y = !1, c = null, w = null;
|
|
513
513
|
const u = { editor: 0, preview: 0 }, m = { editor: null, preview: null };
|
|
514
514
|
let g = null, x = () => {
|
|
515
515
|
};
|
|
516
516
|
const h = (a) => {
|
|
517
|
-
|
|
518
|
-
},
|
|
519
|
-
a !== i &&
|
|
520
|
-
}, I = (a,
|
|
517
|
+
f !== null && a !== f || (i = a, d = s() + Bn);
|
|
518
|
+
}, k = (a, T) => {
|
|
519
|
+
a !== i && f === null && s() >= d && !I(a, T) && (i = a), P();
|
|
520
|
+
}, I = (a, T) => {
|
|
521
521
|
const L = m[a];
|
|
522
|
-
return
|
|
523
|
-
}, A = e.onScroll(() =>
|
|
522
|
+
return s() < u[a] || L !== null && Math.abs(T.position() - L) < Ce;
|
|
523
|
+
}, A = e.onScroll(() => k("editor", e)), _ = e.onIntent(() => h("editor")), O = () => {
|
|
524
524
|
const a = t();
|
|
525
525
|
return a !== g && (x(), g = a, x = a === null ? () => {
|
|
526
526
|
} : F(a)), a;
|
|
527
527
|
}, F = (a) => {
|
|
528
|
-
const
|
|
528
|
+
const T = a.onScroll(() => k("preview", a)), L = a.onIntent(() => h("preview"));
|
|
529
529
|
return () => {
|
|
530
|
-
|
|
530
|
+
T(), L();
|
|
531
531
|
};
|
|
532
532
|
}, P = () => {
|
|
533
|
-
!y && p === null && (p =
|
|
533
|
+
!y && p === null && (p = l(H));
|
|
534
534
|
}, H = () => {
|
|
535
535
|
p = null;
|
|
536
|
-
const a =
|
|
536
|
+
const a = O();
|
|
537
537
|
a !== null && (c ??= n(), w ??= Dn(Nn(c, r(c)), { editorMax: e.max(), previewMax: a.max(), editorViewport: e.viewport(), previewViewport: a.viewport() }), i === "editor" ? V(a, "preview", w.toPreview(e.position())) : V(e, "editor", w.toEditor(a.position())));
|
|
538
|
-
}, V = (a,
|
|
539
|
-
if (Math.abs(a.position() - L) <
|
|
540
|
-
m[
|
|
538
|
+
}, V = (a, T, L) => {
|
|
539
|
+
if (Math.abs(a.position() - L) < Ce) {
|
|
540
|
+
m[T] = a.position();
|
|
541
541
|
return;
|
|
542
542
|
}
|
|
543
|
-
u[
|
|
543
|
+
u[T] = s() + Le, m[T] = a.scrollTo(L);
|
|
544
544
|
};
|
|
545
545
|
return P(), {
|
|
546
546
|
editorChanged: (a) => {
|
|
547
547
|
w = null, a && h("editor"), P();
|
|
548
548
|
},
|
|
549
549
|
previewChanged: () => {
|
|
550
|
-
c = null, w = null, u.preview =
|
|
550
|
+
c = null, w = null, u.preview = s() + Le, P();
|
|
551
551
|
},
|
|
552
552
|
showAlone: (a) => {
|
|
553
|
-
|
|
553
|
+
f = a, !(a === null || a === i) && (i = a, d = 0, P());
|
|
554
554
|
},
|
|
555
555
|
dispose: () => {
|
|
556
556
|
y = !0, p !== null && o(p), p = null, A(), _(), x();
|
|
557
557
|
}
|
|
558
558
|
};
|
|
559
|
-
},
|
|
559
|
+
}, Oe = Object.freeze(["wheel", "pointerdown", "keydown", "focusin"]), Ge = (e) => ({
|
|
560
560
|
position: () => e.scrollTop,
|
|
561
561
|
max: () => Math.max(e.scrollHeight - e.clientHeight, 0),
|
|
562
562
|
viewport: () => e.clientHeight,
|
|
563
563
|
scrollTo: (t) => (e.scrollTo({ top: t, behavior: "instant" }), e.scrollTop),
|
|
564
564
|
onScroll: (t) => (e.addEventListener("scroll", t, { passive: !0 }), () => e.removeEventListener("scroll", t)),
|
|
565
565
|
onIntent: (t) => {
|
|
566
|
-
for (const n of
|
|
566
|
+
for (const n of Oe) e.addEventListener(n, t, { capture: !0, passive: !0 });
|
|
567
567
|
return () => {
|
|
568
|
-
for (const n of
|
|
568
|
+
for (const n of Oe) e.removeEventListener(n, t, { capture: !0 });
|
|
569
569
|
};
|
|
570
570
|
}
|
|
571
571
|
}), Z = "[data-aqmd-scroll-container]", Hn = "[data-aqmd-content]", zn = `[${He}]`, Fn = Object.freeze(["p1", "p2", "p3", "p4", "p5", "p6", "p7", "p8"]), We = (e, t) => {
|
|
572
|
-
const n =
|
|
572
|
+
const n = nt(e.peek(t));
|
|
573
573
|
return n !== null && n.document.kind === "markdown" ? { htmlContent: n.document.htmlContent, headings: n.document.headings } : null;
|
|
574
|
-
}, Un = (e, t, n, r,
|
|
574
|
+
}, Un = (e, t, n, r, l) => {
|
|
575
575
|
if (n === void 0) return null;
|
|
576
576
|
let o;
|
|
577
577
|
try {
|
|
578
578
|
o = _n(e, t);
|
|
579
|
-
} catch (
|
|
580
|
-
return console.error("[markdown-explorer] the draft sanitizer cannot run in this browser, so the server renders the preview",
|
|
579
|
+
} catch (s) {
|
|
580
|
+
return console.error("[markdown-explorer] the draft sanitizer cannot run in this browser, so the server renders the preview", s), null;
|
|
581
581
|
}
|
|
582
|
-
return { converter: n, sanitize: o, marksOf: qn, seed: We(r,
|
|
582
|
+
return { converter: n, sanitize: o, marksOf: qn, seed: We(r, l)?.htmlContent ?? null };
|
|
583
583
|
}, Gn = (e) => {
|
|
584
584
|
const t = [];
|
|
585
585
|
let n = null;
|
|
586
586
|
for (const r of e.querySelectorAll(zn)) {
|
|
587
|
-
const
|
|
588
|
-
if (
|
|
589
|
-
n ??= e.scrollTop -
|
|
590
|
-
const { top: o, bottom:
|
|
591
|
-
t.push({ first:
|
|
587
|
+
const l = Kt(r.getAttribute(He));
|
|
588
|
+
if (l === null || r.getClientRects().length === 0) continue;
|
|
589
|
+
n ??= e.scrollTop - ne(e, r);
|
|
590
|
+
const { top: o, bottom: s } = r.getBoundingClientRect();
|
|
591
|
+
t.push({ first: l.first, last: l.last, top: n + o, bottom: n + s });
|
|
592
592
|
}
|
|
593
593
|
return t;
|
|
594
|
-
}, Wn = ({ path: e, readDraft: t, viewer: n, tables: r, concealed:
|
|
595
|
-
const { config:
|
|
594
|
+
}, Wn = ({ path: e, readDraft: t, viewer: n, tables: r, concealed: l, onEditAt: o, onLayout: s, handleRef: i }) => {
|
|
595
|
+
const { config: d, data: f, documents: p, draftConverter: y, labels: c } = se(), [w, u] = te(() => ({ parsed: We(p, e), source: null, failure: null, busy: !0, tier: y === void 0 ? "server" : "instant" })), m = D(null), g = D(null), x = D(w);
|
|
596
596
|
B(() => {
|
|
597
597
|
x.current = w;
|
|
598
598
|
});
|
|
599
599
|
const h = ve(() => t());
|
|
600
600
|
Pe(() => {
|
|
601
|
-
const a = Un(
|
|
602
|
-
return g.current = L, L.update(
|
|
601
|
+
const a = Un(d.iframeHosts, d.dataPath, y, p, e), T = h(), L = Rn({ path: e, instant: a, preview: f.preview, initial: x.current, onView: (v) => Ye(() => u(v)) });
|
|
602
|
+
return g.current = L, L.update(T), () => {
|
|
603
603
|
L.dispose(), g.current = null;
|
|
604
604
|
};
|
|
605
|
-
}, [
|
|
606
|
-
const
|
|
605
|
+
}, [d, f, p, y, e]);
|
|
606
|
+
const k = ve(() => s());
|
|
607
607
|
B(() => {
|
|
608
|
-
w.parsed !== null &&
|
|
608
|
+
w.parsed !== null && k();
|
|
609
609
|
}, [w.parsed]);
|
|
610
610
|
const I = w.parsed !== null;
|
|
611
611
|
B(() => {
|
|
612
612
|
const a = I ? m.current?.querySelector(Z) : null;
|
|
613
613
|
if (!(a instanceof HTMLElement)) return;
|
|
614
614
|
a.tabIndex = 0;
|
|
615
|
-
const
|
|
616
|
-
|
|
615
|
+
const T = new ResizeObserver(() => k());
|
|
616
|
+
T.observe(a);
|
|
617
617
|
const L = a.querySelector(Hn);
|
|
618
|
-
return L !== null &&
|
|
618
|
+
return L !== null && T.observe(L), () => T.disconnect();
|
|
619
619
|
}, [I]);
|
|
620
620
|
const A = D(null);
|
|
621
|
-
|
|
621
|
+
je(
|
|
622
622
|
i,
|
|
623
623
|
() => ({
|
|
624
624
|
draft: (a) => {
|
|
@@ -637,253 +637,250 @@ const ee = (e) => Ze(e.iterLines()), Se = (e, t) => {
|
|
|
637
637
|
a instanceof HTMLElement && a.focus({ preventScroll: !0 });
|
|
638
638
|
},
|
|
639
639
|
anchor: (a) => {
|
|
640
|
-
const
|
|
641
|
-
return
|
|
640
|
+
const T = m.current, L = T?.querySelector(Z);
|
|
641
|
+
return T === null || !(L instanceof HTMLElement) ? null : tt(T, a(L));
|
|
642
642
|
},
|
|
643
|
-
place: ({ line: a, clientTop:
|
|
644
|
-
const v = m.current, S = v === null ? null :
|
|
645
|
-
S !== null && (L(S).scrollTop +=
|
|
643
|
+
place: ({ line: a, clientTop: T }, L) => {
|
|
644
|
+
const v = m.current, S = v === null ? null : Ze(v, a);
|
|
645
|
+
S !== null && (L(S).scrollTop += et(S, a) - T);
|
|
646
646
|
}
|
|
647
647
|
}),
|
|
648
648
|
[]
|
|
649
649
|
);
|
|
650
650
|
const _ = (a) => {
|
|
651
|
-
const
|
|
652
|
-
if (o === void 0 ||
|
|
653
|
-
const v =
|
|
651
|
+
const T = m.current, { target: L } = a;
|
|
652
|
+
if (o === void 0 || T === null || !(L instanceof Element) || !rt(L)) return;
|
|
653
|
+
const v = ot(L, T, T.ownerDocument.getSelection());
|
|
654
654
|
v !== null && o(v);
|
|
655
|
-
},
|
|
656
|
-
() =>
|
|
657
|
-
write: (a) => r.write(
|
|
658
|
-
read: (a) => r.read(
|
|
655
|
+
}, O = w.source === null ? null : w.source.revision, F = J(
|
|
656
|
+
() => O === null ? void 0 : {
|
|
657
|
+
write: (a) => r.write(O, a),
|
|
658
|
+
read: (a) => r.read(O, a),
|
|
659
659
|
undo: r.undo,
|
|
660
660
|
redo: r.redo,
|
|
661
661
|
subscribe: r.subscribe
|
|
662
662
|
},
|
|
663
|
-
[r,
|
|
663
|
+
[r, O]
|
|
664
664
|
), P = J(() => ({ ...n.labels, spreadsheetReadOnly: c.previewTablePending }), [n.labels, c.previewTablePending]), H = J(
|
|
665
665
|
() => ({ ...n, labels: F === void 0 ? P : n.labels, showToc: !1, showStyle: !1, showAlign: !1, renderScrollBar: void 0, spreadsheetEditor: F }),
|
|
666
666
|
[n, P, F]
|
|
667
667
|
), V = J(
|
|
668
|
-
() => w.parsed === null ? null : /* @__PURE__ */
|
|
668
|
+
() => w.parsed === null ? null : /* @__PURE__ */ R("div", { className: "aqmx-document-viewer", children: /* @__PURE__ */ R($t, { ...H, parseResult: w.parsed, content: null }) }),
|
|
669
669
|
[H, w.parsed]
|
|
670
670
|
);
|
|
671
|
-
return /* @__PURE__ */
|
|
671
|
+
return /* @__PURE__ */ le(
|
|
672
672
|
"section",
|
|
673
673
|
{
|
|
674
674
|
ref: m,
|
|
675
675
|
className: "aqmx-edit-preview",
|
|
676
676
|
"aria-label": c.previewRegion,
|
|
677
677
|
"aria-busy": w.busy,
|
|
678
|
-
inert:
|
|
679
|
-
hidden:
|
|
678
|
+
inert: l !== null,
|
|
679
|
+
hidden: l === "removed",
|
|
680
680
|
"data-aqmx-preview-tier": w.tier,
|
|
681
681
|
"data-testid": "markdown-explorer-edit-preview",
|
|
682
682
|
onDoubleClick: o === void 0 ? void 0 : _,
|
|
683
683
|
children: [
|
|
684
|
-
w.failure === null ? null : /* @__PURE__ */
|
|
685
|
-
V ?? (w.failure === null ? /* @__PURE__ */
|
|
686
|
-
w.busy ? /* @__PURE__ */
|
|
684
|
+
w.failure === null ? null : /* @__PURE__ */ R("p", { className: "aqmx-callout aqmx-document-notice", "data-aqmx-tone": "warning", "data-testid": "markdown-explorer-edit-preview-failure", children: c.previewFailed(De(c, w.failure.reason)) }),
|
|
685
|
+
V ?? (w.failure === null ? /* @__PURE__ */ R("div", { className: "aqmx-skeleton", "aria-hidden": "true", "data-testid": "markdown-explorer-edit-preview-skeleton", children: Fn.map((a) => /* @__PURE__ */ R("span", {}, a)) }) : null),
|
|
686
|
+
w.busy ? /* @__PURE__ */ R("p", { className: "aqmx-sr-only", children: c.previewUpdating }) : null
|
|
687
687
|
]
|
|
688
688
|
}
|
|
689
689
|
);
|
|
690
|
-
}, Me = "data-aqmx-edit-split", de = "--aqmx-edit-share", qe = "--aqmx-edit-gutter", $n = "data-aqmx-edit-split-probe", Kn = "aqmx-edit-split",
|
|
690
|
+
}, Me = "data-aqmx-edit-split", de = "--aqmx-edit-share", qe = "--aqmx-edit-gutter", $n = "data-aqmx-edit-split-probe", Kn = "aqmx-edit-split", Xn = "aqmx-edit-editor", jn = "aqmx-edit-preview", Re = { value: ln, unit: "percentage" }, _e = { value: on, unit: "percentage" }, Ne = (e) => {
|
|
691
691
|
if (e.length !== 2) return null;
|
|
692
692
|
const [t = 0, n = 0] = e, r = t + n;
|
|
693
693
|
return r > 0 ? t / r * 100 : null;
|
|
694
|
-
},
|
|
694
|
+
}, ie = (e) => {
|
|
695
695
|
const t = e.current?.parentElement;
|
|
696
696
|
if (t == null) throw new Error("[markdown-explorer] the edit split is not mounted in its surface");
|
|
697
697
|
return t;
|
|
698
698
|
}, Yn = (e, t, n) => {
|
|
699
|
-
const [r,
|
|
699
|
+
const [r, l] = te(null);
|
|
700
700
|
return B(() => {
|
|
701
|
-
const o = e.current,
|
|
702
|
-
if (o === null ||
|
|
703
|
-
const i = { frame: o.getBoundingClientRect().width, measure:
|
|
704
|
-
i.frame > 0 && i.measure > 0 &&
|
|
701
|
+
const o = e.current, s = t.current;
|
|
702
|
+
if (o === null || s === null) throw new Error("[markdown-explorer] the edit split is not mounted");
|
|
703
|
+
const i = { frame: o.getBoundingClientRect().width, measure: s.getBoundingClientRect().width }, d = () => {
|
|
704
|
+
i.frame > 0 && i.measure > 0 && l(sn(i.frame, i.measure, n));
|
|
705
705
|
};
|
|
706
|
-
|
|
707
|
-
const
|
|
706
|
+
d();
|
|
707
|
+
const f = new ResizeObserver((p) => {
|
|
708
708
|
for (const y of p) {
|
|
709
709
|
const [c] = y.borderBoxSize;
|
|
710
|
-
c !== void 0 && (y.target === o && (i.frame = c.inlineSize), y.target ===
|
|
710
|
+
c !== void 0 && (y.target === o && (i.frame = c.inlineSize), y.target === s && (i.measure = c.inlineSize));
|
|
711
711
|
}
|
|
712
|
-
|
|
712
|
+
d();
|
|
713
713
|
});
|
|
714
|
-
return
|
|
714
|
+
return f.observe(o), f.observe(s), () => f.disconnect();
|
|
715
715
|
}, [e, t, n]), r;
|
|
716
716
|
}, Jn = ({ editorId: e }) => {
|
|
717
|
-
const { edits: t, labels: n } =
|
|
717
|
+
const { edits: t, labels: n } = se(), r = D(null), l = D(null), o = cn() ? nn : rn, s = Yn(r, l, o), [i] = te(() => t.editorShare());
|
|
718
718
|
B(() => {
|
|
719
|
-
const p =
|
|
719
|
+
const p = ie(r);
|
|
720
720
|
return p.style.setProperty(qe, `${String(o)}px`), () => {
|
|
721
721
|
p.style.removeProperty(qe);
|
|
722
722
|
};
|
|
723
723
|
}, [o]), B(() => {
|
|
724
|
-
const p =
|
|
724
|
+
const p = ie(r);
|
|
725
725
|
return p.style.setProperty(de, `${String(i)}%`), () => {
|
|
726
726
|
p.style.removeProperty(de);
|
|
727
727
|
};
|
|
728
728
|
}, [i]), B(() => {
|
|
729
|
-
if (
|
|
730
|
-
const p =
|
|
731
|
-
return p.setAttribute(Me,
|
|
732
|
-
}, [
|
|
733
|
-
const
|
|
734
|
-
|
|
729
|
+
if (s === null) return;
|
|
730
|
+
const p = ie(r);
|
|
731
|
+
return p.setAttribute(Me, s), () => p.removeAttribute(Me);
|
|
732
|
+
}, [s]);
|
|
733
|
+
const d = an(
|
|
734
|
+
X(
|
|
735
735
|
(p) => {
|
|
736
736
|
const y = Ne(p);
|
|
737
737
|
y !== null && t.setEditorShare(y);
|
|
738
738
|
},
|
|
739
739
|
[t]
|
|
740
740
|
)
|
|
741
|
-
),
|
|
741
|
+
), f = X(
|
|
742
742
|
(p, y) => {
|
|
743
743
|
const c = Ne(p);
|
|
744
|
-
c !== null &&
|
|
744
|
+
c !== null && ie(r).style.setProperty(de, `${String(c)}%`), d.layoutChanged(p, y);
|
|
745
745
|
},
|
|
746
|
-
[
|
|
746
|
+
[d]
|
|
747
747
|
);
|
|
748
|
-
return /* @__PURE__ */
|
|
749
|
-
/* @__PURE__ */
|
|
750
|
-
|
|
751
|
-
/* @__PURE__ */
|
|
752
|
-
/* @__PURE__ */
|
|
748
|
+
return /* @__PURE__ */ le("div", { ref: r, className: "aqmx-edit-split", "data-testid": "markdown-explorer-edit-split", children: [
|
|
749
|
+
/* @__PURE__ */ R("span", { ref: l, className: "aqmx-edit-split-probe", "aria-hidden": "true", [$n]: "" }),
|
|
750
|
+
s === null ? null : /* @__PURE__ */ le(en, { id: Kn, direction: s === "beside" ? "horizontal" : "vertical", onLayout: f, className: "aqmx-edit-split-group", children: [
|
|
751
|
+
/* @__PURE__ */ R(xe, { id: Xn, defaultSize: { value: i, unit: "percentage" }, minSize: Re, maxSize: _e, contentOverflow: "hidden" }),
|
|
752
|
+
/* @__PURE__ */ R(
|
|
753
753
|
tn,
|
|
754
754
|
{
|
|
755
755
|
thickness: o,
|
|
756
|
-
indicator: { visible: !0, thickness:
|
|
756
|
+
indicator: { visible: !0, thickness: oe.gripThickness, length: oe.gripLength, barThickness: oe.barThickness, barLength: oe.barLength },
|
|
757
757
|
title: n.editViewSplitResize,
|
|
758
758
|
"aria-label": n.editViewSplitResize,
|
|
759
759
|
"aria-controls": e,
|
|
760
|
-
onDragging:
|
|
760
|
+
onDragging: d.draggingChanged,
|
|
761
761
|
className: "aqmx-split-handle aqmx-edit-split-handle"
|
|
762
762
|
}
|
|
763
763
|
),
|
|
764
|
-
/* @__PURE__ */
|
|
764
|
+
/* @__PURE__ */ R(xe, { id: jn, defaultSize: { value: 100 - i, unit: "percentage" }, minSize: Re, maxSize: _e, contentOverflow: "hidden" })
|
|
765
765
|
] })
|
|
766
766
|
] });
|
|
767
767
|
}, Qn = 512, Zn = () => {
|
|
768
768
|
const e = [];
|
|
769
769
|
let t = 0, n = null;
|
|
770
|
-
const r = (
|
|
771
|
-
if (n === null || !Number.isInteger(
|
|
772
|
-
if (
|
|
773
|
-
const o = e[
|
|
770
|
+
const r = (l) => {
|
|
771
|
+
if (n === null || !Number.isInteger(l) || l < t) return null;
|
|
772
|
+
if (l === t + e.length) return n;
|
|
773
|
+
const o = e[l - t];
|
|
774
774
|
return o === void 0 ? null : o.before;
|
|
775
775
|
};
|
|
776
776
|
return {
|
|
777
777
|
revision: () => t + e.length,
|
|
778
|
-
mount: (
|
|
779
|
-
if (n !== null && (n ===
|
|
780
|
-
n =
|
|
778
|
+
mount: (l) => {
|
|
779
|
+
if (n !== null && (n === l || n.eq(l))) {
|
|
780
|
+
n = l;
|
|
781
781
|
return;
|
|
782
782
|
}
|
|
783
783
|
const o = t + e.length;
|
|
784
|
-
e.length = 0, t = n === null ? o : o + 1, n =
|
|
784
|
+
e.length = 0, t = n === null ? o : o + 1, n = l;
|
|
785
785
|
},
|
|
786
|
-
record: (
|
|
786
|
+
record: (l, o) => {
|
|
787
787
|
if (n === null) throw new Error("[markdown-explorer] a change of the editor's text was recorded before an editor mounted");
|
|
788
|
-
e.push({ before: n, changes:
|
|
788
|
+
e.push({ before: n, changes: l }), n = o, e.length > Qn && (e.shift(), t += 1);
|
|
789
789
|
},
|
|
790
|
-
lineOf: (
|
|
791
|
-
const
|
|
792
|
-
if (
|
|
793
|
-
let i =
|
|
794
|
-
for (const
|
|
795
|
-
const
|
|
796
|
-
if (
|
|
797
|
-
i =
|
|
790
|
+
lineOf: (l, o) => {
|
|
791
|
+
const s = r(l);
|
|
792
|
+
if (s === null || n === null || !Number.isInteger(o) || o < 1 || o > s.lines) return null;
|
|
793
|
+
let i = s.line(o).from;
|
|
794
|
+
for (const d of e.slice(l - t)) {
|
|
795
|
+
const f = d.changes.mapPos(i, 1, Bt.TrackAfter);
|
|
796
|
+
if (f === null) return null;
|
|
797
|
+
i = f;
|
|
798
798
|
}
|
|
799
799
|
return n.lineAt(i).number;
|
|
800
800
|
}
|
|
801
801
|
};
|
|
802
|
-
}, er = 144, tr = "[data-aqmd-spreadsheet-fullscreen]", nr =
|
|
802
|
+
}, er = 144, tr = "[data-aqmd-spreadsheet-fullscreen]", nr = (e) => {
|
|
803
803
|
if (typeof e != "object" || e === null) return !1;
|
|
804
804
|
const { generation: t, topLine: n } = e;
|
|
805
805
|
return "state" in e && typeof t == "number" && typeof n == "number";
|
|
806
|
-
},
|
|
806
|
+
}, rr = (e) => {
|
|
807
807
|
e.stopPropagation();
|
|
808
808
|
}, kr = (e) => {
|
|
809
|
-
const { path: t, name: n, session: r } = e, { edits:
|
|
809
|
+
const { path: t, name: n, session: r } = e, { edits: l, labels: o, announcer: s } = se(), { phase: i } = r, d = X(() => l.retry(t), [l, t]);
|
|
810
810
|
switch (Pe(() => {
|
|
811
|
-
i.kind === "failed" &&
|
|
812
|
-
}, [i,
|
|
811
|
+
i.kind === "failed" && s.announce(o.documentFailed(n, De(o, i.failure.reason)));
|
|
812
|
+
}, [i, s, o, n]), i.kind) {
|
|
813
813
|
case "opening":
|
|
814
|
-
return /* @__PURE__ */
|
|
815
|
-
/* @__PURE__ */ M("div", { className: "aqmx-skeleton", "aria-hidden": "true", "data-testid": "markdown-explorer-edit-skeleton", children: nr.map((d) => /* @__PURE__ */ M("span", {}, d)) }),
|
|
816
|
-
/* @__PURE__ */ M("p", { className: "aqmx-sr-only", children: o.editLoading })
|
|
817
|
-
] });
|
|
814
|
+
return /* @__PURE__ */ R(st, { label: o.editLoading, testId: "markdown-explorer-edit-skeleton" });
|
|
818
815
|
case "grant":
|
|
819
|
-
return /* @__PURE__ */
|
|
816
|
+
return /* @__PURE__ */ R("div", { className: "aqmx-edit-message", children: /* @__PURE__ */ R(lt, { href: i.href, onRetry: d, testId: "markdown-explorer-edit-grant" }) });
|
|
820
817
|
case "failed":
|
|
821
|
-
return /* @__PURE__ */
|
|
818
|
+
return /* @__PURE__ */ R("div", { className: "aqmx-edit-message", children: /* @__PURE__ */ R(it, { failure: i.failure, alert: !1, onRetry: d, testId: "markdown-explorer-edit-failure" }) });
|
|
822
819
|
case "editing":
|
|
823
|
-
return /* @__PURE__ */
|
|
820
|
+
return /* @__PURE__ */ R(or, { ...e });
|
|
824
821
|
}
|
|
825
|
-
},
|
|
826
|
-
const { edits: i, labels:
|
|
822
|
+
}, or = ({ path: e, name: t, session: n, layout: r, viewer: l, region: o, paneScroll: s }) => {
|
|
823
|
+
const { edits: i, labels: d } = se(), f = D(null), p = Je(), y = D(null), [c] = te(() => /* @__PURE__ */ new Set()), [w] = te(Zn), u = D(null), m = D(null), g = r === "fill", x = ct(), h = at(n, x, g), k = h !== "editor" || n.previewPrepared, I = k && g, A = D({ layout: r, region: o, paneScroll: s });
|
|
827
824
|
B(() => {
|
|
828
|
-
A.current = { layout: r, region: o, paneScroll:
|
|
825
|
+
A.current = { layout: r, region: o, paneScroll: s };
|
|
829
826
|
});
|
|
830
827
|
const _ = D(n.generation);
|
|
831
828
|
B(() => {
|
|
832
829
|
_.current = n.generation;
|
|
833
830
|
});
|
|
834
|
-
const
|
|
831
|
+
const O = D({ view: h, previewMounted: k });
|
|
835
832
|
B(() => {
|
|
836
|
-
|
|
833
|
+
O.current = { view: h, previewMounted: k };
|
|
837
834
|
});
|
|
838
|
-
const F = D(null), P = D(null), H = D(!1), V = J(() => ({ editor:
|
|
839
|
-
const { region: E, paneScroll:
|
|
840
|
-
return z === null ? b :
|
|
835
|
+
const F = D(null), P = D(null), H = D(!1), V = J(() => ({ editor: d.editorLabel(t), useOurs: d.conflictUseOurs, useTheirs: d.conflictUseTheirs, keepBoth: d.conflictKeepBoth }), [d, t]), a = X((b) => {
|
|
836
|
+
const { region: E, paneScroll: M } = A.current, z = E();
|
|
837
|
+
return z === null ? b : M.scrollerOf(z, b);
|
|
841
838
|
}, []);
|
|
842
839
|
B(() => {
|
|
843
|
-
const b =
|
|
840
|
+
const b = f.current, E = i.draft(e);
|
|
844
841
|
if (b === null || E === null) return;
|
|
845
|
-
const
|
|
846
|
-
let W = null,
|
|
842
|
+
const M = i.editorState.get(e), z = nr(M) && M.generation === _.current ? M : null;
|
|
843
|
+
let W = null, j = null;
|
|
847
844
|
const ae = () => {
|
|
848
|
-
W !== null && clearTimeout(W), W = null,
|
|
845
|
+
W !== null && clearTimeout(W), W = null, j !== null && i.setDraft(e, j.text());
|
|
849
846
|
}, U = Sn({
|
|
850
847
|
parent: b,
|
|
851
848
|
scroll: {
|
|
852
|
-
scrollerOf: (
|
|
853
|
-
const { layout: Y, region: Ke, paneScroll:
|
|
854
|
-
return Y === "fill" || ge === null ?
|
|
849
|
+
scrollerOf: (q) => {
|
|
850
|
+
const { layout: Y, region: Ke, paneScroll: Xe } = A.current, ge = Ke();
|
|
851
|
+
return Y === "fill" || ge === null ? q : Xe.scrollerOf(ge, q);
|
|
855
852
|
},
|
|
856
|
-
reveal: (
|
|
853
|
+
reveal: (q) => A.current.paneScroll.reveal(q)
|
|
857
854
|
},
|
|
858
855
|
text: E,
|
|
859
856
|
saved: z === null ? void 0 : z.state,
|
|
860
857
|
labels: V,
|
|
861
858
|
revisions: w,
|
|
862
|
-
onGeometry: (
|
|
863
|
-
onChange: (
|
|
864
|
-
if (W ??= setTimeout(ae, er), !
|
|
859
|
+
onGeometry: (q) => m.current?.editorChanged(q),
|
|
860
|
+
onChange: (q) => {
|
|
861
|
+
if (W ??= setTimeout(ae, er), !q)
|
|
865
862
|
for (const Y of [...c]) Y();
|
|
866
|
-
|
|
863
|
+
O.current.previewMounted && j !== null && u.current?.draft({ text: j.text(), revision: w.revision() });
|
|
867
864
|
},
|
|
868
865
|
onSave: () => {
|
|
869
866
|
i.save(e);
|
|
870
867
|
}
|
|
871
868
|
});
|
|
872
|
-
|
|
869
|
+
j = U, y.current = U;
|
|
873
870
|
const pe = () => {
|
|
874
|
-
const
|
|
875
|
-
return { line:
|
|
871
|
+
const q = U.topLine();
|
|
872
|
+
return { line: q.line, clientTop: q.clientTop };
|
|
876
873
|
}, he = () => u.current?.anchor(a) ?? null, $e = i.bindEditor(e, {
|
|
877
874
|
flush: ae,
|
|
878
|
-
adopt: (
|
|
875
|
+
adopt: (q) => U.replaceText(q),
|
|
879
876
|
returnPoint: () => {
|
|
880
|
-
const
|
|
881
|
-
return
|
|
877
|
+
const q = O.current.view === "preview" && A.current.layout === "content" ? he() : null;
|
|
878
|
+
return q === null ? pe() : { line: q.lines.first, clientTop: q.clientTop };
|
|
882
879
|
},
|
|
883
|
-
nextConflict: () =>
|
|
884
|
-
beforeView: (
|
|
880
|
+
nextConflict: () => O.current.view !== "preview" ? U.nextConflict() : U.conflicts().length === 0 ? !1 : (H.current = !0, i.setView(e, "editor"), !0),
|
|
881
|
+
beforeView: (q) => {
|
|
885
882
|
if (A.current.layout === "fill") return;
|
|
886
|
-
if (
|
|
883
|
+
if (q === "preview") {
|
|
887
884
|
F.current = { to: "preview", point: pe() };
|
|
888
885
|
return;
|
|
889
886
|
}
|
|
@@ -892,17 +889,17 @@ const ee = (e) => Ze(e.iterLines()), Se = (e, t) => {
|
|
|
892
889
|
}
|
|
893
890
|
});
|
|
894
891
|
return z !== null && U.showLine(z.topLine), () => {
|
|
895
|
-
ae(), i.editorState.set(e, { state: U.save(), generation: _.current, topLine: U.topLine().line }), $e(), U.destroy(),
|
|
892
|
+
ae(), i.editorState.set(e, { state: U.save(), generation: _.current, topLine: U.topLine().line }), $e(), U.destroy(), j = null, y.current = null;
|
|
896
893
|
};
|
|
897
894
|
}, [i, e, V, a, c, w]);
|
|
898
|
-
const { request:
|
|
895
|
+
const { request: T } = n;
|
|
899
896
|
B(() => {
|
|
900
897
|
const b = y.current, E = i.draft(e);
|
|
901
|
-
b === null || E === null ||
|
|
902
|
-
}, [i, e,
|
|
898
|
+
b === null || E === null || T === null || (T.anchor !== null && b.reveal(we(E, T.anchor), T.anchor.clientTop), b.focus(), i.consumeRequest(e));
|
|
899
|
+
}, [i, e, T, V]), B(() => {
|
|
903
900
|
h !== "editor" && !n.previewPrepared && i.preparePreview(e);
|
|
904
901
|
}, [i, e, h, n.previewPrepared]), B(() => {
|
|
905
|
-
const b = F.current, E = P.current,
|
|
902
|
+
const b = F.current, E = P.current, M = H.current;
|
|
906
903
|
F.current = null, P.current = null, H.current = !1;
|
|
907
904
|
const z = y.current;
|
|
908
905
|
if (b?.to === "preview") u.current?.place(b.point, a);
|
|
@@ -910,7 +907,7 @@ const ee = (e) => Ze(e.iterLines()), Se = (e, t) => {
|
|
|
910
907
|
const W = i.draft(e);
|
|
911
908
|
W !== null && z.reveal(we(W, b.anchor), b.anchor.clientTop);
|
|
912
909
|
}
|
|
913
|
-
|
|
910
|
+
M ? z?.nextConflict() : E === "editor" ? z?.focus() : E === "preview" && u.current?.focus();
|
|
914
911
|
}, [i, e, h, a]);
|
|
915
912
|
const L = J(() => {
|
|
916
913
|
const b = () => {
|
|
@@ -919,15 +916,15 @@ const ee = (e) => Ze(e.iterLines()), Se = (e, t) => {
|
|
|
919
916
|
return E;
|
|
920
917
|
};
|
|
921
918
|
return {
|
|
922
|
-
write: (E, { fenceLine:
|
|
923
|
-
read: (E,
|
|
919
|
+
write: (E, { fenceLine: M, expected: z, text: W }) => b().replaceBody(M, z, W, E),
|
|
920
|
+
read: (E, M) => b().readBody(M, E),
|
|
924
921
|
undo: () => b().undo(),
|
|
925
922
|
redo: () => b().redo(),
|
|
926
923
|
subscribe: (E) => (c.add(E), () => {
|
|
927
924
|
c.delete(E);
|
|
928
925
|
})
|
|
929
926
|
};
|
|
930
|
-
}, [c]), v =
|
|
927
|
+
}, [c]), v = X(() => {
|
|
931
928
|
const b = y.current;
|
|
932
929
|
if (b === null) throw new Error("[markdown-explorer] the preview read the draft before the editor was mounted");
|
|
933
930
|
return { text: b.text(), revision: w.revision() };
|
|
@@ -939,20 +936,20 @@ const ee = (e) => Ze(e.iterLines()), Se = (e, t) => {
|
|
|
939
936
|
editor: Ge(b.scrollElement),
|
|
940
937
|
preview: () => u.current?.scrollPort() ?? null,
|
|
941
938
|
previewBlocks: () => u.current?.blocks() ?? [],
|
|
942
|
-
editorSpans: (
|
|
943
|
-
requestFrame: (
|
|
944
|
-
cancelFrame: (
|
|
939
|
+
editorSpans: (M) => b.lineSpans(M),
|
|
940
|
+
requestFrame: (M) => requestAnimationFrame(M),
|
|
941
|
+
cancelFrame: (M) => cancelAnimationFrame(M),
|
|
945
942
|
now: () => performance.now()
|
|
946
943
|
});
|
|
947
|
-
return E.showAlone(be(
|
|
944
|
+
return E.showAlone(be(O.current.view)), m.current = E, () => {
|
|
948
945
|
E.dispose(), m.current = null;
|
|
949
946
|
};
|
|
950
947
|
}, [I, i, e, V]), B(() => {
|
|
951
948
|
m.current?.showAlone(be(h));
|
|
952
949
|
}, [h]);
|
|
953
|
-
const S =
|
|
950
|
+
const S = X(() => m.current?.previewChanged(), []), C = X((b) => i.start(e, b), [i, e]);
|
|
954
951
|
return (
|
|
955
|
-
/* @__PURE__ */
|
|
952
|
+
/* @__PURE__ */ le("div", { className: "aqmx-edit", "data-aqmx-edit-layout": r, "data-aqmx-edit-view": h, "data-testid": "markdown-explorer-edit", onKeyDown: (b) => {
|
|
956
953
|
if (b.target instanceof Element && b.target.closest(tr) !== null) return;
|
|
957
954
|
if (b.key === "Escape") {
|
|
958
955
|
Ee(b);
|
|
@@ -962,10 +959,10 @@ const ee = (e) => Ze(e.iterLines()), Se = (e, t) => {
|
|
|
962
959
|
Ee(b);
|
|
963
960
|
const E = pt(h);
|
|
964
961
|
P.current = E, mt(i, e, E, g);
|
|
965
|
-
}, onDoubleClick:
|
|
966
|
-
/* @__PURE__ */
|
|
967
|
-
h === "split" ? /* @__PURE__ */
|
|
968
|
-
|
|
962
|
+
}, onDoubleClick: rr, children: [
|
|
963
|
+
/* @__PURE__ */ R("div", { ref: f, id: p, className: "aqmx-edit-editor", "data-testid": "markdown-explorer-editor", inert: h === "preview", hidden: h === "preview" && !g, ...ut }),
|
|
964
|
+
h === "split" ? /* @__PURE__ */ R(Jn, { editorId: p }) : null,
|
|
965
|
+
k ? /* @__PURE__ */ R(Wn, { path: e, readDraft: v, viewer: l, tables: L, concealed: h !== "editor" ? null : g ? "overlay" : "removed", onEditAt: h === "preview" ? C : void 0, onLayout: S, handleRef: u }) : null
|
|
969
966
|
] })
|
|
970
967
|
);
|
|
971
968
|
};
|