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