@damiro/stylo 0.4.0 → 0.7.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 +94 -10
- package/dist/{InPlaceView-Ba7JCZ2Y.js → InPlaceView-CS1qy-Ba.js} +277 -265
- package/dist/InPlaceView-CS1qy-Ba.js.map +1 -0
- package/dist/{Preview-Dxb9zPVv.js → Preview-Bw0k3Mev.js} +2 -2
- package/dist/{Preview-Dxb9zPVv.js.map → Preview-Bw0k3Mev.js.map} +1 -1
- package/dist/SplitView.d.ts +3 -2
- package/dist/SplitView.d.ts.map +1 -1
- package/dist/Stylo.d.ts.map +1 -1
- package/dist/editor/SourceView.d.ts +4 -2
- package/dist/editor/SourceView.d.ts.map +1 -1
- package/dist/editor/extensions.d.ts +2 -2
- package/dist/editor/extensions.d.ts.map +1 -1
- package/dist/editor/theme.d.ts.map +1 -1
- package/dist/editor/useCodeMirror.d.ts +4 -2
- package/dist/editor/useCodeMirror.d.ts.map +1 -1
- package/dist/editor/wikilink-complete.d.ts +15 -0
- package/dist/editor/wikilink-complete.d.ts.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/inplace/InPlaceView.d.ts +4 -2
- package/dist/inplace/InPlaceView.d.ts.map +1 -1
- package/dist/inplace/context-menu.d.ts +1 -1
- package/dist/inplace/context-menu.d.ts.map +1 -1
- package/dist/inplace/extension.d.ts.map +1 -1
- package/dist/inplace/menu-open.d.ts +11 -0
- package/dist/inplace/menu-open.d.ts.map +1 -0
- package/dist/inplace/menu-plugin.d.ts +1 -0
- package/dist/inplace/menu-plugin.d.ts.map +1 -1
- package/dist/inplace/selection-bar.d.ts.map +1 -1
- package/dist/inplace/theme.d.ts.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/stylo.js +58 -53
- package/dist/stylo.js.map +1 -1
- package/dist/types.d.ts +25 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/{useCodeMirror-YnIFkvKn.js → useCodeMirror-GPSkaYW6.js} +204 -168
- package/dist/useCodeMirror-GPSkaYW6.js.map +1 -0
- package/dist/wikilink-CTR8IFKc.js +42 -0
- package/dist/wikilink-CTR8IFKc.js.map +1 -0
- package/package.json +4 -1
- package/dist/InPlaceView-Ba7JCZ2Y.js.map +0 -1
- package/dist/useCodeMirror-YnIFkvKn.js.map +0 -1
- package/dist/wikilink-BFpTehto.js +0 -42
- package/dist/wikilink-BFpTehto.js.map +0 -1
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { n as e, t } from "./wikilink-
|
|
1
|
+
import { n as e, t } from "./wikilink-CTR8IFKc.js";
|
|
2
2
|
import { useEffect as n, useRef as r } from "react";
|
|
3
3
|
import { EditorView as i, keymap as a, placeholder as o } from "@codemirror/view";
|
|
4
4
|
import { Annotation as s, ChangeSet as c, Compartment as l, EditorSelection as u, EditorState as d, Facet as f, Prec as p } from "@codemirror/state";
|
|
5
|
-
import { defaultKeymap as ee, history as
|
|
6
|
-
import { markdown as
|
|
7
|
-
import { openSearchPanel as
|
|
5
|
+
import { defaultKeymap as ee, history as te, historyKeymap as m, redo as h, undo as g } from "@codemirror/commands";
|
|
6
|
+
import { markdown as _, markdownLanguage as v } from "@codemirror/lang-markdown";
|
|
7
|
+
import { openSearchPanel as y, search as b, searchKeymap as x } from "@codemirror/search";
|
|
8
8
|
import { HighlightStyle as ne, syntaxHighlighting as re, syntaxTree as ie } from "@codemirror/language";
|
|
9
9
|
import { tags as S } from "@lezer/highlight";
|
|
10
|
+
import { autocompletion as ae } from "@codemirror/autocomplete";
|
|
10
11
|
//#region src/editor/save.ts
|
|
11
12
|
var C = f.define({ combine: (e) => e[0] ?? null });
|
|
12
|
-
function
|
|
13
|
+
function oe(e) {
|
|
13
14
|
let t = e.state.facet(C);
|
|
14
15
|
return t ? (t(e.state.doc.toString()), !0) : !1;
|
|
15
16
|
}
|
|
@@ -19,7 +20,7 @@ function w(e) {
|
|
|
19
20
|
let { from: t, to: n } = e.selection.main;
|
|
20
21
|
return [e.doc.lineAt(t).number, e.doc.lineAt(n).number];
|
|
21
22
|
}
|
|
22
|
-
function
|
|
23
|
+
function se(e, t) {
|
|
23
24
|
let n = "#".repeat(t) + " ", r = e.state, [i, a] = w(r), o = [];
|
|
24
25
|
for (let e = i; e <= a; e++) {
|
|
25
26
|
let i = r.doc.line(e), a = /^(#{1,6}) +/.exec(i.text);
|
|
@@ -40,7 +41,7 @@ function oe(e, t) {
|
|
|
40
41
|
scrollIntoView: !0
|
|
41
42
|
}), e.focus(), !0;
|
|
42
43
|
}
|
|
43
|
-
function
|
|
44
|
+
function ce(e) {
|
|
44
45
|
let t = e.state, [n, r] = w(t), i = [];
|
|
45
46
|
for (let e = n; e <= r; e++) {
|
|
46
47
|
let n = t.doc.line(e), r = /^#{1,6} +/.exec(n.text);
|
|
@@ -54,7 +55,7 @@ function se(e) {
|
|
|
54
55
|
scrollIntoView: !0
|
|
55
56
|
}), e.focus(), !0) : !1;
|
|
56
57
|
}
|
|
57
|
-
function
|
|
58
|
+
function le(e, t) {
|
|
58
59
|
let n = e.state, [r, i] = w(n), a = r === i && !n.doc.line(r).text.trim(), o = !a;
|
|
59
60
|
for (let e = r; e <= i && o; e++) {
|
|
60
61
|
let r = n.doc.line(e).text;
|
|
@@ -92,13 +93,13 @@ function ce(e, t) {
|
|
|
92
93
|
scrollIntoView: !0
|
|
93
94
|
}), e.focus(), !0) : !1;
|
|
94
95
|
}
|
|
95
|
-
function
|
|
96
|
+
function ue(e, t) {
|
|
96
97
|
return t.test(e.doc.lineAt(e.selection.main.head).text);
|
|
97
98
|
}
|
|
98
|
-
var
|
|
99
|
-
function
|
|
99
|
+
var de = /^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/;
|
|
100
|
+
function fe(e) {
|
|
100
101
|
let t = e.state, n = t.doc.lineAt(t.selection.main.head);
|
|
101
|
-
return
|
|
102
|
+
return de.test(n.text) ? e.dispatch({
|
|
102
103
|
changes: {
|
|
103
104
|
from: n.from,
|
|
104
105
|
to: Math.min(n.to + 1, t.doc.length)
|
|
@@ -121,10 +122,10 @@ function de(e) {
|
|
|
121
122
|
scrollIntoView: !0
|
|
122
123
|
}), e.focus(), !0;
|
|
123
124
|
}
|
|
124
|
-
function
|
|
125
|
-
return
|
|
125
|
+
function pe(e) {
|
|
126
|
+
return de.test(e.doc.lineAt(e.selection.main.head).text);
|
|
126
127
|
}
|
|
127
|
-
function
|
|
128
|
+
function me(t) {
|
|
128
129
|
let n = t.state, r = e(n.doc);
|
|
129
130
|
if (r) {
|
|
130
131
|
let e = n.doc.lineAt(r.from), i = n.doc.lineAt(r.to);
|
|
@@ -154,7 +155,7 @@ function pe(t) {
|
|
|
154
155
|
}
|
|
155
156
|
return t.focus(), !0;
|
|
156
157
|
}
|
|
157
|
-
function
|
|
158
|
+
function he(t) {
|
|
158
159
|
return e(t.doc) !== null;
|
|
159
160
|
}
|
|
160
161
|
//#endregion
|
|
@@ -162,7 +163,7 @@ function me(t) {
|
|
|
162
163
|
function T(e) {
|
|
163
164
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
164
165
|
}
|
|
165
|
-
function
|
|
166
|
+
function ge(e, t, n) {
|
|
166
167
|
let r = t, i = t;
|
|
167
168
|
if (n < 0) for (; r > 0 && "*~`$".includes(e[r - 1]);) r--;
|
|
168
169
|
else for (; i < e.length && "*~`$".includes(e[i]);) i++;
|
|
@@ -171,7 +172,7 @@ function he(e, t, n) {
|
|
|
171
172
|
from: r
|
|
172
173
|
};
|
|
173
174
|
}
|
|
174
|
-
function
|
|
175
|
+
function _e(e, t) {
|
|
175
176
|
let n = [];
|
|
176
177
|
for (let r = 0; r < e.length;) {
|
|
177
178
|
if (e[r] !== t) {
|
|
@@ -187,15 +188,15 @@ function ge(e, t) {
|
|
|
187
188
|
}
|
|
188
189
|
return n;
|
|
189
190
|
}
|
|
190
|
-
function
|
|
191
|
+
function ve(e, t, n) {
|
|
191
192
|
return e < n || t < n ? !1 : n > 1 || e % 2 == 1 && t % 2 == 1;
|
|
192
193
|
}
|
|
193
|
-
function
|
|
194
|
+
function ye(e, t, n, r) {
|
|
194
195
|
let i = r.length, a = r[0], o = e.slice(t, n), s = 0;
|
|
195
196
|
for (; o[s] === a;) s++;
|
|
196
197
|
let c = 0;
|
|
197
198
|
for (; o[o.length - 1 - c] === a;) c++;
|
|
198
|
-
if (o.length >= 2 * i && o.startsWith(r) && o.endsWith(r) &&
|
|
199
|
+
if (o.length >= 2 * i && o.startsWith(r) && o.endsWith(r) && ve(s, c, i)) return {
|
|
199
200
|
changes: [{
|
|
200
201
|
from: t,
|
|
201
202
|
to: t + i,
|
|
@@ -208,10 +209,10 @@ function ve(e, t, n, r) {
|
|
|
208
209
|
from: t,
|
|
209
210
|
to: n - 2 * i
|
|
210
211
|
};
|
|
211
|
-
let l =
|
|
212
|
+
let l = ge(e, t, -1), u = ge(e, n, 1), d = _e(l.text, a), f = _e(u.text, a).reverse();
|
|
212
213
|
for (let e = 0; e < Math.min(d.length, f.length); e++) {
|
|
213
214
|
let r = d[e], a = f[e];
|
|
214
|
-
if (!
|
|
215
|
+
if (!ve(r.len, a.len, i)) continue;
|
|
215
216
|
let o = l.from + r.start + r.len, s = n + a.start;
|
|
216
217
|
return {
|
|
217
218
|
changes: [{
|
|
@@ -241,26 +242,26 @@ function ve(e, t, n, r) {
|
|
|
241
242
|
to: n + i
|
|
242
243
|
};
|
|
243
244
|
}
|
|
244
|
-
function
|
|
245
|
+
function be(e, t) {
|
|
245
246
|
let n = e;
|
|
246
247
|
for (let e of [...t].sort((e, t) => t.from - e.from)) n = n.slice(0, e.from) + e.insert + n.slice(e.to);
|
|
247
248
|
return n;
|
|
248
249
|
}
|
|
249
250
|
function E(e, t, n, r) {
|
|
250
|
-
let i =
|
|
251
|
+
let i = ye(e, t, n, r);
|
|
251
252
|
return {
|
|
252
|
-
text:
|
|
253
|
+
text: be(e, i.changes),
|
|
253
254
|
from: i.from,
|
|
254
255
|
to: i.to
|
|
255
256
|
};
|
|
256
257
|
}
|
|
257
|
-
function
|
|
258
|
+
function xe(e, t) {
|
|
258
259
|
let n = D(e, t);
|
|
259
260
|
if (n) return {
|
|
260
261
|
from: n.from,
|
|
261
262
|
to: n.to
|
|
262
263
|
};
|
|
263
|
-
let r =
|
|
264
|
+
let r = A(e, t);
|
|
264
265
|
if (r) return {
|
|
265
266
|
from: r.from,
|
|
266
267
|
to: r.to
|
|
@@ -296,7 +297,7 @@ function D(e, t) {
|
|
|
296
297
|
}
|
|
297
298
|
return null;
|
|
298
299
|
}
|
|
299
|
-
function
|
|
300
|
+
function Se(e, t) {
|
|
300
301
|
let n = /\[([^\]]*)\]\(([^)]*)\)/g;
|
|
301
302
|
for (let r; r = n.exec(e);) {
|
|
302
303
|
let e = r.index, n = e + r[0].length;
|
|
@@ -314,7 +315,7 @@ function xe(e, t) {
|
|
|
314
315
|
}
|
|
315
316
|
return null;
|
|
316
317
|
}
|
|
317
|
-
function
|
|
318
|
+
function Ce(e, t, n) {
|
|
318
319
|
let r = D(e, t);
|
|
319
320
|
if (r) return {
|
|
320
321
|
text: e.slice(0, r.from) + r.label + e.slice(r.to),
|
|
@@ -328,7 +329,7 @@ function Se(e, t, n) {
|
|
|
328
329
|
to: a + 3
|
|
329
330
|
};
|
|
330
331
|
}
|
|
331
|
-
function
|
|
332
|
+
function we(e, t) {
|
|
332
333
|
let n = /<u>([\s\S]*?)<\/u>/gi;
|
|
333
334
|
for (let r; r = n.exec(e);) {
|
|
334
335
|
let e = r.index, n = e + r[0].length;
|
|
@@ -340,8 +341,8 @@ function Ce(e, t) {
|
|
|
340
341
|
}
|
|
341
342
|
return null;
|
|
342
343
|
}
|
|
343
|
-
function
|
|
344
|
-
let r =
|
|
344
|
+
function O(e, t, n) {
|
|
345
|
+
let r = we(e, t);
|
|
345
346
|
if (r) return {
|
|
346
347
|
text: e.slice(0, r.from) + r.inner + e.slice(r.to),
|
|
347
348
|
from: r.from,
|
|
@@ -354,7 +355,7 @@ function we(e, t, n) {
|
|
|
354
355
|
to: t + 3 + i.length
|
|
355
356
|
};
|
|
356
357
|
}
|
|
357
|
-
function
|
|
358
|
+
function k(e, n) {
|
|
358
359
|
for (let r of e.matchAll(t)) {
|
|
359
360
|
let e = r.index ?? 0, t = e + r[0].length;
|
|
360
361
|
if (n >= e && n <= t) return {
|
|
@@ -365,7 +366,7 @@ function O(e, n) {
|
|
|
365
366
|
}
|
|
366
367
|
return null;
|
|
367
368
|
}
|
|
368
|
-
function
|
|
369
|
+
function A(e, n) {
|
|
369
370
|
for (let r of e.matchAll(t)) {
|
|
370
371
|
let e = r.index ?? 0, t = e + r[0].length;
|
|
371
372
|
if (n < e || n > t) continue;
|
|
@@ -382,7 +383,7 @@ function k(e, n) {
|
|
|
382
383
|
return null;
|
|
383
384
|
}
|
|
384
385
|
function Te(e, t, n) {
|
|
385
|
-
let r =
|
|
386
|
+
let r = k(e, t);
|
|
386
387
|
if (r) return {
|
|
387
388
|
text: e.slice(0, r.from) + r.label + e.slice(r.to),
|
|
388
389
|
from: r.from,
|
|
@@ -398,7 +399,7 @@ function Te(e, t, n) {
|
|
|
398
399
|
//#endregion
|
|
399
400
|
//#region src/inplace/table-cell-dom.ts
|
|
400
401
|
var Ee = (e) => [e.head, ...e.body].map((e) => [...e]), De = (e) => e.map((e) => e.map((e) => e.trim())), Oe = (e) => e.replace(/\\\|/g, "|");
|
|
401
|
-
function
|
|
402
|
+
function j(e, t) {
|
|
402
403
|
let n = e.ownerDocument.createTreeWalker(e, NodeFilter.SHOW_TEXT), r = 0;
|
|
403
404
|
for (let e = n.nextNode(); e; e = n.nextNode()) {
|
|
404
405
|
if (e === t) return r;
|
|
@@ -408,10 +409,10 @@ function A(e, t) {
|
|
|
408
409
|
}
|
|
409
410
|
function ke(e) {
|
|
410
411
|
let t = e.ownerDocument.getSelection(), n = t?.anchorNode;
|
|
411
|
-
return !n || !e.contains(n) ? 0 : n.nodeType === Node.TEXT_NODE ?
|
|
412
|
+
return !n || !e.contains(n) ? 0 : n.nodeType === Node.TEXT_NODE ? j(e, n) + (t?.anchorOffset ?? 0) : (t?.anchorOffset ?? 0) > 0 ? (e.textContent ?? "").length : 0;
|
|
412
413
|
}
|
|
413
414
|
function Ae(e) {
|
|
414
|
-
let t = e.ownerDocument.getSelection(), n = (e.textContent ?? "").length, r = (t, r) => !t || !e.contains(t) ? n : t.nodeType === Node.TEXT_NODE ?
|
|
415
|
+
let t = e.ownerDocument.getSelection(), n = (e.textContent ?? "").length, r = (t, r) => !t || !e.contains(t) ? n : t.nodeType === Node.TEXT_NODE ? j(e, t) + r : r > 0 ? n : 0;
|
|
415
416
|
if (!t || t.rangeCount === 0) return {
|
|
416
417
|
from: n,
|
|
417
418
|
to: n
|
|
@@ -431,18 +432,18 @@ function je(e, t, n) {
|
|
|
431
432
|
let e = r.caretRangeFromPoint(t, n);
|
|
432
433
|
e && ([i, a] = [e.startContainer, e.startOffset]);
|
|
433
434
|
}
|
|
434
|
-
return !i || !e.contains(i) ? 0 :
|
|
435
|
+
return !i || !e.contains(i) ? 0 : j(e, i) + (i.nodeType === Node.TEXT_NODE ? a : 0);
|
|
435
436
|
}
|
|
436
437
|
var Me = /[\p{L}\p{N}_]/u;
|
|
437
438
|
function Ne(e, t, n) {
|
|
438
|
-
let r = e.textContent ?? "", i = je(e, t, n), a =
|
|
439
|
-
if (a) return
|
|
439
|
+
let r = e.textContent ?? "", i = je(e, t, n), a = xe(r, i);
|
|
440
|
+
if (a) return M(e, a.from, a.to), !0;
|
|
440
441
|
let o = i, s = i;
|
|
441
442
|
for (; o > 0 && Me.test(r[o - 1]);) o--;
|
|
442
443
|
for (; s < r.length && Me.test(r[s]);) s++;
|
|
443
|
-
return s <= o ? !1 : (
|
|
444
|
+
return s <= o ? !1 : (M(e, o, s), !0);
|
|
444
445
|
}
|
|
445
|
-
function
|
|
446
|
+
function M(e, t, n = t) {
|
|
446
447
|
e.focus();
|
|
447
448
|
let r = e.ownerDocument, i = r.createRange(), a = e.firstChild;
|
|
448
449
|
if (a && a.nodeType === Node.TEXT_NODE) {
|
|
@@ -459,29 +460,29 @@ function Pe(e) {
|
|
|
459
460
|
let t = e.dom.ownerDocument.activeElement;
|
|
460
461
|
return !(t instanceof HTMLElement) || !e.dom.contains(t) ? null : t.matches(".cm-inplace-tcell") ? t : null;
|
|
461
462
|
}
|
|
462
|
-
function
|
|
463
|
+
function N(e, t) {
|
|
463
464
|
let { from: n, to: r } = Ae(e), i = t(e.textContent ?? "", n, r);
|
|
464
|
-
e.textContent = i.text,
|
|
465
|
+
e.textContent = i.text, M(e, i.from, i.to), e.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
465
466
|
}
|
|
466
|
-
function
|
|
467
|
+
function P(e, t) {
|
|
467
468
|
let n = Pe(e);
|
|
468
|
-
return n ? (
|
|
469
|
+
return n ? (N(n, t), !0) : !1;
|
|
469
470
|
}
|
|
470
|
-
var
|
|
471
|
+
var Fe = {
|
|
471
472
|
b: (e, t, n) => E(e, t, n, "**"),
|
|
472
473
|
i: (e, t, n) => E(e, t, n, "*"),
|
|
473
|
-
u:
|
|
474
|
-
k:
|
|
474
|
+
u: O,
|
|
475
|
+
k: Ce,
|
|
475
476
|
K: Te
|
|
476
477
|
};
|
|
477
|
-
function
|
|
478
|
+
function Ie(e, t) {
|
|
478
479
|
if (!(e.metaKey || e.ctrlKey) || e.altKey) return !1;
|
|
479
|
-
let n =
|
|
480
|
-
return n ? (e.preventDefault(),
|
|
480
|
+
let n = Fe[e.shiftKey ? e.key.toUpperCase() : e.key.toLowerCase()];
|
|
481
|
+
return n ? (e.preventDefault(), N(t, n), !0) : !1;
|
|
481
482
|
}
|
|
482
483
|
//#endregion
|
|
483
484
|
//#region src/toolbar/fence.ts
|
|
484
|
-
function
|
|
485
|
+
function F(e, t) {
|
|
485
486
|
for (let n = ie(e).resolveInner(t, 0); n; n = n.parent) {
|
|
486
487
|
if (n.name === "FencedCode") return {
|
|
487
488
|
from: n.from,
|
|
@@ -491,8 +492,8 @@ function N(e, t) {
|
|
|
491
492
|
}
|
|
492
493
|
return null;
|
|
493
494
|
}
|
|
494
|
-
function
|
|
495
|
-
let t = e.state, n =
|
|
495
|
+
function Le(e) {
|
|
496
|
+
let t = e.state, n = F(t, t.selection.main.head);
|
|
496
497
|
if (n) {
|
|
497
498
|
let r = t.doc.lineAt(n.from), i = t.doc.lineAt(n.to), a = [{
|
|
498
499
|
from: r.from,
|
|
@@ -521,11 +522,11 @@ function Re(e) {
|
|
|
521
522
|
}
|
|
522
523
|
return e.focus(), !0;
|
|
523
524
|
}
|
|
524
|
-
function
|
|
525
|
-
return
|
|
525
|
+
function I(e) {
|
|
526
|
+
return F(e, e.selection.main.head) !== null;
|
|
526
527
|
}
|
|
527
|
-
function
|
|
528
|
-
let t =
|
|
528
|
+
function Re(e) {
|
|
529
|
+
let t = F(e, e.selection.main.head);
|
|
529
530
|
if (!t) return null;
|
|
530
531
|
let n = e.doc.lineAt(t.from), r = /^(\s*(?:`{3,}|~{3,})[ \t]*)(.*?)[ \t]*$/.exec(n.text);
|
|
531
532
|
if (!r) return null;
|
|
@@ -536,10 +537,10 @@ function ze(e) {
|
|
|
536
537
|
lang: r[2]
|
|
537
538
|
};
|
|
538
539
|
}
|
|
539
|
-
var
|
|
540
|
-
function
|
|
540
|
+
var ze = /^\s*\$\$\s*$/;
|
|
541
|
+
function Be(e, t) {
|
|
541
542
|
let n = 0, r = 0;
|
|
542
|
-
for (let i = 1; i <= e.doc.lines; i++) if (
|
|
543
|
+
for (let i = 1; i <= e.doc.lines; i++) if (ze.test(e.doc.line(i).text)) {
|
|
543
544
|
if (r++, r % 2 == 1) {
|
|
544
545
|
if (n = i, i > t) return null;
|
|
545
546
|
} else if (i >= t) return [n, i];
|
|
@@ -547,7 +548,7 @@ function F(e, t) {
|
|
|
547
548
|
return null;
|
|
548
549
|
}
|
|
549
550
|
function Ve(e) {
|
|
550
|
-
let t = e.state, [n, r] = w(t), i =
|
|
551
|
+
let t = e.state, [n, r] = w(t), i = Be(t, t.doc.lineAt(t.selection.main.head).number);
|
|
551
552
|
if (i) {
|
|
552
553
|
let n = t.doc.line(i[0]), r = t.doc.line(i[1]);
|
|
553
554
|
e.dispatch({
|
|
@@ -573,16 +574,16 @@ function Ve(e) {
|
|
|
573
574
|
});
|
|
574
575
|
return e.focus(), !0;
|
|
575
576
|
}
|
|
576
|
-
function
|
|
577
|
-
return
|
|
577
|
+
function L(e) {
|
|
578
|
+
return Be(e, e.doc.lineAt(e.selection.main.head).number) !== null;
|
|
578
579
|
}
|
|
579
580
|
//#endregion
|
|
580
581
|
//#region src/toolbar/inline.ts
|
|
581
|
-
function
|
|
582
|
+
function R(e, t) {
|
|
582
583
|
let n = e.state.doc.toString();
|
|
583
584
|
return e.dispatch({
|
|
584
585
|
...e.state.changeByRange((e) => {
|
|
585
|
-
let r =
|
|
586
|
+
let r = ye(n, e.from, e.to, t);
|
|
586
587
|
return {
|
|
587
588
|
changes: r.changes,
|
|
588
589
|
range: r.from === r.to ? u.cursor(r.from) : u.range(r.from, r.to)
|
|
@@ -591,7 +592,7 @@ function L(e, t) {
|
|
|
591
592
|
scrollIntoView: !0
|
|
592
593
|
}), e.focus(), !0;
|
|
593
594
|
}
|
|
594
|
-
function
|
|
595
|
+
function z(e, t) {
|
|
595
596
|
let n = e.selection.main, r = e.doc.lineAt(n.head), i = RegExp(T(t) + "(?!\\s)(?:[^]*?\\S)??" + T(t), "g");
|
|
596
597
|
for (let e; e = i.exec(r.text);) {
|
|
597
598
|
if (e[0].length <= 2 * t.length || t === "$" && (r.text[e.index - 1] === "$" || r.text[e.index + e[0].length] === "$")) continue;
|
|
@@ -634,7 +635,7 @@ function We(e) {
|
|
|
634
635
|
return He(e) !== null;
|
|
635
636
|
}
|
|
636
637
|
function Ge(e) {
|
|
637
|
-
let { head: t } = e.selection.main, n = e.doc.lineAt(t), r =
|
|
638
|
+
let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = k(n.text, t - n.from);
|
|
638
639
|
return r ? {
|
|
639
640
|
from: n.from + r.from,
|
|
640
641
|
to: n.from + r.to,
|
|
@@ -667,7 +668,7 @@ function qe(e) {
|
|
|
667
668
|
return Ge(e) !== null;
|
|
668
669
|
}
|
|
669
670
|
function Je(e) {
|
|
670
|
-
let { head: t } = e.selection.main, n = e.doc.lineAt(t), r =
|
|
671
|
+
let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = we(n.text, t - n.from);
|
|
671
672
|
return r ? {
|
|
672
673
|
from: n.from + r.from,
|
|
673
674
|
to: n.from + r.to,
|
|
@@ -716,7 +717,7 @@ function $e(e) {
|
|
|
716
717
|
let t = e.trim(), n = t.startsWith(":"), r = t.endsWith(":");
|
|
717
718
|
return n && r ? "center" : r ? "right" : n ? "left" : "";
|
|
718
719
|
}
|
|
719
|
-
function
|
|
720
|
+
function B(e) {
|
|
720
721
|
if (e.length < 2 || !Ze(e[1])) return null;
|
|
721
722
|
let t = Qe(e[1]).map($e), n = e.filter((e, t) => t !== 1).map(Qe), r = Math.max(t.length, ...n.map((e) => e.length)), i = n.map((e) => {
|
|
722
723
|
let t = e.slice(0, r);
|
|
@@ -746,7 +747,7 @@ function nt(e, t) {
|
|
|
746
747
|
let n = Math.max(3, e);
|
|
747
748
|
return t === "left" ? ":" + "-".repeat(n - 1) : t === "right" ? "-".repeat(n - 1) + ":" : t === "center" ? ":" + "-".repeat(n - 2) + ":" : "-".repeat(n);
|
|
748
749
|
}
|
|
749
|
-
function
|
|
750
|
+
function V(e) {
|
|
750
751
|
let t = e.aligns.length, n = [];
|
|
751
752
|
for (let r = 0; r < t; r++) {
|
|
752
753
|
let t = 3;
|
|
@@ -781,7 +782,7 @@ function rt(e) {
|
|
|
781
782
|
}
|
|
782
783
|
//#endregion
|
|
783
784
|
//#region src/toolbar/table.ts
|
|
784
|
-
function
|
|
785
|
+
function H(e, t) {
|
|
785
786
|
let n = e.lineAt(t);
|
|
786
787
|
if (!n.text.includes("|")) return null;
|
|
787
788
|
let r = n.number;
|
|
@@ -799,7 +800,7 @@ function V(e, t) {
|
|
|
799
800
|
if (i - r < 1) return null;
|
|
800
801
|
let a = [];
|
|
801
802
|
for (let t = r; t <= i; t++) a.push(e.line(t).text);
|
|
802
|
-
return
|
|
803
|
+
return B(a) ? {
|
|
803
804
|
from: e.line(r).from,
|
|
804
805
|
to: e.line(i).to,
|
|
805
806
|
lines: a
|
|
@@ -835,15 +836,15 @@ function it(e, t, n) {
|
|
|
835
836
|
}
|
|
836
837
|
return null;
|
|
837
838
|
}
|
|
838
|
-
function
|
|
839
|
+
function U(e, t, n) {
|
|
839
840
|
let r = e.split("\n"), i = n.onDelimiter ? 1 : n.row === 0 ? 0 : n.row + 1, a = t;
|
|
840
841
|
for (let e = 0; e < i; e++) a += r[e].length + 1;
|
|
841
842
|
let o = rt(r[i]), s = o[Math.min(n.col, o.length - 1)];
|
|
842
843
|
return s ? a + s.contentStart + Math.min(n.offset, s.contentEnd - s.contentStart) : a;
|
|
843
844
|
}
|
|
844
845
|
function at(e, t, n, r) {
|
|
845
|
-
let i =
|
|
846
|
-
return i ?
|
|
846
|
+
let i = H(e, t);
|
|
847
|
+
return i ? U(i.lines.join("\n"), i.from, {
|
|
847
848
|
row: n,
|
|
848
849
|
col: r,
|
|
849
850
|
offset: 0,
|
|
@@ -882,24 +883,24 @@ function st(e) {
|
|
|
882
883
|
scrollIntoView: !0
|
|
883
884
|
}), e.focus(), ot(e, a), !0;
|
|
884
885
|
}
|
|
885
|
-
function
|
|
886
|
-
return
|
|
886
|
+
function W(e) {
|
|
887
|
+
return H(e.doc, e.selection.main.head) !== null;
|
|
887
888
|
}
|
|
888
|
-
function
|
|
889
|
-
let n =
|
|
889
|
+
function G(e, t) {
|
|
890
|
+
let n = H(e.state.doc, e.state.selection.main.head);
|
|
890
891
|
if (!n) return !1;
|
|
891
|
-
let r =
|
|
892
|
+
let r = B(n.lines), i = it(n.lines, n.from, e.state.selection.main.head);
|
|
892
893
|
if (!r || !i) return !1;
|
|
893
894
|
let a = t(r, i);
|
|
894
895
|
if (!a) return !1;
|
|
895
|
-
let o =
|
|
896
|
+
let o = V(r);
|
|
896
897
|
return e.dispatch({
|
|
897
898
|
changes: {
|
|
898
899
|
from: n.from,
|
|
899
900
|
to: n.to,
|
|
900
901
|
insert: o
|
|
901
902
|
},
|
|
902
|
-
selection: u.cursor(
|
|
903
|
+
selection: u.cursor(U(o, n.from, a)),
|
|
903
904
|
scrollIntoView: !0
|
|
904
905
|
}), e.focus(), !0;
|
|
905
906
|
}
|
|
@@ -924,23 +925,23 @@ function lt(e, t) {
|
|
|
924
925
|
var ut = a.of([
|
|
925
926
|
{
|
|
926
927
|
key: "Tab",
|
|
927
|
-
run: (e) =>
|
|
928
|
+
run: (e) => G(e, (e, t) => ct(e, t, 1))
|
|
928
929
|
},
|
|
929
930
|
{
|
|
930
931
|
key: "Shift-Tab",
|
|
931
|
-
run: (e) =>
|
|
932
|
+
run: (e) => G(e, (e, t) => ct(e, t, -1))
|
|
932
933
|
},
|
|
933
934
|
{
|
|
934
935
|
key: "Enter",
|
|
935
|
-
run: (e) =>
|
|
936
|
+
run: (e) => G(e, lt)
|
|
936
937
|
}
|
|
937
938
|
]), dt = d.transactionFilter.of((e) => {
|
|
938
939
|
if (!e.docChanged || !e.isUserEvent("input") && !e.isUserEvent("delete")) return e;
|
|
939
|
-
let t = e.newSelection.main.head, n =
|
|
940
|
+
let t = e.newSelection.main.head, n = H(e.newDoc, t);
|
|
940
941
|
if (!n) return e;
|
|
941
|
-
let r =
|
|
942
|
+
let r = B(n.lines);
|
|
942
943
|
if (!r) return e;
|
|
943
|
-
let i =
|
|
944
|
+
let i = V(r);
|
|
944
945
|
if (i === n.lines.join("\n")) return e;
|
|
945
946
|
let a = it(n.lines, n.from, t), o = c.of([{
|
|
946
947
|
from: n.from,
|
|
@@ -949,28 +950,28 @@ var ut = a.of([
|
|
|
949
950
|
}], e.newDoc.length);
|
|
950
951
|
return {
|
|
951
952
|
changes: e.changes.compose(o),
|
|
952
|
-
selection: a ? u.cursor(
|
|
953
|
+
selection: a ? u.cursor(U(i, n.from, a)) : e.newSelection,
|
|
953
954
|
effects: e.effects,
|
|
954
955
|
scrollIntoView: e.scrollIntoView
|
|
955
956
|
};
|
|
956
|
-
}),
|
|
957
|
+
}), K = (e) => /^\s{0,3}#{1,6}(?:\s|$)/.test(e.doc.lineAt(e.selection.main.head).text), q = (t) => {
|
|
957
958
|
let n = e(t.doc);
|
|
958
959
|
return n !== null && t.selection.main.head <= n.to;
|
|
959
|
-
},
|
|
960
|
+
}, J = (e) => q(e) || I(e) || L(e), ft = (e) => (t) => e !== "`" && z(t, "`") || e !== "$" && z(t, "$"), pt = (e) => e.selection.main.empty && !e.wordAt(e.selection.main.head), Y = (...e) => (t) => e.some((e) => e(t)), X = /^(\s*)(?:[-*+] \[[ xX]\] +|\d+\. +|[-*+] +)/, mt = {
|
|
960
961
|
match: /^ {0,3}> ?/,
|
|
961
962
|
insert: "> "
|
|
962
963
|
}, ht = {
|
|
963
964
|
match: /^(\s*)[-*+] +(?!\[[ xX]\])/,
|
|
964
965
|
insert: "- ",
|
|
965
|
-
siblings:
|
|
966
|
+
siblings: X
|
|
966
967
|
}, gt = {
|
|
967
968
|
match: /^(\s*)\d+\. +/,
|
|
968
969
|
insert: (e) => `${e + 1}. `,
|
|
969
|
-
siblings:
|
|
970
|
+
siblings: X
|
|
970
971
|
}, _t = {
|
|
971
972
|
match: /^(\s*)[-*+] \[[ xX]\] +/,
|
|
972
973
|
insert: "- [ ] ",
|
|
973
|
-
siblings:
|
|
974
|
+
siblings: X
|
|
974
975
|
};
|
|
975
976
|
function vt(e, t, n) {
|
|
976
977
|
return {
|
|
@@ -982,44 +983,44 @@ function vt(e, t, n) {
|
|
|
982
983
|
}
|
|
983
984
|
};
|
|
984
985
|
}
|
|
985
|
-
function
|
|
986
|
+
function Z(e, t, n, r) {
|
|
986
987
|
return {
|
|
987
988
|
id: e,
|
|
988
989
|
title: t,
|
|
989
|
-
run: (e) =>
|
|
990
|
-
isActive: (e) =>
|
|
991
|
-
disabled: J
|
|
990
|
+
run: (e) => P(e, (e, t, r) => E(e, t, r, n)) || R(e, n),
|
|
991
|
+
isActive: (e) => z(e, n),
|
|
992
|
+
disabled: Y(J, ft(n), pt),
|
|
992
993
|
keys: r
|
|
993
994
|
};
|
|
994
995
|
}
|
|
995
|
-
function
|
|
996
|
+
function Q(e) {
|
|
996
997
|
let t = RegExp(`^#{${e}} `);
|
|
997
998
|
return {
|
|
998
999
|
id: `h${e}`,
|
|
999
1000
|
title: `Heading ${e}`,
|
|
1000
|
-
run: (t) =>
|
|
1001
|
+
run: (t) => se(t, e),
|
|
1001
1002
|
isActive: (e) => t.test(e.doc.lineAt(e.selection.main.head).text),
|
|
1002
|
-
disabled:
|
|
1003
|
+
disabled: Y(W, J),
|
|
1003
1004
|
keys: [`Mod-Alt-${e}`]
|
|
1004
1005
|
};
|
|
1005
1006
|
}
|
|
1006
|
-
function
|
|
1007
|
+
function $(e, t, n, ...r) {
|
|
1007
1008
|
return {
|
|
1008
1009
|
id: e,
|
|
1009
1010
|
title: t,
|
|
1010
|
-
run: (e) =>
|
|
1011
|
-
isActive: (e) =>
|
|
1012
|
-
disabled:
|
|
1011
|
+
run: (e) => le(e, n),
|
|
1012
|
+
isActive: (e) => ue(e, n.match),
|
|
1013
|
+
disabled: Y(W, J, ...r)
|
|
1013
1014
|
};
|
|
1014
1015
|
}
|
|
1015
1016
|
var yt = [
|
|
1016
|
-
vt("undo", "Undo",
|
|
1017
|
-
vt("redo", "Redo",
|
|
1017
|
+
vt("undo", "Undo", g),
|
|
1018
|
+
vt("redo", "Redo", h),
|
|
1018
1019
|
{
|
|
1019
1020
|
id: "save",
|
|
1020
1021
|
title: "Save",
|
|
1021
1022
|
run: (e) => {
|
|
1022
|
-
let t =
|
|
1023
|
+
let t = oe(e);
|
|
1023
1024
|
return e.focus(), t;
|
|
1024
1025
|
},
|
|
1025
1026
|
disabled: (e) => e.facet(C) == null
|
|
@@ -1027,86 +1028,86 @@ var yt = [
|
|
|
1027
1028
|
{
|
|
1028
1029
|
id: "search",
|
|
1029
1030
|
title: "Find / replace",
|
|
1030
|
-
run: (e) =>
|
|
1031
|
+
run: (e) => y(e),
|
|
1031
1032
|
keys: ["Mod-f"]
|
|
1032
1033
|
},
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1034
|
+
Q(1),
|
|
1035
|
+
Q(2),
|
|
1036
|
+
Q(3),
|
|
1036
1037
|
{
|
|
1037
1038
|
id: "body",
|
|
1038
1039
|
title: "Body",
|
|
1039
|
-
run: (e) => (
|
|
1040
|
+
run: (e) => (ce(e) || e.focus(), !0),
|
|
1040
1041
|
isActive: (e) => !/^#{1,6} /.test(e.doc.lineAt(e.selection.main.head).text),
|
|
1041
|
-
disabled:
|
|
1042
|
+
disabled: Y(W, J)
|
|
1042
1043
|
},
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1044
|
+
Z("bold", "Bold", "**", ["Mod-b"]),
|
|
1045
|
+
Z("italic", "Italic", "*", ["Mod-i"]),
|
|
1046
|
+
Z("strike", "Strikethrough", "~~"),
|
|
1046
1047
|
{
|
|
1047
1048
|
id: "underline",
|
|
1048
1049
|
title: "Underline",
|
|
1049
|
-
run: (e) =>
|
|
1050
|
+
run: (e) => P(e, O) || Ye(e),
|
|
1050
1051
|
isActive: Xe,
|
|
1051
|
-
disabled: J
|
|
1052
|
+
disabled: Y(J, ft("u"), pt),
|
|
1052
1053
|
keys: ["Mod-u"]
|
|
1053
1054
|
},
|
|
1054
|
-
|
|
1055
|
+
Z("code", "Inline code", "`"),
|
|
1055
1056
|
{
|
|
1056
1057
|
id: "codeBlock",
|
|
1057
1058
|
title: "Code block",
|
|
1058
|
-
run: (e) =>
|
|
1059
|
-
isActive: (e) =>
|
|
1060
|
-
disabled:
|
|
1059
|
+
run: (e) => P(e, (e, t, n) => E(e, t, n, "`")) || (W(e.state) ? R(e, "`") : Le(e)),
|
|
1060
|
+
isActive: (e) => W(e) ? z(e, "`") : I(e),
|
|
1061
|
+
disabled: Y(q, L, K)
|
|
1061
1062
|
},
|
|
1062
1063
|
{
|
|
1063
1064
|
id: "link",
|
|
1064
1065
|
title: "Link",
|
|
1065
|
-
run: (e) =>
|
|
1066
|
+
run: (e) => P(e, Ce) || Ue(e),
|
|
1066
1067
|
isActive: We,
|
|
1067
|
-
disabled:
|
|
1068
|
+
disabled: J,
|
|
1068
1069
|
keys: ["Mod-k"]
|
|
1069
1070
|
},
|
|
1070
1071
|
{
|
|
1071
1072
|
id: "wikilink",
|
|
1072
1073
|
title: "Wikilink",
|
|
1073
|
-
run: (e) =>
|
|
1074
|
+
run: (e) => P(e, Te) || Ke(e),
|
|
1074
1075
|
isActive: qe,
|
|
1075
|
-
disabled:
|
|
1076
|
+
disabled: J,
|
|
1076
1077
|
keys: ["Mod-Shift-k"]
|
|
1077
1078
|
},
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1079
|
+
$("quote", "Blockquote", mt),
|
|
1080
|
+
$("bulletList", "Bulleted list", ht, K),
|
|
1081
|
+
$("orderedList", "Numbered list", gt, K),
|
|
1082
|
+
$("task", "Task list", _t, K),
|
|
1082
1083
|
{
|
|
1083
1084
|
id: "hr",
|
|
1084
1085
|
title: "Divider",
|
|
1085
|
-
run:
|
|
1086
|
-
isActive:
|
|
1087
|
-
disabled:
|
|
1086
|
+
run: fe,
|
|
1087
|
+
isActive: pe,
|
|
1088
|
+
disabled: Y(W, J)
|
|
1088
1089
|
},
|
|
1089
1090
|
{
|
|
1090
1091
|
id: "frontmatter",
|
|
1091
1092
|
title: "Frontmatter",
|
|
1092
|
-
run:
|
|
1093
|
-
isActive:
|
|
1094
|
-
disabled:
|
|
1093
|
+
run: me,
|
|
1094
|
+
isActive: he,
|
|
1095
|
+
disabled: Y(W, I, L, K)
|
|
1095
1096
|
},
|
|
1096
1097
|
{
|
|
1097
1098
|
id: "table",
|
|
1098
1099
|
title: "Table",
|
|
1099
1100
|
run: st,
|
|
1100
|
-
isActive:
|
|
1101
|
-
disabled:
|
|
1101
|
+
isActive: W,
|
|
1102
|
+
disabled: Y(W, q, I, L, K)
|
|
1102
1103
|
},
|
|
1103
|
-
|
|
1104
|
+
Z("math", "Inline math", "$"),
|
|
1104
1105
|
{
|
|
1105
1106
|
id: "mathBlock",
|
|
1106
1107
|
title: "Block math",
|
|
1107
|
-
run: (e) =>
|
|
1108
|
-
isActive: (e) =>
|
|
1109
|
-
disabled:
|
|
1108
|
+
run: (e) => P(e, (e, t, n) => E(e, t, n, "$")) || (W(e.state) ? R(e, "$") : Ve(e)),
|
|
1109
|
+
isActive: (e) => W(e) ? z(e, "$") : L(e),
|
|
1110
|
+
disabled: Y(q, I, K)
|
|
1110
1111
|
}
|
|
1111
1112
|
], bt = Object.fromEntries(yt.map((e) => [e.id, e])), xt = p.high(a.of(yt.filter((e) => e.keys && e.keys.length > 0).flatMap((e) => e.keys.map((t) => ({
|
|
1112
1113
|
key: t,
|
|
@@ -1200,10 +1201,10 @@ var yt = [
|
|
|
1200
1201
|
"&": {
|
|
1201
1202
|
color: "var(--stylo-text)",
|
|
1202
1203
|
backgroundColor: "var(--stylo-bg)",
|
|
1203
|
-
fontSize: "0.9375rem"
|
|
1204
|
+
fontSize: "var(--stylo-font-size, 0.9375rem)"
|
|
1204
1205
|
},
|
|
1205
1206
|
".cm-content": {
|
|
1206
|
-
fontFamily: "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",
|
|
1207
|
+
fontFamily: "var(--stylo-font-family-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace)",
|
|
1207
1208
|
padding: "0.75rem 0",
|
|
1208
1209
|
caretColor: "var(--stylo-text)"
|
|
1209
1210
|
},
|
|
@@ -1262,28 +1263,63 @@ var yt = [
|
|
|
1262
1263
|
backgroundColor: "color-mix(in srgb, var(--stylo-ring) 70%, transparent)",
|
|
1263
1264
|
outline: "1px solid var(--stylo-ring)"
|
|
1264
1265
|
}
|
|
1265
|
-
})
|
|
1266
|
+
}), Tt = /\[\[([^[\]\n|]*)$/;
|
|
1267
|
+
function Et(e) {
|
|
1268
|
+
let t = e.label && e.label !== e.target ? e.label : void 0, n = t ? `${e.target}|${t}` : e.target;
|
|
1269
|
+
return {
|
|
1270
|
+
label: e.label ?? e.target,
|
|
1271
|
+
apply: (e, t, r, i) => {
|
|
1272
|
+
let a = e.state.sliceDoc(i, i + 2) === "]]";
|
|
1273
|
+
e.dispatch({
|
|
1274
|
+
changes: {
|
|
1275
|
+
from: r,
|
|
1276
|
+
to: i,
|
|
1277
|
+
insert: a ? n : `${n}]]`
|
|
1278
|
+
},
|
|
1279
|
+
selection: { anchor: r + n.length + 2 },
|
|
1280
|
+
userEvent: "input.complete"
|
|
1281
|
+
});
|
|
1282
|
+
}
|
|
1283
|
+
};
|
|
1284
|
+
}
|
|
1285
|
+
function Dt(e) {
|
|
1286
|
+
return async (t) => {
|
|
1287
|
+
let n = t.matchBefore(Tt);
|
|
1288
|
+
if (!n || n.from + 2 === t.pos && !t.explicit) return null;
|
|
1289
|
+
let r = (await e(n.text.slice(2))).map(Et);
|
|
1290
|
+
return r.length ? {
|
|
1291
|
+
from: n.from + 2,
|
|
1292
|
+
to: t.pos,
|
|
1293
|
+
options: r,
|
|
1294
|
+
filter: !1
|
|
1295
|
+
} : null;
|
|
1296
|
+
};
|
|
1297
|
+
}
|
|
1298
|
+
function Ot(e) {
|
|
1299
|
+
return e ? [ae(), v.data.of({ autocomplete: Dt(e) })] : [];
|
|
1300
|
+
}
|
|
1266
1301
|
//#endregion
|
|
1267
1302
|
//#region src/editor/extensions.ts
|
|
1268
|
-
function
|
|
1303
|
+
function kt(e, t) {
|
|
1269
1304
|
return [
|
|
1270
|
-
|
|
1271
|
-
a.of([...ee, ...
|
|
1305
|
+
te(),
|
|
1306
|
+
a.of([...ee, ...m]),
|
|
1272
1307
|
p.high(ut),
|
|
1273
1308
|
xt,
|
|
1274
1309
|
dt,
|
|
1275
|
-
|
|
1276
|
-
a.of(
|
|
1277
|
-
|
|
1278
|
-
base:
|
|
1310
|
+
b({ top: !0 }),
|
|
1311
|
+
a.of(x),
|
|
1312
|
+
_({
|
|
1313
|
+
base: v,
|
|
1279
1314
|
codeLanguages: e
|
|
1280
1315
|
}),
|
|
1281
1316
|
Ct,
|
|
1317
|
+
Ot(t),
|
|
1282
1318
|
i.lineWrapping,
|
|
1283
1319
|
wt
|
|
1284
1320
|
];
|
|
1285
1321
|
}
|
|
1286
|
-
function
|
|
1322
|
+
function At(e) {
|
|
1287
1323
|
return [
|
|
1288
1324
|
d.readOnly.of(e.readOnly),
|
|
1289
1325
|
i.editable.of(!e.readOnly),
|
|
@@ -1293,8 +1329,8 @@ function Et(e) {
|
|
|
1293
1329
|
}
|
|
1294
1330
|
//#endregion
|
|
1295
1331
|
//#region src/editor/useCodeMirror.ts
|
|
1296
|
-
var
|
|
1297
|
-
function
|
|
1332
|
+
var jt = s.define();
|
|
1333
|
+
function Mt({ value: e, onChange: t, readOnly: o = !1, placeholder: s, onSave: c, onViewChange: u, extensions: f, codeLanguages: ee, wikiLinkSource: te }) {
|
|
1298
1334
|
let m = r(null), h = r(null), g = r(t);
|
|
1299
1335
|
g.current = t;
|
|
1300
1336
|
let _ = r(c);
|
|
@@ -1310,19 +1346,19 @@ function Dt({ value: e, onChange: t, readOnly: o = !1, placeholder: s, onSave: c
|
|
|
1310
1346
|
state: d.create({
|
|
1311
1347
|
doc: e,
|
|
1312
1348
|
extensions: [
|
|
1313
|
-
|
|
1314
|
-
x.current.of(
|
|
1349
|
+
kt(ee, te),
|
|
1350
|
+
x.current.of(At({
|
|
1315
1351
|
readOnly: o,
|
|
1316
1352
|
placeholder: s,
|
|
1317
1353
|
save: y ? v : void 0
|
|
1318
1354
|
})),
|
|
1319
1355
|
p.high(a.of([{
|
|
1320
1356
|
key: "Mod-s",
|
|
1321
|
-
run:
|
|
1357
|
+
run: oe
|
|
1322
1358
|
}])),
|
|
1323
1359
|
...f ?? [],
|
|
1324
1360
|
i.updateListener.of((e) => {
|
|
1325
|
-
e.docChanged && (e.transactions.some((e) => !!e.annotation(
|
|
1361
|
+
e.docChanged && (e.transactions.some((e) => !!e.annotation(jt)) || g.current(e.state.doc.toString()));
|
|
1326
1362
|
})
|
|
1327
1363
|
]
|
|
1328
1364
|
})
|
|
@@ -1340,10 +1376,10 @@ function Dt({ value: e, onChange: t, readOnly: o = !1, placeholder: s, onSave: c
|
|
|
1340
1376
|
to: n.length,
|
|
1341
1377
|
insert: e
|
|
1342
1378
|
},
|
|
1343
|
-
annotations:
|
|
1379
|
+
annotations: jt.of(!0)
|
|
1344
1380
|
});
|
|
1345
1381
|
}, [e]), n(() => {
|
|
1346
|
-
h.current?.dispatch({ effects: x.current.reconfigure(
|
|
1382
|
+
h.current?.dispatch({ effects: x.current.reconfigure(At({
|
|
1347
1383
|
readOnly: o,
|
|
1348
1384
|
placeholder: s,
|
|
1349
1385
|
save: y ? v : void 0
|
|
@@ -1356,6 +1392,6 @@ function Dt({ value: e, onChange: t, readOnly: o = !1, placeholder: s, onSave: c
|
|
|
1356
1392
|
]), m;
|
|
1357
1393
|
}
|
|
1358
1394
|
//#endregion
|
|
1359
|
-
export { Oe as _,
|
|
1395
|
+
export { Oe as _, V as a, A as b, Pe as c, je as d, M as f, De as g, Ae as h, B as i, Ie as l, Ne as m, bt as n, Re as o, ke as p, at as r, I as s, Mt as t, Ee as u, Se as v, k as y };
|
|
1360
1396
|
|
|
1361
|
-
//# sourceMappingURL=useCodeMirror-
|
|
1397
|
+
//# sourceMappingURL=useCodeMirror-GPSkaYW6.js.map
|