@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,100 @@
1
+ import { EditorState, type EditorStateConfig, type Extension } from "@codemirror/state";
2
+ import { EditorView } from "@codemirror/view";
3
+ import type { MboxThemeSpec } from "./plugin.js";
4
+ import { type MboxDecorationError, type MboxPlugin } from "./plugin.js";
5
+ import { type MboxPluginOptions } from "../plugins/mbox/default.js";
6
+ export interface CreateEditorStateOptions {
7
+ /** Highlights the focused line's background and, when a host adds a gutter,
8
+ * its gutter entry. Off by default. */
9
+ activeLine?: boolean;
10
+ /** Accessible name for the editable textbox. Defaults to `Text editor`. */
11
+ ariaLabel?: string;
12
+ doc?: string;
13
+ extensions?: Extension[];
14
+ /** Read-only viewer mode: rejects edits (`EditorState.readOnly`) AND drops
15
+ * `contenteditable` (`EditorView.editable` off), so the editor never takes
16
+ * focus and every line always shows its rendered form -- raw syntax never
17
+ * appears. Text stays selectable and copyable. `EditorState.readOnly`
18
+ * alone is NOT this: the editor would still take focus on click and reveal
19
+ * the focused line's raw syntax. Off by default. */
20
+ readOnly?: boolean;
21
+ selection?: EditorStateConfig["selection"];
22
+ }
23
+ export interface CreateEditorViewOptions {
24
+ parent: HTMLElement;
25
+ state: EditorState;
26
+ }
27
+ export interface MboxEditorPresentationOptions {
28
+ container?: false | EditorPresentationThemeOptions;
29
+ /** Notation themes take no parameters, so this is an off switch only. */
30
+ notation?: false;
31
+ }
32
+ export type MboxEditorPresentation = false | MboxEditorPresentationOptions;
33
+ export interface SharedMboxEditorOptions {
34
+ /** Highlights the focused line's background and, when a host adds a gutter,
35
+ * its gutter entry. Off by default. */
36
+ activeLine?: boolean;
37
+ /** Accessible name for the editable textbox. Defaults to `Text editor`. */
38
+ ariaLabel?: string;
39
+ doc?: string;
40
+ selection?: EditorStateConfig["selection"];
41
+ extraPlugins?: MboxPlugin[];
42
+ extensions?: Extension[];
43
+ onDecorationError?: (error: MboxDecorationError) => void;
44
+ presentation?: MboxEditorPresentation;
45
+ /** Read-only viewer mode: rejects edits (`EditorState.readOnly`) AND drops
46
+ * `contenteditable` (`EditorView.editable` off), so the editor never takes
47
+ * focus and every line always shows its rendered form -- raw syntax never
48
+ * appears. Text stays selectable and copyable. `EditorState.readOnly`
49
+ * alone is NOT this: the editor would still take focus on click and reveal
50
+ * the focused line's raw syntax. Off by default. */
51
+ readOnly?: boolean;
52
+ }
53
+ export type CreateMboxEditorStateOptions = SharedMboxEditorOptions & MboxPluginOptions;
54
+ export type CreateMboxEditorOptions = CreateMboxEditorStateOptions & {
55
+ parent: HTMLElement;
56
+ };
57
+ export declare function createEditorState(options?: CreateEditorStateOptions): EditorState;
58
+ export declare function createEditorView(options: CreateEditorViewOptions): EditorView;
59
+ /**
60
+ * Shared assembly behind every namespace's own `createXxxEditorState`
61
+ * (see {@link createMboxEditorState}, and `createGfmEditorState` /
62
+ * `createHatenaEditorState` / `createScrapboxEditorState` in their own
63
+ * namespace entry files): only the plugin bundle and the notation's own
64
+ * optional presentation theme differ between namespaces, so those are the
65
+ * only two things each caller supplies.
66
+ */
67
+ export declare function createNotationEditorState(options: SharedMboxEditorOptions, plugins: MboxPlugin[], notationPresentationTheme: () => Extension): EditorState;
68
+ export declare function createMboxEditorState(options?: CreateMboxEditorStateOptions): EditorState;
69
+ export declare function createMboxEditor(options: CreateMboxEditorOptions): EditorView;
70
+ export interface EditorPresentationThemeOptions {
71
+ fontSize?: string;
72
+ padding?: string;
73
+ minHeight?: string;
74
+ }
75
+ /**
76
+ * Optional default editor-container presentation: comfortable font size and
77
+ * padding, and a height that fills the parent element -- "&"'s `100%` is
78
+ * relative, so unlike a fixed px floor it never fights an embedding context
79
+ * (a comment box, a sidebar, ...). A host adds this to its own extensions if
80
+ * it wants the reference look; nothing in core requires it.
81
+ *
82
+ * Every value here is a CSS variable with this default as its fallback (see
83
+ * {@link editorPresentationThemeSpecFor}), so a host can retune the look from
84
+ * a stylesheet alone, matching every namespace's own presentation theme.
85
+ */
86
+ export declare const defaultEditorPresentationThemeSpec: MboxThemeSpec;
87
+ /**
88
+ * Pure spec builder behind {@link editorPresentationTheme}, exported so a
89
+ * test can pin the function's defaults to {@link defaultEditorPresentationThemeSpec}
90
+ * without inspecting the opaque `Extension` `EditorView.theme()` returns.
91
+ *
92
+ * A value the caller explicitly passes is used as a plain literal, not
93
+ * wrapped in a CSS variable: the caller already made a deliberate choice at
94
+ * the call site, and layering a CSS variable on top would let an unrelated
95
+ * stylesheet silently override it. The CSS-variable escape hatch only
96
+ * applies to the un-parameterized default. "&"'s fill-parent `minHeight` has
97
+ * no JS override of its own, so it is always CSS-variable-wrapped.
98
+ */
99
+ export declare function editorPresentationThemeSpecFor(options?: EditorPresentationThemeOptions): MboxThemeSpec;
100
+ export declare function editorPresentationTheme(options?: EditorPresentationThemeOptions): Extension;
@@ -0,0 +1,20 @@
1
+ import type { EditorState } from "@codemirror/state";
2
+ export interface DocumentCacheEntry<TDocument> {
3
+ input: string;
4
+ document: TDocument;
5
+ }
6
+ export interface DocumentCache<TDocument> {
7
+ getEntry(state: EditorState): DocumentCacheEntry<TDocument>;
8
+ get(state: EditorState): TDocument;
9
+ }
10
+ /**
11
+ * Cache one parsed document per text document (`state.doc`). Selection-only
12
+ * updates produce a new `EditorState` but reuse the same immutable `Text`
13
+ * instance, so keying on `state.doc` means the text is re-parsed only when it
14
+ * actually changes — never on cursor movement.
15
+ *
16
+ * This is how a notation namespace owns its parse: build the cache once at
17
+ * module level from a plain `parse(input)` function and read it from any
18
+ * `EditorState` (decorations and keymaps alike).
19
+ */
20
+ export declare function createDocumentCache<TDocument>(parse: (input: string) => TDocument): DocumentCache<TDocument>;
@@ -0,0 +1,14 @@
1
+ import { StateField, type EditorState } from "@codemirror/state";
2
+ import type { EditorView } from "@codemirror/view";
3
+ export type MboxActiveLineNumbers = Set<number>;
4
+ export interface PointerLease {
5
+ pointerId: number;
6
+ lineNumber: number;
7
+ }
8
+ export declare const setPointerLease: import("@codemirror/state").StateEffectType<PointerLease>;
9
+ export declare const clearPointerLease: import("@codemirror/state").StateEffectType<number>;
10
+ export declare const pointerLeaseField: StateField<ReadonlyMap<number, number>>;
11
+ export declare function getActiveLineNumbersFromState(state: EditorState): MboxActiveLineNumbers;
12
+ export declare function getActiveLineNumbersFromView(view: Pick<EditorView, "state"> & {
13
+ hasFocus?: boolean;
14
+ }): MboxActiveLineNumbers;
@@ -0,0 +1,191 @@
1
+ import { Facet, type EditorState, type Extension } from "@codemirror/state";
2
+ import { EditorView, type KeyBinding, type WidgetType } from "@codemirror/view";
3
+ import { type MboxActiveLineNumbers } from "./focused-line.js";
4
+ export type MboxThemeSpec = Parameters<typeof EditorView.theme>[0];
5
+ /**
6
+ * Style the text in the range with a class (and optional attributes).
7
+ * `inclusiveStart`/`inclusiveEnd` claim a widget/replace decoration that
8
+ * starts/ends at the same position as this mark's own start/end, nesting it
9
+ * inside this mark's DOM element instead of splitting it out as a sibling
10
+ * (CodeMirror's default when a mark and a lower-precedence decoration share
11
+ * a boundary offset).
12
+ */
13
+ export interface MboxMarkDecorationSpec {
14
+ type?: "mark";
15
+ from: number;
16
+ to: number;
17
+ className: string;
18
+ /** Optional semantic element used to wrap the marked content. */
19
+ tagName?: string;
20
+ attributes?: Record<string, string>;
21
+ inclusiveStart?: boolean;
22
+ inclusiveEnd?: boolean;
23
+ }
24
+ /**
25
+ * Style the whole line containing `from` with a class (and optional
26
+ * attributes). `from` may be ANY offset on the line — the renderer resolves
27
+ * the line start.
28
+ */
29
+ export interface MboxLineDecorationSpec {
30
+ type: "line";
31
+ from: number;
32
+ className: string;
33
+ attributes?: Record<string, string>;
34
+ }
35
+ /**
36
+ * Hide the text in the range, optionally rendering a widget in its place.
37
+ * The widget's own DOM carries any classes — CodeMirror does not apply a
38
+ * class to a replace decoration.
39
+ */
40
+ export interface MboxReplaceDecorationSpec {
41
+ type: "replace";
42
+ from: number;
43
+ to: number;
44
+ widget?: WidgetType;
45
+ }
46
+ /**
47
+ * Render a widget at `from` without hiding any text. As with replace
48
+ * decorations, classes live on the widget's own DOM.
49
+ */
50
+ export interface MboxWidgetDecorationSpec {
51
+ type: "widget";
52
+ from: number;
53
+ widget: WidgetType;
54
+ side?: number;
55
+ }
56
+ /**
57
+ * Style the whole GROUP of lines containing `from`..`to` as one container.
58
+ * Every line in the range gets `className` (and `attributes`); the renderer
59
+ * additionally marks the boundary lines with `${className}-first` and
60
+ * `${className}-last`, so CSS can draw real container edges (top border /
61
+ * radius on -first, bottom on -last, left border on all).
62
+ *
63
+ * Ranges may nest or overlap — each lowers independently, so a line inside two
64
+ * ranges carries both classes. For depth-dependent styling (nested quote
65
+ * indent), pass a CSS custom property per range via `attributes`.
66
+ *
67
+ * The lines themselves always remain in the layout: mbox has no primitive for
68
+ * removing a whole line (see the Decoration.replace boundary notes in todo.md),
69
+ * so a hidden marker line inside a range renders as an empty styled row.
70
+ */
71
+ export interface MboxLineRangeDecorationSpec {
72
+ type: "lineRange";
73
+ from: number;
74
+ to: number;
75
+ className: string;
76
+ attributes?: Record<string, string>;
77
+ }
78
+ export type MboxDecorationSpec = MboxMarkDecorationSpec | MboxLineDecorationSpec | MboxLineRangeDecorationSpec | MboxReplaceDecorationSpec | MboxWidgetDecorationSpec;
79
+ /**
80
+ * The per-update context shared by every decoration provider: the editor
81
+ * state, and the 1-based line numbers whose raw syntax is revealed (the
82
+ * selected lines while the editor has focus).
83
+ *
84
+ * The context is deliberately notation-agnostic. A notation plugin reads its
85
+ * parsed document with the matching public `getXxxDocumentFromState` accessor.
86
+ */
87
+ export interface MboxDecorationContext {
88
+ state: EditorState;
89
+ activeLineNumbers: MboxActiveLineNumbers;
90
+ }
91
+ export type MboxDecorationProvider = (context: MboxDecorationContext) => MboxDecorationSpec[];
92
+ /** @internal An inactive source range whose non-owner decorations must not render. */
93
+ export interface MboxDecorationFirewallRange {
94
+ from: number;
95
+ to: number;
96
+ }
97
+ type MboxDecorationFirewallProvider = (context: MboxDecorationContext) => MboxDecorationFirewallRange[];
98
+ export interface MboxDecorationProviderEntry {
99
+ provider: MboxDecorationProvider;
100
+ firewallRanges?: MboxDecorationFirewallProvider;
101
+ pluginName?: string;
102
+ pluginIndex?: number;
103
+ }
104
+ export interface CreateMboxExtensionOptions {
105
+ plugins?: MboxPlugin[];
106
+ /**
107
+ * Called for each recoverable decoration failure (a plugin's `decorations()`
108
+ * threw, or returned a spec with malformed coordinates) instead of
109
+ * crashing the whole `EditorView`. If a provider throws, that provider's
110
+ * entire output for the update is dropped. If lowering one returned spec
111
+ * fails, only that spec is dropped and the provider's other specs remain.
112
+ * Everything else keeps rendering. Route this to your own error tracking --
113
+ * by default these failures are silent. Exceptions thrown by this handler
114
+ * are swallowed so a failing error reporter cannot interrupt rendering or
115
+ * prevent the other handlers from receiving the failure.
116
+ */
117
+ onDecorationError?: (error: MboxDecorationError) => void;
118
+ }
119
+ /**
120
+ * One editor feature as plain data: CodeMirror extensions, key bindings, a
121
+ * theme fragment, and a decoration provider. Every field is a direct value —
122
+ * build laziness, if needed, into the plugin factory function that returns
123
+ * this object.
124
+ */
125
+ export interface MboxPlugin {
126
+ name?: string;
127
+ extensions?: Extension[];
128
+ keymap?: KeyBinding[];
129
+ theme?: MboxThemeSpec;
130
+ decorations?: MboxDecorationProvider;
131
+ /**
132
+ * Internal structural ownership boundary. Its ranges suppress mark, replace,
133
+ * and widget output from every other provider before lowering; the declaring
134
+ * provider is exempt by provenance, not by decoration shape.
135
+ */
136
+ decorationFirewallRanges?: MboxDecorationFirewallProvider;
137
+ }
138
+ export declare const mboxDecorationProviders: Facet<MboxDecorationProviderEntry, MboxDecorationProviderEntry[]>;
139
+ /**
140
+ * Lower a plugin-produced spec array to the same sorted `DecorationSet` a real
141
+ * `EditorView` renders -- the ONE place spec-to-CodeMirror-decoration
142
+ * conversion happens, shared between the live facet below and
143
+ * `validateDecorationSpecs` (test-context.ts). Internal only: a spec that
144
+ * violates a decoration invariant (for example reversed or out-of-bounds
145
+ * coordinates) throws here, exactly as it would in production, so a unit test
146
+ * that runs specs through this function catches what raw spec assertions alone
147
+ * cannot.
148
+ */
149
+ export declare function createMboxDecorationSetStrict(state: EditorState, specs: MboxDecorationSpec[]): import("@codemirror/view").DecorationSet;
150
+ /**
151
+ * A recoverable failure while turning plugin output into live decorations.
152
+ * "provider" means a plugin's own `decorations()` function threw; "lowering"
153
+ * means a spec it returned violates a lowering invariant (e.g. reversed or
154
+ * out-of-bounds coordinates). Passed to `createMboxExtension`'s
155
+ * `onDecorationError`.
156
+ */
157
+ export interface MboxDecorationError {
158
+ phase: "provider" | "lowering";
159
+ error: unknown;
160
+ spec?: MboxDecorationSpec;
161
+ pluginName?: string;
162
+ pluginIndex?: number;
163
+ }
164
+ /**
165
+ * Like {@link createMboxDecorationSetStrict}, but a spec with malformed
166
+ * coordinates (for example reversed or out-of-bounds coordinates) is dropped
167
+ * instead of throwing --
168
+ * one broken spec from one plugin should not take the whole live EditorView
169
+ * down for every subsequent update. Used by the live `mboxDecorations` facet;
170
+ * `validateDecorationSpecs` (test-context.ts) uses the throwing variant on
171
+ * purpose, so a broken spec still fails a unit test.
172
+ */
173
+ export declare function createMboxDecorationSetSafe(state: EditorState, specs: MboxDecorationSpec[], onDecorationError?: (error: MboxDecorationError) => void): import("@codemirror/view").DecorationSet;
174
+ /**
175
+ * Build a mark that represents the FULL styled
176
+ * content of a span (a list item's body, emphasis/strong content, etc.) --
177
+ * one that may fully or partially coincide with an embedded widget/replace
178
+ * decoration (a link, image, checkbox...). Always sets inclusiveStart and
179
+ * inclusiveEnd, so CodeMirror nests the coincident widget inside this mark's
180
+ * DOM element instead of splitting it out as a sibling -- which would
181
+ * silently drop the mark's own styling from that widget's content. Narrow
182
+ * marks that only ever style a fixed syntax fragment (a footnote marker, a
183
+ * heading's hidden `#`, ...) do not need these inclusive boundaries.
184
+ */
185
+ export declare function createContentMarkSpec(from: number, to: number, className: string, tagName?: string): MboxMarkDecorationSpec;
186
+ export declare function createMboxExtension(options?: CreateMboxExtensionOptions): Extension[];
187
+ /** @internal Sort and merge firewall ranges into a searchable union. */
188
+ export declare function sortDecorationFirewallRanges(ranges: readonly MboxDecorationFirewallRange[]): MboxDecorationFirewallRange[];
189
+ /** @internal Filter specs through a sorted, merged firewall range union. */
190
+ export declare function filterSpecsThroughDecorationFirewallRanges(specs: MboxDecorationSpec[], firewallRanges: readonly MboxDecorationFirewallRange[]): MboxDecorationSpec[];
191
+ export {};
@@ -0,0 +1,28 @@
1
+ import { type MboxDecorationContext, type MboxDecorationSpec } from "./plugin.js";
2
+ export interface CreateTestContextOptions {
3
+ /** Explicit 1-based active line numbers; overrides `selection` derivation. */
4
+ activeLines?: Iterable<number>;
5
+ /** A cursor offset or range whose lines become the active lines. */
6
+ selection?: number | {
7
+ anchor: number;
8
+ head?: number;
9
+ };
10
+ }
11
+ /**
12
+ * Build a decoration context straight from a document string, for exercising
13
+ * `plugin.decorations(context)` in tests without a DOM or an editor view.
14
+ * With no options the context is unfocused (no active lines), matching a
15
+ * blurred editor.
16
+ */
17
+ export declare function createTestContext(doc: string, options?: CreateTestContextOptions): MboxDecorationContext;
18
+ /**
19
+ * Run a plugin's spec output through the same normalization and lowering as a
20
+ * real `EditorView`. Empty mark and replace ranges are normalized as they are
21
+ * in production; invalid positions and reversed ranges still throw, so a
22
+ * plugin/kit test catches malformed output that raw spec assertions alone
23
+ * cannot. Add one call at the end of a test's `specsFor()` helper.
24
+ *
25
+ * This deliberately uses the throwing Strict variant rather than the live
26
+ * facet's Safe variant: malformed specs should fail a test, not be dropped.
27
+ */
28
+ export declare function validateDecorationSpecs(context: MboxDecorationContext, specs: MboxDecorationSpec[]): void;
package/dist/gfm.d.ts ADDED
@@ -0,0 +1,34 @@
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 GfmPluginsOptions } from "./plugins/gfm/index.js";
5
+ export { gfmPlugins } from "./plugins/gfm/index.js";
6
+ export type { GfmPluginsOptions } from "./plugins/gfm/index.js";
7
+ export { gfmHeadingClassNames, gfmHeadingLineClassName, gfmHeadingPlugin, gfmHeadingSetextUnderlineClassName, } from "./plugins/gfm/heading.js";
8
+ export { gfmBulletClassName, gfmListDepthClassName, gfmListLineClassName, gfmListPlugin, gfmTaskCheckboxClassName, gfmTaskLineClassName, GfmBulletWidget, GfmTaskCheckboxWidget, } from "./plugins/gfm/list.js";
9
+ export { gfmQuoteClassName, gfmQuotePlugin } from "./plugins/gfm/quote.js";
10
+ export { gfmCodeBlockClassName, gfmCodeBlockClassNames, gfmCodeBlockHighlightPlugin, gfmCodeBlockPlugin, GfmCodeBlockCopyButtonWidget, } from "./plugins/gfm/code-block.js";
11
+ export type { GfmCodeBlockHighlightPluginOptions } from "./plugins/gfm/code-block.js";
12
+ export { gfmMathClassName, gfmMathPlugin, GfmMathWidget } from "./plugins/gfm/math.js";
13
+ export type { GfmMathPluginOptions, GfmMathRenderer } from "./plugins/gfm/math.js";
14
+ export { gfmImageClassName, gfmImageClassNames, gfmImagePlugin } from "./plugins/gfm/image.js";
15
+ export type { GfmImagePluginOptions, GfmImageRenderMode } from "./plugins/gfm/image.js";
16
+ export { gfmFootnoteClassName, gfmFootnoteMarkerClassName, gfmFootnotePlugin, gfmFootnoteRefClassName, GfmFootnoteRefWidget, } from "./plugins/gfm/footnote.js";
17
+ export { gfmInlineClassNames, gfmInlinePlugin } from "./plugins/gfm/inline.js";
18
+ export { gfmInlineCodeClassName, gfmInlineCodePlugin } from "./plugins/gfm/inline-code.js";
19
+ export { gfmLinkClassName, gfmLinkPlugin, gfmUnsafeLinkClassName, GfmLinkWidget } from "./plugins/gfm/link.js";
20
+ export type { GfmLinkOptions } from "./plugins/gfm/link.js";
21
+ export { gfmTableClassNames, gfmTablePlugin, gfmTableRawCellClassName, gfmTableRenderedClassName } from "./plugins/gfm/table.js";
22
+ export { gfmThematicBreakClassName, gfmThematicBreakLineClassName, gfmThematicBreakPlugin, GfmThematicBreakWidget, } from "./plugins/gfm/thematic-break.js";
23
+ export { adaptGfmDocument, parseGfmDocument } from "./plugins/gfm/parser.js";
24
+ export type { GfmBlockquote, GfmCodeBlock, GfmCodeBlockContentSegment, GfmCodeBlockLanguage, GfmDocument, GfmEscape, GfmFootnoteDefinition, GfmFootnoteReference, GfmHardBreak, GfmHeading, GfmImage, GfmInlineCode, GfmInlineStyle, GfmInlineStyleType, GfmLink, GfmListItem, GfmQuoteMarker, GfmRange, GfmTable, GfmTableAlign, GfmTableCell, GfmTableRow, GfmTask, GfmThematicBreak, } from "./plugins/gfm/parser.js";
25
+ export { gfmDefaultPresentationTheme, gfmDefaultPresentationThemeSpec } from "./themes/gfm-presentation.js";
26
+ export { getGfmDocumentFromState } from "./plugins/gfm/parser-cache.js";
27
+ export type CreateGfmEditorStateOptions = SharedMboxEditorOptions & GfmPluginsOptions;
28
+ export type CreateGfmEditorOptions = CreateGfmEditorStateOptions & {
29
+ parent: HTMLElement;
30
+ };
31
+ /** GFM-specific editor-state shortcut. GFM-specific plugin options are visible
32
+ * directly. */
33
+ export declare function createGfmEditorState(options?: CreateGfmEditorStateOptions): EditorState;
34
+ export declare function createGfmEditor(options: CreateGfmEditorOptions): EditorView;