@aiquants/markdown-explorer 0.35.0 → 0.37.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 +165 -0
- package/README.md +105 -13
- package/dist/{EditSurface-D2j1kCEE.js → EditSurface-BQgwRUrR.js} +250 -245
- package/dist/EditSurface-Xvk5wZu7.cjs +6 -0
- package/dist/ExplorerSplit-C_3FChSt.cjs +2 -0
- package/dist/ExplorerSplit-C_kaEnyM.js +1619 -0
- package/dist/{MultiLayout-CxV5SI7f.cjs → MultiLayout-BZNj1GYo.cjs} +1 -1
- package/dist/{MultiLayout-BeJ5Lubb.js → MultiLayout-DROxkTdD.js} +24 -24
- package/dist/{NativeScrollBar-RWXpVhbI.cjs → NativeScrollBar-BDF9A1sc.cjs} +1 -1
- package/dist/{NativeScrollBar-BM5NULzg.js → NativeScrollBar-DvdOpwIW.js} +2 -2
- package/dist/TreeLayout-Cc-ykewY.js +103 -0
- package/dist/TreeLayout-D_DYV64_.cjs +1 -0
- package/dist/client/MarkdownExplorer.d.cts +4 -5
- package/dist/client/MarkdownExplorer.d.ts +4 -5
- package/dist/client/hostContract.d.cts +1 -8
- package/dist/client/hostContract.d.ts +1 -8
- package/dist/core/config.d.cts +6 -0
- package/dist/core/config.d.ts +6 -0
- package/dist/core/contracts.d.cts +21 -0
- package/dist/core/contracts.d.ts +21 -0
- package/dist/core/dataRoute.d.cts +5 -1
- package/dist/core/dataRoute.d.ts +5 -1
- package/dist/core/documentId.d.cts +6 -0
- package/dist/core/documentId.d.ts +6 -0
- package/dist/core/labels.d.cts +10 -9
- package/dist/core/labels.d.ts +10 -9
- package/dist/core/location.d.cts +21 -0
- package/dist/core/location.d.ts +21 -0
- package/dist/explorerCore-DivWkFQF.cjs +1 -0
- package/dist/explorerCore-EkU0mwdW.js +1085 -0
- package/dist/index-BmOU3xcK.cjs +18 -0
- package/dist/{index-C1YMH-yI.js → index-dtjghDWY.js} +2647 -2466
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +49 -45
- package/dist/location-Dh6K-y7w.js +761 -0
- package/dist/location-DrOP6t1F.cjs +1 -0
- package/dist/{merge-DQUYEGCx.cjs → merge-BCFCL1cF.cjs} +1 -1
- package/dist/{merge-Bb_HpPhe.js → merge-DC_h-t31.js} +1 -1
- package/dist/ownUrls-BTPGNhBt.cjs +1 -0
- package/dist/ownUrls-DD0cSCsF.js +409 -0
- package/dist/{sanitizeJob-BYRk17nr.js → sanitizeJob-BYqzjFJC.js} +1 -1
- package/dist/{sanitizeJob-Cs9o3Vpl.cjs → sanitizeJob-CudE1RUP.cjs} +1 -1
- package/dist/{sanitizePolicy-CiQfnxyd.cjs → sanitizePolicy-C-ehd0J_.cjs} +1 -1
- package/dist/{sanitizePolicy-CEMdaLUB.js → sanitizePolicy-DAPnUUVm.js} +1 -1
- package/dist/sanitizeWorker.cjs +1 -1
- package/dist/sanitizeWorker.js +3 -3
- package/dist/{sanitizerService-KWXv7bPm.js → sanitizerService-B8v4ap9t.js} +1 -1
- package/dist/{sanitizerService-BY4CPCoA.cjs → sanitizerService-DomN7lwC.cjs} +1 -1
- package/dist/server/anonymous.d.cts +2 -2
- package/dist/server/anonymous.d.ts +2 -2
- package/dist/server/errors.d.cts +1 -1
- package/dist/server/errors.d.ts +1 -1
- package/dist/server/ports.d.cts +24 -2
- package/dist/server/ports.d.ts +24 -2
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +16 -16
- package/dist/serverBrowser.cjs +1 -1
- package/dist/serverBrowser.js +3 -3
- package/dist/serverCore.cjs +1 -1
- package/dist/serverCore.d.cts +1 -1
- package/dist/serverCore.d.ts +1 -1
- package/dist/serverCore.js +4 -4
- package/dist/styles/markdown-explorer.css +1 -1
- package/dist/{tapScrollCircle-BEydRn0y.js → tapScrollCircle-CqMZzWjo.js} +1 -1
- package/dist/{tapScrollCircle-DdX0Wri0.cjs → tapScrollCircle-DVNlszeF.cjs} +1 -1
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +5 -0
- package/dist/testing.d.ts +5 -0
- package/dist/testing.js +80 -2
- package/dist/{useSplitPersistence-B2Fj508K.cjs → useSplitPersistence-BUa_KMsV.cjs} +1 -1
- package/dist/{useSplitPersistence-Fkqak8G8.js → useSplitPersistence-pnb21dsr.js} +1 -1
- package/docs/behavior/dom-hooks.md +11 -2
- package/docs/behavior/hosting.md +1 -1
- package/docs/behavior/localization.md +2 -2
- package/docs/behavior/security.md +24 -3
- package/docs/behavior/url-contract.md +26 -0
- package/package.json +6 -4
- package/dist/EditSurface-CLG70Vnn.cjs +0 -6
- package/dist/ExplorerSplit-CfP1smbT.js +0 -1589
- package/dist/ExplorerSplit-D_0VohOv.cjs +0 -2
- package/dist/TreeLayout-AxLw-36S.js +0 -103
- package/dist/TreeLayout-Bg2YH-EY.cjs +0 -1
- package/dist/explorerCore-DLpDuSev.js +0 -998
- package/dist/explorerCore-DYrxS9ez.cjs +0 -1
- package/dist/index-LQWQfpAf.cjs +0 -18
- package/dist/location--KvTA0Ri.js +0 -726
- package/dist/location-D8DyDkuA.cjs +0 -1
- package/dist/ownUrls-B259RGgd.cjs +0 -1
- package/dist/ownUrls-Dh5g6ZJi.js +0 -370
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as oe, useRef as N, useLayoutEffect as D, useEffectEvent as Ee, useEffect as Ve, useImperativeHandle as
|
|
3
|
-
import { v as ie, k as ge, l as
|
|
4
|
-
import { fencedBodyAsRead as
|
|
5
|
-
import { history as
|
|
6
|
-
import { markdown as
|
|
7
|
-
import { syntaxHighlighting as
|
|
8
|
-
import { highlightSelectionMatches as
|
|
9
|
-
import { EditorState as
|
|
10
|
-
import { EditorView as $, lineNumbers as
|
|
1
|
+
import { jsx as M, jsxs as re, Fragment as et } from "react/jsx-runtime";
|
|
2
|
+
import { useState as oe, useRef as N, useLayoutEffect as D, useEffectEvent as Ee, useEffect as Ve, useImperativeHandle as tt, useMemo as Y, startTransition as nt, useCallback as J, useId as rt } from "react";
|
|
3
|
+
import { v as ie, k as ge, l as ot, u as se, m as it, n as st, o as lt, p as ct, q as at, t as ut, w as He, A as dt, x as Fe, c as ft, y as mt, E as pt, z as ht, B as gt, G as vt, H as wt, I as Se, J as xe, K as bt, L as Et, M as ye, O as St, Q as xt, R as yt, S as kt } from "./index-dtjghDWY.js";
|
|
4
|
+
import { fencedBodyAsRead as Tt, planFencedBodyEdit as At, fencedCodeLanguageOf as It, SPREADSHEETS_LANGUAGE as Ot, readFencedLine as Ct, listItemWidthOn as Lt, openingFenceOn as Mt } from "@aiquants/markdown/code-blocks";
|
|
5
|
+
import { history as qt, historyKeymap as Rt, defaultKeymap as _t, historyField as Pt, redo as Nt, undo as Dt, isolateHistory as Bt } from "@codemirror/commands";
|
|
6
|
+
import { markdown as Vt, markdownLanguage as Ht } from "@codemirror/lang-markdown";
|
|
7
|
+
import { syntaxHighlighting as Ft, syntaxTreeAvailable as zt, HighlightStyle as Gt, ensureSyntaxTree as ze } from "@codemirror/language";
|
|
8
|
+
import { highlightSelectionMatches as Ut, searchKeymap as Wt } from "@codemirror/search";
|
|
9
|
+
import { EditorState as Ge, EditorSelection as he, StateField as Kt, RangeSetBuilder as $t, MapMode as Xt } from "@codemirror/state";
|
|
10
|
+
import { EditorView as $, lineNumbers as jt, highlightActiveLineGutter as Yt, drawSelection as Jt, highlightActiveLine as Qt, keymap as Zt, ViewPlugin as en, Decoration as ue, WidgetType as tn } from "@codemirror/view";
|
|
11
11
|
import { tags as _ } from "@lezer/highlight";
|
|
12
|
-
import { MarkdownViewer as
|
|
13
|
-
import { SOURCE_LINES_ATTRIBUTE as
|
|
14
|
-
import {
|
|
15
|
-
import { H as
|
|
16
|
-
import
|
|
17
|
-
import { o as
|
|
18
|
-
import { d as
|
|
19
|
-
import { PanelGroup as
|
|
20
|
-
import { t as
|
|
21
|
-
const
|
|
12
|
+
import { MarkdownViewer as nn } from "@aiquants/markdown";
|
|
13
|
+
import { SOURCE_LINES_ATTRIBUTE as Ue, parseSourceLines as rn } from "@aiquants/markdown/source-lines";
|
|
14
|
+
import { U as on, k as le, E as sn } from "./ownUrls-DD0cSCsF.js";
|
|
15
|
+
import { H as ln, c as cn, M as an } from "./sanitizePolicy-DAPnUUVm.js";
|
|
16
|
+
import un from "isomorphic-dompurify";
|
|
17
|
+
import { o as dn, C as fn, F as mn, E as pn, m as hn, n as ce, q as gn } from "./location-Dh6K-y7w.js";
|
|
18
|
+
import { d as vn } from "./describeValue-CLlVRO8d.js";
|
|
19
|
+
import { PanelGroup as wn, Panel as ke, PanelResizeHandle as bn } from "@aiquants/resize-panels";
|
|
20
|
+
import { t as En, u as Sn } from "./useSplitPersistence-pnb21dsr.js";
|
|
21
|
+
const We = { history: Pt }, xn = Gt.define([
|
|
22
22
|
{ tag: [_.heading1, _.heading2, _.heading3, _.heading4, _.heading5, _.heading6, _.heading], color: "var(--aqmx-syntax-heading)", fontWeight: "700" },
|
|
23
23
|
{ tag: _.strong, fontWeight: "700" },
|
|
24
24
|
{ tag: _.emphasis, fontStyle: "italic" },
|
|
@@ -28,7 +28,7 @@ const Ue = { history: Rt }, En = zt.define([
|
|
|
28
28
|
{ tag: _.monospace, color: "var(--aqmx-syntax-code)" },
|
|
29
29
|
{ tag: _.quote, color: "var(--aqmx-syntax-quote)" },
|
|
30
30
|
{ tag: [_.processingInstruction, _.contentSeparator, _.labelName, _.meta], color: "var(--aqmx-syntax-mark)" }
|
|
31
|
-
]),
|
|
31
|
+
]), yn = $.theme({
|
|
32
32
|
"&": { height: "100%", color: "var(--aqmx-text)", backgroundColor: "var(--aqmx-surface)", fontSize: "var(--aqmx-font-size-title)" },
|
|
33
33
|
"&.cm-focused": { outline: "none" },
|
|
34
34
|
".cm-scroller": { fontFamily: 'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace', lineHeight: "var(--aqmx-line-height-prose)" },
|
|
@@ -41,8 +41,8 @@ const Ue = { history: Rt }, En = zt.define([
|
|
|
41
41
|
".cm-activeLineGutter": { backgroundColor: "var(--aqmx-editor-active-line)" },
|
|
42
42
|
".cm-searchMatch": { outline: "var(--aqmx-space-1) solid var(--aqmx-border-strong)" },
|
|
43
43
|
".cm-panels": { backgroundColor: "var(--aqmx-surface-raised)", color: "var(--aqmx-text)" }
|
|
44
|
-
}),
|
|
45
|
-
class
|
|
44
|
+
}), Ke = "data-aqmx-conflict-actions", kn = ue.line({ attributes: { "data-aqmx-conflict-line": "marker" } }), Tn = ue.line({ attributes: { "data-aqmx-conflict-line": "ours" } }), An = ue.line({ attributes: { "data-aqmx-conflict-line": "theirs" } });
|
|
45
|
+
class In extends tn {
|
|
46
46
|
constructor(t, n) {
|
|
47
47
|
super(), this.index = t, this.labels = n;
|
|
48
48
|
}
|
|
@@ -53,7 +53,7 @@ class Tn extends Zt {
|
|
|
53
53
|
}
|
|
54
54
|
toDOM(t) {
|
|
55
55
|
const n = document.createElement("div");
|
|
56
|
-
n.setAttribute(
|
|
56
|
+
n.setAttribute(Ke, String(this.index));
|
|
57
57
|
for (const [o, i] of [
|
|
58
58
|
["ours", this.labels.useOurs],
|
|
59
59
|
["theirs", this.labels.useTheirs],
|
|
@@ -62,7 +62,7 @@ class Tn extends Zt {
|
|
|
62
62
|
const r = document.createElement("button");
|
|
63
63
|
r.type = "button", r.textContent = i, r.setAttribute("data-aqmx-conflict-choice", o), r.addEventListener("mousedown", (l) => l.preventDefault()), r.addEventListener("click", () => {
|
|
64
64
|
const l = ne(t.state.doc)[this.index];
|
|
65
|
-
l !== void 0 && (
|
|
65
|
+
l !== void 0 && ($e(t, l, o), t.focus());
|
|
66
66
|
}), n.append(r);
|
|
67
67
|
}
|
|
68
68
|
return n;
|
|
@@ -71,21 +71,21 @@ class Tn extends Zt {
|
|
|
71
71
|
return !0;
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
-
const ne = (e) =>
|
|
75
|
-
const n = new
|
|
74
|
+
const ne = (e) => ot(e.iterLines()), Te = (e, t) => {
|
|
75
|
+
const n = new $t();
|
|
76
76
|
return ne(e).forEach((o, i) => {
|
|
77
77
|
const r = e.line(o.start);
|
|
78
|
-
n.add(r.from, r.from, ue.widget({ widget: new
|
|
78
|
+
n.add(r.from, r.from, ue.widget({ widget: new In(i, t), block: !0, side: -1 }));
|
|
79
79
|
for (let l = o.start; l <= o.end; l += 1) {
|
|
80
|
-
const s = e.line(l).from, f = l === o.start || l === o.separator || l === o.end ?
|
|
80
|
+
const s = e.line(l).from, f = l === o.start || l === o.separator || l === o.end ? kn : l < o.separator ? Tn : An;
|
|
81
81
|
n.add(s, s, f);
|
|
82
82
|
}
|
|
83
83
|
}), n.finish();
|
|
84
|
-
},
|
|
84
|
+
}, On = (e) => Kt.define({
|
|
85
85
|
create: (t) => Te(t.doc, e),
|
|
86
86
|
update: (t, n) => n.docChanged ? Te(n.state.doc, e) : t,
|
|
87
87
|
provide: (t) => $.decorations.from(t)
|
|
88
|
-
}),
|
|
88
|
+
}), $e = (e, t, n) => {
|
|
89
89
|
const { doc: o } = e.state, i = (w, c) => {
|
|
90
90
|
const v = [];
|
|
91
91
|
for (let u = w; u <= c; u += 1) v.push(o.line(u).text);
|
|
@@ -96,7 +96,7 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
|
|
|
96
96
|
const b = s.join(`
|
|
97
97
|
`);
|
|
98
98
|
e.dispatch({ changes: { from: f, to: d, insert: b }, selection: he.cursor(f), scrollIntoView: !0, userEvent: "input.resolve" });
|
|
99
|
-
}, Ae = "input.preview",
|
|
99
|
+
}, Ae = "input.preview", Cn = 20, Ln = en.fromClass(
|
|
100
100
|
class {
|
|
101
101
|
constructor(e) {
|
|
102
102
|
this.view = e, this.schedule();
|
|
@@ -107,11 +107,11 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
|
|
|
107
107
|
e.docChanged && this.schedule();
|
|
108
108
|
}
|
|
109
109
|
schedule() {
|
|
110
|
-
if (this.cancel !== null ||
|
|
110
|
+
if (this.cancel !== null || zt(this.view.state)) return;
|
|
111
111
|
const e = this.view.dom.ownerDocument.defaultView;
|
|
112
112
|
if (e === null) return;
|
|
113
113
|
const t = () => {
|
|
114
|
-
this.cancel = null, ze(this.view.state, this.view.state.doc.length,
|
|
114
|
+
this.cancel = null, ze(this.view.state, this.view.state.doc.length, Cn), this.schedule();
|
|
115
115
|
};
|
|
116
116
|
if (typeof e.requestIdleCallback == "function") {
|
|
117
117
|
const n = e.requestIdleCallback(t);
|
|
@@ -125,7 +125,7 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
|
|
|
125
125
|
this.cancel?.(), this.cancel = null;
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
|
-
),
|
|
128
|
+
), Mn = /`{3,}|~{3,}/u, ee = Object.freeze({ kind: "absent" }), me = Object.freeze({ kind: "unreadable" }), qn = (e, t, n) => {
|
|
129
129
|
const o = [];
|
|
130
130
|
for (let f = t.parent; f !== null; f = f.parent)
|
|
131
131
|
(f.name === "Blockquote" || f.name === "ListItem") && o.unshift(f);
|
|
@@ -136,16 +136,16 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
|
|
|
136
136
|
for (const f of o) {
|
|
137
137
|
const d = e.lineAt(f.from).number;
|
|
138
138
|
if (f.name === "ListItem") {
|
|
139
|
-
const b =
|
|
139
|
+
const b = Lt(e.line(d).text, i, l(d));
|
|
140
140
|
if (b === null) return null;
|
|
141
141
|
i.push({ kind: "listItem", width: b });
|
|
142
142
|
} else
|
|
143
143
|
i.push({ kind: "quote" });
|
|
144
144
|
r.push(d);
|
|
145
145
|
}
|
|
146
|
-
const s =
|
|
146
|
+
const s = Mt(n.text, i, l(n.number));
|
|
147
147
|
return s === null ? null : { containers: i, ...s };
|
|
148
|
-
},
|
|
148
|
+
}, Rn = (e, t) => {
|
|
149
149
|
const { doc: n } = e;
|
|
150
150
|
let o = n.lineAt(t).to;
|
|
151
151
|
for (; ; ) {
|
|
@@ -159,58 +159,58 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
|
|
|
159
159
|
}, Ie = (e, t) => {
|
|
160
160
|
const { doc: n } = e;
|
|
161
161
|
if (!Number.isInteger(t) || t < 1 || t > n.lines) return ee;
|
|
162
|
-
const o = n.line(t), i =
|
|
162
|
+
const o = n.line(t), i = Mn.exec(o.text);
|
|
163
163
|
if (i === null) return ee;
|
|
164
|
-
const r =
|
|
164
|
+
const r = Rn(e, o.from + i.index);
|
|
165
165
|
if (r === null) return ee;
|
|
166
166
|
const l = r.getChild("CodeInfo");
|
|
167
167
|
if (l === null) return ee;
|
|
168
|
-
const s =
|
|
168
|
+
const s = It(n.sliceString(l.from, l.to));
|
|
169
169
|
if (s === null) return me;
|
|
170
|
-
if (s !==
|
|
171
|
-
const f =
|
|
170
|
+
if (s !== Ot) return ee;
|
|
171
|
+
const f = qn(n, r, o);
|
|
172
172
|
if (f === null) return me;
|
|
173
173
|
const [, ...d] = r.getChildren("CodeMark"), b = d.at(-1), w = b === void 0 ? n.lineAt(r.to).number : n.lineAt(b.from).number - 1, c = [];
|
|
174
174
|
let v = "";
|
|
175
175
|
for (let u = t + 1; u <= w; u += 1) {
|
|
176
|
-
const m = n.line(u).text, h =
|
|
176
|
+
const m = n.line(u).text, h = Ct(m, f);
|
|
177
177
|
if (h === null) return me;
|
|
178
178
|
c.push(m), v += u < n.lines ? `${h.content}
|
|
179
179
|
` : h.content;
|
|
180
180
|
}
|
|
181
181
|
return { kind: "found", firstLine: t + 1, lines: c, layout: f, body: v };
|
|
182
|
-
},
|
|
182
|
+
}, _n = ({ parent: e, scroll: t, text: n, saved: o, labels: i, revisions: r, onChange: l, onGeometry: s, onSave: f }) => {
|
|
183
183
|
let d = !1;
|
|
184
184
|
const b = [
|
|
185
|
-
$.scrollHandler.of((u, m, h) => (
|
|
186
|
-
$t(),
|
|
187
|
-
Xt(),
|
|
188
|
-
Lt(),
|
|
185
|
+
$.scrollHandler.of((u, m, h) => (Pn(u, m.head, h, t), !0)),
|
|
189
186
|
jt(),
|
|
190
187
|
Yt(),
|
|
191
|
-
|
|
188
|
+
qt(),
|
|
189
|
+
Jt(),
|
|
190
|
+
Qt(),
|
|
191
|
+
Ut(),
|
|
192
192
|
$.lineWrapping,
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
193
|
+
Vt({ base: Ht }),
|
|
194
|
+
Ln,
|
|
195
|
+
Ft(xn),
|
|
196
|
+
On(i),
|
|
197
|
+
Zt.of([
|
|
198
198
|
{
|
|
199
199
|
key: "Mod-s",
|
|
200
200
|
preventDefault: !0,
|
|
201
201
|
run: () => (f(), !0)
|
|
202
202
|
},
|
|
203
|
-
...
|
|
204
|
-
...
|
|
205
|
-
...
|
|
203
|
+
...Wt,
|
|
204
|
+
...Rt,
|
|
205
|
+
..._t
|
|
206
206
|
]),
|
|
207
207
|
$.contentAttributes.of({ "aria-label": i.editor, "aria-multiline": "true" }),
|
|
208
208
|
$.updateListener.of((u) => {
|
|
209
209
|
for (const m of u.transactions) m.docChanged && r.record(m.changes, m.newDoc);
|
|
210
210
|
u.docChanged && l(u.transactions.every((m) => !m.docChanged || m.isUserEvent(Ae))), (u.docChanged || u.heightChanged || u.geometryChanged) && s(u.docChanged && !d);
|
|
211
211
|
}),
|
|
212
|
-
|
|
213
|
-
], w =
|
|
212
|
+
yn
|
|
213
|
+
], w = Bn(o, b) ?? Ge.create({ doc: n, extensions: b }), c = new $({ state: w, parent: e });
|
|
214
214
|
r.mount(c.state.doc);
|
|
215
215
|
const v = (u) => {
|
|
216
216
|
d = !0;
|
|
@@ -226,85 +226,85 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
|
|
|
226
226
|
const m = c.state.doc.toString();
|
|
227
227
|
if (m === u) return;
|
|
228
228
|
let h = 0;
|
|
229
|
-
const
|
|
230
|
-
for (; h <
|
|
229
|
+
const S = Math.min(m.length, u.length);
|
|
230
|
+
for (; h < S && m.charCodeAt(h) === u.charCodeAt(h); ) h += 1;
|
|
231
231
|
let p = 0;
|
|
232
|
-
for (; p <
|
|
232
|
+
for (; p < S - h && m.charCodeAt(m.length - 1 - p) === u.charCodeAt(u.length - 1 - p); ) p += 1;
|
|
233
233
|
c.dispatch({ changes: { from: h, to: m.length - p, insert: u.slice(h, u.length - p) }, userEvent: "input.replace" });
|
|
234
234
|
},
|
|
235
|
-
replaceBody: (u, m, h,
|
|
236
|
-
const { doc: p } = c.state,
|
|
237
|
-
if (
|
|
238
|
-
const I = Ie(c.state,
|
|
235
|
+
replaceBody: (u, m, h, S) => {
|
|
236
|
+
const { doc: p } = c.state, x = r.lineOf(S, u);
|
|
237
|
+
if (x === null) return "changed";
|
|
238
|
+
const I = Ie(c.state, x);
|
|
239
239
|
if (I.kind === "absent") return "changed";
|
|
240
240
|
if (I.kind === "unreadable") return "unwritable";
|
|
241
|
-
if (I.body !==
|
|
242
|
-
const k =
|
|
241
|
+
if (I.body !== Tt(m, I.layout)) return "changed";
|
|
242
|
+
const k = At(I.lines, I.layout, h);
|
|
243
243
|
if (k.kind !== "edit") return k.kind;
|
|
244
244
|
if (k.from === k.to && k.lines.length === 0) return "written";
|
|
245
|
-
const R = (
|
|
246
|
-
const V = I.firstLine +
|
|
245
|
+
const R = (F) => {
|
|
246
|
+
const V = I.firstLine + F;
|
|
247
247
|
return V <= p.lines ? p.line(V).from : p.length;
|
|
248
248
|
}, L = R(k.from), B = `${L === p.length && p.sliceString(p.length - 1) !== `
|
|
249
249
|
` ? `
|
|
250
|
-
` : ""}${k.lines.map((
|
|
250
|
+
` : ""}${k.lines.map((F) => `${F}
|
|
251
251
|
`).join("")}`;
|
|
252
|
-
return v(() => c.dispatch({ changes: { from: L, to: R(k.to), insert: B }, userEvent: Ae, annotations:
|
|
252
|
+
return v(() => c.dispatch({ changes: { from: L, to: R(k.to), insert: B }, userEvent: Ae, annotations: Bt.of("full") })), "written";
|
|
253
253
|
},
|
|
254
254
|
readBody: (u, m) => {
|
|
255
255
|
const h = r.lineOf(m, u);
|
|
256
256
|
if (h === null) return null;
|
|
257
|
-
const
|
|
258
|
-
return
|
|
257
|
+
const S = Ie(c.state, h);
|
|
258
|
+
return S.kind === "found" ? S.body : null;
|
|
259
259
|
},
|
|
260
|
-
undo: () => v(() =>
|
|
261
|
-
redo: () => v(() =>
|
|
260
|
+
undo: () => v(() => Dt(c)),
|
|
261
|
+
redo: () => v(() => Nt(c)),
|
|
262
262
|
reveal: ({ line: u, column: m }, h) => {
|
|
263
|
-
const { doc:
|
|
264
|
-
c.dispatch({ selection: he.cursor(
|
|
263
|
+
const { doc: S } = c.state, p = S.line(Math.min(Math.max(u, 1), S.lines)), x = Math.min(p.from + m, p.to);
|
|
264
|
+
c.dispatch({ selection: he.cursor(x), effects: Oe(c, x, h, t) });
|
|
265
265
|
},
|
|
266
266
|
showLine: (u) => {
|
|
267
267
|
const { doc: m } = c.state, h = m.line(Math.min(Math.max(u, 1), m.lines)).from;
|
|
268
268
|
c.dispatch({ effects: Oe(c, h, null, t) });
|
|
269
269
|
},
|
|
270
270
|
topLine: () => {
|
|
271
|
-
const u = t.scrollerOf(c.scrollDOM), m = ie(u, c.contentDOM), h = ge(u) + u.clientHeight, { documentTop:
|
|
272
|
-
let
|
|
273
|
-
for (; p.lineAt(
|
|
274
|
-
const R = c.lineBlockAt(
|
|
275
|
-
if (
|
|
276
|
-
|
|
271
|
+
const u = t.scrollerOf(c.scrollDOM), m = ie(u, c.contentDOM), h = ge(u) + u.clientHeight, { documentTop: S } = c, { doc: p } = c.state;
|
|
272
|
+
let x = c.lineBlockAtHeight(Math.max(m - S, 0));
|
|
273
|
+
for (; p.lineAt(x.from).text.trim() === "" && x.to < p.length; ) {
|
|
274
|
+
const R = c.lineBlockAt(x.to + 1);
|
|
275
|
+
if (S + R.top >= h) break;
|
|
276
|
+
x = R;
|
|
277
277
|
}
|
|
278
|
-
const I = c.coordsAtPos(
|
|
279
|
-
return { line: c.state.doc.lineAt(
|
|
278
|
+
const I = c.coordsAtPos(x.from), k = I === null ? S + x.top : I.top;
|
|
279
|
+
return { line: c.state.doc.lineAt(x.from).number, clientTop: k, offset: k - m };
|
|
280
280
|
},
|
|
281
281
|
lineSpans: (u) => {
|
|
282
|
-
const m = c.scrollDOM, h = m.scrollTop + c.documentTop - ie(m, c.contentDOM), { doc:
|
|
283
|
-
return u.map(({ first:
|
|
282
|
+
const m = c.scrollDOM, h = m.scrollTop + c.documentTop - ie(m, c.contentDOM), { doc: S } = c.state, p = (x) => S.line(Math.min(Math.max(x, 1), S.lines)).from;
|
|
283
|
+
return u.map(({ first: x, last: I }) => ({ top: h + c.lineBlockAt(p(x)).top, bottom: h + c.lineBlockAt(p(I)).bottom }));
|
|
284
284
|
},
|
|
285
285
|
scrollElement: c.scrollDOM,
|
|
286
286
|
focus: () => c.focus(),
|
|
287
287
|
conflicts: () => ne(c.state.doc),
|
|
288
288
|
resolveAtCursor: (u) => {
|
|
289
|
-
const m = ne(c.state.doc), h = c.state.doc.lineAt(c.state.selection.main.head).number,
|
|
290
|
-
return
|
|
289
|
+
const m = ne(c.state.doc), h = c.state.doc.lineAt(c.state.selection.main.head).number, S = m.find((p) => p.end >= h);
|
|
290
|
+
return S === void 0 ? !1 : ($e(c, S, u), !0);
|
|
291
291
|
},
|
|
292
292
|
nextConflict: () => {
|
|
293
293
|
const u = ne(c.state.doc);
|
|
294
294
|
if (u[0] === void 0) return !1;
|
|
295
|
-
const h = c.state.doc.lineAt(c.state.selection.main.head).number,
|
|
296
|
-
c.dispatch({ selection: he.cursor(
|
|
297
|
-
const I = c.contentDOM.querySelector(`[${
|
|
295
|
+
const h = c.state.doc.lineAt(c.state.selection.main.head).number, S = u.findIndex((k) => k.start > h), p = S < 0 ? 0 : S, x = c.state.doc.line(u[p].start).from;
|
|
296
|
+
c.dispatch({ selection: he.cursor(x), effects: $.scrollIntoView(x, { y: "center" }) });
|
|
297
|
+
const I = c.contentDOM.querySelector(`[${Ke}="${String(p)}"] button`);
|
|
298
298
|
return I instanceof HTMLElement ? I.focus({ preventScroll: !0 }) : c.focus(), !0;
|
|
299
299
|
},
|
|
300
|
-
save: () => c.state.toJSON(
|
|
300
|
+
save: () => c.state.toJSON(We),
|
|
301
301
|
destroy: () => c.destroy()
|
|
302
302
|
};
|
|
303
303
|
}, Oe = (e, t, n, o) => {
|
|
304
304
|
const i = o.scrollerOf(e.scrollDOM), r = (n === null ? ie(i, e.contentDOM) : n) - ge(i);
|
|
305
305
|
return $.scrollIntoView(t, { y: "start", yMargin: r });
|
|
306
|
-
},
|
|
307
|
-
const i =
|
|
306
|
+
}, Pn = (e, t, n, o) => {
|
|
307
|
+
const i = Nn(e, t), r = o.scrollerOf(e.scrollDOM), l = ge(r), s = ie(r, e.contentDOM), f = l + r.clientHeight;
|
|
308
308
|
let d = 0;
|
|
309
309
|
switch (n.y) {
|
|
310
310
|
case "start":
|
|
@@ -320,9 +320,9 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
|
|
|
320
320
|
i.top < s + n.yMargin ? d = i.top - (s + n.yMargin) : i.bottom > f - n.yMargin && (d = Math.min(i.bottom - (f - n.yMargin), i.top - (s + n.yMargin)));
|
|
321
321
|
}
|
|
322
322
|
if (d !== 0 && (r.scrollTop += d), n.y === "start") return;
|
|
323
|
-
const b =
|
|
323
|
+
const b = Dn(e, t);
|
|
324
324
|
b !== null && o.reveal(b);
|
|
325
|
-
},
|
|
325
|
+
}, Nn = (e, t) => {
|
|
326
326
|
const { node: n, offset: o } = e.domAtPos(t);
|
|
327
327
|
if (n.nodeType === Node.TEXT_NODE) {
|
|
328
328
|
const l = n.ownerDocument?.createRange();
|
|
@@ -334,60 +334,60 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
|
|
|
334
334
|
}
|
|
335
335
|
const i = e.lineBlockAt(t), r = e.documentTop + i.top;
|
|
336
336
|
return { top: r, bottom: r + i.height };
|
|
337
|
-
},
|
|
337
|
+
}, Dn = (e, t) => {
|
|
338
338
|
const { node: n } = e.domAtPos(t);
|
|
339
339
|
for (let o = n instanceof Element ? n : n.parentElement; o !== null; o = o.parentElement)
|
|
340
340
|
if (o.parentElement === e.contentDOM) return o;
|
|
341
341
|
return null;
|
|
342
|
-
},
|
|
342
|
+
}, Bn = (e, t) => {
|
|
343
343
|
if (e == null) return null;
|
|
344
344
|
try {
|
|
345
|
-
return
|
|
345
|
+
return Ge.fromJSON(e, { extensions: t }, We);
|
|
346
346
|
} catch {
|
|
347
347
|
return null;
|
|
348
348
|
}
|
|
349
|
-
},
|
|
349
|
+
}, Vn = 610, Hn = 987, Ce = Object.freeze({ kind: "unavailable" }), Fn = "true", zn = "false", Gn = (e) => e === Fn ? !0 : e === zn ? !1 : null, Un = (e) => {
|
|
350
350
|
const t = new DOMParser().parseFromString(e, "text/html"), n = [];
|
|
351
351
|
for (const o of t.querySelectorAll("img[data-asset-src], a[data-doc-path]")) {
|
|
352
352
|
const i = o.localName === "img", r = o.getAttribute(i ? "data-asset-src" : "data-doc-path");
|
|
353
|
-
r !== null && n.push({ target: { kind: i ? "asset" : "doc", path: r }, exists:
|
|
353
|
+
r !== null && n.push({ target: { kind: i ? "asset" : "doc", path: r }, exists: Gn(o.getAttribute(i ? "data-asset-exists" : "data-doc-exists")) });
|
|
354
354
|
}
|
|
355
355
|
return n;
|
|
356
|
-
},
|
|
356
|
+
}, Wn = ({ path: e, instant: t, preview: n, initial: o, onView: i }) => {
|
|
357
357
|
const r = new AbortController(), l = { asset: /* @__PURE__ */ new Map(), doc: /* @__PURE__ */ new Map() };
|
|
358
|
-
let s = o, f = null, d = !1, b = !1, w = null, c = null, v = [], u, m = !1, h,
|
|
358
|
+
let s = o, f = null, d = !1, b = !1, w = null, c = null, v = [], u, m = !1, h, S = null;
|
|
359
359
|
const p = (g) => {
|
|
360
360
|
g.parsed === s.parsed && g.source === s.source && g.failure === s.failure && g.busy === s.busy && g.tier === s.tier || (s = g, i(g));
|
|
361
|
-
},
|
|
361
|
+
}, x = (g, E) => {
|
|
362
362
|
d || (d = !0, console.error(`[markdown-explorer] ${g}`, ...E === void 0 ? [] : [E]));
|
|
363
363
|
}, I = (g) => {
|
|
364
364
|
if (t !== null)
|
|
365
365
|
for (const { target: E, exists: C } of t.marksOf(g)) l[E.kind].set(E.path, C);
|
|
366
366
|
}, k = () => {
|
|
367
|
-
clearTimeout(h), h = void 0,
|
|
367
|
+
clearTimeout(h), h = void 0, S?.abort(), S = null;
|
|
368
368
|
}, R = () => {
|
|
369
369
|
c = null, v = [], clearTimeout(u), u = void 0;
|
|
370
370
|
}, L = (g, E) => {
|
|
371
371
|
p({ ...s, failure: g, busy: !1, tier: E });
|
|
372
372
|
}, G = () => {
|
|
373
|
-
clearTimeout(u), u = v.length === 0 ? void 0 : setTimeout(
|
|
373
|
+
clearTimeout(u), u = v.length === 0 ? void 0 : setTimeout(F, Hn);
|
|
374
374
|
}, B = () => {
|
|
375
375
|
if (t === null || c === null) return;
|
|
376
376
|
const g = c, E = [], C = { asset: /* @__PURE__ */ new Set(), doc: /* @__PURE__ */ new Set() };
|
|
377
377
|
let U;
|
|
378
378
|
try {
|
|
379
|
-
U = t.sanitize(g.html, (
|
|
380
|
-
const de = l[
|
|
381
|
-
return de === void 0 && !C[
|
|
379
|
+
U = t.sanitize(g.html, (z) => {
|
|
380
|
+
const de = l[z.kind].get(z.path);
|
|
381
|
+
return de === void 0 && !C[z.kind].has(z.path) && (C[z.kind].add(z.path), E.push(z)), de ?? void 0;
|
|
382
382
|
});
|
|
383
|
-
} catch (
|
|
384
|
-
R(),
|
|
383
|
+
} catch (z) {
|
|
384
|
+
R(), z instanceof ln ? L(le("too-large"), "instant") : (x("the draft sanitizer failed", z), L(le("failed"), "instant"));
|
|
385
385
|
return;
|
|
386
386
|
}
|
|
387
387
|
v = E;
|
|
388
388
|
const X = s.parsed !== null && s.parsed.htmlContent === U && s.parsed.headings === g.headings ? s.parsed : { htmlContent: U, headings: g.headings };
|
|
389
389
|
p({ parsed: X, source: g.draft, failure: null, busy: !1, tier: "instant" }), G();
|
|
390
|
-
},
|
|
390
|
+
}, F = () => {
|
|
391
391
|
if (u = void 0, m || c === null || v.length === 0) return;
|
|
392
392
|
m = !0;
|
|
393
393
|
const g = v;
|
|
@@ -401,37 +401,37 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
|
|
|
401
401
|
}, V = (g) => {
|
|
402
402
|
k(), R(), p({ ...s, busy: !0, tier: "server" });
|
|
403
403
|
const E = new AbortController();
|
|
404
|
-
|
|
404
|
+
S = E, h = setTimeout(() => {
|
|
405
405
|
h = void 0, n(e, g.text, E.signal).then((C) => {
|
|
406
406
|
if (!(E.signal.aborted || !("kind" in C))) {
|
|
407
|
-
if (
|
|
407
|
+
if (S = null, C.kind === "failure") {
|
|
408
408
|
L(C.failure, "server");
|
|
409
409
|
return;
|
|
410
410
|
}
|
|
411
411
|
I(C.htmlContent), p({ parsed: { htmlContent: C.htmlContent, headings: C.headings }, source: g, failure: null, busy: !1, tier: "server" });
|
|
412
412
|
}
|
|
413
413
|
});
|
|
414
|
-
},
|
|
414
|
+
}, Vn);
|
|
415
415
|
}, a = async (g, E) => {
|
|
416
416
|
let C;
|
|
417
417
|
try {
|
|
418
418
|
C = await g.convert({ path: e, text: E }, r.signal);
|
|
419
419
|
} catch (X) {
|
|
420
|
-
return r.signal.aborted ||
|
|
420
|
+
return r.signal.aborted || x("the draft converter rejected a conversion, which its contract allows only once the signal aborted", X), Ce;
|
|
421
421
|
}
|
|
422
|
-
const U =
|
|
423
|
-
return U === null ? C : (
|
|
422
|
+
const U = on(C);
|
|
423
|
+
return U === null ? C : (x(`the draft converter answered outside its contract: ${U}`), Ce);
|
|
424
424
|
}, T = (g, E) => {
|
|
425
425
|
switch (E.kind) {
|
|
426
426
|
case "preview":
|
|
427
|
-
if (k(), E.headings.length >
|
|
428
|
-
R(), L(
|
|
427
|
+
if (k(), E.headings.length > sn) {
|
|
428
|
+
R(), L(le("too-large"), "instant");
|
|
429
429
|
return;
|
|
430
430
|
}
|
|
431
431
|
c = { draft: g, html: E.htmlContent, headings: E.headings.map(({ text: C, depth: U, id: X }) => ({ text: C, depth: U, id: X })) }, B();
|
|
432
432
|
return;
|
|
433
433
|
case "failure":
|
|
434
|
-
k(), R(), L(
|
|
434
|
+
k(), R(), L(le(E.failure.reason, E.failure.code), "instant");
|
|
435
435
|
return;
|
|
436
436
|
case "unavailable":
|
|
437
437
|
V(g);
|
|
@@ -465,7 +465,7 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
|
|
|
465
465
|
r.abort(), w = null, clearTimeout(u), u = void 0, k();
|
|
466
466
|
}
|
|
467
467
|
};
|
|
468
|
-
},
|
|
468
|
+
}, Kn = (e) => cn(un(window), e.iframeHosts, e.dataPath, an, dn(e)), $n = (e, t) => e.flatMap((n, o) => {
|
|
469
469
|
const i = t[o];
|
|
470
470
|
return i === void 0 ? [] : [
|
|
471
471
|
{ editor: i.top, preview: n.top },
|
|
@@ -473,9 +473,9 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
|
|
|
473
473
|
];
|
|
474
474
|
}), j = (e, t) => {
|
|
475
475
|
const n = e[t];
|
|
476
|
-
if (n === void 0) throw new RangeError(`[markdown-explorer] a scroll map index must be in 0..${String(e.length - 1)}; got ${
|
|
476
|
+
if (n === void 0) throw new RangeError(`[markdown-explorer] a scroll map index must be in 0..${String(e.length - 1)}; got ${vn(t)}`);
|
|
477
477
|
return n;
|
|
478
|
-
},
|
|
478
|
+
}, Xn = (e) => {
|
|
479
479
|
const t = [];
|
|
480
480
|
for (const o of e) {
|
|
481
481
|
let i = 0, r = t.length;
|
|
@@ -488,11 +488,11 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
|
|
|
488
488
|
const n = [];
|
|
489
489
|
for (let o = t.at(-1); o !== void 0; o = o.before) n.push(o.pair);
|
|
490
490
|
return n.reverse();
|
|
491
|
-
},
|
|
491
|
+
}, jn = (e, t) => {
|
|
492
492
|
const n = Math.max(t.editorMax, 0), o = Math.max(t.previewMax, 0), i = n - t.editorViewport, r = o - t.previewViewport, l = e.filter((d) => d.editor > 0 && d.editor < i && d.preview > 0 && d.preview < r).sort((d, b) => d.editor - b.editor || d.preview - b.preview);
|
|
493
493
|
let s = { editor: 0, preview: 0 };
|
|
494
494
|
const f = [s];
|
|
495
|
-
for (const d of
|
|
495
|
+
for (const d of Xn(l))
|
|
496
496
|
d.editor > s.editor && d.preview > s.preview && (f.push(d), s = d);
|
|
497
497
|
return f.push({ editor: n, preview: o }), {
|
|
498
498
|
toPreview: (d) => Le(f, "editor", "preview", d),
|
|
@@ -509,33 +509,33 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
|
|
|
509
509
|
}
|
|
510
510
|
const f = j(e, l), d = j(e, s);
|
|
511
511
|
return f[n] + (d[n] - f[n]) * (o - f[t]) / (d[t] - f[t]);
|
|
512
|
-
},
|
|
512
|
+
}, Yn = 610, Me = 89, qe = 0.5, Jn = ({ editor: e, preview: t, previewBlocks: n, editorSpans: o, requestFrame: i, cancelFrame: r, now: l }) => {
|
|
513
513
|
let s = "editor", f = 0, d = null, b = null, w = !1, c = null, v = null;
|
|
514
514
|
const u = { editor: 0, preview: 0 }, m = { editor: null, preview: null };
|
|
515
|
-
let h = null,
|
|
515
|
+
let h = null, S = () => {
|
|
516
516
|
};
|
|
517
517
|
const p = (a) => {
|
|
518
|
-
d !== null && a !== d || (s = a, f = l() +
|
|
519
|
-
},
|
|
518
|
+
d !== null && a !== d || (s = a, f = l() + Yn);
|
|
519
|
+
}, x = (a, T) => {
|
|
520
520
|
a !== s && d === null && l() >= f && !I(a, T) && (s = a), B();
|
|
521
521
|
}, I = (a, T) => {
|
|
522
522
|
const A = m[a];
|
|
523
523
|
return l() < u[a] || A !== null && Math.abs(T.position() - A) < qe;
|
|
524
|
-
}, k = e.onScroll(() =>
|
|
524
|
+
}, k = e.onScroll(() => x("editor", e)), R = e.onIntent(() => p("editor")), L = () => {
|
|
525
525
|
const a = t();
|
|
526
|
-
return a !== h && (
|
|
526
|
+
return a !== h && (S(), h = a, S = a === null ? () => {
|
|
527
527
|
} : G(a)), a;
|
|
528
528
|
}, G = (a) => {
|
|
529
|
-
const T = a.onScroll(() =>
|
|
529
|
+
const T = a.onScroll(() => x("preview", a)), A = a.onIntent(() => p("preview"));
|
|
530
530
|
return () => {
|
|
531
531
|
T(), A();
|
|
532
532
|
};
|
|
533
533
|
}, B = () => {
|
|
534
|
-
!w && b === null && (b = i(
|
|
535
|
-
},
|
|
534
|
+
!w && b === null && (b = i(F));
|
|
535
|
+
}, F = () => {
|
|
536
536
|
b = null;
|
|
537
537
|
const a = L();
|
|
538
|
-
a !== null && (c ??= n(), v ??= $n(
|
|
538
|
+
a !== null && (c ??= n(), v ??= jn($n(c, o(c)), { editorMax: e.max(), previewMax: a.max(), editorViewport: e.viewport(), previewViewport: a.viewport() }), s === "editor" ? V(a, "preview", v.toPreview(e.position())) : V(e, "editor", v.toEditor(a.position())));
|
|
539
539
|
}, V = (a, T, A) => {
|
|
540
540
|
if (Math.abs(a.position() - A) < qe) {
|
|
541
541
|
m[T] = a.position();
|
|
@@ -554,10 +554,10 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
|
|
|
554
554
|
d = a, !(a === null || a === s) && (s = a, f = 0, B());
|
|
555
555
|
},
|
|
556
556
|
dispose: () => {
|
|
557
|
-
w = !0, b !== null && r(b), b = null, k(), R(),
|
|
557
|
+
w = !0, b !== null && r(b), b = null, k(), R(), S();
|
|
558
558
|
}
|
|
559
559
|
};
|
|
560
|
-
}, Re = Object.freeze(["wheel", "pointerdown", "keydown", "focusin"]),
|
|
560
|
+
}, Re = Object.freeze(["wheel", "pointerdown", "keydown", "focusin"]), Xe = (e) => ({
|
|
561
561
|
position: () => e.scrollTop,
|
|
562
562
|
max: () => Math.max(e.scrollHeight - e.clientHeight, 0),
|
|
563
563
|
viewport: () => e.clientHeight,
|
|
@@ -569,57 +569,57 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
|
|
|
569
569
|
for (const n of Re) e.removeEventListener(n, t, { capture: !0 });
|
|
570
570
|
};
|
|
571
571
|
}
|
|
572
|
-
}), te = "[data-aqmd-scroll-container]",
|
|
573
|
-
const n =
|
|
572
|
+
}), te = "[data-aqmd-scroll-container]", Qn = "[data-aqmd-content]", Zn = `[${Ue}]`, er = Object.freeze(["p1", "p2", "p3", "p4", "p5", "p6", "p7", "p8"]), je = (e, t) => {
|
|
573
|
+
const n = ct(e.peek(t));
|
|
574
574
|
return n !== null && n.document.kind === "markdown" ? { htmlContent: n.document.htmlContent, headings: n.document.headings } : null;
|
|
575
|
-
},
|
|
575
|
+
}, tr = (e, t, n, o) => {
|
|
576
576
|
if (t === void 0) return null;
|
|
577
577
|
let i;
|
|
578
578
|
try {
|
|
579
|
-
i =
|
|
579
|
+
i = Kn(e);
|
|
580
580
|
} catch (r) {
|
|
581
581
|
return console.error("[markdown-explorer] the draft sanitizer cannot run in this browser, so the server renders the preview", r), null;
|
|
582
582
|
}
|
|
583
|
-
return { converter: t, sanitize: i, marksOf:
|
|
584
|
-
},
|
|
583
|
+
return { converter: t, sanitize: i, marksOf: Un, seed: je(n, o)?.htmlContent ?? null };
|
|
584
|
+
}, nr = (e) => {
|
|
585
585
|
const t = [];
|
|
586
586
|
let n = null;
|
|
587
|
-
for (const o of e.querySelectorAll(
|
|
588
|
-
const i =
|
|
587
|
+
for (const o of e.querySelectorAll(Zn)) {
|
|
588
|
+
const i = rn(o.getAttribute(Ue));
|
|
589
589
|
if (i === null || o.getClientRects().length === 0) continue;
|
|
590
590
|
n ??= e.scrollTop - ie(e, o);
|
|
591
591
|
const { top: r, bottom: l } = o.getBoundingClientRect();
|
|
592
592
|
t.push({ first: i.first, last: i.last, top: n + r, bottom: n + l });
|
|
593
593
|
}
|
|
594
594
|
return t;
|
|
595
|
-
},
|
|
596
|
-
const { config: f, data: d, documents: b, draftConverter: w, labels: c } =
|
|
595
|
+
}, rr = ({ path: e, readDraft: t, viewer: n, tables: o, concealed: i, onEditAt: r, onLayout: l, handleRef: s }) => {
|
|
596
|
+
const { config: f, data: d, documents: b, draftConverter: w, labels: c } = se(), [v, u] = oe(() => ({ parsed: je(b, e), source: null, failure: null, busy: !0, tier: w === void 0 ? "server" : "instant" })), m = N(null), h = N(null), S = N(v);
|
|
597
597
|
D(() => {
|
|
598
|
-
|
|
598
|
+
S.current = v;
|
|
599
599
|
});
|
|
600
600
|
const p = Ee(() => t());
|
|
601
601
|
Ve(() => {
|
|
602
|
-
const a =
|
|
602
|
+
const a = tr(f, w, b, e), T = p(), A = Wn({ path: e, instant: a, preview: d.preview, initial: S.current, onView: (g) => nt(() => u(g)) });
|
|
603
603
|
return h.current = A, A.update(T), () => {
|
|
604
604
|
A.dispose(), h.current = null;
|
|
605
605
|
};
|
|
606
606
|
}, [f, d, b, w, e]);
|
|
607
|
-
const
|
|
607
|
+
const x = Ee(() => l());
|
|
608
608
|
D(() => {
|
|
609
|
-
v.parsed !== null &&
|
|
609
|
+
v.parsed !== null && x();
|
|
610
610
|
}, [v.parsed]);
|
|
611
611
|
const I = v.parsed !== null;
|
|
612
612
|
D(() => {
|
|
613
613
|
const a = I ? m.current?.querySelector(te) : null;
|
|
614
614
|
if (!(a instanceof HTMLElement)) return;
|
|
615
615
|
a.tabIndex = 0;
|
|
616
|
-
const T = new ResizeObserver(() =>
|
|
616
|
+
const T = new ResizeObserver(() => x());
|
|
617
617
|
T.observe(a);
|
|
618
|
-
const A = a.querySelector(
|
|
618
|
+
const A = a.querySelector(Qn);
|
|
619
619
|
return A !== null && T.observe(A), () => T.disconnect();
|
|
620
620
|
}, [I]);
|
|
621
621
|
const k = N(null);
|
|
622
|
-
|
|
622
|
+
tt(
|
|
623
623
|
s,
|
|
624
624
|
() => ({
|
|
625
625
|
draft: (a) => {
|
|
@@ -627,11 +627,11 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
|
|
|
627
627
|
},
|
|
628
628
|
scrollPort: () => {
|
|
629
629
|
const a = m.current?.querySelector(te);
|
|
630
|
-
return a instanceof HTMLElement ? (k.current?.scroller !== a && (k.current = { scroller: a, port:
|
|
630
|
+
return a instanceof HTMLElement ? (k.current?.scroller !== a && (k.current = { scroller: a, port: Xe(a) }), k.current.port) : null;
|
|
631
631
|
},
|
|
632
632
|
blocks: () => {
|
|
633
633
|
const a = m.current?.querySelector(te);
|
|
634
|
-
return a instanceof HTMLElement ?
|
|
634
|
+
return a instanceof HTMLElement ? nr(a) : [];
|
|
635
635
|
},
|
|
636
636
|
focus: () => {
|
|
637
637
|
const a = m.current?.querySelector(te);
|
|
@@ -639,19 +639,19 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
|
|
|
639
639
|
},
|
|
640
640
|
anchor: (a) => {
|
|
641
641
|
const T = m.current, A = T?.querySelector(te);
|
|
642
|
-
return T === null || !(A instanceof HTMLElement) ? null :
|
|
642
|
+
return T === null || !(A instanceof HTMLElement) ? null : lt(T, a(A));
|
|
643
643
|
},
|
|
644
644
|
place: ({ line: a, clientTop: T }, A) => {
|
|
645
|
-
const g = m.current, E = g === null ? null :
|
|
646
|
-
E !== null && (A(E).scrollTop +=
|
|
645
|
+
const g = m.current, E = g === null ? null : it(g, a);
|
|
646
|
+
E !== null && (A(E).scrollTop += st(E, a) - T);
|
|
647
647
|
}
|
|
648
648
|
}),
|
|
649
649
|
[]
|
|
650
650
|
);
|
|
651
651
|
const R = (a) => {
|
|
652
652
|
const T = m.current, { target: A } = a;
|
|
653
|
-
if (r === void 0 || T === null || !(A instanceof Element) || !
|
|
654
|
-
const g =
|
|
653
|
+
if (r === void 0 || T === null || !(A instanceof Element) || !at(A)) return;
|
|
654
|
+
const g = ut(A, T, T.ownerDocument.getSelection());
|
|
655
655
|
g !== null && r(g);
|
|
656
656
|
}, L = v.source === null ? null : v.source.revision, G = Y(
|
|
657
657
|
() => L === null ? void 0 : {
|
|
@@ -662,7 +662,7 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
|
|
|
662
662
|
subscribe: o.subscribe
|
|
663
663
|
},
|
|
664
664
|
[o, L]
|
|
665
|
-
), B = Y(() => ({ ...n.labels, spreadsheetReadOnly: c.previewTablePending }), [n.labels, c.previewTablePending]),
|
|
665
|
+
), B = Y(() => ({ ...n.labels, spreadsheetReadOnly: c.previewTablePending }), [n.labels, c.previewTablePending]), F = Y(
|
|
666
666
|
() => ({
|
|
667
667
|
...n,
|
|
668
668
|
labels: G === void 0 ? B : n.labels,
|
|
@@ -678,8 +678,8 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
|
|
|
678
678
|
}),
|
|
679
679
|
[n, B, G]
|
|
680
680
|
), V = Y(
|
|
681
|
-
() => v.parsed === null ? null : /* @__PURE__ */
|
|
682
|
-
[
|
|
681
|
+
() => v.parsed === null ? null : /* @__PURE__ */ M("div", { className: "aqmx-document-viewer", children: /* @__PURE__ */ M(nn, { ...F, parseResult: v.parsed, content: null }) }),
|
|
682
|
+
[F, v.parsed]
|
|
683
683
|
);
|
|
684
684
|
return /* @__PURE__ */ re(
|
|
685
685
|
"section",
|
|
@@ -694,27 +694,30 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
|
|
|
694
694
|
"data-testid": "markdown-explorer-edit-preview",
|
|
695
695
|
onDoubleClick: r === void 0 ? void 0 : R,
|
|
696
696
|
children: [
|
|
697
|
-
v.failure === null ? null : /* @__PURE__ */
|
|
698
|
-
V ?? (v.failure === null ? /* @__PURE__ */
|
|
699
|
-
v.busy ? /* @__PURE__ */
|
|
697
|
+
v.failure === null ? null : /* @__PURE__ */ M(or, { failure: v.failure }),
|
|
698
|
+
V ?? (v.failure === null ? /* @__PURE__ */ M("div", { className: "aqmx-skeleton", "aria-hidden": "true", "data-testid": "markdown-explorer-edit-preview-skeleton", children: er.map((a) => /* @__PURE__ */ M("span", {}, a)) }) : null),
|
|
699
|
+
v.busy ? /* @__PURE__ */ M("p", { className: "aqmx-sr-only", children: c.previewUpdating }) : null
|
|
700
700
|
]
|
|
701
701
|
}
|
|
702
702
|
);
|
|
703
|
-
},
|
|
703
|
+
}, or = ({ failure: e }) => {
|
|
704
|
+
const { labels: t } = se(), { reason: n } = e;
|
|
705
|
+
return He(n) ? /* @__PURE__ */ M(dt, { failure: e, place: "read", deniedSentence: null, retry: null, testId: "markdown-explorer-edit-preview-failure" }) : /* @__PURE__ */ M("p", { className: "aqmx-callout aqmx-document-notice", "data-aqmx-tone": "warning", "data-testid": "markdown-explorer-edit-preview-failure", children: t.previewFailed(Fe(t, n)) });
|
|
706
|
+
}, _e = "data-aqmx-edit-split", pe = "--aqmx-edit-share", Pe = "--aqmx-edit-gutter", ir = "data-aqmx-edit-split-probe", sr = "aqmx-edit-split", lr = "aqmx-edit-editor", cr = "aqmx-edit-preview", Ne = { value: hn, unit: "percentage" }, De = { value: pn, unit: "percentage" }, Be = (e) => {
|
|
704
707
|
if (e.length !== 2) return null;
|
|
705
708
|
const [t = 0, n = 0] = e, o = t + n;
|
|
706
709
|
return o > 0 ? t / o * 100 : null;
|
|
707
|
-
},
|
|
710
|
+
}, ae = (e) => {
|
|
708
711
|
const t = e.current?.parentElement;
|
|
709
712
|
if (t == null) throw new Error("[markdown-explorer] the edit split is not mounted in its surface");
|
|
710
713
|
return t;
|
|
711
|
-
},
|
|
714
|
+
}, ar = (e, t, n) => {
|
|
712
715
|
const [o, i] = oe(null);
|
|
713
716
|
return D(() => {
|
|
714
717
|
const r = e.current, l = t.current;
|
|
715
718
|
if (r === null || l === null) throw new Error("[markdown-explorer] the edit split is not mounted");
|
|
716
719
|
const s = { frame: r.getBoundingClientRect().width, measure: l.getBoundingClientRect().width }, f = () => {
|
|
717
|
-
s.frame > 0 && s.measure > 0 && i(
|
|
720
|
+
s.frame > 0 && s.measure > 0 && i(gn(s.frame, s.measure, n));
|
|
718
721
|
};
|
|
719
722
|
f();
|
|
720
723
|
const d = new ResizeObserver((b) => {
|
|
@@ -726,24 +729,24 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
|
|
|
726
729
|
});
|
|
727
730
|
return d.observe(r), d.observe(l), () => d.disconnect();
|
|
728
731
|
}, [e, t, n]), o;
|
|
729
|
-
},
|
|
730
|
-
const { edits: t, labels: n } =
|
|
732
|
+
}, ur = ({ editorId: e }) => {
|
|
733
|
+
const { edits: t, labels: n } = se(), o = Y(() => En(n), [n]), i = N(null), r = N(null), l = ft() ? fn : mn, s = ar(i, r, l), [f] = oe(() => t.editorShare());
|
|
731
734
|
D(() => {
|
|
732
|
-
const w =
|
|
735
|
+
const w = ae(i);
|
|
733
736
|
return w.style.setProperty(Pe, `${String(l)}px`), () => {
|
|
734
737
|
w.style.removeProperty(Pe);
|
|
735
738
|
};
|
|
736
739
|
}, [l]), D(() => {
|
|
737
|
-
const w =
|
|
740
|
+
const w = ae(i);
|
|
738
741
|
return w.style.setProperty(pe, `${String(f)}%`), () => {
|
|
739
742
|
w.style.removeProperty(pe);
|
|
740
743
|
};
|
|
741
744
|
}, [f]), D(() => {
|
|
742
745
|
if (s === null) return;
|
|
743
|
-
const w =
|
|
746
|
+
const w = ae(i);
|
|
744
747
|
return w.setAttribute(_e, s), () => w.removeAttribute(_e);
|
|
745
748
|
}, [s]);
|
|
746
|
-
const d =
|
|
749
|
+
const d = Sn(
|
|
747
750
|
J(
|
|
748
751
|
(w) => {
|
|
749
752
|
const c = Be(w);
|
|
@@ -754,19 +757,19 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
|
|
|
754
757
|
), b = J(
|
|
755
758
|
(w, c) => {
|
|
756
759
|
const v = Be(w);
|
|
757
|
-
v !== null &&
|
|
760
|
+
v !== null && ae(i).style.setProperty(pe, `${String(v)}%`), d.layoutChanged(w, c);
|
|
758
761
|
},
|
|
759
762
|
[d]
|
|
760
763
|
);
|
|
761
764
|
return /* @__PURE__ */ re("div", { ref: i, className: "aqmx-edit-split", "data-testid": "markdown-explorer-edit-split", children: [
|
|
762
|
-
/* @__PURE__ */
|
|
763
|
-
s === null ? null : /* @__PURE__ */ re(
|
|
764
|
-
/* @__PURE__ */
|
|
765
|
-
/* @__PURE__ */
|
|
766
|
-
|
|
765
|
+
/* @__PURE__ */ M("span", { ref: r, className: "aqmx-edit-split-probe", "aria-hidden": "true", [ir]: "" }),
|
|
766
|
+
s === null ? null : /* @__PURE__ */ re(wn, { id: sr, direction: s === "beside" ? "horizontal" : "vertical", onLayout: b, labels: o, className: "aqmx-edit-split-group", children: [
|
|
767
|
+
/* @__PURE__ */ M(ke, { id: lr, defaultSize: { value: f, unit: "percentage" }, minSize: Ne, maxSize: De, contentOverflow: "hidden" }),
|
|
768
|
+
/* @__PURE__ */ M(
|
|
769
|
+
bn,
|
|
767
770
|
{
|
|
768
771
|
thickness: l,
|
|
769
|
-
indicator: { visible: !0, thickness:
|
|
772
|
+
indicator: { visible: !0, thickness: ce.gripThickness, length: ce.gripLength, barThickness: ce.barThickness, barLength: ce.barLength },
|
|
770
773
|
title: n.editViewSplitResize,
|
|
771
774
|
"aria-label": n.editViewSplitResize,
|
|
772
775
|
"aria-controls": e,
|
|
@@ -774,10 +777,10 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
|
|
|
774
777
|
className: "aqmx-split-handle aqmx-edit-split-handle"
|
|
775
778
|
}
|
|
776
779
|
),
|
|
777
|
-
/* @__PURE__ */
|
|
780
|
+
/* @__PURE__ */ M(ke, { id: cr, defaultSize: { value: 100 - f, unit: "percentage" }, minSize: Ne, maxSize: De, contentOverflow: "hidden" })
|
|
778
781
|
] })
|
|
779
782
|
] });
|
|
780
|
-
},
|
|
783
|
+
}, dr = 512, fr = () => {
|
|
781
784
|
const e = [];
|
|
782
785
|
let t = 0, n = null;
|
|
783
786
|
const o = (i) => {
|
|
@@ -798,42 +801,44 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
|
|
|
798
801
|
},
|
|
799
802
|
record: (i, r) => {
|
|
800
803
|
if (n === null) throw new Error("[markdown-explorer] a change of the editor's text was recorded before an editor mounted");
|
|
801
|
-
e.push({ before: n, changes: i }), n = r, e.length >
|
|
804
|
+
e.push({ before: n, changes: i }), n = r, e.length > dr && (e.shift(), t += 1);
|
|
802
805
|
},
|
|
803
806
|
lineOf: (i, r) => {
|
|
804
807
|
const l = o(i);
|
|
805
808
|
if (l === null || n === null || !Number.isInteger(r) || r < 1 || r > l.lines) return null;
|
|
806
809
|
let s = l.line(r).from;
|
|
807
810
|
for (const f of e.slice(i - t)) {
|
|
808
|
-
const d = f.changes.mapPos(s, 1,
|
|
811
|
+
const d = f.changes.mapPos(s, 1, Xt.TrackAfter);
|
|
809
812
|
if (d === null) return null;
|
|
810
813
|
s = d;
|
|
811
814
|
}
|
|
812
815
|
return n.lineAt(s).number;
|
|
813
816
|
}
|
|
814
817
|
};
|
|
815
|
-
},
|
|
818
|
+
}, mr = 144, pr = (e) => {
|
|
816
819
|
if (typeof e != "object" || e === null) return !1;
|
|
817
820
|
const { generation: t, topLine: n } = e;
|
|
818
821
|
return "state" in e && typeof t == "number" && typeof n == "number";
|
|
819
|
-
},
|
|
822
|
+
}, hr = (e) => {
|
|
820
823
|
e.stopPropagation();
|
|
821
|
-
},
|
|
822
|
-
const { path: t, name: n, session: o } = e, { edits: i, labels: r, announcer: l } =
|
|
824
|
+
}, Dr = (e) => {
|
|
825
|
+
const { path: t, name: n, session: o } = e, { edits: i, labels: r, announcer: l } = se(), { phase: s } = o, f = J(() => i.retry(t), [i, t]);
|
|
823
826
|
switch (Ve(() => {
|
|
824
|
-
s.kind
|
|
827
|
+
if (s.kind !== "failed") return;
|
|
828
|
+
const { reason: d } = s.failure;
|
|
829
|
+
He(d) || l.announce(r.documentFailed(n, Fe(r, d)));
|
|
825
830
|
}, [s, l, r, n]), s.kind) {
|
|
826
831
|
case "opening":
|
|
827
|
-
return /* @__PURE__ */
|
|
832
|
+
return /* @__PURE__ */ M(ht, { label: r.editLoading, testId: "markdown-explorer-edit-skeleton" });
|
|
828
833
|
case "grant":
|
|
829
|
-
return /* @__PURE__ */
|
|
834
|
+
return /* @__PURE__ */ M("div", { className: "aqmx-edit-message", children: /* @__PURE__ */ M(pt, { href: s.href, onRetry: f, testId: "markdown-explorer-edit-grant" }) });
|
|
830
835
|
case "failed":
|
|
831
|
-
return /* @__PURE__ */
|
|
836
|
+
return /* @__PURE__ */ M("div", { className: "aqmx-edit-message", children: /* @__PURE__ */ M(mt, { failure: s.failure, alert: !1, onRetry: f, testId: "markdown-explorer-edit-failure" }) });
|
|
832
837
|
case "editing":
|
|
833
|
-
return /* @__PURE__ */
|
|
838
|
+
return /* @__PURE__ */ M(gr, { ...e });
|
|
834
839
|
}
|
|
835
|
-
},
|
|
836
|
-
const { edits: s, labels: f } =
|
|
840
|
+
}, gr = ({ path: e, name: t, session: n, layout: o, viewer: i, region: r, paneScroll: l }) => {
|
|
841
|
+
const { edits: s, labels: f } = se(), d = N(null), b = rt(), w = N(null), [c] = oe(() => /* @__PURE__ */ new Set()), [v] = oe(fr), u = N(null), m = N(null), h = o === "fill", S = gt(), p = vt(n, S, h), x = p !== "editor" || n.previewPrepared, I = x && h, k = N({ layout: o, region: r, paneScroll: l });
|
|
837
842
|
D(() => {
|
|
838
843
|
k.current = { layout: o, region: r, paneScroll: l };
|
|
839
844
|
});
|
|
@@ -841,13 +846,13 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
|
|
|
841
846
|
D(() => {
|
|
842
847
|
R.current = n.generation;
|
|
843
848
|
});
|
|
844
|
-
const L = N({ view: p, previewMounted:
|
|
849
|
+
const L = N({ view: p, previewMounted: x });
|
|
845
850
|
D(() => {
|
|
846
|
-
L.current = { view: p, previewMounted:
|
|
851
|
+
L.current = { view: p, previewMounted: x };
|
|
847
852
|
});
|
|
848
|
-
const { requestSave: G, confirmation: B } =
|
|
853
|
+
const { requestSave: G, confirmation: B } = wt(e), F = N(G);
|
|
849
854
|
D(() => {
|
|
850
|
-
|
|
855
|
+
F.current = G;
|
|
851
856
|
});
|
|
852
857
|
const V = N(null), a = N(null), T = N(!1), A = Y(() => ({ editor: f.editorLabel(t), useOurs: f.conflictUseOurs, useTheirs: f.conflictUseTheirs, keepBoth: f.conflictKeepBoth }), [f, t]), g = J((y) => {
|
|
853
858
|
const { region: O, paneScroll: P } = k.current, H = O();
|
|
@@ -856,46 +861,46 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
|
|
|
856
861
|
D(() => {
|
|
857
862
|
const y = d.current, O = s.draft(e);
|
|
858
863
|
if (y === null || O === null) return;
|
|
859
|
-
const P = s.editorState.get(e), H =
|
|
864
|
+
const P = s.editorState.get(e), H = pr(P) && P.generation === R.current ? P : null;
|
|
860
865
|
let K = null, Q = null;
|
|
861
866
|
const fe = () => {
|
|
862
867
|
K !== null && clearTimeout(K), K = null, Q !== null && s.setDraft(e, Q.text());
|
|
863
|
-
}, W =
|
|
868
|
+
}, W = _n({
|
|
864
869
|
parent: y,
|
|
865
870
|
scroll: {
|
|
866
|
-
scrollerOf: (
|
|
867
|
-
const { layout: Z, region:
|
|
868
|
-
return Z === "fill" || be === null ?
|
|
871
|
+
scrollerOf: (q) => {
|
|
872
|
+
const { layout: Z, region: Qe, paneScroll: Ze } = k.current, be = Qe();
|
|
873
|
+
return Z === "fill" || be === null ? q : Ze.scrollerOf(be, q);
|
|
869
874
|
},
|
|
870
|
-
reveal: (
|
|
875
|
+
reveal: (q) => k.current.paneScroll.reveal(q)
|
|
871
876
|
},
|
|
872
877
|
text: O,
|
|
873
878
|
saved: H === null ? void 0 : H.state,
|
|
874
879
|
labels: A,
|
|
875
880
|
revisions: v,
|
|
876
|
-
onGeometry: (
|
|
877
|
-
onChange: (
|
|
878
|
-
if (K ??= setTimeout(fe,
|
|
881
|
+
onGeometry: (q) => m.current?.editorChanged(q),
|
|
882
|
+
onChange: (q) => {
|
|
883
|
+
if (K ??= setTimeout(fe, mr), !q)
|
|
879
884
|
for (const Z of [...c]) Z();
|
|
880
885
|
L.current.previewMounted && Q !== null && u.current?.draft({ text: Q.text(), revision: v.revision() });
|
|
881
886
|
},
|
|
882
|
-
onSave: () =>
|
|
887
|
+
onSave: () => F.current()
|
|
883
888
|
});
|
|
884
889
|
Q = W, w.current = W;
|
|
885
890
|
const ve = () => {
|
|
886
|
-
const
|
|
887
|
-
return { line:
|
|
888
|
-
}, we = () => u.current?.anchor(g) ?? null,
|
|
891
|
+
const q = W.topLine();
|
|
892
|
+
return { line: q.line, clientTop: q.clientTop };
|
|
893
|
+
}, we = () => u.current?.anchor(g) ?? null, Je = s.bindEditor(e, {
|
|
889
894
|
flush: fe,
|
|
890
|
-
adopt: (
|
|
895
|
+
adopt: (q) => W.replaceText(q),
|
|
891
896
|
returnPoint: () => {
|
|
892
|
-
const
|
|
893
|
-
return
|
|
897
|
+
const q = L.current.view === "preview" && k.current.layout === "content" ? we() : null;
|
|
898
|
+
return q === null ? ve() : { line: q.lines.first, clientTop: q.clientTop };
|
|
894
899
|
},
|
|
895
900
|
nextConflict: () => L.current.view !== "preview" ? W.nextConflict() : W.conflicts().length === 0 ? !1 : (T.current = !0, s.setView(e, "editor"), !0),
|
|
896
|
-
beforeView: (
|
|
901
|
+
beforeView: (q) => {
|
|
897
902
|
if (k.current.layout === "fill") return;
|
|
898
|
-
if (
|
|
903
|
+
if (q === "preview") {
|
|
899
904
|
V.current = { to: "preview", point: ve() };
|
|
900
905
|
return;
|
|
901
906
|
}
|
|
@@ -904,13 +909,13 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
|
|
|
904
909
|
}
|
|
905
910
|
});
|
|
906
911
|
return H !== null && W.showLine(H.topLine), () => {
|
|
907
|
-
fe(), s.editorState.set(e, { state: W.save(), generation: R.current, topLine: W.topLine().line }),
|
|
912
|
+
fe(), s.editorState.set(e, { state: W.save(), generation: R.current, topLine: W.topLine().line }), Je(), W.destroy(), Q = null, w.current = null;
|
|
908
913
|
};
|
|
909
914
|
}, [s, e, A, g, c, v]);
|
|
910
915
|
const { request: E } = n;
|
|
911
916
|
D(() => {
|
|
912
917
|
const y = w.current, O = s.draft(e);
|
|
913
|
-
y === null || O === null || E === null || (E.anchor !== null && y.reveal(
|
|
918
|
+
y === null || O === null || E === null || (E.anchor !== null && y.reveal(Se(O, E.anchor), E.anchor.clientTop), y.focus(), s.consumeRequest(e));
|
|
914
919
|
}, [s, e, E, A]), D(() => {
|
|
915
920
|
p !== "editor" && !n.previewPrepared && s.preparePreview(e);
|
|
916
921
|
}, [s, e, p, n.previewPrepared]), D(() => {
|
|
@@ -920,7 +925,7 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
|
|
|
920
925
|
if (y?.to === "preview") u.current?.place(y.point, g);
|
|
921
926
|
else if (y?.to === "editor" && H !== null) {
|
|
922
927
|
const K = s.draft(e);
|
|
923
|
-
K !== null && H.reveal(
|
|
928
|
+
K !== null && H.reveal(Se(K, y.anchor), y.anchor.clientTop);
|
|
924
929
|
}
|
|
925
930
|
P ? H?.nextConflict() : O === "editor" ? H?.focus() : O === "preview" && u.current?.focus();
|
|
926
931
|
}, [s, e, p, g]);
|
|
@@ -947,8 +952,8 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
|
|
|
947
952
|
D(() => {
|
|
948
953
|
const y = w.current;
|
|
949
954
|
if (!I || y === null) return;
|
|
950
|
-
const O =
|
|
951
|
-
editor:
|
|
955
|
+
const O = Jn({
|
|
956
|
+
editor: Xe(y.scrollElement),
|
|
952
957
|
preview: () => u.current?.scrollPort() ?? null,
|
|
953
958
|
previewBlocks: () => u.current?.blocks() ?? [],
|
|
954
959
|
editorSpans: (P) => y.lineSpans(P),
|
|
@@ -956,35 +961,35 @@ const ne = (e) => rt(e.iterLines()), Te = (e, t) => {
|
|
|
956
961
|
cancelFrame: (P) => cancelAnimationFrame(P),
|
|
957
962
|
now: () => performance.now()
|
|
958
963
|
});
|
|
959
|
-
return O.showAlone(
|
|
964
|
+
return O.showAlone(xe(L.current.view)), m.current = O, () => {
|
|
960
965
|
O.dispose(), m.current = null;
|
|
961
966
|
};
|
|
962
967
|
}, [I, s, e, A]), D(() => {
|
|
963
|
-
m.current?.showAlone(
|
|
968
|
+
m.current?.showAlone(xe(p));
|
|
964
969
|
}, [p]);
|
|
965
|
-
const X = J(() => m.current?.previewChanged(), []),
|
|
970
|
+
const X = J(() => m.current?.previewChanged(), []), z = J((y) => s.start(e, y), [s, e]), Ye = (
|
|
966
971
|
/* @__PURE__ */ re("div", { className: "aqmx-edit", "data-aqmx-edit-layout": o, "data-aqmx-edit-view": p, "data-testid": "markdown-explorer-edit", onKeyDown: (y) => {
|
|
967
|
-
if (
|
|
972
|
+
if (Et(y.target)) return;
|
|
968
973
|
if (y.key === "Escape") {
|
|
969
974
|
ye(y);
|
|
970
975
|
return;
|
|
971
976
|
}
|
|
972
|
-
if (!
|
|
977
|
+
if (!St(y.nativeEvent, xt(navigator.platform))) return;
|
|
973
978
|
ye(y);
|
|
974
|
-
const O =
|
|
975
|
-
a.current = O,
|
|
976
|
-
}, onDoubleClick:
|
|
977
|
-
/* @__PURE__ */
|
|
978
|
-
p === "split" ? /* @__PURE__ */
|
|
979
|
-
|
|
979
|
+
const O = kt(p);
|
|
980
|
+
a.current = O, yt(s, e, O, h);
|
|
981
|
+
}, onDoubleClick: hr, children: [
|
|
982
|
+
/* @__PURE__ */ M("div", { ref: d, id: b, className: "aqmx-edit-editor", "data-testid": "markdown-explorer-editor", inert: p === "preview", hidden: p === "preview" && !h, ...bt }),
|
|
983
|
+
p === "split" ? /* @__PURE__ */ M(ur, { editorId: b }) : null,
|
|
984
|
+
x ? /* @__PURE__ */ M(rr, { path: e, readDraft: U, viewer: i, tables: C, concealed: p !== "editor" ? null : h ? "overlay" : "removed", onEditAt: p === "preview" ? z : void 0, onLayout: X, handleRef: u }) : null
|
|
980
985
|
] })
|
|
981
986
|
);
|
|
982
|
-
return /* @__PURE__ */ re(
|
|
983
|
-
|
|
987
|
+
return /* @__PURE__ */ re(et, { children: [
|
|
988
|
+
Ye,
|
|
984
989
|
B
|
|
985
990
|
] });
|
|
986
991
|
};
|
|
987
992
|
export {
|
|
988
|
-
|
|
989
|
-
|
|
993
|
+
mr as DRAFT_WRITE_INTERVAL_MS,
|
|
994
|
+
Dr as default
|
|
990
995
|
};
|