@damiro/stylo 0.17.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/dist/{InPlaceView-CRb5AkfX.js → InPlaceView-D2GIV1A-.js} +692 -613
- package/dist/InPlaceView-D2GIV1A-.js.map +1 -0
- package/dist/{Preview-5lm2uUVj.js → Preview-BRA_R_Gp.js} +3 -3
- package/dist/{Preview-5lm2uUVj.js.map → Preview-BRA_R_Gp.js.map} +1 -1
- package/dist/Stylo.d.ts.map +1 -1
- package/dist/{embed-DKKeCE1Y.js → embed-DJAydn-v.js} +2 -2
- package/dist/{embed-DKKeCE1Y.js.map → embed-DJAydn-v.js.map} +1 -1
- package/dist/{embed-cache-CcBfVrc9.js → embed-cache-BU9Smn-h.js} +24 -17
- package/dist/embed-cache-BU9Smn-h.js.map +1 -0
- package/dist/inplace/InPlaceView.d.ts.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 +4 -4
- 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 +10 -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/styles.css +1 -1
- package/dist/stylo.js +391 -166
- package/dist/stylo.js.map +1 -1
- package/dist/toolbar/OverflowBar.d.ts +19 -0
- package/dist/toolbar/OverflowBar.d.ts.map +1 -0
- package/dist/toolbar/OverflowMenu.d.ts +24 -0
- package/dist/toolbar/OverflowMenu.d.ts.map +1 -0
- package/dist/toolbar/Toolbar.d.ts +5 -1
- package/dist/toolbar/Toolbar.d.ts.map +1 -1
- package/dist/toolbar/overflow-fit.d.ts +27 -0
- package/dist/toolbar/overflow-fit.d.ts.map +1 -0
- package/dist/toolbar/toolbar-model.d.ts +31 -0
- package/dist/toolbar/toolbar-model.d.ts.map +1 -0
- package/dist/toolbar/use-toolbar-overflow.d.ts +17 -0
- package/dist/toolbar/use-toolbar-overflow.d.ts.map +1 -0
- package/dist/types/inplace.d.ts +48 -5
- package/dist/types/inplace.d.ts.map +1 -1
- package/dist/types/toolbar.d.ts +16 -0
- package/dist/types/toolbar.d.ts.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/{useCodeMirror-B07wRexo.js → useCodeMirror-Fn6qEfMx.js} +2 -2
- package/dist/{useCodeMirror-B07wRexo.js.map → useCodeMirror-Fn6qEfMx.js.map} +1 -1
- package/package.json +1 -1
- package/dist/InPlaceView-CRb5AkfX.js.map +0 -1
- package/dist/embed-cache-CcBfVrc9.js.map +0 -1
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { l as e, s as t, u as n } from "./embed-cache-
|
|
2
|
-
import { C as r, D as i, E as a, O as o, S as s, T as c, _ as l, a as u, b as d, c as f, d as p, f as m, g as h, h as ee, i as te, k as ne, l as 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
|
|
1
|
+
import { l as e, s as t, u as n } from "./embed-cache-BU9Smn-h.js";
|
|
2
|
+
import { C as r, D as i, E as a, O as o, S as s, T as c, _ as l, a as u, b as d, c as f, d as p, f as m, g as h, h as ee, i as te, k as ne, l as re, m as ie, n as g, o as 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,264 @@ 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) {
|
|
984
|
+
let t = h(e), n = t?.closest("table");
|
|
985
|
+
if (!t || !n) return;
|
|
986
|
+
let i = e.posAtDOM(n), a = i;
|
|
987
|
+
e.state.field(Y).between(i, i, (e) => (a = e, !1));
|
|
988
|
+
let o = le(e.state.doc, a, Number(t.dataset.r), Number(t.dataset.c));
|
|
989
|
+
if (o == null) return;
|
|
990
|
+
let { from: s, to: c } = r(t);
|
|
991
|
+
e.dispatch({ selection: {
|
|
992
|
+
anchor: o + s,
|
|
993
|
+
head: o + c
|
|
994
|
+
} });
|
|
995
|
+
}
|
|
996
|
+
//#endregion
|
|
997
|
+
//#region src/inplace/host-items.ts
|
|
998
|
+
var ln = /* @__PURE__ */ new WeakMap();
|
|
999
|
+
function un(e, t) {
|
|
1000
|
+
if (e == null || typeof e == "string") return null;
|
|
1001
|
+
if (ln.has(t)) return ln.get(t) ?? null;
|
|
1002
|
+
let n = document.createElement("span"), r = Ae(n), i = null;
|
|
1003
|
+
try {
|
|
1004
|
+
Ce(() => r.render(e)), i = n.firstElementChild;
|
|
1005
|
+
} catch {}
|
|
1006
|
+
return r.unmount(), ln.set(t, i), i;
|
|
1007
|
+
}
|
|
1008
|
+
var dn = (e) => e.state.facet(L).includes("host"), fn = (e) => dn(e) && e.state.facet(Re)().some((e) => e.readOnlySafe);
|
|
1009
|
+
function pn(e, t) {
|
|
1010
|
+
if (!dn(e)) return [];
|
|
1011
|
+
let n = e.state.readOnly, r = [];
|
|
1012
|
+
for (let i of e.state.facet(Re)()) {
|
|
1013
|
+
if (n && !i.readOnlySafe) continue;
|
|
1014
|
+
let a = i.when ?? "always";
|
|
1015
|
+
if (a === "selection" && !t.selected || a === "no-selection" && t.selected) continue;
|
|
1016
|
+
let o = un(i.icon, i);
|
|
1017
|
+
r.push({
|
|
1018
|
+
id: i.id,
|
|
1019
|
+
label: i.title,
|
|
1020
|
+
icon: typeof i.icon == "string" ? i.icon : void 0,
|
|
1021
|
+
iconNode: o ?? void 0,
|
|
1022
|
+
disabled: i.disabled?.(e.state) ?? !1,
|
|
1023
|
+
onSelect: () => {
|
|
1024
|
+
t.prepare?.(), i.run(e);
|
|
1025
|
+
}
|
|
1026
|
+
});
|
|
1027
|
+
}
|
|
1028
|
+
return r;
|
|
1029
|
+
}
|
|
1030
|
+
//#endregion
|
|
819
1031
|
//#region src/inplace/link-row.ts
|
|
820
|
-
var
|
|
1032
|
+
var mn = (e) => {
|
|
821
1033
|
let t = e.trim().replace(/^<([^]*)>$/, "$1");
|
|
822
1034
|
return /[\s()]/.test(t) ? `<${t.replace(/[<>]/g, "")}>` : t;
|
|
823
|
-
},
|
|
824
|
-
function
|
|
1035
|
+
}, hn = (e) => e.replace(/^<([^]*)>$/, "$1");
|
|
1036
|
+
function gn(e, t) {
|
|
825
1037
|
let n = e.doc.lineAt(t.from);
|
|
826
1038
|
if (e.doc.lineAt(t.to).number !== n.number) return null;
|
|
827
1039
|
let r = t.from - n.from, i = t.to - n.from, s = o(n.text, r) ?? o(n.text, i);
|
|
@@ -837,7 +1049,7 @@ function Yt(e, t) {
|
|
|
837
1049
|
text: c.label
|
|
838
1050
|
} : null;
|
|
839
1051
|
}
|
|
840
|
-
function
|
|
1052
|
+
function _n(e, t) {
|
|
841
1053
|
let { state: n } = e, r = n.selection.main, i = n.doc.lineAt(r.head), a = t.partsIn(i.text, r.head - i.from);
|
|
842
1054
|
if (a) {
|
|
843
1055
|
let n = i.from + a.from, r = i.from + a.to, o = t.editActions?.(e, a) ?? [];
|
|
@@ -866,7 +1078,7 @@ function Xt(e, t) {
|
|
|
866
1078
|
actions: o
|
|
867
1079
|
};
|
|
868
1080
|
}
|
|
869
|
-
let o =
|
|
1081
|
+
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
1082
|
return {
|
|
871
1083
|
field: !0,
|
|
872
1084
|
label: t.addLabel,
|
|
@@ -876,18 +1088,18 @@ function Xt(e, t) {
|
|
|
876
1088
|
onSubmit: (n) => t.onAdd(e, s, c, l, n)
|
|
877
1089
|
};
|
|
878
1090
|
}
|
|
879
|
-
var
|
|
880
|
-
icon:
|
|
1091
|
+
var vn = {
|
|
1092
|
+
icon: b.link,
|
|
881
1093
|
placeholder: "https://…",
|
|
882
1094
|
editLabel: "Edit external link",
|
|
883
1095
|
addLabel: "Add external link",
|
|
884
1096
|
partsIn: o,
|
|
885
|
-
editValue: (e) =>
|
|
1097
|
+
editValue: (e) => hn(e.url),
|
|
886
1098
|
editActions: (e, t) => {
|
|
887
|
-
let n = e.state.facet(
|
|
1099
|
+
let n = e.state.facet(Pe);
|
|
888
1100
|
return !n || !t.url ? [] : [{
|
|
889
1101
|
label: "Open link",
|
|
890
|
-
icon:
|
|
1102
|
+
icon: b.link,
|
|
891
1103
|
onSelect: () => n(t.url)
|
|
892
1104
|
}];
|
|
893
1105
|
},
|
|
@@ -895,7 +1107,7 @@ var Zt = {
|
|
|
895
1107
|
e.dispatch({ changes: {
|
|
896
1108
|
from: t.urlFrom,
|
|
897
1109
|
to: t.urlTo,
|
|
898
|
-
insert:
|
|
1110
|
+
insert: mn(n)
|
|
899
1111
|
} }), e.focus();
|
|
900
1112
|
},
|
|
901
1113
|
onAdd: (e, t, n, r, i) => {
|
|
@@ -904,7 +1116,7 @@ var Zt = {
|
|
|
904
1116
|
changes: {
|
|
905
1117
|
from: t,
|
|
906
1118
|
to: n,
|
|
907
|
-
insert: `[${a}](${
|
|
1119
|
+
insert: `[${a}](${mn(i)})`
|
|
908
1120
|
},
|
|
909
1121
|
selection: {
|
|
910
1122
|
anchor: t + 1,
|
|
@@ -912,8 +1124,8 @@ var Zt = {
|
|
|
912
1124
|
}
|
|
913
1125
|
}), e.focus();
|
|
914
1126
|
}
|
|
915
|
-
},
|
|
916
|
-
icon:
|
|
1127
|
+
}, yn = {
|
|
1128
|
+
icon: b.wikilink,
|
|
917
1129
|
placeholder: "note or path",
|
|
918
1130
|
editLabel: "Edit link",
|
|
919
1131
|
addLabel: "Add link",
|
|
@@ -941,27 +1153,27 @@ var Zt = {
|
|
|
941
1153
|
}), e.focus();
|
|
942
1154
|
}
|
|
943
1155
|
};
|
|
944
|
-
function
|
|
945
|
-
return
|
|
1156
|
+
function bn(e) {
|
|
1157
|
+
return _n(e, vn);
|
|
946
1158
|
}
|
|
947
|
-
function
|
|
948
|
-
return
|
|
1159
|
+
function xn(e) {
|
|
1160
|
+
return _n(e, yn);
|
|
949
1161
|
}
|
|
950
1162
|
//#endregion
|
|
951
1163
|
//#region src/inplace/context-menu-shell.ts
|
|
952
|
-
function
|
|
1164
|
+
function Sn(e, t, n, r) {
|
|
953
1165
|
let i = r?.innerWidth ?? 0, a = r?.innerHeight ?? 0;
|
|
954
1166
|
e.style.left = "0", e.style.top = "0";
|
|
955
1167
|
let { width: o, height: s } = e.getBoundingClientRect();
|
|
956
1168
|
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
1169
|
}
|
|
958
|
-
function
|
|
1170
|
+
function Cn(e, t, n) {
|
|
959
1171
|
let r = n?.innerWidth ?? 0, i = n?.innerHeight ?? 0;
|
|
960
1172
|
e.style.left = "0", e.style.top = "0";
|
|
961
1173
|
let { width: a, height: o } = e.getBoundingClientRect(), s = t.right - 4, c = s + a > r - 4 ? t.left - a + 4 : s;
|
|
962
1174
|
e.style.left = `${Math.max(4, c)}px`, e.style.top = `${Math.max(4, Math.min(t.top - 4, i - o - 4))}px`;
|
|
963
1175
|
}
|
|
964
|
-
function
|
|
1176
|
+
function wn(e, t, n, r = 350) {
|
|
965
1177
|
let i = Date.now(), a = (e) => !t.contains(e.target), o = (e) => {
|
|
966
1178
|
a(e) && n();
|
|
967
1179
|
}, s = (e) => {
|
|
@@ -975,10 +1187,10 @@ function rn(e, t, n, r = 350) {
|
|
|
975
1187
|
}
|
|
976
1188
|
//#endregion
|
|
977
1189
|
//#region src/inplace/context-menu-types.ts
|
|
978
|
-
var
|
|
1190
|
+
var Tn = (e) => typeof e != "string" && "rows" in e, En = (e) => typeof e != "string" && "field" in e;
|
|
979
1191
|
//#endregion
|
|
980
1192
|
//#region src/inplace/context-menu.ts
|
|
981
|
-
function
|
|
1193
|
+
function X(e, t = "cm-inplace-menu", n) {
|
|
982
1194
|
let r = e.defaultView, i = e.createElement("div");
|
|
983
1195
|
i.className = t, i.setAttribute("contenteditable", "false"), i.hidden = !0;
|
|
984
1196
|
let a = null, o = null, s = () => {
|
|
@@ -987,13 +1199,13 @@ function J(e, t = "cm-inplace-menu", n) {
|
|
|
987
1199
|
i.hidden || (s(), i.hidden = !0, i.replaceChildren(), o?.(), o = null, n?.(!1));
|
|
988
1200
|
}, l = (e) => e.addEventListener("mousedown", (e) => {
|
|
989
1201
|
e.preventDefault(), e.stopPropagation();
|
|
990
|
-
}), u = (t, n, r) => {
|
|
991
|
-
r && t.appendChild(
|
|
992
|
-
let
|
|
993
|
-
|
|
1202
|
+
}), u = (t, n, r, i) => {
|
|
1203
|
+
i ? t.appendChild(i.cloneNode(!0)) : r && t.appendChild(fe(e, r));
|
|
1204
|
+
let a = e.createElement("span");
|
|
1205
|
+
a.textContent = n, t.appendChild(a);
|
|
994
1206
|
}, d = (n) => {
|
|
995
1207
|
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", () => {
|
|
1208
|
+
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
1209
|
r.closest(`.${t}-panel[data-for]`) || s();
|
|
998
1210
|
}), r.addEventListener("click", (e) => {
|
|
999
1211
|
e.stopPropagation(), c(), n.onSelect();
|
|
@@ -1006,7 +1218,7 @@ function J(e, t = "cm-inplace-menu", n) {
|
|
|
1006
1218
|
if (a?.dataset.for === n) return;
|
|
1007
1219
|
s();
|
|
1008
1220
|
let e = c();
|
|
1009
|
-
e.dataset.for = n, i.appendChild(e),
|
|
1221
|
+
e.dataset.for = n, i.appendChild(e), Cn(e, f.getBoundingClientRect(), r), a = e, e.querySelector("input")?.focus({ preventScroll: !0 });
|
|
1010
1222
|
};
|
|
1011
1223
|
return f.addEventListener("pointerenter", p), f.addEventListener("click", (e) => {
|
|
1012
1224
|
e.stopPropagation(), p();
|
|
@@ -1029,7 +1241,7 @@ function J(e, t = "cm-inplace-menu", n) {
|
|
|
1029
1241
|
for (let i of n) if (i === "separator") {
|
|
1030
1242
|
let n = e.createElement("div");
|
|
1031
1243
|
n.className = `${t}-sep`, r.appendChild(n);
|
|
1032
|
-
} else
|
|
1244
|
+
} 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
1245
|
return r;
|
|
1034
1246
|
};
|
|
1035
1247
|
return {
|
|
@@ -1040,12 +1252,12 @@ function J(e, t = "cm-inplace-menu", n) {
|
|
|
1040
1252
|
show: (t, a, s) => {
|
|
1041
1253
|
c();
|
|
1042
1254
|
let l = m(t);
|
|
1043
|
-
i.appendChild(l), i.hidden = !1,
|
|
1255
|
+
i.appendChild(l), i.hidden = !1, Sn(l, a, s, r), o = wn(e, i, c), n?.(!0);
|
|
1044
1256
|
},
|
|
1045
1257
|
showField: (t, a, s) => {
|
|
1046
1258
|
c();
|
|
1047
1259
|
let l = p(t);
|
|
1048
|
-
i.appendChild(l), i.hidden = !1,
|
|
1260
|
+
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
1261
|
},
|
|
1050
1262
|
hide: c,
|
|
1051
1263
|
destroy: () => {
|
|
@@ -1055,14 +1267,14 @@ function J(e, t = "cm-inplace-menu", n) {
|
|
|
1055
1267
|
}
|
|
1056
1268
|
//#endregion
|
|
1057
1269
|
//#region src/inplace/math-edit.ts
|
|
1058
|
-
function
|
|
1059
|
-
let { state: t } = e, n = t.selection.main, r = t.doc.lineAt(n.head), i =
|
|
1270
|
+
function Dn(e) {
|
|
1271
|
+
let { state: t } = e, n = t.selection.main, r = t.doc.lineAt(n.head), i = Qe(r.text, n.head - r.from);
|
|
1060
1272
|
if (i) {
|
|
1061
1273
|
let t = r.from + i.from, n = r.from + i.to, a = i.block ? "$$" : "$";
|
|
1062
1274
|
return {
|
|
1063
1275
|
field: !0,
|
|
1064
1276
|
label: "Edit math",
|
|
1065
|
-
icon:
|
|
1277
|
+
icon: b.math,
|
|
1066
1278
|
value: i.src,
|
|
1067
1279
|
placeholder: "e^{i\\pi} + 1 = 0",
|
|
1068
1280
|
onSubmit: (r) => {
|
|
@@ -1095,7 +1307,7 @@ function sn(e) {
|
|
|
1095
1307
|
return {
|
|
1096
1308
|
field: !0,
|
|
1097
1309
|
label: "Add math",
|
|
1098
|
-
icon:
|
|
1310
|
+
icon: b.math,
|
|
1099
1311
|
value: "",
|
|
1100
1312
|
placeholder: "e^{i\\pi} + 1 = 0",
|
|
1101
1313
|
onSubmit: (t) => {
|
|
@@ -1114,27 +1326,27 @@ function sn(e) {
|
|
|
1114
1326
|
}
|
|
1115
1327
|
};
|
|
1116
1328
|
}
|
|
1117
|
-
var
|
|
1329
|
+
var On = class {
|
|
1118
1330
|
menu;
|
|
1119
1331
|
contentDOM;
|
|
1120
1332
|
onClick;
|
|
1121
1333
|
constructor(e) {
|
|
1122
|
-
this.menu =
|
|
1123
|
-
if (!e.state.facet(
|
|
1334
|
+
this.menu = X(e.dom.ownerDocument), e.dom.appendChild(this.menu.el), this.contentDOM = e.contentDOM, this.onClick = (t) => {
|
|
1335
|
+
if (!e.state.facet(M).math) return;
|
|
1124
1336
|
let n = t.target?.closest(".cm-inplace-math");
|
|
1125
1337
|
if (!n) return;
|
|
1126
1338
|
let r = e.posAtDOM(n);
|
|
1127
1339
|
if (r < 0) return;
|
|
1128
1340
|
let i = e.state.doc.lineAt(r);
|
|
1129
|
-
|
|
1341
|
+
Qe(i.text, r - i.from) && (e.dispatch({ selection: { anchor: r } }), this.menu.showField(Dn(e), t.clientX, t.clientY));
|
|
1130
1342
|
}, this.contentDOM.addEventListener("click", this.onClick);
|
|
1131
1343
|
}
|
|
1132
1344
|
destroy() {
|
|
1133
1345
|
this.contentDOM.removeEventListener("click", this.onClick), this.menu.destroy();
|
|
1134
1346
|
}
|
|
1135
|
-
},
|
|
1136
|
-
if (!e.state.facet(
|
|
1137
|
-
let n = e.state.doc.lineAt(t), r =
|
|
1347
|
+
}, kn = T.fromClass(On), An = be((e, t) => {
|
|
1348
|
+
if (!e.state.facet(M).math) return null;
|
|
1349
|
+
let n = e.state.doc.lineAt(t), r = Qe(n.text, t - n.from);
|
|
1138
1350
|
return r ? {
|
|
1139
1351
|
pos: n.from + r.from,
|
|
1140
1352
|
end: n.from + r.to,
|
|
@@ -1147,18 +1359,18 @@ var cn = class {
|
|
|
1147
1359
|
});
|
|
1148
1360
|
//#endregion
|
|
1149
1361
|
//#region src/inplace/context-menu-actions.ts
|
|
1150
|
-
function
|
|
1362
|
+
function Z(e) {
|
|
1151
1363
|
let t = h(e);
|
|
1152
1364
|
if (!t) return !1;
|
|
1153
1365
|
let { from: n, to: i } = r(t);
|
|
1154
1366
|
return i > n;
|
|
1155
1367
|
}
|
|
1156
|
-
function
|
|
1157
|
-
let t =
|
|
1368
|
+
function jn(e) {
|
|
1369
|
+
let t = ie(e.state);
|
|
1158
1370
|
return {
|
|
1159
1371
|
field: !0,
|
|
1160
1372
|
label: "Language",
|
|
1161
|
-
icon:
|
|
1373
|
+
icon: b.codeBlock,
|
|
1162
1374
|
value: t?.lang ?? "",
|
|
1163
1375
|
placeholder: "ts, python, …",
|
|
1164
1376
|
onSubmit: (n) => {
|
|
@@ -1171,49 +1383,53 @@ function dn(e) {
|
|
|
1171
1383
|
actions: [{
|
|
1172
1384
|
label: "Remove code block",
|
|
1173
1385
|
onSelect: () => {
|
|
1174
|
-
|
|
1386
|
+
g.codeBlock?.run(e), e.focus();
|
|
1175
1387
|
}
|
|
1176
1388
|
}]
|
|
1177
1389
|
};
|
|
1178
1390
|
}
|
|
1179
|
-
var
|
|
1180
|
-
...
|
|
1391
|
+
var Mn = (e, t = !1) => [
|
|
1392
|
+
...U(e, Bt, !1, t),
|
|
1181
1393
|
"separator",
|
|
1182
|
-
...t ?
|
|
1394
|
+
...t ? U(e, Vt, !1, !0) : [Kt(e, "code", !1), Dn(e)]
|
|
1183
1395
|
];
|
|
1184
|
-
function
|
|
1185
|
-
let t = e.state.facet(
|
|
1186
|
-
return
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1396
|
+
function Nn(e) {
|
|
1397
|
+
let t = e.state.facet(L), n = Z(e), r = [];
|
|
1398
|
+
return K(r, pn(e, {
|
|
1399
|
+
selected: n,
|
|
1400
|
+
prepare: () => cn(e)
|
|
1401
|
+
})), n ? (t.includes("format") && K(r, [G("Format", b.format, Mn(e, !0))]), t.includes("clipboard") && K(r, W(e)), r) : r;
|
|
1402
|
+
}
|
|
1403
|
+
var Pn = (e) => [
|
|
1404
|
+
...U(e, Ht),
|
|
1190
1405
|
"separator",
|
|
1191
|
-
...
|
|
1406
|
+
...U(e, [...Ut, "body"]),
|
|
1192
1407
|
"separator",
|
|
1193
|
-
...
|
|
1194
|
-
],
|
|
1195
|
-
...
|
|
1408
|
+
...U(e, ["quote"])
|
|
1409
|
+
], Fn = (e) => [
|
|
1410
|
+
...U(e, Wt),
|
|
1196
1411
|
"separator",
|
|
1197
|
-
...
|
|
1412
|
+
...U(e, Gt)
|
|
1198
1413
|
];
|
|
1199
|
-
function
|
|
1200
|
-
let { state: t } = e, n = t.facet(
|
|
1201
|
-
if (
|
|
1414
|
+
function In(e) {
|
|
1415
|
+
let { state: t } = e, n = t.facet(L), r = (e) => n.includes(e);
|
|
1416
|
+
if (Z(e)) return Nn(e);
|
|
1417
|
+
let i = pn(e, { selected: !t.selection.main.empty });
|
|
1202
1418
|
if (ee(t)) {
|
|
1203
|
-
let t = [
|
|
1204
|
-
return r("clipboard") &&
|
|
1419
|
+
let t = [];
|
|
1420
|
+
return K(t, i), K(t, [jn(e)]), r("clipboard") && K(t, W(e)), t;
|
|
1205
1421
|
}
|
|
1206
|
-
if (
|
|
1207
|
-
let t = [
|
|
1208
|
-
return r("clipboard") &&
|
|
1422
|
+
if (qt(t)) {
|
|
1423
|
+
let t = [];
|
|
1424
|
+
return K(t, i), K(t, [Xt(e)]), r("clipboard") && K(t, W(e)), t;
|
|
1209
1425
|
}
|
|
1210
|
-
let
|
|
1211
|
-
for (let t of n) t === "link" &&
|
|
1212
|
-
return
|
|
1426
|
+
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 = [];
|
|
1427
|
+
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));
|
|
1428
|
+
return l;
|
|
1213
1429
|
}
|
|
1214
1430
|
//#endregion
|
|
1215
1431
|
//#region src/inplace/long-press.ts
|
|
1216
|
-
function
|
|
1432
|
+
function Ln(e, t) {
|
|
1217
1433
|
let n = t.delay ?? 450, r = t.slop ?? 20, i = null, a = 0, o = 0, s = () => {
|
|
1218
1434
|
i != null && (clearTimeout(i), i = null);
|
|
1219
1435
|
}, c = (e) => {
|
|
@@ -1235,10 +1451,10 @@ function _n(e, t) {
|
|
|
1235
1451
|
}
|
|
1236
1452
|
//#endregion
|
|
1237
1453
|
//#region src/inplace/table-gizmos.ts
|
|
1238
|
-
function
|
|
1454
|
+
function Rn(e, t) {
|
|
1239
1455
|
let n = e.createElement("div");
|
|
1240
1456
|
n.className = "cm-inplace-table-gizmos", n.setAttribute("contenteditable", "false");
|
|
1241
|
-
let r =
|
|
1457
|
+
let r = X(e), i = (t, n, r) => {
|
|
1242
1458
|
let i = e.createElement("button");
|
|
1243
1459
|
return i.type = "button", i.className = t, i.setAttribute("aria-label", n), i.addEventListener("mousedown", (e) => {
|
|
1244
1460
|
e.preventDefault(), e.stopPropagation();
|
|
@@ -1321,7 +1537,7 @@ function vn(e, t) {
|
|
|
1321
1537
|
}
|
|
1322
1538
|
//#endregion
|
|
1323
1539
|
//#region src/inplace/table-widget-keys.ts
|
|
1324
|
-
function
|
|
1540
|
+
function zn(e, t, n) {
|
|
1325
1541
|
let r = e.target.closest("td, th");
|
|
1326
1542
|
if (!r) return;
|
|
1327
1543
|
if (l(e, r)) {
|
|
@@ -1389,209 +1605,54 @@ function yn(e, t, n) {
|
|
|
1389
1605
|
}
|
|
1390
1606
|
}
|
|
1391
1607
|
//#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
1608
|
//#region src/inplace/table-widget-render.ts
|
|
1468
|
-
function
|
|
1609
|
+
function Bn(e, t, n) {
|
|
1469
1610
|
let r = Number(e.dataset.r), i = Number(e.dataset.c), a = t.rows[r]?.[i] ?? "";
|
|
1470
|
-
e.replaceChildren(n ? e.ownerDocument.createTextNode(a) :
|
|
1611
|
+
e.replaceChildren(n ? e.ownerDocument.createTextNode(a) : Zt(c(a), t.embeds));
|
|
1471
1612
|
}
|
|
1472
|
-
function
|
|
1613
|
+
function Vn(e, t, n, r) {
|
|
1473
1614
|
let i = document.createElement(r ? "th" : "td");
|
|
1474
1615
|
i.className = "cm-inplace-tcell", i.setAttribute("contenteditable", "true"), i.dataset.r = String(t), i.dataset.c = String(n);
|
|
1475
1616
|
let a = e.aligns[n];
|
|
1476
|
-
return a && (i.style.textAlign = a),
|
|
1617
|
+
return a && (i.style.textAlign = a), Bn(i, e, !1), i;
|
|
1477
1618
|
}
|
|
1478
|
-
function
|
|
1619
|
+
function Hn(e, t) {
|
|
1479
1620
|
e.replaceChildren();
|
|
1480
1621
|
let n = t.aligns.length, r = e.createTHead().insertRow();
|
|
1481
|
-
for (let e = 0; e < n; e++) r.appendChild(
|
|
1622
|
+
for (let e = 0; e < n; e++) r.appendChild(Vn(t, 0, e, !0));
|
|
1482
1623
|
let i = e.createTBody();
|
|
1483
1624
|
for (let e = 1; e < t.rows.length; e++) {
|
|
1484
1625
|
let r = i.insertRow();
|
|
1485
|
-
for (let i = 0; i < n; i++) r.appendChild(
|
|
1626
|
+
for (let i = 0; i < n; i++) r.appendChild(Vn(t, e, i, !1));
|
|
1486
1627
|
}
|
|
1487
1628
|
}
|
|
1488
1629
|
//#endregion
|
|
1489
1630
|
//#region src/inplace/table-structure.ts
|
|
1490
1631
|
var Q = (e) => e.aligns.length;
|
|
1491
|
-
function
|
|
1632
|
+
function Un(e, t) {
|
|
1492
1633
|
let n = Math.max(0, Math.min(t, Q(e)));
|
|
1493
1634
|
for (let t of e.rows) t.splice(n, 0, "");
|
|
1494
1635
|
e.aligns.splice(n, 0, "");
|
|
1495
1636
|
}
|
|
1496
|
-
function
|
|
1637
|
+
function Wn(e, t) {
|
|
1497
1638
|
if (!(Q(e) <= 1 || t < 0 || t >= Q(e))) {
|
|
1498
1639
|
for (let n of e.rows) n.splice(t, 1);
|
|
1499
1640
|
e.aligns.splice(t, 1);
|
|
1500
1641
|
}
|
|
1501
1642
|
}
|
|
1502
|
-
function
|
|
1643
|
+
function Gn(e, t) {
|
|
1503
1644
|
let n = Math.max(1, Math.min(t, e.rows.length));
|
|
1504
1645
|
e.rows.splice(n, 0, Array(Q(e)).fill(""));
|
|
1505
1646
|
}
|
|
1506
|
-
function
|
|
1647
|
+
function Kn(e, t) {
|
|
1507
1648
|
t <= 0 || t >= e.rows.length || e.rows.length <= 2 || e.rows.splice(t, 1);
|
|
1508
1649
|
}
|
|
1509
|
-
function
|
|
1650
|
+
function qn(e, t, n) {
|
|
1510
1651
|
t >= 0 && t < Q(e) && (e.aligns[t] = n);
|
|
1511
1652
|
}
|
|
1512
1653
|
//#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 {
|
|
1654
|
+
//#region src/inplace/table-widget.ts
|
|
1655
|
+
var $ = we.define(), Jn = class extends E {
|
|
1595
1656
|
data;
|
|
1596
1657
|
embeds;
|
|
1597
1658
|
table = null;
|
|
@@ -1603,10 +1664,10 @@ var Rn = M.define({
|
|
|
1603
1664
|
longPress = null;
|
|
1604
1665
|
longPressAt = 0;
|
|
1605
1666
|
constructor(e, t = !1) {
|
|
1606
|
-
super(), this.data = e, this.embeds = t, this.rows =
|
|
1667
|
+
super(), this.data = e, this.embeds = t, this.rows = v(e);
|
|
1607
1668
|
}
|
|
1608
1669
|
eq(e) {
|
|
1609
|
-
return !this.table && JSON.stringify(
|
|
1670
|
+
return !this.table && JSON.stringify(y(this.rows)) === JSON.stringify(y(e.rows));
|
|
1610
1671
|
}
|
|
1611
1672
|
ignoreEvent() {
|
|
1612
1673
|
return !0;
|
|
@@ -1616,7 +1677,7 @@ var Rn = M.define({
|
|
|
1616
1677
|
}
|
|
1617
1678
|
bounds(e) {
|
|
1618
1679
|
let t = e.posAtDOM(this.table), n = null;
|
|
1619
|
-
return e.state.field(
|
|
1680
|
+
return e.state.field(Y).between(t, t, (e, t) => (n = {
|
|
1620
1681
|
from: e,
|
|
1621
1682
|
to: t
|
|
1622
1683
|
}, !1)), n ?? e.state.doc.lineAt(t);
|
|
@@ -1631,21 +1692,21 @@ var Rn = M.define({
|
|
|
1631
1692
|
};
|
|
1632
1693
|
}
|
|
1633
1694
|
paint(e, t) {
|
|
1634
|
-
|
|
1695
|
+
Bn(e, {
|
|
1635
1696
|
rows: this.rows,
|
|
1636
1697
|
aligns: this.data.aligns,
|
|
1637
1698
|
embeds: this.embeds
|
|
1638
1699
|
}, t);
|
|
1639
1700
|
}
|
|
1640
1701
|
renderCells() {
|
|
1641
|
-
|
|
1702
|
+
Hn(this.table, {
|
|
1642
1703
|
rows: this.rows,
|
|
1643
1704
|
aligns: this.data.aligns,
|
|
1644
1705
|
embeds: this.embeds
|
|
1645
1706
|
});
|
|
1646
1707
|
}
|
|
1647
1708
|
appendRow() {
|
|
1648
|
-
|
|
1709
|
+
Gn(this.model(), this.rows.length), this.renderCells(), this.gizmos?.layout(this.table);
|
|
1649
1710
|
}
|
|
1650
1711
|
model() {
|
|
1651
1712
|
return {
|
|
@@ -1656,7 +1717,7 @@ var Rn = M.define({
|
|
|
1656
1717
|
runOp(e, t) {
|
|
1657
1718
|
if (!this.table) return;
|
|
1658
1719
|
let n = this.model();
|
|
1659
|
-
if (t.kind === "insertColumn" ?
|
|
1720
|
+
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
1721
|
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
1722
|
this.cellAt(e, n)?.focus();
|
|
1662
1723
|
}
|
|
@@ -1668,7 +1729,7 @@ var Rn = M.define({
|
|
|
1668
1729
|
onFocusIn(e) {
|
|
1669
1730
|
let t = e.target.closest("td, th");
|
|
1670
1731
|
if (!t || t === this.editing) return;
|
|
1671
|
-
let n = this.pendingOffset ??
|
|
1732
|
+
let n = this.pendingOffset ?? ue(t);
|
|
1672
1733
|
this.pendingOffset = null, this.editing && this.finish(this.editing, !1), this.editing = t, this.paint(t, !0), d(t, n);
|
|
1673
1734
|
}
|
|
1674
1735
|
onFocusOut(e) {
|
|
@@ -1709,7 +1770,7 @@ var Rn = M.define({
|
|
|
1709
1770
|
})));
|
|
1710
1771
|
}
|
|
1711
1772
|
onKey(e, t) {
|
|
1712
|
-
this.table &&
|
|
1773
|
+
this.table && zn(e, t, {
|
|
1713
1774
|
coords: (e) => this.coords(e),
|
|
1714
1775
|
rows: () => this.rows.length,
|
|
1715
1776
|
cols: () => this.cols(),
|
|
@@ -1732,8 +1793,8 @@ var Rn = M.define({
|
|
|
1732
1793
|
openCellMenuAt(e, t, n, r) {
|
|
1733
1794
|
let i = r?.closest("td, th");
|
|
1734
1795
|
if (!i) return;
|
|
1735
|
-
this.editing === i && !
|
|
1736
|
-
let a =
|
|
1796
|
+
this.editing === i && !Z(e) && s(i, t, n);
|
|
1797
|
+
let a = Nn(e);
|
|
1737
1798
|
this.gizmos?.openFor(i, t, n, a);
|
|
1738
1799
|
}
|
|
1739
1800
|
toDOM(e) {
|
|
@@ -1743,7 +1804,7 @@ var Rn = M.define({
|
|
|
1743
1804
|
this.table = n, this.editing = null, n.className = "cm-inplace-table cm-inplace-table-edit", this.renderCells(), n.addEventListener("mousedown", (e) => {
|
|
1744
1805
|
e.stopPropagation();
|
|
1745
1806
|
let t = e.target.closest("td, th");
|
|
1746
|
-
this.pendingOffset = t && t !== this.editing ?
|
|
1807
|
+
this.pendingOffset = t && t !== this.editing ? de(t, e.clientX, e.clientY) : null;
|
|
1747
1808
|
}), n.addEventListener("focusin", (e) => this.onFocusIn(e)), n.addEventListener("focusout", (e) => this.onFocusOut(e));
|
|
1748
1809
|
let r = (t) => {
|
|
1749
1810
|
t && (this.editing = t, this.finish(t, !0), this.sync(e));
|
|
@@ -1756,9 +1817,9 @@ var Rn = M.define({
|
|
|
1756
1817
|
document.execCommand("insertText", !1, t);
|
|
1757
1818
|
}), n.addEventListener("contextmenu", (t) => {
|
|
1758
1819
|
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 =
|
|
1820
|
+
}), this.longPress = Ln(n, { onLongPress: (t, n, r) => {
|
|
1760
1821
|
this.longPressAt = Date.now(), this.openCellMenuAt(e, t, n, r);
|
|
1761
|
-
} }), this.gizmos =
|
|
1822
|
+
} }), this.gizmos = Rn(document, {
|
|
1762
1823
|
dims: () => ({
|
|
1763
1824
|
cols: this.cols(),
|
|
1764
1825
|
rows: this.rows.length,
|
|
@@ -1770,11 +1831,11 @@ var Rn = M.define({
|
|
|
1770
1831
|
destroy() {
|
|
1771
1832
|
this.longPress?.dispose(), this.longPress = null, this.gizmos?.destroy(), this.gizmos = null, this.table = null, this.editing = null;
|
|
1772
1833
|
}
|
|
1773
|
-
},
|
|
1834
|
+
}, Yn = /* @__PURE__ */ new Set([
|
|
1774
1835
|
"-",
|
|
1775
1836
|
"*",
|
|
1776
1837
|
"_"
|
|
1777
|
-
]),
|
|
1838
|
+
]), Xn = Ee.transactionFilter.of((e) => {
|
|
1778
1839
|
if (!e.docChanged || e.isUserEvent("undo") || e.isUserEvent("redo") || e.annotation($) || !e.startState.selection.main.empty) return e;
|
|
1779
1840
|
let t = e.startState.selection.main.head, n = "", r = 0;
|
|
1780
1841
|
if (e.changes.iterChanges((e, i, a, o, s) => {
|
|
@@ -1805,7 +1866,7 @@ var Rn = M.define({
|
|
|
1805
1866
|
},
|
|
1806
1867
|
anchor: a + 1
|
|
1807
1868
|
};
|
|
1808
|
-
else if (
|
|
1869
|
+
else if (Yn.has(n) && RegExp(`^\\${n}{3,}$`).test(s)) {
|
|
1809
1870
|
let e = o.number === 1 || i.line(o.number - 1).text.trim() === "", t = n === "-" && !e, r = o.number === i.lines;
|
|
1810
1871
|
if (t || r) {
|
|
1811
1872
|
let e = [];
|
|
@@ -1828,38 +1889,38 @@ var Rn = M.define({
|
|
|
1828
1889
|
scrollIntoView: !0,
|
|
1829
1890
|
userEvent: "input.autoformat"
|
|
1830
1891
|
}] : e;
|
|
1831
|
-
}),
|
|
1892
|
+
}), Zn = /* @__PURE__ */ new Set([
|
|
1832
1893
|
"EmphasisMark",
|
|
1833
1894
|
"CodeMark",
|
|
1834
1895
|
"StrikethroughMark"
|
|
1835
1896
|
]);
|
|
1836
|
-
function
|
|
1897
|
+
function Qn(e, t, n) {
|
|
1837
1898
|
let r = t;
|
|
1838
1899
|
for (;;) {
|
|
1839
1900
|
let t = e.resolveInner(r, n);
|
|
1840
|
-
if (!
|
|
1901
|
+
if (!Zn.has(t.name) || t.from >= t.to) return r;
|
|
1841
1902
|
let i = n < 0 ? t.from : t.to;
|
|
1842
1903
|
if (i === r) return r;
|
|
1843
1904
|
r = i;
|
|
1844
1905
|
}
|
|
1845
1906
|
}
|
|
1846
|
-
function
|
|
1847
|
-
let n =
|
|
1907
|
+
function $n(e, t) {
|
|
1908
|
+
let n = V(e, t, !0);
|
|
1848
1909
|
if (!n) return t;
|
|
1849
|
-
let r =
|
|
1850
|
-
return t === n.contentTo ?
|
|
1910
|
+
let r = j(e);
|
|
1911
|
+
return t === n.contentTo ? Qn(r, t, 1) : t === n.contentFrom ? Qn(r, t, -1) : t;
|
|
1851
1912
|
}
|
|
1852
|
-
var
|
|
1913
|
+
var er = Ee.transactionFilter.of((e) => {
|
|
1853
1914
|
if (!e.docChanged || e.isUserEvent("undo") || e.isUserEvent("redo") || e.annotation($)) return e;
|
|
1854
1915
|
let t = e.startState, n = t.selection.main;
|
|
1855
|
-
if (!n.empty || !
|
|
1916
|
+
if (!n.empty || !B(t, t.doc.lineAt(n.head).number)) return e;
|
|
1856
1917
|
let r = [], i = 0;
|
|
1857
1918
|
e.changes.iterChanges((e, t, a, o, s) => {
|
|
1858
1919
|
i++, e === t && e === n.head && s.length > 0 && r.push(s.toString());
|
|
1859
1920
|
});
|
|
1860
1921
|
let a = r[0];
|
|
1861
1922
|
if (i !== 1 || a === void 0) return e;
|
|
1862
|
-
let o =
|
|
1923
|
+
let o = $n(t, n.head);
|
|
1863
1924
|
return o === n.head ? e : {
|
|
1864
1925
|
changes: {
|
|
1865
1926
|
from: o,
|
|
@@ -1869,25 +1930,25 @@ var Gn = Ce.transactionFilter.of((e) => {
|
|
|
1869
1930
|
scrollIntoView: !0,
|
|
1870
1931
|
userEvent: "input.type"
|
|
1871
1932
|
};
|
|
1872
|
-
}),
|
|
1873
|
-
function
|
|
1933
|
+
}), tr = RegExp(`^(?:${_.match.source.replace(/^\^/, "")})+`);
|
|
1934
|
+
function nr(e, t) {
|
|
1874
1935
|
let n = e.doc.lineAt(t).number;
|
|
1875
|
-
for (let r =
|
|
1936
|
+
for (let r = j(e).resolveInner(t, 1); r; r = r.parent) {
|
|
1876
1937
|
if (r.name !== "ListItem" || e.doc.lineAt(r.from).number === n) continue;
|
|
1877
1938
|
let t = u.exec(e.doc.lineAt(r.from).text);
|
|
1878
1939
|
if (t) return t[0].length;
|
|
1879
1940
|
}
|
|
1880
1941
|
return null;
|
|
1881
1942
|
}
|
|
1882
|
-
function
|
|
1883
|
-
let n = t.text, r =
|
|
1943
|
+
function rr(e, t) {
|
|
1944
|
+
let n = t.text, r = oe.exec(n);
|
|
1884
1945
|
if (r) return {
|
|
1885
1946
|
prefixLen: r[0].length,
|
|
1886
1947
|
drop: [0, r[0].length]
|
|
1887
1948
|
};
|
|
1888
|
-
let i =
|
|
1949
|
+
let i = tr.exec(n);
|
|
1889
1950
|
if (i) {
|
|
1890
|
-
let e =
|
|
1951
|
+
let e = _.match.exec(n)[0].length;
|
|
1891
1952
|
return {
|
|
1892
1953
|
prefixLen: i[0].length,
|
|
1893
1954
|
drop: [0, e]
|
|
@@ -1898,11 +1959,11 @@ function Jn(e, t) {
|
|
|
1898
1959
|
prefixLen: a[0].length,
|
|
1899
1960
|
drop: [0, a[0].length]
|
|
1900
1961
|
};
|
|
1901
|
-
let o = te.match.exec(n) ??
|
|
1962
|
+
let o = te.match.exec(n) ?? ae.match.exec(n);
|
|
1902
1963
|
if (o) {
|
|
1903
1964
|
let n = o[1] ?? "", r = o[0].length - n.length;
|
|
1904
1965
|
if (n) {
|
|
1905
|
-
let r =
|
|
1966
|
+
let r = nr(e, t.from) ?? 2, i = n.startsWith(" ") ? 1 : Math.min(r, n.length);
|
|
1906
1967
|
return {
|
|
1907
1968
|
prefixLen: o[0].length,
|
|
1908
1969
|
drop: [0, i]
|
|
@@ -1915,15 +1976,15 @@ function Jn(e, t) {
|
|
|
1915
1976
|
}
|
|
1916
1977
|
return null;
|
|
1917
1978
|
}
|
|
1918
|
-
var
|
|
1979
|
+
var ir = k.high(D.of([{
|
|
1919
1980
|
key: "Backspace",
|
|
1920
1981
|
run: (e) => {
|
|
1921
1982
|
if (h(e)) return !1;
|
|
1922
1983
|
let { state: t } = e, n = t.selection.main;
|
|
1923
1984
|
if (!n.empty) return !1;
|
|
1924
1985
|
let r = t.doc.lineAt(n.head);
|
|
1925
|
-
if (!
|
|
1926
|
-
let i =
|
|
1986
|
+
if (!B(t, r.number)) return !1;
|
|
1987
|
+
let i = rr(t, r);
|
|
1927
1988
|
if (!i || n.head < r.from || n.head > r.from + i.prefixLen) return !1;
|
|
1928
1989
|
let [a, o] = i.drop;
|
|
1929
1990
|
return e.dispatch({
|
|
@@ -1937,13 +1998,13 @@ var Yn = j.high(k.of([{
|
|
|
1937
1998
|
scrollIntoView: !0
|
|
1938
1999
|
}), !0;
|
|
1939
2000
|
}
|
|
1940
|
-
}])),
|
|
2001
|
+
}])), ar = class {
|
|
1941
2002
|
menu;
|
|
1942
2003
|
contentDOM;
|
|
1943
2004
|
onClick;
|
|
1944
2005
|
constructor(e) {
|
|
1945
|
-
this.menu =
|
|
1946
|
-
if (e.state.facet(
|
|
2006
|
+
this.menu = X(e.dom.ownerDocument), e.dom.appendChild(this.menu.el), this.contentDOM = e.contentDOM, this.onClick = (t) => {
|
|
2007
|
+
if (e.state.facet(F) !== "never" || !e.state.facet(M).links) return;
|
|
1947
2008
|
let n = t.target?.closest(".cm-inplace-link");
|
|
1948
2009
|
if (!n || n.classList.contains("cm-inplace-wikilink")) return;
|
|
1949
2010
|
let r = e.posAtDOM(n);
|
|
@@ -1955,13 +2016,13 @@ var Yn = j.high(k.of([{
|
|
|
1955
2016
|
if (n == null) return;
|
|
1956
2017
|
r = n;
|
|
1957
2018
|
}
|
|
1958
|
-
e.dispatch({ selection: { anchor: r } }), this.menu.showField(
|
|
2019
|
+
e.dispatch({ selection: { anchor: r } }), this.menu.showField(bn(e), t.clientX, t.clientY);
|
|
1959
2020
|
}, this.contentDOM.addEventListener("click", this.onClick);
|
|
1960
2021
|
}
|
|
1961
2022
|
destroy() {
|
|
1962
2023
|
this.contentDOM.removeEventListener("click", this.onClick), this.menu.destroy();
|
|
1963
2024
|
}
|
|
1964
|
-
},
|
|
2025
|
+
}, or = T.fromClass(ar), sr = (e) => e.replace(/^<([^]*)>$/, "$1").trim(), cr = (e, t, n) => n ? {
|
|
1965
2026
|
pos: e,
|
|
1966
2027
|
end: t,
|
|
1967
2028
|
above: !0,
|
|
@@ -1970,27 +2031,27 @@ var Yn = j.high(k.of([{
|
|
|
1970
2031
|
return e.className = "cm-inplace-href-tip", e.textContent = n, { dom: e };
|
|
1971
2032
|
}
|
|
1972
2033
|
} : null;
|
|
1973
|
-
function
|
|
1974
|
-
for (let n =
|
|
2034
|
+
function lr(e, t) {
|
|
2035
|
+
for (let n = j(e.state).resolveInner(t, -1); n; n = n.parent) {
|
|
1975
2036
|
if (n.name !== "Link") continue;
|
|
1976
2037
|
if (e.state.doc.sliceString(Math.max(0, n.from - 1), n.from) === "[") break;
|
|
1977
2038
|
let t = n.getChild("URL"), r = t ? e.state.sliceDoc(t.from, t.to) : e.state.sliceDoc(n.from, n.to);
|
|
1978
|
-
return
|
|
2039
|
+
return cr(n.from, n.to, sr(r));
|
|
1979
2040
|
}
|
|
1980
2041
|
return null;
|
|
1981
2042
|
}
|
|
1982
|
-
function
|
|
2043
|
+
function ur(t, n) {
|
|
1983
2044
|
let r = t.state.doc.lineAt(n);
|
|
1984
2045
|
for (let t of r.text.matchAll(e)) {
|
|
1985
2046
|
let e = r.from + (t.index ?? 0), i = e + t[0].length;
|
|
1986
|
-
if (!(n < e || n > i)) return
|
|
2047
|
+
if (!(n < e || n > i)) return cr(e, i, (t[1] ?? "").trim());
|
|
1987
2048
|
}
|
|
1988
2049
|
return null;
|
|
1989
2050
|
}
|
|
1990
|
-
var
|
|
1991
|
-
let n = e.state.facet(
|
|
1992
|
-
return (n.links ?
|
|
1993
|
-
}),
|
|
2051
|
+
var dr = be((e, t) => {
|
|
2052
|
+
let n = e.state.facet(M);
|
|
2053
|
+
return (n.links ? lr(e, t) : null) ?? (n.wikilinks ? ur(e, t) : null);
|
|
2054
|
+
}), fr = class extends E {
|
|
1994
2055
|
ref;
|
|
1995
2056
|
inline;
|
|
1996
2057
|
registry;
|
|
@@ -2017,52 +2078,52 @@ var nr = ve((e, t) => {
|
|
|
2017
2078
|
return !1;
|
|
2018
2079
|
}
|
|
2019
2080
|
};
|
|
2020
|
-
function
|
|
2021
|
-
let t = e.facet(
|
|
2022
|
-
if (!t || !e.facet(
|
|
2023
|
-
let n =
|
|
2081
|
+
function pr(e) {
|
|
2082
|
+
let t = e.facet(N);
|
|
2083
|
+
if (!t || !e.facet(M).embeds || !e.doc.toString().includes("![[")) return C.none;
|
|
2084
|
+
let n = R(e), r = j(e), i = [];
|
|
2024
2085
|
for (let a = 1; a <= e.doc.lines; a++) {
|
|
2025
2086
|
let o = e.doc.line(a);
|
|
2026
2087
|
if (!(!o.text.includes("![[") || n.has(a))) {
|
|
2027
|
-
if (
|
|
2028
|
-
|
|
2029
|
-
let e = (
|
|
2030
|
-
if (!e ||
|
|
2031
|
-
i.push(
|
|
2032
|
-
widget: new
|
|
2088
|
+
if (me(o.text)) {
|
|
2089
|
+
x.lastIndex = 0;
|
|
2090
|
+
let e = (x.exec(o.text.trim())?.[1] ?? "").trim();
|
|
2091
|
+
if (!e || z(r, o.from + o.text.indexOf("!["))) continue;
|
|
2092
|
+
i.push(C.replace({
|
|
2093
|
+
widget: new fr(e, !1, t),
|
|
2033
2094
|
block: !0
|
|
2034
2095
|
}).range(o.from, o.to));
|
|
2035
2096
|
continue;
|
|
2036
2097
|
}
|
|
2037
|
-
|
|
2038
|
-
for (let e of o.text.matchAll(
|
|
2098
|
+
x.lastIndex = 0;
|
|
2099
|
+
for (let e of o.text.matchAll(x)) {
|
|
2039
2100
|
let n = (e[1] ?? "").trim();
|
|
2040
2101
|
if (!n) continue;
|
|
2041
2102
|
let a = o.from + (e.index ?? 0);
|
|
2042
|
-
|
|
2103
|
+
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
2104
|
}
|
|
2044
2105
|
}
|
|
2045
2106
|
}
|
|
2046
|
-
return
|
|
2107
|
+
return C.set(i, !0);
|
|
2047
2108
|
}
|
|
2048
|
-
function
|
|
2109
|
+
function mr(e, t) {
|
|
2049
2110
|
for (let n of t.ranges) {
|
|
2050
2111
|
let t = e.doc.lineAt(n.from).number, r = e.doc.lineAt(n.to).number;
|
|
2051
2112
|
for (let n = t; n <= r; n++) if (e.doc.line(n).text.includes("![[")) return !0;
|
|
2052
2113
|
}
|
|
2053
2114
|
return !1;
|
|
2054
2115
|
}
|
|
2055
|
-
var
|
|
2056
|
-
create:
|
|
2057
|
-
update: (e, t) => t.docChanged || t.selection && (
|
|
2058
|
-
provide: (e) => [
|
|
2059
|
-
}),
|
|
2116
|
+
var hr = A.define({
|
|
2117
|
+
create: pr,
|
|
2118
|
+
update: (e, t) => t.docChanged || t.selection && (mr(t.state, t.startState.selection) || mr(t.state, t.state.selection)) ? pr(t.state) : e,
|
|
2119
|
+
provide: (e) => [w.decorations.from(e), w.atomicRanges.of((t) => t.state.field(e))]
|
|
2120
|
+
}), gr = De.define(), _r = A.define({
|
|
2060
2121
|
create: () => !1,
|
|
2061
2122
|
update(e, t) {
|
|
2062
|
-
for (let n of t.effects) n.is(
|
|
2123
|
+
for (let n of t.effects) n.is(gr) && (e = n.value);
|
|
2063
2124
|
return e;
|
|
2064
2125
|
}
|
|
2065
|
-
}),
|
|
2126
|
+
}), vr = class {
|
|
2066
2127
|
view;
|
|
2067
2128
|
menu;
|
|
2068
2129
|
onContextMenu;
|
|
@@ -2073,29 +2134,36 @@ var or = M.define({
|
|
|
2073
2134
|
longPressAt = 0;
|
|
2074
2135
|
destroyed = !1;
|
|
2075
2136
|
constructor(e) {
|
|
2076
|
-
this.view = e, this.menu =
|
|
2077
|
-
this.destroyed || e.dispatch({ effects:
|
|
2137
|
+
this.view = e, this.menu = X(e.dom.ownerDocument, "cm-inplace-menu", (t) => {
|
|
2138
|
+
this.destroyed || e.dispatch({ effects: gr.of(t) });
|
|
2078
2139
|
}), e.dom.appendChild(this.menu.el), this.contentDOM = e.contentDOM, this.onPointerDown = () => {
|
|
2079
2140
|
let t = e.state.selection.main;
|
|
2080
2141
|
this.stashed = t.empty ? null : {
|
|
2081
2142
|
anchor: t.anchor,
|
|
2082
2143
|
head: t.head
|
|
2083
2144
|
};
|
|
2084
|
-
}, this.contentDOM.addEventListener("pointerdown", this.onPointerDown, !0), this.onContextMenu = (
|
|
2085
|
-
let
|
|
2086
|
-
|
|
2087
|
-
}, this.contentDOM.addEventListener("contextmenu", this.onContextMenu), this.longPress =
|
|
2145
|
+
}, this.contentDOM.addEventListener("pointerdown", this.onPointerDown, !0), this.onContextMenu = (e) => {
|
|
2146
|
+
let t = e.target;
|
|
2147
|
+
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()));
|
|
2148
|
+
}, this.contentDOM.addEventListener("contextmenu", this.onContextMenu), this.longPress = Ln(this.contentDOM, { onLongPress: (e, t, n) => {
|
|
2088
2149
|
this.longPressAt = Date.now(), this.openMenuAt(e, t, n);
|
|
2089
2150
|
} });
|
|
2090
2151
|
}
|
|
2152
|
+
canOpen() {
|
|
2153
|
+
let { state: e } = this.view;
|
|
2154
|
+
return e.facet(Fe) && (!e.readOnly || fn(this.view));
|
|
2155
|
+
}
|
|
2156
|
+
rows() {
|
|
2157
|
+
let e = this.view;
|
|
2158
|
+
return e.state.readOnly ? pn(e, { selected: !e.state.selection.main.empty }) : In(e);
|
|
2159
|
+
}
|
|
2091
2160
|
openMenuAt(e, t, n) {
|
|
2092
2161
|
let r = this.view;
|
|
2093
|
-
if (!
|
|
2162
|
+
if (!this.canOpen() || n?.closest(".cm-inplace-table-edit")) return !1;
|
|
2094
2163
|
let i = n?.closest(".cm-inplace-hr");
|
|
2095
2164
|
if (i) {
|
|
2096
2165
|
let n = r.posAtDOM(i);
|
|
2097
|
-
n >= 0 && r.dispatch({ selection: { anchor: n } }), this.
|
|
2098
|
-
return;
|
|
2166
|
+
return n >= 0 && r.dispatch({ selection: { anchor: n } }), this.show(e, t);
|
|
2099
2167
|
}
|
|
2100
2168
|
if (this.stashed && r.state.selection.main.empty) r.dispatch({ selection: this.stashed });
|
|
2101
2169
|
else if (r.state.selection.main.empty) {
|
|
@@ -2104,7 +2172,7 @@ var or = M.define({
|
|
|
2104
2172
|
y: t
|
|
2105
2173
|
});
|
|
2106
2174
|
if (n != null) {
|
|
2107
|
-
let e =
|
|
2175
|
+
let e = V(r.state, n, !1, !0), t = r.state.wordAt(n) ?? { anchor: n };
|
|
2108
2176
|
e?.kind === "link" ? t = {
|
|
2109
2177
|
anchor: e.from,
|
|
2110
2178
|
head: e.to
|
|
@@ -2114,15 +2182,19 @@ var or = M.define({
|
|
|
2114
2182
|
}), r.dispatch({ selection: t });
|
|
2115
2183
|
}
|
|
2116
2184
|
}
|
|
2117
|
-
this.
|
|
2185
|
+
return this.show(e, t);
|
|
2186
|
+
}
|
|
2187
|
+
show(e, t) {
|
|
2188
|
+
let n = this.rows();
|
|
2189
|
+
return n.length ? (this.menu.show(n, e, t), !0) : !1;
|
|
2118
2190
|
}
|
|
2119
2191
|
destroy() {
|
|
2120
2192
|
this.destroyed = !0, this.contentDOM.removeEventListener("pointerdown", this.onPointerDown, !0), this.contentDOM.removeEventListener("contextmenu", this.onContextMenu), this.longPress.dispose(), this.menu.destroy();
|
|
2121
2193
|
}
|
|
2122
|
-
},
|
|
2194
|
+
}, yr = T.fromClass(vr);
|
|
2123
2195
|
//#endregion
|
|
2124
2196
|
//#region src/inplace/selection-bar-position.ts
|
|
2125
|
-
function
|
|
2197
|
+
function br(e) {
|
|
2126
2198
|
let t = e.state.selection.main;
|
|
2127
2199
|
if (!t.empty) {
|
|
2128
2200
|
let n = e.coordsAtPos(t.from), r = e.coordsAtPos(t.to);
|
|
@@ -2136,7 +2208,7 @@ function dr(e) {
|
|
|
2136
2208
|
}
|
|
2137
2209
|
};
|
|
2138
2210
|
}
|
|
2139
|
-
if (!
|
|
2211
|
+
if (!Z(e)) return null;
|
|
2140
2212
|
let n = e.dom.ownerDocument.getSelection();
|
|
2141
2213
|
if (!n || n.rangeCount === 0) return null;
|
|
2142
2214
|
let r = n.getRangeAt(0).getBoundingClientRect();
|
|
@@ -2150,15 +2222,15 @@ function dr(e) {
|
|
|
2150
2222
|
}
|
|
2151
2223
|
};
|
|
2152
2224
|
}
|
|
2153
|
-
function
|
|
2154
|
-
if (e.state.facet(
|
|
2155
|
-
let r =
|
|
2225
|
+
function xr(e, t, n) {
|
|
2226
|
+
if (e.state.facet(Ve) !== "bar" || e.state.readOnly || e.state.field(_r, !1)) return null;
|
|
2227
|
+
let r = br(e);
|
|
2156
2228
|
if (!r) return null;
|
|
2157
2229
|
let { box: i, inCell: a } = r;
|
|
2158
2230
|
if (!a && !e.hasFocus) return null;
|
|
2159
2231
|
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
2232
|
for (let t of n) {
|
|
2161
|
-
let n =
|
|
2233
|
+
let n = g[t], r = !a && !!n.disabled?.(e.state);
|
|
2162
2234
|
f[t] = r, p[t] = !r && !a && !!n.isActive?.(e.state);
|
|
2163
2235
|
}
|
|
2164
2236
|
return n.every((e) => f[e]) ? null : {
|
|
@@ -2170,7 +2242,7 @@ function fr(e, t, n) {
|
|
|
2170
2242
|
}
|
|
2171
2243
|
//#endregion
|
|
2172
2244
|
//#region src/inplace/selection-bar.ts
|
|
2173
|
-
var
|
|
2245
|
+
var Sr = class {
|
|
2174
2246
|
view;
|
|
2175
2247
|
bar;
|
|
2176
2248
|
ids;
|
|
@@ -2185,12 +2257,12 @@ var pr = class {
|
|
|
2185
2257
|
constructor(e) {
|
|
2186
2258
|
this.view = e;
|
|
2187
2259
|
let t = e.dom.ownerDocument;
|
|
2188
|
-
this.ids = e.state.facet(
|
|
2260
|
+
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
2261
|
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(
|
|
2262
|
+
let r = g[n], i = t.createElement("button");
|
|
2263
|
+
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
2264
|
t.preventDefault();
|
|
2193
|
-
let a = !!h(e), o = !a && n === "link" ?
|
|
2265
|
+
let a = !!h(e), o = !a && n === "link" ? bn(e) : !a && n === "wikilink" ? xn(e) : null;
|
|
2194
2266
|
if (o) {
|
|
2195
2267
|
let e = i.getBoundingClientRect();
|
|
2196
2268
|
this.linkMenu.showField(o, e.left, e.bottom + 6);
|
|
@@ -2202,7 +2274,7 @@ var pr = class {
|
|
|
2202
2274
|
e.dom.appendChild(this.bar), t.addEventListener("scroll", this.onScroll, !0), t.addEventListener("selectionchange", this.onSelectionChange);
|
|
2203
2275
|
}
|
|
2204
2276
|
update(e) {
|
|
2205
|
-
let t = e.startState.field(
|
|
2277
|
+
let t = e.startState.field(_r, !1) !== e.state.field(_r, !1), n = e.startState.readOnly !== e.state.readOnly;
|
|
2206
2278
|
(e.selectionSet || e.docChanged || e.focusChanged || t || n) && this.schedule();
|
|
2207
2279
|
}
|
|
2208
2280
|
schedule() {
|
|
@@ -2213,7 +2285,7 @@ var pr = class {
|
|
|
2213
2285
|
});
|
|
2214
2286
|
}
|
|
2215
2287
|
measure() {
|
|
2216
|
-
return
|
|
2288
|
+
return xr(this.view, this.bar, this.ids);
|
|
2217
2289
|
}
|
|
2218
2290
|
apply(e) {
|
|
2219
2291
|
if (!e) {
|
|
@@ -2227,30 +2299,30 @@ var pr = class {
|
|
|
2227
2299
|
let e = this.view.dom.ownerDocument;
|
|
2228
2300
|
e.removeEventListener("scroll", this.onScroll, !0), e.removeEventListener("selectionchange", this.onSelectionChange), this.linkMenu.destroy(), this.bar.remove();
|
|
2229
2301
|
}
|
|
2230
|
-
},
|
|
2302
|
+
}, Cr = T.fromClass(Sr), wr = (e) => (t) => {
|
|
2231
2303
|
if (h(t)) return !1;
|
|
2232
2304
|
let n = t.state.selection.main;
|
|
2233
2305
|
if (!n.empty) return !1;
|
|
2234
2306
|
let { doc: r } = t.state, i = r.lineAt(n.head), a = e ? i.number + 1 : i.number - 1;
|
|
2235
2307
|
if (a < 1 || a > r.lines) return !1;
|
|
2236
2308
|
let o = r.line(a), s = -1, c = -1, l;
|
|
2237
|
-
if (t.state.field(
|
|
2309
|
+
if (t.state.field(Y).between(o.from, o.to, (t, n, r) => {
|
|
2238
2310
|
if (e ? t === o.from : n === o.to) return s = t, c = n, l = r.spec.widget, !1;
|
|
2239
2311
|
}), s < 0) return !1;
|
|
2240
|
-
if (t.state.facet(
|
|
2312
|
+
if (t.state.facet(P) === "cells") return l instanceof Jn && l.focusEdge(e ? "first" : "last");
|
|
2241
2313
|
let u = e ? r.lineAt(s).from : r.lineAt(c).to;
|
|
2242
2314
|
return t.dispatch({
|
|
2243
2315
|
selection: { anchor: u },
|
|
2244
2316
|
userEvent: "select",
|
|
2245
2317
|
scrollIntoView: !0
|
|
2246
2318
|
}), !0;
|
|
2247
|
-
},
|
|
2319
|
+
}, Tr = wr(!0), Er = wr(!1), Dr = k.high(D.of([{
|
|
2248
2320
|
key: "ArrowDown",
|
|
2249
|
-
run:
|
|
2321
|
+
run: Tr
|
|
2250
2322
|
}, {
|
|
2251
2323
|
key: "ArrowUp",
|
|
2252
|
-
run:
|
|
2253
|
-
}])),
|
|
2324
|
+
run: Er
|
|
2325
|
+
}])), Or = {
|
|
2254
2326
|
".cm-inplace-callout": {
|
|
2255
2327
|
borderLeft: "0.25rem solid var(--stylo-callout-accent, var(--stylo-border))",
|
|
2256
2328
|
padding: "0 var(--stylo-rhythm-callout-padding-x, 1rem)",
|
|
@@ -2284,9 +2356,9 @@ var pr = class {
|
|
|
2284
2356
|
content: "\"\"",
|
|
2285
2357
|
display: "none"
|
|
2286
2358
|
}
|
|
2287
|
-
},
|
|
2359
|
+
}, 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
2360
|
"& .cm-content": {
|
|
2289
|
-
fontFamily:
|
|
2361
|
+
fontFamily: Ar,
|
|
2290
2362
|
lineHeight: "1.75",
|
|
2291
2363
|
padding: "0.75rem",
|
|
2292
2364
|
WebkitTouchCallout: "none"
|
|
@@ -2329,14 +2401,14 @@ var pr = class {
|
|
|
2329
2401
|
".cm-inplace-em": { fontStyle: "italic" },
|
|
2330
2402
|
".cm-inplace-strike": { textDecoration: "line-through" },
|
|
2331
2403
|
".cm-inplace-code": {
|
|
2332
|
-
fontFamily:
|
|
2404
|
+
fontFamily: kr,
|
|
2333
2405
|
fontSize: "0.9em",
|
|
2334
2406
|
padding: "0.1em 0.35em",
|
|
2335
2407
|
borderRadius: "3px",
|
|
2336
2408
|
background: "color-mix(in srgb, var(--stylo-border) 45%, transparent)"
|
|
2337
2409
|
},
|
|
2338
2410
|
".cm-inplace-mono": {
|
|
2339
|
-
fontFamily:
|
|
2411
|
+
fontFamily: kr,
|
|
2340
2412
|
fontSize: "0.9em",
|
|
2341
2413
|
background: "color-mix(in srgb, var(--stylo-border) 35%, transparent)",
|
|
2342
2414
|
padding: "0 0.9rem"
|
|
@@ -2414,21 +2486,21 @@ var pr = class {
|
|
|
2414
2486
|
cursor: "pointer"
|
|
2415
2487
|
},
|
|
2416
2488
|
".cm-inplace-fm": {
|
|
2417
|
-
fontFamily:
|
|
2489
|
+
fontFamily: kr,
|
|
2418
2490
|
fontSize: "0.85em",
|
|
2419
2491
|
color: "var(--stylo-text-muted)"
|
|
2420
2492
|
},
|
|
2421
2493
|
".cm-inplace-fm-first::before": {
|
|
2422
2494
|
content: "\"Frontmatter\"",
|
|
2423
2495
|
marginRight: "0.6em",
|
|
2424
|
-
fontFamily:
|
|
2496
|
+
fontFamily: Ar,
|
|
2425
2497
|
fontSize: "0.8rem",
|
|
2426
2498
|
fontWeight: "600",
|
|
2427
2499
|
textTransform: "uppercase",
|
|
2428
2500
|
letterSpacing: "0.04em",
|
|
2429
2501
|
color: "var(--stylo-text-muted)"
|
|
2430
2502
|
}
|
|
2431
|
-
},
|
|
2503
|
+
}, Mr = {
|
|
2432
2504
|
".cm-inplace-menu": {
|
|
2433
2505
|
position: "fixed",
|
|
2434
2506
|
inset: "0",
|
|
@@ -2502,7 +2574,7 @@ var pr = class {
|
|
|
2502
2574
|
outline: "none"
|
|
2503
2575
|
},
|
|
2504
2576
|
".cm-inplace-menu-input:focus": { borderColor: "var(--stylo-ring)" }
|
|
2505
|
-
},
|
|
2577
|
+
}, Nr = {
|
|
2506
2578
|
".cm-inplace-selbar": {
|
|
2507
2579
|
position: "fixed",
|
|
2508
2580
|
zIndex: "20",
|
|
@@ -2587,7 +2659,7 @@ var pr = class {
|
|
|
2587
2659
|
lineHeight: "1.4",
|
|
2588
2660
|
wordBreak: "break-all"
|
|
2589
2661
|
}
|
|
2590
|
-
},
|
|
2662
|
+
}, Pr = {
|
|
2591
2663
|
".cm-inplace-table": {
|
|
2592
2664
|
borderCollapse: "collapse",
|
|
2593
2665
|
padding: "1em 0 1.4em",
|
|
@@ -2610,7 +2682,7 @@ var pr = class {
|
|
|
2610
2682
|
outline: "none"
|
|
2611
2683
|
},
|
|
2612
2684
|
".cm-inplace-table-edit .cm-inplace-tcell:focus": { boxShadow: "inset 0 0 0 2px var(--stylo-ring)" }
|
|
2613
|
-
},
|
|
2685
|
+
}, Fr = {
|
|
2614
2686
|
".cm-inplace-table-wrap": {
|
|
2615
2687
|
position: "relative",
|
|
2616
2688
|
display: "inline-block",
|
|
@@ -2652,57 +2724,58 @@ var pr = class {
|
|
|
2652
2724
|
},
|
|
2653
2725
|
".cm-inplace-tg-edge:hover .cm-inplace-tg-plus": { color: "var(--stylo-text)" },
|
|
2654
2726
|
"@media (hover: none)": { ".cm-inplace-tg-edge": { opacity: "0.5" } }
|
|
2655
|
-
},
|
|
2656
|
-
...
|
|
2657
|
-
...
|
|
2658
|
-
...
|
|
2659
|
-
...
|
|
2660
|
-
...
|
|
2661
|
-
...
|
|
2662
|
-
}),
|
|
2663
|
-
function
|
|
2664
|
-
let t =
|
|
2727
|
+
}, Ir = w.theme({
|
|
2728
|
+
...jr,
|
|
2729
|
+
...Or,
|
|
2730
|
+
...Pr,
|
|
2731
|
+
...Fr,
|
|
2732
|
+
...Mr,
|
|
2733
|
+
...Nr
|
|
2734
|
+
}), Lr = ".cm-inplace-math, .cm-inplace-hr, .cm-inplace-table, .cm-inplace-embed, .cm-inplace-embed-inline";
|
|
2735
|
+
function Rr(e = {}) {
|
|
2736
|
+
let t = Le(e.inPlace?.contextMenu);
|
|
2665
2737
|
return [
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2738
|
+
M.of(Ne(e.inPlace)),
|
|
2739
|
+
N.of(e.embedRegistry ?? null),
|
|
2740
|
+
P.of(e.inPlace?.table ?? "source"),
|
|
2741
|
+
F.of(e.inPlace?.reveal ?? "caret"),
|
|
2742
|
+
Pe.of(e.onLinkClick ?? null),
|
|
2743
|
+
Fe.of(t.enabled),
|
|
2744
|
+
L.of(t.groups),
|
|
2745
|
+
Re.of(e.hostItems ?? (() => t.items)),
|
|
2746
|
+
Ve.of(e.inPlace?.selectionUI ?? "menu"),
|
|
2747
|
+
Be.of(ze(e.inPlace?.selectionBarItems)),
|
|
2748
|
+
Dt(),
|
|
2749
|
+
ir,
|
|
2750
|
+
Yt,
|
|
2751
|
+
Rt,
|
|
2752
|
+
Dr,
|
|
2753
|
+
er,
|
|
2754
|
+
Xn,
|
|
2755
|
+
nt,
|
|
2756
|
+
hr,
|
|
2757
|
+
Ue,
|
|
2758
|
+
Y,
|
|
2759
|
+
_r,
|
|
2760
|
+
yr,
|
|
2761
|
+
Cr,
|
|
2683
2762
|
or,
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
Zn,
|
|
2690
|
-
nr,
|
|
2691
|
-
ln,
|
|
2692
|
-
un,
|
|
2693
|
-
j.high(Dr),
|
|
2694
|
-
E.domEventHandlers({
|
|
2763
|
+
dr,
|
|
2764
|
+
kn,
|
|
2765
|
+
An,
|
|
2766
|
+
k.high(Ir),
|
|
2767
|
+
w.domEventHandlers({
|
|
2695
2768
|
mousedown(e, t) {
|
|
2696
2769
|
let n = e.target;
|
|
2697
2770
|
if (n?.closest(".cm-inplace-table-edit") || n?.closest(".stylo-embed-content")) return !1;
|
|
2698
|
-
let r = n?.closest(
|
|
2771
|
+
let r = n?.closest(Lr);
|
|
2699
2772
|
if (!r) return !1;
|
|
2700
2773
|
let i = t.posAtDOM(r);
|
|
2701
2774
|
if (i < 0) return !1;
|
|
2702
2775
|
let a = n?.closest("[data-stylo-row]");
|
|
2703
2776
|
if (a && r.contains(a)) {
|
|
2704
|
-
let n =
|
|
2705
|
-
n != null && (i = n +
|
|
2777
|
+
let n = le(t.state.doc, i, Number(a.dataset.styloRow), Number(a.dataset.styloCol));
|
|
2778
|
+
n != null && (i = n + de(a, e.clientX, e.clientY));
|
|
2706
2779
|
}
|
|
2707
2780
|
return t.focus(), t.dispatch({ selection: { anchor: i } }), !0;
|
|
2708
2781
|
},
|
|
@@ -2716,49 +2789,55 @@ function kr(e = {}) {
|
|
|
2716
2789
|
}
|
|
2717
2790
|
//#endregion
|
|
2718
2791
|
//#region src/inplace/InPlaceView.tsx
|
|
2719
|
-
var
|
|
2720
|
-
function
|
|
2721
|
-
let te =
|
|
2792
|
+
var zr = () => () => {}, Br = () => null;
|
|
2793
|
+
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 }) {
|
|
2794
|
+
let te = S(a);
|
|
2722
2795
|
te.current = a;
|
|
2723
|
-
let re =
|
|
2796
|
+
let re = S(o);
|
|
2724
2797
|
re.current = o;
|
|
2725
|
-
let
|
|
2726
|
-
|
|
2727
|
-
let
|
|
2728
|
-
|
|
2729
|
-
|
|
2798
|
+
let ie = S(s?.contextMenu);
|
|
2799
|
+
ie.current = s?.contextMenu;
|
|
2800
|
+
let [g] = ve(() => new je()), ae = ye(g.subscribe, g.getSnapshot, g.getSnapshot), [oe, se] = ve(null), _ = S(m);
|
|
2801
|
+
_.current = m;
|
|
2802
|
+
let le = S((e) => {
|
|
2803
|
+
se(e), _.current?.(e);
|
|
2804
|
+
}).current, v = S(h);
|
|
2730
2805
|
v.current = h;
|
|
2731
|
-
let [y] =
|
|
2806
|
+
let [y] = ve(() => h ? new ne() : null), ue = ye(y?.subscribe ?? zr, y?.getSnapshot ?? Br), [de] = ve(() => [Rr({
|
|
2732
2807
|
onWikiLinkClick: (e) => te.current?.(e),
|
|
2733
2808
|
onLinkClick: (e) => re.current?.(e),
|
|
2734
2809
|
inPlace: s,
|
|
2810
|
+
hostItems: () => {
|
|
2811
|
+
let e = ie.current;
|
|
2812
|
+
return typeof e == "object" ? e.items ?? [] : [];
|
|
2813
|
+
},
|
|
2735
2814
|
embedRegistry: d ? g : void 0
|
|
2736
|
-
}), ...y ? [
|
|
2815
|
+
}), ...y ? [xe.of(y.panel)] : []]), fe = ce({
|
|
2737
2816
|
value: e,
|
|
2738
2817
|
onChange: t,
|
|
2739
2818
|
readOnly: r,
|
|
2740
2819
|
placeholder: i,
|
|
2741
|
-
extensions:
|
|
2820
|
+
extensions: de,
|
|
2742
2821
|
codeLanguages: c,
|
|
2743
2822
|
wikiLinkSource: l,
|
|
2744
2823
|
tagSource: u,
|
|
2745
2824
|
onResolveError: f,
|
|
2746
2825
|
onSave: p,
|
|
2747
|
-
onViewChange:
|
|
2826
|
+
onViewChange: le,
|
|
2748
2827
|
hostExtensions: ee
|
|
2749
2828
|
});
|
|
2750
|
-
return /* @__PURE__ */
|
|
2829
|
+
return /* @__PURE__ */ ke("div", {
|
|
2751
2830
|
className: n.inplace,
|
|
2752
|
-
ref:
|
|
2753
|
-
children: [d &&
|
|
2831
|
+
ref: fe,
|
|
2832
|
+
children: [d && ae.map((e) => Se(/* @__PURE__ */ Oe(he, {
|
|
2754
2833
|
reference: e.ref,
|
|
2755
2834
|
source: d,
|
|
2756
2835
|
onError: f,
|
|
2757
2836
|
inline: e.inline
|
|
2758
|
-
}), e.el, String(e.id))),
|
|
2837
|
+
}), e.el, String(e.id))), ue && v.current && Se(v.current({ view: oe }), ue)]
|
|
2759
2838
|
});
|
|
2760
2839
|
}
|
|
2761
2840
|
//#endregion
|
|
2762
|
-
export {
|
|
2841
|
+
export { Vr as InPlaceView };
|
|
2763
2842
|
|
|
2764
|
-
//# sourceMappingURL=InPlaceView-
|
|
2843
|
+
//# sourceMappingURL=InPlaceView-D2GIV1A-.js.map
|