@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.
Files changed (111) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +80 -2
  3. package/dist/create-editor-BKTpQ8TK.js +2866 -0
  4. package/dist/editor/create-editor.d.ts +100 -0
  5. package/dist/editor/document-cache.d.ts +20 -0
  6. package/dist/editor/focused-line.d.ts +14 -0
  7. package/dist/editor/plugin.d.ts +191 -0
  8. package/dist/editor/test-context.d.ts +28 -0
  9. package/dist/gfm.d.ts +34 -0
  10. package/dist/gfm.js +1719 -0
  11. package/dist/hatena.d.ts +32 -0
  12. package/dist/hatena.js +856 -0
  13. package/dist/index.d.ts +34 -0
  14. package/dist/index.js +77 -0
  15. package/dist/plugin-DI0ubB-M.js +297 -0
  16. package/dist/plugins/bracket-pair-kit.d.ts +9 -0
  17. package/dist/plugins/code-block-kit.d.ts +77 -0
  18. package/dist/plugins/code-block-language-loader.d.ts +33 -0
  19. package/dist/plugins/gfm/active-lines.d.ts +11 -0
  20. package/dist/plugins/gfm/code-block.d.ts +28 -0
  21. package/dist/plugins/gfm/footnote.d.ts +17 -0
  22. package/dist/plugins/gfm/heading.d.ts +12 -0
  23. package/dist/plugins/gfm/image.d.ts +30 -0
  24. package/dist/plugins/gfm/index.d.ts +19 -0
  25. package/dist/plugins/gfm/inline-code.d.ts +4 -0
  26. package/dist/plugins/gfm/inline.d.ts +4 -0
  27. package/dist/plugins/gfm/link.d.ts +34 -0
  28. package/dist/plugins/gfm/list.d.ts +32 -0
  29. package/dist/plugins/gfm/math.d.ts +39 -0
  30. package/dist/plugins/gfm/parser-cache.d.ts +3 -0
  31. package/dist/plugins/gfm/parser.d.ts +355 -0
  32. package/dist/plugins/gfm/quote.d.ts +3 -0
  33. package/dist/plugins/gfm/table.d.ts +34 -0
  34. package/dist/plugins/gfm/thematic-break.d.ts +9 -0
  35. package/dist/plugins/hatena/blockquote.d.ts +12 -0
  36. package/dist/plugins/hatena/definition.d.ts +5 -0
  37. package/dist/plugins/hatena/footnote.d.ts +15 -0
  38. package/dist/plugins/hatena/heading.d.ts +8 -0
  39. package/dist/plugins/hatena/index.d.ts +12 -0
  40. package/dist/plugins/hatena/link.d.ts +16 -0
  41. package/dist/plugins/hatena/list.d.ts +24 -0
  42. package/dist/plugins/hatena/parser-cache.d.ts +5 -0
  43. package/dist/plugins/hatena/parser.d.ts +129 -0
  44. package/dist/plugins/hatena/pre.d.ts +3 -0
  45. package/dist/plugins/hatena/shared.d.ts +31 -0
  46. package/dist/plugins/hatena/super-pre.d.ts +23 -0
  47. package/dist/plugins/hatena/table.d.ts +12 -0
  48. package/dist/plugins/image-kit.d.ts +84 -0
  49. package/dist/plugins/inline-notation-kit.d.ts +39 -0
  50. package/dist/plugins/inline-style-kit.d.ts +38 -0
  51. package/dist/plugins/link-url.d.ts +1 -0
  52. package/dist/plugins/logical-lines.d.ts +18 -0
  53. package/dist/plugins/mbox/bracket.d.ts +4 -0
  54. package/dist/plugins/mbox/code-block.d.ts +32 -0
  55. package/dist/plugins/mbox/complete.d.ts +33 -0
  56. package/dist/plugins/mbox/default.d.ts +13 -0
  57. package/dist/plugins/mbox/emoji.d.ts +3 -0
  58. package/dist/plugins/mbox/footnote.d.ts +14 -0
  59. package/dist/plugins/mbox/heading.d.ts +10 -0
  60. package/dist/plugins/mbox/inline-code.d.ts +6 -0
  61. package/dist/plugins/mbox/inline-style.d.ts +7 -0
  62. package/dist/plugins/mbox/inline-visitor.d.ts +8 -0
  63. package/dist/plugins/mbox/list.d.ts +13 -0
  64. package/dist/plugins/mbox/markdown-image.d.ts +13 -0
  65. package/dist/plugins/mbox/page-link.d.ts +19 -0
  66. package/dist/plugins/mbox/paragraph.d.ts +6 -0
  67. package/dist/plugins/mbox/parser-cache.d.ts +3 -0
  68. package/dist/plugins/mbox/parser.d.ts +2 -0
  69. package/dist/plugins/mbox/quote.d.ts +5 -0
  70. package/dist/plugins/mbox/table.d.ts +13 -0
  71. package/dist/plugins/mbox/task-list.d.ts +19 -0
  72. package/dist/plugins/mbox/types.d.ts +172 -0
  73. package/dist/plugins/mbox/url-link.d.ts +3 -0
  74. package/dist/plugins/mbox/vertical-motion.d.ts +3 -0
  75. package/dist/plugins/pipe-table-row.d.ts +18 -0
  76. package/dist/plugins/scrapbox/bracket.d.ts +20 -0
  77. package/dist/plugins/scrapbox/code-block.d.ts +37 -0
  78. package/dist/plugins/scrapbox/command-line.d.ts +9 -0
  79. package/dist/plugins/scrapbox/complete.d.ts +58 -0
  80. package/dist/plugins/scrapbox/decoration.d.ts +16 -0
  81. package/dist/plugins/scrapbox/formula.d.ts +43 -0
  82. package/dist/plugins/scrapbox/image.d.ts +62 -0
  83. package/dist/plugins/scrapbox/indent.d.ts +40 -0
  84. package/dist/plugins/scrapbox/index.d.ts +41 -0
  85. package/dist/plugins/scrapbox/inline-code-highlight.d.ts +16 -0
  86. package/dist/plugins/scrapbox/inline-code.d.ts +7 -0
  87. package/dist/plugins/scrapbox/inline-scanner-kit.d.ts +66 -0
  88. package/dist/plugins/scrapbox/inline-walker.d.ts +2 -0
  89. package/dist/plugins/scrapbox/inline.d.ts +86 -0
  90. package/dist/plugins/scrapbox/link.d.ts +110 -0
  91. package/dist/plugins/scrapbox/list.d.ts +21 -0
  92. package/dist/plugins/scrapbox/parser-cache.d.ts +5 -0
  93. package/dist/plugins/scrapbox/parser.d.ts +65 -0
  94. package/dist/plugins/scrapbox/quote.d.ts +7 -0
  95. package/dist/plugins/scrapbox/table.d.ts +22 -0
  96. package/dist/plugins/scrapbox/title.d.ts +3 -0
  97. package/dist/plugins/scrapbox/visible-lines.d.ts +34 -0
  98. package/dist/plugins/table-kit.d.ts +142 -0
  99. package/dist/plugins/task-checkbox-kit.d.ts +18 -0
  100. package/dist/scrapbox.d.ts +42 -0
  101. package/dist/scrapbox.js +1903 -0
  102. package/dist/testing.d.ts +2 -0
  103. package/dist/testing.js +13 -0
  104. package/dist/themes/code-token-presentation.d.ts +6 -0
  105. package/dist/themes/default-presentation.d.ts +4 -0
  106. package/dist/themes/gfm-presentation.d.ts +15 -0
  107. package/dist/themes/hatena-presentation.d.ts +10 -0
  108. package/dist/themes/heading-presentation.d.ts +18 -0
  109. package/dist/themes/scrapbox-presentation.d.ts +10 -0
  110. package/docs/guide.md +297 -0
  111. package/package.json +121 -4
package/dist/hatena.js ADDED
@@ -0,0 +1,856 @@
1
+ import { ah as re, ai as se, aj as ie, ak as B, al as le, am as ce, an as ue, ao as he, ap as me, aq as pe, ar as fe, as as de, at as ge, au as be, av as xe, n as ke, aw as Ce } from "./create-editor-BKTpQ8TK.js";
2
+ import { WidgetType as b, EditorView as Le } from "@codemirror/view";
3
+ import { c as $e } from "./plugin-DI0ubB-M.js";
4
+ const Se = /^(\*+)/, ve = /^([-+]+)(\s?)/, E = "||<", Ne = ">>", Pe = "<<", we = 5, ye = /\[(https?:\/\/[^\[\]\s]+?)(?::title(?:=([^\]]*))?)?\]/g, Me = /https?:\/\/[^\s\]]+/g, He = /id:([A-Za-z0-9_-]+)/g;
5
+ function Re(n) {
6
+ const e = [], t = re(n), a = t.map((l) => l.text), { superPreRoles: o, superPreLanguages: r, preRoles: s } = ze(a), i = a.map((l, c) => o[c] !== null || s[c] !== null), u = _e(a, i);
7
+ for (const l of t) {
8
+ const c = l.line - 1, h = o[c], d = s[c];
9
+ if (i[c]) {
10
+ e.push({
11
+ line: l.line,
12
+ from: l.from,
13
+ to: l.to,
14
+ heading: null,
15
+ list: null,
16
+ definition: null,
17
+ footnotes: [],
18
+ links: [],
19
+ quote: null,
20
+ superPre: h,
21
+ superPreLang: r[c],
22
+ pre: d
23
+ });
24
+ continue;
25
+ }
26
+ e.push({
27
+ line: l.line,
28
+ from: l.from,
29
+ to: l.to,
30
+ heading: De(l.text, l.from),
31
+ list: Oe(l.text, l.from),
32
+ definition: Be(l.text, l.from),
33
+ footnotes: Fe(l.text, l.from),
34
+ links: Ke(l.text, l.from),
35
+ quote: u[c],
36
+ superPre: null,
37
+ superPreLang: null,
38
+ pre: null
39
+ });
40
+ }
41
+ return Ae(e), We(e), { lines: e, tables: Te(t, i) };
42
+ }
43
+ const Ee = /^\|/;
44
+ function Te(n, e) {
45
+ const t = [];
46
+ let a = [];
47
+ const o = () => {
48
+ a.length > 0 && (t.push({
49
+ line: a[0].line,
50
+ from: a[0].from,
51
+ to: a[a.length - 1].to,
52
+ rows: a
53
+ }), a = []);
54
+ };
55
+ for (const r of n)
56
+ !e[r.line - 1] && Ee.test(r.text) ? a.push(qe(r.text, r.from, r.line)) : o();
57
+ return o(), t;
58
+ }
59
+ function qe(n, e, t) {
60
+ const a = se(n), o = n.trimEnd().endsWith("|") && a.length > 1, r = [
61
+ a[0],
62
+ ...a.slice(1, o ? -1 : void 0),
63
+ o ? a[a.length - 1] : n.length
64
+ ], s = [];
65
+ for (let i = 0; i < r.length - 1; i += 1) {
66
+ const u = r[i] + 1, l = r[i + 1], c = n.slice(u, l), h = c.length - c.trimStart().length, d = c.length - c.trimEnd().length, p = u + h, g = l - d, $ = p < g && n[p] === "*", oe = $ ? { from: e + p, to: e + p + 1 } : null, R = $ ? p + 1 : p;
67
+ s.push({
68
+ from: e + u,
69
+ to: e + l,
70
+ header: $,
71
+ marker: oe,
72
+ content: { from: e + R, to: e + g },
73
+ value: n.slice(R, g)
74
+ });
75
+ }
76
+ return { line: t, from: e, to: e + n.length, cells: s };
77
+ }
78
+ function De(n, e) {
79
+ const t = Se.exec(n);
80
+ if (!t)
81
+ return null;
82
+ const a = t[1].length, o = /^([A-Za-z0-9_-]+)\*/.exec(n.slice(a)), r = a + (o ? o[0].length : 0);
83
+ return {
84
+ marker: { from: e, to: e + r },
85
+ level: Math.min(a + 2, we),
86
+ name: o ? o[1] : null
87
+ };
88
+ }
89
+ function Fe(n, e) {
90
+ const t = [];
91
+ let a = 0;
92
+ for (; ; ) {
93
+ const o = n.indexOf("((", a);
94
+ if (o === -1)
95
+ break;
96
+ const r = n.indexOf("))", o + 3);
97
+ if (r === -1)
98
+ break;
99
+ const s = o + 2;
100
+ t.push({
101
+ marker: { from: e + o, to: e + r + 2 },
102
+ content: { from: e + s, to: e + r },
103
+ text: n.slice(s, r),
104
+ number: 0
105
+ // assigned in a document-order pass once every line is parsed.
106
+ }), a = r + 2;
107
+ }
108
+ return t;
109
+ }
110
+ function We(n) {
111
+ let e = 0;
112
+ for (const t of n)
113
+ for (const a of t.footnotes)
114
+ e += 1, a.number = e;
115
+ }
116
+ function Be(n, e) {
117
+ if (n.startsWith("::"))
118
+ return { continuation: !0, marker: { from: e, to: e + 2 }, term: null, separator: null };
119
+ const t = /^:([^:]*):/.exec(n);
120
+ if (!t)
121
+ return null;
122
+ const a = e + 1, o = a + t[1].length;
123
+ return {
124
+ continuation: !1,
125
+ marker: { from: e, to: e + 1 },
126
+ term: { from: a, to: o },
127
+ separator: { from: o, to: o + 1 }
128
+ };
129
+ }
130
+ function Oe(n, e) {
131
+ const t = ve.exec(n);
132
+ if (!t)
133
+ return null;
134
+ const a = t[1], o = a.length + t[2].length;
135
+ return {
136
+ marker: { from: e, to: e + o },
137
+ depth: a.length,
138
+ // The innermost level's marker char decides the visible bullet: `+` = ordered.
139
+ ordered: a[a.length - 1] === "+",
140
+ ordinal: null
141
+ // assigned in a second pass once every line's list is known.
142
+ };
143
+ }
144
+ function Ae(n) {
145
+ const e = [], t = [];
146
+ for (const a of n) {
147
+ const o = a.list;
148
+ if (!o) {
149
+ e.length = 0, t.length = 0;
150
+ continue;
151
+ }
152
+ const r = o.depth;
153
+ if (e.length = r, t.length = r, !o.ordered) {
154
+ e[r - 1] = 0, t[r - 1] = !1;
155
+ continue;
156
+ }
157
+ const s = t[r - 1] ? (e[r - 1] ?? 0) + 1 : 1;
158
+ e[r - 1] = s, t[r - 1] = !0, o.ordinal = s;
159
+ }
160
+ }
161
+ const Ie = /^>\|([^|]*)\|$/, Qe = ">|", T = "|<";
162
+ function ze(n) {
163
+ const e = new Array(n.length).fill(null), t = new Array(n.length).fill(null), a = new Array(n.length).fill(null);
164
+ let o = null;
165
+ for (let r = 0; r < n.length; r++) {
166
+ const s = n[r];
167
+ if (o === null) {
168
+ const i = Ie.exec(s);
169
+ i ? (e[r] = "opener", t[r] = i[1] === "" ? null : i[1], o = "superpre") : s === Qe && (a[r] = "opener", o = "pre");
170
+ continue;
171
+ }
172
+ if (o === "superpre") {
173
+ e[r] = s === E ? "closer" : "body", s === E && (o = null);
174
+ continue;
175
+ }
176
+ a[r] = s === T ? "closer" : "body", s === T && (o = null);
177
+ }
178
+ return { superPreRoles: e, superPreLanguages: t, preRoles: a };
179
+ }
180
+ function _e(n, e) {
181
+ const t = new Array(n.length).fill(null);
182
+ let a = 0;
183
+ for (let o = 0; o < n.length; o++) {
184
+ if (e[o])
185
+ continue;
186
+ const r = n[o], s = /^>(https?:\/\/\S+)>$/.exec(r);
187
+ r === Ne ? (a += 1, t[o] = { depth: a, role: "open", cite: null }) : s ? (a += 1, t[o] = { depth: a, role: "open", cite: s[1] }) : r === Pe && a > 0 ? (t[o] = { depth: a, role: "close", cite: null }, a -= 1) : a > 0 && (t[o] = { depth: a, role: "content", cite: null });
188
+ }
189
+ return t;
190
+ }
191
+ function Ke(n, e) {
192
+ const t = [], a = [];
193
+ for (const s of n.matchAll(ye)) {
194
+ const i = e + s.index, u = i + s[0].length;
195
+ a.push({ from: i, to: u });
196
+ const l = s[1], c = s[2] !== void 0 && s[2] !== "" ? s[2] : l;
197
+ t.push({ from: i, to: u, href: l, label: c, kind: "bracket" });
198
+ }
199
+ let o = 0;
200
+ for (const s of n.matchAll(Me)) {
201
+ const i = e + s.index, u = i + s[0].length;
202
+ for (; a[o]?.to <= i; )
203
+ o += 1;
204
+ const l = a[o];
205
+ l !== void 0 && i >= l.from && i < l.to || t.push({ from: i, to: u, href: s[0], label: s[0], kind: "url" });
206
+ }
207
+ let r = 0;
208
+ for (const s of n.matchAll(He)) {
209
+ const i = e + s.index, u = i + s[0].length;
210
+ for (; a[r]?.to <= i; )
211
+ r += 1;
212
+ const l = a[r];
213
+ l !== void 0 && i >= l.from && i < l.to || t.push({ from: i, to: u, href: s[1], label: s[0], kind: "id" });
214
+ }
215
+ return t.sort((s, i) => s.from - i.from);
216
+ }
217
+ const O = ie(Re);
218
+ function q(n) {
219
+ return O.getEntry(n);
220
+ }
221
+ function L(n) {
222
+ return O.get(n);
223
+ }
224
+ function f(n) {
225
+ return (e) => n(L(e.state), e.activeLineNumbers);
226
+ }
227
+ function A(n, e, t) {
228
+ const { roleOf: a, className: o, widgetFor: r } = t, s = [];
229
+ for (const i of n.lines) {
230
+ const u = a(i);
231
+ u !== null && ((u === "opener" || s.length === 0) && s.push([]), s[s.length - 1].push(i));
232
+ }
233
+ return s.flatMap((i) => {
234
+ const u = i[0], l = i[i.length - 1], c = [{ type: "lineRange", from: u.from, to: l.to, className: o }];
235
+ for (const h of i) {
236
+ const d = a(h);
237
+ if (!(d === "opener" || d === "closer") || e.has(h.line))
238
+ continue;
239
+ const g = r?.(h);
240
+ c.push(
241
+ g ? { type: "replace", from: h.from, to: h.to, widget: g } : { type: "replace", from: h.from, to: h.to }
242
+ );
243
+ }
244
+ return c;
245
+ });
246
+ }
247
+ function I(n) {
248
+ return {
249
+ [`.${n}`]: {
250
+ whiteSpace: "pre"
251
+ }
252
+ };
253
+ }
254
+ const v = "mbox-hatena-quote-block", Q = "mbox-hatena-quote", N = "mbox-hatena-quote-cite", Ue = "#cbd5e1", S = 0.9, je = 16;
255
+ function Ve(n) {
256
+ const e = Math.min(n, je);
257
+ return `padding-left:calc(${e} * ${S}em + 0.5em);background:repeating-linear-gradient(to right, ${Ue} 0 3px, transparent 3px ${S}em) 0 0/calc(${e} * ${S}em) 100% no-repeat,rgba(148, 163, 184, 0.06);`;
258
+ }
259
+ class Ze extends b {
260
+ constructor(e) {
261
+ super(), this.url = e;
262
+ }
263
+ url;
264
+ eq(e) {
265
+ return this.constructor === e.constructor && this.url === e.url;
266
+ }
267
+ toDOM() {
268
+ const e = document.createElement("cite");
269
+ e.className = N;
270
+ const t = document.createElement("a");
271
+ return t.href = this.url, t.textContent = this.url, t.rel = "noreferrer", e.append("— ", t), e;
272
+ }
273
+ }
274
+ function Xe(n, e) {
275
+ const t = [];
276
+ for (const a of n.lines) {
277
+ if (!a.quote)
278
+ continue;
279
+ const o = t[t.length - 1];
280
+ (!o || o[o.length - 1].line !== a.line - 1) && t.push([]), t[t.length - 1].push(a);
281
+ }
282
+ return t.flatMap((a) => {
283
+ const o = [
284
+ { type: "lineRange", from: a[0].from, to: a[a.length - 1].to, className: v }
285
+ ];
286
+ for (const r of a) {
287
+ if (!r.quote)
288
+ continue;
289
+ if (o.push({
290
+ type: "line",
291
+ from: r.from,
292
+ className: Q,
293
+ attributes: { style: Ve(r.quote.depth) }
294
+ }), (r.quote.role === "open" || r.quote.role === "close") && !e.has(r.line)) {
295
+ const i = r.quote.role === "open" && r.quote.cite ? new Ze(r.quote.cite) : void 0;
296
+ o.push({ type: "replace", from: r.from, to: r.to, widget: i });
297
+ }
298
+ }
299
+ return o;
300
+ });
301
+ }
302
+ function Ye() {
303
+ return {
304
+ theme: {
305
+ // The bars and box tint live in the per-line inline background (they depend
306
+ // on depth); the run only owns its top/bottom edges and the text colour.
307
+ [`.${v}-first`]: { borderTop: "1px solid #e2e8f0" },
308
+ [`.${v}-last`]: { borderBottom: "1px solid #e2e8f0" },
309
+ [`.${Q}`]: { color: "#475569" },
310
+ [`.${N}`]: { color: "#64748b", fontSize: "0.85em", fontStyle: "normal" },
311
+ [`.${N} a`]: { color: "inherit" }
312
+ },
313
+ name: "hatena/blockquote",
314
+ decorations: f(Xe)
315
+ };
316
+ }
317
+ const P = "mbox-hatena-deflist", z = "mbox-hatena-deflist-cont", _ = "mbox-hatena-deflist-term";
318
+ function Ge(n, e) {
319
+ return n.lines.flatMap((t) => {
320
+ const a = t.definition;
321
+ if (!a)
322
+ return [];
323
+ const o = a.continuation ? `${P} ${z}` : P, r = [{ type: "line", from: t.from, className: o }];
324
+ return e.has(t.line) || (r.push({ type: "replace", from: a.marker.from, to: a.marker.to }), a.term && r.push($e(a.term.from, a.term.to, _)), a.separator && r.push({ type: "replace", from: a.separator.from, to: a.separator.to })), r;
325
+ });
326
+ }
327
+ function Je() {
328
+ return {
329
+ theme: {
330
+ // The description (dd) is indented; the term (dt) hangs back to the left
331
+ // edge via a negative margin so it aligns with the `:` column.
332
+ [`.${P}`]: { paddingLeft: "2.2em" },
333
+ // The continuation line is a bare dd: indented like the description, no
334
+ // term of its own.
335
+ [`.${z}`]: { paddingLeft: "2.2em" },
336
+ // The term renders as its own block, so the description flows onto the next
337
+ // visual row — matching Hatena's stacked <dt>/<dd>.
338
+ [`.${_}`]: { display: "block", marginLeft: "-2.2em", fontWeight: "700" }
339
+ },
340
+ name: "hatena/definition",
341
+ decorations: f(Ge)
342
+ };
343
+ }
344
+ const K = "mbox-hatena-footnote", U = "mbox-hatena-footnote-line";
345
+ class et extends b {
346
+ constructor(e, t) {
347
+ super(), this.number = e, this.note = t;
348
+ }
349
+ number;
350
+ note;
351
+ eq(e) {
352
+ const t = e;
353
+ return this.constructor === e.constructor && this.number === t.number && this.note === t.note;
354
+ }
355
+ toDOM() {
356
+ const e = document.createElement("sup");
357
+ return e.className = K, e.textContent = `*${this.number}`, e.setAttribute("role", "doc-footnote"), e.setAttribute("aria-label", `Footnote ${this.number}: ${this.note}`), this.note && (e.title = this.note), e;
358
+ }
359
+ }
360
+ function tt(n, e, t) {
361
+ return n.lines.flatMap((a) => {
362
+ if (a.footnotes.length === 0)
363
+ return [];
364
+ const o = t.has(a.line);
365
+ return [
366
+ { type: "line", from: a.from, className: U },
367
+ ...a.footnotes.flatMap(
368
+ (r) => B(r.marker, o, e, () => new et(r.number, r.text))
369
+ )
370
+ ];
371
+ });
372
+ }
373
+ function nt() {
374
+ return {
375
+ theme: {
376
+ [`.${K}`]: {
377
+ color: "var(--mbox-hatena-footnote-color, #119e4d)",
378
+ cursor: "help",
379
+ fontSize: "0.75em",
380
+ padding: "0 0.15em",
381
+ // Lift the number like a superscript WITHOUT growing the line box: baseline
382
+ // alignment + a relative offset + zero line-height keep it out of layout, so
383
+ // the row height is set solely by the footnote-line rule below (and stays
384
+ // equal to the active line, which has no sup).
385
+ verticalAlign: "baseline",
386
+ position: "relative",
387
+ top: "-0.35em",
388
+ lineHeight: "0"
389
+ },
390
+ // Hold every footnote line at the same (slightly taller) height, active or
391
+ // not, so focus — which swaps the sup for raw text — never changes it.
392
+ [`.${U}`]: { lineHeight: "1.5" }
393
+ },
394
+ name: "hatena/footnote",
395
+ decorations: (n) => tt(L(n.state), n.state.doc, n.activeLineNumbers)
396
+ };
397
+ }
398
+ const at = "mbox-hatena-heading", x = {
399
+ h3: "mbox-hatena-h3",
400
+ h4: "mbox-hatena-h4",
401
+ h5: "mbox-hatena-h5"
402
+ };
403
+ function ot(n) {
404
+ return `${at} ${x[`h${n}`]}`;
405
+ }
406
+ function rt(n, e) {
407
+ return n.lines.flatMap((t) => {
408
+ if (!t.heading)
409
+ return [];
410
+ const a = [
411
+ { type: "line", from: t.from, className: ot(t.heading.level) }
412
+ ];
413
+ return e.has(t.line) || a.push({ type: "replace", from: t.heading.marker.from, to: t.heading.marker.to }), a;
414
+ });
415
+ }
416
+ function st() {
417
+ return {
418
+ name: "hatena/heading",
419
+ decorations: f(rt)
420
+ };
421
+ }
422
+ const w = "mbox-hatena-link", it = (n) => `/${n}`;
423
+ class lt extends b {
424
+ constructor(e, t, a) {
425
+ super(), this.href = e, this.label = t, this.kind = a;
426
+ }
427
+ href;
428
+ label;
429
+ kind;
430
+ // eq() lets CodeMirror REUSE the produced DOM instead of rebuilding it. Every
431
+ // field that affects the rendered anchor is compared; the constructor guard
432
+ // keeps a subclass from ever comparing equal to this base.
433
+ eq(e) {
434
+ return this.constructor === e.constructor && this.href === e.href && this.label === e.label && this.kind === e.kind;
435
+ }
436
+ toDOM() {
437
+ const e = `${w} ${w}-${this.kind}`;
438
+ return le({
439
+ href: this.href,
440
+ text: this.label,
441
+ className: e,
442
+ attributes: this.kind !== "id" ? { target: "_blank", rel: "noreferrer" } : void 0
443
+ });
444
+ }
445
+ }
446
+ function ct(n, e, t, a) {
447
+ return n.lines.flatMap(
448
+ (o) => o.links.flatMap(
449
+ (r) => B(r, t.has(o.line), e, () => {
450
+ const s = r.kind === "id" ? a(r.href) : r.href;
451
+ return new lt(s, r.label, r.kind);
452
+ })
453
+ )
454
+ );
455
+ }
456
+ function ut(n = {}) {
457
+ const e = n.idUrl ?? it;
458
+ return {
459
+ name: "hatena/link",
460
+ decorations: (t) => ct(L(t.state), t.state.doc, t.activeLineNumbers, e)
461
+ };
462
+ }
463
+ const j = "mbox-hatena-list", ht = "mbox-hatena-list-active", mt = "mbox-hatena-list-collapsed", V = "mbox-hatena-list-marker", Z = "mbox-hatena-list-indent", C = "mbox-hatena-list-marker-slot", X = "mbox-hatena-list-marker-slot-active", Y = "mbox-hatena-list-marker-slot-collapsed", G = "mbox-hatena-list-marker-slot-ordered", pt = "--mbox-hatena-list-depth", y = "--mbox-hatena-list-hang", J = 1.2, k = 1;
464
+ class ft extends b {
465
+ constructor(e, t, a) {
466
+ super(), this.depth = e, this.active = t, this.ordinal = a;
467
+ }
468
+ depth;
469
+ active;
470
+ ordinal;
471
+ eq(e) {
472
+ const t = e;
473
+ return this.constructor === e.constructor && this.depth === t.depth && this.active === t.active && this.ordinal === t.ordinal;
474
+ }
475
+ toDOM() {
476
+ const e = document.createElement("span");
477
+ e.className = V;
478
+ for (let t = 0; t < this.depth; t += 1) {
479
+ const a = t === this.depth - 1, o = document.createElement("span");
480
+ a && this.ordinal !== null ? (o.className = `${C} ${G}`, o.textContent = `${this.ordinal}.`) : a ? (o.className = [
481
+ C,
482
+ this.active ? X : Y
483
+ ].join(" "), o.textContent = "​") : (o.className = Z, o.textContent = "​"), e.appendChild(o);
484
+ }
485
+ return e;
486
+ }
487
+ ignoreEvent() {
488
+ return !1;
489
+ }
490
+ }
491
+ function dt(n) {
492
+ return k + Math.max(0, n - 1) * J;
493
+ }
494
+ function gt(n, e) {
495
+ return n.lines.flatMap((t) => {
496
+ if (!t.list)
497
+ return [];
498
+ const a = e.has(t.line), o = [
499
+ j,
500
+ a ? ht : mt
501
+ ].join(" ");
502
+ return [
503
+ {
504
+ type: "line",
505
+ from: t.from,
506
+ className: o,
507
+ attributes: {
508
+ style: `${pt}:${t.list.depth}; ${y}: ${dt(
509
+ t.list.depth
510
+ )}em`
511
+ }
512
+ },
513
+ {
514
+ type: "replace",
515
+ from: t.list.marker.from,
516
+ to: t.list.marker.to,
517
+ widget: new ft(t.list.depth, a, t.list.ordinal)
518
+ }
519
+ ];
520
+ });
521
+ }
522
+ function bt() {
523
+ return {
524
+ theme: {
525
+ [`.${j}`]: {
526
+ boxSizing: "border-box",
527
+ paddingLeft: `calc(6px + var(${y}, ${k}em))`,
528
+ textIndent: `calc(-1 * var(${y}, ${k}em))`
529
+ },
530
+ [`.${V}`]: {
531
+ display: "inline-block",
532
+ textIndent: "0",
533
+ whiteSpace: "pre"
534
+ },
535
+ [`.${Z}`]: {
536
+ display: "inline-block",
537
+ width: `${J}em`,
538
+ whiteSpace: "pre"
539
+ },
540
+ [`.${C}`]: {
541
+ display: "inline-block",
542
+ position: "relative",
543
+ width: `${k}em`,
544
+ whiteSpace: "pre"
545
+ },
546
+ [`.${C}::after`]: {
547
+ content: '""',
548
+ position: "absolute",
549
+ left: "0",
550
+ top: "50%",
551
+ transform: "translateY(-50%)",
552
+ pointerEvents: "none"
553
+ },
554
+ [`.${Y}::after`]: {
555
+ width: "0.4em",
556
+ height: "0.4em",
557
+ borderRadius: "50%",
558
+ background: "var(--mbox-hatena-list-marker-color, #575d63)"
559
+ },
560
+ [`.${X}::after`]: {
561
+ width: "0.65em",
562
+ height: "2px",
563
+ borderRadius: "999px",
564
+ background: "var(--mbox-hatena-list-active-marker-color, #575d63)"
565
+ },
566
+ [`.${G}`]: {
567
+ // The number sits right-aligned against the content, like an <ol> marker.
568
+ textAlign: "right",
569
+ paddingRight: "0.25em",
570
+ color: "var(--mbox-hatena-list-marker-color, #575d63)"
571
+ }
572
+ },
573
+ name: "hatena/list",
574
+ decorations: f(gt)
575
+ };
576
+ }
577
+ const M = "mbox-hatena-pre";
578
+ function xt(n, e) {
579
+ return A(n, e, {
580
+ roleOf: (t) => t.pre,
581
+ className: M
582
+ });
583
+ }
584
+ function kt() {
585
+ return {
586
+ theme: I(M),
587
+ name: "hatena/pre",
588
+ decorations: f(xt)
589
+ };
590
+ }
591
+ const H = "mbox-hatena-superpre", ee = "mbox-hatena-superpre-lang";
592
+ class Ct extends b {
593
+ constructor(e) {
594
+ super(), this.language = e;
595
+ }
596
+ language;
597
+ eq(e) {
598
+ return this.constructor === e.constructor && this.language === e.language;
599
+ }
600
+ toDOM() {
601
+ const e = document.createElement("span");
602
+ return e.className = ee, e.textContent = this.language, e;
603
+ }
604
+ }
605
+ function Lt(n, e) {
606
+ return A(n, e, {
607
+ roleOf: (t) => t.superPre,
608
+ className: H,
609
+ // A `>|lang|` opener becomes a small language label instead of vanishing.
610
+ widgetFor: (t) => t.superPre === "opener" && t.superPreLang ? new Ct(t.superPreLang) : void 0
611
+ });
612
+ }
613
+ function $t() {
614
+ return {
615
+ theme: I(H),
616
+ name: "hatena/super-pre",
617
+ decorations: f(Lt)
618
+ };
619
+ }
620
+ const te = "mbox-hatena-superpre-token";
621
+ function St(n, e) {
622
+ const t = [];
623
+ let a = null;
624
+ for (const o of n.lines)
625
+ o.superPre === "opener" ? (a = { language: o.superPreLang, segments: [] }, t.push(a)) : o.superPre === "body" && a ? a.segments.push({ from: o.from, to: o.to, text: e.slice(o.from, o.to) }) : o.superPre === "closer" && (a = null);
626
+ return t;
627
+ }
628
+ function D(n, e, t) {
629
+ return St(n, e).flatMap((a) => {
630
+ const o = a.language ? t(a.language) : null;
631
+ return o ? ue(a.segments, o, te) : [];
632
+ });
633
+ }
634
+ function vt(n = {}) {
635
+ if (!n.languages)
636
+ return {
637
+ name: "hatena/super-pre-highlight",
638
+ decorations: (t) => {
639
+ const { input: a, document: o } = q(t.state);
640
+ return D(o, a, he);
641
+ }
642
+ };
643
+ const e = ce(
644
+ (t) => L(t).lines.map((a) => a.superPreLang).filter((a) => a !== null),
645
+ {
646
+ ...n.languages === "all" ? {} : { languages: n.languages },
647
+ onLoadError: n.onLoadError
648
+ }
649
+ );
650
+ return {
651
+ extensions: [e.extension],
652
+ name: "hatena/super-pre-highlight",
653
+ decorations: (t) => {
654
+ const { input: a, document: o } = q(t.state);
655
+ return D(o, a, e.getLanguage);
656
+ }
657
+ };
658
+ }
659
+ const ne = "mbox-hatena-table-rendered", ae = "mbox-hatena-table-raw-cell", m = {
660
+ table: "mbox-hatena-table",
661
+ row: "mbox-hatena-table-row",
662
+ cell: "mbox-hatena-table-cell",
663
+ headerCell: "mbox-hatena-table-header-cell",
664
+ rendered: ne,
665
+ rawCell: ae
666
+ }, F = {
667
+ table: m.table,
668
+ renderedLine: ne,
669
+ cell: m.cell,
670
+ rawCell: ae
671
+ };
672
+ function Nt(n, e) {
673
+ return n.tables.flatMap((t) => wt(t, e));
674
+ }
675
+ function Pt(n) {
676
+ return n.rows.map((e) => ({
677
+ className: m.row,
678
+ line: e.line,
679
+ from: e.from,
680
+ to: e.to,
681
+ cells: e.cells.map((t) => ({
682
+ ...t,
683
+ className: t.header ? m.headerCell : void 0
684
+ }))
685
+ }));
686
+ }
687
+ function wt(n, e) {
688
+ const t = Pt(n);
689
+ return [
690
+ ...me(t, e, F, { tableId: `hatena-table-${n.from}` }),
691
+ ...pe(t, e, { tableId: `hatena-table-${n.from}` }),
692
+ ...fe(t, e, F, { measureWidth: de }, { tableId: `hatena-table-${n.from}`, isHeaderCell: (a, o, r) => !!a.cells[r]?.className }),
693
+ ...n.rows.flatMap((a) => yt(a, e.has(a.line))),
694
+ ...n.rows.flatMap((a) => Mt(a, e.has(a.line))),
695
+ ...ge(t, e)
696
+ ];
697
+ }
698
+ function yt(n, e) {
699
+ return e ? [] : n.cells.flatMap((t) => {
700
+ const a = t.marker ? t.marker.from : t.content.from, o = Ht(t);
701
+ return [
702
+ { type: "replace", from: t.from, to: a },
703
+ { type: "replace", from: o.to, to: t.to }
704
+ ];
705
+ });
706
+ }
707
+ function Mt(n, e) {
708
+ return e ? [] : n.cells.flatMap(
709
+ (t) => t.marker ? [{ type: "replace", from: t.marker.from, to: t.marker.to }] : []
710
+ );
711
+ }
712
+ function Ht(n) {
713
+ return n.content.from < n.content.to ? n.content : { from: n.from, to: n.to };
714
+ }
715
+ function Rt() {
716
+ return {
717
+ theme: {
718
+ [`.${m.table}`]: {
719
+ fontFamily: 'var(--mbox-table-font-family, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace)'
720
+ },
721
+ [`.${m.cell}`]: {
722
+ width: "var(--mbox-table-cell-width, var(--mbox-table-kit-column-width))",
723
+ maxWidth: "var(--mbox-table-kit-cell-max-width, 100%)",
724
+ minWidth: 0,
725
+ overflowWrap: "anywhere"
726
+ },
727
+ // Both classes: a raw cell carries the base cell class too, so a
728
+ // single-class rule would only win by being written second.
729
+ [`.${m.cell}.${m.rawCell}`]: {
730
+ width: "auto",
731
+ maxWidth: "none",
732
+ minWidth: "auto"
733
+ }
734
+ },
735
+ name: "hatena/table",
736
+ decorations: f(Nt)
737
+ };
738
+ }
739
+ function Et(n) {
740
+ return n === !0 ? void 0 : n || void 0;
741
+ }
742
+ function Tt(n = {}) {
743
+ return [
744
+ // Super-pre first: it owns the literal block. The other plugins produce no
745
+ // specs for its lines because the parser leaves them syntax-free — including
746
+ // the table plugin, which never groups a super-pre line into a table.
747
+ $t(),
748
+ ...n.codeHighlight ? [vt(Et(n.codeHighlight))] : [],
749
+ kt(),
750
+ Ye(),
751
+ st(),
752
+ bt(),
753
+ Je(),
754
+ ut(n.link),
755
+ nt(),
756
+ Rt()
757
+ ];
758
+ }
759
+ const qt = "var(--mbox-hatena-literal-font-family, ui-monospace, SFMono-Regular, Menlo, monospace)";
760
+ function W(n, e) {
761
+ return {
762
+ [`.${n}`]: { fontFamily: qt, background: e },
763
+ [`.${n}-first`]: { borderTopLeftRadius: "4px", borderTopRightRadius: "4px" },
764
+ [`.${n}-last`]: { borderBottomLeftRadius: "4px", borderBottomRightRadius: "4px" }
765
+ };
766
+ }
767
+ const Dt = {
768
+ ...xe([te]),
769
+ ...be([
770
+ { level: 3, className: x.h3 },
771
+ { level: 4, className: x.h4 },
772
+ { level: 5, className: x.h5 }
773
+ ]),
774
+ [`.${w}`]: {
775
+ color: "var(--mbox-hatena-link-color, #2563eb)",
776
+ textDecoration: "underline",
777
+ cursor: "pointer"
778
+ },
779
+ // TRANSLUCENT on purpose: these classes sit on `.cm-line` elements, which
780
+ // paint *above* CodeMirror's selection layer (drawSelection's
781
+ // `.cm-selectionLayer` is at a negative z-index, behind the content) -- an
782
+ // opaque background hides the selection highlight underneath. A translucent
783
+ // tint lets the selection blend through; the same rule the scrapbox quote
784
+ // background documents. Values composite on white to the previous opaque
785
+ // defaults (#f8fafc / #f1f5f9).
786
+ ...W(M, "var(--mbox-hatena-pre-background, rgba(148, 163, 184, 0.06))"),
787
+ ...W(
788
+ H,
789
+ "var(--mbox-hatena-superpre-background, rgba(148, 163, 184, 0.12))"
790
+ ),
791
+ [`.${ee}`]: {
792
+ color: "var(--mbox-hatena-superpre-lang-color, #64748b)",
793
+ fontFamily: "var(--mbox-hatena-superpre-lang-font-family, ui-sans-serif, system-ui, sans-serif)",
794
+ fontSize: "var(--mbox-hatena-superpre-lang-font-size, 0.8em)",
795
+ fontWeight: "var(--mbox-hatena-superpre-lang-font-weight, 600)"
796
+ }
797
+ };
798
+ function Ft() {
799
+ return Le.theme(Dt);
800
+ }
801
+ function Wt(n = {}) {
802
+ return Ce(n, Tt(n), Ft);
803
+ }
804
+ function It(n) {
805
+ const { parent: e, ...t } = n;
806
+ return ke({ parent: e, state: Wt(t) });
807
+ }
808
+ export {
809
+ et as HatenaFootnoteWidget,
810
+ lt as HatenaLinkWidget,
811
+ Ct as HatenaSuperPreLangWidget,
812
+ It as createHatenaEditor,
813
+ Wt as createHatenaEditorState,
814
+ L as getHatenaDocumentFromState,
815
+ Ye as hatenaBlockquotePlugin,
816
+ Ft as hatenaDefaultPresentationTheme,
817
+ Dt as hatenaDefaultPresentationThemeSpec,
818
+ z as hatenaDefinitionContinuationClassName,
819
+ P as hatenaDefinitionLineClassName,
820
+ Je as hatenaDefinitionPlugin,
821
+ _ as hatenaDefinitionTermClassName,
822
+ K as hatenaFootnoteClassName,
823
+ U as hatenaFootnoteLineClassName,
824
+ nt as hatenaFootnotePlugin,
825
+ x as hatenaHeadingClassNames,
826
+ at as hatenaHeadingLineClassName,
827
+ st as hatenaHeadingPlugin,
828
+ w as hatenaLinkClassName,
829
+ ut as hatenaLinkPlugin,
830
+ ht as hatenaListActiveClassName,
831
+ mt as hatenaListCollapsedClassName,
832
+ Z as hatenaListIndentClassName,
833
+ j as hatenaListLineClassName,
834
+ V as hatenaListMarkerClassName,
835
+ X as hatenaListMarkerSlotActiveClassName,
836
+ C as hatenaListMarkerSlotClassName,
837
+ Y as hatenaListMarkerSlotCollapsedClassName,
838
+ G as hatenaListMarkerSlotOrderedClassName,
839
+ bt as hatenaListPlugin,
840
+ Tt as hatenaPlugins,
841
+ M as hatenaPreClassName,
842
+ kt as hatenaPrePlugin,
843
+ v as hatenaQuoteBlockClassName,
844
+ N as hatenaQuoteCiteClassName,
845
+ Q as hatenaQuoteClassName,
846
+ H as hatenaSuperPreClassName,
847
+ vt as hatenaSuperPreHighlightPlugin,
848
+ ee as hatenaSuperPreLangClassName,
849
+ $t as hatenaSuperPrePlugin,
850
+ te as hatenaSuperPreTokenClassName,
851
+ m as hatenaTableClassNames,
852
+ Rt as hatenaTablePlugin,
853
+ ae as hatenaTableRawCellClassName,
854
+ ne as hatenaTableRenderedClassName,
855
+ Re as parseHatenaDocument
856
+ };