@damiro/stylo 0.10.1 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/dist/{InPlaceView-CkbMemAa.js → InPlaceView-Dyf7I4XQ.js} +566 -562
- package/dist/InPlaceView-Dyf7I4XQ.js.map +1 -0
- package/dist/{Preview-AaGGwLQP.js → Preview-DIsFdBFA.js} +3 -3
- package/dist/{Preview-AaGGwLQP.js.map → Preview-DIsFdBFA.js.map} +1 -1
- package/dist/SplitView.d.ts +6 -1
- package/dist/SplitView.d.ts.map +1 -1
- package/dist/Stylo.d.ts.map +1 -1
- package/dist/editor/SourceView.d.ts +6 -1
- package/dist/editor/SourceView.d.ts.map +1 -1
- package/dist/editor/canvas-header-panel.d.ts +27 -0
- package/dist/editor/canvas-header-panel.d.ts.map +1 -0
- package/dist/{embed-B2Dfkpd_.js → embed-Dsu6b-MV.js} +16 -9
- package/dist/embed-Dsu6b-MV.js.map +1 -0
- package/dist/frontmatter-DTCC0gaa.js +40 -0
- package/dist/frontmatter-DTCC0gaa.js.map +1 -0
- package/dist/inplace/InPlaceView.d.ts +6 -1
- package/dist/inplace/InPlaceView.d.ts.map +1 -1
- package/dist/inplace/table-widget.d.ts +10 -5
- package/dist/inplace/table-widget.d.ts.map +1 -1
- package/dist/inplace/theme-canvas.d.ts +7 -1
- package/dist/inplace/theme-canvas.d.ts.map +1 -1
- package/dist/render/Embed.d.ts.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/stylo.js +190 -163
- package/dist/stylo.js.map +1 -1
- package/dist/toolbar/Toolbar.d.ts.map +1 -1
- package/dist/toolbar/commands.d.ts.map +1 -1
- package/dist/types.d.ts +12 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/{useCodeMirror-CpE_Ncfn.js → useCodeMirror-CjG9CwpB.js} +229 -207
- package/dist/useCodeMirror-CjG9CwpB.js.map +1 -0
- package/package.json +1 -1
- package/dist/InPlaceView-CkbMemAa.js.map +0 -1
- package/dist/embed-B2Dfkpd_.js.map +0 -1
- package/dist/frontmatter-DGUkb9z-.js +0 -39
- package/dist/frontmatter-DGUkb9z-.js.map +0 -1
- package/dist/useCodeMirror-CpE_Ncfn.js.map +0 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { i as e, r as t, t as n } from "./frontmatter-
|
|
2
|
-
import {
|
|
3
|
-
import { a as
|
|
4
|
-
import { a as
|
|
5
|
-
import { t as
|
|
6
|
-
import { useRef as
|
|
7
|
-
import { Decoration as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
1
|
+
import { i as e, r as t, t as n } from "./frontmatter-DTCC0gaa.js";
|
|
2
|
+
import { S as r, _ as i, a, b as o, c as s, d as c, f as l, g as u, h as d, i as f, l as p, m, n as h, o as ee, p as g, r as _, s as te, t as ne, u as re, v as ie, x as v, y as ae } from "./useCodeMirror-CjG9CwpB.js";
|
|
3
|
+
import { a as y, i as b } from "./config-DTBxVhtH.js";
|
|
4
|
+
import { a as oe, n as se, o as ce, r as x, t as S } from "./embed-Dsu6b-MV.js";
|
|
5
|
+
import { t as le } from "./katex-BfiLlqfN.js";
|
|
6
|
+
import { useRef as C, useState as w, useSyncExternalStore as ue } from "react";
|
|
7
|
+
import { Decoration as T, EditorView as E, ViewPlugin as D, WidgetType as O, hoverTooltip as de, keymap as k, showPanel as fe } from "@codemirror/view";
|
|
8
|
+
import { createPortal as pe } from "react-dom";
|
|
9
|
+
import { Annotation as me, EditorSelection as he, EditorState as ge, Facet as A, Prec as j, StateEffect as _e, StateField as M } from "@codemirror/state";
|
|
10
|
+
import { syntaxTree as N } from "@codemirror/language";
|
|
11
|
+
import { jsx as ve, jsxs as ye } from "react/jsx-runtime";
|
|
12
12
|
//#region src/inplace/embed-registry.ts
|
|
13
|
-
var
|
|
13
|
+
var be = class {
|
|
14
14
|
slots = /* @__PURE__ */ new Map();
|
|
15
15
|
listeners = /* @__PURE__ */ new Set();
|
|
16
16
|
snapshot = [];
|
|
@@ -33,7 +33,7 @@ var Se = class {
|
|
|
33
33
|
for (let e of this.listeners) e();
|
|
34
34
|
}));
|
|
35
35
|
}
|
|
36
|
-
},
|
|
36
|
+
}, xe = {
|
|
37
37
|
headings: !0,
|
|
38
38
|
emphasis: !0,
|
|
39
39
|
links: !0,
|
|
@@ -48,19 +48,19 @@ var Se = class {
|
|
|
48
48
|
tables: !0,
|
|
49
49
|
embeds: !0
|
|
50
50
|
};
|
|
51
|
-
function
|
|
51
|
+
function Se(e) {
|
|
52
52
|
return {
|
|
53
|
-
...
|
|
53
|
+
...xe,
|
|
54
54
|
...e?.decorations
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
-
var
|
|
57
|
+
var P = A.define({ combine: (e) => e[0] ?? xe }), F = A.define({ combine: (e) => e[0] ?? null }), I = A.define({ combine: (e) => e[0] ?? "source" }), L = A.define({ combine: (e) => e[0] ?? "caret" }), Ce = A.define({ combine: (e) => e[0] ?? null }), we = A.define({ combine: (e) => e[0] ?? !0 }), Te = [
|
|
58
58
|
"link",
|
|
59
59
|
"format",
|
|
60
60
|
"paragraph",
|
|
61
61
|
"insert",
|
|
62
62
|
"clipboard"
|
|
63
|
-
],
|
|
63
|
+
], R = [
|
|
64
64
|
"bold",
|
|
65
65
|
"italic",
|
|
66
66
|
"strike",
|
|
@@ -69,54 +69,54 @@ var k = T.define({ combine: (e) => e[0] ?? Ce }), A = T.define({ combine: (e) =>
|
|
|
69
69
|
"wikilink",
|
|
70
70
|
"math"
|
|
71
71
|
];
|
|
72
|
-
function
|
|
72
|
+
function Ee(e) {
|
|
73
73
|
return e === !1 ? {
|
|
74
74
|
enabled: !1,
|
|
75
75
|
groups: []
|
|
76
76
|
} : e == null || e === !0 ? {
|
|
77
77
|
enabled: !0,
|
|
78
|
-
groups:
|
|
78
|
+
groups: Te
|
|
79
79
|
} : {
|
|
80
80
|
enabled: !0,
|
|
81
|
-
groups: e.groups?.length ? e.groups :
|
|
81
|
+
groups: e.groups?.length ? e.groups : Te
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
|
-
var
|
|
85
|
-
function
|
|
86
|
-
if (!e?.length) return
|
|
87
|
-
let t = e.filter((e) =>
|
|
88
|
-
return t.length ? t :
|
|
84
|
+
var De = A.define({ combine: (e) => e[0] ?? Te });
|
|
85
|
+
function Oe(e) {
|
|
86
|
+
if (!e?.length) return R;
|
|
87
|
+
let t = e.filter((e) => R.includes(e));
|
|
88
|
+
return t.length ? t : R;
|
|
89
89
|
}
|
|
90
|
-
var
|
|
90
|
+
var ke = A.define({ combine: (e) => e[0] ?? R }), Ae = A.define({ combine: (e) => e[0] ?? "menu" });
|
|
91
91
|
//#endregion
|
|
92
92
|
//#region src/inplace/frontmatter.ts
|
|
93
|
-
function
|
|
94
|
-
if (!e.facet(
|
|
93
|
+
function je(e) {
|
|
94
|
+
if (!e.facet(P).frontmatter) return T.none;
|
|
95
95
|
let t = n(e.doc);
|
|
96
|
-
if (!t) return
|
|
96
|
+
if (!t) return T.none;
|
|
97
97
|
let r = e.doc.lineAt(t.from).number, i = e.doc.lineAt(t.to).number, a = e.selection.ranges.some((t) => {
|
|
98
98
|
let n = e.doc.lineAt(t.from).number;
|
|
99
99
|
return n >= r && n <= i;
|
|
100
100
|
}), o = [];
|
|
101
101
|
for (let t = r; t <= i; t++) {
|
|
102
102
|
let n = e.doc.line(t), s = t === r ? "cm-inplace-fm cm-inplace-fm-first" : "cm-inplace-fm";
|
|
103
|
-
o.push(
|
|
103
|
+
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));
|
|
104
104
|
}
|
|
105
|
-
return
|
|
105
|
+
return T.set(o, !0);
|
|
106
106
|
}
|
|
107
|
-
var
|
|
108
|
-
create:
|
|
109
|
-
update: (e, t) => t.docChanged || t.selection ?
|
|
110
|
-
provide: (e) =>
|
|
107
|
+
var Me = M.define({
|
|
108
|
+
create: je,
|
|
109
|
+
update: (e, t) => t.docChanged || t.selection ? je(t.state) : e,
|
|
110
|
+
provide: (e) => E.decorations.from(e)
|
|
111
111
|
});
|
|
112
112
|
//#endregion
|
|
113
113
|
//#region src/inplace/list-guides.ts
|
|
114
|
-
function
|
|
114
|
+
function Ne(e) {
|
|
115
115
|
let t = 1;
|
|
116
116
|
for (let n = e.node.parent; n; n = n.parent) n.name === "ListItem" && t++;
|
|
117
117
|
return t;
|
|
118
118
|
}
|
|
119
|
-
function
|
|
119
|
+
function Pe(e, t, n, r, i, a) {
|
|
120
120
|
if (!i.lists) return;
|
|
121
121
|
let o = /* @__PURE__ */ new Set();
|
|
122
122
|
n.iterate({
|
|
@@ -124,10 +124,10 @@ function Ie(e, t, n, r, i, a) {
|
|
|
124
124
|
to: t,
|
|
125
125
|
enter: (e) => {
|
|
126
126
|
if (e.name !== "ListItem") return;
|
|
127
|
-
let t =
|
|
127
|
+
let t = Ne(e) - 1;
|
|
128
128
|
if (t < 1) return;
|
|
129
129
|
let n = r.lineAt(e.from).number, i = e.node.getChild("BulletList") ?? e.node.getChild("OrderedList"), s = r.lineAt(i ? i.from - 1 : Math.min(e.to, r.length)).number;
|
|
130
|
-
for (let e = n; e <= s; e++) o.has(e) || (o.add(e), a.push(
|
|
130
|
+
for (let e = n; e <= s; e++) o.has(e) || (o.add(e), a.push(T.line({
|
|
131
131
|
class: "cm-inplace-li",
|
|
132
132
|
attributes: { style: `--sl-li-depth:${t}` }
|
|
133
133
|
}).range(r.line(e).from)));
|
|
@@ -136,7 +136,7 @@ function Ie(e, t, n, r, i, a) {
|
|
|
136
136
|
}
|
|
137
137
|
//#endregion
|
|
138
138
|
//#region src/inplace/reveal.ts
|
|
139
|
-
function
|
|
139
|
+
function z(e) {
|
|
140
140
|
let t = /* @__PURE__ */ new Set();
|
|
141
141
|
for (let n of e.selection.ranges) {
|
|
142
142
|
let r = e.doc.lineAt(n.from).number, i = e.doc.lineAt(n.to).number;
|
|
@@ -146,22 +146,22 @@ function P(e) {
|
|
|
146
146
|
}
|
|
147
147
|
//#endregion
|
|
148
148
|
//#region src/inplace/scan.ts
|
|
149
|
-
var
|
|
149
|
+
var Fe = /* @__PURE__ */ new Set([
|
|
150
150
|
"InlineCode",
|
|
151
151
|
"FencedCode",
|
|
152
152
|
"CodeBlock",
|
|
153
153
|
"CodeText"
|
|
154
154
|
]);
|
|
155
|
-
function
|
|
155
|
+
function B(e, t) {
|
|
156
156
|
let n = e.resolveInner(t, 1);
|
|
157
157
|
for (;;) {
|
|
158
|
-
if (
|
|
158
|
+
if (Fe.has(n.name)) return !0;
|
|
159
159
|
let e = n.parent;
|
|
160
160
|
if (!e) return !1;
|
|
161
161
|
n = e;
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
|
-
function
|
|
164
|
+
function Ie(e, t) {
|
|
165
165
|
let n = e.resolveInner(t, 1);
|
|
166
166
|
for (;;) {
|
|
167
167
|
if (n.name === "Table") return !0;
|
|
@@ -170,16 +170,16 @@ function Re(e, t) {
|
|
|
170
170
|
n = e;
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
|
-
function
|
|
173
|
+
function Le(e, t, n, r) {
|
|
174
174
|
let i = t.lineAt(n).number, a = t.lineAt(r).number;
|
|
175
175
|
for (let t = i; t <= a; t++) if (e.has(t)) return !0;
|
|
176
176
|
return !1;
|
|
177
177
|
}
|
|
178
178
|
//#endregion
|
|
179
179
|
//#region src/inplace/math.ts
|
|
180
|
-
var
|
|
181
|
-
function
|
|
182
|
-
for (let n of e.matchAll(
|
|
180
|
+
var Re = /(?<![\w$])\$(?!\s)([^\n$]+?)(?<!\s)\$(?![\w$])/g, ze = /(?<![\w$])\$\$([^\n$]+?)\$\$(?![\w$])/g, Be = /(?<![\w$])\$\$([^]+?)\$\$/g;
|
|
181
|
+
function Ve(e, t) {
|
|
182
|
+
for (let n of e.matchAll(ze)) {
|
|
183
183
|
let e = n.index ?? 0, r = e + (n[0] ?? "").length;
|
|
184
184
|
if (t >= e && t <= r) return {
|
|
185
185
|
from: e,
|
|
@@ -188,7 +188,7 @@ function L(e, t) {
|
|
|
188
188
|
block: !0
|
|
189
189
|
};
|
|
190
190
|
}
|
|
191
|
-
for (let n of e.matchAll(
|
|
191
|
+
for (let n of e.matchAll(Re)) {
|
|
192
192
|
let e = n.index ?? 0, r = e + (n[0] ?? "").length;
|
|
193
193
|
if (t >= e && t <= r) return {
|
|
194
194
|
from: e,
|
|
@@ -199,7 +199,7 @@ function L(e, t) {
|
|
|
199
199
|
}
|
|
200
200
|
return null;
|
|
201
201
|
}
|
|
202
|
-
var
|
|
202
|
+
var He = class extends O {
|
|
203
203
|
src;
|
|
204
204
|
block;
|
|
205
205
|
constructor(e, t) {
|
|
@@ -212,7 +212,7 @@ var R = class extends C {
|
|
|
212
212
|
let e = document.createElement(this.block ? "div" : "span");
|
|
213
213
|
e.className = this.block ? "cm-inplace-math cm-inplace-math-block" : "cm-inplace-math";
|
|
214
214
|
try {
|
|
215
|
-
|
|
215
|
+
le.render(this.src, e, {
|
|
216
216
|
displayMode: this.block,
|
|
217
217
|
throwOnError: !1
|
|
218
218
|
});
|
|
@@ -225,45 +225,45 @@ var R = class extends C {
|
|
|
225
225
|
return !1;
|
|
226
226
|
}
|
|
227
227
|
};
|
|
228
|
-
function
|
|
228
|
+
function Ue(e, t, n, r, i, a) {
|
|
229
229
|
let o = e.state.doc.sliceString(t, n);
|
|
230
230
|
if (!o.includes("$")) return;
|
|
231
231
|
let { doc: s } = e.state, c = [];
|
|
232
|
-
for (let e of o.matchAll(
|
|
232
|
+
for (let e of o.matchAll(ze)) {
|
|
233
233
|
let n = (e[1] ?? "").trim(), o = t + (e.index ?? 0), l = o + (e[0] ?? "").length;
|
|
234
|
-
!n ||
|
|
234
|
+
!n || B(i, o + 2) || (c.push([o, l]), !Le(r, s, o, l) && a.push(T.replace({ widget: new He(n, !0) }).range(o, l)));
|
|
235
235
|
}
|
|
236
|
-
for (let e of o.matchAll(
|
|
236
|
+
for (let e of o.matchAll(Re)) {
|
|
237
237
|
let n = (e[1] ?? "").trim(), o = t + (e.index ?? 0), l = o + (e[0] ?? "").length;
|
|
238
|
-
!n ||
|
|
238
|
+
!n || B(i, o + 1) || c.some(([e, t]) => o >= e && l <= t) || Le(r, s, o, l) || a.push(T.replace({ widget: new He(n, !1) }).range(o, l));
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
|
-
var
|
|
242
|
-
create:
|
|
241
|
+
var We = M.define({
|
|
242
|
+
create: Ge,
|
|
243
243
|
update(e, t) {
|
|
244
|
-
return t.docChanged || t.selection ?
|
|
244
|
+
return t.docChanged || t.selection ? Ge(t.state) : e;
|
|
245
245
|
},
|
|
246
|
-
provide: (e) => [
|
|
246
|
+
provide: (e) => [E.decorations.from(e), E.atomicRanges.of((t) => t.state.field(e))]
|
|
247
247
|
});
|
|
248
|
-
function
|
|
249
|
-
if (!e.facet(
|
|
248
|
+
function Ge(e) {
|
|
249
|
+
if (!e.facet(P).math) return T.none;
|
|
250
250
|
let t = e.doc.toString();
|
|
251
|
-
if (!t.includes("$$")) return
|
|
252
|
-
let n = [], r =
|
|
253
|
-
for (let a of t.matchAll(
|
|
251
|
+
if (!t.includes("$$")) return T.none;
|
|
252
|
+
let n = [], r = z(e), i = N(e);
|
|
253
|
+
for (let a of t.matchAll(Be)) {
|
|
254
254
|
let t = a[0] ?? "", o = (a[1] ?? "").trim();
|
|
255
255
|
if (!o || !t.includes("\n")) continue;
|
|
256
256
|
let s = a.index ?? 0, c = s + t.length, l = e.doc.lineAt(s), u = e.doc.lineAt(c), d = e.doc.sliceString(l.from, s).trim(), f = e.doc.sliceString(c, u.to).trim();
|
|
257
|
-
d === "" && f === "" && (
|
|
258
|
-
widget: new
|
|
257
|
+
d === "" && f === "" && (B(i, s + 2) || Le(r, e.doc, s, c) || n.push(T.replace({
|
|
258
|
+
widget: new He(o, !0),
|
|
259
259
|
block: !0
|
|
260
260
|
}).range(s, c)));
|
|
261
261
|
}
|
|
262
|
-
return
|
|
262
|
+
return T.set(n, !0);
|
|
263
263
|
}
|
|
264
264
|
//#endregion
|
|
265
265
|
//#region src/inplace/nodes-inline.ts
|
|
266
|
-
var
|
|
266
|
+
var Ke = {
|
|
267
267
|
StrongEmphasis: {
|
|
268
268
|
mark: "EmphasisMark",
|
|
269
269
|
className: "cm-inplace-strong",
|
|
@@ -285,26 +285,26 @@ var Ge = {
|
|
|
285
285
|
toggle: "code"
|
|
286
286
|
}
|
|
287
287
|
};
|
|
288
|
-
function
|
|
288
|
+
function qe(e, t, n) {
|
|
289
289
|
let { doc: r, revealed: i, out: a, toggles: o } = t;
|
|
290
290
|
if (!o[n.toggle]) return;
|
|
291
291
|
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;
|
|
292
|
-
f > d && a.push(
|
|
292
|
+
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)));
|
|
293
293
|
}
|
|
294
|
-
function
|
|
294
|
+
function Je(e, t) {
|
|
295
295
|
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);
|
|
296
296
|
if (o === "[" && s === "]" || !a.links) return !1;
|
|
297
|
-
let c = n.lineAt(e.from), l =
|
|
297
|
+
let c = n.lineAt(e.from), l = x.exec(c.text);
|
|
298
298
|
if (l && e.from - c.from < l[1].length + l[2].length) return !1;
|
|
299
299
|
let u = e.node.getChildren("LinkMark");
|
|
300
300
|
if (u.length >= 2) {
|
|
301
301
|
let t = u[0], a = u[1];
|
|
302
|
-
a.from > t.to && i.push(
|
|
302
|
+
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)));
|
|
303
303
|
}
|
|
304
304
|
}
|
|
305
305
|
//#endregion
|
|
306
306
|
//#region src/inplace/widgets.ts
|
|
307
|
-
var
|
|
307
|
+
var Ye = class extends O {
|
|
308
308
|
eq() {
|
|
309
309
|
return !0;
|
|
310
310
|
}
|
|
@@ -315,7 +315,7 @@ var Je = class extends C {
|
|
|
315
315
|
ignoreEvent() {
|
|
316
316
|
return !1;
|
|
317
317
|
}
|
|
318
|
-
},
|
|
318
|
+
}, Xe = class extends O {
|
|
319
319
|
eq() {
|
|
320
320
|
return !0;
|
|
321
321
|
}
|
|
@@ -326,7 +326,7 @@ var Je = class extends C {
|
|
|
326
326
|
ignoreEvent() {
|
|
327
327
|
return !1;
|
|
328
328
|
}
|
|
329
|
-
},
|
|
329
|
+
}, Ze = class extends O {
|
|
330
330
|
checked;
|
|
331
331
|
constructor(e) {
|
|
332
332
|
super(), this.checked = e;
|
|
@@ -348,58 +348,58 @@ var Je = class extends C {
|
|
|
348
348
|
ignoreEvent() {
|
|
349
349
|
return !0;
|
|
350
350
|
}
|
|
351
|
-
},
|
|
352
|
-
function
|
|
351
|
+
}, Qe = /^[-*+]$/;
|
|
352
|
+
function $e(e, t) {
|
|
353
353
|
let { doc: n, revealed: r, out: i, toggles: a } = t;
|
|
354
354
|
if (!a.horizontalRule) return !1;
|
|
355
355
|
let o = n.lineAt(e.from);
|
|
356
|
-
return r.has(o.number) || (i.push(
|
|
356
|
+
return r.has(o.number) || (i.push(T.line({ class: "cm-inplace-hr-line" }).range(o.from)), i.push(T.replace({ widget: new Ye() }).range(o.from, o.to))), !1;
|
|
357
357
|
}
|
|
358
|
-
function
|
|
358
|
+
function et(e, t) {
|
|
359
359
|
let { doc: n, revealed: r, caretRevealed: i, out: a, toggles: o, quoteRevealed: s } = t;
|
|
360
360
|
if (o.blockquote) {
|
|
361
|
-
let t = n.lineAt(e.from).number, o = n.lineAt(Math.min(e.to, n.length)).number, c = n.line(t), l =
|
|
361
|
+
let t = n.lineAt(e.from).number, o = n.lineAt(Math.min(e.to, n.length)).number, c = n.line(t), l = x.exec(c.text), u = l ? oe(l[3]) : null, d = !1;
|
|
362
362
|
for (let e = t; e <= o; e++) i.has(e) && (d = !0);
|
|
363
363
|
if (d) for (let e = t; e <= o; e++) s.add(e);
|
|
364
364
|
for (let e = t; e <= o; e++) {
|
|
365
365
|
let r = u ? `cm-inplace-callout cm-inplace-callout-${u}` : "cm-inplace-quote";
|
|
366
366
|
u && e === t && (r += " cm-inplace-callout-head"), u && e === o && (r += " cm-inplace-callout-foot");
|
|
367
367
|
let i = {};
|
|
368
|
-
u && (i["data-callout"] = l[3].toLowerCase()), u && d && (i["data-revealed"] = ""), a.push(
|
|
368
|
+
u && (i["data-callout"] = l[3].toLowerCase()), u && d && (i["data-revealed"] = ""), a.push(T.line({
|
|
369
369
|
class: r,
|
|
370
370
|
attributes: i
|
|
371
371
|
}).range(n.line(e).from));
|
|
372
372
|
}
|
|
373
373
|
if (u && !d && !r.has(t)) {
|
|
374
374
|
let e = c.from + l[1].length;
|
|
375
|
-
a.push(
|
|
375
|
+
a.push(T.replace({}).range(e, e + l[2].length));
|
|
376
376
|
}
|
|
377
377
|
}
|
|
378
378
|
}
|
|
379
|
-
function
|
|
379
|
+
function tt(e, t) {
|
|
380
380
|
let { doc: n, revealed: r, out: i, toggles: a, quoteRevealed: o } = t;
|
|
381
381
|
if (!a.blockquote) return !1;
|
|
382
382
|
let s = n.lineAt(e.from);
|
|
383
383
|
if (!r.has(s.number) && !o.has(s.number)) {
|
|
384
|
-
let t = Math.min(e.to + 1, s.to), n =
|
|
385
|
-
i.push(
|
|
384
|
+
let t = Math.min(e.to + 1, s.to), n = x.exec(s.text), r = n ? s.text.slice(n[1].length + n[2].length) : s.text.slice(t - s.from);
|
|
385
|
+
i.push(T.replace({}).range(e.from, r.trim() === "" ? e.to : t));
|
|
386
386
|
}
|
|
387
387
|
return !1;
|
|
388
388
|
}
|
|
389
|
-
function
|
|
389
|
+
function nt(e, t) {
|
|
390
390
|
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"));
|
|
391
|
-
return r.has(s.number) || (l ? a.tasks && i.push(
|
|
391
|
+
return r.has(s.number) || (l ? a.tasks && i.push(T.replace({}).range(e.from, Math.min(e.to + 1, s.to))) : a.lists && Qe.test(o) && i.push(T.replace({ widget: new Xe() }).range(e.from, e.to))), !1;
|
|
392
392
|
}
|
|
393
|
-
function
|
|
393
|
+
function rt(e, t) {
|
|
394
394
|
let { doc: n, revealed: r, out: i, toggles: a } = t;
|
|
395
395
|
if (!a.tasks) return !1;
|
|
396
396
|
if (!r.has(n.lineAt(e.from).number)) {
|
|
397
397
|
let t = n.sliceString(e.from + 1, e.to - 1).toLowerCase() === "x";
|
|
398
|
-
i.push(
|
|
398
|
+
i.push(T.replace({ widget: new Ze(t) }).range(e.from, e.to));
|
|
399
399
|
}
|
|
400
400
|
return !1;
|
|
401
401
|
}
|
|
402
|
-
function
|
|
402
|
+
function it(e, t) {
|
|
403
403
|
let { doc: n, revealed: r, caretRevealed: i, out: a, toggles: o } = t;
|
|
404
404
|
if (!o.code) return !1;
|
|
405
405
|
let s = e.name === "FencedCode", c = n.lineAt(e.from).number, l = n.lineAt(e.to > e.from ? e.to - 1 : e.to).number, u = l > c + 1, d = !1;
|
|
@@ -409,18 +409,18 @@ function rt(e, t) {
|
|
|
409
409
|
let t = s && (e === c || e === l), r = "cm-inplace-mono";
|
|
410
410
|
e === c && (r += " cm-inplace-code-top"), e === l && (r += " cm-inplace-code-bottom"), t && (r += f ? " cm-inplace-code-pad" : " cm-inplace-fence");
|
|
411
411
|
let i = n.line(e);
|
|
412
|
-
a.push(
|
|
412
|
+
a.push(T.line({ class: r }).range(i.from)), t && f && i.to > i.from && a.push(T.replace({}).range(i.from, i.to));
|
|
413
413
|
}
|
|
414
414
|
return !1;
|
|
415
415
|
}
|
|
416
416
|
//#endregion
|
|
417
417
|
//#region src/inplace/nodes.ts
|
|
418
|
-
var
|
|
419
|
-
function
|
|
418
|
+
var at = /^ATXHeading([1-6])$/, ot = /^SetextHeading([12])$/;
|
|
419
|
+
function st(e, t, n) {
|
|
420
420
|
let { doc: r, revealed: i, out: a, toggles: o } = t;
|
|
421
421
|
if (o.headings) {
|
|
422
422
|
let t = r.lineAt(e.from);
|
|
423
|
-
if (a.push(
|
|
423
|
+
if (a.push(T.line({
|
|
424
424
|
class: `cm-inplace-heading cm-inplace-h${n}`,
|
|
425
425
|
attributes: {
|
|
426
426
|
role: "heading",
|
|
@@ -428,15 +428,15 @@ function ot(e, t, n) {
|
|
|
428
428
|
}
|
|
429
429
|
}).range(t.from)), !i.has(t.number)) {
|
|
430
430
|
let n = e.node.firstChild;
|
|
431
|
-
n?.name === "HeaderMark" && a.push(
|
|
431
|
+
n?.name === "HeaderMark" && a.push(T.replace({}).range(n.from, Math.min(n.to + 1, t.to)));
|
|
432
432
|
}
|
|
433
433
|
}
|
|
434
434
|
}
|
|
435
|
-
function
|
|
435
|
+
function ct(e, t, n) {
|
|
436
436
|
let { doc: r, caretRevealed: i, out: a, toggles: o } = t;
|
|
437
437
|
if (o.headings) {
|
|
438
438
|
let t = r.lineAt(e.from);
|
|
439
|
-
a.push(
|
|
439
|
+
a.push(T.line({
|
|
440
440
|
class: `cm-inplace-heading cm-inplace-h${n}`,
|
|
441
441
|
attributes: {
|
|
442
442
|
role: "heading",
|
|
@@ -446,47 +446,47 @@ function st(e, t, n) {
|
|
|
446
446
|
let o = e.node.getChild("HeaderMark");
|
|
447
447
|
if (o) {
|
|
448
448
|
let e = r.lineAt(o.from);
|
|
449
|
-
!i.has(t.number) && !i.has(e.number) && (a.push(
|
|
449
|
+
!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)));
|
|
450
450
|
}
|
|
451
451
|
}
|
|
452
452
|
}
|
|
453
|
-
function
|
|
453
|
+
function lt(e, t) {
|
|
454
454
|
if (e.to <= t.fmEnd) return !1;
|
|
455
|
-
let n =
|
|
456
|
-
if (n) return
|
|
457
|
-
let r =
|
|
458
|
-
if (r) return
|
|
459
|
-
let i =
|
|
460
|
-
if (i) return
|
|
461
|
-
if (e.name === "Link") return
|
|
462
|
-
if (e.name === "HorizontalRule") return
|
|
463
|
-
if (e.name === "Blockquote") return
|
|
464
|
-
if (e.name === "QuoteMark") return
|
|
465
|
-
if (e.name === "ListMark") return
|
|
466
|
-
if (e.name === "TaskMarker") return
|
|
467
|
-
if (e.name === "FencedCode" || e.name === "CodeBlock") return
|
|
455
|
+
let n = at.exec(e.name);
|
|
456
|
+
if (n) return st(e, t, n[1]);
|
|
457
|
+
let r = ot.exec(e.name);
|
|
458
|
+
if (r) return ct(e, t, r[1]);
|
|
459
|
+
let i = Ke[e.name];
|
|
460
|
+
if (i) return qe(e, t, i);
|
|
461
|
+
if (e.name === "Link") return Je(e, t);
|
|
462
|
+
if (e.name === "HorizontalRule") return $e(e, t);
|
|
463
|
+
if (e.name === "Blockquote") return et(e, t);
|
|
464
|
+
if (e.name === "QuoteMark") return tt(e, t);
|
|
465
|
+
if (e.name === "ListMark") return nt(e, t);
|
|
466
|
+
if (e.name === "TaskMarker") return rt(e, t);
|
|
467
|
+
if (e.name === "FencedCode" || e.name === "CodeBlock") return it(e, t);
|
|
468
468
|
}
|
|
469
469
|
//#endregion
|
|
470
470
|
//#region src/inplace/wikilinks.ts
|
|
471
|
-
function
|
|
471
|
+
function ut(e, n, r, i, a, o) {
|
|
472
472
|
let s = e.state.doc.sliceString(n, r);
|
|
473
473
|
if (!s.includes("[[")) return;
|
|
474
|
-
let c = e.state.facet(
|
|
474
|
+
let c = e.state.facet(F) != null;
|
|
475
475
|
for (let r of s.matchAll(t)) {
|
|
476
476
|
let [t = "", s = "", l] = r, u = s.trim(), d = n + (r.index ?? 0);
|
|
477
|
-
if (!u ||
|
|
477
|
+
if (!u || B(a, d + 1) || c && d > 0 && e.state.doc.sliceString(d - 1, d) === "!") continue;
|
|
478
478
|
let f = d + t.length, p = l == null ? d + 2 : d + 2 + s.length + 1, m = f - 2;
|
|
479
|
-
o.push(
|
|
479
|
+
o.push(T.mark({
|
|
480
480
|
class: "cm-inplace-link cm-inplace-wikilink",
|
|
481
481
|
attributes: { "data-stylo-wikilink": u }
|
|
482
|
-
}).range(p, m)), i.has(e.state.doc.lineAt(d).number) || (o.push(
|
|
482
|
+
}).range(p, m)), i.has(e.state.doc.lineAt(d).number) || (o.push(T.replace({}).range(d, p)), o.push(T.replace({}).range(m, f)));
|
|
483
483
|
}
|
|
484
484
|
}
|
|
485
485
|
//#endregion
|
|
486
486
|
//#region src/inplace/decorate.ts
|
|
487
|
-
var
|
|
488
|
-
function
|
|
489
|
-
let t = [], r =
|
|
487
|
+
var dt = /* @__PURE__ */ new Set(), ft = T.replace({});
|
|
488
|
+
function pt(e) {
|
|
489
|
+
let t = [], r = z(e.state), i = e.state.facet(L) === "never" ? dt : r, a = N(e.state), { doc: o } = e.state, s = e.state.facet(P), c = {
|
|
490
490
|
doc: o,
|
|
491
491
|
revealed: i,
|
|
492
492
|
caretRevealed: r,
|
|
@@ -498,8 +498,8 @@ function ft(e) {
|
|
|
498
498
|
for (let n of e.visibleRanges) a.iterate({
|
|
499
499
|
from: n.from,
|
|
500
500
|
to: n.to,
|
|
501
|
-
enter: (e) =>
|
|
502
|
-
}), s.wikilinks &&
|
|
501
|
+
enter: (e) => lt(e, c)
|
|
502
|
+
}), s.wikilinks && ut(e, n.from, n.to, i, a, t), s.math && Ue(e, n.from, n.to, i, a, t), Pe(n.from, n.to, a, o, s, t);
|
|
503
503
|
let l = t.filter((e) => e.from < e.to && !e.value.spec.class).sort((e, t) => e.from - t.from || e.to - t.to), u = [];
|
|
504
504
|
for (let e of l) {
|
|
505
505
|
if (!e.value.spec.widget) {
|
|
@@ -507,38 +507,38 @@ function ft(e) {
|
|
|
507
507
|
if (e.from === t.from && e.to === t.to) continue;
|
|
508
508
|
}
|
|
509
509
|
let t = u[u.length - 1];
|
|
510
|
-
t && e.from <= t.to ? e.to > t.to && (u[u.length - 1] =
|
|
510
|
+
t && e.from <= t.to ? e.to > t.to && (u[u.length - 1] = ft.range(t.from, e.to)) : u.push(ft.range(e.from, e.to));
|
|
511
511
|
}
|
|
512
512
|
return {
|
|
513
|
-
decorations:
|
|
514
|
-
atomic:
|
|
513
|
+
decorations: T.set(t, !0),
|
|
514
|
+
atomic: T.set(u, !0)
|
|
515
515
|
};
|
|
516
516
|
}
|
|
517
517
|
//#endregion
|
|
518
518
|
//#region src/inplace/plugin.ts
|
|
519
|
-
var
|
|
519
|
+
var mt = D.fromClass(class {
|
|
520
520
|
decorations;
|
|
521
521
|
atomic;
|
|
522
522
|
constructor(e) {
|
|
523
|
-
let t =
|
|
523
|
+
let t = pt(e);
|
|
524
524
|
this.decorations = t.decorations, this.atomic = t.atomic;
|
|
525
525
|
}
|
|
526
526
|
update(e) {
|
|
527
527
|
if (e.docChanged || e.viewportChanged || e.selectionSet) {
|
|
528
|
-
let t =
|
|
528
|
+
let t = pt(e.view);
|
|
529
529
|
this.decorations = t.decorations, this.atomic = t.atomic;
|
|
530
530
|
}
|
|
531
531
|
}
|
|
532
532
|
}, {
|
|
533
533
|
decorations: (e) => e.decorations,
|
|
534
|
-
provide: (e) =>
|
|
534
|
+
provide: (e) => E.atomicRanges.of((t) => t.plugin(e)?.atomic ?? T.none)
|
|
535
535
|
});
|
|
536
|
-
function
|
|
537
|
-
return
|
|
536
|
+
function ht() {
|
|
537
|
+
return mt;
|
|
538
538
|
}
|
|
539
539
|
//#endregion
|
|
540
540
|
//#region src/inplace/wrap-at.ts
|
|
541
|
-
var
|
|
541
|
+
var gt = {
|
|
542
542
|
StrongEmphasis: {
|
|
543
543
|
markType: "EmphasisMark",
|
|
544
544
|
toggle: "emphasis"
|
|
@@ -556,15 +556,15 @@ var ht = {
|
|
|
556
556
|
toggle: "code"
|
|
557
557
|
}
|
|
558
558
|
};
|
|
559
|
-
function
|
|
560
|
-
return e.facet(
|
|
559
|
+
function V(e, t) {
|
|
560
|
+
return e.facet(L) === "never" || !z(e).has(t);
|
|
561
561
|
}
|
|
562
|
-
function
|
|
562
|
+
function H(e, n, r = !1, i = !1) {
|
|
563
563
|
let a = e.doc.lineAt(n);
|
|
564
|
-
if (!i && !
|
|
565
|
-
let o = e.facet(
|
|
564
|
+
if (!i && !V(e, a.number)) return null;
|
|
565
|
+
let o = e.facet(P), s = N(e);
|
|
566
566
|
for (let t of [-1, 1]) for (let i = s.resolveInner(n, t); i; i = i.parent) {
|
|
567
|
-
let t =
|
|
567
|
+
let t = gt[i.name];
|
|
568
568
|
if (t) {
|
|
569
569
|
if (!o[t.toggle]) break;
|
|
570
570
|
let e = i.getChildren(t.markType), n = e[0], r = e[e.length - 1];
|
|
@@ -606,8 +606,8 @@ function B(e, n, r = !1, i = !1) {
|
|
|
606
606
|
}
|
|
607
607
|
//#endregion
|
|
608
608
|
//#region src/inplace/edit-boundaries.ts
|
|
609
|
-
function
|
|
610
|
-
let r = e.plugin(
|
|
609
|
+
function _t(e, t, n) {
|
|
610
|
+
let r = e.plugin(mt)?.decorations;
|
|
611
611
|
if (!r) return t;
|
|
612
612
|
let i = n < 0 ? 0 : e.state.doc.length, a = t;
|
|
613
613
|
for (let e = !0; e;) e = !1, r.between(Math.min(a, i), Math.max(a, i), (t, r, i) => {
|
|
@@ -615,18 +615,18 @@ function gt(e, t, n) {
|
|
|
615
615
|
});
|
|
616
616
|
return a;
|
|
617
617
|
}
|
|
618
|
-
var
|
|
619
|
-
if (
|
|
618
|
+
var vt = (e) => (t) => {
|
|
619
|
+
if (p(t)) return !1;
|
|
620
620
|
let n = t.state.selection.main;
|
|
621
621
|
if (!n.empty) return !1;
|
|
622
622
|
let { state: r } = t;
|
|
623
|
-
if (!
|
|
624
|
-
let i =
|
|
623
|
+
if (!V(r, r.doc.lineAt(n.head).number)) return !1;
|
|
624
|
+
let i = _t(t, n.head, e);
|
|
625
625
|
if (i === n.head) return !1;
|
|
626
626
|
let a = r.doc;
|
|
627
627
|
if (e < 0 ? i <= 0 : i >= a.length) return !0;
|
|
628
628
|
let o = e < 0 ? i - 1 : i, s = e < 0 ? i : i + 1;
|
|
629
|
-
for (let e =
|
|
629
|
+
for (let e = H(r, o); e && o <= e.contentFrom && s >= e.contentTo && e.contentTo > e.contentFrom && !(e.from >= o && e.to <= s); e = H(r, o)) o = Math.min(o, e.from), s = Math.max(s, e.to);
|
|
630
630
|
return t.dispatch({
|
|
631
631
|
changes: {
|
|
632
632
|
from: o,
|
|
@@ -637,87 +637,87 @@ var _t = (e) => (t) => {
|
|
|
637
637
|
userEvent: e < 0 ? "delete.backward" : "delete.forward",
|
|
638
638
|
scrollIntoView: !0
|
|
639
639
|
}), !0;
|
|
640
|
-
},
|
|
641
|
-
function
|
|
640
|
+
}, yt = vt(-1), bt = vt(1);
|
|
641
|
+
function xt(e, t, n) {
|
|
642
642
|
if (n <= t) return !1;
|
|
643
|
-
let r = e.plugin(
|
|
643
|
+
let r = e.plugin(mt)?.decorations;
|
|
644
644
|
if (!r) return !1;
|
|
645
645
|
let i = t;
|
|
646
646
|
return r.between(t, n, (e, t, n) => {
|
|
647
647
|
n.spec.widget || n.spec.class || t <= e || e <= i && (i = Math.max(i, t));
|
|
648
648
|
}), i >= n;
|
|
649
649
|
}
|
|
650
|
-
var
|
|
651
|
-
if (
|
|
650
|
+
var U = (e, t) => (n) => {
|
|
651
|
+
if (p(n)) return !1;
|
|
652
652
|
let r = n.state.selection.main;
|
|
653
|
-
if (!t && !r.empty || !
|
|
653
|
+
if (!t && !r.empty || !V(n.state, n.state.doc.lineAt(r.head).number)) return !1;
|
|
654
654
|
let i = n.moveByChar(r, e);
|
|
655
|
-
if (
|
|
656
|
-
let a = t ?
|
|
655
|
+
if (xt(n, Math.min(r.head, i.head), Math.max(r.head, i.head)) && (i = n.moveByChar(i, e)), i.head === r.head) return !1;
|
|
656
|
+
let a = t ? he.range(r.anchor, i.head) : he.cursor(i.head);
|
|
657
657
|
return n.dispatch({
|
|
658
658
|
selection: a,
|
|
659
659
|
userEvent: "select"
|
|
660
660
|
}), !0;
|
|
661
|
-
},
|
|
661
|
+
}, St = U(!1, !1), Ct = U(!0, !1), wt = U(!1, !0), Tt = U(!0, !0), Et = j.high(k.of([
|
|
662
662
|
{
|
|
663
663
|
key: "Backspace",
|
|
664
|
-
run:
|
|
664
|
+
run: yt
|
|
665
665
|
},
|
|
666
666
|
{
|
|
667
667
|
key: "Delete",
|
|
668
|
-
run:
|
|
668
|
+
run: bt
|
|
669
669
|
},
|
|
670
670
|
{
|
|
671
671
|
key: "ArrowLeft",
|
|
672
|
-
run:
|
|
672
|
+
run: St
|
|
673
673
|
},
|
|
674
674
|
{
|
|
675
675
|
key: "ArrowRight",
|
|
676
|
-
run:
|
|
676
|
+
run: Ct
|
|
677
677
|
},
|
|
678
678
|
{
|
|
679
679
|
key: "Shift-ArrowLeft",
|
|
680
|
-
run:
|
|
680
|
+
run: wt
|
|
681
681
|
},
|
|
682
682
|
{
|
|
683
683
|
key: "Shift-ArrowRight",
|
|
684
|
-
run:
|
|
684
|
+
run: Tt
|
|
685
685
|
}
|
|
686
|
-
])),
|
|
686
|
+
])), Dt = (e) => e === "h1" || e === "h2" || e === "h3" ? b.heading : b[e], Ot = [
|
|
687
687
|
"bold",
|
|
688
688
|
"italic",
|
|
689
689
|
"strike"
|
|
690
|
-
],
|
|
690
|
+
], kt = ["code", "math"], At = [
|
|
691
691
|
"bulletList",
|
|
692
692
|
"orderedList",
|
|
693
693
|
"task"
|
|
694
|
-
],
|
|
694
|
+
], jt = [
|
|
695
695
|
"h1",
|
|
696
696
|
"h2",
|
|
697
697
|
"h3"
|
|
698
|
-
],
|
|
698
|
+
], Mt = ["table", "hr"], Nt = [
|
|
699
699
|
"codeBlock",
|
|
700
700
|
"mathBlock",
|
|
701
701
|
"frontmatter"
|
|
702
|
-
],
|
|
703
|
-
let r =
|
|
702
|
+
], Pt = (e, t, n = !1) => {
|
|
703
|
+
let r = h[t];
|
|
704
704
|
return r ? {
|
|
705
705
|
label: r.title,
|
|
706
|
-
icon:
|
|
706
|
+
icon: Dt(t),
|
|
707
707
|
active: !n && !!r.isActive?.(e.state),
|
|
708
708
|
disabled: !n && !!r.disabled?.(e.state),
|
|
709
709
|
onSelect: () => {
|
|
710
710
|
r.run(e), e.focus();
|
|
711
711
|
}
|
|
712
712
|
} : null;
|
|
713
|
-
},
|
|
713
|
+
}, W = (e, t, n = !1, r = !1) => {
|
|
714
714
|
let i = [];
|
|
715
715
|
for (let a of t) {
|
|
716
|
-
let t =
|
|
716
|
+
let t = Pt(e, a, r);
|
|
717
717
|
t && !(n && t.disabled) && i.push(t);
|
|
718
718
|
}
|
|
719
719
|
return i;
|
|
720
|
-
},
|
|
720
|
+
}, G = (e) => {
|
|
721
721
|
let t = e.contentDOM.ownerDocument, n = (n) => () => {
|
|
722
722
|
e.focus();
|
|
723
723
|
try {
|
|
@@ -727,79 +727,79 @@ var V = (e, t) => (n) => {
|
|
|
727
727
|
return [
|
|
728
728
|
{
|
|
729
729
|
label: "Cut",
|
|
730
|
-
icon:
|
|
730
|
+
icon: b.cut,
|
|
731
731
|
onSelect: n("cut")
|
|
732
732
|
},
|
|
733
733
|
{
|
|
734
734
|
label: "Copy",
|
|
735
|
-
icon:
|
|
735
|
+
icon: b.copy,
|
|
736
736
|
onSelect: n("copy")
|
|
737
737
|
},
|
|
738
738
|
i ? {
|
|
739
739
|
label: "Paste",
|
|
740
|
-
icon:
|
|
740
|
+
icon: b.paste,
|
|
741
741
|
onSelect: () => {
|
|
742
|
-
let n =
|
|
742
|
+
let n = p(e);
|
|
743
743
|
n || e.focus(), r?.readText().then((r) => {
|
|
744
744
|
r && (n ? t.execCommand("insertText", !1, r) : e.dispatch(e.state.replaceSelection(r)));
|
|
745
745
|
}).catch(() => {});
|
|
746
746
|
}
|
|
747
747
|
} : {
|
|
748
748
|
label: "Paste",
|
|
749
|
-
icon:
|
|
749
|
+
icon: b.paste,
|
|
750
750
|
disabled: !0,
|
|
751
751
|
title: "Paste with the keyboard shortcut",
|
|
752
752
|
onSelect: () => {}
|
|
753
753
|
}
|
|
754
754
|
];
|
|
755
|
-
},
|
|
755
|
+
}, K = (e, t, n, r = !1) => ({
|
|
756
756
|
label: e,
|
|
757
757
|
icon: t,
|
|
758
758
|
rows: n,
|
|
759
759
|
disabled: r
|
|
760
760
|
});
|
|
761
|
-
function
|
|
761
|
+
function q(e, t) {
|
|
762
762
|
t.length && (e.length && e.push("separator"), e.push(...t));
|
|
763
763
|
}
|
|
764
764
|
//#endregion
|
|
765
765
|
//#region src/inplace/edit-divider.ts
|
|
766
|
-
function
|
|
766
|
+
function Ft(e) {
|
|
767
767
|
let t = e.selection.main;
|
|
768
768
|
if (!t.empty) return !1;
|
|
769
769
|
let n = e.doc.lineAt(t.head);
|
|
770
|
-
if (!
|
|
771
|
-
for (let t =
|
|
770
|
+
if (!V(e, n.number)) return !1;
|
|
771
|
+
for (let t = N(e).resolveInner(n.from, 1); t; t = t.parent) {
|
|
772
772
|
if (t.name === "HorizontalRule") return !0;
|
|
773
773
|
if (!t.parent) break;
|
|
774
774
|
}
|
|
775
775
|
return !1;
|
|
776
776
|
}
|
|
777
|
-
var
|
|
777
|
+
var It = (e) => p(e) || !Ft(e.state) ? !1 : _(e), Lt = j.high(k.of([{
|
|
778
778
|
key: "Backspace",
|
|
779
|
-
run:
|
|
779
|
+
run: It
|
|
780
780
|
}, {
|
|
781
781
|
key: "Delete",
|
|
782
|
-
run:
|
|
782
|
+
run: It
|
|
783
783
|
}]));
|
|
784
|
-
function
|
|
784
|
+
function Rt(e) {
|
|
785
785
|
return {
|
|
786
786
|
label: "Remove divider",
|
|
787
|
-
icon:
|
|
787
|
+
icon: b.hr,
|
|
788
788
|
onSelect: () => {
|
|
789
|
-
|
|
789
|
+
h.hr?.run(e), e.focus();
|
|
790
790
|
}
|
|
791
791
|
};
|
|
792
792
|
}
|
|
793
793
|
//#endregion
|
|
794
794
|
//#region src/inplace/link-row.ts
|
|
795
|
-
var
|
|
795
|
+
var zt = (e) => {
|
|
796
796
|
let t = e.trim().replace(/^<([^]*)>$/, "$1");
|
|
797
797
|
return /[\s()]/.test(t) ? `<${t.replace(/[<>]/g, "")}>` : t;
|
|
798
|
-
},
|
|
799
|
-
function
|
|
798
|
+
}, Bt = (e) => e.replace(/^<([^]*)>$/, "$1");
|
|
799
|
+
function Vt(e, t) {
|
|
800
800
|
let n = e.doc.lineAt(t.from);
|
|
801
801
|
if (e.doc.lineAt(t.to).number !== n.number) return null;
|
|
802
|
-
let r = t.from - n.from, i = t.to - n.from, a =
|
|
802
|
+
let r = t.from - n.from, i = t.to - n.from, a = v(n.text, r) ?? v(n.text, i);
|
|
803
803
|
if (a) return {
|
|
804
804
|
from: n.from + a.from,
|
|
805
805
|
to: n.from + a.to,
|
|
@@ -812,13 +812,13 @@ function Bt(e, t) {
|
|
|
812
812
|
text: o.label
|
|
813
813
|
} : null;
|
|
814
814
|
}
|
|
815
|
-
function
|
|
816
|
-
let { state: t } = e, n = t.selection.main, r = t.doc.lineAt(n.head), i =
|
|
815
|
+
function Ht(e) {
|
|
816
|
+
let { state: t } = e, n = t.selection.main, r = t.doc.lineAt(n.head), i = v(r.text, n.head - r.from);
|
|
817
817
|
if (i) {
|
|
818
|
-
let n = r.from + i.from, a = r.from + i.to, o = r.from + i.urlFrom, s = r.from + i.urlTo, c = t.facet(
|
|
818
|
+
let n = r.from + i.from, a = r.from + i.to, o = r.from + i.urlFrom, s = r.from + i.urlTo, c = t.facet(Ce), l = [];
|
|
819
819
|
return c && i.url && l.push({
|
|
820
820
|
label: "Open link",
|
|
821
|
-
icon:
|
|
821
|
+
icon: b.link,
|
|
822
822
|
onSelect: () => c(i.url)
|
|
823
823
|
}), l.push({
|
|
824
824
|
label: "Remove link",
|
|
@@ -838,24 +838,24 @@ function K(e) {
|
|
|
838
838
|
}), {
|
|
839
839
|
field: !0,
|
|
840
840
|
label: "Edit external link",
|
|
841
|
-
icon:
|
|
842
|
-
value:
|
|
841
|
+
icon: b.link,
|
|
842
|
+
value: Bt(i.url),
|
|
843
843
|
placeholder: "https://…",
|
|
844
844
|
onSubmit: (t) => {
|
|
845
845
|
e.dispatch({ changes: {
|
|
846
846
|
from: o,
|
|
847
847
|
to: s,
|
|
848
|
-
insert:
|
|
848
|
+
insert: zt(t)
|
|
849
849
|
} }), e.focus();
|
|
850
850
|
},
|
|
851
851
|
actions: l
|
|
852
852
|
};
|
|
853
853
|
}
|
|
854
|
-
let a =
|
|
854
|
+
let a = Vt(t, n), o = a ? a.from : n.from, s = a ? a.to : n.to, c = (a ? a.text : t.sliceDoc(n.from, n.to)) || "link";
|
|
855
855
|
return {
|
|
856
856
|
field: !0,
|
|
857
857
|
label: "Add external link",
|
|
858
|
-
icon:
|
|
858
|
+
icon: b.link,
|
|
859
859
|
value: "",
|
|
860
860
|
placeholder: "https://…",
|
|
861
861
|
onSubmit: (t) => {
|
|
@@ -863,7 +863,7 @@ function K(e) {
|
|
|
863
863
|
changes: {
|
|
864
864
|
from: o,
|
|
865
865
|
to: s,
|
|
866
|
-
insert: `[${c}](${
|
|
866
|
+
insert: `[${c}](${zt(t)})`
|
|
867
867
|
},
|
|
868
868
|
selection: {
|
|
869
869
|
anchor: o + 1,
|
|
@@ -873,14 +873,14 @@ function K(e) {
|
|
|
873
873
|
}
|
|
874
874
|
};
|
|
875
875
|
}
|
|
876
|
-
function
|
|
877
|
-
let { state: t } = e, n = t.selection.main, r = t.doc.lineAt(n.head), i =
|
|
876
|
+
function Ut(e) {
|
|
877
|
+
let { state: t } = e, n = t.selection.main, r = t.doc.lineAt(n.head), i = o(r.text, n.head - r.from);
|
|
878
878
|
if (i) {
|
|
879
879
|
let t = r.from + i.from, n = r.from + i.to, a = r.from + i.targetFrom, o = r.from + i.targetTo, s = i.label || i.target;
|
|
880
880
|
return {
|
|
881
881
|
field: !0,
|
|
882
882
|
label: "Edit link",
|
|
883
|
-
icon:
|
|
883
|
+
icon: b.wikilink,
|
|
884
884
|
value: i.target,
|
|
885
885
|
placeholder: "note or path",
|
|
886
886
|
onSubmit: (t) => {
|
|
@@ -908,11 +908,11 @@ function Vt(e) {
|
|
|
908
908
|
}]
|
|
909
909
|
};
|
|
910
910
|
}
|
|
911
|
-
let
|
|
911
|
+
let a = Vt(t, n), s = a ? a.from : n.from, c = a ? a.to : n.to, l = a ? a.text : t.sliceDoc(n.from, n.to);
|
|
912
912
|
return {
|
|
913
913
|
field: !0,
|
|
914
914
|
label: "Add link",
|
|
915
|
-
icon:
|
|
915
|
+
icon: b.wikilink,
|
|
916
916
|
value: "",
|
|
917
917
|
placeholder: "note or path",
|
|
918
918
|
onSubmit: (t) => {
|
|
@@ -933,19 +933,19 @@ function Vt(e) {
|
|
|
933
933
|
}
|
|
934
934
|
//#endregion
|
|
935
935
|
//#region src/inplace/context-menu-shell.ts
|
|
936
|
-
function
|
|
936
|
+
function Wt(e, t, n, r) {
|
|
937
937
|
let i = r?.innerWidth ?? 0, a = r?.innerHeight ?? 0;
|
|
938
938
|
e.style.left = "0", e.style.top = "0";
|
|
939
939
|
let { width: o, height: s } = e.getBoundingClientRect();
|
|
940
940
|
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`;
|
|
941
941
|
}
|
|
942
|
-
function
|
|
942
|
+
function Gt(e, t, n) {
|
|
943
943
|
let r = n?.innerWidth ?? 0, i = n?.innerHeight ?? 0;
|
|
944
944
|
e.style.left = "0", e.style.top = "0";
|
|
945
945
|
let { width: a, height: o } = e.getBoundingClientRect(), s = t.right - 4, c = s + a > r - 4 ? t.left - a + 4 : s;
|
|
946
946
|
e.style.left = `${Math.max(4, c)}px`, e.style.top = `${Math.max(4, Math.min(t.top - 4, i - o - 4))}px`;
|
|
947
947
|
}
|
|
948
|
-
function
|
|
948
|
+
function Kt(e, t, n, r = 350) {
|
|
949
949
|
let i = Date.now(), a = (e) => !t.contains(e.target), o = (e) => {
|
|
950
950
|
a(e) && n();
|
|
951
951
|
}, s = (e) => {
|
|
@@ -959,10 +959,10 @@ function Wt(e, t, n, r = 350) {
|
|
|
959
959
|
}
|
|
960
960
|
//#endregion
|
|
961
961
|
//#region src/inplace/context-menu-types.ts
|
|
962
|
-
var
|
|
962
|
+
var qt = (e) => typeof e != "string" && "rows" in e, Jt = (e) => typeof e != "string" && "field" in e;
|
|
963
963
|
//#endregion
|
|
964
964
|
//#region src/inplace/context-menu.ts
|
|
965
|
-
function
|
|
965
|
+
function J(e, t = "cm-inplace-menu", n) {
|
|
966
966
|
let r = e.defaultView, i = e.createElement("div");
|
|
967
967
|
i.className = t, i.setAttribute("contenteditable", "false"), i.hidden = !0;
|
|
968
968
|
let a = null, o = null, s = () => {
|
|
@@ -972,7 +972,7 @@ function q(e, t = "cm-inplace-menu", n) {
|
|
|
972
972
|
}, l = (e) => e.addEventListener("mousedown", (e) => {
|
|
973
973
|
e.preventDefault(), e.stopPropagation();
|
|
974
974
|
}), u = (t, n, r) => {
|
|
975
|
-
r && t.appendChild(
|
|
975
|
+
r && t.appendChild(y(e, r));
|
|
976
976
|
let i = e.createElement("span");
|
|
977
977
|
i.textContent = n, t.appendChild(i);
|
|
978
978
|
}, d = (n) => {
|
|
@@ -990,7 +990,7 @@ function q(e, t = "cm-inplace-menu", n) {
|
|
|
990
990
|
if (a?.dataset.for === n) return;
|
|
991
991
|
s();
|
|
992
992
|
let e = c();
|
|
993
|
-
e.dataset.for = n, i.appendChild(e),
|
|
993
|
+
e.dataset.for = n, i.appendChild(e), Gt(e, f.getBoundingClientRect(), r), a = e, e.querySelector("input")?.focus({ preventScroll: !0 });
|
|
994
994
|
};
|
|
995
995
|
return f.addEventListener("pointerenter", p), f.addEventListener("click", (e) => {
|
|
996
996
|
e.stopPropagation(), p();
|
|
@@ -1013,7 +1013,7 @@ function q(e, t = "cm-inplace-menu", n) {
|
|
|
1013
1013
|
for (let i of n) if (i === "separator") {
|
|
1014
1014
|
let n = e.createElement("div");
|
|
1015
1015
|
n.className = `${t}-sep`, r.appendChild(n);
|
|
1016
|
-
} else
|
|
1016
|
+
} else qt(i) ? r.appendChild(f(i.label, i.icon, () => m(i.rows), i.disabled)) : Jt(i) ? r.appendChild(f(i.label, i.icon, () => p(i))) : r.appendChild(d(i));
|
|
1017
1017
|
return r;
|
|
1018
1018
|
};
|
|
1019
1019
|
return {
|
|
@@ -1024,12 +1024,12 @@ function q(e, t = "cm-inplace-menu", n) {
|
|
|
1024
1024
|
show: (t, a, s) => {
|
|
1025
1025
|
c();
|
|
1026
1026
|
let l = m(t);
|
|
1027
|
-
i.appendChild(l), i.hidden = !1,
|
|
1027
|
+
i.appendChild(l), i.hidden = !1, Wt(l, a, s, r), o = Kt(e, i, c), n?.(!0);
|
|
1028
1028
|
},
|
|
1029
1029
|
showField: (t, a, s) => {
|
|
1030
1030
|
c();
|
|
1031
1031
|
let l = p(t);
|
|
1032
|
-
i.appendChild(l), i.hidden = !1,
|
|
1032
|
+
i.appendChild(l), i.hidden = !1, Wt(l, a, s, r), l.querySelector("input")?.focus({ preventScroll: !0 }), o = Kt(e, i, c), n?.(!0);
|
|
1033
1033
|
},
|
|
1034
1034
|
hide: c,
|
|
1035
1035
|
destroy: () => {
|
|
@@ -1039,14 +1039,14 @@ function q(e, t = "cm-inplace-menu", n) {
|
|
|
1039
1039
|
}
|
|
1040
1040
|
//#endregion
|
|
1041
1041
|
//#region src/inplace/math-edit.ts
|
|
1042
|
-
function
|
|
1043
|
-
let { state: t } = e, n = t.selection.main, r = t.doc.lineAt(n.head), i =
|
|
1042
|
+
function Yt(e) {
|
|
1043
|
+
let { state: t } = e, n = t.selection.main, r = t.doc.lineAt(n.head), i = Ve(r.text, n.head - r.from);
|
|
1044
1044
|
if (i) {
|
|
1045
1045
|
let t = r.from + i.from, n = r.from + i.to, a = i.block ? "$$" : "$";
|
|
1046
1046
|
return {
|
|
1047
1047
|
field: !0,
|
|
1048
1048
|
label: "Edit math",
|
|
1049
|
-
icon:
|
|
1049
|
+
icon: b.math,
|
|
1050
1050
|
value: i.src,
|
|
1051
1051
|
placeholder: "e^{i\\pi} + 1 = 0",
|
|
1052
1052
|
onSubmit: (r) => {
|
|
@@ -1079,7 +1079,7 @@ function qt(e) {
|
|
|
1079
1079
|
return {
|
|
1080
1080
|
field: !0,
|
|
1081
1081
|
label: "Add math",
|
|
1082
|
-
icon:
|
|
1082
|
+
icon: b.math,
|
|
1083
1083
|
value: "",
|
|
1084
1084
|
placeholder: "e^{i\\pi} + 1 = 0",
|
|
1085
1085
|
onSubmit: (t) => {
|
|
@@ -1098,27 +1098,27 @@ function qt(e) {
|
|
|
1098
1098
|
}
|
|
1099
1099
|
};
|
|
1100
1100
|
}
|
|
1101
|
-
var
|
|
1101
|
+
var Xt = class {
|
|
1102
1102
|
menu;
|
|
1103
1103
|
contentDOM;
|
|
1104
1104
|
onClick;
|
|
1105
1105
|
constructor(e) {
|
|
1106
|
-
this.menu =
|
|
1107
|
-
if (!e.state.facet(
|
|
1106
|
+
this.menu = J(e.dom.ownerDocument), e.dom.appendChild(this.menu.el), this.contentDOM = e.contentDOM, this.onClick = (t) => {
|
|
1107
|
+
if (!e.state.facet(P).math) return;
|
|
1108
1108
|
let n = t.target?.closest(".cm-inplace-math");
|
|
1109
1109
|
if (!n) return;
|
|
1110
1110
|
let r = e.posAtDOM(n);
|
|
1111
1111
|
if (r < 0) return;
|
|
1112
1112
|
let i = e.state.doc.lineAt(r);
|
|
1113
|
-
|
|
1113
|
+
Ve(i.text, r - i.from) && (e.dispatch({ selection: { anchor: r } }), this.menu.showField(Yt(e), t.clientX, t.clientY));
|
|
1114
1114
|
}, this.contentDOM.addEventListener("click", this.onClick);
|
|
1115
1115
|
}
|
|
1116
1116
|
destroy() {
|
|
1117
1117
|
this.contentDOM.removeEventListener("click", this.onClick), this.menu.destroy();
|
|
1118
1118
|
}
|
|
1119
|
-
},
|
|
1120
|
-
if (!e.state.facet(
|
|
1121
|
-
let n = e.state.doc.lineAt(t), r =
|
|
1119
|
+
}, Zt = D.fromClass(Xt), Qt = de((e, t) => {
|
|
1120
|
+
if (!e.state.facet(P).math) return null;
|
|
1121
|
+
let n = e.state.doc.lineAt(t), r = Ve(n.text, t - n.from);
|
|
1122
1122
|
return r ? {
|
|
1123
1123
|
pos: n.from + r.from,
|
|
1124
1124
|
end: n.from + r.to,
|
|
@@ -1131,18 +1131,18 @@ var Jt = class {
|
|
|
1131
1131
|
});
|
|
1132
1132
|
//#endregion
|
|
1133
1133
|
//#region src/inplace/context-menu-actions.ts
|
|
1134
|
-
function
|
|
1135
|
-
let t =
|
|
1134
|
+
function Y(e) {
|
|
1135
|
+
let t = p(e);
|
|
1136
1136
|
if (!t) return !1;
|
|
1137
|
-
let { from: n, to: r } =
|
|
1137
|
+
let { from: n, to: r } = u(t);
|
|
1138
1138
|
return r > n;
|
|
1139
1139
|
}
|
|
1140
|
-
function
|
|
1140
|
+
function $t(e) {
|
|
1141
1141
|
let t = te(e.state);
|
|
1142
1142
|
return {
|
|
1143
1143
|
field: !0,
|
|
1144
1144
|
label: "Language",
|
|
1145
|
-
icon:
|
|
1145
|
+
icon: b.codeBlock,
|
|
1146
1146
|
value: t?.lang ?? "",
|
|
1147
1147
|
placeholder: "ts, python, …",
|
|
1148
1148
|
onSubmit: (n) => {
|
|
@@ -1155,49 +1155,49 @@ function Zt(e) {
|
|
|
1155
1155
|
actions: [{
|
|
1156
1156
|
label: "Remove code block",
|
|
1157
1157
|
onSelect: () => {
|
|
1158
|
-
|
|
1158
|
+
h.codeBlock?.run(e), e.focus();
|
|
1159
1159
|
}
|
|
1160
1160
|
}]
|
|
1161
1161
|
};
|
|
1162
1162
|
}
|
|
1163
|
-
var
|
|
1164
|
-
...
|
|
1163
|
+
var en = (e, t = !1) => [
|
|
1164
|
+
...W(e, Ot, !1, t),
|
|
1165
1165
|
"separator",
|
|
1166
|
-
...t ?
|
|
1166
|
+
...t ? W(e, kt, !1, !0) : [Pt(e, "code", !1), Yt(e)]
|
|
1167
1167
|
];
|
|
1168
|
-
function
|
|
1169
|
-
let t = e.state.facet(
|
|
1170
|
-
return t.includes("format") &&
|
|
1168
|
+
function tn(e) {
|
|
1169
|
+
let t = e.state.facet(De), n = [];
|
|
1170
|
+
return t.includes("format") && q(n, [K("Format", b.format, en(e, !0))]), t.includes("clipboard") && q(n, G(e)), n;
|
|
1171
1171
|
}
|
|
1172
|
-
var
|
|
1173
|
-
...
|
|
1172
|
+
var nn = (e) => [
|
|
1173
|
+
...W(e, At),
|
|
1174
1174
|
"separator",
|
|
1175
|
-
...
|
|
1175
|
+
...W(e, [...jt, "body"]),
|
|
1176
1176
|
"separator",
|
|
1177
|
-
...
|
|
1178
|
-
],
|
|
1179
|
-
...
|
|
1177
|
+
...W(e, ["quote"])
|
|
1178
|
+
], rn = (e) => [
|
|
1179
|
+
...W(e, Mt),
|
|
1180
1180
|
"separator",
|
|
1181
|
-
...
|
|
1181
|
+
...W(e, Nt)
|
|
1182
1182
|
];
|
|
1183
|
-
function
|
|
1184
|
-
let { state: t } = e, n = t.facet(
|
|
1185
|
-
if (
|
|
1186
|
-
if (
|
|
1187
|
-
let t = [
|
|
1188
|
-
return r("clipboard") &&
|
|
1189
|
-
}
|
|
1190
|
-
if (
|
|
1191
|
-
let t = [
|
|
1192
|
-
return r("clipboard") &&
|
|
1193
|
-
}
|
|
1194
|
-
let i = t.selection.main, a = t.doc.lineAt(i.head).text.trim() === "",
|
|
1195
|
-
for (let t of n) t === "link" && c ?
|
|
1183
|
+
function an(e) {
|
|
1184
|
+
let { state: t } = e, n = t.facet(De), r = (e) => n.includes(e);
|
|
1185
|
+
if (Y(e)) return tn(e);
|
|
1186
|
+
if (s(t)) {
|
|
1187
|
+
let t = [$t(e)];
|
|
1188
|
+
return r("clipboard") && q(t, G(e)), t;
|
|
1189
|
+
}
|
|
1190
|
+
if (Ft(t)) {
|
|
1191
|
+
let t = [Rt(e)];
|
|
1192
|
+
return r("clipboard") && q(t, G(e)), t;
|
|
1193
|
+
}
|
|
1194
|
+
let i = t.selection.main, a = t.doc.lineAt(i.head).text.trim() === "", o = !i.empty || !!t.wordAt(i.head), c = t.facet(Ae) === "menu", l = [];
|
|
1195
|
+
for (let t of n) t === "link" && c ? q(l, [Ut(e), Ht(e)]) : t === "format" && c ? q(l, [K("Format", b.format, en(e), !o)]) : t === "paragraph" ? q(l, [K("Paragraph", b.paragraph, nn(e))]) : t === "insert" ? q(l, [K("Insert", b.insert, rn(e), !a)]) : t === "clipboard" && q(l, G(e));
|
|
1196
1196
|
return l;
|
|
1197
1197
|
}
|
|
1198
1198
|
//#endregion
|
|
1199
1199
|
//#region src/inplace/long-press.ts
|
|
1200
|
-
function
|
|
1200
|
+
function on(e, t) {
|
|
1201
1201
|
let n = t.delay ?? 450, r = t.slop ?? 20, i = null, a = 0, o = 0, s = () => {
|
|
1202
1202
|
i != null && (clearTimeout(i), i = null);
|
|
1203
1203
|
}, c = (e) => {
|
|
@@ -1219,10 +1219,10 @@ function rn(e, t) {
|
|
|
1219
1219
|
}
|
|
1220
1220
|
//#endregion
|
|
1221
1221
|
//#region src/inplace/table-gizmos.ts
|
|
1222
|
-
function
|
|
1222
|
+
function sn(e, t) {
|
|
1223
1223
|
let n = e.createElement("div");
|
|
1224
1224
|
n.className = "cm-inplace-table-gizmos", n.setAttribute("contenteditable", "false");
|
|
1225
|
-
let r =
|
|
1225
|
+
let r = J(e), i = (t, n, r) => {
|
|
1226
1226
|
let i = e.createElement("button");
|
|
1227
1227
|
return i.type = "button", i.className = t, i.setAttribute("aria-label", n), i.addEventListener("mousedown", (e) => {
|
|
1228
1228
|
e.preventDefault(), e.stopPropagation();
|
|
@@ -1305,7 +1305,7 @@ function an(e, t) {
|
|
|
1305
1305
|
}
|
|
1306
1306
|
//#endregion
|
|
1307
1307
|
//#region src/inplace/table-widget-caret.ts
|
|
1308
|
-
function
|
|
1308
|
+
function cn(e) {
|
|
1309
1309
|
let t = e.ownerDocument.getSelection(), n = e.firstChild, r = (e.textContent ?? "").length, i = t?.anchorNode === n ? t?.anchorOffset ?? 0 : r;
|
|
1310
1310
|
return {
|
|
1311
1311
|
offset: i,
|
|
@@ -1314,66 +1314,66 @@ function on(e) {
|
|
|
1314
1314
|
}
|
|
1315
1315
|
//#endregion
|
|
1316
1316
|
//#region src/inplace/inline-md.ts
|
|
1317
|
-
function
|
|
1317
|
+
function ln(e, t = !1) {
|
|
1318
1318
|
let n = document.createDocumentFragment();
|
|
1319
|
-
return
|
|
1319
|
+
return fn(n, e, t), n;
|
|
1320
1320
|
}
|
|
1321
|
-
var
|
|
1321
|
+
var un = /!\[\[[^\]\n]+?\]\]/, dn = [
|
|
1322
1322
|
{
|
|
1323
1323
|
re: /`([^`\n]+)`/,
|
|
1324
|
-
build: (e) =>
|
|
1324
|
+
build: (e) => X("code", "cm-inplace-code", document.createTextNode(e[1]))
|
|
1325
1325
|
},
|
|
1326
1326
|
{
|
|
1327
1327
|
re: /(?<![\d$])\$(?!\s)([^$\n]+?)(?<!\s)\$(?![\d$])/,
|
|
1328
1328
|
build: (e) => {
|
|
1329
|
-
let t =
|
|
1330
|
-
return
|
|
1329
|
+
let t = X("span", "cm-inplace-math");
|
|
1330
|
+
return le.render(e[1], t, { throwOnError: !1 }), t;
|
|
1331
1331
|
}
|
|
1332
1332
|
},
|
|
1333
1333
|
{
|
|
1334
1334
|
re: new RegExp(t.source),
|
|
1335
1335
|
build: (e) => {
|
|
1336
|
-
let t =
|
|
1336
|
+
let t = X("span", "cm-inplace-wikilink", document.createTextNode(e[2] || e[1] || ""));
|
|
1337
1337
|
return t.dataset.styloWikilink = e[1] ?? "", t;
|
|
1338
1338
|
}
|
|
1339
1339
|
},
|
|
1340
1340
|
{
|
|
1341
1341
|
re: /\[([^\]\n]*)\]\(([^)\n]*)\)/,
|
|
1342
1342
|
build: (e, t) => {
|
|
1343
|
-
let n =
|
|
1344
|
-
return n.href = e[2] ?? "", n.append(
|
|
1343
|
+
let n = X("a", "cm-inplace-link");
|
|
1344
|
+
return n.href = e[2] ?? "", n.append(Z(e[1] ?? "", t)), n;
|
|
1345
1345
|
}
|
|
1346
1346
|
},
|
|
1347
1347
|
{
|
|
1348
1348
|
re: /\*\*\*([^*\n]+?)\*\*\*/,
|
|
1349
|
-
build: (e, t) =>
|
|
1349
|
+
build: (e, t) => X("strong", "cm-inplace-strong", X("em", "cm-inplace-em", Z(e[1], t)))
|
|
1350
1350
|
},
|
|
1351
1351
|
{
|
|
1352
1352
|
re: /\*\*([^\n]+?)\*\*/,
|
|
1353
|
-
build: (e, t) =>
|
|
1353
|
+
build: (e, t) => X("strong", "cm-inplace-strong", Z(e[1], t))
|
|
1354
1354
|
},
|
|
1355
1355
|
{
|
|
1356
1356
|
re: /~~([^\n]+?)~~/,
|
|
1357
|
-
build: (e, t) =>
|
|
1357
|
+
build: (e, t) => X("span", "cm-inplace-strike", Z(e[1], t))
|
|
1358
1358
|
},
|
|
1359
1359
|
{
|
|
1360
1360
|
re: /(?<!\*)\*(?!\*|\s)([^\n]+?)(?<!\s)\*(?!\*)/,
|
|
1361
|
-
build: (e, t) =>
|
|
1361
|
+
build: (e, t) => X("em", "cm-inplace-em", Z(e[1], t))
|
|
1362
1362
|
}
|
|
1363
1363
|
];
|
|
1364
|
-
function
|
|
1364
|
+
function X(e, t, ...n) {
|
|
1365
1365
|
let r = document.createElement(e);
|
|
1366
1366
|
return r.className = t, r.append(...n), r;
|
|
1367
1367
|
}
|
|
1368
|
-
function
|
|
1368
|
+
function Z(e, t) {
|
|
1369
1369
|
let n = document.createDocumentFragment();
|
|
1370
|
-
return
|
|
1370
|
+
return fn(n, e, t), n;
|
|
1371
1371
|
}
|
|
1372
|
-
function
|
|
1372
|
+
function fn(e, t, n) {
|
|
1373
1373
|
for (; t;) {
|
|
1374
|
-
let r = -1, i = null, a = n ?
|
|
1374
|
+
let r = -1, i = null, a = n ? un.exec(t) : null;
|
|
1375
1375
|
a && (r = a.index, i = { literal: a[0] });
|
|
1376
|
-
for (let e of
|
|
1376
|
+
for (let e of dn) {
|
|
1377
1377
|
let n = e.re.exec(t);
|
|
1378
1378
|
n && (r < 0 || n.index < r) && (r = n.index, i = {
|
|
1379
1379
|
rule: e,
|
|
@@ -1389,53 +1389,121 @@ function un(e, t, n) {
|
|
|
1389
1389
|
}
|
|
1390
1390
|
//#endregion
|
|
1391
1391
|
//#region src/inplace/table-widget-render.ts
|
|
1392
|
-
function
|
|
1392
|
+
function pn(e, t, n) {
|
|
1393
1393
|
let r = Number(e.dataset.r), i = Number(e.dataset.c), a = t.rows[r]?.[i] ?? "";
|
|
1394
|
-
e.replaceChildren(n ? e.ownerDocument.createTextNode(a) :
|
|
1394
|
+
e.replaceChildren(n ? e.ownerDocument.createTextNode(a) : ln(ie(a), t.embeds));
|
|
1395
1395
|
}
|
|
1396
|
-
function
|
|
1396
|
+
function mn(e, t, n, r) {
|
|
1397
1397
|
let i = document.createElement(r ? "th" : "td");
|
|
1398
1398
|
i.className = "cm-inplace-tcell", i.setAttribute("contenteditable", "true"), i.dataset.r = String(t), i.dataset.c = String(n);
|
|
1399
1399
|
let a = e.aligns[n];
|
|
1400
|
-
return a && (i.style.textAlign = a),
|
|
1400
|
+
return a && (i.style.textAlign = a), pn(i, e, !1), i;
|
|
1401
1401
|
}
|
|
1402
|
-
function
|
|
1402
|
+
function hn(e, t) {
|
|
1403
1403
|
e.replaceChildren();
|
|
1404
1404
|
let n = t.aligns.length, r = e.createTHead().insertRow();
|
|
1405
|
-
for (let e = 0; e < n; e++) r.appendChild(
|
|
1405
|
+
for (let e = 0; e < n; e++) r.appendChild(mn(t, 0, e, !0));
|
|
1406
1406
|
let i = e.createTBody();
|
|
1407
1407
|
for (let e = 1; e < t.rows.length; e++) {
|
|
1408
1408
|
let r = i.insertRow();
|
|
1409
|
-
for (let i = 0; i < n; i++) r.appendChild(
|
|
1409
|
+
for (let i = 0; i < n; i++) r.appendChild(mn(t, e, i, !1));
|
|
1410
1410
|
}
|
|
1411
1411
|
}
|
|
1412
1412
|
//#endregion
|
|
1413
1413
|
//#region src/inplace/table-structure.ts
|
|
1414
|
-
var
|
|
1415
|
-
function
|
|
1416
|
-
let n = Math.max(0, Math.min(t,
|
|
1414
|
+
var Q = (e) => e.aligns.length;
|
|
1415
|
+
function gn(e, t) {
|
|
1416
|
+
let n = Math.max(0, Math.min(t, Q(e)));
|
|
1417
1417
|
for (let t of e.rows) t.splice(n, 0, "");
|
|
1418
1418
|
e.aligns.splice(n, 0, "");
|
|
1419
1419
|
}
|
|
1420
|
-
function
|
|
1421
|
-
if (!(
|
|
1420
|
+
function _n(e, t) {
|
|
1421
|
+
if (!(Q(e) <= 1 || t < 0 || t >= Q(e))) {
|
|
1422
1422
|
for (let n of e.rows) n.splice(t, 1);
|
|
1423
1423
|
e.aligns.splice(t, 1);
|
|
1424
1424
|
}
|
|
1425
1425
|
}
|
|
1426
|
-
function
|
|
1426
|
+
function vn(e, t) {
|
|
1427
1427
|
let n = Math.max(1, Math.min(t, e.rows.length));
|
|
1428
|
-
e.rows.splice(n, 0, Array(
|
|
1428
|
+
e.rows.splice(n, 0, Array(Q(e)).fill(""));
|
|
1429
1429
|
}
|
|
1430
|
-
function
|
|
1430
|
+
function yn(e, t) {
|
|
1431
1431
|
t <= 0 || t >= e.rows.length || e.rows.length <= 2 || e.rows.splice(t, 1);
|
|
1432
1432
|
}
|
|
1433
|
-
function
|
|
1434
|
-
t >= 0 && t <
|
|
1433
|
+
function bn(e, t, n) {
|
|
1434
|
+
t >= 0 && t < Q(e) && (e.aligns[t] = n);
|
|
1435
1435
|
}
|
|
1436
1436
|
//#endregion
|
|
1437
|
-
//#region src/inplace/
|
|
1438
|
-
var
|
|
1437
|
+
//#region src/inplace/tables.ts
|
|
1438
|
+
var xn = class extends O {
|
|
1439
|
+
table;
|
|
1440
|
+
embeds;
|
|
1441
|
+
constructor(e, t) {
|
|
1442
|
+
super(), this.table = e, this.embeds = t;
|
|
1443
|
+
}
|
|
1444
|
+
eq(e) {
|
|
1445
|
+
return JSON.stringify(this.table) === JSON.stringify(e.table);
|
|
1446
|
+
}
|
|
1447
|
+
toDOM() {
|
|
1448
|
+
let { head: e, body: t, aligns: n } = this.table, r = document.createElement("table");
|
|
1449
|
+
r.className = "cm-inplace-table";
|
|
1450
|
+
let i = (e) => ln(e.replace(/\\\|/g, "|"), this.embeds), a = r.createTHead().insertRow();
|
|
1451
|
+
e.forEach((e, t) => {
|
|
1452
|
+
let r = document.createElement("th");
|
|
1453
|
+
r.appendChild(i(e)), r.dataset.styloRow = "0", r.dataset.styloCol = String(t), Sn(r, n[t]), a.appendChild(r);
|
|
1454
|
+
});
|
|
1455
|
+
let o = r.createTBody();
|
|
1456
|
+
return t.forEach((t, r) => {
|
|
1457
|
+
let a = o.insertRow();
|
|
1458
|
+
for (let o = 0; o < e.length; o++) {
|
|
1459
|
+
let e = a.insertCell();
|
|
1460
|
+
e.appendChild(i(t[o] ?? "")), e.dataset.styloRow = String(r + 1), e.dataset.styloCol = String(o), Sn(e, n[o]);
|
|
1461
|
+
}
|
|
1462
|
+
}), r;
|
|
1463
|
+
}
|
|
1464
|
+
ignoreEvent() {
|
|
1465
|
+
return !1;
|
|
1466
|
+
}
|
|
1467
|
+
};
|
|
1468
|
+
function Sn(e, t) {
|
|
1469
|
+
t && (e.style.textAlign = t);
|
|
1470
|
+
}
|
|
1471
|
+
function Cn(e, t) {
|
|
1472
|
+
let n = t.lineAt(e.from).number, r = t.lineAt(e.to).number, i = [];
|
|
1473
|
+
for (let e = n; e <= r; e++) i.push(t.line(e).text);
|
|
1474
|
+
let o = a(i);
|
|
1475
|
+
return !o || o.rows.length === 0 ? null : {
|
|
1476
|
+
head: o.rows[0],
|
|
1477
|
+
body: o.rows.slice(1),
|
|
1478
|
+
aligns: o.aligns
|
|
1479
|
+
};
|
|
1480
|
+
}
|
|
1481
|
+
function wn(e) {
|
|
1482
|
+
if (!e.facet(P).tables) return T.none;
|
|
1483
|
+
let t = e.facet(I) === "cells", r = e.facet(F) != null && e.facet(P).embeds, i = N(e), a = n(e.doc), o = t ? null : z(e), s = [];
|
|
1484
|
+
return i.iterate({ enter: (n) => {
|
|
1485
|
+
if (n.name !== "Table") return;
|
|
1486
|
+
if (a && n.from < a.to) return !1;
|
|
1487
|
+
if (o) {
|
|
1488
|
+
let t = e.doc.lineAt(n.from).number, r = e.doc.lineAt(n.to).number;
|
|
1489
|
+
for (let e = t; e <= r; e++) if (o.has(e)) return !1;
|
|
1490
|
+
}
|
|
1491
|
+
let i = Cn(n.node, e.doc);
|
|
1492
|
+
if (i) {
|
|
1493
|
+
let e = t ? new En(i, r) : new xn(i, r);
|
|
1494
|
+
s.push(T.replace({
|
|
1495
|
+
widget: e,
|
|
1496
|
+
block: !0
|
|
1497
|
+
}).range(n.from, n.to));
|
|
1498
|
+
}
|
|
1499
|
+
return !1;
|
|
1500
|
+
} }), T.set(s, !0);
|
|
1501
|
+
}
|
|
1502
|
+
var Tn = M.define({
|
|
1503
|
+
create: wn,
|
|
1504
|
+
update: (e, t) => t.annotation($) ? e.map(t.changes) : t.state.facet(I) === "cells" ? t.docChanged ? wn(t.state) : e.map(t.changes) : t.docChanged || t.selection ? wn(t.state) : e,
|
|
1505
|
+
provide: (e) => [E.decorations.from(e), E.atomicRanges.of((t) => t.state.field(e))]
|
|
1506
|
+
}), $ = me.define(), En = class extends O {
|
|
1439
1507
|
data;
|
|
1440
1508
|
embeds;
|
|
1441
1509
|
table = null;
|
|
@@ -1448,7 +1516,7 @@ var Q = ge.define(), yn = class extends C {
|
|
|
1448
1516
|
longPress = null;
|
|
1449
1517
|
longPressAt = 0;
|
|
1450
1518
|
constructor(e, t = !1) {
|
|
1451
|
-
super(), this.data = e, this.embeds = t, this.rows =
|
|
1519
|
+
super(), this.data = e, this.embeds = t, this.rows = c(e), this.current = i(this.rows);
|
|
1452
1520
|
}
|
|
1453
1521
|
eq(e) {
|
|
1454
1522
|
return !this.table && JSON.stringify(this.current) === JSON.stringify(e.current);
|
|
@@ -1460,16 +1528,11 @@ var Q = ge.define(), yn = class extends C {
|
|
|
1460
1528
|
return this.data.aligns.length;
|
|
1461
1529
|
}
|
|
1462
1530
|
bounds(e) {
|
|
1463
|
-
let t = e.
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
for (; i < t.lines && n(i + 1);) i++;
|
|
1469
|
-
return {
|
|
1470
|
-
from: t.line(r).from,
|
|
1471
|
-
to: t.line(i).to
|
|
1472
|
-
};
|
|
1531
|
+
let t = e.posAtDOM(this.table), n = null;
|
|
1532
|
+
return e.state.field(Tn).between(t, t, (e, t) => (n = {
|
|
1533
|
+
from: e,
|
|
1534
|
+
to: t
|
|
1535
|
+
}, !1)), n ?? e.state.doc.lineAt(t);
|
|
1473
1536
|
}
|
|
1474
1537
|
cellAt(e, t) {
|
|
1475
1538
|
return this.table ? (e === 0 ? this.table.tHead.rows[0] : this.table.tBodies[0].rows[e - 1])?.cells[t] ?? null : null;
|
|
@@ -1481,21 +1544,21 @@ var Q = ge.define(), yn = class extends C {
|
|
|
1481
1544
|
};
|
|
1482
1545
|
}
|
|
1483
1546
|
paint(e, t) {
|
|
1484
|
-
|
|
1547
|
+
pn(e, {
|
|
1485
1548
|
rows: this.rows,
|
|
1486
1549
|
aligns: this.data.aligns,
|
|
1487
1550
|
embeds: this.embeds
|
|
1488
1551
|
}, t);
|
|
1489
1552
|
}
|
|
1490
1553
|
renderCells() {
|
|
1491
|
-
|
|
1554
|
+
hn(this.table, {
|
|
1492
1555
|
rows: this.rows,
|
|
1493
1556
|
aligns: this.data.aligns,
|
|
1494
1557
|
embeds: this.embeds
|
|
1495
1558
|
});
|
|
1496
1559
|
}
|
|
1497
1560
|
appendRow() {
|
|
1498
|
-
|
|
1561
|
+
vn(this.model(), this.rows.length), this.renderCells(), this.gizmos?.layout(this.table);
|
|
1499
1562
|
}
|
|
1500
1563
|
model() {
|
|
1501
1564
|
return {
|
|
@@ -1506,7 +1569,7 @@ var Q = ge.define(), yn = class extends C {
|
|
|
1506
1569
|
runOp(e, t) {
|
|
1507
1570
|
if (!this.table) return;
|
|
1508
1571
|
let n = this.model();
|
|
1509
|
-
if (t.kind === "insertColumn" ?
|
|
1572
|
+
if (t.kind === "insertColumn" ? gn(n, t.at) : t.kind === "deleteColumn" ? _n(n, t.at) : t.kind === "insertRow" ? vn(n, t.at) : t.kind === "deleteRow" ? yn(n, t.at) : bn(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") {
|
|
1510
1573
|
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));
|
|
1511
1574
|
this.cellAt(e, n)?.focus();
|
|
1512
1575
|
}
|
|
@@ -1518,7 +1581,7 @@ var Q = ge.define(), yn = class extends C {
|
|
|
1518
1581
|
onFocusIn(e) {
|
|
1519
1582
|
let t = e.target.closest("td, th");
|
|
1520
1583
|
if (!t || t === this.editing) return;
|
|
1521
|
-
let n = this.pendingOffset ??
|
|
1584
|
+
let n = this.pendingOffset ?? m(t);
|
|
1522
1585
|
this.pendingOffset = null, this.editing && this.finish(this.editing, !1), this.editing = t, this.paint(t, !0), g(t, n);
|
|
1523
1586
|
}
|
|
1524
1587
|
onFocusOut(e) {
|
|
@@ -1532,7 +1595,7 @@ var Q = ge.define(), yn = class extends C {
|
|
|
1532
1595
|
return {
|
|
1533
1596
|
r: e,
|
|
1534
1597
|
c: t,
|
|
1535
|
-
...
|
|
1598
|
+
...cn(this.editing)
|
|
1536
1599
|
};
|
|
1537
1600
|
}
|
|
1538
1601
|
writeCaret(e) {
|
|
@@ -1541,19 +1604,19 @@ var Q = ge.define(), yn = class extends C {
|
|
|
1541
1604
|
}
|
|
1542
1605
|
sync(e) {
|
|
1543
1606
|
if (!this.table) return;
|
|
1544
|
-
let t = this.readCaret(), n =
|
|
1607
|
+
let t = this.readCaret(), n = ee({
|
|
1545
1608
|
rows: this.rows,
|
|
1546
1609
|
aligns: this.data.aligns
|
|
1547
1610
|
});
|
|
1548
|
-
this.current =
|
|
1549
|
-
let { from:
|
|
1550
|
-
e.state.sliceDoc(
|
|
1611
|
+
this.current = i(this.rows);
|
|
1612
|
+
let { from: r, to: a } = this.bounds(e);
|
|
1613
|
+
e.state.sliceDoc(r, a) !== n && (this.syncing = !0, e.dispatch({
|
|
1551
1614
|
changes: {
|
|
1552
|
-
from:
|
|
1615
|
+
from: r,
|
|
1553
1616
|
to: a,
|
|
1554
1617
|
insert: n
|
|
1555
1618
|
},
|
|
1556
|
-
annotations:
|
|
1619
|
+
annotations: $.of(!0),
|
|
1557
1620
|
userEvent: "input"
|
|
1558
1621
|
}), this.syncing = !1, t && (this.writeCaret(t), requestAnimationFrame(() => {
|
|
1559
1622
|
this.table && t && this.writeCaret(t);
|
|
@@ -1621,8 +1684,8 @@ var Q = ge.define(), yn = class extends C {
|
|
|
1621
1684
|
openCellMenuAt(e, t, n, r) {
|
|
1622
1685
|
let i = r?.closest("td, th");
|
|
1623
1686
|
if (!i) return;
|
|
1624
|
-
this.editing === i && !
|
|
1625
|
-
let a =
|
|
1687
|
+
this.editing === i && !Y(e) && d(i, t, n);
|
|
1688
|
+
let a = Y(e) ? tn(e) : void 0;
|
|
1626
1689
|
this.gizmos?.openFor(i, t, n, a);
|
|
1627
1690
|
}
|
|
1628
1691
|
toDOM(e) {
|
|
@@ -1632,7 +1695,7 @@ var Q = ge.define(), yn = class extends C {
|
|
|
1632
1695
|
this.table = n, this.editing = null, n.className = "cm-inplace-table cm-inplace-table-edit", this.renderCells(), n.addEventListener("mousedown", (e) => {
|
|
1633
1696
|
e.stopPropagation();
|
|
1634
1697
|
let t = e.target.closest("td, th");
|
|
1635
|
-
this.pendingOffset = t && t !== this.editing ?
|
|
1698
|
+
this.pendingOffset = t && t !== this.editing ? l(t, e.clientX, e.clientY) : null;
|
|
1636
1699
|
}), n.addEventListener("focusin", (e) => this.onFocusIn(e)), n.addEventListener("focusout", (e) => this.onFocusOut(e));
|
|
1637
1700
|
let r = (t) => {
|
|
1638
1701
|
t && (this.editing = t, this.finish(t, !0), this.sync(e));
|
|
@@ -1645,9 +1708,9 @@ var Q = ge.define(), yn = class extends C {
|
|
|
1645
1708
|
document.execCommand("insertText", !1, t);
|
|
1646
1709
|
}), n.addEventListener("contextmenu", (t) => {
|
|
1647
1710
|
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));
|
|
1648
|
-
}), this.longPress =
|
|
1711
|
+
}), this.longPress = on(n, { onLongPress: (t, n, r) => {
|
|
1649
1712
|
this.longPressAt = Date.now(), this.openCellMenuAt(e, t, n, r);
|
|
1650
|
-
} }), this.gizmos =
|
|
1713
|
+
} }), this.gizmos = sn(document, {
|
|
1651
1714
|
dims: () => ({
|
|
1652
1715
|
cols: this.cols(),
|
|
1653
1716
|
rows: this.rows.length,
|
|
@@ -1659,12 +1722,12 @@ var Q = ge.define(), yn = class extends C {
|
|
|
1659
1722
|
destroy() {
|
|
1660
1723
|
this.longPress?.dispose(), this.longPress = null, this.gizmos?.destroy(), this.gizmos = null, this.table = null, this.editing = null;
|
|
1661
1724
|
}
|
|
1662
|
-
},
|
|
1725
|
+
}, Dn = /* @__PURE__ */ new Set([
|
|
1663
1726
|
"-",
|
|
1664
1727
|
"*",
|
|
1665
1728
|
"_"
|
|
1666
|
-
]),
|
|
1667
|
-
if (!e.docChanged || e.isUserEvent("undo") || e.isUserEvent("redo") || e.annotation(
|
|
1729
|
+
]), On = ge.transactionFilter.of((e) => {
|
|
1730
|
+
if (!e.docChanged || e.isUserEvent("undo") || e.isUserEvent("redo") || e.annotation($) || !e.startState.selection.main.empty) return e;
|
|
1668
1731
|
let t = e.startState.selection.main.head, n = "", r = 0;
|
|
1669
1732
|
if (e.changes.iterChanges((e, i, a, o, s) => {
|
|
1670
1733
|
r += 1, e === i && e === t && (n = s.toString());
|
|
@@ -1694,7 +1757,7 @@ var Q = ge.define(), yn = class extends C {
|
|
|
1694
1757
|
},
|
|
1695
1758
|
anchor: a + 1
|
|
1696
1759
|
};
|
|
1697
|
-
else if (
|
|
1760
|
+
else if (Dn.has(n) && RegExp(`^\\${n}{3,}$`).test(s)) {
|
|
1698
1761
|
let e = o.number === 1 || i.line(o.number - 1).text.trim() === "", t = n === "-" && !e, r = o.number === i.lines;
|
|
1699
1762
|
if (t || r) {
|
|
1700
1763
|
let e = [];
|
|
@@ -1717,38 +1780,38 @@ var Q = ge.define(), yn = class extends C {
|
|
|
1717
1780
|
scrollIntoView: !0,
|
|
1718
1781
|
userEvent: "input.autoformat"
|
|
1719
1782
|
}] : e;
|
|
1720
|
-
}),
|
|
1783
|
+
}), kn = /* @__PURE__ */ new Set([
|
|
1721
1784
|
"EmphasisMark",
|
|
1722
1785
|
"CodeMark",
|
|
1723
1786
|
"StrikethroughMark"
|
|
1724
1787
|
]);
|
|
1725
|
-
function
|
|
1788
|
+
function An(e, t, n) {
|
|
1726
1789
|
let r = t;
|
|
1727
1790
|
for (;;) {
|
|
1728
1791
|
let t = e.resolveInner(r, n);
|
|
1729
|
-
if (!
|
|
1792
|
+
if (!kn.has(t.name) || t.from >= t.to) return r;
|
|
1730
1793
|
let i = n < 0 ? t.from : t.to;
|
|
1731
1794
|
if (i === r) return r;
|
|
1732
1795
|
r = i;
|
|
1733
1796
|
}
|
|
1734
1797
|
}
|
|
1735
|
-
function
|
|
1736
|
-
let n =
|
|
1798
|
+
function jn(e, t) {
|
|
1799
|
+
let n = H(e, t, !0);
|
|
1737
1800
|
if (!n) return t;
|
|
1738
|
-
let r =
|
|
1739
|
-
return t === n.contentTo ?
|
|
1801
|
+
let r = N(e);
|
|
1802
|
+
return t === n.contentTo ? An(r, t, 1) : t === n.contentFrom ? An(r, t, -1) : t;
|
|
1740
1803
|
}
|
|
1741
|
-
var
|
|
1742
|
-
if (!e.docChanged || e.isUserEvent("undo") || e.isUserEvent("redo") || e.annotation(
|
|
1804
|
+
var Mn = ge.transactionFilter.of((e) => {
|
|
1805
|
+
if (!e.docChanged || e.isUserEvent("undo") || e.isUserEvent("redo") || e.annotation($)) return e;
|
|
1743
1806
|
let t = e.startState, n = t.selection.main;
|
|
1744
|
-
if (!n.empty || !
|
|
1807
|
+
if (!n.empty || !V(t, t.doc.lineAt(n.head).number)) return e;
|
|
1745
1808
|
let r = [], i = 0;
|
|
1746
1809
|
e.changes.iterChanges((e, t, a, o, s) => {
|
|
1747
1810
|
i++, e === t && e === n.head && s.length > 0 && r.push(s.toString());
|
|
1748
1811
|
});
|
|
1749
1812
|
let a = r[0];
|
|
1750
1813
|
if (i !== 1 || a === void 0) return e;
|
|
1751
|
-
let o =
|
|
1814
|
+
let o = jn(t, n.head);
|
|
1752
1815
|
return o === n.head ? e : {
|
|
1753
1816
|
changes: {
|
|
1754
1817
|
from: o,
|
|
@@ -1761,7 +1824,7 @@ var Tn = ve.transactionFilter.of((e) => {
|
|
|
1761
1824
|
});
|
|
1762
1825
|
//#endregion
|
|
1763
1826
|
//#region src/inplace/edit-line-prefix.ts
|
|
1764
|
-
function
|
|
1827
|
+
function Nn(e) {
|
|
1765
1828
|
let t = /^#{1,6} /.exec(e);
|
|
1766
1829
|
if (t) return {
|
|
1767
1830
|
prefixLen: t[0].length,
|
|
@@ -1797,15 +1860,15 @@ function En(e) {
|
|
|
1797
1860
|
}
|
|
1798
1861
|
return null;
|
|
1799
1862
|
}
|
|
1800
|
-
var
|
|
1863
|
+
var Pn = j.high(k.of([{
|
|
1801
1864
|
key: "Backspace",
|
|
1802
1865
|
run: (e) => {
|
|
1803
|
-
if (
|
|
1866
|
+
if (p(e)) return !1;
|
|
1804
1867
|
let { state: t } = e, n = t.selection.main;
|
|
1805
1868
|
if (!n.empty) return !1;
|
|
1806
1869
|
let r = t.doc.lineAt(n.head);
|
|
1807
|
-
if (!
|
|
1808
|
-
let i =
|
|
1870
|
+
if (!V(t, r.number)) return !1;
|
|
1871
|
+
let i = Nn(r.text);
|
|
1809
1872
|
if (!i || n.head < r.from || n.head > r.from + i.prefixLen) return !1;
|
|
1810
1873
|
let [a, o] = i.drop;
|
|
1811
1874
|
return e.dispatch({
|
|
@@ -1819,13 +1882,13 @@ var Dn = E.high(w.of([{
|
|
|
1819
1882
|
scrollIntoView: !0
|
|
1820
1883
|
}), !0;
|
|
1821
1884
|
}
|
|
1822
|
-
}])),
|
|
1885
|
+
}])), Fn = class {
|
|
1823
1886
|
menu;
|
|
1824
1887
|
contentDOM;
|
|
1825
1888
|
onClick;
|
|
1826
1889
|
constructor(e) {
|
|
1827
|
-
this.menu =
|
|
1828
|
-
if (e.state.facet(
|
|
1890
|
+
this.menu = J(e.dom.ownerDocument), e.dom.appendChild(this.menu.el), this.contentDOM = e.contentDOM, this.onClick = (t) => {
|
|
1891
|
+
if (e.state.facet(L) !== "never" || !e.state.facet(P).links) return;
|
|
1829
1892
|
let n = t.target?.closest(".cm-inplace-link");
|
|
1830
1893
|
if (!n || n.classList.contains("cm-inplace-wikilink")) return;
|
|
1831
1894
|
let r = e.posAtDOM(n);
|
|
@@ -1837,13 +1900,13 @@ var Dn = E.high(w.of([{
|
|
|
1837
1900
|
if (n == null) return;
|
|
1838
1901
|
r = n;
|
|
1839
1902
|
}
|
|
1840
|
-
e.dispatch({ selection: { anchor: r } }), this.menu.showField(
|
|
1903
|
+
e.dispatch({ selection: { anchor: r } }), this.menu.showField(Ht(e), t.clientX, t.clientY);
|
|
1841
1904
|
}, this.contentDOM.addEventListener("click", this.onClick);
|
|
1842
1905
|
}
|
|
1843
1906
|
destroy() {
|
|
1844
1907
|
this.contentDOM.removeEventListener("click", this.onClick), this.menu.destroy();
|
|
1845
1908
|
}
|
|
1846
|
-
},
|
|
1909
|
+
}, In = D.fromClass(Fn), Ln = (e) => e.replace(/^<([^]*)>$/, "$1").trim(), Rn = (e, t, n) => n ? {
|
|
1847
1910
|
pos: e,
|
|
1848
1911
|
end: t,
|
|
1849
1912
|
above: !0,
|
|
@@ -1852,27 +1915,27 @@ var Dn = E.high(w.of([{
|
|
|
1852
1915
|
return e.className = "cm-inplace-href-tip", e.textContent = n, { dom: e };
|
|
1853
1916
|
}
|
|
1854
1917
|
} : null;
|
|
1855
|
-
function
|
|
1856
|
-
for (let n =
|
|
1918
|
+
function zn(e, t) {
|
|
1919
|
+
for (let n = N(e.state).resolveInner(t, -1); n; n = n.parent) {
|
|
1857
1920
|
if (n.name !== "Link") continue;
|
|
1858
1921
|
if (e.state.doc.sliceString(Math.max(0, n.from - 1), n.from) === "[") break;
|
|
1859
1922
|
let t = n.getChild("URL"), r = t ? e.state.sliceDoc(t.from, t.to) : e.state.sliceDoc(n.from, n.to);
|
|
1860
|
-
return
|
|
1923
|
+
return Rn(n.from, n.to, Ln(r));
|
|
1861
1924
|
}
|
|
1862
1925
|
return null;
|
|
1863
1926
|
}
|
|
1864
|
-
function
|
|
1927
|
+
function Bn(e, n) {
|
|
1865
1928
|
let r = e.state.doc.lineAt(n);
|
|
1866
1929
|
for (let e of r.text.matchAll(t)) {
|
|
1867
1930
|
let t = r.from + (e.index ?? 0), i = t + e[0].length;
|
|
1868
|
-
if (!(n < t || n > i)) return
|
|
1931
|
+
if (!(n < t || n > i)) return Rn(t, i, (e[1] ?? "").trim());
|
|
1869
1932
|
}
|
|
1870
1933
|
return null;
|
|
1871
1934
|
}
|
|
1872
|
-
var
|
|
1873
|
-
let n = e.state.facet(
|
|
1874
|
-
return (n.links ?
|
|
1875
|
-
}),
|
|
1935
|
+
var Vn = de((e, t) => {
|
|
1936
|
+
let n = e.state.facet(P);
|
|
1937
|
+
return (n.links ? zn(e, t) : null) ?? (n.wikilinks ? Bn(e, t) : null);
|
|
1938
|
+
}), Hn = class extends O {
|
|
1876
1939
|
ref;
|
|
1877
1940
|
inline;
|
|
1878
1941
|
registry;
|
|
@@ -1899,45 +1962,45 @@ var Pn = he((e, t) => {
|
|
|
1899
1962
|
return !1;
|
|
1900
1963
|
}
|
|
1901
1964
|
};
|
|
1902
|
-
function
|
|
1903
|
-
let t = e.facet(
|
|
1904
|
-
if (!t || !e.facet(
|
|
1905
|
-
let n =
|
|
1965
|
+
function Un(e) {
|
|
1966
|
+
let t = e.facet(F);
|
|
1967
|
+
if (!t || !e.facet(P).embeds || !e.doc.toString().includes("![[")) return T.none;
|
|
1968
|
+
let n = z(e), r = N(e), i = [];
|
|
1906
1969
|
for (let a = 1; a <= e.doc.lines; a++) {
|
|
1907
1970
|
let o = e.doc.line(a);
|
|
1908
1971
|
if (!(!o.text.includes("![[") || n.has(a))) {
|
|
1909
|
-
if (
|
|
1910
|
-
|
|
1911
|
-
let e = (
|
|
1912
|
-
if (!e ||
|
|
1913
|
-
i.push(
|
|
1914
|
-
widget: new
|
|
1972
|
+
if (se(o.text)) {
|
|
1973
|
+
S.lastIndex = 0;
|
|
1974
|
+
let e = (S.exec(o.text.trim())?.[1] ?? "").trim();
|
|
1975
|
+
if (!e || B(r, o.from + o.text.indexOf("!["))) continue;
|
|
1976
|
+
i.push(T.replace({
|
|
1977
|
+
widget: new Hn(e, !1, t),
|
|
1915
1978
|
block: !0
|
|
1916
1979
|
}).range(o.from, o.to));
|
|
1917
1980
|
continue;
|
|
1918
1981
|
}
|
|
1919
|
-
|
|
1920
|
-
for (let e of o.text.matchAll(
|
|
1982
|
+
S.lastIndex = 0;
|
|
1983
|
+
for (let e of o.text.matchAll(S)) {
|
|
1921
1984
|
let n = (e[1] ?? "").trim();
|
|
1922
1985
|
if (!n) continue;
|
|
1923
1986
|
let a = o.from + (e.index ?? 0);
|
|
1924
|
-
|
|
1987
|
+
B(r, a + 2) || Ie(r, a + 2) || i.push(T.replace({ widget: new Hn(n, !0, t) }).range(a, a + e[0].length));
|
|
1925
1988
|
}
|
|
1926
1989
|
}
|
|
1927
1990
|
}
|
|
1928
|
-
return
|
|
1991
|
+
return T.set(i, !0);
|
|
1929
1992
|
}
|
|
1930
|
-
var
|
|
1931
|
-
create:
|
|
1932
|
-
update: (e, t) => t.docChanged || t.selection ?
|
|
1933
|
-
provide: (e) => [
|
|
1934
|
-
}),
|
|
1993
|
+
var Wn = M.define({
|
|
1994
|
+
create: Un,
|
|
1995
|
+
update: (e, t) => t.docChanged || t.selection ? Un(t.state) : e,
|
|
1996
|
+
provide: (e) => [E.decorations.from(e), E.atomicRanges.of((t) => t.state.field(e))]
|
|
1997
|
+
}), Gn = _e.define(), Kn = M.define({
|
|
1935
1998
|
create: () => !1,
|
|
1936
1999
|
update(e, t) {
|
|
1937
|
-
for (let n of t.effects) n.is(
|
|
2000
|
+
for (let n of t.effects) n.is(Gn) && (e = n.value);
|
|
1938
2001
|
return e;
|
|
1939
2002
|
}
|
|
1940
|
-
}),
|
|
2003
|
+
}), qn = class {
|
|
1941
2004
|
view;
|
|
1942
2005
|
menu;
|
|
1943
2006
|
onContextMenu;
|
|
@@ -1948,8 +2011,8 @@ var Ln = D.define({
|
|
|
1948
2011
|
longPressAt = 0;
|
|
1949
2012
|
destroyed = !1;
|
|
1950
2013
|
constructor(e) {
|
|
1951
|
-
this.view = e, this.menu =
|
|
1952
|
-
this.destroyed || e.dispatch({ effects:
|
|
2014
|
+
this.view = e, this.menu = J(e.dom.ownerDocument, "cm-inplace-menu", (t) => {
|
|
2015
|
+
this.destroyed || e.dispatch({ effects: Gn.of(t) });
|
|
1953
2016
|
}), e.dom.appendChild(this.menu.el), this.contentDOM = e.contentDOM, this.onPointerDown = () => {
|
|
1954
2017
|
let t = e.state.selection.main;
|
|
1955
2018
|
this.stashed = t.empty ? null : {
|
|
@@ -1958,18 +2021,18 @@ var Ln = D.define({
|
|
|
1958
2021
|
};
|
|
1959
2022
|
}, this.contentDOM.addEventListener("pointerdown", this.onPointerDown, !0), this.onContextMenu = (t) => {
|
|
1960
2023
|
let n = t.target;
|
|
1961
|
-
e.state.facet(
|
|
1962
|
-
}, this.contentDOM.addEventListener("contextmenu", this.onContextMenu), this.longPress =
|
|
2024
|
+
e.state.facet(we) && (n?.closest(".cm-inplace-table-edit") || (t.preventDefault(), this.longPress.cancel(), !(Date.now() - this.longPressAt < 700) && this.openMenuAt(t.clientX, t.clientY, n)));
|
|
2025
|
+
}, this.contentDOM.addEventListener("contextmenu", this.onContextMenu), this.longPress = on(this.contentDOM, { onLongPress: (e, t, n) => {
|
|
1963
2026
|
this.longPressAt = Date.now(), this.openMenuAt(e, t, n);
|
|
1964
2027
|
} });
|
|
1965
2028
|
}
|
|
1966
2029
|
openMenuAt(e, t, n) {
|
|
1967
2030
|
let r = this.view;
|
|
1968
|
-
if (!r.state.facet(
|
|
2031
|
+
if (!r.state.facet(we) || n?.closest(".cm-inplace-table-edit")) return;
|
|
1969
2032
|
let i = n?.closest(".cm-inplace-hr");
|
|
1970
2033
|
if (i) {
|
|
1971
2034
|
let n = r.posAtDOM(i);
|
|
1972
|
-
n >= 0 && r.dispatch({ selection: { anchor: n } }), this.menu.show(
|
|
2035
|
+
n >= 0 && r.dispatch({ selection: { anchor: n } }), this.menu.show(an(r), e, t);
|
|
1973
2036
|
return;
|
|
1974
2037
|
}
|
|
1975
2038
|
if (this.stashed && r.state.selection.main.empty) r.dispatch({ selection: this.stashed });
|
|
@@ -1979,7 +2042,7 @@ var Ln = D.define({
|
|
|
1979
2042
|
y: t
|
|
1980
2043
|
});
|
|
1981
2044
|
if (n != null) {
|
|
1982
|
-
let e =
|
|
2045
|
+
let e = H(r.state, n, !1, !0), t = r.state.wordAt(n) ?? { anchor: n };
|
|
1983
2046
|
e?.kind === "link" ? t = {
|
|
1984
2047
|
anchor: e.from,
|
|
1985
2048
|
head: e.to
|
|
@@ -1989,15 +2052,15 @@ var Ln = D.define({
|
|
|
1989
2052
|
}), r.dispatch({ selection: t });
|
|
1990
2053
|
}
|
|
1991
2054
|
}
|
|
1992
|
-
this.menu.show(
|
|
2055
|
+
this.menu.show(an(r), e, t);
|
|
1993
2056
|
}
|
|
1994
2057
|
destroy() {
|
|
1995
2058
|
this.destroyed = !0, this.contentDOM.removeEventListener("pointerdown", this.onPointerDown, !0), this.contentDOM.removeEventListener("contextmenu", this.onContextMenu), this.longPress.dispose(), this.menu.destroy();
|
|
1996
2059
|
}
|
|
1997
|
-
},
|
|
2060
|
+
}, Jn = D.fromClass(qn);
|
|
1998
2061
|
//#endregion
|
|
1999
2062
|
//#region src/inplace/selection-bar-position.ts
|
|
2000
|
-
function
|
|
2063
|
+
function Yn(e) {
|
|
2001
2064
|
let t = e.state.selection.main;
|
|
2002
2065
|
if (!t.empty) {
|
|
2003
2066
|
let n = e.coordsAtPos(t.from), r = e.coordsAtPos(t.to);
|
|
@@ -2011,7 +2074,7 @@ function Vn(e) {
|
|
|
2011
2074
|
}
|
|
2012
2075
|
};
|
|
2013
2076
|
}
|
|
2014
|
-
if (!
|
|
2077
|
+
if (!Y(e)) return null;
|
|
2015
2078
|
let n = e.dom.ownerDocument.getSelection();
|
|
2016
2079
|
if (!n || n.rangeCount === 0) return null;
|
|
2017
2080
|
let r = n.getRangeAt(0).getBoundingClientRect();
|
|
@@ -2025,15 +2088,15 @@ function Vn(e) {
|
|
|
2025
2088
|
}
|
|
2026
2089
|
};
|
|
2027
2090
|
}
|
|
2028
|
-
function
|
|
2029
|
-
if (e.state.facet(
|
|
2030
|
-
let r =
|
|
2091
|
+
function Xn(e, t, n) {
|
|
2092
|
+
if (e.state.facet(Ae) !== "bar" || e.state.field(Kn, !1)) return null;
|
|
2093
|
+
let r = Yn(e);
|
|
2031
2094
|
if (!r) return null;
|
|
2032
2095
|
let { box: i, inCell: a } = r;
|
|
2033
2096
|
if (!a && !e.hasFocus) return null;
|
|
2034
2097
|
let o = t.getBoundingClientRect(), s = e.dom.ownerDocument.defaultView?.innerWidth ?? 0, c = (i.left + i.right) / 2, l = e.dom.getBoundingClientRect().top, u = i.top - o.height - 6, d = i.bottom + 6, f = {}, p = {};
|
|
2035
2098
|
for (let t of n) {
|
|
2036
|
-
let n =
|
|
2099
|
+
let n = h[t], r = !a && !!n.disabled?.(e.state);
|
|
2037
2100
|
f[t] = r, p[t] = !r && !a && !!n.isActive?.(e.state);
|
|
2038
2101
|
}
|
|
2039
2102
|
return n.every((e) => f[e]) ? null : {
|
|
@@ -2045,7 +2108,7 @@ function Hn(e, t, n) {
|
|
|
2045
2108
|
}
|
|
2046
2109
|
//#endregion
|
|
2047
2110
|
//#region src/inplace/selection-bar.ts
|
|
2048
|
-
var
|
|
2111
|
+
var Zn = class {
|
|
2049
2112
|
view;
|
|
2050
2113
|
bar;
|
|
2051
2114
|
ids;
|
|
@@ -2055,17 +2118,17 @@ var Un = class {
|
|
|
2055
2118
|
this.bar.hidden = !0;
|
|
2056
2119
|
};
|
|
2057
2120
|
onSelectionChange = () => {
|
|
2058
|
-
|
|
2121
|
+
p(this.view) && this.schedule();
|
|
2059
2122
|
};
|
|
2060
2123
|
constructor(e) {
|
|
2061
2124
|
this.view = e;
|
|
2062
2125
|
let t = e.dom.ownerDocument;
|
|
2063
|
-
this.ids = e.state.facet(
|
|
2126
|
+
this.ids = e.state.facet(ke), this.linkMenu = J(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;
|
|
2064
2127
|
for (let n of this.ids) {
|
|
2065
|
-
let r =
|
|
2066
|
-
i.type = "button", i.className = "cm-inplace-selbar-btn", i.title = r.title, i.setAttribute("aria-label", r.title), i.appendChild(
|
|
2128
|
+
let r = h[n], i = t.createElement("button");
|
|
2129
|
+
i.type = "button", i.className = "cm-inplace-selbar-btn", i.title = r.title, i.setAttribute("aria-label", r.title), i.appendChild(y(t, b[n] ?? "")), i.addEventListener("mousedown", (e) => e.preventDefault()), i.addEventListener("click", (t) => {
|
|
2067
2130
|
t.preventDefault();
|
|
2068
|
-
let a = !!
|
|
2131
|
+
let a = !!p(e), o = !a && n === "link" ? Ht(e) : !a && n === "wikilink" ? Ut(e) : null;
|
|
2069
2132
|
if (o) {
|
|
2070
2133
|
let e = i.getBoundingClientRect();
|
|
2071
2134
|
this.linkMenu.showField(o, e.left, e.bottom + 6);
|
|
@@ -2077,7 +2140,7 @@ var Un = class {
|
|
|
2077
2140
|
e.dom.appendChild(this.bar), t.addEventListener("scroll", this.onScroll, !0), t.addEventListener("selectionchange", this.onSelectionChange);
|
|
2078
2141
|
}
|
|
2079
2142
|
update(e) {
|
|
2080
|
-
let t = e.startState.field(
|
|
2143
|
+
let t = e.startState.field(Kn, !1) !== e.state.field(Kn, !1);
|
|
2081
2144
|
(e.selectionSet || e.docChanged || e.focusChanged || t) && this.schedule();
|
|
2082
2145
|
}
|
|
2083
2146
|
schedule() {
|
|
@@ -2088,7 +2151,7 @@ var Un = class {
|
|
|
2088
2151
|
});
|
|
2089
2152
|
}
|
|
2090
2153
|
measure() {
|
|
2091
|
-
return
|
|
2154
|
+
return Xn(this.view, this.bar, this.ids);
|
|
2092
2155
|
}
|
|
2093
2156
|
apply(e) {
|
|
2094
2157
|
if (!e) {
|
|
@@ -2102,98 +2165,30 @@ var Un = class {
|
|
|
2102
2165
|
let e = this.view.dom.ownerDocument;
|
|
2103
2166
|
e.removeEventListener("scroll", this.onScroll, !0), e.removeEventListener("selectionchange", this.onSelectionChange), this.linkMenu.destroy(), this.bar.remove();
|
|
2104
2167
|
}
|
|
2105
|
-
},
|
|
2106
|
-
|
|
2107
|
-
embeds;
|
|
2108
|
-
constructor(e, t) {
|
|
2109
|
-
super(), this.table = e, this.embeds = t;
|
|
2110
|
-
}
|
|
2111
|
-
eq(e) {
|
|
2112
|
-
return JSON.stringify(this.table) === JSON.stringify(e.table);
|
|
2113
|
-
}
|
|
2114
|
-
toDOM() {
|
|
2115
|
-
let { head: e, body: t, aligns: n } = this.table, r = document.createElement("table");
|
|
2116
|
-
r.className = "cm-inplace-table";
|
|
2117
|
-
let i = (e) => sn(e.replace(/\\\|/g, "|"), this.embeds), a = r.createTHead().insertRow();
|
|
2118
|
-
e.forEach((e, t) => {
|
|
2119
|
-
let r = document.createElement("th");
|
|
2120
|
-
r.appendChild(i(e)), r.dataset.styloRow = "0", r.dataset.styloCol = String(t), Kn(r, n[t]), a.appendChild(r);
|
|
2121
|
-
});
|
|
2122
|
-
let o = r.createTBody();
|
|
2123
|
-
return t.forEach((t, r) => {
|
|
2124
|
-
let a = o.insertRow();
|
|
2125
|
-
for (let o = 0; o < e.length; o++) {
|
|
2126
|
-
let e = a.insertCell();
|
|
2127
|
-
e.appendChild(i(t[o] ?? "")), e.dataset.styloRow = String(r + 1), e.dataset.styloCol = String(o), Kn(e, n[o]);
|
|
2128
|
-
}
|
|
2129
|
-
}), r;
|
|
2130
|
-
}
|
|
2131
|
-
ignoreEvent() {
|
|
2132
|
-
return !1;
|
|
2133
|
-
}
|
|
2134
|
-
};
|
|
2135
|
-
function Kn(e, t) {
|
|
2136
|
-
t && (e.style.textAlign = t);
|
|
2137
|
-
}
|
|
2138
|
-
function qn(e, t) {
|
|
2139
|
-
let n = t.lineAt(e.from).number, r = t.lineAt(e.to).number, a = [];
|
|
2140
|
-
for (let e = n; e <= r; e++) a.push(t.line(e).text);
|
|
2141
|
-
let o = i(a);
|
|
2142
|
-
return !o || o.rows.length === 0 ? null : {
|
|
2143
|
-
head: o.rows[0],
|
|
2144
|
-
body: o.rows.slice(1),
|
|
2145
|
-
aligns: o.aligns
|
|
2146
|
-
};
|
|
2147
|
-
}
|
|
2148
|
-
function Jn(e) {
|
|
2149
|
-
if (!e.facet(k).tables) return b.none;
|
|
2150
|
-
let t = e.facet(j) === "cells", r = e.facet(A) != null && e.facet(k).embeds, i = O(e), a = n(e.doc), o = t ? null : P(e), s = [];
|
|
2151
|
-
return i.iterate({ enter: (n) => {
|
|
2152
|
-
if (n.name !== "Table") return;
|
|
2153
|
-
if (a && n.from < a.to) return !1;
|
|
2154
|
-
if (o) {
|
|
2155
|
-
let t = e.doc.lineAt(n.from).number, r = e.doc.lineAt(n.to).number;
|
|
2156
|
-
for (let e = t; e <= r; e++) if (o.has(e)) return !1;
|
|
2157
|
-
}
|
|
2158
|
-
let i = qn(n.node, e.doc);
|
|
2159
|
-
if (i) {
|
|
2160
|
-
let e = t ? new yn(i, r) : new Gn(i, r);
|
|
2161
|
-
s.push(b.replace({
|
|
2162
|
-
widget: e,
|
|
2163
|
-
block: !0
|
|
2164
|
-
}).range(n.from, n.to));
|
|
2165
|
-
}
|
|
2166
|
-
return !1;
|
|
2167
|
-
} }), b.set(s, !0);
|
|
2168
|
-
}
|
|
2169
|
-
var Yn = D.define({
|
|
2170
|
-
create: Jn,
|
|
2171
|
-
update: (e, t) => t.annotation(Q) ? e.map(t.changes) : t.state.facet(j) === "cells" ? t.docChanged ? Jn(t.state) : e.map(t.changes) : t.docChanged || t.selection ? Jn(t.state) : e,
|
|
2172
|
-
provide: (e) => [x.decorations.from(e), x.atomicRanges.of((t) => t.state.field(e))]
|
|
2173
|
-
}), Xn = (e) => (t) => {
|
|
2174
|
-
if (f(t)) return !1;
|
|
2168
|
+
}, Qn = D.fromClass(Zn), $n = (e) => (t) => {
|
|
2169
|
+
if (p(t)) return !1;
|
|
2175
2170
|
let n = t.state.selection.main;
|
|
2176
2171
|
if (!n.empty) return !1;
|
|
2177
2172
|
let { doc: r } = t.state, i = r.lineAt(n.head), a = e ? i.number + 1 : i.number - 1;
|
|
2178
2173
|
if (a < 1 || a > r.lines) return !1;
|
|
2179
2174
|
let o = r.line(a), s = -1, c = -1, l;
|
|
2180
|
-
if (t.state.field(
|
|
2175
|
+
if (t.state.field(Tn).between(o.from, o.to, (t, n, r) => {
|
|
2181
2176
|
if (e ? t === o.from : n === o.to) return s = t, c = n, l = r.spec.widget, !1;
|
|
2182
2177
|
}), s < 0) return !1;
|
|
2183
|
-
if (t.state.facet(
|
|
2178
|
+
if (t.state.facet(I) === "cells") return l instanceof En && l.focusEdge(e ? "first" : "last");
|
|
2184
2179
|
let u = e ? r.lineAt(s).from : r.lineAt(c).to;
|
|
2185
2180
|
return t.dispatch({
|
|
2186
2181
|
selection: { anchor: u },
|
|
2187
2182
|
userEvent: "select",
|
|
2188
2183
|
scrollIntoView: !0
|
|
2189
2184
|
}), !0;
|
|
2190
|
-
},
|
|
2185
|
+
}, er = $n(!0), tr = $n(!1), nr = j.high(k.of([{
|
|
2191
2186
|
key: "ArrowDown",
|
|
2192
|
-
run:
|
|
2187
|
+
run: er
|
|
2193
2188
|
}, {
|
|
2194
2189
|
key: "ArrowUp",
|
|
2195
|
-
run:
|
|
2196
|
-
}])),
|
|
2190
|
+
run: tr
|
|
2191
|
+
}])), rr = {
|
|
2197
2192
|
".cm-inplace-callout": {
|
|
2198
2193
|
borderLeft: "0.25rem solid var(--stylo-callout-accent, var(--stylo-border))",
|
|
2199
2194
|
padding: "0 1rem",
|
|
@@ -2227,9 +2222,9 @@ var Yn = D.define({
|
|
|
2227
2222
|
content: "\"\"",
|
|
2228
2223
|
display: "none"
|
|
2229
2224
|
}
|
|
2230
|
-
},
|
|
2225
|
+
}, ir = "var(--stylo-font-family-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace)", ar = "var(--stylo-font-family, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif)", or = {
|
|
2231
2226
|
"& .cm-content": {
|
|
2232
|
-
fontFamily:
|
|
2227
|
+
fontFamily: ar,
|
|
2233
2228
|
lineHeight: "1.75",
|
|
2234
2229
|
padding: "0.75rem",
|
|
2235
2230
|
WebkitTouchCallout: "none"
|
|
@@ -2268,14 +2263,14 @@ var Yn = D.define({
|
|
|
2268
2263
|
".cm-inplace-em": { fontStyle: "italic" },
|
|
2269
2264
|
".cm-inplace-strike": { textDecoration: "line-through" },
|
|
2270
2265
|
".cm-inplace-code": {
|
|
2271
|
-
fontFamily:
|
|
2266
|
+
fontFamily: ir,
|
|
2272
2267
|
fontSize: "0.9em",
|
|
2273
2268
|
padding: "0.1em 0.35em",
|
|
2274
2269
|
borderRadius: "3px",
|
|
2275
2270
|
background: "color-mix(in srgb, var(--stylo-border) 45%, transparent)"
|
|
2276
2271
|
},
|
|
2277
2272
|
".cm-inplace-mono": {
|
|
2278
|
-
fontFamily:
|
|
2273
|
+
fontFamily: ir,
|
|
2279
2274
|
fontSize: "0.9em",
|
|
2280
2275
|
background: "color-mix(in srgb, var(--stylo-border) 35%, transparent)",
|
|
2281
2276
|
padding: "0 0.9rem"
|
|
@@ -2309,12 +2304,14 @@ var Yn = D.define({
|
|
|
2309
2304
|
".cm-inplace-math-block .katex-display": { margin: "0" },
|
|
2310
2305
|
".cm-inplace-embed": {
|
|
2311
2306
|
display: "block",
|
|
2312
|
-
|
|
2307
|
+
padding: "0.9em 0"
|
|
2313
2308
|
},
|
|
2314
2309
|
".cm-inplace-embed .stylo-embed-content": {
|
|
2315
2310
|
borderLeft: "3px solid var(--stylo-embed-accent, var(--stylo-border))",
|
|
2316
2311
|
paddingLeft: "1rem"
|
|
2317
2312
|
},
|
|
2313
|
+
".cm-inplace-embed .stylo-embed-content > :first-child": { marginTop: "0" },
|
|
2314
|
+
".cm-inplace-embed .stylo-embed-content > :last-child": { marginBottom: "0" },
|
|
2318
2315
|
".cm-inplace-embed-inline": { display: "inline" },
|
|
2319
2316
|
".cm-inplace-hr-line": {
|
|
2320
2317
|
fontSize: "0",
|
|
@@ -2349,21 +2346,21 @@ var Yn = D.define({
|
|
|
2349
2346
|
cursor: "pointer"
|
|
2350
2347
|
},
|
|
2351
2348
|
".cm-inplace-fm": {
|
|
2352
|
-
fontFamily:
|
|
2349
|
+
fontFamily: ir,
|
|
2353
2350
|
fontSize: "0.85em",
|
|
2354
2351
|
color: "var(--stylo-text-muted)"
|
|
2355
2352
|
},
|
|
2356
2353
|
".cm-inplace-fm-first::before": {
|
|
2357
2354
|
content: "\"Frontmatter\"",
|
|
2358
2355
|
marginRight: "0.6em",
|
|
2359
|
-
fontFamily:
|
|
2356
|
+
fontFamily: ar,
|
|
2360
2357
|
fontSize: "0.8rem",
|
|
2361
2358
|
fontWeight: "600",
|
|
2362
2359
|
textTransform: "uppercase",
|
|
2363
2360
|
letterSpacing: "0.04em",
|
|
2364
2361
|
color: "var(--stylo-text-muted)"
|
|
2365
2362
|
}
|
|
2366
|
-
},
|
|
2363
|
+
}, sr = {
|
|
2367
2364
|
".cm-inplace-menu": {
|
|
2368
2365
|
position: "fixed",
|
|
2369
2366
|
inset: "0",
|
|
@@ -2437,7 +2434,7 @@ var Yn = D.define({
|
|
|
2437
2434
|
outline: "none"
|
|
2438
2435
|
},
|
|
2439
2436
|
".cm-inplace-menu-input:focus": { borderColor: "var(--stylo-ring)" }
|
|
2440
|
-
},
|
|
2437
|
+
}, cr = {
|
|
2441
2438
|
".cm-inplace-selbar": {
|
|
2442
2439
|
position: "fixed",
|
|
2443
2440
|
zIndex: "20",
|
|
@@ -2522,7 +2519,7 @@ var Yn = D.define({
|
|
|
2522
2519
|
lineHeight: "1.4",
|
|
2523
2520
|
wordBreak: "break-all"
|
|
2524
2521
|
}
|
|
2525
|
-
},
|
|
2522
|
+
}, lr = {
|
|
2526
2523
|
".cm-inplace-table": {
|
|
2527
2524
|
borderCollapse: "collapse",
|
|
2528
2525
|
padding: "1em 0 1.4em",
|
|
@@ -2545,7 +2542,7 @@ var Yn = D.define({
|
|
|
2545
2542
|
outline: "none"
|
|
2546
2543
|
},
|
|
2547
2544
|
".cm-inplace-table-edit .cm-inplace-tcell:focus": { boxShadow: "inset 0 0 0 2px var(--stylo-ring)" }
|
|
2548
|
-
},
|
|
2545
|
+
}, ur = {
|
|
2549
2546
|
".cm-inplace-table-wrap": {
|
|
2550
2547
|
position: "relative",
|
|
2551
2548
|
display: "inline-block",
|
|
@@ -2586,15 +2583,15 @@ var Yn = D.define({
|
|
|
2586
2583
|
},
|
|
2587
2584
|
".cm-inplace-tg-edge:hover .cm-inplace-tg-plus": { color: "var(--stylo-text)" },
|
|
2588
2585
|
"@media (hover: none)": { ".cm-inplace-tg-edge": { opacity: "0.5" } }
|
|
2589
|
-
},
|
|
2590
|
-
...rr,
|
|
2591
|
-
...er,
|
|
2586
|
+
}, dr = E.theme({
|
|
2592
2587
|
...or,
|
|
2588
|
+
...rr,
|
|
2589
|
+
...lr,
|
|
2590
|
+
...ur,
|
|
2593
2591
|
...sr,
|
|
2594
|
-
...
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
function ur(e, t, n) {
|
|
2592
|
+
...cr
|
|
2593
|
+
}), fr = ".cm-inplace-math, .cm-inplace-hr, .cm-inplace-table, .cm-inplace-embed, .cm-inplace-embed-inline";
|
|
2594
|
+
function pr(e, t, n) {
|
|
2598
2595
|
let r = e.firstChild, i = e.textContent?.length ?? 0;
|
|
2599
2596
|
if (!r || r.nodeType !== Node.TEXT_NODE || i === 0) return 0;
|
|
2600
2597
|
let a = e.ownerDocument, o = null, s = 0;
|
|
@@ -2607,49 +2604,49 @@ function ur(e, t, n) {
|
|
|
2607
2604
|
}
|
|
2608
2605
|
return o === r ? Math.min(s, i) : o === e && s > 0 ? i : 0;
|
|
2609
2606
|
}
|
|
2610
|
-
function
|
|
2611
|
-
let t =
|
|
2607
|
+
function mr(e = {}) {
|
|
2608
|
+
let t = Ee(e.inPlace?.contextMenu);
|
|
2612
2609
|
return [
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
Dn,
|
|
2624
|
-
It,
|
|
2625
|
-
Tt,
|
|
2626
|
-
$n,
|
|
2627
|
-
Tn,
|
|
2628
|
-
xn,
|
|
2629
|
-
Ue,
|
|
2630
|
-
Ln,
|
|
2631
|
-
Pe,
|
|
2632
|
-
Yn,
|
|
2633
|
-
$,
|
|
2634
|
-
Bn,
|
|
2635
|
-
Wn,
|
|
2636
|
-
kn,
|
|
2610
|
+
P.of(Se(e.inPlace)),
|
|
2611
|
+
F.of(e.embedRegistry ?? null),
|
|
2612
|
+
I.of(e.inPlace?.table ?? "source"),
|
|
2613
|
+
L.of(e.inPlace?.reveal ?? "caret"),
|
|
2614
|
+
Ce.of(e.onLinkClick ?? null),
|
|
2615
|
+
we.of(t.enabled),
|
|
2616
|
+
De.of(t.groups),
|
|
2617
|
+
Ae.of(e.inPlace?.selectionUI ?? "menu"),
|
|
2618
|
+
ke.of(Oe(e.inPlace?.selectionBarItems)),
|
|
2619
|
+
ht(),
|
|
2637
2620
|
Pn,
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2621
|
+
Lt,
|
|
2622
|
+
Et,
|
|
2623
|
+
nr,
|
|
2624
|
+
Mn,
|
|
2625
|
+
On,
|
|
2626
|
+
We,
|
|
2627
|
+
Wn,
|
|
2628
|
+
Me,
|
|
2629
|
+
Tn,
|
|
2630
|
+
Kn,
|
|
2631
|
+
Jn,
|
|
2632
|
+
Qn,
|
|
2633
|
+
In,
|
|
2634
|
+
Vn,
|
|
2635
|
+
Zt,
|
|
2636
|
+
Qt,
|
|
2637
|
+
j.high(dr),
|
|
2638
|
+
E.domEventHandlers({
|
|
2642
2639
|
mousedown(e, t) {
|
|
2643
2640
|
let n = e.target;
|
|
2644
2641
|
if (n?.closest(".cm-inplace-table-edit") || n?.closest(".stylo-embed-content")) return !1;
|
|
2645
|
-
let r = n?.closest(
|
|
2642
|
+
let r = n?.closest(fr);
|
|
2646
2643
|
if (!r) return !1;
|
|
2647
2644
|
let i = t.posAtDOM(r);
|
|
2648
2645
|
if (i < 0) return !1;
|
|
2649
2646
|
let a = n?.closest("[data-stylo-row]");
|
|
2650
2647
|
if (a && r.contains(a)) {
|
|
2651
|
-
let n =
|
|
2652
|
-
n != null && (i = n +
|
|
2648
|
+
let n = f(t.state.doc, i, Number(a.dataset.styloRow), Number(a.dataset.styloCol));
|
|
2649
|
+
n != null && (i = n + pr(a, e.clientX, e.clientY));
|
|
2653
2650
|
}
|
|
2654
2651
|
return t.focus(), t.dispatch({ selection: { anchor: i } }), !0;
|
|
2655
2652
|
},
|
|
@@ -2663,40 +2660,47 @@ function dr(e = {}) {
|
|
|
2663
2660
|
}
|
|
2664
2661
|
//#endregion
|
|
2665
2662
|
//#region src/inplace/InPlaceView.tsx
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
})
|
|
2663
|
+
var hr = () => () => {}, gr = () => null;
|
|
2664
|
+
function _r({ value: t, onChange: n, readOnly: i, placeholder: a, onWikiLinkClick: o, onLinkClick: s, inPlace: c, codeLanguages: l, wikiLinkSource: u, embedSource: d, onResolveError: f, onSave: p, onViewChange: m, canvasHeader: h }) {
|
|
2665
|
+
let ee = C(o);
|
|
2666
|
+
ee.current = o;
|
|
2667
|
+
let g = C(s);
|
|
2668
|
+
g.current = s;
|
|
2669
|
+
let [_] = w(() => new be()), te = ue(_.subscribe, _.getSnapshot, _.getSnapshot), [re, ie] = w(null), v = C(m);
|
|
2670
|
+
v.current = m;
|
|
2671
|
+
let ae = C((e) => {
|
|
2672
|
+
ie(e), v.current?.(e);
|
|
2673
|
+
}).current, y = C(h);
|
|
2674
|
+
y.current = h;
|
|
2675
|
+
let [b] = w(() => h ? new r() : null), oe = ue(b?.subscribe ?? hr, b?.getSnapshot ?? gr), [se] = w(() => [mr({
|
|
2676
|
+
onWikiLinkClick: (e) => ee.current?.(e),
|
|
2677
|
+
onLinkClick: (e) => g.current?.(e),
|
|
2678
|
+
inPlace: c,
|
|
2679
|
+
embedRegistry: d ? _ : void 0
|
|
2680
|
+
}), ...b ? [fe.of(b.panel)] : []]), x = ne({
|
|
2677
2681
|
value: t,
|
|
2678
2682
|
onChange: n,
|
|
2679
|
-
readOnly:
|
|
2680
|
-
placeholder:
|
|
2681
|
-
extensions:
|
|
2682
|
-
codeLanguages:
|
|
2683
|
-
wikiLinkSource:
|
|
2684
|
-
onResolveError:
|
|
2685
|
-
onSave:
|
|
2686
|
-
onViewChange:
|
|
2683
|
+
readOnly: i,
|
|
2684
|
+
placeholder: a,
|
|
2685
|
+
extensions: se,
|
|
2686
|
+
codeLanguages: l,
|
|
2687
|
+
wikiLinkSource: u,
|
|
2688
|
+
onResolveError: f,
|
|
2689
|
+
onSave: p,
|
|
2690
|
+
onViewChange: ae
|
|
2687
2691
|
});
|
|
2688
|
-
return /* @__PURE__ */
|
|
2692
|
+
return /* @__PURE__ */ ye("div", {
|
|
2689
2693
|
className: e.inplace,
|
|
2690
|
-
ref:
|
|
2691
|
-
children:
|
|
2694
|
+
ref: x,
|
|
2695
|
+
children: [d && te.map((e) => pe(/* @__PURE__ */ ve(ce, {
|
|
2692
2696
|
reference: e.ref,
|
|
2693
|
-
source:
|
|
2694
|
-
onError:
|
|
2697
|
+
source: d,
|
|
2698
|
+
onError: f,
|
|
2695
2699
|
inline: e.inline
|
|
2696
|
-
}), e.el, String(e.id)))
|
|
2700
|
+
}), e.el, String(e.id))), oe && y.current && pe(y.current({ view: re }), oe)]
|
|
2697
2701
|
});
|
|
2698
2702
|
}
|
|
2699
2703
|
//#endregion
|
|
2700
|
-
export {
|
|
2704
|
+
export { _r as InPlaceView };
|
|
2701
2705
|
|
|
2702
|
-
//# sourceMappingURL=InPlaceView-
|
|
2706
|
+
//# sourceMappingURL=InPlaceView-Dyf7I4XQ.js.map
|