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