@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
@@ -0,0 +1,86 @@
1
+ import type { ScrapboxLine, ScrapboxRange } from "./parser.js";
2
+ export interface ScrapboxTextNode extends ScrapboxRange {
3
+ type: "text";
4
+ value: string;
5
+ }
6
+ export interface ScrapboxCodeNode extends ScrapboxRange {
7
+ type: "code";
8
+ openingMarker: ScrapboxRange;
9
+ closingMarker: ScrapboxRange;
10
+ content: ScrapboxRange;
11
+ value: string;
12
+ }
13
+ export interface ScrapboxDecorationNode extends ScrapboxRange {
14
+ type: "decoration";
15
+ rawDecos: string;
16
+ decos: string[];
17
+ openingMarker: ScrapboxRange;
18
+ closingMarker: ScrapboxRange;
19
+ content: ScrapboxRange;
20
+ children: ScrapboxInlineNode[];
21
+ }
22
+ export interface ScrapboxStrongNode extends ScrapboxRange {
23
+ type: "strong";
24
+ openingMarker: ScrapboxRange;
25
+ closingMarker: ScrapboxRange;
26
+ content: ScrapboxRange;
27
+ children: ScrapboxInlineNode[];
28
+ }
29
+ export interface ScrapboxInternalLinkNode extends ScrapboxRange {
30
+ type: "internalLink";
31
+ pathType: "root" | "relative";
32
+ href: string;
33
+ openingMarker: ScrapboxRange;
34
+ closingMarker: ScrapboxRange;
35
+ target: ScrapboxRange;
36
+ }
37
+ export interface ScrapboxExternalLinkNode extends ScrapboxRange {
38
+ type: "externalLink";
39
+ bracketed: boolean;
40
+ href: string;
41
+ content: string;
42
+ hrefRange: ScrapboxRange;
43
+ contentRange: ScrapboxRange | null;
44
+ }
45
+ export interface ScrapboxHashTagNode extends ScrapboxRange {
46
+ type: "hashTag";
47
+ href: string;
48
+ marker: ScrapboxRange;
49
+ target: ScrapboxRange;
50
+ }
51
+ export interface ScrapboxImageNode extends ScrapboxRange {
52
+ type: "image";
53
+ src: string;
54
+ link: string;
55
+ }
56
+ export interface ScrapboxStrongImageNode extends ScrapboxRange {
57
+ type: "strongImage";
58
+ src: string;
59
+ }
60
+ export interface ScrapboxIconNode extends ScrapboxRange {
61
+ type: "icon";
62
+ path: string;
63
+ pathType: "root" | "relative";
64
+ repeatCount: number;
65
+ }
66
+ export interface ScrapboxFormulaNode extends ScrapboxRange {
67
+ type: "formula";
68
+ expression: string;
69
+ content: ScrapboxRange;
70
+ }
71
+ export type ScrapboxInlineNode = ScrapboxTextNode | ScrapboxCodeNode | ScrapboxDecorationNode | ScrapboxStrongNode | ScrapboxInternalLinkNode | ScrapboxExternalLinkNode | ScrapboxHashTagNode | ScrapboxImageNode | ScrapboxStrongImageNode | ScrapboxIconNode | ScrapboxFormulaNode;
72
+ /**
73
+ * Parse the inline content of a single Scrapbox line into offset-aware nodes.
74
+ *
75
+ * Tokens are selected by their leftmost start position. Matcher order, then
76
+ * pattern order, breaks ties at the same position. Each pattern owns a global
77
+ * RegExp clone and caches its next match, so its scan position only advances
78
+ * through this input once. `nested` content skips the matchers mbox does not
79
+ * re-enter (code, decoration, strong).
80
+ */
81
+ export declare function parseScrapboxInline(text: string, base?: number): ScrapboxInlineNode[];
82
+ /**
83
+ * Parse the inline content of one already-parsed line, resolving absolute
84
+ * offsets. Number-list markers (`N. `) are excluded from the inline region.
85
+ */
86
+ export declare function parseScrapboxLineInline(input: string, line: ScrapboxLine): ScrapboxInlineNode[];
@@ -0,0 +1,110 @@
1
+ import { WidgetType } from "@codemirror/view";
2
+ import { type MboxPlugin } from "../../editor/plugin.js";
3
+ import type { ScrapboxLine } from "./parser.js";
4
+ export declare const scrapboxLinkClassName = "mbox-scrapbox-link";
5
+ export declare const scrapboxUrlClassName = "mbox-scrapbox-url";
6
+ export declare const scrapboxHashTagClassName = "mbox-scrapbox-hashtag";
7
+ export declare const scrapboxIconClassName = "mbox-scrapbox-icon";
8
+ export declare const scrapboxIconImageClassName = "mbox-scrapbox-icon-image";
9
+ export declare const scrapboxStrongIconClassName = "mbox-scrapbox-icon-strong";
10
+ export declare const scrapboxStrongIconMeasureClassName = "mbox-scrapbox-icon-strong-measure";
11
+ export declare const scrapboxPageMissingClassName = "mbox-scrapbox-page-missing";
12
+ export declare const scrapboxLinkClassNames: {
13
+ link: string;
14
+ url: string;
15
+ hashTag: string;
16
+ icon: string;
17
+ strongIcon: string;
18
+ pageMissing: string;
19
+ };
20
+ /**
21
+ * Build the avatar image URL for an icon notation from its raw name — the exact
22
+ * text between `[` and `.icon]`, unparsed. `[demo-user.icon]` passes
23
+ * `"demo-user"`, `[/team/bob.icon]` passes `"/team/bob"`, `[team/alice.icon]`
24
+ * passes `"team/alice"`. The library makes no assumption about project/host/path
25
+ * structure — the consumer maps the name to whatever URL their instance uses.
26
+ */
27
+ export type ScrapboxIconUrlResolver = (iconName: string) => string;
28
+ /**
29
+ * Build the href for an internal page reference from its raw name — the exact
30
+ * text between `[` and `]` (or after `#`), unparsed. `[Page]` passes `"Page"`,
31
+ * `[/proj/Page]` passes `"/proj/Page"`, `#tag` passes `"tag"`. Like
32
+ * {@link ScrapboxIconUrlResolver}, the library assumes nothing about the URL;
33
+ * the consumer maps the name to whatever their instance uses. When omitted the
34
+ * href defaults to `./name` (or the raw `/proj/name` for a root reference).
35
+ */
36
+ export type ScrapboxPageUrlResolver = (pageName: string) => string;
37
+ /**
38
+ * Test whether an internal page reference exists from its raw name — the exact
39
+ * text between `[` and `]` (or after `#`), unparsed. `[Page]` passes `"Page"`,
40
+ * `[/proj/Page]` passes `"/proj/Page"`, `#tag` passes `"tag"`. Normalization
41
+ * is the consumer's responsibility. Page references for which this returns
42
+ * `false` get {@link scrapboxPageMissingClassName} added; when omitted no
43
+ * missing-page class is added, preserving the previous behavior. This predicate
44
+ * is called synchronously for every page-reference node whenever decorations
45
+ * are rebuilt, so it must be cheap and pure (no side effects, no async work) and
46
+ * must not throw — like {@link ScrapboxPageUrlResolver}, an exception from it
47
+ * discards the link plugin's decorations for that update cycle. After existence
48
+ * data changes, the consumer controls immediate reflection by dispatching an
49
+ * editor transaction.
50
+ */
51
+ export type ScrapboxPageExistsResolver = (pageName: string) => boolean;
52
+ export interface ScrapboxLinkPluginOptions {
53
+ iconUrl?: ScrapboxIconUrlResolver;
54
+ pageUrl?: ScrapboxPageUrlResolver;
55
+ /**
56
+ * Test whether a page reference exists from its raw name. `[Page]` passes
57
+ * `"Page"`, `[/proj/Page]` passes `"/proj/Page"`, and `#tag` passes `"tag"`;
58
+ * normalization is the consumer's responsibility. Returning `false` adds
59
+ * {@link scrapboxPageMissingClassName}; omitting the resolver adds no class.
60
+ * Called synchronously per page-reference node on every decoration rebuild,
61
+ * so it must be cheap, pure, side-effect free, and non-async. Dispatch a
62
+ * transaction after existence data changes to reflect updates immediately.
63
+ */
64
+ pageExists?: ScrapboxPageExistsResolver;
65
+ }
66
+ export declare class ScrapboxLinkWidget extends WidgetType {
67
+ private readonly href;
68
+ private readonly text;
69
+ private readonly className;
70
+ private readonly external;
71
+ constructor(href: string, text: string, className: string, external: boolean);
72
+ eq(other: WidgetType): boolean;
73
+ toDOM(): HTMLElement;
74
+ }
75
+ export declare class ScrapboxIconWidget extends WidgetType {
76
+ private readonly href;
77
+ private readonly name;
78
+ private readonly iconUrl;
79
+ private readonly repeatCount;
80
+ private readonly strong;
81
+ constructor(href: string, name: string, iconUrl: string | undefined, repeatCount?: number, strong?: boolean);
82
+ eq(other: WidgetType): boolean;
83
+ toDOM(): HTMLElement;
84
+ }
85
+ /**
86
+ * Build the href for an internal page reference. When a `pageUrl` resolver is
87
+ * given the consumer owns the whole URL (raw `name` passed through); otherwise
88
+ * fall back to the default `./name` (or the raw `/proj/name` for a root ref).
89
+ */
90
+ export declare function pageHref(name: string, pathType: "root" | "relative", pageUrl?: ScrapboxPageUrlResolver): string;
91
+ /**
92
+ * @internal Exported for focused projection tests and table-kit integration;
93
+ * not part of the notation bundle's public API.
94
+ *
95
+ * Project a range as its link widgets display it. This belongs in the link
96
+ * module because it owns both the widget replacements and their labels;
97
+ * `table.ts` only asks for the projection to measure a cell. Icons always
98
+ * project to the final page-name segment (`[alice/bob.icon]` becomes `bob`),
99
+ * independently of `iconUrl`: without a resolver this exactly matches the
100
+ * text fallback. With a resolver the final segment is usually wider than the
101
+ * roughly 1em image, but that is not guaranteed: it depends on the name
102
+ * length, the loaded image's aspect ratio, and the host cell box. A one-letter
103
+ * name reserves only 1ch, which can be narrower than 1em.
104
+ *
105
+ * Work-list 4-4 records the measured host interaction: the fixture's square
106
+ * icon fits because its cell has extra host width, while a wide image crosses
107
+ * its cell. This projection remains text-only; it cannot promise image fit.
108
+ */
109
+ export declare function projectScrapboxLinkDisplayValue(input: string, line: ScrapboxLine, from: number, to: number): string | undefined;
110
+ export declare function scrapboxLinkPlugin(options?: ScrapboxLinkPluginOptions): MboxPlugin;
@@ -0,0 +1,21 @@
1
+ import type { MboxPlugin } from "../../editor/plugin.js";
2
+ export declare const scrapboxListLineClassName = "mbox-scrapbox-list-line";
3
+ export declare const scrapboxBulletClassName = "mbox-scrapbox-bullet";
4
+ export declare const scrapboxNumberClassName = "mbox-scrapbox-number";
5
+ export declare const scrapboxIndentAttribute = "data-mbox-scrapbox-indent";
6
+ /**
7
+ * Width of one Scrapbox indent level, in em. The indent whitespace is rendered
8
+ * at this fixed width per level (in both the focused and unfocused states), so
9
+ * a half-width space and a full-width space indent by the same amount — as in
10
+ * Scrapbox — and focus never shifts the content horizontally.
11
+ */
12
+ export declare const scrapboxIndentLevelWidth = 1.5;
13
+ export declare const scrapboxListClassNames: {
14
+ line: string;
15
+ };
16
+ export interface ScrapboxListClassNames {
17
+ line: string;
18
+ bullet: string;
19
+ number: string;
20
+ }
21
+ export declare function scrapboxListPlugin(): MboxPlugin;
@@ -0,0 +1,5 @@
1
+ import type { EditorState } from "@codemirror/state";
2
+ import { type DocumentCacheEntry } from "../../editor/document-cache.js";
3
+ import { type ScrapboxDocument } from "./parser.js";
4
+ export declare function getScrapboxDocumentCacheEntryFromState(state: EditorState): DocumentCacheEntry<ScrapboxDocument>;
5
+ export declare function getScrapboxDocumentFromState(state: EditorState): ScrapboxDocument;
@@ -0,0 +1,65 @@
1
+ import { type ScrapboxInlineNode } from "./inline.js";
2
+ export interface ScrapboxRange {
3
+ from: number;
4
+ to: number;
5
+ }
6
+ export type ScrapboxListType = "none" | "bullet" | "number";
7
+ export interface ScrapboxLine {
8
+ line: number;
9
+ /** Raw input end, including a CR in a CRLF terminator. */
10
+ from: number;
11
+ to: number;
12
+ /** Syntax-facing end; excludes only the CR in a CRLF terminator. */
13
+ logicalTo: number;
14
+ indent: number;
15
+ listType: ScrapboxListType;
16
+ marker: ScrapboxRange;
17
+ content: ScrapboxRange;
18
+ number: number | null;
19
+ numberMarker: ScrapboxRange | null;
20
+ /**
21
+ * Inline nodes parsed once at document-parse time and shared across every
22
+ * inline provider (link / decoration / image / formula), the way mbox and
23
+ * hatena already bake inline into their documents. Empty on code-block lines,
24
+ * which stay fully literal.
25
+ */
26
+ inline: ScrapboxInlineNode[];
27
+ }
28
+ export interface ScrapboxCodeBlock {
29
+ type: "codeBlock";
30
+ /** `code:tex` and `code:latex` are Cosense formula blocks, not code cards. */
31
+ kind: "code" | "formula";
32
+ indent: number;
33
+ fileName: string;
34
+ openerLine: ScrapboxLine;
35
+ bodyLines: ScrapboxLine[];
36
+ }
37
+ export interface ScrapboxTableBlock {
38
+ type: "table";
39
+ indent: number;
40
+ name: string;
41
+ openerLine: ScrapboxLine;
42
+ bodyLines: ScrapboxLine[];
43
+ }
44
+ export interface ScrapboxDocument {
45
+ lines: ScrapboxLine[];
46
+ codeBlocks: ScrapboxCodeBlock[];
47
+ tableBlocks: ScrapboxTableBlock[];
48
+ }
49
+ /**
50
+ * Parse Scrapbox notation text into a flat, line-oriented document model.
51
+ *
52
+ * Indentation follows Scrapbox semantics: the depth is the number of leading
53
+ * whitespace characters (single-byte space, double-byte space and tab each
54
+ * count as one level). A number list is a line whose content begins with
55
+ * `N. `; any other indented line is a bullet, even when there is no content
56
+ * after the leading whitespace.
57
+ */
58
+ export declare function parseScrapboxDocument(input: string): ScrapboxDocument;
59
+ /**
60
+ * The set of 1-based line numbers occupied by any code block (opener + body).
61
+ * Other plugins use this to leave code-block content untouched.
62
+ */
63
+ export declare function scrapboxCodeBlockLineNumbers(document: ScrapboxDocument): Set<number>;
64
+ /** The 1-based line numbers occupied by any table block (opener + body). */
65
+ export declare function scrapboxTableBlockLineNumbers(document: ScrapboxDocument): Set<number>;
@@ -0,0 +1,7 @@
1
+ import { type MboxPlugin } from "../../editor/plugin.js";
2
+ export declare const scrapboxQuoteLineClassName = "mbox-scrapbox-quote-line";
3
+ export declare const scrapboxQuoteMarkerHiddenClassName = "mbox-scrapbox-quote-marker-hidden";
4
+ export declare const scrapboxQuoteClassNames: {
5
+ line: string;
6
+ };
7
+ export declare function scrapboxQuotePlugin(): MboxPlugin;
@@ -0,0 +1,22 @@
1
+ import type { MboxPlugin } from "../../editor/plugin.js";
2
+ export declare const scrapboxTableClassName = "mbox-scrapbox-table";
3
+ export declare const scrapboxTableOpenerClassName = "mbox-scrapbox-table-opener";
4
+ export declare const scrapboxTableRowClassName = "mbox-scrapbox-table-row";
5
+ export declare const scrapboxTableHeaderClassName = "mbox-scrapbox-table-header";
6
+ export declare const scrapboxTableCellClassName = "mbox-scrapbox-table-cell";
7
+ export declare const scrapboxTableRawCellClassName = "mbox-scrapbox-table-raw-cell";
8
+ export declare const scrapboxTableRenderedClassName = "mbox-scrapbox-table-rendered";
9
+ export declare const scrapboxTableKeywordClassName = "mbox-scrapbox-table-keyword";
10
+ export declare const scrapboxTableNameClassName = "mbox-scrapbox-table-name";
11
+ export declare const scrapboxTableClassNames: {
12
+ table: string;
13
+ opener: string;
14
+ row: string;
15
+ header: string;
16
+ cell: string;
17
+ rawCell: string;
18
+ rendered: string;
19
+ keyword: string;
20
+ name: string;
21
+ };
22
+ export declare function scrapboxTablePlugin(): MboxPlugin;
@@ -0,0 +1,3 @@
1
+ import type { MboxPlugin } from "../../editor/plugin.js";
2
+ export declare const scrapboxTitleLineClassName = "mbox-scrapbox-title-line";
3
+ export declare function scrapboxTitlePlugin(): MboxPlugin;
@@ -0,0 +1,34 @@
1
+ import type { MboxActiveLineNumbers } from "../../editor/focused-line.js";
2
+ import { type ScrapboxDocument } from "./parser.js";
3
+ /**
4
+ * The 1-based line numbers occupied by a code block or a table block. Code
5
+ * blocks stay literal for every inline provider; table cells are selectively
6
+ * rendered: mbox keeps links live in table cells but leaves images and
7
+ * formulas raw, because a figure or a formula widget breaks the cell grid.
8
+ */
9
+ export declare function scrapboxBlockLineNumbers(document: ScrapboxDocument): Set<number>;
10
+ /**
11
+ * The 1-based lines the link plugin must leave raw. Links are the only inline
12
+ * provider with this set because mbox renders links in table body cells,
13
+ * yet a `table:` name is download metadata rather than page-link syntax.
14
+ * Other providers leave the complete table block literal through
15
+ * {@link scrapboxBlockLineNumbers}.
16
+ */
17
+ export declare function scrapboxLinkSkippedLineNumbers(document: ScrapboxDocument): Set<number>;
18
+ /**
19
+ * The 1-based line numbers a syntax-revealing scrapbox plugin must leave
20
+ * untouched: the active (revealed) lines, plus every code-block and table-block
21
+ * line. The formula plugin uses this because it decides per line. Quote,
22
+ * decoration, and image plugins instead start with
23
+ * {@link scrapboxBlockLineNumbers} and consult active state per node.
24
+ * Command-line also starts with that block-only set, deliberately applies on
25
+ * active lines too, and therefore does not inspect `activeLines`. The link
26
+ * plugin is the sole exception to the block part: it permits table body cells,
27
+ * but not table opener names.
28
+ *
29
+ * The list plugin deliberately does NOT use this: its bullet dot hides no
30
+ * syntax (the raw indent is always shown), so there is nothing to reveal and
31
+ * the dot stays visible even while the cursor is on the line. See
32
+ * {@link scrapboxBlockLineNumbers}.
33
+ */
34
+ export declare function scrapboxSkippedLineNumbers(document: ScrapboxDocument, activeLines: MboxActiveLineNumbers): Set<number>;
@@ -0,0 +1,142 @@
1
+ import type { MboxDecorationSpec } from "../editor/plugin.js";
2
+ /**
3
+ * Shared table lowering mechanics. This module does not identify or select a
4
+ * notation: each caller supplies parsed cell geometry, projected display text,
5
+ * and ARIA policy. `displayValue` affects width only; `virtual` supplies an
6
+ * idle-only placeholder; `excludeFromSemantics` suppresses that cell's ARIA
7
+ * attributes for callers that still need it; and `columnCount` describes the caller's logical grid. These
8
+ * policies may coexist across a table without the kit inferring one from
9
+ * another.
10
+ */
11
+ /** @internal Constituent of the src-shared TableKitCell; not a package export. */
12
+ export interface TableKitRange {
13
+ from: number;
14
+ to: number;
15
+ }
16
+ /**
17
+ * One cell's raw span (`from`/`to`, padding included) plus its already-trimmed
18
+ * display range (`content`) and its trimmed source text (`value`, used for
19
+ * width measurement when no display projection is supplied). `displayValue` is an
20
+ * optional exact projection of the `content` range that will be displayed, for
21
+ * example after inline markers are hidden. It must not include table padding at
22
+ * either cell boundary. Unlike `value`, which is trimmed before measuring,
23
+ * `displayValue` is deliberately not trimmed: inline code and similar content
24
+ * may intentionally retain leading or trailing spaces. For a cell whose
25
+ * inline syntax is hidden, do not mechanically copy `value` into
26
+ * `displayValue`; a cell without such decoration may correctly use either.
27
+ * `align` and `className` are namespace-specific data a notation attaches per
28
+ * cell — GFM's column alignment, mbox/GFM's delimiter-cell / Hatena's
29
+ * header-cell class — rather than behavior the kit special-cases. `className`
30
+ * is ADDITIVE: appended after the kit's own `classNames.cell`, never replaces it.
31
+ */
32
+ export interface TableKitCell {
33
+ from: number;
34
+ to: number;
35
+ content: TableKitRange;
36
+ value: string;
37
+ displayValue?: string;
38
+ align?: "left" | "right" | "center" | null;
39
+ className?: string;
40
+ /**
41
+ * A floor this cell puts under its column, in the SAME UNITS `measureWidth`
42
+ * returns -- grid units, not characters. With the default measurement one
43
+ * unit happens to be one narrow character, but a caller that injects its own
44
+ * `measureWidth` sets the unit, and this number has to be read in that unit
45
+ * or it means nothing.
46
+ *
47
+ * It is a separate channel on purpose. A cell can want a width that no text
48
+ * of its would produce -- an image has no character width at all -- and the
49
+ * alternative, padding `displayValue` out with invented characters, breaks
50
+ * the rule other work relies on: `displayValue` is the text actually shown.
51
+ *
52
+ * It only ever raises. The column still fits its widest content, so a cell
53
+ * with a long string is never squeezed to make room for this.
54
+ */
55
+ minimumColumnWidth?: number;
56
+ /**
57
+ * An idle-layout-only cell anchored at a document position. It never creates
58
+ * source text and disappears completely while its row is active.
59
+ */
60
+ virtual?: boolean;
61
+ /** Excludes a visible caller-provided cell from the logical ARIA grid. */
62
+ excludeFromSemantics?: boolean;
63
+ }
64
+ /**
65
+ * One table row. `line` is the 1-based line used to look up `activeLines` —
66
+ * mbox/GFM compute it from the table's start line plus a row offset since
67
+ * their row types carry no line number of their own; Hatena's rows already
68
+ * have one.
69
+ *
70
+ * `className` is ADDITIVE (same convention as the cell's), appended after the
71
+ * kit's own `classNames.table` — mbox/GFM use it for their header/delimiter/row
72
+ * classes; a namespace with no such distinction can leave it unset.
73
+ *
74
+ * `includeInColumnWidths` (default true) excludes a row's cells from the
75
+ * column-width measurement — mbox/GFM's delimiter row (`---|---`) sets this to
76
+ * false since its text isn't real column content.
77
+ */
78
+ export interface TableKitRow {
79
+ line: number;
80
+ from: number;
81
+ to: number;
82
+ cells: TableKitCell[];
83
+ className?: string;
84
+ includeInColumnWidths?: boolean;
85
+ attributes?: Record<string, string>;
86
+ }
87
+ export interface TableKitSemantics {
88
+ tableId: string;
89
+ headerRowIndex?: number;
90
+ /** The notation's logical column count, when it differs from a wide source row. */
91
+ columnCount?: number;
92
+ isHeaderCell?: (row: TableKitRow, rowIndex: number, columnIndex: number) => boolean;
93
+ }
94
+ export interface TableKitClassNames {
95
+ table: string;
96
+ renderedLine: string;
97
+ cell: string;
98
+ rawCell: string;
99
+ }
100
+ export interface TableKitCellOptions {
101
+ /**
102
+ * Column width measurement, given the projected display text. The supplied
103
+ * string may include leading or trailing whitespace; `displayValue` is
104
+ * intentionally not trimmed. Defaults to character count; Hatena injects a
105
+ * CJK-aware measure instead. Whatever
106
+ * it returns is rendered back as a `ch`-unit column width (see
107
+ * `createCellSpec` below), so the default is only visually correct under a
108
+ * monospace (or other uniform `ch`-grid) font -- a caller rendering table
109
+ * text in a variable-width font must supply its own `measureWidth` that
110
+ * matches that font's actual glyph widths.
111
+ */
112
+ measureWidth?: (displayedValue: string) => number;
113
+ }
114
+ /**
115
+ * Practical CJK/emoji column-width approximation for
116
+ * {@link TableKitCellOptions.measureWidth}; it counts selected wide/fullwidth
117
+ * ranges as two units and everything else as one, rather than fully
118
+ * implementing East Asian Width.
119
+ *
120
+ * Known limitations: this counts code points, not grapheme clusters, so emoji
121
+ * sequences such as `👍🏽` (4) and `👩‍💻` (5) do not measure as their single
122
+ * two-column glyph. Combining marks also count independently, so decomposed
123
+ * `e + U+0301` measures as 2 although it displays as one column. Correcting
124
+ * either requires grapheme-cluster segmentation and is outside this helper's
125
+ * scope. Callers that need it can inject their own implementation through
126
+ * {@link TableKitCellOptions.measureWidth}.
127
+ */
128
+ export declare function displayWidth(text: string): number;
129
+ /** One `line` decoration per row: the row's own class (if any) plus the
130
+ * rendered-line suffix outside the active line, and a column-count CSS
131
+ * variable for the row's overall cell-width budget. */
132
+ export declare function createTableLineSpecs(rows: readonly TableKitRow[], activeLines: Set<number>, classNames: TableKitClassNames, semantics?: TableKitSemantics): MboxDecorationSpec[];
133
+ /** One cell spec per cell: trimmed content laid out in a fixed `ch`-width
134
+ * column, or the cell's raw span on its own active line. */
135
+ export declare function createTableCellSpecs(rows: readonly TableKitRow[], activeLines: Set<number>, classNames: TableKitClassNames, options?: TableKitCellOptions, semantics?: TableKitSemantics): MboxDecorationSpec[];
136
+ export declare function createTableHeaderRowSpecs(rows: readonly TableKitRow[], activeLines: Set<number>, semantics?: TableKitSemantics): MboxDecorationSpec[];
137
+ /** Hides the padding around each cell's trimmed content outside the active
138
+ * line — the pipes themselves are `createTablePipeHideSpecs`'s job. */
139
+ export declare function createTableWhitespaceHideSpecs(rows: readonly TableKitRow[], activeLines: Set<number>): MboxDecorationSpec[];
140
+ /** Hides the leading, inter-cell, and trailing pipe (and any padding
141
+ * touching it) outside the active line. */
142
+ export declare function createTablePipeHideSpecs(rows: readonly TableKitRow[], activeLines: Set<number>): MboxDecorationSpec[];
@@ -0,0 +1,18 @@
1
+ import type { EditorView } from "@codemirror/view";
2
+ export interface TaskCheckboxKitOptions {
3
+ checked: boolean;
4
+ /** Document range of the `[ ]` / `[x]` marker, for the toggle dispatch. */
5
+ from: number;
6
+ to: number;
7
+ className?: string;
8
+ }
9
+ /** Rebind a registered checkbox widget to its current decoration data. */
10
+ export declare function updateTaskCheckboxInput(input: HTMLInputElement, view: EditorView, options: TaskCheckboxKitOptions): boolean;
11
+ /**
12
+ * The interactive `<input type="checkbox">` every task-list checkbox widget
13
+ * renders: reflects `checked`, and a click dispatches the `[ ]` <-> `[x]`
14
+ * text edit directly (mbox and GFM's identical toggle behavior). The
15
+ * surrounding wrapper element (and whether it carries its own class) is the
16
+ * caller's own layout, not this function's concern.
17
+ */
18
+ export declare function createTaskCheckboxInput(view: EditorView, options: TaskCheckboxKitOptions): HTMLInputElement;
@@ -0,0 +1,42 @@
1
+ import type { EditorState } from "@codemirror/state";
2
+ import type { EditorView } from "@codemirror/view";
3
+ import { type SharedMboxEditorOptions } from "./editor/create-editor.js";
4
+ import { type ScrapboxPluginsOptions } from "./plugins/scrapbox/index.js";
5
+ export { scrapboxBulletClassName, scrapboxIndentAttribute, scrapboxIndentLevelWidth, scrapboxListClassNames, scrapboxListLineClassName, scrapboxListPlugin, scrapboxNumberClassName, } from "./plugins/scrapbox/list.js";
6
+ export type { ScrapboxListClassNames } from "./plugins/scrapbox/list.js";
7
+ export { parseScrapboxDocument, scrapboxCodeBlockLineNumbers, scrapboxTableBlockLineNumbers } from "./plugins/scrapbox/parser.js";
8
+ export type { ScrapboxCodeBlock, ScrapboxDocument, ScrapboxLine, ScrapboxListType, ScrapboxRange, ScrapboxTableBlock, } from "./plugins/scrapbox/parser.js";
9
+ export { scrapboxQuoteClassNames, scrapboxQuoteLineClassName, scrapboxQuotePlugin, } from "./plugins/scrapbox/quote.js";
10
+ export { scrapboxCodeBlockBodyClassName, scrapboxCodeBlockClassName, scrapboxCodeBlockClassNames, scrapboxCodeBlockCopyButtonClassName, scrapboxCodeBlockFileNameClassName, scrapboxCodeBlockHighlightPlugin, scrapboxCodeBlockKeywordClassName, scrapboxCodeBlockLanguageLabelClassName, scrapboxCodeBlockOpenerClassName, scrapboxCodeBlockPlugin, scrapboxCodeBlockTokenClassName, ScrapboxCodeBlockCopyButtonWidget, } from "./plugins/scrapbox/code-block.js";
11
+ export type { ScrapboxCodeBlockHighlightPluginOptions } from "./plugins/scrapbox/code-block.js";
12
+ export { scrapboxFormulaClassName, scrapboxFormulaClassNames, scrapboxFormulaPlugin, ScrapboxFormulaWidget, } from "./plugins/scrapbox/formula.js";
13
+ export type { ScrapboxFormulaPluginOptions, ScrapboxFormulaRenderer } from "./plugins/scrapbox/formula.js";
14
+ export { scrapboxTableCellClassName, scrapboxTableClassName, scrapboxTableClassNames, scrapboxTableHeaderClassName, scrapboxTableKeywordClassName, scrapboxTableNameClassName, scrapboxTableOpenerClassName, scrapboxTablePlugin, scrapboxTableRawCellClassName, scrapboxTableRenderedClassName, scrapboxTableRowClassName, } from "./plugins/scrapbox/table.js";
15
+ export { parseScrapboxInline, parseScrapboxLineInline } from "./plugins/scrapbox/inline.js";
16
+ export type { ScrapboxCodeNode, ScrapboxDecorationNode, ScrapboxExternalLinkNode, ScrapboxFormulaNode, ScrapboxHashTagNode, ScrapboxIconNode, ScrapboxImageNode, ScrapboxInlineNode, ScrapboxInternalLinkNode, ScrapboxStrongImageNode, ScrapboxStrongNode, ScrapboxTextNode, } from "./plugins/scrapbox/inline.js";
17
+ export { scrapboxHashTagClassName, scrapboxIconClassName, scrapboxIconImageClassName, scrapboxStrongIconClassName, scrapboxStrongIconMeasureClassName, scrapboxLinkClassName, scrapboxLinkClassNames, scrapboxLinkPlugin, scrapboxPageMissingClassName, scrapboxUrlClassName, ScrapboxIconWidget, ScrapboxLinkWidget, } from "./plugins/scrapbox/link.js";
18
+ export type { ScrapboxIconUrlResolver, ScrapboxLinkPluginOptions, ScrapboxPageExistsResolver, ScrapboxPageUrlResolver, } from "./plugins/scrapbox/link.js";
19
+ export { scrapboxTitleLineClassName, scrapboxTitlePlugin } from "./plugins/scrapbox/title.js";
20
+ export { scrapboxCommandClassName, scrapboxCommandLineClassName, scrapboxCommandLineClassNames, scrapboxCommandLinePlugin, scrapboxCommandPromptClassName, } from "./plugins/scrapbox/command-line.js";
21
+ export { defaultScrapboxImageSrcResolver, scrapboxImageClassName, scrapboxImageClassNames, scrapboxImageElementClassName, scrapboxImageMeasureClassName, scrapboxImagePlugin, scrapboxImagePreviewClassName, scrapboxImageStrongClassName, scrapboxImageTokenClassName, ScrapboxImageMeasureWidget, ScrapboxImagePreviewWidget, ScrapboxImageWidget, } from "./plugins/scrapbox/image.js";
22
+ export type { ScrapboxImagePluginOptions, ScrapboxImageRenderMode, ScrapboxImageSrcResolver, } from "./plugins/scrapbox/image.js";
23
+ export { backspaceScrapboxIndent, enterScrapboxEmptyList, indentScrapboxLines, outdentScrapboxLines, scrapboxIndentPlugin, scrapboxLineStart, } from "./plugins/scrapbox/indent.js";
24
+ export { scrapboxBracketPlugin } from "./plugins/scrapbox/bracket.js";
25
+ export { scrapboxInlineCodePlugin } from "./plugins/scrapbox/inline-code.js";
26
+ export { scrapboxInlineCodeHighlightPlugin, scrapboxInlineCodeTokenClassName, } from "./plugins/scrapbox/inline-code-highlight.js";
27
+ export type { ScrapboxInlineCodeHighlightPluginOptions } from "./plugins/scrapbox/inline-code-highlight.js";
28
+ export { scrapboxCompletePlugin, scrapboxCompletionClassNames, scrapboxCompletionOptionClassName, scrapboxCompletionOptionWithPreviewClassName, scrapboxCompletionPreviewClassName, scrapboxCompletionPreviewImageClassName, } from "./plugins/scrapbox/complete.js";
29
+ export type { ScrapboxCompletePluginOptions, ScrapboxCompletionCandidate, ScrapboxCompletionNotation, ScrapboxRecommend, } from "./plugins/scrapbox/complete.js";
30
+ export { scrapboxPlugins } from "./plugins/scrapbox/index.js";
31
+ export type { ScrapboxPluginsOptions } from "./plugins/scrapbox/index.js";
32
+ export { scrapboxCodeClassName, scrapboxDecorationClassName, scrapboxDecorationClassNames, scrapboxDecorationPlugin, scrapboxEmphasisClassName, scrapboxStrikethroughClassName, scrapboxStrongClassName, scrapboxUnderlineClassName, } from "./plugins/scrapbox/decoration.js";
33
+ export { scrapboxDefaultPresentationTheme, scrapboxDefaultPresentationThemeSpec } from "./themes/scrapbox-presentation.js";
34
+ export { getScrapboxDocumentFromState } from "./plugins/scrapbox/parser-cache.js";
35
+ export type CreateScrapboxEditorStateOptions = SharedMboxEditorOptions & ScrapboxPluginsOptions;
36
+ export type CreateScrapboxEditorOptions = CreateScrapboxEditorStateOptions & {
37
+ parent: HTMLElement;
38
+ };
39
+ /** Scrapbox-specific editor-state shortcut. Scrapbox-specific plugin options
40
+ * are visible directly. */
41
+ export declare function createScrapboxEditorState(options?: CreateScrapboxEditorStateOptions): EditorState;
42
+ export declare function createScrapboxEditor(options: CreateScrapboxEditorOptions): EditorView;