@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/index.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export { createEditorState, createEditorView, createMboxEditor, createMboxEditorState, defaultEditorPresentationThemeSpec, editorPresentationTheme, } from "./editor/create-editor.js";
|
|
2
|
+
export type { CreateEditorStateOptions, CreateEditorViewOptions, CreateMboxEditorOptions, CreateMboxEditorStateOptions, EditorPresentationThemeOptions, MboxEditorPresentation, MboxEditorPresentationOptions, SharedMboxEditorOptions, } from "./editor/create-editor.js";
|
|
3
|
+
export type { MboxActiveLineNumbers } from "./editor/focused-line.js";
|
|
4
|
+
export { createContentMarkSpec, createMboxExtension, } from "./editor/plugin.js";
|
|
5
|
+
export type { CreateMboxExtensionOptions, MboxDecorationError, MboxDecorationProvider, MboxDecorationContext, MboxDecorationSpec, MboxLineDecorationSpec, MboxLineRangeDecorationSpec, MboxMarkDecorationSpec, MboxReplaceDecorationSpec, MboxWidgetDecorationSpec, MboxPlugin, MboxThemeSpec, } from "./editor/plugin.js";
|
|
6
|
+
export { mboxPlugins } from "./plugins/mbox/default.js";
|
|
7
|
+
export type { MboxPluginOptions } from "./plugins/mbox/default.js";
|
|
8
|
+
export { CodeBlockCopyButtonWidget, codeBlockClassNames, codeBlockHighlightClassNames, codeBlockHighlightPlugin, codeBlockPlugin, getCodeBlockLanguageId, } from "./plugins/mbox/code-block.js";
|
|
9
|
+
export type { CodeBlockHighlightPluginOptions } from "./plugins/mbox/code-block.js";
|
|
10
|
+
export { insertMboxBracketPair, mboxBracketPlugin } from "./plugins/mbox/bracket.js";
|
|
11
|
+
export { completionClassNames, completionOptionClassName, completionOptionWithPreviewClassName, completionPreviewClassName, completionPreviewImageClassName, mboxCompletePlugin, } from "./plugins/mbox/complete.js";
|
|
12
|
+
export type { MboxCompletePluginOptions, MboxCompletionCandidate, MboxRecommend } from "./plugins/mbox/complete.js";
|
|
13
|
+
export { emojiClassName, emojiPlugin } from "./plugins/mbox/emoji.js";
|
|
14
|
+
export { headingClassNames, headingPlugin } from "./plugins/mbox/heading.js";
|
|
15
|
+
export { inlineCodeClassName, inlineCodeClassNames, inlineCodePlugin } from "./plugins/mbox/inline-code.js";
|
|
16
|
+
export { inlineStyleClassNames, inlineStylePlugin } from "./plugins/mbox/inline-style.js";
|
|
17
|
+
export { listClassNames, listPlugin } from "./plugins/mbox/list.js";
|
|
18
|
+
export { runListDeleteBackward, runListDeleteForward, runListEnter, runListIndent, runListLineStart, runListOutdent, runListSpace, } from "./plugins/mbox/list.js";
|
|
19
|
+
export { markdownImageClassName, markdownImageClassNames, markdownImagePlugin } from "./plugins/mbox/markdown-image.js";
|
|
20
|
+
export type { MarkdownImagePluginOptions, MarkdownImageRenderMode } from "./plugins/mbox/markdown-image.js";
|
|
21
|
+
export { MboxIconWidget, iconClassName, iconImageClassName, pageLinkClassName, pageLinkPlugin } from "./plugins/mbox/page-link.js";
|
|
22
|
+
export type { PageLinkPluginOptions } from "./plugins/mbox/page-link.js";
|
|
23
|
+
export { MboxFootnoteRefWidget, mboxFootnoteClassName, mboxFootnoteMarkerClassName, mboxFootnotePlugin, mboxFootnoteRefClassName, } from "./plugins/mbox/footnote.js";
|
|
24
|
+
export { paragraphClassNames, paragraphPlugin } from "./plugins/mbox/paragraph.js";
|
|
25
|
+
export { quoteClassNames, quotePlugin } from "./plugins/mbox/quote.js";
|
|
26
|
+
export { tableClassNames, tablePlugin, tableRawCellClassName, tableRenderedClassName } from "./plugins/mbox/table.js";
|
|
27
|
+
export { taskListClassNames, taskListPlugin } from "./plugins/mbox/task-list.js";
|
|
28
|
+
export { urlLinkClassName, urlLinkPlugin } from "./plugins/mbox/url-link.js";
|
|
29
|
+
export { parseMboxDocument } from "./plugins/mbox/parser.js";
|
|
30
|
+
export { getMboxDocumentFromState } from "./plugins/mbox/parser-cache.js";
|
|
31
|
+
export type { MboxAutoLinkNode, MboxBaseBlock, MboxBlock, MboxCodeBlock, MboxDocument, MboxEmojiNode, MboxFootnoteDefinitionBlock, MboxFootnoteRefNode, MboxHeadingBlock, MboxIconNode, MboxInlineCodeNode, MboxInlineNode, MboxInlineStyleNode, MboxInlineTextNode, MboxListItemBlock, MboxMarkdownImageNode, MboxMarkdownLinkNode, MboxParagraphBlock, MboxQuoteBlock, MboxRange, MboxTableBlock, MboxTableCell, MboxTableRow, MboxTaskListItemBlock, MboxWikiLinkNode, } from "./plugins/mbox/types.js";
|
|
32
|
+
export { ImageKitMeasureWidget, ImageKitPreviewWidget, ImageKitTokenWidget } from "./plugins/image-kit.js";
|
|
33
|
+
export type { ImageKitClassNames, ImageKitImage, ImageKitMeasureClassNames } from "./plugins/image-kit.js";
|
|
34
|
+
export { mboxDefaultPresentationTheme, mboxDefaultPresentationThemeSpec } from "./themes/default-presentation.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { C as s, I as t, a as o, b as i, M as n, c as l, d as m, e as r, f as g, g as u, h as C, i as c, j as d, k as N, l as P, m as b, n as p, o as k, p as x, q as L, r as h, s as w, t as I, u as M, v as B, w as S, x as f, y as E, z as F, A as W, B as D, D as T, E as v, F as R, G as y, H as K, J as O, K as j, L as q, N as H, O as V, P as z, Q as A, R as G, S as J, T as Q, U, V as X, W as Y, X as Z, Y as _, Z as $, _ as aa, $ as ea, a0 as sa, a1 as ta, a2 as oa, a3 as ia, a4 as na, a5 as la, a6 as ma, a7 as ra, a8 as ga, a9 as ua, aa as Ca, ab as ca, ac as da, ad as Na, ae as Pa, af as ba, ag as pa } from "./create-editor-BKTpQ8TK.js";
|
|
2
|
+
import { c as xa, a as La } from "./plugin-DI0ubB-M.js";
|
|
3
|
+
export {
|
|
4
|
+
s as CodeBlockCopyButtonWidget,
|
|
5
|
+
t as ImageKitMeasureWidget,
|
|
6
|
+
o as ImageKitPreviewWidget,
|
|
7
|
+
i as ImageKitTokenWidget,
|
|
8
|
+
n as MboxFootnoteRefWidget,
|
|
9
|
+
l as MboxIconWidget,
|
|
10
|
+
m as codeBlockClassNames,
|
|
11
|
+
r as codeBlockHighlightClassNames,
|
|
12
|
+
g as codeBlockHighlightPlugin,
|
|
13
|
+
u as codeBlockPlugin,
|
|
14
|
+
C as completionClassNames,
|
|
15
|
+
c as completionOptionClassName,
|
|
16
|
+
d as completionOptionWithPreviewClassName,
|
|
17
|
+
N as completionPreviewClassName,
|
|
18
|
+
P as completionPreviewImageClassName,
|
|
19
|
+
xa as createContentMarkSpec,
|
|
20
|
+
b as createEditorState,
|
|
21
|
+
p as createEditorView,
|
|
22
|
+
k as createMboxEditor,
|
|
23
|
+
x as createMboxEditorState,
|
|
24
|
+
La as createMboxExtension,
|
|
25
|
+
L as defaultEditorPresentationThemeSpec,
|
|
26
|
+
h as editorPresentationTheme,
|
|
27
|
+
w as emojiClassName,
|
|
28
|
+
I as emojiPlugin,
|
|
29
|
+
M as getCodeBlockLanguageId,
|
|
30
|
+
B as getMboxDocumentFromState,
|
|
31
|
+
S as headingClassNames,
|
|
32
|
+
f as headingPlugin,
|
|
33
|
+
E as iconClassName,
|
|
34
|
+
F as iconImageClassName,
|
|
35
|
+
W as inlineCodeClassName,
|
|
36
|
+
D as inlineCodeClassNames,
|
|
37
|
+
T as inlineCodePlugin,
|
|
38
|
+
v as inlineStyleClassNames,
|
|
39
|
+
R as inlineStylePlugin,
|
|
40
|
+
y as insertMboxBracketPair,
|
|
41
|
+
K as listClassNames,
|
|
42
|
+
O as listPlugin,
|
|
43
|
+
j as markdownImageClassName,
|
|
44
|
+
q as markdownImageClassNames,
|
|
45
|
+
H as markdownImagePlugin,
|
|
46
|
+
V as mboxBracketPlugin,
|
|
47
|
+
z as mboxCompletePlugin,
|
|
48
|
+
A as mboxDefaultPresentationTheme,
|
|
49
|
+
G as mboxDefaultPresentationThemeSpec,
|
|
50
|
+
J as mboxFootnoteClassName,
|
|
51
|
+
Q as mboxFootnoteMarkerClassName,
|
|
52
|
+
U as mboxFootnotePlugin,
|
|
53
|
+
X as mboxFootnoteRefClassName,
|
|
54
|
+
Y as mboxPlugins,
|
|
55
|
+
Z as pageLinkClassName,
|
|
56
|
+
_ as pageLinkPlugin,
|
|
57
|
+
$ as paragraphClassNames,
|
|
58
|
+
aa as paragraphPlugin,
|
|
59
|
+
ea as parseMboxDocument,
|
|
60
|
+
sa as quoteClassNames,
|
|
61
|
+
ta as quotePlugin,
|
|
62
|
+
oa as runListDeleteBackward,
|
|
63
|
+
ia as runListDeleteForward,
|
|
64
|
+
na as runListEnter,
|
|
65
|
+
la as runListIndent,
|
|
66
|
+
ma as runListLineStart,
|
|
67
|
+
ra as runListOutdent,
|
|
68
|
+
ga as runListSpace,
|
|
69
|
+
ua as tableClassNames,
|
|
70
|
+
Ca as tablePlugin,
|
|
71
|
+
ca as tableRawCellClassName,
|
|
72
|
+
da as tableRenderedClassName,
|
|
73
|
+
Na as taskListClassNames,
|
|
74
|
+
Pa as taskListPlugin,
|
|
75
|
+
ba as urlLinkClassName,
|
|
76
|
+
pa as urlLinkPlugin
|
|
77
|
+
};
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { StateField as E, StateEffect as h, Facet as g, Prec as N } from "@codemirror/state";
|
|
2
|
+
import { EditorView as w, keymap as S, ViewPlugin as y, Decoration as f } from "@codemirror/view";
|
|
3
|
+
const v = h.define(), p = h.define(), b = E.define({
|
|
4
|
+
create: () => /* @__PURE__ */ new Map(),
|
|
5
|
+
update(e, t) {
|
|
6
|
+
let n = e;
|
|
7
|
+
for (const r of t.effects)
|
|
8
|
+
if (r.is(v) && (n = new Map(n).set(r.value.pointerId, r.value.lineNumber)), r.is(p) && n.has(r.value)) {
|
|
9
|
+
const o = new Map(n);
|
|
10
|
+
o.delete(r.value), n = o;
|
|
11
|
+
}
|
|
12
|
+
return n;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
function P(e) {
|
|
16
|
+
const t = /* @__PURE__ */ new Set();
|
|
17
|
+
for (const n of e.selection.ranges) {
|
|
18
|
+
const r = Math.min(Math.max(n.from, 0), e.doc.length), o = Math.min(Math.max(n.to, 0), e.doc.length), a = r === o ? o : Math.max(r, o - 1), i = e.doc.lineAt(r).number, s = e.doc.lineAt(a).number;
|
|
19
|
+
for (let l = i; l <= s; l += 1)
|
|
20
|
+
t.add(l);
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
}
|
|
24
|
+
function R(e) {
|
|
25
|
+
if (e.hasFocus === !1)
|
|
26
|
+
return /* @__PURE__ */ new Set();
|
|
27
|
+
const t = P(e.state), n = e.state.field(b, !1);
|
|
28
|
+
if (n !== void 0)
|
|
29
|
+
for (const r of n.values())
|
|
30
|
+
t.delete(r);
|
|
31
|
+
return t;
|
|
32
|
+
}
|
|
33
|
+
const M = g.define({
|
|
34
|
+
combine: (e) => [...e]
|
|
35
|
+
});
|
|
36
|
+
function H(e, t) {
|
|
37
|
+
return f.set(
|
|
38
|
+
t.flatMap((n) => x(n, e)),
|
|
39
|
+
!0
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
function K(e, t, n, r) {
|
|
43
|
+
return {
|
|
44
|
+
type: "mark",
|
|
45
|
+
from: e,
|
|
46
|
+
to: t,
|
|
47
|
+
className: n,
|
|
48
|
+
...r === void 0 ? {} : { tagName: r },
|
|
49
|
+
inclusiveStart: !0,
|
|
50
|
+
inclusiveEnd: !0
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const D = g.define({
|
|
54
|
+
combine: (e) => [...e]
|
|
55
|
+
}), L = w.decorations.of((e) => {
|
|
56
|
+
const t = e.state.facet(M);
|
|
57
|
+
if (t.length === 0)
|
|
58
|
+
return m([]);
|
|
59
|
+
const n = e.state.facet(D), r = (s) => {
|
|
60
|
+
for (const l of n)
|
|
61
|
+
try {
|
|
62
|
+
l(s);
|
|
63
|
+
} catch {
|
|
64
|
+
}
|
|
65
|
+
}, o = B(e), a = T(t.flatMap((s) => {
|
|
66
|
+
if (!s.firewallRanges) return [];
|
|
67
|
+
try {
|
|
68
|
+
return s.firewallRanges(o);
|
|
69
|
+
} catch (l) {
|
|
70
|
+
return r({ phase: "provider", error: l, pluginName: s.pluginName, pluginIndex: s.pluginIndex }), [];
|
|
71
|
+
}
|
|
72
|
+
})), i = [];
|
|
73
|
+
for (const s of t) {
|
|
74
|
+
let l;
|
|
75
|
+
try {
|
|
76
|
+
l = s.provider(o);
|
|
77
|
+
} catch (I) {
|
|
78
|
+
r({ phase: "provider", error: I, pluginName: s.pluginName, pluginIndex: s.pluginIndex });
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
$(
|
|
82
|
+
e.state,
|
|
83
|
+
k(l, a, s),
|
|
84
|
+
i,
|
|
85
|
+
s,
|
|
86
|
+
r
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
return m(i, r);
|
|
90
|
+
});
|
|
91
|
+
function q(e = {}) {
|
|
92
|
+
const { plugins: t = [], onDecorationError: n } = e, r = t.flatMap((i) => i.theme ? [i.theme] : []), o = t.flatMap(
|
|
93
|
+
(i, s) => i.decorations ? [{ provider: i.decorations, firewallRanges: i.decorationFirewallRanges, pluginName: i.name, pluginIndex: s }] : []
|
|
94
|
+
), a = t.flatMap((i) => i.keymap ?? []);
|
|
95
|
+
return [
|
|
96
|
+
r.map((i) => w.theme(i)),
|
|
97
|
+
o.map((i) => M.of(i)),
|
|
98
|
+
n ? D.of(n) : [],
|
|
99
|
+
b,
|
|
100
|
+
O,
|
|
101
|
+
L,
|
|
102
|
+
a.length > 0 ? N.high(S.of(a)) : [],
|
|
103
|
+
t.flatMap((i) => i.extensions ?? [])
|
|
104
|
+
];
|
|
105
|
+
}
|
|
106
|
+
function k(e, t, n) {
|
|
107
|
+
return t.length === 0 || n.firewallRanges ? e : A(e, t);
|
|
108
|
+
}
|
|
109
|
+
function T(e) {
|
|
110
|
+
const t = e.filter((r) => r.from < r.to).map((r) => ({ ...r })).sort((r, o) => r.from - o.from || r.to - o.to), n = [];
|
|
111
|
+
for (const r of t) {
|
|
112
|
+
const o = n[n.length - 1];
|
|
113
|
+
o && r.from <= o.to ? o.to = Math.max(o.to, r.to) : n.push(r);
|
|
114
|
+
}
|
|
115
|
+
return n;
|
|
116
|
+
}
|
|
117
|
+
function A(e, t) {
|
|
118
|
+
return e.filter((n) => {
|
|
119
|
+
if (n.type === "line" || n.type === "lineRange") return !0;
|
|
120
|
+
let r = 0, o = t.length;
|
|
121
|
+
for (; r < o; ) {
|
|
122
|
+
const s = Math.floor((r + o) / 2);
|
|
123
|
+
t[s].to <= n.from ? r = s + 1 : o = s;
|
|
124
|
+
}
|
|
125
|
+
const a = t[r];
|
|
126
|
+
return a ? !(n.type === "widget" ? a.from <= n.from : a.from < n.to) : !0;
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
const C = 5;
|
|
130
|
+
class F {
|
|
131
|
+
constructor(t) {
|
|
132
|
+
this.view = t, this.window = t.dom.ownerDocument.defaultView ?? window, t.contentDOM.addEventListener("pointerdown", this.onPointerDown, !0), t.contentDOM.addEventListener("click", this.onClick, !0), this.window.addEventListener("pointermove", this.onPointerMove, !0), this.window.addEventListener("pointerup", this.onPointerUp, !0), this.window.addEventListener("pointercancel", this.onPointerCancel, !0), this.window.addEventListener("blur", this.onBlur);
|
|
133
|
+
}
|
|
134
|
+
view;
|
|
135
|
+
window;
|
|
136
|
+
leases = /* @__PURE__ */ new Map();
|
|
137
|
+
releaseTimers = /* @__PURE__ */ new Map();
|
|
138
|
+
nextToken = 0;
|
|
139
|
+
destroy() {
|
|
140
|
+
this.view.contentDOM.removeEventListener("pointerdown", this.onPointerDown, !0), this.view.contentDOM.removeEventListener("click", this.onClick, !0), this.window.removeEventListener("pointermove", this.onPointerMove, !0), this.window.removeEventListener("pointerup", this.onPointerUp, !0), this.window.removeEventListener("pointercancel", this.onPointerCancel, !0), this.window.removeEventListener("blur", this.onBlur);
|
|
141
|
+
for (const t of this.releaseTimers.values())
|
|
142
|
+
clearTimeout(t);
|
|
143
|
+
this.releaseTimers.clear();
|
|
144
|
+
}
|
|
145
|
+
onPointerDown = (t) => {
|
|
146
|
+
if (this.view.state.readOnly || t.button !== 0 || !t.isPrimary)
|
|
147
|
+
return;
|
|
148
|
+
const n = d(t.target, this.view.contentDOM);
|
|
149
|
+
if (n === void 0)
|
|
150
|
+
return;
|
|
151
|
+
const r = this.view.state.doc.lineAt(this.view.posAtDOM(n, 0)).number, o = {
|
|
152
|
+
pointerId: t.pointerId,
|
|
153
|
+
lineNumber: r,
|
|
154
|
+
startX: t.clientX,
|
|
155
|
+
startY: t.clientY,
|
|
156
|
+
token: this.nextToken += 1
|
|
157
|
+
}, a = this.leases.get(o.pointerId);
|
|
158
|
+
a !== void 0 && this.release(a), this.leases.set(o.pointerId, o), this.view.dispatch({ effects: v.of({ pointerId: o.pointerId, lineNumber: r }) });
|
|
159
|
+
};
|
|
160
|
+
onPointerMove = (t) => {
|
|
161
|
+
const n = this.leases.get(t.pointerId);
|
|
162
|
+
n !== void 0 && Math.hypot(t.clientX - n.startX, t.clientY - n.startY) > C && this.release(n);
|
|
163
|
+
};
|
|
164
|
+
onPointerUp = (t) => {
|
|
165
|
+
const n = this.leases.get(t.pointerId);
|
|
166
|
+
n !== void 0 && this.scheduleRelease(n);
|
|
167
|
+
};
|
|
168
|
+
onPointerCancel = (t) => {
|
|
169
|
+
const n = this.leases.get(t.pointerId);
|
|
170
|
+
n !== void 0 && this.release(n);
|
|
171
|
+
};
|
|
172
|
+
onBlur = () => {
|
|
173
|
+
for (const t of [...this.leases.values()])
|
|
174
|
+
this.release(t);
|
|
175
|
+
};
|
|
176
|
+
onClick = (t) => {
|
|
177
|
+
const n = d(t.target, this.view.contentDOM);
|
|
178
|
+
if (n === void 0)
|
|
179
|
+
return;
|
|
180
|
+
const r = this.view.state.doc.lineAt(this.view.posAtDOM(n, 0)).number, o = [...this.leases.values()].filter((a) => a.lineNumber === r);
|
|
181
|
+
o.length === 1 && this.scheduleRelease(o[0]);
|
|
182
|
+
};
|
|
183
|
+
scheduleRelease(t) {
|
|
184
|
+
if (this.releaseTimers.has(t.pointerId))
|
|
185
|
+
return;
|
|
186
|
+
const n = setTimeout(() => {
|
|
187
|
+
this.releaseTimers.delete(t.pointerId), this.release(t);
|
|
188
|
+
}, 0);
|
|
189
|
+
this.releaseTimers.set(t.pointerId, n);
|
|
190
|
+
}
|
|
191
|
+
release(t) {
|
|
192
|
+
if (this.leases.get(t.pointerId)?.token !== t.token)
|
|
193
|
+
return;
|
|
194
|
+
const n = this.releaseTimers.get(t.pointerId);
|
|
195
|
+
n !== void 0 && (clearTimeout(n), this.releaseTimers.delete(t.pointerId)), this.leases.delete(t.pointerId), this.view.dispatch({ effects: p.of(t.pointerId) });
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
const O = y.fromClass(F);
|
|
199
|
+
function d(e, t) {
|
|
200
|
+
if (e === null || typeof e.closest != "function")
|
|
201
|
+
return;
|
|
202
|
+
const n = e.closest("a[href], [data-mbox-interaction-lease]");
|
|
203
|
+
return n !== null && t.contains(n) ? n : void 0;
|
|
204
|
+
}
|
|
205
|
+
function $(e, t, n, r, o) {
|
|
206
|
+
for (const a of t)
|
|
207
|
+
try {
|
|
208
|
+
n.push(...x(a, e));
|
|
209
|
+
} catch (i) {
|
|
210
|
+
o?.({
|
|
211
|
+
phase: "lowering",
|
|
212
|
+
error: i,
|
|
213
|
+
spec: a,
|
|
214
|
+
pluginName: r?.pluginName,
|
|
215
|
+
pluginIndex: r?.pluginIndex
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
function m(e, t) {
|
|
220
|
+
try {
|
|
221
|
+
return f.set(e, !0);
|
|
222
|
+
} catch (n) {
|
|
223
|
+
return t?.({ phase: "lowering", error: n }), f.none;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
function B(e) {
|
|
227
|
+
return {
|
|
228
|
+
state: e.state,
|
|
229
|
+
activeLineNumbers: R(e)
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
function x(e, t) {
|
|
233
|
+
return V(e, t.doc.length, t.doc).flatMap((r) => X(r, t));
|
|
234
|
+
}
|
|
235
|
+
function V(e, t, n) {
|
|
236
|
+
switch (e.type) {
|
|
237
|
+
case void 0:
|
|
238
|
+
case "mark":
|
|
239
|
+
return c(e.from, t), c(e.to, t), u(e.from, e.to), e.from === e.to ? [] : [e];
|
|
240
|
+
case "replace":
|
|
241
|
+
if (c(e.from, t), c(e.to, t), u(e.from, e.to), n?.sliceString(e.from, e.to).includes(`
|
|
242
|
+
`))
|
|
243
|
+
throw new RangeError(`Replace decorations must not span line breaks (from ${e.from} to ${e.to})`);
|
|
244
|
+
return e.from !== e.to ? [e] : e.widget ? [{ type: "widget", from: e.from, widget: e.widget }] : [];
|
|
245
|
+
case "lineRange":
|
|
246
|
+
return c(e.from, t), c(e.to, t), u(e.from, e.to), [e];
|
|
247
|
+
case "widget":
|
|
248
|
+
return c(e.from, t), [e];
|
|
249
|
+
case "line":
|
|
250
|
+
return c(e.from, t), [e];
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
function u(e, t) {
|
|
254
|
+
if (e > t)
|
|
255
|
+
throw new RangeError(`Decoration range from ${e} must not be greater than to ${t}`);
|
|
256
|
+
}
|
|
257
|
+
function c(e, t) {
|
|
258
|
+
if (!Number.isInteger(e) || e < 0 || e > t)
|
|
259
|
+
throw new RangeError(`Invalid decoration position ${e}: expected an integer from 0 to ${t}`);
|
|
260
|
+
}
|
|
261
|
+
function X(e, t) {
|
|
262
|
+
return e.type === "lineRange" ? Y(e, t) : e.type === "line" ? [
|
|
263
|
+
f.line({ class: e.className, attributes: e.attributes }).range(
|
|
264
|
+
t.doc.lineAt(e.from).from
|
|
265
|
+
)
|
|
266
|
+
] : [z(e)];
|
|
267
|
+
}
|
|
268
|
+
function Y(e, t) {
|
|
269
|
+
const n = t.doc.lineAt(e.from).number, r = t.doc.lineAt(e.to).number, o = [];
|
|
270
|
+
for (let a = n; a <= r; a += 1) {
|
|
271
|
+
const i = t.doc.line(a), s = [
|
|
272
|
+
e.className,
|
|
273
|
+
a === n ? `${e.className}-first` : "",
|
|
274
|
+
a === r ? `${e.className}-last` : ""
|
|
275
|
+
].filter(Boolean).join(" ");
|
|
276
|
+
o.push(f.line({ class: s, attributes: e.attributes }).range(i.from));
|
|
277
|
+
}
|
|
278
|
+
return o;
|
|
279
|
+
}
|
|
280
|
+
function z(e) {
|
|
281
|
+
return e.type === "replace" ? f.replace(e.widget ? { widget: e.widget } : {}).range(e.from, e.to) : e.type === "widget" ? f.widget({
|
|
282
|
+
widget: e.widget,
|
|
283
|
+
side: e.side ?? 1
|
|
284
|
+
}).range(e.from) : f.mark({
|
|
285
|
+
class: e.className,
|
|
286
|
+
tagName: e.tagName,
|
|
287
|
+
attributes: e.attributes,
|
|
288
|
+
inclusiveStart: e.inclusiveStart,
|
|
289
|
+
inclusiveEnd: e.inclusiveEnd
|
|
290
|
+
}).range(e.from, e.to);
|
|
291
|
+
}
|
|
292
|
+
export {
|
|
293
|
+
q as a,
|
|
294
|
+
H as b,
|
|
295
|
+
K as c,
|
|
296
|
+
P as g
|
|
297
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type EditorState, type TransactionSpec } from "@codemirror/state";
|
|
2
|
+
import type { MboxPlugin } from "../editor/plugin.js";
|
|
3
|
+
export interface BracketPairKitOptions {
|
|
4
|
+
open: string;
|
|
5
|
+
close: string;
|
|
6
|
+
requireNonEmptySelection?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function createBracketPairTransaction(state: EditorState, options: BracketPairKitOptions): TransactionSpec;
|
|
9
|
+
export declare function bracketPairInputPlugin(options: BracketPairKitOptions): MboxPlugin;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { Language, LRLanguage } from "@codemirror/language";
|
|
2
|
+
import { WidgetType } from "@codemirror/view";
|
|
3
|
+
import type { MboxDecorationSpec } from "../editor/plugin.js";
|
|
4
|
+
export interface CodeBlockKitRange {
|
|
5
|
+
from: number;
|
|
6
|
+
to: number;
|
|
7
|
+
}
|
|
8
|
+
/** A syntactically accepted first token from a fenced code block's info
|
|
9
|
+
* string. `from` and `to` are offsets within that string, not the document. */
|
|
10
|
+
export interface CodeBlockKitInfoStringToken extends CodeBlockKitRange {
|
|
11
|
+
value: string;
|
|
12
|
+
}
|
|
13
|
+
/** Parses a fenced code block's info string once for every consumer that needs
|
|
14
|
+
* its language token. The string may have horizontal whitespace around it and
|
|
15
|
+
* trailing metadata after the first token, but must not contain a line
|
|
16
|
+
* terminator. A rejected value is an input-boundary failure, not an unknown
|
|
17
|
+
* language: unknown ids still return a token so callers can label them. */
|
|
18
|
+
export declare function parseCodeBlockKitInfoString(infoValue: string): CodeBlockKitInfoStringToken | null;
|
|
19
|
+
/** Parses a Scrapbox-style filename. Unlike an info string, spaces are part of
|
|
20
|
+
* the value; it only shares the input boundary rule that a parser-facing value
|
|
21
|
+
* must not contain a line terminator. Horizontal surrounding whitespace is
|
|
22
|
+
* ignored without silently repairing `\r` or `\n`. */
|
|
23
|
+
export declare function parseCodeBlockKitFileName(fileName: string): string | null;
|
|
24
|
+
/** A working Copy button: writes `code` to the clipboard, shows "Copied" for a
|
|
25
|
+
* second, and flags a failed write via `data-copy-failed` (cleared on the next
|
|
26
|
+
* successful copy). `className` is the caller's own button class. */
|
|
27
|
+
export declare class CodeBlockKitCopyButtonWidget extends WidgetType {
|
|
28
|
+
private readonly code;
|
|
29
|
+
private readonly className;
|
|
30
|
+
constructor(code: string, className: string);
|
|
31
|
+
eq(other: WidgetType): boolean;
|
|
32
|
+
toDOM(): HTMLElement;
|
|
33
|
+
ignoreEvent(): boolean;
|
|
34
|
+
}
|
|
35
|
+
/** Resolves a fenced code block's info string (e.g. `ts`, or `sample.ts` when
|
|
36
|
+
* the id itself is a filename) to the LRLanguage its content should be
|
|
37
|
+
* highlighted with, or null when unsupported (or absent). Only the first
|
|
38
|
+
* whitespace-separated token is considered -- info strings may carry
|
|
39
|
+
* trailing metadata after the language id (e.g. `ts title="demo"`). */
|
|
40
|
+
export declare function getCodeBlockKitLanguage(infoValue: string): LRLanguage | null;
|
|
41
|
+
/** Resolves a whole filename (e.g. `my file.js`, spaces and all) to the
|
|
42
|
+
* LRLanguage its content should be highlighted with, or null when unsupported
|
|
43
|
+
* (or absent). Unlike {@link getCodeBlockKitLanguage}, the entire trimmed
|
|
44
|
+
* string is one filename -- there is no trailing-metadata token to split off,
|
|
45
|
+
* so a space in the name (e.g. scrapbox's `code:my file.js`) doesn't hide the
|
|
46
|
+
* extension. */
|
|
47
|
+
export declare function getCodeBlockKitLanguageForFileName(fileName: string): LRLanguage | null;
|
|
48
|
+
/** One piece of a code block's content: `text` is the already-extracted
|
|
49
|
+
* source (e.g. a fenced block's whole interior, or one scrapbox body line
|
|
50
|
+
* with its required indent marker already stripped), `from`/`to` is the
|
|
51
|
+
* document range that same text occupies. */
|
|
52
|
+
export interface CodeBlockKitSegment extends CodeBlockKitRange {
|
|
53
|
+
text: string;
|
|
54
|
+
}
|
|
55
|
+
/** Parses one or more content segments -- joined with `"\n"` into a single
|
|
56
|
+
* virtual string -- as one `language`, and emits mark specs mapped back to
|
|
57
|
+
* each segment's own document range. A token that spans the virtual `"\n"`
|
|
58
|
+
* joining two segments (e.g. a multi-line comment split across scrapbox body
|
|
59
|
+
* lines with their markers stripped) is split into one mark per segment it
|
|
60
|
+
* touches, rather than one mark stretching across the stripped-out markers
|
|
61
|
+
* that sit between segments in the real document. */
|
|
62
|
+
export declare function createCodeBlockKitSegmentedHighlightSpecs(segments: readonly CodeBlockKitSegment[], language: Language, tokenClassName: string): MboxDecorationSpec[];
|
|
63
|
+
/** Parses `value` (the block's content text) with `language` and emits one
|
|
64
|
+
* mark spec per highlighted token, offset by `contentFrom` into the document
|
|
65
|
+
* and classed `${tokenClassName} ${lezerClasses}`. `language` accepts any
|
|
66
|
+
* `Language` (not just the Lezer-native `LRLanguage`) so `StreamLanguage`-backed
|
|
67
|
+
* grammars -- e.g. Ruby, wrapped from `@codemirror/legacy-modes` -- work too.
|
|
68
|
+
* A thin single-segment wrapper around {@link createCodeBlockKitSegmentedHighlightSpecs}. */
|
|
69
|
+
export declare function createCodeBlockKitHighlightSpecs(value: string, contentFrom: number, language: Language, tokenClassName: string): MboxDecorationSpec[];
|
|
70
|
+
/** The accepted first token of an info string (e.g. `ts` in
|
|
71
|
+
* `ts title="demo"`) is the code block's language label. It is a projection
|
|
72
|
+
* of {@link parseCodeBlockKitInfoString}, so an input-boundary failure such as
|
|
73
|
+
* a line terminator has no label range. */
|
|
74
|
+
export declare function getCodeBlockKitLanguageLabelRange(infoValue: string, infoFrom: number): CodeBlockKitRange | null;
|
|
75
|
+
/** The start offset of each line within `value` (the block's content text,
|
|
76
|
+
* fences excluded), for tagging every content line with its own decoration. */
|
|
77
|
+
export declare function getCodeBlockKitContentLineStarts(content: CodeBlockKitRange, value: string): number[];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type Language } from "@codemirror/language";
|
|
2
|
+
import type { EditorState, Extension } from "@codemirror/state";
|
|
3
|
+
export interface CodeBlockKitLanguageLoaderOptions {
|
|
4
|
+
/** Restrict matching to these language names/aliases/extensions; omit to
|
|
5
|
+
* consider the full @codemirror/language-data registry. */
|
|
6
|
+
languages?: readonly string[];
|
|
7
|
+
onLoadError?: (languageId: string, error: unknown) => void;
|
|
8
|
+
/** How to read the code block string passed to getLanguage/ensureLanguageLoaded:
|
|
9
|
+
* `"infoString"` (default) treats it as a fenced block's info string, where only
|
|
10
|
+
* the first whitespace-separated token is the language id/filename (trailing
|
|
11
|
+
* text is metadata, e.g. `ts title="demo"`). `"fileName"` treats the whole
|
|
12
|
+
* trimmed string as one filename -- for callers like scrapbox whose code block
|
|
13
|
+
* string is always a bare filename that may itself contain spaces. Both
|
|
14
|
+
* modes reject line terminators; filename mode only trims surrounding
|
|
15
|
+
* horizontal whitespace. */
|
|
16
|
+
infoValueKind?: "infoString" | "fileName";
|
|
17
|
+
}
|
|
18
|
+
export interface CodeBlockKitLanguageLoader {
|
|
19
|
+
/** The language already loaded for this info string, or null when
|
|
20
|
+
* unsupported OR not yet loaded. Never triggers a load itself. */
|
|
21
|
+
getLanguage(infoValue: string): Language | null;
|
|
22
|
+
/** Starts loading the language for this info string unless it's already
|
|
23
|
+
* loading, loaded, or has already failed (failed loads are not retried
|
|
24
|
+
* within this loader's lifetime). Resolves once settled, or immediately if
|
|
25
|
+
* there's nothing to load -- safe to call redundantly, and safe to await
|
|
26
|
+
* in tests. */
|
|
27
|
+
ensureLanguageLoaded(infoValue: string): Promise<void>;
|
|
28
|
+
/** Wire this into a plugin's `extensions`: drives background loading for
|
|
29
|
+
* every code block info string `getCodeBlockInfoValues` finds in the
|
|
30
|
+
* document, and re-dispatches once a language finishes loading. */
|
|
31
|
+
extension: Extension;
|
|
32
|
+
}
|
|
33
|
+
export declare function createCodeBlockKitLanguageLoader(getCodeBlockInfoValues: (state: EditorState) => Iterable<string>, options?: CodeBlockKitLanguageLoaderOptions): CodeBlockKitLanguageLoader;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface GfmLineSpan {
|
|
2
|
+
startLine: number;
|
|
3
|
+
endLine: number;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Whether any line a span touches is active. GFM inline constructs (links,
|
|
7
|
+
* emphasis/strong/strike, inline code) can span multiple lines, so revealing
|
|
8
|
+
* one on an active line means checking every line it covers, not just its
|
|
9
|
+
* first.
|
|
10
|
+
*/
|
|
11
|
+
export declare function isLineSpanActive(span: GfmLineSpan, activeLines: Set<number>): boolean;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { MboxPlugin } from "../../editor/plugin.js";
|
|
2
|
+
import { CodeBlockKitCopyButtonWidget as GfmCodeBlockCopyButtonWidget } from "../code-block-kit.js";
|
|
3
|
+
export { GfmCodeBlockCopyButtonWidget };
|
|
4
|
+
export declare const gfmCodeBlockClassName = "mbox-gfm-code-block";
|
|
5
|
+
export declare const gfmCodeBlockClassNames: {
|
|
6
|
+
fenceLine: string;
|
|
7
|
+
headerLine: string;
|
|
8
|
+
openingFenceLine: string;
|
|
9
|
+
closingFenceLine: string;
|
|
10
|
+
contentLine: string;
|
|
11
|
+
copyButton: string;
|
|
12
|
+
languageLabel: string;
|
|
13
|
+
token: string;
|
|
14
|
+
};
|
|
15
|
+
export declare function gfmCodeBlockPlugin(options?: {
|
|
16
|
+
excludeMathFences?: boolean;
|
|
17
|
+
}): MboxPlugin;
|
|
18
|
+
export interface GfmCodeBlockHighlightPluginOptions {
|
|
19
|
+
/** Restrict dynamic loading to these language names/aliases/extensions, or
|
|
20
|
+
* pass `"all"` to allow any language in the full @codemirror/language-data
|
|
21
|
+
* registry (still only loaded, one dynamic import at a time, for a
|
|
22
|
+
* language actually used in the document). Omit entirely to skip the
|
|
23
|
+
* dynamic loader altogether and stay on the zero-dependency JS/TS sync
|
|
24
|
+
* default. */
|
|
25
|
+
languages?: readonly string[] | "all";
|
|
26
|
+
onLoadError?: (languageId: string, error: unknown) => void;
|
|
27
|
+
}
|
|
28
|
+
export declare function gfmCodeBlockHighlightPlugin(options?: GfmCodeBlockHighlightPluginOptions): MboxPlugin;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { WidgetType } from "@codemirror/view";
|
|
2
|
+
import type { MboxPlugin } from "../../editor/plugin.js";
|
|
3
|
+
export declare const gfmFootnoteClassName = "mbox-gfm-footnote";
|
|
4
|
+
export declare const gfmFootnoteMarkerClassName = "mbox-gfm-footnote-marker";
|
|
5
|
+
export declare const gfmFootnoteRefClassName = "mbox-gfm-footnote-ref";
|
|
6
|
+
export declare class GfmFootnoteRefWidget extends WidgetType {
|
|
7
|
+
readonly label: string;
|
|
8
|
+
/** The definition's flattened body, shown as the chip's tooltip. */
|
|
9
|
+
readonly note: string;
|
|
10
|
+
readonly targetId?: string | undefined;
|
|
11
|
+
constructor(label: string,
|
|
12
|
+
/** The definition's flattened body, shown as the chip's tooltip. */
|
|
13
|
+
note: string, targetId?: string | undefined);
|
|
14
|
+
eq(other: WidgetType): boolean;
|
|
15
|
+
toDOM(): HTMLElement;
|
|
16
|
+
}
|
|
17
|
+
export declare function gfmFootnotePlugin(): MboxPlugin;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { MboxPlugin } from "../../editor/plugin.js";
|
|
2
|
+
export declare const gfmHeadingLineClassName = "mbox-gfm-heading";
|
|
3
|
+
export declare const gfmHeadingSetextUnderlineClassName = "mbox-gfm-heading-setext-underline";
|
|
4
|
+
export declare const gfmHeadingClassNames: {
|
|
5
|
+
h1: string;
|
|
6
|
+
h2: string;
|
|
7
|
+
h3: string;
|
|
8
|
+
h4: string;
|
|
9
|
+
h5: string;
|
|
10
|
+
h6: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function gfmHeadingPlugin(): MboxPlugin;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Facet } from "@codemirror/state";
|
|
2
|
+
import type { MboxPlugin } from "../../editor/plugin.js";
|
|
3
|
+
export declare const gfmImageClassName = "mbox-gfm-image";
|
|
4
|
+
export declare const gfmImageClassNames: {
|
|
5
|
+
image: string;
|
|
6
|
+
token: string;
|
|
7
|
+
preview: string;
|
|
8
|
+
element: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const gfmImageInternalClassNames: {
|
|
11
|
+
measure: string;
|
|
12
|
+
};
|
|
13
|
+
export type GfmImageRenderMode = "token" | "preview";
|
|
14
|
+
export interface GfmImagePluginOptions {
|
|
15
|
+
renderMode?: GfmImageRenderMode;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* @internal Whether any image plugin in this editor renders previews.
|
|
19
|
+
*
|
|
20
|
+
* The table plugin needs this to decide whether a cell holding an image should
|
|
21
|
+
* claim a wider column: reserving that width when the image will be drawn as
|
|
22
|
+
* alt text anyway would leave a wide empty column. The two plugins do not know
|
|
23
|
+
* about each other otherwise, and a host is free to assemble them individually
|
|
24
|
+
* rather than through `gfmPlugins`, so passing the option along that path only
|
|
25
|
+
* would break exactly the hand-assembled case -- and break it silently.
|
|
26
|
+
*
|
|
27
|
+
* Combined with `some`: one preview-rendering image plugin is enough.
|
|
28
|
+
*/
|
|
29
|
+
export declare const gfmImagePreviewEnabled: Facet<boolean, boolean>;
|
|
30
|
+
export declare function gfmImagePlugin(options?: GfmImagePluginOptions): MboxPlugin;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { MboxPlugin } from "../../editor/plugin.js";
|
|
2
|
+
import { type GfmCodeBlockHighlightPluginOptions } from "./code-block.js";
|
|
3
|
+
import { type GfmImagePluginOptions } from "./image.js";
|
|
4
|
+
import { type GfmLinkOptions } from "./link.js";
|
|
5
|
+
import { type GfmMathPluginOptions } from "./math.js";
|
|
6
|
+
import { type GfmTablePluginOptions } from "./table.js";
|
|
7
|
+
export interface GfmPluginsOptions {
|
|
8
|
+
link?: GfmLinkOptions;
|
|
9
|
+
image?: GfmImagePluginOptions;
|
|
10
|
+
/** `true` adds the code-block syntax highlighter with its zero-dependency
|
|
11
|
+
* JS/TS default; pass a GfmCodeBlockHighlightPluginOptions object instead
|
|
12
|
+
* to also set `languages`/`onLoadError`. Omitted or falsy adds no
|
|
13
|
+
* highlighter at all. */
|
|
14
|
+
codeHighlight?: boolean | GfmCodeBlockHighlightPluginOptions;
|
|
15
|
+
math?: GfmMathPluginOptions;
|
|
16
|
+
/** Table layout options -- currently the column a cell with an image claims. */
|
|
17
|
+
table?: GfmTablePluginOptions;
|
|
18
|
+
}
|
|
19
|
+
export declare function gfmPlugins(options?: GfmPluginsOptions): MboxPlugin[];
|