@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
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
export interface HatenaRange {
|
|
2
|
+
from: number;
|
|
3
|
+
to: number;
|
|
4
|
+
}
|
|
5
|
+
export interface HatenaHeading {
|
|
6
|
+
/**
|
|
7
|
+
* The hidden prefix: the leading star run, plus a `name*` anchor attribute
|
|
8
|
+
* when present (`*name1*名前1` hides `*name1*`, leaving `名前1`).
|
|
9
|
+
*/
|
|
10
|
+
marker: HatenaRange;
|
|
11
|
+
/** 3 = h3 (`*`), 4 = h4 (`**`), 5 = h5 (`***`); capped at 5. */
|
|
12
|
+
level: number;
|
|
13
|
+
/** The anchor name from a `*name*text` heading, else null. */
|
|
14
|
+
name: string | null;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A definition-list line: `:用語:説明` (a term + its description) or `::説明` (a
|
|
18
|
+
* continuation description under the previous term). Each `::` line adds
|
|
19
|
+
* another description under the same term.
|
|
20
|
+
*/
|
|
21
|
+
export interface HatenaDefinition {
|
|
22
|
+
/** True for a `::` continuation line (no term of its own). */
|
|
23
|
+
continuation: boolean;
|
|
24
|
+
/** The leading `:` or `::` marker. */
|
|
25
|
+
marker: HatenaRange;
|
|
26
|
+
/** The term run between the two colons; null for a continuation. */
|
|
27
|
+
term: HatenaRange | null;
|
|
28
|
+
/** The middle `:` separating term and description; null for a continuation. */
|
|
29
|
+
separator: HatenaRange | null;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* One inline footnote `((content))`. The notation collects these into a
|
|
33
|
+
* numbered list at the article end, leaving a superscript reference in the
|
|
34
|
+
* text; mbox keeps the number inline (with the content as a tooltip), so it
|
|
35
|
+
* stores the whole marker span, the inner content, and the document-order
|
|
36
|
+
* number.
|
|
37
|
+
*/
|
|
38
|
+
export interface HatenaFootnote {
|
|
39
|
+
marker: HatenaRange;
|
|
40
|
+
content: HatenaRange;
|
|
41
|
+
/** The footnote body text (between the `((` `))`), for the superscript tooltip. */
|
|
42
|
+
text: string;
|
|
43
|
+
number: number;
|
|
44
|
+
}
|
|
45
|
+
export interface HatenaList {
|
|
46
|
+
/** The leading `-`/`+` run plus one optional trailing space. */
|
|
47
|
+
marker: HatenaRange;
|
|
48
|
+
/** Nesting depth = number of leading marker characters. */
|
|
49
|
+
depth: number;
|
|
50
|
+
/** True when the innermost marker char is `+` — the ordered-list form. */
|
|
51
|
+
ordered: boolean;
|
|
52
|
+
/** 1-based position within the current same-depth ordered run; null if bulleted. */
|
|
53
|
+
ordinal: number | null;
|
|
54
|
+
}
|
|
55
|
+
export type HatenaLinkKind = "bracket" | "url" | "id";
|
|
56
|
+
export interface HatenaLink {
|
|
57
|
+
from: number;
|
|
58
|
+
to: number;
|
|
59
|
+
/**
|
|
60
|
+
* The link's own destination for `bracket`/`url` kinds (already the final
|
|
61
|
+
* URL the user wrote). For `id`, this is the RAW username, not a resolved
|
|
62
|
+
* path -- the parser stays a pure projection of the syntax; mapping a
|
|
63
|
+
* username to a destination is a host policy, so `hatenaLinkPlugin`'s
|
|
64
|
+
* `idUrl` resolver applies it at decoration time (mirroring gfm/scrapbox's
|
|
65
|
+
* consumer-resolver pattern).
|
|
66
|
+
*/
|
|
67
|
+
href: string;
|
|
68
|
+
/** The text to display in place of the raw syntax. */
|
|
69
|
+
label: string;
|
|
70
|
+
kind: HatenaLinkKind;
|
|
71
|
+
}
|
|
72
|
+
export type HatenaQuoteRole = "open" | "close" | "content";
|
|
73
|
+
export interface HatenaQuote {
|
|
74
|
+
/** 1-based nesting depth of the blockquote this line belongs to. */
|
|
75
|
+
depth: number;
|
|
76
|
+
role: HatenaQuoteRole;
|
|
77
|
+
/** The source URL of a `>URL>` cite opener; null for `>>` or non-openers. */
|
|
78
|
+
cite: string | null;
|
|
79
|
+
}
|
|
80
|
+
export type HatenaSuperPreRole = "opener" | "body" | "closer";
|
|
81
|
+
export type HatenaPreRole = "opener" | "body" | "closer";
|
|
82
|
+
export interface HatenaLine {
|
|
83
|
+
line: number;
|
|
84
|
+
from: number;
|
|
85
|
+
to: number;
|
|
86
|
+
heading: HatenaHeading | null;
|
|
87
|
+
list: HatenaList | null;
|
|
88
|
+
definition: HatenaDefinition | null;
|
|
89
|
+
footnotes: HatenaFootnote[];
|
|
90
|
+
links: HatenaLink[];
|
|
91
|
+
quote: HatenaQuote | null;
|
|
92
|
+
superPre: HatenaSuperPreRole | null;
|
|
93
|
+
/** On a `>|lang|` opener, the captured language; null for `>||` or non-openers. */
|
|
94
|
+
superPreLang: string | null;
|
|
95
|
+
/** Plain `>| ... |<` pre block role; null outside a plain pre. */
|
|
96
|
+
pre: HatenaPreRole | null;
|
|
97
|
+
}
|
|
98
|
+
export interface HatenaTableCell {
|
|
99
|
+
/** Full cell span between the surrounding pipes (padding included). */
|
|
100
|
+
from: number;
|
|
101
|
+
to: number;
|
|
102
|
+
/** True when the trimmed cell text starts with `*`. */
|
|
103
|
+
header: boolean;
|
|
104
|
+
/** The leading `*` marker range for a header cell, else null. */
|
|
105
|
+
marker: HatenaRange | null;
|
|
106
|
+
/** The DISPLAYED content range (a header's leading `*` excluded). */
|
|
107
|
+
content: HatenaRange;
|
|
108
|
+
/** That same displayed text — the run laid out in the column. */
|
|
109
|
+
value: string;
|
|
110
|
+
}
|
|
111
|
+
export interface HatenaTableRow {
|
|
112
|
+
/** 1-based line of this row. */
|
|
113
|
+
line: number;
|
|
114
|
+
from: number;
|
|
115
|
+
to: number;
|
|
116
|
+
cells: HatenaTableCell[];
|
|
117
|
+
}
|
|
118
|
+
export interface HatenaTable {
|
|
119
|
+
/** 1-based line of the first row. Body rows follow one per line. */
|
|
120
|
+
line: number;
|
|
121
|
+
from: number;
|
|
122
|
+
to: number;
|
|
123
|
+
rows: HatenaTableRow[];
|
|
124
|
+
}
|
|
125
|
+
export interface HatenaDocument {
|
|
126
|
+
lines: HatenaLine[];
|
|
127
|
+
tables: HatenaTable[];
|
|
128
|
+
}
|
|
129
|
+
export declare function parseHatenaDocument(input: string): HatenaDocument;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { WidgetType } from "@codemirror/view";
|
|
2
|
+
import type { MboxDecorationProvider, MboxDecorationSpec, MboxThemeSpec } from "../../editor/plugin.js";
|
|
3
|
+
import type { HatenaDocument, HatenaLine } from "./parser.js";
|
|
4
|
+
/**
|
|
5
|
+
* Wire a `(document, activeLines) => specs` builder into an
|
|
6
|
+
* {@link MboxDecorationProvider}. Collapses the one `decorations` line every
|
|
7
|
+
* Hatena plugin repeats — read the cached parse, pass the active line numbers —
|
|
8
|
+
* so each plugin only supplies its builder.
|
|
9
|
+
*/
|
|
10
|
+
export declare function hatenaDecorationProvider(create: (document: HatenaDocument, activeLines: Set<number>) => MboxDecorationSpec[]): MboxDecorationProvider;
|
|
11
|
+
/** The role a line plays in a literal block (`>|…|<` pre, `>||…||<` super-pre). */
|
|
12
|
+
export type HatenaLiteralBlockRole = "opener" | "body" | "closer" | null;
|
|
13
|
+
/**
|
|
14
|
+
* Group a document's literal-block lines into opener-triggered runs and emit one
|
|
15
|
+
* `lineRange` per block plus a `replace` that hides each marker line while
|
|
16
|
+
* inactive. pre and super-pre share this exactly; they differ only in which role
|
|
17
|
+
* field they read and whether an opener reveals a widget (super-pre's lang label).
|
|
18
|
+
*/
|
|
19
|
+
export declare function emitLiteralBlockSpecs(document: HatenaDocument, activeLines: Set<number>, options: {
|
|
20
|
+
roleOf: (line: HatenaLine) => HatenaLiteralBlockRole;
|
|
21
|
+
className: string;
|
|
22
|
+
widgetFor?: (line: HatenaLine) => WidgetType | undefined;
|
|
23
|
+
}): MboxDecorationSpec[];
|
|
24
|
+
/**
|
|
25
|
+
* The structural rule shared by every multi-line literal block: overrides the
|
|
26
|
+
* editor's own line-wrapping default so "literal" content displays exactly as
|
|
27
|
+
* written, unwrapped. Font, background, and corner radii are visual
|
|
28
|
+
* preference, not structural -- a host opts in through its own presentation
|
|
29
|
+
* theme on the public class passed in here.
|
|
30
|
+
*/
|
|
31
|
+
export declare function literalBlockTheme(className: string): MboxThemeSpec;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { WidgetType } from "@codemirror/view";
|
|
2
|
+
import type { MboxPlugin } from "../../editor/plugin.js";
|
|
3
|
+
export declare const hatenaSuperPreClassName = "mbox-hatena-superpre";
|
|
4
|
+
export declare const hatenaSuperPreLangClassName = "mbox-hatena-superpre-lang";
|
|
5
|
+
export declare class HatenaSuperPreLangWidget extends WidgetType {
|
|
6
|
+
readonly language: string;
|
|
7
|
+
constructor(language: string);
|
|
8
|
+
eq(other: WidgetType): boolean;
|
|
9
|
+
toDOM(): HTMLElement;
|
|
10
|
+
}
|
|
11
|
+
export declare function hatenaSuperPrePlugin(): MboxPlugin;
|
|
12
|
+
export declare const hatenaSuperPreTokenClassName = "mbox-hatena-superpre-token";
|
|
13
|
+
export interface HatenaSuperPreHighlightPluginOptions {
|
|
14
|
+
/** Restrict dynamic loading to these language names/aliases/extensions, or
|
|
15
|
+
* pass `"all"` to allow any language in the full @codemirror/language-data
|
|
16
|
+
* registry (still only loaded, one dynamic import at a time, for a
|
|
17
|
+
* language actually used in the document). Omit entirely to skip the
|
|
18
|
+
* dynamic loader altogether and stay on the zero-dependency JS/TS sync
|
|
19
|
+
* default. */
|
|
20
|
+
languages?: readonly string[] | "all";
|
|
21
|
+
onLoadError?: (languageId: string, error: unknown) => void;
|
|
22
|
+
}
|
|
23
|
+
export declare function hatenaSuperPreHighlightPlugin(options?: HatenaSuperPreHighlightPluginOptions): MboxPlugin;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { MboxPlugin } from "../../editor/plugin.js";
|
|
2
|
+
export declare const hatenaTableRenderedClassName = "mbox-hatena-table-rendered";
|
|
3
|
+
export declare const hatenaTableRawCellClassName = "mbox-hatena-table-raw-cell";
|
|
4
|
+
export declare const hatenaTableClassNames: {
|
|
5
|
+
table: string;
|
|
6
|
+
row: string;
|
|
7
|
+
cell: string;
|
|
8
|
+
headerCell: string;
|
|
9
|
+
rendered: string;
|
|
10
|
+
rawCell: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function hatenaTablePlugin(): MboxPlugin;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { WidgetType } from "@codemirror/view";
|
|
2
|
+
import type { MboxDecorationSpec, MboxThemeSpec } from "../editor/plugin.js";
|
|
3
|
+
import { type InlineNotationSource } from "./inline-notation-kit.js";
|
|
4
|
+
export type ImageKitRenderMode = "token" | "preview";
|
|
5
|
+
export interface ImageKitClassNames {
|
|
6
|
+
image: string;
|
|
7
|
+
token: string;
|
|
8
|
+
preview: string;
|
|
9
|
+
element: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ImageKitMeasureClassNames {
|
|
12
|
+
measure: string;
|
|
13
|
+
}
|
|
14
|
+
export interface ImageKitImage {
|
|
15
|
+
src: string;
|
|
16
|
+
alt?: string;
|
|
17
|
+
text?: string;
|
|
18
|
+
link?: string;
|
|
19
|
+
/** Additive: appended after the widget's own base class(es), never replaces them. */
|
|
20
|
+
className?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface ImageKitInfo extends ImageKitImage {
|
|
23
|
+
from: number;
|
|
24
|
+
to: number;
|
|
25
|
+
}
|
|
26
|
+
export interface ImageKitWidgetFactories {
|
|
27
|
+
token?: (image: ImageKitImage, classNames: ImageKitClassNames) => WidgetType;
|
|
28
|
+
preview?: (image: ImageKitImage, classNames: ImageKitClassNames) => WidgetType;
|
|
29
|
+
measure?: (image: ImageKitImage, classNames: ImageKitClassNames, measureClassNames: ImageKitMeasureClassNames) => WidgetType;
|
|
30
|
+
}
|
|
31
|
+
export declare class ImageKitTokenWidget extends WidgetType {
|
|
32
|
+
private readonly image;
|
|
33
|
+
private readonly classNames;
|
|
34
|
+
constructor(image: ImageKitImage, classNames: ImageKitClassNames);
|
|
35
|
+
eq(other: WidgetType): boolean;
|
|
36
|
+
toDOM(): HTMLElement;
|
|
37
|
+
}
|
|
38
|
+
export declare class ImageKitPreviewWidget extends WidgetType {
|
|
39
|
+
private readonly image;
|
|
40
|
+
private readonly classNames;
|
|
41
|
+
constructor(image: ImageKitImage, classNames: ImageKitClassNames);
|
|
42
|
+
eq(other: WidgetType): boolean;
|
|
43
|
+
toDOM(): HTMLElement;
|
|
44
|
+
}
|
|
45
|
+
export declare class ImageKitMeasureWidget extends WidgetType {
|
|
46
|
+
private readonly image;
|
|
47
|
+
private readonly classNames;
|
|
48
|
+
private readonly measureClassNames;
|
|
49
|
+
constructor(image: ImageKitImage, classNames: ImageKitClassNames, measureClassNames: ImageKitMeasureClassNames);
|
|
50
|
+
eq(other: WidgetType): boolean;
|
|
51
|
+
toDOM(): HTMLElement;
|
|
52
|
+
/**
|
|
53
|
+
* The hidden, correctly-sized preview figure whose intrinsic size reserves the
|
|
54
|
+
* space the visible preview would occupy. Exposed so a subclass can reuse or
|
|
55
|
+
* customize it (e.g. to reserve only its height, not its width) without
|
|
56
|
+
* re-deriving the class list and image attributes.
|
|
57
|
+
*/
|
|
58
|
+
protected renderFigure(): HTMLElement;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* A measure figure that cancels its own inline advance.
|
|
62
|
+
*
|
|
63
|
+
* The plain {@link ImageKitMeasureWidget} reserves the preview's height AND its
|
|
64
|
+
* width, which shoves any same-line text far to the right while the line is
|
|
65
|
+
* being edited. A host can undo that with a negative margin of its own, but
|
|
66
|
+
* only if it knows the figure's width -- which is responsive, so it does not.
|
|
67
|
+
*
|
|
68
|
+
* The figure stays in normal flow, because its sizing has to resolve against
|
|
69
|
+
* the real content width: a wrapper that could clip it would become its
|
|
70
|
+
* containing block and collapse the width, taking the height with it. Instead
|
|
71
|
+
* its rendered width is pulled back with a negative inline-end margin, so the
|
|
72
|
+
* inline advance is ~0 while the height stays, and a ResizeObserver keeps that
|
|
73
|
+
* margin in step as the content width changes.
|
|
74
|
+
*
|
|
75
|
+
* Opt in per notation. The mbox notation deliberately does not use this -- its
|
|
76
|
+
* demo cancels the width in CSS, and changing that would change how an mbox
|
|
77
|
+
* document looks while editing.
|
|
78
|
+
*/
|
|
79
|
+
export declare class ImageKitSelfCancelingMeasureWidget extends ImageKitMeasureWidget {
|
|
80
|
+
toDOM(): HTMLElement;
|
|
81
|
+
destroy(dom: HTMLElement): void;
|
|
82
|
+
}
|
|
83
|
+
export declare function createImageKitSpecs(images: ImageKitInfo[], active: boolean, source: InlineNotationSource, classNames: ImageKitClassNames, measureClassNames: ImageKitMeasureClassNames, renderMode: ImageKitRenderMode, widgetFactories?: ImageKitWidgetFactories): MboxDecorationSpec[];
|
|
84
|
+
export declare function imageKitTheme(classNames: ImageKitClassNames, measureClassNames: ImageKitMeasureClassNames): MboxThemeSpec;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { WidgetType } from "@codemirror/view";
|
|
2
|
+
import type { MboxReplaceDecorationSpec } from "../editor/plugin.js";
|
|
3
|
+
export interface InlineNotationKitRange {
|
|
4
|
+
from: number;
|
|
5
|
+
to: number;
|
|
6
|
+
}
|
|
7
|
+
/** The smallest document surface inline-notation lowering needs. */
|
|
8
|
+
export type InlineNotationSource = string | {
|
|
9
|
+
sliceString(from: number, to: number): string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* CodeMirror plugins cannot replace a range containing a line break. Keep this
|
|
13
|
+
* decision beside the shared inline-notation reveal rule so a new caller
|
|
14
|
+
* cannot accidentally reintroduce the crash by forgetting a second guard.
|
|
15
|
+
*
|
|
16
|
+
* Temporary 8-pre behavior: leave multiline notation raw. Section 8A replaces
|
|
17
|
+
* this with the widget-plus-hidden-lines rendering model.
|
|
18
|
+
*/
|
|
19
|
+
export declare function canReplaceInlineNotation(range: InlineNotationKitRange, source: InlineNotationSource): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Replaces `range` with a widget the caller's factory creates, on an inactive
|
|
22
|
+
* line -- the reveal/hide rule shared by every inline notation (emoji, link,
|
|
23
|
+
* footnote reference, formula, ...). On an active line, the raw source stays
|
|
24
|
+
* as-is: no spec at all, and `createWidget` is never even called.
|
|
25
|
+
*/
|
|
26
|
+
export declare function createInactiveInlineNotationSpecs(range: InlineNotationKitRange, active: boolean, source: InlineNotationSource, createWidget: () => WidgetType): MboxReplaceDecorationSpec[];
|
|
27
|
+
export interface AnchorElementOptions {
|
|
28
|
+
href: string;
|
|
29
|
+
text: string;
|
|
30
|
+
className: string;
|
|
31
|
+
/** Extra attributes beyond href/class (e.g. `target`/`rel`); an `undefined`
|
|
32
|
+
* value is skipped, so callers can pass a conditional attribute inline. */
|
|
33
|
+
attributes?: Record<string, string | undefined>;
|
|
34
|
+
}
|
|
35
|
+
/** Builds the `<a>` DOM every link-shaped inline notation widget renders --
|
|
36
|
+
* href, text, class, and any extra attributes. Notation-specific policy
|
|
37
|
+
* (autolink styling, external-link target/rel, ...) is the caller's own
|
|
38
|
+
* className/attributes, not something this function decides. */
|
|
39
|
+
export declare function createAnchorElement(options: AnchorElementOptions): HTMLAnchorElement;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type MboxDecorationSpec } from "../editor/plugin.js";
|
|
2
|
+
/** @internal Constituent of the src-shared InlineStyleKitSpan; not a package export. */
|
|
3
|
+
export interface InlineStyleKitRange {
|
|
4
|
+
from: number;
|
|
5
|
+
to: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* One open-marker/content/close-marker span: emphasis, strong, strikethrough,
|
|
9
|
+
* and inline code all share this shape across namespaces. `className` styles
|
|
10
|
+
* the content; `tagName`, when supplied by a namespace, chooses its semantic
|
|
11
|
+
* wrapper. The markers carry no class of their own (a `replace` spec's class
|
|
12
|
+
* lives on its widget, and these markers have none).
|
|
13
|
+
*/
|
|
14
|
+
export interface InlineStyleKitSpan {
|
|
15
|
+
openMarker: InlineStyleKitRange;
|
|
16
|
+
content: InlineStyleKitRange;
|
|
17
|
+
closeMarker: InlineStyleKitRange;
|
|
18
|
+
className: string;
|
|
19
|
+
tagName?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Mark the content, and hide both markers when `hideMarkers` is true. Callers
|
|
23
|
+
* own the active/inactive decision — mbox reveals inline style spans only via
|
|
24
|
+
* the inactive-node visitor (so it never calls this for an active node in the
|
|
25
|
+
* first place), while GFM keeps the content mark on active lines too and
|
|
26
|
+
* hides only the markers, gating `hideMarkers` on a multi-line "any touched
|
|
27
|
+
* line is active" check. Neither policy lives in this kit.
|
|
28
|
+
*
|
|
29
|
+
* This assumes `span.content` is never empty: CodeMirror's mark decoration
|
|
30
|
+
* throws for a from===to range (table-kit hit exactly this for an empty table
|
|
31
|
+
* cell and had to special-case it with a widget). Verified this can't happen
|
|
32
|
+
* here -- mbox's own parser rejects a delimiter pair with nothing between
|
|
33
|
+
* (`parseDelimitedInlineStyleAt`/`parseInlineCodeAt` both return null), and
|
|
34
|
+
* GFM's mdast/micromark adapter never emits an empty emphasis/strong/
|
|
35
|
+
* inlineCode node for the same CommonMark reason. No defensive check added
|
|
36
|
+
* here since the scenario is confirmed unreachable, not just unlikely.
|
|
37
|
+
*/
|
|
38
|
+
export declare function createInlineStyleKitSpecs(span: InlineStyleKitSpan, hideMarkers: boolean): MboxDecorationSpec[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isHttpUrl(value: string): boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One physical input line with both its raw input boundary and its
|
|
3
|
+
* syntax-facing boundary. `to` remains the raw offset, including a CR that is
|
|
4
|
+
* part of a CRLF terminator; `logicalTo` and `text` exclude that terminator.
|
|
5
|
+
* A lone CR is source text, not a line terminator. Only Scrapbox exposes
|
|
6
|
+
* `logicalTo` on its public line model: its consumers reconstruct content from
|
|
7
|
+
* line offsets. Hatena and mbox consumers need the raw end for literal bodies,
|
|
8
|
+
* so their public line models intentionally do not expose a logical end.
|
|
9
|
+
*/
|
|
10
|
+
export interface LogicalLine {
|
|
11
|
+
text: string;
|
|
12
|
+
line: number;
|
|
13
|
+
from: number;
|
|
14
|
+
to: number;
|
|
15
|
+
logicalTo: number;
|
|
16
|
+
}
|
|
17
|
+
/** Construct syntax-facing lines without losing raw source geometry. */
|
|
18
|
+
export declare function createLogicalLines(input: string): LogicalLine[];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { EditorState, TransactionSpec } from "@codemirror/state";
|
|
2
|
+
import type { MboxPlugin } from "../../editor/plugin.js";
|
|
3
|
+
export declare function insertMboxBracketPair(state: EditorState): TransactionSpec;
|
|
4
|
+
export declare function mboxBracketPlugin(): MboxPlugin;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { MboxPlugin } from "../../editor/plugin.js";
|
|
2
|
+
import type { MboxBlock } from "./types.js";
|
|
3
|
+
import { CodeBlockKitCopyButtonWidget as CodeBlockCopyButtonWidget } from "../code-block-kit.js";
|
|
4
|
+
export { CodeBlockCopyButtonWidget };
|
|
5
|
+
export declare const codeBlockClassNames: {
|
|
6
|
+
block: string;
|
|
7
|
+
fenceLine: string;
|
|
8
|
+
headerLine: string;
|
|
9
|
+
openingFenceLine: string;
|
|
10
|
+
closingFenceLine: string;
|
|
11
|
+
contentLine: string;
|
|
12
|
+
copyButton: string;
|
|
13
|
+
info: string;
|
|
14
|
+
languageLabel: string;
|
|
15
|
+
text: string;
|
|
16
|
+
};
|
|
17
|
+
export declare const codeBlockHighlightClassNames: {
|
|
18
|
+
token: string;
|
|
19
|
+
};
|
|
20
|
+
export declare function codeBlockPlugin(): MboxPlugin;
|
|
21
|
+
export interface CodeBlockHighlightPluginOptions {
|
|
22
|
+
/** Restrict dynamic loading to these language names/aliases/extensions, or
|
|
23
|
+
* pass `"all"` to allow any language in the full @codemirror/language-data
|
|
24
|
+
* registry (still only loaded, one dynamic import at a time, for a
|
|
25
|
+
* language actually used in the document). Omit entirely to skip the
|
|
26
|
+
* dynamic loader altogether and stay on the zero-dependency JS/TS sync
|
|
27
|
+
* default. */
|
|
28
|
+
languages?: readonly string[] | "all";
|
|
29
|
+
onLoadError?: (languageId: string, error: unknown) => void;
|
|
30
|
+
}
|
|
31
|
+
export declare function codeBlockHighlightPlugin(options?: CodeBlockHighlightPluginOptions): MboxPlugin;
|
|
32
|
+
export declare function getCodeBlockLanguageId(block: MboxBlock | undefined): string | null;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type CompletionContext, type CompletionResult } from "@codemirror/autocomplete";
|
|
2
|
+
import type { MboxPlugin } from "../../editor/plugin.js";
|
|
3
|
+
export declare const completionOptionClassName = "mbox-completion-option";
|
|
4
|
+
export declare const completionOptionWithPreviewClassName = "mbox-completion-option-with-preview";
|
|
5
|
+
export declare const completionPreviewClassName = "mbox-completion-preview";
|
|
6
|
+
export declare const completionPreviewImageClassName = "mbox-completion-preview-image";
|
|
7
|
+
export declare const completionClassNames: {
|
|
8
|
+
readonly option: "mbox-completion-option";
|
|
9
|
+
readonly optionWithPreview: "mbox-completion-option-with-preview";
|
|
10
|
+
readonly preview: "mbox-completion-preview";
|
|
11
|
+
readonly previewImage: "mbox-completion-preview-image";
|
|
12
|
+
};
|
|
13
|
+
export interface MboxCompletionCandidate {
|
|
14
|
+
title: string;
|
|
15
|
+
/** 完全な置換文字列(ブラケット込み)を候補側が明示的に指定したい場合に使う。省略時は`type`から自動生成する。 */
|
|
16
|
+
apply?: string;
|
|
17
|
+
/** 省略時は`"page"`扱いで`[title]`、`"icon"`なら`[title.icon]`をデフォルトの`apply`として使う。 */
|
|
18
|
+
type?: "page" | "icon";
|
|
19
|
+
/** 補完候補にアイコンまたはサムネイル画像として表示されるURL。 */
|
|
20
|
+
iconUrl?: string;
|
|
21
|
+
}
|
|
22
|
+
export type MboxRecommend = (query: string) => MboxCompletionCandidate[];
|
|
23
|
+
export interface MboxCompletePluginOptions {
|
|
24
|
+
recommend?: MboxRecommend;
|
|
25
|
+
}
|
|
26
|
+
export interface MboxActiveToken {
|
|
27
|
+
query: string;
|
|
28
|
+
from: number;
|
|
29
|
+
to: number;
|
|
30
|
+
}
|
|
31
|
+
export declare function findMboxActiveToken(lineText: string, cursorCh: number): MboxActiveToken | null;
|
|
32
|
+
export declare function createMboxCompletionSource(recommend: MboxRecommend): (context: CompletionContext) => CompletionResult | null;
|
|
33
|
+
export declare function mboxCompletePlugin(options?: MboxCompletePluginOptions): MboxPlugin;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { MboxPlugin } from "../../editor/plugin.js";
|
|
2
|
+
import { type CodeBlockHighlightPluginOptions } from "./code-block.js";
|
|
3
|
+
import { type MboxCompletePluginOptions } from "./complete.js";
|
|
4
|
+
import { type MarkdownImagePluginOptions } from "./markdown-image.js";
|
|
5
|
+
import { type PageLinkPluginOptions } from "./page-link.js";
|
|
6
|
+
export interface MboxPluginOptions {
|
|
7
|
+
link?: PageLinkPluginOptions;
|
|
8
|
+
image?: MarkdownImagePluginOptions;
|
|
9
|
+
codeHighlight?: boolean | CodeBlockHighlightPluginOptions;
|
|
10
|
+
/** Inert (no autocomplete extension installed) unless `recommend` is set. */
|
|
11
|
+
complete?: MboxCompletePluginOptions;
|
|
12
|
+
}
|
|
13
|
+
export declare function mboxPlugins(options?: MboxPluginOptions): MboxPlugin[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { WidgetType } from "@codemirror/view";
|
|
2
|
+
import type { MboxPlugin } from "../../editor/plugin.js";
|
|
3
|
+
export declare const mboxFootnoteClassName = "mbox-footnote";
|
|
4
|
+
export declare const mboxFootnoteMarkerClassName = "mbox-footnote-marker";
|
|
5
|
+
export declare const mboxFootnoteRefClassName = "mbox-footnote-ref";
|
|
6
|
+
export declare class MboxFootnoteRefWidget extends WidgetType {
|
|
7
|
+
readonly label: string;
|
|
8
|
+
readonly note: string;
|
|
9
|
+
readonly targetId?: string | undefined;
|
|
10
|
+
constructor(label: string, note: string, targetId?: string | undefined);
|
|
11
|
+
eq(other: WidgetType): boolean;
|
|
12
|
+
toDOM(): HTMLElement;
|
|
13
|
+
}
|
|
14
|
+
export declare function mboxFootnotePlugin(): MboxPlugin;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MboxActiveLineNumbers } from "../../editor/focused-line.js";
|
|
2
|
+
import type { MboxDecorationSpec } from "../../editor/plugin.js";
|
|
3
|
+
import type { MboxBlock, MboxDocument, MboxInlineNode } from "./types.js";
|
|
4
|
+
type InlineBlock = MboxBlock & {
|
|
5
|
+
inline: MboxInlineNode[];
|
|
6
|
+
};
|
|
7
|
+
export declare function createInactiveInlineNodeSpecs(document: MboxDocument, activeLines: MboxActiveLineNumbers, createSpecs: (node: MboxInlineNode, block: InlineBlock) => MboxDecorationSpec[]): MboxDecorationSpec[];
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type EditorView } from "@codemirror/view";
|
|
2
|
+
import { type MboxPlugin } from "../../editor/plugin.js";
|
|
3
|
+
export declare const listClassNames: {
|
|
4
|
+
ul: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function runListEnter(view: EditorView): boolean;
|
|
7
|
+
export declare function runListIndent(view: EditorView): boolean;
|
|
8
|
+
export declare function runListOutdent(view: EditorView): boolean;
|
|
9
|
+
export declare function runListDeleteBackward(view: EditorView): boolean;
|
|
10
|
+
export declare function runListDeleteForward(view: EditorView): boolean;
|
|
11
|
+
export declare function runListSpace(view: EditorView): boolean;
|
|
12
|
+
export declare function runListLineStart(view: EditorView): boolean;
|
|
13
|
+
export declare function listPlugin(): MboxPlugin;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { MboxPlugin } from "../../editor/plugin.js";
|
|
2
|
+
export declare const markdownImageClassName = "mbox-image";
|
|
3
|
+
export declare const markdownImageClassNames: {
|
|
4
|
+
image: string;
|
|
5
|
+
token: string;
|
|
6
|
+
preview: string;
|
|
7
|
+
element: string;
|
|
8
|
+
};
|
|
9
|
+
export type MarkdownImageRenderMode = "token" | "preview";
|
|
10
|
+
export interface MarkdownImagePluginOptions {
|
|
11
|
+
renderMode?: MarkdownImageRenderMode;
|
|
12
|
+
}
|
|
13
|
+
export declare function markdownImagePlugin(options?: MarkdownImagePluginOptions): MboxPlugin;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { MboxPlugin } from "../../editor/plugin.js";
|
|
2
|
+
import { WidgetType } from "@codemirror/view";
|
|
3
|
+
export declare const pageLinkClassName = "mbox-page-link";
|
|
4
|
+
export declare const iconClassName = "mbox-icon";
|
|
5
|
+
export declare const iconImageClassName = "mbox-icon-image";
|
|
6
|
+
export interface PageLinkPluginOptions {
|
|
7
|
+
pageUrl?: (pageName: string) => string;
|
|
8
|
+
iconUrl?: (iconName: string) => string;
|
|
9
|
+
icons?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare class MboxIconWidget extends WidgetType {
|
|
12
|
+
private readonly href;
|
|
13
|
+
private readonly name;
|
|
14
|
+
private readonly iconUrl;
|
|
15
|
+
constructor(href: string, name: string, iconUrl: string | undefined);
|
|
16
|
+
eq(other: WidgetType): boolean;
|
|
17
|
+
toDOM(): HTMLElement;
|
|
18
|
+
}
|
|
19
|
+
export declare function pageLinkPlugin(options?: PageLinkPluginOptions): MboxPlugin;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { MboxPlugin } from "../../editor/plugin.js";
|
|
2
|
+
export declare const tableRenderedClassName = "mbox-table-rendered";
|
|
3
|
+
export declare const tableRawCellClassName = "mbox-table-raw-cell";
|
|
4
|
+
export declare const tableClassNames: {
|
|
5
|
+
table: string;
|
|
6
|
+
header: string;
|
|
7
|
+
delimiter: string;
|
|
8
|
+
row: string;
|
|
9
|
+
cell: string;
|
|
10
|
+
rendered: string;
|
|
11
|
+
rawCell: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function tablePlugin(): MboxPlugin;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { WidgetType, type EditorView } from "@codemirror/view";
|
|
2
|
+
import { type MboxPlugin } from "../../editor/plugin.js";
|
|
3
|
+
export declare const taskListClassNames: {
|
|
4
|
+
item: string;
|
|
5
|
+
checkbox: string;
|
|
6
|
+
};
|
|
7
|
+
export declare class TaskListCheckboxWidget extends WidgetType {
|
|
8
|
+
private readonly checked;
|
|
9
|
+
private readonly className;
|
|
10
|
+
private readonly from;
|
|
11
|
+
private readonly to;
|
|
12
|
+
private readonly readOnly;
|
|
13
|
+
constructor(checked: boolean, className: string, from: number, to: number, readOnly?: boolean);
|
|
14
|
+
eq(other: WidgetType): boolean;
|
|
15
|
+
updateDOM(dom: HTMLElement, view: EditorView): boolean;
|
|
16
|
+
toDOM(view: EditorView): HTMLElement;
|
|
17
|
+
ignoreEvent(): boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare function taskListPlugin(): MboxPlugin;
|