@damiro/stylo 0.16.0 → 0.18.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 +6 -4
- package/dist/{InPlaceView-CC5hZCcI.js → InPlaceView-Z8c9cqW8.js} +461 -460
- package/dist/{InPlaceView-CC5hZCcI.js.map → InPlaceView-Z8c9cqW8.js.map} +1 -1
- package/dist/{Preview-5lm2uUVj.js → Preview-BRA_R_Gp.js} +3 -3
- package/dist/{Preview-5lm2uUVj.js.map → Preview-BRA_R_Gp.js.map} +1 -1
- package/dist/SplitView.d.ts +4 -1
- package/dist/SplitView.d.ts.map +1 -1
- package/dist/Stylo.d.ts.map +1 -1
- package/dist/editor/SourceView.d.ts +4 -1
- package/dist/editor/SourceView.d.ts.map +1 -1
- package/dist/editor/theme.d.ts.map +1 -1
- package/dist/editor/useCodeMirror.d.ts +7 -1
- package/dist/editor/useCodeMirror.d.ts.map +1 -1
- package/dist/{embed-DKKeCE1Y.js → embed-DJAydn-v.js} +2 -2
- package/dist/{embed-DKKeCE1Y.js.map → embed-DJAydn-v.js.map} +1 -1
- package/dist/{embed-cache-CcBfVrc9.js → embed-cache-BU9Smn-h.js} +24 -17
- package/dist/embed-cache-BU9Smn-h.js.map +1 -0
- package/dist/inplace/InPlaceView.d.ts +4 -1
- package/dist/inplace/InPlaceView.d.ts.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/stylo.js +384 -154
- package/dist/stylo.js.map +1 -1
- package/dist/toolbar/OverflowBar.d.ts +19 -0
- package/dist/toolbar/OverflowBar.d.ts.map +1 -0
- package/dist/toolbar/OverflowMenu.d.ts +24 -0
- package/dist/toolbar/OverflowMenu.d.ts.map +1 -0
- package/dist/toolbar/Toolbar.d.ts +5 -1
- package/dist/toolbar/Toolbar.d.ts.map +1 -1
- package/dist/toolbar/overflow-fit.d.ts +27 -0
- package/dist/toolbar/overflow-fit.d.ts.map +1 -0
- package/dist/toolbar/toolbar-model.d.ts +31 -0
- package/dist/toolbar/toolbar-model.d.ts.map +1 -0
- package/dist/toolbar/use-toolbar-overflow.d.ts +17 -0
- package/dist/toolbar/use-toolbar-overflow.d.ts.map +1 -0
- package/dist/types/core.d.ts +9 -0
- package/dist/types/core.d.ts.map +1 -1
- package/dist/types/toolbar.d.ts +16 -0
- package/dist/types/toolbar.d.ts.map +1 -1
- package/dist/{useCodeMirror-TAWSJQiZ.js → useCodeMirror-Fn6qEfMx.js} +262 -254
- package/dist/{useCodeMirror-TAWSJQiZ.js.map → useCodeMirror-Fn6qEfMx.js.map} +1 -1
- package/package.json +4 -4
- package/dist/embed-cache-CcBfVrc9.js.map +0 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { l as e, s as t, u as n } from "./embed-cache-
|
|
2
|
-
import { C as r, D as i, E as a, O as o, S as s, T as c, _ as l, a as u, b as d, c as f, d as p, f as m, g as h, h as ee, i as te, k as ne, l as
|
|
3
|
-
import { a as
|
|
4
|
-
import { a as
|
|
5
|
-
import { t as
|
|
6
|
-
import { useRef as
|
|
7
|
-
import { Decoration as
|
|
8
|
-
import { createPortal as
|
|
9
|
-
import { Annotation as
|
|
10
|
-
import { syntaxTree as
|
|
11
|
-
import { jsx as
|
|
1
|
+
import { l as e, s as t, u as n } from "./embed-cache-BU9Smn-h.js";
|
|
2
|
+
import { C as r, D as i, E as a, O as o, S as s, T as c, _ as l, a as u, b as d, c as f, d as p, f as m, g as h, h as ee, i as te, k as ne, l as re, m as g, n as _, o as ie, p as ae, r as oe, s as se, t as ce, u as v, v as y, w as b, x as le, y as ue } from "./useCodeMirror-Fn6qEfMx.js";
|
|
3
|
+
import { a as de, i as x } from "./config-DTBxVhtH.js";
|
|
4
|
+
import { a as fe, n as pe, o as me, r as he, t as S } from "./embed-DJAydn-v.js";
|
|
5
|
+
import { t as ge } from "./katex-BfiLlqfN.js";
|
|
6
|
+
import { useRef as C, useState as w, useSyncExternalStore as _e } from "react";
|
|
7
|
+
import { Decoration as T, EditorView as E, ViewPlugin as D, WidgetType as O, hoverTooltip as ve, keymap as k, showPanel as ye } from "@codemirror/view";
|
|
8
|
+
import { createPortal as be } from "react-dom";
|
|
9
|
+
import { Annotation as xe, EditorSelection as Se, EditorState as Ce, Facet as A, Prec as j, StateEffect as we, StateField as M } from "@codemirror/state";
|
|
10
|
+
import { syntaxTree as N } from "@codemirror/language";
|
|
11
|
+
import { jsx as Te, jsxs as Ee } from "react/jsx-runtime";
|
|
12
12
|
//#region src/inplace/embed-registry.ts
|
|
13
|
-
var
|
|
13
|
+
var De = class {
|
|
14
14
|
slots = /* @__PURE__ */ new Map();
|
|
15
15
|
listeners = /* @__PURE__ */ new Set();
|
|
16
16
|
snapshot = [];
|
|
@@ -33,7 +33,7 @@ var Oe = class {
|
|
|
33
33
|
for (let e of this.listeners) e();
|
|
34
34
|
}));
|
|
35
35
|
}
|
|
36
|
-
},
|
|
36
|
+
}, Oe = {
|
|
37
37
|
headings: !0,
|
|
38
38
|
emphasis: !0,
|
|
39
39
|
links: !0,
|
|
@@ -48,19 +48,19 @@ var Oe = class {
|
|
|
48
48
|
tables: !0,
|
|
49
49
|
embeds: !0
|
|
50
50
|
};
|
|
51
|
-
function
|
|
51
|
+
function ke(e) {
|
|
52
52
|
return {
|
|
53
|
-
...
|
|
53
|
+
...Oe,
|
|
54
54
|
...e?.decorations
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
-
var
|
|
57
|
+
var P = A.define({ combine: (e) => e[0] ?? Oe }), F = A.define({ combine: (e) => e[0] ?? null }), I = A.define({ combine: (e) => e[0] ?? "source" }), L = A.define({ combine: (e) => e[0] ?? "caret" }), Ae = A.define({ combine: (e) => e[0] ?? null }), je = A.define({ combine: (e) => e[0] ?? !0 }), Me = [
|
|
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 N = k.define({ combine: (e) => e[0] ?? ke }), P = k.define({ combine: (e) =>
|
|
|
69
69
|
"wikilink",
|
|
70
70
|
"math"
|
|
71
71
|
];
|
|
72
|
-
function
|
|
72
|
+
function Ne(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: Me
|
|
79
79
|
} : {
|
|
80
80
|
enabled: !0,
|
|
81
|
-
groups: e.groups?.length ? e.groups :
|
|
81
|
+
groups: e.groups?.length ? e.groups : Me
|
|
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 Pe = A.define({ combine: (e) => e[0] ?? Me });
|
|
85
|
+
function Fe(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 Ie = A.define({ combine: (e) => e[0] ?? R }), Le = 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 Re(e) {
|
|
94
|
+
if (!e.facet(P).frontmatter) return T.none;
|
|
95
95
|
let n = t(e.doc);
|
|
96
|
-
if (!n) return
|
|
96
|
+
if (!n) return T.none;
|
|
97
97
|
let r = e.doc.lineAt(n.from).number, i = e.doc.lineAt(n.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 ze = M.define({
|
|
108
|
+
create: Re,
|
|
109
|
+
update: (e, t) => t.docChanged || t.selection ? Re(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 Be(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 Ve(e, t, n, r, i, a) {
|
|
120
120
|
if (!i.lists) return;
|
|
121
121
|
let o = /* @__PURE__ */ new Set();
|
|
122
122
|
n.iterate({
|
|
@@ -124,17 +124,17 @@ function He(e, t, n, r, i, a) {
|
|
|
124
124
|
to: t,
|
|
125
125
|
enter: (e) => {
|
|
126
126
|
if (e.name !== "ListItem") return;
|
|
127
|
-
let t =
|
|
128
|
-
for (let e = i; e <= s; e++) c && e >= l && e <= u || (n >= 1 && !o.has(e) && (o.add(e), a.push(
|
|
127
|
+
let t = Be(e), n = t - 1, i = r.lineAt(e.from).number, s = r.lineAt(Math.min(e.to, r.length)).number, c = e.node.getChild("BulletList") ?? e.node.getChild("OrderedList"), l = c ? r.lineAt(c.from).number : -1, u = c ? r.lineAt(Math.max(c.from, c.to - 1)).number : -1, d = e.node.prevSibling ? "cm-inplace-item-gap" : t > 1 ? "cm-inplace-item-gap-nested" : null;
|
|
128
|
+
for (let e = i; e <= s; e++) c && e >= l && e <= u || (n >= 1 && !o.has(e) && (o.add(e), a.push(T.line({
|
|
129
129
|
class: "cm-inplace-li",
|
|
130
130
|
attributes: { style: `--sl-li-depth:${n}` }
|
|
131
|
-
}).range(r.line(e).from))), e === i && d && a.push(
|
|
131
|
+
}).range(r.line(e).from))), e === i && d && a.push(T.line({ class: d }).range(r.line(e).from)));
|
|
132
132
|
}
|
|
133
133
|
});
|
|
134
134
|
}
|
|
135
135
|
//#endregion
|
|
136
136
|
//#region src/inplace/reveal.ts
|
|
137
|
-
function
|
|
137
|
+
function z(e) {
|
|
138
138
|
let t = /* @__PURE__ */ new Set();
|
|
139
139
|
for (let n of e.selection.ranges) {
|
|
140
140
|
let r = e.doc.lineAt(n.from).number, i = e.doc.lineAt(n.to).number;
|
|
@@ -144,22 +144,22 @@ function R(e) {
|
|
|
144
144
|
}
|
|
145
145
|
//#endregion
|
|
146
146
|
//#region src/inplace/scan.ts
|
|
147
|
-
var
|
|
147
|
+
var He = /* @__PURE__ */ new Set([
|
|
148
148
|
"InlineCode",
|
|
149
149
|
"FencedCode",
|
|
150
150
|
"CodeBlock",
|
|
151
151
|
"CodeText"
|
|
152
152
|
]);
|
|
153
|
-
function
|
|
153
|
+
function B(e, t) {
|
|
154
154
|
let n = e.resolveInner(t, 1);
|
|
155
155
|
for (;;) {
|
|
156
|
-
if (
|
|
156
|
+
if (He.has(n.name)) return !0;
|
|
157
157
|
let e = n.parent;
|
|
158
158
|
if (!e) return !1;
|
|
159
159
|
n = e;
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
|
-
function
|
|
162
|
+
function Ue(e, t) {
|
|
163
163
|
let n = e.resolveInner(t, 1);
|
|
164
164
|
for (;;) {
|
|
165
165
|
if (n.name === "Table") return !0;
|
|
@@ -168,16 +168,16 @@ function We(e, t) {
|
|
|
168
168
|
n = e;
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
|
-
function
|
|
171
|
+
function We(e, t, n, r) {
|
|
172
172
|
let i = t.lineAt(n).number, a = t.lineAt(r).number;
|
|
173
173
|
for (let t = i; t <= a; t++) if (e.has(t)) return !0;
|
|
174
174
|
return !1;
|
|
175
175
|
}
|
|
176
176
|
//#endregion
|
|
177
177
|
//#region src/inplace/math.ts
|
|
178
|
-
var
|
|
179
|
-
function
|
|
180
|
-
for (let n of e.matchAll(
|
|
178
|
+
var Ge = /(?<![\w$])\$(?!\s)([^\n$]+?)(?<!\s)\$(?![\w$])/g, Ke = /(?<![\w$])\$\$([^\n$]+?)\$\$(?![\w$])/g, qe = /(?<![\w$])\$\$([^]+?)\$\$/g;
|
|
179
|
+
function Je(e, t) {
|
|
180
|
+
for (let n of e.matchAll(Ke)) {
|
|
181
181
|
let e = n.index ?? 0, r = e + (n[0] ?? "").length;
|
|
182
182
|
if (t >= e && t <= r) return {
|
|
183
183
|
from: e,
|
|
@@ -186,7 +186,7 @@ function Ye(e, t) {
|
|
|
186
186
|
block: !0
|
|
187
187
|
};
|
|
188
188
|
}
|
|
189
|
-
for (let n of e.matchAll(
|
|
189
|
+
for (let n of e.matchAll(Ge)) {
|
|
190
190
|
let e = n.index ?? 0, r = e + (n[0] ?? "").length;
|
|
191
191
|
if (t >= e && t <= r) return {
|
|
192
192
|
from: e,
|
|
@@ -197,7 +197,7 @@ function Ye(e, t) {
|
|
|
197
197
|
}
|
|
198
198
|
return null;
|
|
199
199
|
}
|
|
200
|
-
var
|
|
200
|
+
var Ye = class extends O {
|
|
201
201
|
src;
|
|
202
202
|
block;
|
|
203
203
|
constructor(e, t) {
|
|
@@ -210,7 +210,7 @@ var Xe = class extends D {
|
|
|
210
210
|
let e = document.createElement(this.block ? "div" : "span");
|
|
211
211
|
e.className = this.block ? "cm-inplace-math cm-inplace-math-block" : "cm-inplace-math";
|
|
212
212
|
try {
|
|
213
|
-
|
|
213
|
+
ge.render(this.src, e, {
|
|
214
214
|
displayMode: this.block,
|
|
215
215
|
throwOnError: !1
|
|
216
216
|
});
|
|
@@ -223,19 +223,19 @@ var Xe = class extends D {
|
|
|
223
223
|
return !1;
|
|
224
224
|
}
|
|
225
225
|
};
|
|
226
|
-
function
|
|
226
|
+
function Xe(e, t, n, r, i, a, o) {
|
|
227
227
|
if (!r.includes("$")) return;
|
|
228
228
|
let { doc: s } = e.state, c = [];
|
|
229
|
-
for (let e of r.matchAll(
|
|
229
|
+
for (let e of r.matchAll(Ke)) {
|
|
230
230
|
let n = (e[1] ?? "").trim(), r = t + (e.index ?? 0), l = r + (e[0] ?? "").length;
|
|
231
|
-
!n ||
|
|
231
|
+
!n || B(a, r + 2) || (c.push([r, l]), !We(i, s, r, l) && o.push(T.replace({ widget: new Ye(n, !0) }).range(r, l)));
|
|
232
232
|
}
|
|
233
|
-
for (let e of r.matchAll(
|
|
233
|
+
for (let e of r.matchAll(Ge)) {
|
|
234
234
|
let n = (e[1] ?? "").trim(), r = t + (e.index ?? 0), l = r + (e[0] ?? "").length;
|
|
235
|
-
!n ||
|
|
235
|
+
!n || B(a, r + 1) || c.some(([e, t]) => r >= e && l <= t) || We(i, s, r, l) || o.push(T.replace({ widget: new Ye(n, !1) }).range(r, l));
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
|
-
function
|
|
238
|
+
function Ze(e, t, n) {
|
|
239
239
|
let r = n.map((t) => ({
|
|
240
240
|
first: e.doc.lineAt(t.from).number,
|
|
241
241
|
last: e.doc.lineAt(t.to).number
|
|
@@ -246,44 +246,44 @@ function Qe(e, t, n) {
|
|
|
246
246
|
}
|
|
247
247
|
return !1;
|
|
248
248
|
}
|
|
249
|
-
var
|
|
250
|
-
create:
|
|
249
|
+
var Qe = M.define({
|
|
250
|
+
create: $e,
|
|
251
251
|
update(e, t) {
|
|
252
|
-
return t.docChanged || t.selection && (
|
|
252
|
+
return t.docChanged || t.selection && (Ze(t.state, t.startState.selection, e.ranges) || Ze(t.state, t.state.selection, e.ranges)) ? $e(t.state) : e;
|
|
253
253
|
},
|
|
254
|
-
provide: (e) => [
|
|
254
|
+
provide: (e) => [E.decorations.from(e, (e) => e.decorations), E.atomicRanges.of((t) => t.state.field(e).decorations)]
|
|
255
255
|
});
|
|
256
|
-
function
|
|
257
|
-
if (!e.facet(
|
|
258
|
-
decorations:
|
|
256
|
+
function $e(e) {
|
|
257
|
+
if (!e.facet(P).math) return {
|
|
258
|
+
decorations: T.none,
|
|
259
259
|
ranges: []
|
|
260
260
|
};
|
|
261
261
|
let t = e.doc.toString();
|
|
262
262
|
if (!t.includes("$$")) return {
|
|
263
|
-
decorations:
|
|
263
|
+
decorations: T.none,
|
|
264
264
|
ranges: []
|
|
265
265
|
};
|
|
266
|
-
let n = [], r = [], i =
|
|
267
|
-
for (let o of t.matchAll(
|
|
266
|
+
let n = [], r = [], i = z(e), a = N(e);
|
|
267
|
+
for (let o of t.matchAll(qe)) {
|
|
268
268
|
let t = o[0] ?? "", s = (o[1] ?? "").trim();
|
|
269
269
|
if (!s || !t.includes("\n")) continue;
|
|
270
270
|
let c = o.index ?? 0, l = c + t.length, u = e.doc.lineAt(c), d = e.doc.lineAt(l), f = e.doc.sliceString(u.from, c).trim(), p = e.doc.sliceString(l, d.to).trim();
|
|
271
|
-
f === "" && p === "" && (
|
|
271
|
+
f === "" && p === "" && (B(a, c + 2) || (r.push({
|
|
272
272
|
from: c,
|
|
273
273
|
to: l
|
|
274
|
-
}), !
|
|
275
|
-
widget: new
|
|
274
|
+
}), !We(i, e.doc, c, l) && n.push(T.replace({
|
|
275
|
+
widget: new Ye(s, !0),
|
|
276
276
|
block: !0
|
|
277
277
|
}).range(c, l))));
|
|
278
278
|
}
|
|
279
279
|
return {
|
|
280
|
-
decorations:
|
|
280
|
+
decorations: T.set(n, !0),
|
|
281
281
|
ranges: r
|
|
282
282
|
};
|
|
283
283
|
}
|
|
284
284
|
//#endregion
|
|
285
285
|
//#region src/inplace/nodes-inline.ts
|
|
286
|
-
var
|
|
286
|
+
var et = {
|
|
287
287
|
StrongEmphasis: {
|
|
288
288
|
mark: "EmphasisMark",
|
|
289
289
|
className: "cm-inplace-strong",
|
|
@@ -305,26 +305,26 @@ var tt = {
|
|
|
305
305
|
toggle: "code"
|
|
306
306
|
}
|
|
307
307
|
};
|
|
308
|
-
function
|
|
308
|
+
function tt(e, t, n) {
|
|
309
309
|
let { doc: r, revealed: i, out: a, toggles: o } = t;
|
|
310
310
|
if (!o[n.toggle]) return;
|
|
311
311
|
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;
|
|
312
|
-
f > d && a.push(
|
|
312
|
+
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)));
|
|
313
313
|
}
|
|
314
|
-
function
|
|
314
|
+
function nt(e, t) {
|
|
315
315
|
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);
|
|
316
316
|
if (o === "[" && s === "]" || !a.links) return !1;
|
|
317
|
-
let c = n.lineAt(e.from), l =
|
|
317
|
+
let c = n.lineAt(e.from), l = he.exec(c.text);
|
|
318
318
|
if (l && e.from - c.from < l[1].length + l[2].length) return !1;
|
|
319
319
|
let u = e.node.getChildren("LinkMark");
|
|
320
320
|
if (u.length >= 2) {
|
|
321
321
|
let t = u[0], a = u[1];
|
|
322
|
-
a.from > t.to && i.push(
|
|
322
|
+
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)));
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
325
|
//#endregion
|
|
326
326
|
//#region src/inplace/widgets.ts
|
|
327
|
-
var
|
|
327
|
+
var rt = class extends O {
|
|
328
328
|
eq() {
|
|
329
329
|
return !0;
|
|
330
330
|
}
|
|
@@ -335,7 +335,7 @@ var it = class extends D {
|
|
|
335
335
|
ignoreEvent() {
|
|
336
336
|
return !1;
|
|
337
337
|
}
|
|
338
|
-
},
|
|
338
|
+
}, it = class extends O {
|
|
339
339
|
eq() {
|
|
340
340
|
return !0;
|
|
341
341
|
}
|
|
@@ -346,7 +346,7 @@ var it = class extends D {
|
|
|
346
346
|
ignoreEvent() {
|
|
347
347
|
return !1;
|
|
348
348
|
}
|
|
349
|
-
},
|
|
349
|
+
}, at = class extends O {
|
|
350
350
|
checked;
|
|
351
351
|
constructor(e) {
|
|
352
352
|
super(), this.checked = e;
|
|
@@ -368,58 +368,58 @@ var it = class extends D {
|
|
|
368
368
|
ignoreEvent() {
|
|
369
369
|
return !0;
|
|
370
370
|
}
|
|
371
|
-
},
|
|
372
|
-
function
|
|
371
|
+
}, ot = /^[-*+]$/;
|
|
372
|
+
function st(e, t) {
|
|
373
373
|
let { doc: n, revealed: r, out: i, toggles: a } = t;
|
|
374
374
|
if (!a.horizontalRule) return !1;
|
|
375
375
|
let o = n.lineAt(e.from);
|
|
376
|
-
return r.has(o.number) || (i.push(
|
|
376
|
+
return r.has(o.number) || (i.push(T.line({ class: "cm-inplace-hr-line" }).range(o.from)), i.push(T.replace({ widget: new rt() }).range(o.from, o.to))), !1;
|
|
377
377
|
}
|
|
378
|
-
function
|
|
378
|
+
function ct(e, t) {
|
|
379
379
|
let { doc: n, revealed: r, caretRevealed: i, out: a, toggles: o, quoteRevealed: s } = t;
|
|
380
380
|
if (o.blockquote) {
|
|
381
|
-
let t = n.lineAt(e.from).number, o = n.lineAt(Math.min(e.to, n.length)).number, c = n.line(t), l =
|
|
381
|
+
let t = n.lineAt(e.from).number, o = n.lineAt(Math.min(e.to, n.length)).number, c = n.line(t), l = he.exec(c.text), u = l ? fe(l[3]) : null, d = !1;
|
|
382
382
|
for (let e = t; e <= o; e++) i.has(e) && (d = !0);
|
|
383
383
|
if (d) for (let e = t; e <= o; e++) s.add(e);
|
|
384
384
|
for (let e = t; e <= o; e++) {
|
|
385
385
|
let r = u ? `cm-inplace-callout cm-inplace-callout-${u}` : "cm-inplace-quote";
|
|
386
386
|
u && e === t && (r += " cm-inplace-callout-head"), u && e === o && (r += " cm-inplace-callout-foot");
|
|
387
387
|
let i = {};
|
|
388
|
-
u && (i["data-callout"] = l[3].toLowerCase()), u && d && (i["data-revealed"] = ""), a.push(
|
|
388
|
+
u && (i["data-callout"] = l[3].toLowerCase()), u && d && (i["data-revealed"] = ""), a.push(T.line({
|
|
389
389
|
class: r,
|
|
390
390
|
attributes: i
|
|
391
391
|
}).range(n.line(e).from));
|
|
392
392
|
}
|
|
393
393
|
if (u && !d && !r.has(t)) {
|
|
394
394
|
let e = c.from + l[1].length;
|
|
395
|
-
a.push(
|
|
395
|
+
a.push(T.replace({}).range(e, e + l[2].length));
|
|
396
396
|
}
|
|
397
397
|
}
|
|
398
398
|
}
|
|
399
|
-
function
|
|
399
|
+
function lt(e, t) {
|
|
400
400
|
let { doc: n, revealed: r, out: i, toggles: a, quoteRevealed: o } = t;
|
|
401
401
|
if (!a.blockquote) return !1;
|
|
402
402
|
let s = n.lineAt(e.from);
|
|
403
403
|
if (!r.has(s.number) && !o.has(s.number)) {
|
|
404
|
-
let t = Math.min(e.to + 1, s.to), n =
|
|
405
|
-
i.push(
|
|
404
|
+
let t = Math.min(e.to + 1, s.to), n = he.exec(s.text), r = n ? s.text.slice(n[1].length + n[2].length) : s.text.slice(t - s.from);
|
|
405
|
+
i.push(T.replace({}).range(e.from, r.trim() === "" ? e.to : t));
|
|
406
406
|
}
|
|
407
407
|
return !1;
|
|
408
408
|
}
|
|
409
|
-
function
|
|
409
|
+
function ut(e, t) {
|
|
410
410
|
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"));
|
|
411
|
-
return r.has(s.number) || (l ? a.tasks && i.push(
|
|
411
|
+
return r.has(s.number) || (l ? a.tasks && i.push(T.replace({}).range(e.from, Math.min(e.to + 1, s.to))) : a.lists && ot.test(o) && i.push(T.replace({ widget: new it() }).range(e.from, e.to))), !1;
|
|
412
412
|
}
|
|
413
|
-
function
|
|
413
|
+
function dt(e, t) {
|
|
414
414
|
let { doc: n, revealed: r, out: i, toggles: a } = t;
|
|
415
415
|
if (!a.tasks) return !1;
|
|
416
416
|
if (!r.has(n.lineAt(e.from).number)) {
|
|
417
417
|
let t = n.sliceString(e.from + 1, e.to - 1).toLowerCase() === "x";
|
|
418
|
-
i.push(
|
|
418
|
+
i.push(T.replace({ widget: new at(t) }).range(e.from, e.to));
|
|
419
419
|
}
|
|
420
420
|
return !1;
|
|
421
421
|
}
|
|
422
|
-
function
|
|
422
|
+
function ft(e, t) {
|
|
423
423
|
let { doc: n, revealed: r, caretRevealed: i, out: a, toggles: o } = t;
|
|
424
424
|
if (!o.code) return !1;
|
|
425
425
|
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;
|
|
@@ -429,18 +429,18 @@ function pt(e, t) {
|
|
|
429
429
|
let t = s && (e === c || e === l), r = "cm-inplace-mono";
|
|
430
430
|
e === c && (r += " cm-inplace-code-top"), e === l && (r += " cm-inplace-code-bottom"), t && (r += f ? " cm-inplace-code-pad" : " cm-inplace-fence");
|
|
431
431
|
let i = n.line(e);
|
|
432
|
-
a.push(
|
|
432
|
+
a.push(T.line({ class: r }).range(i.from)), t && f && i.to > i.from && a.push(T.replace({}).range(i.from, i.to));
|
|
433
433
|
}
|
|
434
434
|
return !1;
|
|
435
435
|
}
|
|
436
436
|
//#endregion
|
|
437
437
|
//#region src/inplace/nodes.ts
|
|
438
|
-
var
|
|
439
|
-
function
|
|
438
|
+
var pt = /^ATXHeading([1-6])$/, mt = /^SetextHeading([12])$/;
|
|
439
|
+
function ht(e, t, n) {
|
|
440
440
|
let { doc: r, revealed: i, out: a, toggles: o } = t;
|
|
441
441
|
if (o.headings) {
|
|
442
442
|
let t = r.lineAt(e.from);
|
|
443
|
-
if (a.push(
|
|
443
|
+
if (a.push(T.line({
|
|
444
444
|
class: `cm-inplace-heading cm-inplace-h${n}`,
|
|
445
445
|
attributes: {
|
|
446
446
|
role: "heading",
|
|
@@ -448,15 +448,15 @@ function gt(e, t, n) {
|
|
|
448
448
|
}
|
|
449
449
|
}).range(t.from)), !i.has(t.number)) {
|
|
450
450
|
let n = e.node.firstChild;
|
|
451
|
-
n?.name === "HeaderMark" && a.push(
|
|
451
|
+
n?.name === "HeaderMark" && a.push(T.replace({}).range(n.from, Math.min(n.to + 1, t.to)));
|
|
452
452
|
}
|
|
453
453
|
}
|
|
454
454
|
}
|
|
455
|
-
function
|
|
455
|
+
function gt(e, t, n) {
|
|
456
456
|
let { doc: r, caretRevealed: i, out: a, toggles: o } = t;
|
|
457
457
|
if (o.headings) {
|
|
458
458
|
let t = r.lineAt(e.from);
|
|
459
|
-
a.push(
|
|
459
|
+
a.push(T.line({
|
|
460
460
|
class: `cm-inplace-heading cm-inplace-h${n}`,
|
|
461
461
|
attributes: {
|
|
462
462
|
role: "heading",
|
|
@@ -466,46 +466,46 @@ function _t(e, t, n) {
|
|
|
466
466
|
let o = e.node.getChild("HeaderMark");
|
|
467
467
|
if (o) {
|
|
468
468
|
let e = r.lineAt(o.from);
|
|
469
|
-
!i.has(t.number) && !i.has(e.number) && (a.push(
|
|
469
|
+
!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)));
|
|
470
470
|
}
|
|
471
471
|
}
|
|
472
472
|
}
|
|
473
|
-
function
|
|
473
|
+
function _t(e, t) {
|
|
474
474
|
if (e.to <= t.fmEnd) return !1;
|
|
475
|
-
let n =
|
|
476
|
-
if (n) return
|
|
477
|
-
let r =
|
|
478
|
-
if (r) return
|
|
479
|
-
let i =
|
|
480
|
-
if (i) return
|
|
481
|
-
if (e.name === "Link") return
|
|
482
|
-
if (e.name === "HorizontalRule") return
|
|
483
|
-
if (e.name === "Blockquote") return
|
|
484
|
-
if (e.name === "QuoteMark") return
|
|
485
|
-
if (e.name === "ListMark") return
|
|
486
|
-
if (e.name === "TaskMarker") return
|
|
487
|
-
if (e.name === "FencedCode" || e.name === "CodeBlock") return
|
|
475
|
+
let n = pt.exec(e.name);
|
|
476
|
+
if (n) return ht(e, t, n[1]);
|
|
477
|
+
let r = mt.exec(e.name);
|
|
478
|
+
if (r) return gt(e, t, r[1]);
|
|
479
|
+
let i = et[e.name];
|
|
480
|
+
if (i) return tt(e, t, i);
|
|
481
|
+
if (e.name === "Link") return nt(e, t);
|
|
482
|
+
if (e.name === "HorizontalRule") return st(e, t);
|
|
483
|
+
if (e.name === "Blockquote") return ct(e, t);
|
|
484
|
+
if (e.name === "QuoteMark") return lt(e, t);
|
|
485
|
+
if (e.name === "ListMark") return ut(e, t);
|
|
486
|
+
if (e.name === "TaskMarker") return dt(e, t);
|
|
487
|
+
if (e.name === "FencedCode" || e.name === "CodeBlock") return ft(e, t);
|
|
488
488
|
}
|
|
489
489
|
//#endregion
|
|
490
490
|
//#region src/inplace/wikilinks.ts
|
|
491
|
-
function
|
|
491
|
+
function vt(t, n, r, i, a, o, s) {
|
|
492
492
|
if (!i.includes("[[")) return;
|
|
493
|
-
let c = t.state.facet(
|
|
493
|
+
let c = t.state.facet(F) != null;
|
|
494
494
|
for (let r of i.matchAll(e)) {
|
|
495
495
|
let [e = "", i = "", l] = r, u = i.trim(), d = n + (r.index ?? 0);
|
|
496
|
-
if (!u ||
|
|
496
|
+
if (!u || B(o, d + 1) || c && d > 0 && t.state.doc.sliceString(d - 1, d) === "!") continue;
|
|
497
497
|
let f = d + e.length, p = l == null ? d + 2 : d + 2 + i.length + 1, m = f - 2;
|
|
498
|
-
s.push(
|
|
498
|
+
s.push(T.mark({
|
|
499
499
|
class: "cm-inplace-link cm-inplace-wikilink",
|
|
500
500
|
attributes: { "data-stylo-wikilink": u }
|
|
501
|
-
}).range(p, m)), a.has(t.state.doc.lineAt(d).number) || (s.push(
|
|
501
|
+
}).range(p, m)), a.has(t.state.doc.lineAt(d).number) || (s.push(T.replace({}).range(d, p)), s.push(T.replace({}).range(m, f)));
|
|
502
502
|
}
|
|
503
503
|
}
|
|
504
504
|
//#endregion
|
|
505
505
|
//#region src/inplace/decorate.ts
|
|
506
|
-
var
|
|
507
|
-
function
|
|
508
|
-
let n = [], r =
|
|
506
|
+
var yt = /* @__PURE__ */ new Set(), bt = T.replace({});
|
|
507
|
+
function xt(e) {
|
|
508
|
+
let n = [], r = z(e.state), i = e.state.facet(L) === "never" ? yt : r, a = N(e.state), { doc: o } = e.state, s = e.state.facet(P), c = {
|
|
509
509
|
doc: o,
|
|
510
510
|
revealed: i,
|
|
511
511
|
caretRevealed: r,
|
|
@@ -518,10 +518,10 @@ function St(e) {
|
|
|
518
518
|
a.iterate({
|
|
519
519
|
from: t.from,
|
|
520
520
|
to: t.to,
|
|
521
|
-
enter: (e) =>
|
|
521
|
+
enter: (e) => _t(e, c)
|
|
522
522
|
});
|
|
523
523
|
let r = e.state.doc.sliceString(t.from, t.to);
|
|
524
|
-
s.wikilinks &&
|
|
524
|
+
s.wikilinks && vt(e, t.from, t.to, r, i, a, n), s.math && Xe(e, t.from, t.to, r, i, a, n), Ve(t.from, t.to, a, o, s, n);
|
|
525
525
|
}
|
|
526
526
|
let l = n.filter((e) => e.from < e.to && !e.value.spec.class).sort((e, t) => e.from - t.from || e.to - t.to), u = [];
|
|
527
527
|
for (let e of l) {
|
|
@@ -530,38 +530,38 @@ function St(e) {
|
|
|
530
530
|
if (e.from === t.from && e.to === t.to) continue;
|
|
531
531
|
}
|
|
532
532
|
let t = u[u.length - 1];
|
|
533
|
-
t && e.from <= t.to ? e.to > t.to && (u[u.length - 1] =
|
|
533
|
+
t && e.from <= t.to ? e.to > t.to && (u[u.length - 1] = bt.range(t.from, e.to)) : u.push(bt.range(e.from, e.to));
|
|
534
534
|
}
|
|
535
535
|
return {
|
|
536
|
-
decorations:
|
|
537
|
-
atomic:
|
|
536
|
+
decorations: T.set(n, !0),
|
|
537
|
+
atomic: T.set(u, !0)
|
|
538
538
|
};
|
|
539
539
|
}
|
|
540
540
|
//#endregion
|
|
541
541
|
//#region src/inplace/plugin.ts
|
|
542
|
-
var
|
|
542
|
+
var St = D.fromClass(class {
|
|
543
543
|
decorations;
|
|
544
544
|
atomic;
|
|
545
545
|
constructor(e) {
|
|
546
|
-
let t =
|
|
546
|
+
let t = xt(e);
|
|
547
547
|
this.decorations = t.decorations, this.atomic = t.atomic;
|
|
548
548
|
}
|
|
549
549
|
update(e) {
|
|
550
550
|
if (e.docChanged || e.viewportChanged || e.selectionSet) {
|
|
551
|
-
let t =
|
|
551
|
+
let t = xt(e.view);
|
|
552
552
|
this.decorations = t.decorations, this.atomic = t.atomic;
|
|
553
553
|
}
|
|
554
554
|
}
|
|
555
555
|
}, {
|
|
556
556
|
decorations: (e) => e.decorations,
|
|
557
|
-
provide: (e) =>
|
|
557
|
+
provide: (e) => E.atomicRanges.of((t) => t.plugin(e)?.atomic ?? T.none)
|
|
558
558
|
});
|
|
559
|
-
function
|
|
560
|
-
return
|
|
559
|
+
function Ct() {
|
|
560
|
+
return St;
|
|
561
561
|
}
|
|
562
562
|
//#endregion
|
|
563
563
|
//#region src/inplace/wrap-at.ts
|
|
564
|
-
var
|
|
564
|
+
var wt = {
|
|
565
565
|
StrongEmphasis: {
|
|
566
566
|
markType: "EmphasisMark",
|
|
567
567
|
toggle: "emphasis"
|
|
@@ -579,15 +579,15 @@ var Tt = {
|
|
|
579
579
|
toggle: "code"
|
|
580
580
|
}
|
|
581
581
|
};
|
|
582
|
-
function
|
|
583
|
-
return e.facet(
|
|
582
|
+
function V(e, t) {
|
|
583
|
+
return e.facet(L) === "never" || !z(e).has(t);
|
|
584
584
|
}
|
|
585
|
-
function
|
|
585
|
+
function H(t, n, r = !1, i = !1) {
|
|
586
586
|
let a = t.doc.lineAt(n);
|
|
587
|
-
if (!i && !
|
|
588
|
-
let o = t.facet(
|
|
587
|
+
if (!i && !V(t, a.number)) return null;
|
|
588
|
+
let o = t.facet(P), s = N(t);
|
|
589
589
|
for (let e of [-1, 1]) for (let i = s.resolveInner(n, e); i; i = i.parent) {
|
|
590
|
-
let e =
|
|
590
|
+
let e = wt[i.name];
|
|
591
591
|
if (e) {
|
|
592
592
|
if (!o[e.toggle]) break;
|
|
593
593
|
let t = i.getChildren(e.markType), n = t[0], r = t[t.length - 1];
|
|
@@ -629,8 +629,8 @@ function V(t, n, r = !1, i = !1) {
|
|
|
629
629
|
}
|
|
630
630
|
//#endregion
|
|
631
631
|
//#region src/inplace/edit-boundaries.ts
|
|
632
|
-
function
|
|
633
|
-
let r = e.plugin(
|
|
632
|
+
function Tt(e, t, n) {
|
|
633
|
+
let r = e.plugin(St)?.decorations;
|
|
634
634
|
if (!r) return t;
|
|
635
635
|
let i = n < 0 ? 0 : e.state.doc.length, a = t;
|
|
636
636
|
for (let e = !0; e;) e = !1, r.between(Math.min(a, i), Math.max(a, i), (t, r, i) => {
|
|
@@ -638,18 +638,18 @@ function Et(e, t, n) {
|
|
|
638
638
|
});
|
|
639
639
|
return a;
|
|
640
640
|
}
|
|
641
|
-
var
|
|
641
|
+
var Et = (e) => (t) => {
|
|
642
642
|
if (h(t)) return !1;
|
|
643
643
|
let n = t.state.selection.main;
|
|
644
644
|
if (!n.empty) return !1;
|
|
645
645
|
let { state: r } = t;
|
|
646
|
-
if (!
|
|
647
|
-
let i =
|
|
646
|
+
if (!V(r, r.doc.lineAt(n.head).number)) return !1;
|
|
647
|
+
let i = Tt(t, n.head, e);
|
|
648
648
|
if (i === n.head) return !1;
|
|
649
649
|
let a = r.doc;
|
|
650
650
|
if (e < 0 ? i <= 0 : i >= a.length) return !0;
|
|
651
651
|
let o = e < 0 ? i - 1 : i, s = e < 0 ? i : i + 1;
|
|
652
|
-
for (let e =
|
|
652
|
+
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);
|
|
653
653
|
return t.dispatch({
|
|
654
654
|
changes: {
|
|
655
655
|
from: o,
|
|
@@ -660,89 +660,89 @@ var Dt = (e) => (t) => {
|
|
|
660
660
|
userEvent: e < 0 ? "delete.backward" : "delete.forward",
|
|
661
661
|
scrollIntoView: !0
|
|
662
662
|
}), !0;
|
|
663
|
-
},
|
|
664
|
-
function
|
|
663
|
+
}, Dt = Et(-1), Ot = Et(1);
|
|
664
|
+
function kt(e, t, n) {
|
|
665
665
|
if (n <= t) return !1;
|
|
666
|
-
let r = e.plugin(
|
|
666
|
+
let r = e.plugin(St)?.decorations;
|
|
667
667
|
if (!r) return !1;
|
|
668
668
|
let i = t;
|
|
669
669
|
return r.between(t, n, (e, t, n) => {
|
|
670
670
|
n.spec.widget || n.spec.class || t <= e || e <= i && (i = Math.max(i, t));
|
|
671
671
|
}), i >= n;
|
|
672
672
|
}
|
|
673
|
-
var
|
|
673
|
+
var U = (e, t) => (n) => {
|
|
674
674
|
if (h(n)) return !1;
|
|
675
675
|
let r = n.state.selection.main;
|
|
676
|
-
if (!t && !r.empty || !
|
|
676
|
+
if (!t && !r.empty || !V(n.state, n.state.doc.lineAt(r.head).number)) return !1;
|
|
677
677
|
let i = n.moveByChar(r, e);
|
|
678
|
-
if (
|
|
679
|
-
let a = t ?
|
|
678
|
+
if (kt(n, Math.min(r.head, i.head), Math.max(r.head, i.head)) && (i = n.moveByChar(i, e)), i.head === r.head) return !1;
|
|
679
|
+
let a = t ? Se.range(r.anchor, i.head) : Se.cursor(i.head);
|
|
680
680
|
return n.dispatch({
|
|
681
681
|
selection: a,
|
|
682
682
|
userEvent: "select"
|
|
683
683
|
}), !0;
|
|
684
|
-
},
|
|
684
|
+
}, At = U(!1, !1), jt = U(!0, !1), Mt = U(!1, !0), Nt = U(!0, !0), Pt = j.high(k.of([
|
|
685
685
|
{
|
|
686
686
|
key: "Backspace",
|
|
687
|
-
run:
|
|
687
|
+
run: Dt
|
|
688
688
|
},
|
|
689
689
|
{
|
|
690
690
|
key: "Delete",
|
|
691
|
-
run:
|
|
691
|
+
run: Ot
|
|
692
692
|
},
|
|
693
693
|
{
|
|
694
694
|
key: "ArrowLeft",
|
|
695
|
-
run:
|
|
695
|
+
run: At
|
|
696
696
|
},
|
|
697
697
|
{
|
|
698
698
|
key: "ArrowRight",
|
|
699
|
-
run:
|
|
699
|
+
run: jt
|
|
700
700
|
},
|
|
701
701
|
{
|
|
702
702
|
key: "Shift-ArrowLeft",
|
|
703
|
-
run:
|
|
703
|
+
run: Mt
|
|
704
704
|
},
|
|
705
705
|
{
|
|
706
706
|
key: "Shift-ArrowRight",
|
|
707
|
-
run:
|
|
707
|
+
run: Nt
|
|
708
708
|
}
|
|
709
|
-
])),
|
|
709
|
+
])), Ft = (e) => e === "h1" || e === "h2" || e === "h3" ? x.heading : x[e], It = [
|
|
710
710
|
"bold",
|
|
711
711
|
"italic",
|
|
712
712
|
"strike"
|
|
713
|
-
],
|
|
713
|
+
], Lt = ["code", "math"], Rt = [
|
|
714
714
|
"bulletList",
|
|
715
715
|
"orderedList",
|
|
716
716
|
"task"
|
|
717
|
-
],
|
|
717
|
+
], zt = [
|
|
718
718
|
"h1",
|
|
719
719
|
"h2",
|
|
720
720
|
"h3"
|
|
721
|
-
],
|
|
721
|
+
], Bt = ["table", "hr"], Vt = [
|
|
722
722
|
"codeBlock",
|
|
723
723
|
"mathBlock",
|
|
724
724
|
"frontmatter"
|
|
725
|
-
],
|
|
725
|
+
], Ht = (e, t, n = !1) => {
|
|
726
726
|
let r = _[t];
|
|
727
727
|
if (!r) return null;
|
|
728
|
-
let { disabled: i, active: a } =
|
|
728
|
+
let { disabled: i, active: a } = re(e.state, r, n);
|
|
729
729
|
return {
|
|
730
730
|
label: r.title,
|
|
731
|
-
icon:
|
|
731
|
+
icon: Ft(t),
|
|
732
732
|
active: a,
|
|
733
733
|
disabled: i,
|
|
734
734
|
onSelect: () => {
|
|
735
735
|
r.run(e), e.focus();
|
|
736
736
|
}
|
|
737
737
|
};
|
|
738
|
-
},
|
|
738
|
+
}, W = (e, t, n = !1, r = !1) => {
|
|
739
739
|
let i = [];
|
|
740
740
|
for (let a of t) {
|
|
741
|
-
let t =
|
|
741
|
+
let t = Ht(e, a, r);
|
|
742
742
|
t && !(n && t.disabled) && i.push(t);
|
|
743
743
|
}
|
|
744
744
|
return i;
|
|
745
|
-
},
|
|
745
|
+
}, G = (e) => {
|
|
746
746
|
let t = e.contentDOM.ownerDocument, n = (n) => () => {
|
|
747
747
|
e.focus();
|
|
748
748
|
try {
|
|
@@ -752,17 +752,17 @@ var H = (e, t) => (n) => {
|
|
|
752
752
|
return [
|
|
753
753
|
{
|
|
754
754
|
label: "Cut",
|
|
755
|
-
icon:
|
|
755
|
+
icon: x.cut,
|
|
756
756
|
onSelect: n("cut")
|
|
757
757
|
},
|
|
758
758
|
{
|
|
759
759
|
label: "Copy",
|
|
760
|
-
icon:
|
|
760
|
+
icon: x.copy,
|
|
761
761
|
onSelect: n("copy")
|
|
762
762
|
},
|
|
763
763
|
i ? {
|
|
764
764
|
label: "Paste",
|
|
765
|
-
icon:
|
|
765
|
+
icon: x.paste,
|
|
766
766
|
onSelect: () => {
|
|
767
767
|
let n = h(e);
|
|
768
768
|
n || e.focus(), r?.readText().then((r) => {
|
|
@@ -771,45 +771,45 @@ var H = (e, t) => (n) => {
|
|
|
771
771
|
}
|
|
772
772
|
} : {
|
|
773
773
|
label: "Paste",
|
|
774
|
-
icon:
|
|
774
|
+
icon: x.paste,
|
|
775
775
|
disabled: !0,
|
|
776
776
|
title: "Paste with the keyboard shortcut",
|
|
777
777
|
onSelect: () => {}
|
|
778
778
|
}
|
|
779
779
|
];
|
|
780
|
-
},
|
|
780
|
+
}, K = (e, t, n, r = !1) => ({
|
|
781
781
|
label: e,
|
|
782
782
|
icon: t,
|
|
783
783
|
rows: n,
|
|
784
784
|
disabled: r
|
|
785
785
|
});
|
|
786
|
-
function
|
|
786
|
+
function q(e, t) {
|
|
787
787
|
t.length && (e.length && e.push("separator"), e.push(...t));
|
|
788
788
|
}
|
|
789
789
|
//#endregion
|
|
790
790
|
//#region src/inplace/edit-divider.ts
|
|
791
|
-
function
|
|
791
|
+
function Ut(e) {
|
|
792
792
|
let t = e.selection.main;
|
|
793
793
|
if (!t.empty) return !1;
|
|
794
794
|
let n = e.doc.lineAt(t.head);
|
|
795
|
-
if (!
|
|
796
|
-
for (let t =
|
|
795
|
+
if (!V(e, n.number)) return !1;
|
|
796
|
+
for (let t = N(e).resolveInner(n.from, 1); t; t = t.parent) {
|
|
797
797
|
if (t.name === "HorizontalRule") return !0;
|
|
798
798
|
if (!t.parent) break;
|
|
799
799
|
}
|
|
800
800
|
return !1;
|
|
801
801
|
}
|
|
802
|
-
var
|
|
802
|
+
var Wt = (e) => h(e) || !Ut(e.state) ? !1 : oe(e), Gt = j.high(k.of([{
|
|
803
803
|
key: "Backspace",
|
|
804
|
-
run:
|
|
804
|
+
run: Wt
|
|
805
805
|
}, {
|
|
806
806
|
key: "Delete",
|
|
807
|
-
run:
|
|
807
|
+
run: Wt
|
|
808
808
|
}]));
|
|
809
|
-
function
|
|
809
|
+
function Kt(e) {
|
|
810
810
|
return {
|
|
811
811
|
label: "Remove divider",
|
|
812
|
-
icon:
|
|
812
|
+
icon: x.hr,
|
|
813
813
|
onSelect: () => {
|
|
814
814
|
_.hr?.run(e), e.focus();
|
|
815
815
|
}
|
|
@@ -817,11 +817,11 @@ function qt(e) {
|
|
|
817
817
|
}
|
|
818
818
|
//#endregion
|
|
819
819
|
//#region src/inplace/link-row.ts
|
|
820
|
-
var
|
|
820
|
+
var qt = (e) => {
|
|
821
821
|
let t = e.trim().replace(/^<([^]*)>$/, "$1");
|
|
822
822
|
return /[\s()]/.test(t) ? `<${t.replace(/[<>]/g, "")}>` : t;
|
|
823
|
-
},
|
|
824
|
-
function
|
|
823
|
+
}, Jt = (e) => e.replace(/^<([^]*)>$/, "$1");
|
|
824
|
+
function Yt(e, t) {
|
|
825
825
|
let n = e.doc.lineAt(t.from);
|
|
826
826
|
if (e.doc.lineAt(t.to).number !== n.number) return null;
|
|
827
827
|
let r = t.from - n.from, i = t.to - n.from, s = o(n.text, r) ?? o(n.text, i);
|
|
@@ -837,7 +837,7 @@ function Xt(e, t) {
|
|
|
837
837
|
text: c.label
|
|
838
838
|
} : null;
|
|
839
839
|
}
|
|
840
|
-
function
|
|
840
|
+
function Xt(e, t) {
|
|
841
841
|
let { state: n } = e, r = n.selection.main, i = n.doc.lineAt(r.head), a = t.partsIn(i.text, r.head - i.from);
|
|
842
842
|
if (a) {
|
|
843
843
|
let n = i.from + a.from, r = i.from + a.to, o = t.editActions?.(e, a) ?? [];
|
|
@@ -866,7 +866,7 @@ function Zt(e, t) {
|
|
|
866
866
|
actions: o
|
|
867
867
|
};
|
|
868
868
|
}
|
|
869
|
-
let o =
|
|
869
|
+
let o = Yt(n, r), s = o ? o.from : r.from, c = o ? o.to : r.to, l = o ? o.text : n.sliceDoc(r.from, r.to);
|
|
870
870
|
return {
|
|
871
871
|
field: !0,
|
|
872
872
|
label: t.addLabel,
|
|
@@ -876,18 +876,18 @@ function Zt(e, t) {
|
|
|
876
876
|
onSubmit: (n) => t.onAdd(e, s, c, l, n)
|
|
877
877
|
};
|
|
878
878
|
}
|
|
879
|
-
var
|
|
880
|
-
icon:
|
|
879
|
+
var Zt = {
|
|
880
|
+
icon: x.link,
|
|
881
881
|
placeholder: "https://…",
|
|
882
882
|
editLabel: "Edit external link",
|
|
883
883
|
addLabel: "Add external link",
|
|
884
884
|
partsIn: o,
|
|
885
|
-
editValue: (e) =>
|
|
885
|
+
editValue: (e) => Jt(e.url),
|
|
886
886
|
editActions: (e, t) => {
|
|
887
|
-
let n = e.state.facet(
|
|
887
|
+
let n = e.state.facet(Ae);
|
|
888
888
|
return !n || !t.url ? [] : [{
|
|
889
889
|
label: "Open link",
|
|
890
|
-
icon:
|
|
890
|
+
icon: x.link,
|
|
891
891
|
onSelect: () => n(t.url)
|
|
892
892
|
}];
|
|
893
893
|
},
|
|
@@ -895,7 +895,7 @@ var Qt = {
|
|
|
895
895
|
e.dispatch({ changes: {
|
|
896
896
|
from: t.urlFrom,
|
|
897
897
|
to: t.urlTo,
|
|
898
|
-
insert:
|
|
898
|
+
insert: qt(n)
|
|
899
899
|
} }), e.focus();
|
|
900
900
|
},
|
|
901
901
|
onAdd: (e, t, n, r, i) => {
|
|
@@ -904,7 +904,7 @@ var Qt = {
|
|
|
904
904
|
changes: {
|
|
905
905
|
from: t,
|
|
906
906
|
to: n,
|
|
907
|
-
insert: `[${a}](${
|
|
907
|
+
insert: `[${a}](${qt(i)})`
|
|
908
908
|
},
|
|
909
909
|
selection: {
|
|
910
910
|
anchor: t + 1,
|
|
@@ -912,8 +912,8 @@ var Qt = {
|
|
|
912
912
|
}
|
|
913
913
|
}), e.focus();
|
|
914
914
|
}
|
|
915
|
-
},
|
|
916
|
-
icon:
|
|
915
|
+
}, Qt = {
|
|
916
|
+
icon: x.wikilink,
|
|
917
917
|
placeholder: "note or path",
|
|
918
918
|
editLabel: "Edit link",
|
|
919
919
|
addLabel: "Add link",
|
|
@@ -941,27 +941,27 @@ var Qt = {
|
|
|
941
941
|
}), e.focus();
|
|
942
942
|
}
|
|
943
943
|
};
|
|
944
|
-
function
|
|
945
|
-
return
|
|
944
|
+
function $t(e) {
|
|
945
|
+
return Xt(e, Zt);
|
|
946
946
|
}
|
|
947
|
-
function
|
|
948
|
-
return
|
|
947
|
+
function en(e) {
|
|
948
|
+
return Xt(e, Qt);
|
|
949
949
|
}
|
|
950
950
|
//#endregion
|
|
951
951
|
//#region src/inplace/context-menu-shell.ts
|
|
952
|
-
function
|
|
952
|
+
function tn(e, t, n, r) {
|
|
953
953
|
let i = r?.innerWidth ?? 0, a = r?.innerHeight ?? 0;
|
|
954
954
|
e.style.left = "0", e.style.top = "0";
|
|
955
955
|
let { width: o, height: s } = e.getBoundingClientRect();
|
|
956
956
|
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`;
|
|
957
957
|
}
|
|
958
|
-
function
|
|
958
|
+
function nn(e, t, n) {
|
|
959
959
|
let r = n?.innerWidth ?? 0, i = n?.innerHeight ?? 0;
|
|
960
960
|
e.style.left = "0", e.style.top = "0";
|
|
961
961
|
let { width: a, height: o } = e.getBoundingClientRect(), s = t.right - 4, c = s + a > r - 4 ? t.left - a + 4 : s;
|
|
962
962
|
e.style.left = `${Math.max(4, c)}px`, e.style.top = `${Math.max(4, Math.min(t.top - 4, i - o - 4))}px`;
|
|
963
963
|
}
|
|
964
|
-
function
|
|
964
|
+
function rn(e, t, n, r = 350) {
|
|
965
965
|
let i = Date.now(), a = (e) => !t.contains(e.target), o = (e) => {
|
|
966
966
|
a(e) && n();
|
|
967
967
|
}, s = (e) => {
|
|
@@ -975,10 +975,10 @@ function an(e, t, n, r = 350) {
|
|
|
975
975
|
}
|
|
976
976
|
//#endregion
|
|
977
977
|
//#region src/inplace/context-menu-types.ts
|
|
978
|
-
var
|
|
978
|
+
var an = (e) => typeof e != "string" && "rows" in e, on = (e) => typeof e != "string" && "field" in e;
|
|
979
979
|
//#endregion
|
|
980
980
|
//#region src/inplace/context-menu.ts
|
|
981
|
-
function
|
|
981
|
+
function J(e, t = "cm-inplace-menu", n) {
|
|
982
982
|
let r = e.defaultView, i = e.createElement("div");
|
|
983
983
|
i.className = t, i.setAttribute("contenteditable", "false"), i.hidden = !0;
|
|
984
984
|
let a = null, o = null, s = () => {
|
|
@@ -988,7 +988,7 @@ function q(e, t = "cm-inplace-menu", n) {
|
|
|
988
988
|
}, l = (e) => e.addEventListener("mousedown", (e) => {
|
|
989
989
|
e.preventDefault(), e.stopPropagation();
|
|
990
990
|
}), u = (t, n, r) => {
|
|
991
|
-
r && t.appendChild(
|
|
991
|
+
r && t.appendChild(de(e, r));
|
|
992
992
|
let i = e.createElement("span");
|
|
993
993
|
i.textContent = n, t.appendChild(i);
|
|
994
994
|
}, d = (n) => {
|
|
@@ -1006,7 +1006,7 @@ function q(e, t = "cm-inplace-menu", n) {
|
|
|
1006
1006
|
if (a?.dataset.for === n) return;
|
|
1007
1007
|
s();
|
|
1008
1008
|
let e = c();
|
|
1009
|
-
e.dataset.for = n, i.appendChild(e),
|
|
1009
|
+
e.dataset.for = n, i.appendChild(e), nn(e, f.getBoundingClientRect(), r), a = e, e.querySelector("input")?.focus({ preventScroll: !0 });
|
|
1010
1010
|
};
|
|
1011
1011
|
return f.addEventListener("pointerenter", p), f.addEventListener("click", (e) => {
|
|
1012
1012
|
e.stopPropagation(), p();
|
|
@@ -1029,7 +1029,7 @@ function q(e, t = "cm-inplace-menu", n) {
|
|
|
1029
1029
|
for (let i of n) if (i === "separator") {
|
|
1030
1030
|
let n = e.createElement("div");
|
|
1031
1031
|
n.className = `${t}-sep`, r.appendChild(n);
|
|
1032
|
-
} else
|
|
1032
|
+
} else an(i) ? r.appendChild(f(i.label, i.icon, () => m(i.rows), i.disabled)) : on(i) ? r.appendChild(f(i.label, i.icon, () => p(i))) : r.appendChild(d(i));
|
|
1033
1033
|
return r;
|
|
1034
1034
|
};
|
|
1035
1035
|
return {
|
|
@@ -1040,12 +1040,12 @@ function q(e, t = "cm-inplace-menu", n) {
|
|
|
1040
1040
|
show: (t, a, s) => {
|
|
1041
1041
|
c();
|
|
1042
1042
|
let l = m(t);
|
|
1043
|
-
i.appendChild(l), i.hidden = !1,
|
|
1043
|
+
i.appendChild(l), i.hidden = !1, tn(l, a, s, r), o = rn(e, i, c), n?.(!0);
|
|
1044
1044
|
},
|
|
1045
1045
|
showField: (t, a, s) => {
|
|
1046
1046
|
c();
|
|
1047
1047
|
let l = p(t);
|
|
1048
|
-
i.appendChild(l), i.hidden = !1,
|
|
1048
|
+
i.appendChild(l), i.hidden = !1, tn(l, a, s, r), l.querySelector("input")?.focus({ preventScroll: !0 }), o = rn(e, i, c), n?.(!0);
|
|
1049
1049
|
},
|
|
1050
1050
|
hide: c,
|
|
1051
1051
|
destroy: () => {
|
|
@@ -1055,14 +1055,14 @@ function q(e, t = "cm-inplace-menu", n) {
|
|
|
1055
1055
|
}
|
|
1056
1056
|
//#endregion
|
|
1057
1057
|
//#region src/inplace/math-edit.ts
|
|
1058
|
-
function
|
|
1059
|
-
let { state: t } = e, n = t.selection.main, r = t.doc.lineAt(n.head), i =
|
|
1058
|
+
function sn(e) {
|
|
1059
|
+
let { state: t } = e, n = t.selection.main, r = t.doc.lineAt(n.head), i = Je(r.text, n.head - r.from);
|
|
1060
1060
|
if (i) {
|
|
1061
1061
|
let t = r.from + i.from, n = r.from + i.to, a = i.block ? "$$" : "$";
|
|
1062
1062
|
return {
|
|
1063
1063
|
field: !0,
|
|
1064
1064
|
label: "Edit math",
|
|
1065
|
-
icon:
|
|
1065
|
+
icon: x.math,
|
|
1066
1066
|
value: i.src,
|
|
1067
1067
|
placeholder: "e^{i\\pi} + 1 = 0",
|
|
1068
1068
|
onSubmit: (r) => {
|
|
@@ -1095,7 +1095,7 @@ function cn(e) {
|
|
|
1095
1095
|
return {
|
|
1096
1096
|
field: !0,
|
|
1097
1097
|
label: "Add math",
|
|
1098
|
-
icon:
|
|
1098
|
+
icon: x.math,
|
|
1099
1099
|
value: "",
|
|
1100
1100
|
placeholder: "e^{i\\pi} + 1 = 0",
|
|
1101
1101
|
onSubmit: (t) => {
|
|
@@ -1114,27 +1114,27 @@ function cn(e) {
|
|
|
1114
1114
|
}
|
|
1115
1115
|
};
|
|
1116
1116
|
}
|
|
1117
|
-
var
|
|
1117
|
+
var cn = class {
|
|
1118
1118
|
menu;
|
|
1119
1119
|
contentDOM;
|
|
1120
1120
|
onClick;
|
|
1121
1121
|
constructor(e) {
|
|
1122
|
-
this.menu =
|
|
1123
|
-
if (!e.state.facet(
|
|
1122
|
+
this.menu = J(e.dom.ownerDocument), e.dom.appendChild(this.menu.el), this.contentDOM = e.contentDOM, this.onClick = (t) => {
|
|
1123
|
+
if (!e.state.facet(P).math) return;
|
|
1124
1124
|
let n = t.target?.closest(".cm-inplace-math");
|
|
1125
1125
|
if (!n) return;
|
|
1126
1126
|
let r = e.posAtDOM(n);
|
|
1127
1127
|
if (r < 0) return;
|
|
1128
1128
|
let i = e.state.doc.lineAt(r);
|
|
1129
|
-
|
|
1129
|
+
Je(i.text, r - i.from) && (e.dispatch({ selection: { anchor: r } }), this.menu.showField(sn(e), t.clientX, t.clientY));
|
|
1130
1130
|
}, this.contentDOM.addEventListener("click", this.onClick);
|
|
1131
1131
|
}
|
|
1132
1132
|
destroy() {
|
|
1133
1133
|
this.contentDOM.removeEventListener("click", this.onClick), this.menu.destroy();
|
|
1134
1134
|
}
|
|
1135
|
-
},
|
|
1136
|
-
if (!e.state.facet(
|
|
1137
|
-
let n = e.state.doc.lineAt(t), r =
|
|
1135
|
+
}, ln = D.fromClass(cn), un = ve((e, t) => {
|
|
1136
|
+
if (!e.state.facet(P).math) return null;
|
|
1137
|
+
let n = e.state.doc.lineAt(t), r = Je(n.text, t - n.from);
|
|
1138
1138
|
return r ? {
|
|
1139
1139
|
pos: n.from + r.from,
|
|
1140
1140
|
end: n.from + r.to,
|
|
@@ -1147,18 +1147,18 @@ var ln = class {
|
|
|
1147
1147
|
});
|
|
1148
1148
|
//#endregion
|
|
1149
1149
|
//#region src/inplace/context-menu-actions.ts
|
|
1150
|
-
function
|
|
1150
|
+
function Y(e) {
|
|
1151
1151
|
let t = h(e);
|
|
1152
1152
|
if (!t) return !1;
|
|
1153
1153
|
let { from: n, to: i } = r(t);
|
|
1154
1154
|
return i > n;
|
|
1155
1155
|
}
|
|
1156
|
-
function
|
|
1157
|
-
let t =
|
|
1156
|
+
function dn(e) {
|
|
1157
|
+
let t = g(e.state);
|
|
1158
1158
|
return {
|
|
1159
1159
|
field: !0,
|
|
1160
1160
|
label: "Language",
|
|
1161
|
-
icon:
|
|
1161
|
+
icon: x.codeBlock,
|
|
1162
1162
|
value: t?.lang ?? "",
|
|
1163
1163
|
placeholder: "ts, python, …",
|
|
1164
1164
|
onSubmit: (n) => {
|
|
@@ -1176,44 +1176,44 @@ function fn(e) {
|
|
|
1176
1176
|
}]
|
|
1177
1177
|
};
|
|
1178
1178
|
}
|
|
1179
|
-
var
|
|
1180
|
-
...
|
|
1179
|
+
var fn = (e, t = !1) => [
|
|
1180
|
+
...W(e, It, !1, t),
|
|
1181
1181
|
"separator",
|
|
1182
|
-
...t ?
|
|
1182
|
+
...t ? W(e, Lt, !1, !0) : [Ht(e, "code", !1), sn(e)]
|
|
1183
1183
|
];
|
|
1184
|
-
function
|
|
1185
|
-
let t = e.state.facet(
|
|
1186
|
-
return t.includes("format") &&
|
|
1184
|
+
function pn(e) {
|
|
1185
|
+
let t = e.state.facet(Pe), n = [];
|
|
1186
|
+
return t.includes("format") && q(n, [K("Format", x.format, fn(e, !0))]), t.includes("clipboard") && q(n, G(e)), n;
|
|
1187
1187
|
}
|
|
1188
|
-
var
|
|
1189
|
-
...
|
|
1188
|
+
var mn = (e) => [
|
|
1189
|
+
...W(e, Rt),
|
|
1190
1190
|
"separator",
|
|
1191
|
-
...
|
|
1191
|
+
...W(e, [...zt, "body"]),
|
|
1192
1192
|
"separator",
|
|
1193
|
-
...
|
|
1194
|
-
],
|
|
1195
|
-
...
|
|
1193
|
+
...W(e, ["quote"])
|
|
1194
|
+
], hn = (e) => [
|
|
1195
|
+
...W(e, Bt),
|
|
1196
1196
|
"separator",
|
|
1197
|
-
...
|
|
1197
|
+
...W(e, Vt)
|
|
1198
1198
|
];
|
|
1199
|
-
function
|
|
1200
|
-
let { state: t } = e, n = t.facet(
|
|
1201
|
-
if (
|
|
1199
|
+
function gn(e) {
|
|
1200
|
+
let { state: t } = e, n = t.facet(Pe), r = (e) => n.includes(e);
|
|
1201
|
+
if (Y(e)) return pn(e);
|
|
1202
1202
|
if (ee(t)) {
|
|
1203
|
-
let t = [
|
|
1204
|
-
return r("clipboard") &&
|
|
1203
|
+
let t = [dn(e)];
|
|
1204
|
+
return r("clipboard") && q(t, G(e)), t;
|
|
1205
1205
|
}
|
|
1206
|
-
if (
|
|
1207
|
-
let t = [
|
|
1208
|
-
return r("clipboard") &&
|
|
1206
|
+
if (Ut(t)) {
|
|
1207
|
+
let t = [Kt(e)];
|
|
1208
|
+
return r("clipboard") && q(t, G(e)), t;
|
|
1209
1209
|
}
|
|
1210
|
-
let i = t.selection.main, a = t.doc.lineAt(i.head).text.trim() === "", o = !i.empty || !!t.wordAt(i.head), s = t.facet(
|
|
1211
|
-
for (let t of n) t === "link" && s ?
|
|
1210
|
+
let i = t.selection.main, a = t.doc.lineAt(i.head).text.trim() === "", o = !i.empty || !!t.wordAt(i.head), s = t.facet(Le) === "menu", c = [];
|
|
1211
|
+
for (let t of n) t === "link" && s ? q(c, [en(e), $t(e)]) : t === "format" && s ? q(c, [K("Format", x.format, fn(e), !o)]) : t === "paragraph" ? q(c, [K("Paragraph", x.paragraph, mn(e))]) : t === "insert" ? q(c, [K("Insert", x.insert, hn(e), !a)]) : t === "clipboard" && q(c, G(e));
|
|
1212
1212
|
return c;
|
|
1213
1213
|
}
|
|
1214
1214
|
//#endregion
|
|
1215
1215
|
//#region src/inplace/long-press.ts
|
|
1216
|
-
function
|
|
1216
|
+
function _n(e, t) {
|
|
1217
1217
|
let n = t.delay ?? 450, r = t.slop ?? 20, i = null, a = 0, o = 0, s = () => {
|
|
1218
1218
|
i != null && (clearTimeout(i), i = null);
|
|
1219
1219
|
}, c = (e) => {
|
|
@@ -1235,10 +1235,10 @@ function vn(e, t) {
|
|
|
1235
1235
|
}
|
|
1236
1236
|
//#endregion
|
|
1237
1237
|
//#region src/inplace/table-gizmos.ts
|
|
1238
|
-
function
|
|
1238
|
+
function vn(e, t) {
|
|
1239
1239
|
let n = e.createElement("div");
|
|
1240
1240
|
n.className = "cm-inplace-table-gizmos", n.setAttribute("contenteditable", "false");
|
|
1241
|
-
let r =
|
|
1241
|
+
let r = J(e), i = (t, n, r) => {
|
|
1242
1242
|
let i = e.createElement("button");
|
|
1243
1243
|
return i.type = "button", i.className = t, i.setAttribute("aria-label", n), i.addEventListener("mousedown", (e) => {
|
|
1244
1244
|
e.preventDefault(), e.stopPropagation();
|
|
@@ -1321,7 +1321,7 @@ function yn(e, t) {
|
|
|
1321
1321
|
}
|
|
1322
1322
|
//#endregion
|
|
1323
1323
|
//#region src/inplace/table-widget-keys.ts
|
|
1324
|
-
function
|
|
1324
|
+
function yn(e, t, n) {
|
|
1325
1325
|
let r = e.target.closest("td, th");
|
|
1326
1326
|
if (!r) return;
|
|
1327
1327
|
if (l(e, r)) {
|
|
@@ -1390,66 +1390,66 @@ function bn(e, t, n) {
|
|
|
1390
1390
|
}
|
|
1391
1391
|
//#endregion
|
|
1392
1392
|
//#region src/inplace/inline-md.ts
|
|
1393
|
-
function
|
|
1393
|
+
function bn(e, t = !1) {
|
|
1394
1394
|
let n = document.createDocumentFragment();
|
|
1395
|
-
return
|
|
1395
|
+
return Cn(n, e, t), n;
|
|
1396
1396
|
}
|
|
1397
|
-
var
|
|
1397
|
+
var xn = /!\[\[[^\]\n]+?\]\]/, Sn = [
|
|
1398
1398
|
{
|
|
1399
1399
|
re: /`([^`\n]+)`/,
|
|
1400
|
-
build: (e) =>
|
|
1400
|
+
build: (e) => X("code", "cm-inplace-code", document.createTextNode(e[1]))
|
|
1401
1401
|
},
|
|
1402
1402
|
{
|
|
1403
|
-
re: new RegExp(
|
|
1403
|
+
re: new RegExp(Ge.source),
|
|
1404
1404
|
build: (e) => {
|
|
1405
|
-
let t =
|
|
1406
|
-
return
|
|
1405
|
+
let t = X("span", "cm-inplace-math");
|
|
1406
|
+
return ge.render(e[1], t, { throwOnError: !1 }), t;
|
|
1407
1407
|
}
|
|
1408
1408
|
},
|
|
1409
1409
|
{
|
|
1410
1410
|
re: new RegExp(e.source),
|
|
1411
1411
|
build: (e) => {
|
|
1412
|
-
let t =
|
|
1412
|
+
let t = X("span", "cm-inplace-wikilink", document.createTextNode(e[2] || e[1] || ""));
|
|
1413
1413
|
return t.dataset.styloWikilink = e[1] ?? "", t;
|
|
1414
1414
|
}
|
|
1415
1415
|
},
|
|
1416
1416
|
{
|
|
1417
1417
|
re: /\[([^\]\n]*)\]\(([^)\n]*)\)/,
|
|
1418
1418
|
build: (e, t) => {
|
|
1419
|
-
let n =
|
|
1420
|
-
return n.href = e[2] ?? "", n.append(
|
|
1419
|
+
let n = X("a", "cm-inplace-link");
|
|
1420
|
+
return n.href = e[2] ?? "", n.append(Z(e[1] ?? "", t)), n;
|
|
1421
1421
|
}
|
|
1422
1422
|
},
|
|
1423
1423
|
{
|
|
1424
1424
|
re: /\*\*\*([^*\n]+?)\*\*\*/,
|
|
1425
|
-
build: (e, t) =>
|
|
1425
|
+
build: (e, t) => X("strong", "cm-inplace-strong", X("em", "cm-inplace-em", Z(e[1], t)))
|
|
1426
1426
|
},
|
|
1427
1427
|
{
|
|
1428
1428
|
re: /\*\*([^\n]+?)\*\*/,
|
|
1429
|
-
build: (e, t) =>
|
|
1429
|
+
build: (e, t) => X("strong", "cm-inplace-strong", Z(e[1], t))
|
|
1430
1430
|
},
|
|
1431
1431
|
{
|
|
1432
1432
|
re: /~~([^\n]+?)~~/,
|
|
1433
|
-
build: (e, t) =>
|
|
1433
|
+
build: (e, t) => X("span", "cm-inplace-strike", Z(e[1], t))
|
|
1434
1434
|
},
|
|
1435
1435
|
{
|
|
1436
1436
|
re: /(?<!\*)\*(?!\*|\s)([^\n]+?)(?<!\s)\*(?!\*)/,
|
|
1437
|
-
build: (e, t) =>
|
|
1437
|
+
build: (e, t) => X("em", "cm-inplace-em", Z(e[1], t))
|
|
1438
1438
|
}
|
|
1439
1439
|
];
|
|
1440
|
-
function
|
|
1440
|
+
function X(e, t, ...n) {
|
|
1441
1441
|
let r = document.createElement(e);
|
|
1442
1442
|
return r.className = t, r.append(...n), r;
|
|
1443
1443
|
}
|
|
1444
|
-
function
|
|
1444
|
+
function Z(e, t) {
|
|
1445
1445
|
let n = document.createDocumentFragment();
|
|
1446
|
-
return
|
|
1446
|
+
return Cn(n, e, t), n;
|
|
1447
1447
|
}
|
|
1448
|
-
function
|
|
1448
|
+
function Cn(e, t, n) {
|
|
1449
1449
|
for (; t;) {
|
|
1450
|
-
let r = -1, i = null, a = n ?
|
|
1450
|
+
let r = -1, i = null, a = n ? xn.exec(t) : null;
|
|
1451
1451
|
a && (r = a.index, i = { literal: a[0] });
|
|
1452
|
-
for (let e of
|
|
1452
|
+
for (let e of Sn) {
|
|
1453
1453
|
let n = e.re.exec(t);
|
|
1454
1454
|
n && (r < 0 || n.index < r) && (r = n.index, i = {
|
|
1455
1455
|
rule: e,
|
|
@@ -1465,53 +1465,53 @@ function wn(e, t, n) {
|
|
|
1465
1465
|
}
|
|
1466
1466
|
//#endregion
|
|
1467
1467
|
//#region src/inplace/table-widget-render.ts
|
|
1468
|
-
function
|
|
1468
|
+
function wn(e, t, n) {
|
|
1469
1469
|
let r = Number(e.dataset.r), i = Number(e.dataset.c), a = t.rows[r]?.[i] ?? "";
|
|
1470
|
-
e.replaceChildren(n ? e.ownerDocument.createTextNode(a) :
|
|
1470
|
+
e.replaceChildren(n ? e.ownerDocument.createTextNode(a) : bn(c(a), t.embeds));
|
|
1471
1471
|
}
|
|
1472
|
-
function
|
|
1472
|
+
function Tn(e, t, n, r) {
|
|
1473
1473
|
let i = document.createElement(r ? "th" : "td");
|
|
1474
1474
|
i.className = "cm-inplace-tcell", i.setAttribute("contenteditable", "true"), i.dataset.r = String(t), i.dataset.c = String(n);
|
|
1475
1475
|
let a = e.aligns[n];
|
|
1476
|
-
return a && (i.style.textAlign = a),
|
|
1476
|
+
return a && (i.style.textAlign = a), wn(i, e, !1), i;
|
|
1477
1477
|
}
|
|
1478
|
-
function
|
|
1478
|
+
function En(e, t) {
|
|
1479
1479
|
e.replaceChildren();
|
|
1480
1480
|
let n = t.aligns.length, r = e.createTHead().insertRow();
|
|
1481
|
-
for (let e = 0; e < n; e++) r.appendChild(
|
|
1481
|
+
for (let e = 0; e < n; e++) r.appendChild(Tn(t, 0, e, !0));
|
|
1482
1482
|
let i = e.createTBody();
|
|
1483
1483
|
for (let e = 1; e < t.rows.length; e++) {
|
|
1484
1484
|
let r = i.insertRow();
|
|
1485
|
-
for (let i = 0; i < n; i++) r.appendChild(
|
|
1485
|
+
for (let i = 0; i < n; i++) r.appendChild(Tn(t, e, i, !1));
|
|
1486
1486
|
}
|
|
1487
1487
|
}
|
|
1488
1488
|
//#endregion
|
|
1489
1489
|
//#region src/inplace/table-structure.ts
|
|
1490
|
-
var
|
|
1491
|
-
function
|
|
1492
|
-
let n = Math.max(0, Math.min(t,
|
|
1490
|
+
var Q = (e) => e.aligns.length;
|
|
1491
|
+
function Dn(e, t) {
|
|
1492
|
+
let n = Math.max(0, Math.min(t, Q(e)));
|
|
1493
1493
|
for (let t of e.rows) t.splice(n, 0, "");
|
|
1494
1494
|
e.aligns.splice(n, 0, "");
|
|
1495
1495
|
}
|
|
1496
|
-
function
|
|
1497
|
-
if (!(
|
|
1496
|
+
function On(e, t) {
|
|
1497
|
+
if (!(Q(e) <= 1 || t < 0 || t >= Q(e))) {
|
|
1498
1498
|
for (let n of e.rows) n.splice(t, 1);
|
|
1499
1499
|
e.aligns.splice(t, 1);
|
|
1500
1500
|
}
|
|
1501
1501
|
}
|
|
1502
|
-
function
|
|
1502
|
+
function kn(e, t) {
|
|
1503
1503
|
let n = Math.max(1, Math.min(t, e.rows.length));
|
|
1504
|
-
e.rows.splice(n, 0, Array(
|
|
1504
|
+
e.rows.splice(n, 0, Array(Q(e)).fill(""));
|
|
1505
1505
|
}
|
|
1506
|
-
function
|
|
1506
|
+
function An(e, t) {
|
|
1507
1507
|
t <= 0 || t >= e.rows.length || e.rows.length <= 2 || e.rows.splice(t, 1);
|
|
1508
1508
|
}
|
|
1509
|
-
function
|
|
1510
|
-
t >= 0 && t <
|
|
1509
|
+
function jn(e, t, n) {
|
|
1510
|
+
t >= 0 && t < Q(e) && (e.aligns[t] = n);
|
|
1511
1511
|
}
|
|
1512
1512
|
//#endregion
|
|
1513
1513
|
//#region src/inplace/tables.ts
|
|
1514
|
-
var
|
|
1514
|
+
var Mn = class extends O {
|
|
1515
1515
|
table;
|
|
1516
1516
|
embeds;
|
|
1517
1517
|
constructor(e, t) {
|
|
@@ -1523,17 +1523,17 @@ var Nn = class extends D {
|
|
|
1523
1523
|
toDOM() {
|
|
1524
1524
|
let { head: e, body: t, aligns: n } = this.table, r = document.createElement("table");
|
|
1525
1525
|
r.className = "cm-inplace-table";
|
|
1526
|
-
let i = (e) =>
|
|
1526
|
+
let i = (e) => bn(e.replace(/\\\|/g, "|"), this.embeds), a = r.createTHead().insertRow();
|
|
1527
1527
|
e.forEach((e, t) => {
|
|
1528
1528
|
let r = document.createElement("th");
|
|
1529
|
-
r.appendChild(i(e)), r.dataset.styloRow = "0", r.dataset.styloCol = String(t),
|
|
1529
|
+
r.appendChild(i(e)), r.dataset.styloRow = "0", r.dataset.styloCol = String(t), Nn(r, n[t]), a.appendChild(r);
|
|
1530
1530
|
});
|
|
1531
1531
|
let o = r.createTBody();
|
|
1532
1532
|
return t.forEach((t, r) => {
|
|
1533
1533
|
let a = o.insertRow();
|
|
1534
1534
|
for (let o = 0; o < e.length; o++) {
|
|
1535
1535
|
let e = a.insertCell();
|
|
1536
|
-
e.appendChild(i(t[o] ?? "")), e.dataset.styloRow = String(r + 1), e.dataset.styloCol = String(o),
|
|
1536
|
+
e.appendChild(i(t[o] ?? "")), e.dataset.styloRow = String(r + 1), e.dataset.styloCol = String(o), Nn(e, n[o]);
|
|
1537
1537
|
}
|
|
1538
1538
|
}), r;
|
|
1539
1539
|
}
|
|
@@ -1541,10 +1541,10 @@ var Nn = class extends D {
|
|
|
1541
1541
|
return !1;
|
|
1542
1542
|
}
|
|
1543
1543
|
};
|
|
1544
|
-
function
|
|
1544
|
+
function Nn(e, t) {
|
|
1545
1545
|
t && (e.style.textAlign = t);
|
|
1546
1546
|
}
|
|
1547
|
-
function
|
|
1547
|
+
function Pn(e, t) {
|
|
1548
1548
|
let n = t.lineAt(e.from).number, r = t.lineAt(e.to).number, i = [];
|
|
1549
1549
|
for (let e = n; e <= r; e++) i.push(t.line(e).text);
|
|
1550
1550
|
let a = p(i);
|
|
@@ -1554,17 +1554,17 @@ function Fn(e, t) {
|
|
|
1554
1554
|
aligns: a.aligns
|
|
1555
1555
|
};
|
|
1556
1556
|
}
|
|
1557
|
-
function
|
|
1558
|
-
let n =
|
|
1557
|
+
function Fn(e, t) {
|
|
1558
|
+
let n = N(e);
|
|
1559
1559
|
for (let e of [-1, 1]) for (let r = n.resolveInner(t, e); r; r = r.parent) if (r.name === "Table") return !0;
|
|
1560
1560
|
return !1;
|
|
1561
1561
|
}
|
|
1562
|
-
function
|
|
1563
|
-
return t.ranges.some((t) =>
|
|
1562
|
+
function In(e, t) {
|
|
1563
|
+
return t.ranges.some((t) => Fn(e, t.from) || Fn(e, t.to));
|
|
1564
1564
|
}
|
|
1565
|
-
function
|
|
1566
|
-
if (!e.facet(
|
|
1567
|
-
let n = e.facet(
|
|
1565
|
+
function Ln(e) {
|
|
1566
|
+
if (!e.facet(P).tables) return T.none;
|
|
1567
|
+
let n = e.facet(I) === "cells" && !e.readOnly, r = e.facet(F) != null && e.facet(P).embeds, i = N(e), a = t(e.doc), o = n ? null : z(e), s = [];
|
|
1568
1568
|
return i.iterate({ enter: (t) => {
|
|
1569
1569
|
if (t.name !== "Table") return;
|
|
1570
1570
|
if (a && t.from < a.to) return !1;
|
|
@@ -1572,26 +1572,26 @@ function Rn(e) {
|
|
|
1572
1572
|
let n = e.doc.lineAt(t.from).number, r = e.doc.lineAt(t.to).number;
|
|
1573
1573
|
for (let e = n; e <= r; e++) if (o.has(e)) return !1;
|
|
1574
1574
|
}
|
|
1575
|
-
let i =
|
|
1575
|
+
let i = Pn(t.node, e.doc);
|
|
1576
1576
|
if (i) {
|
|
1577
|
-
let e = n ? new
|
|
1578
|
-
s.push(
|
|
1577
|
+
let e = n ? new zn(i, r) : new Mn(i, r);
|
|
1578
|
+
s.push(T.replace({
|
|
1579
1579
|
widget: e,
|
|
1580
1580
|
block: !0
|
|
1581
1581
|
}).range(t.from, t.to));
|
|
1582
1582
|
}
|
|
1583
1583
|
return !1;
|
|
1584
|
-
} }),
|
|
1584
|
+
} }), T.set(s, !0);
|
|
1585
1585
|
}
|
|
1586
|
-
var
|
|
1587
|
-
create:
|
|
1586
|
+
var Rn = M.define({
|
|
1587
|
+
create: Ln,
|
|
1588
1588
|
update: (e, t) => {
|
|
1589
|
-
if (t.annotation(
|
|
1589
|
+
if (t.annotation($)) return e.map(t.changes);
|
|
1590
1590
|
let n = t.startState.readOnly !== t.state.readOnly;
|
|
1591
|
-
return t.state.facet(
|
|
1591
|
+
return t.state.facet(I) === "cells" ? t.docChanged || n ? Ln(t.state) : e.map(t.changes) : t.docChanged || n || t.selection && (In(t.state, t.startState.selection) || In(t.state, t.state.selection)) ? Ln(t.state) : e;
|
|
1592
1592
|
},
|
|
1593
|
-
provide: (e) => [
|
|
1594
|
-
}),
|
|
1593
|
+
provide: (e) => [E.decorations.from(e), E.atomicRanges.of((t) => t.state.field(e))]
|
|
1594
|
+
}), $ = xe.define(), zn = class extends O {
|
|
1595
1595
|
data;
|
|
1596
1596
|
embeds;
|
|
1597
1597
|
table = null;
|
|
@@ -1603,10 +1603,10 @@ var zn = j.define({
|
|
|
1603
1603
|
longPress = null;
|
|
1604
1604
|
longPressAt = 0;
|
|
1605
1605
|
constructor(e, t = !1) {
|
|
1606
|
-
super(), this.data = e, this.embeds = t, this.rows =
|
|
1606
|
+
super(), this.data = e, this.embeds = t, this.rows = y(e);
|
|
1607
1607
|
}
|
|
1608
1608
|
eq(e) {
|
|
1609
|
-
return !this.table && JSON.stringify(
|
|
1609
|
+
return !this.table && JSON.stringify(b(this.rows)) === JSON.stringify(b(e.rows));
|
|
1610
1610
|
}
|
|
1611
1611
|
ignoreEvent() {
|
|
1612
1612
|
return !0;
|
|
@@ -1616,7 +1616,7 @@ var zn = j.define({
|
|
|
1616
1616
|
}
|
|
1617
1617
|
bounds(e) {
|
|
1618
1618
|
let t = e.posAtDOM(this.table), n = null;
|
|
1619
|
-
return e.state.field(
|
|
1619
|
+
return e.state.field(Rn).between(t, t, (e, t) => (n = {
|
|
1620
1620
|
from: e,
|
|
1621
1621
|
to: t
|
|
1622
1622
|
}, !1)), n ?? e.state.doc.lineAt(t);
|
|
@@ -1631,21 +1631,21 @@ var zn = j.define({
|
|
|
1631
1631
|
};
|
|
1632
1632
|
}
|
|
1633
1633
|
paint(e, t) {
|
|
1634
|
-
|
|
1634
|
+
wn(e, {
|
|
1635
1635
|
rows: this.rows,
|
|
1636
1636
|
aligns: this.data.aligns,
|
|
1637
1637
|
embeds: this.embeds
|
|
1638
1638
|
}, t);
|
|
1639
1639
|
}
|
|
1640
1640
|
renderCells() {
|
|
1641
|
-
|
|
1641
|
+
En(this.table, {
|
|
1642
1642
|
rows: this.rows,
|
|
1643
1643
|
aligns: this.data.aligns,
|
|
1644
1644
|
embeds: this.embeds
|
|
1645
1645
|
});
|
|
1646
1646
|
}
|
|
1647
1647
|
appendRow() {
|
|
1648
|
-
|
|
1648
|
+
kn(this.model(), this.rows.length), this.renderCells(), this.gizmos?.layout(this.table);
|
|
1649
1649
|
}
|
|
1650
1650
|
model() {
|
|
1651
1651
|
return {
|
|
@@ -1656,7 +1656,7 @@ var zn = j.define({
|
|
|
1656
1656
|
runOp(e, t) {
|
|
1657
1657
|
if (!this.table) return;
|
|
1658
1658
|
let n = this.model();
|
|
1659
|
-
if (t.kind === "insertColumn" ?
|
|
1659
|
+
if (t.kind === "insertColumn" ? Dn(n, t.at) : t.kind === "deleteColumn" ? On(n, t.at) : t.kind === "insertRow" ? kn(n, t.at) : t.kind === "deleteRow" ? An(n, t.at) : jn(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") {
|
|
1660
1660
|
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));
|
|
1661
1661
|
this.cellAt(e, n)?.focus();
|
|
1662
1662
|
}
|
|
@@ -1668,7 +1668,7 @@ var zn = j.define({
|
|
|
1668
1668
|
onFocusIn(e) {
|
|
1669
1669
|
let t = e.target.closest("td, th");
|
|
1670
1670
|
if (!t || t === this.editing) return;
|
|
1671
|
-
let n = this.pendingOffset ??
|
|
1671
|
+
let n = this.pendingOffset ?? le(t);
|
|
1672
1672
|
this.pendingOffset = null, this.editing && this.finish(this.editing, !1), this.editing = t, this.paint(t, !0), d(t, n);
|
|
1673
1673
|
}
|
|
1674
1674
|
onFocusOut(e) {
|
|
@@ -1702,14 +1702,14 @@ var zn = j.define({
|
|
|
1702
1702
|
to: i,
|
|
1703
1703
|
insert: n
|
|
1704
1704
|
},
|
|
1705
|
-
annotations:
|
|
1705
|
+
annotations: $.of(!0),
|
|
1706
1706
|
userEvent: "input"
|
|
1707
1707
|
}), this.syncing = !1, t && (this.writeCaret(t), requestAnimationFrame(() => {
|
|
1708
1708
|
this.table && t && this.writeCaret(t);
|
|
1709
1709
|
})));
|
|
1710
1710
|
}
|
|
1711
1711
|
onKey(e, t) {
|
|
1712
|
-
this.table &&
|
|
1712
|
+
this.table && yn(e, t, {
|
|
1713
1713
|
coords: (e) => this.coords(e),
|
|
1714
1714
|
rows: () => this.rows.length,
|
|
1715
1715
|
cols: () => this.cols(),
|
|
@@ -1732,8 +1732,8 @@ var zn = j.define({
|
|
|
1732
1732
|
openCellMenuAt(e, t, n, r) {
|
|
1733
1733
|
let i = r?.closest("td, th");
|
|
1734
1734
|
if (!i) return;
|
|
1735
|
-
this.editing === i && !
|
|
1736
|
-
let a =
|
|
1735
|
+
this.editing === i && !Y(e) && s(i, t, n);
|
|
1736
|
+
let a = Y(e) ? pn(e) : void 0;
|
|
1737
1737
|
this.gizmos?.openFor(i, t, n, a);
|
|
1738
1738
|
}
|
|
1739
1739
|
toDOM(e) {
|
|
@@ -1743,7 +1743,7 @@ var zn = j.define({
|
|
|
1743
1743
|
this.table = n, this.editing = null, n.className = "cm-inplace-table cm-inplace-table-edit", this.renderCells(), n.addEventListener("mousedown", (e) => {
|
|
1744
1744
|
e.stopPropagation();
|
|
1745
1745
|
let t = e.target.closest("td, th");
|
|
1746
|
-
this.pendingOffset = t && t !== this.editing ?
|
|
1746
|
+
this.pendingOffset = t && t !== this.editing ? ue(t, e.clientX, e.clientY) : null;
|
|
1747
1747
|
}), n.addEventListener("focusin", (e) => this.onFocusIn(e)), n.addEventListener("focusout", (e) => this.onFocusOut(e));
|
|
1748
1748
|
let r = (t) => {
|
|
1749
1749
|
t && (this.editing = t, this.finish(t, !0), this.sync(e));
|
|
@@ -1756,9 +1756,9 @@ var zn = j.define({
|
|
|
1756
1756
|
document.execCommand("insertText", !1, t);
|
|
1757
1757
|
}), n.addEventListener("contextmenu", (t) => {
|
|
1758
1758
|
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));
|
|
1759
|
-
}), this.longPress =
|
|
1759
|
+
}), this.longPress = _n(n, { onLongPress: (t, n, r) => {
|
|
1760
1760
|
this.longPressAt = Date.now(), this.openCellMenuAt(e, t, n, r);
|
|
1761
|
-
} }), this.gizmos =
|
|
1761
|
+
} }), this.gizmos = vn(document, {
|
|
1762
1762
|
dims: () => ({
|
|
1763
1763
|
cols: this.cols(),
|
|
1764
1764
|
rows: this.rows.length,
|
|
@@ -1770,12 +1770,12 @@ var zn = j.define({
|
|
|
1770
1770
|
destroy() {
|
|
1771
1771
|
this.longPress?.dispose(), this.longPress = null, this.gizmos?.destroy(), this.gizmos = null, this.table = null, this.editing = null;
|
|
1772
1772
|
}
|
|
1773
|
-
},
|
|
1773
|
+
}, Bn = /* @__PURE__ */ new Set([
|
|
1774
1774
|
"-",
|
|
1775
1775
|
"*",
|
|
1776
1776
|
"_"
|
|
1777
|
-
]),
|
|
1778
|
-
if (!e.docChanged || e.isUserEvent("undo") || e.isUserEvent("redo") || e.annotation(
|
|
1777
|
+
]), Vn = Ce.transactionFilter.of((e) => {
|
|
1778
|
+
if (!e.docChanged || e.isUserEvent("undo") || e.isUserEvent("redo") || e.annotation($) || !e.startState.selection.main.empty) return e;
|
|
1779
1779
|
let t = e.startState.selection.main.head, n = "", r = 0;
|
|
1780
1780
|
if (e.changes.iterChanges((e, i, a, o, s) => {
|
|
1781
1781
|
r += 1, e === i && e === t && (n = s.toString());
|
|
@@ -1805,7 +1805,7 @@ var zn = j.define({
|
|
|
1805
1805
|
},
|
|
1806
1806
|
anchor: a + 1
|
|
1807
1807
|
};
|
|
1808
|
-
else if (
|
|
1808
|
+
else if (Bn.has(n) && RegExp(`^\\${n}{3,}$`).test(s)) {
|
|
1809
1809
|
let e = o.number === 1 || i.line(o.number - 1).text.trim() === "", t = n === "-" && !e, r = o.number === i.lines;
|
|
1810
1810
|
if (t || r) {
|
|
1811
1811
|
let e = [];
|
|
@@ -1828,38 +1828,38 @@ var zn = j.define({
|
|
|
1828
1828
|
scrollIntoView: !0,
|
|
1829
1829
|
userEvent: "input.autoformat"
|
|
1830
1830
|
}] : e;
|
|
1831
|
-
}),
|
|
1831
|
+
}), Hn = /* @__PURE__ */ new Set([
|
|
1832
1832
|
"EmphasisMark",
|
|
1833
1833
|
"CodeMark",
|
|
1834
1834
|
"StrikethroughMark"
|
|
1835
1835
|
]);
|
|
1836
|
-
function
|
|
1836
|
+
function Un(e, t, n) {
|
|
1837
1837
|
let r = t;
|
|
1838
1838
|
for (;;) {
|
|
1839
1839
|
let t = e.resolveInner(r, n);
|
|
1840
|
-
if (!
|
|
1840
|
+
if (!Hn.has(t.name) || t.from >= t.to) return r;
|
|
1841
1841
|
let i = n < 0 ? t.from : t.to;
|
|
1842
1842
|
if (i === r) return r;
|
|
1843
1843
|
r = i;
|
|
1844
1844
|
}
|
|
1845
1845
|
}
|
|
1846
|
-
function
|
|
1847
|
-
let n =
|
|
1846
|
+
function Wn(e, t) {
|
|
1847
|
+
let n = H(e, t, !0);
|
|
1848
1848
|
if (!n) return t;
|
|
1849
|
-
let r =
|
|
1850
|
-
return t === n.contentTo ?
|
|
1849
|
+
let r = N(e);
|
|
1850
|
+
return t === n.contentTo ? Un(r, t, 1) : t === n.contentFrom ? Un(r, t, -1) : t;
|
|
1851
1851
|
}
|
|
1852
|
-
var
|
|
1853
|
-
if (!e.docChanged || e.isUserEvent("undo") || e.isUserEvent("redo") || e.annotation(
|
|
1852
|
+
var Gn = Ce.transactionFilter.of((e) => {
|
|
1853
|
+
if (!e.docChanged || e.isUserEvent("undo") || e.isUserEvent("redo") || e.annotation($)) return e;
|
|
1854
1854
|
let t = e.startState, n = t.selection.main;
|
|
1855
|
-
if (!n.empty || !
|
|
1855
|
+
if (!n.empty || !V(t, t.doc.lineAt(n.head).number)) return e;
|
|
1856
1856
|
let r = [], i = 0;
|
|
1857
1857
|
e.changes.iterChanges((e, t, a, o, s) => {
|
|
1858
1858
|
i++, e === t && e === n.head && s.length > 0 && r.push(s.toString());
|
|
1859
1859
|
});
|
|
1860
1860
|
let a = r[0];
|
|
1861
1861
|
if (i !== 1 || a === void 0) return e;
|
|
1862
|
-
let o =
|
|
1862
|
+
let o = Wn(t, n.head);
|
|
1863
1863
|
return o === n.head ? e : {
|
|
1864
1864
|
changes: {
|
|
1865
1865
|
from: o,
|
|
@@ -1869,25 +1869,25 @@ var Kn = we.transactionFilter.of((e) => {
|
|
|
1869
1869
|
scrollIntoView: !0,
|
|
1870
1870
|
userEvent: "input.type"
|
|
1871
1871
|
};
|
|
1872
|
-
}),
|
|
1873
|
-
function
|
|
1872
|
+
}), Kn = RegExp(`^(?:${se.match.source.replace(/^\^/, "")})+`);
|
|
1873
|
+
function qn(e, t) {
|
|
1874
1874
|
let n = e.doc.lineAt(t).number;
|
|
1875
|
-
for (let r =
|
|
1875
|
+
for (let r = N(e).resolveInner(t, 1); r; r = r.parent) {
|
|
1876
1876
|
if (r.name !== "ListItem" || e.doc.lineAt(r.from).number === n) continue;
|
|
1877
1877
|
let t = u.exec(e.doc.lineAt(r.from).text);
|
|
1878
1878
|
if (t) return t[0].length;
|
|
1879
1879
|
}
|
|
1880
1880
|
return null;
|
|
1881
1881
|
}
|
|
1882
|
-
function
|
|
1882
|
+
function Jn(e, t) {
|
|
1883
1883
|
let n = t.text, r = ae.exec(n);
|
|
1884
1884
|
if (r) return {
|
|
1885
1885
|
prefixLen: r[0].length,
|
|
1886
1886
|
drop: [0, r[0].length]
|
|
1887
1887
|
};
|
|
1888
|
-
let i =
|
|
1888
|
+
let i = Kn.exec(n);
|
|
1889
1889
|
if (i) {
|
|
1890
|
-
let e =
|
|
1890
|
+
let e = se.match.exec(n)[0].length;
|
|
1891
1891
|
return {
|
|
1892
1892
|
prefixLen: i[0].length,
|
|
1893
1893
|
drop: [0, e]
|
|
@@ -1902,7 +1902,7 @@ function Yn(e, t) {
|
|
|
1902
1902
|
if (o) {
|
|
1903
1903
|
let n = o[1] ?? "", r = o[0].length - n.length;
|
|
1904
1904
|
if (n) {
|
|
1905
|
-
let r =
|
|
1905
|
+
let r = qn(e, t.from) ?? 2, i = n.startsWith(" ") ? 1 : Math.min(r, n.length);
|
|
1906
1906
|
return {
|
|
1907
1907
|
prefixLen: o[0].length,
|
|
1908
1908
|
drop: [0, i]
|
|
@@ -1915,15 +1915,15 @@ function Yn(e, t) {
|
|
|
1915
1915
|
}
|
|
1916
1916
|
return null;
|
|
1917
1917
|
}
|
|
1918
|
-
var
|
|
1918
|
+
var Yn = j.high(k.of([{
|
|
1919
1919
|
key: "Backspace",
|
|
1920
1920
|
run: (e) => {
|
|
1921
1921
|
if (h(e)) return !1;
|
|
1922
1922
|
let { state: t } = e, n = t.selection.main;
|
|
1923
1923
|
if (!n.empty) return !1;
|
|
1924
1924
|
let r = t.doc.lineAt(n.head);
|
|
1925
|
-
if (!
|
|
1926
|
-
let i =
|
|
1925
|
+
if (!V(t, r.number)) return !1;
|
|
1926
|
+
let i = Jn(t, r);
|
|
1927
1927
|
if (!i || n.head < r.from || n.head > r.from + i.prefixLen) return !1;
|
|
1928
1928
|
let [a, o] = i.drop;
|
|
1929
1929
|
return e.dispatch({
|
|
@@ -1937,13 +1937,13 @@ var Xn = A.high(O.of([{
|
|
|
1937
1937
|
scrollIntoView: !0
|
|
1938
1938
|
}), !0;
|
|
1939
1939
|
}
|
|
1940
|
-
}])),
|
|
1940
|
+
}])), Xn = class {
|
|
1941
1941
|
menu;
|
|
1942
1942
|
contentDOM;
|
|
1943
1943
|
onClick;
|
|
1944
1944
|
constructor(e) {
|
|
1945
|
-
this.menu =
|
|
1946
|
-
if (e.state.facet(
|
|
1945
|
+
this.menu = J(e.dom.ownerDocument), e.dom.appendChild(this.menu.el), this.contentDOM = e.contentDOM, this.onClick = (t) => {
|
|
1946
|
+
if (e.state.facet(L) !== "never" || !e.state.facet(P).links) return;
|
|
1947
1947
|
let n = t.target?.closest(".cm-inplace-link");
|
|
1948
1948
|
if (!n || n.classList.contains("cm-inplace-wikilink")) return;
|
|
1949
1949
|
let r = e.posAtDOM(n);
|
|
@@ -1955,13 +1955,13 @@ var Xn = A.high(O.of([{
|
|
|
1955
1955
|
if (n == null) return;
|
|
1956
1956
|
r = n;
|
|
1957
1957
|
}
|
|
1958
|
-
e.dispatch({ selection: { anchor: r } }), this.menu.showField(
|
|
1958
|
+
e.dispatch({ selection: { anchor: r } }), this.menu.showField($t(e), t.clientX, t.clientY);
|
|
1959
1959
|
}, this.contentDOM.addEventListener("click", this.onClick);
|
|
1960
1960
|
}
|
|
1961
1961
|
destroy() {
|
|
1962
1962
|
this.contentDOM.removeEventListener("click", this.onClick), this.menu.destroy();
|
|
1963
1963
|
}
|
|
1964
|
-
},
|
|
1964
|
+
}, Zn = D.fromClass(Xn), Qn = (e) => e.replace(/^<([^]*)>$/, "$1").trim(), $n = (e, t, n) => n ? {
|
|
1965
1965
|
pos: e,
|
|
1966
1966
|
end: t,
|
|
1967
1967
|
above: !0,
|
|
@@ -1970,27 +1970,27 @@ var Xn = A.high(O.of([{
|
|
|
1970
1970
|
return e.className = "cm-inplace-href-tip", e.textContent = n, { dom: e };
|
|
1971
1971
|
}
|
|
1972
1972
|
} : null;
|
|
1973
|
-
function
|
|
1974
|
-
for (let n =
|
|
1973
|
+
function er(e, t) {
|
|
1974
|
+
for (let n = N(e.state).resolveInner(t, -1); n; n = n.parent) {
|
|
1975
1975
|
if (n.name !== "Link") continue;
|
|
1976
1976
|
if (e.state.doc.sliceString(Math.max(0, n.from - 1), n.from) === "[") break;
|
|
1977
1977
|
let t = n.getChild("URL"), r = t ? e.state.sliceDoc(t.from, t.to) : e.state.sliceDoc(n.from, n.to);
|
|
1978
|
-
return
|
|
1978
|
+
return $n(n.from, n.to, Qn(r));
|
|
1979
1979
|
}
|
|
1980
1980
|
return null;
|
|
1981
1981
|
}
|
|
1982
|
-
function
|
|
1982
|
+
function tr(t, n) {
|
|
1983
1983
|
let r = t.state.doc.lineAt(n);
|
|
1984
1984
|
for (let t of r.text.matchAll(e)) {
|
|
1985
1985
|
let e = r.from + (t.index ?? 0), i = e + t[0].length;
|
|
1986
|
-
if (!(n < e || n > i)) return
|
|
1986
|
+
if (!(n < e || n > i)) return $n(e, i, (t[1] ?? "").trim());
|
|
1987
1987
|
}
|
|
1988
1988
|
return null;
|
|
1989
1989
|
}
|
|
1990
|
-
var
|
|
1991
|
-
let n = e.state.facet(
|
|
1992
|
-
return (n.links ?
|
|
1993
|
-
}),
|
|
1990
|
+
var nr = ve((e, t) => {
|
|
1991
|
+
let n = e.state.facet(P);
|
|
1992
|
+
return (n.links ? er(e, t) : null) ?? (n.wikilinks ? tr(e, t) : null);
|
|
1993
|
+
}), rr = class extends O {
|
|
1994
1994
|
ref;
|
|
1995
1995
|
inline;
|
|
1996
1996
|
registry;
|
|
@@ -2017,49 +2017,49 @@ var rr = ye((e, t) => {
|
|
|
2017
2017
|
return !1;
|
|
2018
2018
|
}
|
|
2019
2019
|
};
|
|
2020
|
-
function
|
|
2021
|
-
let t = e.facet(
|
|
2022
|
-
if (!t || !e.facet(
|
|
2023
|
-
let n =
|
|
2020
|
+
function ir(e) {
|
|
2021
|
+
let t = e.facet(F);
|
|
2022
|
+
if (!t || !e.facet(P).embeds || !e.doc.toString().includes("![[")) return T.none;
|
|
2023
|
+
let n = z(e), r = N(e), i = [];
|
|
2024
2024
|
for (let a = 1; a <= e.doc.lines; a++) {
|
|
2025
2025
|
let o = e.doc.line(a);
|
|
2026
2026
|
if (!(!o.text.includes("![[") || n.has(a))) {
|
|
2027
|
-
if (
|
|
2028
|
-
|
|
2029
|
-
let e = (
|
|
2030
|
-
if (!e ||
|
|
2031
|
-
i.push(
|
|
2032
|
-
widget: new
|
|
2027
|
+
if (pe(o.text)) {
|
|
2028
|
+
S.lastIndex = 0;
|
|
2029
|
+
let e = (S.exec(o.text.trim())?.[1] ?? "").trim();
|
|
2030
|
+
if (!e || B(r, o.from + o.text.indexOf("!["))) continue;
|
|
2031
|
+
i.push(T.replace({
|
|
2032
|
+
widget: new rr(e, !1, t),
|
|
2033
2033
|
block: !0
|
|
2034
2034
|
}).range(o.from, o.to));
|
|
2035
2035
|
continue;
|
|
2036
2036
|
}
|
|
2037
|
-
|
|
2038
|
-
for (let e of o.text.matchAll(
|
|
2037
|
+
S.lastIndex = 0;
|
|
2038
|
+
for (let e of o.text.matchAll(S)) {
|
|
2039
2039
|
let n = (e[1] ?? "").trim();
|
|
2040
2040
|
if (!n) continue;
|
|
2041
2041
|
let a = o.from + (e.index ?? 0);
|
|
2042
|
-
|
|
2042
|
+
B(r, a + 2) || Ue(r, a + 2) || i.push(T.replace({ widget: new rr(n, !0, t) }).range(a, a + e[0].length));
|
|
2043
2043
|
}
|
|
2044
2044
|
}
|
|
2045
2045
|
}
|
|
2046
|
-
return
|
|
2046
|
+
return T.set(i, !0);
|
|
2047
2047
|
}
|
|
2048
|
-
function
|
|
2048
|
+
function ar(e, t) {
|
|
2049
2049
|
for (let n of t.ranges) {
|
|
2050
2050
|
let t = e.doc.lineAt(n.from).number, r = e.doc.lineAt(n.to).number;
|
|
2051
2051
|
for (let n = t; n <= r; n++) if (e.doc.line(n).text.includes("![[")) return !0;
|
|
2052
2052
|
}
|
|
2053
2053
|
return !1;
|
|
2054
2054
|
}
|
|
2055
|
-
var
|
|
2056
|
-
create:
|
|
2057
|
-
update: (e, t) => t.docChanged || t.selection && (
|
|
2058
|
-
provide: (e) => [
|
|
2059
|
-
}),
|
|
2055
|
+
var or = M.define({
|
|
2056
|
+
create: ir,
|
|
2057
|
+
update: (e, t) => t.docChanged || t.selection && (ar(t.state, t.startState.selection) || ar(t.state, t.state.selection)) ? ir(t.state) : e,
|
|
2058
|
+
provide: (e) => [E.decorations.from(e), E.atomicRanges.of((t) => t.state.field(e))]
|
|
2059
|
+
}), sr = we.define(), cr = M.define({
|
|
2060
2060
|
create: () => !1,
|
|
2061
2061
|
update(e, t) {
|
|
2062
|
-
for (let n of t.effects) n.is(
|
|
2062
|
+
for (let n of t.effects) n.is(sr) && (e = n.value);
|
|
2063
2063
|
return e;
|
|
2064
2064
|
}
|
|
2065
2065
|
}), lr = class {
|
|
@@ -2073,8 +2073,8 @@ var sr = j.define({
|
|
|
2073
2073
|
longPressAt = 0;
|
|
2074
2074
|
destroyed = !1;
|
|
2075
2075
|
constructor(e) {
|
|
2076
|
-
this.view = e, this.menu =
|
|
2077
|
-
this.destroyed || e.dispatch({ effects:
|
|
2076
|
+
this.view = e, this.menu = J(e.dom.ownerDocument, "cm-inplace-menu", (t) => {
|
|
2077
|
+
this.destroyed || e.dispatch({ effects: sr.of(t) });
|
|
2078
2078
|
}), e.dom.appendChild(this.menu.el), this.contentDOM = e.contentDOM, this.onPointerDown = () => {
|
|
2079
2079
|
let t = e.state.selection.main;
|
|
2080
2080
|
this.stashed = t.empty ? null : {
|
|
@@ -2083,18 +2083,18 @@ var sr = j.define({
|
|
|
2083
2083
|
};
|
|
2084
2084
|
}, this.contentDOM.addEventListener("pointerdown", this.onPointerDown, !0), this.onContextMenu = (t) => {
|
|
2085
2085
|
let n = t.target;
|
|
2086
|
-
!e.state.facet(
|
|
2087
|
-
}, this.contentDOM.addEventListener("contextmenu", this.onContextMenu), this.longPress =
|
|
2086
|
+
!e.state.facet(je) || e.state.readOnly || n?.closest(".cm-inplace-table-edit") || (t.preventDefault(), this.longPress.cancel(), !(Date.now() - this.longPressAt < 700) && this.openMenuAt(t.clientX, t.clientY, n));
|
|
2087
|
+
}, this.contentDOM.addEventListener("contextmenu", this.onContextMenu), this.longPress = _n(this.contentDOM, { onLongPress: (e, t, n) => {
|
|
2088
2088
|
this.longPressAt = Date.now(), this.openMenuAt(e, t, n);
|
|
2089
2089
|
} });
|
|
2090
2090
|
}
|
|
2091
2091
|
openMenuAt(e, t, n) {
|
|
2092
2092
|
let r = this.view;
|
|
2093
|
-
if (!r.state.facet(
|
|
2093
|
+
if (!r.state.facet(je) || r.state.readOnly || n?.closest(".cm-inplace-table-edit")) return;
|
|
2094
2094
|
let i = n?.closest(".cm-inplace-hr");
|
|
2095
2095
|
if (i) {
|
|
2096
2096
|
let n = r.posAtDOM(i);
|
|
2097
|
-
n >= 0 && r.dispatch({ selection: { anchor: n } }), this.menu.show(
|
|
2097
|
+
n >= 0 && r.dispatch({ selection: { anchor: n } }), this.menu.show(gn(r), e, t);
|
|
2098
2098
|
return;
|
|
2099
2099
|
}
|
|
2100
2100
|
if (this.stashed && r.state.selection.main.empty) r.dispatch({ selection: this.stashed });
|
|
@@ -2104,7 +2104,7 @@ var sr = j.define({
|
|
|
2104
2104
|
y: t
|
|
2105
2105
|
});
|
|
2106
2106
|
if (n != null) {
|
|
2107
|
-
let e =
|
|
2107
|
+
let e = H(r.state, n, !1, !0), t = r.state.wordAt(n) ?? { anchor: n };
|
|
2108
2108
|
e?.kind === "link" ? t = {
|
|
2109
2109
|
anchor: e.from,
|
|
2110
2110
|
head: e.to
|
|
@@ -2114,12 +2114,12 @@ var sr = j.define({
|
|
|
2114
2114
|
}), r.dispatch({ selection: t });
|
|
2115
2115
|
}
|
|
2116
2116
|
}
|
|
2117
|
-
this.menu.show(
|
|
2117
|
+
this.menu.show(gn(r), e, t);
|
|
2118
2118
|
}
|
|
2119
2119
|
destroy() {
|
|
2120
2120
|
this.destroyed = !0, this.contentDOM.removeEventListener("pointerdown", this.onPointerDown, !0), this.contentDOM.removeEventListener("contextmenu", this.onContextMenu), this.longPress.dispose(), this.menu.destroy();
|
|
2121
2121
|
}
|
|
2122
|
-
}, ur =
|
|
2122
|
+
}, ur = D.fromClass(lr);
|
|
2123
2123
|
//#endregion
|
|
2124
2124
|
//#region src/inplace/selection-bar-position.ts
|
|
2125
2125
|
function dr(e) {
|
|
@@ -2136,7 +2136,7 @@ function dr(e) {
|
|
|
2136
2136
|
}
|
|
2137
2137
|
};
|
|
2138
2138
|
}
|
|
2139
|
-
if (!
|
|
2139
|
+
if (!Y(e)) return null;
|
|
2140
2140
|
let n = e.dom.ownerDocument.getSelection();
|
|
2141
2141
|
if (!n || n.rangeCount === 0) return null;
|
|
2142
2142
|
let r = n.getRangeAt(0).getBoundingClientRect();
|
|
@@ -2151,7 +2151,7 @@ function dr(e) {
|
|
|
2151
2151
|
};
|
|
2152
2152
|
}
|
|
2153
2153
|
function fr(e, t, n) {
|
|
2154
|
-
if (e.state.facet(
|
|
2154
|
+
if (e.state.facet(Le) !== "bar" || e.state.readOnly || e.state.field(cr, !1)) return null;
|
|
2155
2155
|
let r = dr(e);
|
|
2156
2156
|
if (!r) return null;
|
|
2157
2157
|
let { box: i, inCell: a } = r;
|
|
@@ -2185,12 +2185,12 @@ var pr = class {
|
|
|
2185
2185
|
constructor(e) {
|
|
2186
2186
|
this.view = e;
|
|
2187
2187
|
let t = e.dom.ownerDocument;
|
|
2188
|
-
this.ids = e.state.facet(
|
|
2188
|
+
this.ids = e.state.facet(Ie), 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;
|
|
2189
2189
|
for (let n of this.ids) {
|
|
2190
2190
|
let r = _[n], i = t.createElement("button");
|
|
2191
|
-
i.type = "button", i.className = "cm-inplace-selbar-btn", i.title = r.title, i.setAttribute("aria-label", r.title), i.appendChild(
|
|
2191
|
+
i.type = "button", i.className = "cm-inplace-selbar-btn", i.title = r.title, i.setAttribute("aria-label", r.title), i.appendChild(de(t, x[n] ?? "")), i.addEventListener("mousedown", (e) => e.preventDefault()), i.addEventListener("click", (t) => {
|
|
2192
2192
|
t.preventDefault();
|
|
2193
|
-
let a = !!h(e), o = !a && n === "link" ?
|
|
2193
|
+
let a = !!h(e), o = !a && n === "link" ? $t(e) : !a && n === "wikilink" ? en(e) : null;
|
|
2194
2194
|
if (o) {
|
|
2195
2195
|
let e = i.getBoundingClientRect();
|
|
2196
2196
|
this.linkMenu.showField(o, e.left, e.bottom + 6);
|
|
@@ -2202,7 +2202,7 @@ var pr = class {
|
|
|
2202
2202
|
e.dom.appendChild(this.bar), t.addEventListener("scroll", this.onScroll, !0), t.addEventListener("selectionchange", this.onSelectionChange);
|
|
2203
2203
|
}
|
|
2204
2204
|
update(e) {
|
|
2205
|
-
let t = e.startState.field(
|
|
2205
|
+
let t = e.startState.field(cr, !1) !== e.state.field(cr, !1), n = e.startState.readOnly !== e.state.readOnly;
|
|
2206
2206
|
(e.selectionSet || e.docChanged || e.focusChanged || t || n) && this.schedule();
|
|
2207
2207
|
}
|
|
2208
2208
|
schedule() {
|
|
@@ -2227,24 +2227,24 @@ var pr = class {
|
|
|
2227
2227
|
let e = this.view.dom.ownerDocument;
|
|
2228
2228
|
e.removeEventListener("scroll", this.onScroll, !0), e.removeEventListener("selectionchange", this.onSelectionChange), this.linkMenu.destroy(), this.bar.remove();
|
|
2229
2229
|
}
|
|
2230
|
-
}, mr =
|
|
2230
|
+
}, mr = D.fromClass(pr), hr = (e) => (t) => {
|
|
2231
2231
|
if (h(t)) return !1;
|
|
2232
2232
|
let n = t.state.selection.main;
|
|
2233
2233
|
if (!n.empty) return !1;
|
|
2234
2234
|
let { doc: r } = t.state, i = r.lineAt(n.head), a = e ? i.number + 1 : i.number - 1;
|
|
2235
2235
|
if (a < 1 || a > r.lines) return !1;
|
|
2236
2236
|
let o = r.line(a), s = -1, c = -1, l;
|
|
2237
|
-
if (t.state.field(
|
|
2237
|
+
if (t.state.field(Rn).between(o.from, o.to, (t, n, r) => {
|
|
2238
2238
|
if (e ? t === o.from : n === o.to) return s = t, c = n, l = r.spec.widget, !1;
|
|
2239
2239
|
}), s < 0) return !1;
|
|
2240
|
-
if (t.state.facet(
|
|
2240
|
+
if (t.state.facet(I) === "cells") return l instanceof zn && l.focusEdge(e ? "first" : "last");
|
|
2241
2241
|
let u = e ? r.lineAt(s).from : r.lineAt(c).to;
|
|
2242
2242
|
return t.dispatch({
|
|
2243
2243
|
selection: { anchor: u },
|
|
2244
2244
|
userEvent: "select",
|
|
2245
2245
|
scrollIntoView: !0
|
|
2246
2246
|
}), !0;
|
|
2247
|
-
}, gr = hr(!0), _r = hr(!1), vr =
|
|
2247
|
+
}, gr = hr(!0), _r = hr(!1), vr = j.high(k.of([{
|
|
2248
2248
|
key: "ArrowDown",
|
|
2249
2249
|
run: gr
|
|
2250
2250
|
}, {
|
|
@@ -2652,7 +2652,7 @@ var pr = class {
|
|
|
2652
2652
|
},
|
|
2653
2653
|
".cm-inplace-tg-edge:hover .cm-inplace-tg-plus": { color: "var(--stylo-text)" },
|
|
2654
2654
|
"@media (hover: none)": { ".cm-inplace-tg-edge": { opacity: "0.5" } }
|
|
2655
|
-
}, Dr =
|
|
2655
|
+
}, Dr = E.theme({
|
|
2656
2656
|
...Sr,
|
|
2657
2657
|
...yr,
|
|
2658
2658
|
...Tr,
|
|
@@ -2661,37 +2661,37 @@ var pr = class {
|
|
|
2661
2661
|
...wr
|
|
2662
2662
|
}), Or = ".cm-inplace-math, .cm-inplace-hr, .cm-inplace-table, .cm-inplace-embed, .cm-inplace-embed-inline";
|
|
2663
2663
|
function kr(e = {}) {
|
|
2664
|
-
let t =
|
|
2664
|
+
let t = Ne(e.inPlace?.contextMenu);
|
|
2665
2665
|
return [
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2666
|
+
P.of(ke(e.inPlace)),
|
|
2667
|
+
F.of(e.embedRegistry ?? null),
|
|
2668
|
+
I.of(e.inPlace?.table ?? "source"),
|
|
2669
|
+
L.of(e.inPlace?.reveal ?? "caret"),
|
|
2670
|
+
Ae.of(e.onLinkClick ?? null),
|
|
2671
|
+
je.of(t.enabled),
|
|
2672
|
+
Pe.of(t.groups),
|
|
2673
|
+
Le.of(e.inPlace?.selectionUI ?? "menu"),
|
|
2674
|
+
Ie.of(Fe(e.inPlace?.selectionBarItems)),
|
|
2675
|
+
Ct(),
|
|
2676
|
+
Yn,
|
|
2677
|
+
Gt,
|
|
2678
|
+
Pt,
|
|
2679
2679
|
vr,
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2680
|
+
Gn,
|
|
2681
|
+
Vn,
|
|
2682
|
+
Qe,
|
|
2683
|
+
or,
|
|
2684
|
+
ze,
|
|
2685
|
+
Rn,
|
|
2686
|
+
cr,
|
|
2687
2687
|
ur,
|
|
2688
2688
|
mr,
|
|
2689
|
-
|
|
2690
|
-
|
|
2689
|
+
Zn,
|
|
2690
|
+
nr,
|
|
2691
|
+
ln,
|
|
2691
2692
|
un,
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
T.domEventHandlers({
|
|
2693
|
+
j.high(Dr),
|
|
2694
|
+
E.domEventHandlers({
|
|
2695
2695
|
mousedown(e, t) {
|
|
2696
2696
|
let n = e.target;
|
|
2697
2697
|
if (n?.closest(".cm-inplace-table-edit") || n?.closest(".stylo-embed-content")) return !1;
|
|
@@ -2701,8 +2701,8 @@ function kr(e = {}) {
|
|
|
2701
2701
|
if (i < 0) return !1;
|
|
2702
2702
|
let a = n?.closest("[data-stylo-row]");
|
|
2703
2703
|
if (a && r.contains(a)) {
|
|
2704
|
-
let n =
|
|
2705
|
-
n != null && (i = n +
|
|
2704
|
+
let n = v(t.state.doc, i, Number(a.dataset.styloRow), Number(a.dataset.styloCol));
|
|
2705
|
+
n != null && (i = n + ue(a, e.clientX, e.clientY));
|
|
2706
2706
|
}
|
|
2707
2707
|
return t.focus(), t.dispatch({ selection: { anchor: i } }), !0;
|
|
2708
2708
|
},
|
|
@@ -2717,23 +2717,23 @@ function kr(e = {}) {
|
|
|
2717
2717
|
//#endregion
|
|
2718
2718
|
//#region src/inplace/InPlaceView.tsx
|
|
2719
2719
|
var Ar = () => () => {}, jr = () => null;
|
|
2720
|
-
function Mr({ value: e, onChange: t, readOnly: r, placeholder: i, onWikiLinkClick: a, onLinkClick: o, inPlace: s, codeLanguages: c, wikiLinkSource: l, tagSource: u, embedSource: d, onResolveError: f, onSave: p, onViewChange: m, canvasHeader: h }) {
|
|
2721
|
-
let
|
|
2722
|
-
|
|
2723
|
-
let
|
|
2724
|
-
|
|
2725
|
-
let [g] =
|
|
2726
|
-
|
|
2727
|
-
let
|
|
2728
|
-
|
|
2729
|
-
}).current, v =
|
|
2720
|
+
function Mr({ value: e, onChange: t, readOnly: r, placeholder: i, onWikiLinkClick: a, onLinkClick: o, inPlace: s, codeLanguages: c, wikiLinkSource: l, tagSource: u, embedSource: d, onResolveError: f, onSave: p, onViewChange: m, canvasHeader: h, hostExtensions: ee }) {
|
|
2721
|
+
let te = C(a);
|
|
2722
|
+
te.current = a;
|
|
2723
|
+
let re = C(o);
|
|
2724
|
+
re.current = o;
|
|
2725
|
+
let [g] = w(() => new De()), _ = _e(g.subscribe, g.getSnapshot, g.getSnapshot), [ie, ae] = w(null), oe = C(m);
|
|
2726
|
+
oe.current = m;
|
|
2727
|
+
let se = C((e) => {
|
|
2728
|
+
ae(e), oe.current?.(e);
|
|
2729
|
+
}).current, v = C(h);
|
|
2730
2730
|
v.current = h;
|
|
2731
|
-
let [y] =
|
|
2732
|
-
onWikiLinkClick: (e) =>
|
|
2733
|
-
onLinkClick: (e) =>
|
|
2731
|
+
let [y] = w(() => h ? new ne() : null), b = _e(y?.subscribe ?? Ar, y?.getSnapshot ?? jr), [le] = w(() => [kr({
|
|
2732
|
+
onWikiLinkClick: (e) => te.current?.(e),
|
|
2733
|
+
onLinkClick: (e) => re.current?.(e),
|
|
2734
2734
|
inPlace: s,
|
|
2735
2735
|
embedRegistry: d ? g : void 0
|
|
2736
|
-
}), ...y ? [
|
|
2736
|
+
}), ...y ? [ye.of(y.panel)] : []]), ue = ce({
|
|
2737
2737
|
value: e,
|
|
2738
2738
|
onChange: t,
|
|
2739
2739
|
readOnly: r,
|
|
@@ -2744,20 +2744,21 @@ function Mr({ value: e, onChange: t, readOnly: r, placeholder: i, onWikiLinkClic
|
|
|
2744
2744
|
tagSource: u,
|
|
2745
2745
|
onResolveError: f,
|
|
2746
2746
|
onSave: p,
|
|
2747
|
-
onViewChange:
|
|
2747
|
+
onViewChange: se,
|
|
2748
|
+
hostExtensions: ee
|
|
2748
2749
|
});
|
|
2749
|
-
return /* @__PURE__ */
|
|
2750
|
+
return /* @__PURE__ */ Ee("div", {
|
|
2750
2751
|
className: n.inplace,
|
|
2751
2752
|
ref: ue,
|
|
2752
|
-
children: [d &&
|
|
2753
|
+
children: [d && _.map((e) => be(/* @__PURE__ */ Te(me, {
|
|
2753
2754
|
reference: e.ref,
|
|
2754
2755
|
source: d,
|
|
2755
2756
|
onError: f,
|
|
2756
2757
|
inline: e.inline
|
|
2757
|
-
}), e.el, String(e.id))),
|
|
2758
|
+
}), e.el, String(e.id))), b && v.current && be(v.current({ view: ie }), b)]
|
|
2758
2759
|
});
|
|
2759
2760
|
}
|
|
2760
2761
|
//#endregion
|
|
2761
2762
|
export { Mr as InPlaceView };
|
|
2762
2763
|
|
|
2763
|
-
//# sourceMappingURL=InPlaceView-
|
|
2764
|
+
//# sourceMappingURL=InPlaceView-Z8c9cqW8.js.map
|