@damiro/stylo 0.4.0 → 0.7.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/README.md +94 -10
- package/dist/{InPlaceView-Ba7JCZ2Y.js → InPlaceView-CS1qy-Ba.js} +277 -265
- package/dist/InPlaceView-CS1qy-Ba.js.map +1 -0
- package/dist/{Preview-Dxb9zPVv.js → Preview-Bw0k3Mev.js} +2 -2
- package/dist/{Preview-Dxb9zPVv.js.map → Preview-Bw0k3Mev.js.map} +1 -1
- package/dist/SplitView.d.ts +3 -2
- package/dist/SplitView.d.ts.map +1 -1
- package/dist/Stylo.d.ts.map +1 -1
- package/dist/editor/SourceView.d.ts +4 -2
- package/dist/editor/SourceView.d.ts.map +1 -1
- package/dist/editor/extensions.d.ts +2 -2
- package/dist/editor/extensions.d.ts.map +1 -1
- package/dist/editor/theme.d.ts.map +1 -1
- package/dist/editor/useCodeMirror.d.ts +4 -2
- package/dist/editor/useCodeMirror.d.ts.map +1 -1
- package/dist/editor/wikilink-complete.d.ts +15 -0
- package/dist/editor/wikilink-complete.d.ts.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/inplace/InPlaceView.d.ts +4 -2
- package/dist/inplace/InPlaceView.d.ts.map +1 -1
- package/dist/inplace/context-menu.d.ts +1 -1
- package/dist/inplace/context-menu.d.ts.map +1 -1
- package/dist/inplace/extension.d.ts.map +1 -1
- package/dist/inplace/menu-open.d.ts +11 -0
- package/dist/inplace/menu-open.d.ts.map +1 -0
- package/dist/inplace/menu-plugin.d.ts +1 -0
- package/dist/inplace/menu-plugin.d.ts.map +1 -1
- package/dist/inplace/selection-bar.d.ts.map +1 -1
- package/dist/inplace/theme.d.ts.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/stylo.js +58 -53
- package/dist/stylo.js.map +1 -1
- package/dist/types.d.ts +25 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/{useCodeMirror-YnIFkvKn.js → useCodeMirror-GPSkaYW6.js} +204 -168
- package/dist/useCodeMirror-GPSkaYW6.js.map +1 -0
- package/dist/wikilink-CTR8IFKc.js +42 -0
- package/dist/wikilink-CTR8IFKc.js.map +1 -0
- package/package.json +4 -1
- package/dist/InPlaceView-Ba7JCZ2Y.js.map +0 -1
- package/dist/useCodeMirror-YnIFkvKn.js.map +0 -1
- package/dist/wikilink-BFpTehto.js +0 -42
- package/dist/wikilink-BFpTehto.js.map +0 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { i as e, n as t, t as n } from "./wikilink-
|
|
2
|
-
import { _ as r, a as i, b as a, c as o, d as s, f as c, g as l, h as u, i as d, l as f, m as p, n as m, o as
|
|
1
|
+
import { i as e, n as t, t as n } from "./wikilink-CTR8IFKc.js";
|
|
2
|
+
import { _ as r, a as i, b as a, c as o, d as s, f as c, g as l, h as u, i as d, l as f, m as p, n as m, o as h, p as ee, r as te, s as ne, t as re, u as ie, v as ae, y as oe } from "./useCodeMirror-GPSkaYW6.js";
|
|
3
3
|
import { a as se, i as g } from "./config-DTBxVhtH.js";
|
|
4
4
|
import { t as ce } from "./katex-BfiLlqfN.js";
|
|
5
5
|
import { r as le, t as _ } from "./callout-oLE630ZP.js";
|
|
6
6
|
import { useRef as ue, useState as de } from "react";
|
|
7
7
|
import { Decoration as v, EditorView as y, ViewPlugin as b, WidgetType as x, hoverTooltip as fe, keymap as pe } from "@codemirror/view";
|
|
8
|
-
import { Annotation as me, EditorSelection as he, EditorState as ge, Facet as S, Prec as C, StateField as w } from "@codemirror/state";
|
|
8
|
+
import { Annotation as me, EditorSelection as he, EditorState as ge, Facet as S, Prec as C, StateEffect as _e, StateField as w } from "@codemirror/state";
|
|
9
9
|
import { syntaxTree as T } from "@codemirror/language";
|
|
10
|
-
import { jsx as
|
|
10
|
+
import { jsx as ve } from "react/jsx-runtime";
|
|
11
11
|
//#region src/inplace/config.ts
|
|
12
|
-
var
|
|
12
|
+
var ye = {
|
|
13
13
|
headings: !0,
|
|
14
14
|
emphasis: !0,
|
|
15
15
|
links: !0,
|
|
@@ -23,13 +23,13 @@ var ve = {
|
|
|
23
23
|
frontmatter: !0,
|
|
24
24
|
tables: !0
|
|
25
25
|
};
|
|
26
|
-
function
|
|
26
|
+
function be(e) {
|
|
27
27
|
return {
|
|
28
|
-
...
|
|
28
|
+
...ye,
|
|
29
29
|
...e?.decorations
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
var E = S.define({ combine: (e) => e[0] ??
|
|
32
|
+
var E = S.define({ combine: (e) => e[0] ?? ye }), D = S.define({ combine: (e) => e[0] ?? "source" }), O = S.define({ combine: (e) => e[0] ?? "caret" }), xe = S.define({ combine: (e) => e[0] ?? null }), k = S.define({ combine: (e) => e[0] ?? !0 }), A = [
|
|
33
33
|
"link",
|
|
34
34
|
"format",
|
|
35
35
|
"paragraph",
|
|
@@ -44,7 +44,7 @@ var E = S.define({ combine: (e) => e[0] ?? ve }), D = S.define({ combine: (e) =>
|
|
|
44
44
|
"wikilink",
|
|
45
45
|
"math"
|
|
46
46
|
];
|
|
47
|
-
function
|
|
47
|
+
function Se(e) {
|
|
48
48
|
return e === !1 ? {
|
|
49
49
|
enabled: !1,
|
|
50
50
|
groups: []
|
|
@@ -57,15 +57,15 @@ function xe(e) {
|
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
var M = S.define({ combine: (e) => e[0] ?? A });
|
|
60
|
-
function
|
|
60
|
+
function Ce(e) {
|
|
61
61
|
if (!e?.length) return j;
|
|
62
62
|
let t = e.filter((e) => j.includes(e));
|
|
63
63
|
return t.length ? t : j;
|
|
64
64
|
}
|
|
65
|
-
var
|
|
65
|
+
var we = S.define({ combine: (e) => e[0] ?? j }), N = S.define({ combine: (e) => e[0] ?? "menu" });
|
|
66
66
|
//#endregion
|
|
67
67
|
//#region src/inplace/frontmatter.ts
|
|
68
|
-
function
|
|
68
|
+
function Te(e) {
|
|
69
69
|
if (!e.facet(E).frontmatter) return v.none;
|
|
70
70
|
let n = t(e.doc);
|
|
71
71
|
if (!n) return v.none;
|
|
@@ -79,19 +79,19 @@ function we(e) {
|
|
|
79
79
|
}
|
|
80
80
|
return v.set(o, !0);
|
|
81
81
|
}
|
|
82
|
-
var
|
|
83
|
-
create:
|
|
84
|
-
update: (e, t) => t.docChanged || t.selection ?
|
|
82
|
+
var Ee = w.define({
|
|
83
|
+
create: Te,
|
|
84
|
+
update: (e, t) => t.docChanged || t.selection ? Te(t.state) : e,
|
|
85
85
|
provide: (e) => y.decorations.from(e)
|
|
86
86
|
});
|
|
87
87
|
//#endregion
|
|
88
88
|
//#region src/inplace/list-guides.ts
|
|
89
|
-
function
|
|
89
|
+
function De(e) {
|
|
90
90
|
let t = 1;
|
|
91
91
|
for (let n = e.node.parent; n; n = n.parent) n.name === "ListItem" && t++;
|
|
92
92
|
return t;
|
|
93
93
|
}
|
|
94
|
-
function
|
|
94
|
+
function Oe(e, t, n, r, i, a) {
|
|
95
95
|
if (!i.lists) return;
|
|
96
96
|
let o = /* @__PURE__ */ new Set();
|
|
97
97
|
n.iterate({
|
|
@@ -99,7 +99,7 @@ function De(e, t, n, r, i, a) {
|
|
|
99
99
|
to: t,
|
|
100
100
|
enter: (e) => {
|
|
101
101
|
if (e.name !== "ListItem") return;
|
|
102
|
-
let t =
|
|
102
|
+
let t = De(e) - 1;
|
|
103
103
|
if (t < 1) return;
|
|
104
104
|
let n = r.lineAt(e.from).number, i = e.node.getChild("BulletList") ?? e.node.getChild("OrderedList"), s = r.lineAt(i ? i.from - 1 : Math.min(e.to, r.length)).number;
|
|
105
105
|
for (let e = n; e <= s; e++) o.has(e) || (o.add(e), a.push(v.line({
|
|
@@ -121,7 +121,7 @@ function P(e) {
|
|
|
121
121
|
}
|
|
122
122
|
//#endregion
|
|
123
123
|
//#region src/inplace/scan.ts
|
|
124
|
-
var
|
|
124
|
+
var ke = /* @__PURE__ */ new Set([
|
|
125
125
|
"InlineCode",
|
|
126
126
|
"FencedCode",
|
|
127
127
|
"CodeBlock",
|
|
@@ -130,7 +130,7 @@ var Oe = /* @__PURE__ */ new Set([
|
|
|
130
130
|
function F(e, t) {
|
|
131
131
|
let n = e.resolveInner(t, 1);
|
|
132
132
|
for (;;) {
|
|
133
|
-
if (
|
|
133
|
+
if (ke.has(n.name)) return !0;
|
|
134
134
|
let e = n.parent;
|
|
135
135
|
if (!e) return !1;
|
|
136
136
|
n = e;
|
|
@@ -143,7 +143,7 @@ function I(e, t, n, r) {
|
|
|
143
143
|
}
|
|
144
144
|
//#endregion
|
|
145
145
|
//#region src/inplace/math.ts
|
|
146
|
-
var
|
|
146
|
+
var Ae = /(?<![\w$])\$(?!\s)([^\n$]+?)(?<!\s)\$(?![\w$])/g, je = /(?<![\w$])\$\$([^\n$]+?)\$\$(?![\w$])/g, Me = /(?<![\w$])\$\$([^]+?)\$\$/g, L = class extends x {
|
|
147
147
|
src;
|
|
148
148
|
block;
|
|
149
149
|
constructor(e, t) {
|
|
@@ -169,32 +169,32 @@ var ke = /(?<![\w$])\$(?!\s)([^\n$]+?)(?<!\s)\$(?![\w$])/g, Ae = /(?<![\w$])\$\$
|
|
|
169
169
|
return !1;
|
|
170
170
|
}
|
|
171
171
|
};
|
|
172
|
-
function
|
|
172
|
+
function Ne(e, t, n, r, i, a) {
|
|
173
173
|
let o = e.state.doc.sliceString(t, n);
|
|
174
174
|
if (!o.includes("$")) return;
|
|
175
175
|
let { doc: s } = e.state, c = [];
|
|
176
|
-
for (let e of o.matchAll(
|
|
176
|
+
for (let e of o.matchAll(je)) {
|
|
177
177
|
let n = (e[1] ?? "").trim(), o = t + (e.index ?? 0), l = o + (e[0] ?? "").length;
|
|
178
178
|
!n || F(i, o + 2) || (c.push([o, l]), !I(r, s, o, l) && a.push(v.replace({ widget: new L(n, !0) }).range(o, l)));
|
|
179
179
|
}
|
|
180
|
-
for (let e of o.matchAll(
|
|
180
|
+
for (let e of o.matchAll(Ae)) {
|
|
181
181
|
let n = (e[1] ?? "").trim(), o = t + (e.index ?? 0), l = o + (e[0] ?? "").length;
|
|
182
182
|
!n || F(i, o + 1) || c.some(([e, t]) => o >= e && l <= t) || I(r, s, o, l) || a.push(v.replace({ widget: new L(n, !1) }).range(o, l));
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
|
-
var
|
|
186
|
-
create:
|
|
185
|
+
var Pe = w.define({
|
|
186
|
+
create: Fe,
|
|
187
187
|
update(e, t) {
|
|
188
|
-
return t.docChanged || t.selection ?
|
|
188
|
+
return t.docChanged || t.selection ? Fe(t.state) : e;
|
|
189
189
|
},
|
|
190
190
|
provide: (e) => [y.decorations.from(e), y.atomicRanges.of((t) => t.state.field(e))]
|
|
191
191
|
});
|
|
192
|
-
function
|
|
192
|
+
function Fe(e) {
|
|
193
193
|
if (!e.facet(E).math) return v.none;
|
|
194
194
|
let t = e.doc.toString();
|
|
195
195
|
if (!t.includes("$$")) return v.none;
|
|
196
196
|
let n = [], r = P(e), i = T(e);
|
|
197
|
-
for (let a of t.matchAll(
|
|
197
|
+
for (let a of t.matchAll(Me)) {
|
|
198
198
|
let t = a[0] ?? "", o = (a[1] ?? "").trim();
|
|
199
199
|
if (!o || !t.includes("\n")) continue;
|
|
200
200
|
let s = a.index ?? 0, c = s + t.length, l = e.doc.lineAt(s), u = e.doc.lineAt(c), d = e.doc.sliceString(l.from, s).trim(), f = e.doc.sliceString(c, u.to).trim();
|
|
@@ -207,7 +207,7 @@ function Pe(e) {
|
|
|
207
207
|
}
|
|
208
208
|
//#endregion
|
|
209
209
|
//#region src/inplace/widgets.ts
|
|
210
|
-
var
|
|
210
|
+
var Ie = class extends x {
|
|
211
211
|
eq() {
|
|
212
212
|
return !0;
|
|
213
213
|
}
|
|
@@ -218,7 +218,7 @@ var Fe = class extends x {
|
|
|
218
218
|
ignoreEvent() {
|
|
219
219
|
return !1;
|
|
220
220
|
}
|
|
221
|
-
},
|
|
221
|
+
}, Le = class extends x {
|
|
222
222
|
eq() {
|
|
223
223
|
return !0;
|
|
224
224
|
}
|
|
@@ -229,7 +229,7 @@ var Fe = class extends x {
|
|
|
229
229
|
ignoreEvent() {
|
|
230
230
|
return !1;
|
|
231
231
|
}
|
|
232
|
-
},
|
|
232
|
+
}, Re = class extends x {
|
|
233
233
|
checked;
|
|
234
234
|
constructor(e) {
|
|
235
235
|
super(), this.checked = e;
|
|
@@ -251,7 +251,7 @@ var Fe = class extends x {
|
|
|
251
251
|
ignoreEvent() {
|
|
252
252
|
return !0;
|
|
253
253
|
}
|
|
254
|
-
},
|
|
254
|
+
}, ze = /^ATXHeading([1-6])$/, Be = /^SetextHeading([12])$/, Ve = /^[-*+]$/, He = {
|
|
255
255
|
StrongEmphasis: {
|
|
256
256
|
mark: "EmphasisMark",
|
|
257
257
|
className: "cm-inplace-strong",
|
|
@@ -273,10 +273,10 @@ var Fe = class extends x {
|
|
|
273
273
|
toggle: "code"
|
|
274
274
|
}
|
|
275
275
|
};
|
|
276
|
-
function
|
|
276
|
+
function Ue(e, t) {
|
|
277
277
|
let { doc: n, revealed: r, caretRevealed: i, out: a, toggles: o, fmEnd: s, quoteRevealed: c } = t;
|
|
278
278
|
if (e.to <= s) return !1;
|
|
279
|
-
let l =
|
|
279
|
+
let l = ze.exec(e.name);
|
|
280
280
|
if (l) {
|
|
281
281
|
if (o.headings) {
|
|
282
282
|
let t = n.lineAt(e.from);
|
|
@@ -293,7 +293,7 @@ function He(e, t) {
|
|
|
293
293
|
}
|
|
294
294
|
return;
|
|
295
295
|
}
|
|
296
|
-
let u =
|
|
296
|
+
let u = Be.exec(e.name);
|
|
297
297
|
if (u) {
|
|
298
298
|
if (o.headings) {
|
|
299
299
|
let t = n.lineAt(e.from);
|
|
@@ -312,7 +312,7 @@ function He(e, t) {
|
|
|
312
312
|
}
|
|
313
313
|
return;
|
|
314
314
|
}
|
|
315
|
-
let d =
|
|
315
|
+
let d = He[e.name];
|
|
316
316
|
if (d) {
|
|
317
317
|
if (!o[d.toggle]) return;
|
|
318
318
|
let t = e.node.getChildren(d.mark), i = t[0], s = t[t.length - 1], c = i && s && i !== s, l = c ? i.to : e.from, u = c ? s.from : e.to;
|
|
@@ -334,7 +334,7 @@ function He(e, t) {
|
|
|
334
334
|
if (e.name === "HorizontalRule") {
|
|
335
335
|
if (!o.horizontalRule) return !1;
|
|
336
336
|
let t = n.lineAt(e.from);
|
|
337
|
-
return i.has(t.number) || (a.push(v.line({ class: "cm-inplace-hr-line" }).range(t.from)), a.push(v.replace({ widget: new
|
|
337
|
+
return i.has(t.number) || (a.push(v.line({ class: "cm-inplace-hr-line" }).range(t.from)), a.push(v.replace({ widget: new Ie() }).range(t.from, t.to))), !1;
|
|
338
338
|
}
|
|
339
339
|
if (e.name === "Blockquote") {
|
|
340
340
|
if (o.blockquote) {
|
|
@@ -368,13 +368,13 @@ function He(e, t) {
|
|
|
368
368
|
}
|
|
369
369
|
if (e.name === "ListMark") {
|
|
370
370
|
let t = n.sliceString(e.from, e.to), i = n.lineAt(e.from), s = e.node.parent, c = !!(s?.getChild("Task") ?? s?.getChild("TaskMarker"));
|
|
371
|
-
return r.has(i.number) || (c ? o.tasks && a.push(v.replace({}).range(e.from, Math.min(e.to + 1, i.to))) : o.lists &&
|
|
371
|
+
return r.has(i.number) || (c ? o.tasks && a.push(v.replace({}).range(e.from, Math.min(e.to + 1, i.to))) : o.lists && Ve.test(t) && a.push(v.replace({ widget: new Le() }).range(e.from, e.to))), !1;
|
|
372
372
|
}
|
|
373
373
|
if (e.name === "TaskMarker") {
|
|
374
374
|
if (!o.tasks) return !1;
|
|
375
375
|
if (!r.has(n.lineAt(e.from).number)) {
|
|
376
376
|
let t = n.sliceString(e.from + 1, e.to - 1).toLowerCase() === "x";
|
|
377
|
-
a.push(v.replace({ widget: new
|
|
377
|
+
a.push(v.replace({ widget: new Re(t) }).range(e.from, e.to));
|
|
378
378
|
}
|
|
379
379
|
return !1;
|
|
380
380
|
}
|
|
@@ -394,7 +394,7 @@ function He(e, t) {
|
|
|
394
394
|
}
|
|
395
395
|
//#endregion
|
|
396
396
|
//#region src/inplace/wikilinks.ts
|
|
397
|
-
function
|
|
397
|
+
function We(e, t, r, i, a, o) {
|
|
398
398
|
let s = e.state.doc.sliceString(t, r);
|
|
399
399
|
if (s.includes("[[")) for (let r of s.matchAll(n)) {
|
|
400
400
|
let [n = "", s = "", c] = r, l = s.trim(), u = t + (r.index ?? 0);
|
|
@@ -408,9 +408,9 @@ function Ue(e, t, r, i, a, o) {
|
|
|
408
408
|
}
|
|
409
409
|
//#endregion
|
|
410
410
|
//#region src/inplace/decorate.ts
|
|
411
|
-
var
|
|
412
|
-
function
|
|
413
|
-
let n = [], r = P(e.state), i = e.state.facet(O) === "never" ?
|
|
411
|
+
var Ge = /* @__PURE__ */ new Set(), Ke = v.replace({});
|
|
412
|
+
function qe(e) {
|
|
413
|
+
let n = [], r = P(e.state), i = e.state.facet(O) === "never" ? Ge : r, a = T(e.state), { doc: o } = e.state, s = e.state.facet(E), c = {
|
|
414
414
|
doc: o,
|
|
415
415
|
revealed: i,
|
|
416
416
|
caretRevealed: r,
|
|
@@ -422,8 +422,8 @@ function Ke(e) {
|
|
|
422
422
|
for (let t of e.visibleRanges) a.iterate({
|
|
423
423
|
from: t.from,
|
|
424
424
|
to: t.to,
|
|
425
|
-
enter: (e) =>
|
|
426
|
-
}), s.wikilinks &&
|
|
425
|
+
enter: (e) => Ue(e, c)
|
|
426
|
+
}), s.wikilinks && We(e, t.from, t.to, i, a, n), s.math && Ne(e, t.from, t.to, r, a, n), Oe(t.from, t.to, a, o, s, n);
|
|
427
427
|
let l = n.filter((e) => e.from < e.to && !e.value.spec.class).sort((e, t) => e.from - t.from || e.to - t.to), u = [];
|
|
428
428
|
for (let e of l) {
|
|
429
429
|
if (!e.value.spec.widget) {
|
|
@@ -431,7 +431,7 @@ function Ke(e) {
|
|
|
431
431
|
if (e.from === t.from && e.to === t.to) continue;
|
|
432
432
|
}
|
|
433
433
|
let t = u[u.length - 1];
|
|
434
|
-
t && e.from <= t.to ? e.to > t.to && (u[u.length - 1] =
|
|
434
|
+
t && e.from <= t.to ? e.to > t.to && (u[u.length - 1] = Ke.range(t.from, e.to)) : u.push(Ke.range(e.from, e.to));
|
|
435
435
|
}
|
|
436
436
|
return {
|
|
437
437
|
decorations: v.set(n, !0),
|
|
@@ -444,12 +444,12 @@ var R = b.fromClass(class {
|
|
|
444
444
|
decorations;
|
|
445
445
|
atomic;
|
|
446
446
|
constructor(e) {
|
|
447
|
-
let t =
|
|
447
|
+
let t = qe(e);
|
|
448
448
|
this.decorations = t.decorations, this.atomic = t.atomic;
|
|
449
449
|
}
|
|
450
450
|
update(e) {
|
|
451
451
|
if (e.docChanged || e.viewportChanged || e.selectionSet) {
|
|
452
|
-
let t =
|
|
452
|
+
let t = qe(e.view);
|
|
453
453
|
this.decorations = t.decorations, this.atomic = t.atomic;
|
|
454
454
|
}
|
|
455
455
|
}
|
|
@@ -457,12 +457,12 @@ var R = b.fromClass(class {
|
|
|
457
457
|
decorations: (e) => e.decorations,
|
|
458
458
|
provide: (e) => y.atomicRanges.of((t) => t.plugin(e)?.atomic ?? v.none)
|
|
459
459
|
});
|
|
460
|
-
function
|
|
460
|
+
function Je() {
|
|
461
461
|
return R;
|
|
462
462
|
}
|
|
463
463
|
//#endregion
|
|
464
464
|
//#region src/inplace/edit-boundaries.ts
|
|
465
|
-
var
|
|
465
|
+
var Ye = {
|
|
466
466
|
StrongEmphasis: {
|
|
467
467
|
markType: "EmphasisMark",
|
|
468
468
|
toggle: "emphasis"
|
|
@@ -483,7 +483,7 @@ var Je = {
|
|
|
483
483
|
function z(e, t) {
|
|
484
484
|
return e.facet(O) === "never" || !P(e).has(t);
|
|
485
485
|
}
|
|
486
|
-
function
|
|
486
|
+
function Xe(e, t, n) {
|
|
487
487
|
let r = e.plugin(R)?.decorations;
|
|
488
488
|
if (!r) return t;
|
|
489
489
|
let i = n < 0 ? 0 : e.state.doc.length, a = t;
|
|
@@ -497,7 +497,7 @@ function B(e, t, r = !1, i = !1) {
|
|
|
497
497
|
if (!i && !z(e, a.number)) return null;
|
|
498
498
|
let o = e.facet(E), s = T(e);
|
|
499
499
|
for (let n of [-1, 1]) for (let i = s.resolveInner(t, n); i; i = i.parent) {
|
|
500
|
-
let t =
|
|
500
|
+
let t = Ye[i.name];
|
|
501
501
|
if (t) {
|
|
502
502
|
if (!o[t.toggle]) break;
|
|
503
503
|
let e = i.getChildren(t.markType), n = e[0], r = e[e.length - 1];
|
|
@@ -537,13 +537,13 @@ function B(e, t, r = !1, i = !1) {
|
|
|
537
537
|
}
|
|
538
538
|
return null;
|
|
539
539
|
}
|
|
540
|
-
var
|
|
540
|
+
var Ze = (e) => (t) => {
|
|
541
541
|
if (o(t)) return !1;
|
|
542
542
|
let n = t.state.selection.main;
|
|
543
543
|
if (!n.empty) return !1;
|
|
544
544
|
let { state: r } = t;
|
|
545
545
|
if (!z(r, r.doc.lineAt(n.head).number)) return !1;
|
|
546
|
-
let i =
|
|
546
|
+
let i = Xe(t, n.head, e);
|
|
547
547
|
if (i === n.head) return !1;
|
|
548
548
|
let a = r.doc;
|
|
549
549
|
if (e < 0 ? i <= 0 : i >= a.length) return !0;
|
|
@@ -559,8 +559,8 @@ var Xe = (e) => (t) => {
|
|
|
559
559
|
userEvent: e < 0 ? "delete.backward" : "delete.forward",
|
|
560
560
|
scrollIntoView: !0
|
|
561
561
|
}), !0;
|
|
562
|
-
},
|
|
563
|
-
function
|
|
562
|
+
}, Qe = Ze(-1), $e = Ze(1);
|
|
563
|
+
function et(e, t, n) {
|
|
564
564
|
if (n <= t) return !1;
|
|
565
565
|
let r = e.plugin(R)?.decorations;
|
|
566
566
|
if (!r) return !1;
|
|
@@ -574,50 +574,50 @@ var V = (e, t) => (n) => {
|
|
|
574
574
|
let r = n.state.selection.main;
|
|
575
575
|
if (!t && !r.empty || !z(n.state, n.state.doc.lineAt(r.head).number)) return !1;
|
|
576
576
|
let i = n.moveByChar(r, e);
|
|
577
|
-
if (
|
|
577
|
+
if (et(n, Math.min(r.head, i.head), Math.max(r.head, i.head)) && (i = n.moveByChar(i, e)), i.head === r.head) return !1;
|
|
578
578
|
let a = t ? he.range(r.anchor, i.head) : he.cursor(i.head);
|
|
579
579
|
return n.dispatch({
|
|
580
580
|
selection: a,
|
|
581
581
|
userEvent: "select"
|
|
582
582
|
}), !0;
|
|
583
|
-
},
|
|
583
|
+
}, tt = V(!1, !1), nt = V(!0, !1), rt = V(!1, !0), it = V(!0, !0), at = C.high(pe.of([
|
|
584
584
|
{
|
|
585
585
|
key: "Backspace",
|
|
586
|
-
run:
|
|
586
|
+
run: Qe
|
|
587
587
|
},
|
|
588
588
|
{
|
|
589
589
|
key: "Delete",
|
|
590
|
-
run:
|
|
590
|
+
run: $e
|
|
591
591
|
},
|
|
592
592
|
{
|
|
593
593
|
key: "ArrowLeft",
|
|
594
|
-
run:
|
|
594
|
+
run: tt
|
|
595
595
|
},
|
|
596
596
|
{
|
|
597
597
|
key: "ArrowRight",
|
|
598
|
-
run:
|
|
598
|
+
run: nt
|
|
599
599
|
},
|
|
600
600
|
{
|
|
601
601
|
key: "Shift-ArrowLeft",
|
|
602
|
-
run:
|
|
602
|
+
run: rt
|
|
603
603
|
},
|
|
604
604
|
{
|
|
605
605
|
key: "Shift-ArrowRight",
|
|
606
|
-
run:
|
|
606
|
+
run: it
|
|
607
607
|
}
|
|
608
|
-
])),
|
|
608
|
+
])), ot = (e) => e === "h1" || e === "h2" || e === "h3" ? g.heading : g[e], st = [
|
|
609
609
|
"bold",
|
|
610
610
|
"italic",
|
|
611
611
|
"strike"
|
|
612
|
-
],
|
|
612
|
+
], ct = ["code", "math"], lt = [
|
|
613
613
|
"bulletList",
|
|
614
614
|
"orderedList",
|
|
615
615
|
"task"
|
|
616
|
-
],
|
|
616
|
+
], ut = [
|
|
617
617
|
"h1",
|
|
618
618
|
"h2",
|
|
619
619
|
"h3"
|
|
620
|
-
],
|
|
620
|
+
], dt = ["table", "hr"], ft = [
|
|
621
621
|
"codeBlock",
|
|
622
622
|
"mathBlock",
|
|
623
623
|
"frontmatter"
|
|
@@ -628,11 +628,11 @@ function H(e) {
|
|
|
628
628
|
let { from: n, to: r } = u(t);
|
|
629
629
|
return r > n;
|
|
630
630
|
}
|
|
631
|
-
var
|
|
631
|
+
var pt = (e, t, n = !1) => {
|
|
632
632
|
let r = m[t];
|
|
633
633
|
return r ? {
|
|
634
634
|
label: r.title,
|
|
635
|
-
icon:
|
|
635
|
+
icon: ot(t),
|
|
636
636
|
active: !n && !!r.isActive?.(e.state),
|
|
637
637
|
disabled: !n && !!r.disabled?.(e.state),
|
|
638
638
|
onSelect: () => {
|
|
@@ -642,7 +642,7 @@ var ft = (e, t, n = !1) => {
|
|
|
642
642
|
}, U = (e, t, n = !1, r = !1) => {
|
|
643
643
|
let i = [];
|
|
644
644
|
for (let a of t) {
|
|
645
|
-
let t =
|
|
645
|
+
let t = pt(e, a, r);
|
|
646
646
|
t && !(n && t.disabled) && i.push(t);
|
|
647
647
|
}
|
|
648
648
|
return i;
|
|
@@ -681,11 +681,11 @@ var ft = (e, t, n = !1) => {
|
|
|
681
681
|
onSelect: () => {}
|
|
682
682
|
}
|
|
683
683
|
];
|
|
684
|
-
},
|
|
684
|
+
}, mt = (e) => {
|
|
685
685
|
let t = e.trim().replace(/^<([^]*)>$/, "$1");
|
|
686
686
|
return /[\s()]/.test(t) ? `<${t.replace(/[<>]/g, "")}>` : t;
|
|
687
|
-
},
|
|
688
|
-
function
|
|
687
|
+
}, ht = (e) => e.replace(/^<([^]*)>$/, "$1");
|
|
688
|
+
function gt(e, t) {
|
|
689
689
|
let n = e.doc.lineAt(t.from);
|
|
690
690
|
if (e.doc.lineAt(t.to).number !== n.number) return null;
|
|
691
691
|
let r = t.from - n.from, i = t.to - n.from, a = ae(n.text, r) ?? ae(n.text, i);
|
|
@@ -704,7 +704,7 @@ function ht(e, t) {
|
|
|
704
704
|
function G(e) {
|
|
705
705
|
let { state: t } = e, n = t.selection.main, r = t.doc.lineAt(n.head), i = ae(r.text, n.head - r.from);
|
|
706
706
|
if (i) {
|
|
707
|
-
let n = r.from + i.from, a = r.from + i.to, o = r.from + i.urlFrom, s = r.from + i.urlTo, c = t.facet(
|
|
707
|
+
let n = r.from + i.from, a = r.from + i.to, o = r.from + i.urlFrom, s = r.from + i.urlTo, c = t.facet(xe), l = [];
|
|
708
708
|
return c && i.url && l.push({
|
|
709
709
|
label: "Open link",
|
|
710
710
|
icon: g.link,
|
|
@@ -728,19 +728,19 @@ function G(e) {
|
|
|
728
728
|
field: !0,
|
|
729
729
|
label: "Edit external link",
|
|
730
730
|
icon: g.link,
|
|
731
|
-
value:
|
|
731
|
+
value: ht(i.url),
|
|
732
732
|
placeholder: "https://…",
|
|
733
733
|
onSubmit: (t) => {
|
|
734
734
|
e.dispatch({ changes: {
|
|
735
735
|
from: o,
|
|
736
736
|
to: s,
|
|
737
|
-
insert:
|
|
737
|
+
insert: mt(t)
|
|
738
738
|
} }), e.focus();
|
|
739
739
|
},
|
|
740
740
|
actions: l
|
|
741
741
|
};
|
|
742
742
|
}
|
|
743
|
-
let a =
|
|
743
|
+
let a = gt(t, n), o = a ? a.from : n.from, s = a ? a.to : n.to, c = (a ? a.text : t.sliceDoc(n.from, n.to)) || "link";
|
|
744
744
|
return {
|
|
745
745
|
field: !0,
|
|
746
746
|
label: "Add external link",
|
|
@@ -752,7 +752,7 @@ function G(e) {
|
|
|
752
752
|
changes: {
|
|
753
753
|
from: o,
|
|
754
754
|
to: s,
|
|
755
|
-
insert: `[${c}](${
|
|
755
|
+
insert: `[${c}](${mt(t)})`
|
|
756
756
|
},
|
|
757
757
|
selection: {
|
|
758
758
|
anchor: o + 1,
|
|
@@ -762,7 +762,7 @@ function G(e) {
|
|
|
762
762
|
}
|
|
763
763
|
};
|
|
764
764
|
}
|
|
765
|
-
function
|
|
765
|
+
function _t(e) {
|
|
766
766
|
let { state: t } = e, n = t.selection.main, r = t.doc.lineAt(n.head), i = a(r.text, n.head - r.from);
|
|
767
767
|
if (i) {
|
|
768
768
|
let t = r.from + i.from, n = r.from + i.to, a = r.from + i.targetFrom, o = r.from + i.targetTo, s = i.label || i.target;
|
|
@@ -797,7 +797,7 @@ function gt(e) {
|
|
|
797
797
|
}]
|
|
798
798
|
};
|
|
799
799
|
}
|
|
800
|
-
let o =
|
|
800
|
+
let o = gt(t, n), s = o ? o.from : n.from, c = o ? o.to : n.to, l = o ? o.text : t.sliceDoc(n.from, n.to);
|
|
801
801
|
return {
|
|
802
802
|
field: !0,
|
|
803
803
|
label: "Add link",
|
|
@@ -826,8 +826,8 @@ var K = (e, t, n, r = !1) => ({
|
|
|
826
826
|
rows: n,
|
|
827
827
|
disabled: r
|
|
828
828
|
});
|
|
829
|
-
function
|
|
830
|
-
let t =
|
|
829
|
+
function vt(e) {
|
|
830
|
+
let t = h(e.state);
|
|
831
831
|
return {
|
|
832
832
|
field: !0,
|
|
833
833
|
label: "Language",
|
|
@@ -849,47 +849,47 @@ function _t(e) {
|
|
|
849
849
|
}]
|
|
850
850
|
};
|
|
851
851
|
}
|
|
852
|
-
var
|
|
853
|
-
...U(e,
|
|
852
|
+
var yt = (e, t = !1) => [
|
|
853
|
+
...U(e, st, !1, t),
|
|
854
854
|
"separator",
|
|
855
|
-
...U(e,
|
|
855
|
+
...U(e, ct, !1, t)
|
|
856
856
|
];
|
|
857
|
-
function
|
|
857
|
+
function bt(e) {
|
|
858
858
|
let t = e.state.facet(M), n = [];
|
|
859
|
-
return t.includes("format") && q(n, [K("Format", g.format,
|
|
859
|
+
return t.includes("format") && q(n, [K("Format", g.format, yt(e, !0))]), t.includes("clipboard") && q(n, W(e)), n;
|
|
860
860
|
}
|
|
861
|
-
var
|
|
862
|
-
...U(e,
|
|
861
|
+
var xt = (e) => [
|
|
862
|
+
...U(e, lt),
|
|
863
863
|
"separator",
|
|
864
|
-
...U(e, [...
|
|
864
|
+
...U(e, [...ut, "body"]),
|
|
865
865
|
"separator",
|
|
866
866
|
...U(e, ["quote"])
|
|
867
|
-
],
|
|
868
|
-
...U(e,
|
|
867
|
+
], St = (e) => [
|
|
868
|
+
...U(e, dt),
|
|
869
869
|
"separator",
|
|
870
|
-
...U(e,
|
|
870
|
+
...U(e, ft)
|
|
871
871
|
];
|
|
872
872
|
function q(e, t) {
|
|
873
873
|
t.length && (e.length && e.push("separator"), e.push(...t));
|
|
874
874
|
}
|
|
875
|
-
function
|
|
875
|
+
function Ct(e) {
|
|
876
876
|
let { state: t } = e, n = t.facet(M), r = (e) => n.includes(e);
|
|
877
|
-
if (H(e)) return
|
|
877
|
+
if (H(e)) return bt(e);
|
|
878
878
|
if (ne(t)) {
|
|
879
|
-
let t = [
|
|
879
|
+
let t = [vt(e)];
|
|
880
880
|
return r("clipboard") && q(t, W(e)), t;
|
|
881
881
|
}
|
|
882
882
|
let i = t.selection.main, a = t.doc.lineAt(i.head).text.trim() === "", o = !i.empty || !!t.wordAt(i.head), s = t.facet(N) === "menu", c = [];
|
|
883
|
-
for (let t of n) t === "link" && s ? q(c, [
|
|
883
|
+
for (let t of n) t === "link" && s ? q(c, [_t(e), G(e)]) : t === "format" && s ? q(c, [K("Format", g.format, yt(e), !o)]) : t === "paragraph" ? q(c, [K("Paragraph", g.paragraph, xt(e))]) : t === "insert" ? q(c, [K("Insert", g.insert, St(e), !a)]) : t === "clipboard" && q(c, W(e));
|
|
884
884
|
return c;
|
|
885
885
|
}
|
|
886
886
|
//#endregion
|
|
887
887
|
//#region src/inplace/inline-md.ts
|
|
888
|
-
function
|
|
888
|
+
function wt(e) {
|
|
889
889
|
let t = document.createDocumentFragment();
|
|
890
|
-
return
|
|
890
|
+
return Et(t, e), t;
|
|
891
891
|
}
|
|
892
|
-
var
|
|
892
|
+
var Tt = [
|
|
893
893
|
{
|
|
894
894
|
re: /`([^`\n]+)`/,
|
|
895
895
|
build: (e) => J("code", "cm-inplace-code", document.createTextNode(e[1]))
|
|
@@ -938,12 +938,12 @@ function J(e, t, ...n) {
|
|
|
938
938
|
}
|
|
939
939
|
function Y(e) {
|
|
940
940
|
let t = document.createDocumentFragment();
|
|
941
|
-
return
|
|
941
|
+
return Et(t, e), t;
|
|
942
942
|
}
|
|
943
|
-
function
|
|
943
|
+
function Et(e, t) {
|
|
944
944
|
for (; t;) {
|
|
945
945
|
let n = -1, r = null;
|
|
946
|
-
for (let e of
|
|
946
|
+
for (let e of Tt) {
|
|
947
947
|
let i = e.re.exec(t);
|
|
948
948
|
i && (n < 0 || i.index < n) && (n = i.index, r = {
|
|
949
949
|
rule: e,
|
|
@@ -959,7 +959,7 @@ function Tt(e, t) {
|
|
|
959
959
|
}
|
|
960
960
|
//#endregion
|
|
961
961
|
//#region src/inplace/long-press.ts
|
|
962
|
-
function
|
|
962
|
+
function Dt(e, t) {
|
|
963
963
|
let n = t.delay ?? 450, r = t.slop ?? 20, i = null, a = 0, o = 0, s = () => {
|
|
964
964
|
i != null && (clearTimeout(i), i = null);
|
|
965
965
|
}, c = (e) => {
|
|
@@ -981,41 +981,41 @@ function Et(e, t) {
|
|
|
981
981
|
}
|
|
982
982
|
//#endregion
|
|
983
983
|
//#region src/inplace/context-menu.ts
|
|
984
|
-
var
|
|
985
|
-
function X(e, t = "cm-inplace-menu") {
|
|
986
|
-
let
|
|
987
|
-
|
|
988
|
-
let
|
|
989
|
-
|
|
990
|
-
},
|
|
991
|
-
|
|
992
|
-
},
|
|
984
|
+
var Ot = (e) => typeof e != "string" && "rows" in e, kt = (e) => typeof e != "string" && "field" in e;
|
|
985
|
+
function X(e, t = "cm-inplace-menu", n) {
|
|
986
|
+
let r = e.defaultView, i = e.createElement("div");
|
|
987
|
+
i.className = t, i.setAttribute("contenteditable", "false"), i.hidden = !0;
|
|
988
|
+
let a = null, o = null, s = () => {
|
|
989
|
+
a?.remove(), a = null;
|
|
990
|
+
}, c = () => {
|
|
991
|
+
i.hidden || (s(), i.hidden = !0, i.replaceChildren(), o?.(), o = null, n?.(!1));
|
|
992
|
+
}, l = (e) => e.addEventListener("mousedown", (e) => {
|
|
993
993
|
e.preventDefault(), e.stopPropagation();
|
|
994
|
-
}),
|
|
994
|
+
}), u = (t, n, r) => {
|
|
995
995
|
r && t.appendChild(se(e, r));
|
|
996
996
|
let i = e.createElement("span");
|
|
997
997
|
i.textContent = n, t.appendChild(i);
|
|
998
|
-
},
|
|
998
|
+
}, d = (n) => {
|
|
999
999
|
let r = e.createElement("button");
|
|
1000
|
-
return r.type = "button", r.className = `${t}-item`,
|
|
1001
|
-
r.closest(`.${t}-panel[data-for]`) ||
|
|
1000
|
+
return r.type = "button", r.className = `${t}-item`, u(r, n.label, n.icon), n.title && (r.title = n.title), n.active && (r.dataset.active = ""), n.disabled ? r.disabled = !0 : (l(r), r.addEventListener("pointerenter", () => {
|
|
1001
|
+
r.closest(`.${t}-panel[data-for]`) || s();
|
|
1002
1002
|
}), r.addEventListener("click", (e) => {
|
|
1003
|
-
e.stopPropagation(),
|
|
1003
|
+
e.stopPropagation(), c(), n.onSelect();
|
|
1004
1004
|
})), r;
|
|
1005
|
-
},
|
|
1005
|
+
}, f = (n, r, o, c = !1) => {
|
|
1006
1006
|
let d = e.createElement("button");
|
|
1007
|
-
if (d.type = "button", d.className = `${t}-item ${t}-parent`,
|
|
1008
|
-
|
|
1007
|
+
if (d.type = "button", d.className = `${t}-item ${t}-parent`, u(d, n, r), c) return d.disabled = !0, d;
|
|
1008
|
+
l(d);
|
|
1009
1009
|
let f = () => {
|
|
1010
|
-
if (
|
|
1011
|
-
|
|
1012
|
-
let e =
|
|
1013
|
-
e.dataset.for = n,
|
|
1010
|
+
if (a?.dataset.for === n) return;
|
|
1011
|
+
s();
|
|
1012
|
+
let e = o();
|
|
1013
|
+
e.dataset.for = n, i.appendChild(e), ee(e, d.getBoundingClientRect()), a = e, e.querySelector("input")?.focus({ preventScroll: !0 });
|
|
1014
1014
|
};
|
|
1015
1015
|
return d.addEventListener("pointerenter", f), d.addEventListener("click", (e) => {
|
|
1016
1016
|
e.stopPropagation(), f();
|
|
1017
1017
|
}), d;
|
|
1018
|
-
},
|
|
1018
|
+
}, p = (n) => {
|
|
1019
1019
|
let r = e.createElement("div");
|
|
1020
1020
|
r.className = `${t}-panel`;
|
|
1021
1021
|
let i = e.createElement("input");
|
|
@@ -1023,64 +1023,64 @@ function X(e, t = "cm-inplace-menu") {
|
|
|
1023
1023
|
if (e.key !== "Enter") return;
|
|
1024
1024
|
e.preventDefault();
|
|
1025
1025
|
let t = i.value.trim();
|
|
1026
|
-
|
|
1026
|
+
c(), n.onSubmit(t);
|
|
1027
1027
|
}), r.appendChild(i);
|
|
1028
|
-
for (let e of n.actions ?? []) r.appendChild(
|
|
1028
|
+
for (let e of n.actions ?? []) r.appendChild(d(e));
|
|
1029
1029
|
return r;
|
|
1030
|
-
},
|
|
1030
|
+
}, m = (n) => {
|
|
1031
1031
|
let r = e.createElement("div");
|
|
1032
1032
|
r.className = `${t}-panel`;
|
|
1033
1033
|
for (let i of n) if (i === "separator") {
|
|
1034
1034
|
let n = e.createElement("div");
|
|
1035
1035
|
n.className = `${t}-sep`, r.appendChild(n);
|
|
1036
|
-
} else
|
|
1036
|
+
} else Ot(i) ? r.appendChild(f(i.label, i.icon, () => m(i.rows), i.disabled)) : kt(i) ? r.appendChild(f(i.label, i.icon, () => p(i))) : r.appendChild(d(i));
|
|
1037
1037
|
return r;
|
|
1038
|
-
},
|
|
1039
|
-
let i =
|
|
1038
|
+
}, h = (e, t, n) => {
|
|
1039
|
+
let i = r?.innerWidth ?? 0, a = r?.innerHeight ?? 0;
|
|
1040
1040
|
e.style.left = "0", e.style.top = "0";
|
|
1041
1041
|
let { width: o, height: s } = e.getBoundingClientRect();
|
|
1042
|
-
e.style.left = `${Math.max(4, Math.min(t, i - o - 4))}px`, e.style.top = `${Math.max(4, Math.min(
|
|
1042
|
+
e.style.left = `${Math.max(4, Math.min(t, i - o - 4))}px`, e.style.top = `${Math.max(4, Math.min(n, a - s - 4))}px`;
|
|
1043
1043
|
}, ee = (e, t) => {
|
|
1044
|
-
let
|
|
1044
|
+
let n = r?.innerWidth ?? 0, i = r?.innerHeight ?? 0;
|
|
1045
1045
|
e.style.left = "0", e.style.top = "0";
|
|
1046
|
-
let { width: a, height: o } = e.getBoundingClientRect(), s = t.right - 4, c = s + a >
|
|
1046
|
+
let { width: a, height: o } = e.getBoundingClientRect(), s = t.right - 4, c = s + a > n - 4 ? t.left - a + 4 : s;
|
|
1047
1047
|
e.style.left = `${Math.max(4, c)}px`, e.style.top = `${Math.max(4, Math.min(t.top - 4, i - o - 4))}px`;
|
|
1048
|
-
},
|
|
1049
|
-
let t = Date.now(), n = (e) => !
|
|
1050
|
-
n(e) &&
|
|
1051
|
-
},
|
|
1052
|
-
e.key === "Escape" &&
|
|
1053
|
-
},
|
|
1054
|
-
Date.now() - t < 350 || n(e) &&
|
|
1048
|
+
}, te = () => {
|
|
1049
|
+
let t = Date.now(), n = (e) => !i.contains(e.target), r = (e) => {
|
|
1050
|
+
n(e) && c();
|
|
1051
|
+
}, a = (e) => {
|
|
1052
|
+
e.key === "Escape" && c();
|
|
1053
|
+
}, s = (e) => {
|
|
1054
|
+
Date.now() - t < 350 || n(e) && c();
|
|
1055
1055
|
};
|
|
1056
|
-
e.addEventListener("pointerdown",
|
|
1057
|
-
e.removeEventListener("pointerdown",
|
|
1056
|
+
e.addEventListener("pointerdown", r, !0), e.addEventListener("mousedown", r, !0), e.addEventListener("keydown", a, !0), e.addEventListener("scroll", s, !0), o = () => {
|
|
1057
|
+
e.removeEventListener("pointerdown", r, !0), e.removeEventListener("mousedown", r, !0), e.removeEventListener("keydown", a, !0), e.removeEventListener("scroll", s, !0);
|
|
1058
1058
|
};
|
|
1059
1059
|
};
|
|
1060
1060
|
return {
|
|
1061
|
-
el:
|
|
1061
|
+
el: i,
|
|
1062
1062
|
get isOpen() {
|
|
1063
|
-
return !
|
|
1063
|
+
return !i.hidden;
|
|
1064
1064
|
},
|
|
1065
|
-
show: (e, t,
|
|
1066
|
-
|
|
1067
|
-
let
|
|
1068
|
-
|
|
1065
|
+
show: (e, t, r) => {
|
|
1066
|
+
c();
|
|
1067
|
+
let a = m(e);
|
|
1068
|
+
i.appendChild(a), i.hidden = !1, h(a, t, r), te(), n?.(!0);
|
|
1069
1069
|
},
|
|
1070
|
-
showField: (e, t,
|
|
1071
|
-
|
|
1072
|
-
let
|
|
1073
|
-
|
|
1070
|
+
showField: (e, t, r) => {
|
|
1071
|
+
c();
|
|
1072
|
+
let a = p(e);
|
|
1073
|
+
i.appendChild(a), i.hidden = !1, h(a, t, r), a.querySelector("input")?.focus({ preventScroll: !0 }), te(), n?.(!0);
|
|
1074
1074
|
},
|
|
1075
|
-
hide:
|
|
1075
|
+
hide: c,
|
|
1076
1076
|
destroy: () => {
|
|
1077
|
-
|
|
1077
|
+
c(), i.remove();
|
|
1078
1078
|
}
|
|
1079
1079
|
};
|
|
1080
1080
|
}
|
|
1081
1081
|
//#endregion
|
|
1082
1082
|
//#region src/inplace/table-gizmos.ts
|
|
1083
|
-
function
|
|
1083
|
+
function At(e, t) {
|
|
1084
1084
|
let n = e.createElement("div");
|
|
1085
1085
|
n.className = "cm-inplace-table-gizmos", n.setAttribute("contenteditable", "false");
|
|
1086
1086
|
let r = X(e), i = (t, n, r) => {
|
|
@@ -1167,30 +1167,30 @@ function kt(e, t) {
|
|
|
1167
1167
|
//#endregion
|
|
1168
1168
|
//#region src/inplace/table-structure.ts
|
|
1169
1169
|
var Z = (e) => e.aligns.length;
|
|
1170
|
-
function
|
|
1170
|
+
function jt(e, t) {
|
|
1171
1171
|
let n = Math.max(0, Math.min(t, Z(e)));
|
|
1172
1172
|
for (let t of e.rows) t.splice(n, 0, "");
|
|
1173
1173
|
e.aligns.splice(n, 0, "");
|
|
1174
1174
|
}
|
|
1175
|
-
function
|
|
1175
|
+
function Mt(e, t) {
|
|
1176
1176
|
if (!(Z(e) <= 1 || t < 0 || t >= Z(e))) {
|
|
1177
1177
|
for (let n of e.rows) n.splice(t, 1);
|
|
1178
1178
|
e.aligns.splice(t, 1);
|
|
1179
1179
|
}
|
|
1180
1180
|
}
|
|
1181
|
-
function
|
|
1181
|
+
function Nt(e, t) {
|
|
1182
1182
|
let n = Math.max(1, Math.min(t, e.rows.length));
|
|
1183
1183
|
e.rows.splice(n, 0, Array(Z(e)).fill(""));
|
|
1184
1184
|
}
|
|
1185
|
-
function
|
|
1185
|
+
function Pt(e, t) {
|
|
1186
1186
|
t <= 0 || t >= e.rows.length || e.rows.length <= 2 || e.rows.splice(t, 1);
|
|
1187
1187
|
}
|
|
1188
|
-
function
|
|
1188
|
+
function Ft(e, t, n) {
|
|
1189
1189
|
t >= 0 && t < Z(e) && (e.aligns[t] = n);
|
|
1190
1190
|
}
|
|
1191
1191
|
//#endregion
|
|
1192
1192
|
//#region src/inplace/table-widget.ts
|
|
1193
|
-
var Q = me.define(),
|
|
1193
|
+
var Q = me.define(), It = class extends x {
|
|
1194
1194
|
data;
|
|
1195
1195
|
table = null;
|
|
1196
1196
|
rows;
|
|
@@ -1236,7 +1236,7 @@ var Q = me.define(), Ft = class extends x {
|
|
|
1236
1236
|
}
|
|
1237
1237
|
paint(e, t) {
|
|
1238
1238
|
let { r: n, c: i } = this.coords(e), a = this.rows[n]?.[i] ?? "";
|
|
1239
|
-
e.replaceChildren(t ? e.ownerDocument.createTextNode(a) :
|
|
1239
|
+
e.replaceChildren(t ? e.ownerDocument.createTextNode(a) : wt(r(a)));
|
|
1240
1240
|
}
|
|
1241
1241
|
mkCell(e, t, n) {
|
|
1242
1242
|
let r = document.createElement(n ? "th" : "td");
|
|
@@ -1256,7 +1256,7 @@ var Q = me.define(), Ft = class extends x {
|
|
|
1256
1256
|
}
|
|
1257
1257
|
}
|
|
1258
1258
|
appendRow() {
|
|
1259
|
-
|
|
1259
|
+
Nt(this.model(), this.rows.length), this.renderCells(), this.gizmos?.layout(this.table);
|
|
1260
1260
|
}
|
|
1261
1261
|
model() {
|
|
1262
1262
|
return {
|
|
@@ -1267,7 +1267,7 @@ var Q = me.define(), Ft = class extends x {
|
|
|
1267
1267
|
runOp(e, t) {
|
|
1268
1268
|
if (!this.table) return;
|
|
1269
1269
|
let n = this.model();
|
|
1270
|
-
if (t.kind === "insertColumn" ?
|
|
1270
|
+
if (t.kind === "insertColumn" ? jt(n, t.at) : t.kind === "deleteColumn" ? Mt(n, t.at) : t.kind === "insertRow" ? Nt(n, t.at) : t.kind === "deleteRow" ? Pt(n, t.at) : Ft(n, t.at, n.aligns[t.at] === t.value ? "" : t.value), this.editing = null, this.sync(e), this.renderCells(), this.gizmos?.layout(this.table), t.kind !== "align") {
|
|
1271
1271
|
let e = Math.max(0, Math.min(t.focus[0], this.rows.length - 1)), n = Math.max(0, Math.min(t.focus[1], this.cols() - 1));
|
|
1272
1272
|
this.cellAt(e, n)?.focus();
|
|
1273
1273
|
}
|
|
@@ -1279,7 +1279,7 @@ var Q = me.define(), Ft = class extends x {
|
|
|
1279
1279
|
onFocusIn(e) {
|
|
1280
1280
|
let t = e.target.closest("td, th");
|
|
1281
1281
|
if (!t || t === this.editing) return;
|
|
1282
|
-
let n = this.pendingOffset ??
|
|
1282
|
+
let n = this.pendingOffset ?? ee(t);
|
|
1283
1283
|
this.pendingOffset = null, this.editing && this.finish(this.editing, !1), this.editing = t, this.paint(t, !0), c(t, n);
|
|
1284
1284
|
}
|
|
1285
1285
|
onFocusOut(e) {
|
|
@@ -1384,7 +1384,7 @@ var Q = me.define(), Ft = class extends x {
|
|
|
1384
1384
|
let i = r?.closest("td, th");
|
|
1385
1385
|
if (!i) return;
|
|
1386
1386
|
this.editing === i && !H(e) && p(i, t, n);
|
|
1387
|
-
let a = H(e) ?
|
|
1387
|
+
let a = H(e) ? bt(e) : void 0;
|
|
1388
1388
|
this.gizmos?.openFor(i, t, n, a);
|
|
1389
1389
|
}
|
|
1390
1390
|
toDOM(e) {
|
|
@@ -1407,9 +1407,9 @@ var Q = me.define(), Ft = class extends x {
|
|
|
1407
1407
|
document.execCommand("insertText", !1, t);
|
|
1408
1408
|
}), n.addEventListener("contextmenu", (t) => {
|
|
1409
1409
|
t.target.closest("td, th") && (t.preventDefault(), t.stopPropagation(), this.longPress?.cancel(), !(Date.now() - this.longPressAt < 700) && this.openCellMenuAt(e, t.clientX, t.clientY, t.target));
|
|
1410
|
-
}), this.longPress =
|
|
1410
|
+
}), this.longPress = Dt(n, { onLongPress: (t, n, r) => {
|
|
1411
1411
|
this.longPressAt = Date.now(), this.openCellMenuAt(e, t, n, r);
|
|
1412
|
-
} }), this.gizmos =
|
|
1412
|
+
} }), this.gizmos = At(document, {
|
|
1413
1413
|
dims: () => ({
|
|
1414
1414
|
cols: this.cols(),
|
|
1415
1415
|
rows: this.rows.length,
|
|
@@ -1421,11 +1421,11 @@ var Q = me.define(), Ft = class extends x {
|
|
|
1421
1421
|
destroy() {
|
|
1422
1422
|
this.longPress?.dispose(), this.longPress = null, this.gizmos?.destroy(), this.gizmos = null, this.table = null, this.editing = null;
|
|
1423
1423
|
}
|
|
1424
|
-
},
|
|
1424
|
+
}, Lt = /* @__PURE__ */ new Set([
|
|
1425
1425
|
"-",
|
|
1426
1426
|
"*",
|
|
1427
1427
|
"_"
|
|
1428
|
-
]),
|
|
1428
|
+
]), Rt = ge.transactionFilter.of((e) => {
|
|
1429
1429
|
if (!e.docChanged || e.isUserEvent("undo") || e.isUserEvent("redo") || e.annotation(Q) || !e.startState.selection.main.empty) return e;
|
|
1430
1430
|
let t = e.startState.selection.main.head, n = "", r = 0;
|
|
1431
1431
|
if (e.changes.iterChanges((e, i, a, o, s) => {
|
|
@@ -1456,7 +1456,7 @@ var Q = me.define(), Ft = class extends x {
|
|
|
1456
1456
|
},
|
|
1457
1457
|
anchor: a + 1
|
|
1458
1458
|
};
|
|
1459
|
-
else if (
|
|
1459
|
+
else if (Lt.has(n) && RegExp(`^\\${n}{3,}$`).test(s)) {
|
|
1460
1460
|
let e = o.number === 1 || i.line(o.number - 1).text.trim() === "", t = n === "-" && !e, r = o.number === i.lines;
|
|
1461
1461
|
if (t || r) {
|
|
1462
1462
|
let e = [];
|
|
@@ -1479,28 +1479,28 @@ var Q = me.define(), Ft = class extends x {
|
|
|
1479
1479
|
scrollIntoView: !0,
|
|
1480
1480
|
userEvent: "input.autoformat"
|
|
1481
1481
|
}] : e;
|
|
1482
|
-
}),
|
|
1482
|
+
}), zt = /* @__PURE__ */ new Set([
|
|
1483
1483
|
"EmphasisMark",
|
|
1484
1484
|
"CodeMark",
|
|
1485
1485
|
"StrikethroughMark"
|
|
1486
1486
|
]);
|
|
1487
|
-
function
|
|
1487
|
+
function Bt(e, t, n) {
|
|
1488
1488
|
let r = t;
|
|
1489
1489
|
for (;;) {
|
|
1490
1490
|
let t = e.resolveInner(r, n);
|
|
1491
|
-
if (!
|
|
1491
|
+
if (!zt.has(t.name) || t.from >= t.to) return r;
|
|
1492
1492
|
let i = n < 0 ? t.from : t.to;
|
|
1493
1493
|
if (i === r) return r;
|
|
1494
1494
|
r = i;
|
|
1495
1495
|
}
|
|
1496
1496
|
}
|
|
1497
|
-
function
|
|
1497
|
+
function Vt(e, t) {
|
|
1498
1498
|
let n = B(e, t, !0);
|
|
1499
1499
|
if (!n) return t;
|
|
1500
1500
|
let r = T(e);
|
|
1501
|
-
return t === n.contentTo ?
|
|
1501
|
+
return t === n.contentTo ? Bt(r, t, 1) : t === n.contentFrom ? Bt(r, t, -1) : t;
|
|
1502
1502
|
}
|
|
1503
|
-
var
|
|
1503
|
+
var Ht = ge.transactionFilter.of((e) => {
|
|
1504
1504
|
if (!e.docChanged || e.isUserEvent("undo") || e.isUserEvent("redo") || e.annotation(Q)) return e;
|
|
1505
1505
|
let t = e.startState, n = t.selection.main;
|
|
1506
1506
|
if (!n.empty || !z(t, t.doc.lineAt(n.head).number)) return e;
|
|
@@ -1510,7 +1510,7 @@ var Vt = ge.transactionFilter.of((e) => {
|
|
|
1510
1510
|
});
|
|
1511
1511
|
let a = r[0];
|
|
1512
1512
|
if (i !== 1 || a === void 0) return e;
|
|
1513
|
-
let o =
|
|
1513
|
+
let o = Vt(t, n.head);
|
|
1514
1514
|
return o === n.head ? e : {
|
|
1515
1515
|
changes: {
|
|
1516
1516
|
from: o,
|
|
@@ -1523,7 +1523,7 @@ var Vt = ge.transactionFilter.of((e) => {
|
|
|
1523
1523
|
});
|
|
1524
1524
|
//#endregion
|
|
1525
1525
|
//#region src/inplace/edit-line-prefix.ts
|
|
1526
|
-
function
|
|
1526
|
+
function Ut(e) {
|
|
1527
1527
|
let t = /^#{1,6} /.exec(e);
|
|
1528
1528
|
if (t) return {
|
|
1529
1529
|
prefixLen: t[0].length,
|
|
@@ -1559,7 +1559,7 @@ function Ht(e) {
|
|
|
1559
1559
|
}
|
|
1560
1560
|
return null;
|
|
1561
1561
|
}
|
|
1562
|
-
var
|
|
1562
|
+
var Wt = C.high(pe.of([{
|
|
1563
1563
|
key: "Backspace",
|
|
1564
1564
|
run: (e) => {
|
|
1565
1565
|
if (o(e)) return !1;
|
|
@@ -1567,7 +1567,7 @@ var Ut = C.high(pe.of([{
|
|
|
1567
1567
|
if (!n.empty) return !1;
|
|
1568
1568
|
let r = t.doc.lineAt(n.head);
|
|
1569
1569
|
if (!z(t, r.number)) return !1;
|
|
1570
|
-
let i =
|
|
1570
|
+
let i = Ut(r.text);
|
|
1571
1571
|
if (!i || n.head < r.from || n.head > r.from + i.prefixLen) return !1;
|
|
1572
1572
|
let [a, s] = i.drop;
|
|
1573
1573
|
return e.dispatch({
|
|
@@ -1581,7 +1581,7 @@ var Ut = C.high(pe.of([{
|
|
|
1581
1581
|
scrollIntoView: !0
|
|
1582
1582
|
}), !0;
|
|
1583
1583
|
}
|
|
1584
|
-
}])),
|
|
1584
|
+
}])), Gt = class {
|
|
1585
1585
|
menu;
|
|
1586
1586
|
contentDOM;
|
|
1587
1587
|
onClick;
|
|
@@ -1605,7 +1605,7 @@ var Ut = C.high(pe.of([{
|
|
|
1605
1605
|
destroy() {
|
|
1606
1606
|
this.contentDOM.removeEventListener("click", this.onClick), this.menu.destroy();
|
|
1607
1607
|
}
|
|
1608
|
-
},
|
|
1608
|
+
}, Kt = b.fromClass(Gt), qt = (e) => e.replace(/^<([^]*)>$/, "$1").trim(), Jt = (e, t, n) => n ? {
|
|
1609
1609
|
pos: e,
|
|
1610
1610
|
end: t,
|
|
1611
1611
|
above: !0,
|
|
@@ -1614,27 +1614,33 @@ var Ut = C.high(pe.of([{
|
|
|
1614
1614
|
return e.className = "cm-inplace-href-tip", e.textContent = n, { dom: e };
|
|
1615
1615
|
}
|
|
1616
1616
|
} : null;
|
|
1617
|
-
function
|
|
1617
|
+
function Yt(e, t) {
|
|
1618
1618
|
for (let n = T(e.state).resolveInner(t, -1); n; n = n.parent) {
|
|
1619
1619
|
if (n.name !== "Link") continue;
|
|
1620
1620
|
if (e.state.doc.sliceString(Math.max(0, n.from - 1), n.from) === "[") break;
|
|
1621
1621
|
let t = n.getChild("URL"), r = t ? e.state.sliceDoc(t.from, t.to) : e.state.sliceDoc(n.from, n.to);
|
|
1622
|
-
return
|
|
1622
|
+
return Jt(n.from, n.to, qt(r));
|
|
1623
1623
|
}
|
|
1624
1624
|
return null;
|
|
1625
1625
|
}
|
|
1626
|
-
function
|
|
1626
|
+
function Xt(e, t) {
|
|
1627
1627
|
let r = e.state.doc.lineAt(t);
|
|
1628
1628
|
for (let e of r.text.matchAll(n)) {
|
|
1629
1629
|
let n = r.from + (e.index ?? 0), i = n + e[0].length;
|
|
1630
|
-
if (!(t < n || t > i)) return
|
|
1630
|
+
if (!(t < n || t > i)) return Jt(n, i, (e[1] ?? "").trim());
|
|
1631
1631
|
}
|
|
1632
1632
|
return null;
|
|
1633
1633
|
}
|
|
1634
|
-
var
|
|
1634
|
+
var Zt = fe((e, t) => {
|
|
1635
1635
|
let n = e.state.facet(E);
|
|
1636
|
-
return (n.links ?
|
|
1637
|
-
}),
|
|
1636
|
+
return (n.links ? Yt(e, t) : null) ?? (n.wikilinks ? Xt(e, t) : null);
|
|
1637
|
+
}), Qt = _e.define(), $ = w.define({
|
|
1638
|
+
create: () => !1,
|
|
1639
|
+
update(e, t) {
|
|
1640
|
+
for (let n of t.effects) n.is(Qt) && (e = n.value);
|
|
1641
|
+
return e;
|
|
1642
|
+
}
|
|
1643
|
+
}), $t = class {
|
|
1638
1644
|
view;
|
|
1639
1645
|
menu;
|
|
1640
1646
|
onContextMenu;
|
|
@@ -1643,8 +1649,11 @@ var Xt = fe((e, t) => {
|
|
|
1643
1649
|
contentDOM;
|
|
1644
1650
|
stashed = null;
|
|
1645
1651
|
longPressAt = 0;
|
|
1652
|
+
destroyed = !1;
|
|
1646
1653
|
constructor(e) {
|
|
1647
|
-
this.view = e, this.menu = X(e.dom.ownerDocument
|
|
1654
|
+
this.view = e, this.menu = X(e.dom.ownerDocument, "cm-inplace-menu", (t) => {
|
|
1655
|
+
this.destroyed || e.dispatch({ effects: Qt.of(t) });
|
|
1656
|
+
}), e.dom.appendChild(this.menu.el), this.contentDOM = e.contentDOM, this.onPointerDown = () => {
|
|
1648
1657
|
let t = e.state.selection.main;
|
|
1649
1658
|
this.stashed = t.empty ? null : {
|
|
1650
1659
|
anchor: t.anchor,
|
|
@@ -1653,7 +1662,7 @@ var Xt = fe((e, t) => {
|
|
|
1653
1662
|
}, this.contentDOM.addEventListener("pointerdown", this.onPointerDown, !0), this.onContextMenu = (t) => {
|
|
1654
1663
|
let n = t.target;
|
|
1655
1664
|
e.state.facet(k) && (n?.closest(".cm-inplace-table-edit") || (t.preventDefault(), this.longPress.cancel(), !(Date.now() - this.longPressAt < 700) && this.openMenuAt(t.clientX, t.clientY, n)));
|
|
1656
|
-
}, this.contentDOM.addEventListener("contextmenu", this.onContextMenu), this.longPress =
|
|
1665
|
+
}, this.contentDOM.addEventListener("contextmenu", this.onContextMenu), this.longPress = Dt(this.contentDOM, { onLongPress: (e, t, n) => {
|
|
1657
1666
|
this.longPressAt = Date.now(), this.openMenuAt(e, t, n);
|
|
1658
1667
|
} });
|
|
1659
1668
|
}
|
|
@@ -1677,13 +1686,13 @@ var Xt = fe((e, t) => {
|
|
|
1677
1686
|
}), r.dispatch({ selection: t });
|
|
1678
1687
|
}
|
|
1679
1688
|
}
|
|
1680
|
-
this.menu.show(
|
|
1689
|
+
this.menu.show(Ct(r), e, t);
|
|
1681
1690
|
}
|
|
1682
1691
|
}
|
|
1683
1692
|
destroy() {
|
|
1684
|
-
this.contentDOM.removeEventListener("pointerdown", this.onPointerDown, !0), this.contentDOM.removeEventListener("contextmenu", this.onContextMenu), this.longPress.dispose(), this.menu.destroy();
|
|
1693
|
+
this.destroyed = !0, this.contentDOM.removeEventListener("pointerdown", this.onPointerDown, !0), this.contentDOM.removeEventListener("contextmenu", this.onContextMenu), this.longPress.dispose(), this.menu.destroy();
|
|
1685
1694
|
}
|
|
1686
|
-
},
|
|
1695
|
+
}, en = b.fromClass($t), tn = class {
|
|
1687
1696
|
view;
|
|
1688
1697
|
bar;
|
|
1689
1698
|
ids;
|
|
@@ -1698,12 +1707,12 @@ var Xt = fe((e, t) => {
|
|
|
1698
1707
|
constructor(e) {
|
|
1699
1708
|
this.view = e;
|
|
1700
1709
|
let t = e.dom.ownerDocument;
|
|
1701
|
-
this.ids = e.state.facet(
|
|
1710
|
+
this.ids = e.state.facet(we), this.linkMenu = X(t), e.dom.appendChild(this.linkMenu.el), this.bar = t.createElement("div"), this.bar.className = "cm-inplace-selbar", this.bar.setAttribute("contenteditable", "false"), this.bar.hidden = !0;
|
|
1702
1711
|
for (let n of this.ids) {
|
|
1703
1712
|
let r = m[n], i = t.createElement("button");
|
|
1704
1713
|
i.type = "button", i.className = "cm-inplace-selbar-btn", i.title = r.title, i.setAttribute("aria-label", r.title), i.appendChild(se(t, g[n] ?? "")), i.addEventListener("mousedown", (e) => e.preventDefault()), i.addEventListener("click", (t) => {
|
|
1705
1714
|
t.preventDefault();
|
|
1706
|
-
let a = !!o(e), s = !a && n === "link" ? G(e) : !a && n === "wikilink" ?
|
|
1715
|
+
let a = !!o(e), s = !a && n === "link" ? G(e) : !a && n === "wikilink" ? _t(e) : null;
|
|
1707
1716
|
if (s) {
|
|
1708
1717
|
let e = i.getBoundingClientRect();
|
|
1709
1718
|
this.linkMenu.showField(s, e.left, e.bottom + 6);
|
|
@@ -1715,7 +1724,8 @@ var Xt = fe((e, t) => {
|
|
|
1715
1724
|
e.dom.appendChild(this.bar), t.addEventListener("scroll", this.onScroll, !0), t.addEventListener("selectionchange", this.onSelectionChange);
|
|
1716
1725
|
}
|
|
1717
1726
|
update(e) {
|
|
1718
|
-
|
|
1727
|
+
let t = e.startState.field($, !1) !== e.state.field($, !1);
|
|
1728
|
+
(e.selectionSet || e.docChanged || e.focusChanged || t) && this.schedule();
|
|
1719
1729
|
}
|
|
1720
1730
|
schedule() {
|
|
1721
1731
|
this.view.requestMeasure({
|
|
@@ -1754,7 +1764,7 @@ var Xt = fe((e, t) => {
|
|
|
1754
1764
|
}
|
|
1755
1765
|
measure() {
|
|
1756
1766
|
let { view: e } = this;
|
|
1757
|
-
if (e.state.facet(N) !== "bar") return null;
|
|
1767
|
+
if (e.state.facet(N) !== "bar" || e.state.field($, !1)) return null;
|
|
1758
1768
|
let t = this.selectionBox();
|
|
1759
1769
|
if (!t) return null;
|
|
1760
1770
|
let { box: n, inCell: r } = t;
|
|
@@ -1783,7 +1793,7 @@ var Xt = fe((e, t) => {
|
|
|
1783
1793
|
let e = this.view.dom.ownerDocument;
|
|
1784
1794
|
e.removeEventListener("scroll", this.onScroll, !0), e.removeEventListener("selectionchange", this.onSelectionChange), this.linkMenu.destroy(), this.bar.remove();
|
|
1785
1795
|
}
|
|
1786
|
-
},
|
|
1796
|
+
}, nn = b.fromClass(tn), rn = class extends x {
|
|
1787
1797
|
table;
|
|
1788
1798
|
constructor(e) {
|
|
1789
1799
|
super(), this.table = e;
|
|
@@ -1794,17 +1804,17 @@ var Xt = fe((e, t) => {
|
|
|
1794
1804
|
toDOM() {
|
|
1795
1805
|
let { head: e, body: t, aligns: n } = this.table, r = document.createElement("table");
|
|
1796
1806
|
r.className = "cm-inplace-table";
|
|
1797
|
-
let i = (e) =>
|
|
1807
|
+
let i = (e) => wt(e.replace(/\\\|/g, "|")), a = r.createTHead().insertRow();
|
|
1798
1808
|
e.forEach((e, t) => {
|
|
1799
1809
|
let r = document.createElement("th");
|
|
1800
|
-
r.appendChild(i(e)), r.dataset.styloRow = "0", r.dataset.styloCol = String(t),
|
|
1810
|
+
r.appendChild(i(e)), r.dataset.styloRow = "0", r.dataset.styloCol = String(t), an(r, n[t]), a.appendChild(r);
|
|
1801
1811
|
});
|
|
1802
1812
|
let o = r.createTBody();
|
|
1803
1813
|
return t.forEach((t, r) => {
|
|
1804
1814
|
let a = o.insertRow();
|
|
1805
1815
|
for (let o = 0; o < e.length; o++) {
|
|
1806
1816
|
let e = a.insertCell();
|
|
1807
|
-
e.appendChild(i(t[o] ?? "")), e.dataset.styloRow = String(r + 1), e.dataset.styloCol = String(o),
|
|
1817
|
+
e.appendChild(i(t[o] ?? "")), e.dataset.styloRow = String(r + 1), e.dataset.styloCol = String(o), an(e, n[o]);
|
|
1808
1818
|
}
|
|
1809
1819
|
}), r;
|
|
1810
1820
|
}
|
|
@@ -1812,10 +1822,10 @@ var Xt = fe((e, t) => {
|
|
|
1812
1822
|
return !1;
|
|
1813
1823
|
}
|
|
1814
1824
|
};
|
|
1815
|
-
function
|
|
1825
|
+
function an(e, t) {
|
|
1816
1826
|
t && (e.style.textAlign = t);
|
|
1817
1827
|
}
|
|
1818
|
-
function
|
|
1828
|
+
function on(e, t) {
|
|
1819
1829
|
let n = t.lineAt(e.from).number, r = t.lineAt(e.to).number, i = [];
|
|
1820
1830
|
for (let e = n; e <= r; e++) i.push(t.line(e).text);
|
|
1821
1831
|
let a = d(i);
|
|
@@ -1825,7 +1835,7 @@ function rn(e, t) {
|
|
|
1825
1835
|
aligns: a.aligns
|
|
1826
1836
|
};
|
|
1827
1837
|
}
|
|
1828
|
-
function
|
|
1838
|
+
function sn(e) {
|
|
1829
1839
|
if (!e.facet(E).tables) return v.none;
|
|
1830
1840
|
let n = e.facet(D) === "cells", r = T(e), i = t(e.doc), a = n ? null : P(e), o = [];
|
|
1831
1841
|
return r.iterate({ enter: (t) => {
|
|
@@ -1835,9 +1845,9 @@ function an(e) {
|
|
|
1835
1845
|
let n = e.doc.lineAt(t.from).number, r = e.doc.lineAt(t.to).number;
|
|
1836
1846
|
for (let e = n; e <= r; e++) if (a.has(e)) return !1;
|
|
1837
1847
|
}
|
|
1838
|
-
let r =
|
|
1848
|
+
let r = on(t.node, e.doc);
|
|
1839
1849
|
if (r) {
|
|
1840
|
-
let e = n ? new
|
|
1850
|
+
let e = n ? new It(r) : new rn(r);
|
|
1841
1851
|
o.push(v.replace({
|
|
1842
1852
|
widget: e,
|
|
1843
1853
|
block: !0
|
|
@@ -1846,36 +1856,36 @@ function an(e) {
|
|
|
1846
1856
|
return !1;
|
|
1847
1857
|
} }), v.set(o, !0);
|
|
1848
1858
|
}
|
|
1849
|
-
var
|
|
1850
|
-
create:
|
|
1851
|
-
update: (e, t) => t.annotation(Q) ? e.map(t.changes) : t.state.facet(D) === "cells" ? t.docChanged ?
|
|
1859
|
+
var cn = w.define({
|
|
1860
|
+
create: sn,
|
|
1861
|
+
update: (e, t) => t.annotation(Q) ? e.map(t.changes) : t.state.facet(D) === "cells" ? t.docChanged ? sn(t.state) : e.map(t.changes) : t.docChanged || t.selection ? sn(t.state) : e,
|
|
1852
1862
|
provide: (e) => [y.decorations.from(e), y.atomicRanges.of((t) => t.state.field(e))]
|
|
1853
|
-
}),
|
|
1863
|
+
}), ln = (e) => (t) => {
|
|
1854
1864
|
if (o(t)) return !1;
|
|
1855
1865
|
let n = t.state.selection.main;
|
|
1856
1866
|
if (!n.empty) return !1;
|
|
1857
1867
|
let { doc: r } = t.state, i = r.lineAt(n.head), a = e ? i.number + 1 : i.number - 1;
|
|
1858
1868
|
if (a < 1 || a > r.lines) return !1;
|
|
1859
1869
|
let s = r.line(a), c = -1, l = -1, u;
|
|
1860
|
-
if (t.state.field(
|
|
1870
|
+
if (t.state.field(cn).between(s.from, s.to, (t, n, r) => {
|
|
1861
1871
|
if (e ? t === s.from : n === s.to) return c = t, l = n, u = r.spec.widget, !1;
|
|
1862
1872
|
}), c < 0) return !1;
|
|
1863
|
-
if (t.state.facet(D) === "cells") return u instanceof
|
|
1873
|
+
if (t.state.facet(D) === "cells") return u instanceof It && u.focusEdge(e ? "first" : "last");
|
|
1864
1874
|
let d = e ? r.lineAt(c).from : r.lineAt(l).to;
|
|
1865
1875
|
return t.dispatch({
|
|
1866
1876
|
selection: { anchor: d },
|
|
1867
1877
|
userEvent: "select",
|
|
1868
1878
|
scrollIntoView: !0
|
|
1869
1879
|
}), !0;
|
|
1870
|
-
},
|
|
1880
|
+
}, un = ln(!0), dn = ln(!1), fn = C.high(pe.of([{
|
|
1871
1881
|
key: "ArrowDown",
|
|
1872
|
-
run:
|
|
1882
|
+
run: un
|
|
1873
1883
|
}, {
|
|
1874
1884
|
key: "ArrowUp",
|
|
1875
|
-
run:
|
|
1876
|
-
}])),
|
|
1885
|
+
run: dn
|
|
1886
|
+
}])), pn = "var(--stylo-font-family-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace)", mn = "var(--stylo-font-family, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif)", hn = y.theme({
|
|
1877
1887
|
"& .cm-content": {
|
|
1878
|
-
fontFamily:
|
|
1888
|
+
fontFamily: mn,
|
|
1879
1889
|
lineHeight: "1.75",
|
|
1880
1890
|
padding: "0.75rem",
|
|
1881
1891
|
WebkitTouchCallout: "none"
|
|
@@ -1914,14 +1924,14 @@ var on = w.define({
|
|
|
1914
1924
|
".cm-inplace-em": { fontStyle: "italic" },
|
|
1915
1925
|
".cm-inplace-strike": { textDecoration: "line-through" },
|
|
1916
1926
|
".cm-inplace-code": {
|
|
1917
|
-
fontFamily:
|
|
1927
|
+
fontFamily: pn,
|
|
1918
1928
|
fontSize: "0.9em",
|
|
1919
1929
|
padding: "0.1em 0.35em",
|
|
1920
1930
|
borderRadius: "3px",
|
|
1921
1931
|
background: "color-mix(in srgb, var(--stylo-border) 45%, transparent)"
|
|
1922
1932
|
},
|
|
1923
1933
|
".cm-inplace-mono": {
|
|
1924
|
-
fontFamily:
|
|
1934
|
+
fontFamily: pn,
|
|
1925
1935
|
fontSize: "0.9em",
|
|
1926
1936
|
background: "color-mix(in srgb, var(--stylo-border) 35%, transparent)",
|
|
1927
1937
|
padding: "0 0.9rem"
|
|
@@ -2019,14 +2029,14 @@ var on = w.define({
|
|
|
2019
2029
|
cursor: "pointer"
|
|
2020
2030
|
},
|
|
2021
2031
|
".cm-inplace-fm": {
|
|
2022
|
-
fontFamily:
|
|
2032
|
+
fontFamily: pn,
|
|
2023
2033
|
fontSize: "0.85em",
|
|
2024
2034
|
color: "var(--stylo-text-muted)"
|
|
2025
2035
|
},
|
|
2026
2036
|
".cm-inplace-fm-first::before": {
|
|
2027
2037
|
content: "\"Frontmatter\"",
|
|
2028
2038
|
marginRight: "0.6em",
|
|
2029
|
-
fontFamily:
|
|
2039
|
+
fontFamily: mn,
|
|
2030
2040
|
fontSize: "0.8rem",
|
|
2031
2041
|
fontWeight: "600",
|
|
2032
2042
|
textTransform: "uppercase",
|
|
@@ -2252,8 +2262,8 @@ var on = w.define({
|
|
|
2252
2262
|
lineHeight: "1.4",
|
|
2253
2263
|
wordBreak: "break-all"
|
|
2254
2264
|
}
|
|
2255
|
-
}),
|
|
2256
|
-
function
|
|
2265
|
+
}), gn = ".cm-inplace-math, .cm-inplace-hr, .cm-inplace-table";
|
|
2266
|
+
function _n(e, t, n) {
|
|
2257
2267
|
let r = e.firstChild, i = e.textContent?.length ?? 0;
|
|
2258
2268
|
if (!r || r.nodeType !== Node.TEXT_NODE || i === 0) return 0;
|
|
2259
2269
|
let a = e.ownerDocument, o = null, s = 0;
|
|
@@ -2266,43 +2276,44 @@ function pn(e, t, n) {
|
|
|
2266
2276
|
}
|
|
2267
2277
|
return o === r ? Math.min(s, i) : o === e && s > 0 ? i : 0;
|
|
2268
2278
|
}
|
|
2269
|
-
function
|
|
2270
|
-
let t =
|
|
2279
|
+
function vn(e = {}) {
|
|
2280
|
+
let t = Se(e.inPlace?.contextMenu);
|
|
2271
2281
|
return [
|
|
2272
|
-
E.of(
|
|
2282
|
+
E.of(be(e.inPlace)),
|
|
2273
2283
|
D.of(e.inPlace?.table ?? "source"),
|
|
2274
2284
|
O.of(e.inPlace?.reveal ?? "caret"),
|
|
2275
|
-
|
|
2285
|
+
xe.of(e.onLinkClick ?? null),
|
|
2276
2286
|
k.of(t.enabled),
|
|
2277
2287
|
M.of(t.groups),
|
|
2278
2288
|
N.of(e.inPlace?.selectionUI ?? "menu"),
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2289
|
+
we.of(Ce(e.inPlace?.selectionBarItems)),
|
|
2290
|
+
Je(),
|
|
2291
|
+
Wt,
|
|
2292
|
+
at,
|
|
2293
|
+
fn,
|
|
2294
|
+
Ht,
|
|
2295
|
+
Rt,
|
|
2296
|
+
Pe,
|
|
2297
|
+
Ee,
|
|
2298
|
+
cn,
|
|
2299
|
+
$,
|
|
2290
2300
|
en,
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2301
|
+
nn,
|
|
2302
|
+
Kt,
|
|
2303
|
+
Zt,
|
|
2304
|
+
C.high(hn),
|
|
2294
2305
|
y.domEventHandlers({
|
|
2295
2306
|
mousedown(e, t) {
|
|
2296
2307
|
let n = e.target;
|
|
2297
2308
|
if (n?.closest(".cm-inplace-table-edit")) return !1;
|
|
2298
|
-
let r = n?.closest(
|
|
2309
|
+
let r = n?.closest(gn);
|
|
2299
2310
|
if (!r) return !1;
|
|
2300
2311
|
let i = t.posAtDOM(r);
|
|
2301
2312
|
if (i < 0) return !1;
|
|
2302
2313
|
let a = n?.closest("[data-stylo-row]");
|
|
2303
2314
|
if (a && r.contains(a)) {
|
|
2304
2315
|
let n = te(t.state.doc, i, Number(a.dataset.styloRow), Number(a.dataset.styloCol));
|
|
2305
|
-
n != null && (i = n +
|
|
2316
|
+
n != null && (i = n + _n(a, e.clientX, e.clientY));
|
|
2306
2317
|
}
|
|
2307
2318
|
return t.focus(), t.dispatch({ selection: { anchor: i } }), !0;
|
|
2308
2319
|
},
|
|
@@ -2316,31 +2327,32 @@ function mn(e = {}) {
|
|
|
2316
2327
|
}
|
|
2317
2328
|
//#endregion
|
|
2318
2329
|
//#region src/inplace/InPlaceView.tsx
|
|
2319
|
-
function
|
|
2320
|
-
let
|
|
2321
|
-
|
|
2322
|
-
let
|
|
2323
|
-
|
|
2324
|
-
let [
|
|
2325
|
-
onWikiLinkClick: (e) =>
|
|
2326
|
-
onLinkClick: (e) =>
|
|
2330
|
+
function yn({ value: t, onChange: n, readOnly: r, placeholder: i, onWikiLinkClick: a, onLinkClick: o, inPlace: s, codeLanguages: c, wikiLinkSource: l, onSave: u, onViewChange: d }) {
|
|
2331
|
+
let f = ue(a);
|
|
2332
|
+
f.current = a;
|
|
2333
|
+
let p = ue(o);
|
|
2334
|
+
p.current = o;
|
|
2335
|
+
let [m] = de(() => [vn({
|
|
2336
|
+
onWikiLinkClick: (e) => f.current?.(e),
|
|
2337
|
+
onLinkClick: (e) => p.current?.(e),
|
|
2327
2338
|
inPlace: s
|
|
2328
|
-
})]),
|
|
2339
|
+
})]), h = re({
|
|
2329
2340
|
value: t,
|
|
2330
2341
|
onChange: n,
|
|
2331
2342
|
readOnly: r,
|
|
2332
2343
|
placeholder: i,
|
|
2333
|
-
extensions:
|
|
2344
|
+
extensions: m,
|
|
2334
2345
|
codeLanguages: c,
|
|
2335
|
-
|
|
2336
|
-
|
|
2346
|
+
wikiLinkSource: l,
|
|
2347
|
+
onSave: u,
|
|
2348
|
+
onViewChange: d
|
|
2337
2349
|
});
|
|
2338
|
-
return /* @__PURE__ */
|
|
2350
|
+
return /* @__PURE__ */ ve("div", {
|
|
2339
2351
|
className: e.inplace,
|
|
2340
|
-
ref:
|
|
2352
|
+
ref: h
|
|
2341
2353
|
});
|
|
2342
2354
|
}
|
|
2343
2355
|
//#endregion
|
|
2344
|
-
export {
|
|
2356
|
+
export { yn as InPlaceView };
|
|
2345
2357
|
|
|
2346
|
-
//# sourceMappingURL=InPlaceView-
|
|
2358
|
+
//# sourceMappingURL=InPlaceView-CS1qy-Ba.js.map
|