@damiro/stylo 0.19.0 → 0.20.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/dist/{InPlaceView-D2GIV1A-.js → InPlaceView-AZ_ufoP3.js} +634 -446
- package/dist/InPlaceView-AZ_ufoP3.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/inplace/InPlaceView.d.ts.map +1 -1
- package/dist/inplace/config.d.ts +4 -2
- package/dist/inplace/config.d.ts.map +1 -1
- package/dist/inplace/context-menu-actions.d.ts +1 -1
- package/dist/inplace/context-menu-actions.d.ts.map +1 -1
- package/dist/inplace/extension.d.ts +4 -2
- package/dist/inplace/extension.d.ts.map +1 -1
- package/dist/inplace/host-cell.d.ts +5 -1
- package/dist/inplace/host-cell.d.ts.map +1 -1
- package/dist/inplace/host-items.d.ts +2 -0
- package/dist/inplace/host-items.d.ts.map +1 -1
- package/dist/inplace/selection-rect.d.ts +11 -0
- package/dist/inplace/selection-rect.d.ts.map +1 -0
- package/dist/inplace/table-cell-dom.d.ts +3 -2
- package/dist/inplace/table-cell-dom.d.ts.map +1 -1
- package/dist/inplace/table-cell-marks.d.ts +50 -0
- package/dist/inplace/table-cell-marks.d.ts.map +1 -0
- package/dist/inplace/table-marks-plugin.d.ts +12 -0
- package/dist/inplace/table-marks-plugin.d.ts.map +1 -0
- package/dist/inplace/table-widget-render.d.ts +6 -0
- package/dist/inplace/table-widget-render.d.ts.map +1 -1
- package/dist/inplace/table-widget.d.ts +8 -0
- package/dist/inplace/table-widget.d.ts.map +1 -1
- package/dist/stylo.js +2 -2
- package/dist/types/inplace.d.ts +26 -2
- package/dist/types/inplace.d.ts.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/{useCodeMirror-Fn6qEfMx.js → useCodeMirror-DbhMZGZ7.js} +334 -322
- package/dist/useCodeMirror-DbhMZGZ7.js.map +1 -0
- package/package.json +1 -1
- package/dist/InPlaceView-D2GIV1A-.js.map +0 -1
- package/dist/useCodeMirror-Fn6qEfMx.js.map +0 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { l as e, s as t, u as n } from "./embed-cache-BU9Smn-h.js";
|
|
2
|
-
import { C as r, D as i, E as a, O as o, S as s, T as c, _ as l, a as u, b as d, c as f, d as p, f as m, g as h, h as ee, i as te, k as ne, l as re, m as ie, n as g, o as
|
|
3
|
-
import { a as
|
|
4
|
-
import { a as
|
|
5
|
-
import { t as
|
|
6
|
-
import { useRef as
|
|
7
|
-
import { Decoration as
|
|
8
|
-
import { createPortal as
|
|
9
|
-
import { Annotation as
|
|
10
|
-
import { syntaxTree as
|
|
11
|
-
import { jsx as
|
|
12
|
-
import { createRoot as
|
|
2
|
+
import { C as r, D as i, E as a, O as o, S as s, T as c, _ as l, a as u, b as d, c as f, d as p, f as m, g as h, h as ee, i as te, k as ne, l as re, m as ie, n as g, o as _, p as ae, r as oe, s as se, t as ce, u as v, v as le, w as y, x as b, y as x } from "./useCodeMirror-DbhMZGZ7.js";
|
|
3
|
+
import { a as ue, i as S } from "./config-DTBxVhtH.js";
|
|
4
|
+
import { a as de, n as fe, o as pe, r as me, t as C } from "./embed-DJAydn-v.js";
|
|
5
|
+
import { t as he } from "./katex-BfiLlqfN.js";
|
|
6
|
+
import { useRef as w, useState as T, useSyncExternalStore as ge } from "react";
|
|
7
|
+
import { Decoration as E, EditorView as D, ViewPlugin as O, WidgetType as k, hoverTooltip as _e, keymap as ve, showPanel as ye } from "@codemirror/view";
|
|
8
|
+
import { createPortal as be, flushSync as xe } from "react-dom";
|
|
9
|
+
import { Annotation as Se, EditorSelection as Ce, EditorState as we, Facet as A, Prec as j, StateEffect as Te, StateField as M } from "@codemirror/state";
|
|
10
|
+
import { syntaxTree as N } from "@codemirror/language";
|
|
11
|
+
import { jsx as Ee, jsxs as De } from "react/jsx-runtime";
|
|
12
|
+
import { createRoot as Oe } from "react-dom/client";
|
|
13
13
|
//#region src/inplace/embed-registry.ts
|
|
14
|
-
var
|
|
14
|
+
var ke = class {
|
|
15
15
|
slots = /* @__PURE__ */ new Map();
|
|
16
16
|
listeners = /* @__PURE__ */ new Set();
|
|
17
17
|
snapshot = [];
|
|
@@ -34,7 +34,7 @@ var je = class {
|
|
|
34
34
|
for (let e of this.listeners) e();
|
|
35
35
|
}));
|
|
36
36
|
}
|
|
37
|
-
},
|
|
37
|
+
}, Ae = {
|
|
38
38
|
headings: !0,
|
|
39
39
|
emphasis: !0,
|
|
40
40
|
links: !0,
|
|
@@ -49,20 +49,20 @@ var je = class {
|
|
|
49
49
|
tables: !0,
|
|
50
50
|
embeds: !0
|
|
51
51
|
};
|
|
52
|
-
function
|
|
52
|
+
function je(e) {
|
|
53
53
|
return {
|
|
54
|
-
...
|
|
54
|
+
...Ae,
|
|
55
55
|
...e?.decorations
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
|
-
var
|
|
58
|
+
var P = A.define({ combine: (e) => e[0] ?? Ae }), F = A.define({ combine: (e) => e[0] ?? null }), I = A.define({ combine: (e) => e[0] ?? "source" }), L = A.define({ combine: (e) => e[0] ?? "caret" }), Me = A.define({ combine: (e) => e[0] ?? null }), Ne = A.define({ combine: (e) => e[0] ?? !0 }), Pe = [
|
|
59
59
|
"host",
|
|
60
60
|
"link",
|
|
61
61
|
"format",
|
|
62
62
|
"paragraph",
|
|
63
63
|
"insert",
|
|
64
64
|
"clipboard"
|
|
65
|
-
],
|
|
65
|
+
], R = [
|
|
66
66
|
"bold",
|
|
67
67
|
"italic",
|
|
68
68
|
"strike",
|
|
@@ -71,48 +71,48 @@ var M = O.define({ combine: (e) => e[0] ?? Me }), N = O.define({ combine: (e) =>
|
|
|
71
71
|
"wikilink",
|
|
72
72
|
"math"
|
|
73
73
|
];
|
|
74
|
-
function
|
|
74
|
+
function Fe(e) {
|
|
75
75
|
return e === !1 ? {
|
|
76
76
|
enabled: !1,
|
|
77
77
|
groups: [],
|
|
78
78
|
items: []
|
|
79
79
|
} : e == null || e === !0 ? {
|
|
80
80
|
enabled: !0,
|
|
81
|
-
groups:
|
|
81
|
+
groups: Pe,
|
|
82
82
|
items: []
|
|
83
83
|
} : {
|
|
84
84
|
enabled: !0,
|
|
85
|
-
groups: e.groups?.length ? e.groups :
|
|
85
|
+
groups: e.groups?.length ? e.groups : Pe,
|
|
86
86
|
items: e.items ?? []
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
|
-
var
|
|
89
|
+
var Ie = A.define({ combine: (e) => e[0] ?? (() => []) }), Le = A.define({ combine: (e) => e[0] ?? (() => []) }), Re = A.define({ combine: (e) => e[0] ?? Pe });
|
|
90
90
|
function ze(e) {
|
|
91
|
-
if (!e?.length) return
|
|
92
|
-
let t = e.filter((e) =>
|
|
93
|
-
return t.length ? t :
|
|
91
|
+
if (!e?.length) return R;
|
|
92
|
+
let t = e.filter((e) => R.includes(e));
|
|
93
|
+
return t.length ? t : R;
|
|
94
94
|
}
|
|
95
|
-
var Be =
|
|
95
|
+
var Be = A.define({ combine: (e) => e[0] ?? R }), Ve = A.define({ combine: (e) => e[0] ?? "menu" });
|
|
96
96
|
//#endregion
|
|
97
97
|
//#region src/inplace/frontmatter.ts
|
|
98
98
|
function He(e) {
|
|
99
|
-
if (!e.facet(
|
|
99
|
+
if (!e.facet(P).frontmatter) return E.none;
|
|
100
100
|
let n = t(e.doc);
|
|
101
|
-
if (!n) return
|
|
101
|
+
if (!n) return E.none;
|
|
102
102
|
let r = e.doc.lineAt(n.from).number, i = e.doc.lineAt(n.to).number, a = e.selection.ranges.some((t) => {
|
|
103
103
|
let n = e.doc.lineAt(t.from).number;
|
|
104
104
|
return n >= r && n <= i;
|
|
105
105
|
}), o = [];
|
|
106
106
|
for (let t = r; t <= i; t++) {
|
|
107
107
|
let n = e.doc.line(t), s = t === r ? "cm-inplace-fm cm-inplace-fm-first" : "cm-inplace-fm";
|
|
108
|
-
o.push(
|
|
108
|
+
o.push(E.line({ class: s }).range(n.from)), (t === r || t === i) && !a && n.to > n.from && o.push(E.replace({}).range(n.from, n.to));
|
|
109
109
|
}
|
|
110
|
-
return
|
|
110
|
+
return E.set(o, !0);
|
|
111
111
|
}
|
|
112
|
-
var Ue =
|
|
112
|
+
var Ue = M.define({
|
|
113
113
|
create: He,
|
|
114
114
|
update: (e, t) => t.docChanged || t.selection ? He(t.state) : e,
|
|
115
|
-
provide: (e) =>
|
|
115
|
+
provide: (e) => D.decorations.from(e)
|
|
116
116
|
});
|
|
117
117
|
//#endregion
|
|
118
118
|
//#region src/inplace/list-guides.ts
|
|
@@ -130,16 +130,16 @@ function Ge(e, t, n, r, i, a) {
|
|
|
130
130
|
enter: (e) => {
|
|
131
131
|
if (e.name !== "ListItem") return;
|
|
132
132
|
let t = We(e), n = t - 1, i = r.lineAt(e.from).number, s = r.lineAt(Math.min(e.to, r.length)).number, c = e.node.getChild("BulletList") ?? e.node.getChild("OrderedList"), l = c ? r.lineAt(c.from).number : -1, u = c ? r.lineAt(Math.max(c.from, c.to - 1)).number : -1, d = e.node.prevSibling ? "cm-inplace-item-gap" : t > 1 ? "cm-inplace-item-gap-nested" : null;
|
|
133
|
-
for (let e = i; e <= s; e++) c && e >= l && e <= u || (n >= 1 && !o.has(e) && (o.add(e), a.push(
|
|
133
|
+
for (let e = i; e <= s; e++) c && e >= l && e <= u || (n >= 1 && !o.has(e) && (o.add(e), a.push(E.line({
|
|
134
134
|
class: "cm-inplace-li",
|
|
135
135
|
attributes: { style: `--sl-li-depth:${n}` }
|
|
136
|
-
}).range(r.line(e).from))), e === i && d && a.push(
|
|
136
|
+
}).range(r.line(e).from))), e === i && d && a.push(E.line({ class: d }).range(r.line(e).from)));
|
|
137
137
|
}
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
140
|
//#endregion
|
|
141
141
|
//#region src/inplace/reveal.ts
|
|
142
|
-
function
|
|
142
|
+
function z(e) {
|
|
143
143
|
let t = /* @__PURE__ */ new Set();
|
|
144
144
|
for (let n of e.selection.ranges) {
|
|
145
145
|
let r = e.doc.lineAt(n.from).number, i = e.doc.lineAt(n.to).number;
|
|
@@ -155,7 +155,7 @@ var Ke = /* @__PURE__ */ new Set([
|
|
|
155
155
|
"CodeBlock",
|
|
156
156
|
"CodeText"
|
|
157
157
|
]);
|
|
158
|
-
function
|
|
158
|
+
function B(e, t) {
|
|
159
159
|
let n = e.resolveInner(t, 1);
|
|
160
160
|
for (;;) {
|
|
161
161
|
if (Ke.has(n.name)) return !0;
|
|
@@ -202,7 +202,7 @@ function Qe(e, t) {
|
|
|
202
202
|
}
|
|
203
203
|
return null;
|
|
204
204
|
}
|
|
205
|
-
var $e = class extends
|
|
205
|
+
var $e = class extends k {
|
|
206
206
|
src;
|
|
207
207
|
block;
|
|
208
208
|
constructor(e, t) {
|
|
@@ -215,7 +215,7 @@ var $e = class extends E {
|
|
|
215
215
|
let e = document.createElement(this.block ? "div" : "span");
|
|
216
216
|
e.className = this.block ? "cm-inplace-math cm-inplace-math-block" : "cm-inplace-math";
|
|
217
217
|
try {
|
|
218
|
-
|
|
218
|
+
he.render(this.src, e, {
|
|
219
219
|
displayMode: this.block,
|
|
220
220
|
throwOnError: !1
|
|
221
221
|
});
|
|
@@ -233,11 +233,11 @@ function et(e, t, n, r, i, a, o) {
|
|
|
233
233
|
let { doc: s } = e.state, c = [];
|
|
234
234
|
for (let e of r.matchAll(Xe)) {
|
|
235
235
|
let n = (e[1] ?? "").trim(), r = t + (e.index ?? 0), l = r + (e[0] ?? "").length;
|
|
236
|
-
!n ||
|
|
236
|
+
!n || B(a, r + 2) || (c.push([r, l]), !Je(i, s, r, l) && o.push(E.replace({ widget: new $e(n, !0) }).range(r, l)));
|
|
237
237
|
}
|
|
238
238
|
for (let e of r.matchAll(Ye)) {
|
|
239
239
|
let n = (e[1] ?? "").trim(), r = t + (e.index ?? 0), l = r + (e[0] ?? "").length;
|
|
240
|
-
!n ||
|
|
240
|
+
!n || B(a, r + 1) || c.some(([e, t]) => r >= e && l <= t) || Je(i, s, r, l) || o.push(E.replace({ widget: new $e(n, !1) }).range(r, l));
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
243
|
function tt(e, t, n) {
|
|
@@ -251,38 +251,38 @@ function tt(e, t, n) {
|
|
|
251
251
|
}
|
|
252
252
|
return !1;
|
|
253
253
|
}
|
|
254
|
-
var nt =
|
|
254
|
+
var nt = M.define({
|
|
255
255
|
create: rt,
|
|
256
256
|
update(e, t) {
|
|
257
257
|
return t.docChanged || t.selection && (tt(t.state, t.startState.selection, e.ranges) || tt(t.state, t.state.selection, e.ranges)) ? rt(t.state) : e;
|
|
258
258
|
},
|
|
259
|
-
provide: (e) => [
|
|
259
|
+
provide: (e) => [D.decorations.from(e, (e) => e.decorations), D.atomicRanges.of((t) => t.state.field(e).decorations)]
|
|
260
260
|
});
|
|
261
261
|
function rt(e) {
|
|
262
|
-
if (!e.facet(
|
|
263
|
-
decorations:
|
|
262
|
+
if (!e.facet(P).math) return {
|
|
263
|
+
decorations: E.none,
|
|
264
264
|
ranges: []
|
|
265
265
|
};
|
|
266
266
|
let t = e.doc.toString();
|
|
267
267
|
if (!t.includes("$$")) return {
|
|
268
|
-
decorations:
|
|
268
|
+
decorations: E.none,
|
|
269
269
|
ranges: []
|
|
270
270
|
};
|
|
271
|
-
let n = [], r = [], i =
|
|
271
|
+
let n = [], r = [], i = z(e), a = N(e);
|
|
272
272
|
for (let o of t.matchAll(Ze)) {
|
|
273
273
|
let t = o[0] ?? "", s = (o[1] ?? "").trim();
|
|
274
274
|
if (!s || !t.includes("\n")) continue;
|
|
275
275
|
let c = o.index ?? 0, l = c + t.length, u = e.doc.lineAt(c), d = e.doc.lineAt(l), f = e.doc.sliceString(u.from, c).trim(), p = e.doc.sliceString(l, d.to).trim();
|
|
276
|
-
f === "" && p === "" && (
|
|
276
|
+
f === "" && p === "" && (B(a, c + 2) || (r.push({
|
|
277
277
|
from: c,
|
|
278
278
|
to: l
|
|
279
|
-
}), !Je(i, e.doc, c, l) && n.push(
|
|
279
|
+
}), !Je(i, e.doc, c, l) && n.push(E.replace({
|
|
280
280
|
widget: new $e(s, !0),
|
|
281
281
|
block: !0
|
|
282
282
|
}).range(c, l))));
|
|
283
283
|
}
|
|
284
284
|
return {
|
|
285
|
-
decorations:
|
|
285
|
+
decorations: E.set(n, !0),
|
|
286
286
|
ranges: r
|
|
287
287
|
};
|
|
288
288
|
}
|
|
@@ -314,22 +314,22 @@ function at(e, t, n) {
|
|
|
314
314
|
let { doc: r, revealed: i, out: a, toggles: o } = t;
|
|
315
315
|
if (!o[n.toggle]) return;
|
|
316
316
|
let s = e.node.getChildren(n.mark), c = s[0], l = s[s.length - 1], u = c && l && c !== l, d = u ? c.to : e.from, f = u ? l.from : e.to;
|
|
317
|
-
f > d && a.push(
|
|
317
|
+
f > d && a.push(E.mark({ class: n.className }).range(d, f)), u && !i.has(r.lineAt(e.from).number) && (a.push(E.replace({}).range(c.from, c.to)), a.push(E.replace({}).range(l.from, l.to)));
|
|
318
318
|
}
|
|
319
319
|
function ot(e, t) {
|
|
320
320
|
let { doc: n, revealed: r, out: i, toggles: a } = t, o = n.sliceString(Math.max(0, e.from - 1), e.from), s = n.sliceString(e.to, e.to + 1);
|
|
321
321
|
if (o === "[" && s === "]" || !a.links) return !1;
|
|
322
|
-
let c = n.lineAt(e.from), l =
|
|
322
|
+
let c = n.lineAt(e.from), l = me.exec(c.text);
|
|
323
323
|
if (l && e.from - c.from < l[1].length + l[2].length) return !1;
|
|
324
324
|
let u = e.node.getChildren("LinkMark");
|
|
325
325
|
if (u.length >= 2) {
|
|
326
326
|
let t = u[0], a = u[1];
|
|
327
|
-
a.from > t.to && i.push(
|
|
327
|
+
a.from > t.to && i.push(E.mark({ class: "cm-inplace-link" }).range(t.to, a.from)), r.has(n.lineAt(e.from).number) || (i.push(E.replace({}).range(e.from, t.to)), i.push(E.replace({}).range(a.from, e.to)));
|
|
328
328
|
}
|
|
329
329
|
}
|
|
330
330
|
//#endregion
|
|
331
331
|
//#region src/inplace/widgets.ts
|
|
332
|
-
var st = class extends
|
|
332
|
+
var st = class extends k {
|
|
333
333
|
eq() {
|
|
334
334
|
return !0;
|
|
335
335
|
}
|
|
@@ -340,7 +340,7 @@ var st = class extends E {
|
|
|
340
340
|
ignoreEvent() {
|
|
341
341
|
return !1;
|
|
342
342
|
}
|
|
343
|
-
}, ct = class extends
|
|
343
|
+
}, ct = class extends k {
|
|
344
344
|
eq() {
|
|
345
345
|
return !0;
|
|
346
346
|
}
|
|
@@ -351,7 +351,7 @@ var st = class extends E {
|
|
|
351
351
|
ignoreEvent() {
|
|
352
352
|
return !1;
|
|
353
353
|
}
|
|
354
|
-
}, lt = class extends
|
|
354
|
+
}, lt = class extends k {
|
|
355
355
|
checked;
|
|
356
356
|
constructor(e) {
|
|
357
357
|
super(), this.checked = e;
|
|
@@ -378,26 +378,26 @@ function dt(e, t) {
|
|
|
378
378
|
let { doc: n, revealed: r, out: i, toggles: a } = t;
|
|
379
379
|
if (!a.horizontalRule) return !1;
|
|
380
380
|
let o = n.lineAt(e.from);
|
|
381
|
-
return r.has(o.number) || (i.push(
|
|
381
|
+
return r.has(o.number) || (i.push(E.line({ class: "cm-inplace-hr-line" }).range(o.from)), i.push(E.replace({ widget: new st() }).range(o.from, o.to))), !1;
|
|
382
382
|
}
|
|
383
383
|
function ft(e, t) {
|
|
384
384
|
let { doc: n, revealed: r, caretRevealed: i, out: a, toggles: o, quoteRevealed: s } = t;
|
|
385
385
|
if (o.blockquote) {
|
|
386
|
-
let t = n.lineAt(e.from).number, o = n.lineAt(Math.min(e.to, n.length)).number, c = n.line(t), l =
|
|
386
|
+
let t = n.lineAt(e.from).number, o = n.lineAt(Math.min(e.to, n.length)).number, c = n.line(t), l = me.exec(c.text), u = l ? de(l[3]) : null, d = !1;
|
|
387
387
|
for (let e = t; e <= o; e++) i.has(e) && (d = !0);
|
|
388
388
|
if (d) for (let e = t; e <= o; e++) s.add(e);
|
|
389
389
|
for (let e = t; e <= o; e++) {
|
|
390
390
|
let r = u ? `cm-inplace-callout cm-inplace-callout-${u}` : "cm-inplace-quote";
|
|
391
391
|
u && e === t && (r += " cm-inplace-callout-head"), u && e === o && (r += " cm-inplace-callout-foot");
|
|
392
392
|
let i = {};
|
|
393
|
-
u && (i["data-callout"] = l[3].toLowerCase()), u && d && (i["data-revealed"] = ""), a.push(
|
|
393
|
+
u && (i["data-callout"] = l[3].toLowerCase()), u && d && (i["data-revealed"] = ""), a.push(E.line({
|
|
394
394
|
class: r,
|
|
395
395
|
attributes: i
|
|
396
396
|
}).range(n.line(e).from));
|
|
397
397
|
}
|
|
398
398
|
if (u && !d && !r.has(t)) {
|
|
399
399
|
let e = c.from + l[1].length;
|
|
400
|
-
a.push(
|
|
400
|
+
a.push(E.replace({}).range(e, e + l[2].length));
|
|
401
401
|
}
|
|
402
402
|
}
|
|
403
403
|
}
|
|
@@ -406,21 +406,21 @@ function pt(e, t) {
|
|
|
406
406
|
if (!a.blockquote) return !1;
|
|
407
407
|
let s = n.lineAt(e.from);
|
|
408
408
|
if (!r.has(s.number) && !o.has(s.number)) {
|
|
409
|
-
let t = Math.min(e.to + 1, s.to), n =
|
|
410
|
-
i.push(
|
|
409
|
+
let t = Math.min(e.to + 1, s.to), n = me.exec(s.text), r = n ? s.text.slice(n[1].length + n[2].length) : s.text.slice(t - s.from);
|
|
410
|
+
i.push(E.replace({}).range(e.from, r.trim() === "" ? e.to : t));
|
|
411
411
|
}
|
|
412
412
|
return !1;
|
|
413
413
|
}
|
|
414
414
|
function mt(e, t) {
|
|
415
415
|
let { doc: n, revealed: r, out: i, toggles: a } = t, o = n.sliceString(e.from, e.to), s = n.lineAt(e.from), c = e.node.parent, l = !!(c?.getChild("Task") ?? c?.getChild("TaskMarker"));
|
|
416
|
-
return r.has(s.number) || (l ? a.tasks && i.push(
|
|
416
|
+
return r.has(s.number) || (l ? a.tasks && i.push(E.replace({}).range(e.from, Math.min(e.to + 1, s.to))) : a.lists && ut.test(o) && i.push(E.replace({ widget: new ct() }).range(e.from, e.to))), !1;
|
|
417
417
|
}
|
|
418
418
|
function ht(e, t) {
|
|
419
419
|
let { doc: n, revealed: r, out: i, toggles: a } = t;
|
|
420
420
|
if (!a.tasks) return !1;
|
|
421
421
|
if (!r.has(n.lineAt(e.from).number)) {
|
|
422
422
|
let t = n.sliceString(e.from + 1, e.to - 1).toLowerCase() === "x";
|
|
423
|
-
i.push(
|
|
423
|
+
i.push(E.replace({ widget: new lt(t) }).range(e.from, e.to));
|
|
424
424
|
}
|
|
425
425
|
return !1;
|
|
426
426
|
}
|
|
@@ -434,7 +434,7 @@ function gt(e, t) {
|
|
|
434
434
|
let t = s && (e === c || e === l), r = "cm-inplace-mono";
|
|
435
435
|
e === c && (r += " cm-inplace-code-top"), e === l && (r += " cm-inplace-code-bottom"), t && (r += f ? " cm-inplace-code-pad" : " cm-inplace-fence");
|
|
436
436
|
let i = n.line(e);
|
|
437
|
-
a.push(
|
|
437
|
+
a.push(E.line({ class: r }).range(i.from)), t && f && i.to > i.from && a.push(E.replace({}).range(i.from, i.to));
|
|
438
438
|
}
|
|
439
439
|
return !1;
|
|
440
440
|
}
|
|
@@ -445,7 +445,7 @@ function yt(e, t, n) {
|
|
|
445
445
|
let { doc: r, revealed: i, out: a, toggles: o } = t;
|
|
446
446
|
if (o.headings) {
|
|
447
447
|
let t = r.lineAt(e.from);
|
|
448
|
-
if (a.push(
|
|
448
|
+
if (a.push(E.line({
|
|
449
449
|
class: `cm-inplace-heading cm-inplace-h${n}`,
|
|
450
450
|
attributes: {
|
|
451
451
|
role: "heading",
|
|
@@ -453,7 +453,7 @@ function yt(e, t, n) {
|
|
|
453
453
|
}
|
|
454
454
|
}).range(t.from)), !i.has(t.number)) {
|
|
455
455
|
let n = e.node.firstChild;
|
|
456
|
-
n?.name === "HeaderMark" && a.push(
|
|
456
|
+
n?.name === "HeaderMark" && a.push(E.replace({}).range(n.from, Math.min(n.to + 1, t.to)));
|
|
457
457
|
}
|
|
458
458
|
}
|
|
459
459
|
}
|
|
@@ -461,7 +461,7 @@ function bt(e, t, n) {
|
|
|
461
461
|
let { doc: r, caretRevealed: i, out: a, toggles: o } = t;
|
|
462
462
|
if (o.headings) {
|
|
463
463
|
let t = r.lineAt(e.from);
|
|
464
|
-
a.push(
|
|
464
|
+
a.push(E.line({
|
|
465
465
|
class: `cm-inplace-heading cm-inplace-h${n}`,
|
|
466
466
|
attributes: {
|
|
467
467
|
role: "heading",
|
|
@@ -471,7 +471,7 @@ function bt(e, t, n) {
|
|
|
471
471
|
let o = e.node.getChild("HeaderMark");
|
|
472
472
|
if (o) {
|
|
473
473
|
let e = r.lineAt(o.from);
|
|
474
|
-
!i.has(t.number) && !i.has(e.number) && (a.push(
|
|
474
|
+
!i.has(t.number) && !i.has(e.number) && (a.push(E.line({ class: "cm-inplace-setext-rule" }).range(e.from)), a.push(E.replace({}).range(o.from, o.to)));
|
|
475
475
|
}
|
|
476
476
|
}
|
|
477
477
|
}
|
|
@@ -495,22 +495,22 @@ function xt(e, t) {
|
|
|
495
495
|
//#region src/inplace/wikilinks.ts
|
|
496
496
|
function St(t, n, r, i, a, o, s) {
|
|
497
497
|
if (!i.includes("[[")) return;
|
|
498
|
-
let c = t.state.facet(
|
|
498
|
+
let c = t.state.facet(F) != null;
|
|
499
499
|
for (let r of i.matchAll(e)) {
|
|
500
500
|
let [e = "", i = "", l] = r, u = i.trim(), d = n + (r.index ?? 0);
|
|
501
|
-
if (!u ||
|
|
501
|
+
if (!u || B(o, d + 1) || c && d > 0 && t.state.doc.sliceString(d - 1, d) === "!") continue;
|
|
502
502
|
let f = d + e.length, p = l == null ? d + 2 : d + 2 + i.length + 1, m = f - 2;
|
|
503
|
-
s.push(
|
|
503
|
+
s.push(E.mark({
|
|
504
504
|
class: "cm-inplace-link cm-inplace-wikilink",
|
|
505
505
|
attributes: { "data-stylo-wikilink": u }
|
|
506
|
-
}).range(p, m)), a.has(t.state.doc.lineAt(d).number) || (s.push(
|
|
506
|
+
}).range(p, m)), a.has(t.state.doc.lineAt(d).number) || (s.push(E.replace({}).range(d, p)), s.push(E.replace({}).range(m, f)));
|
|
507
507
|
}
|
|
508
508
|
}
|
|
509
509
|
//#endregion
|
|
510
510
|
//#region src/inplace/decorate.ts
|
|
511
|
-
var Ct = /* @__PURE__ */ new Set(), wt =
|
|
511
|
+
var Ct = /* @__PURE__ */ new Set(), wt = E.replace({});
|
|
512
512
|
function Tt(e) {
|
|
513
|
-
let n = [], r =
|
|
513
|
+
let n = [], r = z(e.state), i = e.state.facet(L) === "never" ? Ct : r, a = N(e.state), { doc: o } = e.state, s = e.state.facet(P), c = {
|
|
514
514
|
doc: o,
|
|
515
515
|
revealed: i,
|
|
516
516
|
caretRevealed: r,
|
|
@@ -538,13 +538,13 @@ function Tt(e) {
|
|
|
538
538
|
t && e.from <= t.to ? e.to > t.to && (u[u.length - 1] = wt.range(t.from, e.to)) : u.push(wt.range(e.from, e.to));
|
|
539
539
|
}
|
|
540
540
|
return {
|
|
541
|
-
decorations:
|
|
542
|
-
atomic:
|
|
541
|
+
decorations: E.set(n, !0),
|
|
542
|
+
atomic: E.set(u, !0)
|
|
543
543
|
};
|
|
544
544
|
}
|
|
545
545
|
//#endregion
|
|
546
546
|
//#region src/inplace/plugin.ts
|
|
547
|
-
var Et =
|
|
547
|
+
var Et = O.fromClass(class {
|
|
548
548
|
decorations;
|
|
549
549
|
atomic;
|
|
550
550
|
constructor(e) {
|
|
@@ -559,7 +559,7 @@ var Et = T.fromClass(class {
|
|
|
559
559
|
}
|
|
560
560
|
}, {
|
|
561
561
|
decorations: (e) => e.decorations,
|
|
562
|
-
provide: (e) =>
|
|
562
|
+
provide: (e) => D.atomicRanges.of((t) => t.plugin(e)?.atomic ?? E.none)
|
|
563
563
|
});
|
|
564
564
|
function Dt() {
|
|
565
565
|
return Et;
|
|
@@ -584,13 +584,13 @@ var Ot = {
|
|
|
584
584
|
toggle: "code"
|
|
585
585
|
}
|
|
586
586
|
};
|
|
587
|
-
function
|
|
588
|
-
return e.facet(
|
|
587
|
+
function V(e, t) {
|
|
588
|
+
return e.facet(L) === "never" || !z(e).has(t);
|
|
589
589
|
}
|
|
590
|
-
function
|
|
590
|
+
function H(t, n, r = !1, i = !1) {
|
|
591
591
|
let a = t.doc.lineAt(n);
|
|
592
|
-
if (!i && !
|
|
593
|
-
let o = t.facet(
|
|
592
|
+
if (!i && !V(t, a.number)) return null;
|
|
593
|
+
let o = t.facet(P), s = N(t);
|
|
594
594
|
for (let e of [-1, 1]) for (let i = s.resolveInner(n, e); i; i = i.parent) {
|
|
595
595
|
let e = Ot[i.name];
|
|
596
596
|
if (e) {
|
|
@@ -648,13 +648,13 @@ var At = (e) => (t) => {
|
|
|
648
648
|
let n = t.state.selection.main;
|
|
649
649
|
if (!n.empty) return !1;
|
|
650
650
|
let { state: r } = t;
|
|
651
|
-
if (!
|
|
651
|
+
if (!V(r, r.doc.lineAt(n.head).number)) return !1;
|
|
652
652
|
let i = kt(t, n.head, e);
|
|
653
653
|
if (i === n.head) return !1;
|
|
654
654
|
let a = r.doc;
|
|
655
655
|
if (e < 0 ? i <= 0 : i >= a.length) return !0;
|
|
656
656
|
let o = e < 0 ? i - 1 : i, s = e < 0 ? i : i + 1;
|
|
657
|
-
for (let e =
|
|
657
|
+
for (let e = H(r, o); e && o <= e.contentFrom && s >= e.contentTo && e.contentTo > e.contentFrom && !(e.from >= o && e.to <= s); e = H(r, o)) o = Math.min(o, e.from), s = Math.max(s, e.to);
|
|
658
658
|
return t.dispatch({
|
|
659
659
|
changes: {
|
|
660
660
|
from: o,
|
|
@@ -675,18 +675,18 @@ function Nt(e, t, n) {
|
|
|
675
675
|
n.spec.widget || n.spec.class || t <= e || e <= i && (i = Math.max(i, t));
|
|
676
676
|
}), i >= n;
|
|
677
677
|
}
|
|
678
|
-
var
|
|
678
|
+
var U = (e, t) => (n) => {
|
|
679
679
|
if (h(n)) return !1;
|
|
680
680
|
let r = n.state.selection.main;
|
|
681
|
-
if (!t && !r.empty || !
|
|
681
|
+
if (!t && !r.empty || !V(n.state, n.state.doc.lineAt(r.head).number)) return !1;
|
|
682
682
|
let i = n.moveByChar(r, e);
|
|
683
683
|
if (Nt(n, Math.min(r.head, i.head), Math.max(r.head, i.head)) && (i = n.moveByChar(i, e)), i.head === r.head) return !1;
|
|
684
|
-
let a = t ?
|
|
684
|
+
let a = t ? Ce.range(r.anchor, i.head) : Ce.cursor(i.head);
|
|
685
685
|
return n.dispatch({
|
|
686
686
|
selection: a,
|
|
687
687
|
userEvent: "select"
|
|
688
688
|
}), !0;
|
|
689
|
-
}, Pt =
|
|
689
|
+
}, Pt = U(!1, !1), Ft = U(!0, !1), It = U(!1, !0), Lt = U(!0, !0), Rt = j.high(ve.of([
|
|
690
690
|
{
|
|
691
691
|
key: "Backspace",
|
|
692
692
|
run: jt
|
|
@@ -711,43 +711,155 @@ var H = (e, t) => (n) => {
|
|
|
711
711
|
key: "Shift-ArrowRight",
|
|
712
712
|
run: Lt
|
|
713
713
|
}
|
|
714
|
-
]))
|
|
714
|
+
]));
|
|
715
|
+
//#endregion
|
|
716
|
+
//#region src/inplace/table-cell-marks.ts
|
|
717
|
+
function zt(e, t, n, r) {
|
|
718
|
+
let i = {
|
|
719
|
+
marks: [],
|
|
720
|
+
cellClass: []
|
|
721
|
+
};
|
|
722
|
+
for (let a of e) if (!(a.to <= t || a.from >= t + r || a.to <= a.from)) {
|
|
723
|
+
i.marks.push({
|
|
724
|
+
from: Math.max(a.from - t, 0) + n,
|
|
725
|
+
to: Math.min(a.to - t, r) + n,
|
|
726
|
+
class: a.class,
|
|
727
|
+
attributes: a.attributes
|
|
728
|
+
});
|
|
729
|
+
for (let e of a.cellClass?.split(/\s+/) ?? []) e && !i.cellClass.includes(e) && i.cellClass.push(e);
|
|
730
|
+
}
|
|
731
|
+
return i.marks.length || i.cellClass.length ? i : null;
|
|
732
|
+
}
|
|
733
|
+
function Bt(e, t) {
|
|
734
|
+
let n = document.createElement("span");
|
|
735
|
+
n.className = e.class;
|
|
736
|
+
for (let [t, r] of Object.entries(e.attributes ?? {})) try {
|
|
737
|
+
n.setAttribute(t, r);
|
|
738
|
+
} catch {}
|
|
739
|
+
return n.append(t), n;
|
|
740
|
+
}
|
|
741
|
+
function Vt(e, t) {
|
|
742
|
+
let n = e.node.data, r = e.start + n.length, i = t.filter((t) => t.from < r && t.to > e.start);
|
|
743
|
+
if (!i.length) return !1;
|
|
744
|
+
let a = /* @__PURE__ */ new Set([e.start, r]);
|
|
745
|
+
for (let t of i) a.add(Math.max(t.from, e.start)), a.add(Math.min(t.to, r));
|
|
746
|
+
let o = [...a].sort((e, t) => e - t), s = document.createDocumentFragment();
|
|
747
|
+
for (let t = 0; t < o.length - 1; t++) {
|
|
748
|
+
let [r, a] = [o[t], o[t + 1]], c = document.createTextNode(n.slice(r - e.start, a - e.start));
|
|
749
|
+
for (let e of i) e.from <= r && e.to >= a && (c = Bt(e, c));
|
|
750
|
+
s.append(c);
|
|
751
|
+
}
|
|
752
|
+
return e.node.replaceWith(s), !0;
|
|
753
|
+
}
|
|
754
|
+
function Ht(e, t) {
|
|
755
|
+
let n = [], r = 0, i = (e) => {
|
|
756
|
+
for (let a of e.childNodes) if (a instanceof Text) {
|
|
757
|
+
let e = t.indexOf(a.data, r);
|
|
758
|
+
if (e < 0) return !1;
|
|
759
|
+
n.push({
|
|
760
|
+
node: a,
|
|
761
|
+
start: e
|
|
762
|
+
}), r = e + a.data.length;
|
|
763
|
+
} else if (a.hasAttribute?.("data-stylo-wikilink")) {
|
|
764
|
+
let e = t.indexOf("[[", r), i = e < 0 ? -1 : t.indexOf("]]", e), o = a.firstChild;
|
|
765
|
+
if (i < 0 || !(o instanceof Text)) return !1;
|
|
766
|
+
n.push({
|
|
767
|
+
node: o,
|
|
768
|
+
start: i - o.data.length
|
|
769
|
+
}), r = i + 2;
|
|
770
|
+
} else if (a.classList?.contains("cm-inplace-math")) {
|
|
771
|
+
let e = t.indexOf("$", r), n = e < 0 ? -1 : t.indexOf("$", e + 1);
|
|
772
|
+
if (n < 0) return !1;
|
|
773
|
+
r = n + 1;
|
|
774
|
+
} else if (!i(a)) return !1;
|
|
775
|
+
return !0;
|
|
776
|
+
};
|
|
777
|
+
return i(e) ? n : null;
|
|
778
|
+
}
|
|
779
|
+
function Ut(e, t) {
|
|
780
|
+
for (let n of t) {
|
|
781
|
+
let t = Bt(n, e.ownerDocument.createDocumentFragment());
|
|
782
|
+
t.append(...e.childNodes), e.append(t);
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
function Wt(e, t, n, r) {
|
|
786
|
+
let i = n.marks, a = [], o;
|
|
787
|
+
if (r) o = e.firstChild instanceof Text ? [{
|
|
788
|
+
node: e.firstChild,
|
|
789
|
+
start: 0
|
|
790
|
+
}] : null;
|
|
791
|
+
else {
|
|
792
|
+
let n = [...t.matchAll(/\\\|/g)].map((e) => e.index), r = (e) => e - n.filter((t) => t < e).length;
|
|
793
|
+
o = Ht(e, t.replace(/\\\|/g, "|")), i = i.map((e) => ({
|
|
794
|
+
...e,
|
|
795
|
+
from: r(e.from),
|
|
796
|
+
to: r(e.to)
|
|
797
|
+
}));
|
|
798
|
+
}
|
|
799
|
+
if (!o) return Ut(e, i);
|
|
800
|
+
let s = /* @__PURE__ */ new Set();
|
|
801
|
+
for (let e of o) for (let t of i) t.from < e.start + e.node.data.length && t.to > e.start && s.add(t);
|
|
802
|
+
for (let e of i) s.has(e) || a.push(e);
|
|
803
|
+
for (let e of o) Vt(e, i);
|
|
804
|
+
Ut(e, a);
|
|
805
|
+
}
|
|
806
|
+
function Gt(e) {
|
|
807
|
+
let t = null;
|
|
808
|
+
return (n, r) => {
|
|
809
|
+
let i = e.view();
|
|
810
|
+
if (!i || !e.mounted()) return null;
|
|
811
|
+
if (t?.state !== i.state) {
|
|
812
|
+
let n = i.state.facet(Le)(i.state);
|
|
813
|
+
t = {
|
|
814
|
+
state: i.state,
|
|
815
|
+
marks: n,
|
|
816
|
+
from: n.length ? e.from(i) : 0
|
|
817
|
+
};
|
|
818
|
+
}
|
|
819
|
+
if (!t.marks.length) return null;
|
|
820
|
+
let a = v(i.state.doc, t.from, n, r), o = e.raw(n, r);
|
|
821
|
+
return a == null ? null : zt(t.marks, a, o.length - o.trimStart().length, o.trim().length);
|
|
822
|
+
};
|
|
823
|
+
}
|
|
824
|
+
//#endregion
|
|
825
|
+
//#region src/inplace/context-menu-helpers.ts
|
|
826
|
+
var Kt = (e) => e === "h1" || e === "h2" || e === "h3" ? S.heading : S[e], qt = [
|
|
715
827
|
"bold",
|
|
716
828
|
"italic",
|
|
717
829
|
"strike"
|
|
718
|
-
],
|
|
830
|
+
], Jt = ["code", "math"], Yt = [
|
|
719
831
|
"bulletList",
|
|
720
832
|
"orderedList",
|
|
721
833
|
"task"
|
|
722
|
-
],
|
|
834
|
+
], Xt = [
|
|
723
835
|
"h1",
|
|
724
836
|
"h2",
|
|
725
837
|
"h3"
|
|
726
|
-
],
|
|
838
|
+
], Zt = ["table", "hr"], Qt = [
|
|
727
839
|
"codeBlock",
|
|
728
840
|
"mathBlock",
|
|
729
841
|
"frontmatter"
|
|
730
|
-
],
|
|
842
|
+
], $t = (e, t, n = !1) => {
|
|
731
843
|
let r = g[t];
|
|
732
844
|
if (!r) return null;
|
|
733
845
|
let { disabled: i, active: a } = re(e.state, r, n);
|
|
734
846
|
return {
|
|
735
847
|
label: r.title,
|
|
736
|
-
icon:
|
|
848
|
+
icon: Kt(t),
|
|
737
849
|
active: a,
|
|
738
850
|
disabled: i,
|
|
739
851
|
onSelect: () => {
|
|
740
852
|
r.run(e), e.focus();
|
|
741
853
|
}
|
|
742
854
|
};
|
|
743
|
-
},
|
|
855
|
+
}, W = (e, t, n = !1, r = !1) => {
|
|
744
856
|
let i = [];
|
|
745
857
|
for (let a of t) {
|
|
746
|
-
let t =
|
|
858
|
+
let t = $t(e, a, r);
|
|
747
859
|
t && !(n && t.disabled) && i.push(t);
|
|
748
860
|
}
|
|
749
861
|
return i;
|
|
750
|
-
},
|
|
862
|
+
}, G = (e) => {
|
|
751
863
|
let t = e.contentDOM.ownerDocument, n = (n) => () => {
|
|
752
864
|
e.focus();
|
|
753
865
|
try {
|
|
@@ -757,17 +869,17 @@ var H = (e, t) => (n) => {
|
|
|
757
869
|
return [
|
|
758
870
|
{
|
|
759
871
|
label: "Cut",
|
|
760
|
-
icon:
|
|
872
|
+
icon: S.cut,
|
|
761
873
|
onSelect: n("cut")
|
|
762
874
|
},
|
|
763
875
|
{
|
|
764
876
|
label: "Copy",
|
|
765
|
-
icon:
|
|
877
|
+
icon: S.copy,
|
|
766
878
|
onSelect: n("copy")
|
|
767
879
|
},
|
|
768
880
|
i ? {
|
|
769
881
|
label: "Paste",
|
|
770
|
-
icon:
|
|
882
|
+
icon: S.paste,
|
|
771
883
|
onSelect: () => {
|
|
772
884
|
let n = h(e);
|
|
773
885
|
n || e.focus(), r?.readText().then((r) => {
|
|
@@ -776,45 +888,45 @@ var H = (e, t) => (n) => {
|
|
|
776
888
|
}
|
|
777
889
|
} : {
|
|
778
890
|
label: "Paste",
|
|
779
|
-
icon:
|
|
891
|
+
icon: S.paste,
|
|
780
892
|
disabled: !0,
|
|
781
893
|
title: "Paste with the keyboard shortcut",
|
|
782
894
|
onSelect: () => {}
|
|
783
895
|
}
|
|
784
896
|
];
|
|
785
|
-
},
|
|
897
|
+
}, K = (e, t, n, r = !1) => ({
|
|
786
898
|
label: e,
|
|
787
899
|
icon: t,
|
|
788
900
|
rows: n,
|
|
789
901
|
disabled: r
|
|
790
902
|
});
|
|
791
|
-
function
|
|
903
|
+
function q(e, t) {
|
|
792
904
|
t.length && (e.length && e.push("separator"), e.push(...t));
|
|
793
905
|
}
|
|
794
906
|
//#endregion
|
|
795
907
|
//#region src/inplace/edit-divider.ts
|
|
796
|
-
function
|
|
908
|
+
function en(e) {
|
|
797
909
|
let t = e.selection.main;
|
|
798
910
|
if (!t.empty) return !1;
|
|
799
911
|
let n = e.doc.lineAt(t.head);
|
|
800
|
-
if (!
|
|
801
|
-
for (let t =
|
|
912
|
+
if (!V(e, n.number)) return !1;
|
|
913
|
+
for (let t = N(e).resolveInner(n.from, 1); t; t = t.parent) {
|
|
802
914
|
if (t.name === "HorizontalRule") return !0;
|
|
803
915
|
if (!t.parent) break;
|
|
804
916
|
}
|
|
805
917
|
return !1;
|
|
806
918
|
}
|
|
807
|
-
var
|
|
919
|
+
var tn = (e) => h(e) || !en(e.state) ? !1 : oe(e), nn = j.high(ve.of([{
|
|
808
920
|
key: "Backspace",
|
|
809
|
-
run:
|
|
921
|
+
run: tn
|
|
810
922
|
}, {
|
|
811
923
|
key: "Delete",
|
|
812
|
-
run:
|
|
924
|
+
run: tn
|
|
813
925
|
}]));
|
|
814
|
-
function
|
|
926
|
+
function rn(e) {
|
|
815
927
|
return {
|
|
816
928
|
label: "Remove divider",
|
|
817
|
-
icon:
|
|
929
|
+
icon: S.hr,
|
|
818
930
|
onSelect: () => {
|
|
819
931
|
g.hr?.run(e), e.focus();
|
|
820
932
|
}
|
|
@@ -822,66 +934,66 @@ function Xt(e) {
|
|
|
822
934
|
}
|
|
823
935
|
//#endregion
|
|
824
936
|
//#region src/inplace/inline-md.ts
|
|
825
|
-
function
|
|
937
|
+
function an(e, t = !1) {
|
|
826
938
|
let n = document.createDocumentFragment();
|
|
827
|
-
return
|
|
939
|
+
return cn(n, e, t), n;
|
|
828
940
|
}
|
|
829
|
-
var
|
|
941
|
+
var on = /!\[\[[^\]\n]+?\]\]/, sn = [
|
|
830
942
|
{
|
|
831
943
|
re: /`([^`\n]+)`/,
|
|
832
|
-
build: (e) =>
|
|
944
|
+
build: (e) => J("code", "cm-inplace-code", document.createTextNode(e[1]))
|
|
833
945
|
},
|
|
834
946
|
{
|
|
835
947
|
re: new RegExp(Ye.source),
|
|
836
948
|
build: (e) => {
|
|
837
|
-
let t =
|
|
838
|
-
return
|
|
949
|
+
let t = J("span", "cm-inplace-math");
|
|
950
|
+
return he.render(e[1], t, { throwOnError: !1 }), t;
|
|
839
951
|
}
|
|
840
952
|
},
|
|
841
953
|
{
|
|
842
954
|
re: new RegExp(e.source),
|
|
843
955
|
build: (e) => {
|
|
844
|
-
let t =
|
|
956
|
+
let t = J("span", "cm-inplace-wikilink", document.createTextNode(e[2] || e[1] || ""));
|
|
845
957
|
return t.dataset.styloWikilink = e[1] ?? "", t;
|
|
846
958
|
}
|
|
847
959
|
},
|
|
848
960
|
{
|
|
849
961
|
re: /\[([^\]\n]*)\]\(([^)\n]*)\)/,
|
|
850
962
|
build: (e, t) => {
|
|
851
|
-
let n =
|
|
852
|
-
return n.href = e[2] ?? "", n.append(
|
|
963
|
+
let n = J("a", "cm-inplace-link");
|
|
964
|
+
return n.href = e[2] ?? "", n.append(Y(e[1] ?? "", t)), n;
|
|
853
965
|
}
|
|
854
966
|
},
|
|
855
967
|
{
|
|
856
968
|
re: /\*\*\*([^*\n]+?)\*\*\*/,
|
|
857
|
-
build: (e, t) =>
|
|
969
|
+
build: (e, t) => J("strong", "cm-inplace-strong", J("em", "cm-inplace-em", Y(e[1], t)))
|
|
858
970
|
},
|
|
859
971
|
{
|
|
860
972
|
re: /\*\*([^\n]+?)\*\*/,
|
|
861
|
-
build: (e, t) =>
|
|
973
|
+
build: (e, t) => J("strong", "cm-inplace-strong", Y(e[1], t))
|
|
862
974
|
},
|
|
863
975
|
{
|
|
864
976
|
re: /~~([^\n]+?)~~/,
|
|
865
|
-
build: (e, t) =>
|
|
977
|
+
build: (e, t) => J("span", "cm-inplace-strike", Y(e[1], t))
|
|
866
978
|
},
|
|
867
979
|
{
|
|
868
980
|
re: /(?<!\*)\*(?!\*|\s)([^\n]+?)(?<!\s)\*(?!\*)/,
|
|
869
|
-
build: (e, t) =>
|
|
981
|
+
build: (e, t) => J("em", "cm-inplace-em", Y(e[1], t))
|
|
870
982
|
}
|
|
871
983
|
];
|
|
872
|
-
function
|
|
984
|
+
function J(e, t, ...n) {
|
|
873
985
|
let r = document.createElement(e);
|
|
874
986
|
return r.className = t, r.append(...n), r;
|
|
875
987
|
}
|
|
876
|
-
function
|
|
988
|
+
function Y(e, t) {
|
|
877
989
|
let n = document.createDocumentFragment();
|
|
878
|
-
return
|
|
990
|
+
return cn(n, e, t), n;
|
|
879
991
|
}
|
|
880
|
-
function
|
|
992
|
+
function cn(e, t, n) {
|
|
881
993
|
for (; t;) {
|
|
882
|
-
let r = -1, i = null, a = n ?
|
|
994
|
+
let r = -1, i = null, a = n ? on.exec(t) : null;
|
|
883
995
|
a && (r = a.index, i = { literal: a[0] });
|
|
884
|
-
for (let e of
|
|
996
|
+
for (let e of sn) {
|
|
885
997
|
let n = e.re.exec(t);
|
|
886
998
|
n && (r < 0 || n.index < r) && (r = n.index, i = {
|
|
887
999
|
rule: e,
|
|
@@ -897,7 +1009,7 @@ function en(e, t, n) {
|
|
|
897
1009
|
}
|
|
898
1010
|
//#endregion
|
|
899
1011
|
//#region src/inplace/tables.ts
|
|
900
|
-
var
|
|
1012
|
+
var ln = class extends k {
|
|
901
1013
|
table;
|
|
902
1014
|
embeds;
|
|
903
1015
|
constructor(e, t) {
|
|
@@ -909,17 +1021,17 @@ var tn = class extends E {
|
|
|
909
1021
|
toDOM() {
|
|
910
1022
|
let { head: e, body: t, aligns: n } = this.table, r = document.createElement("table");
|
|
911
1023
|
r.className = "cm-inplace-table";
|
|
912
|
-
let i = (e) =>
|
|
1024
|
+
let i = (e) => an(e.replace(/\\\|/g, "|"), this.embeds), a = r.createTHead().insertRow();
|
|
913
1025
|
e.forEach((e, t) => {
|
|
914
1026
|
let r = document.createElement("th");
|
|
915
|
-
r.appendChild(i(e)), r.dataset.styloRow = "0", r.dataset.styloCol = String(t),
|
|
1027
|
+
r.appendChild(i(e)), r.dataset.styloRow = "0", r.dataset.styloCol = String(t), un(r, n[t]), a.appendChild(r);
|
|
916
1028
|
});
|
|
917
1029
|
let o = r.createTBody();
|
|
918
1030
|
return t.forEach((t, r) => {
|
|
919
1031
|
let a = o.insertRow();
|
|
920
1032
|
for (let o = 0; o < e.length; o++) {
|
|
921
1033
|
let e = a.insertCell();
|
|
922
|
-
e.appendChild(i(t[o] ?? "")), e.dataset.styloRow = String(r + 1), e.dataset.styloCol = String(o),
|
|
1034
|
+
e.appendChild(i(t[o] ?? "")), e.dataset.styloRow = String(r + 1), e.dataset.styloCol = String(o), un(e, n[o]);
|
|
923
1035
|
}
|
|
924
1036
|
}), r;
|
|
925
1037
|
}
|
|
@@ -927,10 +1039,10 @@ var tn = class extends E {
|
|
|
927
1039
|
return !1;
|
|
928
1040
|
}
|
|
929
1041
|
};
|
|
930
|
-
function
|
|
1042
|
+
function un(e, t) {
|
|
931
1043
|
t && (e.style.textAlign = t);
|
|
932
1044
|
}
|
|
933
|
-
function
|
|
1045
|
+
function dn(e, t) {
|
|
934
1046
|
let n = t.lineAt(e.from).number, r = t.lineAt(e.to).number, i = [];
|
|
935
1047
|
for (let e = n; e <= r; e++) i.push(t.line(e).text);
|
|
936
1048
|
let a = p(i);
|
|
@@ -940,17 +1052,17 @@ function rn(e, t) {
|
|
|
940
1052
|
aligns: a.aligns
|
|
941
1053
|
};
|
|
942
1054
|
}
|
|
943
|
-
function
|
|
944
|
-
let n =
|
|
1055
|
+
function fn(e, t) {
|
|
1056
|
+
let n = N(e);
|
|
945
1057
|
for (let e of [-1, 1]) for (let r = n.resolveInner(t, e); r; r = r.parent) if (r.name === "Table") return !0;
|
|
946
1058
|
return !1;
|
|
947
1059
|
}
|
|
948
|
-
function
|
|
949
|
-
return t.ranges.some((t) =>
|
|
1060
|
+
function pn(e, t) {
|
|
1061
|
+
return t.ranges.some((t) => fn(e, t.from) || fn(e, t.to));
|
|
950
1062
|
}
|
|
951
|
-
function
|
|
952
|
-
if (!e.facet(
|
|
953
|
-
let n = e.facet(
|
|
1063
|
+
function mn(e) {
|
|
1064
|
+
if (!e.facet(P).tables) return E.none;
|
|
1065
|
+
let n = e.facet(I) === "cells" && !e.readOnly, r = e.facet(F) != null && e.facet(P).embeds, i = N(e), a = t(e.doc), o = n ? null : z(e), s = [];
|
|
954
1066
|
return i.iterate({ enter: (t) => {
|
|
955
1067
|
if (t.name !== "Table") return;
|
|
956
1068
|
if (a && t.from < a.to) return !1;
|
|
@@ -958,82 +1070,115 @@ function sn(e) {
|
|
|
958
1070
|
let n = e.doc.lineAt(t.from).number, r = e.doc.lineAt(t.to).number;
|
|
959
1071
|
for (let e = n; e <= r; e++) if (o.has(e)) return !1;
|
|
960
1072
|
}
|
|
961
|
-
let i =
|
|
1073
|
+
let i = dn(t.node, e.doc);
|
|
962
1074
|
if (i) {
|
|
963
|
-
let e = n ? new
|
|
964
|
-
s.push(
|
|
1075
|
+
let e = n ? new ur(i, r) : new ln(i, r);
|
|
1076
|
+
s.push(E.replace({
|
|
965
1077
|
widget: e,
|
|
966
1078
|
block: !0
|
|
967
1079
|
}).range(t.from, t.to));
|
|
968
1080
|
}
|
|
969
1081
|
return !1;
|
|
970
|
-
} }),
|
|
1082
|
+
} }), E.set(s, !0);
|
|
971
1083
|
}
|
|
972
|
-
var
|
|
973
|
-
create:
|
|
1084
|
+
var X = M.define({
|
|
1085
|
+
create: mn,
|
|
974
1086
|
update: (e, t) => {
|
|
975
|
-
if (t.annotation(
|
|
1087
|
+
if (t.annotation(cr)) return e.map(t.changes);
|
|
976
1088
|
let n = t.startState.readOnly !== t.state.readOnly;
|
|
977
|
-
return t.state.facet(
|
|
1089
|
+
return t.state.facet(I) === "cells" ? t.docChanged || n ? mn(t.state) : e.map(t.changes) : t.docChanged || n || t.selection && (pn(t.state, t.startState.selection) || pn(t.state, t.state.selection)) ? mn(t.state) : e;
|
|
978
1090
|
},
|
|
979
|
-
provide: (e) => [
|
|
1091
|
+
provide: (e) => [D.decorations.from(e), D.atomicRanges.of((t) => t.state.field(e))]
|
|
980
1092
|
});
|
|
981
1093
|
//#endregion
|
|
982
1094
|
//#region src/inplace/host-cell.ts
|
|
983
|
-
function
|
|
984
|
-
let
|
|
985
|
-
if (!
|
|
986
|
-
let
|
|
987
|
-
e.state.field(
|
|
988
|
-
let
|
|
989
|
-
if (
|
|
990
|
-
let { from:
|
|
1095
|
+
function hn(e, t, n) {
|
|
1096
|
+
let i = t.closest("table");
|
|
1097
|
+
if (!i) return;
|
|
1098
|
+
let a = e.posAtDOM(i), o = a;
|
|
1099
|
+
e.state.field(X).between(a, a, (e) => (o = e, !1));
|
|
1100
|
+
let s = v(e.state.doc, o, Number(t.dataset.r), Number(t.dataset.c));
|
|
1101
|
+
if (s == null) return;
|
|
1102
|
+
let { from: c, to: l } = n ? r(t) : {
|
|
1103
|
+
from: 0,
|
|
1104
|
+
to: 0
|
|
1105
|
+
};
|
|
991
1106
|
e.dispatch({ selection: {
|
|
992
|
-
anchor:
|
|
993
|
-
head:
|
|
1107
|
+
anchor: s + c,
|
|
1108
|
+
head: s + l
|
|
994
1109
|
} });
|
|
995
1110
|
}
|
|
996
1111
|
//#endregion
|
|
1112
|
+
//#region src/inplace/selection-rect.ts
|
|
1113
|
+
var gn = (e, t, n, r) => {
|
|
1114
|
+
let i = {
|
|
1115
|
+
x: e,
|
|
1116
|
+
y: t,
|
|
1117
|
+
left: e,
|
|
1118
|
+
top: t,
|
|
1119
|
+
right: n,
|
|
1120
|
+
bottom: r,
|
|
1121
|
+
width: n - e,
|
|
1122
|
+
height: r - t
|
|
1123
|
+
};
|
|
1124
|
+
return {
|
|
1125
|
+
...i,
|
|
1126
|
+
toJSON: () => i
|
|
1127
|
+
};
|
|
1128
|
+
};
|
|
1129
|
+
function _n(e) {
|
|
1130
|
+
let { from: t, to: n } = e.state.selection.main, r = e.coordsAtPos(t), i = t === n ? r : e.coordsAtPos(n, -1);
|
|
1131
|
+
return !r || !i ? e.dom.getBoundingClientRect() : gn(Math.min(r.left, i.left), Math.min(r.top, i.top), Math.max(r.right, i.right), Math.max(r.bottom, i.bottom));
|
|
1132
|
+
}
|
|
1133
|
+
function vn(e, t) {
|
|
1134
|
+
let n = e?.ownerDocument.getSelection();
|
|
1135
|
+
if (e && t && n && n.rangeCount > 0) {
|
|
1136
|
+
let e = n.getRangeAt(0).getBoundingClientRect?.();
|
|
1137
|
+
if (e && (e.width > 0 || e.height > 0)) return e;
|
|
1138
|
+
}
|
|
1139
|
+
return e?.getBoundingClientRect() ?? gn(0, 0, 0, 0);
|
|
1140
|
+
}
|
|
1141
|
+
//#endregion
|
|
997
1142
|
//#region src/inplace/host-items.ts
|
|
998
|
-
var
|
|
999
|
-
function
|
|
1143
|
+
var yn = /* @__PURE__ */ new WeakMap();
|
|
1144
|
+
function bn(e, t) {
|
|
1000
1145
|
if (e == null || typeof e == "string") return null;
|
|
1001
|
-
if (
|
|
1002
|
-
let n = document.createElement("span"), r =
|
|
1146
|
+
if (yn.has(t)) return yn.get(t) ?? null;
|
|
1147
|
+
let n = document.createElement("span"), r = Oe(n), i = null;
|
|
1003
1148
|
try {
|
|
1004
|
-
|
|
1149
|
+
xe(() => r.render(e)), i = n.firstElementChild;
|
|
1005
1150
|
} catch {}
|
|
1006
|
-
return r.unmount(),
|
|
1007
|
-
}
|
|
1008
|
-
var
|
|
1009
|
-
function
|
|
1010
|
-
if (!
|
|
1011
|
-
let n = e.state.readOnly, r = [];
|
|
1012
|
-
for (let
|
|
1013
|
-
if (n && !
|
|
1014
|
-
let
|
|
1015
|
-
if (
|
|
1016
|
-
let
|
|
1151
|
+
return r.unmount(), yn.set(t, i), i;
|
|
1152
|
+
}
|
|
1153
|
+
var xn = (e) => e.state.facet(Re).includes("host"), Sn = (e) => xn(e) && e.state.facet(Ie)().some((e) => e.readOnlySafe);
|
|
1154
|
+
function Cn(e, t) {
|
|
1155
|
+
if (!xn(e)) return [];
|
|
1156
|
+
let n = e.state.readOnly, r = [], i;
|
|
1157
|
+
for (let a of e.state.facet(Ie)()) {
|
|
1158
|
+
if (n && !a.readOnlySafe) continue;
|
|
1159
|
+
let o = a.when ?? "always";
|
|
1160
|
+
if (o === "selection" && !t.selected || o === "no-selection" && t.selected) continue;
|
|
1161
|
+
let s = bn(a.icon, a);
|
|
1017
1162
|
r.push({
|
|
1018
|
-
id:
|
|
1019
|
-
label:
|
|
1020
|
-
icon: typeof
|
|
1021
|
-
iconNode:
|
|
1022
|
-
disabled:
|
|
1163
|
+
id: a.id,
|
|
1164
|
+
label: a.title,
|
|
1165
|
+
icon: typeof a.icon == "string" ? a.icon : void 0,
|
|
1166
|
+
iconNode: s ?? void 0,
|
|
1167
|
+
disabled: a.disabled?.(e.state) ?? !1,
|
|
1023
1168
|
onSelect: () => {
|
|
1024
|
-
t.prepare?.(),
|
|
1169
|
+
t.prepare?.(), a.run(e, { rect: i });
|
|
1025
1170
|
}
|
|
1026
1171
|
});
|
|
1027
1172
|
}
|
|
1028
|
-
return r;
|
|
1173
|
+
return r.length && (i = t.rect?.() ?? _n(e)), r;
|
|
1029
1174
|
}
|
|
1030
1175
|
//#endregion
|
|
1031
1176
|
//#region src/inplace/link-row.ts
|
|
1032
|
-
var
|
|
1177
|
+
var wn = (e) => {
|
|
1033
1178
|
let t = e.trim().replace(/^<([^]*)>$/, "$1");
|
|
1034
1179
|
return /[\s()]/.test(t) ? `<${t.replace(/[<>]/g, "")}>` : t;
|
|
1035
|
-
},
|
|
1036
|
-
function
|
|
1180
|
+
}, Tn = (e) => e.replace(/^<([^]*)>$/, "$1");
|
|
1181
|
+
function En(e, t) {
|
|
1037
1182
|
let n = e.doc.lineAt(t.from);
|
|
1038
1183
|
if (e.doc.lineAt(t.to).number !== n.number) return null;
|
|
1039
1184
|
let r = t.from - n.from, i = t.to - n.from, s = o(n.text, r) ?? o(n.text, i);
|
|
@@ -1049,7 +1194,7 @@ function gn(e, t) {
|
|
|
1049
1194
|
text: c.label
|
|
1050
1195
|
} : null;
|
|
1051
1196
|
}
|
|
1052
|
-
function
|
|
1197
|
+
function Dn(e, t) {
|
|
1053
1198
|
let { state: n } = e, r = n.selection.main, i = n.doc.lineAt(r.head), a = t.partsIn(i.text, r.head - i.from);
|
|
1054
1199
|
if (a) {
|
|
1055
1200
|
let n = i.from + a.from, r = i.from + a.to, o = t.editActions?.(e, a) ?? [];
|
|
@@ -1078,7 +1223,7 @@ function _n(e, t) {
|
|
|
1078
1223
|
actions: o
|
|
1079
1224
|
};
|
|
1080
1225
|
}
|
|
1081
|
-
let o =
|
|
1226
|
+
let o = En(n, r), s = o ? o.from : r.from, c = o ? o.to : r.to, l = o ? o.text : n.sliceDoc(r.from, r.to);
|
|
1082
1227
|
return {
|
|
1083
1228
|
field: !0,
|
|
1084
1229
|
label: t.addLabel,
|
|
@@ -1088,18 +1233,18 @@ function _n(e, t) {
|
|
|
1088
1233
|
onSubmit: (n) => t.onAdd(e, s, c, l, n)
|
|
1089
1234
|
};
|
|
1090
1235
|
}
|
|
1091
|
-
var
|
|
1092
|
-
icon:
|
|
1236
|
+
var On = {
|
|
1237
|
+
icon: S.link,
|
|
1093
1238
|
placeholder: "https://…",
|
|
1094
1239
|
editLabel: "Edit external link",
|
|
1095
1240
|
addLabel: "Add external link",
|
|
1096
1241
|
partsIn: o,
|
|
1097
|
-
editValue: (e) =>
|
|
1242
|
+
editValue: (e) => Tn(e.url),
|
|
1098
1243
|
editActions: (e, t) => {
|
|
1099
|
-
let n = e.state.facet(
|
|
1244
|
+
let n = e.state.facet(Me);
|
|
1100
1245
|
return !n || !t.url ? [] : [{
|
|
1101
1246
|
label: "Open link",
|
|
1102
|
-
icon:
|
|
1247
|
+
icon: S.link,
|
|
1103
1248
|
onSelect: () => n(t.url)
|
|
1104
1249
|
}];
|
|
1105
1250
|
},
|
|
@@ -1107,7 +1252,7 @@ var vn = {
|
|
|
1107
1252
|
e.dispatch({ changes: {
|
|
1108
1253
|
from: t.urlFrom,
|
|
1109
1254
|
to: t.urlTo,
|
|
1110
|
-
insert:
|
|
1255
|
+
insert: wn(n)
|
|
1111
1256
|
} }), e.focus();
|
|
1112
1257
|
},
|
|
1113
1258
|
onAdd: (e, t, n, r, i) => {
|
|
@@ -1116,7 +1261,7 @@ var vn = {
|
|
|
1116
1261
|
changes: {
|
|
1117
1262
|
from: t,
|
|
1118
1263
|
to: n,
|
|
1119
|
-
insert: `[${a}](${
|
|
1264
|
+
insert: `[${a}](${wn(i)})`
|
|
1120
1265
|
},
|
|
1121
1266
|
selection: {
|
|
1122
1267
|
anchor: t + 1,
|
|
@@ -1124,8 +1269,8 @@ var vn = {
|
|
|
1124
1269
|
}
|
|
1125
1270
|
}), e.focus();
|
|
1126
1271
|
}
|
|
1127
|
-
},
|
|
1128
|
-
icon:
|
|
1272
|
+
}, kn = {
|
|
1273
|
+
icon: S.wikilink,
|
|
1129
1274
|
placeholder: "note or path",
|
|
1130
1275
|
editLabel: "Edit link",
|
|
1131
1276
|
addLabel: "Add link",
|
|
@@ -1153,27 +1298,27 @@ var vn = {
|
|
|
1153
1298
|
}), e.focus();
|
|
1154
1299
|
}
|
|
1155
1300
|
};
|
|
1156
|
-
function
|
|
1157
|
-
return
|
|
1301
|
+
function An(e) {
|
|
1302
|
+
return Dn(e, On);
|
|
1158
1303
|
}
|
|
1159
|
-
function
|
|
1160
|
-
return
|
|
1304
|
+
function jn(e) {
|
|
1305
|
+
return Dn(e, kn);
|
|
1161
1306
|
}
|
|
1162
1307
|
//#endregion
|
|
1163
1308
|
//#region src/inplace/context-menu-shell.ts
|
|
1164
|
-
function
|
|
1309
|
+
function Mn(e, t, n, r) {
|
|
1165
1310
|
let i = r?.innerWidth ?? 0, a = r?.innerHeight ?? 0;
|
|
1166
1311
|
e.style.left = "0", e.style.top = "0";
|
|
1167
1312
|
let { width: o, height: s } = e.getBoundingClientRect();
|
|
1168
1313
|
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`;
|
|
1169
1314
|
}
|
|
1170
|
-
function
|
|
1315
|
+
function Nn(e, t, n) {
|
|
1171
1316
|
let r = n?.innerWidth ?? 0, i = n?.innerHeight ?? 0;
|
|
1172
1317
|
e.style.left = "0", e.style.top = "0";
|
|
1173
1318
|
let { width: a, height: o } = e.getBoundingClientRect(), s = t.right - 4, c = s + a > r - 4 ? t.left - a + 4 : s;
|
|
1174
1319
|
e.style.left = `${Math.max(4, c)}px`, e.style.top = `${Math.max(4, Math.min(t.top - 4, i - o - 4))}px`;
|
|
1175
1320
|
}
|
|
1176
|
-
function
|
|
1321
|
+
function Pn(e, t, n, r = 350) {
|
|
1177
1322
|
let i = Date.now(), a = (e) => !t.contains(e.target), o = (e) => {
|
|
1178
1323
|
a(e) && n();
|
|
1179
1324
|
}, s = (e) => {
|
|
@@ -1187,10 +1332,10 @@ function wn(e, t, n, r = 350) {
|
|
|
1187
1332
|
}
|
|
1188
1333
|
//#endregion
|
|
1189
1334
|
//#region src/inplace/context-menu-types.ts
|
|
1190
|
-
var
|
|
1335
|
+
var Fn = (e) => typeof e != "string" && "rows" in e, In = (e) => typeof e != "string" && "field" in e;
|
|
1191
1336
|
//#endregion
|
|
1192
1337
|
//#region src/inplace/context-menu.ts
|
|
1193
|
-
function
|
|
1338
|
+
function Z(e, t = "cm-inplace-menu", n) {
|
|
1194
1339
|
let r = e.defaultView, i = e.createElement("div");
|
|
1195
1340
|
i.className = t, i.setAttribute("contenteditable", "false"), i.hidden = !0;
|
|
1196
1341
|
let a = null, o = null, s = () => {
|
|
@@ -1200,7 +1345,7 @@ function X(e, t = "cm-inplace-menu", n) {
|
|
|
1200
1345
|
}, l = (e) => e.addEventListener("mousedown", (e) => {
|
|
1201
1346
|
e.preventDefault(), e.stopPropagation();
|
|
1202
1347
|
}), u = (t, n, r, i) => {
|
|
1203
|
-
i ? t.appendChild(i.cloneNode(!0)) : r && t.appendChild(
|
|
1348
|
+
i ? t.appendChild(i.cloneNode(!0)) : r && t.appendChild(ue(e, r));
|
|
1204
1349
|
let a = e.createElement("span");
|
|
1205
1350
|
a.textContent = n, t.appendChild(a);
|
|
1206
1351
|
}, d = (n) => {
|
|
@@ -1218,7 +1363,7 @@ function X(e, t = "cm-inplace-menu", n) {
|
|
|
1218
1363
|
if (a?.dataset.for === n) return;
|
|
1219
1364
|
s();
|
|
1220
1365
|
let e = c();
|
|
1221
|
-
e.dataset.for = n, i.appendChild(e),
|
|
1366
|
+
e.dataset.for = n, i.appendChild(e), Nn(e, f.getBoundingClientRect(), r), a = e, e.querySelector("input")?.focus({ preventScroll: !0 });
|
|
1222
1367
|
};
|
|
1223
1368
|
return f.addEventListener("pointerenter", p), f.addEventListener("click", (e) => {
|
|
1224
1369
|
e.stopPropagation(), p();
|
|
@@ -1241,7 +1386,7 @@ function X(e, t = "cm-inplace-menu", n) {
|
|
|
1241
1386
|
for (let i of n) if (i === "separator") {
|
|
1242
1387
|
let n = e.createElement("div");
|
|
1243
1388
|
n.className = `${t}-sep`, r.appendChild(n);
|
|
1244
|
-
} else
|
|
1389
|
+
} else Fn(i) ? r.appendChild(f(i.label, i.icon, () => m(i.rows), i.disabled)) : In(i) ? r.appendChild(f(i.label, i.icon, () => p(i))) : r.appendChild(d(i));
|
|
1245
1390
|
return r;
|
|
1246
1391
|
};
|
|
1247
1392
|
return {
|
|
@@ -1252,12 +1397,12 @@ function X(e, t = "cm-inplace-menu", n) {
|
|
|
1252
1397
|
show: (t, a, s) => {
|
|
1253
1398
|
c();
|
|
1254
1399
|
let l = m(t);
|
|
1255
|
-
i.appendChild(l), i.hidden = !1,
|
|
1400
|
+
i.appendChild(l), i.hidden = !1, Mn(l, a, s, r), o = Pn(e, i, c), n?.(!0);
|
|
1256
1401
|
},
|
|
1257
1402
|
showField: (t, a, s) => {
|
|
1258
1403
|
c();
|
|
1259
1404
|
let l = p(t);
|
|
1260
|
-
i.appendChild(l), i.hidden = !1,
|
|
1405
|
+
i.appendChild(l), i.hidden = !1, Mn(l, a, s, r), l.querySelector("input")?.focus({ preventScroll: !0 }), o = Pn(e, i, c), n?.(!0);
|
|
1261
1406
|
},
|
|
1262
1407
|
hide: c,
|
|
1263
1408
|
destroy: () => {
|
|
@@ -1267,14 +1412,14 @@ function X(e, t = "cm-inplace-menu", n) {
|
|
|
1267
1412
|
}
|
|
1268
1413
|
//#endregion
|
|
1269
1414
|
//#region src/inplace/math-edit.ts
|
|
1270
|
-
function
|
|
1415
|
+
function Ln(e) {
|
|
1271
1416
|
let { state: t } = e, n = t.selection.main, r = t.doc.lineAt(n.head), i = Qe(r.text, n.head - r.from);
|
|
1272
1417
|
if (i) {
|
|
1273
1418
|
let t = r.from + i.from, n = r.from + i.to, a = i.block ? "$$" : "$";
|
|
1274
1419
|
return {
|
|
1275
1420
|
field: !0,
|
|
1276
1421
|
label: "Edit math",
|
|
1277
|
-
icon:
|
|
1422
|
+
icon: S.math,
|
|
1278
1423
|
value: i.src,
|
|
1279
1424
|
placeholder: "e^{i\\pi} + 1 = 0",
|
|
1280
1425
|
onSubmit: (r) => {
|
|
@@ -1307,7 +1452,7 @@ function Dn(e) {
|
|
|
1307
1452
|
return {
|
|
1308
1453
|
field: !0,
|
|
1309
1454
|
label: "Add math",
|
|
1310
|
-
icon:
|
|
1455
|
+
icon: S.math,
|
|
1311
1456
|
value: "",
|
|
1312
1457
|
placeholder: "e^{i\\pi} + 1 = 0",
|
|
1313
1458
|
onSubmit: (t) => {
|
|
@@ -1326,26 +1471,26 @@ function Dn(e) {
|
|
|
1326
1471
|
}
|
|
1327
1472
|
};
|
|
1328
1473
|
}
|
|
1329
|
-
var
|
|
1474
|
+
var Rn = class {
|
|
1330
1475
|
menu;
|
|
1331
1476
|
contentDOM;
|
|
1332
1477
|
onClick;
|
|
1333
1478
|
constructor(e) {
|
|
1334
|
-
this.menu =
|
|
1335
|
-
if (!e.state.facet(
|
|
1479
|
+
this.menu = Z(e.dom.ownerDocument), e.dom.appendChild(this.menu.el), this.contentDOM = e.contentDOM, this.onClick = (t) => {
|
|
1480
|
+
if (!e.state.facet(P).math) return;
|
|
1336
1481
|
let n = t.target?.closest(".cm-inplace-math");
|
|
1337
1482
|
if (!n) return;
|
|
1338
1483
|
let r = e.posAtDOM(n);
|
|
1339
1484
|
if (r < 0) return;
|
|
1340
1485
|
let i = e.state.doc.lineAt(r);
|
|
1341
|
-
Qe(i.text, r - i.from) && (e.dispatch({ selection: { anchor: r } }), this.menu.showField(
|
|
1486
|
+
Qe(i.text, r - i.from) && (e.dispatch({ selection: { anchor: r } }), this.menu.showField(Ln(e), t.clientX, t.clientY));
|
|
1342
1487
|
}, this.contentDOM.addEventListener("click", this.onClick);
|
|
1343
1488
|
}
|
|
1344
1489
|
destroy() {
|
|
1345
1490
|
this.contentDOM.removeEventListener("click", this.onClick), this.menu.destroy();
|
|
1346
1491
|
}
|
|
1347
|
-
},
|
|
1348
|
-
if (!e.state.facet(
|
|
1492
|
+
}, zn = O.fromClass(Rn), Bn = _e((e, t) => {
|
|
1493
|
+
if (!e.state.facet(P).math) return null;
|
|
1349
1494
|
let n = e.state.doc.lineAt(t), r = Qe(n.text, t - n.from);
|
|
1350
1495
|
return r ? {
|
|
1351
1496
|
pos: n.from + r.from,
|
|
@@ -1359,18 +1504,18 @@ var On = class {
|
|
|
1359
1504
|
});
|
|
1360
1505
|
//#endregion
|
|
1361
1506
|
//#region src/inplace/context-menu-actions.ts
|
|
1362
|
-
function
|
|
1507
|
+
function Vn(e) {
|
|
1363
1508
|
let t = h(e);
|
|
1364
1509
|
if (!t) return !1;
|
|
1365
1510
|
let { from: n, to: i } = r(t);
|
|
1366
1511
|
return i > n;
|
|
1367
1512
|
}
|
|
1368
|
-
function
|
|
1513
|
+
function Hn(e) {
|
|
1369
1514
|
let t = ie(e.state);
|
|
1370
1515
|
return {
|
|
1371
1516
|
field: !0,
|
|
1372
1517
|
label: "Language",
|
|
1373
|
-
icon:
|
|
1518
|
+
icon: S.codeBlock,
|
|
1374
1519
|
value: t?.lang ?? "",
|
|
1375
1520
|
placeholder: "ts, python, …",
|
|
1376
1521
|
onSubmit: (n) => {
|
|
@@ -1388,48 +1533,49 @@ function jn(e) {
|
|
|
1388
1533
|
}]
|
|
1389
1534
|
};
|
|
1390
1535
|
}
|
|
1391
|
-
var
|
|
1392
|
-
...
|
|
1536
|
+
var Un = (e, t = !1) => [
|
|
1537
|
+
...W(e, qt, !1, t),
|
|
1393
1538
|
"separator",
|
|
1394
|
-
...t ?
|
|
1539
|
+
...t ? W(e, Jt, !1, !0) : [$t(e, "code", !1), Ln(e)]
|
|
1395
1540
|
];
|
|
1396
|
-
function
|
|
1397
|
-
let
|
|
1398
|
-
return
|
|
1399
|
-
selected:
|
|
1400
|
-
prepare: () =>
|
|
1401
|
-
|
|
1402
|
-
}
|
|
1403
|
-
|
|
1404
|
-
|
|
1541
|
+
function Wn(e, t) {
|
|
1542
|
+
let n = e.state.facet(Re), r = t ?? h(e), i = Vn(e) && r === h(e), a = [];
|
|
1543
|
+
return q(a, Cn(e, {
|
|
1544
|
+
selected: i,
|
|
1545
|
+
prepare: () => r && hn(e, r, i),
|
|
1546
|
+
rect: () => vn(r, i)
|
|
1547
|
+
})), i ? (n.includes("format") && q(a, [K("Format", S.format, Un(e, !0))]), n.includes("clipboard") && q(a, G(e)), a) : a;
|
|
1548
|
+
}
|
|
1549
|
+
var Gn = (e) => [
|
|
1550
|
+
...W(e, Yt),
|
|
1405
1551
|
"separator",
|
|
1406
|
-
...
|
|
1552
|
+
...W(e, [...Xt, "body"]),
|
|
1407
1553
|
"separator",
|
|
1408
|
-
...
|
|
1409
|
-
],
|
|
1410
|
-
...
|
|
1554
|
+
...W(e, ["quote"])
|
|
1555
|
+
], Kn = (e) => [
|
|
1556
|
+
...W(e, Zt),
|
|
1411
1557
|
"separator",
|
|
1412
|
-
...
|
|
1558
|
+
...W(e, Qt)
|
|
1413
1559
|
];
|
|
1414
|
-
function
|
|
1415
|
-
let { state: t } = e, n = t.facet(
|
|
1416
|
-
if (
|
|
1417
|
-
let i =
|
|
1560
|
+
function qn(e) {
|
|
1561
|
+
let { state: t } = e, n = t.facet(Re), r = (e) => n.includes(e);
|
|
1562
|
+
if (Vn(e)) return Wn(e);
|
|
1563
|
+
let i = Cn(e, { selected: !t.selection.main.empty });
|
|
1418
1564
|
if (ee(t)) {
|
|
1419
1565
|
let t = [];
|
|
1420
|
-
return
|
|
1566
|
+
return q(t, i), q(t, [Hn(e)]), r("clipboard") && q(t, G(e)), t;
|
|
1421
1567
|
}
|
|
1422
|
-
if (
|
|
1568
|
+
if (en(t)) {
|
|
1423
1569
|
let t = [];
|
|
1424
|
-
return
|
|
1570
|
+
return q(t, i), q(t, [rn(e)]), r("clipboard") && q(t, G(e)), t;
|
|
1425
1571
|
}
|
|
1426
1572
|
let a = t.selection.main, o = t.doc.lineAt(a.head).text.trim() === "", s = !a.empty || !!t.wordAt(a.head), c = t.facet(Ve) === "menu", l = [];
|
|
1427
|
-
for (let t of n) t === "host" ?
|
|
1573
|
+
for (let t of n) t === "host" ? q(l, i) : t === "link" && c ? q(l, [jn(e), An(e)]) : t === "format" && c ? q(l, [K("Format", S.format, Un(e), !s)]) : t === "paragraph" ? q(l, [K("Paragraph", S.paragraph, Gn(e))]) : t === "insert" ? q(l, [K("Insert", S.insert, Kn(e), !o)]) : t === "clipboard" && q(l, G(e));
|
|
1428
1574
|
return l;
|
|
1429
1575
|
}
|
|
1430
1576
|
//#endregion
|
|
1431
1577
|
//#region src/inplace/long-press.ts
|
|
1432
|
-
function
|
|
1578
|
+
function Jn(e, t) {
|
|
1433
1579
|
let n = t.delay ?? 450, r = t.slop ?? 20, i = null, a = 0, o = 0, s = () => {
|
|
1434
1580
|
i != null && (clearTimeout(i), i = null);
|
|
1435
1581
|
}, c = (e) => {
|
|
@@ -1451,10 +1597,10 @@ function Ln(e, t) {
|
|
|
1451
1597
|
}
|
|
1452
1598
|
//#endregion
|
|
1453
1599
|
//#region src/inplace/table-gizmos.ts
|
|
1454
|
-
function
|
|
1600
|
+
function Yn(e, t) {
|
|
1455
1601
|
let n = e.createElement("div");
|
|
1456
1602
|
n.className = "cm-inplace-table-gizmos", n.setAttribute("contenteditable", "false");
|
|
1457
|
-
let r =
|
|
1603
|
+
let r = Z(e), i = (t, n, r) => {
|
|
1458
1604
|
let i = e.createElement("button");
|
|
1459
1605
|
return i.type = "button", i.className = t, i.setAttribute("aria-label", n), i.addEventListener("mousedown", (e) => {
|
|
1460
1606
|
e.preventDefault(), e.stopPropagation();
|
|
@@ -1537,7 +1683,7 @@ function Rn(e, t) {
|
|
|
1537
1683
|
}
|
|
1538
1684
|
//#endregion
|
|
1539
1685
|
//#region src/inplace/table-widget-keys.ts
|
|
1540
|
-
function
|
|
1686
|
+
function Xn(e, t, n) {
|
|
1541
1687
|
let r = e.target.closest("td, th");
|
|
1542
1688
|
if (!r) return;
|
|
1543
1689
|
if (l(e, r)) {
|
|
@@ -1606,56 +1752,65 @@ function zn(e, t, n) {
|
|
|
1606
1752
|
}
|
|
1607
1753
|
//#endregion
|
|
1608
1754
|
//#region src/inplace/table-widget-render.ts
|
|
1609
|
-
|
|
1755
|
+
var Zn = /* @__PURE__ */ new WeakMap(), Qn = (e) => JSON.stringify(e), $n = (e, t) => (Zn.get(e)?.sig ?? "null") === Qn(t);
|
|
1756
|
+
function er(e, t, n) {
|
|
1610
1757
|
let r = Number(e.dataset.r), i = Number(e.dataset.c), a = t.rows[r]?.[i] ?? "";
|
|
1611
|
-
e.replaceChildren(n ? e.ownerDocument.createTextNode(a) :
|
|
1758
|
+
e.replaceChildren(n ? e.ownerDocument.createTextNode(a) : an(c(a), t.embeds));
|
|
1759
|
+
let o = Zn.get(e);
|
|
1760
|
+
o && e.classList.remove(...o.cellClass);
|
|
1761
|
+
let s = t.paintOf?.(r, i) ?? null;
|
|
1762
|
+
s && (Wt(e, a, s, n), e.classList.add(...s.cellClass)), Zn.set(e, {
|
|
1763
|
+
sig: Qn(s),
|
|
1764
|
+
cellClass: s?.cellClass ?? []
|
|
1765
|
+
});
|
|
1612
1766
|
}
|
|
1613
|
-
function
|
|
1767
|
+
function tr(e, t, n, r) {
|
|
1614
1768
|
let i = document.createElement(r ? "th" : "td");
|
|
1615
1769
|
i.className = "cm-inplace-tcell", i.setAttribute("contenteditable", "true"), i.dataset.r = String(t), i.dataset.c = String(n);
|
|
1616
1770
|
let a = e.aligns[n];
|
|
1617
|
-
return a && (i.style.textAlign = a),
|
|
1771
|
+
return a && (i.style.textAlign = a), er(i, e, !1), i;
|
|
1618
1772
|
}
|
|
1619
|
-
function
|
|
1773
|
+
function nr(e, t) {
|
|
1620
1774
|
e.replaceChildren();
|
|
1621
1775
|
let n = t.aligns.length, r = e.createTHead().insertRow();
|
|
1622
|
-
for (let e = 0; e < n; e++) r.appendChild(
|
|
1776
|
+
for (let e = 0; e < n; e++) r.appendChild(tr(t, 0, e, !0));
|
|
1623
1777
|
let i = e.createTBody();
|
|
1624
1778
|
for (let e = 1; e < t.rows.length; e++) {
|
|
1625
1779
|
let r = i.insertRow();
|
|
1626
|
-
for (let i = 0; i < n; i++) r.appendChild(
|
|
1780
|
+
for (let i = 0; i < n; i++) r.appendChild(tr(t, e, i, !1));
|
|
1627
1781
|
}
|
|
1628
1782
|
}
|
|
1629
1783
|
//#endregion
|
|
1630
1784
|
//#region src/inplace/table-structure.ts
|
|
1631
1785
|
var Q = (e) => e.aligns.length;
|
|
1632
|
-
function
|
|
1786
|
+
function rr(e, t) {
|
|
1633
1787
|
let n = Math.max(0, Math.min(t, Q(e)));
|
|
1634
1788
|
for (let t of e.rows) t.splice(n, 0, "");
|
|
1635
1789
|
e.aligns.splice(n, 0, "");
|
|
1636
1790
|
}
|
|
1637
|
-
function
|
|
1791
|
+
function ir(e, t) {
|
|
1638
1792
|
if (!(Q(e) <= 1 || t < 0 || t >= Q(e))) {
|
|
1639
1793
|
for (let n of e.rows) n.splice(t, 1);
|
|
1640
1794
|
e.aligns.splice(t, 1);
|
|
1641
1795
|
}
|
|
1642
1796
|
}
|
|
1643
|
-
function
|
|
1797
|
+
function ar(e, t) {
|
|
1644
1798
|
let n = Math.max(1, Math.min(t, e.rows.length));
|
|
1645
1799
|
e.rows.splice(n, 0, Array(Q(e)).fill(""));
|
|
1646
1800
|
}
|
|
1647
|
-
function
|
|
1801
|
+
function or(e, t) {
|
|
1648
1802
|
t <= 0 || t >= e.rows.length || e.rows.length <= 2 || e.rows.splice(t, 1);
|
|
1649
1803
|
}
|
|
1650
|
-
function
|
|
1804
|
+
function sr(e, t, n) {
|
|
1651
1805
|
t >= 0 && t < Q(e) && (e.aligns[t] = n);
|
|
1652
1806
|
}
|
|
1653
1807
|
//#endregion
|
|
1654
1808
|
//#region src/inplace/table-widget.ts
|
|
1655
|
-
var
|
|
1809
|
+
var cr = Se.define(), lr = /* @__PURE__ */ new WeakMap(), ur = class extends k {
|
|
1656
1810
|
data;
|
|
1657
1811
|
embeds;
|
|
1658
1812
|
table = null;
|
|
1813
|
+
view = null;
|
|
1659
1814
|
rows;
|
|
1660
1815
|
editing = null;
|
|
1661
1816
|
syncing = !1;
|
|
@@ -1664,7 +1819,7 @@ var $ = we.define(), Jn = class extends E {
|
|
|
1664
1819
|
longPress = null;
|
|
1665
1820
|
longPressAt = 0;
|
|
1666
1821
|
constructor(e, t = !1) {
|
|
1667
|
-
super(), this.data = e, this.embeds = t, this.rows =
|
|
1822
|
+
super(), this.data = e, this.embeds = t, this.rows = le(e);
|
|
1668
1823
|
}
|
|
1669
1824
|
eq(e) {
|
|
1670
1825
|
return !this.table && JSON.stringify(y(this.rows)) === JSON.stringify(y(e.rows));
|
|
@@ -1677,7 +1832,7 @@ var $ = we.define(), Jn = class extends E {
|
|
|
1677
1832
|
}
|
|
1678
1833
|
bounds(e) {
|
|
1679
1834
|
let t = e.posAtDOM(this.table), n = null;
|
|
1680
|
-
return e.state.field(
|
|
1835
|
+
return e.state.field(X).between(t, t, (e, t) => (n = {
|
|
1681
1836
|
from: e,
|
|
1682
1837
|
to: t
|
|
1683
1838
|
}, !1)), n ?? e.state.doc.lineAt(t);
|
|
@@ -1691,22 +1846,34 @@ var $ = we.define(), Jn = class extends E {
|
|
|
1691
1846
|
c: Number(e.dataset.c)
|
|
1692
1847
|
};
|
|
1693
1848
|
}
|
|
1694
|
-
|
|
1695
|
-
|
|
1849
|
+
paintOf = Gt({
|
|
1850
|
+
view: () => this.view,
|
|
1851
|
+
mounted: () => !!this.table?.isConnected,
|
|
1852
|
+
from: (e) => this.bounds(e).from,
|
|
1853
|
+
raw: (e, t) => this.rows[e]?.[t] ?? ""
|
|
1854
|
+
});
|
|
1855
|
+
grid() {
|
|
1856
|
+
return {
|
|
1696
1857
|
rows: this.rows,
|
|
1697
1858
|
aligns: this.data.aligns,
|
|
1698
|
-
embeds: this.embeds
|
|
1699
|
-
|
|
1859
|
+
embeds: this.embeds,
|
|
1860
|
+
paintOf: this.paintOf
|
|
1861
|
+
};
|
|
1862
|
+
}
|
|
1863
|
+
paint(e, t) {
|
|
1864
|
+
er(e, this.grid(), t);
|
|
1865
|
+
}
|
|
1866
|
+
repaintMarks() {
|
|
1867
|
+
for (let e of this.table?.querySelectorAll("td, th") ?? []) {
|
|
1868
|
+
let { r: t, c: n } = this.coords(e);
|
|
1869
|
+
e !== this.editing && !$n(e, this.paintOf(t, n)) && this.paint(e, !1);
|
|
1870
|
+
}
|
|
1700
1871
|
}
|
|
1701
1872
|
renderCells() {
|
|
1702
|
-
|
|
1703
|
-
rows: this.rows,
|
|
1704
|
-
aligns: this.data.aligns,
|
|
1705
|
-
embeds: this.embeds
|
|
1706
|
-
});
|
|
1873
|
+
nr(this.table, this.grid());
|
|
1707
1874
|
}
|
|
1708
1875
|
appendRow() {
|
|
1709
|
-
|
|
1876
|
+
ar(this.model(), this.rows.length), this.renderCells(), this.gizmos?.layout(this.table);
|
|
1710
1877
|
}
|
|
1711
1878
|
model() {
|
|
1712
1879
|
return {
|
|
@@ -1717,7 +1884,7 @@ var $ = we.define(), Jn = class extends E {
|
|
|
1717
1884
|
runOp(e, t) {
|
|
1718
1885
|
if (!this.table) return;
|
|
1719
1886
|
let n = this.model();
|
|
1720
|
-
if (t.kind === "insertColumn" ?
|
|
1887
|
+
if (t.kind === "insertColumn" ? rr(n, t.at) : t.kind === "deleteColumn" ? ir(n, t.at) : t.kind === "insertRow" ? ar(n, t.at) : t.kind === "deleteRow" ? or(n, t.at) : sr(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") {
|
|
1721
1888
|
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));
|
|
1722
1889
|
this.cellAt(e, n)?.focus();
|
|
1723
1890
|
}
|
|
@@ -1729,7 +1896,7 @@ var $ = we.define(), Jn = class extends E {
|
|
|
1729
1896
|
onFocusIn(e) {
|
|
1730
1897
|
let t = e.target.closest("td, th");
|
|
1731
1898
|
if (!t || t === this.editing) return;
|
|
1732
|
-
let n = this.pendingOffset ??
|
|
1899
|
+
let n = this.pendingOffset ?? b(t);
|
|
1733
1900
|
this.pendingOffset = null, this.editing && this.finish(this.editing, !1), this.editing = t, this.paint(t, !0), d(t, n);
|
|
1734
1901
|
}
|
|
1735
1902
|
onFocusOut(e) {
|
|
@@ -1763,14 +1930,14 @@ var $ = we.define(), Jn = class extends E {
|
|
|
1763
1930
|
to: i,
|
|
1764
1931
|
insert: n
|
|
1765
1932
|
},
|
|
1766
|
-
annotations:
|
|
1933
|
+
annotations: cr.of(!0),
|
|
1767
1934
|
userEvent: "input"
|
|
1768
1935
|
}), this.syncing = !1, t && (this.writeCaret(t), requestAnimationFrame(() => {
|
|
1769
1936
|
this.table && t && this.writeCaret(t);
|
|
1770
1937
|
})));
|
|
1771
1938
|
}
|
|
1772
1939
|
onKey(e, t) {
|
|
1773
|
-
this.table &&
|
|
1940
|
+
this.table && Xn(e, t, {
|
|
1774
1941
|
coords: (e) => this.coords(e),
|
|
1775
1942
|
rows: () => this.rows.length,
|
|
1776
1943
|
cols: () => this.cols(),
|
|
@@ -1793,18 +1960,22 @@ var $ = we.define(), Jn = class extends E {
|
|
|
1793
1960
|
openCellMenuAt(e, t, n, r) {
|
|
1794
1961
|
let i = r?.closest("td, th");
|
|
1795
1962
|
if (!i) return;
|
|
1796
|
-
this.editing === i && !
|
|
1797
|
-
let a =
|
|
1963
|
+
this.editing === i && !Vn(e) && s(i, t, n);
|
|
1964
|
+
let a = Wn(e, i);
|
|
1798
1965
|
this.gizmos?.openFor(i, t, n, a);
|
|
1799
1966
|
}
|
|
1800
1967
|
toDOM(e) {
|
|
1801
1968
|
let t = document.createElement("div");
|
|
1802
1969
|
t.className = "cm-inplace-table-wrap";
|
|
1803
1970
|
let n = document.createElement("table");
|
|
1804
|
-
this.table = n, this.editing = null, n.className = "cm-inplace-table cm-inplace-table-edit", this.renderCells(),
|
|
1971
|
+
this.table = n, this.view = e, this.editing = null, lr.set(n, this), n.className = "cm-inplace-table cm-inplace-table-edit", this.renderCells(), e.requestMeasure({
|
|
1972
|
+
read: () => null,
|
|
1973
|
+
write: () => this.repaintMarks(),
|
|
1974
|
+
key: this
|
|
1975
|
+
}), n.addEventListener("mousedown", (e) => {
|
|
1805
1976
|
e.stopPropagation();
|
|
1806
1977
|
let t = e.target.closest("td, th");
|
|
1807
|
-
this.pendingOffset = t && t !== this.editing ?
|
|
1978
|
+
this.pendingOffset = t && t !== this.editing ? x(t, e.clientX, e.clientY) : null;
|
|
1808
1979
|
}), n.addEventListener("focusin", (e) => this.onFocusIn(e)), n.addEventListener("focusout", (e) => this.onFocusOut(e));
|
|
1809
1980
|
let r = (t) => {
|
|
1810
1981
|
t && (this.editing = t, this.finish(t, !0), this.sync(e));
|
|
@@ -1817,9 +1988,9 @@ var $ = we.define(), Jn = class extends E {
|
|
|
1817
1988
|
document.execCommand("insertText", !1, t);
|
|
1818
1989
|
}), n.addEventListener("contextmenu", (t) => {
|
|
1819
1990
|
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));
|
|
1820
|
-
}), this.longPress =
|
|
1991
|
+
}), this.longPress = Jn(n, { onLongPress: (t, n, r) => {
|
|
1821
1992
|
this.longPressAt = Date.now(), this.openCellMenuAt(e, t, n, r);
|
|
1822
|
-
} }), this.gizmos =
|
|
1993
|
+
} }), this.gizmos = Yn(document, {
|
|
1823
1994
|
dims: () => ({
|
|
1824
1995
|
cols: this.cols(),
|
|
1825
1996
|
rows: this.rows.length,
|
|
@@ -1829,14 +2000,14 @@ var $ = we.define(), Jn = class extends E {
|
|
|
1829
2000
|
}), t.append(n, this.gizmos.el), t.addEventListener("mouseenter", () => this.gizmos?.layout(n)), requestAnimationFrame(() => this.gizmos?.layout(n)), t;
|
|
1830
2001
|
}
|
|
1831
2002
|
destroy() {
|
|
1832
|
-
this.longPress?.dispose(), this.longPress = null, this.gizmos?.destroy(), this.gizmos = null, this.table = null, this.editing = null;
|
|
2003
|
+
this.longPress?.dispose(), this.longPress = null, this.gizmos?.destroy(), this.gizmos = null, this.table = null, this.view = null, this.editing = null;
|
|
1833
2004
|
}
|
|
1834
|
-
},
|
|
2005
|
+
}, dr = /* @__PURE__ */ new Set([
|
|
1835
2006
|
"-",
|
|
1836
2007
|
"*",
|
|
1837
2008
|
"_"
|
|
1838
|
-
]),
|
|
1839
|
-
if (!e.docChanged || e.isUserEvent("undo") || e.isUserEvent("redo") || e.annotation(
|
|
2009
|
+
]), fr = we.transactionFilter.of((e) => {
|
|
2010
|
+
if (!e.docChanged || e.isUserEvent("undo") || e.isUserEvent("redo") || e.annotation(cr) || !e.startState.selection.main.empty) return e;
|
|
1840
2011
|
let t = e.startState.selection.main.head, n = "", r = 0;
|
|
1841
2012
|
if (e.changes.iterChanges((e, i, a, o, s) => {
|
|
1842
2013
|
r += 1, e === i && e === t && (n = s.toString());
|
|
@@ -1866,7 +2037,7 @@ var $ = we.define(), Jn = class extends E {
|
|
|
1866
2037
|
},
|
|
1867
2038
|
anchor: a + 1
|
|
1868
2039
|
};
|
|
1869
|
-
else if (
|
|
2040
|
+
else if (dr.has(n) && RegExp(`^\\${n}{3,}$`).test(s)) {
|
|
1870
2041
|
let e = o.number === 1 || i.line(o.number - 1).text.trim() === "", t = n === "-" && !e, r = o.number === i.lines;
|
|
1871
2042
|
if (t || r) {
|
|
1872
2043
|
let e = [];
|
|
@@ -1889,38 +2060,38 @@ var $ = we.define(), Jn = class extends E {
|
|
|
1889
2060
|
scrollIntoView: !0,
|
|
1890
2061
|
userEvent: "input.autoformat"
|
|
1891
2062
|
}] : e;
|
|
1892
|
-
}),
|
|
2063
|
+
}), pr = /* @__PURE__ */ new Set([
|
|
1893
2064
|
"EmphasisMark",
|
|
1894
2065
|
"CodeMark",
|
|
1895
2066
|
"StrikethroughMark"
|
|
1896
2067
|
]);
|
|
1897
|
-
function
|
|
2068
|
+
function mr(e, t, n) {
|
|
1898
2069
|
let r = t;
|
|
1899
2070
|
for (;;) {
|
|
1900
2071
|
let t = e.resolveInner(r, n);
|
|
1901
|
-
if (!
|
|
2072
|
+
if (!pr.has(t.name) || t.from >= t.to) return r;
|
|
1902
2073
|
let i = n < 0 ? t.from : t.to;
|
|
1903
2074
|
if (i === r) return r;
|
|
1904
2075
|
r = i;
|
|
1905
2076
|
}
|
|
1906
2077
|
}
|
|
1907
|
-
function
|
|
1908
|
-
let n =
|
|
2078
|
+
function hr(e, t) {
|
|
2079
|
+
let n = H(e, t, !0);
|
|
1909
2080
|
if (!n) return t;
|
|
1910
|
-
let r =
|
|
1911
|
-
return t === n.contentTo ?
|
|
2081
|
+
let r = N(e);
|
|
2082
|
+
return t === n.contentTo ? mr(r, t, 1) : t === n.contentFrom ? mr(r, t, -1) : t;
|
|
1912
2083
|
}
|
|
1913
|
-
var
|
|
1914
|
-
if (!e.docChanged || e.isUserEvent("undo") || e.isUserEvent("redo") || e.annotation(
|
|
2084
|
+
var gr = we.transactionFilter.of((e) => {
|
|
2085
|
+
if (!e.docChanged || e.isUserEvent("undo") || e.isUserEvent("redo") || e.annotation(cr)) return e;
|
|
1915
2086
|
let t = e.startState, n = t.selection.main;
|
|
1916
|
-
if (!n.empty || !
|
|
2087
|
+
if (!n.empty || !V(t, t.doc.lineAt(n.head).number)) return e;
|
|
1917
2088
|
let r = [], i = 0;
|
|
1918
2089
|
e.changes.iterChanges((e, t, a, o, s) => {
|
|
1919
2090
|
i++, e === t && e === n.head && s.length > 0 && r.push(s.toString());
|
|
1920
2091
|
});
|
|
1921
2092
|
let a = r[0];
|
|
1922
2093
|
if (i !== 1 || a === void 0) return e;
|
|
1923
|
-
let o =
|
|
2094
|
+
let o = hr(t, n.head);
|
|
1924
2095
|
return o === n.head ? e : {
|
|
1925
2096
|
changes: {
|
|
1926
2097
|
from: o,
|
|
@@ -1930,25 +2101,25 @@ var er = Ee.transactionFilter.of((e) => {
|
|
|
1930
2101
|
scrollIntoView: !0,
|
|
1931
2102
|
userEvent: "input.type"
|
|
1932
2103
|
};
|
|
1933
|
-
}),
|
|
1934
|
-
function
|
|
2104
|
+
}), _r = RegExp(`^(?:${se.match.source.replace(/^\^/, "")})+`);
|
|
2105
|
+
function vr(e, t) {
|
|
1935
2106
|
let n = e.doc.lineAt(t).number;
|
|
1936
|
-
for (let r =
|
|
2107
|
+
for (let r = N(e).resolveInner(t, 1); r; r = r.parent) {
|
|
1937
2108
|
if (r.name !== "ListItem" || e.doc.lineAt(r.from).number === n) continue;
|
|
1938
2109
|
let t = u.exec(e.doc.lineAt(r.from).text);
|
|
1939
2110
|
if (t) return t[0].length;
|
|
1940
2111
|
}
|
|
1941
2112
|
return null;
|
|
1942
2113
|
}
|
|
1943
|
-
function
|
|
1944
|
-
let n = t.text, r =
|
|
2114
|
+
function yr(e, t) {
|
|
2115
|
+
let n = t.text, r = ae.exec(n);
|
|
1945
2116
|
if (r) return {
|
|
1946
2117
|
prefixLen: r[0].length,
|
|
1947
2118
|
drop: [0, r[0].length]
|
|
1948
2119
|
};
|
|
1949
|
-
let i =
|
|
2120
|
+
let i = _r.exec(n);
|
|
1950
2121
|
if (i) {
|
|
1951
|
-
let e =
|
|
2122
|
+
let e = se.match.exec(n)[0].length;
|
|
1952
2123
|
return {
|
|
1953
2124
|
prefixLen: i[0].length,
|
|
1954
2125
|
drop: [0, e]
|
|
@@ -1959,11 +2130,11 @@ function rr(e, t) {
|
|
|
1959
2130
|
prefixLen: a[0].length,
|
|
1960
2131
|
drop: [0, a[0].length]
|
|
1961
2132
|
};
|
|
1962
|
-
let o = te.match.exec(n) ??
|
|
2133
|
+
let o = te.match.exec(n) ?? _.match.exec(n);
|
|
1963
2134
|
if (o) {
|
|
1964
2135
|
let n = o[1] ?? "", r = o[0].length - n.length;
|
|
1965
2136
|
if (n) {
|
|
1966
|
-
let r =
|
|
2137
|
+
let r = vr(e, t.from) ?? 2, i = n.startsWith(" ") ? 1 : Math.min(r, n.length);
|
|
1967
2138
|
return {
|
|
1968
2139
|
prefixLen: o[0].length,
|
|
1969
2140
|
drop: [0, i]
|
|
@@ -1976,15 +2147,15 @@ function rr(e, t) {
|
|
|
1976
2147
|
}
|
|
1977
2148
|
return null;
|
|
1978
2149
|
}
|
|
1979
|
-
var
|
|
2150
|
+
var br = j.high(ve.of([{
|
|
1980
2151
|
key: "Backspace",
|
|
1981
2152
|
run: (e) => {
|
|
1982
2153
|
if (h(e)) return !1;
|
|
1983
2154
|
let { state: t } = e, n = t.selection.main;
|
|
1984
2155
|
if (!n.empty) return !1;
|
|
1985
2156
|
let r = t.doc.lineAt(n.head);
|
|
1986
|
-
if (!
|
|
1987
|
-
let i =
|
|
2157
|
+
if (!V(t, r.number)) return !1;
|
|
2158
|
+
let i = yr(t, r);
|
|
1988
2159
|
if (!i || n.head < r.from || n.head > r.from + i.prefixLen) return !1;
|
|
1989
2160
|
let [a, o] = i.drop;
|
|
1990
2161
|
return e.dispatch({
|
|
@@ -1998,13 +2169,13 @@ var ir = k.high(D.of([{
|
|
|
1998
2169
|
scrollIntoView: !0
|
|
1999
2170
|
}), !0;
|
|
2000
2171
|
}
|
|
2001
|
-
}])),
|
|
2172
|
+
}])), xr = class {
|
|
2002
2173
|
menu;
|
|
2003
2174
|
contentDOM;
|
|
2004
2175
|
onClick;
|
|
2005
2176
|
constructor(e) {
|
|
2006
|
-
this.menu =
|
|
2007
|
-
if (e.state.facet(
|
|
2177
|
+
this.menu = Z(e.dom.ownerDocument), e.dom.appendChild(this.menu.el), this.contentDOM = e.contentDOM, this.onClick = (t) => {
|
|
2178
|
+
if (e.state.facet(L) !== "never" || !e.state.facet(P).links) return;
|
|
2008
2179
|
let n = t.target?.closest(".cm-inplace-link");
|
|
2009
2180
|
if (!n || n.classList.contains("cm-inplace-wikilink")) return;
|
|
2010
2181
|
let r = e.posAtDOM(n);
|
|
@@ -2016,13 +2187,13 @@ var ir = k.high(D.of([{
|
|
|
2016
2187
|
if (n == null) return;
|
|
2017
2188
|
r = n;
|
|
2018
2189
|
}
|
|
2019
|
-
e.dispatch({ selection: { anchor: r } }), this.menu.showField(
|
|
2190
|
+
e.dispatch({ selection: { anchor: r } }), this.menu.showField(An(e), t.clientX, t.clientY);
|
|
2020
2191
|
}, this.contentDOM.addEventListener("click", this.onClick);
|
|
2021
2192
|
}
|
|
2022
2193
|
destroy() {
|
|
2023
2194
|
this.contentDOM.removeEventListener("click", this.onClick), this.menu.destroy();
|
|
2024
2195
|
}
|
|
2025
|
-
},
|
|
2196
|
+
}, Sr = O.fromClass(xr), Cr = (e) => e.replace(/^<([^]*)>$/, "$1").trim(), wr = (e, t, n) => n ? {
|
|
2026
2197
|
pos: e,
|
|
2027
2198
|
end: t,
|
|
2028
2199
|
above: !0,
|
|
@@ -2031,27 +2202,27 @@ var ir = k.high(D.of([{
|
|
|
2031
2202
|
return e.className = "cm-inplace-href-tip", e.textContent = n, { dom: e };
|
|
2032
2203
|
}
|
|
2033
2204
|
} : null;
|
|
2034
|
-
function
|
|
2035
|
-
for (let n =
|
|
2205
|
+
function Tr(e, t) {
|
|
2206
|
+
for (let n = N(e.state).resolveInner(t, -1); n; n = n.parent) {
|
|
2036
2207
|
if (n.name !== "Link") continue;
|
|
2037
2208
|
if (e.state.doc.sliceString(Math.max(0, n.from - 1), n.from) === "[") break;
|
|
2038
2209
|
let t = n.getChild("URL"), r = t ? e.state.sliceDoc(t.from, t.to) : e.state.sliceDoc(n.from, n.to);
|
|
2039
|
-
return
|
|
2210
|
+
return wr(n.from, n.to, Cr(r));
|
|
2040
2211
|
}
|
|
2041
2212
|
return null;
|
|
2042
2213
|
}
|
|
2043
|
-
function
|
|
2214
|
+
function Er(t, n) {
|
|
2044
2215
|
let r = t.state.doc.lineAt(n);
|
|
2045
2216
|
for (let t of r.text.matchAll(e)) {
|
|
2046
2217
|
let e = r.from + (t.index ?? 0), i = e + t[0].length;
|
|
2047
|
-
if (!(n < e || n > i)) return
|
|
2218
|
+
if (!(n < e || n > i)) return wr(e, i, (t[1] ?? "").trim());
|
|
2048
2219
|
}
|
|
2049
2220
|
return null;
|
|
2050
2221
|
}
|
|
2051
|
-
var
|
|
2052
|
-
let n = e.state.facet(
|
|
2053
|
-
return (n.links ?
|
|
2054
|
-
}),
|
|
2222
|
+
var Dr = _e((e, t) => {
|
|
2223
|
+
let n = e.state.facet(P);
|
|
2224
|
+
return (n.links ? Tr(e, t) : null) ?? (n.wikilinks ? Er(e, t) : null);
|
|
2225
|
+
}), Or = class extends k {
|
|
2055
2226
|
ref;
|
|
2056
2227
|
inline;
|
|
2057
2228
|
registry;
|
|
@@ -2078,52 +2249,52 @@ var dr = be((e, t) => {
|
|
|
2078
2249
|
return !1;
|
|
2079
2250
|
}
|
|
2080
2251
|
};
|
|
2081
|
-
function
|
|
2082
|
-
let t = e.facet(
|
|
2083
|
-
if (!t || !e.facet(
|
|
2084
|
-
let n =
|
|
2252
|
+
function kr(e) {
|
|
2253
|
+
let t = e.facet(F);
|
|
2254
|
+
if (!t || !e.facet(P).embeds || !e.doc.toString().includes("![[")) return E.none;
|
|
2255
|
+
let n = z(e), r = N(e), i = [];
|
|
2085
2256
|
for (let a = 1; a <= e.doc.lines; a++) {
|
|
2086
2257
|
let o = e.doc.line(a);
|
|
2087
2258
|
if (!(!o.text.includes("![[") || n.has(a))) {
|
|
2088
|
-
if (
|
|
2089
|
-
|
|
2090
|
-
let e = (
|
|
2091
|
-
if (!e ||
|
|
2092
|
-
i.push(
|
|
2093
|
-
widget: new
|
|
2259
|
+
if (fe(o.text)) {
|
|
2260
|
+
C.lastIndex = 0;
|
|
2261
|
+
let e = (C.exec(o.text.trim())?.[1] ?? "").trim();
|
|
2262
|
+
if (!e || B(r, o.from + o.text.indexOf("!["))) continue;
|
|
2263
|
+
i.push(E.replace({
|
|
2264
|
+
widget: new Or(e, !1, t),
|
|
2094
2265
|
block: !0
|
|
2095
2266
|
}).range(o.from, o.to));
|
|
2096
2267
|
continue;
|
|
2097
2268
|
}
|
|
2098
|
-
|
|
2099
|
-
for (let e of o.text.matchAll(
|
|
2269
|
+
C.lastIndex = 0;
|
|
2270
|
+
for (let e of o.text.matchAll(C)) {
|
|
2100
2271
|
let n = (e[1] ?? "").trim();
|
|
2101
2272
|
if (!n) continue;
|
|
2102
2273
|
let a = o.from + (e.index ?? 0);
|
|
2103
|
-
|
|
2274
|
+
B(r, a + 2) || qe(r, a + 2) || i.push(E.replace({ widget: new Or(n, !0, t) }).range(a, a + e[0].length));
|
|
2104
2275
|
}
|
|
2105
2276
|
}
|
|
2106
2277
|
}
|
|
2107
|
-
return
|
|
2278
|
+
return E.set(i, !0);
|
|
2108
2279
|
}
|
|
2109
|
-
function
|
|
2280
|
+
function Ar(e, t) {
|
|
2110
2281
|
for (let n of t.ranges) {
|
|
2111
2282
|
let t = e.doc.lineAt(n.from).number, r = e.doc.lineAt(n.to).number;
|
|
2112
2283
|
for (let n = t; n <= r; n++) if (e.doc.line(n).text.includes("![[")) return !0;
|
|
2113
2284
|
}
|
|
2114
2285
|
return !1;
|
|
2115
2286
|
}
|
|
2116
|
-
var
|
|
2117
|
-
create:
|
|
2118
|
-
update: (e, t) => t.docChanged || t.selection && (
|
|
2119
|
-
provide: (e) => [
|
|
2120
|
-
}),
|
|
2287
|
+
var jr = M.define({
|
|
2288
|
+
create: kr,
|
|
2289
|
+
update: (e, t) => t.docChanged || t.selection && (Ar(t.state, t.startState.selection) || Ar(t.state, t.state.selection)) ? kr(t.state) : e,
|
|
2290
|
+
provide: (e) => [D.decorations.from(e), D.atomicRanges.of((t) => t.state.field(e))]
|
|
2291
|
+
}), Mr = Te.define(), $ = M.define({
|
|
2121
2292
|
create: () => !1,
|
|
2122
2293
|
update(e, t) {
|
|
2123
|
-
for (let n of t.effects) n.is(
|
|
2294
|
+
for (let n of t.effects) n.is(Mr) && (e = n.value);
|
|
2124
2295
|
return e;
|
|
2125
2296
|
}
|
|
2126
|
-
}),
|
|
2297
|
+
}), Nr = class {
|
|
2127
2298
|
view;
|
|
2128
2299
|
menu;
|
|
2129
2300
|
onContextMenu;
|
|
@@ -2134,8 +2305,8 @@ var hr = A.define({
|
|
|
2134
2305
|
longPressAt = 0;
|
|
2135
2306
|
destroyed = !1;
|
|
2136
2307
|
constructor(e) {
|
|
2137
|
-
this.view = e, this.menu =
|
|
2138
|
-
this.destroyed || e.dispatch({ effects:
|
|
2308
|
+
this.view = e, this.menu = Z(e.dom.ownerDocument, "cm-inplace-menu", (t) => {
|
|
2309
|
+
this.destroyed || e.dispatch({ effects: Mr.of(t) });
|
|
2139
2310
|
}), e.dom.appendChild(this.menu.el), this.contentDOM = e.contentDOM, this.onPointerDown = () => {
|
|
2140
2311
|
let t = e.state.selection.main;
|
|
2141
2312
|
this.stashed = t.empty ? null : {
|
|
@@ -2145,17 +2316,17 @@ var hr = A.define({
|
|
|
2145
2316
|
}, this.contentDOM.addEventListener("pointerdown", this.onPointerDown, !0), this.onContextMenu = (e) => {
|
|
2146
2317
|
let t = e.target;
|
|
2147
2318
|
this.canOpen() && (t?.closest(".cm-inplace-table-edit") || (this.longPress.cancel(), (Date.now() - this.longPressAt < 700 || this.openMenuAt(e.clientX, e.clientY, t)) && e.preventDefault()));
|
|
2148
|
-
}, this.contentDOM.addEventListener("contextmenu", this.onContextMenu), this.longPress =
|
|
2319
|
+
}, this.contentDOM.addEventListener("contextmenu", this.onContextMenu), this.longPress = Jn(this.contentDOM, { onLongPress: (e, t, n) => {
|
|
2149
2320
|
this.longPressAt = Date.now(), this.openMenuAt(e, t, n);
|
|
2150
2321
|
} });
|
|
2151
2322
|
}
|
|
2152
2323
|
canOpen() {
|
|
2153
2324
|
let { state: e } = this.view;
|
|
2154
|
-
return e.facet(
|
|
2325
|
+
return e.facet(Ne) && (!e.readOnly || Sn(this.view));
|
|
2155
2326
|
}
|
|
2156
2327
|
rows() {
|
|
2157
2328
|
let e = this.view;
|
|
2158
|
-
return e.state.readOnly ?
|
|
2329
|
+
return e.state.readOnly ? Cn(e, { selected: !e.state.selection.main.empty }) : qn(e);
|
|
2159
2330
|
}
|
|
2160
2331
|
openMenuAt(e, t, n) {
|
|
2161
2332
|
let r = this.view;
|
|
@@ -2172,7 +2343,7 @@ var hr = A.define({
|
|
|
2172
2343
|
y: t
|
|
2173
2344
|
});
|
|
2174
2345
|
if (n != null) {
|
|
2175
|
-
let e =
|
|
2346
|
+
let e = H(r.state, n, !1, !0), t = r.state.wordAt(n) ?? { anchor: n };
|
|
2176
2347
|
e?.kind === "link" ? t = {
|
|
2177
2348
|
anchor: e.from,
|
|
2178
2349
|
head: e.to
|
|
@@ -2191,10 +2362,10 @@ var hr = A.define({
|
|
|
2191
2362
|
destroy() {
|
|
2192
2363
|
this.destroyed = !0, this.contentDOM.removeEventListener("pointerdown", this.onPointerDown, !0), this.contentDOM.removeEventListener("contextmenu", this.onContextMenu), this.longPress.dispose(), this.menu.destroy();
|
|
2193
2364
|
}
|
|
2194
|
-
},
|
|
2365
|
+
}, Pr = O.fromClass(Nr);
|
|
2195
2366
|
//#endregion
|
|
2196
2367
|
//#region src/inplace/selection-bar-position.ts
|
|
2197
|
-
function
|
|
2368
|
+
function Fr(e) {
|
|
2198
2369
|
let t = e.state.selection.main;
|
|
2199
2370
|
if (!t.empty) {
|
|
2200
2371
|
let n = e.coordsAtPos(t.from), r = e.coordsAtPos(t.to);
|
|
@@ -2208,7 +2379,7 @@ function br(e) {
|
|
|
2208
2379
|
}
|
|
2209
2380
|
};
|
|
2210
2381
|
}
|
|
2211
|
-
if (!
|
|
2382
|
+
if (!Vn(e)) return null;
|
|
2212
2383
|
let n = e.dom.ownerDocument.getSelection();
|
|
2213
2384
|
if (!n || n.rangeCount === 0) return null;
|
|
2214
2385
|
let r = n.getRangeAt(0).getBoundingClientRect();
|
|
@@ -2222,9 +2393,9 @@ function br(e) {
|
|
|
2222
2393
|
}
|
|
2223
2394
|
};
|
|
2224
2395
|
}
|
|
2225
|
-
function
|
|
2226
|
-
if (e.state.facet(Ve) !== "bar" || e.state.readOnly || e.state.field(
|
|
2227
|
-
let r =
|
|
2396
|
+
function Ir(e, t, n) {
|
|
2397
|
+
if (e.state.facet(Ve) !== "bar" || e.state.readOnly || e.state.field($, !1)) return null;
|
|
2398
|
+
let r = Fr(e);
|
|
2228
2399
|
if (!r) return null;
|
|
2229
2400
|
let { box: i, inCell: a } = r;
|
|
2230
2401
|
if (!a && !e.hasFocus) return null;
|
|
@@ -2242,7 +2413,7 @@ function xr(e, t, n) {
|
|
|
2242
2413
|
}
|
|
2243
2414
|
//#endregion
|
|
2244
2415
|
//#region src/inplace/selection-bar.ts
|
|
2245
|
-
var
|
|
2416
|
+
var Lr = class {
|
|
2246
2417
|
view;
|
|
2247
2418
|
bar;
|
|
2248
2419
|
ids;
|
|
@@ -2257,12 +2428,12 @@ var Sr = class {
|
|
|
2257
2428
|
constructor(e) {
|
|
2258
2429
|
this.view = e;
|
|
2259
2430
|
let t = e.dom.ownerDocument;
|
|
2260
|
-
this.ids = e.state.facet(Be), this.linkMenu =
|
|
2431
|
+
this.ids = e.state.facet(Be), this.linkMenu = Z(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;
|
|
2261
2432
|
for (let n of this.ids) {
|
|
2262
2433
|
let r = g[n], i = t.createElement("button");
|
|
2263
|
-
i.type = "button", i.className = "cm-inplace-selbar-btn", i.title = r.title, i.setAttribute("aria-label", r.title), i.appendChild(
|
|
2434
|
+
i.type = "button", i.className = "cm-inplace-selbar-btn", i.title = r.title, i.setAttribute("aria-label", r.title), i.appendChild(ue(t, S[n] ?? "")), i.addEventListener("mousedown", (e) => e.preventDefault()), i.addEventListener("click", (t) => {
|
|
2264
2435
|
t.preventDefault();
|
|
2265
|
-
let a = !!h(e), o = !a && n === "link" ?
|
|
2436
|
+
let a = !!h(e), o = !a && n === "link" ? An(e) : !a && n === "wikilink" ? jn(e) : null;
|
|
2266
2437
|
if (o) {
|
|
2267
2438
|
let e = i.getBoundingClientRect();
|
|
2268
2439
|
this.linkMenu.showField(o, e.left, e.bottom + 6);
|
|
@@ -2274,7 +2445,7 @@ var Sr = class {
|
|
|
2274
2445
|
e.dom.appendChild(this.bar), t.addEventListener("scroll", this.onScroll, !0), t.addEventListener("selectionchange", this.onSelectionChange);
|
|
2275
2446
|
}
|
|
2276
2447
|
update(e) {
|
|
2277
|
-
let t = e.startState.field(
|
|
2448
|
+
let t = e.startState.field($, !1) !== e.state.field($, !1), n = e.startState.readOnly !== e.state.readOnly;
|
|
2278
2449
|
(e.selectionSet || e.docChanged || e.focusChanged || t || n) && this.schedule();
|
|
2279
2450
|
}
|
|
2280
2451
|
schedule() {
|
|
@@ -2285,7 +2456,7 @@ var Sr = class {
|
|
|
2285
2456
|
});
|
|
2286
2457
|
}
|
|
2287
2458
|
measure() {
|
|
2288
|
-
return
|
|
2459
|
+
return Ir(this.view, this.bar, this.ids);
|
|
2289
2460
|
}
|
|
2290
2461
|
apply(e) {
|
|
2291
2462
|
if (!e) {
|
|
@@ -2299,30 +2470,42 @@ var Sr = class {
|
|
|
2299
2470
|
let e = this.view.dom.ownerDocument;
|
|
2300
2471
|
e.removeEventListener("scroll", this.onScroll, !0), e.removeEventListener("selectionchange", this.onSelectionChange), this.linkMenu.destroy(), this.bar.remove();
|
|
2301
2472
|
}
|
|
2302
|
-
},
|
|
2473
|
+
}, Rr = O.fromClass(Lr), zr = (e) => (t) => {
|
|
2303
2474
|
if (h(t)) return !1;
|
|
2304
2475
|
let n = t.state.selection.main;
|
|
2305
2476
|
if (!n.empty) return !1;
|
|
2306
2477
|
let { doc: r } = t.state, i = r.lineAt(n.head), a = e ? i.number + 1 : i.number - 1;
|
|
2307
2478
|
if (a < 1 || a > r.lines) return !1;
|
|
2308
2479
|
let o = r.line(a), s = -1, c = -1, l;
|
|
2309
|
-
if (t.state.field(
|
|
2480
|
+
if (t.state.field(X).between(o.from, o.to, (t, n, r) => {
|
|
2310
2481
|
if (e ? t === o.from : n === o.to) return s = t, c = n, l = r.spec.widget, !1;
|
|
2311
2482
|
}), s < 0) return !1;
|
|
2312
|
-
if (t.state.facet(
|
|
2483
|
+
if (t.state.facet(I) === "cells") return l instanceof ur && l.focusEdge(e ? "first" : "last");
|
|
2313
2484
|
let u = e ? r.lineAt(s).from : r.lineAt(c).to;
|
|
2314
2485
|
return t.dispatch({
|
|
2315
2486
|
selection: { anchor: u },
|
|
2316
2487
|
userEvent: "select",
|
|
2317
2488
|
scrollIntoView: !0
|
|
2318
2489
|
}), !0;
|
|
2319
|
-
},
|
|
2490
|
+
}, Br = zr(!0), Vr = zr(!1), Hr = j.high(ve.of([{
|
|
2320
2491
|
key: "ArrowDown",
|
|
2321
|
-
run:
|
|
2492
|
+
run: Br
|
|
2322
2493
|
}, {
|
|
2323
2494
|
key: "ArrowUp",
|
|
2324
|
-
run:
|
|
2325
|
-
}])),
|
|
2495
|
+
run: Vr
|
|
2496
|
+
}])), Ur = O.fromClass(class {
|
|
2497
|
+
last = "[]";
|
|
2498
|
+
update(e) {
|
|
2499
|
+
let t = JSON.stringify(e.state.facet(Le)(e.state));
|
|
2500
|
+
t === this.last && !e.docChanged || (t !== "[]" || this.last !== "[]") && (this.last = t, e.view.requestMeasure({
|
|
2501
|
+
read: () => null,
|
|
2502
|
+
write: (e, t) => {
|
|
2503
|
+
for (let e of t.dom.querySelectorAll(".cm-inplace-table-edit")) lr.get(e)?.repaintMarks();
|
|
2504
|
+
},
|
|
2505
|
+
key: this
|
|
2506
|
+
}));
|
|
2507
|
+
}
|
|
2508
|
+
}), Wr = {
|
|
2326
2509
|
".cm-inplace-callout": {
|
|
2327
2510
|
borderLeft: "0.25rem solid var(--stylo-callout-accent, var(--stylo-border))",
|
|
2328
2511
|
padding: "0 var(--stylo-rhythm-callout-padding-x, 1rem)",
|
|
@@ -2356,9 +2539,9 @@ var Sr = class {
|
|
|
2356
2539
|
content: "\"\"",
|
|
2357
2540
|
display: "none"
|
|
2358
2541
|
}
|
|
2359
|
-
},
|
|
2542
|
+
}, Gr = "var(--stylo-font-family-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace)", Kr = "var(--stylo-font-family, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif)", qr = {
|
|
2360
2543
|
"& .cm-content": {
|
|
2361
|
-
fontFamily:
|
|
2544
|
+
fontFamily: Kr,
|
|
2362
2545
|
lineHeight: "1.75",
|
|
2363
2546
|
padding: "0.75rem",
|
|
2364
2547
|
WebkitTouchCallout: "none"
|
|
@@ -2401,14 +2584,14 @@ var Sr = class {
|
|
|
2401
2584
|
".cm-inplace-em": { fontStyle: "italic" },
|
|
2402
2585
|
".cm-inplace-strike": { textDecoration: "line-through" },
|
|
2403
2586
|
".cm-inplace-code": {
|
|
2404
|
-
fontFamily:
|
|
2587
|
+
fontFamily: Gr,
|
|
2405
2588
|
fontSize: "0.9em",
|
|
2406
2589
|
padding: "0.1em 0.35em",
|
|
2407
2590
|
borderRadius: "3px",
|
|
2408
2591
|
background: "color-mix(in srgb, var(--stylo-border) 45%, transparent)"
|
|
2409
2592
|
},
|
|
2410
2593
|
".cm-inplace-mono": {
|
|
2411
|
-
fontFamily:
|
|
2594
|
+
fontFamily: Gr,
|
|
2412
2595
|
fontSize: "0.9em",
|
|
2413
2596
|
background: "color-mix(in srgb, var(--stylo-border) 35%, transparent)",
|
|
2414
2597
|
padding: "0 0.9rem"
|
|
@@ -2486,21 +2669,21 @@ var Sr = class {
|
|
|
2486
2669
|
cursor: "pointer"
|
|
2487
2670
|
},
|
|
2488
2671
|
".cm-inplace-fm": {
|
|
2489
|
-
fontFamily:
|
|
2672
|
+
fontFamily: Gr,
|
|
2490
2673
|
fontSize: "0.85em",
|
|
2491
2674
|
color: "var(--stylo-text-muted)"
|
|
2492
2675
|
},
|
|
2493
2676
|
".cm-inplace-fm-first::before": {
|
|
2494
2677
|
content: "\"Frontmatter\"",
|
|
2495
2678
|
marginRight: "0.6em",
|
|
2496
|
-
fontFamily:
|
|
2679
|
+
fontFamily: Kr,
|
|
2497
2680
|
fontSize: "0.8rem",
|
|
2498
2681
|
fontWeight: "600",
|
|
2499
2682
|
textTransform: "uppercase",
|
|
2500
2683
|
letterSpacing: "0.04em",
|
|
2501
2684
|
color: "var(--stylo-text-muted)"
|
|
2502
2685
|
}
|
|
2503
|
-
},
|
|
2686
|
+
}, Jr = {
|
|
2504
2687
|
".cm-inplace-menu": {
|
|
2505
2688
|
position: "fixed",
|
|
2506
2689
|
inset: "0",
|
|
@@ -2574,7 +2757,7 @@ var Sr = class {
|
|
|
2574
2757
|
outline: "none"
|
|
2575
2758
|
},
|
|
2576
2759
|
".cm-inplace-menu-input:focus": { borderColor: "var(--stylo-ring)" }
|
|
2577
|
-
},
|
|
2760
|
+
}, Yr = {
|
|
2578
2761
|
".cm-inplace-selbar": {
|
|
2579
2762
|
position: "fixed",
|
|
2580
2763
|
zIndex: "20",
|
|
@@ -2659,7 +2842,7 @@ var Sr = class {
|
|
|
2659
2842
|
lineHeight: "1.4",
|
|
2660
2843
|
wordBreak: "break-all"
|
|
2661
2844
|
}
|
|
2662
|
-
},
|
|
2845
|
+
}, Xr = {
|
|
2663
2846
|
".cm-inplace-table": {
|
|
2664
2847
|
borderCollapse: "collapse",
|
|
2665
2848
|
padding: "1em 0 1.4em",
|
|
@@ -2682,7 +2865,7 @@ var Sr = class {
|
|
|
2682
2865
|
outline: "none"
|
|
2683
2866
|
},
|
|
2684
2867
|
".cm-inplace-table-edit .cm-inplace-tcell:focus": { boxShadow: "inset 0 0 0 2px var(--stylo-ring)" }
|
|
2685
|
-
},
|
|
2868
|
+
}, Zr = {
|
|
2686
2869
|
".cm-inplace-table-wrap": {
|
|
2687
2870
|
position: "relative",
|
|
2688
2871
|
display: "inline-block",
|
|
@@ -2724,58 +2907,60 @@ var Sr = class {
|
|
|
2724
2907
|
},
|
|
2725
2908
|
".cm-inplace-tg-edge:hover .cm-inplace-tg-plus": { color: "var(--stylo-text)" },
|
|
2726
2909
|
"@media (hover: none)": { ".cm-inplace-tg-edge": { opacity: "0.5" } }
|
|
2727
|
-
},
|
|
2728
|
-
...
|
|
2729
|
-
...
|
|
2730
|
-
...
|
|
2731
|
-
...
|
|
2732
|
-
...
|
|
2733
|
-
...
|
|
2734
|
-
}),
|
|
2735
|
-
function
|
|
2736
|
-
let t =
|
|
2910
|
+
}, Qr = D.theme({
|
|
2911
|
+
...qr,
|
|
2912
|
+
...Wr,
|
|
2913
|
+
...Xr,
|
|
2914
|
+
...Zr,
|
|
2915
|
+
...Jr,
|
|
2916
|
+
...Yr
|
|
2917
|
+
}), $r = ".cm-inplace-math, .cm-inplace-hr, .cm-inplace-table, .cm-inplace-embed, .cm-inplace-embed-inline";
|
|
2918
|
+
function ei(e = {}) {
|
|
2919
|
+
let t = Fe(e.inPlace?.contextMenu);
|
|
2737
2920
|
return [
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2921
|
+
P.of(je(e.inPlace)),
|
|
2922
|
+
F.of(e.embedRegistry ?? null),
|
|
2923
|
+
I.of(e.inPlace?.table ?? "source"),
|
|
2924
|
+
L.of(e.inPlace?.reveal ?? "caret"),
|
|
2925
|
+
Me.of(e.onLinkClick ?? null),
|
|
2926
|
+
Ne.of(t.enabled),
|
|
2927
|
+
Re.of(t.groups),
|
|
2928
|
+
Ie.of(e.hostItems ?? (() => t.items)),
|
|
2929
|
+
Le.of(e.cellMarks ?? e.inPlace?.cellMarks ?? (() => [])),
|
|
2746
2930
|
Ve.of(e.inPlace?.selectionUI ?? "menu"),
|
|
2747
2931
|
Be.of(ze(e.inPlace?.selectionBarItems)),
|
|
2748
2932
|
Dt(),
|
|
2749
|
-
|
|
2750
|
-
|
|
2933
|
+
br,
|
|
2934
|
+
nn,
|
|
2751
2935
|
Rt,
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2936
|
+
Hr,
|
|
2937
|
+
gr,
|
|
2938
|
+
fr,
|
|
2755
2939
|
nt,
|
|
2756
|
-
|
|
2940
|
+
jr,
|
|
2757
2941
|
Ue,
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2942
|
+
X,
|
|
2943
|
+
Ur,
|
|
2944
|
+
$,
|
|
2945
|
+
Pr,
|
|
2946
|
+
Rr,
|
|
2947
|
+
Sr,
|
|
2948
|
+
Dr,
|
|
2949
|
+
zn,
|
|
2950
|
+
Bn,
|
|
2951
|
+
j.high(Qr),
|
|
2952
|
+
D.domEventHandlers({
|
|
2768
2953
|
mousedown(e, t) {
|
|
2769
2954
|
let n = e.target;
|
|
2770
2955
|
if (n?.closest(".cm-inplace-table-edit") || n?.closest(".stylo-embed-content")) return !1;
|
|
2771
|
-
let r = n?.closest(
|
|
2956
|
+
let r = n?.closest($r);
|
|
2772
2957
|
if (!r) return !1;
|
|
2773
2958
|
let i = t.posAtDOM(r);
|
|
2774
2959
|
if (i < 0) return !1;
|
|
2775
2960
|
let a = n?.closest("[data-stylo-row]");
|
|
2776
2961
|
if (a && r.contains(a)) {
|
|
2777
|
-
let n =
|
|
2778
|
-
n != null && (i = n +
|
|
2962
|
+
let n = v(t.state.doc, i, Number(a.dataset.styloRow), Number(a.dataset.styloCol));
|
|
2963
|
+
n != null && (i = n + x(a, e.clientX, e.clientY));
|
|
2779
2964
|
}
|
|
2780
2965
|
return t.focus(), t.dispatch({ selection: { anchor: i } }), !0;
|
|
2781
2966
|
},
|
|
@@ -2789,21 +2974,23 @@ function Rr(e = {}) {
|
|
|
2789
2974
|
}
|
|
2790
2975
|
//#endregion
|
|
2791
2976
|
//#region src/inplace/InPlaceView.tsx
|
|
2792
|
-
var
|
|
2793
|
-
function
|
|
2794
|
-
let te =
|
|
2977
|
+
var ti = () => () => {}, ni = () => null;
|
|
2978
|
+
function ri({ value: e, onChange: t, readOnly: r, placeholder: i, onWikiLinkClick: a, onLinkClick: o, inPlace: s, codeLanguages: c, wikiLinkSource: l, tagSource: u, embedSource: d, onResolveError: f, onSave: p, onViewChange: m, canvasHeader: h, hostExtensions: ee }) {
|
|
2979
|
+
let te = w(a);
|
|
2795
2980
|
te.current = a;
|
|
2796
|
-
let re =
|
|
2981
|
+
let re = w(o);
|
|
2797
2982
|
re.current = o;
|
|
2798
|
-
let ie =
|
|
2983
|
+
let ie = w(s?.contextMenu);
|
|
2799
2984
|
ie.current = s?.contextMenu;
|
|
2800
|
-
let
|
|
2801
|
-
|
|
2802
|
-
let
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2985
|
+
let g = w(s?.cellMarks);
|
|
2986
|
+
g.current = s?.cellMarks;
|
|
2987
|
+
let [_] = T(() => new ke()), ae = ge(_.subscribe, _.getSnapshot, _.getSnapshot), [oe, se] = T(null), v = w(m);
|
|
2988
|
+
v.current = m;
|
|
2989
|
+
let le = w((e) => {
|
|
2990
|
+
se(e), v.current?.(e);
|
|
2991
|
+
}).current, y = w(h);
|
|
2992
|
+
y.current = h;
|
|
2993
|
+
let [b] = T(() => h ? new ne() : null), x = ge(b?.subscribe ?? ti, b?.getSnapshot ?? ni), [ue] = T(() => [ei({
|
|
2807
2994
|
onWikiLinkClick: (e) => te.current?.(e),
|
|
2808
2995
|
onLinkClick: (e) => re.current?.(e),
|
|
2809
2996
|
inPlace: s,
|
|
@@ -2811,13 +2998,14 @@ function Vr({ value: e, onChange: t, readOnly: r, placeholder: i, onWikiLinkClic
|
|
|
2811
2998
|
let e = ie.current;
|
|
2812
2999
|
return typeof e == "object" ? e.items ?? [] : [];
|
|
2813
3000
|
},
|
|
2814
|
-
|
|
2815
|
-
|
|
3001
|
+
cellMarks: (e) => g.current?.(e) ?? [],
|
|
3002
|
+
embedRegistry: d ? _ : void 0
|
|
3003
|
+
}), ...b ? [ye.of(b.panel)] : []]), S = ce({
|
|
2816
3004
|
value: e,
|
|
2817
3005
|
onChange: t,
|
|
2818
3006
|
readOnly: r,
|
|
2819
3007
|
placeholder: i,
|
|
2820
|
-
extensions:
|
|
3008
|
+
extensions: ue,
|
|
2821
3009
|
codeLanguages: c,
|
|
2822
3010
|
wikiLinkSource: l,
|
|
2823
3011
|
tagSource: u,
|
|
@@ -2826,18 +3014,18 @@ function Vr({ value: e, onChange: t, readOnly: r, placeholder: i, onWikiLinkClic
|
|
|
2826
3014
|
onViewChange: le,
|
|
2827
3015
|
hostExtensions: ee
|
|
2828
3016
|
});
|
|
2829
|
-
return /* @__PURE__ */
|
|
3017
|
+
return /* @__PURE__ */ De("div", {
|
|
2830
3018
|
className: n.inplace,
|
|
2831
|
-
ref:
|
|
2832
|
-
children: [d && ae.map((e) =>
|
|
3019
|
+
ref: S,
|
|
3020
|
+
children: [d && ae.map((e) => be(/* @__PURE__ */ Ee(pe, {
|
|
2833
3021
|
reference: e.ref,
|
|
2834
3022
|
source: d,
|
|
2835
3023
|
onError: f,
|
|
2836
3024
|
inline: e.inline
|
|
2837
|
-
}), e.el, String(e.id))),
|
|
3025
|
+
}), e.el, String(e.id))), x && y.current && be(y.current({ view: oe }), x)]
|
|
2838
3026
|
});
|
|
2839
3027
|
}
|
|
2840
3028
|
//#endregion
|
|
2841
|
-
export {
|
|
3029
|
+
export { ri as InPlaceView };
|
|
2842
3030
|
|
|
2843
|
-
//# sourceMappingURL=InPlaceView-
|
|
3031
|
+
//# sourceMappingURL=InPlaceView-AZ_ufoP3.js.map
|