@damiro/stylo 0.10.1 → 0.12.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 +15 -3
- package/dist/{InPlaceView-CkbMemAa.js → InPlaceView-BWc06Jso.js} +491 -486
- package/dist/InPlaceView-BWc06Jso.js.map +1 -0
- package/dist/{Preview-AaGGwLQP.js → Preview-DIsFdBFA.js} +3 -3
- package/dist/{Preview-AaGGwLQP.js.map → Preview-DIsFdBFA.js.map} +1 -1
- package/dist/SplitView.d.ts +8 -2
- package/dist/SplitView.d.ts.map +1 -1
- package/dist/Stylo.d.ts.map +1 -1
- package/dist/editor/SourceView.d.ts +10 -3
- package/dist/editor/SourceView.d.ts.map +1 -1
- package/dist/editor/canvas-header-panel.d.ts +27 -0
- package/dist/editor/canvas-header-panel.d.ts.map +1 -0
- package/dist/editor/extensions.d.ts +2 -2
- package/dist/editor/extensions.d.ts.map +1 -1
- package/dist/editor/tag-complete.d.ts +16 -0
- package/dist/editor/tag-complete.d.ts.map +1 -0
- package/dist/editor/useCodeMirror.d.ts +8 -3
- package/dist/editor/useCodeMirror.d.ts.map +1 -1
- package/dist/{embed-B2Dfkpd_.js → embed-Dsu6b-MV.js} +16 -9
- package/dist/embed-Dsu6b-MV.js.map +1 -0
- package/dist/frontmatter-DTCC0gaa.js +40 -0
- package/dist/frontmatter-DTCC0gaa.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/inplace/InPlaceView.d.ts +10 -3
- package/dist/inplace/InPlaceView.d.ts.map +1 -1
- package/dist/inplace/table-widget.d.ts +10 -5
- package/dist/inplace/table-widget.d.ts.map +1 -1
- package/dist/inplace/theme-canvas.d.ts +7 -1
- package/dist/inplace/theme-canvas.d.ts.map +1 -1
- package/dist/render/Embed.d.ts.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/stylo.js +200 -168
- package/dist/stylo.js.map +1 -1
- package/dist/toolbar/Toolbar.d.ts.map +1 -1
- package/dist/toolbar/commands.d.ts.map +1 -1
- package/dist/types.d.ts +38 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/{useCodeMirror-CpE_Ncfn.js → useCodeMirror-BI1kEPRE.js} +402 -334
- package/dist/useCodeMirror-BI1kEPRE.js.map +1 -0
- package/package.json +1 -1
- package/dist/InPlaceView-CkbMemAa.js.map +0 -1
- package/dist/embed-B2Dfkpd_.js.map +0 -1
- package/dist/frontmatter-DGUkb9z-.js +0 -39
- package/dist/frontmatter-DGUkb9z-.js.map +0 -1
- package/dist/useCodeMirror-CpE_Ncfn.js.map +0 -1
|
@@ -1,15 +1,36 @@
|
|
|
1
|
-
import { r as e, t } from "./frontmatter-
|
|
1
|
+
import { r as e, t } from "./frontmatter-DTCC0gaa.js";
|
|
2
2
|
import { useEffect as n, useRef as r } from "react";
|
|
3
3
|
import { EditorView as i, keymap as a, placeholder as o, runScopeHandlers as s } from "@codemirror/view";
|
|
4
4
|
import { Annotation as c, ChangeSet as l, Compartment as u, EditorSelection as d, EditorState as f, Facet as p, Prec as m } from "@codemirror/state";
|
|
5
|
-
import { defaultKeymap as ee, history as
|
|
6
|
-
import { markdown as
|
|
7
|
-
import { SearchQuery as
|
|
8
|
-
import { HighlightStyle as
|
|
9
|
-
import { tags as
|
|
10
|
-
import { autocompletion as
|
|
5
|
+
import { defaultKeymap as ee, history as te, historyKeymap as h, redo as g, undo as _ } from "@codemirror/commands";
|
|
6
|
+
import { markdown as ne, markdownLanguage as v } from "@codemirror/lang-markdown";
|
|
7
|
+
import { SearchQuery as y, closeSearchPanel as b, findNext as x, findPrevious as S, getSearchQuery as C, openSearchPanel as w, replaceAll as re, replaceNext as ie, search as ae, searchKeymap as oe, searchPanelOpen as se, selectMatches as ce, setSearchQuery as le } from "@codemirror/search";
|
|
8
|
+
import { HighlightStyle as ue, syntaxHighlighting as de, syntaxTree as fe } from "@codemirror/language";
|
|
9
|
+
import { tags as T } from "@lezer/highlight";
|
|
10
|
+
import { autocompletion as pe } from "@codemirror/autocomplete";
|
|
11
|
+
//#region src/editor/canvas-header-panel.ts
|
|
12
|
+
var me = "stylo-canvas-header", he = class {
|
|
13
|
+
dom = null;
|
|
14
|
+
listeners = /* @__PURE__ */ new Set();
|
|
15
|
+
panel = () => {
|
|
16
|
+
let e = document.createElement("div");
|
|
17
|
+
return e.className = me, this.dom = e, this.notify(), {
|
|
18
|
+
dom: e,
|
|
19
|
+
top: !0,
|
|
20
|
+
destroy: () => {
|
|
21
|
+
this.dom = null, this.notify();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
subscribe = (e) => (this.listeners.add(e), () => this.listeners.delete(e));
|
|
26
|
+
getSnapshot = () => this.dom;
|
|
27
|
+
notify() {
|
|
28
|
+
for (let e of this.listeners) e();
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
//#endregion
|
|
11
32
|
//#region src/toolbar/link-ops.ts
|
|
12
|
-
function
|
|
33
|
+
function E(e, t) {
|
|
13
34
|
let n = /\[([^\]]*)\]\([^)]*\)/g;
|
|
14
35
|
for (let r; r = n.exec(e);) {
|
|
15
36
|
let e = r.index, n = e + r[0].length;
|
|
@@ -21,7 +42,7 @@ function T(e, t) {
|
|
|
21
42
|
}
|
|
22
43
|
return null;
|
|
23
44
|
}
|
|
24
|
-
function
|
|
45
|
+
function ge(e, t) {
|
|
25
46
|
let n = /\[([^\]]*)\]\(([^)]*)\)/g;
|
|
26
47
|
for (let r; r = n.exec(e);) {
|
|
27
48
|
let e = r.index, n = e + r[0].length;
|
|
@@ -39,8 +60,8 @@ function he(e, t) {
|
|
|
39
60
|
}
|
|
40
61
|
return null;
|
|
41
62
|
}
|
|
42
|
-
function
|
|
43
|
-
let r =
|
|
63
|
+
function _e(e, t, n) {
|
|
64
|
+
let r = E(e, t);
|
|
44
65
|
if (r) return {
|
|
45
66
|
text: e.slice(0, r.from) + r.label + e.slice(r.to),
|
|
46
67
|
from: r.from,
|
|
@@ -55,7 +76,7 @@ function ge(e, t, n) {
|
|
|
55
76
|
}
|
|
56
77
|
//#endregion
|
|
57
78
|
//#region src/toolbar/wikilink-ops.ts
|
|
58
|
-
function
|
|
79
|
+
function D(t, n) {
|
|
59
80
|
for (let r of t.matchAll(e)) {
|
|
60
81
|
let e = r.index ?? 0, t = e + r[0].length;
|
|
61
82
|
if (n >= e && n <= t) return {
|
|
@@ -66,7 +87,7 @@ function E(t, n) {
|
|
|
66
87
|
}
|
|
67
88
|
return null;
|
|
68
89
|
}
|
|
69
|
-
function
|
|
90
|
+
function ve(t, n) {
|
|
70
91
|
for (let r of t.matchAll(e)) {
|
|
71
92
|
let e = r.index ?? 0, t = e + r[0].length;
|
|
72
93
|
if (n < e || n > t) continue;
|
|
@@ -82,8 +103,8 @@ function _e(t, n) {
|
|
|
82
103
|
}
|
|
83
104
|
return null;
|
|
84
105
|
}
|
|
85
|
-
function
|
|
86
|
-
let r =
|
|
106
|
+
function ye(e, t, n) {
|
|
107
|
+
let r = D(e, t);
|
|
87
108
|
if (r) return {
|
|
88
109
|
text: e.slice(0, r.from) + r.label + e.slice(r.to),
|
|
89
110
|
from: r.from,
|
|
@@ -98,7 +119,7 @@ function ve(e, t, n) {
|
|
|
98
119
|
}
|
|
99
120
|
//#endregion
|
|
100
121
|
//#region src/toolbar/underline-ops.ts
|
|
101
|
-
function
|
|
122
|
+
function be(e, t) {
|
|
102
123
|
let n = /<u>([\s\S]*?)<\/u>/gi;
|
|
103
124
|
for (let r; r = n.exec(e);) {
|
|
104
125
|
let e = r.index, n = e + r[0].length;
|
|
@@ -110,8 +131,8 @@ function ye(e, t) {
|
|
|
110
131
|
}
|
|
111
132
|
return null;
|
|
112
133
|
}
|
|
113
|
-
function
|
|
114
|
-
let r =
|
|
134
|
+
function xe(e, t, n) {
|
|
135
|
+
let r = be(e, t);
|
|
115
136
|
if (r) return {
|
|
116
137
|
text: e.slice(0, r.from) + r.inner + e.slice(r.to),
|
|
117
138
|
from: r.from,
|
|
@@ -126,10 +147,10 @@ function be(e, t, n) {
|
|
|
126
147
|
}
|
|
127
148
|
//#endregion
|
|
128
149
|
//#region src/toolbar/inline-ops.ts
|
|
129
|
-
function
|
|
150
|
+
function O(e) {
|
|
130
151
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
131
152
|
}
|
|
132
|
-
function
|
|
153
|
+
function Se(e, t, n) {
|
|
133
154
|
let r = t, i = t;
|
|
134
155
|
if (n < 0) for (; r > 0 && "*~`$".includes(e[r - 1]);) r--;
|
|
135
156
|
else for (; i < e.length && "*~`$".includes(e[i]);) i++;
|
|
@@ -138,7 +159,7 @@ function xe(e, t, n) {
|
|
|
138
159
|
from: r
|
|
139
160
|
};
|
|
140
161
|
}
|
|
141
|
-
function
|
|
162
|
+
function Ce(e, t) {
|
|
142
163
|
let n = [];
|
|
143
164
|
for (let r = 0; r < e.length;) {
|
|
144
165
|
if (e[r] !== t) {
|
|
@@ -154,15 +175,15 @@ function Se(e, t) {
|
|
|
154
175
|
}
|
|
155
176
|
return n;
|
|
156
177
|
}
|
|
157
|
-
function
|
|
178
|
+
function we(e, t, n) {
|
|
158
179
|
return e < n || t < n ? !1 : n > 1 || e % 2 == 1 && t % 2 == 1;
|
|
159
180
|
}
|
|
160
|
-
function
|
|
181
|
+
function Te(e, t, n, r) {
|
|
161
182
|
let i = r.length, a = r[0], o = e.slice(t, n), s = 0;
|
|
162
183
|
for (; o[s] === a;) s++;
|
|
163
184
|
let c = 0;
|
|
164
185
|
for (; o[o.length - 1 - c] === a;) c++;
|
|
165
|
-
if (o.length >= 2 * i && o.startsWith(r) && o.endsWith(r) &&
|
|
186
|
+
if (o.length >= 2 * i && o.startsWith(r) && o.endsWith(r) && we(s, c, i)) return {
|
|
166
187
|
changes: [{
|
|
167
188
|
from: t,
|
|
168
189
|
to: t + i,
|
|
@@ -175,10 +196,10 @@ function we(e, t, n, r) {
|
|
|
175
196
|
from: t,
|
|
176
197
|
to: n - 2 * i
|
|
177
198
|
};
|
|
178
|
-
let l =
|
|
199
|
+
let l = Se(e, t, -1), u = Se(e, n, 1), d = Ce(l.text, a), f = Ce(u.text, a).reverse();
|
|
179
200
|
for (let e = 0; e < Math.min(d.length, f.length); e++) {
|
|
180
201
|
let r = d[e], a = f[e];
|
|
181
|
-
if (!
|
|
202
|
+
if (!we(r.len, a.len, i)) continue;
|
|
182
203
|
let o = l.from + r.start + r.len, s = n + a.start;
|
|
183
204
|
return {
|
|
184
205
|
changes: [{
|
|
@@ -208,26 +229,26 @@ function we(e, t, n, r) {
|
|
|
208
229
|
to: n + i
|
|
209
230
|
};
|
|
210
231
|
}
|
|
211
|
-
function
|
|
232
|
+
function Ee(e, t) {
|
|
212
233
|
let n = e;
|
|
213
234
|
for (let e of [...t].sort((e, t) => t.from - e.from)) n = n.slice(0, e.from) + e.insert + n.slice(e.to);
|
|
214
235
|
return n;
|
|
215
236
|
}
|
|
216
|
-
function
|
|
217
|
-
let i =
|
|
237
|
+
function k(e, t, n, r) {
|
|
238
|
+
let i = Te(e, t, n, r);
|
|
218
239
|
return {
|
|
219
|
-
text:
|
|
240
|
+
text: Ee(e, i.changes),
|
|
220
241
|
from: i.from,
|
|
221
242
|
to: i.to
|
|
222
243
|
};
|
|
223
244
|
}
|
|
224
|
-
function
|
|
225
|
-
let n =
|
|
245
|
+
function De(e, t) {
|
|
246
|
+
let n = E(e, t);
|
|
226
247
|
if (n) return {
|
|
227
248
|
from: n.from,
|
|
228
249
|
to: n.to
|
|
229
250
|
};
|
|
230
|
-
let r =
|
|
251
|
+
let r = ve(e, t);
|
|
231
252
|
if (r) return {
|
|
232
253
|
from: r.from,
|
|
233
254
|
to: r.to
|
|
@@ -239,7 +260,7 @@ function Ee(e, t) {
|
|
|
239
260
|
"*",
|
|
240
261
|
"`"
|
|
241
262
|
]) {
|
|
242
|
-
let r = RegExp(
|
|
263
|
+
let r = RegExp(O(n) + "(?!\\s)(?:[^]*?\\S)??" + O(n), "g");
|
|
243
264
|
for (let a; a = r.exec(e);) {
|
|
244
265
|
if (a[0].length <= 2 * n.length) continue;
|
|
245
266
|
let e = a.index + n.length, r = a.index + a[0].length - n.length;
|
|
@@ -253,8 +274,8 @@ function Ee(e, t) {
|
|
|
253
274
|
}
|
|
254
275
|
//#endregion
|
|
255
276
|
//#region src/inplace/table-cell-dom.ts
|
|
256
|
-
var
|
|
257
|
-
function
|
|
277
|
+
var Oe = (e) => [e.head, ...e.body].map((e) => [...e]), ke = (e) => e.map((e) => e.map((e) => e.trim())), Ae = (e) => e.replace(/\\\|/g, "|");
|
|
278
|
+
function A(e, t) {
|
|
258
279
|
let n = e.ownerDocument.createTreeWalker(e, NodeFilter.SHOW_TEXT), r = 0;
|
|
259
280
|
for (let e = n.nextNode(); e; e = n.nextNode()) {
|
|
260
281
|
if (e === t) return r;
|
|
@@ -262,12 +283,12 @@ function k(e, t) {
|
|
|
262
283
|
}
|
|
263
284
|
return r;
|
|
264
285
|
}
|
|
265
|
-
function
|
|
286
|
+
function je(e) {
|
|
266
287
|
let t = e.ownerDocument.getSelection(), n = t?.anchorNode;
|
|
267
|
-
return !n || !e.contains(n) ? 0 : n.nodeType === Node.TEXT_NODE ?
|
|
288
|
+
return !n || !e.contains(n) ? 0 : n.nodeType === Node.TEXT_NODE ? A(e, n) + (t?.anchorOffset ?? 0) : (t?.anchorOffset ?? 0) > 0 ? (e.textContent ?? "").length : 0;
|
|
268
289
|
}
|
|
269
|
-
function
|
|
270
|
-
let t = e.ownerDocument.getSelection(), n = (e.textContent ?? "").length, r = (t, r) => !t || !e.contains(t) ? n : t.nodeType === Node.TEXT_NODE ?
|
|
290
|
+
function Me(e) {
|
|
291
|
+
let t = e.ownerDocument.getSelection(), n = (e.textContent ?? "").length, r = (t, r) => !t || !e.contains(t) ? n : t.nodeType === Node.TEXT_NODE ? A(e, t) + r : r > 0 ? n : 0;
|
|
271
292
|
if (!t || t.rangeCount === 0) return {
|
|
272
293
|
from: n,
|
|
273
294
|
to: n
|
|
@@ -278,7 +299,7 @@ function je(e) {
|
|
|
278
299
|
to: Math.max(i, a)
|
|
279
300
|
};
|
|
280
301
|
}
|
|
281
|
-
function
|
|
302
|
+
function Ne(e, t, n) {
|
|
282
303
|
let r = e.ownerDocument, i = null, a = 0;
|
|
283
304
|
if (r.caretPositionFromPoint) {
|
|
284
305
|
let e = r.caretPositionFromPoint(t, n);
|
|
@@ -287,18 +308,18 @@ function Me(e, t, n) {
|
|
|
287
308
|
let e = r.caretRangeFromPoint(t, n);
|
|
288
309
|
e && ([i, a] = [e.startContainer, e.startOffset]);
|
|
289
310
|
}
|
|
290
|
-
return !i || !e.contains(i) ? 0 :
|
|
311
|
+
return !i || !e.contains(i) ? 0 : A(e, i) + (i.nodeType === Node.TEXT_NODE ? a : 0);
|
|
291
312
|
}
|
|
292
|
-
var
|
|
293
|
-
function
|
|
294
|
-
let r = e.textContent ?? "", i =
|
|
295
|
-
if (a) return
|
|
313
|
+
var Pe = /[\p{L}\p{N}_]/u;
|
|
314
|
+
function Fe(e, t, n) {
|
|
315
|
+
let r = e.textContent ?? "", i = Ne(e, t, n), a = De(r, i);
|
|
316
|
+
if (a) return j(e, a.from, a.to), !0;
|
|
296
317
|
let o = i, s = i;
|
|
297
|
-
for (; o > 0 &&
|
|
298
|
-
for (; s < r.length &&
|
|
299
|
-
return s <= o ? !1 : (
|
|
318
|
+
for (; o > 0 && Pe.test(r[o - 1]);) o--;
|
|
319
|
+
for (; s < r.length && Pe.test(r[s]);) s++;
|
|
320
|
+
return s <= o ? !1 : (j(e, o, s), !0);
|
|
300
321
|
}
|
|
301
|
-
function
|
|
322
|
+
function j(e, t, n = t) {
|
|
302
323
|
e.focus();
|
|
303
324
|
let r = e.ownerDocument, i = r.createRange(), a = e.firstChild;
|
|
304
325
|
if (a && a.nodeType === Node.TEXT_NODE) {
|
|
@@ -311,38 +332,38 @@ function A(e, t, n = t) {
|
|
|
311
332
|
}
|
|
312
333
|
//#endregion
|
|
313
334
|
//#region src/toolbar/cell-inline.ts
|
|
314
|
-
function
|
|
335
|
+
function Ie(e) {
|
|
315
336
|
let t = e.dom.ownerDocument.activeElement;
|
|
316
337
|
return !(t instanceof HTMLElement) || !e.dom.contains(t) ? null : t.matches(".cm-inplace-tcell") ? t : null;
|
|
317
338
|
}
|
|
318
|
-
function
|
|
319
|
-
let { from: n, to: r } =
|
|
320
|
-
e.textContent = i.text,
|
|
339
|
+
function Le(e, t) {
|
|
340
|
+
let { from: n, to: r } = Me(e), i = t(e.textContent ?? "", n, r);
|
|
341
|
+
e.textContent = i.text, j(e, i.from, i.to), e.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
321
342
|
}
|
|
322
|
-
function
|
|
323
|
-
let n =
|
|
324
|
-
return n ? (
|
|
343
|
+
function M(e, t) {
|
|
344
|
+
let n = Ie(e);
|
|
345
|
+
return n ? (Le(n, t), !0) : !1;
|
|
325
346
|
}
|
|
326
|
-
var
|
|
327
|
-
b: (e, t, n) =>
|
|
328
|
-
i: (e, t, n) =>
|
|
329
|
-
u:
|
|
330
|
-
k:
|
|
331
|
-
K:
|
|
347
|
+
var Re = {
|
|
348
|
+
b: (e, t, n) => k(e, t, n, "**"),
|
|
349
|
+
i: (e, t, n) => k(e, t, n, "*"),
|
|
350
|
+
u: xe,
|
|
351
|
+
k: _e,
|
|
352
|
+
K: ye
|
|
332
353
|
};
|
|
333
|
-
function
|
|
354
|
+
function ze(e, t) {
|
|
334
355
|
if (!(e.metaKey || e.ctrlKey) || e.altKey) return !1;
|
|
335
|
-
let n =
|
|
336
|
-
return n ? (e.preventDefault(),
|
|
356
|
+
let n = Re[e.shiftKey ? e.key.toUpperCase() : e.key.toLowerCase()];
|
|
357
|
+
return n ? (e.preventDefault(), Le(t, n), !0) : !1;
|
|
337
358
|
}
|
|
338
359
|
//#endregion
|
|
339
360
|
//#region src/toolbar/block.ts
|
|
340
|
-
function
|
|
361
|
+
function N(e) {
|
|
341
362
|
let { from: t, to: n } = e.selection.main;
|
|
342
363
|
return [e.doc.lineAt(t).number, e.doc.lineAt(n).number];
|
|
343
364
|
}
|
|
344
|
-
function
|
|
345
|
-
let n = e.state, [r, i] =
|
|
365
|
+
function Be(e, t) {
|
|
366
|
+
let n = e.state, [r, i] = N(n), a = r === i && !n.doc.line(r).text.trim(), o = !a;
|
|
346
367
|
for (let e = r; e <= i && o; e++) {
|
|
347
368
|
let r = n.doc.line(e).text;
|
|
348
369
|
r.trim() && !t.match.test(r) && (o = !1);
|
|
@@ -379,13 +400,13 @@ function ze(e, t) {
|
|
|
379
400
|
scrollIntoView: !0
|
|
380
401
|
}), e.focus(), !0) : !1;
|
|
381
402
|
}
|
|
382
|
-
function
|
|
403
|
+
function Ve(e, t) {
|
|
383
404
|
return t.test(e.doc.lineAt(e.selection.main.head).text);
|
|
384
405
|
}
|
|
385
406
|
//#endregion
|
|
386
407
|
//#region src/toolbar/fence.ts
|
|
387
|
-
function
|
|
388
|
-
for (let n =
|
|
408
|
+
function P(e, t) {
|
|
409
|
+
for (let n = fe(e).resolveInner(t, 0); n; n = n.parent) {
|
|
389
410
|
if (n.name === "FencedCode") return {
|
|
390
411
|
from: n.from,
|
|
391
412
|
to: n.to
|
|
@@ -394,8 +415,8 @@ function N(e, t) {
|
|
|
394
415
|
}
|
|
395
416
|
return null;
|
|
396
417
|
}
|
|
397
|
-
function
|
|
398
|
-
let t = e.state, n =
|
|
418
|
+
function He(e) {
|
|
419
|
+
let t = e.state, n = P(t, t.selection.main.head);
|
|
399
420
|
if (n) {
|
|
400
421
|
let r = t.doc.lineAt(n.from), i = t.doc.lineAt(n.to), a = [{
|
|
401
422
|
from: r.from,
|
|
@@ -409,7 +430,7 @@ function Ve(e) {
|
|
|
409
430
|
scrollIntoView: !0
|
|
410
431
|
});
|
|
411
432
|
} else {
|
|
412
|
-
let [n, r] =
|
|
433
|
+
let [n, r] = N(t);
|
|
413
434
|
e.dispatch({
|
|
414
435
|
changes: [{
|
|
415
436
|
from: t.doc.line(n).from,
|
|
@@ -424,11 +445,11 @@ function Ve(e) {
|
|
|
424
445
|
}
|
|
425
446
|
return e.focus(), !0;
|
|
426
447
|
}
|
|
427
|
-
function
|
|
428
|
-
return
|
|
448
|
+
function F(e) {
|
|
449
|
+
return P(e, e.selection.main.head) !== null;
|
|
429
450
|
}
|
|
430
|
-
function
|
|
431
|
-
let t =
|
|
451
|
+
function Ue(e) {
|
|
452
|
+
let t = P(e, e.selection.main.head);
|
|
432
453
|
if (!t) return null;
|
|
433
454
|
let n = e.doc.lineAt(t.from), r = /^(\s*(?:`{3,}|~{3,})[ \t]*)(.*?)[ \t]*$/.exec(n.text);
|
|
434
455
|
if (!r) return null;
|
|
@@ -439,18 +460,18 @@ function He(e) {
|
|
|
439
460
|
lang: r[2]
|
|
440
461
|
};
|
|
441
462
|
}
|
|
442
|
-
var
|
|
443
|
-
function
|
|
463
|
+
var We = /^\s*\$\$\s*$/;
|
|
464
|
+
function Ge(e, t) {
|
|
444
465
|
let n = 0, r = 0;
|
|
445
|
-
for (let i = 1; i <= e.doc.lines; i++) if (
|
|
466
|
+
for (let i = 1; i <= e.doc.lines; i++) if (We.test(e.doc.line(i).text)) {
|
|
446
467
|
if (r++, r % 2 == 1) {
|
|
447
468
|
if (n = i, i > t) return null;
|
|
448
469
|
} else if (i >= t) return [n, i];
|
|
449
470
|
}
|
|
450
471
|
return null;
|
|
451
472
|
}
|
|
452
|
-
function
|
|
453
|
-
let t = e.state, [n, r] =
|
|
473
|
+
function Ke(e) {
|
|
474
|
+
let t = e.state, [n, r] = N(t), i = Ge(t, t.doc.lineAt(t.selection.main.head).number);
|
|
454
475
|
if (i) {
|
|
455
476
|
let n = t.doc.line(i[0]), r = t.doc.line(i[1]);
|
|
456
477
|
e.dispatch({
|
|
@@ -476,13 +497,13 @@ function Ge(e) {
|
|
|
476
497
|
});
|
|
477
498
|
return e.focus(), !0;
|
|
478
499
|
}
|
|
479
|
-
function
|
|
480
|
-
return
|
|
500
|
+
function I(e) {
|
|
501
|
+
return Ge(e, e.doc.lineAt(e.selection.main.head).number) !== null;
|
|
481
502
|
}
|
|
482
503
|
//#endregion
|
|
483
504
|
//#region src/toolbar/heading.ts
|
|
484
|
-
function
|
|
485
|
-
let n = "#".repeat(t) + " ", r = e.state, [i, a] =
|
|
505
|
+
function qe(e, t) {
|
|
506
|
+
let n = "#".repeat(t) + " ", r = e.state, [i, a] = N(r), o = [];
|
|
486
507
|
for (let e = i; e <= a; e++) {
|
|
487
508
|
let i = r.doc.line(e), a = /^(#{1,6}) +/.exec(i.text);
|
|
488
509
|
a && a[1].length === t ? o.push({
|
|
@@ -502,8 +523,8 @@ function Ke(e, t) {
|
|
|
502
523
|
scrollIntoView: !0
|
|
503
524
|
}), e.focus(), !0;
|
|
504
525
|
}
|
|
505
|
-
function
|
|
506
|
-
let t = e.state, [n, r] =
|
|
526
|
+
function Je(e) {
|
|
527
|
+
let t = e.state, [n, r] = N(t), i = [];
|
|
507
528
|
for (let e = n; e <= r; e++) {
|
|
508
529
|
let n = t.doc.line(e), r = /^#{1,6} +/.exec(n.text);
|
|
509
530
|
r && i.push({
|
|
@@ -518,11 +539,11 @@ function qe(e) {
|
|
|
518
539
|
}
|
|
519
540
|
//#endregion
|
|
520
541
|
//#region src/toolbar/inline.ts
|
|
521
|
-
function
|
|
542
|
+
function L(e, t) {
|
|
522
543
|
let n = e.state.doc.toString();
|
|
523
544
|
return e.dispatch({
|
|
524
545
|
...e.state.changeByRange((e) => {
|
|
525
|
-
let r =
|
|
546
|
+
let r = Te(n, e.from, e.to, t);
|
|
526
547
|
return {
|
|
527
548
|
changes: r.changes,
|
|
528
549
|
range: r.from === r.to ? d.cursor(r.from) : d.range(r.from, r.to)
|
|
@@ -531,8 +552,8 @@ function I(e, t) {
|
|
|
531
552
|
scrollIntoView: !0
|
|
532
553
|
}), e.focus(), !0;
|
|
533
554
|
}
|
|
534
|
-
function
|
|
535
|
-
let n = e.selection.main, r = e.doc.lineAt(n.head), i = RegExp(
|
|
555
|
+
function R(e, t) {
|
|
556
|
+
let n = e.selection.main, r = e.doc.lineAt(n.head), i = RegExp(O(t) + "(?!\\s)(?:[^]*?\\S)??" + O(t), "g");
|
|
536
557
|
for (let e; e = i.exec(r.text);) {
|
|
537
558
|
if (e[0].length <= 2 * t.length || t === "$" && (r.text[e.index - 1] === "$" || r.text[e.index + e[0].length] === "$")) continue;
|
|
538
559
|
let i = r.from + e.index;
|
|
@@ -540,16 +561,16 @@ function L(e, t) {
|
|
|
540
561
|
}
|
|
541
562
|
return !1;
|
|
542
563
|
}
|
|
543
|
-
function
|
|
544
|
-
let { head: t } = e.selection.main, n = e.doc.lineAt(t), r =
|
|
564
|
+
function Ye(e) {
|
|
565
|
+
let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = E(n.text, t - n.from);
|
|
545
566
|
return r ? {
|
|
546
567
|
from: n.from + r.from,
|
|
547
568
|
to: n.from + r.to,
|
|
548
569
|
text: r.label
|
|
549
570
|
} : null;
|
|
550
571
|
}
|
|
551
|
-
function
|
|
552
|
-
let t =
|
|
572
|
+
function Xe(e) {
|
|
573
|
+
let t = Ye(e.state);
|
|
553
574
|
if (t) return e.dispatch({
|
|
554
575
|
changes: {
|
|
555
576
|
from: t.from,
|
|
@@ -570,19 +591,19 @@ function Ye(e) {
|
|
|
570
591
|
scrollIntoView: !0
|
|
571
592
|
}), e.focus(), !0;
|
|
572
593
|
}
|
|
573
|
-
function Xe(e) {
|
|
574
|
-
return Je(e) !== null;
|
|
575
|
-
}
|
|
576
594
|
function Ze(e) {
|
|
577
|
-
|
|
595
|
+
return Ye(e) !== null;
|
|
596
|
+
}
|
|
597
|
+
function Qe(e) {
|
|
598
|
+
let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = D(n.text, t - n.from);
|
|
578
599
|
return r ? {
|
|
579
600
|
from: n.from + r.from,
|
|
580
601
|
to: n.from + r.to,
|
|
581
602
|
text: r.label
|
|
582
603
|
} : null;
|
|
583
604
|
}
|
|
584
|
-
function
|
|
585
|
-
let t =
|
|
605
|
+
function $e(e) {
|
|
606
|
+
let t = Qe(e.state);
|
|
586
607
|
if (t) return e.dispatch({
|
|
587
608
|
changes: {
|
|
588
609
|
from: t.from,
|
|
@@ -603,19 +624,19 @@ function Qe(e) {
|
|
|
603
624
|
scrollIntoView: !0
|
|
604
625
|
}), e.focus(), !0;
|
|
605
626
|
}
|
|
606
|
-
function $e(e) {
|
|
607
|
-
return Ze(e) !== null;
|
|
608
|
-
}
|
|
609
627
|
function et(e) {
|
|
610
|
-
|
|
628
|
+
return Qe(e) !== null;
|
|
629
|
+
}
|
|
630
|
+
function tt(e) {
|
|
631
|
+
let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = be(n.text, t - n.from);
|
|
611
632
|
return r ? {
|
|
612
633
|
from: n.from + r.from,
|
|
613
634
|
to: n.from + r.to,
|
|
614
635
|
inner: r.inner
|
|
615
636
|
} : null;
|
|
616
637
|
}
|
|
617
|
-
function
|
|
618
|
-
let t =
|
|
638
|
+
function nt(e) {
|
|
639
|
+
let t = tt(e.state);
|
|
619
640
|
if (t) return e.dispatch({
|
|
620
641
|
changes: {
|
|
621
642
|
from: t.from,
|
|
@@ -636,29 +657,29 @@ function tt(e) {
|
|
|
636
657
|
scrollIntoView: !0
|
|
637
658
|
}), e.focus(), !0;
|
|
638
659
|
}
|
|
639
|
-
function
|
|
640
|
-
return
|
|
660
|
+
function rt(e) {
|
|
661
|
+
return tt(e) !== null;
|
|
641
662
|
}
|
|
642
663
|
//#endregion
|
|
643
664
|
//#region src/toolbar/table-grid.ts
|
|
644
|
-
function
|
|
665
|
+
function it(e) {
|
|
645
666
|
let t = e.trim();
|
|
646
667
|
return t.includes("-") && t.includes("|") && /^[\s|:-]+$/.test(t);
|
|
647
668
|
}
|
|
648
|
-
function
|
|
669
|
+
function at(e) {
|
|
649
670
|
let t = e.trim();
|
|
650
671
|
t.startsWith("|") && (t = t.slice(1)), t.endsWith("|") && !t.endsWith("\\|") && (t = t.slice(0, -1));
|
|
651
672
|
let n = [], r = "";
|
|
652
673
|
for (let e = 0; e < t.length; e++) t[e] === "\\" && t[e + 1] === "|" ? (r += "\\|", e++) : t[e] === "|" ? (n.push(r.trim()), r = "") : r += t[e];
|
|
653
674
|
return n.push(r.trim()), n;
|
|
654
675
|
}
|
|
655
|
-
function
|
|
676
|
+
function ot(e) {
|
|
656
677
|
let t = e.trim(), n = t.startsWith(":"), r = t.endsWith(":");
|
|
657
678
|
return n && r ? "center" : r ? "right" : n ? "left" : "";
|
|
658
679
|
}
|
|
659
|
-
function
|
|
660
|
-
if (e.length < 2 || !
|
|
661
|
-
let t =
|
|
680
|
+
function z(e) {
|
|
681
|
+
if (e.length < 2 || !it(e[1])) return null;
|
|
682
|
+
let t = at(e[1]).map(ot), n = e.filter((e, t) => t !== 1).map(at), r = Math.max(t.length, ...n.map((e) => e.length)), i = n.map((e) => {
|
|
662
683
|
let t = e.slice(0, r);
|
|
663
684
|
for (; t.length < r;) t.push("");
|
|
664
685
|
return t;
|
|
@@ -669,11 +690,11 @@ function R(e) {
|
|
|
669
690
|
aligns: a
|
|
670
691
|
};
|
|
671
692
|
}
|
|
672
|
-
function
|
|
693
|
+
function st(e) {
|
|
673
694
|
return e.replace(/\\\|/g, "|").length;
|
|
674
695
|
}
|
|
675
|
-
function
|
|
676
|
-
let r = t -
|
|
696
|
+
function ct(e, t, n) {
|
|
697
|
+
let r = t - st(e);
|
|
677
698
|
if (r <= 0) return e;
|
|
678
699
|
if (n === "right") return " ".repeat(r) + e;
|
|
679
700
|
if (n === "center") {
|
|
@@ -682,23 +703,23 @@ function st(e, t, n) {
|
|
|
682
703
|
}
|
|
683
704
|
return e + " ".repeat(r);
|
|
684
705
|
}
|
|
685
|
-
function
|
|
706
|
+
function lt(e, t) {
|
|
686
707
|
let n = Math.max(3, e);
|
|
687
708
|
return t === "left" ? ":" + "-".repeat(n - 1) : t === "right" ? "-".repeat(n - 1) + ":" : t === "center" ? ":" + "-".repeat(n - 2) + ":" : "-".repeat(n);
|
|
688
709
|
}
|
|
689
|
-
function
|
|
710
|
+
function B(e) {
|
|
690
711
|
let t = e.aligns.length, n = [];
|
|
691
712
|
for (let r = 0; r < t; r++) {
|
|
692
713
|
let t = 3;
|
|
693
|
-
for (let n of e.rows) t = Math.max(t,
|
|
714
|
+
for (let n of e.rows) t = Math.max(t, st(n[r] ?? ""));
|
|
694
715
|
n.push(t);
|
|
695
716
|
}
|
|
696
|
-
let r = (t) => "| " + t.map((t, r) =>
|
|
697
|
-
i.push("| " + e.aligns.map((e, t) =>
|
|
717
|
+
let r = (t) => "| " + t.map((t, r) => ct(t ?? "", n[r], e.aligns[r])).join(" | ") + " |", i = [r(e.rows[0] ?? [])];
|
|
718
|
+
i.push("| " + e.aligns.map((e, t) => lt(n[t], e)).join(" | ") + " |");
|
|
698
719
|
for (let t = 1; t < e.rows.length; t++) i.push(r(e.rows[t]));
|
|
699
720
|
return i.join("\n");
|
|
700
721
|
}
|
|
701
|
-
function
|
|
722
|
+
function ut(e) {
|
|
702
723
|
let t = [];
|
|
703
724
|
for (let n = 0; n < e.length; n++) {
|
|
704
725
|
if (e[n] === "\\") {
|
|
@@ -721,7 +742,7 @@ function lt(e) {
|
|
|
721
742
|
}
|
|
722
743
|
//#endregion
|
|
723
744
|
//#region src/toolbar/table-position.ts
|
|
724
|
-
function
|
|
745
|
+
function V(e, t) {
|
|
725
746
|
let n = e.lineAt(t);
|
|
726
747
|
if (!n.text.includes("|")) return null;
|
|
727
748
|
let r = n.number;
|
|
@@ -739,13 +760,13 @@ function B(e, t) {
|
|
|
739
760
|
if (i - r < 1) return null;
|
|
740
761
|
let a = [];
|
|
741
762
|
for (let t = r; t <= i; t++) a.push(e.line(t).text);
|
|
742
|
-
return
|
|
763
|
+
return z(a) ? {
|
|
743
764
|
from: e.line(r).from,
|
|
744
765
|
to: e.line(i).to,
|
|
745
766
|
lines: a
|
|
746
767
|
} : null;
|
|
747
768
|
}
|
|
748
|
-
function
|
|
769
|
+
function dt(e, t, n) {
|
|
749
770
|
let r = t;
|
|
750
771
|
for (let t = 0; t < e.length; t++) {
|
|
751
772
|
let i = e[t];
|
|
@@ -761,7 +782,7 @@ function ut(e, t, n) {
|
|
|
761
782
|
onDelimiter: !0
|
|
762
783
|
};
|
|
763
784
|
}
|
|
764
|
-
let a =
|
|
785
|
+
let a = ut(i), o = 0;
|
|
765
786
|
for (let t = 0; t < a.length && (o = t, !(e <= a[t].end)); t++);
|
|
766
787
|
let s = a[o], c = s ? Math.max(0, Math.min(e, s.contentEnd) - s.contentStart) : 0;
|
|
767
788
|
return {
|
|
@@ -775,15 +796,15 @@ function ut(e, t, n) {
|
|
|
775
796
|
}
|
|
776
797
|
return null;
|
|
777
798
|
}
|
|
778
|
-
function
|
|
799
|
+
function H(e, t, n) {
|
|
779
800
|
let r = e.split("\n"), i = n.onDelimiter ? 1 : n.row === 0 ? 0 : n.row + 1, a = t;
|
|
780
801
|
for (let e = 0; e < i; e++) a += r[e].length + 1;
|
|
781
|
-
let o =
|
|
802
|
+
let o = ut(r[i]), s = o[Math.min(n.col, o.length - 1)];
|
|
782
803
|
return s ? a + s.contentStart + Math.min(n.offset, s.contentEnd - s.contentStart) : a;
|
|
783
804
|
}
|
|
784
|
-
function
|
|
785
|
-
let i =
|
|
786
|
-
return i ?
|
|
805
|
+
function ft(e, t, n, r) {
|
|
806
|
+
let i = V(e, t);
|
|
807
|
+
return i ? H(i.lines.join("\n"), i.from, {
|
|
787
808
|
row: n,
|
|
788
809
|
col: r,
|
|
789
810
|
offset: 0,
|
|
@@ -792,7 +813,7 @@ function dt(e, t, n, r) {
|
|
|
792
813
|
}
|
|
793
814
|
//#endregion
|
|
794
815
|
//#region src/toolbar/table.ts
|
|
795
|
-
function
|
|
816
|
+
function pt(e, t) {
|
|
796
817
|
requestAnimationFrame(() => {
|
|
797
818
|
let n = e.dom.querySelectorAll(".cm-inplace-table-edit");
|
|
798
819
|
if (n.length === 0) return;
|
|
@@ -812,7 +833,7 @@ function ft(e, t) {
|
|
|
812
833
|
s?.removeAllRanges(), s?.addRange(o), a.focus();
|
|
813
834
|
});
|
|
814
835
|
}
|
|
815
|
-
function
|
|
836
|
+
function mt(e) {
|
|
816
837
|
let { from: t, to: n } = e.state.selection.main, r = e.state.doc.lineAt(t), i = r.text.slice(0, t - r.from).trim() ? "\n\n" : "", a = t + i.length + 2;
|
|
817
838
|
return e.dispatch({
|
|
818
839
|
changes: {
|
|
@@ -822,30 +843,30 @@ function pt(e) {
|
|
|
822
843
|
},
|
|
823
844
|
selection: d.range(a, a + 8),
|
|
824
845
|
scrollIntoView: !0
|
|
825
|
-
}), e.focus(),
|
|
846
|
+
}), e.focus(), pt(e, a), !0;
|
|
826
847
|
}
|
|
827
|
-
function
|
|
828
|
-
return
|
|
848
|
+
function U(e) {
|
|
849
|
+
return V(e.doc, e.selection.main.head) !== null;
|
|
829
850
|
}
|
|
830
|
-
function
|
|
831
|
-
let n =
|
|
851
|
+
function W(e, t) {
|
|
852
|
+
let n = V(e.state.doc, e.state.selection.main.head);
|
|
832
853
|
if (!n) return !1;
|
|
833
|
-
let r =
|
|
854
|
+
let r = z(n.lines), i = dt(n.lines, n.from, e.state.selection.main.head);
|
|
834
855
|
if (!r || !i) return !1;
|
|
835
856
|
let a = t(r, i);
|
|
836
857
|
if (!a) return !1;
|
|
837
|
-
let o =
|
|
858
|
+
let o = B(r);
|
|
838
859
|
return e.dispatch({
|
|
839
860
|
changes: {
|
|
840
861
|
from: n.from,
|
|
841
862
|
to: n.to,
|
|
842
863
|
insert: o
|
|
843
864
|
},
|
|
844
|
-
selection: d.cursor(
|
|
865
|
+
selection: d.cursor(H(o, n.from, a)),
|
|
845
866
|
scrollIntoView: !0
|
|
846
867
|
}), e.focus(), !0;
|
|
847
868
|
}
|
|
848
|
-
function
|
|
869
|
+
function ht(e, t, n) {
|
|
849
870
|
let r = e.aligns.length, { row: i, col: a } = t;
|
|
850
871
|
return a += n, a >= r ? (i++, a = 0) : a < 0 && (i--, a = r - 1), i < 0 ? null : (i >= e.rows.length && e.rows.push(Array(r).fill("")), {
|
|
851
872
|
row: i,
|
|
@@ -854,7 +875,7 @@ function mt(e, t, n) {
|
|
|
854
875
|
onDelimiter: !1
|
|
855
876
|
});
|
|
856
877
|
}
|
|
857
|
-
function
|
|
878
|
+
function gt(e, t) {
|
|
858
879
|
let n = t.row + 1;
|
|
859
880
|
return n >= e.rows.length && e.rows.push(Array(e.aligns.length).fill("")), {
|
|
860
881
|
row: n,
|
|
@@ -863,58 +884,58 @@ function ht(e, t) {
|
|
|
863
884
|
onDelimiter: !1
|
|
864
885
|
};
|
|
865
886
|
}
|
|
866
|
-
var
|
|
887
|
+
var _t = a.of([
|
|
867
888
|
{
|
|
868
889
|
key: "Tab",
|
|
869
|
-
run: (e) =>
|
|
890
|
+
run: (e) => W(e, (e, t) => ht(e, t, 1))
|
|
870
891
|
},
|
|
871
892
|
{
|
|
872
893
|
key: "Shift-Tab",
|
|
873
|
-
run: (e) =>
|
|
894
|
+
run: (e) => W(e, (e, t) => ht(e, t, -1))
|
|
874
895
|
},
|
|
875
896
|
{
|
|
876
897
|
key: "Enter",
|
|
877
|
-
run: (e) =>
|
|
898
|
+
run: (e) => W(e, gt)
|
|
878
899
|
}
|
|
879
|
-
]),
|
|
900
|
+
]), vt = f.transactionFilter.of((e) => {
|
|
880
901
|
if (!e.docChanged || !e.isUserEvent("input") && !e.isUserEvent("delete")) return e;
|
|
881
|
-
let t = e.newSelection.main.head, n =
|
|
902
|
+
let t = e.newSelection.main.head, n = V(e.newDoc, t);
|
|
882
903
|
if (!n) return e;
|
|
883
|
-
let r =
|
|
904
|
+
let r = z(n.lines);
|
|
884
905
|
if (!r) return e;
|
|
885
|
-
let i =
|
|
906
|
+
let i = B(r);
|
|
886
907
|
if (i === n.lines.join("\n")) return e;
|
|
887
|
-
let a =
|
|
908
|
+
let a = dt(n.lines, n.from, t), o = l.of([{
|
|
888
909
|
from: n.from,
|
|
889
910
|
to: n.to,
|
|
890
911
|
insert: i
|
|
891
912
|
}], e.newDoc.length);
|
|
892
913
|
return {
|
|
893
914
|
changes: e.changes.compose(o),
|
|
894
|
-
selection: a ? d.cursor(
|
|
915
|
+
selection: a ? d.cursor(H(i, n.from, a)) : e.newSelection,
|
|
895
916
|
effects: e.effects,
|
|
896
917
|
scrollIntoView: e.scrollIntoView
|
|
897
918
|
};
|
|
898
|
-
}),
|
|
919
|
+
}), G = (e) => /^\s{0,3}#{1,6}(?:\s|$)/.test(e.doc.lineAt(e.selection.main.head).text), K = (e) => {
|
|
899
920
|
let n = t(e.doc);
|
|
900
921
|
return n !== null && e.selection.main.head <= n.to;
|
|
901
|
-
},
|
|
922
|
+
}, q = (e) => K(e) || F(e) || I(e), yt = (e) => (t) => e !== "`" && R(t, "`") || e !== "$" && R(t, "$"), bt = (e) => e.selection.main.empty && !e.wordAt(e.selection.main.head), J = (...e) => (t) => e.some((e) => e(t)), Y = /^(\s*)(?:[-*+] \[[ xX]\] +|\d+\. +|[-*+] +)/, xt = {
|
|
902
923
|
match: /^ {0,3}> ?/,
|
|
903
924
|
insert: "> "
|
|
904
|
-
},
|
|
925
|
+
}, St = {
|
|
905
926
|
match: /^(\s*)[-*+] +(?!\[[ xX]\])/,
|
|
906
927
|
insert: "- ",
|
|
907
|
-
siblings:
|
|
908
|
-
},
|
|
928
|
+
siblings: Y
|
|
929
|
+
}, Ct = {
|
|
909
930
|
match: /^(\s*)\d+\. +/,
|
|
910
931
|
insert: (e) => `${e + 1}. `,
|
|
911
|
-
siblings:
|
|
912
|
-
},
|
|
932
|
+
siblings: Y
|
|
933
|
+
}, wt = {
|
|
913
934
|
match: /^(\s*)[-*+] \[[ xX]\] +/,
|
|
914
935
|
insert: "- [ ] ",
|
|
915
|
-
siblings:
|
|
936
|
+
siblings: Y
|
|
916
937
|
};
|
|
917
|
-
function
|
|
938
|
+
function Tt(e, t, n) {
|
|
918
939
|
return {
|
|
919
940
|
id: e,
|
|
920
941
|
title: t,
|
|
@@ -924,24 +945,24 @@ function wt(e, t, n) {
|
|
|
924
945
|
}
|
|
925
946
|
};
|
|
926
947
|
}
|
|
927
|
-
function
|
|
948
|
+
function X(e, t, n, r) {
|
|
928
949
|
return {
|
|
929
950
|
id: e,
|
|
930
951
|
title: t,
|
|
931
|
-
run: (e) =>
|
|
932
|
-
isActive: (e) =>
|
|
933
|
-
disabled: q
|
|
952
|
+
run: (e) => M(e, (e, t, r) => k(e, t, r, n)) || L(e, n),
|
|
953
|
+
isActive: (e) => R(e, n),
|
|
954
|
+
disabled: J(q, yt(n), bt),
|
|
934
955
|
keys: r
|
|
935
956
|
};
|
|
936
957
|
}
|
|
937
|
-
function
|
|
958
|
+
function Et(e) {
|
|
938
959
|
let t = RegExp(`^#{${e}} `);
|
|
939
960
|
return {
|
|
940
961
|
id: `h${e}`,
|
|
941
962
|
title: `Heading ${e}`,
|
|
942
|
-
run: (t) =>
|
|
963
|
+
run: (t) => qe(t, e),
|
|
943
964
|
isActive: (e) => t.test(e.doc.lineAt(e.selection.main.head).text),
|
|
944
|
-
disabled:
|
|
965
|
+
disabled: J(U, q),
|
|
945
966
|
keys: [`Mod-Alt-${e}`]
|
|
946
967
|
};
|
|
947
968
|
}
|
|
@@ -949,14 +970,14 @@ function Z(e, t, n, ...r) {
|
|
|
949
970
|
return {
|
|
950
971
|
id: e,
|
|
951
972
|
title: t,
|
|
952
|
-
run: (e) =>
|
|
953
|
-
isActive: (e) =>
|
|
954
|
-
disabled:
|
|
973
|
+
run: (e) => Be(e, n),
|
|
974
|
+
isActive: (e) => Ve(e, n.match),
|
|
975
|
+
disabled: J(U, q, ...r)
|
|
955
976
|
};
|
|
956
977
|
}
|
|
957
978
|
//#endregion
|
|
958
979
|
//#region src/toolbar/frontmatter-toggle.ts
|
|
959
|
-
function
|
|
980
|
+
function Dt(e) {
|
|
960
981
|
let n = e.state, r = t(n.doc);
|
|
961
982
|
if (r) {
|
|
962
983
|
let t = n.doc.lineAt(r.from), i = n.doc.lineAt(r.to);
|
|
@@ -986,15 +1007,15 @@ function Tt(e) {
|
|
|
986
1007
|
}
|
|
987
1008
|
return e.focus(), !0;
|
|
988
1009
|
}
|
|
989
|
-
function
|
|
1010
|
+
function Ot(e) {
|
|
990
1011
|
return t(e.doc) !== null;
|
|
991
1012
|
}
|
|
992
1013
|
//#endregion
|
|
993
1014
|
//#region src/toolbar/rule.ts
|
|
994
|
-
var
|
|
995
|
-
function
|
|
1015
|
+
var kt = /^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/;
|
|
1016
|
+
function At(e) {
|
|
996
1017
|
let t = e.state, n = t.doc.lineAt(t.selection.main.head);
|
|
997
|
-
return
|
|
1018
|
+
return kt.test(n.text) ? e.dispatch({
|
|
998
1019
|
changes: {
|
|
999
1020
|
from: n.from,
|
|
1000
1021
|
to: Math.min(n.to + 1, t.doc.length)
|
|
@@ -1017,46 +1038,46 @@ function Ot(e) {
|
|
|
1017
1038
|
scrollIntoView: !0
|
|
1018
1039
|
}), e.focus(), !0;
|
|
1019
1040
|
}
|
|
1020
|
-
function
|
|
1021
|
-
return
|
|
1041
|
+
function jt(e) {
|
|
1042
|
+
return kt.test(e.doc.lineAt(e.selection.main.head).text);
|
|
1022
1043
|
}
|
|
1023
1044
|
//#endregion
|
|
1024
1045
|
//#region src/editor/save.ts
|
|
1025
|
-
var
|
|
1026
|
-
function
|
|
1027
|
-
let t = e.state.facet(
|
|
1046
|
+
var Mt = p.define({ combine: (e) => e[0] ?? null });
|
|
1047
|
+
function Nt(e) {
|
|
1048
|
+
let t = e.state.facet(Mt);
|
|
1028
1049
|
return t ? (t(e.state.doc.toString()), !0) : !1;
|
|
1029
1050
|
}
|
|
1030
1051
|
//#endregion
|
|
1031
1052
|
//#region src/editor/search-panel-dom.ts
|
|
1032
|
-
var
|
|
1033
|
-
function
|
|
1053
|
+
var Pt = "stylo-search-panel";
|
|
1054
|
+
function Ft(e) {
|
|
1034
1055
|
e.setAttribute("form", "");
|
|
1035
1056
|
}
|
|
1036
|
-
function
|
|
1057
|
+
function It(e, t, n) {
|
|
1037
1058
|
let r = document.createElement("input");
|
|
1038
|
-
return r.type = "text", r.name = e, r.placeholder = t, r.setAttribute("aria-label", t), r.className = n,
|
|
1059
|
+
return r.type = "text", r.name = e, r.placeholder = t, r.setAttribute("aria-label", t), r.className = n, Ft(r), r;
|
|
1039
1060
|
}
|
|
1040
1061
|
function Q(e, t) {
|
|
1041
1062
|
let n = document.createElement("button");
|
|
1042
1063
|
return n.type = "button", n.name = e, n.className = "stylo-search-button", n.textContent = t, n;
|
|
1043
1064
|
}
|
|
1044
|
-
function
|
|
1065
|
+
function Lt(e, t) {
|
|
1045
1066
|
let n = document.createElement("input");
|
|
1046
|
-
n.type = "checkbox", n.name = e,
|
|
1067
|
+
n.type = "checkbox", n.name = e, Ft(n);
|
|
1047
1068
|
let r = document.createElement("label");
|
|
1048
1069
|
return r.className = "stylo-search-check", r.append(n, document.createTextNode(t)), {
|
|
1049
1070
|
field: n,
|
|
1050
1071
|
wrap: r
|
|
1051
1072
|
};
|
|
1052
1073
|
}
|
|
1053
|
-
function
|
|
1054
|
-
let t = (t) => e.state.phrase(t), n =
|
|
1074
|
+
function Rt(e) {
|
|
1075
|
+
let t = (t) => e.state.phrase(t), n = It("search", t("Find"), "stylo-search-field");
|
|
1055
1076
|
n.setAttribute("main-field", "true");
|
|
1056
|
-
let r = Q("next", t("next")), i = Q("prev", t("previous")), a = Q("select", t("all")), o =
|
|
1077
|
+
let r = Q("next", t("next")), i = Q("prev", t("previous")), a = Q("select", t("all")), o = It("replace", t("Replace"), "stylo-search-field stylo-search-replace"), s = Q("replace", t("replace")), c = Q("replaceAll", t("replace all")), l = Lt("case", t("match case")), u = Lt("re", t("regexp")), d = Lt("word", t("by word")), f = Q("close", "×");
|
|
1057
1078
|
f.classList.add("stylo-search-close"), f.setAttribute("aria-label", t("close"));
|
|
1058
1079
|
let p = document.createElement("div");
|
|
1059
|
-
return p.className =
|
|
1080
|
+
return p.className = Pt, p.append(n, r, i, a, o, s, c, l.wrap, u.wrap, d.wrap, f), {
|
|
1060
1081
|
root: p,
|
|
1061
1082
|
find: n,
|
|
1062
1083
|
next: r,
|
|
@@ -1073,31 +1094,31 @@ function It(e) {
|
|
|
1073
1094
|
}
|
|
1074
1095
|
//#endregion
|
|
1075
1096
|
//#region src/editor/search-panel.ts
|
|
1076
|
-
var
|
|
1077
|
-
function
|
|
1078
|
-
return
|
|
1097
|
+
var zt = "cm-search-closing", Bt = 160;
|
|
1098
|
+
function Vt(e) {
|
|
1099
|
+
return se(e.state) ? $(e) : w(e);
|
|
1079
1100
|
}
|
|
1080
1101
|
function $(e) {
|
|
1081
|
-
let t = e.dom.querySelector(`.${
|
|
1082
|
-
return !t || t.classList.contains(
|
|
1083
|
-
e.dom.isConnected &&
|
|
1084
|
-
},
|
|
1102
|
+
let t = e.dom.querySelector(`.${Pt}`);
|
|
1103
|
+
return !t || t.classList.contains(zt) ? !0 : (t.classList.add(zt), setTimeout(() => {
|
|
1104
|
+
e.dom.isConnected && b(e);
|
|
1105
|
+
}, Bt), !0);
|
|
1085
1106
|
}
|
|
1086
|
-
function
|
|
1087
|
-
let t =
|
|
1107
|
+
function Ht(e) {
|
|
1108
|
+
let t = Rt(e), n = C(e.state);
|
|
1088
1109
|
r(n);
|
|
1089
1110
|
function r(e) {
|
|
1090
1111
|
t.find.value = e.search, t.replace.value = e.replace, t.caseSensitive.checked = e.caseSensitive, t.regexp.checked = e.regexp, t.wholeWord.checked = e.wholeWord;
|
|
1091
1112
|
}
|
|
1092
1113
|
function i() {
|
|
1093
|
-
let r = new
|
|
1114
|
+
let r = new y({
|
|
1094
1115
|
search: t.find.value,
|
|
1095
1116
|
caseSensitive: t.caseSensitive.checked,
|
|
1096
1117
|
regexp: t.regexp.checked,
|
|
1097
1118
|
wholeWord: t.wholeWord.checked,
|
|
1098
1119
|
replace: t.replace.value
|
|
1099
1120
|
});
|
|
1100
|
-
r.eq(n) || (n = r, e.dispatch({ effects:
|
|
1121
|
+
r.eq(n) || (n = r, e.dispatch({ effects: le.of(n) }));
|
|
1101
1122
|
}
|
|
1102
1123
|
for (let e of [
|
|
1103
1124
|
t.find,
|
|
@@ -1115,202 +1136,248 @@ function Bt(e) {
|
|
|
1115
1136
|
n.preventDefault();
|
|
1116
1137
|
return;
|
|
1117
1138
|
}
|
|
1118
|
-
n.key === "Enter" && (n.preventDefault(), n.target === t.find ? (n.shiftKey ? S : x)(e) : n.target === t.replace &&
|
|
1119
|
-
}), t.next.addEventListener("click", () => x(e)), t.prev.addEventListener("click", () => S(e)), t.all.addEventListener("click", () =>
|
|
1139
|
+
n.key === "Enter" && (n.preventDefault(), n.target === t.find ? (n.shiftKey ? S : x)(e) : n.target === t.replace && ie(e));
|
|
1140
|
+
}), t.next.addEventListener("click", () => x(e)), t.prev.addEventListener("click", () => S(e)), t.all.addEventListener("click", () => ce(e)), t.replaceBtn.addEventListener("click", () => ie(e)), t.replaceAllBtn.addEventListener("click", () => re(e)), t.close.addEventListener("click", () => $(e)), {
|
|
1120
1141
|
dom: t.root,
|
|
1121
1142
|
top: !0,
|
|
1122
1143
|
update(e) {
|
|
1123
|
-
for (let t of e.transactions) for (let e of t.effects) e.is(
|
|
1144
|
+
for (let t of e.transactions) for (let e of t.effects) e.is(le) && !e.value.eq(n) && (n = e.value, r(n));
|
|
1124
1145
|
}
|
|
1125
1146
|
};
|
|
1126
1147
|
}
|
|
1127
1148
|
//#endregion
|
|
1128
1149
|
//#region src/toolbar/commands.ts
|
|
1129
|
-
var
|
|
1130
|
-
|
|
1131
|
-
|
|
1150
|
+
var Ut = [
|
|
1151
|
+
Tt("undo", "Undo", _),
|
|
1152
|
+
Tt("redo", "Redo", g),
|
|
1132
1153
|
{
|
|
1133
1154
|
id: "save",
|
|
1134
1155
|
title: "Save",
|
|
1135
1156
|
run: (e) => {
|
|
1136
|
-
let t =
|
|
1157
|
+
let t = Nt(e);
|
|
1137
1158
|
return e.focus(), t;
|
|
1138
1159
|
},
|
|
1139
|
-
disabled: (e) => e.facet(
|
|
1160
|
+
disabled: (e) => e.facet(Mt) == null
|
|
1140
1161
|
},
|
|
1141
1162
|
{
|
|
1142
1163
|
id: "search",
|
|
1143
1164
|
title: "Find / replace",
|
|
1144
|
-
run: (e) =>
|
|
1165
|
+
run: (e) => Vt(e),
|
|
1166
|
+
isActive: (e) => se(e),
|
|
1145
1167
|
keys: ["Mod-f"]
|
|
1146
1168
|
},
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1169
|
+
Et(1),
|
|
1170
|
+
Et(2),
|
|
1171
|
+
Et(3),
|
|
1150
1172
|
{
|
|
1151
1173
|
id: "body",
|
|
1152
1174
|
title: "Body",
|
|
1153
|
-
run: (e) => (
|
|
1175
|
+
run: (e) => (Je(e) || e.focus(), !0),
|
|
1154
1176
|
isActive: (e) => !/^#{1,6} /.test(e.doc.lineAt(e.selection.main.head).text),
|
|
1155
|
-
disabled:
|
|
1177
|
+
disabled: J(U, q)
|
|
1156
1178
|
},
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1179
|
+
X("bold", "Bold", "**", ["Mod-b"]),
|
|
1180
|
+
X("italic", "Italic", "*", ["Mod-i"]),
|
|
1181
|
+
X("strike", "Strikethrough", "~~"),
|
|
1160
1182
|
{
|
|
1161
1183
|
id: "underline",
|
|
1162
1184
|
title: "Underline",
|
|
1163
|
-
run: (e) =>
|
|
1164
|
-
isActive:
|
|
1165
|
-
disabled: q
|
|
1185
|
+
run: (e) => M(e, xe) || nt(e),
|
|
1186
|
+
isActive: rt,
|
|
1187
|
+
disabled: J(q, yt("u"), bt),
|
|
1166
1188
|
keys: ["Mod-u"]
|
|
1167
1189
|
},
|
|
1168
|
-
|
|
1190
|
+
X("code", "Inline code", "`"),
|
|
1169
1191
|
{
|
|
1170
1192
|
id: "codeBlock",
|
|
1171
1193
|
title: "Code block",
|
|
1172
|
-
run: (e) =>
|
|
1173
|
-
isActive: (e) =>
|
|
1174
|
-
disabled:
|
|
1194
|
+
run: (e) => M(e, (e, t, n) => k(e, t, n, "`")) || (U(e.state) ? L(e, "`") : He(e)),
|
|
1195
|
+
isActive: (e) => U(e) ? R(e, "`") : F(e),
|
|
1196
|
+
disabled: J(K, I, G)
|
|
1175
1197
|
},
|
|
1176
1198
|
{
|
|
1177
1199
|
id: "link",
|
|
1178
1200
|
title: "Link",
|
|
1179
|
-
run: (e) =>
|
|
1180
|
-
isActive:
|
|
1181
|
-
disabled:
|
|
1201
|
+
run: (e) => M(e, _e) || Xe(e),
|
|
1202
|
+
isActive: Ze,
|
|
1203
|
+
disabled: q,
|
|
1182
1204
|
keys: ["Mod-k"]
|
|
1183
1205
|
},
|
|
1184
1206
|
{
|
|
1185
1207
|
id: "wikilink",
|
|
1186
1208
|
title: "Wikilink",
|
|
1187
|
-
run: (e) =>
|
|
1188
|
-
isActive:
|
|
1189
|
-
disabled:
|
|
1209
|
+
run: (e) => M(e, ye) || $e(e),
|
|
1210
|
+
isActive: et,
|
|
1211
|
+
disabled: q,
|
|
1190
1212
|
keys: ["Mod-Shift-k"]
|
|
1191
1213
|
},
|
|
1192
|
-
Z("quote", "Blockquote",
|
|
1193
|
-
Z("bulletList", "Bulleted list",
|
|
1194
|
-
Z("orderedList", "Numbered list",
|
|
1195
|
-
Z("task", "Task list",
|
|
1214
|
+
Z("quote", "Blockquote", xt),
|
|
1215
|
+
Z("bulletList", "Bulleted list", St, G),
|
|
1216
|
+
Z("orderedList", "Numbered list", Ct, G),
|
|
1217
|
+
Z("task", "Task list", wt, G),
|
|
1196
1218
|
{
|
|
1197
1219
|
id: "hr",
|
|
1198
1220
|
title: "Divider",
|
|
1199
|
-
run:
|
|
1200
|
-
isActive:
|
|
1201
|
-
disabled:
|
|
1221
|
+
run: At,
|
|
1222
|
+
isActive: jt,
|
|
1223
|
+
disabled: J(U, q)
|
|
1202
1224
|
},
|
|
1203
1225
|
{
|
|
1204
1226
|
id: "frontmatter",
|
|
1205
1227
|
title: "Frontmatter",
|
|
1206
|
-
run:
|
|
1207
|
-
isActive:
|
|
1208
|
-
disabled:
|
|
1228
|
+
run: Dt,
|
|
1229
|
+
isActive: Ot,
|
|
1230
|
+
disabled: J(U, F, I, G)
|
|
1209
1231
|
},
|
|
1210
1232
|
{
|
|
1211
1233
|
id: "table",
|
|
1212
1234
|
title: "Table",
|
|
1213
|
-
run:
|
|
1214
|
-
isActive:
|
|
1215
|
-
disabled:
|
|
1235
|
+
run: mt,
|
|
1236
|
+
isActive: U,
|
|
1237
|
+
disabled: J(U, K, F, I, G)
|
|
1216
1238
|
},
|
|
1217
|
-
|
|
1239
|
+
X("math", "Inline math", "$"),
|
|
1218
1240
|
{
|
|
1219
1241
|
id: "mathBlock",
|
|
1220
1242
|
title: "Block math",
|
|
1221
|
-
run: (e) =>
|
|
1222
|
-
isActive: (e) =>
|
|
1223
|
-
disabled:
|
|
1243
|
+
run: (e) => M(e, (e, t, n) => k(e, t, n, "$")) || (U(e.state) ? L(e, "$") : Ke(e)),
|
|
1244
|
+
isActive: (e) => U(e) ? R(e, "$") : I(e),
|
|
1245
|
+
disabled: J(K, F, G)
|
|
1224
1246
|
}
|
|
1225
|
-
],
|
|
1247
|
+
], Wt = Object.fromEntries(Ut.map((e) => [e.id, e])), Gt = m.high(a.of(Ut.filter((e) => e.keys && e.keys.length > 0).flatMap((e) => e.keys.map((t) => ({
|
|
1226
1248
|
key: t,
|
|
1227
1249
|
preventDefault: !0,
|
|
1228
1250
|
run: ((t) => !e.disabled?.(t.state) && e.run(t))
|
|
1229
|
-
}))))),
|
|
1251
|
+
}))))), Kt = ue.define([
|
|
1230
1252
|
{
|
|
1231
1253
|
tag: [
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1254
|
+
T.keyword,
|
|
1255
|
+
T.modifier,
|
|
1256
|
+
T.controlKeyword,
|
|
1257
|
+
T.operatorKeyword,
|
|
1258
|
+
T.definitionKeyword,
|
|
1259
|
+
T.moduleKeyword
|
|
1238
1260
|
],
|
|
1239
1261
|
color: "var(--stylo-syntax-keyword)"
|
|
1240
1262
|
},
|
|
1241
1263
|
{
|
|
1242
1264
|
tag: [
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1265
|
+
T.string,
|
|
1266
|
+
T.special(T.string),
|
|
1267
|
+
T.regexp,
|
|
1268
|
+
T.attributeValue
|
|
1247
1269
|
],
|
|
1248
1270
|
color: "var(--stylo-syntax-string)"
|
|
1249
1271
|
},
|
|
1250
1272
|
{
|
|
1251
|
-
tag: [
|
|
1273
|
+
tag: [T.escape, T.character],
|
|
1252
1274
|
color: "var(--stylo-syntax-escape)"
|
|
1253
1275
|
},
|
|
1254
1276
|
{
|
|
1255
1277
|
tag: [
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1278
|
+
T.comment,
|
|
1279
|
+
T.lineComment,
|
|
1280
|
+
T.blockComment,
|
|
1281
|
+
T.docComment
|
|
1260
1282
|
],
|
|
1261
1283
|
color: "var(--stylo-syntax-comment)",
|
|
1262
1284
|
fontStyle: "italic"
|
|
1263
1285
|
},
|
|
1264
1286
|
{
|
|
1265
1287
|
tag: [
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1288
|
+
T.number,
|
|
1289
|
+
T.integer,
|
|
1290
|
+
T.float
|
|
1269
1291
|
],
|
|
1270
1292
|
color: "var(--stylo-syntax-number)"
|
|
1271
1293
|
},
|
|
1272
1294
|
{
|
|
1273
1295
|
tag: [
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1296
|
+
T.bool,
|
|
1297
|
+
T.null,
|
|
1298
|
+
T.atom,
|
|
1299
|
+
T.constant(T.name)
|
|
1278
1300
|
],
|
|
1279
1301
|
color: "var(--stylo-syntax-constant)"
|
|
1280
1302
|
},
|
|
1281
1303
|
{
|
|
1282
1304
|
tag: [
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1305
|
+
T.function(T.variableName),
|
|
1306
|
+
T.function(T.propertyName),
|
|
1307
|
+
T.macroName
|
|
1286
1308
|
],
|
|
1287
1309
|
color: "var(--stylo-syntax-function)"
|
|
1288
1310
|
},
|
|
1289
1311
|
{
|
|
1290
1312
|
tag: [
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1313
|
+
T.typeName,
|
|
1314
|
+
T.className,
|
|
1315
|
+
T.namespace
|
|
1294
1316
|
],
|
|
1295
1317
|
color: "var(--stylo-syntax-type)"
|
|
1296
1318
|
},
|
|
1297
1319
|
{
|
|
1298
|
-
tag: [
|
|
1320
|
+
tag: [T.propertyName, T.attributeName],
|
|
1299
1321
|
color: "var(--stylo-syntax-property)"
|
|
1300
1322
|
},
|
|
1301
1323
|
{
|
|
1302
|
-
tag: [
|
|
1324
|
+
tag: [T.tagName],
|
|
1303
1325
|
color: "var(--stylo-syntax-tag)"
|
|
1304
1326
|
},
|
|
1305
1327
|
{
|
|
1306
|
-
tag: [
|
|
1328
|
+
tag: [T.meta, T.annotation],
|
|
1307
1329
|
color: "var(--stylo-syntax-comment)"
|
|
1308
1330
|
},
|
|
1309
1331
|
{
|
|
1310
|
-
tag: [
|
|
1332
|
+
tag: [T.invalid],
|
|
1311
1333
|
color: "var(--stylo-syntax-invalid)"
|
|
1312
1334
|
}
|
|
1313
|
-
]),
|
|
1335
|
+
]), qt = de(Kt), Jt = /(?<=^|\s)#[^\s#]*$/;
|
|
1336
|
+
function Yt(e) {
|
|
1337
|
+
return {
|
|
1338
|
+
label: e.tag,
|
|
1339
|
+
apply: (t, n, r, i) => {
|
|
1340
|
+
t.dispatch({
|
|
1341
|
+
changes: {
|
|
1342
|
+
from: r,
|
|
1343
|
+
to: i,
|
|
1344
|
+
insert: e.tag
|
|
1345
|
+
},
|
|
1346
|
+
selection: { anchor: r + e.tag.length },
|
|
1347
|
+
userEvent: "input.complete"
|
|
1348
|
+
});
|
|
1349
|
+
}
|
|
1350
|
+
};
|
|
1351
|
+
}
|
|
1352
|
+
function Xt(e, t) {
|
|
1353
|
+
return async (n) => {
|
|
1354
|
+
let r = n.matchBefore(Jt);
|
|
1355
|
+
if (!r || r.from + 1 === n.pos && !n.explicit) return null;
|
|
1356
|
+
let i = r.text.slice(1);
|
|
1357
|
+
if (/^\d/.test(i)) return null;
|
|
1358
|
+
let a;
|
|
1359
|
+
try {
|
|
1360
|
+
a = (await e(i)).map(Yt);
|
|
1361
|
+
} catch (e) {
|
|
1362
|
+
return t?.(e, {
|
|
1363
|
+
source: "tagSource",
|
|
1364
|
+
input: i
|
|
1365
|
+
}), null;
|
|
1366
|
+
}
|
|
1367
|
+
return a.length ? {
|
|
1368
|
+
from: r.from + 1,
|
|
1369
|
+
to: n.pos,
|
|
1370
|
+
options: a,
|
|
1371
|
+
filter: !1
|
|
1372
|
+
} : null;
|
|
1373
|
+
};
|
|
1374
|
+
}
|
|
1375
|
+
function Zt(e, t) {
|
|
1376
|
+
return e ? [pe(), v.data.of({ autocomplete: Xt(e, t) })] : [];
|
|
1377
|
+
}
|
|
1378
|
+
//#endregion
|
|
1379
|
+
//#region src/editor/theme.ts
|
|
1380
|
+
var Qt = i.theme({
|
|
1314
1381
|
"&": {
|
|
1315
1382
|
color: "var(--stylo-text)",
|
|
1316
1383
|
backgroundColor: "var(--stylo-bg)",
|
|
@@ -1412,8 +1479,8 @@ var Vt = [
|
|
|
1412
1479
|
backgroundColor: "color-mix(in srgb, var(--stylo-ring) 70%, transparent)",
|
|
1413
1480
|
outline: "1px solid var(--stylo-ring)"
|
|
1414
1481
|
}
|
|
1415
|
-
}),
|
|
1416
|
-
function
|
|
1482
|
+
}), $t = /\[\[([^[\]\n|]*)$/;
|
|
1483
|
+
function en(e) {
|
|
1417
1484
|
let t = e.label && e.label !== e.target ? e.label : void 0, n = t ? `${e.target}|${t}` : e.target;
|
|
1418
1485
|
return {
|
|
1419
1486
|
label: e.label ?? e.target,
|
|
@@ -1431,13 +1498,13 @@ function Jt(e) {
|
|
|
1431
1498
|
}
|
|
1432
1499
|
};
|
|
1433
1500
|
}
|
|
1434
|
-
function
|
|
1501
|
+
function tn(e, t) {
|
|
1435
1502
|
return async (n) => {
|
|
1436
|
-
let r = n.matchBefore(
|
|
1503
|
+
let r = n.matchBefore($t);
|
|
1437
1504
|
if (!r || r.from + 2 === n.pos && !n.explicit) return null;
|
|
1438
1505
|
let i = r.text.slice(2), a;
|
|
1439
1506
|
try {
|
|
1440
|
-
a = (await e(i)).map(
|
|
1507
|
+
a = (await e(i)).map(en);
|
|
1441
1508
|
} catch (e) {
|
|
1442
1509
|
return t?.(e, {
|
|
1443
1510
|
source: "wikiLinkSource",
|
|
@@ -1452,56 +1519,57 @@ function Yt(e, t) {
|
|
|
1452
1519
|
} : null;
|
|
1453
1520
|
};
|
|
1454
1521
|
}
|
|
1455
|
-
function
|
|
1456
|
-
return e ? [
|
|
1522
|
+
function nn(e, t) {
|
|
1523
|
+
return e ? [pe(), v.data.of({ autocomplete: tn(e, t) })] : [];
|
|
1457
1524
|
}
|
|
1458
1525
|
//#endregion
|
|
1459
1526
|
//#region src/editor/extensions.ts
|
|
1460
|
-
function
|
|
1527
|
+
function rn(e, t, n, r) {
|
|
1461
1528
|
return [
|
|
1462
|
-
|
|
1463
|
-
a.of([...ee, ...
|
|
1464
|
-
m.high(
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1529
|
+
te(),
|
|
1530
|
+
a.of([...ee, ...h]),
|
|
1531
|
+
m.high(_t),
|
|
1532
|
+
Gt,
|
|
1533
|
+
vt,
|
|
1534
|
+
ae({
|
|
1468
1535
|
top: !0,
|
|
1469
|
-
createPanel:
|
|
1536
|
+
createPanel: Ht
|
|
1470
1537
|
}),
|
|
1471
|
-
a.of(
|
|
1472
|
-
|
|
1473
|
-
base:
|
|
1538
|
+
a.of(oe),
|
|
1539
|
+
ne({
|
|
1540
|
+
base: v,
|
|
1474
1541
|
codeLanguages: e
|
|
1475
1542
|
}),
|
|
1476
|
-
|
|
1477
|
-
|
|
1543
|
+
qt,
|
|
1544
|
+
nn(t, n),
|
|
1545
|
+
Zt(r, n),
|
|
1478
1546
|
i.lineWrapping,
|
|
1479
|
-
|
|
1547
|
+
Qt
|
|
1480
1548
|
];
|
|
1481
1549
|
}
|
|
1482
|
-
function
|
|
1550
|
+
function an(e) {
|
|
1483
1551
|
return [
|
|
1484
1552
|
f.readOnly.of(e.readOnly),
|
|
1485
1553
|
i.editable.of(!e.readOnly),
|
|
1486
1554
|
e.placeholder ? o(e.placeholder) : [],
|
|
1487
|
-
e.save ?
|
|
1555
|
+
e.save ? Mt.of(e.save) : []
|
|
1488
1556
|
];
|
|
1489
1557
|
}
|
|
1490
1558
|
//#endregion
|
|
1491
1559
|
//#region src/editor/useCodeMirror.ts
|
|
1492
|
-
var
|
|
1493
|
-
function
|
|
1494
|
-
let g = r(null), _ = r(null),
|
|
1495
|
-
|
|
1560
|
+
var on = c.define();
|
|
1561
|
+
function sn({ value: e, onChange: t, readOnly: o = !1, placeholder: s, onSave: c, onViewChange: l, extensions: d, codeLanguages: p, wikiLinkSource: ee, tagSource: te, onResolveError: h }) {
|
|
1562
|
+
let g = r(null), _ = r(null), ne = r(t);
|
|
1563
|
+
ne.current = t;
|
|
1496
1564
|
let v = r(c);
|
|
1497
1565
|
v.current = c;
|
|
1498
1566
|
let y = r((e) => v.current?.(e)).current, b = r(h);
|
|
1499
1567
|
b.current = h;
|
|
1500
|
-
let
|
|
1568
|
+
let x = r((e, t) => {
|
|
1501
1569
|
b.current?.(e, t);
|
|
1502
|
-
}).current,
|
|
1503
|
-
|
|
1504
|
-
let
|
|
1570
|
+
}).current, S = c != null, C = r(l);
|
|
1571
|
+
C.current = l;
|
|
1572
|
+
let w = r(new u());
|
|
1505
1573
|
return n(() => {
|
|
1506
1574
|
let t = g.current;
|
|
1507
1575
|
if (!t) return;
|
|
@@ -1510,25 +1578,25 @@ function en({ value: e, onChange: t, readOnly: o = !1, placeholder: s, onSave: c
|
|
|
1510
1578
|
state: f.create({
|
|
1511
1579
|
doc: e,
|
|
1512
1580
|
extensions: [
|
|
1513
|
-
|
|
1514
|
-
|
|
1581
|
+
rn(p, ee, x, te),
|
|
1582
|
+
w.current.of(an({
|
|
1515
1583
|
readOnly: o,
|
|
1516
1584
|
placeholder: s,
|
|
1517
|
-
save:
|
|
1585
|
+
save: S ? y : void 0
|
|
1518
1586
|
})),
|
|
1519
1587
|
m.high(a.of([{
|
|
1520
1588
|
key: "Mod-s",
|
|
1521
|
-
run:
|
|
1589
|
+
run: Nt
|
|
1522
1590
|
}])),
|
|
1523
1591
|
...d ?? [],
|
|
1524
1592
|
i.updateListener.of((e) => {
|
|
1525
|
-
e.docChanged && (e.transactions.some((e) => !!e.annotation(
|
|
1593
|
+
e.docChanged && (e.transactions.some((e) => !!e.annotation(on)) || ne.current(e.state.doc.toString()));
|
|
1526
1594
|
})
|
|
1527
1595
|
]
|
|
1528
1596
|
})
|
|
1529
1597
|
});
|
|
1530
|
-
return _.current = n,
|
|
1531
|
-
|
|
1598
|
+
return _.current = n, C.current?.(n), () => {
|
|
1599
|
+
C.current?.(null), n.destroy(), _.current = null;
|
|
1532
1600
|
};
|
|
1533
1601
|
}, []), n(() => {
|
|
1534
1602
|
let t = _.current;
|
|
@@ -1540,22 +1608,22 @@ function en({ value: e, onChange: t, readOnly: o = !1, placeholder: s, onSave: c
|
|
|
1540
1608
|
to: n.length,
|
|
1541
1609
|
insert: e
|
|
1542
1610
|
},
|
|
1543
|
-
annotations:
|
|
1611
|
+
annotations: on.of(!0)
|
|
1544
1612
|
});
|
|
1545
1613
|
}, [e]), n(() => {
|
|
1546
|
-
_.current?.dispatch({ effects:
|
|
1614
|
+
_.current?.dispatch({ effects: w.current.reconfigure(an({
|
|
1547
1615
|
readOnly: o,
|
|
1548
1616
|
placeholder: s,
|
|
1549
|
-
save:
|
|
1617
|
+
save: S ? y : void 0
|
|
1550
1618
|
})) });
|
|
1551
1619
|
}, [
|
|
1552
1620
|
o,
|
|
1553
1621
|
s,
|
|
1554
|
-
|
|
1622
|
+
S,
|
|
1555
1623
|
y
|
|
1556
1624
|
]), g;
|
|
1557
1625
|
}
|
|
1558
1626
|
//#endregion
|
|
1559
|
-
export {
|
|
1627
|
+
export { he as S, ke as _, z as a, ve as b, F as c, Oe as d, Ne as f, Me as g, Fe as h, ft as i, Ie as l, je as m, Wt as n, B as o, j as p, At as r, Ue as s, sn as t, ze as u, Ae as v, ge as x, D as y };
|
|
1560
1628
|
|
|
1561
|
-
//# sourceMappingURL=useCodeMirror-
|
|
1629
|
+
//# sourceMappingURL=useCodeMirror-BI1kEPRE.js.map
|