@damiro/stylo 0.20.1 → 0.22.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-gei6uiAm.js → InPlaceView-CKPumo8B.js} +564 -455
- package/dist/InPlaceView-CKPumo8B.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-static-paint.d.ts +13 -0
- package/dist/inplace/table-static-paint.d.ts.map +1 -0
- package/dist/inplace/table-widget.d.ts.map +1 -1
- package/dist/inplace/tables.d.ts.map +1 -1
- package/dist/stylo.js +2 -2
- package/dist/types/inplace.d.ts +28 -2
- package/dist/types/inplace.d.ts.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/{useCodeMirror-DbhMZGZ7.js → useCodeMirror-O1ProA2R.js} +246 -234
- package/dist/useCodeMirror-O1ProA2R.js.map +1 -0
- package/package.json +1 -1
- package/dist/InPlaceView-gei6uiAm.js.map +0 -1
- package/dist/useCodeMirror-DbhMZGZ7.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
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
|
-
import { useRef as w, useState as
|
|
7
|
-
import { Decoration as
|
|
6
|
+
import { useRef as w, useState as ge, useSyncExternalStore as _e } from "react";
|
|
7
|
+
import { Decoration as T, EditorView as E, ViewPlugin as D, WidgetType as O, hoverTooltip as ve, keymap as k, showPanel as ye } from "@codemirror/view";
|
|
8
8
|
import { createPortal as be, flushSync as xe } from "react-dom";
|
|
9
9
|
import { Annotation as Se, EditorSelection as Ce, EditorState as we, Facet as A, Prec as j, StateEffect as Te, StateField as M } from "@codemirror/state";
|
|
10
10
|
import { syntaxTree as N } from "@codemirror/language";
|
|
@@ -86,7 +86,7 @@ function Fe(e) {
|
|
|
86
86
|
items: e.items ?? []
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
|
-
var Ie = A.define({ combine: (e) => e[0] ?? (() => []) }), Le = A.define({ combine: (e) => e[0] ?? (() => []) }), Re = A.define({ combine: (e) => e[0] ?? Pe });
|
|
89
|
+
var Ie = A.define({ combine: (e) => e[0] ?? (() => []) }), Le = A.define({ combine: (e) => e[0] ?? (() => []) }), Re = A.define({ combine: (e) => e[0] ?? (() => []) }), z = A.define({ combine: (e) => e[0] ?? Pe });
|
|
90
90
|
function ze(e) {
|
|
91
91
|
if (!e?.length) return R;
|
|
92
92
|
let t = e.filter((e) => R.includes(e));
|
|
@@ -96,23 +96,23 @@ var Be = A.define({ combine: (e) => e[0] ?? R }), Ve = A.define({ combine: (e) =
|
|
|
96
96
|
//#endregion
|
|
97
97
|
//#region src/inplace/frontmatter.ts
|
|
98
98
|
function He(e) {
|
|
99
|
-
if (!e.facet(P).frontmatter) return
|
|
99
|
+
if (!e.facet(P).frontmatter) return T.none;
|
|
100
100
|
let n = t(e.doc);
|
|
101
|
-
if (!n) return
|
|
101
|
+
if (!n) return T.none;
|
|
102
102
|
let r = e.doc.lineAt(n.from).number, i = e.doc.lineAt(n.to).number, a = e.selection.ranges.some((t) => {
|
|
103
103
|
let n = e.doc.lineAt(t.from).number;
|
|
104
104
|
return n >= r && n <= i;
|
|
105
105
|
}), o = [];
|
|
106
106
|
for (let t = r; t <= i; t++) {
|
|
107
107
|
let n = e.doc.line(t), s = t === r ? "cm-inplace-fm cm-inplace-fm-first" : "cm-inplace-fm";
|
|
108
|
-
o.push(
|
|
108
|
+
o.push(T.line({ class: s }).range(n.from)), (t === r || t === i) && !a && n.to > n.from && o.push(T.replace({}).range(n.from, n.to));
|
|
109
109
|
}
|
|
110
|
-
return
|
|
110
|
+
return T.set(o, !0);
|
|
111
111
|
}
|
|
112
112
|
var Ue = M.define({
|
|
113
113
|
create: He,
|
|
114
114
|
update: (e, t) => t.docChanged || t.selection ? He(t.state) : e,
|
|
115
|
-
provide: (e) =>
|
|
115
|
+
provide: (e) => E.decorations.from(e)
|
|
116
116
|
});
|
|
117
117
|
//#endregion
|
|
118
118
|
//#region src/inplace/list-guides.ts
|
|
@@ -130,16 +130,16 @@ function Ge(e, t, n, r, i, a) {
|
|
|
130
130
|
enter: (e) => {
|
|
131
131
|
if (e.name !== "ListItem") return;
|
|
132
132
|
let t = We(e), n = t - 1, i = r.lineAt(e.from).number, s = r.lineAt(Math.min(e.to, r.length)).number, c = e.node.getChild("BulletList") ?? e.node.getChild("OrderedList"), l = c ? r.lineAt(c.from).number : -1, u = c ? r.lineAt(Math.max(c.from, c.to - 1)).number : -1, d = e.node.prevSibling ? "cm-inplace-item-gap" : t > 1 ? "cm-inplace-item-gap-nested" : null;
|
|
133
|
-
for (let e = i; e <= s; e++) c && e >= l && e <= u || (n >= 1 && !o.has(e) && (o.add(e), a.push(
|
|
133
|
+
for (let e = i; e <= s; e++) c && e >= l && e <= u || (n >= 1 && !o.has(e) && (o.add(e), a.push(T.line({
|
|
134
134
|
class: "cm-inplace-li",
|
|
135
135
|
attributes: { style: `--sl-li-depth:${n}` }
|
|
136
|
-
}).range(r.line(e).from))), e === i && d && a.push(
|
|
136
|
+
}).range(r.line(e).from))), e === i && d && a.push(T.line({ class: d }).range(r.line(e).from)));
|
|
137
137
|
}
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
140
|
//#endregion
|
|
141
141
|
//#region src/inplace/reveal.ts
|
|
142
|
-
function
|
|
142
|
+
function B(e) {
|
|
143
143
|
let t = /* @__PURE__ */ new Set();
|
|
144
144
|
for (let n of e.selection.ranges) {
|
|
145
145
|
let r = e.doc.lineAt(n.from).number, i = e.doc.lineAt(n.to).number;
|
|
@@ -155,7 +155,7 @@ var Ke = /* @__PURE__ */ new Set([
|
|
|
155
155
|
"CodeBlock",
|
|
156
156
|
"CodeText"
|
|
157
157
|
]);
|
|
158
|
-
function
|
|
158
|
+
function V(e, t) {
|
|
159
159
|
let n = e.resolveInner(t, 1);
|
|
160
160
|
for (;;) {
|
|
161
161
|
if (Ke.has(n.name)) return !0;
|
|
@@ -202,7 +202,7 @@ function Qe(e, t) {
|
|
|
202
202
|
}
|
|
203
203
|
return null;
|
|
204
204
|
}
|
|
205
|
-
var $e = class extends
|
|
205
|
+
var $e = class extends O {
|
|
206
206
|
src;
|
|
207
207
|
block;
|
|
208
208
|
constructor(e, t) {
|
|
@@ -233,11 +233,11 @@ function et(e, t, n, r, i, a, o) {
|
|
|
233
233
|
let { doc: s } = e.state, c = [];
|
|
234
234
|
for (let e of r.matchAll(Xe)) {
|
|
235
235
|
let n = (e[1] ?? "").trim(), r = t + (e.index ?? 0), l = r + (e[0] ?? "").length;
|
|
236
|
-
!n ||
|
|
236
|
+
!n || V(a, r + 2) || (c.push([r, l]), !Je(i, s, r, l) && o.push(T.replace({ widget: new $e(n, !0) }).range(r, l)));
|
|
237
237
|
}
|
|
238
238
|
for (let e of r.matchAll(Ye)) {
|
|
239
239
|
let n = (e[1] ?? "").trim(), r = t + (e.index ?? 0), l = r + (e[0] ?? "").length;
|
|
240
|
-
!n ||
|
|
240
|
+
!n || V(a, r + 1) || c.some(([e, t]) => r >= e && l <= t) || Je(i, s, r, l) || o.push(T.replace({ widget: new $e(n, !1) }).range(r, l));
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
243
|
function tt(e, t, n) {
|
|
@@ -256,33 +256,33 @@ var nt = M.define({
|
|
|
256
256
|
update(e, t) {
|
|
257
257
|
return t.docChanged || t.selection && (tt(t.state, t.startState.selection, e.ranges) || tt(t.state, t.state.selection, e.ranges)) ? rt(t.state) : e;
|
|
258
258
|
},
|
|
259
|
-
provide: (e) => [
|
|
259
|
+
provide: (e) => [E.decorations.from(e, (e) => e.decorations), E.atomicRanges.of((t) => t.state.field(e).decorations)]
|
|
260
260
|
});
|
|
261
261
|
function rt(e) {
|
|
262
262
|
if (!e.facet(P).math) return {
|
|
263
|
-
decorations:
|
|
263
|
+
decorations: T.none,
|
|
264
264
|
ranges: []
|
|
265
265
|
};
|
|
266
266
|
let t = e.doc.toString();
|
|
267
267
|
if (!t.includes("$$")) return {
|
|
268
|
-
decorations:
|
|
268
|
+
decorations: T.none,
|
|
269
269
|
ranges: []
|
|
270
270
|
};
|
|
271
|
-
let n = [], r = [], i =
|
|
271
|
+
let n = [], r = [], i = B(e), a = N(e);
|
|
272
272
|
for (let o of t.matchAll(Ze)) {
|
|
273
273
|
let t = o[0] ?? "", s = (o[1] ?? "").trim();
|
|
274
274
|
if (!s || !t.includes("\n")) continue;
|
|
275
275
|
let c = o.index ?? 0, l = c + t.length, u = e.doc.lineAt(c), d = e.doc.lineAt(l), f = e.doc.sliceString(u.from, c).trim(), p = e.doc.sliceString(l, d.to).trim();
|
|
276
|
-
f === "" && p === "" && (
|
|
276
|
+
f === "" && p === "" && (V(a, c + 2) || (r.push({
|
|
277
277
|
from: c,
|
|
278
278
|
to: l
|
|
279
|
-
}), !Je(i, e.doc, c, l) && n.push(
|
|
279
|
+
}), !Je(i, e.doc, c, l) && n.push(T.replace({
|
|
280
280
|
widget: new $e(s, !0),
|
|
281
281
|
block: !0
|
|
282
282
|
}).range(c, l))));
|
|
283
283
|
}
|
|
284
284
|
return {
|
|
285
|
-
decorations:
|
|
285
|
+
decorations: T.set(n, !0),
|
|
286
286
|
ranges: r
|
|
287
287
|
};
|
|
288
288
|
}
|
|
@@ -314,7 +314,7 @@ function at(e, t, n) {
|
|
|
314
314
|
let { doc: r, revealed: i, out: a, toggles: o } = t;
|
|
315
315
|
if (!o[n.toggle]) return;
|
|
316
316
|
let s = e.node.getChildren(n.mark), c = s[0], l = s[s.length - 1], u = c && l && c !== l, d = u ? c.to : e.from, f = u ? l.from : e.to;
|
|
317
|
-
f > d && a.push(
|
|
317
|
+
f > d && a.push(T.mark({ class: n.className }).range(d, f)), u && !i.has(r.lineAt(e.from).number) && (a.push(T.replace({}).range(c.from, c.to)), a.push(T.replace({}).range(l.from, l.to)));
|
|
318
318
|
}
|
|
319
319
|
function ot(e, t) {
|
|
320
320
|
let { doc: n, revealed: r, out: i, toggles: a } = t, o = n.sliceString(Math.max(0, e.from - 1), e.from), s = n.sliceString(e.to, e.to + 1);
|
|
@@ -324,12 +324,12 @@ function ot(e, t) {
|
|
|
324
324
|
let u = e.node.getChildren("LinkMark");
|
|
325
325
|
if (u.length >= 2) {
|
|
326
326
|
let t = u[0], a = u[1];
|
|
327
|
-
a.from > t.to && i.push(
|
|
327
|
+
a.from > t.to && i.push(T.mark({ class: "cm-inplace-link" }).range(t.to, a.from)), r.has(n.lineAt(e.from).number) || (i.push(T.replace({}).range(e.from, t.to)), i.push(T.replace({}).range(a.from, e.to)));
|
|
328
328
|
}
|
|
329
329
|
}
|
|
330
330
|
//#endregion
|
|
331
331
|
//#region src/inplace/widgets.ts
|
|
332
|
-
var st = class extends
|
|
332
|
+
var st = class extends O {
|
|
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
|
-
}, ct = class extends
|
|
343
|
+
}, ct = class extends O {
|
|
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
|
-
}, lt = class extends
|
|
354
|
+
}, lt = class extends O {
|
|
355
355
|
checked;
|
|
356
356
|
constructor(e) {
|
|
357
357
|
super(), this.checked = e;
|
|
@@ -378,7 +378,7 @@ function dt(e, t) {
|
|
|
378
378
|
let { doc: n, revealed: r, out: i, toggles: a } = t;
|
|
379
379
|
if (!a.horizontalRule) return !1;
|
|
380
380
|
let o = n.lineAt(e.from);
|
|
381
|
-
return r.has(o.number) || (i.push(
|
|
381
|
+
return r.has(o.number) || (i.push(T.line({ class: "cm-inplace-hr-line" }).range(o.from)), i.push(T.replace({ widget: new st() }).range(o.from, o.to))), !1;
|
|
382
382
|
}
|
|
383
383
|
function ft(e, t) {
|
|
384
384
|
let { doc: n, revealed: r, caretRevealed: i, out: a, toggles: o, quoteRevealed: s } = t;
|
|
@@ -390,14 +390,14 @@ function ft(e, t) {
|
|
|
390
390
|
let r = u ? `cm-inplace-callout cm-inplace-callout-${u}` : "cm-inplace-quote";
|
|
391
391
|
u && e === t && (r += " cm-inplace-callout-head"), u && e === o && (r += " cm-inplace-callout-foot");
|
|
392
392
|
let i = {};
|
|
393
|
-
u && (i["data-callout"] = l[3].toLowerCase()), u && d && (i["data-revealed"] = ""), a.push(
|
|
393
|
+
u && (i["data-callout"] = l[3].toLowerCase()), u && d && (i["data-revealed"] = ""), a.push(T.line({
|
|
394
394
|
class: r,
|
|
395
395
|
attributes: i
|
|
396
396
|
}).range(n.line(e).from));
|
|
397
397
|
}
|
|
398
398
|
if (u && !d && !r.has(t)) {
|
|
399
399
|
let e = c.from + l[1].length;
|
|
400
|
-
a.push(
|
|
400
|
+
a.push(T.replace({}).range(e, e + l[2].length));
|
|
401
401
|
}
|
|
402
402
|
}
|
|
403
403
|
}
|
|
@@ -407,20 +407,20 @@ function pt(e, t) {
|
|
|
407
407
|
let s = n.lineAt(e.from);
|
|
408
408
|
if (!r.has(s.number) && !o.has(s.number)) {
|
|
409
409
|
let t = Math.min(e.to + 1, s.to), n = me.exec(s.text), r = n ? s.text.slice(n[1].length + n[2].length) : s.text.slice(t - s.from);
|
|
410
|
-
i.push(
|
|
410
|
+
i.push(T.replace({}).range(e.from, r.trim() === "" ? e.to : t));
|
|
411
411
|
}
|
|
412
412
|
return !1;
|
|
413
413
|
}
|
|
414
414
|
function mt(e, t) {
|
|
415
415
|
let { doc: n, revealed: r, out: i, toggles: a } = t, o = n.sliceString(e.from, e.to), s = n.lineAt(e.from), c = e.node.parent, l = !!(c?.getChild("Task") ?? c?.getChild("TaskMarker"));
|
|
416
|
-
return r.has(s.number) || (l ? a.tasks && i.push(
|
|
416
|
+
return r.has(s.number) || (l ? a.tasks && i.push(T.replace({}).range(e.from, Math.min(e.to + 1, s.to))) : a.lists && ut.test(o) && i.push(T.replace({ widget: new ct() }).range(e.from, e.to))), !1;
|
|
417
417
|
}
|
|
418
418
|
function ht(e, t) {
|
|
419
419
|
let { doc: n, revealed: r, out: i, toggles: a } = t;
|
|
420
420
|
if (!a.tasks) return !1;
|
|
421
421
|
if (!r.has(n.lineAt(e.from).number)) {
|
|
422
422
|
let t = n.sliceString(e.from + 1, e.to - 1).toLowerCase() === "x";
|
|
423
|
-
i.push(
|
|
423
|
+
i.push(T.replace({ widget: new lt(t) }).range(e.from, e.to));
|
|
424
424
|
}
|
|
425
425
|
return !1;
|
|
426
426
|
}
|
|
@@ -434,7 +434,7 @@ function gt(e, t) {
|
|
|
434
434
|
let t = s && (e === c || e === l), r = "cm-inplace-mono";
|
|
435
435
|
e === c && (r += " cm-inplace-code-top"), e === l && (r += " cm-inplace-code-bottom"), t && (r += f ? " cm-inplace-code-pad" : " cm-inplace-fence");
|
|
436
436
|
let i = n.line(e);
|
|
437
|
-
a.push(
|
|
437
|
+
a.push(T.line({ class: r }).range(i.from)), t && f && i.to > i.from && a.push(T.replace({}).range(i.from, i.to));
|
|
438
438
|
}
|
|
439
439
|
return !1;
|
|
440
440
|
}
|
|
@@ -445,7 +445,7 @@ function yt(e, t, n) {
|
|
|
445
445
|
let { doc: r, revealed: i, out: a, toggles: o } = t;
|
|
446
446
|
if (o.headings) {
|
|
447
447
|
let t = r.lineAt(e.from);
|
|
448
|
-
if (a.push(
|
|
448
|
+
if (a.push(T.line({
|
|
449
449
|
class: `cm-inplace-heading cm-inplace-h${n}`,
|
|
450
450
|
attributes: {
|
|
451
451
|
role: "heading",
|
|
@@ -453,7 +453,7 @@ function yt(e, t, n) {
|
|
|
453
453
|
}
|
|
454
454
|
}).range(t.from)), !i.has(t.number)) {
|
|
455
455
|
let n = e.node.firstChild;
|
|
456
|
-
n?.name === "HeaderMark" && a.push(
|
|
456
|
+
n?.name === "HeaderMark" && a.push(T.replace({}).range(n.from, Math.min(n.to + 1, t.to)));
|
|
457
457
|
}
|
|
458
458
|
}
|
|
459
459
|
}
|
|
@@ -461,7 +461,7 @@ function bt(e, t, n) {
|
|
|
461
461
|
let { doc: r, caretRevealed: i, out: a, toggles: o } = t;
|
|
462
462
|
if (o.headings) {
|
|
463
463
|
let t = r.lineAt(e.from);
|
|
464
|
-
a.push(
|
|
464
|
+
a.push(T.line({
|
|
465
465
|
class: `cm-inplace-heading cm-inplace-h${n}`,
|
|
466
466
|
attributes: {
|
|
467
467
|
role: "heading",
|
|
@@ -471,7 +471,7 @@ function bt(e, t, n) {
|
|
|
471
471
|
let o = e.node.getChild("HeaderMark");
|
|
472
472
|
if (o) {
|
|
473
473
|
let e = r.lineAt(o.from);
|
|
474
|
-
!i.has(t.number) && !i.has(e.number) && (a.push(
|
|
474
|
+
!i.has(t.number) && !i.has(e.number) && (a.push(T.line({ class: "cm-inplace-setext-rule" }).range(e.from)), a.push(T.replace({}).range(o.from, o.to)));
|
|
475
475
|
}
|
|
476
476
|
}
|
|
477
477
|
}
|
|
@@ -498,19 +498,19 @@ function St(t, n, r, i, a, o, s) {
|
|
|
498
498
|
let c = t.state.facet(F) != null;
|
|
499
499
|
for (let r of i.matchAll(e)) {
|
|
500
500
|
let [e = "", i = "", l] = r, u = i.trim(), d = n + (r.index ?? 0);
|
|
501
|
-
if (!u ||
|
|
501
|
+
if (!u || V(o, d + 1) || c && d > 0 && t.state.doc.sliceString(d - 1, d) === "!") continue;
|
|
502
502
|
let f = d + e.length, p = l == null ? d + 2 : d + 2 + i.length + 1, m = f - 2;
|
|
503
|
-
s.push(
|
|
503
|
+
s.push(T.mark({
|
|
504
504
|
class: "cm-inplace-link cm-inplace-wikilink",
|
|
505
505
|
attributes: { "data-stylo-wikilink": u }
|
|
506
|
-
}).range(p, m)), a.has(t.state.doc.lineAt(d).number) || (s.push(
|
|
506
|
+
}).range(p, m)), a.has(t.state.doc.lineAt(d).number) || (s.push(T.replace({}).range(d, p)), s.push(T.replace({}).range(m, f)));
|
|
507
507
|
}
|
|
508
508
|
}
|
|
509
509
|
//#endregion
|
|
510
510
|
//#region src/inplace/decorate.ts
|
|
511
|
-
var Ct = /* @__PURE__ */ new Set(), wt =
|
|
511
|
+
var Ct = /* @__PURE__ */ new Set(), wt = T.replace({});
|
|
512
512
|
function Tt(e) {
|
|
513
|
-
let n = [], r =
|
|
513
|
+
let n = [], r = B(e.state), i = e.state.facet(L) === "never" ? Ct : r, a = N(e.state), { doc: o } = e.state, s = e.state.facet(P), c = {
|
|
514
514
|
doc: o,
|
|
515
515
|
revealed: i,
|
|
516
516
|
caretRevealed: r,
|
|
@@ -538,13 +538,13 @@ function Tt(e) {
|
|
|
538
538
|
t && e.from <= t.to ? e.to > t.to && (u[u.length - 1] = wt.range(t.from, e.to)) : u.push(wt.range(e.from, e.to));
|
|
539
539
|
}
|
|
540
540
|
return {
|
|
541
|
-
decorations:
|
|
542
|
-
atomic:
|
|
541
|
+
decorations: T.set(n, !0),
|
|
542
|
+
atomic: T.set(u, !0)
|
|
543
543
|
};
|
|
544
544
|
}
|
|
545
545
|
//#endregion
|
|
546
546
|
//#region src/inplace/plugin.ts
|
|
547
|
-
var Et =
|
|
547
|
+
var Et = D.fromClass(class {
|
|
548
548
|
decorations;
|
|
549
549
|
atomic;
|
|
550
550
|
constructor(e) {
|
|
@@ -559,7 +559,7 @@ var Et = O.fromClass(class {
|
|
|
559
559
|
}
|
|
560
560
|
}, {
|
|
561
561
|
decorations: (e) => e.decorations,
|
|
562
|
-
provide: (e) =>
|
|
562
|
+
provide: (e) => E.atomicRanges.of((t) => t.plugin(e)?.atomic ?? T.none)
|
|
563
563
|
});
|
|
564
564
|
function Dt() {
|
|
565
565
|
return Et;
|
|
@@ -584,12 +584,12 @@ var Ot = {
|
|
|
584
584
|
toggle: "code"
|
|
585
585
|
}
|
|
586
586
|
};
|
|
587
|
-
function
|
|
588
|
-
return e.facet(L) === "never" || !
|
|
587
|
+
function H(e, t) {
|
|
588
|
+
return e.facet(L) === "never" || !B(e).has(t);
|
|
589
589
|
}
|
|
590
|
-
function
|
|
590
|
+
function U(t, n, r = !1, i = !1) {
|
|
591
591
|
let a = t.doc.lineAt(n);
|
|
592
|
-
if (!i && !
|
|
592
|
+
if (!i && !H(t, a.number)) return null;
|
|
593
593
|
let o = t.facet(P), s = N(t);
|
|
594
594
|
for (let e of [-1, 1]) for (let i = s.resolveInner(n, e); i; i = i.parent) {
|
|
595
595
|
let e = Ot[i.name];
|
|
@@ -648,13 +648,13 @@ var At = (e) => (t) => {
|
|
|
648
648
|
let n = t.state.selection.main;
|
|
649
649
|
if (!n.empty) return !1;
|
|
650
650
|
let { state: r } = t;
|
|
651
|
-
if (!
|
|
651
|
+
if (!H(r, r.doc.lineAt(n.head).number)) return !1;
|
|
652
652
|
let i = kt(t, n.head, e);
|
|
653
653
|
if (i === n.head) return !1;
|
|
654
654
|
let a = r.doc;
|
|
655
655
|
if (e < 0 ? i <= 0 : i >= a.length) return !0;
|
|
656
656
|
let o = e < 0 ? i - 1 : i, s = e < 0 ? i : i + 1;
|
|
657
|
-
for (let e =
|
|
657
|
+
for (let e = U(r, o); e && o <= e.contentFrom && s >= e.contentTo && e.contentTo > e.contentFrom && !(e.from >= o && e.to <= s); e = U(r, o)) o = Math.min(o, e.from), s = Math.max(s, e.to);
|
|
658
658
|
return t.dispatch({
|
|
659
659
|
changes: {
|
|
660
660
|
from: o,
|
|
@@ -675,10 +675,10 @@ function Nt(e, t, n) {
|
|
|
675
675
|
n.spec.widget || n.spec.class || t <= e || e <= i && (i = Math.max(i, t));
|
|
676
676
|
}), i >= n;
|
|
677
677
|
}
|
|
678
|
-
var
|
|
678
|
+
var W = (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 || !H(n.state, n.state.doc.lineAt(r.head).number)) return !1;
|
|
682
682
|
let i = n.moveByChar(r, e);
|
|
683
683
|
if (Nt(n, Math.min(r.head, i.head), Math.max(r.head, i.head)) && (i = n.moveByChar(i, e)), i.head === r.head) return !1;
|
|
684
684
|
let a = t ? Ce.range(r.anchor, i.head) : Ce.cursor(i.head);
|
|
@@ -686,7 +686,7 @@ var U = (e, t) => (n) => {
|
|
|
686
686
|
selection: a,
|
|
687
687
|
userEvent: "select"
|
|
688
688
|
}), !0;
|
|
689
|
-
}, Pt =
|
|
689
|
+
}, Pt = W(!1, !1), Ft = W(!0, !1), It = W(!1, !0), Lt = W(!0, !0), Rt = j.high(k.of([
|
|
690
690
|
{
|
|
691
691
|
key: "Backspace",
|
|
692
692
|
run: jt
|
|
@@ -713,45 +713,8 @@ var U = (e, t) => (n) => {
|
|
|
713
713
|
}
|
|
714
714
|
]));
|
|
715
715
|
//#endregion
|
|
716
|
-
//#region src/inplace/table-cell-
|
|
717
|
-
function zt(e, t
|
|
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, n.dataset.styloCellMark = "";
|
|
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 zt(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
|
}
|
|
742
|
+
//#endregion
|
|
743
|
+
//#region src/inplace/table-cell-widgets.ts
|
|
744
|
+
function Bt(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 Vt(e) {
|
|
753
|
+
let t = e.build();
|
|
754
|
+
return t.setAttribute("contenteditable", "false"), t.dataset.styloCellWidget = "", t;
|
|
755
|
+
}
|
|
756
|
+
function Ht(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
|
+
}
|
|
779
771
|
function Ut(e, t) {
|
|
772
|
+
let n = /* @__PURE__ */ new Map(), r = [];
|
|
773
|
+
for (let i of t) {
|
|
774
|
+
let t = e && Ht(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 Wt(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
|
+
}), Gt(i, a.cellClass));
|
|
799
|
+
return i.marks.length || i.cellClass.length ? i : null;
|
|
800
|
+
}
|
|
801
|
+
var Gt = (e, t) => {
|
|
802
|
+
for (let n of t?.split(/\s+/) ?? []) n && !e.cellClass.includes(n) && e.cellClass.push(n);
|
|
803
|
+
};
|
|
804
|
+
function Kt(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 qt(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(Vt(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 = Kt(e, o));
|
|
825
|
+
c.append(o), l(i);
|
|
826
|
+
}
|
|
827
|
+
return e.node.replaceWith(c), !0;
|
|
828
|
+
}
|
|
829
|
+
function Jt(e, t) {
|
|
780
830
|
for (let n of t) {
|
|
781
|
-
let t =
|
|
831
|
+
let t = Kt(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 Yt(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 = zt(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 } = Ut(s, a), u = () => e.append(...l.map(Vt));
|
|
853
|
+
if (!s) return Jt(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) qt(e, i, c.get(e) ?? []);
|
|
858
|
+
Jt(e, o), u();
|
|
805
859
|
}
|
|
806
|
-
function
|
|
860
|
+
function Xt(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(Le)(i.state), r = i.state.facet(Re)(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 = Wt(t.marks, a, s, c), u = Bt(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) Gt(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 Zt = (e) => e === "h1" || e === "h2" || e === "h3" ? S.heading : S[e], Qt = [
|
|
827
892
|
"bold",
|
|
828
893
|
"italic",
|
|
829
894
|
"strike"
|
|
830
|
-
],
|
|
895
|
+
], $t = ["code", "math"], en = [
|
|
831
896
|
"bulletList",
|
|
832
897
|
"orderedList",
|
|
833
898
|
"task"
|
|
834
|
-
],
|
|
899
|
+
], tn = [
|
|
835
900
|
"h1",
|
|
836
901
|
"h2",
|
|
837
902
|
"h3"
|
|
838
|
-
],
|
|
903
|
+
], nn = ["table", "hr"], rn = [
|
|
839
904
|
"codeBlock",
|
|
840
905
|
"mathBlock",
|
|
841
906
|
"frontmatter"
|
|
842
|
-
],
|
|
907
|
+
], an = (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: Zt(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
|
+
}, G = (e, t, n = !1, r = !1) => {
|
|
856
921
|
let i = [];
|
|
857
922
|
for (let a of t) {
|
|
858
|
-
let t =
|
|
923
|
+
let t = an(e, a, r);
|
|
859
924
|
t && !(n && t.disabled) && i.push(t);
|
|
860
925
|
}
|
|
861
926
|
return i;
|
|
862
|
-
},
|
|
927
|
+
}, K = (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
|
+
}, q = (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 J(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 on(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 (!
|
|
977
|
+
if (!H(e, n.number)) return !1;
|
|
913
978
|
for (let t = N(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 sn = (e) => h(e) || !on(e.state) ? !1 : oe(e), cn = j.high(k.of([{
|
|
920
985
|
key: "Backspace",
|
|
921
|
-
run:
|
|
986
|
+
run: sn
|
|
922
987
|
}, {
|
|
923
988
|
key: "Delete",
|
|
924
|
-
run:
|
|
989
|
+
run: sn
|
|
925
990
|
}]));
|
|
926
|
-
function
|
|
991
|
+
function ln(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 un(e, t = !1) {
|
|
938
1003
|
let n = document.createDocumentFragment();
|
|
939
|
-
return
|
|
1004
|
+
return pn(n, e, t), n;
|
|
940
1005
|
}
|
|
941
|
-
var
|
|
1006
|
+
var dn = /!\[\[[^\]\n]+?\]\]/, fn = [
|
|
942
1007
|
{
|
|
943
1008
|
re: /`([^`\n]+)`/,
|
|
944
|
-
build: (e) =>
|
|
1009
|
+
build: (e) => Y("code", "cm-inplace-code", document.createTextNode(e[1]))
|
|
945
1010
|
},
|
|
946
1011
|
{
|
|
947
1012
|
re: new RegExp(Ye.source),
|
|
948
1013
|
build: (e) => {
|
|
949
|
-
let t =
|
|
1014
|
+
let t = Y("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 = Y("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 = Y("a", "cm-inplace-link");
|
|
1029
|
+
return n.href = e[2] ?? "", n.append(X(e[1] ?? "", t)), n;
|
|
965
1030
|
}
|
|
966
1031
|
},
|
|
967
1032
|
{
|
|
968
1033
|
re: /\*\*\*([^*\n]+?)\*\*\*/,
|
|
969
|
-
build: (e, t) =>
|
|
1034
|
+
build: (e, t) => Y("strong", "cm-inplace-strong", Y("em", "cm-inplace-em", X(e[1], t)))
|
|
970
1035
|
},
|
|
971
1036
|
{
|
|
972
1037
|
re: /\*\*([^\n]+?)\*\*/,
|
|
973
|
-
build: (e, t) =>
|
|
1038
|
+
build: (e, t) => Y("strong", "cm-inplace-strong", X(e[1], t))
|
|
974
1039
|
},
|
|
975
1040
|
{
|
|
976
1041
|
re: /~~([^\n]+?)~~/,
|
|
977
|
-
build: (e, t) =>
|
|
1042
|
+
build: (e, t) => Y("span", "cm-inplace-strike", X(e[1], t))
|
|
978
1043
|
},
|
|
979
1044
|
{
|
|
980
1045
|
re: /(?<!\*)\*(?!\*|\s)([^\n]+?)(?<!\s)\*(?!\*)/,
|
|
981
|
-
build: (e, t) =>
|
|
1046
|
+
build: (e, t) => Y("em", "cm-inplace-em", X(e[1], t))
|
|
982
1047
|
}
|
|
983
1048
|
];
|
|
984
|
-
function
|
|
1049
|
+
function Y(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 X(e, t) {
|
|
989
1054
|
let n = document.createDocumentFragment();
|
|
990
|
-
return
|
|
1055
|
+
return pn(n, e, t), n;
|
|
991
1056
|
}
|
|
992
|
-
function
|
|
1057
|
+
function pn(e, t, n) {
|
|
993
1058
|
for (; t;) {
|
|
994
|
-
let r = -1, i = null, a = n ?
|
|
1059
|
+
let r = -1, i = null, a = n ? dn.exec(t) : null;
|
|
995
1060
|
a && (r = a.index, i = { literal: a[0] });
|
|
996
|
-
for (let e of
|
|
1061
|
+
for (let e of fn) {
|
|
997
1062
|
let n = e.re.exec(t);
|
|
998
1063
|
n && (r < 0 || n.index < r) && (r = n.index, i = {
|
|
999
1064
|
rule: e,
|
|
@@ -1008,8 +1073,69 @@ function cn(e, t, n) {
|
|
|
1008
1073
|
}
|
|
1009
1074
|
}
|
|
1010
1075
|
//#endregion
|
|
1076
|
+
//#region src/inplace/table-widget-render.ts
|
|
1077
|
+
var mn = /* @__PURE__ */ new WeakMap(), hn = (e) => JSON.stringify(e), gn = (e, t) => (mn.get(e)?.sig ?? "null") === hn(t);
|
|
1078
|
+
function _n(e, t, n) {
|
|
1079
|
+
let r = Number(e.dataset.r ?? e.dataset.styloRow), i = Number(e.dataset.c ?? e.dataset.styloCol), a = t.rows[r]?.[i] ?? "";
|
|
1080
|
+
e.replaceChildren(n ? e.ownerDocument.createTextNode(a) : un(c(a), t.embeds));
|
|
1081
|
+
let o = mn.get(e);
|
|
1082
|
+
o && e.classList.remove(...o.cellClass);
|
|
1083
|
+
let s = t.paintOf?.(r, i) ?? null;
|
|
1084
|
+
s && (Yt(e, a, s, n), e.classList.add(...s.cellClass)), mn.set(e, {
|
|
1085
|
+
sig: hn(s),
|
|
1086
|
+
cellClass: s?.cellClass ?? []
|
|
1087
|
+
});
|
|
1088
|
+
}
|
|
1089
|
+
function vn(e, t, n, r) {
|
|
1090
|
+
let i = document.createElement(r ? "th" : "td");
|
|
1091
|
+
i.className = "cm-inplace-tcell", i.setAttribute("contenteditable", "true"), i.dataset.r = String(t), i.dataset.c = String(n);
|
|
1092
|
+
let a = e.aligns[n];
|
|
1093
|
+
return a && (i.style.textAlign = a), _n(i, e, !1), i;
|
|
1094
|
+
}
|
|
1095
|
+
function yn(e, t) {
|
|
1096
|
+
e.replaceChildren();
|
|
1097
|
+
let n = t.aligns.length, r = e.createTHead().insertRow();
|
|
1098
|
+
for (let e = 0; e < n; e++) r.appendChild(vn(t, 0, e, !0));
|
|
1099
|
+
let i = e.createTBody();
|
|
1100
|
+
for (let e = 1; e < t.rows.length; e++) {
|
|
1101
|
+
let r = i.insertRow();
|
|
1102
|
+
for (let i = 0; i < n; i++) r.appendChild(vn(t, e, i, !1));
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
//#endregion
|
|
1106
|
+
//#region src/inplace/table-static-paint.ts
|
|
1107
|
+
var bn = /* @__PURE__ */ new WeakMap(), xn = "[data-stylo-cell-widget], [data-stylo-cell-mark]";
|
|
1108
|
+
function Sn(e, t, n, r, i) {
|
|
1109
|
+
let a = Xt({
|
|
1110
|
+
view: () => t,
|
|
1111
|
+
mounted: () => e.isConnected,
|
|
1112
|
+
from: (t) => {
|
|
1113
|
+
let n = t.posAtDOM(e), r = n;
|
|
1114
|
+
return t.state.field(i).between(n, n, (e) => (r = e, !1)), r;
|
|
1115
|
+
},
|
|
1116
|
+
raw: (e, t) => n[e]?.[t] ?? ""
|
|
1117
|
+
}), o = {
|
|
1118
|
+
rows: n,
|
|
1119
|
+
aligns: [],
|
|
1120
|
+
embeds: r,
|
|
1121
|
+
paintOf: a
|
|
1122
|
+
}, s = () => {
|
|
1123
|
+
for (let t of e.querySelectorAll("td, th")) {
|
|
1124
|
+
let [e, n] = [Number(t.dataset.styloRow), Number(t.dataset.styloCol)];
|
|
1125
|
+
gn(t, a(e, n)) || _n(t, o, !1);
|
|
1126
|
+
}
|
|
1127
|
+
};
|
|
1128
|
+
bn.set(e, s), t.requestMeasure({
|
|
1129
|
+
read: () => null,
|
|
1130
|
+
write: s,
|
|
1131
|
+
key: e
|
|
1132
|
+
}), e.addEventListener("mousedown", (e) => {
|
|
1133
|
+
e.target.closest(xn) && (e.preventDefault(), e.stopPropagation());
|
|
1134
|
+
});
|
|
1135
|
+
}
|
|
1136
|
+
//#endregion
|
|
1011
1137
|
//#region src/inplace/tables.ts
|
|
1012
|
-
var
|
|
1138
|
+
var Cn = class extends O {
|
|
1013
1139
|
table;
|
|
1014
1140
|
embeds;
|
|
1015
1141
|
constructor(e, t) {
|
|
@@ -1018,31 +1144,31 @@ var ln = class extends k {
|
|
|
1018
1144
|
eq(e) {
|
|
1019
1145
|
return JSON.stringify(this.table) === JSON.stringify(e.table);
|
|
1020
1146
|
}
|
|
1021
|
-
toDOM() {
|
|
1022
|
-
let { head:
|
|
1023
|
-
|
|
1024
|
-
let
|
|
1025
|
-
|
|
1026
|
-
let
|
|
1027
|
-
|
|
1147
|
+
toDOM(e) {
|
|
1148
|
+
let { head: t, body: n, aligns: r } = this.table, i = document.createElement("table");
|
|
1149
|
+
i.className = "cm-inplace-table";
|
|
1150
|
+
let a = (e) => un(e.replace(/\\\|/g, "|"), this.embeds), o = i.createTHead().insertRow();
|
|
1151
|
+
t.forEach((e, t) => {
|
|
1152
|
+
let n = document.createElement("th");
|
|
1153
|
+
n.appendChild(a(e)), n.dataset.styloRow = "0", n.dataset.styloCol = String(t), wn(n, r[t]), o.appendChild(n);
|
|
1028
1154
|
});
|
|
1029
|
-
let
|
|
1030
|
-
return
|
|
1031
|
-
let
|
|
1032
|
-
for (let o = 0; o <
|
|
1033
|
-
let
|
|
1034
|
-
|
|
1155
|
+
let s = i.createTBody();
|
|
1156
|
+
return n.forEach((e, n) => {
|
|
1157
|
+
let i = s.insertRow();
|
|
1158
|
+
for (let o = 0; o < t.length; o++) {
|
|
1159
|
+
let t = i.insertCell();
|
|
1160
|
+
t.appendChild(a(e[o] ?? "")), t.dataset.styloRow = String(n + 1), t.dataset.styloCol = String(o), wn(t, r[o]);
|
|
1035
1161
|
}
|
|
1036
|
-
}),
|
|
1162
|
+
}), Sn(i, e, [t, ...n], this.embeds, Z), i;
|
|
1037
1163
|
}
|
|
1038
1164
|
ignoreEvent() {
|
|
1039
1165
|
return !1;
|
|
1040
1166
|
}
|
|
1041
1167
|
};
|
|
1042
|
-
function
|
|
1168
|
+
function wn(e, t) {
|
|
1043
1169
|
t && (e.style.textAlign = t);
|
|
1044
1170
|
}
|
|
1045
|
-
function
|
|
1171
|
+
function Tn(e, t) {
|
|
1046
1172
|
let n = t.lineAt(e.from).number, r = t.lineAt(e.to).number, i = [];
|
|
1047
1173
|
for (let e = n; e <= r; e++) i.push(t.line(e).text);
|
|
1048
1174
|
let a = p(i);
|
|
@@ -1052,17 +1178,17 @@ function dn(e, t) {
|
|
|
1052
1178
|
aligns: a.aligns
|
|
1053
1179
|
};
|
|
1054
1180
|
}
|
|
1055
|
-
function
|
|
1181
|
+
function En(e, t) {
|
|
1056
1182
|
let n = N(e);
|
|
1057
1183
|
for (let e of [-1, 1]) for (let r = n.resolveInner(t, e); r; r = r.parent) if (r.name === "Table") return !0;
|
|
1058
1184
|
return !1;
|
|
1059
1185
|
}
|
|
1060
|
-
function
|
|
1061
|
-
return t.ranges.some((t) =>
|
|
1186
|
+
function Dn(e, t) {
|
|
1187
|
+
return t.ranges.some((t) => En(e, t.from) || En(e, t.to));
|
|
1062
1188
|
}
|
|
1063
|
-
function
|
|
1064
|
-
if (!e.facet(P).tables) return
|
|
1065
|
-
let n = e.facet(I) === "cells" && !e.readOnly, r = e.facet(F) != null && e.facet(P).embeds, i = N(e), a = t(e.doc), o = n ? null :
|
|
1189
|
+
function On(e) {
|
|
1190
|
+
if (!e.facet(P).tables) return T.none;
|
|
1191
|
+
let n = e.facet(I) === "cells" && !e.readOnly, r = e.facet(F) != null && e.facet(P).embeds, i = N(e), a = t(e.doc), o = n ? null : B(e), s = [];
|
|
1066
1192
|
return i.iterate({ enter: (t) => {
|
|
1067
1193
|
if (t.name !== "Table") return;
|
|
1068
1194
|
if (a && t.from < a.to) return !1;
|
|
@@ -1070,33 +1196,33 @@ function mn(e) {
|
|
|
1070
1196
|
let n = e.doc.lineAt(t.from).number, r = e.doc.lineAt(t.to).number;
|
|
1071
1197
|
for (let e = n; e <= r; e++) if (o.has(e)) return !1;
|
|
1072
1198
|
}
|
|
1073
|
-
let i =
|
|
1199
|
+
let i = Tn(t.node, e.doc);
|
|
1074
1200
|
if (i) {
|
|
1075
|
-
let e = n ? new
|
|
1076
|
-
s.push(
|
|
1201
|
+
let e = n ? new vr(i, r) : new Cn(i, r);
|
|
1202
|
+
s.push(T.replace({
|
|
1077
1203
|
widget: e,
|
|
1078
1204
|
block: !0
|
|
1079
1205
|
}).range(t.from, t.to));
|
|
1080
1206
|
}
|
|
1081
1207
|
return !1;
|
|
1082
|
-
} }),
|
|
1208
|
+
} }), T.set(s, !0);
|
|
1083
1209
|
}
|
|
1084
|
-
var
|
|
1085
|
-
create:
|
|
1210
|
+
var Z = M.define({
|
|
1211
|
+
create: On,
|
|
1086
1212
|
update: (e, t) => {
|
|
1087
|
-
if (t.annotation(
|
|
1213
|
+
if (t.annotation(gr)) return e.map(t.changes);
|
|
1088
1214
|
let n = t.startState.readOnly !== t.state.readOnly;
|
|
1089
|
-
return t.state.facet(I) === "cells" ? t.docChanged || n ?
|
|
1215
|
+
return t.state.facet(I) === "cells" ? t.docChanged || n ? On(t.state) : e.map(t.changes) : t.docChanged || n || t.selection && (Dn(t.state, t.startState.selection) || Dn(t.state, t.state.selection)) ? On(t.state) : e;
|
|
1090
1216
|
},
|
|
1091
|
-
provide: (e) => [
|
|
1217
|
+
provide: (e) => [E.decorations.from(e), E.atomicRanges.of((t) => t.state.field(e))]
|
|
1092
1218
|
});
|
|
1093
1219
|
//#endregion
|
|
1094
1220
|
//#region src/inplace/host-cell.ts
|
|
1095
|
-
function
|
|
1221
|
+
function kn(e, t, n) {
|
|
1096
1222
|
let i = t.closest("table");
|
|
1097
1223
|
if (!i) return;
|
|
1098
1224
|
let a = e.posAtDOM(i), o = a;
|
|
1099
|
-
e.state.field(
|
|
1225
|
+
e.state.field(Z).between(a, a, (e) => (o = e, !1));
|
|
1100
1226
|
let s = v(e.state.doc, o, Number(t.dataset.r), Number(t.dataset.c));
|
|
1101
1227
|
if (s == null) return;
|
|
1102
1228
|
let { from: c, to: l } = n ? r(t) : {
|
|
@@ -1110,7 +1236,7 @@ function hn(e, t, n) {
|
|
|
1110
1236
|
}
|
|
1111
1237
|
//#endregion
|
|
1112
1238
|
//#region src/inplace/selection-rect.ts
|
|
1113
|
-
var
|
|
1239
|
+
var An = (e, t, n, r) => {
|
|
1114
1240
|
let i = {
|
|
1115
1241
|
x: e,
|
|
1116
1242
|
y: t,
|
|
@@ -1126,39 +1252,39 @@ var gn = (e, t, n, r) => {
|
|
|
1126
1252
|
toJSON: () => i
|
|
1127
1253
|
};
|
|
1128
1254
|
};
|
|
1129
|
-
function
|
|
1255
|
+
function jn(e) {
|
|
1130
1256
|
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() :
|
|
1257
|
+
return !r || !i ? e.dom.getBoundingClientRect() : An(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
1258
|
}
|
|
1133
|
-
function
|
|
1259
|
+
function Mn(e, t) {
|
|
1134
1260
|
let n = e?.ownerDocument.getSelection();
|
|
1135
1261
|
if (e && t && n && n.rangeCount > 0) {
|
|
1136
1262
|
let e = n.getRangeAt(0).getBoundingClientRect?.();
|
|
1137
1263
|
if (e && (e.width > 0 || e.height > 0)) return e;
|
|
1138
1264
|
}
|
|
1139
|
-
return e?.getBoundingClientRect() ??
|
|
1265
|
+
return e?.getBoundingClientRect() ?? An(0, 0, 0, 0);
|
|
1140
1266
|
}
|
|
1141
1267
|
//#endregion
|
|
1142
1268
|
//#region src/inplace/host-items.ts
|
|
1143
|
-
var
|
|
1144
|
-
function
|
|
1269
|
+
var Nn = /* @__PURE__ */ new WeakMap();
|
|
1270
|
+
function Pn(e, t) {
|
|
1145
1271
|
if (e == null || typeof e == "string") return null;
|
|
1146
|
-
if (
|
|
1272
|
+
if (Nn.has(t)) return Nn.get(t) ?? null;
|
|
1147
1273
|
let n = document.createElement("span"), r = Oe(n), i = null;
|
|
1148
1274
|
try {
|
|
1149
1275
|
xe(() => r.render(e)), i = n.firstElementChild;
|
|
1150
1276
|
} catch {}
|
|
1151
|
-
return r.unmount(),
|
|
1277
|
+
return r.unmount(), Nn.set(t, i), i;
|
|
1152
1278
|
}
|
|
1153
|
-
var
|
|
1154
|
-
function
|
|
1155
|
-
if (!
|
|
1279
|
+
var Fn = (e) => e.state.facet(z).includes("host"), In = (e) => Fn(e) && e.state.facet(Ie)().some((e) => e.readOnlySafe);
|
|
1280
|
+
function Ln(e, t) {
|
|
1281
|
+
if (!Fn(e)) return [];
|
|
1156
1282
|
let n = e.state.readOnly, r = [], i;
|
|
1157
1283
|
for (let a of e.state.facet(Ie)()) {
|
|
1158
1284
|
if (n && !a.readOnlySafe) continue;
|
|
1159
1285
|
let o = a.when ?? "always";
|
|
1160
1286
|
if (o === "selection" && !t.selected || o === "no-selection" && t.selected) continue;
|
|
1161
|
-
let s =
|
|
1287
|
+
let s = Pn(a.icon, a);
|
|
1162
1288
|
r.push({
|
|
1163
1289
|
id: a.id,
|
|
1164
1290
|
label: a.title,
|
|
@@ -1170,15 +1296,15 @@ function Cn(e, t) {
|
|
|
1170
1296
|
}
|
|
1171
1297
|
});
|
|
1172
1298
|
}
|
|
1173
|
-
return r.length && (i = t.rect?.() ??
|
|
1299
|
+
return r.length && (i = t.rect?.() ?? jn(e)), r;
|
|
1174
1300
|
}
|
|
1175
1301
|
//#endregion
|
|
1176
1302
|
//#region src/inplace/link-row.ts
|
|
1177
|
-
var
|
|
1303
|
+
var Rn = (e) => {
|
|
1178
1304
|
let t = e.trim().replace(/^<([^]*)>$/, "$1");
|
|
1179
1305
|
return /[\s()]/.test(t) ? `<${t.replace(/[<>]/g, "")}>` : t;
|
|
1180
|
-
},
|
|
1181
|
-
function
|
|
1306
|
+
}, zn = (e) => e.replace(/^<([^]*)>$/, "$1");
|
|
1307
|
+
function Bn(e, t) {
|
|
1182
1308
|
let n = e.doc.lineAt(t.from);
|
|
1183
1309
|
if (e.doc.lineAt(t.to).number !== n.number) return null;
|
|
1184
1310
|
let r = t.from - n.from, i = t.to - n.from, s = o(n.text, r) ?? o(n.text, i);
|
|
@@ -1194,7 +1320,7 @@ function En(e, t) {
|
|
|
1194
1320
|
text: c.label
|
|
1195
1321
|
} : null;
|
|
1196
1322
|
}
|
|
1197
|
-
function
|
|
1323
|
+
function Vn(e, t) {
|
|
1198
1324
|
let { state: n } = e, r = n.selection.main, i = n.doc.lineAt(r.head), a = t.partsIn(i.text, r.head - i.from);
|
|
1199
1325
|
if (a) {
|
|
1200
1326
|
let n = i.from + a.from, r = i.from + a.to, o = t.editActions?.(e, a) ?? [];
|
|
@@ -1223,7 +1349,7 @@ function Dn(e, t) {
|
|
|
1223
1349
|
actions: o
|
|
1224
1350
|
};
|
|
1225
1351
|
}
|
|
1226
|
-
let o =
|
|
1352
|
+
let o = Bn(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
1353
|
return {
|
|
1228
1354
|
field: !0,
|
|
1229
1355
|
label: t.addLabel,
|
|
@@ -1233,13 +1359,13 @@ function Dn(e, t) {
|
|
|
1233
1359
|
onSubmit: (n) => t.onAdd(e, s, c, l, n)
|
|
1234
1360
|
};
|
|
1235
1361
|
}
|
|
1236
|
-
var
|
|
1362
|
+
var Hn = {
|
|
1237
1363
|
icon: S.link,
|
|
1238
1364
|
placeholder: "https://…",
|
|
1239
1365
|
editLabel: "Edit external link",
|
|
1240
1366
|
addLabel: "Add external link",
|
|
1241
1367
|
partsIn: o,
|
|
1242
|
-
editValue: (e) =>
|
|
1368
|
+
editValue: (e) => zn(e.url),
|
|
1243
1369
|
editActions: (e, t) => {
|
|
1244
1370
|
let n = e.state.facet(Me);
|
|
1245
1371
|
return !n || !t.url ? [] : [{
|
|
@@ -1252,7 +1378,7 @@ var On = {
|
|
|
1252
1378
|
e.dispatch({ changes: {
|
|
1253
1379
|
from: t.urlFrom,
|
|
1254
1380
|
to: t.urlTo,
|
|
1255
|
-
insert:
|
|
1381
|
+
insert: Rn(n)
|
|
1256
1382
|
} }), e.focus();
|
|
1257
1383
|
},
|
|
1258
1384
|
onAdd: (e, t, n, r, i) => {
|
|
@@ -1261,7 +1387,7 @@ var On = {
|
|
|
1261
1387
|
changes: {
|
|
1262
1388
|
from: t,
|
|
1263
1389
|
to: n,
|
|
1264
|
-
insert: `[${a}](${
|
|
1390
|
+
insert: `[${a}](${Rn(i)})`
|
|
1265
1391
|
},
|
|
1266
1392
|
selection: {
|
|
1267
1393
|
anchor: t + 1,
|
|
@@ -1269,7 +1395,7 @@ var On = {
|
|
|
1269
1395
|
}
|
|
1270
1396
|
}), e.focus();
|
|
1271
1397
|
}
|
|
1272
|
-
},
|
|
1398
|
+
}, Un = {
|
|
1273
1399
|
icon: S.wikilink,
|
|
1274
1400
|
placeholder: "note or path",
|
|
1275
1401
|
editLabel: "Edit link",
|
|
@@ -1298,27 +1424,27 @@ var On = {
|
|
|
1298
1424
|
}), e.focus();
|
|
1299
1425
|
}
|
|
1300
1426
|
};
|
|
1301
|
-
function
|
|
1302
|
-
return
|
|
1427
|
+
function Wn(e) {
|
|
1428
|
+
return Vn(e, Hn);
|
|
1303
1429
|
}
|
|
1304
|
-
function
|
|
1305
|
-
return
|
|
1430
|
+
function Gn(e) {
|
|
1431
|
+
return Vn(e, Un);
|
|
1306
1432
|
}
|
|
1307
1433
|
//#endregion
|
|
1308
1434
|
//#region src/inplace/context-menu-shell.ts
|
|
1309
|
-
function
|
|
1435
|
+
function Kn(e, t, n, r) {
|
|
1310
1436
|
let i = r?.innerWidth ?? 0, a = r?.innerHeight ?? 0;
|
|
1311
1437
|
e.style.left = "0", e.style.top = "0";
|
|
1312
1438
|
let { width: o, height: s } = e.getBoundingClientRect();
|
|
1313
1439
|
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
1440
|
}
|
|
1315
|
-
function
|
|
1441
|
+
function qn(e, t, n) {
|
|
1316
1442
|
let r = n?.innerWidth ?? 0, i = n?.innerHeight ?? 0;
|
|
1317
1443
|
e.style.left = "0", e.style.top = "0";
|
|
1318
1444
|
let { width: a, height: o } = e.getBoundingClientRect(), s = t.right - 4, c = s + a > r - 4 ? t.left - a + 4 : s;
|
|
1319
1445
|
e.style.left = `${Math.max(4, c)}px`, e.style.top = `${Math.max(4, Math.min(t.top - 4, i - o - 4))}px`;
|
|
1320
1446
|
}
|
|
1321
|
-
function
|
|
1447
|
+
function Jn(e, t, n, r = 350) {
|
|
1322
1448
|
let i = Date.now(), a = (e) => !t.contains(e.target), o = (e) => {
|
|
1323
1449
|
a(e) && n();
|
|
1324
1450
|
}, s = (e) => {
|
|
@@ -1332,10 +1458,10 @@ function Pn(e, t, n, r = 350) {
|
|
|
1332
1458
|
}
|
|
1333
1459
|
//#endregion
|
|
1334
1460
|
//#region src/inplace/context-menu-types.ts
|
|
1335
|
-
var
|
|
1461
|
+
var Yn = (e) => typeof e != "string" && "rows" in e, Xn = (e) => typeof e != "string" && "field" in e;
|
|
1336
1462
|
//#endregion
|
|
1337
1463
|
//#region src/inplace/context-menu.ts
|
|
1338
|
-
function
|
|
1464
|
+
function Q(e, t = "cm-inplace-menu", n) {
|
|
1339
1465
|
let r = e.defaultView, i = e.createElement("div");
|
|
1340
1466
|
i.className = t, i.setAttribute("contenteditable", "false"), i.hidden = !0;
|
|
1341
1467
|
let a = null, o = null, s = () => {
|
|
@@ -1345,7 +1471,7 @@ function Z(e, t = "cm-inplace-menu", n) {
|
|
|
1345
1471
|
}, l = (e) => e.addEventListener("mousedown", (e) => {
|
|
1346
1472
|
e.preventDefault(), e.stopPropagation();
|
|
1347
1473
|
}), u = (t, n, r, i) => {
|
|
1348
|
-
i ? t.appendChild(i.cloneNode(!0)) : r && t.appendChild(
|
|
1474
|
+
i ? t.appendChild(i.cloneNode(!0)) : r && t.appendChild(x(e, r));
|
|
1349
1475
|
let a = e.createElement("span");
|
|
1350
1476
|
a.textContent = n, t.appendChild(a);
|
|
1351
1477
|
}, d = (n) => {
|
|
@@ -1363,7 +1489,7 @@ function Z(e, t = "cm-inplace-menu", n) {
|
|
|
1363
1489
|
if (a?.dataset.for === n) return;
|
|
1364
1490
|
s();
|
|
1365
1491
|
let e = c();
|
|
1366
|
-
e.dataset.for = n, i.appendChild(e),
|
|
1492
|
+
e.dataset.for = n, i.appendChild(e), qn(e, f.getBoundingClientRect(), r), a = e, e.querySelector("input")?.focus({ preventScroll: !0 });
|
|
1367
1493
|
};
|
|
1368
1494
|
return f.addEventListener("pointerenter", p), f.addEventListener("click", (e) => {
|
|
1369
1495
|
e.stopPropagation(), p();
|
|
@@ -1386,7 +1512,7 @@ function Z(e, t = "cm-inplace-menu", n) {
|
|
|
1386
1512
|
for (let i of n) if (i === "separator") {
|
|
1387
1513
|
let n = e.createElement("div");
|
|
1388
1514
|
n.className = `${t}-sep`, r.appendChild(n);
|
|
1389
|
-
} else
|
|
1515
|
+
} else Yn(i) ? r.appendChild(f(i.label, i.icon, () => m(i.rows), i.disabled)) : Xn(i) ? r.appendChild(f(i.label, i.icon, () => p(i))) : r.appendChild(d(i));
|
|
1390
1516
|
return r;
|
|
1391
1517
|
};
|
|
1392
1518
|
return {
|
|
@@ -1397,12 +1523,12 @@ function Z(e, t = "cm-inplace-menu", n) {
|
|
|
1397
1523
|
show: (t, a, s) => {
|
|
1398
1524
|
c();
|
|
1399
1525
|
let l = m(t);
|
|
1400
|
-
i.appendChild(l), i.hidden = !1,
|
|
1526
|
+
i.appendChild(l), i.hidden = !1, Kn(l, a, s, r), o = Jn(e, i, c), n?.(!0);
|
|
1401
1527
|
},
|
|
1402
1528
|
showField: (t, a, s) => {
|
|
1403
1529
|
c();
|
|
1404
1530
|
let l = p(t);
|
|
1405
|
-
i.appendChild(l), i.hidden = !1,
|
|
1531
|
+
i.appendChild(l), i.hidden = !1, Kn(l, a, s, r), l.querySelector("input")?.focus({ preventScroll: !0 }), o = Jn(e, i, c), n?.(!0);
|
|
1406
1532
|
},
|
|
1407
1533
|
hide: c,
|
|
1408
1534
|
destroy: () => {
|
|
@@ -1412,7 +1538,7 @@ function Z(e, t = "cm-inplace-menu", n) {
|
|
|
1412
1538
|
}
|
|
1413
1539
|
//#endregion
|
|
1414
1540
|
//#region src/inplace/math-edit.ts
|
|
1415
|
-
function
|
|
1541
|
+
function Zn(e) {
|
|
1416
1542
|
let { state: t } = e, n = t.selection.main, r = t.doc.lineAt(n.head), i = Qe(r.text, n.head - r.from);
|
|
1417
1543
|
if (i) {
|
|
1418
1544
|
let t = r.from + i.from, n = r.from + i.to, a = i.block ? "$$" : "$";
|
|
@@ -1471,25 +1597,25 @@ function Ln(e) {
|
|
|
1471
1597
|
}
|
|
1472
1598
|
};
|
|
1473
1599
|
}
|
|
1474
|
-
var
|
|
1600
|
+
var Qn = class {
|
|
1475
1601
|
menu;
|
|
1476
1602
|
contentDOM;
|
|
1477
1603
|
onClick;
|
|
1478
1604
|
constructor(e) {
|
|
1479
|
-
this.menu =
|
|
1605
|
+
this.menu = Q(e.dom.ownerDocument), e.dom.appendChild(this.menu.el), this.contentDOM = e.contentDOM, this.onClick = (t) => {
|
|
1480
1606
|
if (!e.state.facet(P).math) return;
|
|
1481
1607
|
let n = t.target?.closest(".cm-inplace-math");
|
|
1482
1608
|
if (!n) return;
|
|
1483
1609
|
let r = e.posAtDOM(n);
|
|
1484
1610
|
if (r < 0) return;
|
|
1485
1611
|
let i = e.state.doc.lineAt(r);
|
|
1486
|
-
Qe(i.text, r - i.from) && (e.dispatch({ selection: { anchor: r } }), this.menu.showField(
|
|
1612
|
+
Qe(i.text, r - i.from) && (e.dispatch({ selection: { anchor: r } }), this.menu.showField(Zn(e), t.clientX, t.clientY));
|
|
1487
1613
|
}, this.contentDOM.addEventListener("click", this.onClick);
|
|
1488
1614
|
}
|
|
1489
1615
|
destroy() {
|
|
1490
1616
|
this.contentDOM.removeEventListener("click", this.onClick), this.menu.destroy();
|
|
1491
1617
|
}
|
|
1492
|
-
},
|
|
1618
|
+
}, $n = D.fromClass(Qn), er = ve((e, t) => {
|
|
1493
1619
|
if (!e.state.facet(P).math) return null;
|
|
1494
1620
|
let n = e.state.doc.lineAt(t), r = Qe(n.text, t - n.from);
|
|
1495
1621
|
return r ? {
|
|
@@ -1504,13 +1630,13 @@ var Rn = class {
|
|
|
1504
1630
|
});
|
|
1505
1631
|
//#endregion
|
|
1506
1632
|
//#region src/inplace/context-menu-actions.ts
|
|
1507
|
-
function
|
|
1633
|
+
function tr(e) {
|
|
1508
1634
|
let t = h(e);
|
|
1509
1635
|
if (!t) return !1;
|
|
1510
1636
|
let { from: n, to: i } = r(t);
|
|
1511
1637
|
return i > n;
|
|
1512
1638
|
}
|
|
1513
|
-
function
|
|
1639
|
+
function nr(e) {
|
|
1514
1640
|
let t = ie(e.state);
|
|
1515
1641
|
return {
|
|
1516
1642
|
field: !0,
|
|
@@ -1533,49 +1659,49 @@ function Hn(e) {
|
|
|
1533
1659
|
}]
|
|
1534
1660
|
};
|
|
1535
1661
|
}
|
|
1536
|
-
var
|
|
1537
|
-
...
|
|
1662
|
+
var rr = (e, t = !1) => [
|
|
1663
|
+
...G(e, Qt, !1, t),
|
|
1538
1664
|
"separator",
|
|
1539
|
-
...t ?
|
|
1665
|
+
...t ? G(e, $t, !1, !0) : [an(e, "code", !1), Zn(e)]
|
|
1540
1666
|
];
|
|
1541
|
-
function
|
|
1542
|
-
let n = e.state.facet(
|
|
1543
|
-
return
|
|
1667
|
+
function ir(e, t) {
|
|
1668
|
+
let n = e.state.facet(z), r = t ?? h(e), i = tr(e) && r === h(e), a = [];
|
|
1669
|
+
return J(a, Ln(e, {
|
|
1544
1670
|
selected: i,
|
|
1545
|
-
prepare: () => r &&
|
|
1546
|
-
rect: () =>
|
|
1547
|
-
})), i ? (n.includes("format") &&
|
|
1671
|
+
prepare: () => r && kn(e, r, i),
|
|
1672
|
+
rect: () => Mn(r, i)
|
|
1673
|
+
})), i ? (n.includes("format") && J(a, [q("Format", S.format, rr(e, !0))]), n.includes("clipboard") && J(a, K(e)), a) : a;
|
|
1548
1674
|
}
|
|
1549
|
-
var
|
|
1550
|
-
...
|
|
1675
|
+
var ar = (e) => [
|
|
1676
|
+
...G(e, en),
|
|
1551
1677
|
"separator",
|
|
1552
|
-
...
|
|
1678
|
+
...G(e, [...tn, "body"]),
|
|
1553
1679
|
"separator",
|
|
1554
|
-
...
|
|
1555
|
-
],
|
|
1556
|
-
...
|
|
1680
|
+
...G(e, ["quote"])
|
|
1681
|
+
], or = (e) => [
|
|
1682
|
+
...G(e, nn),
|
|
1557
1683
|
"separator",
|
|
1558
|
-
...
|
|
1684
|
+
...G(e, rn)
|
|
1559
1685
|
];
|
|
1560
|
-
function
|
|
1561
|
-
let { state: t } = e, n = t.facet(
|
|
1562
|
-
if (
|
|
1563
|
-
let i =
|
|
1686
|
+
function sr(e) {
|
|
1687
|
+
let { state: t } = e, n = t.facet(z), r = (e) => n.includes(e);
|
|
1688
|
+
if (tr(e)) return ir(e);
|
|
1689
|
+
let i = Ln(e, { selected: !t.selection.main.empty });
|
|
1564
1690
|
if (ee(t)) {
|
|
1565
1691
|
let t = [];
|
|
1566
|
-
return
|
|
1692
|
+
return J(t, i), J(t, [nr(e)]), r("clipboard") && J(t, K(e)), t;
|
|
1567
1693
|
}
|
|
1568
|
-
if (
|
|
1694
|
+
if (on(t)) {
|
|
1569
1695
|
let t = [];
|
|
1570
|
-
return
|
|
1696
|
+
return J(t, i), J(t, [ln(e)]), r("clipboard") && J(t, K(e)), t;
|
|
1571
1697
|
}
|
|
1572
1698
|
let a = t.selection.main, o = t.doc.lineAt(a.head).text.trim() === "", s = !a.empty || !!t.wordAt(a.head), c = t.facet(Ve) === "menu", l = [];
|
|
1573
|
-
for (let t of n) t === "host" ?
|
|
1699
|
+
for (let t of n) t === "host" ? J(l, i) : t === "link" && c ? J(l, [Gn(e), Wn(e)]) : t === "format" && c ? J(l, [q("Format", S.format, rr(e), !s)]) : t === "paragraph" ? J(l, [q("Paragraph", S.paragraph, ar(e))]) : t === "insert" ? J(l, [q("Insert", S.insert, or(e), !o)]) : t === "clipboard" && J(l, K(e));
|
|
1574
1700
|
return l;
|
|
1575
1701
|
}
|
|
1576
1702
|
//#endregion
|
|
1577
1703
|
//#region src/inplace/long-press.ts
|
|
1578
|
-
function
|
|
1704
|
+
function cr(e, t) {
|
|
1579
1705
|
let n = t.delay ?? 450, r = t.slop ?? 20, i = null, a = 0, o = 0, s = () => {
|
|
1580
1706
|
i != null && (clearTimeout(i), i = null);
|
|
1581
1707
|
}, c = (e) => {
|
|
@@ -1597,10 +1723,10 @@ function Jn(e, t) {
|
|
|
1597
1723
|
}
|
|
1598
1724
|
//#endregion
|
|
1599
1725
|
//#region src/inplace/table-gizmos.ts
|
|
1600
|
-
function
|
|
1726
|
+
function lr(e, t) {
|
|
1601
1727
|
let n = e.createElement("div");
|
|
1602
1728
|
n.className = "cm-inplace-table-gizmos", n.setAttribute("contenteditable", "false");
|
|
1603
|
-
let r =
|
|
1729
|
+
let r = Q(e), i = (t, n, r) => {
|
|
1604
1730
|
let i = e.createElement("button");
|
|
1605
1731
|
return i.type = "button", i.className = t, i.setAttribute("aria-label", n), i.addEventListener("mousedown", (e) => {
|
|
1606
1732
|
e.preventDefault(), e.stopPropagation();
|
|
@@ -1683,7 +1809,7 @@ function Yn(e, t) {
|
|
|
1683
1809
|
}
|
|
1684
1810
|
//#endregion
|
|
1685
1811
|
//#region src/inplace/table-widget-keys.ts
|
|
1686
|
-
function
|
|
1812
|
+
function ur(e, t, n) {
|
|
1687
1813
|
let r = e.target.closest("td, th");
|
|
1688
1814
|
if (!r) return;
|
|
1689
1815
|
if (l(e, r)) {
|
|
@@ -1751,62 +1877,32 @@ function Xn(e, t, n) {
|
|
|
1751
1877
|
}
|
|
1752
1878
|
}
|
|
1753
1879
|
//#endregion
|
|
1754
|
-
//#region src/inplace/table-widget-render.ts
|
|
1755
|
-
var Zn = /* @__PURE__ */ new WeakMap(), Qn = (e) => JSON.stringify(e), $n = (e, t) => (Zn.get(e)?.sig ?? "null") === Qn(t);
|
|
1756
|
-
function er(e, t, n) {
|
|
1757
|
-
let r = Number(e.dataset.r), i = Number(e.dataset.c), a = t.rows[r]?.[i] ?? "";
|
|
1758
|
-
e.replaceChildren(n ? e.ownerDocument.createTextNode(a) : an(c(a), t.embeds));
|
|
1759
|
-
let o = Zn.get(e);
|
|
1760
|
-
o && e.classList.remove(...o.cellClass);
|
|
1761
|
-
let s = t.paintOf?.(r, i) ?? null;
|
|
1762
|
-
s && (Wt(e, a, s, n), e.classList.add(...s.cellClass)), Zn.set(e, {
|
|
1763
|
-
sig: Qn(s),
|
|
1764
|
-
cellClass: s?.cellClass ?? []
|
|
1765
|
-
});
|
|
1766
|
-
}
|
|
1767
|
-
function tr(e, t, n, r) {
|
|
1768
|
-
let i = document.createElement(r ? "th" : "td");
|
|
1769
|
-
i.className = "cm-inplace-tcell", i.setAttribute("contenteditable", "true"), i.dataset.r = String(t), i.dataset.c = String(n);
|
|
1770
|
-
let a = e.aligns[n];
|
|
1771
|
-
return a && (i.style.textAlign = a), er(i, e, !1), i;
|
|
1772
|
-
}
|
|
1773
|
-
function nr(e, t) {
|
|
1774
|
-
e.replaceChildren();
|
|
1775
|
-
let n = t.aligns.length, r = e.createTHead().insertRow();
|
|
1776
|
-
for (let e = 0; e < n; e++) r.appendChild(tr(t, 0, e, !0));
|
|
1777
|
-
let i = e.createTBody();
|
|
1778
|
-
for (let e = 1; e < t.rows.length; e++) {
|
|
1779
|
-
let r = i.insertRow();
|
|
1780
|
-
for (let i = 0; i < n; i++) r.appendChild(tr(t, e, i, !1));
|
|
1781
|
-
}
|
|
1782
|
-
}
|
|
1783
|
-
//#endregion
|
|
1784
1880
|
//#region src/inplace/table-structure.ts
|
|
1785
|
-
var
|
|
1786
|
-
function
|
|
1787
|
-
let n = Math.max(0, Math.min(t,
|
|
1881
|
+
var $ = (e) => e.aligns.length;
|
|
1882
|
+
function dr(e, t) {
|
|
1883
|
+
let n = Math.max(0, Math.min(t, $(e)));
|
|
1788
1884
|
for (let t of e.rows) t.splice(n, 0, "");
|
|
1789
1885
|
e.aligns.splice(n, 0, "");
|
|
1790
1886
|
}
|
|
1791
|
-
function
|
|
1792
|
-
if (!(
|
|
1887
|
+
function fr(e, t) {
|
|
1888
|
+
if (!($(e) <= 1 || t < 0 || t >= $(e))) {
|
|
1793
1889
|
for (let n of e.rows) n.splice(t, 1);
|
|
1794
1890
|
e.aligns.splice(t, 1);
|
|
1795
1891
|
}
|
|
1796
1892
|
}
|
|
1797
|
-
function
|
|
1893
|
+
function pr(e, t) {
|
|
1798
1894
|
let n = Math.max(1, Math.min(t, e.rows.length));
|
|
1799
|
-
e.rows.splice(n, 0, Array(
|
|
1895
|
+
e.rows.splice(n, 0, Array($(e)).fill(""));
|
|
1800
1896
|
}
|
|
1801
|
-
function
|
|
1897
|
+
function mr(e, t) {
|
|
1802
1898
|
t <= 0 || t >= e.rows.length || e.rows.length <= 2 || e.rows.splice(t, 1);
|
|
1803
1899
|
}
|
|
1804
|
-
function
|
|
1805
|
-
t >= 0 && t <
|
|
1900
|
+
function hr(e, t, n) {
|
|
1901
|
+
t >= 0 && t < $(e) && (e.aligns[t] = n);
|
|
1806
1902
|
}
|
|
1807
1903
|
//#endregion
|
|
1808
1904
|
//#region src/inplace/table-widget.ts
|
|
1809
|
-
var
|
|
1905
|
+
var gr = Se.define(), _r = /* @__PURE__ */ new WeakMap(), vr = class extends O {
|
|
1810
1906
|
data;
|
|
1811
1907
|
embeds;
|
|
1812
1908
|
table = null;
|
|
@@ -1823,7 +1919,7 @@ var cr = Se.define(), lr = /* @__PURE__ */ new WeakMap(), ur = class extends k {
|
|
|
1823
1919
|
super(), this.data = e, this.embeds = t, this.rows = le(e);
|
|
1824
1920
|
}
|
|
1825
1921
|
eq(e) {
|
|
1826
|
-
return !this.table && JSON.stringify(
|
|
1922
|
+
return !this.table && JSON.stringify(ue(this.rows)) === JSON.stringify(ue(e.rows));
|
|
1827
1923
|
}
|
|
1828
1924
|
ignoreEvent() {
|
|
1829
1925
|
return !0;
|
|
@@ -1833,7 +1929,7 @@ var cr = Se.define(), lr = /* @__PURE__ */ new WeakMap(), ur = class extends k {
|
|
|
1833
1929
|
}
|
|
1834
1930
|
bounds(e) {
|
|
1835
1931
|
let t = e.posAtDOM(this.table), n = null;
|
|
1836
|
-
return e.state.field(
|
|
1932
|
+
return e.state.field(Z).between(t, t, (e, t) => (n = {
|
|
1837
1933
|
from: e,
|
|
1838
1934
|
to: t
|
|
1839
1935
|
}, !1)), n ?? e.state.doc.lineAt(t);
|
|
@@ -1847,7 +1943,7 @@ var cr = Se.define(), lr = /* @__PURE__ */ new WeakMap(), ur = class extends k {
|
|
|
1847
1943
|
c: Number(e.dataset.c)
|
|
1848
1944
|
};
|
|
1849
1945
|
}
|
|
1850
|
-
paintOf =
|
|
1946
|
+
paintOf = Xt({
|
|
1851
1947
|
view: () => this.view,
|
|
1852
1948
|
mounted: () => !!this.table?.isConnected,
|
|
1853
1949
|
from: (e) => this.bounds(e).from,
|
|
@@ -1862,19 +1958,19 @@ var cr = Se.define(), lr = /* @__PURE__ */ new WeakMap(), ur = class extends k {
|
|
|
1862
1958
|
};
|
|
1863
1959
|
}
|
|
1864
1960
|
paint(e, t) {
|
|
1865
|
-
|
|
1961
|
+
_n(e, this.grid(), t);
|
|
1866
1962
|
}
|
|
1867
1963
|
repaintMarks() {
|
|
1868
1964
|
for (let e of this.table?.querySelectorAll("td, th") ?? []) {
|
|
1869
1965
|
let { r: t, c: n } = this.coords(e);
|
|
1870
|
-
e !== this.editing &&
|
|
1966
|
+
e !== this.editing && !gn(e, this.paintOf(t, n)) && this.paint(e, !1);
|
|
1871
1967
|
}
|
|
1872
1968
|
}
|
|
1873
1969
|
renderCells() {
|
|
1874
|
-
|
|
1970
|
+
yn(this.table, this.grid());
|
|
1875
1971
|
}
|
|
1876
1972
|
appendRow() {
|
|
1877
|
-
|
|
1973
|
+
pr(this.model(), this.rows.length), this.renderCells(), this.gizmos?.layout(this.table);
|
|
1878
1974
|
}
|
|
1879
1975
|
model() {
|
|
1880
1976
|
return {
|
|
@@ -1885,7 +1981,7 @@ var cr = Se.define(), lr = /* @__PURE__ */ new WeakMap(), ur = class extends k {
|
|
|
1885
1981
|
runOp(e, t) {
|
|
1886
1982
|
if (!this.table) return;
|
|
1887
1983
|
let n = this.model();
|
|
1888
|
-
if (t.kind === "insertColumn" ?
|
|
1984
|
+
if (t.kind === "insertColumn" ? dr(n, t.at) : t.kind === "deleteColumn" ? fr(n, t.at) : t.kind === "insertRow" ? pr(n, t.at) : t.kind === "deleteRow" ? mr(n, t.at) : hr(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") {
|
|
1889
1985
|
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));
|
|
1890
1986
|
this.cellAt(e, n)?.focus();
|
|
1891
1987
|
}
|
|
@@ -1895,18 +1991,20 @@ var cr = Se.define(), lr = /* @__PURE__ */ new WeakMap(), ur = class extends k {
|
|
|
1895
1991
|
this.rows[n] && (this.rows[n][r] = (e.textContent ?? "").replace(/\r?\n/g, " ")), t || this.paint(e, !1);
|
|
1896
1992
|
}
|
|
1897
1993
|
onFocusIn(e) {
|
|
1898
|
-
let t = e.target
|
|
1899
|
-
if (
|
|
1994
|
+
let t = e.target;
|
|
1995
|
+
if (t.closest("[data-stylo-cell-widget]")) return;
|
|
1996
|
+
let n = t.closest("td, th");
|
|
1997
|
+
if (!(!n || n === this.editing)) {
|
|
1900
1998
|
if (this.pressOnMark) {
|
|
1901
|
-
this.pressOnMark = !1, document.addEventListener("mouseup", () => setTimeout(() => this.enterCell(
|
|
1999
|
+
this.pressOnMark = !1, document.addEventListener("mouseup", () => setTimeout(() => this.enterCell(n)), { once: !0 });
|
|
1902
2000
|
return;
|
|
1903
2001
|
}
|
|
1904
|
-
this.enterCell(
|
|
2002
|
+
this.enterCell(n);
|
|
1905
2003
|
}
|
|
1906
2004
|
}
|
|
1907
2005
|
enterCell(e) {
|
|
1908
2006
|
if (!this.table?.contains(e) || e === this.editing) return;
|
|
1909
|
-
let t = this.pendingOffset ??
|
|
2007
|
+
let t = this.pendingOffset ?? y(e);
|
|
1910
2008
|
this.pendingOffset = null, this.editing && this.finish(this.editing, !1), this.editing = e, this.paint(e, !0), d(e, t);
|
|
1911
2009
|
}
|
|
1912
2010
|
onFocusOut(e) {
|
|
@@ -1940,14 +2038,14 @@ var cr = Se.define(), lr = /* @__PURE__ */ new WeakMap(), ur = class extends k {
|
|
|
1940
2038
|
to: i,
|
|
1941
2039
|
insert: n
|
|
1942
2040
|
},
|
|
1943
|
-
annotations:
|
|
2041
|
+
annotations: gr.of(!0),
|
|
1944
2042
|
userEvent: "input"
|
|
1945
2043
|
}), this.syncing = !1, t && (this.writeCaret(t), requestAnimationFrame(() => {
|
|
1946
2044
|
this.table && t && this.writeCaret(t);
|
|
1947
2045
|
})));
|
|
1948
2046
|
}
|
|
1949
2047
|
onKey(e, t) {
|
|
1950
|
-
this.table &&
|
|
2048
|
+
this.table && ur(e, t, {
|
|
1951
2049
|
coords: (e) => this.coords(e),
|
|
1952
2050
|
rows: () => this.rows.length,
|
|
1953
2051
|
cols: () => this.cols(),
|
|
@@ -1970,22 +2068,25 @@ var cr = Se.define(), lr = /* @__PURE__ */ new WeakMap(), ur = class extends k {
|
|
|
1970
2068
|
openCellMenuAt(e, t, n, r) {
|
|
1971
2069
|
let i = r?.closest("td, th");
|
|
1972
2070
|
if (!i) return;
|
|
1973
|
-
this.editing === i && !
|
|
1974
|
-
let a =
|
|
2071
|
+
this.editing === i && !tr(e) && s(i, t, n);
|
|
2072
|
+
let a = ir(e, i);
|
|
1975
2073
|
this.gizmos?.openFor(i, t, n, a);
|
|
1976
2074
|
}
|
|
1977
2075
|
toDOM(e) {
|
|
1978
2076
|
let t = document.createElement("div");
|
|
1979
2077
|
t.className = "cm-inplace-table-wrap";
|
|
1980
2078
|
let n = document.createElement("table");
|
|
1981
|
-
this.table = n, this.view = e, this.editing = null,
|
|
2079
|
+
this.table = n, this.view = e, this.editing = null, _r.set(n, this), n.className = "cm-inplace-table cm-inplace-table-edit", this.renderCells(), e.requestMeasure({
|
|
1982
2080
|
read: () => null,
|
|
1983
2081
|
write: () => this.repaintMarks(),
|
|
1984
2082
|
key: this
|
|
1985
2083
|
}), n.addEventListener("mousedown", (e) => {
|
|
1986
|
-
e.stopPropagation()
|
|
2084
|
+
if (e.stopPropagation(), e.target.closest("[data-stylo-cell-widget]")) {
|
|
2085
|
+
e.preventDefault();
|
|
2086
|
+
return;
|
|
2087
|
+
}
|
|
1987
2088
|
let t = e.target.closest("td, th");
|
|
1988
|
-
this.pendingOffset = t && t !== this.editing ?
|
|
2089
|
+
this.pendingOffset = t && t !== this.editing ? b(t, e.clientX, e.clientY) : null, this.pressOnMark = !!e.target.closest("[data-stylo-cell-mark]");
|
|
1989
2090
|
}), n.addEventListener("focusin", (e) => this.onFocusIn(e)), n.addEventListener("focusout", (e) => this.onFocusOut(e));
|
|
1990
2091
|
let r = (t) => {
|
|
1991
2092
|
t && (this.editing = t, this.finish(t, !0), this.sync(e));
|
|
@@ -1998,9 +2099,9 @@ var cr = Se.define(), lr = /* @__PURE__ */ new WeakMap(), ur = class extends k {
|
|
|
1998
2099
|
document.execCommand("insertText", !1, t);
|
|
1999
2100
|
}), n.addEventListener("contextmenu", (t) => {
|
|
2000
2101
|
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));
|
|
2001
|
-
}), this.longPress =
|
|
2102
|
+
}), this.longPress = cr(n, { onLongPress: (t, n, r) => {
|
|
2002
2103
|
this.longPressAt = Date.now(), this.openCellMenuAt(e, t, n, r);
|
|
2003
|
-
} }), this.gizmos =
|
|
2104
|
+
} }), this.gizmos = lr(document, {
|
|
2004
2105
|
dims: () => ({
|
|
2005
2106
|
cols: this.cols(),
|
|
2006
2107
|
rows: this.rows.length,
|
|
@@ -2012,12 +2113,12 @@ var cr = Se.define(), lr = /* @__PURE__ */ new WeakMap(), ur = class extends k {
|
|
|
2012
2113
|
destroy() {
|
|
2013
2114
|
this.longPress?.dispose(), this.longPress = null, this.gizmos?.destroy(), this.gizmos = null, this.table = null, this.view = null, this.editing = null;
|
|
2014
2115
|
}
|
|
2015
|
-
},
|
|
2116
|
+
}, yr = /* @__PURE__ */ new Set([
|
|
2016
2117
|
"-",
|
|
2017
2118
|
"*",
|
|
2018
2119
|
"_"
|
|
2019
|
-
]),
|
|
2020
|
-
if (!e.docChanged || e.isUserEvent("undo") || e.isUserEvent("redo") || e.annotation(
|
|
2120
|
+
]), br = we.transactionFilter.of((e) => {
|
|
2121
|
+
if (!e.docChanged || e.isUserEvent("undo") || e.isUserEvent("redo") || e.annotation(gr) || !e.startState.selection.main.empty) return e;
|
|
2021
2122
|
let t = e.startState.selection.main.head, n = "", r = 0;
|
|
2022
2123
|
if (e.changes.iterChanges((e, i, a, o, s) => {
|
|
2023
2124
|
r += 1, e === i && e === t && (n = s.toString());
|
|
@@ -2047,7 +2148,7 @@ var cr = Se.define(), lr = /* @__PURE__ */ new WeakMap(), ur = class extends k {
|
|
|
2047
2148
|
},
|
|
2048
2149
|
anchor: a + 1
|
|
2049
2150
|
};
|
|
2050
|
-
else if (
|
|
2151
|
+
else if (yr.has(n) && RegExp(`^\\${n}{3,}$`).test(s)) {
|
|
2051
2152
|
let e = o.number === 1 || i.line(o.number - 1).text.trim() === "", t = n === "-" && !e, r = o.number === i.lines;
|
|
2052
2153
|
if (t || r) {
|
|
2053
2154
|
let e = [];
|
|
@@ -2070,38 +2171,38 @@ var cr = Se.define(), lr = /* @__PURE__ */ new WeakMap(), ur = class extends k {
|
|
|
2070
2171
|
scrollIntoView: !0,
|
|
2071
2172
|
userEvent: "input.autoformat"
|
|
2072
2173
|
}] : e;
|
|
2073
|
-
}),
|
|
2174
|
+
}), xr = /* @__PURE__ */ new Set([
|
|
2074
2175
|
"EmphasisMark",
|
|
2075
2176
|
"CodeMark",
|
|
2076
2177
|
"StrikethroughMark"
|
|
2077
2178
|
]);
|
|
2078
|
-
function
|
|
2179
|
+
function Sr(e, t, n) {
|
|
2079
2180
|
let r = t;
|
|
2080
2181
|
for (;;) {
|
|
2081
2182
|
let t = e.resolveInner(r, n);
|
|
2082
|
-
if (!
|
|
2183
|
+
if (!xr.has(t.name) || t.from >= t.to) return r;
|
|
2083
2184
|
let i = n < 0 ? t.from : t.to;
|
|
2084
2185
|
if (i === r) return r;
|
|
2085
2186
|
r = i;
|
|
2086
2187
|
}
|
|
2087
2188
|
}
|
|
2088
|
-
function
|
|
2089
|
-
let n =
|
|
2189
|
+
function Cr(e, t) {
|
|
2190
|
+
let n = U(e, t, !0);
|
|
2090
2191
|
if (!n) return t;
|
|
2091
2192
|
let r = N(e);
|
|
2092
|
-
return t === n.contentTo ?
|
|
2193
|
+
return t === n.contentTo ? Sr(r, t, 1) : t === n.contentFrom ? Sr(r, t, -1) : t;
|
|
2093
2194
|
}
|
|
2094
|
-
var
|
|
2095
|
-
if (!e.docChanged || e.isUserEvent("undo") || e.isUserEvent("redo") || e.annotation(
|
|
2195
|
+
var wr = we.transactionFilter.of((e) => {
|
|
2196
|
+
if (!e.docChanged || e.isUserEvent("undo") || e.isUserEvent("redo") || e.annotation(gr)) return e;
|
|
2096
2197
|
let t = e.startState, n = t.selection.main;
|
|
2097
|
-
if (!n.empty || !
|
|
2198
|
+
if (!n.empty || !H(t, t.doc.lineAt(n.head).number)) return e;
|
|
2098
2199
|
let r = [], i = 0;
|
|
2099
2200
|
e.changes.iterChanges((e, t, a, o, s) => {
|
|
2100
2201
|
i++, e === t && e === n.head && s.length > 0 && r.push(s.toString());
|
|
2101
2202
|
});
|
|
2102
2203
|
let a = r[0];
|
|
2103
2204
|
if (i !== 1 || a === void 0) return e;
|
|
2104
|
-
let o =
|
|
2205
|
+
let o = Cr(t, n.head);
|
|
2105
2206
|
return o === n.head ? e : {
|
|
2106
2207
|
changes: {
|
|
2107
2208
|
from: o,
|
|
@@ -2111,8 +2212,8 @@ var gr = we.transactionFilter.of((e) => {
|
|
|
2111
2212
|
scrollIntoView: !0,
|
|
2112
2213
|
userEvent: "input.type"
|
|
2113
2214
|
};
|
|
2114
|
-
}),
|
|
2115
|
-
function
|
|
2215
|
+
}), Tr = RegExp(`^(?:${se.match.source.replace(/^\^/, "")})+`);
|
|
2216
|
+
function Er(e, t) {
|
|
2116
2217
|
let n = e.doc.lineAt(t).number;
|
|
2117
2218
|
for (let r = N(e).resolveInner(t, 1); r; r = r.parent) {
|
|
2118
2219
|
if (r.name !== "ListItem" || e.doc.lineAt(r.from).number === n) continue;
|
|
@@ -2121,13 +2222,13 @@ function vr(e, t) {
|
|
|
2121
2222
|
}
|
|
2122
2223
|
return null;
|
|
2123
2224
|
}
|
|
2124
|
-
function
|
|
2125
|
-
let n = t.text, r =
|
|
2225
|
+
function Dr(e, t) {
|
|
2226
|
+
let n = t.text, r = _.exec(n);
|
|
2126
2227
|
if (r) return {
|
|
2127
2228
|
prefixLen: r[0].length,
|
|
2128
2229
|
drop: [0, r[0].length]
|
|
2129
2230
|
};
|
|
2130
|
-
let i =
|
|
2231
|
+
let i = Tr.exec(n);
|
|
2131
2232
|
if (i) {
|
|
2132
2233
|
let e = se.match.exec(n)[0].length;
|
|
2133
2234
|
return {
|
|
@@ -2140,11 +2241,11 @@ function yr(e, t) {
|
|
|
2140
2241
|
prefixLen: a[0].length,
|
|
2141
2242
|
drop: [0, a[0].length]
|
|
2142
2243
|
};
|
|
2143
|
-
let o = te.match.exec(n) ??
|
|
2244
|
+
let o = te.match.exec(n) ?? ae.match.exec(n);
|
|
2144
2245
|
if (o) {
|
|
2145
2246
|
let n = o[1] ?? "", r = o[0].length - n.length;
|
|
2146
2247
|
if (n) {
|
|
2147
|
-
let r =
|
|
2248
|
+
let r = Er(e, t.from) ?? 2, i = n.startsWith(" ") ? 1 : Math.min(r, n.length);
|
|
2148
2249
|
return {
|
|
2149
2250
|
prefixLen: o[0].length,
|
|
2150
2251
|
drop: [0, i]
|
|
@@ -2157,15 +2258,15 @@ function yr(e, t) {
|
|
|
2157
2258
|
}
|
|
2158
2259
|
return null;
|
|
2159
2260
|
}
|
|
2160
|
-
var
|
|
2261
|
+
var Or = j.high(k.of([{
|
|
2161
2262
|
key: "Backspace",
|
|
2162
2263
|
run: (e) => {
|
|
2163
2264
|
if (h(e)) return !1;
|
|
2164
2265
|
let { state: t } = e, n = t.selection.main;
|
|
2165
2266
|
if (!n.empty) return !1;
|
|
2166
2267
|
let r = t.doc.lineAt(n.head);
|
|
2167
|
-
if (!
|
|
2168
|
-
let i =
|
|
2268
|
+
if (!H(t, r.number)) return !1;
|
|
2269
|
+
let i = Dr(t, r);
|
|
2169
2270
|
if (!i || n.head < r.from || n.head > r.from + i.prefixLen) return !1;
|
|
2170
2271
|
let [a, o] = i.drop;
|
|
2171
2272
|
return e.dispatch({
|
|
@@ -2179,12 +2280,12 @@ var br = j.high(ve.of([{
|
|
|
2179
2280
|
scrollIntoView: !0
|
|
2180
2281
|
}), !0;
|
|
2181
2282
|
}
|
|
2182
|
-
}])),
|
|
2283
|
+
}])), kr = class {
|
|
2183
2284
|
menu;
|
|
2184
2285
|
contentDOM;
|
|
2185
2286
|
onClick;
|
|
2186
2287
|
constructor(e) {
|
|
2187
|
-
this.menu =
|
|
2288
|
+
this.menu = Q(e.dom.ownerDocument), e.dom.appendChild(this.menu.el), this.contentDOM = e.contentDOM, this.onClick = (t) => {
|
|
2188
2289
|
if (e.state.facet(L) !== "never" || !e.state.facet(P).links) return;
|
|
2189
2290
|
let n = t.target?.closest(".cm-inplace-link");
|
|
2190
2291
|
if (!n || n.classList.contains("cm-inplace-wikilink")) return;
|
|
@@ -2197,13 +2298,13 @@ var br = j.high(ve.of([{
|
|
|
2197
2298
|
if (n == null) return;
|
|
2198
2299
|
r = n;
|
|
2199
2300
|
}
|
|
2200
|
-
e.dispatch({ selection: { anchor: r } }), this.menu.showField(
|
|
2301
|
+
e.dispatch({ selection: { anchor: r } }), this.menu.showField(Wn(e), t.clientX, t.clientY);
|
|
2201
2302
|
}, this.contentDOM.addEventListener("click", this.onClick);
|
|
2202
2303
|
}
|
|
2203
2304
|
destroy() {
|
|
2204
2305
|
this.contentDOM.removeEventListener("click", this.onClick), this.menu.destroy();
|
|
2205
2306
|
}
|
|
2206
|
-
},
|
|
2307
|
+
}, Ar = D.fromClass(kr), jr = (e) => e.replace(/^<([^]*)>$/, "$1").trim(), Mr = (e, t, n) => n ? {
|
|
2207
2308
|
pos: e,
|
|
2208
2309
|
end: t,
|
|
2209
2310
|
above: !0,
|
|
@@ -2212,27 +2313,27 @@ var br = j.high(ve.of([{
|
|
|
2212
2313
|
return e.className = "cm-inplace-href-tip", e.textContent = n, { dom: e };
|
|
2213
2314
|
}
|
|
2214
2315
|
} : null;
|
|
2215
|
-
function
|
|
2316
|
+
function Nr(e, t) {
|
|
2216
2317
|
for (let n = N(e.state).resolveInner(t, -1); n; n = n.parent) {
|
|
2217
2318
|
if (n.name !== "Link") continue;
|
|
2218
2319
|
if (e.state.doc.sliceString(Math.max(0, n.from - 1), n.from) === "[") break;
|
|
2219
2320
|
let t = n.getChild("URL"), r = t ? e.state.sliceDoc(t.from, t.to) : e.state.sliceDoc(n.from, n.to);
|
|
2220
|
-
return
|
|
2321
|
+
return Mr(n.from, n.to, jr(r));
|
|
2221
2322
|
}
|
|
2222
2323
|
return null;
|
|
2223
2324
|
}
|
|
2224
|
-
function
|
|
2325
|
+
function Pr(t, n) {
|
|
2225
2326
|
let r = t.state.doc.lineAt(n);
|
|
2226
2327
|
for (let t of r.text.matchAll(e)) {
|
|
2227
2328
|
let e = r.from + (t.index ?? 0), i = e + t[0].length;
|
|
2228
|
-
if (!(n < e || n > i)) return
|
|
2329
|
+
if (!(n < e || n > i)) return Mr(e, i, (t[1] ?? "").trim());
|
|
2229
2330
|
}
|
|
2230
2331
|
return null;
|
|
2231
2332
|
}
|
|
2232
|
-
var
|
|
2333
|
+
var Fr = ve((e, t) => {
|
|
2233
2334
|
let n = e.state.facet(P);
|
|
2234
|
-
return (n.links ?
|
|
2235
|
-
}),
|
|
2335
|
+
return (n.links ? Nr(e, t) : null) ?? (n.wikilinks ? Pr(e, t) : null);
|
|
2336
|
+
}), Ir = class extends O {
|
|
2236
2337
|
ref;
|
|
2237
2338
|
inline;
|
|
2238
2339
|
registry;
|
|
@@ -2259,19 +2360,19 @@ var Dr = _e((e, t) => {
|
|
|
2259
2360
|
return !1;
|
|
2260
2361
|
}
|
|
2261
2362
|
};
|
|
2262
|
-
function
|
|
2363
|
+
function Lr(e) {
|
|
2263
2364
|
let t = e.facet(F);
|
|
2264
|
-
if (!t || !e.facet(P).embeds || !e.doc.toString().includes("![[")) return
|
|
2265
|
-
let n =
|
|
2365
|
+
if (!t || !e.facet(P).embeds || !e.doc.toString().includes("![[")) return T.none;
|
|
2366
|
+
let n = B(e), r = N(e), i = [];
|
|
2266
2367
|
for (let a = 1; a <= e.doc.lines; a++) {
|
|
2267
2368
|
let o = e.doc.line(a);
|
|
2268
2369
|
if (!(!o.text.includes("![[") || n.has(a))) {
|
|
2269
2370
|
if (fe(o.text)) {
|
|
2270
2371
|
C.lastIndex = 0;
|
|
2271
2372
|
let e = (C.exec(o.text.trim())?.[1] ?? "").trim();
|
|
2272
|
-
if (!e ||
|
|
2273
|
-
i.push(
|
|
2274
|
-
widget: new
|
|
2373
|
+
if (!e || V(r, o.from + o.text.indexOf("!["))) continue;
|
|
2374
|
+
i.push(T.replace({
|
|
2375
|
+
widget: new Ir(e, !1, t),
|
|
2275
2376
|
block: !0
|
|
2276
2377
|
}).range(o.from, o.to));
|
|
2277
2378
|
continue;
|
|
@@ -2281,30 +2382,30 @@ function kr(e) {
|
|
|
2281
2382
|
let n = (e[1] ?? "").trim();
|
|
2282
2383
|
if (!n) continue;
|
|
2283
2384
|
let a = o.from + (e.index ?? 0);
|
|
2284
|
-
|
|
2385
|
+
V(r, a + 2) || qe(r, a + 2) || i.push(T.replace({ widget: new Ir(n, !0, t) }).range(a, a + e[0].length));
|
|
2285
2386
|
}
|
|
2286
2387
|
}
|
|
2287
2388
|
}
|
|
2288
|
-
return
|
|
2389
|
+
return T.set(i, !0);
|
|
2289
2390
|
}
|
|
2290
|
-
function
|
|
2391
|
+
function Rr(e, t) {
|
|
2291
2392
|
for (let n of t.ranges) {
|
|
2292
2393
|
let t = e.doc.lineAt(n.from).number, r = e.doc.lineAt(n.to).number;
|
|
2293
2394
|
for (let n = t; n <= r; n++) if (e.doc.line(n).text.includes("![[")) return !0;
|
|
2294
2395
|
}
|
|
2295
2396
|
return !1;
|
|
2296
2397
|
}
|
|
2297
|
-
var
|
|
2298
|
-
create:
|
|
2299
|
-
update: (e, t) => t.docChanged || t.selection && (
|
|
2300
|
-
provide: (e) => [
|
|
2301
|
-
}),
|
|
2398
|
+
var zr = M.define({
|
|
2399
|
+
create: Lr,
|
|
2400
|
+
update: (e, t) => t.docChanged || t.selection && (Rr(t.state, t.startState.selection) || Rr(t.state, t.state.selection)) ? Lr(t.state) : e,
|
|
2401
|
+
provide: (e) => [E.decorations.from(e), E.atomicRanges.of((t) => t.state.field(e))]
|
|
2402
|
+
}), Br = Te.define(), Vr = M.define({
|
|
2302
2403
|
create: () => !1,
|
|
2303
2404
|
update(e, t) {
|
|
2304
|
-
for (let n of t.effects) n.is(
|
|
2405
|
+
for (let n of t.effects) n.is(Br) && (e = n.value);
|
|
2305
2406
|
return e;
|
|
2306
2407
|
}
|
|
2307
|
-
}),
|
|
2408
|
+
}), Hr = class {
|
|
2308
2409
|
view;
|
|
2309
2410
|
menu;
|
|
2310
2411
|
onContextMenu;
|
|
@@ -2315,8 +2416,8 @@ var jr = M.define({
|
|
|
2315
2416
|
longPressAt = 0;
|
|
2316
2417
|
destroyed = !1;
|
|
2317
2418
|
constructor(e) {
|
|
2318
|
-
this.view = e, this.menu =
|
|
2319
|
-
this.destroyed || e.dispatch({ effects:
|
|
2419
|
+
this.view = e, this.menu = Q(e.dom.ownerDocument, "cm-inplace-menu", (t) => {
|
|
2420
|
+
this.destroyed || e.dispatch({ effects: Br.of(t) });
|
|
2320
2421
|
}), e.dom.appendChild(this.menu.el), this.contentDOM = e.contentDOM, this.onPointerDown = () => {
|
|
2321
2422
|
let t = e.state.selection.main;
|
|
2322
2423
|
this.stashed = t.empty ? null : {
|
|
@@ -2326,17 +2427,17 @@ var jr = M.define({
|
|
|
2326
2427
|
}, this.contentDOM.addEventListener("pointerdown", this.onPointerDown, !0), this.onContextMenu = (e) => {
|
|
2327
2428
|
let t = e.target;
|
|
2328
2429
|
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()));
|
|
2329
|
-
}, this.contentDOM.addEventListener("contextmenu", this.onContextMenu), this.longPress =
|
|
2430
|
+
}, this.contentDOM.addEventListener("contextmenu", this.onContextMenu), this.longPress = cr(this.contentDOM, { onLongPress: (e, t, n) => {
|
|
2330
2431
|
this.longPressAt = Date.now(), this.openMenuAt(e, t, n);
|
|
2331
2432
|
} });
|
|
2332
2433
|
}
|
|
2333
2434
|
canOpen() {
|
|
2334
2435
|
let { state: e } = this.view;
|
|
2335
|
-
return e.facet(Ne) && (!e.readOnly ||
|
|
2436
|
+
return e.facet(Ne) && (!e.readOnly || In(this.view));
|
|
2336
2437
|
}
|
|
2337
2438
|
rows() {
|
|
2338
2439
|
let e = this.view;
|
|
2339
|
-
return e.state.readOnly ?
|
|
2440
|
+
return e.state.readOnly ? Ln(e, { selected: !e.state.selection.main.empty }) : sr(e);
|
|
2340
2441
|
}
|
|
2341
2442
|
openMenuAt(e, t, n) {
|
|
2342
2443
|
let r = this.view;
|
|
@@ -2353,7 +2454,7 @@ var jr = M.define({
|
|
|
2353
2454
|
y: t
|
|
2354
2455
|
});
|
|
2355
2456
|
if (n != null) {
|
|
2356
|
-
let e =
|
|
2457
|
+
let e = U(r.state, n, !1, !0), t = r.state.wordAt(n) ?? { anchor: n };
|
|
2357
2458
|
e?.kind === "link" ? t = {
|
|
2358
2459
|
anchor: e.from,
|
|
2359
2460
|
head: e.to
|
|
@@ -2372,10 +2473,10 @@ var jr = M.define({
|
|
|
2372
2473
|
destroy() {
|
|
2373
2474
|
this.destroyed = !0, this.contentDOM.removeEventListener("pointerdown", this.onPointerDown, !0), this.contentDOM.removeEventListener("contextmenu", this.onContextMenu), this.longPress.dispose(), this.menu.destroy();
|
|
2374
2475
|
}
|
|
2375
|
-
},
|
|
2476
|
+
}, Ur = D.fromClass(Hr);
|
|
2376
2477
|
//#endregion
|
|
2377
2478
|
//#region src/inplace/selection-bar-position.ts
|
|
2378
|
-
function
|
|
2479
|
+
function Wr(e) {
|
|
2379
2480
|
let t = e.state.selection.main;
|
|
2380
2481
|
if (!t.empty) {
|
|
2381
2482
|
let n = e.coordsAtPos(t.from), r = e.coordsAtPos(t.to);
|
|
@@ -2389,7 +2490,7 @@ function Fr(e) {
|
|
|
2389
2490
|
}
|
|
2390
2491
|
};
|
|
2391
2492
|
}
|
|
2392
|
-
if (!
|
|
2493
|
+
if (!tr(e)) return null;
|
|
2393
2494
|
let n = e.dom.ownerDocument.getSelection();
|
|
2394
2495
|
if (!n || n.rangeCount === 0) return null;
|
|
2395
2496
|
let r = n.getRangeAt(0).getBoundingClientRect();
|
|
@@ -2403,9 +2504,9 @@ function Fr(e) {
|
|
|
2403
2504
|
}
|
|
2404
2505
|
};
|
|
2405
2506
|
}
|
|
2406
|
-
function
|
|
2407
|
-
if (e.state.facet(Ve) !== "bar" || e.state.readOnly || e.state.field(
|
|
2408
|
-
let r =
|
|
2507
|
+
function Gr(e, t, n) {
|
|
2508
|
+
if (e.state.facet(Ve) !== "bar" || e.state.readOnly || e.state.field(Vr, !1)) return null;
|
|
2509
|
+
let r = Wr(e);
|
|
2409
2510
|
if (!r) return null;
|
|
2410
2511
|
let { box: i, inCell: a } = r;
|
|
2411
2512
|
if (!a && !e.hasFocus) return null;
|
|
@@ -2423,7 +2524,7 @@ function Ir(e, t, n) {
|
|
|
2423
2524
|
}
|
|
2424
2525
|
//#endregion
|
|
2425
2526
|
//#region src/inplace/selection-bar.ts
|
|
2426
|
-
var
|
|
2527
|
+
var Kr = class {
|
|
2427
2528
|
view;
|
|
2428
2529
|
bar;
|
|
2429
2530
|
ids;
|
|
@@ -2438,12 +2539,12 @@ var Lr = class {
|
|
|
2438
2539
|
constructor(e) {
|
|
2439
2540
|
this.view = e;
|
|
2440
2541
|
let t = e.dom.ownerDocument;
|
|
2441
|
-
this.ids = e.state.facet(Be), this.linkMenu =
|
|
2542
|
+
this.ids = e.state.facet(Be), 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;
|
|
2442
2543
|
for (let n of this.ids) {
|
|
2443
2544
|
let r = g[n], i = t.createElement("button");
|
|
2444
|
-
i.type = "button", i.className = "cm-inplace-selbar-btn", i.title = r.title, i.setAttribute("aria-label", r.title), i.appendChild(
|
|
2545
|
+
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) => {
|
|
2445
2546
|
t.preventDefault();
|
|
2446
|
-
let a = !!h(e), o = !a && n === "link" ?
|
|
2547
|
+
let a = !!h(e), o = !a && n === "link" ? Wn(e) : !a && n === "wikilink" ? Gn(e) : null;
|
|
2447
2548
|
if (o) {
|
|
2448
2549
|
let e = i.getBoundingClientRect();
|
|
2449
2550
|
this.linkMenu.showField(o, e.left, e.bottom + 6);
|
|
@@ -2455,7 +2556,7 @@ var Lr = class {
|
|
|
2455
2556
|
e.dom.appendChild(this.bar), t.addEventListener("scroll", this.onScroll, !0), t.addEventListener("selectionchange", this.onSelectionChange);
|
|
2456
2557
|
}
|
|
2457
2558
|
update(e) {
|
|
2458
|
-
let t = e.startState.field(
|
|
2559
|
+
let t = e.startState.field(Vr, !1) !== e.state.field(Vr, !1), n = e.startState.readOnly !== e.state.readOnly;
|
|
2459
2560
|
(e.selectionSet || e.docChanged || e.focusChanged || t || n) && this.schedule();
|
|
2460
2561
|
}
|
|
2461
2562
|
schedule() {
|
|
@@ -2466,7 +2567,7 @@ var Lr = class {
|
|
|
2466
2567
|
});
|
|
2467
2568
|
}
|
|
2468
2569
|
measure() {
|
|
2469
|
-
return
|
|
2570
|
+
return Gr(this.view, this.bar, this.ids);
|
|
2470
2571
|
}
|
|
2471
2572
|
apply(e) {
|
|
2472
2573
|
if (!e) {
|
|
@@ -2480,42 +2581,46 @@ var Lr = class {
|
|
|
2480
2581
|
let e = this.view.dom.ownerDocument;
|
|
2481
2582
|
e.removeEventListener("scroll", this.onScroll, !0), e.removeEventListener("selectionchange", this.onSelectionChange), this.linkMenu.destroy(), this.bar.remove();
|
|
2482
2583
|
}
|
|
2483
|
-
},
|
|
2584
|
+
}, qr = D.fromClass(Kr), Jr = (e) => (t) => {
|
|
2484
2585
|
if (h(t)) return !1;
|
|
2485
2586
|
let n = t.state.selection.main;
|
|
2486
2587
|
if (!n.empty) return !1;
|
|
2487
2588
|
let { doc: r } = t.state, i = r.lineAt(n.head), a = e ? i.number + 1 : i.number - 1;
|
|
2488
2589
|
if (a < 1 || a > r.lines) return !1;
|
|
2489
2590
|
let o = r.line(a), s = -1, c = -1, l;
|
|
2490
|
-
if (t.state.field(
|
|
2591
|
+
if (t.state.field(Z).between(o.from, o.to, (t, n, r) => {
|
|
2491
2592
|
if (e ? t === o.from : n === o.to) return s = t, c = n, l = r.spec.widget, !1;
|
|
2492
2593
|
}), s < 0) return !1;
|
|
2493
|
-
if (t.state.facet(I) === "cells") return l instanceof
|
|
2594
|
+
if (t.state.facet(I) === "cells") return l instanceof vr && l.focusEdge(e ? "first" : "last");
|
|
2494
2595
|
let u = e ? r.lineAt(s).from : r.lineAt(c).to;
|
|
2495
2596
|
return t.dispatch({
|
|
2496
2597
|
selection: { anchor: u },
|
|
2497
2598
|
userEvent: "select",
|
|
2498
2599
|
scrollIntoView: !0
|
|
2499
2600
|
}), !0;
|
|
2500
|
-
},
|
|
2601
|
+
}, Yr = Jr(!0), Xr = Jr(!1), Zr = j.high(k.of([{
|
|
2501
2602
|
key: "ArrowDown",
|
|
2502
|
-
run:
|
|
2603
|
+
run: Yr
|
|
2503
2604
|
}, {
|
|
2504
2605
|
key: "ArrowUp",
|
|
2505
|
-
run:
|
|
2506
|
-
}])),
|
|
2507
|
-
last =
|
|
2606
|
+
run: Xr
|
|
2607
|
+
}])), Qr = "[[],[]]", $r = D.fromClass(class {
|
|
2608
|
+
last = Qr;
|
|
2508
2609
|
update(e) {
|
|
2509
|
-
let t = JSON.stringify(
|
|
2510
|
-
|
|
2610
|
+
let { state: t } = e, n = JSON.stringify([t.facet(Le)(t), t.facet(Re)(t).map((e) => [
|
|
2611
|
+
e.pos,
|
|
2612
|
+
e.key,
|
|
2613
|
+
e.cellClass
|
|
2614
|
+
])]);
|
|
2615
|
+
n === this.last && !e.docChanged || (n !== Qr || this.last !== Qr) && (this.last = n, e.view.requestMeasure({
|
|
2511
2616
|
read: () => null,
|
|
2512
2617
|
write: (e, t) => {
|
|
2513
|
-
for (let e of t.dom.querySelectorAll(".cm-inplace-table
|
|
2618
|
+
for (let e of t.dom.querySelectorAll(".cm-inplace-table")) _r.get(e)?.repaintMarks(), bn.get(e)?.();
|
|
2514
2619
|
},
|
|
2515
2620
|
key: this
|
|
2516
2621
|
}));
|
|
2517
2622
|
}
|
|
2518
|
-
}),
|
|
2623
|
+
}), ei = {
|
|
2519
2624
|
".cm-inplace-callout": {
|
|
2520
2625
|
borderLeft: "0.25rem solid var(--stylo-callout-accent, var(--stylo-border))",
|
|
2521
2626
|
padding: "0 var(--stylo-rhythm-callout-padding-x, 1rem)",
|
|
@@ -2549,9 +2654,9 @@ var Lr = class {
|
|
|
2549
2654
|
content: "\"\"",
|
|
2550
2655
|
display: "none"
|
|
2551
2656
|
}
|
|
2552
|
-
},
|
|
2657
|
+
}, ti = "var(--stylo-font-family-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace)", ni = "var(--stylo-font-family, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif)", ri = {
|
|
2553
2658
|
"& .cm-content": {
|
|
2554
|
-
fontFamily:
|
|
2659
|
+
fontFamily: ni,
|
|
2555
2660
|
lineHeight: "1.75",
|
|
2556
2661
|
padding: "0.75rem",
|
|
2557
2662
|
WebkitTouchCallout: "none"
|
|
@@ -2594,14 +2699,14 @@ var Lr = class {
|
|
|
2594
2699
|
".cm-inplace-em": { fontStyle: "italic" },
|
|
2595
2700
|
".cm-inplace-strike": { textDecoration: "line-through" },
|
|
2596
2701
|
".cm-inplace-code": {
|
|
2597
|
-
fontFamily:
|
|
2702
|
+
fontFamily: ti,
|
|
2598
2703
|
fontSize: "0.9em",
|
|
2599
2704
|
padding: "0.1em 0.35em",
|
|
2600
2705
|
borderRadius: "3px",
|
|
2601
2706
|
background: "color-mix(in srgb, var(--stylo-border) 45%, transparent)"
|
|
2602
2707
|
},
|
|
2603
2708
|
".cm-inplace-mono": {
|
|
2604
|
-
fontFamily:
|
|
2709
|
+
fontFamily: ti,
|
|
2605
2710
|
fontSize: "0.9em",
|
|
2606
2711
|
background: "color-mix(in srgb, var(--stylo-border) 35%, transparent)",
|
|
2607
2712
|
padding: "0 0.9rem"
|
|
@@ -2679,21 +2784,21 @@ var Lr = class {
|
|
|
2679
2784
|
cursor: "pointer"
|
|
2680
2785
|
},
|
|
2681
2786
|
".cm-inplace-fm": {
|
|
2682
|
-
fontFamily:
|
|
2787
|
+
fontFamily: ti,
|
|
2683
2788
|
fontSize: "0.85em",
|
|
2684
2789
|
color: "var(--stylo-text-muted)"
|
|
2685
2790
|
},
|
|
2686
2791
|
".cm-inplace-fm-first::before": {
|
|
2687
2792
|
content: "\"Frontmatter\"",
|
|
2688
2793
|
marginRight: "0.6em",
|
|
2689
|
-
fontFamily:
|
|
2794
|
+
fontFamily: ni,
|
|
2690
2795
|
fontSize: "0.8rem",
|
|
2691
2796
|
fontWeight: "600",
|
|
2692
2797
|
textTransform: "uppercase",
|
|
2693
2798
|
letterSpacing: "0.04em",
|
|
2694
2799
|
color: "var(--stylo-text-muted)"
|
|
2695
2800
|
}
|
|
2696
|
-
},
|
|
2801
|
+
}, ii = {
|
|
2697
2802
|
".cm-inplace-menu": {
|
|
2698
2803
|
position: "fixed",
|
|
2699
2804
|
inset: "0",
|
|
@@ -2767,7 +2872,7 @@ var Lr = class {
|
|
|
2767
2872
|
outline: "none"
|
|
2768
2873
|
},
|
|
2769
2874
|
".cm-inplace-menu-input:focus": { borderColor: "var(--stylo-ring)" }
|
|
2770
|
-
},
|
|
2875
|
+
}, ai = {
|
|
2771
2876
|
".cm-inplace-selbar": {
|
|
2772
2877
|
position: "fixed",
|
|
2773
2878
|
zIndex: "20",
|
|
@@ -2852,7 +2957,7 @@ var Lr = class {
|
|
|
2852
2957
|
lineHeight: "1.4",
|
|
2853
2958
|
wordBreak: "break-all"
|
|
2854
2959
|
}
|
|
2855
|
-
},
|
|
2960
|
+
}, oi = {
|
|
2856
2961
|
".cm-inplace-table": {
|
|
2857
2962
|
borderCollapse: "collapse",
|
|
2858
2963
|
padding: "1em 0 1.4em",
|
|
@@ -2875,7 +2980,7 @@ var Lr = class {
|
|
|
2875
2980
|
outline: "none"
|
|
2876
2981
|
},
|
|
2877
2982
|
".cm-inplace-table-edit .cm-inplace-tcell:focus": { boxShadow: "inset 0 0 0 2px var(--stylo-ring)" }
|
|
2878
|
-
},
|
|
2983
|
+
}, si = {
|
|
2879
2984
|
".cm-inplace-table-wrap": {
|
|
2880
2985
|
position: "relative",
|
|
2881
2986
|
display: "inline-block",
|
|
@@ -2917,15 +3022,15 @@ var Lr = class {
|
|
|
2917
3022
|
},
|
|
2918
3023
|
".cm-inplace-tg-edge:hover .cm-inplace-tg-plus": { color: "var(--stylo-text)" },
|
|
2919
3024
|
"@media (hover: none)": { ".cm-inplace-tg-edge": { opacity: "0.5" } }
|
|
2920
|
-
},
|
|
2921
|
-
...
|
|
2922
|
-
...
|
|
2923
|
-
...
|
|
2924
|
-
...
|
|
2925
|
-
...
|
|
2926
|
-
...
|
|
2927
|
-
}),
|
|
2928
|
-
function
|
|
3025
|
+
}, ci = E.theme({
|
|
3026
|
+
...ri,
|
|
3027
|
+
...ei,
|
|
3028
|
+
...oi,
|
|
3029
|
+
...si,
|
|
3030
|
+
...ii,
|
|
3031
|
+
...ai
|
|
3032
|
+
}), li = ".cm-inplace-math, .cm-inplace-hr, .cm-inplace-table, .cm-inplace-embed, .cm-inplace-embed-inline";
|
|
3033
|
+
function ui(e = {}) {
|
|
2929
3034
|
let t = Fe(e.inPlace?.contextMenu);
|
|
2930
3035
|
return [
|
|
2931
3036
|
P.of(je(e.inPlace)),
|
|
@@ -2934,43 +3039,44 @@ function ei(e = {}) {
|
|
|
2934
3039
|
L.of(e.inPlace?.reveal ?? "caret"),
|
|
2935
3040
|
Me.of(e.onLinkClick ?? null),
|
|
2936
3041
|
Ne.of(t.enabled),
|
|
2937
|
-
|
|
3042
|
+
z.of(t.groups),
|
|
2938
3043
|
Ie.of(e.hostItems ?? (() => t.items)),
|
|
2939
3044
|
Le.of(e.cellMarks ?? e.inPlace?.cellMarks ?? (() => [])),
|
|
3045
|
+
Re.of(e.cellWidgets ?? e.inPlace?.cellWidgets ?? (() => [])),
|
|
2940
3046
|
Ve.of(e.inPlace?.selectionUI ?? "menu"),
|
|
2941
3047
|
Be.of(ze(e.inPlace?.selectionBarItems)),
|
|
2942
3048
|
Dt(),
|
|
2943
|
-
|
|
2944
|
-
|
|
3049
|
+
Or,
|
|
3050
|
+
cn,
|
|
2945
3051
|
Rt,
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
3052
|
+
Zr,
|
|
3053
|
+
wr,
|
|
3054
|
+
br,
|
|
2949
3055
|
nt,
|
|
2950
|
-
|
|
3056
|
+
zr,
|
|
2951
3057
|
Ue,
|
|
2952
|
-
|
|
3058
|
+
Z,
|
|
3059
|
+
$r,
|
|
3060
|
+
Vr,
|
|
2953
3061
|
Ur,
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
j.high(Qr),
|
|
2962
|
-
D.domEventHandlers({
|
|
3062
|
+
qr,
|
|
3063
|
+
Ar,
|
|
3064
|
+
Fr,
|
|
3065
|
+
$n,
|
|
3066
|
+
er,
|
|
3067
|
+
j.high(ci),
|
|
3068
|
+
E.domEventHandlers({
|
|
2963
3069
|
mousedown(e, t) {
|
|
2964
3070
|
let n = e.target;
|
|
2965
3071
|
if (n?.closest(".cm-inplace-table-edit") || n?.closest(".stylo-embed-content")) return !1;
|
|
2966
|
-
let r = n?.closest(
|
|
3072
|
+
let r = n?.closest(li);
|
|
2967
3073
|
if (!r) return !1;
|
|
2968
3074
|
let i = t.posAtDOM(r);
|
|
2969
3075
|
if (i < 0) return !1;
|
|
2970
3076
|
let a = n?.closest("[data-stylo-row]");
|
|
2971
3077
|
if (a && r.contains(a)) {
|
|
2972
3078
|
let n = v(t.state.doc, i, Number(a.dataset.styloRow), Number(a.dataset.styloCol));
|
|
2973
|
-
n != null && (i = n +
|
|
3079
|
+
n != null && (i = n + b(a, e.clientX, e.clientY));
|
|
2974
3080
|
}
|
|
2975
3081
|
return t.focus(), t.dispatch({ selection: { anchor: i } }), !0;
|
|
2976
3082
|
},
|
|
@@ -2984,8 +3090,8 @@ function ei(e = {}) {
|
|
|
2984
3090
|
}
|
|
2985
3091
|
//#endregion
|
|
2986
3092
|
//#region src/inplace/InPlaceView.tsx
|
|
2987
|
-
var
|
|
2988
|
-
function
|
|
3093
|
+
var di = () => () => {}, fi = () => null;
|
|
3094
|
+
function pi({ 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 }) {
|
|
2989
3095
|
let te = w(a);
|
|
2990
3096
|
te.current = a;
|
|
2991
3097
|
let re = w(o);
|
|
@@ -2994,13 +3100,15 @@ function ri({ value: e, onChange: t, readOnly: r, placeholder: i, onWikiLinkClic
|
|
|
2994
3100
|
ie.current = s?.contextMenu;
|
|
2995
3101
|
let g = w(s?.cellMarks);
|
|
2996
3102
|
g.current = s?.cellMarks;
|
|
2997
|
-
let
|
|
2998
|
-
|
|
2999
|
-
let
|
|
3000
|
-
|
|
3103
|
+
let ae = w(s?.cellWidgets);
|
|
3104
|
+
ae.current = s?.cellWidgets;
|
|
3105
|
+
let [_] = ge(() => new ke()), oe = _e(_.subscribe, _.getSnapshot, _.getSnapshot), [se, v] = ge(null), le = w(m);
|
|
3106
|
+
le.current = m;
|
|
3107
|
+
let ue = w((e) => {
|
|
3108
|
+
v(e), le.current?.(e);
|
|
3001
3109
|
}).current, y = w(h);
|
|
3002
3110
|
y.current = h;
|
|
3003
|
-
let [b] =
|
|
3111
|
+
let [b] = ge(() => h ? new ne() : null), x = _e(b?.subscribe ?? di, b?.getSnapshot ?? fi), [S] = ge(() => [ui({
|
|
3004
3112
|
onWikiLinkClick: (e) => te.current?.(e),
|
|
3005
3113
|
onLinkClick: (e) => re.current?.(e),
|
|
3006
3114
|
inPlace: s,
|
|
@@ -3009,33 +3117,34 @@ function ri({ value: e, onChange: t, readOnly: r, placeholder: i, onWikiLinkClic
|
|
|
3009
3117
|
return typeof e == "object" ? e.items ?? [] : [];
|
|
3010
3118
|
},
|
|
3011
3119
|
cellMarks: (e) => g.current?.(e) ?? [],
|
|
3120
|
+
cellWidgets: (e) => ae.current?.(e) ?? [],
|
|
3012
3121
|
embedRegistry: d ? _ : void 0
|
|
3013
|
-
}), ...b ? [ye.of(b.panel)] : []]),
|
|
3122
|
+
}), ...b ? [ye.of(b.panel)] : []]), de = ce({
|
|
3014
3123
|
value: e,
|
|
3015
3124
|
onChange: t,
|
|
3016
3125
|
readOnly: r,
|
|
3017
3126
|
placeholder: i,
|
|
3018
|
-
extensions:
|
|
3127
|
+
extensions: S,
|
|
3019
3128
|
codeLanguages: c,
|
|
3020
3129
|
wikiLinkSource: l,
|
|
3021
3130
|
tagSource: u,
|
|
3022
3131
|
onResolveError: f,
|
|
3023
3132
|
onSave: p,
|
|
3024
|
-
onViewChange:
|
|
3133
|
+
onViewChange: ue,
|
|
3025
3134
|
hostExtensions: ee
|
|
3026
3135
|
});
|
|
3027
3136
|
return /* @__PURE__ */ De("div", {
|
|
3028
3137
|
className: n.inplace,
|
|
3029
|
-
ref:
|
|
3030
|
-
children: [d &&
|
|
3138
|
+
ref: de,
|
|
3139
|
+
children: [d && oe.map((e) => be(/* @__PURE__ */ Ee(pe, {
|
|
3031
3140
|
reference: e.ref,
|
|
3032
3141
|
source: d,
|
|
3033
3142
|
onError: f,
|
|
3034
3143
|
inline: e.inline
|
|
3035
|
-
}), e.el, String(e.id))), x && y.current && be(y.current({ view:
|
|
3144
|
+
}), e.el, String(e.id))), x && y.current && be(y.current({ view: se }), x)]
|
|
3036
3145
|
});
|
|
3037
3146
|
}
|
|
3038
3147
|
//#endregion
|
|
3039
|
-
export {
|
|
3148
|
+
export { pi as InPlaceView };
|
|
3040
3149
|
|
|
3041
|
-
//# sourceMappingURL=InPlaceView-
|
|
3150
|
+
//# sourceMappingURL=InPlaceView-CKPumo8B.js.map
|