@damiro/stylo 0.16.0 → 0.18.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 +6 -4
- package/dist/{InPlaceView-CC5hZCcI.js → InPlaceView-Z8c9cqW8.js} +461 -460
- package/dist/{InPlaceView-CC5hZCcI.js.map → InPlaceView-Z8c9cqW8.js.map} +1 -1
- package/dist/{Preview-5lm2uUVj.js → Preview-BRA_R_Gp.js} +3 -3
- package/dist/{Preview-5lm2uUVj.js.map → Preview-BRA_R_Gp.js.map} +1 -1
- package/dist/SplitView.d.ts +4 -1
- package/dist/SplitView.d.ts.map +1 -1
- package/dist/Stylo.d.ts.map +1 -1
- package/dist/editor/SourceView.d.ts +4 -1
- package/dist/editor/SourceView.d.ts.map +1 -1
- package/dist/editor/theme.d.ts.map +1 -1
- package/dist/editor/useCodeMirror.d.ts +7 -1
- package/dist/editor/useCodeMirror.d.ts.map +1 -1
- package/dist/{embed-DKKeCE1Y.js → embed-DJAydn-v.js} +2 -2
- package/dist/{embed-DKKeCE1Y.js.map → embed-DJAydn-v.js.map} +1 -1
- package/dist/{embed-cache-CcBfVrc9.js → embed-cache-BU9Smn-h.js} +24 -17
- package/dist/embed-cache-BU9Smn-h.js.map +1 -0
- package/dist/inplace/InPlaceView.d.ts +4 -1
- package/dist/inplace/InPlaceView.d.ts.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/stylo.js +384 -154
- package/dist/stylo.js.map +1 -1
- package/dist/toolbar/OverflowBar.d.ts +19 -0
- package/dist/toolbar/OverflowBar.d.ts.map +1 -0
- package/dist/toolbar/OverflowMenu.d.ts +24 -0
- package/dist/toolbar/OverflowMenu.d.ts.map +1 -0
- package/dist/toolbar/Toolbar.d.ts +5 -1
- package/dist/toolbar/Toolbar.d.ts.map +1 -1
- package/dist/toolbar/overflow-fit.d.ts +27 -0
- package/dist/toolbar/overflow-fit.d.ts.map +1 -0
- package/dist/toolbar/toolbar-model.d.ts +31 -0
- package/dist/toolbar/toolbar-model.d.ts.map +1 -0
- package/dist/toolbar/use-toolbar-overflow.d.ts +17 -0
- package/dist/toolbar/use-toolbar-overflow.d.ts.map +1 -0
- package/dist/types/core.d.ts +9 -0
- package/dist/types/core.d.ts.map +1 -1
- package/dist/types/toolbar.d.ts +16 -0
- package/dist/types/toolbar.d.ts.map +1 -1
- package/dist/{useCodeMirror-TAWSJQiZ.js → useCodeMirror-Fn6qEfMx.js} +262 -254
- package/dist/{useCodeMirror-TAWSJQiZ.js.map → useCodeMirror-Fn6qEfMx.js.map} +1 -1
- package/package.json +4 -4
- package/dist/embed-cache-CcBfVrc9.js.map +0 -1
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { l as e, o as t, s as n } from "./embed-cache-
|
|
1
|
+
import { l as e, o as t, s as n } from "./embed-cache-BU9Smn-h.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
|
|
5
|
+
import { defaultKeymap as te, history as ne, historyKeymap as h, redo as g, undo as _ } from "@codemirror/commands";
|
|
6
6
|
import { markdown as v, markdownLanguage as y } from "@codemirror/lang-markdown";
|
|
7
|
-
import { SearchQuery as
|
|
8
|
-
import { syntaxTree as
|
|
9
|
-
import { autocompletion as
|
|
7
|
+
import { SearchQuery as re, closeSearchPanel as b, findNext as x, findPrevious as S, getSearchQuery as C, openSearchPanel as w, replaceAll as T, replaceNext as E, search as D, searchKeymap as ie, searchPanelOpen as ae, selectMatches as oe, setSearchQuery as se } from "@codemirror/search";
|
|
8
|
+
import { syntaxTree as ce } from "@codemirror/language";
|
|
9
|
+
import { autocompletion as le } from "@codemirror/autocomplete";
|
|
10
10
|
//#region src/editor/canvas-header-panel.ts
|
|
11
|
-
var
|
|
11
|
+
var ue = "stylo-canvas-header", de = 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 = ue, this.dom = e, this.notify(), {
|
|
17
17
|
dom: e,
|
|
18
18
|
top: !0,
|
|
19
19
|
destroy: () => {
|
|
@@ -29,7 +29,7 @@ var fe = "stylo-canvas-header", pe = class {
|
|
|
29
29
|
};
|
|
30
30
|
//#endregion
|
|
31
31
|
//#region src/toolbar/link-ops.ts
|
|
32
|
-
function
|
|
32
|
+
function O(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 E(e, t) {
|
|
|
41
41
|
}
|
|
42
42
|
return null;
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function fe(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 me(e, t) {
|
|
|
59
59
|
}
|
|
60
60
|
return null;
|
|
61
61
|
}
|
|
62
|
-
function
|
|
63
|
-
let r =
|
|
62
|
+
function pe(e, t, n) {
|
|
63
|
+
let r = O(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 he(e, t, n) {
|
|
|
75
75
|
}
|
|
76
76
|
//#endregion
|
|
77
77
|
//#region src/toolbar/wikilink-ops.ts
|
|
78
|
-
function
|
|
78
|
+
function me(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 D(t, n) {
|
|
|
86
86
|
}
|
|
87
87
|
return null;
|
|
88
88
|
}
|
|
89
|
-
function
|
|
89
|
+
function he(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 ge(t, n) {
|
|
|
102
102
|
}
|
|
103
103
|
return null;
|
|
104
104
|
}
|
|
105
|
-
function
|
|
106
|
-
let r =
|
|
105
|
+
function ge(e, t, n) {
|
|
106
|
+
let r = me(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 _e(e, t, n) {
|
|
|
118
118
|
}
|
|
119
119
|
//#endregion
|
|
120
120
|
//#region src/toolbar/underline-ops.ts
|
|
121
|
-
function
|
|
121
|
+
function _e(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 ve(e, t) {
|
|
|
130
130
|
}
|
|
131
131
|
return null;
|
|
132
132
|
}
|
|
133
|
-
function
|
|
134
|
-
let r =
|
|
133
|
+
function ve(e, t, n) {
|
|
134
|
+
let r = _e(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 ye(e, t, n) {
|
|
|
146
146
|
}
|
|
147
147
|
//#endregion
|
|
148
148
|
//#region src/toolbar/inline-ops.ts
|
|
149
|
-
function
|
|
149
|
+
function k(e) {
|
|
150
150
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
151
151
|
}
|
|
152
|
-
function
|
|
152
|
+
function ye(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 be(e, t, n) {
|
|
|
158
158
|
from: r
|
|
159
159
|
};
|
|
160
160
|
}
|
|
161
|
-
function
|
|
161
|
+
function be(e, t) {
|
|
162
162
|
let n = [];
|
|
163
163
|
for (let r = 0; r < e.length;) {
|
|
164
164
|
if (e[r] !== t) {
|
|
@@ -174,29 +174,29 @@ function xe(e, t) {
|
|
|
174
174
|
}
|
|
175
175
|
return n;
|
|
176
176
|
}
|
|
177
|
-
function
|
|
177
|
+
function xe(e, t, n) {
|
|
178
178
|
return e < n || t < n ? !1 : n > 1 || e % 2 == 1 && t % 2 == 1;
|
|
179
179
|
}
|
|
180
|
-
var
|
|
181
|
-
function
|
|
180
|
+
var Se = /[\p{L}\p{N}_]/u;
|
|
181
|
+
function Ce(e, t) {
|
|
182
182
|
let n = t, r = t;
|
|
183
|
-
for (; n > 0 &&
|
|
184
|
-
for (; r < e.length &&
|
|
183
|
+
for (; n > 0 && Se.test(e[n - 1]);) n--;
|
|
184
|
+
for (; r < e.length && Se.test(e[r]);) r++;
|
|
185
185
|
return r > n ? {
|
|
186
186
|
from: n,
|
|
187
187
|
to: r
|
|
188
188
|
} : null;
|
|
189
189
|
}
|
|
190
|
-
function
|
|
190
|
+
function we(e, t, n, r) {
|
|
191
191
|
if (t === n) {
|
|
192
|
-
let r =
|
|
192
|
+
let r = Ce(e, t);
|
|
193
193
|
r && (t = r.from, n = r.to);
|
|
194
194
|
}
|
|
195
195
|
let i = r.length, a = r[0], o = e.slice(t, n), s = 0;
|
|
196
196
|
for (; o[s] === a;) s++;
|
|
197
197
|
let c = 0;
|
|
198
198
|
for (; o[o.length - 1 - c] === a;) c++;
|
|
199
|
-
if (o.length >= 2 * i && o.startsWith(r) && o.endsWith(r) &&
|
|
199
|
+
if (o.length >= 2 * i && o.startsWith(r) && o.endsWith(r) && xe(s, c, i)) return {
|
|
200
200
|
changes: [{
|
|
201
201
|
from: t,
|
|
202
202
|
to: t + i,
|
|
@@ -209,10 +209,10 @@ function Te(e, t, n, r) {
|
|
|
209
209
|
from: t,
|
|
210
210
|
to: n - 2 * i
|
|
211
211
|
};
|
|
212
|
-
let l =
|
|
212
|
+
let l = ye(e, t, -1), u = ye(e, n, 1), d = be(l.text, a), f = be(u.text, a).reverse();
|
|
213
213
|
for (let e = 0; e < Math.min(d.length, f.length); e++) {
|
|
214
214
|
let r = d[e], a = f[e];
|
|
215
|
-
if (!
|
|
215
|
+
if (!xe(r.len, a.len, i)) continue;
|
|
216
216
|
let o = l.from + r.start + r.len, s = n + a.start;
|
|
217
217
|
return {
|
|
218
218
|
changes: [{
|
|
@@ -242,26 +242,26 @@ function Te(e, t, n, r) {
|
|
|
242
242
|
to: n + i
|
|
243
243
|
};
|
|
244
244
|
}
|
|
245
|
-
function
|
|
245
|
+
function Te(e, t) {
|
|
246
246
|
let n = e;
|
|
247
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);
|
|
248
248
|
return n;
|
|
249
249
|
}
|
|
250
|
-
function
|
|
251
|
-
let i =
|
|
250
|
+
function A(e, t, n, r) {
|
|
251
|
+
let i = we(e, t, n, r);
|
|
252
252
|
return {
|
|
253
|
-
text:
|
|
253
|
+
text: Te(e, i.changes),
|
|
254
254
|
from: i.from,
|
|
255
255
|
to: i.to
|
|
256
256
|
};
|
|
257
257
|
}
|
|
258
|
-
function
|
|
259
|
-
let n =
|
|
258
|
+
function Ee(e, t) {
|
|
259
|
+
let n = O(e, t);
|
|
260
260
|
if (n) return {
|
|
261
261
|
from: n.from,
|
|
262
262
|
to: n.to
|
|
263
263
|
};
|
|
264
|
-
let r =
|
|
264
|
+
let r = he(e, t);
|
|
265
265
|
if (r) return {
|
|
266
266
|
from: r.from,
|
|
267
267
|
to: r.to
|
|
@@ -273,7 +273,7 @@ function De(e, t) {
|
|
|
273
273
|
"*",
|
|
274
274
|
"`"
|
|
275
275
|
]) {
|
|
276
|
-
let r = RegExp(
|
|
276
|
+
let r = RegExp(k(n) + "(?!\\s)(?:[^]*?\\S)??" + k(n), "g");
|
|
277
277
|
for (let a; a = r.exec(e);) {
|
|
278
278
|
if (a[0].length <= 2 * n.length) continue;
|
|
279
279
|
let e = a.index + n.length, r = a.index + a[0].length - n.length;
|
|
@@ -287,8 +287,8 @@ function De(e, t) {
|
|
|
287
287
|
}
|
|
288
288
|
//#endregion
|
|
289
289
|
//#region src/inplace/table-cell-dom.ts
|
|
290
|
-
var
|
|
291
|
-
function
|
|
290
|
+
var De = (e) => [e.head, ...e.body].map((e) => [...e]), Oe = (e) => e.map((e) => e.map((e) => e.trim())), ke = (e) => e.replace(/\\\|/g, "|");
|
|
291
|
+
function j(e, t) {
|
|
292
292
|
let n = e.ownerDocument.createTreeWalker(e, NodeFilter.SHOW_TEXT), r = 0;
|
|
293
293
|
for (let e = n.nextNode(); e; e = n.nextNode()) {
|
|
294
294
|
if (e === t) return r;
|
|
@@ -296,12 +296,12 @@ function je(e, t) {
|
|
|
296
296
|
}
|
|
297
297
|
return r;
|
|
298
298
|
}
|
|
299
|
-
function
|
|
299
|
+
function Ae(e) {
|
|
300
300
|
let t = e.ownerDocument.getSelection(), n = t?.anchorNode;
|
|
301
|
-
return !n || !e.contains(n) ? 0 : n.nodeType === Node.TEXT_NODE ?
|
|
301
|
+
return !n || !e.contains(n) ? 0 : n.nodeType === Node.TEXT_NODE ? j(e, n) + (t?.anchorOffset ?? 0) : (t?.anchorOffset ?? 0) > 0 ? (e.textContent ?? "").length : 0;
|
|
302
302
|
}
|
|
303
|
-
function
|
|
304
|
-
let t = e.ownerDocument.getSelection(), n = (e.textContent ?? "").length, r = (t, r) => !t || !e.contains(t) ? n : t.nodeType === Node.TEXT_NODE ?
|
|
303
|
+
function je(e) {
|
|
304
|
+
let t = e.ownerDocument.getSelection(), n = (e.textContent ?? "").length, r = (t, r) => !t || !e.contains(t) ? n : t.nodeType === Node.TEXT_NODE ? j(e, t) + r : r > 0 ? n : 0;
|
|
305
305
|
if (!t || t.rangeCount === 0) return {
|
|
306
306
|
from: n,
|
|
307
307
|
to: n
|
|
@@ -312,7 +312,7 @@ function Ne(e) {
|
|
|
312
312
|
to: Math.max(i, a)
|
|
313
313
|
};
|
|
314
314
|
}
|
|
315
|
-
function
|
|
315
|
+
function Me(e, t, n) {
|
|
316
316
|
let r = e.ownerDocument, i = null, a = 0;
|
|
317
317
|
if (r.caretPositionFromPoint) {
|
|
318
318
|
let e = r.caretPositionFromPoint(t, n);
|
|
@@ -321,18 +321,18 @@ function Pe(e, t, n) {
|
|
|
321
321
|
let e = r.caretRangeFromPoint(t, n);
|
|
322
322
|
e && ([i, a] = [e.startContainer, e.startOffset]);
|
|
323
323
|
}
|
|
324
|
-
return !i || !e.contains(i) ? 0 :
|
|
324
|
+
return !i || !e.contains(i) ? 0 : j(e, i) + (i.nodeType === Node.TEXT_NODE ? a : 0);
|
|
325
325
|
}
|
|
326
|
-
var
|
|
327
|
-
function
|
|
328
|
-
let r = e.textContent ?? "", i =
|
|
329
|
-
if (a) return
|
|
326
|
+
var Ne = /[\p{L}\p{N}_]/u;
|
|
327
|
+
function Pe(e, t, n) {
|
|
328
|
+
let r = e.textContent ?? "", i = Me(e, t, n), a = Ee(r, i);
|
|
329
|
+
if (a) return M(e, a.from, a.to), !0;
|
|
330
330
|
let o = i, s = i;
|
|
331
|
-
for (; o > 0 &&
|
|
332
|
-
for (; s < r.length &&
|
|
333
|
-
return s <= o ? !1 : (
|
|
331
|
+
for (; o > 0 && Ne.test(r[o - 1]);) o--;
|
|
332
|
+
for (; s < r.length && Ne.test(r[s]);) s++;
|
|
333
|
+
return s <= o ? !1 : (M(e, o, s), !0);
|
|
334
334
|
}
|
|
335
|
-
function
|
|
335
|
+
function M(e, t, n = t) {
|
|
336
336
|
e.focus();
|
|
337
337
|
let r = e.ownerDocument, i = r.createRange(), a = e.firstChild;
|
|
338
338
|
if (a && a.nodeType === Node.TEXT_NODE) {
|
|
@@ -345,38 +345,38 @@ function A(e, t, n = t) {
|
|
|
345
345
|
}
|
|
346
346
|
//#endregion
|
|
347
347
|
//#region src/toolbar/cell-inline.ts
|
|
348
|
-
function
|
|
348
|
+
function Fe(e) {
|
|
349
349
|
let t = e.dom.ownerDocument.activeElement;
|
|
350
350
|
return !(t instanceof HTMLElement) || !e.dom.contains(t) ? null : t.matches(".cm-inplace-tcell") ? t : null;
|
|
351
351
|
}
|
|
352
|
-
function
|
|
353
|
-
let { from: n, to: r } =
|
|
354
|
-
e.textContent = i.text,
|
|
352
|
+
function Ie(e, t) {
|
|
353
|
+
let { from: n, to: r } = je(e), i = t(e.textContent ?? "", n, r);
|
|
354
|
+
e.textContent = i.text, M(e, i.from, i.to), e.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
355
355
|
}
|
|
356
|
-
function
|
|
357
|
-
let n =
|
|
358
|
-
return n ? (
|
|
359
|
-
}
|
|
360
|
-
var
|
|
361
|
-
b: (e, t, n) =>
|
|
362
|
-
i: (e, t, n) =>
|
|
363
|
-
u:
|
|
364
|
-
k:
|
|
365
|
-
K:
|
|
356
|
+
function N(e, t) {
|
|
357
|
+
let n = Fe(e);
|
|
358
|
+
return n ? (Ie(n, t), !0) : !1;
|
|
359
|
+
}
|
|
360
|
+
var Le = {
|
|
361
|
+
b: (e, t, n) => A(e, t, n, "**"),
|
|
362
|
+
i: (e, t, n) => A(e, t, n, "*"),
|
|
363
|
+
u: ve,
|
|
364
|
+
k: pe,
|
|
365
|
+
K: ge
|
|
366
366
|
};
|
|
367
|
-
function
|
|
367
|
+
function Re(e, t) {
|
|
368
368
|
if (!(e.metaKey || e.ctrlKey) || e.altKey) return !1;
|
|
369
|
-
let n =
|
|
370
|
-
return n ? (e.preventDefault(),
|
|
369
|
+
let n = Le[e.shiftKey ? e.key.toUpperCase() : e.key.toLowerCase()];
|
|
370
|
+
return n ? (e.preventDefault(), Ie(t, n), !0) : !1;
|
|
371
371
|
}
|
|
372
372
|
//#endregion
|
|
373
373
|
//#region src/toolbar/block.ts
|
|
374
|
-
function
|
|
374
|
+
function P(e) {
|
|
375
375
|
let { from: t, to: n } = e.selection.main;
|
|
376
376
|
return [e.doc.lineAt(t).number, e.doc.lineAt(n).number];
|
|
377
377
|
}
|
|
378
|
-
function
|
|
379
|
-
let n = e.state, [r, i] =
|
|
378
|
+
function ze(e, t) {
|
|
379
|
+
let n = e.state, [r, i] = P(n), a = r === i && !n.doc.line(r).text.trim(), o = !a;
|
|
380
380
|
for (let e = r; e <= i && o; e++) {
|
|
381
381
|
let r = n.doc.line(e).text;
|
|
382
382
|
r.trim() && !t.match.test(r) && (o = !1);
|
|
@@ -413,13 +413,13 @@ function Ve(e, t) {
|
|
|
413
413
|
scrollIntoView: !0
|
|
414
414
|
}), e.focus(), !0) : !1;
|
|
415
415
|
}
|
|
416
|
-
function
|
|
416
|
+
function Be(e, t) {
|
|
417
417
|
return t.test(e.doc.lineAt(e.selection.main.head).text);
|
|
418
418
|
}
|
|
419
419
|
//#endregion
|
|
420
420
|
//#region src/toolbar/fence.ts
|
|
421
|
-
function
|
|
422
|
-
for (let n =
|
|
421
|
+
function F(e, t) {
|
|
422
|
+
for (let n = ce(e).resolveInner(t, 0); n; n = n.parent) {
|
|
423
423
|
if (n.name === "FencedCode") return {
|
|
424
424
|
from: n.from,
|
|
425
425
|
to: n.to
|
|
@@ -428,8 +428,8 @@ function N(e, t) {
|
|
|
428
428
|
}
|
|
429
429
|
return null;
|
|
430
430
|
}
|
|
431
|
-
function
|
|
432
|
-
let t = e.state, n =
|
|
431
|
+
function Ve(e) {
|
|
432
|
+
let t = e.state, n = F(t, t.selection.main.head);
|
|
433
433
|
if (n) {
|
|
434
434
|
let r = t.doc.lineAt(n.from), i = t.doc.lineAt(n.to), a = [{
|
|
435
435
|
from: r.from,
|
|
@@ -443,7 +443,7 @@ function Ue(e) {
|
|
|
443
443
|
scrollIntoView: !0
|
|
444
444
|
});
|
|
445
445
|
} else {
|
|
446
|
-
let [n, r] =
|
|
446
|
+
let [n, r] = P(t);
|
|
447
447
|
e.dispatch({
|
|
448
448
|
changes: [{
|
|
449
449
|
from: t.doc.line(n).from,
|
|
@@ -458,11 +458,11 @@ function Ue(e) {
|
|
|
458
458
|
}
|
|
459
459
|
return e.focus(), !0;
|
|
460
460
|
}
|
|
461
|
-
function
|
|
462
|
-
return
|
|
461
|
+
function I(e) {
|
|
462
|
+
return F(e, e.selection.main.head) !== null;
|
|
463
463
|
}
|
|
464
|
-
function
|
|
465
|
-
let t =
|
|
464
|
+
function He(e) {
|
|
465
|
+
let t = F(e, e.selection.main.head);
|
|
466
466
|
if (!t) return null;
|
|
467
467
|
let n = e.doc.lineAt(t.from), r = /^(\s*(?:`{3,}|~{3,})[ \t]*)(.*?)[ \t]*$/.exec(n.text);
|
|
468
468
|
if (!r) return null;
|
|
@@ -473,18 +473,18 @@ function We(e) {
|
|
|
473
473
|
lang: r[2]
|
|
474
474
|
};
|
|
475
475
|
}
|
|
476
|
-
var
|
|
477
|
-
function
|
|
476
|
+
var Ue = /^\s*\$\$\s*$/;
|
|
477
|
+
function We(e, t) {
|
|
478
478
|
let n = 0, r = 0;
|
|
479
|
-
for (let i = 1; i <= e.doc.lines; i++) if (
|
|
479
|
+
for (let i = 1; i <= e.doc.lines; i++) if (Ue.test(e.doc.line(i).text)) {
|
|
480
480
|
if (r++, r % 2 == 1) {
|
|
481
481
|
if (n = i, i > t) return null;
|
|
482
482
|
} else if (i >= t) return [n, i];
|
|
483
483
|
}
|
|
484
484
|
return null;
|
|
485
485
|
}
|
|
486
|
-
function
|
|
487
|
-
let t = e.state, [n, r] =
|
|
486
|
+
function Ge(e) {
|
|
487
|
+
let t = e.state, [n, r] = P(t), i = We(t, t.doc.lineAt(t.selection.main.head).number);
|
|
488
488
|
if (i) {
|
|
489
489
|
let n = t.doc.line(i[0]), r = t.doc.line(i[1]);
|
|
490
490
|
e.dispatch({
|
|
@@ -510,16 +510,16 @@ function qe(e) {
|
|
|
510
510
|
});
|
|
511
511
|
return e.focus(), !0;
|
|
512
512
|
}
|
|
513
|
-
function
|
|
514
|
-
return
|
|
513
|
+
function L(e) {
|
|
514
|
+
return We(e, e.doc.lineAt(e.selection.main.head).number) !== null;
|
|
515
515
|
}
|
|
516
516
|
//#endregion
|
|
517
517
|
//#region src/toolbar/heading.ts
|
|
518
|
-
var
|
|
519
|
-
function
|
|
520
|
-
let n = "#".repeat(t) + " ", r = e.state, [i, a] =
|
|
518
|
+
var Ke = /^(#{1,6}) +/;
|
|
519
|
+
function qe(e, t) {
|
|
520
|
+
let n = "#".repeat(t) + " ", r = e.state, [i, a] = P(r), o = [];
|
|
521
521
|
for (let e = i; e <= a; e++) {
|
|
522
|
-
let i = r.doc.line(e), a =
|
|
522
|
+
let i = r.doc.line(e), a = Ke.exec(i.text);
|
|
523
523
|
a && a[1].length === t ? o.push({
|
|
524
524
|
from: i.from,
|
|
525
525
|
to: i.from + a[0].length
|
|
@@ -537,10 +537,10 @@ function Je(e, t) {
|
|
|
537
537
|
scrollIntoView: !0
|
|
538
538
|
}), e.focus(), !0;
|
|
539
539
|
}
|
|
540
|
-
function
|
|
541
|
-
let t = e.state, [n, r] =
|
|
540
|
+
function Je(e) {
|
|
541
|
+
let t = e.state, [n, r] = P(t), i = [];
|
|
542
542
|
for (let e = n; e <= r; e++) {
|
|
543
|
-
let n = t.doc.line(e), r =
|
|
543
|
+
let n = t.doc.line(e), r = Ke.exec(n.text);
|
|
544
544
|
r && i.push({
|
|
545
545
|
from: n.from,
|
|
546
546
|
to: n.from + r[0].length
|
|
@@ -553,11 +553,11 @@ function Ye(e) {
|
|
|
553
553
|
}
|
|
554
554
|
//#endregion
|
|
555
555
|
//#region src/toolbar/inline.ts
|
|
556
|
-
function
|
|
556
|
+
function R(e, t) {
|
|
557
557
|
let n = e.state.doc.toString();
|
|
558
558
|
return e.dispatch({
|
|
559
559
|
...e.state.changeByRange((e) => {
|
|
560
|
-
let r =
|
|
560
|
+
let r = we(n, e.from, e.to, t);
|
|
561
561
|
return {
|
|
562
562
|
changes: r.changes,
|
|
563
563
|
range: r.from === r.to ? f.cursor(r.from) : f.range(r.from, r.to)
|
|
@@ -566,8 +566,8 @@ function L(e, t) {
|
|
|
566
566
|
scrollIntoView: !0
|
|
567
567
|
}), e.focus(), !0;
|
|
568
568
|
}
|
|
569
|
-
function
|
|
570
|
-
let n = e.selection.main, r = e.doc.lineAt(n.head), i = RegExp(
|
|
569
|
+
function z(e, t) {
|
|
570
|
+
let n = e.selection.main, r = e.doc.lineAt(n.head), i = RegExp(k(t) + "(?!\\s)(?:[^]*?\\S)??" + k(t), "g");
|
|
571
571
|
for (let e; e = i.exec(r.text);) {
|
|
572
572
|
if (e[0].length <= 2 * t.length || t === "$" && (r.text[e.index - 1] === "$" || r.text[e.index + e[0].length] === "$")) continue;
|
|
573
573
|
let i = r.from + e.index;
|
|
@@ -575,16 +575,16 @@ function R(e, t) {
|
|
|
575
575
|
}
|
|
576
576
|
return !1;
|
|
577
577
|
}
|
|
578
|
-
function
|
|
579
|
-
let { head: t } = e.selection.main, n = e.doc.lineAt(t), r =
|
|
578
|
+
function Ye(e) {
|
|
579
|
+
let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = O(n.text, t - n.from);
|
|
580
580
|
return r ? {
|
|
581
581
|
from: n.from + r.from,
|
|
582
582
|
to: n.from + r.to,
|
|
583
583
|
text: r.label
|
|
584
584
|
} : null;
|
|
585
585
|
}
|
|
586
|
-
function
|
|
587
|
-
let t =
|
|
586
|
+
function Xe(e) {
|
|
587
|
+
let t = Ye(e.state);
|
|
588
588
|
if (t) return e.dispatch({
|
|
589
589
|
changes: {
|
|
590
590
|
from: t.from,
|
|
@@ -605,19 +605,19 @@ function Ze(e) {
|
|
|
605
605
|
scrollIntoView: !0
|
|
606
606
|
}), e.focus(), !0;
|
|
607
607
|
}
|
|
608
|
-
function
|
|
609
|
-
return
|
|
608
|
+
function Ze(e) {
|
|
609
|
+
return Ye(e) !== null;
|
|
610
610
|
}
|
|
611
|
-
function
|
|
612
|
-
let { head: t } = e.selection.main, n = e.doc.lineAt(t), r =
|
|
611
|
+
function Qe(e) {
|
|
612
|
+
let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = me(n.text, t - n.from);
|
|
613
613
|
return r ? {
|
|
614
614
|
from: n.from + r.from,
|
|
615
615
|
to: n.from + r.to,
|
|
616
616
|
text: r.label
|
|
617
617
|
} : null;
|
|
618
618
|
}
|
|
619
|
-
function
|
|
620
|
-
let t =
|
|
619
|
+
function $e(e) {
|
|
620
|
+
let t = Qe(e.state);
|
|
621
621
|
if (t) return e.dispatch({
|
|
622
622
|
changes: {
|
|
623
623
|
from: t.from,
|
|
@@ -638,19 +638,19 @@ function et(e) {
|
|
|
638
638
|
scrollIntoView: !0
|
|
639
639
|
}), e.focus(), !0;
|
|
640
640
|
}
|
|
641
|
-
function
|
|
642
|
-
return
|
|
641
|
+
function et(e) {
|
|
642
|
+
return Qe(e) !== null;
|
|
643
643
|
}
|
|
644
|
-
function
|
|
645
|
-
let { head: t } = e.selection.main, n = e.doc.lineAt(t), r =
|
|
644
|
+
function tt(e) {
|
|
645
|
+
let { head: t } = e.selection.main, n = e.doc.lineAt(t), r = _e(n.text, t - n.from);
|
|
646
646
|
return r ? {
|
|
647
647
|
from: n.from + r.from,
|
|
648
648
|
to: n.from + r.to,
|
|
649
649
|
inner: r.inner
|
|
650
650
|
} : null;
|
|
651
651
|
}
|
|
652
|
-
function
|
|
653
|
-
let t =
|
|
652
|
+
function nt(e) {
|
|
653
|
+
let t = tt(e.state);
|
|
654
654
|
if (t) return e.dispatch({
|
|
655
655
|
changes: {
|
|
656
656
|
from: t.from,
|
|
@@ -671,29 +671,29 @@ function rt(e) {
|
|
|
671
671
|
scrollIntoView: !0
|
|
672
672
|
}), e.focus(), !0;
|
|
673
673
|
}
|
|
674
|
-
function
|
|
675
|
-
return
|
|
674
|
+
function rt(e) {
|
|
675
|
+
return tt(e) !== null;
|
|
676
676
|
}
|
|
677
677
|
//#endregion
|
|
678
678
|
//#region src/toolbar/table-grid.ts
|
|
679
|
-
function
|
|
679
|
+
function it(e) {
|
|
680
680
|
let t = e.trim();
|
|
681
681
|
return t.includes("-") && t.includes("|") && /^[\s|:-]+$/.test(t);
|
|
682
682
|
}
|
|
683
|
-
function
|
|
683
|
+
function at(e) {
|
|
684
684
|
let t = e.trim();
|
|
685
685
|
t.startsWith("|") && (t = t.slice(1)), t.endsWith("|") && !t.endsWith("\\|") && (t = t.slice(0, -1));
|
|
686
686
|
let n = [], r = "";
|
|
687
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];
|
|
688
688
|
return n.push(r.trim()), n;
|
|
689
689
|
}
|
|
690
|
-
function
|
|
690
|
+
function ot(e) {
|
|
691
691
|
let t = e.trim(), n = t.startsWith(":"), r = t.endsWith(":");
|
|
692
692
|
return n && r ? "center" : r ? "right" : n ? "left" : "";
|
|
693
693
|
}
|
|
694
|
-
function
|
|
695
|
-
if (e.length < 2 || !
|
|
696
|
-
let t =
|
|
694
|
+
function B(e) {
|
|
695
|
+
if (e.length < 2 || !it(e[1])) return null;
|
|
696
|
+
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) => {
|
|
697
697
|
let t = e.slice(0, r);
|
|
698
698
|
for (; t.length < r;) t.push("");
|
|
699
699
|
return t;
|
|
@@ -704,11 +704,11 @@ function z(e) {
|
|
|
704
704
|
aligns: a
|
|
705
705
|
};
|
|
706
706
|
}
|
|
707
|
-
function
|
|
707
|
+
function st(e) {
|
|
708
708
|
return e.replace(/\\\|/g, "|").length;
|
|
709
709
|
}
|
|
710
|
-
function
|
|
711
|
-
let r = t -
|
|
710
|
+
function ct(e, t, n) {
|
|
711
|
+
let r = t - st(e);
|
|
712
712
|
if (r <= 0) return e;
|
|
713
713
|
if (n === "right") return " ".repeat(r) + e;
|
|
714
714
|
if (n === "center") {
|
|
@@ -717,23 +717,23 @@ function lt(e, t, n) {
|
|
|
717
717
|
}
|
|
718
718
|
return e + " ".repeat(r);
|
|
719
719
|
}
|
|
720
|
-
function
|
|
720
|
+
function lt(e, t) {
|
|
721
721
|
let n = Math.max(3, e);
|
|
722
722
|
return t === "left" ? ":" + "-".repeat(n - 1) : t === "right" ? "-".repeat(n - 1) + ":" : t === "center" ? ":" + "-".repeat(n - 2) + ":" : "-".repeat(n);
|
|
723
723
|
}
|
|
724
|
-
function
|
|
724
|
+
function V(e) {
|
|
725
725
|
let t = e.aligns.length, n = [];
|
|
726
726
|
for (let r = 0; r < t; r++) {
|
|
727
727
|
let t = 3;
|
|
728
|
-
for (let n of e.rows) t = Math.max(t,
|
|
728
|
+
for (let n of e.rows) t = Math.max(t, st(n[r] ?? ""));
|
|
729
729
|
n.push(t);
|
|
730
730
|
}
|
|
731
|
-
let r = (t) => "| " + t.map((t, r) =>
|
|
732
|
-
i.push("| " + e.aligns.map((e, t) =>
|
|
731
|
+
let r = (t) => "| " + t.map((t, r) => ct(t ?? "", n[r], e.aligns[r])).join(" | ") + " |", i = [r(e.rows[0] ?? [])];
|
|
732
|
+
i.push("| " + e.aligns.map((e, t) => lt(n[t], e)).join(" | ") + " |");
|
|
733
733
|
for (let t = 1; t < e.rows.length; t++) i.push(r(e.rows[t]));
|
|
734
734
|
return i.join("\n");
|
|
735
735
|
}
|
|
736
|
-
function
|
|
736
|
+
function ut(e) {
|
|
737
737
|
let t = [];
|
|
738
738
|
for (let n = 0; n < e.length; n++) {
|
|
739
739
|
if (e[n] === "\\") {
|
|
@@ -756,7 +756,7 @@ function dt(e) {
|
|
|
756
756
|
}
|
|
757
757
|
//#endregion
|
|
758
758
|
//#region src/toolbar/table-position.ts
|
|
759
|
-
function
|
|
759
|
+
function H(e, t) {
|
|
760
760
|
let n = e.lineAt(t);
|
|
761
761
|
if (!n.text.includes("|")) return null;
|
|
762
762
|
let r = n.number;
|
|
@@ -774,13 +774,13 @@ function V(e, t) {
|
|
|
774
774
|
if (i - r < 1) return null;
|
|
775
775
|
let a = [];
|
|
776
776
|
for (let t = r; t <= i; t++) a.push(e.line(t).text);
|
|
777
|
-
return
|
|
777
|
+
return B(a) ? {
|
|
778
778
|
from: e.line(r).from,
|
|
779
779
|
to: e.line(i).to,
|
|
780
780
|
lines: a
|
|
781
781
|
} : null;
|
|
782
782
|
}
|
|
783
|
-
function
|
|
783
|
+
function dt(e, t, n) {
|
|
784
784
|
let r = t;
|
|
785
785
|
for (let t = 0; t < e.length; t++) {
|
|
786
786
|
let i = e[t];
|
|
@@ -796,7 +796,7 @@ function ft(e, t, n) {
|
|
|
796
796
|
onDelimiter: !0
|
|
797
797
|
};
|
|
798
798
|
}
|
|
799
|
-
let a =
|
|
799
|
+
let a = ut(i), o = 0;
|
|
800
800
|
for (let t = 0; t < a.length && (o = t, !(e <= a[t].end)); t++);
|
|
801
801
|
let s = a[o], c = s ? Math.max(0, Math.min(e, s.contentEnd) - s.contentStart) : 0;
|
|
802
802
|
return {
|
|
@@ -810,15 +810,15 @@ function ft(e, t, n) {
|
|
|
810
810
|
}
|
|
811
811
|
return null;
|
|
812
812
|
}
|
|
813
|
-
function
|
|
813
|
+
function U(e, t, n) {
|
|
814
814
|
let r = e.split("\n"), i = n.onDelimiter ? 1 : n.row === 0 ? 0 : n.row + 1, a = t;
|
|
815
815
|
for (let e = 0; e < i; e++) a += r[e].length + 1;
|
|
816
|
-
let o =
|
|
816
|
+
let o = ut(r[i]), s = o[Math.min(n.col, o.length - 1)];
|
|
817
817
|
return s ? a + s.contentStart + Math.min(n.offset, s.contentEnd - s.contentStart) : a;
|
|
818
818
|
}
|
|
819
|
-
function
|
|
820
|
-
let i =
|
|
821
|
-
return i ?
|
|
819
|
+
function ft(e, t, n, r) {
|
|
820
|
+
let i = H(e, t);
|
|
821
|
+
return i ? U(i.lines.join("\n"), i.from, {
|
|
822
822
|
row: n,
|
|
823
823
|
col: r,
|
|
824
824
|
offset: 0,
|
|
@@ -827,7 +827,7 @@ function pt(e, t, n, r) {
|
|
|
827
827
|
}
|
|
828
828
|
//#endregion
|
|
829
829
|
//#region src/toolbar/table.ts
|
|
830
|
-
function
|
|
830
|
+
function pt(e, t) {
|
|
831
831
|
requestAnimationFrame(() => {
|
|
832
832
|
let n = e.dom.querySelectorAll(".cm-inplace-table-edit");
|
|
833
833
|
if (n.length === 0) return;
|
|
@@ -847,7 +847,7 @@ function mt(e, t) {
|
|
|
847
847
|
s?.removeAllRanges(), s?.addRange(o), a.focus();
|
|
848
848
|
});
|
|
849
849
|
}
|
|
850
|
-
function
|
|
850
|
+
function mt(e) {
|
|
851
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;
|
|
852
852
|
return e.dispatch({
|
|
853
853
|
changes: {
|
|
@@ -857,30 +857,30 @@ function ht(e) {
|
|
|
857
857
|
},
|
|
858
858
|
selection: f.range(a, a + 8),
|
|
859
859
|
scrollIntoView: !0
|
|
860
|
-
}), e.focus(),
|
|
860
|
+
}), e.focus(), pt(e, a), !0;
|
|
861
861
|
}
|
|
862
|
-
function
|
|
863
|
-
return
|
|
862
|
+
function W(e) {
|
|
863
|
+
return H(e.doc, e.selection.main.head) !== null;
|
|
864
864
|
}
|
|
865
|
-
function
|
|
866
|
-
let n =
|
|
865
|
+
function G(e, t) {
|
|
866
|
+
let n = H(e.state.doc, e.state.selection.main.head);
|
|
867
867
|
if (!n) return !1;
|
|
868
|
-
let r =
|
|
868
|
+
let r = B(n.lines), i = dt(n.lines, n.from, e.state.selection.main.head);
|
|
869
869
|
if (!r || !i) return !1;
|
|
870
870
|
let a = t(r, i);
|
|
871
871
|
if (!a) return !1;
|
|
872
|
-
let o =
|
|
872
|
+
let o = V(r);
|
|
873
873
|
return e.dispatch({
|
|
874
874
|
changes: {
|
|
875
875
|
from: n.from,
|
|
876
876
|
to: n.to,
|
|
877
877
|
insert: o
|
|
878
878
|
},
|
|
879
|
-
selection: f.cursor(
|
|
879
|
+
selection: f.cursor(U(o, n.from, a)),
|
|
880
880
|
scrollIntoView: !0
|
|
881
881
|
}), e.focus(), !0;
|
|
882
882
|
}
|
|
883
|
-
function
|
|
883
|
+
function ht(e, t, n) {
|
|
884
884
|
let r = e.aligns.length, { row: i, col: a } = t;
|
|
885
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("")), {
|
|
886
886
|
row: i,
|
|
@@ -889,7 +889,7 @@ function gt(e, t, n) {
|
|
|
889
889
|
onDelimiter: !1
|
|
890
890
|
});
|
|
891
891
|
}
|
|
892
|
-
function
|
|
892
|
+
function gt(e, t) {
|
|
893
893
|
let n = t.row + 1;
|
|
894
894
|
return n >= e.rows.length && e.rows.push(Array(e.aligns.length).fill("")), {
|
|
895
895
|
row: n,
|
|
@@ -898,58 +898,58 @@ function _t(e, t) {
|
|
|
898
898
|
onDelimiter: !1
|
|
899
899
|
};
|
|
900
900
|
}
|
|
901
|
-
var
|
|
901
|
+
var _t = o.of([
|
|
902
902
|
{
|
|
903
903
|
key: "Tab",
|
|
904
|
-
run: (e) =>
|
|
904
|
+
run: (e) => G(e, (e, t) => ht(e, t, 1))
|
|
905
905
|
},
|
|
906
906
|
{
|
|
907
907
|
key: "Shift-Tab",
|
|
908
|
-
run: (e) =>
|
|
908
|
+
run: (e) => G(e, (e, t) => ht(e, t, -1))
|
|
909
909
|
},
|
|
910
910
|
{
|
|
911
911
|
key: "Enter",
|
|
912
|
-
run: (e) =>
|
|
912
|
+
run: (e) => G(e, gt)
|
|
913
913
|
}
|
|
914
|
-
]),
|
|
914
|
+
]), vt = p.transactionFilter.of((e) => {
|
|
915
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 =
|
|
916
|
+
let t = e.newSelection.main.head, n = H(e.newDoc, t);
|
|
917
917
|
if (!n) return e;
|
|
918
|
-
let r =
|
|
918
|
+
let r = B(n.lines);
|
|
919
919
|
if (!r) return e;
|
|
920
|
-
let i =
|
|
920
|
+
let i = V(r);
|
|
921
921
|
if (i === n.lines.join("\n")) return e;
|
|
922
|
-
let a =
|
|
922
|
+
let a = dt(n.lines, n.from, t), o = u.of([{
|
|
923
923
|
from: n.from,
|
|
924
924
|
to: n.to,
|
|
925
925
|
insert: i
|
|
926
926
|
}], e.newDoc.length);
|
|
927
927
|
return {
|
|
928
928
|
changes: e.changes.compose(o),
|
|
929
|
-
selection: a ? f.cursor(
|
|
929
|
+
selection: a ? f.cursor(U(i, n.from, a)) : e.newSelection,
|
|
930
930
|
effects: e.effects,
|
|
931
931
|
scrollIntoView: e.scrollIntoView
|
|
932
932
|
};
|
|
933
|
-
}),
|
|
933
|
+
}), K = (e) => /^\s{0,3}#{1,6}(?:\s|$)/.test(e.doc.lineAt(e.selection.main.head).text), q = (e) => {
|
|
934
934
|
let t = n(e.doc);
|
|
935
935
|
return t !== null && e.selection.main.head <= t.to;
|
|
936
|
-
},
|
|
936
|
+
}, J = (e) => q(e) || I(e) || L(e), yt = (e) => (t) => e !== "`" && z(t, "`") || e !== "$" && z(t, "$"), bt = (e) => e.selection.main.empty && !e.wordAt(e.selection.main.head), Y = (...e) => (t) => e.some((e) => e(t)), X = /^(\s*)(?:[-*+] \[[ xX]\] +|\d+[.)] +|[-*+] +)/, xt = {
|
|
937
937
|
match: /^ {0,3}> ?/,
|
|
938
938
|
insert: "> "
|
|
939
|
-
},
|
|
939
|
+
}, St = {
|
|
940
940
|
match: /^(\s*)[-*+] +(?!\[[ xX]\])/,
|
|
941
941
|
insert: "- ",
|
|
942
|
-
siblings:
|
|
943
|
-
},
|
|
942
|
+
siblings: X
|
|
943
|
+
}, Ct = {
|
|
944
944
|
match: /^(\s*)\d+[.)] +/,
|
|
945
945
|
insert: (e) => `${e + 1}. `,
|
|
946
|
-
siblings:
|
|
947
|
-
},
|
|
946
|
+
siblings: X
|
|
947
|
+
}, wt = {
|
|
948
948
|
match: /^(\s*)[-*+] \[[ xX]\] +/,
|
|
949
949
|
insert: "- [ ] ",
|
|
950
|
-
siblings:
|
|
950
|
+
siblings: X
|
|
951
951
|
};
|
|
952
|
-
function
|
|
952
|
+
function Tt(e, t, n) {
|
|
953
953
|
return {
|
|
954
954
|
id: e,
|
|
955
955
|
title: t,
|
|
@@ -959,24 +959,24 @@ function Et(e, t, n) {
|
|
|
959
959
|
}
|
|
960
960
|
};
|
|
961
961
|
}
|
|
962
|
-
function
|
|
962
|
+
function Z(e, t, n, r) {
|
|
963
963
|
return {
|
|
964
964
|
id: e,
|
|
965
965
|
title: t,
|
|
966
|
-
run: (e) =>
|
|
967
|
-
isActive: (e) =>
|
|
968
|
-
disabled: J
|
|
966
|
+
run: (e) => N(e, (e, t, r) => A(e, t, r, n)) || R(e, n),
|
|
967
|
+
isActive: (e) => z(e, n),
|
|
968
|
+
disabled: Y(J, yt(n), bt),
|
|
969
969
|
keys: r
|
|
970
970
|
};
|
|
971
971
|
}
|
|
972
|
-
function
|
|
972
|
+
function Et(e) {
|
|
973
973
|
let t = RegExp(`^#{${e}} `);
|
|
974
974
|
return {
|
|
975
975
|
id: `h${e}`,
|
|
976
976
|
title: `Heading ${e}`,
|
|
977
|
-
run: (t) =>
|
|
977
|
+
run: (t) => qe(t, e),
|
|
978
978
|
isActive: (e) => t.test(e.doc.lineAt(e.selection.main.head).text),
|
|
979
|
-
disabled:
|
|
979
|
+
disabled: Y(W, J),
|
|
980
980
|
keys: [`Mod-Alt-${e}`]
|
|
981
981
|
};
|
|
982
982
|
}
|
|
@@ -1008,9 +1008,9 @@ function Q(e, t, n, ...r) {
|
|
|
1008
1008
|
return {
|
|
1009
1009
|
id: e,
|
|
1010
1010
|
title: t,
|
|
1011
|
-
run: (e) =>
|
|
1012
|
-
isActive: (e) =>
|
|
1013
|
-
disabled:
|
|
1011
|
+
run: (e) => ze(e, n),
|
|
1012
|
+
isActive: (e) => Be(e, n.match),
|
|
1013
|
+
disabled: Y(W, J, ...r)
|
|
1014
1014
|
};
|
|
1015
1015
|
}
|
|
1016
1016
|
//#endregion
|
|
@@ -1134,29 +1134,29 @@ function Bt(e) {
|
|
|
1134
1134
|
//#region src/editor/search-panel.ts
|
|
1135
1135
|
var Vt = "cm-search-closing", Ht = 160;
|
|
1136
1136
|
function Ut(e) {
|
|
1137
|
-
return
|
|
1137
|
+
return ae(e.state) ? Wt(e) : w(e);
|
|
1138
1138
|
}
|
|
1139
1139
|
function Wt(e) {
|
|
1140
1140
|
let t = e.dom.querySelector(`.${It}`);
|
|
1141
1141
|
return !t || t.classList.contains(Vt) ? !0 : (t.classList.add(Vt), setTimeout(() => {
|
|
1142
|
-
e.dom.isConnected &&
|
|
1142
|
+
e.dom.isConnected && b(e);
|
|
1143
1143
|
}, Ht), !0);
|
|
1144
1144
|
}
|
|
1145
1145
|
function Gt(e) {
|
|
1146
|
-
let t = Bt(e), n =
|
|
1146
|
+
let t = Bt(e), n = C(e.state);
|
|
1147
1147
|
r(n);
|
|
1148
1148
|
function r(e) {
|
|
1149
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;
|
|
1150
1150
|
}
|
|
1151
1151
|
function i() {
|
|
1152
|
-
let r = new
|
|
1152
|
+
let r = new re({
|
|
1153
1153
|
search: t.find.value,
|
|
1154
1154
|
caseSensitive: t.caseSensitive.checked,
|
|
1155
1155
|
regexp: t.regexp.checked,
|
|
1156
1156
|
wholeWord: t.wholeWord.checked,
|
|
1157
1157
|
replace: t.replace.value
|
|
1158
1158
|
});
|
|
1159
|
-
r.eq(n) || (n = r, e.dispatch({ effects:
|
|
1159
|
+
r.eq(n) || (n = r, e.dispatch({ effects: se.of(n) }));
|
|
1160
1160
|
}
|
|
1161
1161
|
for (let e of [
|
|
1162
1162
|
t.find,
|
|
@@ -1174,20 +1174,20 @@ function Gt(e) {
|
|
|
1174
1174
|
n.preventDefault();
|
|
1175
1175
|
return;
|
|
1176
1176
|
}
|
|
1177
|
-
n.key === "Enter" && (n.preventDefault(), n.target === t.find ? (n.shiftKey ?
|
|
1178
|
-
}), t.next.addEventListener("click", () =>
|
|
1177
|
+
n.key === "Enter" && (n.preventDefault(), n.target === t.find ? (n.shiftKey ? S : x)(e) : n.target === t.replace && E(e));
|
|
1178
|
+
}), t.next.addEventListener("click", () => x(e)), t.prev.addEventListener("click", () => S(e)), t.all.addEventListener("click", () => oe(e)), t.replaceBtn.addEventListener("click", () => E(e)), t.replaceAllBtn.addEventListener("click", () => T(e)), t.close.addEventListener("click", () => Wt(e)), {
|
|
1179
1179
|
dom: t.root,
|
|
1180
1180
|
top: !0,
|
|
1181
1181
|
update(e) {
|
|
1182
|
-
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(se) && !e.value.eq(n) && (n = e.value, r(n));
|
|
1183
1183
|
}
|
|
1184
1184
|
};
|
|
1185
1185
|
}
|
|
1186
1186
|
//#endregion
|
|
1187
1187
|
//#region src/toolbar/commands.ts
|
|
1188
1188
|
var Kt = [
|
|
1189
|
-
|
|
1190
|
-
|
|
1189
|
+
Tt("undo", "Undo", _),
|
|
1190
|
+
Tt("redo", "Redo", g),
|
|
1191
1191
|
{
|
|
1192
1192
|
id: "save",
|
|
1193
1193
|
title: "Save",
|
|
@@ -1201,86 +1201,86 @@ var Kt = [
|
|
|
1201
1201
|
id: "search",
|
|
1202
1202
|
title: "Find / replace",
|
|
1203
1203
|
run: (e) => Ut(e),
|
|
1204
|
-
isActive: (e) =>
|
|
1204
|
+
isActive: (e) => ae(e),
|
|
1205
1205
|
keys: ["Mod-f"]
|
|
1206
1206
|
},
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1207
|
+
Et(1),
|
|
1208
|
+
Et(2),
|
|
1209
|
+
Et(3),
|
|
1210
1210
|
{
|
|
1211
1211
|
id: "body",
|
|
1212
1212
|
title: "Body",
|
|
1213
|
-
run: (e) => (
|
|
1213
|
+
run: (e) => (Je(e) || e.focus(), !0),
|
|
1214
1214
|
isActive: (e) => !/^#{1,6} /.test(e.doc.lineAt(e.selection.main.head).text),
|
|
1215
|
-
disabled:
|
|
1215
|
+
disabled: Y(W, J)
|
|
1216
1216
|
},
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1217
|
+
Z("bold", "Bold", "**", ["Mod-b"]),
|
|
1218
|
+
Z("italic", "Italic", "*", ["Mod-i"]),
|
|
1219
|
+
Z("strike", "Strikethrough", "~~"),
|
|
1220
1220
|
{
|
|
1221
1221
|
id: "underline",
|
|
1222
1222
|
title: "Underline",
|
|
1223
|
-
run: (e) =>
|
|
1224
|
-
isActive:
|
|
1225
|
-
disabled: J
|
|
1223
|
+
run: (e) => N(e, ve) || nt(e),
|
|
1224
|
+
isActive: rt,
|
|
1225
|
+
disabled: Y(J, yt("u"), bt),
|
|
1226
1226
|
keys: ["Mod-u"]
|
|
1227
1227
|
},
|
|
1228
|
-
|
|
1228
|
+
Z("code", "Inline code", "`"),
|
|
1229
1229
|
{
|
|
1230
1230
|
id: "codeBlock",
|
|
1231
1231
|
title: "Code block",
|
|
1232
|
-
run: (e) =>
|
|
1233
|
-
isActive: (e) =>
|
|
1234
|
-
disabled:
|
|
1232
|
+
run: (e) => N(e, (e, t, n) => A(e, t, n, "`")) || (W(e.state) ? R(e, "`") : Ve(e)),
|
|
1233
|
+
isActive: (e) => W(e) ? z(e, "`") : I(e),
|
|
1234
|
+
disabled: Y(q, L, K)
|
|
1235
1235
|
},
|
|
1236
1236
|
{
|
|
1237
1237
|
id: "link",
|
|
1238
1238
|
title: "Link",
|
|
1239
|
-
run: (e) =>
|
|
1240
|
-
isActive:
|
|
1241
|
-
disabled:
|
|
1239
|
+
run: (e) => N(e, pe) || Xe(e),
|
|
1240
|
+
isActive: Ze,
|
|
1241
|
+
disabled: J,
|
|
1242
1242
|
keys: ["Mod-k"]
|
|
1243
1243
|
},
|
|
1244
1244
|
{
|
|
1245
1245
|
id: "wikilink",
|
|
1246
1246
|
title: "Wikilink",
|
|
1247
|
-
run: (e) =>
|
|
1248
|
-
isActive:
|
|
1249
|
-
disabled:
|
|
1247
|
+
run: (e) => N(e, ge) || $e(e),
|
|
1248
|
+
isActive: et,
|
|
1249
|
+
disabled: J,
|
|
1250
1250
|
keys: ["Mod-Shift-k"]
|
|
1251
1251
|
},
|
|
1252
|
-
Q("quote", "Blockquote",
|
|
1253
|
-
Q("bulletList", "Bulleted list",
|
|
1254
|
-
Q("orderedList", "Numbered list",
|
|
1255
|
-
Q("task", "Task list",
|
|
1252
|
+
Q("quote", "Blockquote", xt),
|
|
1253
|
+
Q("bulletList", "Bulleted list", St, K),
|
|
1254
|
+
Q("orderedList", "Numbered list", Ct, K),
|
|
1255
|
+
Q("task", "Task list", wt, K),
|
|
1256
1256
|
{
|
|
1257
1257
|
id: "hr",
|
|
1258
1258
|
title: "Divider",
|
|
1259
1259
|
run: Mt,
|
|
1260
1260
|
isActive: Nt,
|
|
1261
|
-
disabled:
|
|
1261
|
+
disabled: Y(W, J)
|
|
1262
1262
|
},
|
|
1263
1263
|
{
|
|
1264
1264
|
id: "frontmatter",
|
|
1265
1265
|
title: "Frontmatter",
|
|
1266
1266
|
run: kt,
|
|
1267
1267
|
isActive: At,
|
|
1268
|
-
disabled:
|
|
1268
|
+
disabled: Y(W, I, L, K)
|
|
1269
1269
|
},
|
|
1270
1270
|
{
|
|
1271
1271
|
id: "table",
|
|
1272
1272
|
title: "Table",
|
|
1273
|
-
run:
|
|
1274
|
-
isActive:
|
|
1275
|
-
disabled:
|
|
1273
|
+
run: mt,
|
|
1274
|
+
isActive: W,
|
|
1275
|
+
disabled: Y(W, q, I, L, K)
|
|
1276
1276
|
},
|
|
1277
|
-
|
|
1277
|
+
Z("math", "Inline math", "$"),
|
|
1278
1278
|
{
|
|
1279
1279
|
id: "mathBlock",
|
|
1280
1280
|
title: "Block math",
|
|
1281
|
-
run: (e) =>
|
|
1282
|
-
isActive: (e) =>
|
|
1283
|
-
disabled:
|
|
1281
|
+
run: (e) => N(e, (e, t, n) => A(e, t, n, "$")) || (W(e.state) ? R(e, "$") : Ge(e)),
|
|
1282
|
+
isActive: (e) => W(e) ? z(e, "$") : L(e),
|
|
1283
|
+
disabled: Y(q, I, K)
|
|
1284
1284
|
}
|
|
1285
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) => ({
|
|
1286
1286
|
key: t,
|
|
@@ -1327,7 +1327,7 @@ function Zt(e, t) {
|
|
|
1327
1327
|
};
|
|
1328
1328
|
}
|
|
1329
1329
|
function Qt(e, t) {
|
|
1330
|
-
return e ? [
|
|
1330
|
+
return e ? [le(), y.data.of({ autocomplete: Zt(e, t) })] : [];
|
|
1331
1331
|
}
|
|
1332
1332
|
//#endregion
|
|
1333
1333
|
//#region src/editor/theme.ts
|
|
@@ -1347,7 +1347,11 @@ var $t = a.theme({
|
|
|
1347
1347
|
".cm-cursor, .cm-dropCursor": { borderLeftColor: "var(--stylo-text)" },
|
|
1348
1348
|
"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": { backgroundColor: "color-mix(in srgb, var(--stylo-accent) 15%, transparent)" },
|
|
1349
1349
|
".cm-placeholder": { color: "var(--stylo-text-muted)" },
|
|
1350
|
-
".cm-gutters": {
|
|
1350
|
+
".cm-gutters": {
|
|
1351
|
+
backgroundColor: "transparent",
|
|
1352
|
+
color: "var(--stylo-text-muted)",
|
|
1353
|
+
border: "none"
|
|
1354
|
+
},
|
|
1351
1355
|
".cm-panels": { color: "var(--stylo-text)" },
|
|
1352
1356
|
".cm-panels.cm-panels-top": { background: "var(--stylo-bg)" },
|
|
1353
1357
|
".stylo-search-panel": {
|
|
@@ -1474,22 +1478,22 @@ function nn(e, t) {
|
|
|
1474
1478
|
};
|
|
1475
1479
|
}
|
|
1476
1480
|
function rn(e, t) {
|
|
1477
|
-
return e ? [
|
|
1481
|
+
return e ? [le(), y.data.of({ autocomplete: nn(e, t) })] : [];
|
|
1478
1482
|
}
|
|
1479
1483
|
//#endregion
|
|
1480
1484
|
//#region src/editor/extensions.ts
|
|
1481
1485
|
function an(e, n, r, i) {
|
|
1482
1486
|
return [
|
|
1483
|
-
|
|
1484
|
-
o.of([...te, ...
|
|
1485
|
-
m.high(
|
|
1487
|
+
ne(),
|
|
1488
|
+
o.of([...te, ...h]),
|
|
1489
|
+
m.high(_t),
|
|
1486
1490
|
Jt,
|
|
1487
|
-
|
|
1488
|
-
|
|
1491
|
+
vt,
|
|
1492
|
+
D({
|
|
1489
1493
|
top: !0,
|
|
1490
1494
|
createPanel: Gt
|
|
1491
1495
|
}),
|
|
1492
|
-
o.of(
|
|
1496
|
+
o.of(ie),
|
|
1493
1497
|
v({
|
|
1494
1498
|
base: y,
|
|
1495
1499
|
codeLanguages: e
|
|
@@ -1512,18 +1516,18 @@ function on(e) {
|
|
|
1512
1516
|
//#endregion
|
|
1513
1517
|
//#region src/editor/useCodeMirror.ts
|
|
1514
1518
|
var sn = l.define();
|
|
1515
|
-
function cn({ value: e, onChange: t, readOnly: n = !1, placeholder: s, onSave: c, onViewChange: l, extensions: u,
|
|
1516
|
-
let g = i(null), _ = i(null),
|
|
1517
|
-
|
|
1518
|
-
let
|
|
1519
|
-
|
|
1520
|
-
let b = i((e) =>
|
|
1519
|
+
function cn({ value: e, onChange: t, readOnly: n = !1, placeholder: s, onSave: c, onViewChange: l, extensions: u, hostExtensions: f, codeLanguages: ee, wikiLinkSource: te, tagSource: ne, onResolveError: h }) {
|
|
1520
|
+
let g = i(null), _ = i(null), v = i(t);
|
|
1521
|
+
v.current = t;
|
|
1522
|
+
let y = i([]), re = i(c);
|
|
1523
|
+
re.current = c;
|
|
1524
|
+
let b = i((e) => re.current?.(e)).current, x = i(h);
|
|
1521
1525
|
x.current = h;
|
|
1522
1526
|
let S = i((e, t) => {
|
|
1523
1527
|
x.current?.(e, t);
|
|
1524
1528
|
}).current, C = c != null, w = i(l);
|
|
1525
1529
|
w.current = l;
|
|
1526
|
-
let T = i(new d());
|
|
1530
|
+
let T = i(new d()), E = i(new d()), D = i(f);
|
|
1527
1531
|
return r(() => {
|
|
1528
1532
|
let t = g.current;
|
|
1529
1533
|
if (!t) return;
|
|
@@ -1532,7 +1536,7 @@ function cn({ value: e, onChange: t, readOnly: n = !1, placeholder: s, onSave: c
|
|
|
1532
1536
|
state: p.create({
|
|
1533
1537
|
doc: e,
|
|
1534
1538
|
extensions: [
|
|
1535
|
-
an(
|
|
1539
|
+
an(ee, te, S, ne),
|
|
1536
1540
|
T.current.of(on({
|
|
1537
1541
|
readOnly: n,
|
|
1538
1542
|
placeholder: s,
|
|
@@ -1543,10 +1547,11 @@ function cn({ value: e, onChange: t, readOnly: n = !1, placeholder: s, onSave: c
|
|
|
1543
1547
|
run: Ft
|
|
1544
1548
|
}])),
|
|
1545
1549
|
...u ?? [],
|
|
1550
|
+
E.current.of(f ?? []),
|
|
1546
1551
|
a.updateListener.of((e) => {
|
|
1547
1552
|
if (!e.docChanged || e.transactions.some((e) => !!e.annotation(sn))) return;
|
|
1548
1553
|
let t = e.state.doc.toString();
|
|
1549
|
-
|
|
1554
|
+
y.current.push(t), y.current.length > 20 && y.current.shift(), v.current(t);
|
|
1550
1555
|
})
|
|
1551
1556
|
]
|
|
1552
1557
|
})
|
|
@@ -1558,14 +1563,14 @@ function cn({ value: e, onChange: t, readOnly: n = !1, placeholder: s, onSave: c
|
|
|
1558
1563
|
let t = _.current;
|
|
1559
1564
|
if (!t) return;
|
|
1560
1565
|
let n = t.state.doc.toString();
|
|
1561
|
-
n !== e && (
|
|
1566
|
+
n !== e && (y.current.includes(e) || (t.dispatch({
|
|
1562
1567
|
changes: {
|
|
1563
1568
|
from: 0,
|
|
1564
1569
|
to: n.length,
|
|
1565
1570
|
insert: e
|
|
1566
1571
|
},
|
|
1567
1572
|
annotations: sn.of(!0)
|
|
1568
|
-
}),
|
|
1573
|
+
}), y.current = []));
|
|
1569
1574
|
}, [e]), r(() => {
|
|
1570
1575
|
_.current?.dispatch({ effects: T.current.reconfigure(on({
|
|
1571
1576
|
readOnly: n,
|
|
@@ -1577,9 +1582,12 @@ function cn({ value: e, onChange: t, readOnly: n = !1, placeholder: s, onSave: c
|
|
|
1577
1582
|
s,
|
|
1578
1583
|
C,
|
|
1579
1584
|
b
|
|
1580
|
-
]),
|
|
1585
|
+
]), r(() => {
|
|
1586
|
+
let e = D.current;
|
|
1587
|
+
e !== f && (e && f && e.length === f.length && e.every((e, t) => e === f[t]) || (D.current = f, _.current?.dispatch({ effects: E.current.reconfigure(f ?? []) })));
|
|
1588
|
+
}, [f]), g;
|
|
1581
1589
|
}
|
|
1582
1590
|
//#endregion
|
|
1583
|
-
export {
|
|
1591
|
+
export { je as C, he as D, me as E, fe as O, Pe as S, ke as T, Re as _, X as a, M as b, wt as c, B as d, V as f, Fe as g, I as h, St as i, de as k, Ot as l, He as m, qt as n, Ct as o, Ke as p, Mt as r, xt as s, cn as t, ft as u, De as v, Oe as w, Ae as x, Me as y };
|
|
1584
1592
|
|
|
1585
|
-
//# sourceMappingURL=useCodeMirror-
|
|
1593
|
+
//# sourceMappingURL=useCodeMirror-Fn6qEfMx.js.map
|