@futaba-soft/mbox 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +80 -2
- package/dist/create-editor-BKTpQ8TK.js +2866 -0
- package/dist/editor/create-editor.d.ts +100 -0
- package/dist/editor/document-cache.d.ts +20 -0
- package/dist/editor/focused-line.d.ts +14 -0
- package/dist/editor/plugin.d.ts +191 -0
- package/dist/editor/test-context.d.ts +28 -0
- package/dist/gfm.d.ts +34 -0
- package/dist/gfm.js +1719 -0
- package/dist/hatena.d.ts +32 -0
- package/dist/hatena.js +856 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +77 -0
- package/dist/plugin-DI0ubB-M.js +297 -0
- package/dist/plugins/bracket-pair-kit.d.ts +9 -0
- package/dist/plugins/code-block-kit.d.ts +77 -0
- package/dist/plugins/code-block-language-loader.d.ts +33 -0
- package/dist/plugins/gfm/active-lines.d.ts +11 -0
- package/dist/plugins/gfm/code-block.d.ts +28 -0
- package/dist/plugins/gfm/footnote.d.ts +17 -0
- package/dist/plugins/gfm/heading.d.ts +12 -0
- package/dist/plugins/gfm/image.d.ts +30 -0
- package/dist/plugins/gfm/index.d.ts +19 -0
- package/dist/plugins/gfm/inline-code.d.ts +4 -0
- package/dist/plugins/gfm/inline.d.ts +4 -0
- package/dist/plugins/gfm/link.d.ts +34 -0
- package/dist/plugins/gfm/list.d.ts +32 -0
- package/dist/plugins/gfm/math.d.ts +39 -0
- package/dist/plugins/gfm/parser-cache.d.ts +3 -0
- package/dist/plugins/gfm/parser.d.ts +355 -0
- package/dist/plugins/gfm/quote.d.ts +3 -0
- package/dist/plugins/gfm/table.d.ts +34 -0
- package/dist/plugins/gfm/thematic-break.d.ts +9 -0
- package/dist/plugins/hatena/blockquote.d.ts +12 -0
- package/dist/plugins/hatena/definition.d.ts +5 -0
- package/dist/plugins/hatena/footnote.d.ts +15 -0
- package/dist/plugins/hatena/heading.d.ts +8 -0
- package/dist/plugins/hatena/index.d.ts +12 -0
- package/dist/plugins/hatena/link.d.ts +16 -0
- package/dist/plugins/hatena/list.d.ts +24 -0
- package/dist/plugins/hatena/parser-cache.d.ts +5 -0
- package/dist/plugins/hatena/parser.d.ts +129 -0
- package/dist/plugins/hatena/pre.d.ts +3 -0
- package/dist/plugins/hatena/shared.d.ts +31 -0
- package/dist/plugins/hatena/super-pre.d.ts +23 -0
- package/dist/plugins/hatena/table.d.ts +12 -0
- package/dist/plugins/image-kit.d.ts +84 -0
- package/dist/plugins/inline-notation-kit.d.ts +39 -0
- package/dist/plugins/inline-style-kit.d.ts +38 -0
- package/dist/plugins/link-url.d.ts +1 -0
- package/dist/plugins/logical-lines.d.ts +18 -0
- package/dist/plugins/mbox/bracket.d.ts +4 -0
- package/dist/plugins/mbox/code-block.d.ts +32 -0
- package/dist/plugins/mbox/complete.d.ts +33 -0
- package/dist/plugins/mbox/default.d.ts +13 -0
- package/dist/plugins/mbox/emoji.d.ts +3 -0
- package/dist/plugins/mbox/footnote.d.ts +14 -0
- package/dist/plugins/mbox/heading.d.ts +10 -0
- package/dist/plugins/mbox/inline-code.d.ts +6 -0
- package/dist/plugins/mbox/inline-style.d.ts +7 -0
- package/dist/plugins/mbox/inline-visitor.d.ts +8 -0
- package/dist/plugins/mbox/list.d.ts +13 -0
- package/dist/plugins/mbox/markdown-image.d.ts +13 -0
- package/dist/plugins/mbox/page-link.d.ts +19 -0
- package/dist/plugins/mbox/paragraph.d.ts +6 -0
- package/dist/plugins/mbox/parser-cache.d.ts +3 -0
- package/dist/plugins/mbox/parser.d.ts +2 -0
- package/dist/plugins/mbox/quote.d.ts +5 -0
- package/dist/plugins/mbox/table.d.ts +13 -0
- package/dist/plugins/mbox/task-list.d.ts +19 -0
- package/dist/plugins/mbox/types.d.ts +172 -0
- package/dist/plugins/mbox/url-link.d.ts +3 -0
- package/dist/plugins/mbox/vertical-motion.d.ts +3 -0
- package/dist/plugins/pipe-table-row.d.ts +18 -0
- package/dist/plugins/scrapbox/bracket.d.ts +20 -0
- package/dist/plugins/scrapbox/code-block.d.ts +37 -0
- package/dist/plugins/scrapbox/command-line.d.ts +9 -0
- package/dist/plugins/scrapbox/complete.d.ts +58 -0
- package/dist/plugins/scrapbox/decoration.d.ts +16 -0
- package/dist/plugins/scrapbox/formula.d.ts +43 -0
- package/dist/plugins/scrapbox/image.d.ts +62 -0
- package/dist/plugins/scrapbox/indent.d.ts +40 -0
- package/dist/plugins/scrapbox/index.d.ts +41 -0
- package/dist/plugins/scrapbox/inline-code-highlight.d.ts +16 -0
- package/dist/plugins/scrapbox/inline-code.d.ts +7 -0
- package/dist/plugins/scrapbox/inline-scanner-kit.d.ts +66 -0
- package/dist/plugins/scrapbox/inline-walker.d.ts +2 -0
- package/dist/plugins/scrapbox/inline.d.ts +86 -0
- package/dist/plugins/scrapbox/link.d.ts +110 -0
- package/dist/plugins/scrapbox/list.d.ts +21 -0
- package/dist/plugins/scrapbox/parser-cache.d.ts +5 -0
- package/dist/plugins/scrapbox/parser.d.ts +65 -0
- package/dist/plugins/scrapbox/quote.d.ts +7 -0
- package/dist/plugins/scrapbox/table.d.ts +22 -0
- package/dist/plugins/scrapbox/title.d.ts +3 -0
- package/dist/plugins/scrapbox/visible-lines.d.ts +34 -0
- package/dist/plugins/table-kit.d.ts +142 -0
- package/dist/plugins/task-checkbox-kit.d.ts +18 -0
- package/dist/scrapbox.d.ts +42 -0
- package/dist/scrapbox.js +1903 -0
- package/dist/testing.d.ts +2 -0
- package/dist/testing.js +13 -0
- package/dist/themes/code-token-presentation.d.ts +6 -0
- package/dist/themes/default-presentation.d.ts +4 -0
- package/dist/themes/gfm-presentation.d.ts +15 -0
- package/dist/themes/hatena-presentation.d.ts +10 -0
- package/dist/themes/heading-presentation.d.ts +18 -0
- package/dist/themes/scrapbox-presentation.d.ts +10 -0
- package/docs/guide.md +297 -0
- package/package.json +121 -4
package/dist/scrapbox.js
ADDED
|
@@ -0,0 +1,1903 @@
|
|
|
1
|
+
import { aE as We, ah as Lt, aj as wt, am as Pe, an as $t, C as It, aF as Et, az as Tt, a as Mt, b as vt, ax as Bt, ay as Ot, aG as Wt, al as Pt, ap as At, aq as Ft, ar as Rt, aD as Dt, at as Ut, as as Ht, av as zt, n as qt, aw as Kt } from "./create-editor-BKTpQ8TK.js";
|
|
2
|
+
import { c as B } from "./plugin-DI0ubB-M.js";
|
|
3
|
+
import { completionKeymap as Vt, autocompletion as Qt, moveCompletionSelection as jt, completionStatus as Gt, pickedCompletion as _t, insertCompletionText as Yt, closeCompletion as Jt } from "@codemirror/autocomplete";
|
|
4
|
+
import { EditorView as Ae, WidgetType as E, ViewPlugin as Xt } from "@codemirror/view";
|
|
5
|
+
import { EditorSelection as U } from "@codemirror/state";
|
|
6
|
+
const Zt = { open: "[", close: "]" };
|
|
7
|
+
function en() {
|
|
8
|
+
return We(Zt);
|
|
9
|
+
}
|
|
10
|
+
function tn(e) {
|
|
11
|
+
return "createScanner" in e;
|
|
12
|
+
}
|
|
13
|
+
function nn(e) {
|
|
14
|
+
return e instanceof RegExp ? new RegExp(e.source, e.flags.includes("g") ? e.flags : `${e.flags}g`) : tn(e) ? e.createScanner() : e;
|
|
15
|
+
}
|
|
16
|
+
function on(e) {
|
|
17
|
+
return "resolve" in e ? e.resolve() : e[0];
|
|
18
|
+
}
|
|
19
|
+
function m(e) {
|
|
20
|
+
let t = -1, n = -1, r = Number.POSITIVE_INFINITY;
|
|
21
|
+
return (o) => {
|
|
22
|
+
if (o >= r) return -1;
|
|
23
|
+
if (n !== -1 && t <= o && o <= n) return n;
|
|
24
|
+
const s = e(o);
|
|
25
|
+
return s === -1 ? (r = Math.min(r, o), -1) : (t = o, n = s, s);
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const rn = "(?:png|jpe?g|gif|svg|webp)", sn = "https?://gyazo\\.com/[0-9a-f]{32}", an = `${sn}(?:/raw)?`, cn = `(?:https?://[^\\s\\[\\]]+\\.${rn}(?:\\?[^\\[\\]\\s]+)?|${an})`, ln = /`.*?`/, un = new RegExp(`\\[\\[${cn}\\]\\]`, "i"), S = (e) => /\s/.test(e), Fe = (e, t) => {
|
|
29
|
+
for (let n = t; n < e.length; n += 1) {
|
|
30
|
+
const r = e[n];
|
|
31
|
+
if (r === `
|
|
32
|
+
` || r === "\r" || r === "\u2028" || r === "\u2029") return n;
|
|
33
|
+
}
|
|
34
|
+
return -1;
|
|
35
|
+
};
|
|
36
|
+
function k(e, t, n) {
|
|
37
|
+
for (let r = 0; r < n.length; r += 1) {
|
|
38
|
+
const o = e.charCodeAt(t + r);
|
|
39
|
+
if ((o >= 65 && o <= 90 ? o + 32 : o) !== n.charCodeAt(r)) return !1;
|
|
40
|
+
}
|
|
41
|
+
return !0;
|
|
42
|
+
}
|
|
43
|
+
function Re(e, t) {
|
|
44
|
+
return k(e, t, "http://") ? 7 : k(e, t, "https://") ? 8 : 0;
|
|
45
|
+
}
|
|
46
|
+
function pn(e, t) {
|
|
47
|
+
return t >= 4 && k(e, t - 4, ".png") || t >= 4 && k(e, t - 4, ".jpg") || t >= 5 && k(e, t - 5, ".jpeg") || t >= 4 && k(e, t - 4, ".gif") || t >= 4 && k(e, t - 4, ".svg") || t >= 5 && k(e, t - 5, ".webp");
|
|
48
|
+
}
|
|
49
|
+
function mn(e) {
|
|
50
|
+
const t = e.charCodeAt(0);
|
|
51
|
+
return t >= 48 && t <= 57 || t >= 65 && t <= 70 || t >= 97 && t <= 102;
|
|
52
|
+
}
|
|
53
|
+
function fn(e, t, n, r) {
|
|
54
|
+
const o = n >= 4 && k(e, n - 4, "/raw") ? 4 : 0, s = n - o, a = s - 32, c = "gyazo.com/", l = a - c.length;
|
|
55
|
+
if (l < t + r || !k(e, l, c)) return !1;
|
|
56
|
+
for (let u = a; u < s; u += 1)
|
|
57
|
+
if (!mn(e[u])) return !1;
|
|
58
|
+
return l === t + r;
|
|
59
|
+
}
|
|
60
|
+
function X(e, t, n, r) {
|
|
61
|
+
const o = Re(e, t);
|
|
62
|
+
if (o === 0) return !1;
|
|
63
|
+
const s = r(t + o), a = s !== -1 && s < n ? s : n;
|
|
64
|
+
return (a === n || s + 1 < n) && pn(e, a) ? !0 : fn(e, t, n, o);
|
|
65
|
+
}
|
|
66
|
+
function $e(e, t, n) {
|
|
67
|
+
const r = Re(e, t), o = e.indexOf("[", t);
|
|
68
|
+
return r !== 0 && n > t + r && (o === -1 || o >= n);
|
|
69
|
+
}
|
|
70
|
+
function se(e, t = !1) {
|
|
71
|
+
return {
|
|
72
|
+
createScanner() {
|
|
73
|
+
let n = "";
|
|
74
|
+
const r = t ? "[[" : "[", o = t ? "]]" : "]", s = (p, f) => p.startsWith(o, f) && (!t || p[f + o.length] !== "]"), a = (p) => {
|
|
75
|
+
for (let f = p; f < n.length; f += 1)
|
|
76
|
+
if (S(n[f])) return f;
|
|
77
|
+
return -1;
|
|
78
|
+
}, c = (p) => {
|
|
79
|
+
for (let f = p; f < n.length; f += 1)
|
|
80
|
+
if (!S(n[f])) return f;
|
|
81
|
+
return -1;
|
|
82
|
+
};
|
|
83
|
+
let l = m((p) => n.indexOf(o, p)), u = m((p) => n.indexOf("?", p)), i = m(a), d = m(c);
|
|
84
|
+
const b = (p) => {
|
|
85
|
+
n = p, l = m((f) => n.indexOf(o, f)), u = m((f) => n.indexOf("?", f)), i = m(a), d = m(c);
|
|
86
|
+
}, N = (p) => {
|
|
87
|
+
const f = l(p), h = i(p);
|
|
88
|
+
return f === -1 ? h : h === -1 ? f : Math.min(f, h);
|
|
89
|
+
};
|
|
90
|
+
return {
|
|
91
|
+
exec(p, f) {
|
|
92
|
+
p !== n && b(p);
|
|
93
|
+
let h = p.indexOf(r, f);
|
|
94
|
+
for (; h !== -1; ) {
|
|
95
|
+
const L = h + r.length, g = N(L);
|
|
96
|
+
if (g === -1) return null;
|
|
97
|
+
const Le = !e && X(p, L, g, u), St = e && $e(p, L, g);
|
|
98
|
+
if (s(p, g)) {
|
|
99
|
+
if (Le && !t) {
|
|
100
|
+
const we = g;
|
|
101
|
+
return { index: h, resolve: () => p.slice(h, we + o.length) };
|
|
102
|
+
}
|
|
103
|
+
h = p.indexOf(r, h + 1);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (!Le && !St || !S(p[g])) {
|
|
107
|
+
h = p.indexOf(r, h + 1);
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
const F = d(g);
|
|
111
|
+
if (F === -1) return null;
|
|
112
|
+
const T = N(F);
|
|
113
|
+
if (T !== -1 && s(p, T) && (e ? X(p, F, T, u) : $e(p, F, T))) {
|
|
114
|
+
const yt = T;
|
|
115
|
+
return { index: h, resolve: () => p.slice(h, yt + o.length) };
|
|
116
|
+
}
|
|
117
|
+
h = p.indexOf(r, h + 1);
|
|
118
|
+
}
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
const dn = se(!1), bn = se(!0), hn = se(!1, !0), xn = `!"#%&'()*+,-./{|}<>_~`, gn = {
|
|
126
|
+
exec(e, t) {
|
|
127
|
+
let n = e.indexOf("[", t);
|
|
128
|
+
for (; n !== -1; ) {
|
|
129
|
+
let r = n + 1;
|
|
130
|
+
for (; xn.includes(e[r]); ) r += 1;
|
|
131
|
+
if (r === n + 1 || e[r] !== " ") {
|
|
132
|
+
n = e.indexOf("[", n + 1);
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
let o = r + 1, s = !1, a = -1, c = -1;
|
|
136
|
+
for (; o < e.length; ) {
|
|
137
|
+
if (e[o] === "]") {
|
|
138
|
+
if (s && (c = o), a === -1 || a === o - 1) break;
|
|
139
|
+
a = -1, o += 1;
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
s = !0, e[o] === "[" && (a = o), o += 1;
|
|
143
|
+
}
|
|
144
|
+
if (c !== -1) return { 0: e.slice(n, c + 1), index: n };
|
|
145
|
+
if (o === e.length) return null;
|
|
146
|
+
n = e.indexOf("[", n + 1);
|
|
147
|
+
}
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
}, kn = {
|
|
151
|
+
createScanner() {
|
|
152
|
+
let e = "", t = (s) => Fe(e, s), n = m((s) => e.indexOf(" ]", s)), r = m((s) => e.indexOf("]", s));
|
|
153
|
+
const o = (s) => {
|
|
154
|
+
e = s;
|
|
155
|
+
const a = m((i) => e.indexOf(`
|
|
156
|
+
`, i)), c = m((i) => e.indexOf("\r", i)), l = m((i) => e.indexOf("\u2028", i)), u = m((i) => e.indexOf("\u2029", i));
|
|
157
|
+
t = (i) => {
|
|
158
|
+
const d = [a(i), c(i), l(i), u(i)].filter(
|
|
159
|
+
(b) => b !== -1
|
|
160
|
+
);
|
|
161
|
+
return d.length === 0 ? -1 : Math.min(...d);
|
|
162
|
+
}, n = m((i) => e.indexOf(" ]", i)), r = m((i) => e.indexOf("]", i));
|
|
163
|
+
};
|
|
164
|
+
return {
|
|
165
|
+
exec(s, a) {
|
|
166
|
+
s !== e && o(s);
|
|
167
|
+
let c = s.indexOf("[$ ", a);
|
|
168
|
+
for (; c !== -1; ) {
|
|
169
|
+
const l = c + 3, u = t(l), i = n(l), d = r(l), b = i !== -1 && (u === -1 || i + 1 < u), N = d !== -1 && (u === -1 || d < u);
|
|
170
|
+
if (b || N) {
|
|
171
|
+
const p = b ? i + 1 : d;
|
|
172
|
+
return { 0: s.slice(c, p + 1), index: c };
|
|
173
|
+
}
|
|
174
|
+
if (u === -1) return null;
|
|
175
|
+
c = s.indexOf("[$ ", Math.max(c + 1, u + 1));
|
|
176
|
+
}
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
}, Cn = {
|
|
182
|
+
createScanner() {
|
|
183
|
+
let e = "", t = (o) => Fe(e, o), n = m((o) => e.indexOf("]]", o));
|
|
184
|
+
const r = (o) => {
|
|
185
|
+
e = o;
|
|
186
|
+
const s = m((u) => e.indexOf(`
|
|
187
|
+
`, u)), a = m((u) => e.indexOf("\r", u)), c = m((u) => e.indexOf("\u2028", u)), l = m((u) => e.indexOf("\u2029", u));
|
|
188
|
+
t = (u) => {
|
|
189
|
+
const i = [s(u), a(u), c(u), l(u)].filter(
|
|
190
|
+
(d) => d !== -1
|
|
191
|
+
);
|
|
192
|
+
return i.length === 0 ? -1 : Math.min(...i);
|
|
193
|
+
}, n = m((u) => e.indexOf("]]", u));
|
|
194
|
+
};
|
|
195
|
+
return {
|
|
196
|
+
exec(o, s) {
|
|
197
|
+
o !== e && r(o);
|
|
198
|
+
let a = o.indexOf("[[", s);
|
|
199
|
+
for (; a !== -1; ) {
|
|
200
|
+
let c = a + 2;
|
|
201
|
+
if (o[c] === "[") {
|
|
202
|
+
if (o[c + 1] === "[" || c + 1 >= o.length) {
|
|
203
|
+
a = o.indexOf("[[", a + 1);
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
c += 2;
|
|
207
|
+
} else {
|
|
208
|
+
if (c >= o.length)
|
|
209
|
+
return null;
|
|
210
|
+
c += 1;
|
|
211
|
+
}
|
|
212
|
+
const l = t(c), u = n(c);
|
|
213
|
+
if (u === -1 || l !== -1 && l < u) {
|
|
214
|
+
if (l === -1) return null;
|
|
215
|
+
a = o.indexOf("[[", Math.max(a + 1, l - 3));
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
let i = u + 2;
|
|
219
|
+
for (; o[i] === "]"; ) i += 1;
|
|
220
|
+
return { 0: o.slice(a, i), index: a };
|
|
221
|
+
}
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
}, Nn = {
|
|
227
|
+
exec(e, t) {
|
|
228
|
+
let n = e.indexOf("[", t);
|
|
229
|
+
for (; n !== -1; ) {
|
|
230
|
+
const r = n + 1, o = e.startsWith("http://", r) ? 7 : e.startsWith("https://", r) ? 8 : 0;
|
|
231
|
+
if (o === 0) {
|
|
232
|
+
n = e.indexOf("[", n + 1);
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
let s = r;
|
|
236
|
+
for (; s < e.length && !S(e[s]) && e[s] !== "[" && e[s] !== "]"; )
|
|
237
|
+
s += 1;
|
|
238
|
+
if (s <= r + o || s === e.length || !S(e[s])) {
|
|
239
|
+
n = e.indexOf("[", n + 1);
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
let a = s;
|
|
243
|
+
for (; a < e.length && S(e[a]); ) a += 1;
|
|
244
|
+
let c = e.indexOf("]", a);
|
|
245
|
+
if (c === -1) return null;
|
|
246
|
+
if (e[c + 1] === "]" && (c += 1), !S(e[c - 1])) return { 0: e.slice(n, c + 1), index: n };
|
|
247
|
+
n = e.indexOf("[", c + 1);
|
|
248
|
+
}
|
|
249
|
+
return null;
|
|
250
|
+
}
|
|
251
|
+
}, Sn = /\[[^[\]]*[^\s]\s+https?:\/\/[^\s\[\]]+\]/, yn = /\[https?:\/\/[^\s\[\]]+\]/, Ln = {
|
|
252
|
+
createScanner() {
|
|
253
|
+
let e = "", t = m((o) => e.indexOf("http://", o)), n = m((o) => e.indexOf("https://", o));
|
|
254
|
+
const r = (o) => {
|
|
255
|
+
e = o, t = m((s) => e.indexOf("http://", s)), n = m((s) => e.indexOf("https://", s));
|
|
256
|
+
};
|
|
257
|
+
return {
|
|
258
|
+
exec(o, s) {
|
|
259
|
+
o !== e && r(o);
|
|
260
|
+
let a = t(s), c = n(s);
|
|
261
|
+
for (; a !== -1 || c !== -1; ) {
|
|
262
|
+
const l = c === -1 || a !== -1 && a < c ? a : c, u = l === a ? 7 : 8;
|
|
263
|
+
if (l + u < o.length && !S(o[l + u]))
|
|
264
|
+
return {
|
|
265
|
+
index: l,
|
|
266
|
+
resolve: () => {
|
|
267
|
+
let i = l + u;
|
|
268
|
+
for (; i < o.length && !S(o[i]); ) i += 1;
|
|
269
|
+
return o.slice(l, i);
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
l === a ? a = t(l + 1) : c = n(l + 1);
|
|
273
|
+
}
|
|
274
|
+
return null;
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
}, De = /\[\/?[^[\]]+\.icon(?:[x*](?:[1-9]|1\d|20))?\]/, wn = /\[\/?[^[\]]+\]/, Ue = "#(?=\\S*[^#\\s])\\S+", He = new RegExp(`(?<=^|\\s)${Ue}`), $n = new RegExp(`^${Ue}$`);
|
|
279
|
+
function In(e) {
|
|
280
|
+
return $n.test(e);
|
|
281
|
+
}
|
|
282
|
+
function Z(e, t) {
|
|
283
|
+
return { type: "text", from: t, to: t + e.length, value: e };
|
|
284
|
+
}
|
|
285
|
+
function En(e) {
|
|
286
|
+
const t = new Set(e);
|
|
287
|
+
if (t.has("*")) {
|
|
288
|
+
const n = e.split("*").length - 1;
|
|
289
|
+
t.delete("*"), t.add(`*-${Math.min(n, 10)}`);
|
|
290
|
+
}
|
|
291
|
+
return [...t];
|
|
292
|
+
}
|
|
293
|
+
function Tn(e, t) {
|
|
294
|
+
const n = t + e.length;
|
|
295
|
+
return {
|
|
296
|
+
type: "code",
|
|
297
|
+
from: t,
|
|
298
|
+
to: n,
|
|
299
|
+
openingMarker: { from: t, to: t + 1 },
|
|
300
|
+
closingMarker: { from: n - 1, to: n },
|
|
301
|
+
content: { from: t + 1, to: n - 1 },
|
|
302
|
+
value: e.slice(1, -1)
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
function Mn(e, t) {
|
|
306
|
+
const n = t + e.length, r = e.indexOf(" "), o = e.slice(1, r), s = t + r + 1, a = n - 1;
|
|
307
|
+
return {
|
|
308
|
+
type: "decoration",
|
|
309
|
+
from: t,
|
|
310
|
+
to: n,
|
|
311
|
+
rawDecos: o,
|
|
312
|
+
decos: En(o),
|
|
313
|
+
openingMarker: { from: t, to: s },
|
|
314
|
+
closingMarker: { from: a, to: n },
|
|
315
|
+
content: { from: s, to: a },
|
|
316
|
+
children: ae(e.slice(r + 1, -1), s, !0)
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
function vn(e, t) {
|
|
320
|
+
const n = t + e.length, r = t + 2, o = n - 2, s = e.slice(2, -2), a = `[${s}]`, l = De.exec(a)?.[0] === a ? ze(a, r - 1) : void 0;
|
|
321
|
+
return {
|
|
322
|
+
type: "strong",
|
|
323
|
+
from: t,
|
|
324
|
+
to: n,
|
|
325
|
+
openingMarker: { from: t, to: r },
|
|
326
|
+
closingMarker: { from: o, to: n },
|
|
327
|
+
content: { from: r, to: o },
|
|
328
|
+
children: l === void 0 ? ae(s, r, !0) : [{ ...l, from: r, to: o }]
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
function Bn(e, t) {
|
|
332
|
+
const n = t + e.length, r = e.slice(1, -1);
|
|
333
|
+
return {
|
|
334
|
+
type: "internalLink",
|
|
335
|
+
from: t,
|
|
336
|
+
to: n,
|
|
337
|
+
pathType: r.startsWith("/") ? "root" : "relative",
|
|
338
|
+
href: r,
|
|
339
|
+
openingMarker: { from: t, to: t + 1 },
|
|
340
|
+
closingMarker: { from: n - 1, to: n },
|
|
341
|
+
target: { from: t + 1, to: n - 1 }
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
function On(e, t) {
|
|
345
|
+
const n = e.startsWith("[") && e.endsWith("]"), r = n ? e.slice(1, -1) : e, o = n ? t + 1 : t, s = (n ? /^https?:\/\/[^\s\[\]]/ : /^https?:\/\/[^\s\]]/).test(r), a = (s ? n ? /^https?:\/\/[^\s\[\]]+/ : /^https?:\/\/[^\s\]]+/ : n ? /https?:\/\/[^\s\[\]]+$/ : /https?:\/\/[^\s\]]+$/).exec(r);
|
|
346
|
+
if (a === null) return Z(e, t);
|
|
347
|
+
const c = a[0], l = o + a.index, u = { from: l, to: l + c.length }, i = s ? r.slice(c.length) : r.slice(0, a.index - 1), d = s ? o + c.length : o, b = i.trim(), N = i.length - i.trimStart().length, p = b.length > 0 ? { from: d + N, to: d + N + b.length } : null;
|
|
348
|
+
return {
|
|
349
|
+
type: "externalLink",
|
|
350
|
+
from: t,
|
|
351
|
+
to: t + e.length,
|
|
352
|
+
bracketed: n,
|
|
353
|
+
href: c,
|
|
354
|
+
content: b,
|
|
355
|
+
hrefRange: u,
|
|
356
|
+
contentRange: p
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
function Ie(e, t) {
|
|
360
|
+
const n = e.startsWith("[[") ? 2 : 1, r = e.search(/\s/), o = r === -1 ? e.slice(n, -n) : e.slice(n, r), s = r === -1 ? "" : e.slice(r, -n).replace(/^\s+/, ""), a = m((u) => s.indexOf("?", u)), [c, l] = X(s, 0, s.length, a) ? [s, o] : [o, s];
|
|
361
|
+
return { type: "image", from: t, to: t + e.length, src: c, link: l };
|
|
362
|
+
}
|
|
363
|
+
function Wn(e, t) {
|
|
364
|
+
return { type: "strongImage", from: t, to: t + e.length, src: e.slice(2, -2) };
|
|
365
|
+
}
|
|
366
|
+
function Pn(e, t) {
|
|
367
|
+
const n = t + e.length, r = e.length > 4 && e.at(-2) === " ", o = n - (r ? 2 : 1);
|
|
368
|
+
return {
|
|
369
|
+
type: "formula",
|
|
370
|
+
from: t,
|
|
371
|
+
to: n,
|
|
372
|
+
expression: e.slice(3, r ? -2 : -1),
|
|
373
|
+
content: { from: t + 3, to: o }
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
function ze(e, t) {
|
|
377
|
+
const n = e.slice(1, -1), r = n.match(/[x*](\d+)$/), o = r === null ? 1 : Number(r[1]), s = n.replace(/[x*]\d+$/, "").replace(/\.icon$/, "");
|
|
378
|
+
return {
|
|
379
|
+
type: "icon",
|
|
380
|
+
from: t,
|
|
381
|
+
to: t + e.length,
|
|
382
|
+
path: s,
|
|
383
|
+
pathType: s.startsWith("/") ? "root" : "relative",
|
|
384
|
+
repeatCount: o
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
function An(e, t) {
|
|
388
|
+
const n = t + e.length;
|
|
389
|
+
return {
|
|
390
|
+
type: "hashTag",
|
|
391
|
+
from: t,
|
|
392
|
+
to: n,
|
|
393
|
+
href: e.slice(1),
|
|
394
|
+
marker: { from: t, to: t + 1 },
|
|
395
|
+
target: { from: t + 1, to: n }
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
const Fn = [
|
|
399
|
+
{ nestedAllowed: !1, patterns: [ln], create: Tn },
|
|
400
|
+
{ nestedAllowed: !1, patterns: [gn], create: Mn },
|
|
401
|
+
{ nestedAllowed: !0, patterns: [kn], create: Pn },
|
|
402
|
+
{ nestedAllowed: !1, patterns: [un], create: Wn },
|
|
403
|
+
{ nestedAllowed: !1, patterns: [hn], create: Ie },
|
|
404
|
+
{ nestedAllowed: !1, patterns: [Cn], create: vn },
|
|
405
|
+
{ nestedAllowed: !0, patterns: [dn, bn], create: Ie },
|
|
406
|
+
{
|
|
407
|
+
nestedAllowed: !0,
|
|
408
|
+
patterns: [Nn, Sn, yn, Ln],
|
|
409
|
+
create: On
|
|
410
|
+
},
|
|
411
|
+
{ nestedAllowed: !0, patterns: [De], create: ze },
|
|
412
|
+
{ nestedAllowed: !0, patterns: [wn], create: Bn },
|
|
413
|
+
{ nestedAllowed: !0, patterns: [He], create: An }
|
|
414
|
+
];
|
|
415
|
+
function Rn(e, t = 0) {
|
|
416
|
+
return ae(e, t, !1);
|
|
417
|
+
}
|
|
418
|
+
function ae(e, t, n) {
|
|
419
|
+
const r = Fn.flatMap(
|
|
420
|
+
(a) => n && !a.nestedAllowed ? [] : a.patterns.map((c) => {
|
|
421
|
+
const l = {
|
|
422
|
+
pattern: nn(c),
|
|
423
|
+
next: null,
|
|
424
|
+
initialized: !1
|
|
425
|
+
};
|
|
426
|
+
return { matcher: a, scanner: l };
|
|
427
|
+
})
|
|
428
|
+
), o = [];
|
|
429
|
+
let s = 0;
|
|
430
|
+
for (; s < e.length; ) {
|
|
431
|
+
let a = null;
|
|
432
|
+
for (const { matcher: u, scanner: i } of r) {
|
|
433
|
+
(!i.initialized || i.next !== null && i.next.index < s) && (i.pattern instanceof RegExp ? (i.pattern.lastIndex = s, i.next = i.pattern.exec(e)) : i.next = i.pattern.exec(e, s), i.initialized = !0);
|
|
434
|
+
const d = i.next;
|
|
435
|
+
if (d !== null && (a === null || d.index < a.match.index) && (a = { matcher: u, match: d }), i.pattern instanceof RegExp && i.pattern.source === He.source && e[s] === "#") {
|
|
436
|
+
let b = s + 1;
|
|
437
|
+
for (; b < e.length && !/\s/.test(e[b]); ) b += 1;
|
|
438
|
+
b > s + 1 && In(e.slice(s, b)) && (a === null || s < a.match.index) && (a = { matcher: u, match: { index: s, resolve: () => e.slice(s, b) } });
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
if (a === null) {
|
|
442
|
+
o.push(Z(e.slice(s), t + s));
|
|
443
|
+
break;
|
|
444
|
+
}
|
|
445
|
+
const c = on(a.match), l = a.match.index;
|
|
446
|
+
l > s && o.push(Z(e.slice(s, l), t + s)), o.push(a.matcher.create(c, t + l)), s = l + c.length;
|
|
447
|
+
}
|
|
448
|
+
return o;
|
|
449
|
+
}
|
|
450
|
+
function Dn(e, t) {
|
|
451
|
+
const n = t.numberMarker ? t.numberMarker.to : t.content.from;
|
|
452
|
+
return Rn(e.slice(n, t.logicalTo), n);
|
|
453
|
+
}
|
|
454
|
+
const Un = /^\s+/, Ee = "table:", Hn = /^(\d+)\. /, R = "code:";
|
|
455
|
+
function zn(e) {
|
|
456
|
+
const t = Lt(e), n = [];
|
|
457
|
+
for (const a of t) {
|
|
458
|
+
const { text: c, from: l, to: u, logicalTo: i } = a, d = Un.exec(c)?.[0].length ?? 0, b = l + d, N = { from: b, to: i }, p = c.slice(d), f = Hn.exec(p);
|
|
459
|
+
let h = "none", L = null, g = null;
|
|
460
|
+
f ? (h = "number", L = Number.parseInt(f[1], 10), g = { from: b, to: b + f[0].length }) : d >= 1 && (h = "bullet"), n.push({
|
|
461
|
+
line: a.line,
|
|
462
|
+
from: l,
|
|
463
|
+
to: u,
|
|
464
|
+
logicalTo: i,
|
|
465
|
+
indent: d,
|
|
466
|
+
listType: h,
|
|
467
|
+
marker: { from: l, to: b },
|
|
468
|
+
content: N,
|
|
469
|
+
number: L,
|
|
470
|
+
numberMarker: g,
|
|
471
|
+
inline: []
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
const { codeBlocks: r, tableBlocks: o } = qn(e, n), s = ce(r);
|
|
475
|
+
for (const a of n)
|
|
476
|
+
s.has(a.line) || (a.inline = Dn(e, a));
|
|
477
|
+
return { lines: n, codeBlocks: r, tableBlocks: o };
|
|
478
|
+
}
|
|
479
|
+
function qn(e, t) {
|
|
480
|
+
const n = [], r = [];
|
|
481
|
+
let o = 0;
|
|
482
|
+
for (; o < t.length; ) {
|
|
483
|
+
const s = t[o], a = e.slice(s.content.from, s.logicalTo), c = a.startsWith(R), l = a.startsWith(Ee);
|
|
484
|
+
if (!c && !l) {
|
|
485
|
+
o += 1;
|
|
486
|
+
continue;
|
|
487
|
+
}
|
|
488
|
+
const u = [];
|
|
489
|
+
let i = o + 1;
|
|
490
|
+
for (; i < t.length && t[i].indent > s.indent; )
|
|
491
|
+
u.push(t[i]), i += 1;
|
|
492
|
+
c ? n.push({
|
|
493
|
+
type: "codeBlock",
|
|
494
|
+
kind: a.slice(R.length) === "tex" || a.slice(R.length) === "latex" ? "formula" : "code",
|
|
495
|
+
indent: s.indent,
|
|
496
|
+
fileName: a.slice(R.length),
|
|
497
|
+
openerLine: s,
|
|
498
|
+
bodyLines: u
|
|
499
|
+
}) : r.push({
|
|
500
|
+
type: "table",
|
|
501
|
+
indent: s.indent,
|
|
502
|
+
name: a.slice(Ee.length),
|
|
503
|
+
openerLine: s,
|
|
504
|
+
bodyLines: u
|
|
505
|
+
}), o = i;
|
|
506
|
+
}
|
|
507
|
+
return { codeBlocks: n, tableBlocks: r };
|
|
508
|
+
}
|
|
509
|
+
function ce(e) {
|
|
510
|
+
const t = /* @__PURE__ */ new Set();
|
|
511
|
+
for (const n of e) {
|
|
512
|
+
t.add(n.openerLine.line);
|
|
513
|
+
for (const r of n.bodyLines)
|
|
514
|
+
t.add(r.line);
|
|
515
|
+
}
|
|
516
|
+
return t;
|
|
517
|
+
}
|
|
518
|
+
function qe(e) {
|
|
519
|
+
return ce(e.codeBlocks);
|
|
520
|
+
}
|
|
521
|
+
function Kn(e) {
|
|
522
|
+
return ce(e.tableBlocks);
|
|
523
|
+
}
|
|
524
|
+
const Ke = wt(zn);
|
|
525
|
+
function $(e) {
|
|
526
|
+
return Ke.getEntry(e);
|
|
527
|
+
}
|
|
528
|
+
function x(e) {
|
|
529
|
+
return Ke.get(e);
|
|
530
|
+
}
|
|
531
|
+
const P = "mbox-scrapbox-code-block", Ve = "mbox-scrapbox-code-block-opener", Qe = "mbox-scrapbox-code-block-body", ie = "mbox-scrapbox-code-block-keyword", je = "mbox-scrapbox-code-block-filename", Ge = "mbox-scrapbox-code-block-language-label", _e = "mbox-scrapbox-code-block-copy-button", le = "mbox-scrapbox-code-block-token", Vn = 5, Fr = {
|
|
532
|
+
codeBlock: P,
|
|
533
|
+
opener: Ve,
|
|
534
|
+
body: Qe,
|
|
535
|
+
keyword: ie,
|
|
536
|
+
fileName: je,
|
|
537
|
+
languageLabel: Ge,
|
|
538
|
+
copyButton: _e,
|
|
539
|
+
token: le
|
|
540
|
+
};
|
|
541
|
+
function Ye(e, t) {
|
|
542
|
+
return t.bodyLines.map((n) => {
|
|
543
|
+
const r = n.from + t.indent + 1;
|
|
544
|
+
return { from: r, to: n.logicalTo, text: e.slice(r, n.logicalTo) };
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
function Qn(e, t) {
|
|
548
|
+
return e.codeBlocks.flatMap((n) => {
|
|
549
|
+
if (n.kind === "formula") return [];
|
|
550
|
+
const r = n.openerLine, o = r.content.from + Vn, s = [
|
|
551
|
+
{
|
|
552
|
+
type: "line",
|
|
553
|
+
from: r.from,
|
|
554
|
+
className: `${P} ${Ve}`
|
|
555
|
+
},
|
|
556
|
+
{ type: "mark", from: r.content.from, to: o, className: ie }
|
|
557
|
+
];
|
|
558
|
+
r.logicalTo > o && s.push({
|
|
559
|
+
type: "mark",
|
|
560
|
+
from: o,
|
|
561
|
+
to: r.logicalTo,
|
|
562
|
+
className: `${je} ${Ge}`
|
|
563
|
+
}), s.push({
|
|
564
|
+
type: "widget",
|
|
565
|
+
from: r.to,
|
|
566
|
+
widget: new It(
|
|
567
|
+
Ye(t, n).map((a) => a.text).join(`
|
|
568
|
+
`),
|
|
569
|
+
_e
|
|
570
|
+
),
|
|
571
|
+
side: 1
|
|
572
|
+
});
|
|
573
|
+
for (const a of n.bodyLines)
|
|
574
|
+
s.push({
|
|
575
|
+
type: "line",
|
|
576
|
+
from: a.from,
|
|
577
|
+
className: `${P} ${Qe}`
|
|
578
|
+
});
|
|
579
|
+
return s;
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
function jn(e) {
|
|
583
|
+
return e.codeBlocks.filter((t) => t.kind === "code").map((t) => t.fileName);
|
|
584
|
+
}
|
|
585
|
+
function Gn() {
|
|
586
|
+
return {
|
|
587
|
+
theme: {
|
|
588
|
+
[`.${P}`]: {
|
|
589
|
+
fontFamily: 'var(--mbox-code-block-font-family, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace)'
|
|
590
|
+
}
|
|
591
|
+
},
|
|
592
|
+
name: "scrapbox/code-block",
|
|
593
|
+
decorations: (e) => {
|
|
594
|
+
const { input: t, document: n } = $(e.state);
|
|
595
|
+
return Qn(n, t);
|
|
596
|
+
}
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
function Te(e, t, n) {
|
|
600
|
+
return e.codeBlocks.flatMap((r) => {
|
|
601
|
+
if (r.kind === "formula")
|
|
602
|
+
return [];
|
|
603
|
+
const o = n(r.fileName);
|
|
604
|
+
return o ? $t(Ye(t, r), o, le) : [];
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
function _n(e = {}) {
|
|
608
|
+
if (!e.languages)
|
|
609
|
+
return {
|
|
610
|
+
name: "scrapbox/code-block-highlight",
|
|
611
|
+
decorations: (n) => {
|
|
612
|
+
const { input: r, document: o } = $(n.state);
|
|
613
|
+
return Te(o, r, Et);
|
|
614
|
+
}
|
|
615
|
+
};
|
|
616
|
+
const t = Pe(
|
|
617
|
+
(n) => jn(x(n)),
|
|
618
|
+
{
|
|
619
|
+
...e.languages === "all" ? {} : { languages: e.languages },
|
|
620
|
+
onLoadError: e.onLoadError,
|
|
621
|
+
infoValueKind: "fileName"
|
|
622
|
+
}
|
|
623
|
+
);
|
|
624
|
+
return {
|
|
625
|
+
extensions: [t.extension],
|
|
626
|
+
name: "scrapbox/code-block-highlight",
|
|
627
|
+
decorations: (n) => {
|
|
628
|
+
const { input: r, document: o } = $(n.state);
|
|
629
|
+
return Te(o, r, t.getLanguage);
|
|
630
|
+
}
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
function C(e) {
|
|
634
|
+
const t = qe(e);
|
|
635
|
+
for (const n of Kn(e))
|
|
636
|
+
t.add(n);
|
|
637
|
+
return t;
|
|
638
|
+
}
|
|
639
|
+
function Yn(e) {
|
|
640
|
+
const t = qe(e);
|
|
641
|
+
for (const n of e.tableBlocks)
|
|
642
|
+
t.add(n.openerLine.line);
|
|
643
|
+
return t;
|
|
644
|
+
}
|
|
645
|
+
function Jn(e, t) {
|
|
646
|
+
const n = C(e);
|
|
647
|
+
for (const r of t)
|
|
648
|
+
n.add(r);
|
|
649
|
+
return n;
|
|
650
|
+
}
|
|
651
|
+
const Je = "mbox-scrapbox-command-line", Xn = "mbox-scrapbox-command-prompt", Xe = "mbox-scrapbox-command", Rr = {
|
|
652
|
+
line: Je,
|
|
653
|
+
command: Xe
|
|
654
|
+
}, Zn = /* @__PURE__ */ new Set(["$", "%"]);
|
|
655
|
+
function eo(e, t, n) {
|
|
656
|
+
const r = C(t);
|
|
657
|
+
return t.lines.flatMap((o) => {
|
|
658
|
+
if (!(Zn.has(e[o.content.from]) && e[o.content.from + 1] === " ") || r.has(o.line))
|
|
659
|
+
return [];
|
|
660
|
+
const a = o.content.from + 2;
|
|
661
|
+
return [
|
|
662
|
+
{ type: "line", from: o.from, className: Je },
|
|
663
|
+
{ type: "mark", from: o.content.from, to: o.content.from + 1, className: Xn },
|
|
664
|
+
...a < o.content.to ? [B(a, o.content.to, Xe)] : []
|
|
665
|
+
];
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
function to() {
|
|
669
|
+
return {
|
|
670
|
+
name: "scrapbox/command-line",
|
|
671
|
+
decorations: (e) => {
|
|
672
|
+
const { input: t, document: n } = $(e.state);
|
|
673
|
+
return eo(t, n, e.activeLineNumbers);
|
|
674
|
+
}
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
const ee = "scrapbox-completion-option", ue = "scrapbox-completion-option-with-preview", pe = "scrapbox-completion-preview", me = "scrapbox-completion-preview-image", Dr = {
|
|
678
|
+
option: ee,
|
|
679
|
+
optionWithPreview: ue,
|
|
680
|
+
preview: pe,
|
|
681
|
+
previewImage: me
|
|
682
|
+
}, no = {
|
|
683
|
+
[`.cm-tooltip-autocomplete ul li.${ue}`]: {
|
|
684
|
+
alignItems: "center",
|
|
685
|
+
display: "flex",
|
|
686
|
+
gap: "8px"
|
|
687
|
+
},
|
|
688
|
+
[`.${pe}`]: {
|
|
689
|
+
display: "inline-flex",
|
|
690
|
+
flex: "0 0 auto",
|
|
691
|
+
marginLeft: "auto"
|
|
692
|
+
},
|
|
693
|
+
[`.${me}`]: {
|
|
694
|
+
borderRadius: "2px",
|
|
695
|
+
width: "24px",
|
|
696
|
+
height: "24px",
|
|
697
|
+
objectFit: "contain"
|
|
698
|
+
}
|
|
699
|
+
}, oo = /\[[^[\]]*$/, ro = /(?:^|\s)(#[^\s#[\]]*)$/;
|
|
700
|
+
function Ze(e, t) {
|
|
701
|
+
const n = e.slice(0, t), r = oo.exec(n);
|
|
702
|
+
if (r) {
|
|
703
|
+
const s = r.index, a = n.slice(s + 1), c = e[t] === "]" ? t + 1 : t;
|
|
704
|
+
return { kind: "bracket", query: a, from: s, to: c };
|
|
705
|
+
}
|
|
706
|
+
const o = ro.exec(n);
|
|
707
|
+
if (o) {
|
|
708
|
+
const s = o[1];
|
|
709
|
+
return { kind: "hash", query: s.slice(1), from: n.length - s.length, to: t };
|
|
710
|
+
}
|
|
711
|
+
return null;
|
|
712
|
+
}
|
|
713
|
+
function so(e, t) {
|
|
714
|
+
return t === "bracket" ? `[${e}]` : `#${e}`;
|
|
715
|
+
}
|
|
716
|
+
function ao(e) {
|
|
717
|
+
return `[${e}.icon]`;
|
|
718
|
+
}
|
|
719
|
+
function co(e) {
|
|
720
|
+
return (t) => {
|
|
721
|
+
const n = t.state.doc.lineAt(t.pos), r = x(t.state);
|
|
722
|
+
if (C(r).has(n.number)) return null;
|
|
723
|
+
const o = Ze(n.text, t.pos - n.from);
|
|
724
|
+
if (!o) return null;
|
|
725
|
+
const s = e(o.query, o.kind);
|
|
726
|
+
return s.length === 0 ? null : {
|
|
727
|
+
from: n.from + o.from,
|
|
728
|
+
to: n.from + o.to,
|
|
729
|
+
filter: !1,
|
|
730
|
+
options: s.map(
|
|
731
|
+
(a) => ({
|
|
732
|
+
label: a.title,
|
|
733
|
+
apply: so(a.title, o.kind),
|
|
734
|
+
type: "text",
|
|
735
|
+
iconUrl: a.iconUrl
|
|
736
|
+
})
|
|
737
|
+
)
|
|
738
|
+
};
|
|
739
|
+
};
|
|
740
|
+
}
|
|
741
|
+
function io(e, t, n) {
|
|
742
|
+
const { iconUrl: r } = e;
|
|
743
|
+
if (!r) return null;
|
|
744
|
+
const o = document.createElement("span");
|
|
745
|
+
o.className = pe;
|
|
746
|
+
const s = document.createElement("img");
|
|
747
|
+
return s.className = me, s.src = r, s.alt = "", s.setAttribute("aria-hidden", "true"), s.addEventListener("mousedown", (a) => {
|
|
748
|
+
a.preventDefault(), a.stopPropagation();
|
|
749
|
+
const c = n ?? Ae.findFromDOM(o);
|
|
750
|
+
if (!c) return;
|
|
751
|
+
const l = c.state.selection.main.head, u = c.state.doc.lineAt(l), i = Ze(u.text, l - u.from);
|
|
752
|
+
i?.kind === "bracket" && (c.dispatch({
|
|
753
|
+
...Yt(
|
|
754
|
+
c.state,
|
|
755
|
+
ao(e.label),
|
|
756
|
+
u.from + i.from,
|
|
757
|
+
u.from + i.to
|
|
758
|
+
),
|
|
759
|
+
annotations: _t.of(e)
|
|
760
|
+
}), Jt(c));
|
|
761
|
+
}), o.appendChild(s), o;
|
|
762
|
+
}
|
|
763
|
+
function lo(e) {
|
|
764
|
+
const { iconUrl: t } = e;
|
|
765
|
+
return t ? `${ee} ${ue}` : ee;
|
|
766
|
+
}
|
|
767
|
+
function Me(e, t) {
|
|
768
|
+
return jt(t)(e) || Gt(e.state) !== null;
|
|
769
|
+
}
|
|
770
|
+
function uo(e = {}) {
|
|
771
|
+
const { recommend: t } = e;
|
|
772
|
+
return {
|
|
773
|
+
extensions: t ? [
|
|
774
|
+
Qt({
|
|
775
|
+
icons: !1,
|
|
776
|
+
override: [co(t)],
|
|
777
|
+
addToOptions: [{ position: 90, render: io }],
|
|
778
|
+
optionClass: lo
|
|
779
|
+
})
|
|
780
|
+
] : [],
|
|
781
|
+
keymap: [
|
|
782
|
+
{ key: "Tab", run: (n) => Me(n, !0) },
|
|
783
|
+
{ key: "Shift-Tab", run: (n) => Me(n, !1) },
|
|
784
|
+
...Vt
|
|
785
|
+
],
|
|
786
|
+
theme: no
|
|
787
|
+
};
|
|
788
|
+
}
|
|
789
|
+
function y(e, t) {
|
|
790
|
+
return e.flatMap((n) => [
|
|
791
|
+
...t(n),
|
|
792
|
+
...n.type === "decoration" || n.type === "strong" ? y(n.children, t) : []
|
|
793
|
+
]);
|
|
794
|
+
}
|
|
795
|
+
const fe = "mbox-scrapbox-code", I = "mbox-scrapbox-strong", K = "mbox-scrapbox-em", V = "mbox-scrapbox-strikethrough", Q = "mbox-scrapbox-underline", po = "mbox-scrapbox-decoration", de = "mbox-scrapbox-strong-level", Ur = {
|
|
796
|
+
strong: I,
|
|
797
|
+
em: K,
|
|
798
|
+
strikethrough: V,
|
|
799
|
+
underline: Q,
|
|
800
|
+
code: fe
|
|
801
|
+
};
|
|
802
|
+
function M(e, t) {
|
|
803
|
+
return [B(e.from, e.to, t)];
|
|
804
|
+
}
|
|
805
|
+
function w(e) {
|
|
806
|
+
return [{ type: "replace", from: e.from, to: e.to }];
|
|
807
|
+
}
|
|
808
|
+
function mo(e) {
|
|
809
|
+
const t = [po];
|
|
810
|
+
for (const n of e)
|
|
811
|
+
n.startsWith("*-") ? t.push(I, `${de}-${n.slice(2)}`) : n === "/" ? t.push(K) : n === "-" ? t.push(V) : n === "_" && t.push(Q);
|
|
812
|
+
return t.join(" ");
|
|
813
|
+
}
|
|
814
|
+
function fo(e) {
|
|
815
|
+
const t = [];
|
|
816
|
+
for (const n of e)
|
|
817
|
+
n.startsWith("*-") ? t.push(I, `${de}-${n.slice(2)}`) : n === "/" ? t.push(K) : n === "-" ? t.push(V) : n === "_" && t.push(Q);
|
|
818
|
+
return t.join(" ");
|
|
819
|
+
}
|
|
820
|
+
function bo(e, t) {
|
|
821
|
+
switch (e.type) {
|
|
822
|
+
case "text":
|
|
823
|
+
return [];
|
|
824
|
+
case "code":
|
|
825
|
+
return t ? [] : [
|
|
826
|
+
...w(e.openingMarker),
|
|
827
|
+
...w(e.closingMarker),
|
|
828
|
+
...M(e.content, fe)
|
|
829
|
+
];
|
|
830
|
+
case "strong":
|
|
831
|
+
return t ? M(e.content, I) : [
|
|
832
|
+
...w(e.openingMarker),
|
|
833
|
+
...w(e.closingMarker),
|
|
834
|
+
...M(e.content, I)
|
|
835
|
+
];
|
|
836
|
+
case "decoration":
|
|
837
|
+
if (t) {
|
|
838
|
+
const n = fo(e.decos);
|
|
839
|
+
return n ? M(e.content, n) : [];
|
|
840
|
+
}
|
|
841
|
+
return [
|
|
842
|
+
...w(e.openingMarker),
|
|
843
|
+
...w(e.closingMarker),
|
|
844
|
+
...M(e.content, mo(e.decos))
|
|
845
|
+
];
|
|
846
|
+
default:
|
|
847
|
+
return [];
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
function ho(e, t) {
|
|
851
|
+
const n = C(e);
|
|
852
|
+
return e.lines.flatMap((r) => {
|
|
853
|
+
if (n.has(r.line)) return [];
|
|
854
|
+
const o = t.has(r.line);
|
|
855
|
+
return y(r.inline, (s) => bo(s, o));
|
|
856
|
+
});
|
|
857
|
+
}
|
|
858
|
+
function xo() {
|
|
859
|
+
return {
|
|
860
|
+
name: "scrapbox/decoration",
|
|
861
|
+
decorations: (e) => {
|
|
862
|
+
const t = x(e.state);
|
|
863
|
+
return ho(t, e.activeLineNumbers);
|
|
864
|
+
}
|
|
865
|
+
};
|
|
866
|
+
}
|
|
867
|
+
const et = "mbox-scrapbox-formula", be = "mbox-scrapbox-formula-block", tt = "mbox-scrapbox-formula-hidden-line", nt = "mbox-scrapbox-formula-source", Hr = {
|
|
868
|
+
formula: et,
|
|
869
|
+
block: be
|
|
870
|
+
};
|
|
871
|
+
class j extends E {
|
|
872
|
+
constructor(t, n, r = !1) {
|
|
873
|
+
super(), this.expression = t, this.render = n, this.block = r;
|
|
874
|
+
}
|
|
875
|
+
expression;
|
|
876
|
+
render;
|
|
877
|
+
block;
|
|
878
|
+
eq(t) {
|
|
879
|
+
return t instanceof j && this.expression === t.expression && this.render === t.render && this.block === t.block;
|
|
880
|
+
}
|
|
881
|
+
toDOM() {
|
|
882
|
+
const t = document.createElement("span");
|
|
883
|
+
if (t.className = `${et}${this.block ? ` ${be}` : ""}`, t.setAttribute("role", "math"), this.render) {
|
|
884
|
+
try {
|
|
885
|
+
t.appendChild(this.render(this.expression));
|
|
886
|
+
} catch {
|
|
887
|
+
return t.textContent = this.expression, t;
|
|
888
|
+
}
|
|
889
|
+
if (!this.render.providesAccessibleMath) {
|
|
890
|
+
const n = document.createElement("span");
|
|
891
|
+
n.className = nt, n.textContent = this.expression, t.appendChild(n);
|
|
892
|
+
}
|
|
893
|
+
} else
|
|
894
|
+
t.textContent = this.expression;
|
|
895
|
+
return t;
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
function go(e) {
|
|
899
|
+
return e.type === "formula" ? [{ from: e.from, to: e.to, expression: e.expression }] : [];
|
|
900
|
+
}
|
|
901
|
+
function ko(e, t, n, r = {}) {
|
|
902
|
+
const o = Jn(e, n), s = e.lines.flatMap(
|
|
903
|
+
(c) => o.has(c.line) ? [] : y(c.inline, go).map((l) => ({
|
|
904
|
+
type: "replace",
|
|
905
|
+
from: l.from,
|
|
906
|
+
to: l.to,
|
|
907
|
+
widget: new j(l.expression, r.render)
|
|
908
|
+
}))
|
|
909
|
+
);
|
|
910
|
+
return [...e.codeBlocks.flatMap(
|
|
911
|
+
(c) => c.kind === "formula" && !ot(c, n) ? No(c, t, r.render) : []
|
|
912
|
+
), ...s];
|
|
913
|
+
}
|
|
914
|
+
function ot(e, t) {
|
|
915
|
+
return t.has(e.openerLine.line) || e.bodyLines.some((n) => t.has(n.line));
|
|
916
|
+
}
|
|
917
|
+
function Co(e, t) {
|
|
918
|
+
return e.bodyLines.map((n) => t.slice(n.from + e.indent + 1, n.logicalTo)).join(`
|
|
919
|
+
`);
|
|
920
|
+
}
|
|
921
|
+
function No(e, t, n) {
|
|
922
|
+
const r = [{
|
|
923
|
+
type: "replace",
|
|
924
|
+
from: e.openerLine.from,
|
|
925
|
+
to: e.openerLine.logicalTo,
|
|
926
|
+
widget: new j(Co(e, t), n, !0)
|
|
927
|
+
}];
|
|
928
|
+
for (const o of e.bodyLines)
|
|
929
|
+
o.from < o.logicalTo && r.push({ type: "replace", from: o.from, to: o.logicalTo }), r.push({ type: "line", from: o.from, className: tt });
|
|
930
|
+
return r;
|
|
931
|
+
}
|
|
932
|
+
function So(e, t) {
|
|
933
|
+
return e.codeBlocks.flatMap((n) => {
|
|
934
|
+
if (n.kind !== "formula" || ot(n, t)) return [];
|
|
935
|
+
const r = n.bodyLines.at(-1) ?? n.openerLine;
|
|
936
|
+
return [{ from: n.openerLine.from, to: r.logicalTo }];
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
function yo(e = {}) {
|
|
940
|
+
return {
|
|
941
|
+
name: "scrapbox/formula",
|
|
942
|
+
theme: {
|
|
943
|
+
[`.${be}`]: {
|
|
944
|
+
display: "block"
|
|
945
|
+
},
|
|
946
|
+
[`.${tt}`]: {
|
|
947
|
+
display: "none"
|
|
948
|
+
},
|
|
949
|
+
[`.${nt}`]: {
|
|
950
|
+
border: "0",
|
|
951
|
+
clip: "rect(0 0 0 0)",
|
|
952
|
+
height: "1px",
|
|
953
|
+
margin: "-1px",
|
|
954
|
+
overflow: "hidden",
|
|
955
|
+
padding: "0",
|
|
956
|
+
position: "absolute",
|
|
957
|
+
whiteSpace: "nowrap",
|
|
958
|
+
width: "1px"
|
|
959
|
+
}
|
|
960
|
+
},
|
|
961
|
+
decorations: (t) => {
|
|
962
|
+
const n = x(t.state);
|
|
963
|
+
return ko(n, t.state.doc.toString(), t.activeLineNumbers, e);
|
|
964
|
+
},
|
|
965
|
+
decorationFirewallRanges: (t) => So(x(t.state), t.activeLineNumbers)
|
|
966
|
+
};
|
|
967
|
+
}
|
|
968
|
+
const Lo = "mbox-scrapbox-image", wo = "mbox-scrapbox-image-token", $o = "mbox-scrapbox-image-preview", Io = "mbox-scrapbox-image-element", rt = "mbox-scrapbox-image-strong", Eo = "mbox-scrapbox-image-measure", A = {
|
|
969
|
+
image: Lo,
|
|
970
|
+
token: wo,
|
|
971
|
+
preview: $o,
|
|
972
|
+
element: Io,
|
|
973
|
+
strong: rt
|
|
974
|
+
}, he = {
|
|
975
|
+
measure: Eo
|
|
976
|
+
}, To = {
|
|
977
|
+
renderMode: "token"
|
|
978
|
+
}, Mo = /^https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}$/i;
|
|
979
|
+
function vo(e) {
|
|
980
|
+
return Mo.test(e) ? `${e}/raw` : e;
|
|
981
|
+
}
|
|
982
|
+
class Bo extends vt {
|
|
983
|
+
constructor(t) {
|
|
984
|
+
super(t, A);
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
class Oo extends Mt {
|
|
988
|
+
constructor(t) {
|
|
989
|
+
super(t, A);
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
class Wo extends Tt {
|
|
993
|
+
constructor(t) {
|
|
994
|
+
super(t, A, he);
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
const Po = {
|
|
998
|
+
token: (e) => new Bo(e),
|
|
999
|
+
preview: (e) => new Oo(e),
|
|
1000
|
+
measure: (e) => new Wo(e)
|
|
1001
|
+
};
|
|
1002
|
+
function Ao(e, t) {
|
|
1003
|
+
switch (t.type) {
|
|
1004
|
+
case "image":
|
|
1005
|
+
return [{ from: t.from, to: t.to, src: e(t.src), text: t.src, link: t.link }];
|
|
1006
|
+
case "strongImage":
|
|
1007
|
+
return [
|
|
1008
|
+
{
|
|
1009
|
+
from: t.from,
|
|
1010
|
+
to: t.to,
|
|
1011
|
+
src: e(t.src),
|
|
1012
|
+
text: t.src,
|
|
1013
|
+
link: "",
|
|
1014
|
+
className: rt
|
|
1015
|
+
}
|
|
1016
|
+
];
|
|
1017
|
+
default:
|
|
1018
|
+
return [];
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
function Fo(e, t, n, r = {}) {
|
|
1022
|
+
const o = C(e), s = r.renderMode ?? To.renderMode, a = r.resolveSrc ?? vo;
|
|
1023
|
+
return e.lines.flatMap((c) => {
|
|
1024
|
+
if (o.has(c.line))
|
|
1025
|
+
return [];
|
|
1026
|
+
const l = n.has(c.line), u = y(c.inline, (i) => Ao(a, i));
|
|
1027
|
+
return Ot(
|
|
1028
|
+
u,
|
|
1029
|
+
l,
|
|
1030
|
+
t,
|
|
1031
|
+
A,
|
|
1032
|
+
he,
|
|
1033
|
+
s,
|
|
1034
|
+
Po
|
|
1035
|
+
);
|
|
1036
|
+
});
|
|
1037
|
+
}
|
|
1038
|
+
function Ro(e = {}) {
|
|
1039
|
+
return {
|
|
1040
|
+
theme: Bt(A, he),
|
|
1041
|
+
name: "scrapbox/image",
|
|
1042
|
+
decorations: (t) => {
|
|
1043
|
+
const n = x(t.state);
|
|
1044
|
+
return Fo(n, t.state.doc, t.activeLineNumbers, e);
|
|
1045
|
+
}
|
|
1046
|
+
};
|
|
1047
|
+
}
|
|
1048
|
+
const Do = /^\s+$/, Uo = " ", Ho = /^\s/, zo = /^\s*/;
|
|
1049
|
+
function st(e) {
|
|
1050
|
+
return zo.exec(e)?.[0].length ?? 0;
|
|
1051
|
+
}
|
|
1052
|
+
function at(e) {
|
|
1053
|
+
const t = /* @__PURE__ */ new Set();
|
|
1054
|
+
for (const n of e.selection.ranges) {
|
|
1055
|
+
const r = e.doc.lineAt(n.from), o = e.doc.lineAt(qo(n));
|
|
1056
|
+
for (let s = r.number; s <= o.number; s += 1)
|
|
1057
|
+
t.add(s);
|
|
1058
|
+
}
|
|
1059
|
+
return [...t].sort((n, r) => n - r).map((n) => e.doc.line(n));
|
|
1060
|
+
}
|
|
1061
|
+
function qo(e) {
|
|
1062
|
+
return e.empty ? e.to : Math.max(e.from, e.to - 1);
|
|
1063
|
+
}
|
|
1064
|
+
function Ko(e) {
|
|
1065
|
+
return { changes: at(e).map((n) => ({ from: n.from, insert: Uo })), userEvent: "input.indent", scrollIntoView: !0 };
|
|
1066
|
+
}
|
|
1067
|
+
function Vo(e) {
|
|
1068
|
+
const t = [];
|
|
1069
|
+
for (const n of at(e))
|
|
1070
|
+
Ho.test(e.doc.sliceString(n.from, n.to)) && t.push({ from: n.from, to: n.from + 1 });
|
|
1071
|
+
return t.length === 0 ? null : { changes: t, userEvent: "delete.dedent", scrollIntoView: !0 };
|
|
1072
|
+
}
|
|
1073
|
+
function Qo(e) {
|
|
1074
|
+
if (e.selection.ranges.length !== 1)
|
|
1075
|
+
return null;
|
|
1076
|
+
const t = e.selection.main;
|
|
1077
|
+
if (!t.empty)
|
|
1078
|
+
return null;
|
|
1079
|
+
const n = e.doc.lineAt(t.head), r = st(n.text), o = t.head - n.from;
|
|
1080
|
+
return o < 1 || o > r ? null : {
|
|
1081
|
+
changes: { from: t.head - 1, to: t.head },
|
|
1082
|
+
selection: U.cursor(t.head - 1),
|
|
1083
|
+
userEvent: "delete.backward",
|
|
1084
|
+
scrollIntoView: !0
|
|
1085
|
+
};
|
|
1086
|
+
}
|
|
1087
|
+
function jo(e) {
|
|
1088
|
+
let t = !1;
|
|
1089
|
+
const n = U.create(
|
|
1090
|
+
e.selection.ranges.map((r) => {
|
|
1091
|
+
const o = e.doc.lineAt(r.head), s = st(o.text);
|
|
1092
|
+
return s > 0 && (t = !0), U.cursor(o.from + s);
|
|
1093
|
+
}),
|
|
1094
|
+
e.selection.mainIndex
|
|
1095
|
+
);
|
|
1096
|
+
return !t || n.eq(e.selection) ? null : { selection: n, scrollIntoView: !0 };
|
|
1097
|
+
}
|
|
1098
|
+
function Go(e) {
|
|
1099
|
+
if (e.selection.ranges.length !== 1)
|
|
1100
|
+
return null;
|
|
1101
|
+
const t = e.selection.main;
|
|
1102
|
+
if (!t.empty)
|
|
1103
|
+
return null;
|
|
1104
|
+
const n = e.doc.lineAt(t.head);
|
|
1105
|
+
if (t.head !== n.to || !Do.test(n.text))
|
|
1106
|
+
return null;
|
|
1107
|
+
const r = x(e);
|
|
1108
|
+
return C(r).has(n.number) ? null : {
|
|
1109
|
+
changes: { from: n.from, to: n.to, insert: `
|
|
1110
|
+
` },
|
|
1111
|
+
selection: U.cursor(n.from + 1),
|
|
1112
|
+
userEvent: "input",
|
|
1113
|
+
scrollIntoView: !0
|
|
1114
|
+
};
|
|
1115
|
+
}
|
|
1116
|
+
function _o(e) {
|
|
1117
|
+
const t = Ko(e.state);
|
|
1118
|
+
return e.dispatch(e.state.update(t)), !0;
|
|
1119
|
+
}
|
|
1120
|
+
function Yo(e) {
|
|
1121
|
+
const t = Vo(e.state);
|
|
1122
|
+
return t ? (e.dispatch(e.state.update(t)), !0) : !1;
|
|
1123
|
+
}
|
|
1124
|
+
function ve(e) {
|
|
1125
|
+
const t = Qo(e.state);
|
|
1126
|
+
return t ? (e.dispatch(e.state.update(t)), !0) : !1;
|
|
1127
|
+
}
|
|
1128
|
+
function Jo(e) {
|
|
1129
|
+
const t = jo(e.state);
|
|
1130
|
+
return t ? (e.dispatch(e.state.update(t)), !0) : !1;
|
|
1131
|
+
}
|
|
1132
|
+
function Xo(e) {
|
|
1133
|
+
const t = Go(e.state);
|
|
1134
|
+
return t ? (e.dispatch(e.state.update(t)), !0) : !1;
|
|
1135
|
+
}
|
|
1136
|
+
function Zo() {
|
|
1137
|
+
return {
|
|
1138
|
+
keymap: [
|
|
1139
|
+
{ key: "Enter", run: Xo },
|
|
1140
|
+
{ key: "Tab", run: _o },
|
|
1141
|
+
{ key: "Shift-Tab", run: Yo },
|
|
1142
|
+
{ key: "Backspace", run: ve },
|
|
1143
|
+
{ key: "Ctrl-h", run: ve },
|
|
1144
|
+
{ key: "Ctrl-a", run: Jo }
|
|
1145
|
+
]
|
|
1146
|
+
};
|
|
1147
|
+
}
|
|
1148
|
+
const er = { open: "`", close: "`", requireNonEmptySelection: !0 };
|
|
1149
|
+
function tr() {
|
|
1150
|
+
return We(er);
|
|
1151
|
+
}
|
|
1152
|
+
const ct = "mbox-scrapbox-code-token", Y = "ruby";
|
|
1153
|
+
function nr(e) {
|
|
1154
|
+
const t = C(e);
|
|
1155
|
+
return e.lines.some((n) => t.has(n.line) ? !1 : y(n.inline, (r) => r.type === "code" ? [r] : []).length > 0);
|
|
1156
|
+
}
|
|
1157
|
+
function or(e) {
|
|
1158
|
+
return Xt.define(() => ({
|
|
1159
|
+
update(t) {
|
|
1160
|
+
t.docChanged && e.clear();
|
|
1161
|
+
}
|
|
1162
|
+
}));
|
|
1163
|
+
}
|
|
1164
|
+
function rr(e = {}) {
|
|
1165
|
+
const t = Pe(
|
|
1166
|
+
(o) => nr(x(o)) ? [Y] : [],
|
|
1167
|
+
{
|
|
1168
|
+
languages: [Y],
|
|
1169
|
+
onLoadError: e.onLoadError
|
|
1170
|
+
}
|
|
1171
|
+
), n = /* @__PURE__ */ new Map();
|
|
1172
|
+
function r(o) {
|
|
1173
|
+
if (o.type !== "code")
|
|
1174
|
+
return [];
|
|
1175
|
+
const s = t.getLanguage(Y);
|
|
1176
|
+
if (!s)
|
|
1177
|
+
return [];
|
|
1178
|
+
let a = n.get(o.value);
|
|
1179
|
+
a || (a = Wt(o.value, 0, s, ct), n.set(o.value, a));
|
|
1180
|
+
const c = o.content.from;
|
|
1181
|
+
return a.map((l) => ({ ...l, from: l.from + c, to: l.to + c }));
|
|
1182
|
+
}
|
|
1183
|
+
return {
|
|
1184
|
+
extensions: [t.extension, or(n)],
|
|
1185
|
+
name: "scrapbox/inline-code-highlight",
|
|
1186
|
+
decorations: (o) => {
|
|
1187
|
+
const s = x(o.state), a = C(s);
|
|
1188
|
+
return s.lines.flatMap((c) => a.has(c.line) ? [] : y(c.inline, r));
|
|
1189
|
+
}
|
|
1190
|
+
};
|
|
1191
|
+
}
|
|
1192
|
+
const H = "mbox-scrapbox-link", xe = "mbox-scrapbox-url", ge = "mbox-scrapbox-hashtag", O = "mbox-scrapbox-icon", te = "mbox-scrapbox-icon-image", ke = "mbox-scrapbox-icon-strong", it = "mbox-scrapbox-icon-strong-measure", lt = "mbox-scrapbox-page-missing", zr = {
|
|
1193
|
+
link: H,
|
|
1194
|
+
url: xe,
|
|
1195
|
+
hashTag: ge,
|
|
1196
|
+
icon: O,
|
|
1197
|
+
strongIcon: ke,
|
|
1198
|
+
pageMissing: lt
|
|
1199
|
+
};
|
|
1200
|
+
class W extends E {
|
|
1201
|
+
constructor(t, n, r, o) {
|
|
1202
|
+
super(), this.href = t, this.text = n, this.className = r, this.external = o;
|
|
1203
|
+
}
|
|
1204
|
+
href;
|
|
1205
|
+
text;
|
|
1206
|
+
className;
|
|
1207
|
+
external;
|
|
1208
|
+
eq(t) {
|
|
1209
|
+
return t instanceof W && this.href === t.href && this.text === t.text && this.className === t.className && this.external === t.external;
|
|
1210
|
+
}
|
|
1211
|
+
toDOM() {
|
|
1212
|
+
return Pt({
|
|
1213
|
+
href: this.href,
|
|
1214
|
+
text: this.text,
|
|
1215
|
+
className: this.className,
|
|
1216
|
+
attributes: this.external ? { target: "_blank", rel: "noreferrer" } : void 0
|
|
1217
|
+
});
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
class G extends E {
|
|
1221
|
+
constructor(t, n, r, o = 1, s = !1) {
|
|
1222
|
+
super(), this.href = t, this.name = n, this.iconUrl = r, this.repeatCount = o, this.strong = s;
|
|
1223
|
+
}
|
|
1224
|
+
href;
|
|
1225
|
+
name;
|
|
1226
|
+
iconUrl;
|
|
1227
|
+
repeatCount;
|
|
1228
|
+
strong;
|
|
1229
|
+
eq(t) {
|
|
1230
|
+
return t instanceof G && this.href === t.href && this.name === t.name && this.iconUrl === t.iconUrl && this.repeatCount === t.repeatCount && this.strong === t.strong;
|
|
1231
|
+
}
|
|
1232
|
+
toDOM() {
|
|
1233
|
+
const t = document.createElement("a");
|
|
1234
|
+
if (t.className = O, t.setAttribute("href", this.href), t.setAttribute("title", this.name), this.iconUrl) {
|
|
1235
|
+
const r = document.createElement("img");
|
|
1236
|
+
r.className = te, r.src = this.iconUrl, r.alt = this.name, t.appendChild(r);
|
|
1237
|
+
} else
|
|
1238
|
+
t.textContent = this.name;
|
|
1239
|
+
if (this.repeatCount === 1 && !this.strong) return t;
|
|
1240
|
+
const n = document.createElement("span");
|
|
1241
|
+
n.className = this.strong ? `${O} ${ke}` : O, n.append(t);
|
|
1242
|
+
for (let r = 1; r < this.repeatCount; r += 1) n.append(t.cloneNode(!0));
|
|
1243
|
+
return n;
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
class Ce extends E {
|
|
1247
|
+
eq(t) {
|
|
1248
|
+
return t instanceof Ce;
|
|
1249
|
+
}
|
|
1250
|
+
toDOM() {
|
|
1251
|
+
const t = document.createElement("span");
|
|
1252
|
+
return t.className = it, t.setAttribute("aria-hidden", "true"), t.style.pointerEvents = "none", t;
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
function v(e, t, n) {
|
|
1256
|
+
return { type: "replace", from: e, to: t, widget: n };
|
|
1257
|
+
}
|
|
1258
|
+
function D(e, t, n) {
|
|
1259
|
+
return n ? n(e) : t === "root" ? e.replace(/^[/\\\t\n\r]+/, "/") : `./${e}`;
|
|
1260
|
+
}
|
|
1261
|
+
function Be(e, t, n) {
|
|
1262
|
+
return n.pageExists?.(t) === !1 ? `${e} ${lt}` : e;
|
|
1263
|
+
}
|
|
1264
|
+
function sr(e) {
|
|
1265
|
+
switch (e.type) {
|
|
1266
|
+
case "icon":
|
|
1267
|
+
return (e.path.split("/").pop() ?? e.path).repeat(e.repeatCount);
|
|
1268
|
+
case "internalLink":
|
|
1269
|
+
return e.href;
|
|
1270
|
+
case "externalLink":
|
|
1271
|
+
return e.content || e.href;
|
|
1272
|
+
case "hashTag":
|
|
1273
|
+
return `#${e.href}`;
|
|
1274
|
+
default:
|
|
1275
|
+
return;
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
function ut(e) {
|
|
1279
|
+
return e.split("/").pop() ?? e;
|
|
1280
|
+
}
|
|
1281
|
+
function ar(e, t, n, r) {
|
|
1282
|
+
const o = y(t.inline, (c) => {
|
|
1283
|
+
const l = sr(c);
|
|
1284
|
+
return l !== void 0 && c.from >= n && c.to <= r ? [{ from: c.from, to: c.to, text: l }] : [];
|
|
1285
|
+
});
|
|
1286
|
+
if (o.length === 0) return;
|
|
1287
|
+
let s = n, a = "";
|
|
1288
|
+
for (const c of o)
|
|
1289
|
+
c.from < s || (a += e.slice(s, c.from) + c.text, s = c.to);
|
|
1290
|
+
return a + e.slice(s, r);
|
|
1291
|
+
}
|
|
1292
|
+
function cr(e, t, n) {
|
|
1293
|
+
switch (e.type) {
|
|
1294
|
+
case "icon": {
|
|
1295
|
+
if (n) return [];
|
|
1296
|
+
const r = D(e.path, e.pathType, t.pageUrl), o = ut(e.path);
|
|
1297
|
+
return [
|
|
1298
|
+
v(
|
|
1299
|
+
e.from,
|
|
1300
|
+
e.to,
|
|
1301
|
+
// Pass the raw icon name straight through; the consumer builds the URL.
|
|
1302
|
+
new G(r, o, t.iconUrl?.(e.path), e.repeatCount)
|
|
1303
|
+
)
|
|
1304
|
+
];
|
|
1305
|
+
}
|
|
1306
|
+
case "internalLink": {
|
|
1307
|
+
const r = Be(H, e.href, t);
|
|
1308
|
+
if (n) return [B(e.from, e.to, r)];
|
|
1309
|
+
const o = D(e.href, e.pathType, t.pageUrl);
|
|
1310
|
+
return [
|
|
1311
|
+
v(
|
|
1312
|
+
e.from,
|
|
1313
|
+
e.to,
|
|
1314
|
+
new W(o, e.href, r, !1)
|
|
1315
|
+
)
|
|
1316
|
+
];
|
|
1317
|
+
}
|
|
1318
|
+
case "externalLink": {
|
|
1319
|
+
const r = `${xe} ${H}`;
|
|
1320
|
+
return n ? [B(e.from, e.to, r)] : [
|
|
1321
|
+
v(
|
|
1322
|
+
e.from,
|
|
1323
|
+
e.to,
|
|
1324
|
+
new W(e.href, e.content || e.href, r, !0)
|
|
1325
|
+
)
|
|
1326
|
+
];
|
|
1327
|
+
}
|
|
1328
|
+
case "hashTag": {
|
|
1329
|
+
const r = Be(ge, e.href, t);
|
|
1330
|
+
return n ? [B(e.from, e.to, r)] : [
|
|
1331
|
+
v(
|
|
1332
|
+
e.from,
|
|
1333
|
+
e.to,
|
|
1334
|
+
new W(D(e.href, "relative", t.pageUrl), `#${e.href}`, r, !1)
|
|
1335
|
+
)
|
|
1336
|
+
];
|
|
1337
|
+
}
|
|
1338
|
+
default:
|
|
1339
|
+
return [];
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
function ir(e) {
|
|
1343
|
+
return e.type === "strong" && e.children.length === 1 && e.children[0]?.type === "icon";
|
|
1344
|
+
}
|
|
1345
|
+
function pt(e, t, n) {
|
|
1346
|
+
return e.flatMap((r) => {
|
|
1347
|
+
if (ir(r)) {
|
|
1348
|
+
const s = r.children[0];
|
|
1349
|
+
if (n) return [{ type: "widget", from: r.from, side: -1, widget: new Ce() }];
|
|
1350
|
+
const a = D(s.path, s.pathType, t.pageUrl), c = ut(s.path);
|
|
1351
|
+
return [v(r.from, r.to, new G(a, c, t.iconUrl?.(s.path), s.repeatCount, !0))];
|
|
1352
|
+
}
|
|
1353
|
+
const o = cr(r, t, n);
|
|
1354
|
+
return r.type === "decoration" || r.type === "strong" ? [...o, ...pt(r.children, t, n)] : o;
|
|
1355
|
+
});
|
|
1356
|
+
}
|
|
1357
|
+
function lr(e, t, n = {}) {
|
|
1358
|
+
const r = Yn(e);
|
|
1359
|
+
return e.lines.flatMap((o) => {
|
|
1360
|
+
if (r.has(o.line)) return [];
|
|
1361
|
+
const s = t.has(o.line);
|
|
1362
|
+
return pt(o.inline, n, s);
|
|
1363
|
+
});
|
|
1364
|
+
}
|
|
1365
|
+
function ur(e = {}) {
|
|
1366
|
+
return {
|
|
1367
|
+
theme: {
|
|
1368
|
+
// Keep the icon exactly one text em tall and aligned to the text bottom.
|
|
1369
|
+
// The raw `[name.icon]` text it replaces is one line tall, so an icon that
|
|
1370
|
+
// never exceeds the line box produces no vertical layout shift on focus.
|
|
1371
|
+
[`.${O}`]: {
|
|
1372
|
+
textDecoration: "none"
|
|
1373
|
+
},
|
|
1374
|
+
[`.${te}`]: {
|
|
1375
|
+
height: "1em",
|
|
1376
|
+
width: "auto",
|
|
1377
|
+
verticalAlign: "text-bottom"
|
|
1378
|
+
},
|
|
1379
|
+
[`.${ke} .${te}`]: {
|
|
1380
|
+
height: "calc(var(--mbox-scrapbox-icon-strong-scale, 3) * 1em)"
|
|
1381
|
+
},
|
|
1382
|
+
[`.${it}`]: {
|
|
1383
|
+
// Repeats deliberately have no measure widget: their wrapped height
|
|
1384
|
+
// cannot be reproduced by a zero-width box, and upstream's focused-row
|
|
1385
|
+
// behaviour for repeats has not been observed.
|
|
1386
|
+
display: "inline-block",
|
|
1387
|
+
width: "0",
|
|
1388
|
+
height: "calc(var(--mbox-scrapbox-icon-strong-scale, 3) * 1em)",
|
|
1389
|
+
visibility: "hidden",
|
|
1390
|
+
pointerEvents: "none",
|
|
1391
|
+
verticalAlign: "text-bottom"
|
|
1392
|
+
}
|
|
1393
|
+
},
|
|
1394
|
+
name: "scrapbox/link",
|
|
1395
|
+
decorations: (t) => {
|
|
1396
|
+
const n = x(t.state);
|
|
1397
|
+
return lr(n, t.activeLineNumbers, {
|
|
1398
|
+
iconUrl: e.iconUrl,
|
|
1399
|
+
pageUrl: e.pageUrl,
|
|
1400
|
+
pageExists: e.pageExists
|
|
1401
|
+
});
|
|
1402
|
+
}
|
|
1403
|
+
};
|
|
1404
|
+
}
|
|
1405
|
+
const pr = "mbox-scrapbox-caret-anchor";
|
|
1406
|
+
class mr extends E {
|
|
1407
|
+
eq() {
|
|
1408
|
+
return !0;
|
|
1409
|
+
}
|
|
1410
|
+
toDOM() {
|
|
1411
|
+
const t = document.createElement("span");
|
|
1412
|
+
return t.className = pr, t.textContent = "", t;
|
|
1413
|
+
}
|
|
1414
|
+
ignoreEvent() {
|
|
1415
|
+
return !1;
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
const ne = "mbox-scrapbox-list-line", z = "mbox-scrapbox-bullet", mt = "mbox-scrapbox-bullet-indent", fr = "mbox-scrapbox-number", ft = "data-mbox-scrapbox-indent";
|
|
1419
|
+
class dr extends E {
|
|
1420
|
+
constructor(t) {
|
|
1421
|
+
super(), this.innermost = t;
|
|
1422
|
+
}
|
|
1423
|
+
innermost;
|
|
1424
|
+
eq(t) {
|
|
1425
|
+
return t.innermost === this.innermost;
|
|
1426
|
+
}
|
|
1427
|
+
toDOM() {
|
|
1428
|
+
const t = document.createElement("span");
|
|
1429
|
+
return t.className = this.innermost ? z : mt, t.textContent = "", t;
|
|
1430
|
+
}
|
|
1431
|
+
ignoreEvent() {
|
|
1432
|
+
return !1;
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
const Ne = 1.5, oe = Ne, J = 0.4, qr = {
|
|
1436
|
+
line: ne
|
|
1437
|
+
};
|
|
1438
|
+
function br(e, t) {
|
|
1439
|
+
const n = C(e);
|
|
1440
|
+
return e.lines.flatMap((r) => {
|
|
1441
|
+
if (r.listType === "none" || n.has(r.line))
|
|
1442
|
+
return [];
|
|
1443
|
+
const o = r.listType === "bullet" ? (r.indent - 1) * Ne + oe : null, s = [
|
|
1444
|
+
{
|
|
1445
|
+
type: "line",
|
|
1446
|
+
from: r.from,
|
|
1447
|
+
className: t.line,
|
|
1448
|
+
attributes: {
|
|
1449
|
+
[ft]: String(r.indent),
|
|
1450
|
+
...o !== null ? { style: `--mbox-scrapbox-list-hang: ${o}em` } : {}
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
];
|
|
1454
|
+
if (r.listType === "bullet") {
|
|
1455
|
+
for (let a = 0; a < r.indent; a += 1) {
|
|
1456
|
+
const c = r.marker.from + a, l = a === r.indent - 1;
|
|
1457
|
+
s.push({
|
|
1458
|
+
type: "replace",
|
|
1459
|
+
from: c,
|
|
1460
|
+
to: c + 1,
|
|
1461
|
+
widget: new dr(l)
|
|
1462
|
+
});
|
|
1463
|
+
}
|
|
1464
|
+
r.content.from === r.content.to && s.push({
|
|
1465
|
+
type: "widget",
|
|
1466
|
+
from: r.content.from,
|
|
1467
|
+
widget: new mr(),
|
|
1468
|
+
side: 1
|
|
1469
|
+
});
|
|
1470
|
+
} else r.listType === "number" && r.numberMarker && s.push({
|
|
1471
|
+
type: "mark",
|
|
1472
|
+
from: r.numberMarker.from,
|
|
1473
|
+
to: r.numberMarker.to,
|
|
1474
|
+
className: t.number
|
|
1475
|
+
});
|
|
1476
|
+
return s;
|
|
1477
|
+
});
|
|
1478
|
+
}
|
|
1479
|
+
function hr() {
|
|
1480
|
+
return {
|
|
1481
|
+
theme: {
|
|
1482
|
+
// Hang the wrap by the indent width (set per line via --mbox-scrapbox-list-hang)
|
|
1483
|
+
// while preserving CodeMirror's default `.cm-line` left padding (6px), so the
|
|
1484
|
+
// first line (bullet + text) does not move but wrapped lines align with the text.
|
|
1485
|
+
[`.${ne}`]: {
|
|
1486
|
+
textIndent: "calc(var(--mbox-scrapbox-list-hang, 0px) * -1)",
|
|
1487
|
+
paddingLeft: "calc(6px + var(--mbox-scrapbox-list-hang, 0px))"
|
|
1488
|
+
},
|
|
1489
|
+
// Each indent level is a fixed-width inline-block box painted in place of a
|
|
1490
|
+
// raw space. The innermost box is the narrower bullet slot (its width is
|
|
1491
|
+
// the dot-left-edge-to-text distance, 1.0em); the outer boxes are full
|
|
1492
|
+
// 1.5em indent steps.
|
|
1493
|
+
// `line-height: normal` keeps each box only as tall as the font's natural
|
|
1494
|
+
// height, not the editor's expanded line-height. Without it the inline-block
|
|
1495
|
+
// box grows to the full line box, and a caret parked at the line start
|
|
1496
|
+
// (right against the box, with no text node before it) is measured against
|
|
1497
|
+
// that taller box — so it renders taller than the caret anywhere in the item
|
|
1498
|
+
// text. Matching the font height makes the caret one size wherever it sits,
|
|
1499
|
+
// and the dot still centers on the text (its `top: 50%` is half of a box that
|
|
1500
|
+
// now shares the text's own height).
|
|
1501
|
+
[`.${z}`]: {
|
|
1502
|
+
position: "relative",
|
|
1503
|
+
display: "inline-block",
|
|
1504
|
+
width: `${oe}em`,
|
|
1505
|
+
lineHeight: "normal",
|
|
1506
|
+
whiteSpace: "pre"
|
|
1507
|
+
},
|
|
1508
|
+
[`.${mt}`]: {
|
|
1509
|
+
display: "inline-block",
|
|
1510
|
+
width: `${Ne}em`,
|
|
1511
|
+
lineHeight: "normal",
|
|
1512
|
+
whiteSpace: "pre"
|
|
1513
|
+
},
|
|
1514
|
+
// The dot is an absolutely-positioned pseudo-element (no inline width, so
|
|
1515
|
+
// it never shifts the text). It sits at the horizontal center of the bullet
|
|
1516
|
+
// slot — left inset by half the slot's leftover width — so a selected line
|
|
1517
|
+
// keeps the dot in the middle of its highlighted cell instead of hugging the
|
|
1518
|
+
// left edge. Vertically it is centered on the line (`top: 50%` of the box,
|
|
1519
|
+
// which shares the text's height, then pulled up half its own height).
|
|
1520
|
+
[`.${z}::after`]: {
|
|
1521
|
+
content: '""',
|
|
1522
|
+
position: "absolute",
|
|
1523
|
+
left: `${(oe - J) / 2}em`,
|
|
1524
|
+
top: "50%",
|
|
1525
|
+
width: `${J}em`,
|
|
1526
|
+
height: `${J}em`,
|
|
1527
|
+
transform: "translateY(-50%)",
|
|
1528
|
+
borderRadius: "50%",
|
|
1529
|
+
background: "var(--mbox-scrapbox-bullet-color, #57606a)",
|
|
1530
|
+
pointerEvents: "none"
|
|
1531
|
+
}
|
|
1532
|
+
},
|
|
1533
|
+
name: "scrapbox/list",
|
|
1534
|
+
decorations: (e) => br(x(e.state), {
|
|
1535
|
+
line: ne,
|
|
1536
|
+
number: fr
|
|
1537
|
+
})
|
|
1538
|
+
};
|
|
1539
|
+
}
|
|
1540
|
+
const Se = "mbox-scrapbox-quote-line", dt = "mbox-scrapbox-quote-marker-hidden", Kr = {
|
|
1541
|
+
line: Se
|
|
1542
|
+
};
|
|
1543
|
+
function xr(e, t, n) {
|
|
1544
|
+
const r = C(t);
|
|
1545
|
+
return t.lines.flatMap((o) => {
|
|
1546
|
+
if (!(o.content.to > o.content.from && e[o.content.from] === ">") || r.has(o.line))
|
|
1547
|
+
return [];
|
|
1548
|
+
const a = n.has(o.line);
|
|
1549
|
+
return [
|
|
1550
|
+
{
|
|
1551
|
+
type: "line",
|
|
1552
|
+
from: o.from,
|
|
1553
|
+
className: Se,
|
|
1554
|
+
attributes: { [ft]: String(o.indent) }
|
|
1555
|
+
},
|
|
1556
|
+
...a ? [] : [{ type: "mark", from: o.content.from, to: o.content.from + 1, className: dt }]
|
|
1557
|
+
];
|
|
1558
|
+
});
|
|
1559
|
+
}
|
|
1560
|
+
function gr() {
|
|
1561
|
+
return {
|
|
1562
|
+
theme: {
|
|
1563
|
+
[`.${dt}`]: {
|
|
1564
|
+
visibility: "hidden"
|
|
1565
|
+
}
|
|
1566
|
+
},
|
|
1567
|
+
name: "scrapbox/quote",
|
|
1568
|
+
decorations: (e) => {
|
|
1569
|
+
const { input: t, document: n } = $(e.state);
|
|
1570
|
+
return xr(t, n, e.activeLineNumbers);
|
|
1571
|
+
}
|
|
1572
|
+
};
|
|
1573
|
+
}
|
|
1574
|
+
const _ = "mbox-scrapbox-table", bt = "mbox-scrapbox-table-opener", re = "mbox-scrapbox-table-row", ht = "mbox-scrapbox-table-header", q = "mbox-scrapbox-table-cell", ye = "mbox-scrapbox-table-raw-cell", xt = "mbox-scrapbox-table-rendered", gt = "mbox-scrapbox-table-keyword", kt = "mbox-scrapbox-table-name", kr = 6, Vr = {
|
|
1575
|
+
table: _,
|
|
1576
|
+
opener: bt,
|
|
1577
|
+
row: re,
|
|
1578
|
+
header: ht,
|
|
1579
|
+
cell: q,
|
|
1580
|
+
rawCell: ye,
|
|
1581
|
+
rendered: xt,
|
|
1582
|
+
keyword: gt,
|
|
1583
|
+
name: kt
|
|
1584
|
+
}, Oe = {
|
|
1585
|
+
table: _,
|
|
1586
|
+
renderedLine: xt,
|
|
1587
|
+
cell: q,
|
|
1588
|
+
rawCell: ye
|
|
1589
|
+
};
|
|
1590
|
+
function Cr(e, t, n) {
|
|
1591
|
+
const r = e.slice(t, n), o = r.trim(), s = t + r.indexOf(o);
|
|
1592
|
+
return { from: s, to: s + o.length, value: o };
|
|
1593
|
+
}
|
|
1594
|
+
function Nr(e, t) {
|
|
1595
|
+
return t.bodyLines.map((n, r) => {
|
|
1596
|
+
const o = [];
|
|
1597
|
+
let s = n.content.from;
|
|
1598
|
+
for (const a of e.slice(n.content.from, n.logicalTo).split(" ")) {
|
|
1599
|
+
const c = s + a.length, { value: l, ...u } = Cr(e, s, c), i = ar(e, n, u.from, u.to);
|
|
1600
|
+
o.push({ from: s, to: c, content: u, value: l, ...i === void 0 ? {} : { displayValue: i } }), s = c + 1;
|
|
1601
|
+
}
|
|
1602
|
+
return {
|
|
1603
|
+
className: r === 0 ? `${re} ${ht}` : re,
|
|
1604
|
+
line: n.line,
|
|
1605
|
+
from: n.from,
|
|
1606
|
+
to: n.logicalTo,
|
|
1607
|
+
cells: o
|
|
1608
|
+
};
|
|
1609
|
+
});
|
|
1610
|
+
}
|
|
1611
|
+
function Sr(e, t, n) {
|
|
1612
|
+
return t.tableBlocks.flatMap((r) => {
|
|
1613
|
+
const o = r.openerLine, s = o.content.from + kr, a = [
|
|
1614
|
+
{
|
|
1615
|
+
type: "line",
|
|
1616
|
+
from: o.from,
|
|
1617
|
+
className: `${_} ${bt}`
|
|
1618
|
+
},
|
|
1619
|
+
{ type: "mark", from: o.content.from, to: s, className: gt }
|
|
1620
|
+
];
|
|
1621
|
+
o.logicalTo > s && a.push({ type: "mark", from: s, to: o.logicalTo, className: kt });
|
|
1622
|
+
const c = Nr(e, r);
|
|
1623
|
+
return a.push(
|
|
1624
|
+
...At(c, n, Oe, { tableId: `scrapbox-table-${o.from}` }),
|
|
1625
|
+
...Ft(c, n, { tableId: `scrapbox-table-${o.from}` }),
|
|
1626
|
+
...Rt(c, n, Oe, { measureWidth: Ht }, { tableId: `scrapbox-table-${o.from}` }),
|
|
1627
|
+
...Dt(c, n),
|
|
1628
|
+
...Ut(c, n)
|
|
1629
|
+
), a;
|
|
1630
|
+
});
|
|
1631
|
+
}
|
|
1632
|
+
function yr() {
|
|
1633
|
+
return {
|
|
1634
|
+
theme: {
|
|
1635
|
+
[`.${_}`]: {
|
|
1636
|
+
fontFamily: 'var(--mbox-table-font-family, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace)'
|
|
1637
|
+
},
|
|
1638
|
+
[`.${q}`]: {
|
|
1639
|
+
width: "var(--mbox-table-cell-width, var(--mbox-table-kit-column-width))",
|
|
1640
|
+
maxWidth: "var(--mbox-table-kit-cell-max-width, 100%)",
|
|
1641
|
+
minWidth: 0,
|
|
1642
|
+
overflowWrap: "anywhere"
|
|
1643
|
+
},
|
|
1644
|
+
// Both classes: a raw cell carries the base cell class too, so a
|
|
1645
|
+
// single-class rule would only win by being written second.
|
|
1646
|
+
[`.${q}.${ye}`]: {
|
|
1647
|
+
width: "auto",
|
|
1648
|
+
maxWidth: "none",
|
|
1649
|
+
minWidth: "auto"
|
|
1650
|
+
}
|
|
1651
|
+
},
|
|
1652
|
+
name: "scrapbox/table",
|
|
1653
|
+
decorations: (e) => {
|
|
1654
|
+
const { input: t, document: n } = $(e.state);
|
|
1655
|
+
return Sr(t, n, e.activeLineNumbers);
|
|
1656
|
+
}
|
|
1657
|
+
};
|
|
1658
|
+
}
|
|
1659
|
+
const Ct = "mbox-scrapbox-title-line";
|
|
1660
|
+
function Lr() {
|
|
1661
|
+
return {
|
|
1662
|
+
name: "scrapbox/title",
|
|
1663
|
+
decorations: (e) => [
|
|
1664
|
+
{ type: "line", from: e.state.doc.line(1).from, className: Ct }
|
|
1665
|
+
]
|
|
1666
|
+
};
|
|
1667
|
+
}
|
|
1668
|
+
function wr(e) {
|
|
1669
|
+
return e === !0 ? void 0 : e || void 0;
|
|
1670
|
+
}
|
|
1671
|
+
function $r(e) {
|
|
1672
|
+
return e === !0 ? void 0 : e || void 0;
|
|
1673
|
+
}
|
|
1674
|
+
function Ir(e = {}) {
|
|
1675
|
+
return [
|
|
1676
|
+
en(),
|
|
1677
|
+
tr(),
|
|
1678
|
+
uo(e.complete),
|
|
1679
|
+
Zo(),
|
|
1680
|
+
hr(),
|
|
1681
|
+
gr(),
|
|
1682
|
+
to(),
|
|
1683
|
+
Gn(),
|
|
1684
|
+
...e.codeHighlight ? [_n(wr(e.codeHighlight))] : [],
|
|
1685
|
+
yr(),
|
|
1686
|
+
xo(),
|
|
1687
|
+
...e.inlineCodeHighlight ? [rr($r(e.inlineCodeHighlight))] : [],
|
|
1688
|
+
yo(e.formula),
|
|
1689
|
+
Ro(e.image),
|
|
1690
|
+
ur(e.link),
|
|
1691
|
+
...e.titleLine ? [Lr()] : []
|
|
1692
|
+
];
|
|
1693
|
+
}
|
|
1694
|
+
const Er = "var(--mbox-scrapbox-code-font-family, monospace)", Nt = {};
|
|
1695
|
+
for (let e = 2; e <= 10; e += 1) {
|
|
1696
|
+
const t = (1 + (e - 1) * 0.2).toFixed(1);
|
|
1697
|
+
Nt[`.${de}-${e}`] = {
|
|
1698
|
+
fontSize: `var(--mbox-scrapbox-strong-level-${e}-font-size, ${t}em)`
|
|
1699
|
+
};
|
|
1700
|
+
}
|
|
1701
|
+
const Tr = {
|
|
1702
|
+
...zt([le, ct]),
|
|
1703
|
+
...Nt,
|
|
1704
|
+
[`.${I}`]: {
|
|
1705
|
+
fontWeight: "var(--mbox-scrapbox-strong-font-weight, 700)"
|
|
1706
|
+
},
|
|
1707
|
+
[`.${K}`]: {
|
|
1708
|
+
fontStyle: "italic"
|
|
1709
|
+
},
|
|
1710
|
+
[`.${V}`]: {
|
|
1711
|
+
textDecoration: "line-through"
|
|
1712
|
+
},
|
|
1713
|
+
[`.${Q}`]: {
|
|
1714
|
+
textDecoration: "underline",
|
|
1715
|
+
textUnderlineOffset: "2px"
|
|
1716
|
+
},
|
|
1717
|
+
[`.${fe}`]: {
|
|
1718
|
+
fontFamily: Er,
|
|
1719
|
+
fontSize: "var(--mbox-scrapbox-code-font-size, 0.9em)",
|
|
1720
|
+
background: "var(--mbox-scrapbox-code-background, rgba(175, 184, 193, 0.2))",
|
|
1721
|
+
borderRadius: "4px",
|
|
1722
|
+
padding: "0.1em 0.3em"
|
|
1723
|
+
},
|
|
1724
|
+
// Both internal and external links share the colour and pointer; internal
|
|
1725
|
+
// `[Page]` links carry only this class and are NOT underlined.
|
|
1726
|
+
[`.${H}`]: {
|
|
1727
|
+
color: "var(--mbox-scrapbox-link-color, #0969da)",
|
|
1728
|
+
textDecoration: "none",
|
|
1729
|
+
cursor: "pointer"
|
|
1730
|
+
},
|
|
1731
|
+
// External links additionally carry the url class. Declared after the link
|
|
1732
|
+
// rule so, at equal specificity, its underline wins for external links while
|
|
1733
|
+
// internal page links stay underline-free.
|
|
1734
|
+
[`.${xe}`]: {
|
|
1735
|
+
textDecoration: "underline",
|
|
1736
|
+
textUnderlineOffset: "2px"
|
|
1737
|
+
},
|
|
1738
|
+
[`.${ge}`]: {
|
|
1739
|
+
color: "var(--mbox-scrapbox-hashtag-color, #0969da)",
|
|
1740
|
+
textDecoration: "none",
|
|
1741
|
+
cursor: "pointer"
|
|
1742
|
+
},
|
|
1743
|
+
[`.${Se}`]: {
|
|
1744
|
+
// Shift the border 6px right -- CodeMirror's own `.cm-line` default left
|
|
1745
|
+
// padding, the same constant list.ts's hang-indent math uses -- and take
|
|
1746
|
+
// it back out of the padding, so the border lines up with a normal
|
|
1747
|
+
// line's text start instead of sitting 6px further left than it.
|
|
1748
|
+
marginLeft: "6px",
|
|
1749
|
+
borderLeft: "var(--mbox-scrapbox-quote-border, 3px solid #d0d7de)",
|
|
1750
|
+
paddingLeft: "calc(0.6em - 6px)",
|
|
1751
|
+
color: "var(--mbox-scrapbox-quote-color, #57606a)",
|
|
1752
|
+
// Default `transparent` keeps the previous look. Because the quote class
|
|
1753
|
+
// sits on the `.cm-line` element, this background paints *above* CodeMirror's
|
|
1754
|
+
// selection layer (drawSelection's `.cm-selectionLayer` is at a negative
|
|
1755
|
+
// z-index, behind the content), so an *opaque* value hides the selection
|
|
1756
|
+
// highlight underneath. Pass a *translucent* colour (rgba/hsla or a
|
|
1757
|
+
// `color-mix(... transparent)`) and the selection blends through it -- the
|
|
1758
|
+
// supported way to tint a quote without losing the selection.
|
|
1759
|
+
background: "var(--mbox-scrapbox-quote-background, transparent)"
|
|
1760
|
+
},
|
|
1761
|
+
// fontFamily is NOT here: scrapboxCodeBlockPlugin() carries it in its own
|
|
1762
|
+
// theme instead (not because it's structural -- it isn't, unlike table's --
|
|
1763
|
+
// but so a bare scrapboxCodeBlockPlugin() keeps its default look without
|
|
1764
|
+
// this opt-in presentation theme).
|
|
1765
|
+
[`.${P}`]: {
|
|
1766
|
+
fontSize: "var(--mbox-scrapbox-code-font-size, 0.9em)",
|
|
1767
|
+
background: "var(--mbox-scrapbox-code-block-background, rgba(175, 184, 193, 0.15))"
|
|
1768
|
+
},
|
|
1769
|
+
[`.${ie}`]: {
|
|
1770
|
+
color: "var(--mbox-scrapbox-code-block-keyword-color, #57606a)"
|
|
1771
|
+
},
|
|
1772
|
+
[`.${z}::after`]: {
|
|
1773
|
+
background: "var(--mbox-scrapbox-bullet-color, #57606a)"
|
|
1774
|
+
},
|
|
1775
|
+
// The title line (a document's first line) is set at ~1.73x a normal line's
|
|
1776
|
+
// font size, with ~0.8em of its own font-size as extra room before the body
|
|
1777
|
+
// starts -- enough that the title reads as a heading rather than as a large
|
|
1778
|
+
// first paragraph. The extra room is
|
|
1779
|
+
// line-height/padding, not margin, so it stays part of the line box
|
|
1780
|
+
// CodeMirror measures (no focus/unfocus height jump -- the same reasoning
|
|
1781
|
+
// as Hatena's heading padding, see hatena's own presentation theme).
|
|
1782
|
+
[`.${Ct}`]: {
|
|
1783
|
+
fontSize: "var(--mbox-scrapbox-title-font-size, 1.7em)",
|
|
1784
|
+
fontWeight: "var(--mbox-scrapbox-title-font-weight, 700)",
|
|
1785
|
+
lineHeight: "var(--mbox-scrapbox-title-line-height, 1.5)",
|
|
1786
|
+
paddingBottom: "var(--mbox-scrapbox-title-padding-bottom, 0.8em)"
|
|
1787
|
+
}
|
|
1788
|
+
};
|
|
1789
|
+
function Mr() {
|
|
1790
|
+
return Ae.theme(Tr);
|
|
1791
|
+
}
|
|
1792
|
+
function vr(e = {}) {
|
|
1793
|
+
return Kt(e, Ir(e), Mr);
|
|
1794
|
+
}
|
|
1795
|
+
function Qr(e) {
|
|
1796
|
+
const { parent: t, ...n } = e;
|
|
1797
|
+
return qt({ parent: t, state: vr(n) });
|
|
1798
|
+
}
|
|
1799
|
+
export {
|
|
1800
|
+
It as ScrapboxCodeBlockCopyButtonWidget,
|
|
1801
|
+
j as ScrapboxFormulaWidget,
|
|
1802
|
+
G as ScrapboxIconWidget,
|
|
1803
|
+
Wo as ScrapboxImageMeasureWidget,
|
|
1804
|
+
Oo as ScrapboxImagePreviewWidget,
|
|
1805
|
+
Bo as ScrapboxImageWidget,
|
|
1806
|
+
W as ScrapboxLinkWidget,
|
|
1807
|
+
ve as backspaceScrapboxIndent,
|
|
1808
|
+
Qr as createScrapboxEditor,
|
|
1809
|
+
vr as createScrapboxEditorState,
|
|
1810
|
+
vo as defaultScrapboxImageSrcResolver,
|
|
1811
|
+
Xo as enterScrapboxEmptyList,
|
|
1812
|
+
x as getScrapboxDocumentFromState,
|
|
1813
|
+
_o as indentScrapboxLines,
|
|
1814
|
+
Yo as outdentScrapboxLines,
|
|
1815
|
+
zn as parseScrapboxDocument,
|
|
1816
|
+
Rn as parseScrapboxInline,
|
|
1817
|
+
Dn as parseScrapboxLineInline,
|
|
1818
|
+
en as scrapboxBracketPlugin,
|
|
1819
|
+
z as scrapboxBulletClassName,
|
|
1820
|
+
Qe as scrapboxCodeBlockBodyClassName,
|
|
1821
|
+
P as scrapboxCodeBlockClassName,
|
|
1822
|
+
Fr as scrapboxCodeBlockClassNames,
|
|
1823
|
+
_e as scrapboxCodeBlockCopyButtonClassName,
|
|
1824
|
+
je as scrapboxCodeBlockFileNameClassName,
|
|
1825
|
+
_n as scrapboxCodeBlockHighlightPlugin,
|
|
1826
|
+
ie as scrapboxCodeBlockKeywordClassName,
|
|
1827
|
+
Ge as scrapboxCodeBlockLanguageLabelClassName,
|
|
1828
|
+
qe as scrapboxCodeBlockLineNumbers,
|
|
1829
|
+
Ve as scrapboxCodeBlockOpenerClassName,
|
|
1830
|
+
Gn as scrapboxCodeBlockPlugin,
|
|
1831
|
+
le as scrapboxCodeBlockTokenClassName,
|
|
1832
|
+
fe as scrapboxCodeClassName,
|
|
1833
|
+
Xe as scrapboxCommandClassName,
|
|
1834
|
+
Je as scrapboxCommandLineClassName,
|
|
1835
|
+
Rr as scrapboxCommandLineClassNames,
|
|
1836
|
+
to as scrapboxCommandLinePlugin,
|
|
1837
|
+
Xn as scrapboxCommandPromptClassName,
|
|
1838
|
+
uo as scrapboxCompletePlugin,
|
|
1839
|
+
Dr as scrapboxCompletionClassNames,
|
|
1840
|
+
ee as scrapboxCompletionOptionClassName,
|
|
1841
|
+
ue as scrapboxCompletionOptionWithPreviewClassName,
|
|
1842
|
+
pe as scrapboxCompletionPreviewClassName,
|
|
1843
|
+
me as scrapboxCompletionPreviewImageClassName,
|
|
1844
|
+
po as scrapboxDecorationClassName,
|
|
1845
|
+
Ur as scrapboxDecorationClassNames,
|
|
1846
|
+
xo as scrapboxDecorationPlugin,
|
|
1847
|
+
Mr as scrapboxDefaultPresentationTheme,
|
|
1848
|
+
Tr as scrapboxDefaultPresentationThemeSpec,
|
|
1849
|
+
K as scrapboxEmphasisClassName,
|
|
1850
|
+
et as scrapboxFormulaClassName,
|
|
1851
|
+
Hr as scrapboxFormulaClassNames,
|
|
1852
|
+
yo as scrapboxFormulaPlugin,
|
|
1853
|
+
ge as scrapboxHashTagClassName,
|
|
1854
|
+
O as scrapboxIconClassName,
|
|
1855
|
+
te as scrapboxIconImageClassName,
|
|
1856
|
+
Lo as scrapboxImageClassName,
|
|
1857
|
+
A as scrapboxImageClassNames,
|
|
1858
|
+
Io as scrapboxImageElementClassName,
|
|
1859
|
+
Eo as scrapboxImageMeasureClassName,
|
|
1860
|
+
Ro as scrapboxImagePlugin,
|
|
1861
|
+
$o as scrapboxImagePreviewClassName,
|
|
1862
|
+
rt as scrapboxImageStrongClassName,
|
|
1863
|
+
wo as scrapboxImageTokenClassName,
|
|
1864
|
+
ft as scrapboxIndentAttribute,
|
|
1865
|
+
Ne as scrapboxIndentLevelWidth,
|
|
1866
|
+
Zo as scrapboxIndentPlugin,
|
|
1867
|
+
rr as scrapboxInlineCodeHighlightPlugin,
|
|
1868
|
+
tr as scrapboxInlineCodePlugin,
|
|
1869
|
+
ct as scrapboxInlineCodeTokenClassName,
|
|
1870
|
+
Jo as scrapboxLineStart,
|
|
1871
|
+
H as scrapboxLinkClassName,
|
|
1872
|
+
zr as scrapboxLinkClassNames,
|
|
1873
|
+
ur as scrapboxLinkPlugin,
|
|
1874
|
+
qr as scrapboxListClassNames,
|
|
1875
|
+
ne as scrapboxListLineClassName,
|
|
1876
|
+
hr as scrapboxListPlugin,
|
|
1877
|
+
fr as scrapboxNumberClassName,
|
|
1878
|
+
lt as scrapboxPageMissingClassName,
|
|
1879
|
+
Ir as scrapboxPlugins,
|
|
1880
|
+
Kr as scrapboxQuoteClassNames,
|
|
1881
|
+
Se as scrapboxQuoteLineClassName,
|
|
1882
|
+
gr as scrapboxQuotePlugin,
|
|
1883
|
+
V as scrapboxStrikethroughClassName,
|
|
1884
|
+
I as scrapboxStrongClassName,
|
|
1885
|
+
ke as scrapboxStrongIconClassName,
|
|
1886
|
+
it as scrapboxStrongIconMeasureClassName,
|
|
1887
|
+
Kn as scrapboxTableBlockLineNumbers,
|
|
1888
|
+
q as scrapboxTableCellClassName,
|
|
1889
|
+
_ as scrapboxTableClassName,
|
|
1890
|
+
Vr as scrapboxTableClassNames,
|
|
1891
|
+
ht as scrapboxTableHeaderClassName,
|
|
1892
|
+
gt as scrapboxTableKeywordClassName,
|
|
1893
|
+
kt as scrapboxTableNameClassName,
|
|
1894
|
+
bt as scrapboxTableOpenerClassName,
|
|
1895
|
+
yr as scrapboxTablePlugin,
|
|
1896
|
+
ye as scrapboxTableRawCellClassName,
|
|
1897
|
+
xt as scrapboxTableRenderedClassName,
|
|
1898
|
+
re as scrapboxTableRowClassName,
|
|
1899
|
+
Ct as scrapboxTitleLineClassName,
|
|
1900
|
+
Lr as scrapboxTitlePlugin,
|
|
1901
|
+
Q as scrapboxUnderlineClassName,
|
|
1902
|
+
xe as scrapboxUrlClassName
|
|
1903
|
+
};
|