@damiro/stylo 0.20.0 → 0.21.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-AZ_ufoP3.js → InPlaceView-BIdyqlek.js} +612 -524
- package/dist/InPlaceView-BIdyqlek.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 +3 -1
- package/dist/inplace/config.d.ts.map +1 -1
- package/dist/inplace/extension.d.ts +3 -1
- package/dist/inplace/extension.d.ts.map +1 -1
- package/dist/inplace/table-cell-align.d.ts +9 -0
- package/dist/inplace/table-cell-align.d.ts.map +1 -0
- package/dist/inplace/table-cell-dom.d.ts +2 -0
- package/dist/inplace/table-cell-dom.d.ts.map +1 -1
- package/dist/inplace/table-cell-marks.d.ts +2 -0
- package/dist/inplace/table-cell-marks.d.ts.map +1 -1
- package/dist/inplace/table-cell-widgets.d.ts +26 -0
- package/dist/inplace/table-cell-widgets.d.ts.map +1 -0
- package/dist/inplace/table-marks-plugin.d.ts +1 -1
- package/dist/inplace/table-marks-plugin.d.ts.map +1 -1
- package/dist/inplace/table-widget.d.ts +4 -0
- package/dist/inplace/table-widget.d.ts.map +1 -1
- package/dist/stylo.js +2 -2
- package/dist/types/inplace.d.ts +24 -0
- 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-DbhMZGZ7.js → useCodeMirror-O1ProA2R.js} +246 -234
- package/dist/useCodeMirror-O1ProA2R.js.map +1 -0
- package/package.json +1 -1
- package/dist/InPlaceView-AZ_ufoP3.js.map +0 -1
- package/dist/useCodeMirror-DbhMZGZ7.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
|
|
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 ae, p as _, r as oe, s as se, t as ce, u as v, v as le, w as ue, x as y, y as b } from "./useCodeMirror-O1ProA2R.js";
|
|
3
|
+
import { a as x, i as S } from "./config-DTBxVhtH.js";
|
|
4
4
|
import { a as de, n as fe, o as pe, r as me, t as C } from "./embed-DJAydn-v.js";
|
|
5
5
|
import { t as he } from "./katex-BfiLlqfN.js";
|
|
6
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
|
|
8
|
-
import { createPortal as
|
|
9
|
-
import { Annotation as
|
|
10
|
-
import { syntaxTree as
|
|
11
|
-
import { jsx as
|
|
12
|
-
import { createRoot as
|
|
7
|
+
import { Decoration as E, EditorView as D, ViewPlugin as O, WidgetType as k, hoverTooltip as _e, keymap as A, showPanel as ve } from "@codemirror/view";
|
|
8
|
+
import { createPortal as ye, flushSync as be } from "react-dom";
|
|
9
|
+
import { Annotation as xe, EditorSelection as Se, EditorState as Ce, Facet as j, Prec as M, StateEffect as we, StateField as N } from "@codemirror/state";
|
|
10
|
+
import { syntaxTree as P } from "@codemirror/language";
|
|
11
|
+
import { jsx as Te, jsxs as Ee } from "react/jsx-runtime";
|
|
12
|
+
import { createRoot as De } from "react-dom/client";
|
|
13
13
|
//#region src/inplace/embed-registry.ts
|
|
14
|
-
var
|
|
14
|
+
var Oe = class {
|
|
15
15
|
slots = /* @__PURE__ */ new Map();
|
|
16
16
|
listeners = /* @__PURE__ */ new Set();
|
|
17
17
|
snapshot = [];
|
|
@@ -34,7 +34,7 @@ var ke = class {
|
|
|
34
34
|
for (let e of this.listeners) e();
|
|
35
35
|
}));
|
|
36
36
|
}
|
|
37
|
-
},
|
|
37
|
+
}, ke = {
|
|
38
38
|
headings: !0,
|
|
39
39
|
emphasis: !0,
|
|
40
40
|
links: !0,
|
|
@@ -49,20 +49,20 @@ var ke = class {
|
|
|
49
49
|
tables: !0,
|
|
50
50
|
embeds: !0
|
|
51
51
|
};
|
|
52
|
-
function
|
|
52
|
+
function Ae(e) {
|
|
53
53
|
return {
|
|
54
|
-
...
|
|
54
|
+
...ke,
|
|
55
55
|
...e?.decorations
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
|
-
var
|
|
58
|
+
var F = j.define({ combine: (e) => e[0] ?? ke }), I = j.define({ combine: (e) => e[0] ?? null }), L = j.define({ combine: (e) => e[0] ?? "source" }), R = j.define({ combine: (e) => e[0] ?? "caret" }), je = j.define({ combine: (e) => e[0] ?? null }), Me = j.define({ combine: (e) => e[0] ?? !0 }), Ne = [
|
|
59
59
|
"host",
|
|
60
60
|
"link",
|
|
61
61
|
"format",
|
|
62
62
|
"paragraph",
|
|
63
63
|
"insert",
|
|
64
64
|
"clipboard"
|
|
65
|
-
],
|
|
65
|
+
], z = [
|
|
66
66
|
"bold",
|
|
67
67
|
"italic",
|
|
68
68
|
"strike",
|
|
@@ -71,32 +71,32 @@ var P = A.define({ combine: (e) => e[0] ?? Ae }), F = A.define({ combine: (e) =>
|
|
|
71
71
|
"wikilink",
|
|
72
72
|
"math"
|
|
73
73
|
];
|
|
74
|
-
function
|
|
74
|
+
function Pe(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: Ne,
|
|
82
82
|
items: []
|
|
83
83
|
} : {
|
|
84
84
|
enabled: !0,
|
|
85
|
-
groups: e.groups?.length ? e.groups :
|
|
85
|
+
groups: e.groups?.length ? e.groups : Ne,
|
|
86
86
|
items: e.items ?? []
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
|
-
var Ie =
|
|
90
|
-
function
|
|
91
|
-
if (!e?.length) return
|
|
92
|
-
let t = e.filter((e) =>
|
|
93
|
-
return t.length ? t :
|
|
89
|
+
var Fe = j.define({ combine: (e) => e[0] ?? (() => []) }), Ie = j.define({ combine: (e) => e[0] ?? (() => []) }), Le = j.define({ combine: (e) => e[0] ?? (() => []) }), B = j.define({ combine: (e) => e[0] ?? Ne });
|
|
90
|
+
function Re(e) {
|
|
91
|
+
if (!e?.length) return z;
|
|
92
|
+
let t = e.filter((e) => z.includes(e));
|
|
93
|
+
return t.length ? t : z;
|
|
94
94
|
}
|
|
95
|
-
var
|
|
95
|
+
var ze = j.define({ combine: (e) => e[0] ?? z }), Be = j.define({ combine: (e) => e[0] ?? "menu" });
|
|
96
96
|
//#endregion
|
|
97
97
|
//#region src/inplace/frontmatter.ts
|
|
98
|
-
function
|
|
99
|
-
if (!e.facet(
|
|
98
|
+
function Ve(e) {
|
|
99
|
+
if (!e.facet(F).frontmatter) return E.none;
|
|
100
100
|
let n = t(e.doc);
|
|
101
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) => {
|
|
@@ -109,19 +109,19 @@ function He(e) {
|
|
|
109
109
|
}
|
|
110
110
|
return E.set(o, !0);
|
|
111
111
|
}
|
|
112
|
-
var
|
|
113
|
-
create:
|
|
114
|
-
update: (e, t) => t.docChanged || t.selection ?
|
|
112
|
+
var He = N.define({
|
|
113
|
+
create: Ve,
|
|
114
|
+
update: (e, t) => t.docChanged || t.selection ? Ve(t.state) : e,
|
|
115
115
|
provide: (e) => D.decorations.from(e)
|
|
116
116
|
});
|
|
117
117
|
//#endregion
|
|
118
118
|
//#region src/inplace/list-guides.ts
|
|
119
|
-
function
|
|
119
|
+
function Ue(e) {
|
|
120
120
|
let t = 1;
|
|
121
121
|
for (let n = e.node.parent; n; n = n.parent) n.name === "ListItem" && t++;
|
|
122
122
|
return t;
|
|
123
123
|
}
|
|
124
|
-
function
|
|
124
|
+
function We(e, t, n, r, i, a) {
|
|
125
125
|
if (!i.lists) return;
|
|
126
126
|
let o = /* @__PURE__ */ new Set();
|
|
127
127
|
n.iterate({
|
|
@@ -129,7 +129,7 @@ function Ge(e, t, n, r, i, a) {
|
|
|
129
129
|
to: t,
|
|
130
130
|
enter: (e) => {
|
|
131
131
|
if (e.name !== "ListItem") return;
|
|
132
|
-
let t =
|
|
132
|
+
let t = Ue(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
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}` }
|
|
@@ -139,7 +139,7 @@ function Ge(e, t, n, r, i, a) {
|
|
|
139
139
|
}
|
|
140
140
|
//#endregion
|
|
141
141
|
//#region src/inplace/reveal.ts
|
|
142
|
-
function
|
|
142
|
+
function V(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;
|
|
@@ -149,22 +149,22 @@ function z(e) {
|
|
|
149
149
|
}
|
|
150
150
|
//#endregion
|
|
151
151
|
//#region src/inplace/scan.ts
|
|
152
|
-
var
|
|
152
|
+
var Ge = /* @__PURE__ */ new Set([
|
|
153
153
|
"InlineCode",
|
|
154
154
|
"FencedCode",
|
|
155
155
|
"CodeBlock",
|
|
156
156
|
"CodeText"
|
|
157
157
|
]);
|
|
158
|
-
function
|
|
158
|
+
function H(e, t) {
|
|
159
159
|
let n = e.resolveInner(t, 1);
|
|
160
160
|
for (;;) {
|
|
161
|
-
if (
|
|
161
|
+
if (Ge.has(n.name)) return !0;
|
|
162
162
|
let e = n.parent;
|
|
163
163
|
if (!e) return !1;
|
|
164
164
|
n = e;
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
|
-
function
|
|
167
|
+
function Ke(e, t) {
|
|
168
168
|
let n = e.resolveInner(t, 1);
|
|
169
169
|
for (;;) {
|
|
170
170
|
if (n.name === "Table") return !0;
|
|
@@ -173,16 +173,16 @@ function qe(e, t) {
|
|
|
173
173
|
n = e;
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
|
-
function
|
|
176
|
+
function qe(e, t, n, r) {
|
|
177
177
|
let i = t.lineAt(n).number, a = t.lineAt(r).number;
|
|
178
178
|
for (let t = i; t <= a; t++) if (e.has(t)) return !0;
|
|
179
179
|
return !1;
|
|
180
180
|
}
|
|
181
181
|
//#endregion
|
|
182
182
|
//#region src/inplace/math.ts
|
|
183
|
-
var
|
|
184
|
-
function
|
|
185
|
-
for (let n of e.matchAll(
|
|
183
|
+
var Je = /(?<![\w$])\$(?!\s)([^\n$]+?)(?<!\s)\$(?![\w$])/g, Ye = /(?<![\w$])\$\$([^\n$]+?)\$\$(?![\w$])/g, Xe = /(?<![\w$])\$\$([^]+?)\$\$/g;
|
|
184
|
+
function Ze(e, t) {
|
|
185
|
+
for (let n of e.matchAll(Ye)) {
|
|
186
186
|
let e = n.index ?? 0, r = e + (n[0] ?? "").length;
|
|
187
187
|
if (t >= e && t <= r) return {
|
|
188
188
|
from: e,
|
|
@@ -191,7 +191,7 @@ function Qe(e, t) {
|
|
|
191
191
|
block: !0
|
|
192
192
|
};
|
|
193
193
|
}
|
|
194
|
-
for (let n of e.matchAll(
|
|
194
|
+
for (let n of e.matchAll(Je)) {
|
|
195
195
|
let e = n.index ?? 0, r = e + (n[0] ?? "").length;
|
|
196
196
|
if (t >= e && t <= r) return {
|
|
197
197
|
from: e,
|
|
@@ -202,7 +202,7 @@ function Qe(e, t) {
|
|
|
202
202
|
}
|
|
203
203
|
return null;
|
|
204
204
|
}
|
|
205
|
-
var
|
|
205
|
+
var Qe = class extends k {
|
|
206
206
|
src;
|
|
207
207
|
block;
|
|
208
208
|
constructor(e, t) {
|
|
@@ -228,19 +228,19 @@ var $e = class extends k {
|
|
|
228
228
|
return !1;
|
|
229
229
|
}
|
|
230
230
|
};
|
|
231
|
-
function
|
|
231
|
+
function $e(e, t, n, r, i, a, o) {
|
|
232
232
|
if (!r.includes("$")) return;
|
|
233
233
|
let { doc: s } = e.state, c = [];
|
|
234
|
-
for (let e of r.matchAll(
|
|
234
|
+
for (let e of r.matchAll(Ye)) {
|
|
235
235
|
let n = (e[1] ?? "").trim(), r = t + (e.index ?? 0), l = r + (e[0] ?? "").length;
|
|
236
|
-
!n ||
|
|
236
|
+
!n || H(a, r + 2) || (c.push([r, l]), !qe(i, s, r, l) && o.push(E.replace({ widget: new Qe(n, !0) }).range(r, l)));
|
|
237
237
|
}
|
|
238
|
-
for (let e of r.matchAll(
|
|
238
|
+
for (let e of r.matchAll(Je)) {
|
|
239
239
|
let n = (e[1] ?? "").trim(), r = t + (e.index ?? 0), l = r + (e[0] ?? "").length;
|
|
240
|
-
!n ||
|
|
240
|
+
!n || H(a, r + 1) || c.some(([e, t]) => r >= e && l <= t) || qe(i, s, r, l) || o.push(E.replace({ widget: new Qe(n, !1) }).range(r, l));
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
|
-
function
|
|
243
|
+
function et(e, t, n) {
|
|
244
244
|
let r = n.map((t) => ({
|
|
245
245
|
first: e.doc.lineAt(t.from).number,
|
|
246
246
|
last: e.doc.lineAt(t.to).number
|
|
@@ -251,15 +251,15 @@ function tt(e, t, n) {
|
|
|
251
251
|
}
|
|
252
252
|
return !1;
|
|
253
253
|
}
|
|
254
|
-
var
|
|
255
|
-
create:
|
|
254
|
+
var tt = N.define({
|
|
255
|
+
create: nt,
|
|
256
256
|
update(e, t) {
|
|
257
|
-
return t.docChanged || t.selection && (
|
|
257
|
+
return t.docChanged || t.selection && (et(t.state, t.startState.selection, e.ranges) || et(t.state, t.state.selection, e.ranges)) ? nt(t.state) : e;
|
|
258
258
|
},
|
|
259
259
|
provide: (e) => [D.decorations.from(e, (e) => e.decorations), D.atomicRanges.of((t) => t.state.field(e).decorations)]
|
|
260
260
|
});
|
|
261
|
-
function
|
|
262
|
-
if (!e.facet(
|
|
261
|
+
function nt(e) {
|
|
262
|
+
if (!e.facet(F).math) return {
|
|
263
263
|
decorations: E.none,
|
|
264
264
|
ranges: []
|
|
265
265
|
};
|
|
@@ -268,16 +268,16 @@ function rt(e) {
|
|
|
268
268
|
decorations: E.none,
|
|
269
269
|
ranges: []
|
|
270
270
|
};
|
|
271
|
-
let n = [], r = [], i =
|
|
272
|
-
for (let o of t.matchAll(
|
|
271
|
+
let n = [], r = [], i = V(e), a = P(e);
|
|
272
|
+
for (let o of t.matchAll(Xe)) {
|
|
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 === "" && (H(a, c + 2) || (r.push({
|
|
277
277
|
from: c,
|
|
278
278
|
to: l
|
|
279
|
-
}), !
|
|
280
|
-
widget: new
|
|
279
|
+
}), !qe(i, e.doc, c, l) && n.push(E.replace({
|
|
280
|
+
widget: new Qe(s, !0),
|
|
281
281
|
block: !0
|
|
282
282
|
}).range(c, l))));
|
|
283
283
|
}
|
|
@@ -288,7 +288,7 @@ function rt(e) {
|
|
|
288
288
|
}
|
|
289
289
|
//#endregion
|
|
290
290
|
//#region src/inplace/nodes-inline.ts
|
|
291
|
-
var
|
|
291
|
+
var rt = {
|
|
292
292
|
StrongEmphasis: {
|
|
293
293
|
mark: "EmphasisMark",
|
|
294
294
|
className: "cm-inplace-strong",
|
|
@@ -310,13 +310,13 @@ var it = {
|
|
|
310
310
|
toggle: "code"
|
|
311
311
|
}
|
|
312
312
|
};
|
|
313
|
-
function
|
|
313
|
+
function it(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
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
|
-
function
|
|
319
|
+
function at(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
322
|
let c = n.lineAt(e.from), l = me.exec(c.text);
|
|
@@ -329,7 +329,7 @@ function ot(e, t) {
|
|
|
329
329
|
}
|
|
330
330
|
//#endregion
|
|
331
331
|
//#region src/inplace/widgets.ts
|
|
332
|
-
var
|
|
332
|
+
var ot = class extends k {
|
|
333
333
|
eq() {
|
|
334
334
|
return !0;
|
|
335
335
|
}
|
|
@@ -340,7 +340,7 @@ var st = class extends k {
|
|
|
340
340
|
ignoreEvent() {
|
|
341
341
|
return !1;
|
|
342
342
|
}
|
|
343
|
-
},
|
|
343
|
+
}, st = class extends k {
|
|
344
344
|
eq() {
|
|
345
345
|
return !0;
|
|
346
346
|
}
|
|
@@ -351,7 +351,7 @@ var st = class extends k {
|
|
|
351
351
|
ignoreEvent() {
|
|
352
352
|
return !1;
|
|
353
353
|
}
|
|
354
|
-
},
|
|
354
|
+
}, ct = class extends k {
|
|
355
355
|
checked;
|
|
356
356
|
constructor(e) {
|
|
357
357
|
super(), this.checked = e;
|
|
@@ -373,14 +373,14 @@ var st = class extends k {
|
|
|
373
373
|
ignoreEvent() {
|
|
374
374
|
return !0;
|
|
375
375
|
}
|
|
376
|
-
},
|
|
377
|
-
function
|
|
376
|
+
}, lt = /^[-*+]$/;
|
|
377
|
+
function ut(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(E.line({ class: "cm-inplace-hr-line" }).range(o.from)), i.push(E.replace({ widget: new
|
|
381
|
+
return r.has(o.number) || (i.push(E.line({ class: "cm-inplace-hr-line" }).range(o.from)), i.push(E.replace({ widget: new ot() }).range(o.from, o.to))), !1;
|
|
382
382
|
}
|
|
383
|
-
function
|
|
383
|
+
function dt(e, t) {
|
|
384
384
|
let { doc: n, revealed: r, caretRevealed: i, out: a, toggles: o, quoteRevealed: s } = t;
|
|
385
385
|
if (o.blockquote) {
|
|
386
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;
|
|
@@ -401,7 +401,7 @@ function ft(e, t) {
|
|
|
401
401
|
}
|
|
402
402
|
}
|
|
403
403
|
}
|
|
404
|
-
function
|
|
404
|
+
function ft(e, t) {
|
|
405
405
|
let { doc: n, revealed: r, out: i, toggles: a, quoteRevealed: o } = t;
|
|
406
406
|
if (!a.blockquote) return !1;
|
|
407
407
|
let s = n.lineAt(e.from);
|
|
@@ -411,20 +411,20 @@ function pt(e, t) {
|
|
|
411
411
|
}
|
|
412
412
|
return !1;
|
|
413
413
|
}
|
|
414
|
-
function
|
|
414
|
+
function pt(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(E.replace({}).range(e.from, Math.min(e.to + 1, s.to))) : a.lists &&
|
|
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 && lt.test(o) && i.push(E.replace({ widget: new st() }).range(e.from, e.to))), !1;
|
|
417
417
|
}
|
|
418
|
-
function
|
|
418
|
+
function mt(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(E.replace({ widget: new
|
|
423
|
+
i.push(E.replace({ widget: new ct(t) }).range(e.from, e.to));
|
|
424
424
|
}
|
|
425
425
|
return !1;
|
|
426
426
|
}
|
|
427
|
-
function
|
|
427
|
+
function ht(e, t) {
|
|
428
428
|
let { doc: n, revealed: r, caretRevealed: i, out: a, toggles: o } = t;
|
|
429
429
|
if (!o.code) return !1;
|
|
430
430
|
let s = e.name === "FencedCode", c = n.lineAt(e.from).number, l = n.lineAt(e.to > e.from ? e.to - 1 : e.to).number, u = l > c + 1, d = !1;
|
|
@@ -440,8 +440,8 @@ function gt(e, t) {
|
|
|
440
440
|
}
|
|
441
441
|
//#endregion
|
|
442
442
|
//#region src/inplace/nodes.ts
|
|
443
|
-
var
|
|
444
|
-
function
|
|
443
|
+
var gt = /^ATXHeading([1-6])$/, _t = /^SetextHeading([12])$/;
|
|
444
|
+
function vt(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);
|
|
@@ -457,7 +457,7 @@ function yt(e, t, n) {
|
|
|
457
457
|
}
|
|
458
458
|
}
|
|
459
459
|
}
|
|
460
|
-
function
|
|
460
|
+
function yt(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);
|
|
@@ -475,30 +475,30 @@ function bt(e, t, n) {
|
|
|
475
475
|
}
|
|
476
476
|
}
|
|
477
477
|
}
|
|
478
|
-
function
|
|
478
|
+
function bt(e, t) {
|
|
479
479
|
if (e.to <= t.fmEnd) return !1;
|
|
480
|
-
let n =
|
|
481
|
-
if (n) return
|
|
482
|
-
let r =
|
|
483
|
-
if (r) return
|
|
484
|
-
let i =
|
|
485
|
-
if (i) return
|
|
486
|
-
if (e.name === "Link") return
|
|
487
|
-
if (e.name === "HorizontalRule") return
|
|
488
|
-
if (e.name === "Blockquote") return
|
|
489
|
-
if (e.name === "QuoteMark") return
|
|
490
|
-
if (e.name === "ListMark") return
|
|
491
|
-
if (e.name === "TaskMarker") return
|
|
492
|
-
if (e.name === "FencedCode" || e.name === "CodeBlock") return
|
|
480
|
+
let n = gt.exec(e.name);
|
|
481
|
+
if (n) return vt(e, t, n[1]);
|
|
482
|
+
let r = _t.exec(e.name);
|
|
483
|
+
if (r) return yt(e, t, r[1]);
|
|
484
|
+
let i = rt[e.name];
|
|
485
|
+
if (i) return it(e, t, i);
|
|
486
|
+
if (e.name === "Link") return at(e, t);
|
|
487
|
+
if (e.name === "HorizontalRule") return ut(e, t);
|
|
488
|
+
if (e.name === "Blockquote") return dt(e, t);
|
|
489
|
+
if (e.name === "QuoteMark") return ft(e, t);
|
|
490
|
+
if (e.name === "ListMark") return pt(e, t);
|
|
491
|
+
if (e.name === "TaskMarker") return mt(e, t);
|
|
492
|
+
if (e.name === "FencedCode" || e.name === "CodeBlock") return ht(e, t);
|
|
493
493
|
}
|
|
494
494
|
//#endregion
|
|
495
495
|
//#region src/inplace/wikilinks.ts
|
|
496
|
-
function
|
|
496
|
+
function xt(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(I) != 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 || H(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
503
|
s.push(E.mark({
|
|
504
504
|
class: "cm-inplace-link cm-inplace-wikilink",
|
|
@@ -508,9 +508,9 @@ function St(t, n, r, i, a, o, s) {
|
|
|
508
508
|
}
|
|
509
509
|
//#endregion
|
|
510
510
|
//#region src/inplace/decorate.ts
|
|
511
|
-
var
|
|
512
|
-
function
|
|
513
|
-
let n = [], r =
|
|
511
|
+
var St = /* @__PURE__ */ new Set(), Ct = E.replace({});
|
|
512
|
+
function wt(e) {
|
|
513
|
+
let n = [], r = V(e.state), i = e.state.facet(R) === "never" ? St : r, a = P(e.state), { doc: o } = e.state, s = e.state.facet(F), c = {
|
|
514
514
|
doc: o,
|
|
515
515
|
revealed: i,
|
|
516
516
|
caretRevealed: r,
|
|
@@ -523,10 +523,10 @@ function Tt(e) {
|
|
|
523
523
|
a.iterate({
|
|
524
524
|
from: t.from,
|
|
525
525
|
to: t.to,
|
|
526
|
-
enter: (e) =>
|
|
526
|
+
enter: (e) => bt(e, c)
|
|
527
527
|
});
|
|
528
528
|
let r = e.state.doc.sliceString(t.from, t.to);
|
|
529
|
-
s.wikilinks &&
|
|
529
|
+
s.wikilinks && xt(e, t.from, t.to, r, i, a, n), s.math && $e(e, t.from, t.to, r, i, a, n), We(t.from, t.to, a, o, s, n);
|
|
530
530
|
}
|
|
531
531
|
let l = n.filter((e) => e.from < e.to && !e.value.spec.class).sort((e, t) => e.from - t.from || e.to - t.to), u = [];
|
|
532
532
|
for (let e of l) {
|
|
@@ -535,7 +535,7 @@ function Tt(e) {
|
|
|
535
535
|
if (e.from === t.from && e.to === t.to) continue;
|
|
536
536
|
}
|
|
537
537
|
let t = u[u.length - 1];
|
|
538
|
-
t && e.from <= t.to ? e.to > t.to && (u[u.length - 1] =
|
|
538
|
+
t && e.from <= t.to ? e.to > t.to && (u[u.length - 1] = Ct.range(t.from, e.to)) : u.push(Ct.range(e.from, e.to));
|
|
539
539
|
}
|
|
540
540
|
return {
|
|
541
541
|
decorations: E.set(n, !0),
|
|
@@ -544,16 +544,16 @@ function Tt(e) {
|
|
|
544
544
|
}
|
|
545
545
|
//#endregion
|
|
546
546
|
//#region src/inplace/plugin.ts
|
|
547
|
-
var
|
|
547
|
+
var Tt = O.fromClass(class {
|
|
548
548
|
decorations;
|
|
549
549
|
atomic;
|
|
550
550
|
constructor(e) {
|
|
551
|
-
let t =
|
|
551
|
+
let t = wt(e);
|
|
552
552
|
this.decorations = t.decorations, this.atomic = t.atomic;
|
|
553
553
|
}
|
|
554
554
|
update(e) {
|
|
555
555
|
if (e.docChanged || e.viewportChanged || e.selectionSet) {
|
|
556
|
-
let t =
|
|
556
|
+
let t = wt(e.view);
|
|
557
557
|
this.decorations = t.decorations, this.atomic = t.atomic;
|
|
558
558
|
}
|
|
559
559
|
}
|
|
@@ -561,12 +561,12 @@ var Et = O.fromClass(class {
|
|
|
561
561
|
decorations: (e) => e.decorations,
|
|
562
562
|
provide: (e) => D.atomicRanges.of((t) => t.plugin(e)?.atomic ?? E.none)
|
|
563
563
|
});
|
|
564
|
-
function
|
|
565
|
-
return
|
|
564
|
+
function Et() {
|
|
565
|
+
return Tt;
|
|
566
566
|
}
|
|
567
567
|
//#endregion
|
|
568
568
|
//#region src/inplace/wrap-at.ts
|
|
569
|
-
var
|
|
569
|
+
var Dt = {
|
|
570
570
|
StrongEmphasis: {
|
|
571
571
|
markType: "EmphasisMark",
|
|
572
572
|
toggle: "emphasis"
|
|
@@ -584,15 +584,15 @@ var Ot = {
|
|
|
584
584
|
toggle: "code"
|
|
585
585
|
}
|
|
586
586
|
};
|
|
587
|
-
function
|
|
588
|
-
return e.facet(
|
|
587
|
+
function U(e, t) {
|
|
588
|
+
return e.facet(R) === "never" || !V(e).has(t);
|
|
589
589
|
}
|
|
590
|
-
function
|
|
590
|
+
function W(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 && !U(t, a.number)) return null;
|
|
593
|
+
let o = t.facet(F), s = P(t);
|
|
594
594
|
for (let e of [-1, 1]) for (let i = s.resolveInner(n, e); i; i = i.parent) {
|
|
595
|
-
let e =
|
|
595
|
+
let e = Dt[i.name];
|
|
596
596
|
if (e) {
|
|
597
597
|
if (!o[e.toggle]) break;
|
|
598
598
|
let t = i.getChildren(e.markType), n = t[0], r = t[t.length - 1];
|
|
@@ -634,8 +634,8 @@ function H(t, n, r = !1, i = !1) {
|
|
|
634
634
|
}
|
|
635
635
|
//#endregion
|
|
636
636
|
//#region src/inplace/edit-boundaries.ts
|
|
637
|
-
function
|
|
638
|
-
let r = e.plugin(
|
|
637
|
+
function Ot(e, t, n) {
|
|
638
|
+
let r = e.plugin(Tt)?.decorations;
|
|
639
639
|
if (!r) return t;
|
|
640
640
|
let i = n < 0 ? 0 : e.state.doc.length, a = t;
|
|
641
641
|
for (let e = !0; e;) e = !1, r.between(Math.min(a, i), Math.max(a, i), (t, r, i) => {
|
|
@@ -643,18 +643,18 @@ function kt(e, t, n) {
|
|
|
643
643
|
});
|
|
644
644
|
return a;
|
|
645
645
|
}
|
|
646
|
-
var
|
|
646
|
+
var kt = (e) => (t) => {
|
|
647
647
|
if (h(t)) return !1;
|
|
648
648
|
let n = t.state.selection.main;
|
|
649
649
|
if (!n.empty) return !1;
|
|
650
650
|
let { state: r } = t;
|
|
651
|
-
if (!
|
|
652
|
-
let i =
|
|
651
|
+
if (!U(r, r.doc.lineAt(n.head).number)) return !1;
|
|
652
|
+
let i = Ot(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 = W(r, o); e && o <= e.contentFrom && s >= e.contentTo && e.contentTo > e.contentFrom && !(e.from >= o && e.to <= s); e = W(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,
|
|
@@ -665,93 +665,56 @@ var At = (e) => (t) => {
|
|
|
665
665
|
userEvent: e < 0 ? "delete.backward" : "delete.forward",
|
|
666
666
|
scrollIntoView: !0
|
|
667
667
|
}), !0;
|
|
668
|
-
},
|
|
669
|
-
function
|
|
668
|
+
}, At = kt(-1), jt = kt(1);
|
|
669
|
+
function Mt(e, t, n) {
|
|
670
670
|
if (n <= t) return !1;
|
|
671
|
-
let r = e.plugin(
|
|
671
|
+
let r = e.plugin(Tt)?.decorations;
|
|
672
672
|
if (!r) return !1;
|
|
673
673
|
let i = t;
|
|
674
674
|
return r.between(t, n, (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 G = (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 || !U(n.state, n.state.doc.lineAt(r.head).number)) return !1;
|
|
682
682
|
let i = n.moveByChar(r, e);
|
|
683
|
-
if (
|
|
684
|
-
let a = t ?
|
|
683
|
+
if (Mt(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 ? Se.range(r.anchor, i.head) : Se.cursor(i.head);
|
|
685
685
|
return n.dispatch({
|
|
686
686
|
selection: a,
|
|
687
687
|
userEvent: "select"
|
|
688
688
|
}), !0;
|
|
689
|
-
},
|
|
689
|
+
}, Nt = G(!1, !1), Pt = G(!0, !1), Ft = G(!1, !0), It = G(!0, !0), Lt = M.high(A.of([
|
|
690
690
|
{
|
|
691
691
|
key: "Backspace",
|
|
692
|
-
run:
|
|
692
|
+
run: At
|
|
693
693
|
},
|
|
694
694
|
{
|
|
695
695
|
key: "Delete",
|
|
696
|
-
run:
|
|
696
|
+
run: jt
|
|
697
697
|
},
|
|
698
698
|
{
|
|
699
699
|
key: "ArrowLeft",
|
|
700
|
-
run:
|
|
700
|
+
run: Nt
|
|
701
701
|
},
|
|
702
702
|
{
|
|
703
703
|
key: "ArrowRight",
|
|
704
|
-
run:
|
|
704
|
+
run: Pt
|
|
705
705
|
},
|
|
706
706
|
{
|
|
707
707
|
key: "Shift-ArrowLeft",
|
|
708
|
-
run:
|
|
708
|
+
run: Ft
|
|
709
709
|
},
|
|
710
710
|
{
|
|
711
711
|
key: "Shift-ArrowRight",
|
|
712
|
-
run:
|
|
712
|
+
run: It
|
|
713
713
|
}
|
|
714
714
|
]));
|
|
715
715
|
//#endregion
|
|
716
|
-
//#region src/inplace/table-cell-
|
|
717
|
-
function
|
|
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) {
|
|
716
|
+
//#region src/inplace/table-cell-align.ts
|
|
717
|
+
function Rt(e, t) {
|
|
755
718
|
let n = [], r = 0, i = (e) => {
|
|
756
719
|
for (let a of e.childNodes) if (a instanceof Text) {
|
|
757
720
|
let e = t.indexOf(a.data, r);
|
|
@@ -776,90 +739,192 @@ function Ht(e, t) {
|
|
|
776
739
|
};
|
|
777
740
|
return i(e) ? n : null;
|
|
778
741
|
}
|
|
779
|
-
|
|
742
|
+
//#endregion
|
|
743
|
+
//#region src/inplace/table-cell-widgets.ts
|
|
744
|
+
function zt(e, t, n, r, i) {
|
|
745
|
+
return e.filter((e) => e.pos >= n && e.pos <= n + i).map((e) => ({
|
|
746
|
+
at: e.pos - n + r,
|
|
747
|
+
key: e.key,
|
|
748
|
+
cellClass: e.cellClass,
|
|
749
|
+
build: () => e.toDOM(t)
|
|
750
|
+
}));
|
|
751
|
+
}
|
|
752
|
+
function Bt(e) {
|
|
753
|
+
let t = e.build();
|
|
754
|
+
return t.setAttribute("contenteditable", "false"), t.dataset.styloCellWidget = "", t;
|
|
755
|
+
}
|
|
756
|
+
function Vt(e, t) {
|
|
757
|
+
let n = null, r = Infinity;
|
|
758
|
+
for (let i of e) {
|
|
759
|
+
let e = i.start + i.node.data.length;
|
|
760
|
+
if (t > i.start && t <= e) return {
|
|
761
|
+
piece: i,
|
|
762
|
+
at: t
|
|
763
|
+
};
|
|
764
|
+
for (let a of [i.start, e]) Math.abs(t - a) < r && ([n, r] = [{
|
|
765
|
+
piece: i,
|
|
766
|
+
at: a
|
|
767
|
+
}, Math.abs(t - a)]);
|
|
768
|
+
}
|
|
769
|
+
return n;
|
|
770
|
+
}
|
|
771
|
+
function Ht(e, t) {
|
|
772
|
+
let n = /* @__PURE__ */ new Map(), r = [];
|
|
773
|
+
for (let i of t) {
|
|
774
|
+
let t = e && Vt(e, i.at);
|
|
775
|
+
t ? n.set(t.piece, [...n.get(t.piece) ?? [], {
|
|
776
|
+
...i,
|
|
777
|
+
at: t.at
|
|
778
|
+
}]) : r.push(i);
|
|
779
|
+
}
|
|
780
|
+
return {
|
|
781
|
+
placed: n,
|
|
782
|
+
loose: r
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
//#endregion
|
|
786
|
+
//#region src/inplace/table-cell-marks.ts
|
|
787
|
+
function Ut(e, t, n, r) {
|
|
788
|
+
let i = {
|
|
789
|
+
marks: [],
|
|
790
|
+
widgets: [],
|
|
791
|
+
cellClass: []
|
|
792
|
+
};
|
|
793
|
+
for (let a of e) a.to <= t || a.from >= t + r || a.to <= a.from || (i.marks.push({
|
|
794
|
+
from: Math.max(a.from - t, 0) + n,
|
|
795
|
+
to: Math.min(a.to - t, r) + n,
|
|
796
|
+
class: a.class,
|
|
797
|
+
attributes: a.attributes
|
|
798
|
+
}), Wt(i, a.cellClass));
|
|
799
|
+
return i.marks.length || i.cellClass.length ? i : null;
|
|
800
|
+
}
|
|
801
|
+
var Wt = (e, t) => {
|
|
802
|
+
for (let n of t?.split(/\s+/) ?? []) n && !e.cellClass.includes(n) && e.cellClass.push(n);
|
|
803
|
+
};
|
|
804
|
+
function Gt(e, t) {
|
|
805
|
+
let n = document.createElement("span");
|
|
806
|
+
n.className = e.class, n.dataset.styloCellMark = "";
|
|
807
|
+
for (let [t, r] of Object.entries(e.attributes ?? {})) try {
|
|
808
|
+
n.setAttribute(t, r);
|
|
809
|
+
} catch {}
|
|
810
|
+
return n.append(t), n;
|
|
811
|
+
}
|
|
812
|
+
function Kt(e, t, n) {
|
|
813
|
+
let r = e.node.data, i = e.start + r.length, a = t.filter((t) => t.from < i && t.to > e.start);
|
|
814
|
+
if (!a.length && !n.length) return !1;
|
|
815
|
+
let o = /* @__PURE__ */ new Set([e.start, i]);
|
|
816
|
+
for (let e of n) o.add(e.at);
|
|
817
|
+
for (let t of a) o.add(Math.max(t.from, e.start)), o.add(Math.min(t.to, i));
|
|
818
|
+
let s = [...o].sort((e, t) => e - t), c = document.createDocumentFragment(), l = (e) => {
|
|
819
|
+
for (let t of n) t.at === e && c.append(Bt(t));
|
|
820
|
+
};
|
|
821
|
+
l(e.start);
|
|
822
|
+
for (let t = 0; t < s.length - 1; t++) {
|
|
823
|
+
let [n, i] = [s[t], s[t + 1]], o = document.createTextNode(r.slice(n - e.start, i - e.start));
|
|
824
|
+
for (let e of a) e.from <= n && e.to >= i && (o = Gt(e, o));
|
|
825
|
+
c.append(o), l(i);
|
|
826
|
+
}
|
|
827
|
+
return e.node.replaceWith(c), !0;
|
|
828
|
+
}
|
|
829
|
+
function qt(e, t) {
|
|
780
830
|
for (let n of t) {
|
|
781
|
-
let t =
|
|
831
|
+
let t = Gt(n, e.ownerDocument.createDocumentFragment());
|
|
782
832
|
t.append(...e.childNodes), e.append(t);
|
|
783
833
|
}
|
|
784
834
|
}
|
|
785
|
-
function
|
|
786
|
-
let i = n.marks, a = [], o;
|
|
787
|
-
if (r)
|
|
835
|
+
function Jt(e, t, n, r) {
|
|
836
|
+
let i = n.marks, a = [], o = [], s;
|
|
837
|
+
if (r) s = e.firstChild instanceof Text ? [{
|
|
788
838
|
node: e.firstChild,
|
|
789
839
|
start: 0
|
|
790
840
|
}] : null;
|
|
791
841
|
else {
|
|
792
|
-
let
|
|
793
|
-
|
|
842
|
+
let r = [...t.matchAll(/\\\|/g)].map((e) => e.index), o = (e) => e - r.filter((t) => t < e).length;
|
|
843
|
+
s = Rt(e, t.replace(/\\\|/g, "|")), i = i.map((e) => ({
|
|
844
|
+
...e,
|
|
845
|
+
from: o(e.from),
|
|
846
|
+
to: o(e.to)
|
|
847
|
+
})), a = n.widgets.map((e) => ({
|
|
794
848
|
...e,
|
|
795
|
-
|
|
796
|
-
to: r(e.to)
|
|
849
|
+
at: o(e.at)
|
|
797
850
|
}));
|
|
798
851
|
}
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
for (let e of i)
|
|
803
|
-
for (let e of
|
|
804
|
-
|
|
852
|
+
let { placed: c, loose: l } = Ht(s, a), u = () => e.append(...l.map(Bt));
|
|
853
|
+
if (!s) return qt(e, i), u();
|
|
854
|
+
let d = /* @__PURE__ */ new Set();
|
|
855
|
+
for (let e of s) for (let t of i) t.from < e.start + e.node.data.length && t.to > e.start && d.add(t);
|
|
856
|
+
for (let e of i) d.has(e) || o.push(e);
|
|
857
|
+
for (let e of s) Kt(e, i, c.get(e) ?? []);
|
|
858
|
+
qt(e, o), u();
|
|
805
859
|
}
|
|
806
|
-
function
|
|
860
|
+
function Yt(e) {
|
|
807
861
|
let t = null;
|
|
808
862
|
return (n, r) => {
|
|
809
863
|
let i = e.view();
|
|
810
864
|
if (!i || !e.mounted()) return null;
|
|
811
865
|
if (t?.state !== i.state) {
|
|
812
|
-
let n = i.state.facet(Le)(i.state);
|
|
866
|
+
let n = i.state.facet(Ie)(i.state), r = i.state.facet(Le)(i.state);
|
|
813
867
|
t = {
|
|
814
868
|
state: i.state,
|
|
815
869
|
marks: n,
|
|
816
|
-
|
|
870
|
+
widgets: r,
|
|
871
|
+
from: n.length || r.length ? e.from(i) : 0
|
|
817
872
|
};
|
|
818
873
|
}
|
|
819
|
-
if (!t.marks.length) return null;
|
|
874
|
+
if (!t.marks.length && !t.widgets.length) return null;
|
|
820
875
|
let a = v(i.state.doc, t.from, n, r), o = e.raw(n, r);
|
|
821
|
-
|
|
876
|
+
if (a == null) return null;
|
|
877
|
+
let s = o.length - o.trimStart().length, c = o.trim().length, l = Ut(t.marks, a, s, c), u = zt(t.widgets, i, a, s, c);
|
|
878
|
+
if (!u.length) return l;
|
|
879
|
+
let d = l ?? {
|
|
880
|
+
marks: [],
|
|
881
|
+
widgets: [],
|
|
882
|
+
cellClass: []
|
|
883
|
+
};
|
|
884
|
+
d.widgets = u;
|
|
885
|
+
for (let e of u) Wt(d, e.cellClass);
|
|
886
|
+
return d;
|
|
822
887
|
};
|
|
823
888
|
}
|
|
824
889
|
//#endregion
|
|
825
890
|
//#region src/inplace/context-menu-helpers.ts
|
|
826
|
-
var
|
|
891
|
+
var Xt = (e) => e === "h1" || e === "h2" || e === "h3" ? S.heading : S[e], Zt = [
|
|
827
892
|
"bold",
|
|
828
893
|
"italic",
|
|
829
894
|
"strike"
|
|
830
|
-
],
|
|
895
|
+
], Qt = ["code", "math"], $t = [
|
|
831
896
|
"bulletList",
|
|
832
897
|
"orderedList",
|
|
833
898
|
"task"
|
|
834
|
-
],
|
|
899
|
+
], en = [
|
|
835
900
|
"h1",
|
|
836
901
|
"h2",
|
|
837
902
|
"h3"
|
|
838
|
-
],
|
|
903
|
+
], tn = ["table", "hr"], nn = [
|
|
839
904
|
"codeBlock",
|
|
840
905
|
"mathBlock",
|
|
841
906
|
"frontmatter"
|
|
842
|
-
],
|
|
907
|
+
], rn = (e, t, n = !1) => {
|
|
843
908
|
let r = g[t];
|
|
844
909
|
if (!r) return null;
|
|
845
910
|
let { disabled: i, active: a } = re(e.state, r, n);
|
|
846
911
|
return {
|
|
847
912
|
label: r.title,
|
|
848
|
-
icon:
|
|
913
|
+
icon: Xt(t),
|
|
849
914
|
active: a,
|
|
850
915
|
disabled: i,
|
|
851
916
|
onSelect: () => {
|
|
852
917
|
r.run(e), e.focus();
|
|
853
918
|
}
|
|
854
919
|
};
|
|
855
|
-
},
|
|
920
|
+
}, K = (e, t, n = !1, r = !1) => {
|
|
856
921
|
let i = [];
|
|
857
922
|
for (let a of t) {
|
|
858
|
-
let t =
|
|
923
|
+
let t = rn(e, a, r);
|
|
859
924
|
t && !(n && t.disabled) && i.push(t);
|
|
860
925
|
}
|
|
861
926
|
return i;
|
|
862
|
-
},
|
|
927
|
+
}, q = (e) => {
|
|
863
928
|
let t = e.contentDOM.ownerDocument, n = (n) => () => {
|
|
864
929
|
e.focus();
|
|
865
930
|
try {
|
|
@@ -894,36 +959,36 @@ var Kt = (e) => e === "h1" || e === "h2" || e === "h3" ? S.heading : S[e], qt =
|
|
|
894
959
|
onSelect: () => {}
|
|
895
960
|
}
|
|
896
961
|
];
|
|
897
|
-
},
|
|
962
|
+
}, J = (e, t, n, r = !1) => ({
|
|
898
963
|
label: e,
|
|
899
964
|
icon: t,
|
|
900
965
|
rows: n,
|
|
901
966
|
disabled: r
|
|
902
967
|
});
|
|
903
|
-
function
|
|
968
|
+
function Y(e, t) {
|
|
904
969
|
t.length && (e.length && e.push("separator"), e.push(...t));
|
|
905
970
|
}
|
|
906
971
|
//#endregion
|
|
907
972
|
//#region src/inplace/edit-divider.ts
|
|
908
|
-
function
|
|
973
|
+
function an(e) {
|
|
909
974
|
let t = e.selection.main;
|
|
910
975
|
if (!t.empty) return !1;
|
|
911
976
|
let n = e.doc.lineAt(t.head);
|
|
912
|
-
if (!
|
|
913
|
-
for (let t =
|
|
977
|
+
if (!U(e, n.number)) return !1;
|
|
978
|
+
for (let t = P(e).resolveInner(n.from, 1); t; t = t.parent) {
|
|
914
979
|
if (t.name === "HorizontalRule") return !0;
|
|
915
980
|
if (!t.parent) break;
|
|
916
981
|
}
|
|
917
982
|
return !1;
|
|
918
983
|
}
|
|
919
|
-
var
|
|
984
|
+
var on = (e) => h(e) || !an(e.state) ? !1 : oe(e), sn = M.high(A.of([{
|
|
920
985
|
key: "Backspace",
|
|
921
|
-
run:
|
|
986
|
+
run: on
|
|
922
987
|
}, {
|
|
923
988
|
key: "Delete",
|
|
924
|
-
run:
|
|
989
|
+
run: on
|
|
925
990
|
}]));
|
|
926
|
-
function
|
|
991
|
+
function cn(e) {
|
|
927
992
|
return {
|
|
928
993
|
label: "Remove divider",
|
|
929
994
|
icon: S.hr,
|
|
@@ -934,66 +999,66 @@ function rn(e) {
|
|
|
934
999
|
}
|
|
935
1000
|
//#endregion
|
|
936
1001
|
//#region src/inplace/inline-md.ts
|
|
937
|
-
function
|
|
1002
|
+
function ln(e, t = !1) {
|
|
938
1003
|
let n = document.createDocumentFragment();
|
|
939
|
-
return
|
|
1004
|
+
return fn(n, e, t), n;
|
|
940
1005
|
}
|
|
941
|
-
var
|
|
1006
|
+
var un = /!\[\[[^\]\n]+?\]\]/, dn = [
|
|
942
1007
|
{
|
|
943
1008
|
re: /`([^`\n]+)`/,
|
|
944
|
-
build: (e) =>
|
|
1009
|
+
build: (e) => X("code", "cm-inplace-code", document.createTextNode(e[1]))
|
|
945
1010
|
},
|
|
946
1011
|
{
|
|
947
|
-
re: new RegExp(
|
|
1012
|
+
re: new RegExp(Je.source),
|
|
948
1013
|
build: (e) => {
|
|
949
|
-
let t =
|
|
1014
|
+
let t = X("span", "cm-inplace-math");
|
|
950
1015
|
return he.render(e[1], t, { throwOnError: !1 }), t;
|
|
951
1016
|
}
|
|
952
1017
|
},
|
|
953
1018
|
{
|
|
954
1019
|
re: new RegExp(e.source),
|
|
955
1020
|
build: (e) => {
|
|
956
|
-
let t =
|
|
1021
|
+
let t = X("span", "cm-inplace-wikilink", document.createTextNode(e[2] || e[1] || ""));
|
|
957
1022
|
return t.dataset.styloWikilink = e[1] ?? "", t;
|
|
958
1023
|
}
|
|
959
1024
|
},
|
|
960
1025
|
{
|
|
961
1026
|
re: /\[([^\]\n]*)\]\(([^)\n]*)\)/,
|
|
962
1027
|
build: (e, t) => {
|
|
963
|
-
let n =
|
|
964
|
-
return n.href = e[2] ?? "", n.append(
|
|
1028
|
+
let n = X("a", "cm-inplace-link");
|
|
1029
|
+
return n.href = e[2] ?? "", n.append(Z(e[1] ?? "", t)), n;
|
|
965
1030
|
}
|
|
966
1031
|
},
|
|
967
1032
|
{
|
|
968
1033
|
re: /\*\*\*([^*\n]+?)\*\*\*/,
|
|
969
|
-
build: (e, t) =>
|
|
1034
|
+
build: (e, t) => X("strong", "cm-inplace-strong", X("em", "cm-inplace-em", Z(e[1], t)))
|
|
970
1035
|
},
|
|
971
1036
|
{
|
|
972
1037
|
re: /\*\*([^\n]+?)\*\*/,
|
|
973
|
-
build: (e, t) =>
|
|
1038
|
+
build: (e, t) => X("strong", "cm-inplace-strong", Z(e[1], t))
|
|
974
1039
|
},
|
|
975
1040
|
{
|
|
976
1041
|
re: /~~([^\n]+?)~~/,
|
|
977
|
-
build: (e, t) =>
|
|
1042
|
+
build: (e, t) => X("span", "cm-inplace-strike", Z(e[1], t))
|
|
978
1043
|
},
|
|
979
1044
|
{
|
|
980
1045
|
re: /(?<!\*)\*(?!\*|\s)([^\n]+?)(?<!\s)\*(?!\*)/,
|
|
981
|
-
build: (e, t) =>
|
|
1046
|
+
build: (e, t) => X("em", "cm-inplace-em", Z(e[1], t))
|
|
982
1047
|
}
|
|
983
1048
|
];
|
|
984
|
-
function
|
|
1049
|
+
function X(e, t, ...n) {
|
|
985
1050
|
let r = document.createElement(e);
|
|
986
1051
|
return r.className = t, r.append(...n), r;
|
|
987
1052
|
}
|
|
988
|
-
function
|
|
1053
|
+
function Z(e, t) {
|
|
989
1054
|
let n = document.createDocumentFragment();
|
|
990
|
-
return
|
|
1055
|
+
return fn(n, e, t), n;
|
|
991
1056
|
}
|
|
992
|
-
function
|
|
1057
|
+
function fn(e, t, n) {
|
|
993
1058
|
for (; t;) {
|
|
994
|
-
let r = -1, i = null, a = n ?
|
|
1059
|
+
let r = -1, i = null, a = n ? un.exec(t) : null;
|
|
995
1060
|
a && (r = a.index, i = { literal: a[0] });
|
|
996
|
-
for (let e of
|
|
1061
|
+
for (let e of dn) {
|
|
997
1062
|
let n = e.re.exec(t);
|
|
998
1063
|
n && (r < 0 || n.index < r) && (r = n.index, i = {
|
|
999
1064
|
rule: e,
|
|
@@ -1009,7 +1074,7 @@ function cn(e, t, n) {
|
|
|
1009
1074
|
}
|
|
1010
1075
|
//#endregion
|
|
1011
1076
|
//#region src/inplace/tables.ts
|
|
1012
|
-
var
|
|
1077
|
+
var pn = class extends k {
|
|
1013
1078
|
table;
|
|
1014
1079
|
embeds;
|
|
1015
1080
|
constructor(e, t) {
|
|
@@ -1021,17 +1086,17 @@ var ln = class extends k {
|
|
|
1021
1086
|
toDOM() {
|
|
1022
1087
|
let { head: e, body: t, aligns: n } = this.table, r = document.createElement("table");
|
|
1023
1088
|
r.className = "cm-inplace-table";
|
|
1024
|
-
let i = (e) =>
|
|
1089
|
+
let i = (e) => ln(e.replace(/\\\|/g, "|"), this.embeds), a = r.createTHead().insertRow();
|
|
1025
1090
|
e.forEach((e, t) => {
|
|
1026
1091
|
let r = document.createElement("th");
|
|
1027
|
-
r.appendChild(i(e)), r.dataset.styloRow = "0", r.dataset.styloCol = String(t),
|
|
1092
|
+
r.appendChild(i(e)), r.dataset.styloRow = "0", r.dataset.styloCol = String(t), mn(r, n[t]), a.appendChild(r);
|
|
1028
1093
|
});
|
|
1029
1094
|
let o = r.createTBody();
|
|
1030
1095
|
return t.forEach((t, r) => {
|
|
1031
1096
|
let a = o.insertRow();
|
|
1032
1097
|
for (let o = 0; o < e.length; o++) {
|
|
1033
1098
|
let e = a.insertCell();
|
|
1034
|
-
e.appendChild(i(t[o] ?? "")), e.dataset.styloRow = String(r + 1), e.dataset.styloCol = String(o),
|
|
1099
|
+
e.appendChild(i(t[o] ?? "")), e.dataset.styloRow = String(r + 1), e.dataset.styloCol = String(o), mn(e, n[o]);
|
|
1035
1100
|
}
|
|
1036
1101
|
}), r;
|
|
1037
1102
|
}
|
|
@@ -1039,10 +1104,10 @@ var ln = class extends k {
|
|
|
1039
1104
|
return !1;
|
|
1040
1105
|
}
|
|
1041
1106
|
};
|
|
1042
|
-
function
|
|
1107
|
+
function mn(e, t) {
|
|
1043
1108
|
t && (e.style.textAlign = t);
|
|
1044
1109
|
}
|
|
1045
|
-
function
|
|
1110
|
+
function hn(e, t) {
|
|
1046
1111
|
let n = t.lineAt(e.from).number, r = t.lineAt(e.to).number, i = [];
|
|
1047
1112
|
for (let e = n; e <= r; e++) i.push(t.line(e).text);
|
|
1048
1113
|
let a = p(i);
|
|
@@ -1052,17 +1117,17 @@ function dn(e, t) {
|
|
|
1052
1117
|
aligns: a.aligns
|
|
1053
1118
|
};
|
|
1054
1119
|
}
|
|
1055
|
-
function
|
|
1056
|
-
let n =
|
|
1120
|
+
function gn(e, t) {
|
|
1121
|
+
let n = P(e);
|
|
1057
1122
|
for (let e of [-1, 1]) for (let r = n.resolveInner(t, e); r; r = r.parent) if (r.name === "Table") return !0;
|
|
1058
1123
|
return !1;
|
|
1059
1124
|
}
|
|
1060
|
-
function
|
|
1061
|
-
return t.ranges.some((t) =>
|
|
1125
|
+
function _n(e, t) {
|
|
1126
|
+
return t.ranges.some((t) => gn(e, t.from) || gn(e, t.to));
|
|
1062
1127
|
}
|
|
1063
|
-
function
|
|
1064
|
-
if (!e.facet(
|
|
1065
|
-
let n = e.facet(
|
|
1128
|
+
function vn(e) {
|
|
1129
|
+
if (!e.facet(F).tables) return E.none;
|
|
1130
|
+
let n = e.facet(L) === "cells" && !e.readOnly, r = e.facet(I) != null && e.facet(F).embeds, i = P(e), a = t(e.doc), o = n ? null : V(e), s = [];
|
|
1066
1131
|
return i.iterate({ enter: (t) => {
|
|
1067
1132
|
if (t.name !== "Table") return;
|
|
1068
1133
|
if (a && t.from < a.to) return !1;
|
|
@@ -1070,9 +1135,9 @@ function mn(e) {
|
|
|
1070
1135
|
let n = e.doc.lineAt(t.from).number, r = e.doc.lineAt(t.to).number;
|
|
1071
1136
|
for (let e = n; e <= r; e++) if (o.has(e)) return !1;
|
|
1072
1137
|
}
|
|
1073
|
-
let i =
|
|
1138
|
+
let i = hn(t.node, e.doc);
|
|
1074
1139
|
if (i) {
|
|
1075
|
-
let e = n ? new
|
|
1140
|
+
let e = n ? new hr(i, r) : new pn(i, r);
|
|
1076
1141
|
s.push(E.replace({
|
|
1077
1142
|
widget: e,
|
|
1078
1143
|
block: !0
|
|
@@ -1081,22 +1146,22 @@ function mn(e) {
|
|
|
1081
1146
|
return !1;
|
|
1082
1147
|
} }), E.set(s, !0);
|
|
1083
1148
|
}
|
|
1084
|
-
var
|
|
1085
|
-
create:
|
|
1149
|
+
var yn = N.define({
|
|
1150
|
+
create: vn,
|
|
1086
1151
|
update: (e, t) => {
|
|
1087
|
-
if (t.annotation(
|
|
1152
|
+
if (t.annotation(pr)) return e.map(t.changes);
|
|
1088
1153
|
let n = t.startState.readOnly !== t.state.readOnly;
|
|
1089
|
-
return t.state.facet(
|
|
1154
|
+
return t.state.facet(L) === "cells" ? t.docChanged || n ? vn(t.state) : e.map(t.changes) : t.docChanged || n || t.selection && (_n(t.state, t.startState.selection) || _n(t.state, t.state.selection)) ? vn(t.state) : e;
|
|
1090
1155
|
},
|
|
1091
1156
|
provide: (e) => [D.decorations.from(e), D.atomicRanges.of((t) => t.state.field(e))]
|
|
1092
1157
|
});
|
|
1093
1158
|
//#endregion
|
|
1094
1159
|
//#region src/inplace/host-cell.ts
|
|
1095
|
-
function
|
|
1160
|
+
function bn(e, t, n) {
|
|
1096
1161
|
let i = t.closest("table");
|
|
1097
1162
|
if (!i) return;
|
|
1098
1163
|
let a = e.posAtDOM(i), o = a;
|
|
1099
|
-
e.state.field(
|
|
1164
|
+
e.state.field(yn).between(a, a, (e) => (o = e, !1));
|
|
1100
1165
|
let s = v(e.state.doc, o, Number(t.dataset.r), Number(t.dataset.c));
|
|
1101
1166
|
if (s == null) return;
|
|
1102
1167
|
let { from: c, to: l } = n ? r(t) : {
|
|
@@ -1110,7 +1175,7 @@ function hn(e, t, n) {
|
|
|
1110
1175
|
}
|
|
1111
1176
|
//#endregion
|
|
1112
1177
|
//#region src/inplace/selection-rect.ts
|
|
1113
|
-
var
|
|
1178
|
+
var xn = (e, t, n, r) => {
|
|
1114
1179
|
let i = {
|
|
1115
1180
|
x: e,
|
|
1116
1181
|
y: t,
|
|
@@ -1126,39 +1191,39 @@ var gn = (e, t, n, r) => {
|
|
|
1126
1191
|
toJSON: () => i
|
|
1127
1192
|
};
|
|
1128
1193
|
};
|
|
1129
|
-
function
|
|
1194
|
+
function Sn(e) {
|
|
1130
1195
|
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() :
|
|
1196
|
+
return !r || !i ? e.dom.getBoundingClientRect() : xn(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
1197
|
}
|
|
1133
|
-
function
|
|
1198
|
+
function Cn(e, t) {
|
|
1134
1199
|
let n = e?.ownerDocument.getSelection();
|
|
1135
1200
|
if (e && t && n && n.rangeCount > 0) {
|
|
1136
1201
|
let e = n.getRangeAt(0).getBoundingClientRect?.();
|
|
1137
1202
|
if (e && (e.width > 0 || e.height > 0)) return e;
|
|
1138
1203
|
}
|
|
1139
|
-
return e?.getBoundingClientRect() ??
|
|
1204
|
+
return e?.getBoundingClientRect() ?? xn(0, 0, 0, 0);
|
|
1140
1205
|
}
|
|
1141
1206
|
//#endregion
|
|
1142
1207
|
//#region src/inplace/host-items.ts
|
|
1143
|
-
var
|
|
1144
|
-
function
|
|
1208
|
+
var wn = /* @__PURE__ */ new WeakMap();
|
|
1209
|
+
function Tn(e, t) {
|
|
1145
1210
|
if (e == null || typeof e == "string") return null;
|
|
1146
|
-
if (
|
|
1147
|
-
let n = document.createElement("span"), r =
|
|
1211
|
+
if (wn.has(t)) return wn.get(t) ?? null;
|
|
1212
|
+
let n = document.createElement("span"), r = De(n), i = null;
|
|
1148
1213
|
try {
|
|
1149
|
-
|
|
1214
|
+
be(() => r.render(e)), i = n.firstElementChild;
|
|
1150
1215
|
} catch {}
|
|
1151
|
-
return r.unmount(),
|
|
1216
|
+
return r.unmount(), wn.set(t, i), i;
|
|
1152
1217
|
}
|
|
1153
|
-
var
|
|
1154
|
-
function
|
|
1155
|
-
if (!
|
|
1218
|
+
var En = (e) => e.state.facet(B).includes("host"), Dn = (e) => En(e) && e.state.facet(Fe)().some((e) => e.readOnlySafe);
|
|
1219
|
+
function On(e, t) {
|
|
1220
|
+
if (!En(e)) return [];
|
|
1156
1221
|
let n = e.state.readOnly, r = [], i;
|
|
1157
|
-
for (let a of e.state.facet(
|
|
1222
|
+
for (let a of e.state.facet(Fe)()) {
|
|
1158
1223
|
if (n && !a.readOnlySafe) continue;
|
|
1159
1224
|
let o = a.when ?? "always";
|
|
1160
1225
|
if (o === "selection" && !t.selected || o === "no-selection" && t.selected) continue;
|
|
1161
|
-
let s =
|
|
1226
|
+
let s = Tn(a.icon, a);
|
|
1162
1227
|
r.push({
|
|
1163
1228
|
id: a.id,
|
|
1164
1229
|
label: a.title,
|
|
@@ -1170,15 +1235,15 @@ function Cn(e, t) {
|
|
|
1170
1235
|
}
|
|
1171
1236
|
});
|
|
1172
1237
|
}
|
|
1173
|
-
return r.length && (i = t.rect?.() ??
|
|
1238
|
+
return r.length && (i = t.rect?.() ?? Sn(e)), r;
|
|
1174
1239
|
}
|
|
1175
1240
|
//#endregion
|
|
1176
1241
|
//#region src/inplace/link-row.ts
|
|
1177
|
-
var
|
|
1242
|
+
var kn = (e) => {
|
|
1178
1243
|
let t = e.trim().replace(/^<([^]*)>$/, "$1");
|
|
1179
1244
|
return /[\s()]/.test(t) ? `<${t.replace(/[<>]/g, "")}>` : t;
|
|
1180
|
-
},
|
|
1181
|
-
function
|
|
1245
|
+
}, An = (e) => e.replace(/^<([^]*)>$/, "$1");
|
|
1246
|
+
function jn(e, t) {
|
|
1182
1247
|
let n = e.doc.lineAt(t.from);
|
|
1183
1248
|
if (e.doc.lineAt(t.to).number !== n.number) return null;
|
|
1184
1249
|
let r = t.from - n.from, i = t.to - n.from, s = o(n.text, r) ?? o(n.text, i);
|
|
@@ -1194,7 +1259,7 @@ function En(e, t) {
|
|
|
1194
1259
|
text: c.label
|
|
1195
1260
|
} : null;
|
|
1196
1261
|
}
|
|
1197
|
-
function
|
|
1262
|
+
function Mn(e, t) {
|
|
1198
1263
|
let { state: n } = e, r = n.selection.main, i = n.doc.lineAt(r.head), a = t.partsIn(i.text, r.head - i.from);
|
|
1199
1264
|
if (a) {
|
|
1200
1265
|
let n = i.from + a.from, r = i.from + a.to, o = t.editActions?.(e, a) ?? [];
|
|
@@ -1223,7 +1288,7 @@ function Dn(e, t) {
|
|
|
1223
1288
|
actions: o
|
|
1224
1289
|
};
|
|
1225
1290
|
}
|
|
1226
|
-
let o =
|
|
1291
|
+
let o = jn(n, r), s = o ? o.from : r.from, c = o ? o.to : r.to, l = o ? o.text : n.sliceDoc(r.from, r.to);
|
|
1227
1292
|
return {
|
|
1228
1293
|
field: !0,
|
|
1229
1294
|
label: t.addLabel,
|
|
@@ -1233,15 +1298,15 @@ function Dn(e, t) {
|
|
|
1233
1298
|
onSubmit: (n) => t.onAdd(e, s, c, l, n)
|
|
1234
1299
|
};
|
|
1235
1300
|
}
|
|
1236
|
-
var
|
|
1301
|
+
var Nn = {
|
|
1237
1302
|
icon: S.link,
|
|
1238
1303
|
placeholder: "https://…",
|
|
1239
1304
|
editLabel: "Edit external link",
|
|
1240
1305
|
addLabel: "Add external link",
|
|
1241
1306
|
partsIn: o,
|
|
1242
|
-
editValue: (e) =>
|
|
1307
|
+
editValue: (e) => An(e.url),
|
|
1243
1308
|
editActions: (e, t) => {
|
|
1244
|
-
let n = e.state.facet(
|
|
1309
|
+
let n = e.state.facet(je);
|
|
1245
1310
|
return !n || !t.url ? [] : [{
|
|
1246
1311
|
label: "Open link",
|
|
1247
1312
|
icon: S.link,
|
|
@@ -1252,7 +1317,7 @@ var On = {
|
|
|
1252
1317
|
e.dispatch({ changes: {
|
|
1253
1318
|
from: t.urlFrom,
|
|
1254
1319
|
to: t.urlTo,
|
|
1255
|
-
insert:
|
|
1320
|
+
insert: kn(n)
|
|
1256
1321
|
} }), e.focus();
|
|
1257
1322
|
},
|
|
1258
1323
|
onAdd: (e, t, n, r, i) => {
|
|
@@ -1261,7 +1326,7 @@ var On = {
|
|
|
1261
1326
|
changes: {
|
|
1262
1327
|
from: t,
|
|
1263
1328
|
to: n,
|
|
1264
|
-
insert: `[${a}](${
|
|
1329
|
+
insert: `[${a}](${kn(i)})`
|
|
1265
1330
|
},
|
|
1266
1331
|
selection: {
|
|
1267
1332
|
anchor: t + 1,
|
|
@@ -1269,7 +1334,7 @@ var On = {
|
|
|
1269
1334
|
}
|
|
1270
1335
|
}), e.focus();
|
|
1271
1336
|
}
|
|
1272
|
-
},
|
|
1337
|
+
}, Pn = {
|
|
1273
1338
|
icon: S.wikilink,
|
|
1274
1339
|
placeholder: "note or path",
|
|
1275
1340
|
editLabel: "Edit link",
|
|
@@ -1298,27 +1363,27 @@ var On = {
|
|
|
1298
1363
|
}), e.focus();
|
|
1299
1364
|
}
|
|
1300
1365
|
};
|
|
1301
|
-
function
|
|
1302
|
-
return
|
|
1366
|
+
function Fn(e) {
|
|
1367
|
+
return Mn(e, Nn);
|
|
1303
1368
|
}
|
|
1304
|
-
function
|
|
1305
|
-
return
|
|
1369
|
+
function In(e) {
|
|
1370
|
+
return Mn(e, Pn);
|
|
1306
1371
|
}
|
|
1307
1372
|
//#endregion
|
|
1308
1373
|
//#region src/inplace/context-menu-shell.ts
|
|
1309
|
-
function
|
|
1374
|
+
function Ln(e, t, n, r) {
|
|
1310
1375
|
let i = r?.innerWidth ?? 0, a = r?.innerHeight ?? 0;
|
|
1311
1376
|
e.style.left = "0", e.style.top = "0";
|
|
1312
1377
|
let { width: o, height: s } = e.getBoundingClientRect();
|
|
1313
1378
|
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`;
|
|
1314
1379
|
}
|
|
1315
|
-
function
|
|
1380
|
+
function Rn(e, t, n) {
|
|
1316
1381
|
let r = n?.innerWidth ?? 0, i = n?.innerHeight ?? 0;
|
|
1317
1382
|
e.style.left = "0", e.style.top = "0";
|
|
1318
1383
|
let { width: a, height: o } = e.getBoundingClientRect(), s = t.right - 4, c = s + a > r - 4 ? t.left - a + 4 : s;
|
|
1319
1384
|
e.style.left = `${Math.max(4, c)}px`, e.style.top = `${Math.max(4, Math.min(t.top - 4, i - o - 4))}px`;
|
|
1320
1385
|
}
|
|
1321
|
-
function
|
|
1386
|
+
function zn(e, t, n, r = 350) {
|
|
1322
1387
|
let i = Date.now(), a = (e) => !t.contains(e.target), o = (e) => {
|
|
1323
1388
|
a(e) && n();
|
|
1324
1389
|
}, s = (e) => {
|
|
@@ -1332,10 +1397,10 @@ function Pn(e, t, n, r = 350) {
|
|
|
1332
1397
|
}
|
|
1333
1398
|
//#endregion
|
|
1334
1399
|
//#region src/inplace/context-menu-types.ts
|
|
1335
|
-
var
|
|
1400
|
+
var Bn = (e) => typeof e != "string" && "rows" in e, Vn = (e) => typeof e != "string" && "field" in e;
|
|
1336
1401
|
//#endregion
|
|
1337
1402
|
//#region src/inplace/context-menu.ts
|
|
1338
|
-
function
|
|
1403
|
+
function Q(e, t = "cm-inplace-menu", n) {
|
|
1339
1404
|
let r = e.defaultView, i = e.createElement("div");
|
|
1340
1405
|
i.className = t, i.setAttribute("contenteditable", "false"), i.hidden = !0;
|
|
1341
1406
|
let a = null, o = null, s = () => {
|
|
@@ -1345,7 +1410,7 @@ function Z(e, t = "cm-inplace-menu", n) {
|
|
|
1345
1410
|
}, l = (e) => e.addEventListener("mousedown", (e) => {
|
|
1346
1411
|
e.preventDefault(), e.stopPropagation();
|
|
1347
1412
|
}), u = (t, n, r, i) => {
|
|
1348
|
-
i ? t.appendChild(i.cloneNode(!0)) : r && t.appendChild(
|
|
1413
|
+
i ? t.appendChild(i.cloneNode(!0)) : r && t.appendChild(x(e, r));
|
|
1349
1414
|
let a = e.createElement("span");
|
|
1350
1415
|
a.textContent = n, t.appendChild(a);
|
|
1351
1416
|
}, d = (n) => {
|
|
@@ -1363,7 +1428,7 @@ function Z(e, t = "cm-inplace-menu", n) {
|
|
|
1363
1428
|
if (a?.dataset.for === n) return;
|
|
1364
1429
|
s();
|
|
1365
1430
|
let e = c();
|
|
1366
|
-
e.dataset.for = n, i.appendChild(e),
|
|
1431
|
+
e.dataset.for = n, i.appendChild(e), Rn(e, f.getBoundingClientRect(), r), a = e, e.querySelector("input")?.focus({ preventScroll: !0 });
|
|
1367
1432
|
};
|
|
1368
1433
|
return f.addEventListener("pointerenter", p), f.addEventListener("click", (e) => {
|
|
1369
1434
|
e.stopPropagation(), p();
|
|
@@ -1386,7 +1451,7 @@ function Z(e, t = "cm-inplace-menu", n) {
|
|
|
1386
1451
|
for (let i of n) if (i === "separator") {
|
|
1387
1452
|
let n = e.createElement("div");
|
|
1388
1453
|
n.className = `${t}-sep`, r.appendChild(n);
|
|
1389
|
-
} else
|
|
1454
|
+
} else Bn(i) ? r.appendChild(f(i.label, i.icon, () => m(i.rows), i.disabled)) : Vn(i) ? r.appendChild(f(i.label, i.icon, () => p(i))) : r.appendChild(d(i));
|
|
1390
1455
|
return r;
|
|
1391
1456
|
};
|
|
1392
1457
|
return {
|
|
@@ -1397,12 +1462,12 @@ function Z(e, t = "cm-inplace-menu", n) {
|
|
|
1397
1462
|
show: (t, a, s) => {
|
|
1398
1463
|
c();
|
|
1399
1464
|
let l = m(t);
|
|
1400
|
-
i.appendChild(l), i.hidden = !1,
|
|
1465
|
+
i.appendChild(l), i.hidden = !1, Ln(l, a, s, r), o = zn(e, i, c), n?.(!0);
|
|
1401
1466
|
},
|
|
1402
1467
|
showField: (t, a, s) => {
|
|
1403
1468
|
c();
|
|
1404
1469
|
let l = p(t);
|
|
1405
|
-
i.appendChild(l), i.hidden = !1,
|
|
1470
|
+
i.appendChild(l), i.hidden = !1, Ln(l, a, s, r), l.querySelector("input")?.focus({ preventScroll: !0 }), o = zn(e, i, c), n?.(!0);
|
|
1406
1471
|
},
|
|
1407
1472
|
hide: c,
|
|
1408
1473
|
destroy: () => {
|
|
@@ -1412,8 +1477,8 @@ function Z(e, t = "cm-inplace-menu", n) {
|
|
|
1412
1477
|
}
|
|
1413
1478
|
//#endregion
|
|
1414
1479
|
//#region src/inplace/math-edit.ts
|
|
1415
|
-
function
|
|
1416
|
-
let { state: t } = e, n = t.selection.main, r = t.doc.lineAt(n.head), i =
|
|
1480
|
+
function Hn(e) {
|
|
1481
|
+
let { state: t } = e, n = t.selection.main, r = t.doc.lineAt(n.head), i = Ze(r.text, n.head - r.from);
|
|
1417
1482
|
if (i) {
|
|
1418
1483
|
let t = r.from + i.from, n = r.from + i.to, a = i.block ? "$$" : "$";
|
|
1419
1484
|
return {
|
|
@@ -1471,27 +1536,27 @@ function Ln(e) {
|
|
|
1471
1536
|
}
|
|
1472
1537
|
};
|
|
1473
1538
|
}
|
|
1474
|
-
var
|
|
1539
|
+
var Un = class {
|
|
1475
1540
|
menu;
|
|
1476
1541
|
contentDOM;
|
|
1477
1542
|
onClick;
|
|
1478
1543
|
constructor(e) {
|
|
1479
|
-
this.menu =
|
|
1480
|
-
if (!e.state.facet(
|
|
1544
|
+
this.menu = Q(e.dom.ownerDocument), e.dom.appendChild(this.menu.el), this.contentDOM = e.contentDOM, this.onClick = (t) => {
|
|
1545
|
+
if (!e.state.facet(F).math) return;
|
|
1481
1546
|
let n = t.target?.closest(".cm-inplace-math");
|
|
1482
1547
|
if (!n) return;
|
|
1483
1548
|
let r = e.posAtDOM(n);
|
|
1484
1549
|
if (r < 0) return;
|
|
1485
1550
|
let i = e.state.doc.lineAt(r);
|
|
1486
|
-
|
|
1551
|
+
Ze(i.text, r - i.from) && (e.dispatch({ selection: { anchor: r } }), this.menu.showField(Hn(e), t.clientX, t.clientY));
|
|
1487
1552
|
}, this.contentDOM.addEventListener("click", this.onClick);
|
|
1488
1553
|
}
|
|
1489
1554
|
destroy() {
|
|
1490
1555
|
this.contentDOM.removeEventListener("click", this.onClick), this.menu.destroy();
|
|
1491
1556
|
}
|
|
1492
|
-
},
|
|
1493
|
-
if (!e.state.facet(
|
|
1494
|
-
let n = e.state.doc.lineAt(t), r =
|
|
1557
|
+
}, Wn = O.fromClass(Un), Gn = _e((e, t) => {
|
|
1558
|
+
if (!e.state.facet(F).math) return null;
|
|
1559
|
+
let n = e.state.doc.lineAt(t), r = Ze(n.text, t - n.from);
|
|
1495
1560
|
return r ? {
|
|
1496
1561
|
pos: n.from + r.from,
|
|
1497
1562
|
end: n.from + r.to,
|
|
@@ -1504,13 +1569,13 @@ var Rn = class {
|
|
|
1504
1569
|
});
|
|
1505
1570
|
//#endregion
|
|
1506
1571
|
//#region src/inplace/context-menu-actions.ts
|
|
1507
|
-
function
|
|
1572
|
+
function Kn(e) {
|
|
1508
1573
|
let t = h(e);
|
|
1509
1574
|
if (!t) return !1;
|
|
1510
1575
|
let { from: n, to: i } = r(t);
|
|
1511
1576
|
return i > n;
|
|
1512
1577
|
}
|
|
1513
|
-
function
|
|
1578
|
+
function qn(e) {
|
|
1514
1579
|
let t = ie(e.state);
|
|
1515
1580
|
return {
|
|
1516
1581
|
field: !0,
|
|
@@ -1533,49 +1598,49 @@ function Hn(e) {
|
|
|
1533
1598
|
}]
|
|
1534
1599
|
};
|
|
1535
1600
|
}
|
|
1536
|
-
var
|
|
1537
|
-
...
|
|
1601
|
+
var Jn = (e, t = !1) => [
|
|
1602
|
+
...K(e, Zt, !1, t),
|
|
1538
1603
|
"separator",
|
|
1539
|
-
...t ?
|
|
1604
|
+
...t ? K(e, Qt, !1, !0) : [rn(e, "code", !1), Hn(e)]
|
|
1540
1605
|
];
|
|
1541
|
-
function
|
|
1542
|
-
let n = e.state.facet(
|
|
1543
|
-
return
|
|
1606
|
+
function Yn(e, t) {
|
|
1607
|
+
let n = e.state.facet(B), r = t ?? h(e), i = Kn(e) && r === h(e), a = [];
|
|
1608
|
+
return Y(a, On(e, {
|
|
1544
1609
|
selected: i,
|
|
1545
|
-
prepare: () => r &&
|
|
1546
|
-
rect: () =>
|
|
1547
|
-
})), i ? (n.includes("format") &&
|
|
1610
|
+
prepare: () => r && bn(e, r, i),
|
|
1611
|
+
rect: () => Cn(r, i)
|
|
1612
|
+
})), i ? (n.includes("format") && Y(a, [J("Format", S.format, Jn(e, !0))]), n.includes("clipboard") && Y(a, q(e)), a) : a;
|
|
1548
1613
|
}
|
|
1549
|
-
var
|
|
1550
|
-
...
|
|
1614
|
+
var Xn = (e) => [
|
|
1615
|
+
...K(e, $t),
|
|
1551
1616
|
"separator",
|
|
1552
|
-
...
|
|
1617
|
+
...K(e, [...en, "body"]),
|
|
1553
1618
|
"separator",
|
|
1554
|
-
...
|
|
1555
|
-
],
|
|
1556
|
-
...
|
|
1619
|
+
...K(e, ["quote"])
|
|
1620
|
+
], Zn = (e) => [
|
|
1621
|
+
...K(e, tn),
|
|
1557
1622
|
"separator",
|
|
1558
|
-
...
|
|
1623
|
+
...K(e, nn)
|
|
1559
1624
|
];
|
|
1560
|
-
function
|
|
1561
|
-
let { state: t } = e, n = t.facet(
|
|
1562
|
-
if (
|
|
1563
|
-
let i =
|
|
1625
|
+
function Qn(e) {
|
|
1626
|
+
let { state: t } = e, n = t.facet(B), r = (e) => n.includes(e);
|
|
1627
|
+
if (Kn(e)) return Yn(e);
|
|
1628
|
+
let i = On(e, { selected: !t.selection.main.empty });
|
|
1564
1629
|
if (ee(t)) {
|
|
1565
1630
|
let t = [];
|
|
1566
|
-
return
|
|
1631
|
+
return Y(t, i), Y(t, [qn(e)]), r("clipboard") && Y(t, q(e)), t;
|
|
1567
1632
|
}
|
|
1568
|
-
if (
|
|
1633
|
+
if (an(t)) {
|
|
1569
1634
|
let t = [];
|
|
1570
|
-
return
|
|
1635
|
+
return Y(t, i), Y(t, [cn(e)]), r("clipboard") && Y(t, q(e)), t;
|
|
1571
1636
|
}
|
|
1572
|
-
let a = t.selection.main, o = t.doc.lineAt(a.head).text.trim() === "", s = !a.empty || !!t.wordAt(a.head), c = t.facet(
|
|
1573
|
-
for (let t of n) t === "host" ?
|
|
1637
|
+
let a = t.selection.main, o = t.doc.lineAt(a.head).text.trim() === "", s = !a.empty || !!t.wordAt(a.head), c = t.facet(Be) === "menu", l = [];
|
|
1638
|
+
for (let t of n) t === "host" ? Y(l, i) : t === "link" && c ? Y(l, [In(e), Fn(e)]) : t === "format" && c ? Y(l, [J("Format", S.format, Jn(e), !s)]) : t === "paragraph" ? Y(l, [J("Paragraph", S.paragraph, Xn(e))]) : t === "insert" ? Y(l, [J("Insert", S.insert, Zn(e), !o)]) : t === "clipboard" && Y(l, q(e));
|
|
1574
1639
|
return l;
|
|
1575
1640
|
}
|
|
1576
1641
|
//#endregion
|
|
1577
1642
|
//#region src/inplace/long-press.ts
|
|
1578
|
-
function
|
|
1643
|
+
function $n(e, t) {
|
|
1579
1644
|
let n = t.delay ?? 450, r = t.slop ?? 20, i = null, a = 0, o = 0, s = () => {
|
|
1580
1645
|
i != null && (clearTimeout(i), i = null);
|
|
1581
1646
|
}, c = (e) => {
|
|
@@ -1597,10 +1662,10 @@ function Jn(e, t) {
|
|
|
1597
1662
|
}
|
|
1598
1663
|
//#endregion
|
|
1599
1664
|
//#region src/inplace/table-gizmos.ts
|
|
1600
|
-
function
|
|
1665
|
+
function er(e, t) {
|
|
1601
1666
|
let n = e.createElement("div");
|
|
1602
1667
|
n.className = "cm-inplace-table-gizmos", n.setAttribute("contenteditable", "false");
|
|
1603
|
-
let r =
|
|
1668
|
+
let r = Q(e), i = (t, n, r) => {
|
|
1604
1669
|
let i = e.createElement("button");
|
|
1605
1670
|
return i.type = "button", i.className = t, i.setAttribute("aria-label", n), i.addEventListener("mousedown", (e) => {
|
|
1606
1671
|
e.preventDefault(), e.stopPropagation();
|
|
@@ -1683,7 +1748,7 @@ function Yn(e, t) {
|
|
|
1683
1748
|
}
|
|
1684
1749
|
//#endregion
|
|
1685
1750
|
//#region src/inplace/table-widget-keys.ts
|
|
1686
|
-
function
|
|
1751
|
+
function tr(e, t, n) {
|
|
1687
1752
|
let r = e.target.closest("td, th");
|
|
1688
1753
|
if (!r) return;
|
|
1689
1754
|
if (l(e, r)) {
|
|
@@ -1752,61 +1817,61 @@ function Xn(e, t, n) {
|
|
|
1752
1817
|
}
|
|
1753
1818
|
//#endregion
|
|
1754
1819
|
//#region src/inplace/table-widget-render.ts
|
|
1755
|
-
var
|
|
1756
|
-
function
|
|
1820
|
+
var nr = /* @__PURE__ */ new WeakMap(), rr = (e) => JSON.stringify(e), ir = (e, t) => (nr.get(e)?.sig ?? "null") === rr(t);
|
|
1821
|
+
function ar(e, t, n) {
|
|
1757
1822
|
let r = Number(e.dataset.r), i = Number(e.dataset.c), a = t.rows[r]?.[i] ?? "";
|
|
1758
|
-
e.replaceChildren(n ? e.ownerDocument.createTextNode(a) :
|
|
1759
|
-
let o =
|
|
1823
|
+
e.replaceChildren(n ? e.ownerDocument.createTextNode(a) : ln(c(a), t.embeds));
|
|
1824
|
+
let o = nr.get(e);
|
|
1760
1825
|
o && e.classList.remove(...o.cellClass);
|
|
1761
1826
|
let s = t.paintOf?.(r, i) ?? null;
|
|
1762
|
-
s && (
|
|
1763
|
-
sig:
|
|
1827
|
+
s && (Jt(e, a, s, n), e.classList.add(...s.cellClass)), nr.set(e, {
|
|
1828
|
+
sig: rr(s),
|
|
1764
1829
|
cellClass: s?.cellClass ?? []
|
|
1765
1830
|
});
|
|
1766
1831
|
}
|
|
1767
|
-
function
|
|
1832
|
+
function or(e, t, n, r) {
|
|
1768
1833
|
let i = document.createElement(r ? "th" : "td");
|
|
1769
1834
|
i.className = "cm-inplace-tcell", i.setAttribute("contenteditable", "true"), i.dataset.r = String(t), i.dataset.c = String(n);
|
|
1770
1835
|
let a = e.aligns[n];
|
|
1771
|
-
return a && (i.style.textAlign = a),
|
|
1836
|
+
return a && (i.style.textAlign = a), ar(i, e, !1), i;
|
|
1772
1837
|
}
|
|
1773
|
-
function
|
|
1838
|
+
function sr(e, t) {
|
|
1774
1839
|
e.replaceChildren();
|
|
1775
1840
|
let n = t.aligns.length, r = e.createTHead().insertRow();
|
|
1776
|
-
for (let e = 0; e < n; e++) r.appendChild(
|
|
1841
|
+
for (let e = 0; e < n; e++) r.appendChild(or(t, 0, e, !0));
|
|
1777
1842
|
let i = e.createTBody();
|
|
1778
1843
|
for (let e = 1; e < t.rows.length; e++) {
|
|
1779
1844
|
let r = i.insertRow();
|
|
1780
|
-
for (let i = 0; i < n; i++) r.appendChild(
|
|
1845
|
+
for (let i = 0; i < n; i++) r.appendChild(or(t, e, i, !1));
|
|
1781
1846
|
}
|
|
1782
1847
|
}
|
|
1783
1848
|
//#endregion
|
|
1784
1849
|
//#region src/inplace/table-structure.ts
|
|
1785
|
-
var
|
|
1786
|
-
function
|
|
1787
|
-
let n = Math.max(0, Math.min(t,
|
|
1850
|
+
var $ = (e) => e.aligns.length;
|
|
1851
|
+
function cr(e, t) {
|
|
1852
|
+
let n = Math.max(0, Math.min(t, $(e)));
|
|
1788
1853
|
for (let t of e.rows) t.splice(n, 0, "");
|
|
1789
1854
|
e.aligns.splice(n, 0, "");
|
|
1790
1855
|
}
|
|
1791
|
-
function
|
|
1792
|
-
if (!(
|
|
1856
|
+
function lr(e, t) {
|
|
1857
|
+
if (!($(e) <= 1 || t < 0 || t >= $(e))) {
|
|
1793
1858
|
for (let n of e.rows) n.splice(t, 1);
|
|
1794
1859
|
e.aligns.splice(t, 1);
|
|
1795
1860
|
}
|
|
1796
1861
|
}
|
|
1797
|
-
function
|
|
1862
|
+
function ur(e, t) {
|
|
1798
1863
|
let n = Math.max(1, Math.min(t, e.rows.length));
|
|
1799
|
-
e.rows.splice(n, 0, Array(
|
|
1864
|
+
e.rows.splice(n, 0, Array($(e)).fill(""));
|
|
1800
1865
|
}
|
|
1801
|
-
function
|
|
1866
|
+
function dr(e, t) {
|
|
1802
1867
|
t <= 0 || t >= e.rows.length || e.rows.length <= 2 || e.rows.splice(t, 1);
|
|
1803
1868
|
}
|
|
1804
|
-
function
|
|
1805
|
-
t >= 0 && t <
|
|
1869
|
+
function fr(e, t, n) {
|
|
1870
|
+
t >= 0 && t < $(e) && (e.aligns[t] = n);
|
|
1806
1871
|
}
|
|
1807
1872
|
//#endregion
|
|
1808
1873
|
//#region src/inplace/table-widget.ts
|
|
1809
|
-
var
|
|
1874
|
+
var pr = xe.define(), mr = /* @__PURE__ */ new WeakMap(), hr = class extends k {
|
|
1810
1875
|
data;
|
|
1811
1876
|
embeds;
|
|
1812
1877
|
table = null;
|
|
@@ -1815,6 +1880,7 @@ var cr = Se.define(), lr = /* @__PURE__ */ new WeakMap(), ur = class extends k {
|
|
|
1815
1880
|
editing = null;
|
|
1816
1881
|
syncing = !1;
|
|
1817
1882
|
pendingOffset = null;
|
|
1883
|
+
pressOnMark = !1;
|
|
1818
1884
|
gizmos = null;
|
|
1819
1885
|
longPress = null;
|
|
1820
1886
|
longPressAt = 0;
|
|
@@ -1822,7 +1888,7 @@ var cr = Se.define(), lr = /* @__PURE__ */ new WeakMap(), ur = class extends k {
|
|
|
1822
1888
|
super(), this.data = e, this.embeds = t, this.rows = le(e);
|
|
1823
1889
|
}
|
|
1824
1890
|
eq(e) {
|
|
1825
|
-
return !this.table && JSON.stringify(
|
|
1891
|
+
return !this.table && JSON.stringify(ue(this.rows)) === JSON.stringify(ue(e.rows));
|
|
1826
1892
|
}
|
|
1827
1893
|
ignoreEvent() {
|
|
1828
1894
|
return !0;
|
|
@@ -1832,7 +1898,7 @@ var cr = Se.define(), lr = /* @__PURE__ */ new WeakMap(), ur = class extends k {
|
|
|
1832
1898
|
}
|
|
1833
1899
|
bounds(e) {
|
|
1834
1900
|
let t = e.posAtDOM(this.table), n = null;
|
|
1835
|
-
return e.state.field(
|
|
1901
|
+
return e.state.field(yn).between(t, t, (e, t) => (n = {
|
|
1836
1902
|
from: e,
|
|
1837
1903
|
to: t
|
|
1838
1904
|
}, !1)), n ?? e.state.doc.lineAt(t);
|
|
@@ -1846,7 +1912,7 @@ var cr = Se.define(), lr = /* @__PURE__ */ new WeakMap(), ur = class extends k {
|
|
|
1846
1912
|
c: Number(e.dataset.c)
|
|
1847
1913
|
};
|
|
1848
1914
|
}
|
|
1849
|
-
paintOf =
|
|
1915
|
+
paintOf = Yt({
|
|
1850
1916
|
view: () => this.view,
|
|
1851
1917
|
mounted: () => !!this.table?.isConnected,
|
|
1852
1918
|
from: (e) => this.bounds(e).from,
|
|
@@ -1861,19 +1927,19 @@ var cr = Se.define(), lr = /* @__PURE__ */ new WeakMap(), ur = class extends k {
|
|
|
1861
1927
|
};
|
|
1862
1928
|
}
|
|
1863
1929
|
paint(e, t) {
|
|
1864
|
-
|
|
1930
|
+
ar(e, this.grid(), t);
|
|
1865
1931
|
}
|
|
1866
1932
|
repaintMarks() {
|
|
1867
1933
|
for (let e of this.table?.querySelectorAll("td, th") ?? []) {
|
|
1868
1934
|
let { r: t, c: n } = this.coords(e);
|
|
1869
|
-
e !== this.editing &&
|
|
1935
|
+
e !== this.editing && !ir(e, this.paintOf(t, n)) && this.paint(e, !1);
|
|
1870
1936
|
}
|
|
1871
1937
|
}
|
|
1872
1938
|
renderCells() {
|
|
1873
|
-
|
|
1939
|
+
sr(this.table, this.grid());
|
|
1874
1940
|
}
|
|
1875
1941
|
appendRow() {
|
|
1876
|
-
|
|
1942
|
+
ur(this.model(), this.rows.length), this.renderCells(), this.gizmos?.layout(this.table);
|
|
1877
1943
|
}
|
|
1878
1944
|
model() {
|
|
1879
1945
|
return {
|
|
@@ -1884,7 +1950,7 @@ var cr = Se.define(), lr = /* @__PURE__ */ new WeakMap(), ur = class extends k {
|
|
|
1884
1950
|
runOp(e, t) {
|
|
1885
1951
|
if (!this.table) return;
|
|
1886
1952
|
let n = this.model();
|
|
1887
|
-
if (t.kind === "insertColumn" ?
|
|
1953
|
+
if (t.kind === "insertColumn" ? cr(n, t.at) : t.kind === "deleteColumn" ? lr(n, t.at) : t.kind === "insertRow" ? ur(n, t.at) : t.kind === "deleteRow" ? dr(n, t.at) : fr(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") {
|
|
1888
1954
|
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));
|
|
1889
1955
|
this.cellAt(e, n)?.focus();
|
|
1890
1956
|
}
|
|
@@ -1894,10 +1960,21 @@ var cr = Se.define(), lr = /* @__PURE__ */ new WeakMap(), ur = class extends k {
|
|
|
1894
1960
|
this.rows[n] && (this.rows[n][r] = (e.textContent ?? "").replace(/\r?\n/g, " ")), t || this.paint(e, !1);
|
|
1895
1961
|
}
|
|
1896
1962
|
onFocusIn(e) {
|
|
1897
|
-
let t = e.target
|
|
1898
|
-
if (
|
|
1899
|
-
let n =
|
|
1900
|
-
|
|
1963
|
+
let t = e.target;
|
|
1964
|
+
if (t.closest("[data-stylo-cell-widget]")) return;
|
|
1965
|
+
let n = t.closest("td, th");
|
|
1966
|
+
if (!(!n || n === this.editing)) {
|
|
1967
|
+
if (this.pressOnMark) {
|
|
1968
|
+
this.pressOnMark = !1, document.addEventListener("mouseup", () => setTimeout(() => this.enterCell(n)), { once: !0 });
|
|
1969
|
+
return;
|
|
1970
|
+
}
|
|
1971
|
+
this.enterCell(n);
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
enterCell(e) {
|
|
1975
|
+
if (!this.table?.contains(e) || e === this.editing) return;
|
|
1976
|
+
let t = this.pendingOffset ?? y(e);
|
|
1977
|
+
this.pendingOffset = null, this.editing && this.finish(this.editing, !1), this.editing = e, this.paint(e, !0), d(e, t);
|
|
1901
1978
|
}
|
|
1902
1979
|
onFocusOut(e) {
|
|
1903
1980
|
if (this.syncing || !this.editing) return;
|
|
@@ -1930,14 +2007,14 @@ var cr = Se.define(), lr = /* @__PURE__ */ new WeakMap(), ur = class extends k {
|
|
|
1930
2007
|
to: i,
|
|
1931
2008
|
insert: n
|
|
1932
2009
|
},
|
|
1933
|
-
annotations:
|
|
2010
|
+
annotations: pr.of(!0),
|
|
1934
2011
|
userEvent: "input"
|
|
1935
2012
|
}), this.syncing = !1, t && (this.writeCaret(t), requestAnimationFrame(() => {
|
|
1936
2013
|
this.table && t && this.writeCaret(t);
|
|
1937
2014
|
})));
|
|
1938
2015
|
}
|
|
1939
2016
|
onKey(e, t) {
|
|
1940
|
-
this.table &&
|
|
2017
|
+
this.table && tr(e, t, {
|
|
1941
2018
|
coords: (e) => this.coords(e),
|
|
1942
2019
|
rows: () => this.rows.length,
|
|
1943
2020
|
cols: () => this.cols(),
|
|
@@ -1960,22 +2037,25 @@ var cr = Se.define(), lr = /* @__PURE__ */ new WeakMap(), ur = class extends k {
|
|
|
1960
2037
|
openCellMenuAt(e, t, n, r) {
|
|
1961
2038
|
let i = r?.closest("td, th");
|
|
1962
2039
|
if (!i) return;
|
|
1963
|
-
this.editing === i && !
|
|
1964
|
-
let a =
|
|
2040
|
+
this.editing === i && !Kn(e) && s(i, t, n);
|
|
2041
|
+
let a = Yn(e, i);
|
|
1965
2042
|
this.gizmos?.openFor(i, t, n, a);
|
|
1966
2043
|
}
|
|
1967
2044
|
toDOM(e) {
|
|
1968
2045
|
let t = document.createElement("div");
|
|
1969
2046
|
t.className = "cm-inplace-table-wrap";
|
|
1970
2047
|
let n = document.createElement("table");
|
|
1971
|
-
this.table = n, this.view = e, this.editing = null,
|
|
2048
|
+
this.table = n, this.view = e, this.editing = null, mr.set(n, this), n.className = "cm-inplace-table cm-inplace-table-edit", this.renderCells(), e.requestMeasure({
|
|
1972
2049
|
read: () => null,
|
|
1973
2050
|
write: () => this.repaintMarks(),
|
|
1974
2051
|
key: this
|
|
1975
2052
|
}), n.addEventListener("mousedown", (e) => {
|
|
1976
|
-
e.stopPropagation()
|
|
2053
|
+
if (e.stopPropagation(), e.target.closest("[data-stylo-cell-widget]")) {
|
|
2054
|
+
e.preventDefault();
|
|
2055
|
+
return;
|
|
2056
|
+
}
|
|
1977
2057
|
let t = e.target.closest("td, th");
|
|
1978
|
-
this.pendingOffset = t && t !== this.editing ?
|
|
2058
|
+
this.pendingOffset = t && t !== this.editing ? b(t, e.clientX, e.clientY) : null, this.pressOnMark = !!e.target.closest("[data-stylo-cell-mark]");
|
|
1979
2059
|
}), n.addEventListener("focusin", (e) => this.onFocusIn(e)), n.addEventListener("focusout", (e) => this.onFocusOut(e));
|
|
1980
2060
|
let r = (t) => {
|
|
1981
2061
|
t && (this.editing = t, this.finish(t, !0), this.sync(e));
|
|
@@ -1988,9 +2068,9 @@ var cr = Se.define(), lr = /* @__PURE__ */ new WeakMap(), ur = class extends k {
|
|
|
1988
2068
|
document.execCommand("insertText", !1, t);
|
|
1989
2069
|
}), n.addEventListener("contextmenu", (t) => {
|
|
1990
2070
|
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));
|
|
1991
|
-
}), this.longPress =
|
|
2071
|
+
}), this.longPress = $n(n, { onLongPress: (t, n, r) => {
|
|
1992
2072
|
this.longPressAt = Date.now(), this.openCellMenuAt(e, t, n, r);
|
|
1993
|
-
} }), this.gizmos =
|
|
2073
|
+
} }), this.gizmos = er(document, {
|
|
1994
2074
|
dims: () => ({
|
|
1995
2075
|
cols: this.cols(),
|
|
1996
2076
|
rows: this.rows.length,
|
|
@@ -2002,12 +2082,12 @@ var cr = Se.define(), lr = /* @__PURE__ */ new WeakMap(), ur = class extends k {
|
|
|
2002
2082
|
destroy() {
|
|
2003
2083
|
this.longPress?.dispose(), this.longPress = null, this.gizmos?.destroy(), this.gizmos = null, this.table = null, this.view = null, this.editing = null;
|
|
2004
2084
|
}
|
|
2005
|
-
},
|
|
2085
|
+
}, gr = /* @__PURE__ */ new Set([
|
|
2006
2086
|
"-",
|
|
2007
2087
|
"*",
|
|
2008
2088
|
"_"
|
|
2009
|
-
]),
|
|
2010
|
-
if (!e.docChanged || e.isUserEvent("undo") || e.isUserEvent("redo") || e.annotation(
|
|
2089
|
+
]), _r = Ce.transactionFilter.of((e) => {
|
|
2090
|
+
if (!e.docChanged || e.isUserEvent("undo") || e.isUserEvent("redo") || e.annotation(pr) || !e.startState.selection.main.empty) return e;
|
|
2011
2091
|
let t = e.startState.selection.main.head, n = "", r = 0;
|
|
2012
2092
|
if (e.changes.iterChanges((e, i, a, o, s) => {
|
|
2013
2093
|
r += 1, e === i && e === t && (n = s.toString());
|
|
@@ -2037,7 +2117,7 @@ var cr = Se.define(), lr = /* @__PURE__ */ new WeakMap(), ur = class extends k {
|
|
|
2037
2117
|
},
|
|
2038
2118
|
anchor: a + 1
|
|
2039
2119
|
};
|
|
2040
|
-
else if (
|
|
2120
|
+
else if (gr.has(n) && RegExp(`^\\${n}{3,}$`).test(s)) {
|
|
2041
2121
|
let e = o.number === 1 || i.line(o.number - 1).text.trim() === "", t = n === "-" && !e, r = o.number === i.lines;
|
|
2042
2122
|
if (t || r) {
|
|
2043
2123
|
let e = [];
|
|
@@ -2060,38 +2140,38 @@ var cr = Se.define(), lr = /* @__PURE__ */ new WeakMap(), ur = class extends k {
|
|
|
2060
2140
|
scrollIntoView: !0,
|
|
2061
2141
|
userEvent: "input.autoformat"
|
|
2062
2142
|
}] : e;
|
|
2063
|
-
}),
|
|
2143
|
+
}), vr = /* @__PURE__ */ new Set([
|
|
2064
2144
|
"EmphasisMark",
|
|
2065
2145
|
"CodeMark",
|
|
2066
2146
|
"StrikethroughMark"
|
|
2067
2147
|
]);
|
|
2068
|
-
function
|
|
2148
|
+
function yr(e, t, n) {
|
|
2069
2149
|
let r = t;
|
|
2070
2150
|
for (;;) {
|
|
2071
2151
|
let t = e.resolveInner(r, n);
|
|
2072
|
-
if (!
|
|
2152
|
+
if (!vr.has(t.name) || t.from >= t.to) return r;
|
|
2073
2153
|
let i = n < 0 ? t.from : t.to;
|
|
2074
2154
|
if (i === r) return r;
|
|
2075
2155
|
r = i;
|
|
2076
2156
|
}
|
|
2077
2157
|
}
|
|
2078
|
-
function
|
|
2079
|
-
let n =
|
|
2158
|
+
function br(e, t) {
|
|
2159
|
+
let n = W(e, t, !0);
|
|
2080
2160
|
if (!n) return t;
|
|
2081
|
-
let r =
|
|
2082
|
-
return t === n.contentTo ?
|
|
2161
|
+
let r = P(e);
|
|
2162
|
+
return t === n.contentTo ? yr(r, t, 1) : t === n.contentFrom ? yr(r, t, -1) : t;
|
|
2083
2163
|
}
|
|
2084
|
-
var
|
|
2085
|
-
if (!e.docChanged || e.isUserEvent("undo") || e.isUserEvent("redo") || e.annotation(
|
|
2164
|
+
var xr = Ce.transactionFilter.of((e) => {
|
|
2165
|
+
if (!e.docChanged || e.isUserEvent("undo") || e.isUserEvent("redo") || e.annotation(pr)) return e;
|
|
2086
2166
|
let t = e.startState, n = t.selection.main;
|
|
2087
|
-
if (!n.empty || !
|
|
2167
|
+
if (!n.empty || !U(t, t.doc.lineAt(n.head).number)) return e;
|
|
2088
2168
|
let r = [], i = 0;
|
|
2089
2169
|
e.changes.iterChanges((e, t, a, o, s) => {
|
|
2090
2170
|
i++, e === t && e === n.head && s.length > 0 && r.push(s.toString());
|
|
2091
2171
|
});
|
|
2092
2172
|
let a = r[0];
|
|
2093
2173
|
if (i !== 1 || a === void 0) return e;
|
|
2094
|
-
let o =
|
|
2174
|
+
let o = br(t, n.head);
|
|
2095
2175
|
return o === n.head ? e : {
|
|
2096
2176
|
changes: {
|
|
2097
2177
|
from: o,
|
|
@@ -2101,23 +2181,23 @@ var gr = we.transactionFilter.of((e) => {
|
|
|
2101
2181
|
scrollIntoView: !0,
|
|
2102
2182
|
userEvent: "input.type"
|
|
2103
2183
|
};
|
|
2104
|
-
}),
|
|
2105
|
-
function
|
|
2184
|
+
}), Sr = RegExp(`^(?:${se.match.source.replace(/^\^/, "")})+`);
|
|
2185
|
+
function Cr(e, t) {
|
|
2106
2186
|
let n = e.doc.lineAt(t).number;
|
|
2107
|
-
for (let r =
|
|
2187
|
+
for (let r = P(e).resolveInner(t, 1); r; r = r.parent) {
|
|
2108
2188
|
if (r.name !== "ListItem" || e.doc.lineAt(r.from).number === n) continue;
|
|
2109
2189
|
let t = u.exec(e.doc.lineAt(r.from).text);
|
|
2110
2190
|
if (t) return t[0].length;
|
|
2111
2191
|
}
|
|
2112
2192
|
return null;
|
|
2113
2193
|
}
|
|
2114
|
-
function
|
|
2115
|
-
let n = t.text, r =
|
|
2194
|
+
function wr(e, t) {
|
|
2195
|
+
let n = t.text, r = _.exec(n);
|
|
2116
2196
|
if (r) return {
|
|
2117
2197
|
prefixLen: r[0].length,
|
|
2118
2198
|
drop: [0, r[0].length]
|
|
2119
2199
|
};
|
|
2120
|
-
let i =
|
|
2200
|
+
let i = Sr.exec(n);
|
|
2121
2201
|
if (i) {
|
|
2122
2202
|
let e = se.match.exec(n)[0].length;
|
|
2123
2203
|
return {
|
|
@@ -2130,11 +2210,11 @@ function yr(e, t) {
|
|
|
2130
2210
|
prefixLen: a[0].length,
|
|
2131
2211
|
drop: [0, a[0].length]
|
|
2132
2212
|
};
|
|
2133
|
-
let o = te.match.exec(n) ??
|
|
2213
|
+
let o = te.match.exec(n) ?? ae.match.exec(n);
|
|
2134
2214
|
if (o) {
|
|
2135
2215
|
let n = o[1] ?? "", r = o[0].length - n.length;
|
|
2136
2216
|
if (n) {
|
|
2137
|
-
let r =
|
|
2217
|
+
let r = Cr(e, t.from) ?? 2, i = n.startsWith(" ") ? 1 : Math.min(r, n.length);
|
|
2138
2218
|
return {
|
|
2139
2219
|
prefixLen: o[0].length,
|
|
2140
2220
|
drop: [0, i]
|
|
@@ -2147,15 +2227,15 @@ function yr(e, t) {
|
|
|
2147
2227
|
}
|
|
2148
2228
|
return null;
|
|
2149
2229
|
}
|
|
2150
|
-
var
|
|
2230
|
+
var Tr = M.high(A.of([{
|
|
2151
2231
|
key: "Backspace",
|
|
2152
2232
|
run: (e) => {
|
|
2153
2233
|
if (h(e)) return !1;
|
|
2154
2234
|
let { state: t } = e, n = t.selection.main;
|
|
2155
2235
|
if (!n.empty) return !1;
|
|
2156
2236
|
let r = t.doc.lineAt(n.head);
|
|
2157
|
-
if (!
|
|
2158
|
-
let i =
|
|
2237
|
+
if (!U(t, r.number)) return !1;
|
|
2238
|
+
let i = wr(t, r);
|
|
2159
2239
|
if (!i || n.head < r.from || n.head > r.from + i.prefixLen) return !1;
|
|
2160
2240
|
let [a, o] = i.drop;
|
|
2161
2241
|
return e.dispatch({
|
|
@@ -2169,13 +2249,13 @@ var br = j.high(ve.of([{
|
|
|
2169
2249
|
scrollIntoView: !0
|
|
2170
2250
|
}), !0;
|
|
2171
2251
|
}
|
|
2172
|
-
}])),
|
|
2252
|
+
}])), Er = class {
|
|
2173
2253
|
menu;
|
|
2174
2254
|
contentDOM;
|
|
2175
2255
|
onClick;
|
|
2176
2256
|
constructor(e) {
|
|
2177
|
-
this.menu =
|
|
2178
|
-
if (e.state.facet(
|
|
2257
|
+
this.menu = Q(e.dom.ownerDocument), e.dom.appendChild(this.menu.el), this.contentDOM = e.contentDOM, this.onClick = (t) => {
|
|
2258
|
+
if (e.state.facet(R) !== "never" || !e.state.facet(F).links) return;
|
|
2179
2259
|
let n = t.target?.closest(".cm-inplace-link");
|
|
2180
2260
|
if (!n || n.classList.contains("cm-inplace-wikilink")) return;
|
|
2181
2261
|
let r = e.posAtDOM(n);
|
|
@@ -2187,13 +2267,13 @@ var br = j.high(ve.of([{
|
|
|
2187
2267
|
if (n == null) return;
|
|
2188
2268
|
r = n;
|
|
2189
2269
|
}
|
|
2190
|
-
e.dispatch({ selection: { anchor: r } }), this.menu.showField(
|
|
2270
|
+
e.dispatch({ selection: { anchor: r } }), this.menu.showField(Fn(e), t.clientX, t.clientY);
|
|
2191
2271
|
}, this.contentDOM.addEventListener("click", this.onClick);
|
|
2192
2272
|
}
|
|
2193
2273
|
destroy() {
|
|
2194
2274
|
this.contentDOM.removeEventListener("click", this.onClick), this.menu.destroy();
|
|
2195
2275
|
}
|
|
2196
|
-
},
|
|
2276
|
+
}, Dr = O.fromClass(Er), Or = (e) => e.replace(/^<([^]*)>$/, "$1").trim(), kr = (e, t, n) => n ? {
|
|
2197
2277
|
pos: e,
|
|
2198
2278
|
end: t,
|
|
2199
2279
|
above: !0,
|
|
@@ -2202,27 +2282,27 @@ var br = j.high(ve.of([{
|
|
|
2202
2282
|
return e.className = "cm-inplace-href-tip", e.textContent = n, { dom: e };
|
|
2203
2283
|
}
|
|
2204
2284
|
} : null;
|
|
2205
|
-
function
|
|
2206
|
-
for (let n =
|
|
2285
|
+
function Ar(e, t) {
|
|
2286
|
+
for (let n = P(e.state).resolveInner(t, -1); n; n = n.parent) {
|
|
2207
2287
|
if (n.name !== "Link") continue;
|
|
2208
2288
|
if (e.state.doc.sliceString(Math.max(0, n.from - 1), n.from) === "[") break;
|
|
2209
2289
|
let t = n.getChild("URL"), r = t ? e.state.sliceDoc(t.from, t.to) : e.state.sliceDoc(n.from, n.to);
|
|
2210
|
-
return
|
|
2290
|
+
return kr(n.from, n.to, Or(r));
|
|
2211
2291
|
}
|
|
2212
2292
|
return null;
|
|
2213
2293
|
}
|
|
2214
|
-
function
|
|
2294
|
+
function jr(t, n) {
|
|
2215
2295
|
let r = t.state.doc.lineAt(n);
|
|
2216
2296
|
for (let t of r.text.matchAll(e)) {
|
|
2217
2297
|
let e = r.from + (t.index ?? 0), i = e + t[0].length;
|
|
2218
|
-
if (!(n < e || n > i)) return
|
|
2298
|
+
if (!(n < e || n > i)) return kr(e, i, (t[1] ?? "").trim());
|
|
2219
2299
|
}
|
|
2220
2300
|
return null;
|
|
2221
2301
|
}
|
|
2222
|
-
var
|
|
2223
|
-
let n = e.state.facet(
|
|
2224
|
-
return (n.links ?
|
|
2225
|
-
}),
|
|
2302
|
+
var Mr = _e((e, t) => {
|
|
2303
|
+
let n = e.state.facet(F);
|
|
2304
|
+
return (n.links ? Ar(e, t) : null) ?? (n.wikilinks ? jr(e, t) : null);
|
|
2305
|
+
}), Nr = class extends k {
|
|
2226
2306
|
ref;
|
|
2227
2307
|
inline;
|
|
2228
2308
|
registry;
|
|
@@ -2249,19 +2329,19 @@ var Dr = _e((e, t) => {
|
|
|
2249
2329
|
return !1;
|
|
2250
2330
|
}
|
|
2251
2331
|
};
|
|
2252
|
-
function
|
|
2253
|
-
let t = e.facet(
|
|
2254
|
-
if (!t || !e.facet(
|
|
2255
|
-
let n =
|
|
2332
|
+
function Pr(e) {
|
|
2333
|
+
let t = e.facet(I);
|
|
2334
|
+
if (!t || !e.facet(F).embeds || !e.doc.toString().includes("![[")) return E.none;
|
|
2335
|
+
let n = V(e), r = P(e), i = [];
|
|
2256
2336
|
for (let a = 1; a <= e.doc.lines; a++) {
|
|
2257
2337
|
let o = e.doc.line(a);
|
|
2258
2338
|
if (!(!o.text.includes("![[") || n.has(a))) {
|
|
2259
2339
|
if (fe(o.text)) {
|
|
2260
2340
|
C.lastIndex = 0;
|
|
2261
2341
|
let e = (C.exec(o.text.trim())?.[1] ?? "").trim();
|
|
2262
|
-
if (!e ||
|
|
2342
|
+
if (!e || H(r, o.from + o.text.indexOf("!["))) continue;
|
|
2263
2343
|
i.push(E.replace({
|
|
2264
|
-
widget: new
|
|
2344
|
+
widget: new Nr(e, !1, t),
|
|
2265
2345
|
block: !0
|
|
2266
2346
|
}).range(o.from, o.to));
|
|
2267
2347
|
continue;
|
|
@@ -2271,30 +2351,30 @@ function kr(e) {
|
|
|
2271
2351
|
let n = (e[1] ?? "").trim();
|
|
2272
2352
|
if (!n) continue;
|
|
2273
2353
|
let a = o.from + (e.index ?? 0);
|
|
2274
|
-
|
|
2354
|
+
H(r, a + 2) || Ke(r, a + 2) || i.push(E.replace({ widget: new Nr(n, !0, t) }).range(a, a + e[0].length));
|
|
2275
2355
|
}
|
|
2276
2356
|
}
|
|
2277
2357
|
}
|
|
2278
2358
|
return E.set(i, !0);
|
|
2279
2359
|
}
|
|
2280
|
-
function
|
|
2360
|
+
function Fr(e, t) {
|
|
2281
2361
|
for (let n of t.ranges) {
|
|
2282
2362
|
let t = e.doc.lineAt(n.from).number, r = e.doc.lineAt(n.to).number;
|
|
2283
2363
|
for (let n = t; n <= r; n++) if (e.doc.line(n).text.includes("![[")) return !0;
|
|
2284
2364
|
}
|
|
2285
2365
|
return !1;
|
|
2286
2366
|
}
|
|
2287
|
-
var
|
|
2288
|
-
create:
|
|
2289
|
-
update: (e, t) => t.docChanged || t.selection && (
|
|
2367
|
+
var Ir = N.define({
|
|
2368
|
+
create: Pr,
|
|
2369
|
+
update: (e, t) => t.docChanged || t.selection && (Fr(t.state, t.startState.selection) || Fr(t.state, t.state.selection)) ? Pr(t.state) : e,
|
|
2290
2370
|
provide: (e) => [D.decorations.from(e), D.atomicRanges.of((t) => t.state.field(e))]
|
|
2291
|
-
}),
|
|
2371
|
+
}), Lr = we.define(), Rr = N.define({
|
|
2292
2372
|
create: () => !1,
|
|
2293
2373
|
update(e, t) {
|
|
2294
|
-
for (let n of t.effects) n.is(
|
|
2374
|
+
for (let n of t.effects) n.is(Lr) && (e = n.value);
|
|
2295
2375
|
return e;
|
|
2296
2376
|
}
|
|
2297
|
-
}),
|
|
2377
|
+
}), zr = class {
|
|
2298
2378
|
view;
|
|
2299
2379
|
menu;
|
|
2300
2380
|
onContextMenu;
|
|
@@ -2305,8 +2385,8 @@ var jr = M.define({
|
|
|
2305
2385
|
longPressAt = 0;
|
|
2306
2386
|
destroyed = !1;
|
|
2307
2387
|
constructor(e) {
|
|
2308
|
-
this.view = e, this.menu =
|
|
2309
|
-
this.destroyed || e.dispatch({ effects:
|
|
2388
|
+
this.view = e, this.menu = Q(e.dom.ownerDocument, "cm-inplace-menu", (t) => {
|
|
2389
|
+
this.destroyed || e.dispatch({ effects: Lr.of(t) });
|
|
2310
2390
|
}), e.dom.appendChild(this.menu.el), this.contentDOM = e.contentDOM, this.onPointerDown = () => {
|
|
2311
2391
|
let t = e.state.selection.main;
|
|
2312
2392
|
this.stashed = t.empty ? null : {
|
|
@@ -2316,17 +2396,17 @@ var jr = M.define({
|
|
|
2316
2396
|
}, this.contentDOM.addEventListener("pointerdown", this.onPointerDown, !0), this.onContextMenu = (e) => {
|
|
2317
2397
|
let t = e.target;
|
|
2318
2398
|
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()));
|
|
2319
|
-
}, this.contentDOM.addEventListener("contextmenu", this.onContextMenu), this.longPress =
|
|
2399
|
+
}, this.contentDOM.addEventListener("contextmenu", this.onContextMenu), this.longPress = $n(this.contentDOM, { onLongPress: (e, t, n) => {
|
|
2320
2400
|
this.longPressAt = Date.now(), this.openMenuAt(e, t, n);
|
|
2321
2401
|
} });
|
|
2322
2402
|
}
|
|
2323
2403
|
canOpen() {
|
|
2324
2404
|
let { state: e } = this.view;
|
|
2325
|
-
return e.facet(
|
|
2405
|
+
return e.facet(Me) && (!e.readOnly || Dn(this.view));
|
|
2326
2406
|
}
|
|
2327
2407
|
rows() {
|
|
2328
2408
|
let e = this.view;
|
|
2329
|
-
return e.state.readOnly ?
|
|
2409
|
+
return e.state.readOnly ? On(e, { selected: !e.state.selection.main.empty }) : Qn(e);
|
|
2330
2410
|
}
|
|
2331
2411
|
openMenuAt(e, t, n) {
|
|
2332
2412
|
let r = this.view;
|
|
@@ -2343,7 +2423,7 @@ var jr = M.define({
|
|
|
2343
2423
|
y: t
|
|
2344
2424
|
});
|
|
2345
2425
|
if (n != null) {
|
|
2346
|
-
let e =
|
|
2426
|
+
let e = W(r.state, n, !1, !0), t = r.state.wordAt(n) ?? { anchor: n };
|
|
2347
2427
|
e?.kind === "link" ? t = {
|
|
2348
2428
|
anchor: e.from,
|
|
2349
2429
|
head: e.to
|
|
@@ -2362,10 +2442,10 @@ var jr = M.define({
|
|
|
2362
2442
|
destroy() {
|
|
2363
2443
|
this.destroyed = !0, this.contentDOM.removeEventListener("pointerdown", this.onPointerDown, !0), this.contentDOM.removeEventListener("contextmenu", this.onContextMenu), this.longPress.dispose(), this.menu.destroy();
|
|
2364
2444
|
}
|
|
2365
|
-
},
|
|
2445
|
+
}, Br = O.fromClass(zr);
|
|
2366
2446
|
//#endregion
|
|
2367
2447
|
//#region src/inplace/selection-bar-position.ts
|
|
2368
|
-
function
|
|
2448
|
+
function Vr(e) {
|
|
2369
2449
|
let t = e.state.selection.main;
|
|
2370
2450
|
if (!t.empty) {
|
|
2371
2451
|
let n = e.coordsAtPos(t.from), r = e.coordsAtPos(t.to);
|
|
@@ -2379,7 +2459,7 @@ function Fr(e) {
|
|
|
2379
2459
|
}
|
|
2380
2460
|
};
|
|
2381
2461
|
}
|
|
2382
|
-
if (!
|
|
2462
|
+
if (!Kn(e)) return null;
|
|
2383
2463
|
let n = e.dom.ownerDocument.getSelection();
|
|
2384
2464
|
if (!n || n.rangeCount === 0) return null;
|
|
2385
2465
|
let r = n.getRangeAt(0).getBoundingClientRect();
|
|
@@ -2393,9 +2473,9 @@ function Fr(e) {
|
|
|
2393
2473
|
}
|
|
2394
2474
|
};
|
|
2395
2475
|
}
|
|
2396
|
-
function
|
|
2397
|
-
if (e.state.facet(
|
|
2398
|
-
let r =
|
|
2476
|
+
function Hr(e, t, n) {
|
|
2477
|
+
if (e.state.facet(Be) !== "bar" || e.state.readOnly || e.state.field(Rr, !1)) return null;
|
|
2478
|
+
let r = Vr(e);
|
|
2399
2479
|
if (!r) return null;
|
|
2400
2480
|
let { box: i, inCell: a } = r;
|
|
2401
2481
|
if (!a && !e.hasFocus) return null;
|
|
@@ -2413,7 +2493,7 @@ function Ir(e, t, n) {
|
|
|
2413
2493
|
}
|
|
2414
2494
|
//#endregion
|
|
2415
2495
|
//#region src/inplace/selection-bar.ts
|
|
2416
|
-
var
|
|
2496
|
+
var Ur = class {
|
|
2417
2497
|
view;
|
|
2418
2498
|
bar;
|
|
2419
2499
|
ids;
|
|
@@ -2428,12 +2508,12 @@ var Lr = class {
|
|
|
2428
2508
|
constructor(e) {
|
|
2429
2509
|
this.view = e;
|
|
2430
2510
|
let t = e.dom.ownerDocument;
|
|
2431
|
-
this.ids = e.state.facet(
|
|
2511
|
+
this.ids = e.state.facet(ze), this.linkMenu = Q(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;
|
|
2432
2512
|
for (let n of this.ids) {
|
|
2433
2513
|
let r = g[n], i = t.createElement("button");
|
|
2434
|
-
i.type = "button", i.className = "cm-inplace-selbar-btn", i.title = r.title, i.setAttribute("aria-label", r.title), i.appendChild(
|
|
2514
|
+
i.type = "button", i.className = "cm-inplace-selbar-btn", i.title = r.title, i.setAttribute("aria-label", r.title), i.appendChild(x(t, S[n] ?? "")), i.addEventListener("mousedown", (e) => e.preventDefault()), i.addEventListener("click", (t) => {
|
|
2435
2515
|
t.preventDefault();
|
|
2436
|
-
let a = !!h(e), o = !a && n === "link" ?
|
|
2516
|
+
let a = !!h(e), o = !a && n === "link" ? Fn(e) : !a && n === "wikilink" ? In(e) : null;
|
|
2437
2517
|
if (o) {
|
|
2438
2518
|
let e = i.getBoundingClientRect();
|
|
2439
2519
|
this.linkMenu.showField(o, e.left, e.bottom + 6);
|
|
@@ -2445,7 +2525,7 @@ var Lr = class {
|
|
|
2445
2525
|
e.dom.appendChild(this.bar), t.addEventListener("scroll", this.onScroll, !0), t.addEventListener("selectionchange", this.onSelectionChange);
|
|
2446
2526
|
}
|
|
2447
2527
|
update(e) {
|
|
2448
|
-
let t = e.startState.field(
|
|
2528
|
+
let t = e.startState.field(Rr, !1) !== e.state.field(Rr, !1), n = e.startState.readOnly !== e.state.readOnly;
|
|
2449
2529
|
(e.selectionSet || e.docChanged || e.focusChanged || t || n) && this.schedule();
|
|
2450
2530
|
}
|
|
2451
2531
|
schedule() {
|
|
@@ -2456,7 +2536,7 @@ var Lr = class {
|
|
|
2456
2536
|
});
|
|
2457
2537
|
}
|
|
2458
2538
|
measure() {
|
|
2459
|
-
return
|
|
2539
|
+
return Hr(this.view, this.bar, this.ids);
|
|
2460
2540
|
}
|
|
2461
2541
|
apply(e) {
|
|
2462
2542
|
if (!e) {
|
|
@@ -2470,42 +2550,46 @@ var Lr = class {
|
|
|
2470
2550
|
let e = this.view.dom.ownerDocument;
|
|
2471
2551
|
e.removeEventListener("scroll", this.onScroll, !0), e.removeEventListener("selectionchange", this.onSelectionChange), this.linkMenu.destroy(), this.bar.remove();
|
|
2472
2552
|
}
|
|
2473
|
-
},
|
|
2553
|
+
}, Wr = O.fromClass(Ur), Gr = (e) => (t) => {
|
|
2474
2554
|
if (h(t)) return !1;
|
|
2475
2555
|
let n = t.state.selection.main;
|
|
2476
2556
|
if (!n.empty) return !1;
|
|
2477
2557
|
let { doc: r } = t.state, i = r.lineAt(n.head), a = e ? i.number + 1 : i.number - 1;
|
|
2478
2558
|
if (a < 1 || a > r.lines) return !1;
|
|
2479
2559
|
let o = r.line(a), s = -1, c = -1, l;
|
|
2480
|
-
if (t.state.field(
|
|
2560
|
+
if (t.state.field(yn).between(o.from, o.to, (t, n, r) => {
|
|
2481
2561
|
if (e ? t === o.from : n === o.to) return s = t, c = n, l = r.spec.widget, !1;
|
|
2482
2562
|
}), s < 0) return !1;
|
|
2483
|
-
if (t.state.facet(
|
|
2563
|
+
if (t.state.facet(L) === "cells") return l instanceof hr && l.focusEdge(e ? "first" : "last");
|
|
2484
2564
|
let u = e ? r.lineAt(s).from : r.lineAt(c).to;
|
|
2485
2565
|
return t.dispatch({
|
|
2486
2566
|
selection: { anchor: u },
|
|
2487
2567
|
userEvent: "select",
|
|
2488
2568
|
scrollIntoView: !0
|
|
2489
2569
|
}), !0;
|
|
2490
|
-
},
|
|
2570
|
+
}, Kr = Gr(!0), qr = Gr(!1), Jr = M.high(A.of([{
|
|
2491
2571
|
key: "ArrowDown",
|
|
2492
|
-
run:
|
|
2572
|
+
run: Kr
|
|
2493
2573
|
}, {
|
|
2494
2574
|
key: "ArrowUp",
|
|
2495
|
-
run:
|
|
2496
|
-
}])),
|
|
2497
|
-
last =
|
|
2575
|
+
run: qr
|
|
2576
|
+
}])), Yr = "[[],[]]", Xr = O.fromClass(class {
|
|
2577
|
+
last = Yr;
|
|
2498
2578
|
update(e) {
|
|
2499
|
-
let t = JSON.stringify(
|
|
2500
|
-
|
|
2579
|
+
let { state: t } = e, n = JSON.stringify([t.facet(Ie)(t), t.facet(Le)(t).map((e) => [
|
|
2580
|
+
e.pos,
|
|
2581
|
+
e.key,
|
|
2582
|
+
e.cellClass
|
|
2583
|
+
])]);
|
|
2584
|
+
n === this.last && !e.docChanged || (n !== Yr || this.last !== Yr) && (this.last = n, e.view.requestMeasure({
|
|
2501
2585
|
read: () => null,
|
|
2502
2586
|
write: (e, t) => {
|
|
2503
|
-
for (let e of t.dom.querySelectorAll(".cm-inplace-table-edit"))
|
|
2587
|
+
for (let e of t.dom.querySelectorAll(".cm-inplace-table-edit")) mr.get(e)?.repaintMarks();
|
|
2504
2588
|
},
|
|
2505
2589
|
key: this
|
|
2506
2590
|
}));
|
|
2507
2591
|
}
|
|
2508
|
-
}),
|
|
2592
|
+
}), Zr = {
|
|
2509
2593
|
".cm-inplace-callout": {
|
|
2510
2594
|
borderLeft: "0.25rem solid var(--stylo-callout-accent, var(--stylo-border))",
|
|
2511
2595
|
padding: "0 var(--stylo-rhythm-callout-padding-x, 1rem)",
|
|
@@ -2539,9 +2623,9 @@ var Lr = class {
|
|
|
2539
2623
|
content: "\"\"",
|
|
2540
2624
|
display: "none"
|
|
2541
2625
|
}
|
|
2542
|
-
},
|
|
2626
|
+
}, Qr = "var(--stylo-font-family-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace)", $r = "var(--stylo-font-family, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif)", ei = {
|
|
2543
2627
|
"& .cm-content": {
|
|
2544
|
-
fontFamily:
|
|
2628
|
+
fontFamily: $r,
|
|
2545
2629
|
lineHeight: "1.75",
|
|
2546
2630
|
padding: "0.75rem",
|
|
2547
2631
|
WebkitTouchCallout: "none"
|
|
@@ -2584,14 +2668,14 @@ var Lr = class {
|
|
|
2584
2668
|
".cm-inplace-em": { fontStyle: "italic" },
|
|
2585
2669
|
".cm-inplace-strike": { textDecoration: "line-through" },
|
|
2586
2670
|
".cm-inplace-code": {
|
|
2587
|
-
fontFamily:
|
|
2671
|
+
fontFamily: Qr,
|
|
2588
2672
|
fontSize: "0.9em",
|
|
2589
2673
|
padding: "0.1em 0.35em",
|
|
2590
2674
|
borderRadius: "3px",
|
|
2591
2675
|
background: "color-mix(in srgb, var(--stylo-border) 45%, transparent)"
|
|
2592
2676
|
},
|
|
2593
2677
|
".cm-inplace-mono": {
|
|
2594
|
-
fontFamily:
|
|
2678
|
+
fontFamily: Qr,
|
|
2595
2679
|
fontSize: "0.9em",
|
|
2596
2680
|
background: "color-mix(in srgb, var(--stylo-border) 35%, transparent)",
|
|
2597
2681
|
padding: "0 0.9rem"
|
|
@@ -2669,21 +2753,21 @@ var Lr = class {
|
|
|
2669
2753
|
cursor: "pointer"
|
|
2670
2754
|
},
|
|
2671
2755
|
".cm-inplace-fm": {
|
|
2672
|
-
fontFamily:
|
|
2756
|
+
fontFamily: Qr,
|
|
2673
2757
|
fontSize: "0.85em",
|
|
2674
2758
|
color: "var(--stylo-text-muted)"
|
|
2675
2759
|
},
|
|
2676
2760
|
".cm-inplace-fm-first::before": {
|
|
2677
2761
|
content: "\"Frontmatter\"",
|
|
2678
2762
|
marginRight: "0.6em",
|
|
2679
|
-
fontFamily:
|
|
2763
|
+
fontFamily: $r,
|
|
2680
2764
|
fontSize: "0.8rem",
|
|
2681
2765
|
fontWeight: "600",
|
|
2682
2766
|
textTransform: "uppercase",
|
|
2683
2767
|
letterSpacing: "0.04em",
|
|
2684
2768
|
color: "var(--stylo-text-muted)"
|
|
2685
2769
|
}
|
|
2686
|
-
},
|
|
2770
|
+
}, ti = {
|
|
2687
2771
|
".cm-inplace-menu": {
|
|
2688
2772
|
position: "fixed",
|
|
2689
2773
|
inset: "0",
|
|
@@ -2757,7 +2841,7 @@ var Lr = class {
|
|
|
2757
2841
|
outline: "none"
|
|
2758
2842
|
},
|
|
2759
2843
|
".cm-inplace-menu-input:focus": { borderColor: "var(--stylo-ring)" }
|
|
2760
|
-
},
|
|
2844
|
+
}, ni = {
|
|
2761
2845
|
".cm-inplace-selbar": {
|
|
2762
2846
|
position: "fixed",
|
|
2763
2847
|
zIndex: "20",
|
|
@@ -2842,7 +2926,7 @@ var Lr = class {
|
|
|
2842
2926
|
lineHeight: "1.4",
|
|
2843
2927
|
wordBreak: "break-all"
|
|
2844
2928
|
}
|
|
2845
|
-
},
|
|
2929
|
+
}, ri = {
|
|
2846
2930
|
".cm-inplace-table": {
|
|
2847
2931
|
borderCollapse: "collapse",
|
|
2848
2932
|
padding: "1em 0 1.4em",
|
|
@@ -2865,7 +2949,7 @@ var Lr = class {
|
|
|
2865
2949
|
outline: "none"
|
|
2866
2950
|
},
|
|
2867
2951
|
".cm-inplace-table-edit .cm-inplace-tcell:focus": { boxShadow: "inset 0 0 0 2px var(--stylo-ring)" }
|
|
2868
|
-
},
|
|
2952
|
+
}, ii = {
|
|
2869
2953
|
".cm-inplace-table-wrap": {
|
|
2870
2954
|
position: "relative",
|
|
2871
2955
|
display: "inline-block",
|
|
@@ -2907,60 +2991,61 @@ var Lr = class {
|
|
|
2907
2991
|
},
|
|
2908
2992
|
".cm-inplace-tg-edge:hover .cm-inplace-tg-plus": { color: "var(--stylo-text)" },
|
|
2909
2993
|
"@media (hover: none)": { ".cm-inplace-tg-edge": { opacity: "0.5" } }
|
|
2910
|
-
},
|
|
2911
|
-
...
|
|
2912
|
-
...Wr,
|
|
2913
|
-
...Xr,
|
|
2994
|
+
}, ai = D.theme({
|
|
2995
|
+
...ei,
|
|
2914
2996
|
...Zr,
|
|
2915
|
-
...
|
|
2916
|
-
...
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2997
|
+
...ri,
|
|
2998
|
+
...ii,
|
|
2999
|
+
...ti,
|
|
3000
|
+
...ni
|
|
3001
|
+
}), oi = ".cm-inplace-math, .cm-inplace-hr, .cm-inplace-table, .cm-inplace-embed, .cm-inplace-embed-inline";
|
|
3002
|
+
function si(e = {}) {
|
|
3003
|
+
let t = Pe(e.inPlace?.contextMenu);
|
|
2920
3004
|
return [
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
Be.of(
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
Pr,
|
|
3005
|
+
F.of(Ae(e.inPlace)),
|
|
3006
|
+
I.of(e.embedRegistry ?? null),
|
|
3007
|
+
L.of(e.inPlace?.table ?? "source"),
|
|
3008
|
+
R.of(e.inPlace?.reveal ?? "caret"),
|
|
3009
|
+
je.of(e.onLinkClick ?? null),
|
|
3010
|
+
Me.of(t.enabled),
|
|
3011
|
+
B.of(t.groups),
|
|
3012
|
+
Fe.of(e.hostItems ?? (() => t.items)),
|
|
3013
|
+
Ie.of(e.cellMarks ?? e.inPlace?.cellMarks ?? (() => [])),
|
|
3014
|
+
Le.of(e.cellWidgets ?? e.inPlace?.cellWidgets ?? (() => [])),
|
|
3015
|
+
Be.of(e.inPlace?.selectionUI ?? "menu"),
|
|
3016
|
+
ze.of(Re(e.inPlace?.selectionBarItems)),
|
|
3017
|
+
Et(),
|
|
3018
|
+
Tr,
|
|
3019
|
+
sn,
|
|
3020
|
+
Lt,
|
|
3021
|
+
Jr,
|
|
3022
|
+
xr,
|
|
3023
|
+
_r,
|
|
3024
|
+
tt,
|
|
3025
|
+
Ir,
|
|
3026
|
+
He,
|
|
3027
|
+
yn,
|
|
3028
|
+
Xr,
|
|
2946
3029
|
Rr,
|
|
2947
|
-
|
|
3030
|
+
Br,
|
|
3031
|
+
Wr,
|
|
2948
3032
|
Dr,
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
3033
|
+
Mr,
|
|
3034
|
+
Wn,
|
|
3035
|
+
Gn,
|
|
3036
|
+
M.high(ai),
|
|
2952
3037
|
D.domEventHandlers({
|
|
2953
3038
|
mousedown(e, t) {
|
|
2954
3039
|
let n = e.target;
|
|
2955
3040
|
if (n?.closest(".cm-inplace-table-edit") || n?.closest(".stylo-embed-content")) return !1;
|
|
2956
|
-
let r = n?.closest(
|
|
3041
|
+
let r = n?.closest(oi);
|
|
2957
3042
|
if (!r) return !1;
|
|
2958
3043
|
let i = t.posAtDOM(r);
|
|
2959
3044
|
if (i < 0) return !1;
|
|
2960
3045
|
let a = n?.closest("[data-stylo-row]");
|
|
2961
3046
|
if (a && r.contains(a)) {
|
|
2962
3047
|
let n = v(t.state.doc, i, Number(a.dataset.styloRow), Number(a.dataset.styloCol));
|
|
2963
|
-
n != null && (i = n +
|
|
3048
|
+
n != null && (i = n + b(a, e.clientX, e.clientY));
|
|
2964
3049
|
}
|
|
2965
3050
|
return t.focus(), t.dispatch({ selection: { anchor: i } }), !0;
|
|
2966
3051
|
},
|
|
@@ -2974,8 +3059,8 @@ function ei(e = {}) {
|
|
|
2974
3059
|
}
|
|
2975
3060
|
//#endregion
|
|
2976
3061
|
//#region src/inplace/InPlaceView.tsx
|
|
2977
|
-
var
|
|
2978
|
-
function
|
|
3062
|
+
var ci = () => () => {}, li = () => null;
|
|
3063
|
+
function ui({ 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
3064
|
let te = w(a);
|
|
2980
3065
|
te.current = a;
|
|
2981
3066
|
let re = w(o);
|
|
@@ -2984,13 +3069,15 @@ function ri({ value: e, onChange: t, readOnly: r, placeholder: i, onWikiLinkClic
|
|
|
2984
3069
|
ie.current = s?.contextMenu;
|
|
2985
3070
|
let g = w(s?.cellMarks);
|
|
2986
3071
|
g.current = s?.cellMarks;
|
|
2987
|
-
let
|
|
2988
|
-
|
|
2989
|
-
let
|
|
2990
|
-
|
|
3072
|
+
let ae = w(s?.cellWidgets);
|
|
3073
|
+
ae.current = s?.cellWidgets;
|
|
3074
|
+
let [_] = T(() => new Oe()), oe = ge(_.subscribe, _.getSnapshot, _.getSnapshot), [se, v] = T(null), le = w(m);
|
|
3075
|
+
le.current = m;
|
|
3076
|
+
let ue = w((e) => {
|
|
3077
|
+
v(e), le.current?.(e);
|
|
2991
3078
|
}).current, y = w(h);
|
|
2992
3079
|
y.current = h;
|
|
2993
|
-
let [b] = T(() => h ? new ne() : null), x = ge(b?.subscribe ??
|
|
3080
|
+
let [b] = T(() => h ? new ne() : null), x = ge(b?.subscribe ?? ci, b?.getSnapshot ?? li), [S] = T(() => [si({
|
|
2994
3081
|
onWikiLinkClick: (e) => te.current?.(e),
|
|
2995
3082
|
onLinkClick: (e) => re.current?.(e),
|
|
2996
3083
|
inPlace: s,
|
|
@@ -2999,33 +3086,34 @@ function ri({ value: e, onChange: t, readOnly: r, placeholder: i, onWikiLinkClic
|
|
|
2999
3086
|
return typeof e == "object" ? e.items ?? [] : [];
|
|
3000
3087
|
},
|
|
3001
3088
|
cellMarks: (e) => g.current?.(e) ?? [],
|
|
3089
|
+
cellWidgets: (e) => ae.current?.(e) ?? [],
|
|
3002
3090
|
embedRegistry: d ? _ : void 0
|
|
3003
|
-
}), ...b ? [
|
|
3091
|
+
}), ...b ? [ve.of(b.panel)] : []]), de = ce({
|
|
3004
3092
|
value: e,
|
|
3005
3093
|
onChange: t,
|
|
3006
3094
|
readOnly: r,
|
|
3007
3095
|
placeholder: i,
|
|
3008
|
-
extensions:
|
|
3096
|
+
extensions: S,
|
|
3009
3097
|
codeLanguages: c,
|
|
3010
3098
|
wikiLinkSource: l,
|
|
3011
3099
|
tagSource: u,
|
|
3012
3100
|
onResolveError: f,
|
|
3013
3101
|
onSave: p,
|
|
3014
|
-
onViewChange:
|
|
3102
|
+
onViewChange: ue,
|
|
3015
3103
|
hostExtensions: ee
|
|
3016
3104
|
});
|
|
3017
|
-
return /* @__PURE__ */
|
|
3105
|
+
return /* @__PURE__ */ Ee("div", {
|
|
3018
3106
|
className: n.inplace,
|
|
3019
|
-
ref:
|
|
3020
|
-
children: [d &&
|
|
3107
|
+
ref: de,
|
|
3108
|
+
children: [d && oe.map((e) => ye(/* @__PURE__ */ Te(pe, {
|
|
3021
3109
|
reference: e.ref,
|
|
3022
3110
|
source: d,
|
|
3023
3111
|
onError: f,
|
|
3024
3112
|
inline: e.inline
|
|
3025
|
-
}), e.el, String(e.id))), x && y.current &&
|
|
3113
|
+
}), e.el, String(e.id))), x && y.current && ye(y.current({ view: se }), x)]
|
|
3026
3114
|
});
|
|
3027
3115
|
}
|
|
3028
3116
|
//#endregion
|
|
3029
|
-
export {
|
|
3117
|
+
export { ui as InPlaceView };
|
|
3030
3118
|
|
|
3031
|
-
//# sourceMappingURL=InPlaceView-
|
|
3119
|
+
//# sourceMappingURL=InPlaceView-BIdyqlek.js.map
|