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