@damiro/stylo 0.19.1 → 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-rt6po4_E.js → InPlaceView-AZ_ufoP3.js} +622 -437
- 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.map +1 -1
- package/dist/inplace/extension.d.ts +4 -2
- package/dist/inplace/extension.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-rt6po4_E.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,34 +1070,34 @@ 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
|
|
1095
|
+
function hn(e, t, n) {
|
|
984
1096
|
let i = t.closest("table");
|
|
985
1097
|
if (!i) return;
|
|
986
1098
|
let a = e.posAtDOM(i), o = a;
|
|
987
|
-
e.state.field(
|
|
988
|
-
let s =
|
|
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));
|
|
989
1101
|
if (s == null) return;
|
|
990
1102
|
let { from: c, to: l } = n ? r(t) : {
|
|
991
1103
|
from: 0,
|
|
@@ -997,46 +1109,76 @@ function cn(e, t, n) {
|
|
|
997
1109
|
} });
|
|
998
1110
|
}
|
|
999
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
|
|
1000
1142
|
//#region src/inplace/host-items.ts
|
|
1001
|
-
var
|
|
1002
|
-
function
|
|
1143
|
+
var yn = /* @__PURE__ */ new WeakMap();
|
|
1144
|
+
function bn(e, t) {
|
|
1003
1145
|
if (e == null || typeof e == "string") return null;
|
|
1004
|
-
if (
|
|
1005
|
-
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;
|
|
1006
1148
|
try {
|
|
1007
|
-
|
|
1149
|
+
xe(() => r.render(e)), i = n.firstElementChild;
|
|
1008
1150
|
} catch {}
|
|
1009
|
-
return r.unmount(),
|
|
1010
|
-
}
|
|
1011
|
-
var
|
|
1012
|
-
function
|
|
1013
|
-
if (!
|
|
1014
|
-
let n = e.state.readOnly, r = [];
|
|
1015
|
-
for (let
|
|
1016
|
-
if (n && !
|
|
1017
|
-
let
|
|
1018
|
-
if (
|
|
1019
|
-
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);
|
|
1020
1162
|
r.push({
|
|
1021
|
-
id:
|
|
1022
|
-
label:
|
|
1023
|
-
icon: typeof
|
|
1024
|
-
iconNode:
|
|
1025
|
-
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,
|
|
1026
1168
|
onSelect: () => {
|
|
1027
|
-
t.prepare?.(),
|
|
1169
|
+
t.prepare?.(), a.run(e, { rect: i });
|
|
1028
1170
|
}
|
|
1029
1171
|
});
|
|
1030
1172
|
}
|
|
1031
|
-
return r;
|
|
1173
|
+
return r.length && (i = t.rect?.() ?? _n(e)), r;
|
|
1032
1174
|
}
|
|
1033
1175
|
//#endregion
|
|
1034
1176
|
//#region src/inplace/link-row.ts
|
|
1035
|
-
var
|
|
1177
|
+
var wn = (e) => {
|
|
1036
1178
|
let t = e.trim().replace(/^<([^]*)>$/, "$1");
|
|
1037
1179
|
return /[\s()]/.test(t) ? `<${t.replace(/[<>]/g, "")}>` : t;
|
|
1038
|
-
},
|
|
1039
|
-
function
|
|
1180
|
+
}, Tn = (e) => e.replace(/^<([^]*)>$/, "$1");
|
|
1181
|
+
function En(e, t) {
|
|
1040
1182
|
let n = e.doc.lineAt(t.from);
|
|
1041
1183
|
if (e.doc.lineAt(t.to).number !== n.number) return null;
|
|
1042
1184
|
let r = t.from - n.from, i = t.to - n.from, s = o(n.text, r) ?? o(n.text, i);
|
|
@@ -1052,7 +1194,7 @@ function gn(e, t) {
|
|
|
1052
1194
|
text: c.label
|
|
1053
1195
|
} : null;
|
|
1054
1196
|
}
|
|
1055
|
-
function
|
|
1197
|
+
function Dn(e, t) {
|
|
1056
1198
|
let { state: n } = e, r = n.selection.main, i = n.doc.lineAt(r.head), a = t.partsIn(i.text, r.head - i.from);
|
|
1057
1199
|
if (a) {
|
|
1058
1200
|
let n = i.from + a.from, r = i.from + a.to, o = t.editActions?.(e, a) ?? [];
|
|
@@ -1081,7 +1223,7 @@ function _n(e, t) {
|
|
|
1081
1223
|
actions: o
|
|
1082
1224
|
};
|
|
1083
1225
|
}
|
|
1084
|
-
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);
|
|
1085
1227
|
return {
|
|
1086
1228
|
field: !0,
|
|
1087
1229
|
label: t.addLabel,
|
|
@@ -1091,18 +1233,18 @@ function _n(e, t) {
|
|
|
1091
1233
|
onSubmit: (n) => t.onAdd(e, s, c, l, n)
|
|
1092
1234
|
};
|
|
1093
1235
|
}
|
|
1094
|
-
var
|
|
1095
|
-
icon:
|
|
1236
|
+
var On = {
|
|
1237
|
+
icon: S.link,
|
|
1096
1238
|
placeholder: "https://…",
|
|
1097
1239
|
editLabel: "Edit external link",
|
|
1098
1240
|
addLabel: "Add external link",
|
|
1099
1241
|
partsIn: o,
|
|
1100
|
-
editValue: (e) =>
|
|
1242
|
+
editValue: (e) => Tn(e.url),
|
|
1101
1243
|
editActions: (e, t) => {
|
|
1102
|
-
let n = e.state.facet(
|
|
1244
|
+
let n = e.state.facet(Me);
|
|
1103
1245
|
return !n || !t.url ? [] : [{
|
|
1104
1246
|
label: "Open link",
|
|
1105
|
-
icon:
|
|
1247
|
+
icon: S.link,
|
|
1106
1248
|
onSelect: () => n(t.url)
|
|
1107
1249
|
}];
|
|
1108
1250
|
},
|
|
@@ -1110,7 +1252,7 @@ var vn = {
|
|
|
1110
1252
|
e.dispatch({ changes: {
|
|
1111
1253
|
from: t.urlFrom,
|
|
1112
1254
|
to: t.urlTo,
|
|
1113
|
-
insert:
|
|
1255
|
+
insert: wn(n)
|
|
1114
1256
|
} }), e.focus();
|
|
1115
1257
|
},
|
|
1116
1258
|
onAdd: (e, t, n, r, i) => {
|
|
@@ -1119,7 +1261,7 @@ var vn = {
|
|
|
1119
1261
|
changes: {
|
|
1120
1262
|
from: t,
|
|
1121
1263
|
to: n,
|
|
1122
|
-
insert: `[${a}](${
|
|
1264
|
+
insert: `[${a}](${wn(i)})`
|
|
1123
1265
|
},
|
|
1124
1266
|
selection: {
|
|
1125
1267
|
anchor: t + 1,
|
|
@@ -1127,8 +1269,8 @@ var vn = {
|
|
|
1127
1269
|
}
|
|
1128
1270
|
}), e.focus();
|
|
1129
1271
|
}
|
|
1130
|
-
},
|
|
1131
|
-
icon:
|
|
1272
|
+
}, kn = {
|
|
1273
|
+
icon: S.wikilink,
|
|
1132
1274
|
placeholder: "note or path",
|
|
1133
1275
|
editLabel: "Edit link",
|
|
1134
1276
|
addLabel: "Add link",
|
|
@@ -1156,27 +1298,27 @@ var vn = {
|
|
|
1156
1298
|
}), e.focus();
|
|
1157
1299
|
}
|
|
1158
1300
|
};
|
|
1159
|
-
function
|
|
1160
|
-
return
|
|
1301
|
+
function An(e) {
|
|
1302
|
+
return Dn(e, On);
|
|
1161
1303
|
}
|
|
1162
|
-
function
|
|
1163
|
-
return
|
|
1304
|
+
function jn(e) {
|
|
1305
|
+
return Dn(e, kn);
|
|
1164
1306
|
}
|
|
1165
1307
|
//#endregion
|
|
1166
1308
|
//#region src/inplace/context-menu-shell.ts
|
|
1167
|
-
function
|
|
1309
|
+
function Mn(e, t, n, r) {
|
|
1168
1310
|
let i = r?.innerWidth ?? 0, a = r?.innerHeight ?? 0;
|
|
1169
1311
|
e.style.left = "0", e.style.top = "0";
|
|
1170
1312
|
let { width: o, height: s } = e.getBoundingClientRect();
|
|
1171
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`;
|
|
1172
1314
|
}
|
|
1173
|
-
function
|
|
1315
|
+
function Nn(e, t, n) {
|
|
1174
1316
|
let r = n?.innerWidth ?? 0, i = n?.innerHeight ?? 0;
|
|
1175
1317
|
e.style.left = "0", e.style.top = "0";
|
|
1176
1318
|
let { width: a, height: o } = e.getBoundingClientRect(), s = t.right - 4, c = s + a > r - 4 ? t.left - a + 4 : s;
|
|
1177
1319
|
e.style.left = `${Math.max(4, c)}px`, e.style.top = `${Math.max(4, Math.min(t.top - 4, i - o - 4))}px`;
|
|
1178
1320
|
}
|
|
1179
|
-
function
|
|
1321
|
+
function Pn(e, t, n, r = 350) {
|
|
1180
1322
|
let i = Date.now(), a = (e) => !t.contains(e.target), o = (e) => {
|
|
1181
1323
|
a(e) && n();
|
|
1182
1324
|
}, s = (e) => {
|
|
@@ -1190,10 +1332,10 @@ function wn(e, t, n, r = 350) {
|
|
|
1190
1332
|
}
|
|
1191
1333
|
//#endregion
|
|
1192
1334
|
//#region src/inplace/context-menu-types.ts
|
|
1193
|
-
var
|
|
1335
|
+
var Fn = (e) => typeof e != "string" && "rows" in e, In = (e) => typeof e != "string" && "field" in e;
|
|
1194
1336
|
//#endregion
|
|
1195
1337
|
//#region src/inplace/context-menu.ts
|
|
1196
|
-
function
|
|
1338
|
+
function Z(e, t = "cm-inplace-menu", n) {
|
|
1197
1339
|
let r = e.defaultView, i = e.createElement("div");
|
|
1198
1340
|
i.className = t, i.setAttribute("contenteditable", "false"), i.hidden = !0;
|
|
1199
1341
|
let a = null, o = null, s = () => {
|
|
@@ -1203,7 +1345,7 @@ function X(e, t = "cm-inplace-menu", n) {
|
|
|
1203
1345
|
}, l = (e) => e.addEventListener("mousedown", (e) => {
|
|
1204
1346
|
e.preventDefault(), e.stopPropagation();
|
|
1205
1347
|
}), u = (t, n, r, i) => {
|
|
1206
|
-
i ? t.appendChild(i.cloneNode(!0)) : r && t.appendChild(
|
|
1348
|
+
i ? t.appendChild(i.cloneNode(!0)) : r && t.appendChild(ue(e, r));
|
|
1207
1349
|
let a = e.createElement("span");
|
|
1208
1350
|
a.textContent = n, t.appendChild(a);
|
|
1209
1351
|
}, d = (n) => {
|
|
@@ -1221,7 +1363,7 @@ function X(e, t = "cm-inplace-menu", n) {
|
|
|
1221
1363
|
if (a?.dataset.for === n) return;
|
|
1222
1364
|
s();
|
|
1223
1365
|
let e = c();
|
|
1224
|
-
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 });
|
|
1225
1367
|
};
|
|
1226
1368
|
return f.addEventListener("pointerenter", p), f.addEventListener("click", (e) => {
|
|
1227
1369
|
e.stopPropagation(), p();
|
|
@@ -1244,7 +1386,7 @@ function X(e, t = "cm-inplace-menu", n) {
|
|
|
1244
1386
|
for (let i of n) if (i === "separator") {
|
|
1245
1387
|
let n = e.createElement("div");
|
|
1246
1388
|
n.className = `${t}-sep`, r.appendChild(n);
|
|
1247
|
-
} 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));
|
|
1248
1390
|
return r;
|
|
1249
1391
|
};
|
|
1250
1392
|
return {
|
|
@@ -1255,12 +1397,12 @@ function X(e, t = "cm-inplace-menu", n) {
|
|
|
1255
1397
|
show: (t, a, s) => {
|
|
1256
1398
|
c();
|
|
1257
1399
|
let l = m(t);
|
|
1258
|
-
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);
|
|
1259
1401
|
},
|
|
1260
1402
|
showField: (t, a, s) => {
|
|
1261
1403
|
c();
|
|
1262
1404
|
let l = p(t);
|
|
1263
|
-
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);
|
|
1264
1406
|
},
|
|
1265
1407
|
hide: c,
|
|
1266
1408
|
destroy: () => {
|
|
@@ -1270,14 +1412,14 @@ function X(e, t = "cm-inplace-menu", n) {
|
|
|
1270
1412
|
}
|
|
1271
1413
|
//#endregion
|
|
1272
1414
|
//#region src/inplace/math-edit.ts
|
|
1273
|
-
function
|
|
1415
|
+
function Ln(e) {
|
|
1274
1416
|
let { state: t } = e, n = t.selection.main, r = t.doc.lineAt(n.head), i = Qe(r.text, n.head - r.from);
|
|
1275
1417
|
if (i) {
|
|
1276
1418
|
let t = r.from + i.from, n = r.from + i.to, a = i.block ? "$$" : "$";
|
|
1277
1419
|
return {
|
|
1278
1420
|
field: !0,
|
|
1279
1421
|
label: "Edit math",
|
|
1280
|
-
icon:
|
|
1422
|
+
icon: S.math,
|
|
1281
1423
|
value: i.src,
|
|
1282
1424
|
placeholder: "e^{i\\pi} + 1 = 0",
|
|
1283
1425
|
onSubmit: (r) => {
|
|
@@ -1310,7 +1452,7 @@ function Dn(e) {
|
|
|
1310
1452
|
return {
|
|
1311
1453
|
field: !0,
|
|
1312
1454
|
label: "Add math",
|
|
1313
|
-
icon:
|
|
1455
|
+
icon: S.math,
|
|
1314
1456
|
value: "",
|
|
1315
1457
|
placeholder: "e^{i\\pi} + 1 = 0",
|
|
1316
1458
|
onSubmit: (t) => {
|
|
@@ -1329,26 +1471,26 @@ function Dn(e) {
|
|
|
1329
1471
|
}
|
|
1330
1472
|
};
|
|
1331
1473
|
}
|
|
1332
|
-
var
|
|
1474
|
+
var Rn = class {
|
|
1333
1475
|
menu;
|
|
1334
1476
|
contentDOM;
|
|
1335
1477
|
onClick;
|
|
1336
1478
|
constructor(e) {
|
|
1337
|
-
this.menu =
|
|
1338
|
-
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;
|
|
1339
1481
|
let n = t.target?.closest(".cm-inplace-math");
|
|
1340
1482
|
if (!n) return;
|
|
1341
1483
|
let r = e.posAtDOM(n);
|
|
1342
1484
|
if (r < 0) return;
|
|
1343
1485
|
let i = e.state.doc.lineAt(r);
|
|
1344
|
-
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));
|
|
1345
1487
|
}, this.contentDOM.addEventListener("click", this.onClick);
|
|
1346
1488
|
}
|
|
1347
1489
|
destroy() {
|
|
1348
1490
|
this.contentDOM.removeEventListener("click", this.onClick), this.menu.destroy();
|
|
1349
1491
|
}
|
|
1350
|
-
},
|
|
1351
|
-
if (!e.state.facet(
|
|
1492
|
+
}, zn = O.fromClass(Rn), Bn = _e((e, t) => {
|
|
1493
|
+
if (!e.state.facet(P).math) return null;
|
|
1352
1494
|
let n = e.state.doc.lineAt(t), r = Qe(n.text, t - n.from);
|
|
1353
1495
|
return r ? {
|
|
1354
1496
|
pos: n.from + r.from,
|
|
@@ -1362,18 +1504,18 @@ var On = class {
|
|
|
1362
1504
|
});
|
|
1363
1505
|
//#endregion
|
|
1364
1506
|
//#region src/inplace/context-menu-actions.ts
|
|
1365
|
-
function
|
|
1507
|
+
function Vn(e) {
|
|
1366
1508
|
let t = h(e);
|
|
1367
1509
|
if (!t) return !1;
|
|
1368
1510
|
let { from: n, to: i } = r(t);
|
|
1369
1511
|
return i > n;
|
|
1370
1512
|
}
|
|
1371
|
-
function
|
|
1513
|
+
function Hn(e) {
|
|
1372
1514
|
let t = ie(e.state);
|
|
1373
1515
|
return {
|
|
1374
1516
|
field: !0,
|
|
1375
1517
|
label: "Language",
|
|
1376
|
-
icon:
|
|
1518
|
+
icon: S.codeBlock,
|
|
1377
1519
|
value: t?.lang ?? "",
|
|
1378
1520
|
placeholder: "ts, python, …",
|
|
1379
1521
|
onSubmit: (n) => {
|
|
@@ -1391,48 +1533,49 @@ function jn(e) {
|
|
|
1391
1533
|
}]
|
|
1392
1534
|
};
|
|
1393
1535
|
}
|
|
1394
|
-
var
|
|
1395
|
-
...
|
|
1536
|
+
var Un = (e, t = !1) => [
|
|
1537
|
+
...W(e, qt, !1, t),
|
|
1396
1538
|
"separator",
|
|
1397
|
-
...t ?
|
|
1539
|
+
...t ? W(e, Jt, !1, !0) : [$t(e, "code", !1), Ln(e)]
|
|
1398
1540
|
];
|
|
1399
|
-
function
|
|
1400
|
-
let n = e.state.facet(
|
|
1401
|
-
return
|
|
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, {
|
|
1402
1544
|
selected: i,
|
|
1403
|
-
prepare: () => r &&
|
|
1404
|
-
|
|
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;
|
|
1405
1548
|
}
|
|
1406
|
-
var
|
|
1407
|
-
...
|
|
1549
|
+
var Gn = (e) => [
|
|
1550
|
+
...W(e, Yt),
|
|
1408
1551
|
"separator",
|
|
1409
|
-
...
|
|
1552
|
+
...W(e, [...Xt, "body"]),
|
|
1410
1553
|
"separator",
|
|
1411
|
-
...
|
|
1412
|
-
],
|
|
1413
|
-
...
|
|
1554
|
+
...W(e, ["quote"])
|
|
1555
|
+
], Kn = (e) => [
|
|
1556
|
+
...W(e, Zt),
|
|
1414
1557
|
"separator",
|
|
1415
|
-
...
|
|
1558
|
+
...W(e, Qt)
|
|
1416
1559
|
];
|
|
1417
|
-
function
|
|
1418
|
-
let { state: t } = e, n = t.facet(
|
|
1419
|
-
if (
|
|
1420
|
-
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 });
|
|
1421
1564
|
if (ee(t)) {
|
|
1422
1565
|
let t = [];
|
|
1423
|
-
return
|
|
1566
|
+
return q(t, i), q(t, [Hn(e)]), r("clipboard") && q(t, G(e)), t;
|
|
1424
1567
|
}
|
|
1425
|
-
if (
|
|
1568
|
+
if (en(t)) {
|
|
1426
1569
|
let t = [];
|
|
1427
|
-
return
|
|
1570
|
+
return q(t, i), q(t, [rn(e)]), r("clipboard") && q(t, G(e)), t;
|
|
1428
1571
|
}
|
|
1429
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 = [];
|
|
1430
|
-
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));
|
|
1431
1574
|
return l;
|
|
1432
1575
|
}
|
|
1433
1576
|
//#endregion
|
|
1434
1577
|
//#region src/inplace/long-press.ts
|
|
1435
|
-
function
|
|
1578
|
+
function Jn(e, t) {
|
|
1436
1579
|
let n = t.delay ?? 450, r = t.slop ?? 20, i = null, a = 0, o = 0, s = () => {
|
|
1437
1580
|
i != null && (clearTimeout(i), i = null);
|
|
1438
1581
|
}, c = (e) => {
|
|
@@ -1454,10 +1597,10 @@ function Ln(e, t) {
|
|
|
1454
1597
|
}
|
|
1455
1598
|
//#endregion
|
|
1456
1599
|
//#region src/inplace/table-gizmos.ts
|
|
1457
|
-
function
|
|
1600
|
+
function Yn(e, t) {
|
|
1458
1601
|
let n = e.createElement("div");
|
|
1459
1602
|
n.className = "cm-inplace-table-gizmos", n.setAttribute("contenteditable", "false");
|
|
1460
|
-
let r =
|
|
1603
|
+
let r = Z(e), i = (t, n, r) => {
|
|
1461
1604
|
let i = e.createElement("button");
|
|
1462
1605
|
return i.type = "button", i.className = t, i.setAttribute("aria-label", n), i.addEventListener("mousedown", (e) => {
|
|
1463
1606
|
e.preventDefault(), e.stopPropagation();
|
|
@@ -1540,7 +1683,7 @@ function Rn(e, t) {
|
|
|
1540
1683
|
}
|
|
1541
1684
|
//#endregion
|
|
1542
1685
|
//#region src/inplace/table-widget-keys.ts
|
|
1543
|
-
function
|
|
1686
|
+
function Xn(e, t, n) {
|
|
1544
1687
|
let r = e.target.closest("td, th");
|
|
1545
1688
|
if (!r) return;
|
|
1546
1689
|
if (l(e, r)) {
|
|
@@ -1609,56 +1752,65 @@ function zn(e, t, n) {
|
|
|
1609
1752
|
}
|
|
1610
1753
|
//#endregion
|
|
1611
1754
|
//#region src/inplace/table-widget-render.ts
|
|
1612
|
-
|
|
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) {
|
|
1613
1757
|
let r = Number(e.dataset.r), i = Number(e.dataset.c), a = t.rows[r]?.[i] ?? "";
|
|
1614
|
-
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
|
+
});
|
|
1615
1766
|
}
|
|
1616
|
-
function
|
|
1767
|
+
function tr(e, t, n, r) {
|
|
1617
1768
|
let i = document.createElement(r ? "th" : "td");
|
|
1618
1769
|
i.className = "cm-inplace-tcell", i.setAttribute("contenteditable", "true"), i.dataset.r = String(t), i.dataset.c = String(n);
|
|
1619
1770
|
let a = e.aligns[n];
|
|
1620
|
-
return a && (i.style.textAlign = a),
|
|
1771
|
+
return a && (i.style.textAlign = a), er(i, e, !1), i;
|
|
1621
1772
|
}
|
|
1622
|
-
function
|
|
1773
|
+
function nr(e, t) {
|
|
1623
1774
|
e.replaceChildren();
|
|
1624
1775
|
let n = t.aligns.length, r = e.createTHead().insertRow();
|
|
1625
|
-
for (let e = 0; e < n; e++) r.appendChild(
|
|
1776
|
+
for (let e = 0; e < n; e++) r.appendChild(tr(t, 0, e, !0));
|
|
1626
1777
|
let i = e.createTBody();
|
|
1627
1778
|
for (let e = 1; e < t.rows.length; e++) {
|
|
1628
1779
|
let r = i.insertRow();
|
|
1629
|
-
for (let i = 0; i < n; i++) r.appendChild(
|
|
1780
|
+
for (let i = 0; i < n; i++) r.appendChild(tr(t, e, i, !1));
|
|
1630
1781
|
}
|
|
1631
1782
|
}
|
|
1632
1783
|
//#endregion
|
|
1633
1784
|
//#region src/inplace/table-structure.ts
|
|
1634
1785
|
var Q = (e) => e.aligns.length;
|
|
1635
|
-
function
|
|
1786
|
+
function rr(e, t) {
|
|
1636
1787
|
let n = Math.max(0, Math.min(t, Q(e)));
|
|
1637
1788
|
for (let t of e.rows) t.splice(n, 0, "");
|
|
1638
1789
|
e.aligns.splice(n, 0, "");
|
|
1639
1790
|
}
|
|
1640
|
-
function
|
|
1791
|
+
function ir(e, t) {
|
|
1641
1792
|
if (!(Q(e) <= 1 || t < 0 || t >= Q(e))) {
|
|
1642
1793
|
for (let n of e.rows) n.splice(t, 1);
|
|
1643
1794
|
e.aligns.splice(t, 1);
|
|
1644
1795
|
}
|
|
1645
1796
|
}
|
|
1646
|
-
function
|
|
1797
|
+
function ar(e, t) {
|
|
1647
1798
|
let n = Math.max(1, Math.min(t, e.rows.length));
|
|
1648
1799
|
e.rows.splice(n, 0, Array(Q(e)).fill(""));
|
|
1649
1800
|
}
|
|
1650
|
-
function
|
|
1801
|
+
function or(e, t) {
|
|
1651
1802
|
t <= 0 || t >= e.rows.length || e.rows.length <= 2 || e.rows.splice(t, 1);
|
|
1652
1803
|
}
|
|
1653
|
-
function
|
|
1804
|
+
function sr(e, t, n) {
|
|
1654
1805
|
t >= 0 && t < Q(e) && (e.aligns[t] = n);
|
|
1655
1806
|
}
|
|
1656
1807
|
//#endregion
|
|
1657
1808
|
//#region src/inplace/table-widget.ts
|
|
1658
|
-
var
|
|
1809
|
+
var cr = Se.define(), lr = /* @__PURE__ */ new WeakMap(), ur = class extends k {
|
|
1659
1810
|
data;
|
|
1660
1811
|
embeds;
|
|
1661
1812
|
table = null;
|
|
1813
|
+
view = null;
|
|
1662
1814
|
rows;
|
|
1663
1815
|
editing = null;
|
|
1664
1816
|
syncing = !1;
|
|
@@ -1667,7 +1819,7 @@ var $ = we.define(), Jn = class extends E {
|
|
|
1667
1819
|
longPress = null;
|
|
1668
1820
|
longPressAt = 0;
|
|
1669
1821
|
constructor(e, t = !1) {
|
|
1670
|
-
super(), this.data = e, this.embeds = t, this.rows =
|
|
1822
|
+
super(), this.data = e, this.embeds = t, this.rows = le(e);
|
|
1671
1823
|
}
|
|
1672
1824
|
eq(e) {
|
|
1673
1825
|
return !this.table && JSON.stringify(y(this.rows)) === JSON.stringify(y(e.rows));
|
|
@@ -1680,7 +1832,7 @@ var $ = we.define(), Jn = class extends E {
|
|
|
1680
1832
|
}
|
|
1681
1833
|
bounds(e) {
|
|
1682
1834
|
let t = e.posAtDOM(this.table), n = null;
|
|
1683
|
-
return e.state.field(
|
|
1835
|
+
return e.state.field(X).between(t, t, (e, t) => (n = {
|
|
1684
1836
|
from: e,
|
|
1685
1837
|
to: t
|
|
1686
1838
|
}, !1)), n ?? e.state.doc.lineAt(t);
|
|
@@ -1694,22 +1846,34 @@ var $ = we.define(), Jn = class extends E {
|
|
|
1694
1846
|
c: Number(e.dataset.c)
|
|
1695
1847
|
};
|
|
1696
1848
|
}
|
|
1697
|
-
|
|
1698
|
-
|
|
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 {
|
|
1699
1857
|
rows: this.rows,
|
|
1700
1858
|
aligns: this.data.aligns,
|
|
1701
|
-
embeds: this.embeds
|
|
1702
|
-
|
|
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
|
+
}
|
|
1703
1871
|
}
|
|
1704
1872
|
renderCells() {
|
|
1705
|
-
|
|
1706
|
-
rows: this.rows,
|
|
1707
|
-
aligns: this.data.aligns,
|
|
1708
|
-
embeds: this.embeds
|
|
1709
|
-
});
|
|
1873
|
+
nr(this.table, this.grid());
|
|
1710
1874
|
}
|
|
1711
1875
|
appendRow() {
|
|
1712
|
-
|
|
1876
|
+
ar(this.model(), this.rows.length), this.renderCells(), this.gizmos?.layout(this.table);
|
|
1713
1877
|
}
|
|
1714
1878
|
model() {
|
|
1715
1879
|
return {
|
|
@@ -1720,7 +1884,7 @@ var $ = we.define(), Jn = class extends E {
|
|
|
1720
1884
|
runOp(e, t) {
|
|
1721
1885
|
if (!this.table) return;
|
|
1722
1886
|
let n = this.model();
|
|
1723
|
-
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") {
|
|
1724
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));
|
|
1725
1889
|
this.cellAt(e, n)?.focus();
|
|
1726
1890
|
}
|
|
@@ -1732,7 +1896,7 @@ var $ = we.define(), Jn = class extends E {
|
|
|
1732
1896
|
onFocusIn(e) {
|
|
1733
1897
|
let t = e.target.closest("td, th");
|
|
1734
1898
|
if (!t || t === this.editing) return;
|
|
1735
|
-
let n = this.pendingOffset ??
|
|
1899
|
+
let n = this.pendingOffset ?? b(t);
|
|
1736
1900
|
this.pendingOffset = null, this.editing && this.finish(this.editing, !1), this.editing = t, this.paint(t, !0), d(t, n);
|
|
1737
1901
|
}
|
|
1738
1902
|
onFocusOut(e) {
|
|
@@ -1766,14 +1930,14 @@ var $ = we.define(), Jn = class extends E {
|
|
|
1766
1930
|
to: i,
|
|
1767
1931
|
insert: n
|
|
1768
1932
|
},
|
|
1769
|
-
annotations:
|
|
1933
|
+
annotations: cr.of(!0),
|
|
1770
1934
|
userEvent: "input"
|
|
1771
1935
|
}), this.syncing = !1, t && (this.writeCaret(t), requestAnimationFrame(() => {
|
|
1772
1936
|
this.table && t && this.writeCaret(t);
|
|
1773
1937
|
})));
|
|
1774
1938
|
}
|
|
1775
1939
|
onKey(e, t) {
|
|
1776
|
-
this.table &&
|
|
1940
|
+
this.table && Xn(e, t, {
|
|
1777
1941
|
coords: (e) => this.coords(e),
|
|
1778
1942
|
rows: () => this.rows.length,
|
|
1779
1943
|
cols: () => this.cols(),
|
|
@@ -1796,18 +1960,22 @@ var $ = we.define(), Jn = class extends E {
|
|
|
1796
1960
|
openCellMenuAt(e, t, n, r) {
|
|
1797
1961
|
let i = r?.closest("td, th");
|
|
1798
1962
|
if (!i) return;
|
|
1799
|
-
this.editing === i && !
|
|
1800
|
-
let a =
|
|
1963
|
+
this.editing === i && !Vn(e) && s(i, t, n);
|
|
1964
|
+
let a = Wn(e, i);
|
|
1801
1965
|
this.gizmos?.openFor(i, t, n, a);
|
|
1802
1966
|
}
|
|
1803
1967
|
toDOM(e) {
|
|
1804
1968
|
let t = document.createElement("div");
|
|
1805
1969
|
t.className = "cm-inplace-table-wrap";
|
|
1806
1970
|
let n = document.createElement("table");
|
|
1807
|
-
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) => {
|
|
1808
1976
|
e.stopPropagation();
|
|
1809
1977
|
let t = e.target.closest("td, th");
|
|
1810
|
-
this.pendingOffset = t && t !== this.editing ?
|
|
1978
|
+
this.pendingOffset = t && t !== this.editing ? x(t, e.clientX, e.clientY) : null;
|
|
1811
1979
|
}), n.addEventListener("focusin", (e) => this.onFocusIn(e)), n.addEventListener("focusout", (e) => this.onFocusOut(e));
|
|
1812
1980
|
let r = (t) => {
|
|
1813
1981
|
t && (this.editing = t, this.finish(t, !0), this.sync(e));
|
|
@@ -1820,9 +1988,9 @@ var $ = we.define(), Jn = class extends E {
|
|
|
1820
1988
|
document.execCommand("insertText", !1, t);
|
|
1821
1989
|
}), n.addEventListener("contextmenu", (t) => {
|
|
1822
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));
|
|
1823
|
-
}), this.longPress =
|
|
1991
|
+
}), this.longPress = Jn(n, { onLongPress: (t, n, r) => {
|
|
1824
1992
|
this.longPressAt = Date.now(), this.openCellMenuAt(e, t, n, r);
|
|
1825
|
-
} }), this.gizmos =
|
|
1993
|
+
} }), this.gizmos = Yn(document, {
|
|
1826
1994
|
dims: () => ({
|
|
1827
1995
|
cols: this.cols(),
|
|
1828
1996
|
rows: this.rows.length,
|
|
@@ -1832,14 +2000,14 @@ var $ = we.define(), Jn = class extends E {
|
|
|
1832
2000
|
}), t.append(n, this.gizmos.el), t.addEventListener("mouseenter", () => this.gizmos?.layout(n)), requestAnimationFrame(() => this.gizmos?.layout(n)), t;
|
|
1833
2001
|
}
|
|
1834
2002
|
destroy() {
|
|
1835
|
-
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;
|
|
1836
2004
|
}
|
|
1837
|
-
},
|
|
2005
|
+
}, dr = /* @__PURE__ */ new Set([
|
|
1838
2006
|
"-",
|
|
1839
2007
|
"*",
|
|
1840
2008
|
"_"
|
|
1841
|
-
]),
|
|
1842
|
-
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;
|
|
1843
2011
|
let t = e.startState.selection.main.head, n = "", r = 0;
|
|
1844
2012
|
if (e.changes.iterChanges((e, i, a, o, s) => {
|
|
1845
2013
|
r += 1, e === i && e === t && (n = s.toString());
|
|
@@ -1869,7 +2037,7 @@ var $ = we.define(), Jn = class extends E {
|
|
|
1869
2037
|
},
|
|
1870
2038
|
anchor: a + 1
|
|
1871
2039
|
};
|
|
1872
|
-
else if (
|
|
2040
|
+
else if (dr.has(n) && RegExp(`^\\${n}{3,}$`).test(s)) {
|
|
1873
2041
|
let e = o.number === 1 || i.line(o.number - 1).text.trim() === "", t = n === "-" && !e, r = o.number === i.lines;
|
|
1874
2042
|
if (t || r) {
|
|
1875
2043
|
let e = [];
|
|
@@ -1892,38 +2060,38 @@ var $ = we.define(), Jn = class extends E {
|
|
|
1892
2060
|
scrollIntoView: !0,
|
|
1893
2061
|
userEvent: "input.autoformat"
|
|
1894
2062
|
}] : e;
|
|
1895
|
-
}),
|
|
2063
|
+
}), pr = /* @__PURE__ */ new Set([
|
|
1896
2064
|
"EmphasisMark",
|
|
1897
2065
|
"CodeMark",
|
|
1898
2066
|
"StrikethroughMark"
|
|
1899
2067
|
]);
|
|
1900
|
-
function
|
|
2068
|
+
function mr(e, t, n) {
|
|
1901
2069
|
let r = t;
|
|
1902
2070
|
for (;;) {
|
|
1903
2071
|
let t = e.resolveInner(r, n);
|
|
1904
|
-
if (!
|
|
2072
|
+
if (!pr.has(t.name) || t.from >= t.to) return r;
|
|
1905
2073
|
let i = n < 0 ? t.from : t.to;
|
|
1906
2074
|
if (i === r) return r;
|
|
1907
2075
|
r = i;
|
|
1908
2076
|
}
|
|
1909
2077
|
}
|
|
1910
|
-
function
|
|
1911
|
-
let n =
|
|
2078
|
+
function hr(e, t) {
|
|
2079
|
+
let n = H(e, t, !0);
|
|
1912
2080
|
if (!n) return t;
|
|
1913
|
-
let r =
|
|
1914
|
-
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;
|
|
1915
2083
|
}
|
|
1916
|
-
var
|
|
1917
|
-
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;
|
|
1918
2086
|
let t = e.startState, n = t.selection.main;
|
|
1919
|
-
if (!n.empty || !
|
|
2087
|
+
if (!n.empty || !V(t, t.doc.lineAt(n.head).number)) return e;
|
|
1920
2088
|
let r = [], i = 0;
|
|
1921
2089
|
e.changes.iterChanges((e, t, a, o, s) => {
|
|
1922
2090
|
i++, e === t && e === n.head && s.length > 0 && r.push(s.toString());
|
|
1923
2091
|
});
|
|
1924
2092
|
let a = r[0];
|
|
1925
2093
|
if (i !== 1 || a === void 0) return e;
|
|
1926
|
-
let o =
|
|
2094
|
+
let o = hr(t, n.head);
|
|
1927
2095
|
return o === n.head ? e : {
|
|
1928
2096
|
changes: {
|
|
1929
2097
|
from: o,
|
|
@@ -1933,25 +2101,25 @@ var er = Ee.transactionFilter.of((e) => {
|
|
|
1933
2101
|
scrollIntoView: !0,
|
|
1934
2102
|
userEvent: "input.type"
|
|
1935
2103
|
};
|
|
1936
|
-
}),
|
|
1937
|
-
function
|
|
2104
|
+
}), _r = RegExp(`^(?:${se.match.source.replace(/^\^/, "")})+`);
|
|
2105
|
+
function vr(e, t) {
|
|
1938
2106
|
let n = e.doc.lineAt(t).number;
|
|
1939
|
-
for (let r =
|
|
2107
|
+
for (let r = N(e).resolveInner(t, 1); r; r = r.parent) {
|
|
1940
2108
|
if (r.name !== "ListItem" || e.doc.lineAt(r.from).number === n) continue;
|
|
1941
2109
|
let t = u.exec(e.doc.lineAt(r.from).text);
|
|
1942
2110
|
if (t) return t[0].length;
|
|
1943
2111
|
}
|
|
1944
2112
|
return null;
|
|
1945
2113
|
}
|
|
1946
|
-
function
|
|
1947
|
-
let n = t.text, r =
|
|
2114
|
+
function yr(e, t) {
|
|
2115
|
+
let n = t.text, r = ae.exec(n);
|
|
1948
2116
|
if (r) return {
|
|
1949
2117
|
prefixLen: r[0].length,
|
|
1950
2118
|
drop: [0, r[0].length]
|
|
1951
2119
|
};
|
|
1952
|
-
let i =
|
|
2120
|
+
let i = _r.exec(n);
|
|
1953
2121
|
if (i) {
|
|
1954
|
-
let e =
|
|
2122
|
+
let e = se.match.exec(n)[0].length;
|
|
1955
2123
|
return {
|
|
1956
2124
|
prefixLen: i[0].length,
|
|
1957
2125
|
drop: [0, e]
|
|
@@ -1962,11 +2130,11 @@ function rr(e, t) {
|
|
|
1962
2130
|
prefixLen: a[0].length,
|
|
1963
2131
|
drop: [0, a[0].length]
|
|
1964
2132
|
};
|
|
1965
|
-
let o = te.match.exec(n) ??
|
|
2133
|
+
let o = te.match.exec(n) ?? _.match.exec(n);
|
|
1966
2134
|
if (o) {
|
|
1967
2135
|
let n = o[1] ?? "", r = o[0].length - n.length;
|
|
1968
2136
|
if (n) {
|
|
1969
|
-
let r =
|
|
2137
|
+
let r = vr(e, t.from) ?? 2, i = n.startsWith(" ") ? 1 : Math.min(r, n.length);
|
|
1970
2138
|
return {
|
|
1971
2139
|
prefixLen: o[0].length,
|
|
1972
2140
|
drop: [0, i]
|
|
@@ -1979,15 +2147,15 @@ function rr(e, t) {
|
|
|
1979
2147
|
}
|
|
1980
2148
|
return null;
|
|
1981
2149
|
}
|
|
1982
|
-
var
|
|
2150
|
+
var br = j.high(ve.of([{
|
|
1983
2151
|
key: "Backspace",
|
|
1984
2152
|
run: (e) => {
|
|
1985
2153
|
if (h(e)) return !1;
|
|
1986
2154
|
let { state: t } = e, n = t.selection.main;
|
|
1987
2155
|
if (!n.empty) return !1;
|
|
1988
2156
|
let r = t.doc.lineAt(n.head);
|
|
1989
|
-
if (!
|
|
1990
|
-
let i =
|
|
2157
|
+
if (!V(t, r.number)) return !1;
|
|
2158
|
+
let i = yr(t, r);
|
|
1991
2159
|
if (!i || n.head < r.from || n.head > r.from + i.prefixLen) return !1;
|
|
1992
2160
|
let [a, o] = i.drop;
|
|
1993
2161
|
return e.dispatch({
|
|
@@ -2001,13 +2169,13 @@ var ir = k.high(D.of([{
|
|
|
2001
2169
|
scrollIntoView: !0
|
|
2002
2170
|
}), !0;
|
|
2003
2171
|
}
|
|
2004
|
-
}])),
|
|
2172
|
+
}])), xr = class {
|
|
2005
2173
|
menu;
|
|
2006
2174
|
contentDOM;
|
|
2007
2175
|
onClick;
|
|
2008
2176
|
constructor(e) {
|
|
2009
|
-
this.menu =
|
|
2010
|
-
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;
|
|
2011
2179
|
let n = t.target?.closest(".cm-inplace-link");
|
|
2012
2180
|
if (!n || n.classList.contains("cm-inplace-wikilink")) return;
|
|
2013
2181
|
let r = e.posAtDOM(n);
|
|
@@ -2019,13 +2187,13 @@ var ir = k.high(D.of([{
|
|
|
2019
2187
|
if (n == null) return;
|
|
2020
2188
|
r = n;
|
|
2021
2189
|
}
|
|
2022
|
-
e.dispatch({ selection: { anchor: r } }), this.menu.showField(
|
|
2190
|
+
e.dispatch({ selection: { anchor: r } }), this.menu.showField(An(e), t.clientX, t.clientY);
|
|
2023
2191
|
}, this.contentDOM.addEventListener("click", this.onClick);
|
|
2024
2192
|
}
|
|
2025
2193
|
destroy() {
|
|
2026
2194
|
this.contentDOM.removeEventListener("click", this.onClick), this.menu.destroy();
|
|
2027
2195
|
}
|
|
2028
|
-
},
|
|
2196
|
+
}, Sr = O.fromClass(xr), Cr = (e) => e.replace(/^<([^]*)>$/, "$1").trim(), wr = (e, t, n) => n ? {
|
|
2029
2197
|
pos: e,
|
|
2030
2198
|
end: t,
|
|
2031
2199
|
above: !0,
|
|
@@ -2034,27 +2202,27 @@ var ir = k.high(D.of([{
|
|
|
2034
2202
|
return e.className = "cm-inplace-href-tip", e.textContent = n, { dom: e };
|
|
2035
2203
|
}
|
|
2036
2204
|
} : null;
|
|
2037
|
-
function
|
|
2038
|
-
for (let n =
|
|
2205
|
+
function Tr(e, t) {
|
|
2206
|
+
for (let n = N(e.state).resolveInner(t, -1); n; n = n.parent) {
|
|
2039
2207
|
if (n.name !== "Link") continue;
|
|
2040
2208
|
if (e.state.doc.sliceString(Math.max(0, n.from - 1), n.from) === "[") break;
|
|
2041
2209
|
let t = n.getChild("URL"), r = t ? e.state.sliceDoc(t.from, t.to) : e.state.sliceDoc(n.from, n.to);
|
|
2042
|
-
return
|
|
2210
|
+
return wr(n.from, n.to, Cr(r));
|
|
2043
2211
|
}
|
|
2044
2212
|
return null;
|
|
2045
2213
|
}
|
|
2046
|
-
function
|
|
2214
|
+
function Er(t, n) {
|
|
2047
2215
|
let r = t.state.doc.lineAt(n);
|
|
2048
2216
|
for (let t of r.text.matchAll(e)) {
|
|
2049
2217
|
let e = r.from + (t.index ?? 0), i = e + t[0].length;
|
|
2050
|
-
if (!(n < e || n > i)) return
|
|
2218
|
+
if (!(n < e || n > i)) return wr(e, i, (t[1] ?? "").trim());
|
|
2051
2219
|
}
|
|
2052
2220
|
return null;
|
|
2053
2221
|
}
|
|
2054
|
-
var
|
|
2055
|
-
let n = e.state.facet(
|
|
2056
|
-
return (n.links ?
|
|
2057
|
-
}),
|
|
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 {
|
|
2058
2226
|
ref;
|
|
2059
2227
|
inline;
|
|
2060
2228
|
registry;
|
|
@@ -2081,52 +2249,52 @@ var dr = be((e, t) => {
|
|
|
2081
2249
|
return !1;
|
|
2082
2250
|
}
|
|
2083
2251
|
};
|
|
2084
|
-
function
|
|
2085
|
-
let t = e.facet(
|
|
2086
|
-
if (!t || !e.facet(
|
|
2087
|
-
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 = [];
|
|
2088
2256
|
for (let a = 1; a <= e.doc.lines; a++) {
|
|
2089
2257
|
let o = e.doc.line(a);
|
|
2090
2258
|
if (!(!o.text.includes("![[") || n.has(a))) {
|
|
2091
|
-
if (
|
|
2092
|
-
|
|
2093
|
-
let e = (
|
|
2094
|
-
if (!e ||
|
|
2095
|
-
i.push(
|
|
2096
|
-
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),
|
|
2097
2265
|
block: !0
|
|
2098
2266
|
}).range(o.from, o.to));
|
|
2099
2267
|
continue;
|
|
2100
2268
|
}
|
|
2101
|
-
|
|
2102
|
-
for (let e of o.text.matchAll(
|
|
2269
|
+
C.lastIndex = 0;
|
|
2270
|
+
for (let e of o.text.matchAll(C)) {
|
|
2103
2271
|
let n = (e[1] ?? "").trim();
|
|
2104
2272
|
if (!n) continue;
|
|
2105
2273
|
let a = o.from + (e.index ?? 0);
|
|
2106
|
-
|
|
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));
|
|
2107
2275
|
}
|
|
2108
2276
|
}
|
|
2109
2277
|
}
|
|
2110
|
-
return
|
|
2278
|
+
return E.set(i, !0);
|
|
2111
2279
|
}
|
|
2112
|
-
function
|
|
2280
|
+
function Ar(e, t) {
|
|
2113
2281
|
for (let n of t.ranges) {
|
|
2114
2282
|
let t = e.doc.lineAt(n.from).number, r = e.doc.lineAt(n.to).number;
|
|
2115
2283
|
for (let n = t; n <= r; n++) if (e.doc.line(n).text.includes("![[")) return !0;
|
|
2116
2284
|
}
|
|
2117
2285
|
return !1;
|
|
2118
2286
|
}
|
|
2119
|
-
var
|
|
2120
|
-
create:
|
|
2121
|
-
update: (e, t) => t.docChanged || t.selection && (
|
|
2122
|
-
provide: (e) => [
|
|
2123
|
-
}),
|
|
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({
|
|
2124
2292
|
create: () => !1,
|
|
2125
2293
|
update(e, t) {
|
|
2126
|
-
for (let n of t.effects) n.is(
|
|
2294
|
+
for (let n of t.effects) n.is(Mr) && (e = n.value);
|
|
2127
2295
|
return e;
|
|
2128
2296
|
}
|
|
2129
|
-
}),
|
|
2297
|
+
}), Nr = class {
|
|
2130
2298
|
view;
|
|
2131
2299
|
menu;
|
|
2132
2300
|
onContextMenu;
|
|
@@ -2137,8 +2305,8 @@ var hr = A.define({
|
|
|
2137
2305
|
longPressAt = 0;
|
|
2138
2306
|
destroyed = !1;
|
|
2139
2307
|
constructor(e) {
|
|
2140
|
-
this.view = e, this.menu =
|
|
2141
|
-
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) });
|
|
2142
2310
|
}), e.dom.appendChild(this.menu.el), this.contentDOM = e.contentDOM, this.onPointerDown = () => {
|
|
2143
2311
|
let t = e.state.selection.main;
|
|
2144
2312
|
this.stashed = t.empty ? null : {
|
|
@@ -2148,17 +2316,17 @@ var hr = A.define({
|
|
|
2148
2316
|
}, this.contentDOM.addEventListener("pointerdown", this.onPointerDown, !0), this.onContextMenu = (e) => {
|
|
2149
2317
|
let t = e.target;
|
|
2150
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()));
|
|
2151
|
-
}, this.contentDOM.addEventListener("contextmenu", this.onContextMenu), this.longPress =
|
|
2319
|
+
}, this.contentDOM.addEventListener("contextmenu", this.onContextMenu), this.longPress = Jn(this.contentDOM, { onLongPress: (e, t, n) => {
|
|
2152
2320
|
this.longPressAt = Date.now(), this.openMenuAt(e, t, n);
|
|
2153
2321
|
} });
|
|
2154
2322
|
}
|
|
2155
2323
|
canOpen() {
|
|
2156
2324
|
let { state: e } = this.view;
|
|
2157
|
-
return e.facet(
|
|
2325
|
+
return e.facet(Ne) && (!e.readOnly || Sn(this.view));
|
|
2158
2326
|
}
|
|
2159
2327
|
rows() {
|
|
2160
2328
|
let e = this.view;
|
|
2161
|
-
return e.state.readOnly ?
|
|
2329
|
+
return e.state.readOnly ? Cn(e, { selected: !e.state.selection.main.empty }) : qn(e);
|
|
2162
2330
|
}
|
|
2163
2331
|
openMenuAt(e, t, n) {
|
|
2164
2332
|
let r = this.view;
|
|
@@ -2175,7 +2343,7 @@ var hr = A.define({
|
|
|
2175
2343
|
y: t
|
|
2176
2344
|
});
|
|
2177
2345
|
if (n != null) {
|
|
2178
|
-
let e =
|
|
2346
|
+
let e = H(r.state, n, !1, !0), t = r.state.wordAt(n) ?? { anchor: n };
|
|
2179
2347
|
e?.kind === "link" ? t = {
|
|
2180
2348
|
anchor: e.from,
|
|
2181
2349
|
head: e.to
|
|
@@ -2194,10 +2362,10 @@ var hr = A.define({
|
|
|
2194
2362
|
destroy() {
|
|
2195
2363
|
this.destroyed = !0, this.contentDOM.removeEventListener("pointerdown", this.onPointerDown, !0), this.contentDOM.removeEventListener("contextmenu", this.onContextMenu), this.longPress.dispose(), this.menu.destroy();
|
|
2196
2364
|
}
|
|
2197
|
-
},
|
|
2365
|
+
}, Pr = O.fromClass(Nr);
|
|
2198
2366
|
//#endregion
|
|
2199
2367
|
//#region src/inplace/selection-bar-position.ts
|
|
2200
|
-
function
|
|
2368
|
+
function Fr(e) {
|
|
2201
2369
|
let t = e.state.selection.main;
|
|
2202
2370
|
if (!t.empty) {
|
|
2203
2371
|
let n = e.coordsAtPos(t.from), r = e.coordsAtPos(t.to);
|
|
@@ -2211,7 +2379,7 @@ function br(e) {
|
|
|
2211
2379
|
}
|
|
2212
2380
|
};
|
|
2213
2381
|
}
|
|
2214
|
-
if (!
|
|
2382
|
+
if (!Vn(e)) return null;
|
|
2215
2383
|
let n = e.dom.ownerDocument.getSelection();
|
|
2216
2384
|
if (!n || n.rangeCount === 0) return null;
|
|
2217
2385
|
let r = n.getRangeAt(0).getBoundingClientRect();
|
|
@@ -2225,9 +2393,9 @@ function br(e) {
|
|
|
2225
2393
|
}
|
|
2226
2394
|
};
|
|
2227
2395
|
}
|
|
2228
|
-
function
|
|
2229
|
-
if (e.state.facet(Ve) !== "bar" || e.state.readOnly || e.state.field(
|
|
2230
|
-
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);
|
|
2231
2399
|
if (!r) return null;
|
|
2232
2400
|
let { box: i, inCell: a } = r;
|
|
2233
2401
|
if (!a && !e.hasFocus) return null;
|
|
@@ -2245,7 +2413,7 @@ function xr(e, t, n) {
|
|
|
2245
2413
|
}
|
|
2246
2414
|
//#endregion
|
|
2247
2415
|
//#region src/inplace/selection-bar.ts
|
|
2248
|
-
var
|
|
2416
|
+
var Lr = class {
|
|
2249
2417
|
view;
|
|
2250
2418
|
bar;
|
|
2251
2419
|
ids;
|
|
@@ -2260,12 +2428,12 @@ var Sr = class {
|
|
|
2260
2428
|
constructor(e) {
|
|
2261
2429
|
this.view = e;
|
|
2262
2430
|
let t = e.dom.ownerDocument;
|
|
2263
|
-
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;
|
|
2264
2432
|
for (let n of this.ids) {
|
|
2265
2433
|
let r = g[n], i = t.createElement("button");
|
|
2266
|
-
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) => {
|
|
2267
2435
|
t.preventDefault();
|
|
2268
|
-
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;
|
|
2269
2437
|
if (o) {
|
|
2270
2438
|
let e = i.getBoundingClientRect();
|
|
2271
2439
|
this.linkMenu.showField(o, e.left, e.bottom + 6);
|
|
@@ -2277,7 +2445,7 @@ var Sr = class {
|
|
|
2277
2445
|
e.dom.appendChild(this.bar), t.addEventListener("scroll", this.onScroll, !0), t.addEventListener("selectionchange", this.onSelectionChange);
|
|
2278
2446
|
}
|
|
2279
2447
|
update(e) {
|
|
2280
|
-
let t = e.startState.field(
|
|
2448
|
+
let t = e.startState.field($, !1) !== e.state.field($, !1), n = e.startState.readOnly !== e.state.readOnly;
|
|
2281
2449
|
(e.selectionSet || e.docChanged || e.focusChanged || t || n) && this.schedule();
|
|
2282
2450
|
}
|
|
2283
2451
|
schedule() {
|
|
@@ -2288,7 +2456,7 @@ var Sr = class {
|
|
|
2288
2456
|
});
|
|
2289
2457
|
}
|
|
2290
2458
|
measure() {
|
|
2291
|
-
return
|
|
2459
|
+
return Ir(this.view, this.bar, this.ids);
|
|
2292
2460
|
}
|
|
2293
2461
|
apply(e) {
|
|
2294
2462
|
if (!e) {
|
|
@@ -2302,30 +2470,42 @@ var Sr = class {
|
|
|
2302
2470
|
let e = this.view.dom.ownerDocument;
|
|
2303
2471
|
e.removeEventListener("scroll", this.onScroll, !0), e.removeEventListener("selectionchange", this.onSelectionChange), this.linkMenu.destroy(), this.bar.remove();
|
|
2304
2472
|
}
|
|
2305
|
-
},
|
|
2473
|
+
}, Rr = O.fromClass(Lr), zr = (e) => (t) => {
|
|
2306
2474
|
if (h(t)) return !1;
|
|
2307
2475
|
let n = t.state.selection.main;
|
|
2308
2476
|
if (!n.empty) return !1;
|
|
2309
2477
|
let { doc: r } = t.state, i = r.lineAt(n.head), a = e ? i.number + 1 : i.number - 1;
|
|
2310
2478
|
if (a < 1 || a > r.lines) return !1;
|
|
2311
2479
|
let o = r.line(a), s = -1, c = -1, l;
|
|
2312
|
-
if (t.state.field(
|
|
2480
|
+
if (t.state.field(X).between(o.from, o.to, (t, n, r) => {
|
|
2313
2481
|
if (e ? t === o.from : n === o.to) return s = t, c = n, l = r.spec.widget, !1;
|
|
2314
2482
|
}), s < 0) return !1;
|
|
2315
|
-
if (t.state.facet(
|
|
2483
|
+
if (t.state.facet(I) === "cells") return l instanceof ur && l.focusEdge(e ? "first" : "last");
|
|
2316
2484
|
let u = e ? r.lineAt(s).from : r.lineAt(c).to;
|
|
2317
2485
|
return t.dispatch({
|
|
2318
2486
|
selection: { anchor: u },
|
|
2319
2487
|
userEvent: "select",
|
|
2320
2488
|
scrollIntoView: !0
|
|
2321
2489
|
}), !0;
|
|
2322
|
-
},
|
|
2490
|
+
}, Br = zr(!0), Vr = zr(!1), Hr = j.high(ve.of([{
|
|
2323
2491
|
key: "ArrowDown",
|
|
2324
|
-
run:
|
|
2492
|
+
run: Br
|
|
2325
2493
|
}, {
|
|
2326
2494
|
key: "ArrowUp",
|
|
2327
|
-
run:
|
|
2328
|
-
}])),
|
|
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 = {
|
|
2329
2509
|
".cm-inplace-callout": {
|
|
2330
2510
|
borderLeft: "0.25rem solid var(--stylo-callout-accent, var(--stylo-border))",
|
|
2331
2511
|
padding: "0 var(--stylo-rhythm-callout-padding-x, 1rem)",
|
|
@@ -2359,9 +2539,9 @@ var Sr = class {
|
|
|
2359
2539
|
content: "\"\"",
|
|
2360
2540
|
display: "none"
|
|
2361
2541
|
}
|
|
2362
|
-
},
|
|
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 = {
|
|
2363
2543
|
"& .cm-content": {
|
|
2364
|
-
fontFamily:
|
|
2544
|
+
fontFamily: Kr,
|
|
2365
2545
|
lineHeight: "1.75",
|
|
2366
2546
|
padding: "0.75rem",
|
|
2367
2547
|
WebkitTouchCallout: "none"
|
|
@@ -2404,14 +2584,14 @@ var Sr = class {
|
|
|
2404
2584
|
".cm-inplace-em": { fontStyle: "italic" },
|
|
2405
2585
|
".cm-inplace-strike": { textDecoration: "line-through" },
|
|
2406
2586
|
".cm-inplace-code": {
|
|
2407
|
-
fontFamily:
|
|
2587
|
+
fontFamily: Gr,
|
|
2408
2588
|
fontSize: "0.9em",
|
|
2409
2589
|
padding: "0.1em 0.35em",
|
|
2410
2590
|
borderRadius: "3px",
|
|
2411
2591
|
background: "color-mix(in srgb, var(--stylo-border) 45%, transparent)"
|
|
2412
2592
|
},
|
|
2413
2593
|
".cm-inplace-mono": {
|
|
2414
|
-
fontFamily:
|
|
2594
|
+
fontFamily: Gr,
|
|
2415
2595
|
fontSize: "0.9em",
|
|
2416
2596
|
background: "color-mix(in srgb, var(--stylo-border) 35%, transparent)",
|
|
2417
2597
|
padding: "0 0.9rem"
|
|
@@ -2489,21 +2669,21 @@ var Sr = class {
|
|
|
2489
2669
|
cursor: "pointer"
|
|
2490
2670
|
},
|
|
2491
2671
|
".cm-inplace-fm": {
|
|
2492
|
-
fontFamily:
|
|
2672
|
+
fontFamily: Gr,
|
|
2493
2673
|
fontSize: "0.85em",
|
|
2494
2674
|
color: "var(--stylo-text-muted)"
|
|
2495
2675
|
},
|
|
2496
2676
|
".cm-inplace-fm-first::before": {
|
|
2497
2677
|
content: "\"Frontmatter\"",
|
|
2498
2678
|
marginRight: "0.6em",
|
|
2499
|
-
fontFamily:
|
|
2679
|
+
fontFamily: Kr,
|
|
2500
2680
|
fontSize: "0.8rem",
|
|
2501
2681
|
fontWeight: "600",
|
|
2502
2682
|
textTransform: "uppercase",
|
|
2503
2683
|
letterSpacing: "0.04em",
|
|
2504
2684
|
color: "var(--stylo-text-muted)"
|
|
2505
2685
|
}
|
|
2506
|
-
},
|
|
2686
|
+
}, Jr = {
|
|
2507
2687
|
".cm-inplace-menu": {
|
|
2508
2688
|
position: "fixed",
|
|
2509
2689
|
inset: "0",
|
|
@@ -2577,7 +2757,7 @@ var Sr = class {
|
|
|
2577
2757
|
outline: "none"
|
|
2578
2758
|
},
|
|
2579
2759
|
".cm-inplace-menu-input:focus": { borderColor: "var(--stylo-ring)" }
|
|
2580
|
-
},
|
|
2760
|
+
}, Yr = {
|
|
2581
2761
|
".cm-inplace-selbar": {
|
|
2582
2762
|
position: "fixed",
|
|
2583
2763
|
zIndex: "20",
|
|
@@ -2662,7 +2842,7 @@ var Sr = class {
|
|
|
2662
2842
|
lineHeight: "1.4",
|
|
2663
2843
|
wordBreak: "break-all"
|
|
2664
2844
|
}
|
|
2665
|
-
},
|
|
2845
|
+
}, Xr = {
|
|
2666
2846
|
".cm-inplace-table": {
|
|
2667
2847
|
borderCollapse: "collapse",
|
|
2668
2848
|
padding: "1em 0 1.4em",
|
|
@@ -2685,7 +2865,7 @@ var Sr = class {
|
|
|
2685
2865
|
outline: "none"
|
|
2686
2866
|
},
|
|
2687
2867
|
".cm-inplace-table-edit .cm-inplace-tcell:focus": { boxShadow: "inset 0 0 0 2px var(--stylo-ring)" }
|
|
2688
|
-
},
|
|
2868
|
+
}, Zr = {
|
|
2689
2869
|
".cm-inplace-table-wrap": {
|
|
2690
2870
|
position: "relative",
|
|
2691
2871
|
display: "inline-block",
|
|
@@ -2727,58 +2907,60 @@ var Sr = class {
|
|
|
2727
2907
|
},
|
|
2728
2908
|
".cm-inplace-tg-edge:hover .cm-inplace-tg-plus": { color: "var(--stylo-text)" },
|
|
2729
2909
|
"@media (hover: none)": { ".cm-inplace-tg-edge": { opacity: "0.5" } }
|
|
2730
|
-
},
|
|
2731
|
-
...
|
|
2732
|
-
...
|
|
2733
|
-
...
|
|
2734
|
-
...
|
|
2735
|
-
...
|
|
2736
|
-
...
|
|
2737
|
-
}),
|
|
2738
|
-
function
|
|
2739
|
-
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);
|
|
2740
2920
|
return [
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
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 ?? (() => [])),
|
|
2749
2930
|
Ve.of(e.inPlace?.selectionUI ?? "menu"),
|
|
2750
2931
|
Be.of(ze(e.inPlace?.selectionBarItems)),
|
|
2751
2932
|
Dt(),
|
|
2752
|
-
|
|
2753
|
-
|
|
2933
|
+
br,
|
|
2934
|
+
nn,
|
|
2754
2935
|
Rt,
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2936
|
+
Hr,
|
|
2937
|
+
gr,
|
|
2938
|
+
fr,
|
|
2758
2939
|
nt,
|
|
2759
|
-
|
|
2940
|
+
jr,
|
|
2760
2941
|
Ue,
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2942
|
+
X,
|
|
2943
|
+
Ur,
|
|
2944
|
+
$,
|
|
2945
|
+
Pr,
|
|
2946
|
+
Rr,
|
|
2947
|
+
Sr,
|
|
2948
|
+
Dr,
|
|
2949
|
+
zn,
|
|
2950
|
+
Bn,
|
|
2951
|
+
j.high(Qr),
|
|
2952
|
+
D.domEventHandlers({
|
|
2771
2953
|
mousedown(e, t) {
|
|
2772
2954
|
let n = e.target;
|
|
2773
2955
|
if (n?.closest(".cm-inplace-table-edit") || n?.closest(".stylo-embed-content")) return !1;
|
|
2774
|
-
let r = n?.closest(
|
|
2956
|
+
let r = n?.closest($r);
|
|
2775
2957
|
if (!r) return !1;
|
|
2776
2958
|
let i = t.posAtDOM(r);
|
|
2777
2959
|
if (i < 0) return !1;
|
|
2778
2960
|
let a = n?.closest("[data-stylo-row]");
|
|
2779
2961
|
if (a && r.contains(a)) {
|
|
2780
|
-
let n =
|
|
2781
|
-
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));
|
|
2782
2964
|
}
|
|
2783
2965
|
return t.focus(), t.dispatch({ selection: { anchor: i } }), !0;
|
|
2784
2966
|
},
|
|
@@ -2792,21 +2974,23 @@ function Rr(e = {}) {
|
|
|
2792
2974
|
}
|
|
2793
2975
|
//#endregion
|
|
2794
2976
|
//#region src/inplace/InPlaceView.tsx
|
|
2795
|
-
var
|
|
2796
|
-
function
|
|
2797
|
-
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);
|
|
2798
2980
|
te.current = a;
|
|
2799
|
-
let re =
|
|
2981
|
+
let re = w(o);
|
|
2800
2982
|
re.current = o;
|
|
2801
|
-
let ie =
|
|
2983
|
+
let ie = w(s?.contextMenu);
|
|
2802
2984
|
ie.current = s?.contextMenu;
|
|
2803
|
-
let
|
|
2804
|
-
|
|
2805
|
-
let
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
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({
|
|
2810
2994
|
onWikiLinkClick: (e) => te.current?.(e),
|
|
2811
2995
|
onLinkClick: (e) => re.current?.(e),
|
|
2812
2996
|
inPlace: s,
|
|
@@ -2814,13 +2998,14 @@ function Vr({ value: e, onChange: t, readOnly: r, placeholder: i, onWikiLinkClic
|
|
|
2814
2998
|
let e = ie.current;
|
|
2815
2999
|
return typeof e == "object" ? e.items ?? [] : [];
|
|
2816
3000
|
},
|
|
2817
|
-
|
|
2818
|
-
|
|
3001
|
+
cellMarks: (e) => g.current?.(e) ?? [],
|
|
3002
|
+
embedRegistry: d ? _ : void 0
|
|
3003
|
+
}), ...b ? [ye.of(b.panel)] : []]), S = ce({
|
|
2819
3004
|
value: e,
|
|
2820
3005
|
onChange: t,
|
|
2821
3006
|
readOnly: r,
|
|
2822
3007
|
placeholder: i,
|
|
2823
|
-
extensions:
|
|
3008
|
+
extensions: ue,
|
|
2824
3009
|
codeLanguages: c,
|
|
2825
3010
|
wikiLinkSource: l,
|
|
2826
3011
|
tagSource: u,
|
|
@@ -2829,18 +3014,18 @@ function Vr({ value: e, onChange: t, readOnly: r, placeholder: i, onWikiLinkClic
|
|
|
2829
3014
|
onViewChange: le,
|
|
2830
3015
|
hostExtensions: ee
|
|
2831
3016
|
});
|
|
2832
|
-
return /* @__PURE__ */
|
|
3017
|
+
return /* @__PURE__ */ De("div", {
|
|
2833
3018
|
className: n.inplace,
|
|
2834
|
-
ref:
|
|
2835
|
-
children: [d && ae.map((e) =>
|
|
3019
|
+
ref: S,
|
|
3020
|
+
children: [d && ae.map((e) => be(/* @__PURE__ */ Ee(pe, {
|
|
2836
3021
|
reference: e.ref,
|
|
2837
3022
|
source: d,
|
|
2838
3023
|
onError: f,
|
|
2839
3024
|
inline: e.inline
|
|
2840
|
-
}), e.el, String(e.id))),
|
|
3025
|
+
}), e.el, String(e.id))), x && y.current && be(y.current({ view: oe }), x)]
|
|
2841
3026
|
});
|
|
2842
3027
|
}
|
|
2843
3028
|
//#endregion
|
|
2844
|
-
export {
|
|
3029
|
+
export { ri as InPlaceView };
|
|
2845
3030
|
|
|
2846
|
-
//# sourceMappingURL=InPlaceView-
|
|
3031
|
+
//# sourceMappingURL=InPlaceView-AZ_ufoP3.js.map
|