@damiro/stylo 0.18.0 → 0.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{InPlaceView-Z8c9cqW8.js → InPlaceView-rt6po4_E.js} +694 -612
- package/dist/InPlaceView-rt6po4_E.js.map +1 -0
- package/dist/inplace/InPlaceView.d.ts.map +1 -1
- package/dist/inplace/config.d.ts +8 -1
- package/dist/inplace/config.d.ts.map +1 -1
- package/dist/inplace/context-menu-actions.d.ts +5 -5
- package/dist/inplace/context-menu-actions.d.ts.map +1 -1
- package/dist/inplace/context-menu-types.d.ts +4 -0
- package/dist/inplace/context-menu-types.d.ts.map +1 -1
- package/dist/inplace/context-menu.d.ts.map +1 -1
- package/dist/inplace/extension.d.ts +7 -1
- package/dist/inplace/extension.d.ts.map +1 -1
- package/dist/inplace/host-cell.d.ts +14 -0
- package/dist/inplace/host-cell.d.ts.map +1 -0
- package/dist/inplace/host-items.d.ts +19 -0
- package/dist/inplace/host-items.d.ts.map +1 -0
- package/dist/inplace/menu-plugin.d.ts +9 -1
- package/dist/inplace/menu-plugin.d.ts.map +1 -1
- package/dist/stylo.js +1 -1
- package/dist/types/inplace.d.ts +48 -5
- package/dist/types/inplace.d.ts.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/InPlaceView-Z8c9cqW8.js.map +0 -1
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { l as e, s as t, u as n } from "./embed-cache-BU9Smn-h.js";
|
|
2
|
-
import { C as r, D as i, E as a, O as o, S as s, T as c, _ as l, a as u, b as d, c as f, d as p, f as m, g as h, h as ee, i as te, k as ne, l as re, m as
|
|
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
|
|
2
|
+
import { C as r, D as i, E as a, O as o, S as s, T as c, _ as l, a as u, b as d, c as f, d as p, f as m, g as h, h as ee, i as te, k as ne, l as re, m as ie, n as g, o as ae, p as oe, r as se, s as _, t as ce, u as le, v, w as y, x as ue, y as de } from "./useCodeMirror-Fn6qEfMx.js";
|
|
3
|
+
import { a as fe, i as b } from "./config-DTBxVhtH.js";
|
|
4
|
+
import { a as pe, n as me, o as he, r as ge, t as x } from "./embed-DJAydn-v.js";
|
|
5
|
+
import { t as _e } from "./katex-BfiLlqfN.js";
|
|
6
|
+
import { useRef as S, useState as ve, useSyncExternalStore as ye } from "react";
|
|
7
|
+
import { Decoration as C, EditorView as w, ViewPlugin as T, WidgetType as E, hoverTooltip as be, keymap as D, showPanel as xe } from "@codemirror/view";
|
|
8
|
+
import { createPortal as Se, flushSync as Ce } from "react-dom";
|
|
9
|
+
import { Annotation as we, EditorSelection as Te, EditorState as Ee, Facet as O, Prec as k, StateEffect as De, StateField as A } from "@codemirror/state";
|
|
10
|
+
import { syntaxTree as j } from "@codemirror/language";
|
|
11
|
+
import { jsx as Oe, jsxs as ke } from "react/jsx-runtime";
|
|
12
|
+
import { createRoot as Ae } from "react-dom/client";
|
|
12
13
|
//#region src/inplace/embed-registry.ts
|
|
13
|
-
var
|
|
14
|
+
var je = class {
|
|
14
15
|
slots = /* @__PURE__ */ new Map();
|
|
15
16
|
listeners = /* @__PURE__ */ new Set();
|
|
16
17
|
snapshot = [];
|
|
@@ -33,7 +34,7 @@ var De = class {
|
|
|
33
34
|
for (let e of this.listeners) e();
|
|
34
35
|
}));
|
|
35
36
|
}
|
|
36
|
-
},
|
|
37
|
+
}, Me = {
|
|
37
38
|
headings: !0,
|
|
38
39
|
emphasis: !0,
|
|
39
40
|
links: !0,
|
|
@@ -48,19 +49,20 @@ var De = class {
|
|
|
48
49
|
tables: !0,
|
|
49
50
|
embeds: !0
|
|
50
51
|
};
|
|
51
|
-
function
|
|
52
|
+
function Ne(e) {
|
|
52
53
|
return {
|
|
53
|
-
...
|
|
54
|
+
...Me,
|
|
54
55
|
...e?.decorations
|
|
55
56
|
};
|
|
56
57
|
}
|
|
57
|
-
var
|
|
58
|
+
var M = O.define({ combine: (e) => e[0] ?? Me }), N = O.define({ combine: (e) => e[0] ?? null }), P = O.define({ combine: (e) => e[0] ?? "source" }), F = O.define({ combine: (e) => e[0] ?? "caret" }), Pe = O.define({ combine: (e) => e[0] ?? null }), Fe = O.define({ combine: (e) => e[0] ?? !0 }), Ie = [
|
|
59
|
+
"host",
|
|
58
60
|
"link",
|
|
59
61
|
"format",
|
|
60
62
|
"paragraph",
|
|
61
63
|
"insert",
|
|
62
64
|
"clipboard"
|
|
63
|
-
],
|
|
65
|
+
], I = [
|
|
64
66
|
"bold",
|
|
65
67
|
"italic",
|
|
66
68
|
"strike",
|
|
@@ -69,54 +71,57 @@ var P = A.define({ combine: (e) => e[0] ?? Oe }), F = A.define({ combine: (e) =>
|
|
|
69
71
|
"wikilink",
|
|
70
72
|
"math"
|
|
71
73
|
];
|
|
72
|
-
function
|
|
74
|
+
function Le(e) {
|
|
73
75
|
return e === !1 ? {
|
|
74
76
|
enabled: !1,
|
|
75
|
-
groups: []
|
|
77
|
+
groups: [],
|
|
78
|
+
items: []
|
|
76
79
|
} : e == null || e === !0 ? {
|
|
77
80
|
enabled: !0,
|
|
78
|
-
groups:
|
|
81
|
+
groups: Ie,
|
|
82
|
+
items: []
|
|
79
83
|
} : {
|
|
80
84
|
enabled: !0,
|
|
81
|
-
groups: e.groups?.length ? e.groups :
|
|
85
|
+
groups: e.groups?.length ? e.groups : Ie,
|
|
86
|
+
items: e.items ?? []
|
|
82
87
|
};
|
|
83
88
|
}
|
|
84
|
-
var
|
|
85
|
-
function
|
|
86
|
-
if (!e?.length) return
|
|
87
|
-
let t = e.filter((e) =>
|
|
88
|
-
return t.length ? t :
|
|
89
|
+
var Re = O.define({ combine: (e) => e[0] ?? (() => []) }), L = O.define({ combine: (e) => e[0] ?? Ie });
|
|
90
|
+
function ze(e) {
|
|
91
|
+
if (!e?.length) return I;
|
|
92
|
+
let t = e.filter((e) => I.includes(e));
|
|
93
|
+
return t.length ? t : I;
|
|
89
94
|
}
|
|
90
|
-
var
|
|
95
|
+
var Be = O.define({ combine: (e) => e[0] ?? I }), Ve = O.define({ combine: (e) => e[0] ?? "menu" });
|
|
91
96
|
//#endregion
|
|
92
97
|
//#region src/inplace/frontmatter.ts
|
|
93
|
-
function
|
|
94
|
-
if (!e.facet(
|
|
98
|
+
function He(e) {
|
|
99
|
+
if (!e.facet(M).frontmatter) return C.none;
|
|
95
100
|
let n = t(e.doc);
|
|
96
|
-
if (!n) return
|
|
101
|
+
if (!n) return C.none;
|
|
97
102
|
let r = e.doc.lineAt(n.from).number, i = e.doc.lineAt(n.to).number, a = e.selection.ranges.some((t) => {
|
|
98
103
|
let n = e.doc.lineAt(t.from).number;
|
|
99
104
|
return n >= r && n <= i;
|
|
100
105
|
}), o = [];
|
|
101
106
|
for (let t = r; t <= i; t++) {
|
|
102
107
|
let n = e.doc.line(t), s = t === r ? "cm-inplace-fm cm-inplace-fm-first" : "cm-inplace-fm";
|
|
103
|
-
o.push(
|
|
108
|
+
o.push(C.line({ class: s }).range(n.from)), (t === r || t === i) && !a && n.to > n.from && o.push(C.replace({}).range(n.from, n.to));
|
|
104
109
|
}
|
|
105
|
-
return
|
|
110
|
+
return C.set(o, !0);
|
|
106
111
|
}
|
|
107
|
-
var
|
|
108
|
-
create:
|
|
109
|
-
update: (e, t) => t.docChanged || t.selection ?
|
|
110
|
-
provide: (e) =>
|
|
112
|
+
var Ue = A.define({
|
|
113
|
+
create: He,
|
|
114
|
+
update: (e, t) => t.docChanged || t.selection ? He(t.state) : e,
|
|
115
|
+
provide: (e) => w.decorations.from(e)
|
|
111
116
|
});
|
|
112
117
|
//#endregion
|
|
113
118
|
//#region src/inplace/list-guides.ts
|
|
114
|
-
function
|
|
119
|
+
function We(e) {
|
|
115
120
|
let t = 1;
|
|
116
121
|
for (let n = e.node.parent; n; n = n.parent) n.name === "ListItem" && t++;
|
|
117
122
|
return t;
|
|
118
123
|
}
|
|
119
|
-
function
|
|
124
|
+
function Ge(e, t, n, r, i, a) {
|
|
120
125
|
if (!i.lists) return;
|
|
121
126
|
let o = /* @__PURE__ */ new Set();
|
|
122
127
|
n.iterate({
|
|
@@ -124,17 +129,17 @@ function Ve(e, t, n, r, i, a) {
|
|
|
124
129
|
to: t,
|
|
125
130
|
enter: (e) => {
|
|
126
131
|
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(
|
|
132
|
+
let t = We(e), n = t - 1, i = r.lineAt(e.from).number, s = r.lineAt(Math.min(e.to, r.length)).number, c = e.node.getChild("BulletList") ?? e.node.getChild("OrderedList"), l = c ? r.lineAt(c.from).number : -1, u = c ? r.lineAt(Math.max(c.from, c.to - 1)).number : -1, d = e.node.prevSibling ? "cm-inplace-item-gap" : t > 1 ? "cm-inplace-item-gap-nested" : null;
|
|
133
|
+
for (let e = i; e <= s; e++) c && e >= l && e <= u || (n >= 1 && !o.has(e) && (o.add(e), a.push(C.line({
|
|
129
134
|
class: "cm-inplace-li",
|
|
130
135
|
attributes: { style: `--sl-li-depth:${n}` }
|
|
131
|
-
}).range(r.line(e).from))), e === i && d && a.push(
|
|
136
|
+
}).range(r.line(e).from))), e === i && d && a.push(C.line({ class: d }).range(r.line(e).from)));
|
|
132
137
|
}
|
|
133
138
|
});
|
|
134
139
|
}
|
|
135
140
|
//#endregion
|
|
136
141
|
//#region src/inplace/reveal.ts
|
|
137
|
-
function
|
|
142
|
+
function R(e) {
|
|
138
143
|
let t = /* @__PURE__ */ new Set();
|
|
139
144
|
for (let n of e.selection.ranges) {
|
|
140
145
|
let r = e.doc.lineAt(n.from).number, i = e.doc.lineAt(n.to).number;
|
|
@@ -144,22 +149,22 @@ function z(e) {
|
|
|
144
149
|
}
|
|
145
150
|
//#endregion
|
|
146
151
|
//#region src/inplace/scan.ts
|
|
147
|
-
var
|
|
152
|
+
var Ke = /* @__PURE__ */ new Set([
|
|
148
153
|
"InlineCode",
|
|
149
154
|
"FencedCode",
|
|
150
155
|
"CodeBlock",
|
|
151
156
|
"CodeText"
|
|
152
157
|
]);
|
|
153
|
-
function
|
|
158
|
+
function z(e, t) {
|
|
154
159
|
let n = e.resolveInner(t, 1);
|
|
155
160
|
for (;;) {
|
|
156
|
-
if (
|
|
161
|
+
if (Ke.has(n.name)) return !0;
|
|
157
162
|
let e = n.parent;
|
|
158
163
|
if (!e) return !1;
|
|
159
164
|
n = e;
|
|
160
165
|
}
|
|
161
166
|
}
|
|
162
|
-
function
|
|
167
|
+
function qe(e, t) {
|
|
163
168
|
let n = e.resolveInner(t, 1);
|
|
164
169
|
for (;;) {
|
|
165
170
|
if (n.name === "Table") return !0;
|
|
@@ -168,16 +173,16 @@ function Ue(e, t) {
|
|
|
168
173
|
n = e;
|
|
169
174
|
}
|
|
170
175
|
}
|
|
171
|
-
function
|
|
176
|
+
function Je(e, t, n, r) {
|
|
172
177
|
let i = t.lineAt(n).number, a = t.lineAt(r).number;
|
|
173
178
|
for (let t = i; t <= a; t++) if (e.has(t)) return !0;
|
|
174
179
|
return !1;
|
|
175
180
|
}
|
|
176
181
|
//#endregion
|
|
177
182
|
//#region src/inplace/math.ts
|
|
178
|
-
var
|
|
179
|
-
function
|
|
180
|
-
for (let n of e.matchAll(
|
|
183
|
+
var Ye = /(?<![\w$])\$(?!\s)([^\n$]+?)(?<!\s)\$(?![\w$])/g, Xe = /(?<![\w$])\$\$([^\n$]+?)\$\$(?![\w$])/g, Ze = /(?<![\w$])\$\$([^]+?)\$\$/g;
|
|
184
|
+
function Qe(e, t) {
|
|
185
|
+
for (let n of e.matchAll(Xe)) {
|
|
181
186
|
let e = n.index ?? 0, r = e + (n[0] ?? "").length;
|
|
182
187
|
if (t >= e && t <= r) return {
|
|
183
188
|
from: e,
|
|
@@ -186,7 +191,7 @@ function Je(e, t) {
|
|
|
186
191
|
block: !0
|
|
187
192
|
};
|
|
188
193
|
}
|
|
189
|
-
for (let n of e.matchAll(
|
|
194
|
+
for (let n of e.matchAll(Ye)) {
|
|
190
195
|
let e = n.index ?? 0, r = e + (n[0] ?? "").length;
|
|
191
196
|
if (t >= e && t <= r) return {
|
|
192
197
|
from: e,
|
|
@@ -197,7 +202,7 @@ function Je(e, t) {
|
|
|
197
202
|
}
|
|
198
203
|
return null;
|
|
199
204
|
}
|
|
200
|
-
var
|
|
205
|
+
var $e = class extends E {
|
|
201
206
|
src;
|
|
202
207
|
block;
|
|
203
208
|
constructor(e, t) {
|
|
@@ -210,7 +215,7 @@ var Ye = class extends O {
|
|
|
210
215
|
let e = document.createElement(this.block ? "div" : "span");
|
|
211
216
|
e.className = this.block ? "cm-inplace-math cm-inplace-math-block" : "cm-inplace-math";
|
|
212
217
|
try {
|
|
213
|
-
|
|
218
|
+
_e.render(this.src, e, {
|
|
214
219
|
displayMode: this.block,
|
|
215
220
|
throwOnError: !1
|
|
216
221
|
});
|
|
@@ -223,19 +228,19 @@ var Ye = class extends O {
|
|
|
223
228
|
return !1;
|
|
224
229
|
}
|
|
225
230
|
};
|
|
226
|
-
function
|
|
231
|
+
function et(e, t, n, r, i, a, o) {
|
|
227
232
|
if (!r.includes("$")) return;
|
|
228
233
|
let { doc: s } = e.state, c = [];
|
|
229
|
-
for (let e of r.matchAll(
|
|
234
|
+
for (let e of r.matchAll(Xe)) {
|
|
230
235
|
let n = (e[1] ?? "").trim(), r = t + (e.index ?? 0), l = r + (e[0] ?? "").length;
|
|
231
|
-
!n ||
|
|
236
|
+
!n || z(a, r + 2) || (c.push([r, l]), !Je(i, s, r, l) && o.push(C.replace({ widget: new $e(n, !0) }).range(r, l)));
|
|
232
237
|
}
|
|
233
|
-
for (let e of r.matchAll(
|
|
238
|
+
for (let e of r.matchAll(Ye)) {
|
|
234
239
|
let n = (e[1] ?? "").trim(), r = t + (e.index ?? 0), l = r + (e[0] ?? "").length;
|
|
235
|
-
!n ||
|
|
240
|
+
!n || z(a, r + 1) || c.some(([e, t]) => r >= e && l <= t) || Je(i, s, r, l) || o.push(C.replace({ widget: new $e(n, !1) }).range(r, l));
|
|
236
241
|
}
|
|
237
242
|
}
|
|
238
|
-
function
|
|
243
|
+
function tt(e, t, n) {
|
|
239
244
|
let r = n.map((t) => ({
|
|
240
245
|
first: e.doc.lineAt(t.from).number,
|
|
241
246
|
last: e.doc.lineAt(t.to).number
|
|
@@ -246,44 +251,44 @@ function Ze(e, t, n) {
|
|
|
246
251
|
}
|
|
247
252
|
return !1;
|
|
248
253
|
}
|
|
249
|
-
var
|
|
250
|
-
create:
|
|
254
|
+
var nt = A.define({
|
|
255
|
+
create: rt,
|
|
251
256
|
update(e, t) {
|
|
252
|
-
return t.docChanged || t.selection && (
|
|
257
|
+
return t.docChanged || t.selection && (tt(t.state, t.startState.selection, e.ranges) || tt(t.state, t.state.selection, e.ranges)) ? rt(t.state) : e;
|
|
253
258
|
},
|
|
254
|
-
provide: (e) => [
|
|
259
|
+
provide: (e) => [w.decorations.from(e, (e) => e.decorations), w.atomicRanges.of((t) => t.state.field(e).decorations)]
|
|
255
260
|
});
|
|
256
|
-
function
|
|
257
|
-
if (!e.facet(
|
|
258
|
-
decorations:
|
|
261
|
+
function rt(e) {
|
|
262
|
+
if (!e.facet(M).math) return {
|
|
263
|
+
decorations: C.none,
|
|
259
264
|
ranges: []
|
|
260
265
|
};
|
|
261
266
|
let t = e.doc.toString();
|
|
262
267
|
if (!t.includes("$$")) return {
|
|
263
|
-
decorations:
|
|
268
|
+
decorations: C.none,
|
|
264
269
|
ranges: []
|
|
265
270
|
};
|
|
266
|
-
let n = [], r = [], i =
|
|
267
|
-
for (let o of t.matchAll(
|
|
271
|
+
let n = [], r = [], i = R(e), a = j(e);
|
|
272
|
+
for (let o of t.matchAll(Ze)) {
|
|
268
273
|
let t = o[0] ?? "", s = (o[1] ?? "").trim();
|
|
269
274
|
if (!s || !t.includes("\n")) continue;
|
|
270
275
|
let c = o.index ?? 0, l = c + t.length, u = e.doc.lineAt(c), d = e.doc.lineAt(l), f = e.doc.sliceString(u.from, c).trim(), p = e.doc.sliceString(l, d.to).trim();
|
|
271
|
-
f === "" && p === "" && (
|
|
276
|
+
f === "" && p === "" && (z(a, c + 2) || (r.push({
|
|
272
277
|
from: c,
|
|
273
278
|
to: l
|
|
274
|
-
}), !
|
|
275
|
-
widget: new
|
|
279
|
+
}), !Je(i, e.doc, c, l) && n.push(C.replace({
|
|
280
|
+
widget: new $e(s, !0),
|
|
276
281
|
block: !0
|
|
277
282
|
}).range(c, l))));
|
|
278
283
|
}
|
|
279
284
|
return {
|
|
280
|
-
decorations:
|
|
285
|
+
decorations: C.set(n, !0),
|
|
281
286
|
ranges: r
|
|
282
287
|
};
|
|
283
288
|
}
|
|
284
289
|
//#endregion
|
|
285
290
|
//#region src/inplace/nodes-inline.ts
|
|
286
|
-
var
|
|
291
|
+
var it = {
|
|
287
292
|
StrongEmphasis: {
|
|
288
293
|
mark: "EmphasisMark",
|
|
289
294
|
className: "cm-inplace-strong",
|
|
@@ -305,26 +310,26 @@ var et = {
|
|
|
305
310
|
toggle: "code"
|
|
306
311
|
}
|
|
307
312
|
};
|
|
308
|
-
function
|
|
313
|
+
function at(e, t, n) {
|
|
309
314
|
let { doc: r, revealed: i, out: a, toggles: o } = t;
|
|
310
315
|
if (!o[n.toggle]) return;
|
|
311
316
|
let s = e.node.getChildren(n.mark), c = s[0], l = s[s.length - 1], u = c && l && c !== l, d = u ? c.to : e.from, f = u ? l.from : e.to;
|
|
312
|
-
f > d && a.push(
|
|
317
|
+
f > d && a.push(C.mark({ class: n.className }).range(d, f)), u && !i.has(r.lineAt(e.from).number) && (a.push(C.replace({}).range(c.from, c.to)), a.push(C.replace({}).range(l.from, l.to)));
|
|
313
318
|
}
|
|
314
|
-
function
|
|
319
|
+
function ot(e, t) {
|
|
315
320
|
let { doc: n, revealed: r, out: i, toggles: a } = t, o = n.sliceString(Math.max(0, e.from - 1), e.from), s = n.sliceString(e.to, e.to + 1);
|
|
316
321
|
if (o === "[" && s === "]" || !a.links) return !1;
|
|
317
|
-
let c = n.lineAt(e.from), l =
|
|
322
|
+
let c = n.lineAt(e.from), l = ge.exec(c.text);
|
|
318
323
|
if (l && e.from - c.from < l[1].length + l[2].length) return !1;
|
|
319
324
|
let u = e.node.getChildren("LinkMark");
|
|
320
325
|
if (u.length >= 2) {
|
|
321
326
|
let t = u[0], a = u[1];
|
|
322
|
-
a.from > t.to && i.push(
|
|
327
|
+
a.from > t.to && i.push(C.mark({ class: "cm-inplace-link" }).range(t.to, a.from)), r.has(n.lineAt(e.from).number) || (i.push(C.replace({}).range(e.from, t.to)), i.push(C.replace({}).range(a.from, e.to)));
|
|
323
328
|
}
|
|
324
329
|
}
|
|
325
330
|
//#endregion
|
|
326
331
|
//#region src/inplace/widgets.ts
|
|
327
|
-
var
|
|
332
|
+
var st = class extends E {
|
|
328
333
|
eq() {
|
|
329
334
|
return !0;
|
|
330
335
|
}
|
|
@@ -335,7 +340,7 @@ var rt = class extends O {
|
|
|
335
340
|
ignoreEvent() {
|
|
336
341
|
return !1;
|
|
337
342
|
}
|
|
338
|
-
},
|
|
343
|
+
}, ct = class extends E {
|
|
339
344
|
eq() {
|
|
340
345
|
return !0;
|
|
341
346
|
}
|
|
@@ -346,7 +351,7 @@ var rt = class extends O {
|
|
|
346
351
|
ignoreEvent() {
|
|
347
352
|
return !1;
|
|
348
353
|
}
|
|
349
|
-
},
|
|
354
|
+
}, lt = class extends E {
|
|
350
355
|
checked;
|
|
351
356
|
constructor(e) {
|
|
352
357
|
super(), this.checked = e;
|
|
@@ -368,58 +373,58 @@ var rt = class extends O {
|
|
|
368
373
|
ignoreEvent() {
|
|
369
374
|
return !0;
|
|
370
375
|
}
|
|
371
|
-
},
|
|
372
|
-
function
|
|
376
|
+
}, ut = /^[-*+]$/;
|
|
377
|
+
function dt(e, t) {
|
|
373
378
|
let { doc: n, revealed: r, out: i, toggles: a } = t;
|
|
374
379
|
if (!a.horizontalRule) return !1;
|
|
375
380
|
let o = n.lineAt(e.from);
|
|
376
|
-
return r.has(o.number) || (i.push(
|
|
381
|
+
return r.has(o.number) || (i.push(C.line({ class: "cm-inplace-hr-line" }).range(o.from)), i.push(C.replace({ widget: new st() }).range(o.from, o.to))), !1;
|
|
377
382
|
}
|
|
378
|
-
function
|
|
383
|
+
function ft(e, t) {
|
|
379
384
|
let { doc: n, revealed: r, caretRevealed: i, out: a, toggles: o, quoteRevealed: s } = t;
|
|
380
385
|
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 =
|
|
386
|
+
let t = n.lineAt(e.from).number, o = n.lineAt(Math.min(e.to, n.length)).number, c = n.line(t), l = ge.exec(c.text), u = l ? pe(l[3]) : null, d = !1;
|
|
382
387
|
for (let e = t; e <= o; e++) i.has(e) && (d = !0);
|
|
383
388
|
if (d) for (let e = t; e <= o; e++) s.add(e);
|
|
384
389
|
for (let e = t; e <= o; e++) {
|
|
385
390
|
let r = u ? `cm-inplace-callout cm-inplace-callout-${u}` : "cm-inplace-quote";
|
|
386
391
|
u && e === t && (r += " cm-inplace-callout-head"), u && e === o && (r += " cm-inplace-callout-foot");
|
|
387
392
|
let i = {};
|
|
388
|
-
u && (i["data-callout"] = l[3].toLowerCase()), u && d && (i["data-revealed"] = ""), a.push(
|
|
393
|
+
u && (i["data-callout"] = l[3].toLowerCase()), u && d && (i["data-revealed"] = ""), a.push(C.line({
|
|
389
394
|
class: r,
|
|
390
395
|
attributes: i
|
|
391
396
|
}).range(n.line(e).from));
|
|
392
397
|
}
|
|
393
398
|
if (u && !d && !r.has(t)) {
|
|
394
399
|
let e = c.from + l[1].length;
|
|
395
|
-
a.push(
|
|
400
|
+
a.push(C.replace({}).range(e, e + l[2].length));
|
|
396
401
|
}
|
|
397
402
|
}
|
|
398
403
|
}
|
|
399
|
-
function
|
|
404
|
+
function pt(e, t) {
|
|
400
405
|
let { doc: n, revealed: r, out: i, toggles: a, quoteRevealed: o } = t;
|
|
401
406
|
if (!a.blockquote) return !1;
|
|
402
407
|
let s = n.lineAt(e.from);
|
|
403
408
|
if (!r.has(s.number) && !o.has(s.number)) {
|
|
404
|
-
let t = Math.min(e.to + 1, s.to), n =
|
|
405
|
-
i.push(
|
|
409
|
+
let t = Math.min(e.to + 1, s.to), n = ge.exec(s.text), r = n ? s.text.slice(n[1].length + n[2].length) : s.text.slice(t - s.from);
|
|
410
|
+
i.push(C.replace({}).range(e.from, r.trim() === "" ? e.to : t));
|
|
406
411
|
}
|
|
407
412
|
return !1;
|
|
408
413
|
}
|
|
409
|
-
function
|
|
414
|
+
function mt(e, t) {
|
|
410
415
|
let { doc: n, revealed: r, out: i, toggles: a } = t, o = n.sliceString(e.from, e.to), s = n.lineAt(e.from), c = e.node.parent, l = !!(c?.getChild("Task") ?? c?.getChild("TaskMarker"));
|
|
411
|
-
return r.has(s.number) || (l ? a.tasks && i.push(
|
|
416
|
+
return r.has(s.number) || (l ? a.tasks && i.push(C.replace({}).range(e.from, Math.min(e.to + 1, s.to))) : a.lists && ut.test(o) && i.push(C.replace({ widget: new ct() }).range(e.from, e.to))), !1;
|
|
412
417
|
}
|
|
413
|
-
function
|
|
418
|
+
function ht(e, t) {
|
|
414
419
|
let { doc: n, revealed: r, out: i, toggles: a } = t;
|
|
415
420
|
if (!a.tasks) return !1;
|
|
416
421
|
if (!r.has(n.lineAt(e.from).number)) {
|
|
417
422
|
let t = n.sliceString(e.from + 1, e.to - 1).toLowerCase() === "x";
|
|
418
|
-
i.push(
|
|
423
|
+
i.push(C.replace({ widget: new lt(t) }).range(e.from, e.to));
|
|
419
424
|
}
|
|
420
425
|
return !1;
|
|
421
426
|
}
|
|
422
|
-
function
|
|
427
|
+
function gt(e, t) {
|
|
423
428
|
let { doc: n, revealed: r, caretRevealed: i, out: a, toggles: o } = t;
|
|
424
429
|
if (!o.code) return !1;
|
|
425
430
|
let s = e.name === "FencedCode", c = n.lineAt(e.from).number, l = n.lineAt(e.to > e.from ? e.to - 1 : e.to).number, u = l > c + 1, d = !1;
|
|
@@ -429,18 +434,18 @@ function ft(e, t) {
|
|
|
429
434
|
let t = s && (e === c || e === l), r = "cm-inplace-mono";
|
|
430
435
|
e === c && (r += " cm-inplace-code-top"), e === l && (r += " cm-inplace-code-bottom"), t && (r += f ? " cm-inplace-code-pad" : " cm-inplace-fence");
|
|
431
436
|
let i = n.line(e);
|
|
432
|
-
a.push(
|
|
437
|
+
a.push(C.line({ class: r }).range(i.from)), t && f && i.to > i.from && a.push(C.replace({}).range(i.from, i.to));
|
|
433
438
|
}
|
|
434
439
|
return !1;
|
|
435
440
|
}
|
|
436
441
|
//#endregion
|
|
437
442
|
//#region src/inplace/nodes.ts
|
|
438
|
-
var
|
|
439
|
-
function
|
|
443
|
+
var _t = /^ATXHeading([1-6])$/, vt = /^SetextHeading([12])$/;
|
|
444
|
+
function yt(e, t, n) {
|
|
440
445
|
let { doc: r, revealed: i, out: a, toggles: o } = t;
|
|
441
446
|
if (o.headings) {
|
|
442
447
|
let t = r.lineAt(e.from);
|
|
443
|
-
if (a.push(
|
|
448
|
+
if (a.push(C.line({
|
|
444
449
|
class: `cm-inplace-heading cm-inplace-h${n}`,
|
|
445
450
|
attributes: {
|
|
446
451
|
role: "heading",
|
|
@@ -448,15 +453,15 @@ function ht(e, t, n) {
|
|
|
448
453
|
}
|
|
449
454
|
}).range(t.from)), !i.has(t.number)) {
|
|
450
455
|
let n = e.node.firstChild;
|
|
451
|
-
n?.name === "HeaderMark" && a.push(
|
|
456
|
+
n?.name === "HeaderMark" && a.push(C.replace({}).range(n.from, Math.min(n.to + 1, t.to)));
|
|
452
457
|
}
|
|
453
458
|
}
|
|
454
459
|
}
|
|
455
|
-
function
|
|
460
|
+
function bt(e, t, n) {
|
|
456
461
|
let { doc: r, caretRevealed: i, out: a, toggles: o } = t;
|
|
457
462
|
if (o.headings) {
|
|
458
463
|
let t = r.lineAt(e.from);
|
|
459
|
-
a.push(
|
|
464
|
+
a.push(C.line({
|
|
460
465
|
class: `cm-inplace-heading cm-inplace-h${n}`,
|
|
461
466
|
attributes: {
|
|
462
467
|
role: "heading",
|
|
@@ -466,46 +471,46 @@ function gt(e, t, n) {
|
|
|
466
471
|
let o = e.node.getChild("HeaderMark");
|
|
467
472
|
if (o) {
|
|
468
473
|
let e = r.lineAt(o.from);
|
|
469
|
-
!i.has(t.number) && !i.has(e.number) && (a.push(
|
|
474
|
+
!i.has(t.number) && !i.has(e.number) && (a.push(C.line({ class: "cm-inplace-setext-rule" }).range(e.from)), a.push(C.replace({}).range(o.from, o.to)));
|
|
470
475
|
}
|
|
471
476
|
}
|
|
472
477
|
}
|
|
473
|
-
function
|
|
478
|
+
function xt(e, t) {
|
|
474
479
|
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
|
|
480
|
+
let n = _t.exec(e.name);
|
|
481
|
+
if (n) return yt(e, t, n[1]);
|
|
482
|
+
let r = vt.exec(e.name);
|
|
483
|
+
if (r) return bt(e, t, r[1]);
|
|
484
|
+
let i = it[e.name];
|
|
485
|
+
if (i) return at(e, t, i);
|
|
486
|
+
if (e.name === "Link") return ot(e, t);
|
|
487
|
+
if (e.name === "HorizontalRule") return dt(e, t);
|
|
488
|
+
if (e.name === "Blockquote") return ft(e, t);
|
|
489
|
+
if (e.name === "QuoteMark") return pt(e, t);
|
|
490
|
+
if (e.name === "ListMark") return mt(e, t);
|
|
491
|
+
if (e.name === "TaskMarker") return ht(e, t);
|
|
492
|
+
if (e.name === "FencedCode" || e.name === "CodeBlock") return gt(e, t);
|
|
488
493
|
}
|
|
489
494
|
//#endregion
|
|
490
495
|
//#region src/inplace/wikilinks.ts
|
|
491
|
-
function
|
|
496
|
+
function St(t, n, r, i, a, o, s) {
|
|
492
497
|
if (!i.includes("[[")) return;
|
|
493
|
-
let c = t.state.facet(
|
|
498
|
+
let c = t.state.facet(N) != null;
|
|
494
499
|
for (let r of i.matchAll(e)) {
|
|
495
500
|
let [e = "", i = "", l] = r, u = i.trim(), d = n + (r.index ?? 0);
|
|
496
|
-
if (!u ||
|
|
501
|
+
if (!u || z(o, d + 1) || c && d > 0 && t.state.doc.sliceString(d - 1, d) === "!") continue;
|
|
497
502
|
let f = d + e.length, p = l == null ? d + 2 : d + 2 + i.length + 1, m = f - 2;
|
|
498
|
-
s.push(
|
|
503
|
+
s.push(C.mark({
|
|
499
504
|
class: "cm-inplace-link cm-inplace-wikilink",
|
|
500
505
|
attributes: { "data-stylo-wikilink": u }
|
|
501
|
-
}).range(p, m)), a.has(t.state.doc.lineAt(d).number) || (s.push(
|
|
506
|
+
}).range(p, m)), a.has(t.state.doc.lineAt(d).number) || (s.push(C.replace({}).range(d, p)), s.push(C.replace({}).range(m, f)));
|
|
502
507
|
}
|
|
503
508
|
}
|
|
504
509
|
//#endregion
|
|
505
510
|
//#region src/inplace/decorate.ts
|
|
506
|
-
var
|
|
507
|
-
function
|
|
508
|
-
let n = [], r =
|
|
511
|
+
var Ct = /* @__PURE__ */ new Set(), wt = C.replace({});
|
|
512
|
+
function Tt(e) {
|
|
513
|
+
let n = [], r = R(e.state), i = e.state.facet(F) === "never" ? Ct : r, a = j(e.state), { doc: o } = e.state, s = e.state.facet(M), c = {
|
|
509
514
|
doc: o,
|
|
510
515
|
revealed: i,
|
|
511
516
|
caretRevealed: r,
|
|
@@ -518,10 +523,10 @@ function xt(e) {
|
|
|
518
523
|
a.iterate({
|
|
519
524
|
from: t.from,
|
|
520
525
|
to: t.to,
|
|
521
|
-
enter: (e) =>
|
|
526
|
+
enter: (e) => xt(e, c)
|
|
522
527
|
});
|
|
523
528
|
let r = e.state.doc.sliceString(t.from, t.to);
|
|
524
|
-
s.wikilinks &&
|
|
529
|
+
s.wikilinks && St(e, t.from, t.to, r, i, a, n), s.math && et(e, t.from, t.to, r, i, a, n), Ge(t.from, t.to, a, o, s, n);
|
|
525
530
|
}
|
|
526
531
|
let l = n.filter((e) => e.from < e.to && !e.value.spec.class).sort((e, t) => e.from - t.from || e.to - t.to), u = [];
|
|
527
532
|
for (let e of l) {
|
|
@@ -530,38 +535,38 @@ function xt(e) {
|
|
|
530
535
|
if (e.from === t.from && e.to === t.to) continue;
|
|
531
536
|
}
|
|
532
537
|
let t = u[u.length - 1];
|
|
533
|
-
t && e.from <= t.to ? e.to > t.to && (u[u.length - 1] =
|
|
538
|
+
t && e.from <= t.to ? e.to > t.to && (u[u.length - 1] = wt.range(t.from, e.to)) : u.push(wt.range(e.from, e.to));
|
|
534
539
|
}
|
|
535
540
|
return {
|
|
536
|
-
decorations:
|
|
537
|
-
atomic:
|
|
541
|
+
decorations: C.set(n, !0),
|
|
542
|
+
atomic: C.set(u, !0)
|
|
538
543
|
};
|
|
539
544
|
}
|
|
540
545
|
//#endregion
|
|
541
546
|
//#region src/inplace/plugin.ts
|
|
542
|
-
var
|
|
547
|
+
var Et = T.fromClass(class {
|
|
543
548
|
decorations;
|
|
544
549
|
atomic;
|
|
545
550
|
constructor(e) {
|
|
546
|
-
let t =
|
|
551
|
+
let t = Tt(e);
|
|
547
552
|
this.decorations = t.decorations, this.atomic = t.atomic;
|
|
548
553
|
}
|
|
549
554
|
update(e) {
|
|
550
555
|
if (e.docChanged || e.viewportChanged || e.selectionSet) {
|
|
551
|
-
let t =
|
|
556
|
+
let t = Tt(e.view);
|
|
552
557
|
this.decorations = t.decorations, this.atomic = t.atomic;
|
|
553
558
|
}
|
|
554
559
|
}
|
|
555
560
|
}, {
|
|
556
561
|
decorations: (e) => e.decorations,
|
|
557
|
-
provide: (e) =>
|
|
562
|
+
provide: (e) => w.atomicRanges.of((t) => t.plugin(e)?.atomic ?? C.none)
|
|
558
563
|
});
|
|
559
|
-
function
|
|
560
|
-
return
|
|
564
|
+
function Dt() {
|
|
565
|
+
return Et;
|
|
561
566
|
}
|
|
562
567
|
//#endregion
|
|
563
568
|
//#region src/inplace/wrap-at.ts
|
|
564
|
-
var
|
|
569
|
+
var Ot = {
|
|
565
570
|
StrongEmphasis: {
|
|
566
571
|
markType: "EmphasisMark",
|
|
567
572
|
toggle: "emphasis"
|
|
@@ -579,15 +584,15 @@ var wt = {
|
|
|
579
584
|
toggle: "code"
|
|
580
585
|
}
|
|
581
586
|
};
|
|
582
|
-
function
|
|
583
|
-
return e.facet(
|
|
587
|
+
function B(e, t) {
|
|
588
|
+
return e.facet(F) === "never" || !R(e).has(t);
|
|
584
589
|
}
|
|
585
|
-
function
|
|
590
|
+
function V(t, n, r = !1, i = !1) {
|
|
586
591
|
let a = t.doc.lineAt(n);
|
|
587
|
-
if (!i && !
|
|
588
|
-
let o = t.facet(
|
|
592
|
+
if (!i && !B(t, a.number)) return null;
|
|
593
|
+
let o = t.facet(M), s = j(t);
|
|
589
594
|
for (let e of [-1, 1]) for (let i = s.resolveInner(n, e); i; i = i.parent) {
|
|
590
|
-
let e =
|
|
595
|
+
let e = Ot[i.name];
|
|
591
596
|
if (e) {
|
|
592
597
|
if (!o[e.toggle]) break;
|
|
593
598
|
let t = i.getChildren(e.markType), n = t[0], r = t[t.length - 1];
|
|
@@ -629,8 +634,8 @@ function H(t, n, r = !1, i = !1) {
|
|
|
629
634
|
}
|
|
630
635
|
//#endregion
|
|
631
636
|
//#region src/inplace/edit-boundaries.ts
|
|
632
|
-
function
|
|
633
|
-
let r = e.plugin(
|
|
637
|
+
function kt(e, t, n) {
|
|
638
|
+
let r = e.plugin(Et)?.decorations;
|
|
634
639
|
if (!r) return t;
|
|
635
640
|
let i = n < 0 ? 0 : e.state.doc.length, a = t;
|
|
636
641
|
for (let e = !0; e;) e = !1, r.between(Math.min(a, i), Math.max(a, i), (t, r, i) => {
|
|
@@ -638,18 +643,18 @@ function Tt(e, t, n) {
|
|
|
638
643
|
});
|
|
639
644
|
return a;
|
|
640
645
|
}
|
|
641
|
-
var
|
|
646
|
+
var At = (e) => (t) => {
|
|
642
647
|
if (h(t)) return !1;
|
|
643
648
|
let n = t.state.selection.main;
|
|
644
649
|
if (!n.empty) return !1;
|
|
645
650
|
let { state: r } = t;
|
|
646
|
-
if (!
|
|
647
|
-
let i =
|
|
651
|
+
if (!B(r, r.doc.lineAt(n.head).number)) return !1;
|
|
652
|
+
let i = kt(t, n.head, e);
|
|
648
653
|
if (i === n.head) return !1;
|
|
649
654
|
let a = r.doc;
|
|
650
655
|
if (e < 0 ? i <= 0 : i >= a.length) return !0;
|
|
651
656
|
let o = e < 0 ? i - 1 : i, s = e < 0 ? i : i + 1;
|
|
652
|
-
for (let e =
|
|
657
|
+
for (let e = V(r, o); e && o <= e.contentFrom && s >= e.contentTo && e.contentTo > e.contentFrom && !(e.from >= o && e.to <= s); e = V(r, o)) o = Math.min(o, e.from), s = Math.max(s, e.to);
|
|
653
658
|
return t.dispatch({
|
|
654
659
|
changes: {
|
|
655
660
|
from: o,
|
|
@@ -660,89 +665,89 @@ var Et = (e) => (t) => {
|
|
|
660
665
|
userEvent: e < 0 ? "delete.backward" : "delete.forward",
|
|
661
666
|
scrollIntoView: !0
|
|
662
667
|
}), !0;
|
|
663
|
-
},
|
|
664
|
-
function
|
|
668
|
+
}, jt = At(-1), Mt = At(1);
|
|
669
|
+
function Nt(e, t, n) {
|
|
665
670
|
if (n <= t) return !1;
|
|
666
|
-
let r = e.plugin(
|
|
671
|
+
let r = e.plugin(Et)?.decorations;
|
|
667
672
|
if (!r) return !1;
|
|
668
673
|
let i = t;
|
|
669
674
|
return r.between(t, n, (e, t, n) => {
|
|
670
675
|
n.spec.widget || n.spec.class || t <= e || e <= i && (i = Math.max(i, t));
|
|
671
676
|
}), i >= n;
|
|
672
677
|
}
|
|
673
|
-
var
|
|
678
|
+
var H = (e, t) => (n) => {
|
|
674
679
|
if (h(n)) return !1;
|
|
675
680
|
let r = n.state.selection.main;
|
|
676
|
-
if (!t && !r.empty || !
|
|
681
|
+
if (!t && !r.empty || !B(n.state, n.state.doc.lineAt(r.head).number)) return !1;
|
|
677
682
|
let i = n.moveByChar(r, e);
|
|
678
|
-
if (
|
|
679
|
-
let a = t ?
|
|
683
|
+
if (Nt(n, Math.min(r.head, i.head), Math.max(r.head, i.head)) && (i = n.moveByChar(i, e)), i.head === r.head) return !1;
|
|
684
|
+
let a = t ? Te.range(r.anchor, i.head) : Te.cursor(i.head);
|
|
680
685
|
return n.dispatch({
|
|
681
686
|
selection: a,
|
|
682
687
|
userEvent: "select"
|
|
683
688
|
}), !0;
|
|
684
|
-
},
|
|
689
|
+
}, Pt = H(!1, !1), Ft = H(!0, !1), It = H(!1, !0), Lt = H(!0, !0), Rt = k.high(D.of([
|
|
685
690
|
{
|
|
686
691
|
key: "Backspace",
|
|
687
|
-
run:
|
|
692
|
+
run: jt
|
|
688
693
|
},
|
|
689
694
|
{
|
|
690
695
|
key: "Delete",
|
|
691
|
-
run:
|
|
696
|
+
run: Mt
|
|
692
697
|
},
|
|
693
698
|
{
|
|
694
699
|
key: "ArrowLeft",
|
|
695
|
-
run:
|
|
700
|
+
run: Pt
|
|
696
701
|
},
|
|
697
702
|
{
|
|
698
703
|
key: "ArrowRight",
|
|
699
|
-
run:
|
|
704
|
+
run: Ft
|
|
700
705
|
},
|
|
701
706
|
{
|
|
702
707
|
key: "Shift-ArrowLeft",
|
|
703
|
-
run:
|
|
708
|
+
run: It
|
|
704
709
|
},
|
|
705
710
|
{
|
|
706
711
|
key: "Shift-ArrowRight",
|
|
707
|
-
run:
|
|
712
|
+
run: Lt
|
|
708
713
|
}
|
|
709
|
-
])),
|
|
714
|
+
])), zt = (e) => e === "h1" || e === "h2" || e === "h3" ? b.heading : b[e], Bt = [
|
|
710
715
|
"bold",
|
|
711
716
|
"italic",
|
|
712
717
|
"strike"
|
|
713
|
-
],
|
|
718
|
+
], Vt = ["code", "math"], Ht = [
|
|
714
719
|
"bulletList",
|
|
715
720
|
"orderedList",
|
|
716
721
|
"task"
|
|
717
|
-
],
|
|
722
|
+
], Ut = [
|
|
718
723
|
"h1",
|
|
719
724
|
"h2",
|
|
720
725
|
"h3"
|
|
721
|
-
],
|
|
726
|
+
], Wt = ["table", "hr"], Gt = [
|
|
722
727
|
"codeBlock",
|
|
723
728
|
"mathBlock",
|
|
724
729
|
"frontmatter"
|
|
725
|
-
],
|
|
726
|
-
let r =
|
|
730
|
+
], Kt = (e, t, n = !1) => {
|
|
731
|
+
let r = g[t];
|
|
727
732
|
if (!r) return null;
|
|
728
733
|
let { disabled: i, active: a } = re(e.state, r, n);
|
|
729
734
|
return {
|
|
730
735
|
label: r.title,
|
|
731
|
-
icon:
|
|
736
|
+
icon: zt(t),
|
|
732
737
|
active: a,
|
|
733
738
|
disabled: i,
|
|
734
739
|
onSelect: () => {
|
|
735
740
|
r.run(e), e.focus();
|
|
736
741
|
}
|
|
737
742
|
};
|
|
738
|
-
},
|
|
743
|
+
}, U = (e, t, n = !1, r = !1) => {
|
|
739
744
|
let i = [];
|
|
740
745
|
for (let a of t) {
|
|
741
|
-
let t =
|
|
746
|
+
let t = Kt(e, a, r);
|
|
742
747
|
t && !(n && t.disabled) && i.push(t);
|
|
743
748
|
}
|
|
744
749
|
return i;
|
|
745
|
-
},
|
|
750
|
+
}, W = (e) => {
|
|
746
751
|
let t = e.contentDOM.ownerDocument, n = (n) => () => {
|
|
747
752
|
e.focus();
|
|
748
753
|
try {
|
|
@@ -752,17 +757,17 @@ var U = (e, t) => (n) => {
|
|
|
752
757
|
return [
|
|
753
758
|
{
|
|
754
759
|
label: "Cut",
|
|
755
|
-
icon:
|
|
760
|
+
icon: b.cut,
|
|
756
761
|
onSelect: n("cut")
|
|
757
762
|
},
|
|
758
763
|
{
|
|
759
764
|
label: "Copy",
|
|
760
|
-
icon:
|
|
765
|
+
icon: b.copy,
|
|
761
766
|
onSelect: n("copy")
|
|
762
767
|
},
|
|
763
768
|
i ? {
|
|
764
769
|
label: "Paste",
|
|
765
|
-
icon:
|
|
770
|
+
icon: b.paste,
|
|
766
771
|
onSelect: () => {
|
|
767
772
|
let n = h(e);
|
|
768
773
|
n || e.focus(), r?.readText().then((r) => {
|
|
@@ -771,57 +776,267 @@ var U = (e, t) => (n) => {
|
|
|
771
776
|
}
|
|
772
777
|
} : {
|
|
773
778
|
label: "Paste",
|
|
774
|
-
icon:
|
|
779
|
+
icon: b.paste,
|
|
775
780
|
disabled: !0,
|
|
776
781
|
title: "Paste with the keyboard shortcut",
|
|
777
782
|
onSelect: () => {}
|
|
778
783
|
}
|
|
779
784
|
];
|
|
780
|
-
},
|
|
785
|
+
}, G = (e, t, n, r = !1) => ({
|
|
781
786
|
label: e,
|
|
782
787
|
icon: t,
|
|
783
788
|
rows: n,
|
|
784
789
|
disabled: r
|
|
785
790
|
});
|
|
786
|
-
function
|
|
791
|
+
function K(e, t) {
|
|
787
792
|
t.length && (e.length && e.push("separator"), e.push(...t));
|
|
788
793
|
}
|
|
789
794
|
//#endregion
|
|
790
795
|
//#region src/inplace/edit-divider.ts
|
|
791
|
-
function
|
|
796
|
+
function qt(e) {
|
|
792
797
|
let t = e.selection.main;
|
|
793
798
|
if (!t.empty) return !1;
|
|
794
799
|
let n = e.doc.lineAt(t.head);
|
|
795
|
-
if (!
|
|
796
|
-
for (let t =
|
|
800
|
+
if (!B(e, n.number)) return !1;
|
|
801
|
+
for (let t = j(e).resolveInner(n.from, 1); t; t = t.parent) {
|
|
797
802
|
if (t.name === "HorizontalRule") return !0;
|
|
798
803
|
if (!t.parent) break;
|
|
799
804
|
}
|
|
800
805
|
return !1;
|
|
801
806
|
}
|
|
802
|
-
var
|
|
807
|
+
var Jt = (e) => h(e) || !qt(e.state) ? !1 : se(e), Yt = k.high(D.of([{
|
|
803
808
|
key: "Backspace",
|
|
804
|
-
run:
|
|
809
|
+
run: Jt
|
|
805
810
|
}, {
|
|
806
811
|
key: "Delete",
|
|
807
|
-
run:
|
|
812
|
+
run: Jt
|
|
808
813
|
}]));
|
|
809
|
-
function
|
|
814
|
+
function Xt(e) {
|
|
810
815
|
return {
|
|
811
816
|
label: "Remove divider",
|
|
812
|
-
icon:
|
|
817
|
+
icon: b.hr,
|
|
813
818
|
onSelect: () => {
|
|
814
|
-
|
|
819
|
+
g.hr?.run(e), e.focus();
|
|
815
820
|
}
|
|
816
821
|
};
|
|
817
822
|
}
|
|
818
823
|
//#endregion
|
|
824
|
+
//#region src/inplace/inline-md.ts
|
|
825
|
+
function Zt(e, t = !1) {
|
|
826
|
+
let n = document.createDocumentFragment();
|
|
827
|
+
return en(n, e, t), n;
|
|
828
|
+
}
|
|
829
|
+
var Qt = /!\[\[[^\]\n]+?\]\]/, $t = [
|
|
830
|
+
{
|
|
831
|
+
re: /`([^`\n]+)`/,
|
|
832
|
+
build: (e) => q("code", "cm-inplace-code", document.createTextNode(e[1]))
|
|
833
|
+
},
|
|
834
|
+
{
|
|
835
|
+
re: new RegExp(Ye.source),
|
|
836
|
+
build: (e) => {
|
|
837
|
+
let t = q("span", "cm-inplace-math");
|
|
838
|
+
return _e.render(e[1], t, { throwOnError: !1 }), t;
|
|
839
|
+
}
|
|
840
|
+
},
|
|
841
|
+
{
|
|
842
|
+
re: new RegExp(e.source),
|
|
843
|
+
build: (e) => {
|
|
844
|
+
let t = q("span", "cm-inplace-wikilink", document.createTextNode(e[2] || e[1] || ""));
|
|
845
|
+
return t.dataset.styloWikilink = e[1] ?? "", t;
|
|
846
|
+
}
|
|
847
|
+
},
|
|
848
|
+
{
|
|
849
|
+
re: /\[([^\]\n]*)\]\(([^)\n]*)\)/,
|
|
850
|
+
build: (e, t) => {
|
|
851
|
+
let n = q("a", "cm-inplace-link");
|
|
852
|
+
return n.href = e[2] ?? "", n.append(J(e[1] ?? "", t)), n;
|
|
853
|
+
}
|
|
854
|
+
},
|
|
855
|
+
{
|
|
856
|
+
re: /\*\*\*([^*\n]+?)\*\*\*/,
|
|
857
|
+
build: (e, t) => q("strong", "cm-inplace-strong", q("em", "cm-inplace-em", J(e[1], t)))
|
|
858
|
+
},
|
|
859
|
+
{
|
|
860
|
+
re: /\*\*([^\n]+?)\*\*/,
|
|
861
|
+
build: (e, t) => q("strong", "cm-inplace-strong", J(e[1], t))
|
|
862
|
+
},
|
|
863
|
+
{
|
|
864
|
+
re: /~~([^\n]+?)~~/,
|
|
865
|
+
build: (e, t) => q("span", "cm-inplace-strike", J(e[1], t))
|
|
866
|
+
},
|
|
867
|
+
{
|
|
868
|
+
re: /(?<!\*)\*(?!\*|\s)([^\n]+?)(?<!\s)\*(?!\*)/,
|
|
869
|
+
build: (e, t) => q("em", "cm-inplace-em", J(e[1], t))
|
|
870
|
+
}
|
|
871
|
+
];
|
|
872
|
+
function q(e, t, ...n) {
|
|
873
|
+
let r = document.createElement(e);
|
|
874
|
+
return r.className = t, r.append(...n), r;
|
|
875
|
+
}
|
|
876
|
+
function J(e, t) {
|
|
877
|
+
let n = document.createDocumentFragment();
|
|
878
|
+
return en(n, e, t), n;
|
|
879
|
+
}
|
|
880
|
+
function en(e, t, n) {
|
|
881
|
+
for (; t;) {
|
|
882
|
+
let r = -1, i = null, a = n ? Qt.exec(t) : null;
|
|
883
|
+
a && (r = a.index, i = { literal: a[0] });
|
|
884
|
+
for (let e of $t) {
|
|
885
|
+
let n = e.re.exec(t);
|
|
886
|
+
n && (r < 0 || n.index < r) && (r = n.index, i = {
|
|
887
|
+
rule: e,
|
|
888
|
+
m: n
|
|
889
|
+
});
|
|
890
|
+
}
|
|
891
|
+
if (!i) {
|
|
892
|
+
e.appendChild(document.createTextNode(t));
|
|
893
|
+
return;
|
|
894
|
+
}
|
|
895
|
+
r > 0 && e.appendChild(document.createTextNode(t.slice(0, r))), "literal" in i ? (e.appendChild(document.createTextNode(i.literal)), t = t.slice(r + i.literal.length)) : (e.appendChild(i.rule.build(i.m, n)), t = t.slice(r + i.m[0].length));
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
//#endregion
|
|
899
|
+
//#region src/inplace/tables.ts
|
|
900
|
+
var tn = class extends E {
|
|
901
|
+
table;
|
|
902
|
+
embeds;
|
|
903
|
+
constructor(e, t) {
|
|
904
|
+
super(), this.table = e, this.embeds = t;
|
|
905
|
+
}
|
|
906
|
+
eq(e) {
|
|
907
|
+
return JSON.stringify(this.table) === JSON.stringify(e.table);
|
|
908
|
+
}
|
|
909
|
+
toDOM() {
|
|
910
|
+
let { head: e, body: t, aligns: n } = this.table, r = document.createElement("table");
|
|
911
|
+
r.className = "cm-inplace-table";
|
|
912
|
+
let i = (e) => Zt(e.replace(/\\\|/g, "|"), this.embeds), a = r.createTHead().insertRow();
|
|
913
|
+
e.forEach((e, t) => {
|
|
914
|
+
let r = document.createElement("th");
|
|
915
|
+
r.appendChild(i(e)), r.dataset.styloRow = "0", r.dataset.styloCol = String(t), nn(r, n[t]), a.appendChild(r);
|
|
916
|
+
});
|
|
917
|
+
let o = r.createTBody();
|
|
918
|
+
return t.forEach((t, r) => {
|
|
919
|
+
let a = o.insertRow();
|
|
920
|
+
for (let o = 0; o < e.length; o++) {
|
|
921
|
+
let e = a.insertCell();
|
|
922
|
+
e.appendChild(i(t[o] ?? "")), e.dataset.styloRow = String(r + 1), e.dataset.styloCol = String(o), nn(e, n[o]);
|
|
923
|
+
}
|
|
924
|
+
}), r;
|
|
925
|
+
}
|
|
926
|
+
ignoreEvent() {
|
|
927
|
+
return !1;
|
|
928
|
+
}
|
|
929
|
+
};
|
|
930
|
+
function nn(e, t) {
|
|
931
|
+
t && (e.style.textAlign = t);
|
|
932
|
+
}
|
|
933
|
+
function rn(e, t) {
|
|
934
|
+
let n = t.lineAt(e.from).number, r = t.lineAt(e.to).number, i = [];
|
|
935
|
+
for (let e = n; e <= r; e++) i.push(t.line(e).text);
|
|
936
|
+
let a = p(i);
|
|
937
|
+
return !a || a.rows.length === 0 ? null : {
|
|
938
|
+
head: a.rows[0],
|
|
939
|
+
body: a.rows.slice(1),
|
|
940
|
+
aligns: a.aligns
|
|
941
|
+
};
|
|
942
|
+
}
|
|
943
|
+
function an(e, t) {
|
|
944
|
+
let n = j(e);
|
|
945
|
+
for (let e of [-1, 1]) for (let r = n.resolveInner(t, e); r; r = r.parent) if (r.name === "Table") return !0;
|
|
946
|
+
return !1;
|
|
947
|
+
}
|
|
948
|
+
function on(e, t) {
|
|
949
|
+
return t.ranges.some((t) => an(e, t.from) || an(e, t.to));
|
|
950
|
+
}
|
|
951
|
+
function sn(e) {
|
|
952
|
+
if (!e.facet(M).tables) return C.none;
|
|
953
|
+
let n = e.facet(P) === "cells" && !e.readOnly, r = e.facet(N) != null && e.facet(M).embeds, i = j(e), a = t(e.doc), o = n ? null : R(e), s = [];
|
|
954
|
+
return i.iterate({ enter: (t) => {
|
|
955
|
+
if (t.name !== "Table") return;
|
|
956
|
+
if (a && t.from < a.to) return !1;
|
|
957
|
+
if (o) {
|
|
958
|
+
let n = e.doc.lineAt(t.from).number, r = e.doc.lineAt(t.to).number;
|
|
959
|
+
for (let e = n; e <= r; e++) if (o.has(e)) return !1;
|
|
960
|
+
}
|
|
961
|
+
let i = rn(t.node, e.doc);
|
|
962
|
+
if (i) {
|
|
963
|
+
let e = n ? new Jn(i, r) : new tn(i, r);
|
|
964
|
+
s.push(C.replace({
|
|
965
|
+
widget: e,
|
|
966
|
+
block: !0
|
|
967
|
+
}).range(t.from, t.to));
|
|
968
|
+
}
|
|
969
|
+
return !1;
|
|
970
|
+
} }), C.set(s, !0);
|
|
971
|
+
}
|
|
972
|
+
var Y = A.define({
|
|
973
|
+
create: sn,
|
|
974
|
+
update: (e, t) => {
|
|
975
|
+
if (t.annotation($)) return e.map(t.changes);
|
|
976
|
+
let n = t.startState.readOnly !== t.state.readOnly;
|
|
977
|
+
return t.state.facet(P) === "cells" ? t.docChanged || n ? sn(t.state) : e.map(t.changes) : t.docChanged || n || t.selection && (on(t.state, t.startState.selection) || on(t.state, t.state.selection)) ? sn(t.state) : e;
|
|
978
|
+
},
|
|
979
|
+
provide: (e) => [w.decorations.from(e), w.atomicRanges.of((t) => t.state.field(e))]
|
|
980
|
+
});
|
|
981
|
+
//#endregion
|
|
982
|
+
//#region src/inplace/host-cell.ts
|
|
983
|
+
function cn(e, t, n) {
|
|
984
|
+
let i = t.closest("table");
|
|
985
|
+
if (!i) return;
|
|
986
|
+
let a = e.posAtDOM(i), o = a;
|
|
987
|
+
e.state.field(Y).between(a, a, (e) => (o = e, !1));
|
|
988
|
+
let s = le(e.state.doc, o, Number(t.dataset.r), Number(t.dataset.c));
|
|
989
|
+
if (s == null) return;
|
|
990
|
+
let { from: c, to: l } = n ? r(t) : {
|
|
991
|
+
from: 0,
|
|
992
|
+
to: 0
|
|
993
|
+
};
|
|
994
|
+
e.dispatch({ selection: {
|
|
995
|
+
anchor: s + c,
|
|
996
|
+
head: s + l
|
|
997
|
+
} });
|
|
998
|
+
}
|
|
999
|
+
//#endregion
|
|
1000
|
+
//#region src/inplace/host-items.ts
|
|
1001
|
+
var ln = /* @__PURE__ */ new WeakMap();
|
|
1002
|
+
function un(e, t) {
|
|
1003
|
+
if (e == null || typeof e == "string") return null;
|
|
1004
|
+
if (ln.has(t)) return ln.get(t) ?? null;
|
|
1005
|
+
let n = document.createElement("span"), r = Ae(n), i = null;
|
|
1006
|
+
try {
|
|
1007
|
+
Ce(() => r.render(e)), i = n.firstElementChild;
|
|
1008
|
+
} catch {}
|
|
1009
|
+
return r.unmount(), ln.set(t, i), i;
|
|
1010
|
+
}
|
|
1011
|
+
var dn = (e) => e.state.facet(L).includes("host"), fn = (e) => dn(e) && e.state.facet(Re)().some((e) => e.readOnlySafe);
|
|
1012
|
+
function pn(e, t) {
|
|
1013
|
+
if (!dn(e)) return [];
|
|
1014
|
+
let n = e.state.readOnly, r = [];
|
|
1015
|
+
for (let i of e.state.facet(Re)()) {
|
|
1016
|
+
if (n && !i.readOnlySafe) continue;
|
|
1017
|
+
let a = i.when ?? "always";
|
|
1018
|
+
if (a === "selection" && !t.selected || a === "no-selection" && t.selected) continue;
|
|
1019
|
+
let o = un(i.icon, i);
|
|
1020
|
+
r.push({
|
|
1021
|
+
id: i.id,
|
|
1022
|
+
label: i.title,
|
|
1023
|
+
icon: typeof i.icon == "string" ? i.icon : void 0,
|
|
1024
|
+
iconNode: o ?? void 0,
|
|
1025
|
+
disabled: i.disabled?.(e.state) ?? !1,
|
|
1026
|
+
onSelect: () => {
|
|
1027
|
+
t.prepare?.(), i.run(e);
|
|
1028
|
+
}
|
|
1029
|
+
});
|
|
1030
|
+
}
|
|
1031
|
+
return r;
|
|
1032
|
+
}
|
|
1033
|
+
//#endregion
|
|
819
1034
|
//#region src/inplace/link-row.ts
|
|
820
|
-
var
|
|
1035
|
+
var mn = (e) => {
|
|
821
1036
|
let t = e.trim().replace(/^<([^]*)>$/, "$1");
|
|
822
1037
|
return /[\s()]/.test(t) ? `<${t.replace(/[<>]/g, "")}>` : t;
|
|
823
|
-
},
|
|
824
|
-
function
|
|
1038
|
+
}, hn = (e) => e.replace(/^<([^]*)>$/, "$1");
|
|
1039
|
+
function gn(e, t) {
|
|
825
1040
|
let n = e.doc.lineAt(t.from);
|
|
826
1041
|
if (e.doc.lineAt(t.to).number !== n.number) return null;
|
|
827
1042
|
let r = t.from - n.from, i = t.to - n.from, s = o(n.text, r) ?? o(n.text, i);
|
|
@@ -837,7 +1052,7 @@ function Yt(e, t) {
|
|
|
837
1052
|
text: c.label
|
|
838
1053
|
} : null;
|
|
839
1054
|
}
|
|
840
|
-
function
|
|
1055
|
+
function _n(e, t) {
|
|
841
1056
|
let { state: n } = e, r = n.selection.main, i = n.doc.lineAt(r.head), a = t.partsIn(i.text, r.head - i.from);
|
|
842
1057
|
if (a) {
|
|
843
1058
|
let n = i.from + a.from, r = i.from + a.to, o = t.editActions?.(e, a) ?? [];
|
|
@@ -866,7 +1081,7 @@ function Xt(e, t) {
|
|
|
866
1081
|
actions: o
|
|
867
1082
|
};
|
|
868
1083
|
}
|
|
869
|
-
let o =
|
|
1084
|
+
let o = gn(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
1085
|
return {
|
|
871
1086
|
field: !0,
|
|
872
1087
|
label: t.addLabel,
|
|
@@ -876,18 +1091,18 @@ function Xt(e, t) {
|
|
|
876
1091
|
onSubmit: (n) => t.onAdd(e, s, c, l, n)
|
|
877
1092
|
};
|
|
878
1093
|
}
|
|
879
|
-
var
|
|
880
|
-
icon:
|
|
1094
|
+
var vn = {
|
|
1095
|
+
icon: b.link,
|
|
881
1096
|
placeholder: "https://…",
|
|
882
1097
|
editLabel: "Edit external link",
|
|
883
1098
|
addLabel: "Add external link",
|
|
884
1099
|
partsIn: o,
|
|
885
|
-
editValue: (e) =>
|
|
1100
|
+
editValue: (e) => hn(e.url),
|
|
886
1101
|
editActions: (e, t) => {
|
|
887
|
-
let n = e.state.facet(
|
|
1102
|
+
let n = e.state.facet(Pe);
|
|
888
1103
|
return !n || !t.url ? [] : [{
|
|
889
1104
|
label: "Open link",
|
|
890
|
-
icon:
|
|
1105
|
+
icon: b.link,
|
|
891
1106
|
onSelect: () => n(t.url)
|
|
892
1107
|
}];
|
|
893
1108
|
},
|
|
@@ -895,7 +1110,7 @@ var Zt = {
|
|
|
895
1110
|
e.dispatch({ changes: {
|
|
896
1111
|
from: t.urlFrom,
|
|
897
1112
|
to: t.urlTo,
|
|
898
|
-
insert:
|
|
1113
|
+
insert: mn(n)
|
|
899
1114
|
} }), e.focus();
|
|
900
1115
|
},
|
|
901
1116
|
onAdd: (e, t, n, r, i) => {
|
|
@@ -904,7 +1119,7 @@ var Zt = {
|
|
|
904
1119
|
changes: {
|
|
905
1120
|
from: t,
|
|
906
1121
|
to: n,
|
|
907
|
-
insert: `[${a}](${
|
|
1122
|
+
insert: `[${a}](${mn(i)})`
|
|
908
1123
|
},
|
|
909
1124
|
selection: {
|
|
910
1125
|
anchor: t + 1,
|
|
@@ -912,8 +1127,8 @@ var Zt = {
|
|
|
912
1127
|
}
|
|
913
1128
|
}), e.focus();
|
|
914
1129
|
}
|
|
915
|
-
},
|
|
916
|
-
icon:
|
|
1130
|
+
}, yn = {
|
|
1131
|
+
icon: b.wikilink,
|
|
917
1132
|
placeholder: "note or path",
|
|
918
1133
|
editLabel: "Edit link",
|
|
919
1134
|
addLabel: "Add link",
|
|
@@ -941,27 +1156,27 @@ var Zt = {
|
|
|
941
1156
|
}), e.focus();
|
|
942
1157
|
}
|
|
943
1158
|
};
|
|
944
|
-
function
|
|
945
|
-
return
|
|
1159
|
+
function bn(e) {
|
|
1160
|
+
return _n(e, vn);
|
|
946
1161
|
}
|
|
947
|
-
function
|
|
948
|
-
return
|
|
1162
|
+
function xn(e) {
|
|
1163
|
+
return _n(e, yn);
|
|
949
1164
|
}
|
|
950
1165
|
//#endregion
|
|
951
1166
|
//#region src/inplace/context-menu-shell.ts
|
|
952
|
-
function
|
|
1167
|
+
function Sn(e, t, n, r) {
|
|
953
1168
|
let i = r?.innerWidth ?? 0, a = r?.innerHeight ?? 0;
|
|
954
1169
|
e.style.left = "0", e.style.top = "0";
|
|
955
1170
|
let { width: o, height: s } = e.getBoundingClientRect();
|
|
956
1171
|
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
1172
|
}
|
|
958
|
-
function
|
|
1173
|
+
function Cn(e, t, n) {
|
|
959
1174
|
let r = n?.innerWidth ?? 0, i = n?.innerHeight ?? 0;
|
|
960
1175
|
e.style.left = "0", e.style.top = "0";
|
|
961
1176
|
let { width: a, height: o } = e.getBoundingClientRect(), s = t.right - 4, c = s + a > r - 4 ? t.left - a + 4 : s;
|
|
962
1177
|
e.style.left = `${Math.max(4, c)}px`, e.style.top = `${Math.max(4, Math.min(t.top - 4, i - o - 4))}px`;
|
|
963
1178
|
}
|
|
964
|
-
function
|
|
1179
|
+
function wn(e, t, n, r = 350) {
|
|
965
1180
|
let i = Date.now(), a = (e) => !t.contains(e.target), o = (e) => {
|
|
966
1181
|
a(e) && n();
|
|
967
1182
|
}, s = (e) => {
|
|
@@ -975,10 +1190,10 @@ function rn(e, t, n, r = 350) {
|
|
|
975
1190
|
}
|
|
976
1191
|
//#endregion
|
|
977
1192
|
//#region src/inplace/context-menu-types.ts
|
|
978
|
-
var
|
|
1193
|
+
var Tn = (e) => typeof e != "string" && "rows" in e, En = (e) => typeof e != "string" && "field" in e;
|
|
979
1194
|
//#endregion
|
|
980
1195
|
//#region src/inplace/context-menu.ts
|
|
981
|
-
function
|
|
1196
|
+
function X(e, t = "cm-inplace-menu", n) {
|
|
982
1197
|
let r = e.defaultView, i = e.createElement("div");
|
|
983
1198
|
i.className = t, i.setAttribute("contenteditable", "false"), i.hidden = !0;
|
|
984
1199
|
let a = null, o = null, s = () => {
|
|
@@ -987,13 +1202,13 @@ function J(e, t = "cm-inplace-menu", n) {
|
|
|
987
1202
|
i.hidden || (s(), i.hidden = !0, i.replaceChildren(), o?.(), o = null, n?.(!1));
|
|
988
1203
|
}, l = (e) => e.addEventListener("mousedown", (e) => {
|
|
989
1204
|
e.preventDefault(), e.stopPropagation();
|
|
990
|
-
}), u = (t, n, r) => {
|
|
991
|
-
r && t.appendChild(
|
|
992
|
-
let
|
|
993
|
-
|
|
1205
|
+
}), u = (t, n, r, i) => {
|
|
1206
|
+
i ? t.appendChild(i.cloneNode(!0)) : r && t.appendChild(fe(e, r));
|
|
1207
|
+
let a = e.createElement("span");
|
|
1208
|
+
a.textContent = n, t.appendChild(a);
|
|
994
1209
|
}, d = (n) => {
|
|
995
1210
|
let r = e.createElement("button");
|
|
996
|
-
return r.type = "button", r.className = `${t}-item`, u(r, n.label, n.icon), n.title && (r.title = n.title), n.active && (r.dataset.active = ""), n.disabled ? r.disabled = !0 : (l(r), r.addEventListener("pointerenter", () => {
|
|
1211
|
+
return r.type = "button", r.className = `${t}-item`, u(r, n.label, n.icon, n.iconNode), n.id && (r.dataset.menuItem = n.id), n.title && (r.title = n.title), n.active && (r.dataset.active = ""), n.disabled ? r.disabled = !0 : (l(r), r.addEventListener("pointerenter", () => {
|
|
997
1212
|
r.closest(`.${t}-panel[data-for]`) || s();
|
|
998
1213
|
}), r.addEventListener("click", (e) => {
|
|
999
1214
|
e.stopPropagation(), c(), n.onSelect();
|
|
@@ -1006,7 +1221,7 @@ function J(e, t = "cm-inplace-menu", n) {
|
|
|
1006
1221
|
if (a?.dataset.for === n) return;
|
|
1007
1222
|
s();
|
|
1008
1223
|
let e = c();
|
|
1009
|
-
e.dataset.for = n, i.appendChild(e),
|
|
1224
|
+
e.dataset.for = n, i.appendChild(e), Cn(e, f.getBoundingClientRect(), r), a = e, e.querySelector("input")?.focus({ preventScroll: !0 });
|
|
1010
1225
|
};
|
|
1011
1226
|
return f.addEventListener("pointerenter", p), f.addEventListener("click", (e) => {
|
|
1012
1227
|
e.stopPropagation(), p();
|
|
@@ -1029,7 +1244,7 @@ function J(e, t = "cm-inplace-menu", n) {
|
|
|
1029
1244
|
for (let i of n) if (i === "separator") {
|
|
1030
1245
|
let n = e.createElement("div");
|
|
1031
1246
|
n.className = `${t}-sep`, r.appendChild(n);
|
|
1032
|
-
} else
|
|
1247
|
+
} else Tn(i) ? r.appendChild(f(i.label, i.icon, () => m(i.rows), i.disabled)) : En(i) ? r.appendChild(f(i.label, i.icon, () => p(i))) : r.appendChild(d(i));
|
|
1033
1248
|
return r;
|
|
1034
1249
|
};
|
|
1035
1250
|
return {
|
|
@@ -1040,12 +1255,12 @@ function J(e, t = "cm-inplace-menu", n) {
|
|
|
1040
1255
|
show: (t, a, s) => {
|
|
1041
1256
|
c();
|
|
1042
1257
|
let l = m(t);
|
|
1043
|
-
i.appendChild(l), i.hidden = !1,
|
|
1258
|
+
i.appendChild(l), i.hidden = !1, Sn(l, a, s, r), o = wn(e, i, c), n?.(!0);
|
|
1044
1259
|
},
|
|
1045
1260
|
showField: (t, a, s) => {
|
|
1046
1261
|
c();
|
|
1047
1262
|
let l = p(t);
|
|
1048
|
-
i.appendChild(l), i.hidden = !1,
|
|
1263
|
+
i.appendChild(l), i.hidden = !1, Sn(l, a, s, r), l.querySelector("input")?.focus({ preventScroll: !0 }), o = wn(e, i, c), n?.(!0);
|
|
1049
1264
|
},
|
|
1050
1265
|
hide: c,
|
|
1051
1266
|
destroy: () => {
|
|
@@ -1055,14 +1270,14 @@ function J(e, t = "cm-inplace-menu", n) {
|
|
|
1055
1270
|
}
|
|
1056
1271
|
//#endregion
|
|
1057
1272
|
//#region src/inplace/math-edit.ts
|
|
1058
|
-
function
|
|
1059
|
-
let { state: t } = e, n = t.selection.main, r = t.doc.lineAt(n.head), i =
|
|
1273
|
+
function Dn(e) {
|
|
1274
|
+
let { state: t } = e, n = t.selection.main, r = t.doc.lineAt(n.head), i = Qe(r.text, n.head - r.from);
|
|
1060
1275
|
if (i) {
|
|
1061
1276
|
let t = r.from + i.from, n = r.from + i.to, a = i.block ? "$$" : "$";
|
|
1062
1277
|
return {
|
|
1063
1278
|
field: !0,
|
|
1064
1279
|
label: "Edit math",
|
|
1065
|
-
icon:
|
|
1280
|
+
icon: b.math,
|
|
1066
1281
|
value: i.src,
|
|
1067
1282
|
placeholder: "e^{i\\pi} + 1 = 0",
|
|
1068
1283
|
onSubmit: (r) => {
|
|
@@ -1095,7 +1310,7 @@ function sn(e) {
|
|
|
1095
1310
|
return {
|
|
1096
1311
|
field: !0,
|
|
1097
1312
|
label: "Add math",
|
|
1098
|
-
icon:
|
|
1313
|
+
icon: b.math,
|
|
1099
1314
|
value: "",
|
|
1100
1315
|
placeholder: "e^{i\\pi} + 1 = 0",
|
|
1101
1316
|
onSubmit: (t) => {
|
|
@@ -1114,27 +1329,27 @@ function sn(e) {
|
|
|
1114
1329
|
}
|
|
1115
1330
|
};
|
|
1116
1331
|
}
|
|
1117
|
-
var
|
|
1332
|
+
var On = class {
|
|
1118
1333
|
menu;
|
|
1119
1334
|
contentDOM;
|
|
1120
1335
|
onClick;
|
|
1121
1336
|
constructor(e) {
|
|
1122
|
-
this.menu =
|
|
1123
|
-
if (!e.state.facet(
|
|
1337
|
+
this.menu = X(e.dom.ownerDocument), e.dom.appendChild(this.menu.el), this.contentDOM = e.contentDOM, this.onClick = (t) => {
|
|
1338
|
+
if (!e.state.facet(M).math) return;
|
|
1124
1339
|
let n = t.target?.closest(".cm-inplace-math");
|
|
1125
1340
|
if (!n) return;
|
|
1126
1341
|
let r = e.posAtDOM(n);
|
|
1127
1342
|
if (r < 0) return;
|
|
1128
1343
|
let i = e.state.doc.lineAt(r);
|
|
1129
|
-
|
|
1344
|
+
Qe(i.text, r - i.from) && (e.dispatch({ selection: { anchor: r } }), this.menu.showField(Dn(e), t.clientX, t.clientY));
|
|
1130
1345
|
}, this.contentDOM.addEventListener("click", this.onClick);
|
|
1131
1346
|
}
|
|
1132
1347
|
destroy() {
|
|
1133
1348
|
this.contentDOM.removeEventListener("click", this.onClick), this.menu.destroy();
|
|
1134
1349
|
}
|
|
1135
|
-
},
|
|
1136
|
-
if (!e.state.facet(
|
|
1137
|
-
let n = e.state.doc.lineAt(t), r =
|
|
1350
|
+
}, kn = T.fromClass(On), An = be((e, t) => {
|
|
1351
|
+
if (!e.state.facet(M).math) return null;
|
|
1352
|
+
let n = e.state.doc.lineAt(t), r = Qe(n.text, t - n.from);
|
|
1138
1353
|
return r ? {
|
|
1139
1354
|
pos: n.from + r.from,
|
|
1140
1355
|
end: n.from + r.to,
|
|
@@ -1147,18 +1362,18 @@ var cn = class {
|
|
|
1147
1362
|
});
|
|
1148
1363
|
//#endregion
|
|
1149
1364
|
//#region src/inplace/context-menu-actions.ts
|
|
1150
|
-
function
|
|
1365
|
+
function Z(e) {
|
|
1151
1366
|
let t = h(e);
|
|
1152
1367
|
if (!t) return !1;
|
|
1153
1368
|
let { from: n, to: i } = r(t);
|
|
1154
1369
|
return i > n;
|
|
1155
1370
|
}
|
|
1156
|
-
function
|
|
1157
|
-
let t =
|
|
1371
|
+
function jn(e) {
|
|
1372
|
+
let t = ie(e.state);
|
|
1158
1373
|
return {
|
|
1159
1374
|
field: !0,
|
|
1160
1375
|
label: "Language",
|
|
1161
|
-
icon:
|
|
1376
|
+
icon: b.codeBlock,
|
|
1162
1377
|
value: t?.lang ?? "",
|
|
1163
1378
|
placeholder: "ts, python, …",
|
|
1164
1379
|
onSubmit: (n) => {
|
|
@@ -1171,49 +1386,53 @@ function dn(e) {
|
|
|
1171
1386
|
actions: [{
|
|
1172
1387
|
label: "Remove code block",
|
|
1173
1388
|
onSelect: () => {
|
|
1174
|
-
|
|
1389
|
+
g.codeBlock?.run(e), e.focus();
|
|
1175
1390
|
}
|
|
1176
1391
|
}]
|
|
1177
1392
|
};
|
|
1178
1393
|
}
|
|
1179
|
-
var
|
|
1180
|
-
...
|
|
1394
|
+
var Mn = (e, t = !1) => [
|
|
1395
|
+
...U(e, Bt, !1, t),
|
|
1181
1396
|
"separator",
|
|
1182
|
-
...t ?
|
|
1397
|
+
...t ? U(e, Vt, !1, !0) : [Kt(e, "code", !1), Dn(e)]
|
|
1183
1398
|
];
|
|
1184
|
-
function
|
|
1185
|
-
let
|
|
1186
|
-
return
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1399
|
+
function Nn(e, t) {
|
|
1400
|
+
let n = e.state.facet(L), r = t ?? h(e), i = Z(e) && r === h(e), a = [];
|
|
1401
|
+
return K(a, pn(e, {
|
|
1402
|
+
selected: i,
|
|
1403
|
+
prepare: () => r && cn(e, r, i)
|
|
1404
|
+
})), i ? (n.includes("format") && K(a, [G("Format", b.format, Mn(e, !0))]), n.includes("clipboard") && K(a, W(e)), a) : a;
|
|
1405
|
+
}
|
|
1406
|
+
var Pn = (e) => [
|
|
1407
|
+
...U(e, Ht),
|
|
1190
1408
|
"separator",
|
|
1191
|
-
...
|
|
1409
|
+
...U(e, [...Ut, "body"]),
|
|
1192
1410
|
"separator",
|
|
1193
|
-
...
|
|
1194
|
-
],
|
|
1195
|
-
...
|
|
1411
|
+
...U(e, ["quote"])
|
|
1412
|
+
], Fn = (e) => [
|
|
1413
|
+
...U(e, Wt),
|
|
1196
1414
|
"separator",
|
|
1197
|
-
...
|
|
1415
|
+
...U(e, Gt)
|
|
1198
1416
|
];
|
|
1199
|
-
function
|
|
1200
|
-
let { state: t } = e, n = t.facet(
|
|
1201
|
-
if (
|
|
1417
|
+
function In(e) {
|
|
1418
|
+
let { state: t } = e, n = t.facet(L), r = (e) => n.includes(e);
|
|
1419
|
+
if (Z(e)) return Nn(e);
|
|
1420
|
+
let i = pn(e, { selected: !t.selection.main.empty });
|
|
1202
1421
|
if (ee(t)) {
|
|
1203
|
-
let t = [
|
|
1204
|
-
return r("clipboard") &&
|
|
1422
|
+
let t = [];
|
|
1423
|
+
return K(t, i), K(t, [jn(e)]), r("clipboard") && K(t, W(e)), t;
|
|
1205
1424
|
}
|
|
1206
|
-
if (
|
|
1207
|
-
let t = [
|
|
1208
|
-
return r("clipboard") &&
|
|
1425
|
+
if (qt(t)) {
|
|
1426
|
+
let t = [];
|
|
1427
|
+
return K(t, i), K(t, [Xt(e)]), r("clipboard") && K(t, W(e)), t;
|
|
1209
1428
|
}
|
|
1210
|
-
let
|
|
1211
|
-
for (let t of n) t === "link" &&
|
|
1212
|
-
return
|
|
1429
|
+
let a = t.selection.main, o = t.doc.lineAt(a.head).text.trim() === "", s = !a.empty || !!t.wordAt(a.head), c = t.facet(Ve) === "menu", l = [];
|
|
1430
|
+
for (let t of n) t === "host" ? K(l, i) : t === "link" && c ? K(l, [xn(e), bn(e)]) : t === "format" && c ? K(l, [G("Format", b.format, Mn(e), !s)]) : t === "paragraph" ? K(l, [G("Paragraph", b.paragraph, Pn(e))]) : t === "insert" ? K(l, [G("Insert", b.insert, Fn(e), !o)]) : t === "clipboard" && K(l, W(e));
|
|
1431
|
+
return l;
|
|
1213
1432
|
}
|
|
1214
1433
|
//#endregion
|
|
1215
1434
|
//#region src/inplace/long-press.ts
|
|
1216
|
-
function
|
|
1435
|
+
function Ln(e, t) {
|
|
1217
1436
|
let n = t.delay ?? 450, r = t.slop ?? 20, i = null, a = 0, o = 0, s = () => {
|
|
1218
1437
|
i != null && (clearTimeout(i), i = null);
|
|
1219
1438
|
}, c = (e) => {
|
|
@@ -1235,10 +1454,10 @@ function _n(e, t) {
|
|
|
1235
1454
|
}
|
|
1236
1455
|
//#endregion
|
|
1237
1456
|
//#region src/inplace/table-gizmos.ts
|
|
1238
|
-
function
|
|
1457
|
+
function Rn(e, t) {
|
|
1239
1458
|
let n = e.createElement("div");
|
|
1240
1459
|
n.className = "cm-inplace-table-gizmos", n.setAttribute("contenteditable", "false");
|
|
1241
|
-
let r =
|
|
1460
|
+
let r = X(e), i = (t, n, r) => {
|
|
1242
1461
|
let i = e.createElement("button");
|
|
1243
1462
|
return i.type = "button", i.className = t, i.setAttribute("aria-label", n), i.addEventListener("mousedown", (e) => {
|
|
1244
1463
|
e.preventDefault(), e.stopPropagation();
|
|
@@ -1321,7 +1540,7 @@ function vn(e, t) {
|
|
|
1321
1540
|
}
|
|
1322
1541
|
//#endregion
|
|
1323
1542
|
//#region src/inplace/table-widget-keys.ts
|
|
1324
|
-
function
|
|
1543
|
+
function zn(e, t, n) {
|
|
1325
1544
|
let r = e.target.closest("td, th");
|
|
1326
1545
|
if (!r) return;
|
|
1327
1546
|
if (l(e, r)) {
|
|
@@ -1389,209 +1608,54 @@ function yn(e, t, n) {
|
|
|
1389
1608
|
}
|
|
1390
1609
|
}
|
|
1391
1610
|
//#endregion
|
|
1392
|
-
//#region src/inplace/inline-md.ts
|
|
1393
|
-
function bn(e, t = !1) {
|
|
1394
|
-
let n = document.createDocumentFragment();
|
|
1395
|
-
return Cn(n, e, t), n;
|
|
1396
|
-
}
|
|
1397
|
-
var xn = /!\[\[[^\]\n]+?\]\]/, Sn = [
|
|
1398
|
-
{
|
|
1399
|
-
re: /`([^`\n]+)`/,
|
|
1400
|
-
build: (e) => X("code", "cm-inplace-code", document.createTextNode(e[1]))
|
|
1401
|
-
},
|
|
1402
|
-
{
|
|
1403
|
-
re: new RegExp(Ge.source),
|
|
1404
|
-
build: (e) => {
|
|
1405
|
-
let t = X("span", "cm-inplace-math");
|
|
1406
|
-
return ge.render(e[1], t, { throwOnError: !1 }), t;
|
|
1407
|
-
}
|
|
1408
|
-
},
|
|
1409
|
-
{
|
|
1410
|
-
re: new RegExp(e.source),
|
|
1411
|
-
build: (e) => {
|
|
1412
|
-
let t = X("span", "cm-inplace-wikilink", document.createTextNode(e[2] || e[1] || ""));
|
|
1413
|
-
return t.dataset.styloWikilink = e[1] ?? "", t;
|
|
1414
|
-
}
|
|
1415
|
-
},
|
|
1416
|
-
{
|
|
1417
|
-
re: /\[([^\]\n]*)\]\(([^)\n]*)\)/,
|
|
1418
|
-
build: (e, t) => {
|
|
1419
|
-
let n = X("a", "cm-inplace-link");
|
|
1420
|
-
return n.href = e[2] ?? "", n.append(Z(e[1] ?? "", t)), n;
|
|
1421
|
-
}
|
|
1422
|
-
},
|
|
1423
|
-
{
|
|
1424
|
-
re: /\*\*\*([^*\n]+?)\*\*\*/,
|
|
1425
|
-
build: (e, t) => X("strong", "cm-inplace-strong", X("em", "cm-inplace-em", Z(e[1], t)))
|
|
1426
|
-
},
|
|
1427
|
-
{
|
|
1428
|
-
re: /\*\*([^\n]+?)\*\*/,
|
|
1429
|
-
build: (e, t) => X("strong", "cm-inplace-strong", Z(e[1], t))
|
|
1430
|
-
},
|
|
1431
|
-
{
|
|
1432
|
-
re: /~~([^\n]+?)~~/,
|
|
1433
|
-
build: (e, t) => X("span", "cm-inplace-strike", Z(e[1], t))
|
|
1434
|
-
},
|
|
1435
|
-
{
|
|
1436
|
-
re: /(?<!\*)\*(?!\*|\s)([^\n]+?)(?<!\s)\*(?!\*)/,
|
|
1437
|
-
build: (e, t) => X("em", "cm-inplace-em", Z(e[1], t))
|
|
1438
|
-
}
|
|
1439
|
-
];
|
|
1440
|
-
function X(e, t, ...n) {
|
|
1441
|
-
let r = document.createElement(e);
|
|
1442
|
-
return r.className = t, r.append(...n), r;
|
|
1443
|
-
}
|
|
1444
|
-
function Z(e, t) {
|
|
1445
|
-
let n = document.createDocumentFragment();
|
|
1446
|
-
return Cn(n, e, t), n;
|
|
1447
|
-
}
|
|
1448
|
-
function Cn(e, t, n) {
|
|
1449
|
-
for (; t;) {
|
|
1450
|
-
let r = -1, i = null, a = n ? xn.exec(t) : null;
|
|
1451
|
-
a && (r = a.index, i = { literal: a[0] });
|
|
1452
|
-
for (let e of Sn) {
|
|
1453
|
-
let n = e.re.exec(t);
|
|
1454
|
-
n && (r < 0 || n.index < r) && (r = n.index, i = {
|
|
1455
|
-
rule: e,
|
|
1456
|
-
m: n
|
|
1457
|
-
});
|
|
1458
|
-
}
|
|
1459
|
-
if (!i) {
|
|
1460
|
-
e.appendChild(document.createTextNode(t));
|
|
1461
|
-
return;
|
|
1462
|
-
}
|
|
1463
|
-
r > 0 && e.appendChild(document.createTextNode(t.slice(0, r))), "literal" in i ? (e.appendChild(document.createTextNode(i.literal)), t = t.slice(r + i.literal.length)) : (e.appendChild(i.rule.build(i.m, n)), t = t.slice(r + i.m[0].length));
|
|
1464
|
-
}
|
|
1465
|
-
}
|
|
1466
|
-
//#endregion
|
|
1467
1611
|
//#region src/inplace/table-widget-render.ts
|
|
1468
|
-
function
|
|
1612
|
+
function Bn(e, t, n) {
|
|
1469
1613
|
let r = Number(e.dataset.r), i = Number(e.dataset.c), a = t.rows[r]?.[i] ?? "";
|
|
1470
|
-
e.replaceChildren(n ? e.ownerDocument.createTextNode(a) :
|
|
1614
|
+
e.replaceChildren(n ? e.ownerDocument.createTextNode(a) : Zt(c(a), t.embeds));
|
|
1471
1615
|
}
|
|
1472
|
-
function
|
|
1616
|
+
function Vn(e, t, n, r) {
|
|
1473
1617
|
let i = document.createElement(r ? "th" : "td");
|
|
1474
1618
|
i.className = "cm-inplace-tcell", i.setAttribute("contenteditable", "true"), i.dataset.r = String(t), i.dataset.c = String(n);
|
|
1475
1619
|
let a = e.aligns[n];
|
|
1476
|
-
return a && (i.style.textAlign = a),
|
|
1620
|
+
return a && (i.style.textAlign = a), Bn(i, e, !1), i;
|
|
1477
1621
|
}
|
|
1478
|
-
function
|
|
1622
|
+
function Hn(e, t) {
|
|
1479
1623
|
e.replaceChildren();
|
|
1480
1624
|
let n = t.aligns.length, r = e.createTHead().insertRow();
|
|
1481
|
-
for (let e = 0; e < n; e++) r.appendChild(
|
|
1625
|
+
for (let e = 0; e < n; e++) r.appendChild(Vn(t, 0, e, !0));
|
|
1482
1626
|
let i = e.createTBody();
|
|
1483
1627
|
for (let e = 1; e < t.rows.length; e++) {
|
|
1484
1628
|
let r = i.insertRow();
|
|
1485
|
-
for (let i = 0; i < n; i++) r.appendChild(
|
|
1629
|
+
for (let i = 0; i < n; i++) r.appendChild(Vn(t, e, i, !1));
|
|
1486
1630
|
}
|
|
1487
1631
|
}
|
|
1488
1632
|
//#endregion
|
|
1489
1633
|
//#region src/inplace/table-structure.ts
|
|
1490
1634
|
var Q = (e) => e.aligns.length;
|
|
1491
|
-
function
|
|
1635
|
+
function Un(e, t) {
|
|
1492
1636
|
let n = Math.max(0, Math.min(t, Q(e)));
|
|
1493
1637
|
for (let t of e.rows) t.splice(n, 0, "");
|
|
1494
1638
|
e.aligns.splice(n, 0, "");
|
|
1495
1639
|
}
|
|
1496
|
-
function
|
|
1640
|
+
function Wn(e, t) {
|
|
1497
1641
|
if (!(Q(e) <= 1 || t < 0 || t >= Q(e))) {
|
|
1498
1642
|
for (let n of e.rows) n.splice(t, 1);
|
|
1499
1643
|
e.aligns.splice(t, 1);
|
|
1500
1644
|
}
|
|
1501
1645
|
}
|
|
1502
|
-
function
|
|
1646
|
+
function Gn(e, t) {
|
|
1503
1647
|
let n = Math.max(1, Math.min(t, e.rows.length));
|
|
1504
1648
|
e.rows.splice(n, 0, Array(Q(e)).fill(""));
|
|
1505
1649
|
}
|
|
1506
|
-
function
|
|
1650
|
+
function Kn(e, t) {
|
|
1507
1651
|
t <= 0 || t >= e.rows.length || e.rows.length <= 2 || e.rows.splice(t, 1);
|
|
1508
1652
|
}
|
|
1509
|
-
function
|
|
1653
|
+
function qn(e, t, n) {
|
|
1510
1654
|
t >= 0 && t < Q(e) && (e.aligns[t] = n);
|
|
1511
1655
|
}
|
|
1512
1656
|
//#endregion
|
|
1513
|
-
//#region src/inplace/
|
|
1514
|
-
var
|
|
1515
|
-
table;
|
|
1516
|
-
embeds;
|
|
1517
|
-
constructor(e, t) {
|
|
1518
|
-
super(), this.table = e, this.embeds = t;
|
|
1519
|
-
}
|
|
1520
|
-
eq(e) {
|
|
1521
|
-
return JSON.stringify(this.table) === JSON.stringify(e.table);
|
|
1522
|
-
}
|
|
1523
|
-
toDOM() {
|
|
1524
|
-
let { head: e, body: t, aligns: n } = this.table, r = document.createElement("table");
|
|
1525
|
-
r.className = "cm-inplace-table";
|
|
1526
|
-
let i = (e) => bn(e.replace(/\\\|/g, "|"), this.embeds), a = r.createTHead().insertRow();
|
|
1527
|
-
e.forEach((e, t) => {
|
|
1528
|
-
let r = document.createElement("th");
|
|
1529
|
-
r.appendChild(i(e)), r.dataset.styloRow = "0", r.dataset.styloCol = String(t), Nn(r, n[t]), a.appendChild(r);
|
|
1530
|
-
});
|
|
1531
|
-
let o = r.createTBody();
|
|
1532
|
-
return t.forEach((t, r) => {
|
|
1533
|
-
let a = o.insertRow();
|
|
1534
|
-
for (let o = 0; o < e.length; o++) {
|
|
1535
|
-
let e = a.insertCell();
|
|
1536
|
-
e.appendChild(i(t[o] ?? "")), e.dataset.styloRow = String(r + 1), e.dataset.styloCol = String(o), Nn(e, n[o]);
|
|
1537
|
-
}
|
|
1538
|
-
}), r;
|
|
1539
|
-
}
|
|
1540
|
-
ignoreEvent() {
|
|
1541
|
-
return !1;
|
|
1542
|
-
}
|
|
1543
|
-
};
|
|
1544
|
-
function Nn(e, t) {
|
|
1545
|
-
t && (e.style.textAlign = t);
|
|
1546
|
-
}
|
|
1547
|
-
function Pn(e, t) {
|
|
1548
|
-
let n = t.lineAt(e.from).number, r = t.lineAt(e.to).number, i = [];
|
|
1549
|
-
for (let e = n; e <= r; e++) i.push(t.line(e).text);
|
|
1550
|
-
let a = p(i);
|
|
1551
|
-
return !a || a.rows.length === 0 ? null : {
|
|
1552
|
-
head: a.rows[0],
|
|
1553
|
-
body: a.rows.slice(1),
|
|
1554
|
-
aligns: a.aligns
|
|
1555
|
-
};
|
|
1556
|
-
}
|
|
1557
|
-
function Fn(e, t) {
|
|
1558
|
-
let n = N(e);
|
|
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
|
-
return !1;
|
|
1561
|
-
}
|
|
1562
|
-
function In(e, t) {
|
|
1563
|
-
return t.ranges.some((t) => Fn(e, t.from) || Fn(e, t.to));
|
|
1564
|
-
}
|
|
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
|
-
return i.iterate({ enter: (t) => {
|
|
1569
|
-
if (t.name !== "Table") return;
|
|
1570
|
-
if (a && t.from < a.to) return !1;
|
|
1571
|
-
if (o) {
|
|
1572
|
-
let n = e.doc.lineAt(t.from).number, r = e.doc.lineAt(t.to).number;
|
|
1573
|
-
for (let e = n; e <= r; e++) if (o.has(e)) return !1;
|
|
1574
|
-
}
|
|
1575
|
-
let i = Pn(t.node, e.doc);
|
|
1576
|
-
if (i) {
|
|
1577
|
-
let e = n ? new zn(i, r) : new Mn(i, r);
|
|
1578
|
-
s.push(T.replace({
|
|
1579
|
-
widget: e,
|
|
1580
|
-
block: !0
|
|
1581
|
-
}).range(t.from, t.to));
|
|
1582
|
-
}
|
|
1583
|
-
return !1;
|
|
1584
|
-
} }), T.set(s, !0);
|
|
1585
|
-
}
|
|
1586
|
-
var Rn = M.define({
|
|
1587
|
-
create: Ln,
|
|
1588
|
-
update: (e, t) => {
|
|
1589
|
-
if (t.annotation($)) return e.map(t.changes);
|
|
1590
|
-
let n = t.startState.readOnly !== t.state.readOnly;
|
|
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
|
-
},
|
|
1593
|
-
provide: (e) => [E.decorations.from(e), E.atomicRanges.of((t) => t.state.field(e))]
|
|
1594
|
-
}), $ = xe.define(), zn = class extends O {
|
|
1657
|
+
//#region src/inplace/table-widget.ts
|
|
1658
|
+
var $ = we.define(), Jn = class extends E {
|
|
1595
1659
|
data;
|
|
1596
1660
|
embeds;
|
|
1597
1661
|
table = null;
|
|
@@ -1603,10 +1667,10 @@ var Rn = M.define({
|
|
|
1603
1667
|
longPress = null;
|
|
1604
1668
|
longPressAt = 0;
|
|
1605
1669
|
constructor(e, t = !1) {
|
|
1606
|
-
super(), this.data = e, this.embeds = t, this.rows =
|
|
1670
|
+
super(), this.data = e, this.embeds = t, this.rows = v(e);
|
|
1607
1671
|
}
|
|
1608
1672
|
eq(e) {
|
|
1609
|
-
return !this.table && JSON.stringify(
|
|
1673
|
+
return !this.table && JSON.stringify(y(this.rows)) === JSON.stringify(y(e.rows));
|
|
1610
1674
|
}
|
|
1611
1675
|
ignoreEvent() {
|
|
1612
1676
|
return !0;
|
|
@@ -1616,7 +1680,7 @@ var Rn = M.define({
|
|
|
1616
1680
|
}
|
|
1617
1681
|
bounds(e) {
|
|
1618
1682
|
let t = e.posAtDOM(this.table), n = null;
|
|
1619
|
-
return e.state.field(
|
|
1683
|
+
return e.state.field(Y).between(t, t, (e, t) => (n = {
|
|
1620
1684
|
from: e,
|
|
1621
1685
|
to: t
|
|
1622
1686
|
}, !1)), n ?? e.state.doc.lineAt(t);
|
|
@@ -1631,21 +1695,21 @@ var Rn = M.define({
|
|
|
1631
1695
|
};
|
|
1632
1696
|
}
|
|
1633
1697
|
paint(e, t) {
|
|
1634
|
-
|
|
1698
|
+
Bn(e, {
|
|
1635
1699
|
rows: this.rows,
|
|
1636
1700
|
aligns: this.data.aligns,
|
|
1637
1701
|
embeds: this.embeds
|
|
1638
1702
|
}, t);
|
|
1639
1703
|
}
|
|
1640
1704
|
renderCells() {
|
|
1641
|
-
|
|
1705
|
+
Hn(this.table, {
|
|
1642
1706
|
rows: this.rows,
|
|
1643
1707
|
aligns: this.data.aligns,
|
|
1644
1708
|
embeds: this.embeds
|
|
1645
1709
|
});
|
|
1646
1710
|
}
|
|
1647
1711
|
appendRow() {
|
|
1648
|
-
|
|
1712
|
+
Gn(this.model(), this.rows.length), this.renderCells(), this.gizmos?.layout(this.table);
|
|
1649
1713
|
}
|
|
1650
1714
|
model() {
|
|
1651
1715
|
return {
|
|
@@ -1656,7 +1720,7 @@ var Rn = M.define({
|
|
|
1656
1720
|
runOp(e, t) {
|
|
1657
1721
|
if (!this.table) return;
|
|
1658
1722
|
let n = this.model();
|
|
1659
|
-
if (t.kind === "insertColumn" ?
|
|
1723
|
+
if (t.kind === "insertColumn" ? Un(n, t.at) : t.kind === "deleteColumn" ? Wn(n, t.at) : t.kind === "insertRow" ? Gn(n, t.at) : t.kind === "deleteRow" ? Kn(n, t.at) : qn(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
1724
|
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
1725
|
this.cellAt(e, n)?.focus();
|
|
1662
1726
|
}
|
|
@@ -1668,7 +1732,7 @@ var Rn = M.define({
|
|
|
1668
1732
|
onFocusIn(e) {
|
|
1669
1733
|
let t = e.target.closest("td, th");
|
|
1670
1734
|
if (!t || t === this.editing) return;
|
|
1671
|
-
let n = this.pendingOffset ??
|
|
1735
|
+
let n = this.pendingOffset ?? ue(t);
|
|
1672
1736
|
this.pendingOffset = null, this.editing && this.finish(this.editing, !1), this.editing = t, this.paint(t, !0), d(t, n);
|
|
1673
1737
|
}
|
|
1674
1738
|
onFocusOut(e) {
|
|
@@ -1709,7 +1773,7 @@ var Rn = M.define({
|
|
|
1709
1773
|
})));
|
|
1710
1774
|
}
|
|
1711
1775
|
onKey(e, t) {
|
|
1712
|
-
this.table &&
|
|
1776
|
+
this.table && zn(e, t, {
|
|
1713
1777
|
coords: (e) => this.coords(e),
|
|
1714
1778
|
rows: () => this.rows.length,
|
|
1715
1779
|
cols: () => this.cols(),
|
|
@@ -1732,8 +1796,8 @@ var Rn = M.define({
|
|
|
1732
1796
|
openCellMenuAt(e, t, n, r) {
|
|
1733
1797
|
let i = r?.closest("td, th");
|
|
1734
1798
|
if (!i) return;
|
|
1735
|
-
this.editing === i && !
|
|
1736
|
-
let a =
|
|
1799
|
+
this.editing === i && !Z(e) && s(i, t, n);
|
|
1800
|
+
let a = Nn(e, i);
|
|
1737
1801
|
this.gizmos?.openFor(i, t, n, a);
|
|
1738
1802
|
}
|
|
1739
1803
|
toDOM(e) {
|
|
@@ -1743,7 +1807,7 @@ var Rn = M.define({
|
|
|
1743
1807
|
this.table = n, this.editing = null, n.className = "cm-inplace-table cm-inplace-table-edit", this.renderCells(), n.addEventListener("mousedown", (e) => {
|
|
1744
1808
|
e.stopPropagation();
|
|
1745
1809
|
let t = e.target.closest("td, th");
|
|
1746
|
-
this.pendingOffset = t && t !== this.editing ?
|
|
1810
|
+
this.pendingOffset = t && t !== this.editing ? de(t, e.clientX, e.clientY) : null;
|
|
1747
1811
|
}), n.addEventListener("focusin", (e) => this.onFocusIn(e)), n.addEventListener("focusout", (e) => this.onFocusOut(e));
|
|
1748
1812
|
let r = (t) => {
|
|
1749
1813
|
t && (this.editing = t, this.finish(t, !0), this.sync(e));
|
|
@@ -1756,9 +1820,9 @@ var Rn = M.define({
|
|
|
1756
1820
|
document.execCommand("insertText", !1, t);
|
|
1757
1821
|
}), n.addEventListener("contextmenu", (t) => {
|
|
1758
1822
|
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 =
|
|
1823
|
+
}), this.longPress = Ln(n, { onLongPress: (t, n, r) => {
|
|
1760
1824
|
this.longPressAt = Date.now(), this.openCellMenuAt(e, t, n, r);
|
|
1761
|
-
} }), this.gizmos =
|
|
1825
|
+
} }), this.gizmos = Rn(document, {
|
|
1762
1826
|
dims: () => ({
|
|
1763
1827
|
cols: this.cols(),
|
|
1764
1828
|
rows: this.rows.length,
|
|
@@ -1770,11 +1834,11 @@ var Rn = M.define({
|
|
|
1770
1834
|
destroy() {
|
|
1771
1835
|
this.longPress?.dispose(), this.longPress = null, this.gizmos?.destroy(), this.gizmos = null, this.table = null, this.editing = null;
|
|
1772
1836
|
}
|
|
1773
|
-
},
|
|
1837
|
+
}, Yn = /* @__PURE__ */ new Set([
|
|
1774
1838
|
"-",
|
|
1775
1839
|
"*",
|
|
1776
1840
|
"_"
|
|
1777
|
-
]),
|
|
1841
|
+
]), Xn = Ee.transactionFilter.of((e) => {
|
|
1778
1842
|
if (!e.docChanged || e.isUserEvent("undo") || e.isUserEvent("redo") || e.annotation($) || !e.startState.selection.main.empty) return e;
|
|
1779
1843
|
let t = e.startState.selection.main.head, n = "", r = 0;
|
|
1780
1844
|
if (e.changes.iterChanges((e, i, a, o, s) => {
|
|
@@ -1805,7 +1869,7 @@ var Rn = M.define({
|
|
|
1805
1869
|
},
|
|
1806
1870
|
anchor: a + 1
|
|
1807
1871
|
};
|
|
1808
|
-
else if (
|
|
1872
|
+
else if (Yn.has(n) && RegExp(`^\\${n}{3,}$`).test(s)) {
|
|
1809
1873
|
let e = o.number === 1 || i.line(o.number - 1).text.trim() === "", t = n === "-" && !e, r = o.number === i.lines;
|
|
1810
1874
|
if (t || r) {
|
|
1811
1875
|
let e = [];
|
|
@@ -1828,38 +1892,38 @@ var Rn = M.define({
|
|
|
1828
1892
|
scrollIntoView: !0,
|
|
1829
1893
|
userEvent: "input.autoformat"
|
|
1830
1894
|
}] : e;
|
|
1831
|
-
}),
|
|
1895
|
+
}), Zn = /* @__PURE__ */ new Set([
|
|
1832
1896
|
"EmphasisMark",
|
|
1833
1897
|
"CodeMark",
|
|
1834
1898
|
"StrikethroughMark"
|
|
1835
1899
|
]);
|
|
1836
|
-
function
|
|
1900
|
+
function Qn(e, t, n) {
|
|
1837
1901
|
let r = t;
|
|
1838
1902
|
for (;;) {
|
|
1839
1903
|
let t = e.resolveInner(r, n);
|
|
1840
|
-
if (!
|
|
1904
|
+
if (!Zn.has(t.name) || t.from >= t.to) return r;
|
|
1841
1905
|
let i = n < 0 ? t.from : t.to;
|
|
1842
1906
|
if (i === r) return r;
|
|
1843
1907
|
r = i;
|
|
1844
1908
|
}
|
|
1845
1909
|
}
|
|
1846
|
-
function
|
|
1847
|
-
let n =
|
|
1910
|
+
function $n(e, t) {
|
|
1911
|
+
let n = V(e, t, !0);
|
|
1848
1912
|
if (!n) return t;
|
|
1849
|
-
let r =
|
|
1850
|
-
return t === n.contentTo ?
|
|
1913
|
+
let r = j(e);
|
|
1914
|
+
return t === n.contentTo ? Qn(r, t, 1) : t === n.contentFrom ? Qn(r, t, -1) : t;
|
|
1851
1915
|
}
|
|
1852
|
-
var
|
|
1916
|
+
var er = Ee.transactionFilter.of((e) => {
|
|
1853
1917
|
if (!e.docChanged || e.isUserEvent("undo") || e.isUserEvent("redo") || e.annotation($)) return e;
|
|
1854
1918
|
let t = e.startState, n = t.selection.main;
|
|
1855
|
-
if (!n.empty || !
|
|
1919
|
+
if (!n.empty || !B(t, t.doc.lineAt(n.head).number)) return e;
|
|
1856
1920
|
let r = [], i = 0;
|
|
1857
1921
|
e.changes.iterChanges((e, t, a, o, s) => {
|
|
1858
1922
|
i++, e === t && e === n.head && s.length > 0 && r.push(s.toString());
|
|
1859
1923
|
});
|
|
1860
1924
|
let a = r[0];
|
|
1861
1925
|
if (i !== 1 || a === void 0) return e;
|
|
1862
|
-
let o =
|
|
1926
|
+
let o = $n(t, n.head);
|
|
1863
1927
|
return o === n.head ? e : {
|
|
1864
1928
|
changes: {
|
|
1865
1929
|
from: o,
|
|
@@ -1869,25 +1933,25 @@ var Gn = Ce.transactionFilter.of((e) => {
|
|
|
1869
1933
|
scrollIntoView: !0,
|
|
1870
1934
|
userEvent: "input.type"
|
|
1871
1935
|
};
|
|
1872
|
-
}),
|
|
1873
|
-
function
|
|
1936
|
+
}), tr = RegExp(`^(?:${_.match.source.replace(/^\^/, "")})+`);
|
|
1937
|
+
function nr(e, t) {
|
|
1874
1938
|
let n = e.doc.lineAt(t).number;
|
|
1875
|
-
for (let r =
|
|
1939
|
+
for (let r = j(e).resolveInner(t, 1); r; r = r.parent) {
|
|
1876
1940
|
if (r.name !== "ListItem" || e.doc.lineAt(r.from).number === n) continue;
|
|
1877
1941
|
let t = u.exec(e.doc.lineAt(r.from).text);
|
|
1878
1942
|
if (t) return t[0].length;
|
|
1879
1943
|
}
|
|
1880
1944
|
return null;
|
|
1881
1945
|
}
|
|
1882
|
-
function
|
|
1883
|
-
let n = t.text, r =
|
|
1946
|
+
function rr(e, t) {
|
|
1947
|
+
let n = t.text, r = oe.exec(n);
|
|
1884
1948
|
if (r) return {
|
|
1885
1949
|
prefixLen: r[0].length,
|
|
1886
1950
|
drop: [0, r[0].length]
|
|
1887
1951
|
};
|
|
1888
|
-
let i =
|
|
1952
|
+
let i = tr.exec(n);
|
|
1889
1953
|
if (i) {
|
|
1890
|
-
let e =
|
|
1954
|
+
let e = _.match.exec(n)[0].length;
|
|
1891
1955
|
return {
|
|
1892
1956
|
prefixLen: i[0].length,
|
|
1893
1957
|
drop: [0, e]
|
|
@@ -1898,11 +1962,11 @@ function Jn(e, t) {
|
|
|
1898
1962
|
prefixLen: a[0].length,
|
|
1899
1963
|
drop: [0, a[0].length]
|
|
1900
1964
|
};
|
|
1901
|
-
let o = te.match.exec(n) ??
|
|
1965
|
+
let o = te.match.exec(n) ?? ae.match.exec(n);
|
|
1902
1966
|
if (o) {
|
|
1903
1967
|
let n = o[1] ?? "", r = o[0].length - n.length;
|
|
1904
1968
|
if (n) {
|
|
1905
|
-
let r =
|
|
1969
|
+
let r = nr(e, t.from) ?? 2, i = n.startsWith(" ") ? 1 : Math.min(r, n.length);
|
|
1906
1970
|
return {
|
|
1907
1971
|
prefixLen: o[0].length,
|
|
1908
1972
|
drop: [0, i]
|
|
@@ -1915,15 +1979,15 @@ function Jn(e, t) {
|
|
|
1915
1979
|
}
|
|
1916
1980
|
return null;
|
|
1917
1981
|
}
|
|
1918
|
-
var
|
|
1982
|
+
var ir = k.high(D.of([{
|
|
1919
1983
|
key: "Backspace",
|
|
1920
1984
|
run: (e) => {
|
|
1921
1985
|
if (h(e)) return !1;
|
|
1922
1986
|
let { state: t } = e, n = t.selection.main;
|
|
1923
1987
|
if (!n.empty) return !1;
|
|
1924
1988
|
let r = t.doc.lineAt(n.head);
|
|
1925
|
-
if (!
|
|
1926
|
-
let i =
|
|
1989
|
+
if (!B(t, r.number)) return !1;
|
|
1990
|
+
let i = rr(t, r);
|
|
1927
1991
|
if (!i || n.head < r.from || n.head > r.from + i.prefixLen) return !1;
|
|
1928
1992
|
let [a, o] = i.drop;
|
|
1929
1993
|
return e.dispatch({
|
|
@@ -1937,13 +2001,13 @@ var Yn = j.high(k.of([{
|
|
|
1937
2001
|
scrollIntoView: !0
|
|
1938
2002
|
}), !0;
|
|
1939
2003
|
}
|
|
1940
|
-
}])),
|
|
2004
|
+
}])), ar = class {
|
|
1941
2005
|
menu;
|
|
1942
2006
|
contentDOM;
|
|
1943
2007
|
onClick;
|
|
1944
2008
|
constructor(e) {
|
|
1945
|
-
this.menu =
|
|
1946
|
-
if (e.state.facet(
|
|
2009
|
+
this.menu = X(e.dom.ownerDocument), e.dom.appendChild(this.menu.el), this.contentDOM = e.contentDOM, this.onClick = (t) => {
|
|
2010
|
+
if (e.state.facet(F) !== "never" || !e.state.facet(M).links) return;
|
|
1947
2011
|
let n = t.target?.closest(".cm-inplace-link");
|
|
1948
2012
|
if (!n || n.classList.contains("cm-inplace-wikilink")) return;
|
|
1949
2013
|
let r = e.posAtDOM(n);
|
|
@@ -1955,13 +2019,13 @@ var Yn = j.high(k.of([{
|
|
|
1955
2019
|
if (n == null) return;
|
|
1956
2020
|
r = n;
|
|
1957
2021
|
}
|
|
1958
|
-
e.dispatch({ selection: { anchor: r } }), this.menu.showField(
|
|
2022
|
+
e.dispatch({ selection: { anchor: r } }), this.menu.showField(bn(e), t.clientX, t.clientY);
|
|
1959
2023
|
}, this.contentDOM.addEventListener("click", this.onClick);
|
|
1960
2024
|
}
|
|
1961
2025
|
destroy() {
|
|
1962
2026
|
this.contentDOM.removeEventListener("click", this.onClick), this.menu.destroy();
|
|
1963
2027
|
}
|
|
1964
|
-
},
|
|
2028
|
+
}, or = T.fromClass(ar), sr = (e) => e.replace(/^<([^]*)>$/, "$1").trim(), cr = (e, t, n) => n ? {
|
|
1965
2029
|
pos: e,
|
|
1966
2030
|
end: t,
|
|
1967
2031
|
above: !0,
|
|
@@ -1970,27 +2034,27 @@ var Yn = j.high(k.of([{
|
|
|
1970
2034
|
return e.className = "cm-inplace-href-tip", e.textContent = n, { dom: e };
|
|
1971
2035
|
}
|
|
1972
2036
|
} : null;
|
|
1973
|
-
function
|
|
1974
|
-
for (let n =
|
|
2037
|
+
function lr(e, t) {
|
|
2038
|
+
for (let n = j(e.state).resolveInner(t, -1); n; n = n.parent) {
|
|
1975
2039
|
if (n.name !== "Link") continue;
|
|
1976
2040
|
if (e.state.doc.sliceString(Math.max(0, n.from - 1), n.from) === "[") break;
|
|
1977
2041
|
let t = n.getChild("URL"), r = t ? e.state.sliceDoc(t.from, t.to) : e.state.sliceDoc(n.from, n.to);
|
|
1978
|
-
return
|
|
2042
|
+
return cr(n.from, n.to, sr(r));
|
|
1979
2043
|
}
|
|
1980
2044
|
return null;
|
|
1981
2045
|
}
|
|
1982
|
-
function
|
|
2046
|
+
function ur(t, n) {
|
|
1983
2047
|
let r = t.state.doc.lineAt(n);
|
|
1984
2048
|
for (let t of r.text.matchAll(e)) {
|
|
1985
2049
|
let e = r.from + (t.index ?? 0), i = e + t[0].length;
|
|
1986
|
-
if (!(n < e || n > i)) return
|
|
2050
|
+
if (!(n < e || n > i)) return cr(e, i, (t[1] ?? "").trim());
|
|
1987
2051
|
}
|
|
1988
2052
|
return null;
|
|
1989
2053
|
}
|
|
1990
|
-
var
|
|
1991
|
-
let n = e.state.facet(
|
|
1992
|
-
return (n.links ?
|
|
1993
|
-
}),
|
|
2054
|
+
var dr = be((e, t) => {
|
|
2055
|
+
let n = e.state.facet(M);
|
|
2056
|
+
return (n.links ? lr(e, t) : null) ?? (n.wikilinks ? ur(e, t) : null);
|
|
2057
|
+
}), fr = class extends E {
|
|
1994
2058
|
ref;
|
|
1995
2059
|
inline;
|
|
1996
2060
|
registry;
|
|
@@ -2017,52 +2081,52 @@ var nr = ve((e, t) => {
|
|
|
2017
2081
|
return !1;
|
|
2018
2082
|
}
|
|
2019
2083
|
};
|
|
2020
|
-
function
|
|
2021
|
-
let t = e.facet(
|
|
2022
|
-
if (!t || !e.facet(
|
|
2023
|
-
let n =
|
|
2084
|
+
function pr(e) {
|
|
2085
|
+
let t = e.facet(N);
|
|
2086
|
+
if (!t || !e.facet(M).embeds || !e.doc.toString().includes("![[")) return C.none;
|
|
2087
|
+
let n = R(e), r = j(e), i = [];
|
|
2024
2088
|
for (let a = 1; a <= e.doc.lines; a++) {
|
|
2025
2089
|
let o = e.doc.line(a);
|
|
2026
2090
|
if (!(!o.text.includes("![[") || n.has(a))) {
|
|
2027
|
-
if (
|
|
2028
|
-
|
|
2029
|
-
let e = (
|
|
2030
|
-
if (!e ||
|
|
2031
|
-
i.push(
|
|
2032
|
-
widget: new
|
|
2091
|
+
if (me(o.text)) {
|
|
2092
|
+
x.lastIndex = 0;
|
|
2093
|
+
let e = (x.exec(o.text.trim())?.[1] ?? "").trim();
|
|
2094
|
+
if (!e || z(r, o.from + o.text.indexOf("!["))) continue;
|
|
2095
|
+
i.push(C.replace({
|
|
2096
|
+
widget: new fr(e, !1, t),
|
|
2033
2097
|
block: !0
|
|
2034
2098
|
}).range(o.from, o.to));
|
|
2035
2099
|
continue;
|
|
2036
2100
|
}
|
|
2037
|
-
|
|
2038
|
-
for (let e of o.text.matchAll(
|
|
2101
|
+
x.lastIndex = 0;
|
|
2102
|
+
for (let e of o.text.matchAll(x)) {
|
|
2039
2103
|
let n = (e[1] ?? "").trim();
|
|
2040
2104
|
if (!n) continue;
|
|
2041
2105
|
let a = o.from + (e.index ?? 0);
|
|
2042
|
-
|
|
2106
|
+
z(r, a + 2) || qe(r, a + 2) || i.push(C.replace({ widget: new fr(n, !0, t) }).range(a, a + e[0].length));
|
|
2043
2107
|
}
|
|
2044
2108
|
}
|
|
2045
2109
|
}
|
|
2046
|
-
return
|
|
2110
|
+
return C.set(i, !0);
|
|
2047
2111
|
}
|
|
2048
|
-
function
|
|
2112
|
+
function mr(e, t) {
|
|
2049
2113
|
for (let n of t.ranges) {
|
|
2050
2114
|
let t = e.doc.lineAt(n.from).number, r = e.doc.lineAt(n.to).number;
|
|
2051
2115
|
for (let n = t; n <= r; n++) if (e.doc.line(n).text.includes("![[")) return !0;
|
|
2052
2116
|
}
|
|
2053
2117
|
return !1;
|
|
2054
2118
|
}
|
|
2055
|
-
var
|
|
2056
|
-
create:
|
|
2057
|
-
update: (e, t) => t.docChanged || t.selection && (
|
|
2058
|
-
provide: (e) => [
|
|
2059
|
-
}),
|
|
2119
|
+
var hr = A.define({
|
|
2120
|
+
create: pr,
|
|
2121
|
+
update: (e, t) => t.docChanged || t.selection && (mr(t.state, t.startState.selection) || mr(t.state, t.state.selection)) ? pr(t.state) : e,
|
|
2122
|
+
provide: (e) => [w.decorations.from(e), w.atomicRanges.of((t) => t.state.field(e))]
|
|
2123
|
+
}), gr = De.define(), _r = A.define({
|
|
2060
2124
|
create: () => !1,
|
|
2061
2125
|
update(e, t) {
|
|
2062
|
-
for (let n of t.effects) n.is(
|
|
2126
|
+
for (let n of t.effects) n.is(gr) && (e = n.value);
|
|
2063
2127
|
return e;
|
|
2064
2128
|
}
|
|
2065
|
-
}),
|
|
2129
|
+
}), vr = class {
|
|
2066
2130
|
view;
|
|
2067
2131
|
menu;
|
|
2068
2132
|
onContextMenu;
|
|
@@ -2073,29 +2137,36 @@ var or = M.define({
|
|
|
2073
2137
|
longPressAt = 0;
|
|
2074
2138
|
destroyed = !1;
|
|
2075
2139
|
constructor(e) {
|
|
2076
|
-
this.view = e, this.menu =
|
|
2077
|
-
this.destroyed || e.dispatch({ effects:
|
|
2140
|
+
this.view = e, this.menu = X(e.dom.ownerDocument, "cm-inplace-menu", (t) => {
|
|
2141
|
+
this.destroyed || e.dispatch({ effects: gr.of(t) });
|
|
2078
2142
|
}), e.dom.appendChild(this.menu.el), this.contentDOM = e.contentDOM, this.onPointerDown = () => {
|
|
2079
2143
|
let t = e.state.selection.main;
|
|
2080
2144
|
this.stashed = t.empty ? null : {
|
|
2081
2145
|
anchor: t.anchor,
|
|
2082
2146
|
head: t.head
|
|
2083
2147
|
};
|
|
2084
|
-
}, this.contentDOM.addEventListener("pointerdown", this.onPointerDown, !0), this.onContextMenu = (
|
|
2085
|
-
let
|
|
2086
|
-
|
|
2087
|
-
}, this.contentDOM.addEventListener("contextmenu", this.onContextMenu), this.longPress =
|
|
2148
|
+
}, this.contentDOM.addEventListener("pointerdown", this.onPointerDown, !0), this.onContextMenu = (e) => {
|
|
2149
|
+
let t = e.target;
|
|
2150
|
+
this.canOpen() && (t?.closest(".cm-inplace-table-edit") || (this.longPress.cancel(), (Date.now() - this.longPressAt < 700 || this.openMenuAt(e.clientX, e.clientY, t)) && e.preventDefault()));
|
|
2151
|
+
}, this.contentDOM.addEventListener("contextmenu", this.onContextMenu), this.longPress = Ln(this.contentDOM, { onLongPress: (e, t, n) => {
|
|
2088
2152
|
this.longPressAt = Date.now(), this.openMenuAt(e, t, n);
|
|
2089
2153
|
} });
|
|
2090
2154
|
}
|
|
2155
|
+
canOpen() {
|
|
2156
|
+
let { state: e } = this.view;
|
|
2157
|
+
return e.facet(Fe) && (!e.readOnly || fn(this.view));
|
|
2158
|
+
}
|
|
2159
|
+
rows() {
|
|
2160
|
+
let e = this.view;
|
|
2161
|
+
return e.state.readOnly ? pn(e, { selected: !e.state.selection.main.empty }) : In(e);
|
|
2162
|
+
}
|
|
2091
2163
|
openMenuAt(e, t, n) {
|
|
2092
2164
|
let r = this.view;
|
|
2093
|
-
if (!
|
|
2165
|
+
if (!this.canOpen() || n?.closest(".cm-inplace-table-edit")) return !1;
|
|
2094
2166
|
let i = n?.closest(".cm-inplace-hr");
|
|
2095
2167
|
if (i) {
|
|
2096
2168
|
let n = r.posAtDOM(i);
|
|
2097
|
-
n >= 0 && r.dispatch({ selection: { anchor: n } }), this.
|
|
2098
|
-
return;
|
|
2169
|
+
return n >= 0 && r.dispatch({ selection: { anchor: n } }), this.show(e, t);
|
|
2099
2170
|
}
|
|
2100
2171
|
if (this.stashed && r.state.selection.main.empty) r.dispatch({ selection: this.stashed });
|
|
2101
2172
|
else if (r.state.selection.main.empty) {
|
|
@@ -2104,7 +2175,7 @@ var or = M.define({
|
|
|
2104
2175
|
y: t
|
|
2105
2176
|
});
|
|
2106
2177
|
if (n != null) {
|
|
2107
|
-
let e =
|
|
2178
|
+
let e = V(r.state, n, !1, !0), t = r.state.wordAt(n) ?? { anchor: n };
|
|
2108
2179
|
e?.kind === "link" ? t = {
|
|
2109
2180
|
anchor: e.from,
|
|
2110
2181
|
head: e.to
|
|
@@ -2114,15 +2185,19 @@ var or = M.define({
|
|
|
2114
2185
|
}), r.dispatch({ selection: t });
|
|
2115
2186
|
}
|
|
2116
2187
|
}
|
|
2117
|
-
this.
|
|
2188
|
+
return this.show(e, t);
|
|
2189
|
+
}
|
|
2190
|
+
show(e, t) {
|
|
2191
|
+
let n = this.rows();
|
|
2192
|
+
return n.length ? (this.menu.show(n, e, t), !0) : !1;
|
|
2118
2193
|
}
|
|
2119
2194
|
destroy() {
|
|
2120
2195
|
this.destroyed = !0, this.contentDOM.removeEventListener("pointerdown", this.onPointerDown, !0), this.contentDOM.removeEventListener("contextmenu", this.onContextMenu), this.longPress.dispose(), this.menu.destroy();
|
|
2121
2196
|
}
|
|
2122
|
-
},
|
|
2197
|
+
}, yr = T.fromClass(vr);
|
|
2123
2198
|
//#endregion
|
|
2124
2199
|
//#region src/inplace/selection-bar-position.ts
|
|
2125
|
-
function
|
|
2200
|
+
function br(e) {
|
|
2126
2201
|
let t = e.state.selection.main;
|
|
2127
2202
|
if (!t.empty) {
|
|
2128
2203
|
let n = e.coordsAtPos(t.from), r = e.coordsAtPos(t.to);
|
|
@@ -2136,7 +2211,7 @@ function dr(e) {
|
|
|
2136
2211
|
}
|
|
2137
2212
|
};
|
|
2138
2213
|
}
|
|
2139
|
-
if (!
|
|
2214
|
+
if (!Z(e)) return null;
|
|
2140
2215
|
let n = e.dom.ownerDocument.getSelection();
|
|
2141
2216
|
if (!n || n.rangeCount === 0) return null;
|
|
2142
2217
|
let r = n.getRangeAt(0).getBoundingClientRect();
|
|
@@ -2150,15 +2225,15 @@ function dr(e) {
|
|
|
2150
2225
|
}
|
|
2151
2226
|
};
|
|
2152
2227
|
}
|
|
2153
|
-
function
|
|
2154
|
-
if (e.state.facet(
|
|
2155
|
-
let r =
|
|
2228
|
+
function xr(e, t, n) {
|
|
2229
|
+
if (e.state.facet(Ve) !== "bar" || e.state.readOnly || e.state.field(_r, !1)) return null;
|
|
2230
|
+
let r = br(e);
|
|
2156
2231
|
if (!r) return null;
|
|
2157
2232
|
let { box: i, inCell: a } = r;
|
|
2158
2233
|
if (!a && !e.hasFocus) return null;
|
|
2159
2234
|
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 = {};
|
|
2160
2235
|
for (let t of n) {
|
|
2161
|
-
let n =
|
|
2236
|
+
let n = g[t], r = !a && !!n.disabled?.(e.state);
|
|
2162
2237
|
f[t] = r, p[t] = !r && !a && !!n.isActive?.(e.state);
|
|
2163
2238
|
}
|
|
2164
2239
|
return n.every((e) => f[e]) ? null : {
|
|
@@ -2170,7 +2245,7 @@ function fr(e, t, n) {
|
|
|
2170
2245
|
}
|
|
2171
2246
|
//#endregion
|
|
2172
2247
|
//#region src/inplace/selection-bar.ts
|
|
2173
|
-
var
|
|
2248
|
+
var Sr = class {
|
|
2174
2249
|
view;
|
|
2175
2250
|
bar;
|
|
2176
2251
|
ids;
|
|
@@ -2185,12 +2260,12 @@ var pr = class {
|
|
|
2185
2260
|
constructor(e) {
|
|
2186
2261
|
this.view = e;
|
|
2187
2262
|
let t = e.dom.ownerDocument;
|
|
2188
|
-
this.ids = e.state.facet(
|
|
2263
|
+
this.ids = e.state.facet(Be), this.linkMenu = X(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
2264
|
for (let n of this.ids) {
|
|
2190
|
-
let r =
|
|
2191
|
-
i.type = "button", i.className = "cm-inplace-selbar-btn", i.title = r.title, i.setAttribute("aria-label", r.title), i.appendChild(
|
|
2265
|
+
let r = g[n], i = t.createElement("button");
|
|
2266
|
+
i.type = "button", i.className = "cm-inplace-selbar-btn", i.title = r.title, i.setAttribute("aria-label", r.title), i.appendChild(fe(t, b[n] ?? "")), i.addEventListener("mousedown", (e) => e.preventDefault()), i.addEventListener("click", (t) => {
|
|
2192
2267
|
t.preventDefault();
|
|
2193
|
-
let a = !!h(e), o = !a && n === "link" ?
|
|
2268
|
+
let a = !!h(e), o = !a && n === "link" ? bn(e) : !a && n === "wikilink" ? xn(e) : null;
|
|
2194
2269
|
if (o) {
|
|
2195
2270
|
let e = i.getBoundingClientRect();
|
|
2196
2271
|
this.linkMenu.showField(o, e.left, e.bottom + 6);
|
|
@@ -2202,7 +2277,7 @@ var pr = class {
|
|
|
2202
2277
|
e.dom.appendChild(this.bar), t.addEventListener("scroll", this.onScroll, !0), t.addEventListener("selectionchange", this.onSelectionChange);
|
|
2203
2278
|
}
|
|
2204
2279
|
update(e) {
|
|
2205
|
-
let t = e.startState.field(
|
|
2280
|
+
let t = e.startState.field(_r, !1) !== e.state.field(_r, !1), n = e.startState.readOnly !== e.state.readOnly;
|
|
2206
2281
|
(e.selectionSet || e.docChanged || e.focusChanged || t || n) && this.schedule();
|
|
2207
2282
|
}
|
|
2208
2283
|
schedule() {
|
|
@@ -2213,7 +2288,7 @@ var pr = class {
|
|
|
2213
2288
|
});
|
|
2214
2289
|
}
|
|
2215
2290
|
measure() {
|
|
2216
|
-
return
|
|
2291
|
+
return xr(this.view, this.bar, this.ids);
|
|
2217
2292
|
}
|
|
2218
2293
|
apply(e) {
|
|
2219
2294
|
if (!e) {
|
|
@@ -2227,30 +2302,30 @@ var pr = class {
|
|
|
2227
2302
|
let e = this.view.dom.ownerDocument;
|
|
2228
2303
|
e.removeEventListener("scroll", this.onScroll, !0), e.removeEventListener("selectionchange", this.onSelectionChange), this.linkMenu.destroy(), this.bar.remove();
|
|
2229
2304
|
}
|
|
2230
|
-
},
|
|
2305
|
+
}, Cr = T.fromClass(Sr), wr = (e) => (t) => {
|
|
2231
2306
|
if (h(t)) return !1;
|
|
2232
2307
|
let n = t.state.selection.main;
|
|
2233
2308
|
if (!n.empty) return !1;
|
|
2234
2309
|
let { doc: r } = t.state, i = r.lineAt(n.head), a = e ? i.number + 1 : i.number - 1;
|
|
2235
2310
|
if (a < 1 || a > r.lines) return !1;
|
|
2236
2311
|
let o = r.line(a), s = -1, c = -1, l;
|
|
2237
|
-
if (t.state.field(
|
|
2312
|
+
if (t.state.field(Y).between(o.from, o.to, (t, n, r) => {
|
|
2238
2313
|
if (e ? t === o.from : n === o.to) return s = t, c = n, l = r.spec.widget, !1;
|
|
2239
2314
|
}), s < 0) return !1;
|
|
2240
|
-
if (t.state.facet(
|
|
2315
|
+
if (t.state.facet(P) === "cells") return l instanceof Jn && l.focusEdge(e ? "first" : "last");
|
|
2241
2316
|
let u = e ? r.lineAt(s).from : r.lineAt(c).to;
|
|
2242
2317
|
return t.dispatch({
|
|
2243
2318
|
selection: { anchor: u },
|
|
2244
2319
|
userEvent: "select",
|
|
2245
2320
|
scrollIntoView: !0
|
|
2246
2321
|
}), !0;
|
|
2247
|
-
},
|
|
2322
|
+
}, Tr = wr(!0), Er = wr(!1), Dr = k.high(D.of([{
|
|
2248
2323
|
key: "ArrowDown",
|
|
2249
|
-
run:
|
|
2324
|
+
run: Tr
|
|
2250
2325
|
}, {
|
|
2251
2326
|
key: "ArrowUp",
|
|
2252
|
-
run:
|
|
2253
|
-
}])),
|
|
2327
|
+
run: Er
|
|
2328
|
+
}])), Or = {
|
|
2254
2329
|
".cm-inplace-callout": {
|
|
2255
2330
|
borderLeft: "0.25rem solid var(--stylo-callout-accent, var(--stylo-border))",
|
|
2256
2331
|
padding: "0 var(--stylo-rhythm-callout-padding-x, 1rem)",
|
|
@@ -2284,9 +2359,9 @@ var pr = class {
|
|
|
2284
2359
|
content: "\"\"",
|
|
2285
2360
|
display: "none"
|
|
2286
2361
|
}
|
|
2287
|
-
},
|
|
2362
|
+
}, kr = "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)", jr = {
|
|
2288
2363
|
"& .cm-content": {
|
|
2289
|
-
fontFamily:
|
|
2364
|
+
fontFamily: Ar,
|
|
2290
2365
|
lineHeight: "1.75",
|
|
2291
2366
|
padding: "0.75rem",
|
|
2292
2367
|
WebkitTouchCallout: "none"
|
|
@@ -2329,14 +2404,14 @@ var pr = class {
|
|
|
2329
2404
|
".cm-inplace-em": { fontStyle: "italic" },
|
|
2330
2405
|
".cm-inplace-strike": { textDecoration: "line-through" },
|
|
2331
2406
|
".cm-inplace-code": {
|
|
2332
|
-
fontFamily:
|
|
2407
|
+
fontFamily: kr,
|
|
2333
2408
|
fontSize: "0.9em",
|
|
2334
2409
|
padding: "0.1em 0.35em",
|
|
2335
2410
|
borderRadius: "3px",
|
|
2336
2411
|
background: "color-mix(in srgb, var(--stylo-border) 45%, transparent)"
|
|
2337
2412
|
},
|
|
2338
2413
|
".cm-inplace-mono": {
|
|
2339
|
-
fontFamily:
|
|
2414
|
+
fontFamily: kr,
|
|
2340
2415
|
fontSize: "0.9em",
|
|
2341
2416
|
background: "color-mix(in srgb, var(--stylo-border) 35%, transparent)",
|
|
2342
2417
|
padding: "0 0.9rem"
|
|
@@ -2414,21 +2489,21 @@ var pr = class {
|
|
|
2414
2489
|
cursor: "pointer"
|
|
2415
2490
|
},
|
|
2416
2491
|
".cm-inplace-fm": {
|
|
2417
|
-
fontFamily:
|
|
2492
|
+
fontFamily: kr,
|
|
2418
2493
|
fontSize: "0.85em",
|
|
2419
2494
|
color: "var(--stylo-text-muted)"
|
|
2420
2495
|
},
|
|
2421
2496
|
".cm-inplace-fm-first::before": {
|
|
2422
2497
|
content: "\"Frontmatter\"",
|
|
2423
2498
|
marginRight: "0.6em",
|
|
2424
|
-
fontFamily:
|
|
2499
|
+
fontFamily: Ar,
|
|
2425
2500
|
fontSize: "0.8rem",
|
|
2426
2501
|
fontWeight: "600",
|
|
2427
2502
|
textTransform: "uppercase",
|
|
2428
2503
|
letterSpacing: "0.04em",
|
|
2429
2504
|
color: "var(--stylo-text-muted)"
|
|
2430
2505
|
}
|
|
2431
|
-
},
|
|
2506
|
+
}, Mr = {
|
|
2432
2507
|
".cm-inplace-menu": {
|
|
2433
2508
|
position: "fixed",
|
|
2434
2509
|
inset: "0",
|
|
@@ -2502,7 +2577,7 @@ var pr = class {
|
|
|
2502
2577
|
outline: "none"
|
|
2503
2578
|
},
|
|
2504
2579
|
".cm-inplace-menu-input:focus": { borderColor: "var(--stylo-ring)" }
|
|
2505
|
-
},
|
|
2580
|
+
}, Nr = {
|
|
2506
2581
|
".cm-inplace-selbar": {
|
|
2507
2582
|
position: "fixed",
|
|
2508
2583
|
zIndex: "20",
|
|
@@ -2587,7 +2662,7 @@ var pr = class {
|
|
|
2587
2662
|
lineHeight: "1.4",
|
|
2588
2663
|
wordBreak: "break-all"
|
|
2589
2664
|
}
|
|
2590
|
-
},
|
|
2665
|
+
}, Pr = {
|
|
2591
2666
|
".cm-inplace-table": {
|
|
2592
2667
|
borderCollapse: "collapse",
|
|
2593
2668
|
padding: "1em 0 1.4em",
|
|
@@ -2610,7 +2685,7 @@ var pr = class {
|
|
|
2610
2685
|
outline: "none"
|
|
2611
2686
|
},
|
|
2612
2687
|
".cm-inplace-table-edit .cm-inplace-tcell:focus": { boxShadow: "inset 0 0 0 2px var(--stylo-ring)" }
|
|
2613
|
-
},
|
|
2688
|
+
}, Fr = {
|
|
2614
2689
|
".cm-inplace-table-wrap": {
|
|
2615
2690
|
position: "relative",
|
|
2616
2691
|
display: "inline-block",
|
|
@@ -2652,57 +2727,58 @@ var pr = class {
|
|
|
2652
2727
|
},
|
|
2653
2728
|
".cm-inplace-tg-edge:hover .cm-inplace-tg-plus": { color: "var(--stylo-text)" },
|
|
2654
2729
|
"@media (hover: none)": { ".cm-inplace-tg-edge": { opacity: "0.5" } }
|
|
2655
|
-
},
|
|
2656
|
-
...
|
|
2657
|
-
...
|
|
2658
|
-
...
|
|
2659
|
-
...
|
|
2660
|
-
...
|
|
2661
|
-
...
|
|
2662
|
-
}),
|
|
2663
|
-
function
|
|
2664
|
-
let t =
|
|
2730
|
+
}, Ir = w.theme({
|
|
2731
|
+
...jr,
|
|
2732
|
+
...Or,
|
|
2733
|
+
...Pr,
|
|
2734
|
+
...Fr,
|
|
2735
|
+
...Mr,
|
|
2736
|
+
...Nr
|
|
2737
|
+
}), Lr = ".cm-inplace-math, .cm-inplace-hr, .cm-inplace-table, .cm-inplace-embed, .cm-inplace-embed-inline";
|
|
2738
|
+
function Rr(e = {}) {
|
|
2739
|
+
let t = Le(e.inPlace?.contextMenu);
|
|
2665
2740
|
return [
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2741
|
+
M.of(Ne(e.inPlace)),
|
|
2742
|
+
N.of(e.embedRegistry ?? null),
|
|
2743
|
+
P.of(e.inPlace?.table ?? "source"),
|
|
2744
|
+
F.of(e.inPlace?.reveal ?? "caret"),
|
|
2745
|
+
Pe.of(e.onLinkClick ?? null),
|
|
2746
|
+
Fe.of(t.enabled),
|
|
2747
|
+
L.of(t.groups),
|
|
2748
|
+
Re.of(e.hostItems ?? (() => t.items)),
|
|
2749
|
+
Ve.of(e.inPlace?.selectionUI ?? "menu"),
|
|
2750
|
+
Be.of(ze(e.inPlace?.selectionBarItems)),
|
|
2751
|
+
Dt(),
|
|
2752
|
+
ir,
|
|
2753
|
+
Yt,
|
|
2754
|
+
Rt,
|
|
2755
|
+
Dr,
|
|
2756
|
+
er,
|
|
2757
|
+
Xn,
|
|
2758
|
+
nt,
|
|
2759
|
+
hr,
|
|
2760
|
+
Ue,
|
|
2761
|
+
Y,
|
|
2762
|
+
_r,
|
|
2763
|
+
yr,
|
|
2764
|
+
Cr,
|
|
2683
2765
|
or,
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
Zn,
|
|
2690
|
-
nr,
|
|
2691
|
-
ln,
|
|
2692
|
-
un,
|
|
2693
|
-
j.high(Dr),
|
|
2694
|
-
E.domEventHandlers({
|
|
2766
|
+
dr,
|
|
2767
|
+
kn,
|
|
2768
|
+
An,
|
|
2769
|
+
k.high(Ir),
|
|
2770
|
+
w.domEventHandlers({
|
|
2695
2771
|
mousedown(e, t) {
|
|
2696
2772
|
let n = e.target;
|
|
2697
2773
|
if (n?.closest(".cm-inplace-table-edit") || n?.closest(".stylo-embed-content")) return !1;
|
|
2698
|
-
let r = n?.closest(
|
|
2774
|
+
let r = n?.closest(Lr);
|
|
2699
2775
|
if (!r) return !1;
|
|
2700
2776
|
let i = t.posAtDOM(r);
|
|
2701
2777
|
if (i < 0) return !1;
|
|
2702
2778
|
let a = n?.closest("[data-stylo-row]");
|
|
2703
2779
|
if (a && r.contains(a)) {
|
|
2704
|
-
let n =
|
|
2705
|
-
n != null && (i = n +
|
|
2780
|
+
let n = le(t.state.doc, i, Number(a.dataset.styloRow), Number(a.dataset.styloCol));
|
|
2781
|
+
n != null && (i = n + de(a, e.clientX, e.clientY));
|
|
2706
2782
|
}
|
|
2707
2783
|
return t.focus(), t.dispatch({ selection: { anchor: i } }), !0;
|
|
2708
2784
|
},
|
|
@@ -2716,49 +2792,55 @@ function kr(e = {}) {
|
|
|
2716
2792
|
}
|
|
2717
2793
|
//#endregion
|
|
2718
2794
|
//#region src/inplace/InPlaceView.tsx
|
|
2719
|
-
var
|
|
2720
|
-
function
|
|
2721
|
-
let te =
|
|
2795
|
+
var zr = () => () => {}, Br = () => null;
|
|
2796
|
+
function Vr({ 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 }) {
|
|
2797
|
+
let te = S(a);
|
|
2722
2798
|
te.current = a;
|
|
2723
|
-
let re =
|
|
2799
|
+
let re = S(o);
|
|
2724
2800
|
re.current = o;
|
|
2725
|
-
let
|
|
2726
|
-
|
|
2727
|
-
let
|
|
2728
|
-
|
|
2729
|
-
|
|
2801
|
+
let ie = S(s?.contextMenu);
|
|
2802
|
+
ie.current = s?.contextMenu;
|
|
2803
|
+
let [g] = ve(() => new je()), ae = ye(g.subscribe, g.getSnapshot, g.getSnapshot), [oe, se] = ve(null), _ = S(m);
|
|
2804
|
+
_.current = m;
|
|
2805
|
+
let le = S((e) => {
|
|
2806
|
+
se(e), _.current?.(e);
|
|
2807
|
+
}).current, v = S(h);
|
|
2730
2808
|
v.current = h;
|
|
2731
|
-
let [y] =
|
|
2809
|
+
let [y] = ve(() => h ? new ne() : null), ue = ye(y?.subscribe ?? zr, y?.getSnapshot ?? Br), [de] = ve(() => [Rr({
|
|
2732
2810
|
onWikiLinkClick: (e) => te.current?.(e),
|
|
2733
2811
|
onLinkClick: (e) => re.current?.(e),
|
|
2734
2812
|
inPlace: s,
|
|
2813
|
+
hostItems: () => {
|
|
2814
|
+
let e = ie.current;
|
|
2815
|
+
return typeof e == "object" ? e.items ?? [] : [];
|
|
2816
|
+
},
|
|
2735
2817
|
embedRegistry: d ? g : void 0
|
|
2736
|
-
}), ...y ? [
|
|
2818
|
+
}), ...y ? [xe.of(y.panel)] : []]), fe = ce({
|
|
2737
2819
|
value: e,
|
|
2738
2820
|
onChange: t,
|
|
2739
2821
|
readOnly: r,
|
|
2740
2822
|
placeholder: i,
|
|
2741
|
-
extensions:
|
|
2823
|
+
extensions: de,
|
|
2742
2824
|
codeLanguages: c,
|
|
2743
2825
|
wikiLinkSource: l,
|
|
2744
2826
|
tagSource: u,
|
|
2745
2827
|
onResolveError: f,
|
|
2746
2828
|
onSave: p,
|
|
2747
|
-
onViewChange:
|
|
2829
|
+
onViewChange: le,
|
|
2748
2830
|
hostExtensions: ee
|
|
2749
2831
|
});
|
|
2750
|
-
return /* @__PURE__ */
|
|
2832
|
+
return /* @__PURE__ */ ke("div", {
|
|
2751
2833
|
className: n.inplace,
|
|
2752
|
-
ref:
|
|
2753
|
-
children: [d &&
|
|
2834
|
+
ref: fe,
|
|
2835
|
+
children: [d && ae.map((e) => Se(/* @__PURE__ */ Oe(he, {
|
|
2754
2836
|
reference: e.ref,
|
|
2755
2837
|
source: d,
|
|
2756
2838
|
onError: f,
|
|
2757
2839
|
inline: e.inline
|
|
2758
|
-
}), e.el, String(e.id))),
|
|
2840
|
+
}), e.el, String(e.id))), ue && v.current && Se(v.current({ view: oe }), ue)]
|
|
2759
2841
|
});
|
|
2760
2842
|
}
|
|
2761
2843
|
//#endregion
|
|
2762
|
-
export {
|
|
2844
|
+
export { Vr as InPlaceView };
|
|
2763
2845
|
|
|
2764
|
-
//# sourceMappingURL=InPlaceView-
|
|
2846
|
+
//# sourceMappingURL=InPlaceView-rt6po4_E.js.map
|