@damiro/stylo 0.10.1 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/dist/{InPlaceView-CkbMemAa.js → InPlaceView-Dyf7I4XQ.js} +566 -562
- package/dist/InPlaceView-Dyf7I4XQ.js.map +1 -0
- package/dist/{Preview-AaGGwLQP.js → Preview-DIsFdBFA.js} +3 -3
- package/dist/{Preview-AaGGwLQP.js.map → Preview-DIsFdBFA.js.map} +1 -1
- package/dist/SplitView.d.ts +6 -1
- package/dist/SplitView.d.ts.map +1 -1
- package/dist/Stylo.d.ts.map +1 -1
- package/dist/editor/SourceView.d.ts +6 -1
- package/dist/editor/SourceView.d.ts.map +1 -1
- package/dist/editor/canvas-header-panel.d.ts +27 -0
- package/dist/editor/canvas-header-panel.d.ts.map +1 -0
- package/dist/{embed-B2Dfkpd_.js → embed-Dsu6b-MV.js} +16 -9
- package/dist/embed-Dsu6b-MV.js.map +1 -0
- package/dist/frontmatter-DTCC0gaa.js +40 -0
- package/dist/frontmatter-DTCC0gaa.js.map +1 -0
- package/dist/inplace/InPlaceView.d.ts +6 -1
- package/dist/inplace/InPlaceView.d.ts.map +1 -1
- package/dist/inplace/table-widget.d.ts +10 -5
- package/dist/inplace/table-widget.d.ts.map +1 -1
- package/dist/inplace/theme-canvas.d.ts +7 -1
- package/dist/inplace/theme-canvas.d.ts.map +1 -1
- package/dist/render/Embed.d.ts.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/stylo.js +190 -163
- package/dist/stylo.js.map +1 -1
- package/dist/toolbar/Toolbar.d.ts.map +1 -1
- package/dist/toolbar/commands.d.ts.map +1 -1
- package/dist/types.d.ts +12 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/{useCodeMirror-CpE_Ncfn.js → useCodeMirror-CjG9CwpB.js} +229 -207
- package/dist/useCodeMirror-CjG9CwpB.js.map +1 -0
- package/package.json +1 -1
- package/dist/InPlaceView-CkbMemAa.js.map +0 -1
- package/dist/embed-B2Dfkpd_.js.map +0 -1
- package/dist/frontmatter-DGUkb9z-.js +0 -39
- package/dist/frontmatter-DGUkb9z-.js.map +0 -1
- package/dist/useCodeMirror-CpE_Ncfn.js.map +0 -1
|
@@ -1,13 +1,34 @@
|
|
|
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
|
|
5
|
+
import { defaultKeymap as ee, history as te, historyKeymap as h, redo as g, undo as _ } from "@codemirror/commands";
|
|
6
6
|
import { markdown as v, markdownLanguage as y } from "@codemirror/lang-markdown";
|
|
7
7
|
import { SearchQuery as b, closeSearchPanel as ne, findNext as x, findPrevious as S, getSearchQuery as C, openSearchPanel as re, replaceAll as ie, replaceNext as ae, search as oe, searchKeymap as se, searchPanelOpen as ce, selectMatches as le, setSearchQuery as ue } from "@codemirror/search";
|
|
8
8
|
import { HighlightStyle as de, syntaxHighlighting as fe, syntaxTree as pe } from "@codemirror/language";
|
|
9
9
|
import { tags as w } from "@lezer/highlight";
|
|
10
10
|
import { autocompletion as me } from "@codemirror/autocomplete";
|
|
11
|
+
//#region src/editor/canvas-header-panel.ts
|
|
12
|
+
var he = "stylo-canvas-header", ge = class {
|
|
13
|
+
dom = null;
|
|
14
|
+
listeners = /* @__PURE__ */ new Set();
|
|
15
|
+
panel = () => {
|
|
16
|
+
let e = document.createElement("div");
|
|
17
|
+
return e.className = he, 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
33
|
function T(e, t) {
|
|
13
34
|
let n = /\[([^\]]*)\]\([^)]*\)/g;
|
|
@@ -21,7 +42,7 @@ function T(e, t) {
|
|
|
21
42
|
}
|
|
22
43
|
return null;
|
|
23
44
|
}
|
|
24
|
-
function
|
|
45
|
+
function _e(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,7 +60,7 @@ function he(e, t) {
|
|
|
39
60
|
}
|
|
40
61
|
return null;
|
|
41
62
|
}
|
|
42
|
-
function
|
|
63
|
+
function ve(e, t, n) {
|
|
43
64
|
let r = T(e, t);
|
|
44
65
|
if (r) return {
|
|
45
66
|
text: e.slice(0, r.from) + r.label + e.slice(r.to),
|
|
@@ -66,7 +87,7 @@ function E(t, n) {
|
|
|
66
87
|
}
|
|
67
88
|
return null;
|
|
68
89
|
}
|
|
69
|
-
function
|
|
90
|
+
function ye(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,7 +103,7 @@ function _e(t, n) {
|
|
|
82
103
|
}
|
|
83
104
|
return null;
|
|
84
105
|
}
|
|
85
|
-
function
|
|
106
|
+
function be(e, t, n) {
|
|
86
107
|
let r = E(e, t);
|
|
87
108
|
if (r) return {
|
|
88
109
|
text: e.slice(0, r.from) + r.label + e.slice(r.to),
|
|
@@ -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 xe(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 Se(e, t, n) {
|
|
135
|
+
let r = xe(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,
|
|
@@ -129,7 +150,7 @@ function be(e, t, n) {
|
|
|
129
150
|
function D(e) {
|
|
130
151
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
131
152
|
}
|
|
132
|
-
function
|
|
153
|
+
function Ce(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 we(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 Te(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 Ee(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) && Te(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 = Ce(e, t, -1), u = Ce(e, n, 1), d = we(l.text, a), f = we(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 (!Te(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 De(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
237
|
function O(e, t, n, r) {
|
|
217
|
-
let i =
|
|
238
|
+
let i = Ee(e, t, n, r);
|
|
218
239
|
return {
|
|
219
|
-
text:
|
|
240
|
+
text: De(e, i.changes),
|
|
220
241
|
from: i.from,
|
|
221
242
|
to: i.to
|
|
222
243
|
};
|
|
223
244
|
}
|
|
224
|
-
function
|
|
245
|
+
function Oe(e, t) {
|
|
225
246
|
let n = T(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 = ye(e, t);
|
|
231
252
|
if (r) return {
|
|
232
253
|
from: r.from,
|
|
233
254
|
to: r.to
|
|
@@ -253,7 +274,7 @@ function Ee(e, t) {
|
|
|
253
274
|
}
|
|
254
275
|
//#endregion
|
|
255
276
|
//#region src/inplace/table-cell-dom.ts
|
|
256
|
-
var
|
|
277
|
+
var ke = (e) => [e.head, ...e.body].map((e) => [...e]), Ae = (e) => e.map((e) => e.map((e) => e.trim())), je = (e) => e.replace(/\\\|/g, "|");
|
|
257
278
|
function k(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()) {
|
|
@@ -262,11 +283,11 @@ function k(e, t) {
|
|
|
262
283
|
}
|
|
263
284
|
return r;
|
|
264
285
|
}
|
|
265
|
-
function
|
|
286
|
+
function Me(e) {
|
|
266
287
|
let t = e.ownerDocument.getSelection(), n = t?.anchorNode;
|
|
267
288
|
return !n || !e.contains(n) ? 0 : n.nodeType === Node.TEXT_NODE ? k(e, n) + (t?.anchorOffset ?? 0) : (t?.anchorOffset ?? 0) > 0 ? (e.textContent ?? "").length : 0;
|
|
268
289
|
}
|
|
269
|
-
function
|
|
290
|
+
function Ne(e) {
|
|
270
291
|
let t = e.ownerDocument.getSelection(), n = (e.textContent ?? "").length, r = (t, r) => !t || !e.contains(t) ? n : t.nodeType === Node.TEXT_NODE ? k(e, t) + r : r > 0 ? n : 0;
|
|
271
292
|
if (!t || t.rangeCount === 0) return {
|
|
272
293
|
from: n,
|
|
@@ -278,7 +299,7 @@ function je(e) {
|
|
|
278
299
|
to: Math.max(i, a)
|
|
279
300
|
};
|
|
280
301
|
}
|
|
281
|
-
function
|
|
302
|
+
function Pe(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);
|
|
@@ -289,13 +310,13 @@ function Me(e, t, n) {
|
|
|
289
310
|
}
|
|
290
311
|
return !i || !e.contains(i) ? 0 : k(e, i) + (i.nodeType === Node.TEXT_NODE ? a : 0);
|
|
291
312
|
}
|
|
292
|
-
var
|
|
293
|
-
function
|
|
294
|
-
let r = e.textContent ?? "", i =
|
|
313
|
+
var Fe = /[\p{L}\p{N}_]/u;
|
|
314
|
+
function Ie(e, t, n) {
|
|
315
|
+
let r = e.textContent ?? "", i = Pe(e, t, n), a = Oe(r, i);
|
|
295
316
|
if (a) return A(e, a.from, a.to), !0;
|
|
296
317
|
let o = i, s = i;
|
|
297
|
-
for (; o > 0 &&
|
|
298
|
-
for (; s < r.length &&
|
|
318
|
+
for (; o > 0 && Fe.test(r[o - 1]);) o--;
|
|
319
|
+
for (; s < r.length && Fe.test(r[s]);) s++;
|
|
299
320
|
return s <= o ? !1 : (A(e, o, s), !0);
|
|
300
321
|
}
|
|
301
322
|
function A(e, t, n = t) {
|
|
@@ -311,29 +332,29 @@ function A(e, t, n = t) {
|
|
|
311
332
|
}
|
|
312
333
|
//#endregion
|
|
313
334
|
//#region src/toolbar/cell-inline.ts
|
|
314
|
-
function
|
|
335
|
+
function Le(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 } =
|
|
339
|
+
function Re(e, t) {
|
|
340
|
+
let { from: n, to: r } = Ne(e), i = t(e.textContent ?? "", n, r);
|
|
320
341
|
e.textContent = i.text, A(e, i.from, i.to), e.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
321
342
|
}
|
|
322
343
|
function j(e, t) {
|
|
323
|
-
let n =
|
|
324
|
-
return n ? (
|
|
344
|
+
let n = Le(e);
|
|
345
|
+
return n ? (Re(n, t), !0) : !1;
|
|
325
346
|
}
|
|
326
|
-
var
|
|
347
|
+
var ze = {
|
|
327
348
|
b: (e, t, n) => O(e, t, n, "**"),
|
|
328
349
|
i: (e, t, n) => O(e, t, n, "*"),
|
|
329
|
-
u:
|
|
330
|
-
k:
|
|
331
|
-
K:
|
|
350
|
+
u: Se,
|
|
351
|
+
k: ve,
|
|
352
|
+
K: be
|
|
332
353
|
};
|
|
333
|
-
function
|
|
354
|
+
function Be(e, t) {
|
|
334
355
|
if (!(e.metaKey || e.ctrlKey) || e.altKey) return !1;
|
|
335
|
-
let n =
|
|
336
|
-
return n ? (e.preventDefault(),
|
|
356
|
+
let n = ze[e.shiftKey ? e.key.toUpperCase() : e.key.toLowerCase()];
|
|
357
|
+
return n ? (e.preventDefault(), Re(t, n), !0) : !1;
|
|
337
358
|
}
|
|
338
359
|
//#endregion
|
|
339
360
|
//#region src/toolbar/block.ts
|
|
@@ -341,7 +362,7 @@ function M(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
|
|
365
|
+
function Ve(e, t) {
|
|
345
366
|
let n = e.state, [r, i] = M(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;
|
|
@@ -379,7 +400,7 @@ function ze(e, t) {
|
|
|
379
400
|
scrollIntoView: !0
|
|
380
401
|
}), e.focus(), !0) : !1;
|
|
381
402
|
}
|
|
382
|
-
function
|
|
403
|
+
function He(e, t) {
|
|
383
404
|
return t.test(e.doc.lineAt(e.selection.main.head).text);
|
|
384
405
|
}
|
|
385
406
|
//#endregion
|
|
@@ -394,7 +415,7 @@ function N(e, t) {
|
|
|
394
415
|
}
|
|
395
416
|
return null;
|
|
396
417
|
}
|
|
397
|
-
function
|
|
418
|
+
function Ue(e) {
|
|
398
419
|
let t = e.state, n = N(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 = [{
|
|
@@ -427,7 +448,7 @@ function Ve(e) {
|
|
|
427
448
|
function P(e) {
|
|
428
449
|
return N(e, e.selection.main.head) !== null;
|
|
429
450
|
}
|
|
430
|
-
function
|
|
451
|
+
function We(e) {
|
|
431
452
|
let t = N(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);
|
|
@@ -439,18 +460,18 @@ function He(e) {
|
|
|
439
460
|
lang: r[2]
|
|
440
461
|
};
|
|
441
462
|
}
|
|
442
|
-
var
|
|
443
|
-
function
|
|
463
|
+
var Ge = /^\s*\$\$\s*$/;
|
|
464
|
+
function Ke(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 (Ge.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] = M(t), i =
|
|
473
|
+
function qe(e) {
|
|
474
|
+
let t = e.state, [n, r] = M(t), i = Ke(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({
|
|
@@ -477,11 +498,11 @@ function Ge(e) {
|
|
|
477
498
|
return e.focus(), !0;
|
|
478
499
|
}
|
|
479
500
|
function F(e) {
|
|
480
|
-
return
|
|
501
|
+
return Ke(e, e.doc.lineAt(e.selection.main.head).number) !== null;
|
|
481
502
|
}
|
|
482
503
|
//#endregion
|
|
483
504
|
//#region src/toolbar/heading.ts
|
|
484
|
-
function
|
|
505
|
+
function Je(e, t) {
|
|
485
506
|
let n = "#".repeat(t) + " ", r = e.state, [i, a] = M(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);
|
|
@@ -502,7 +523,7 @@ function Ke(e, t) {
|
|
|
502
523
|
scrollIntoView: !0
|
|
503
524
|
}), e.focus(), !0;
|
|
504
525
|
}
|
|
505
|
-
function
|
|
526
|
+
function Ye(e) {
|
|
506
527
|
let t = e.state, [n, r] = M(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);
|
|
@@ -522,7 +543,7 @@ function I(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 = Ee(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)
|
|
@@ -540,7 +561,7 @@ function L(e, t) {
|
|
|
540
561
|
}
|
|
541
562
|
return !1;
|
|
542
563
|
}
|
|
543
|
-
function
|
|
564
|
+
function Xe(e) {
|
|
544
565
|
let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = T(n.text, t - n.from);
|
|
545
566
|
return r ? {
|
|
546
567
|
from: n.from + r.from,
|
|
@@ -548,8 +569,8 @@ function Je(e) {
|
|
|
548
569
|
text: r.label
|
|
549
570
|
} : null;
|
|
550
571
|
}
|
|
551
|
-
function
|
|
552
|
-
let t =
|
|
572
|
+
function Ze(e) {
|
|
573
|
+
let t = Xe(e.state);
|
|
553
574
|
if (t) return e.dispatch({
|
|
554
575
|
changes: {
|
|
555
576
|
from: t.from,
|
|
@@ -570,10 +591,10 @@ function Ye(e) {
|
|
|
570
591
|
scrollIntoView: !0
|
|
571
592
|
}), e.focus(), !0;
|
|
572
593
|
}
|
|
573
|
-
function
|
|
574
|
-
return
|
|
594
|
+
function Qe(e) {
|
|
595
|
+
return Xe(e) !== null;
|
|
575
596
|
}
|
|
576
|
-
function
|
|
597
|
+
function $e(e) {
|
|
577
598
|
let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = E(n.text, t - n.from);
|
|
578
599
|
return r ? {
|
|
579
600
|
from: n.from + r.from,
|
|
@@ -581,8 +602,8 @@ function Ze(e) {
|
|
|
581
602
|
text: r.label
|
|
582
603
|
} : null;
|
|
583
604
|
}
|
|
584
|
-
function
|
|
585
|
-
let t =
|
|
605
|
+
function et(e) {
|
|
606
|
+
let t = $e(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
|
|
607
|
-
return
|
|
627
|
+
function tt(e) {
|
|
628
|
+
return $e(e) !== null;
|
|
608
629
|
}
|
|
609
|
-
function
|
|
610
|
-
let { head: t } = e.selection.main, n = e.doc.lineAt(t), r =
|
|
630
|
+
function nt(e) {
|
|
631
|
+
let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = xe(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 rt(e) {
|
|
639
|
+
let t = nt(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 it(e) {
|
|
661
|
+
return nt(e) !== null;
|
|
641
662
|
}
|
|
642
663
|
//#endregion
|
|
643
664
|
//#region src/toolbar/table-grid.ts
|
|
644
|
-
function
|
|
665
|
+
function at(e) {
|
|
645
666
|
let t = e.trim();
|
|
646
667
|
return t.includes("-") && t.includes("|") && /^[\s|:-]+$/.test(t);
|
|
647
668
|
}
|
|
648
|
-
function
|
|
669
|
+
function ot(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 st(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
680
|
function R(e) {
|
|
660
|
-
if (e.length < 2 || !
|
|
661
|
-
let t =
|
|
681
|
+
if (e.length < 2 || !at(e[1])) return null;
|
|
682
|
+
let t = ot(e[1]).map(st), n = e.filter((e, t) => t !== 1).map(ot), 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 ct(e) {
|
|
673
694
|
return e.replace(/\\\|/g, "|").length;
|
|
674
695
|
}
|
|
675
|
-
function
|
|
676
|
-
let r = t -
|
|
696
|
+
function lt(e, t, n) {
|
|
697
|
+
let r = t - ct(e);
|
|
677
698
|
if (r <= 0) return e;
|
|
678
699
|
if (n === "right") return " ".repeat(r) + e;
|
|
679
700
|
if (n === "center") {
|
|
@@ -682,7 +703,7 @@ function st(e, t, n) {
|
|
|
682
703
|
}
|
|
683
704
|
return e + " ".repeat(r);
|
|
684
705
|
}
|
|
685
|
-
function
|
|
706
|
+
function ut(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
|
}
|
|
@@ -690,15 +711,15 @@ function z(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, ct(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) => lt(t ?? "", n[r], e.aligns[r])).join(" | ") + " |", i = [r(e.rows[0] ?? [])];
|
|
718
|
+
i.push("| " + e.aligns.map((e, t) => ut(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 dt(e) {
|
|
702
723
|
let t = [];
|
|
703
724
|
for (let n = 0; n < e.length; n++) {
|
|
704
725
|
if (e[n] === "\\") {
|
|
@@ -745,7 +766,7 @@ function B(e, t) {
|
|
|
745
766
|
lines: a
|
|
746
767
|
} : null;
|
|
747
768
|
}
|
|
748
|
-
function
|
|
769
|
+
function ft(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 = dt(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 {
|
|
@@ -778,10 +799,10 @@ function ut(e, t, n) {
|
|
|
778
799
|
function V(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 = dt(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
|
|
805
|
+
function pt(e, t, n, r) {
|
|
785
806
|
let i = B(e, t);
|
|
786
807
|
return i ? V(i.lines.join("\n"), i.from, {
|
|
787
808
|
row: n,
|
|
@@ -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 mt(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 ht(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,7 +843,7 @@ function pt(e) {
|
|
|
822
843
|
},
|
|
823
844
|
selection: d.range(a, a + 8),
|
|
824
845
|
scrollIntoView: !0
|
|
825
|
-
}), e.focus(),
|
|
846
|
+
}), e.focus(), mt(e, a), !0;
|
|
826
847
|
}
|
|
827
848
|
function H(e) {
|
|
828
849
|
return B(e.doc, e.selection.main.head) !== null;
|
|
@@ -830,7 +851,7 @@ function H(e) {
|
|
|
830
851
|
function U(e, t) {
|
|
831
852
|
let n = B(e.state.doc, e.state.selection.main.head);
|
|
832
853
|
if (!n) return !1;
|
|
833
|
-
let r = R(n.lines), i =
|
|
854
|
+
let r = R(n.lines), i = ft(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;
|
|
@@ -845,7 +866,7 @@ function U(e, t) {
|
|
|
845
866
|
scrollIntoView: !0
|
|
846
867
|
}), e.focus(), !0;
|
|
847
868
|
}
|
|
848
|
-
function
|
|
869
|
+
function gt(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 _t(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,20 +884,20 @@ function ht(e, t) {
|
|
|
863
884
|
onDelimiter: !1
|
|
864
885
|
};
|
|
865
886
|
}
|
|
866
|
-
var
|
|
887
|
+
var vt = a.of([
|
|
867
888
|
{
|
|
868
889
|
key: "Tab",
|
|
869
|
-
run: (e) => U(e, (e, t) =>
|
|
890
|
+
run: (e) => U(e, (e, t) => gt(e, t, 1))
|
|
870
891
|
},
|
|
871
892
|
{
|
|
872
893
|
key: "Shift-Tab",
|
|
873
|
-
run: (e) => U(e, (e, t) =>
|
|
894
|
+
run: (e) => U(e, (e, t) => gt(e, t, -1))
|
|
874
895
|
},
|
|
875
896
|
{
|
|
876
897
|
key: "Enter",
|
|
877
|
-
run: (e) => U(e,
|
|
898
|
+
run: (e) => U(e, _t)
|
|
878
899
|
}
|
|
879
|
-
]),
|
|
900
|
+
]), yt = f.transactionFilter.of((e) => {
|
|
880
901
|
if (!e.docChanged || !e.isUserEvent("input") && !e.isUserEvent("delete")) return e;
|
|
881
902
|
let t = e.newSelection.main.head, n = B(e.newDoc, t);
|
|
882
903
|
if (!n) return e;
|
|
@@ -884,7 +905,7 @@ var gt = a.of([
|
|
|
884
905
|
if (!r) return e;
|
|
885
906
|
let i = z(r);
|
|
886
907
|
if (i === n.lines.join("\n")) return e;
|
|
887
|
-
let a =
|
|
908
|
+
let a = ft(n.lines, n.from, t), o = l.of([{
|
|
888
909
|
from: n.from,
|
|
889
910
|
to: n.to,
|
|
890
911
|
insert: i
|
|
@@ -898,23 +919,23 @@ var gt = a.of([
|
|
|
898
919
|
}), W = (e) => /^\s{0,3}#{1,6}(?:\s|$)/.test(e.doc.lineAt(e.selection.main.head).text), G = (e) => {
|
|
899
920
|
let n = t(e.doc);
|
|
900
921
|
return n !== null && e.selection.main.head <= n.to;
|
|
901
|
-
}, K = (e) => G(e) || P(e) || F(e),
|
|
922
|
+
}, K = (e) => G(e) || P(e) || F(e), bt = (e) => (t) => e !== "`" && L(t, "`") || e !== "$" && L(t, "$"), xt = (e) => e.selection.main.empty && !e.wordAt(e.selection.main.head), q = (...e) => (t) => e.some((e) => e(t)), J = /^(\s*)(?:[-*+] \[[ xX]\] +|\d+\. +|[-*+] +)/, St = {
|
|
902
923
|
match: /^ {0,3}> ?/,
|
|
903
924
|
insert: "> "
|
|
904
|
-
},
|
|
925
|
+
}, Ct = {
|
|
905
926
|
match: /^(\s*)[-*+] +(?!\[[ xX]\])/,
|
|
906
927
|
insert: "- ",
|
|
907
928
|
siblings: J
|
|
908
|
-
},
|
|
929
|
+
}, wt = {
|
|
909
930
|
match: /^(\s*)\d+\. +/,
|
|
910
931
|
insert: (e) => `${e + 1}. `,
|
|
911
932
|
siblings: J
|
|
912
|
-
},
|
|
933
|
+
}, Tt = {
|
|
913
934
|
match: /^(\s*)[-*+] \[[ xX]\] +/,
|
|
914
935
|
insert: "- [ ] ",
|
|
915
936
|
siblings: J
|
|
916
937
|
};
|
|
917
|
-
function
|
|
938
|
+
function Et(e, t, n) {
|
|
918
939
|
return {
|
|
919
940
|
id: e,
|
|
920
941
|
title: t,
|
|
@@ -930,7 +951,7 @@ function Y(e, t, n, r) {
|
|
|
930
951
|
title: t,
|
|
931
952
|
run: (e) => j(e, (e, t, r) => O(e, t, r, n)) || I(e, n),
|
|
932
953
|
isActive: (e) => L(e, n),
|
|
933
|
-
disabled: q(K,
|
|
954
|
+
disabled: q(K, bt(n), xt),
|
|
934
955
|
keys: r
|
|
935
956
|
};
|
|
936
957
|
}
|
|
@@ -939,7 +960,7 @@ function X(e) {
|
|
|
939
960
|
return {
|
|
940
961
|
id: `h${e}`,
|
|
941
962
|
title: `Heading ${e}`,
|
|
942
|
-
run: (t) =>
|
|
963
|
+
run: (t) => Je(t, e),
|
|
943
964
|
isActive: (e) => t.test(e.doc.lineAt(e.selection.main.head).text),
|
|
944
965
|
disabled: q(H, K),
|
|
945
966
|
keys: [`Mod-Alt-${e}`]
|
|
@@ -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) =>
|
|
973
|
+
run: (e) => Ve(e, n),
|
|
974
|
+
isActive: (e) => He(e, n.match),
|
|
954
975
|
disabled: q(H, K, ...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 Q = p.define({ combine: (e) => e[0] ?? null });
|
|
1047
|
+
function Mt(e) {
|
|
1048
|
+
let t = e.state.facet(Q);
|
|
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 Nt = "stylo-search-panel";
|
|
1054
|
+
function Pt(e) {
|
|
1034
1055
|
e.setAttribute("form", "");
|
|
1035
1056
|
}
|
|
1036
|
-
function
|
|
1057
|
+
function Ft(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, Pt(r), r;
|
|
1039
1060
|
}
|
|
1040
|
-
function
|
|
1061
|
+
function $(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 It(e, t) {
|
|
1045
1066
|
let n = document.createElement("input");
|
|
1046
|
-
n.type = "checkbox", n.name = e,
|
|
1067
|
+
n.type = "checkbox", n.name = e, Pt(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 Lt(e) {
|
|
1075
|
+
let t = (t) => e.state.phrase(t), n = Ft("search", t("Find"), "stylo-search-field");
|
|
1055
1076
|
n.setAttribute("main-field", "true");
|
|
1056
|
-
let r =
|
|
1077
|
+
let r = $("next", t("next")), i = $("prev", t("previous")), a = $("select", t("all")), o = Ft("replace", t("Replace"), "stylo-search-field stylo-search-replace"), s = $("replace", t("replace")), c = $("replaceAll", t("replace all")), l = It("case", t("match case")), u = It("re", t("regexp")), d = It("word", t("by word")), f = $("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 = Nt, 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,18 +1094,18 @@ function It(e) {
|
|
|
1073
1094
|
}
|
|
1074
1095
|
//#endregion
|
|
1075
1096
|
//#region src/editor/search-panel.ts
|
|
1076
|
-
var
|
|
1077
|
-
function
|
|
1078
|
-
return ce(e.state) ?
|
|
1097
|
+
var Rt = "cm-search-closing", zt = 160;
|
|
1098
|
+
function Bt(e) {
|
|
1099
|
+
return ce(e.state) ? Vt(e) : re(e);
|
|
1079
1100
|
}
|
|
1080
|
-
function
|
|
1081
|
-
let t = e.dom.querySelector(`.${
|
|
1082
|
-
return !t || t.classList.contains(
|
|
1101
|
+
function Vt(e) {
|
|
1102
|
+
let t = e.dom.querySelector(`.${Nt}`);
|
|
1103
|
+
return !t || t.classList.contains(Rt) ? !0 : (t.classList.add(Rt), setTimeout(() => {
|
|
1083
1104
|
e.dom.isConnected && ne(e);
|
|
1084
|
-
},
|
|
1105
|
+
}, zt), !0);
|
|
1085
1106
|
}
|
|
1086
|
-
function
|
|
1087
|
-
let t =
|
|
1107
|
+
function Ht(e) {
|
|
1108
|
+
let t = Lt(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;
|
|
@@ -1108,7 +1129,7 @@ function Bt(e) {
|
|
|
1108
1129
|
]) e.addEventListener("input", i), e.addEventListener("change", i);
|
|
1109
1130
|
return t.root.addEventListener("keydown", (n) => {
|
|
1110
1131
|
if (n.key === "Escape") {
|
|
1111
|
-
n.preventDefault(),
|
|
1132
|
+
n.preventDefault(), Vt(e);
|
|
1112
1133
|
return;
|
|
1113
1134
|
}
|
|
1114
1135
|
if (s(e, n, "search-panel")) {
|
|
@@ -1116,7 +1137,7 @@ function Bt(e) {
|
|
|
1116
1137
|
return;
|
|
1117
1138
|
}
|
|
1118
1139
|
n.key === "Enter" && (n.preventDefault(), n.target === t.find ? (n.shiftKey ? S : x)(e) : n.target === t.replace && ae(e));
|
|
1119
|
-
}), t.next.addEventListener("click", () => x(e)), t.prev.addEventListener("click", () => S(e)), t.all.addEventListener("click", () => le(e)), t.replaceBtn.addEventListener("click", () => ae(e)), t.replaceAllBtn.addEventListener("click", () => ie(e)), t.close.addEventListener("click", () =>
|
|
1140
|
+
}), t.next.addEventListener("click", () => x(e)), t.prev.addEventListener("click", () => S(e)), t.all.addEventListener("click", () => le(e)), t.replaceBtn.addEventListener("click", () => ae(e)), t.replaceAllBtn.addEventListener("click", () => ie(e)), t.close.addEventListener("click", () => Vt(e)), {
|
|
1120
1141
|
dom: t.root,
|
|
1121
1142
|
top: !0,
|
|
1122
1143
|
update(e) {
|
|
@@ -1126,22 +1147,23 @@ function Bt(e) {
|
|
|
1126
1147
|
}
|
|
1127
1148
|
//#endregion
|
|
1128
1149
|
//#region src/toolbar/commands.ts
|
|
1129
|
-
var
|
|
1130
|
-
|
|
1131
|
-
|
|
1150
|
+
var Ut = [
|
|
1151
|
+
Et("undo", "Undo", _),
|
|
1152
|
+
Et("redo", "Redo", g),
|
|
1132
1153
|
{
|
|
1133
1154
|
id: "save",
|
|
1134
1155
|
title: "Save",
|
|
1135
1156
|
run: (e) => {
|
|
1136
|
-
let t =
|
|
1157
|
+
let t = Mt(e);
|
|
1137
1158
|
return e.focus(), t;
|
|
1138
1159
|
},
|
|
1139
|
-
disabled: (e) => e.facet(
|
|
1160
|
+
disabled: (e) => e.facet(Q) == null
|
|
1140
1161
|
},
|
|
1141
1162
|
{
|
|
1142
1163
|
id: "search",
|
|
1143
1164
|
title: "Find / replace",
|
|
1144
|
-
run: (e) =>
|
|
1165
|
+
run: (e) => Bt(e),
|
|
1166
|
+
isActive: (e) => ce(e),
|
|
1145
1167
|
keys: ["Mod-f"]
|
|
1146
1168
|
},
|
|
1147
1169
|
X(1),
|
|
@@ -1150,7 +1172,7 @@ var Vt = [
|
|
|
1150
1172
|
{
|
|
1151
1173
|
id: "body",
|
|
1152
1174
|
title: "Body",
|
|
1153
|
-
run: (e) => (
|
|
1175
|
+
run: (e) => (Ye(e) || e.focus(), !0),
|
|
1154
1176
|
isActive: (e) => !/^#{1,6} /.test(e.doc.lineAt(e.selection.main.head).text),
|
|
1155
1177
|
disabled: q(H, K)
|
|
1156
1178
|
},
|
|
@@ -1160,57 +1182,57 @@ var Vt = [
|
|
|
1160
1182
|
{
|
|
1161
1183
|
id: "underline",
|
|
1162
1184
|
title: "Underline",
|
|
1163
|
-
run: (e) => j(e,
|
|
1164
|
-
isActive:
|
|
1165
|
-
disabled: q(K,
|
|
1185
|
+
run: (e) => j(e, Se) || rt(e),
|
|
1186
|
+
isActive: it,
|
|
1187
|
+
disabled: q(K, bt("u"), xt),
|
|
1166
1188
|
keys: ["Mod-u"]
|
|
1167
1189
|
},
|
|
1168
1190
|
Y("code", "Inline code", "`"),
|
|
1169
1191
|
{
|
|
1170
1192
|
id: "codeBlock",
|
|
1171
1193
|
title: "Code block",
|
|
1172
|
-
run: (e) => j(e, (e, t, n) => O(e, t, n, "`")) || (H(e.state) ? I(e, "`") :
|
|
1194
|
+
run: (e) => j(e, (e, t, n) => O(e, t, n, "`")) || (H(e.state) ? I(e, "`") : Ue(e)),
|
|
1173
1195
|
isActive: (e) => H(e) ? L(e, "`") : P(e),
|
|
1174
1196
|
disabled: q(G, F, W)
|
|
1175
1197
|
},
|
|
1176
1198
|
{
|
|
1177
1199
|
id: "link",
|
|
1178
1200
|
title: "Link",
|
|
1179
|
-
run: (e) => j(e,
|
|
1180
|
-
isActive:
|
|
1201
|
+
run: (e) => j(e, ve) || Ze(e),
|
|
1202
|
+
isActive: Qe,
|
|
1181
1203
|
disabled: K,
|
|
1182
1204
|
keys: ["Mod-k"]
|
|
1183
1205
|
},
|
|
1184
1206
|
{
|
|
1185
1207
|
id: "wikilink",
|
|
1186
1208
|
title: "Wikilink",
|
|
1187
|
-
run: (e) => j(e,
|
|
1188
|
-
isActive:
|
|
1209
|
+
run: (e) => j(e, be) || et(e),
|
|
1210
|
+
isActive: tt,
|
|
1189
1211
|
disabled: K,
|
|
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", St),
|
|
1215
|
+
Z("bulletList", "Bulleted list", Ct, W),
|
|
1216
|
+
Z("orderedList", "Numbered list", wt, W),
|
|
1217
|
+
Z("task", "Task list", Tt, W),
|
|
1196
1218
|
{
|
|
1197
1219
|
id: "hr",
|
|
1198
1220
|
title: "Divider",
|
|
1199
|
-
run:
|
|
1200
|
-
isActive:
|
|
1221
|
+
run: At,
|
|
1222
|
+
isActive: jt,
|
|
1201
1223
|
disabled: q(H, K)
|
|
1202
1224
|
},
|
|
1203
1225
|
{
|
|
1204
1226
|
id: "frontmatter",
|
|
1205
1227
|
title: "Frontmatter",
|
|
1206
|
-
run:
|
|
1207
|
-
isActive:
|
|
1228
|
+
run: Dt,
|
|
1229
|
+
isActive: Ot,
|
|
1208
1230
|
disabled: q(H, P, F, W)
|
|
1209
1231
|
},
|
|
1210
1232
|
{
|
|
1211
1233
|
id: "table",
|
|
1212
1234
|
title: "Table",
|
|
1213
|
-
run:
|
|
1235
|
+
run: ht,
|
|
1214
1236
|
isActive: H,
|
|
1215
1237
|
disabled: q(H, G, P, F, W)
|
|
1216
1238
|
},
|
|
@@ -1218,15 +1240,15 @@ var Vt = [
|
|
|
1218
1240
|
{
|
|
1219
1241
|
id: "mathBlock",
|
|
1220
1242
|
title: "Block math",
|
|
1221
|
-
run: (e) => j(e, (e, t, n) => O(e, t, n, "$")) || (H(e.state) ? I(e, "$") :
|
|
1243
|
+
run: (e) => j(e, (e, t, n) => O(e, t, n, "$")) || (H(e.state) ? I(e, "$") : qe(e)),
|
|
1222
1244
|
isActive: (e) => H(e) ? L(e, "$") : F(e),
|
|
1223
1245
|
disabled: q(G, P, W)
|
|
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 = de.define([
|
|
1230
1252
|
{
|
|
1231
1253
|
tag: [
|
|
1232
1254
|
w.keyword,
|
|
@@ -1310,7 +1332,7 @@ var Vt = [
|
|
|
1310
1332
|
tag: [w.invalid],
|
|
1311
1333
|
color: "var(--stylo-syntax-invalid)"
|
|
1312
1334
|
}
|
|
1313
|
-
]),
|
|
1335
|
+
]), qt = fe(Kt), Jt = i.theme({
|
|
1314
1336
|
"&": {
|
|
1315
1337
|
color: "var(--stylo-text)",
|
|
1316
1338
|
backgroundColor: "var(--stylo-bg)",
|
|
@@ -1412,8 +1434,8 @@ var Vt = [
|
|
|
1412
1434
|
backgroundColor: "color-mix(in srgb, var(--stylo-ring) 70%, transparent)",
|
|
1413
1435
|
outline: "1px solid var(--stylo-ring)"
|
|
1414
1436
|
}
|
|
1415
|
-
}),
|
|
1416
|
-
function
|
|
1437
|
+
}), Yt = /\[\[([^[\]\n|]*)$/;
|
|
1438
|
+
function Xt(e) {
|
|
1417
1439
|
let t = e.label && e.label !== e.target ? e.label : void 0, n = t ? `${e.target}|${t}` : e.target;
|
|
1418
1440
|
return {
|
|
1419
1441
|
label: e.label ?? e.target,
|
|
@@ -1431,13 +1453,13 @@ function Jt(e) {
|
|
|
1431
1453
|
}
|
|
1432
1454
|
};
|
|
1433
1455
|
}
|
|
1434
|
-
function
|
|
1456
|
+
function Zt(e, t) {
|
|
1435
1457
|
return async (n) => {
|
|
1436
|
-
let r = n.matchBefore(
|
|
1458
|
+
let r = n.matchBefore(Yt);
|
|
1437
1459
|
if (!r || r.from + 2 === n.pos && !n.explicit) return null;
|
|
1438
1460
|
let i = r.text.slice(2), a;
|
|
1439
1461
|
try {
|
|
1440
|
-
a = (await e(i)).map(
|
|
1462
|
+
a = (await e(i)).map(Xt);
|
|
1441
1463
|
} catch (e) {
|
|
1442
1464
|
return t?.(e, {
|
|
1443
1465
|
source: "wikiLinkSource",
|
|
@@ -1452,86 +1474,86 @@ function Yt(e, t) {
|
|
|
1452
1474
|
} : null;
|
|
1453
1475
|
};
|
|
1454
1476
|
}
|
|
1455
|
-
function
|
|
1456
|
-
return e ? [me(), y.data.of({ autocomplete:
|
|
1477
|
+
function Qt(e, t) {
|
|
1478
|
+
return e ? [me(), y.data.of({ autocomplete: Zt(e, t) })] : [];
|
|
1457
1479
|
}
|
|
1458
1480
|
//#endregion
|
|
1459
1481
|
//#region src/editor/extensions.ts
|
|
1460
|
-
function
|
|
1482
|
+
function $t(e, t, n) {
|
|
1461
1483
|
return [
|
|
1462
|
-
|
|
1463
|
-
a.of([...ee, ...
|
|
1464
|
-
m.high(
|
|
1465
|
-
|
|
1466
|
-
|
|
1484
|
+
te(),
|
|
1485
|
+
a.of([...ee, ...h]),
|
|
1486
|
+
m.high(vt),
|
|
1487
|
+
Gt,
|
|
1488
|
+
yt,
|
|
1467
1489
|
oe({
|
|
1468
1490
|
top: !0,
|
|
1469
|
-
createPanel:
|
|
1491
|
+
createPanel: Ht
|
|
1470
1492
|
}),
|
|
1471
1493
|
a.of(se),
|
|
1472
1494
|
v({
|
|
1473
1495
|
base: y,
|
|
1474
1496
|
codeLanguages: e
|
|
1475
1497
|
}),
|
|
1476
|
-
|
|
1477
|
-
|
|
1498
|
+
qt,
|
|
1499
|
+
Qt(t, n),
|
|
1478
1500
|
i.lineWrapping,
|
|
1479
|
-
|
|
1501
|
+
Jt
|
|
1480
1502
|
];
|
|
1481
1503
|
}
|
|
1482
|
-
function
|
|
1504
|
+
function en(e) {
|
|
1483
1505
|
return [
|
|
1484
1506
|
f.readOnly.of(e.readOnly),
|
|
1485
1507
|
i.editable.of(!e.readOnly),
|
|
1486
1508
|
e.placeholder ? o(e.placeholder) : [],
|
|
1487
|
-
e.save ?
|
|
1509
|
+
e.save ? Q.of(e.save) : []
|
|
1488
1510
|
];
|
|
1489
1511
|
}
|
|
1490
1512
|
//#endregion
|
|
1491
1513
|
//#region src/editor/useCodeMirror.ts
|
|
1492
|
-
var
|
|
1493
|
-
function
|
|
1494
|
-
let
|
|
1495
|
-
|
|
1514
|
+
var tn = c.define();
|
|
1515
|
+
function nn({ value: e, onChange: t, readOnly: o = !1, placeholder: s, onSave: c, onViewChange: l, extensions: d, codeLanguages: p, wikiLinkSource: ee, onResolveError: te }) {
|
|
1516
|
+
let h = r(null), g = r(null), _ = r(t);
|
|
1517
|
+
_.current = t;
|
|
1496
1518
|
let v = r(c);
|
|
1497
1519
|
v.current = c;
|
|
1498
|
-
let y = r((e) => v.current?.(e)).current, b = r(
|
|
1499
|
-
b.current =
|
|
1520
|
+
let y = r((e) => v.current?.(e)).current, b = r(te);
|
|
1521
|
+
b.current = te;
|
|
1500
1522
|
let ne = r((e, t) => {
|
|
1501
1523
|
b.current?.(e, t);
|
|
1502
1524
|
}).current, x = c != null, S = r(l);
|
|
1503
1525
|
S.current = l;
|
|
1504
1526
|
let C = r(new u());
|
|
1505
1527
|
return n(() => {
|
|
1506
|
-
let t =
|
|
1528
|
+
let t = h.current;
|
|
1507
1529
|
if (!t) return;
|
|
1508
1530
|
let n = new i({
|
|
1509
1531
|
parent: t,
|
|
1510
1532
|
state: f.create({
|
|
1511
1533
|
doc: e,
|
|
1512
1534
|
extensions: [
|
|
1513
|
-
|
|
1514
|
-
C.current.of(
|
|
1535
|
+
$t(p, ee, ne),
|
|
1536
|
+
C.current.of(en({
|
|
1515
1537
|
readOnly: o,
|
|
1516
1538
|
placeholder: s,
|
|
1517
1539
|
save: x ? y : void 0
|
|
1518
1540
|
})),
|
|
1519
1541
|
m.high(a.of([{
|
|
1520
1542
|
key: "Mod-s",
|
|
1521
|
-
run:
|
|
1543
|
+
run: Mt
|
|
1522
1544
|
}])),
|
|
1523
1545
|
...d ?? [],
|
|
1524
1546
|
i.updateListener.of((e) => {
|
|
1525
|
-
e.docChanged && (e.transactions.some((e) => !!e.annotation(
|
|
1547
|
+
e.docChanged && (e.transactions.some((e) => !!e.annotation(tn)) || _.current(e.state.doc.toString()));
|
|
1526
1548
|
})
|
|
1527
1549
|
]
|
|
1528
1550
|
})
|
|
1529
1551
|
});
|
|
1530
|
-
return
|
|
1531
|
-
S.current?.(null), n.destroy(),
|
|
1552
|
+
return g.current = n, S.current?.(n), () => {
|
|
1553
|
+
S.current?.(null), n.destroy(), g.current = null;
|
|
1532
1554
|
};
|
|
1533
1555
|
}, []), n(() => {
|
|
1534
|
-
let t =
|
|
1556
|
+
let t = g.current;
|
|
1535
1557
|
if (!t) return;
|
|
1536
1558
|
let n = t.state.doc.toString();
|
|
1537
1559
|
n !== e && t.dispatch({
|
|
@@ -1540,10 +1562,10 @@ function en({ value: e, onChange: t, readOnly: o = !1, placeholder: s, onSave: c
|
|
|
1540
1562
|
to: n.length,
|
|
1541
1563
|
insert: e
|
|
1542
1564
|
},
|
|
1543
|
-
annotations:
|
|
1565
|
+
annotations: tn.of(!0)
|
|
1544
1566
|
});
|
|
1545
1567
|
}, [e]), n(() => {
|
|
1546
|
-
|
|
1568
|
+
g.current?.dispatch({ effects: C.current.reconfigure(en({
|
|
1547
1569
|
readOnly: o,
|
|
1548
1570
|
placeholder: s,
|
|
1549
1571
|
save: x ? y : void 0
|
|
@@ -1553,9 +1575,9 @@ function en({ value: e, onChange: t, readOnly: o = !1, placeholder: s, onSave: c
|
|
|
1553
1575
|
s,
|
|
1554
1576
|
x,
|
|
1555
1577
|
y
|
|
1556
|
-
]),
|
|
1578
|
+
]), h;
|
|
1557
1579
|
}
|
|
1558
1580
|
//#endregion
|
|
1559
|
-
export {
|
|
1581
|
+
export { ge as S, Ae as _, R as a, ye as b, P as c, ke as d, Pe as f, Ne as g, Ie as h, pt as i, Le as l, Me as m, Wt as n, z as o, A as p, At as r, We as s, nn as t, Be as u, je as v, _e as x, E as y };
|
|
1560
1582
|
|
|
1561
|
-
//# sourceMappingURL=useCodeMirror-
|
|
1583
|
+
//# sourceMappingURL=useCodeMirror-CjG9CwpB.js.map
|