reactive-md 0.4.0 → 0.5.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 (52) hide show
  1. package/CHANGELOG-ch.md +33 -1
  2. package/CHANGELOG.md +33 -1
  3. package/README-ch.md +36 -6
  4. package/README-en.md +37 -7
  5. package/README.md +37 -7
  6. package/THIRD_PARTY_NOTICES.md +94 -1
  7. package/dist-library/reactive-md-editor.css +2 -0
  8. package/dist-library/reactive-md-editor.js +3710 -0
  9. package/dist-library/reactive-md-react.js +9179 -1606
  10. package/dist-library/reactive-md.css +1 -1
  11. package/dist-library/reactive-md.js +98 -97
  12. package/dist-library/{runtime-DtjdPXxJ.js → runtime-DPuMxM_y.js} +1856 -1461
  13. package/dist-library/types/editor/ReactiveMarkdownEditor.d.ts +7 -0
  14. package/dist-library/types/editor/editor-commands.d.ts +50 -0
  15. package/dist-library/types/editor/editor-i18n.d.ts +102 -0
  16. package/dist-library/types/editor/editor-toolbar.d.ts +24 -0
  17. package/dist-library/types/editor/extended-native-components.d.ts +58 -0
  18. package/dist-library/types/editor/index.d.ts +9 -0
  19. package/dist-library/types/editor/locale.d.ts +13 -0
  20. package/dist-library/types/editor/native-components.d.ts +47 -0
  21. package/dist-library/types/editor/source-authoring.d.ts +57 -0
  22. package/dist-library/types/editor/types.d.ts +44 -0
  23. package/dist-library/types/editor/use-gutter-metrics.d.ts +5 -0
  24. package/dist-library/types/editor/use-source-history.d.ts +16 -0
  25. package/dist-library/types/local/code-block.d.ts +24 -0
  26. package/dist-library/types/local/footnotes.d.ts +51 -0
  27. package/dist-library/types/local/image-view.d.ts +21 -0
  28. package/dist-library/types/local/types.d.ts +7 -0
  29. package/dist-standalone/reactive-md-standalone.css +1 -1
  30. package/dist-standalone/reactive-md-standalone.js +47 -36
  31. package/docs/compatibility-ch.md +12 -8
  32. package/docs/compatibility-en.md +12 -8
  33. package/docs/component-protocol-ch.md +2 -2
  34. package/docs/component-protocol-en.md +2 -2
  35. package/docs/editor-ch.md +216 -0
  36. package/docs/editor-en.md +216 -0
  37. package/docs/local-guide-ch.md +11 -5
  38. package/docs/local-guide-en.md +11 -5
  39. package/docs/local-interaction-syntax-ch.md +7 -2
  40. package/docs/local-interaction-syntax-en.md +7 -2
  41. package/docs/release-0.4.0-ch.md +4 -4
  42. package/docs/release-0.4.0-en.md +4 -4
  43. package/docs/release-0.4.1-ch.md +23 -0
  44. package/docs/release-0.4.1-en.md +23 -0
  45. package/docs/release-0.5.0-ch.md +41 -0
  46. package/docs/release-0.5.0-en.md +41 -0
  47. package/docs/releasing-ch.md +18 -11
  48. package/docs/releasing-en.md +18 -11
  49. package/docs/shareable-export-ch.md +4 -2
  50. package/docs/shareable-export-en.md +4 -2
  51. package/examples/integration/react-editor.tsx +74 -0
  52. package/package.json +54 -11
@@ -0,0 +1,7 @@
1
+ import type { ReactiveMarkdownEditorHandle, ReactiveMarkdownEditorProps } from './types.js';
2
+ /**
3
+ * Controlled Markdown source editor with the demo's toolbar and authoring
4
+ * tools. The textarea is the only editing surface; every transformation is
5
+ * reported through `onChange`, and undo history stays inside this instance.
6
+ */
7
+ export declare const ReactiveMarkdownEditor: import("react").ForwardRefExoticComponent<ReactiveMarkdownEditorProps & import("react").RefAttributes<ReactiveMarkdownEditorHandle>>;
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Pure text transformations behind the Markdown source toolbar.
3
+ *
4
+ * Every command receives the current source value and selection, clamps the
5
+ * selection, and returns a new value plus the selection that should be
6
+ * restored on the textarea. Nothing in this module touches the DOM.
7
+ *
8
+ * Commands that insert human-readable text accept an optional locale and
9
+ * default to English, so direct callers keep their original output.
10
+ */
11
+ import type { EditorEdit, EditorLocale, EditorSelection } from './types.js';
12
+ export type { EditorEdit, EditorSelection } from './types.js';
13
+ export interface InsertTemplateOptions {
14
+ block?: boolean;
15
+ }
16
+ export declare function formatBold(value: string, selection: EditorSelection, locale?: EditorLocale): EditorEdit;
17
+ export declare function formatItalic(value: string, selection: EditorSelection, locale?: EditorLocale): EditorEdit;
18
+ export declare function formatStrike(value: string, selection: EditorSelection, locale?: EditorLocale): EditorEdit;
19
+ export declare function formatInlineCode(value: string, rawSelection: EditorSelection, locale?: EditorLocale): EditorEdit;
20
+ export declare function formatHeading(value: string, rawSelection: EditorSelection, level: 0 | 1 | 2 | 3 | 4 | 5 | 6): EditorEdit;
21
+ export declare function formatBulletList(value: string, selection: EditorSelection): EditorEdit;
22
+ export declare function formatOrderedList(value: string, selection: EditorSelection): EditorEdit;
23
+ export declare function formatTaskList(value: string, selection: EditorSelection): EditorEdit;
24
+ export declare function formatQuote(value: string, selection: EditorSelection): EditorEdit;
25
+ export declare function indentSelection(value: string, rawSelection: EditorSelection): EditorEdit;
26
+ export declare function outdentSelection(value: string, rawSelection: EditorSelection): EditorEdit;
27
+ export declare function insertLink(value: string, rawSelection: EditorSelection, locale?: EditorLocale): EditorEdit;
28
+ export declare function insertImage(value: string, rawSelection: EditorSelection, locale?: EditorLocale): EditorEdit;
29
+ export declare function insertCodeBlock(value: string, rawSelection: EditorSelection, locale?: EditorLocale): EditorEdit;
30
+ export declare function insertTable(value: string, rawSelection: EditorSelection, locale?: EditorLocale): EditorEdit;
31
+ export declare function insertDivider(value: string, rawSelection: EditorSelection): EditorEdit;
32
+ export declare function insertText(value: string, rawSelection: EditorSelection, text: string): EditorEdit;
33
+ export declare function insertTemplate(value: string, rawSelection: EditorSelection, template: string, options?: InsertTemplateOptions): EditorEdit;
34
+ export type EditorListType = 'bullet' | 'ordered' | 'task';
35
+ export interface EditorFormatState {
36
+ headingLevel: 0 | 1 | 2 | 3 | 4 | 5 | 6;
37
+ bold: boolean;
38
+ italic: boolean;
39
+ strike: boolean;
40
+ inlineCode: boolean;
41
+ list: EditorListType | null;
42
+ quote: boolean;
43
+ }
44
+ /**
45
+ * Reads the formatting that applies at the selection without changing the
46
+ * document. Line-level state comes from the line holding `selection.start`;
47
+ * inline state comes from markers around or enclosing the selection (or
48
+ * around the caret when the selection is collapsed).
49
+ */
50
+ export declare function readFormatState(value: string, rawSelection: EditorSelection): EditorFormatState;
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Typed copy for the source editor: toolbar chrome, command placeholders and
3
+ * native-component picker text.
4
+ *
5
+ * English strings are the canonical defaults. Chinese strings use the wording
6
+ * shipped in the demo. English native-component labels, descriptions and
7
+ * templates live in `native-components.ts`; this module carries the Chinese
8
+ * overrides plus the group names for both languages.
9
+ */
10
+ import type { EditorLocale } from './types.js';
11
+ export interface EditorCommandCopy {
12
+ boldPlaceholder: string;
13
+ italicPlaceholder: string;
14
+ strikePlaceholder: string;
15
+ inlineCodePlaceholder: string;
16
+ linkText: string;
17
+ imageAlt: string;
18
+ codeBlockPlaceholder: string;
19
+ tableHeaders: readonly [string, string, string];
20
+ tableRows: readonly [
21
+ readonly [string, string, string],
22
+ readonly [string, string, string]
23
+ ];
24
+ }
25
+ export interface EditorToolbarCopy {
26
+ toolbarLabel: string;
27
+ headingLabels: readonly [string, string, string, string, string, string, string];
28
+ headingLevelLabel(heading: string): string;
29
+ headingMenuLabel: string;
30
+ bold: string;
31
+ italic: string;
32
+ listLabel: string;
33
+ listLabelWithType(list: string): string;
34
+ listMenuLabel: string;
35
+ listLabels: {
36
+ bullet: string;
37
+ ordered: string;
38
+ task: string;
39
+ };
40
+ decreaseIndent: string;
41
+ increaseIndent: string;
42
+ insertLink: string;
43
+ insert: string;
44
+ insertMenuLabel: string;
45
+ insertItems: {
46
+ image: string;
47
+ table: string;
48
+ divider: string;
49
+ codeBlock: string;
50
+ inlineCode: string;
51
+ strikethrough: string;
52
+ quote: string;
53
+ };
54
+ emoji: string;
55
+ insertEmojiMenuLabel: string;
56
+ insertEmojiLabel(emoji: string): string;
57
+ componentsTriggerLabel: string;
58
+ componentsLabel: string;
59
+ componentsCompactLabel: string;
60
+ nativeMenuLabel: string;
61
+ nativeTitle: string;
62
+ closeNativeLabel: string;
63
+ searchPlaceholder: string;
64
+ searchLabel: string;
65
+ nativeListLabel: string;
66
+ noMatchingComponents: string;
67
+ inlineBadge: string;
68
+ historyLabel: string;
69
+ undo: string;
70
+ redo: string;
71
+ download: string;
72
+ more: string;
73
+ moreMenuLabel: string;
74
+ linkMenuItem: string;
75
+ }
76
+ export interface NativeComponentGroupCopy {
77
+ input: string;
78
+ action: string;
79
+ layout: string;
80
+ data: string;
81
+ hint: string;
82
+ }
83
+ export interface NativeComponentCopy {
84
+ label: string;
85
+ description: string;
86
+ keywords: readonly string[];
87
+ template: string;
88
+ }
89
+ export interface NativeComponentCatalogCopy {
90
+ groups: NativeComponentGroupCopy;
91
+ /** Per-component Chinese overrides keyed by the stable component id. */
92
+ components: Readonly<Record<string, NativeComponentCopy>>;
93
+ }
94
+ export interface EditorChromeCopy {
95
+ /** Accessible name for the textarea when the host passes no ariaLabel. */
96
+ sourceLabel: string;
97
+ region: string;
98
+ }
99
+ export declare const EDITOR_CHROME_COPY: Record<EditorLocale, EditorChromeCopy>;
100
+ export declare const EDITOR_COMMAND_COPY: Record<EditorLocale, EditorCommandCopy>;
101
+ export declare const EDITOR_TOOLBAR_COPY: Record<EditorLocale, EditorToolbarCopy>;
102
+ export declare const NATIVE_COMPONENT_CATALOG_COPY: Record<EditorLocale, NativeComponentCatalogCopy>;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Editor toolbar for the Reactive MD editor.
3
+ *
4
+ * The toolbar only reads the textarea and hands pure `EditorEdit` results back
5
+ * to the editor. The editor owns history, focus restoration and the controlled
6
+ * value. Format state is derived from the current selection so the toolbar
7
+ * reflects the block and inline formatting under the caret.
8
+ */
9
+ import { type ReactElement, type RefObject } from 'react';
10
+ import { type EditorEdit } from './editor-commands.js';
11
+ export interface EditorToolbarProps {
12
+ editorRef: RefObject<HTMLTextAreaElement | null>;
13
+ onEdit(edit: EditorEdit): void;
14
+ onUndo(): void;
15
+ onRedo(): void;
16
+ canUndo: boolean;
17
+ canRedo: boolean;
18
+ onExport?(): void;
19
+ /** Render the download action only when the host supplies a handler. */
20
+ showExport?: boolean;
21
+ /** Read-only and disabled editors leave every action without effect. */
22
+ disabled?: boolean;
23
+ }
24
+ export declare function EditorToolbar({ editorRef, onEdit, onUndo, onRedo, canUndo, canRedo, onExport, showExport, disabled, }: EditorToolbarProps): ReactElement;
@@ -0,0 +1,58 @@
1
+ import type { NativeComponentDefinition } from './native-components.js';
2
+ export declare const EXTENDED_NATIVE_COMPONENTS: readonly NativeComponentDefinition[];
3
+ export declare const EXTENDED_NATIVE_COMPONENT_COPY_ZH: {
4
+ jump: {
5
+ label: string;
6
+ description: string;
7
+ keywords: string[];
8
+ template: string;
9
+ };
10
+ anchor: {
11
+ label: string;
12
+ description: string;
13
+ keywords: string[];
14
+ template: string;
15
+ };
16
+ text: {
17
+ label: string;
18
+ description: string;
19
+ keywords: string[];
20
+ template: string;
21
+ };
22
+ section: {
23
+ label: string;
24
+ description: string;
25
+ keywords: string[];
26
+ template: string;
27
+ };
28
+ 'multi-select': {
29
+ label: string;
30
+ description: string;
31
+ keywords: string[];
32
+ template: string;
33
+ };
34
+ 'range-slider': {
35
+ label: string;
36
+ description: string;
37
+ keywords: string[];
38
+ template: string;
39
+ };
40
+ coordinate: {
41
+ label: string;
42
+ description: string;
43
+ keywords: string[];
44
+ template: string;
45
+ };
46
+ quiz: {
47
+ label: string;
48
+ description: string;
49
+ keywords: string[];
50
+ template: string;
51
+ };
52
+ steps: {
53
+ label: string;
54
+ description: string;
55
+ keywords: string[];
56
+ template: string;
57
+ };
58
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Public entry for the Reactive MD source editor.
3
+ *
4
+ * This module carries no CSS import, so consumers that only need the component
5
+ * can tree-shake or server-render it. Import `reactive-md/editor/styles.css`
6
+ * for the stylesheet, or use `./library` for the CSS-included bundle.
7
+ */
8
+ export { ReactiveMarkdownEditor } from './ReactiveMarkdownEditor.js';
9
+ export type { EditorEdit, EditorLocale, EditorSelection, EditorTheme, ReactiveMarkdownEditorHandle, ReactiveMarkdownEditorProps, } from './types.js';
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Private locale context for the editor package.
3
+ *
4
+ * The editor keeps its own language state so it can be mounted anywhere
5
+ * without touching the host document or borrowing the demo's provider.
6
+ */
7
+ import { type ReactNode } from 'react';
8
+ import type { EditorLocale } from './types.js';
9
+ export declare function EditorLocaleProvider({ locale, children, }: {
10
+ locale: EditorLocale;
11
+ children: ReactNode;
12
+ }): import("react").JSX.Element;
13
+ export declare function useEditorLocale(): EditorLocale;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Catalog of `local-draft-2` native components offered by the editor toolbar.
3
+ *
4
+ * Templates stay close to the documented authoring syntax:
5
+ * - `{{bind:base}}` is resolved by `renderNativeSnippet` to a fresh bind name.
6
+ * - `{{selection}}`, `{{selection:fallback}}`, `{{caret}}` and `{{select:value}}`
7
+ * are left for the toolbar's `insertTemplate` handler.
8
+ * - Leaf components never receive a closing tag; container bodies use blank
9
+ * lines so inserted Markdown keeps a natural block layout.
10
+ */
11
+ import type { EditorLocale } from './types.js';
12
+ export type NativeComponentGroupId = 'input' | 'action' | 'layout' | 'data' | 'hint';
13
+ export interface NativeComponentGroup {
14
+ id: NativeComponentGroupId;
15
+ label: string;
16
+ }
17
+ export interface NativeComponentDefinition {
18
+ id: string;
19
+ label: string;
20
+ description: string;
21
+ group: NativeComponentGroupId;
22
+ keywords: string[];
23
+ inline?: boolean;
24
+ template: string;
25
+ }
26
+ export declare const NATIVE_COMPONENT_GROUPS: readonly NativeComponentGroup[];
27
+ export declare const NATIVE_COMPONENTS: readonly NativeComponentDefinition[];
28
+ export declare const NATIVE_COMPONENT_GROUPS_ZH: readonly NativeComponentGroup[];
29
+ export declare const NATIVE_COMPONENTS_ZH: readonly NativeComponentDefinition[];
30
+ export interface NativeComponentCatalog {
31
+ groups: readonly NativeComponentGroup[];
32
+ components: readonly NativeComponentDefinition[];
33
+ }
34
+ /**
35
+ * Catalog for the active UI language. Labels, descriptions and templates are
36
+ * localized; keywords keep both English and Chinese terms so either query
37
+ * works in either language.
38
+ */
39
+ export declare function getNativeComponentCatalog(locale?: EditorLocale): NativeComponentCatalog;
40
+ /**
41
+ * Render one toolbar template for insertion into `source`.
42
+ *
43
+ * Only `{{bind:base}}` is resolved here. Selection, caret and selectable tokens
44
+ * stay intact for the toolbar's `insertTemplate` step. `selectedText` is kept
45
+ * for future use; it never replaces the tokens here.
46
+ */
47
+ export declare function renderNativeSnippet(component: NativeComponentDefinition, source: string, selectedText?: string): string;
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Authoring aids layered on the plain source textarea.
3
+ *
4
+ * The textarea stays the single editable surface: the highlight layer is a
5
+ * pointer-transparent copy of the source with token colours, and every action
6
+ * hands an `EditorEdit` back to the editor so history, selection restoration
7
+ * and controlled updates keep working unchanged.
8
+ */
9
+ import { type RefObject } from 'react';
10
+ import type { Diagnostic, LocalDocument, SourceRange } from 'reactive-md';
11
+ import type { EditorEdit } from './types.js';
12
+ export interface AuthorToken {
13
+ kind: string;
14
+ range: SourceRange;
15
+ }
16
+ export interface AuthorBinding {
17
+ name: string;
18
+ declarations: SourceRange[];
19
+ references: SourceRange[];
20
+ }
21
+ export interface AuthorCompletion {
22
+ label: string;
23
+ insertText: string;
24
+ range: SourceRange;
25
+ kind: 'tag' | 'attribute' | 'binding' | 'value';
26
+ detail?: string;
27
+ }
28
+ export interface AuthorAnalysis {
29
+ tokens: AuthorToken[];
30
+ bindings: AuthorBinding[];
31
+ diagnostics: Diagnostic[];
32
+ }
33
+ /**
34
+ * Analyses the exact source; caret movement never retriggers this work.
35
+ * `enabled` lets the editor skip the analysis when authoring tools are off.
36
+ */
37
+ export declare function useAuthorAnalysis(source: string, enabled?: boolean): AuthorAnalysis;
38
+ export interface AuthorHighlightProps {
39
+ source: string;
40
+ tokens: AuthorToken[];
41
+ /** Content width of the textarea, i.e. its client width without scrollbars. */
42
+ width: number;
43
+ editorRef: RefObject<HTMLTextAreaElement | null>;
44
+ }
45
+ export declare const AuthorHighlight: import("react").MemoExoticComponent<({ source, tokens, width, editorRef, }: AuthorHighlightProps) => import("react").JSX.Element>;
46
+ export interface AuthoringPanelProps {
47
+ source: string;
48
+ analysis: AuthorAnalysis;
49
+ /** Latest successful document, used for binding value types. */
50
+ bindingDocument: LocalDocument | null;
51
+ editorRef: RefObject<HTMLTextAreaElement | null>;
52
+ onEdit(edit: EditorEdit): void;
53
+ onLocate(range: SourceRange): void;
54
+ /** Read-only and disabled editors block every authoring action. */
55
+ disabled?: boolean;
56
+ }
57
+ export declare function AuthoringPanel({ source, analysis, bindingDocument, editorRef, onEdit, onLocate, disabled, }: AuthoringPanelProps): import("react").JSX.Element;
@@ -0,0 +1,44 @@
1
+ import type { CSSProperties, RefObject } from 'react';
2
+ import type { Diagnostic, LocalDocument, SourceRange } from '../local/types.js';
3
+ export type EditorLocale = 'en' | 'zh';
4
+ export type EditorTheme = 'light' | 'dark' | 'auto';
5
+ export interface EditorSelection {
6
+ start: number;
7
+ end: number;
8
+ }
9
+ export interface EditorEdit {
10
+ value: string;
11
+ selection: EditorSelection;
12
+ }
13
+ export interface ReactiveMarkdownEditorProps {
14
+ value: string;
15
+ onChange(value: string): void;
16
+ locale?: EditorLocale;
17
+ theme?: EditorTheme;
18
+ id?: string;
19
+ className?: string;
20
+ style?: CSSProperties;
21
+ height?: number | string;
22
+ minHeight?: number | string;
23
+ placeholder?: string;
24
+ ariaLabel?: string;
25
+ readOnly?: boolean;
26
+ disabled?: boolean;
27
+ /** Reset history, selection and scroll when switching source documents. */
28
+ documentKey?: string | number;
29
+ diagnostics?: readonly Diagnostic[];
30
+ /** Optional compiled document for the binding inspector's value types. */
31
+ document?: LocalDocument | null;
32
+ toolbar?: boolean;
33
+ authoring?: boolean;
34
+ onExport?(): void;
35
+ textareaRef?: RefObject<HTMLTextAreaElement | null>;
36
+ }
37
+ export interface ReactiveMarkdownEditorHandle {
38
+ focus(selection?: EditorSelection): void;
39
+ selectRange(range: SourceRange): void;
40
+ getSelection(): EditorSelection;
41
+ getTextarea(): HTMLTextAreaElement | null;
42
+ undo(): void;
43
+ redo(): void;
44
+ }
@@ -0,0 +1,5 @@
1
+ import { type RefObject } from 'react';
2
+ export declare function useGutterMetrics(lines: string[], mirrorRef: RefObject<HTMLDivElement | null>, editorRef: RefObject<HTMLTextAreaElement | null>): {
3
+ width: number;
4
+ heights: number[];
5
+ };
@@ -0,0 +1,16 @@
1
+ import type { EditorSelection } from './types.js';
2
+ export interface HistoryEntry {
3
+ value: string;
4
+ selection: EditorSelection;
5
+ }
6
+ export interface SourceHistoryStore {
7
+ readonly canUndo: boolean;
8
+ readonly canRedo: boolean;
9
+ record(value: string, selection: EditorSelection, mode?: 'merge' | 'separate'): void;
10
+ undo(): HistoryEntry | null;
11
+ redo(): HistoryEntry | null;
12
+ reset(value: string, selection?: EditorSelection): void;
13
+ }
14
+ export type SourceHistory = SourceHistoryStore;
15
+ export declare function createSourceHistory(initialValue: string, initialSelection?: EditorSelection, now?: () => number): SourceHistoryStore;
16
+ export declare function useSourceHistory(initialValue: string, initialSelection?: EditorSelection): SourceHistory;
@@ -0,0 +1,24 @@
1
+ import { type ReactElement, type ReactNode } from 'react';
2
+ /**
3
+ * Fenced code blocks with optional syntax highlighting and a copy button.
4
+ *
5
+ * Highlighting is renderer-only and never trusts source as HTML: lowlight
6
+ * produces a hast tree whose text and span nodes are mapped back to React text
7
+ * and span elements. Unknown languages, oversized sources, mismatched text and
8
+ * highlighting failures all fall back to the exact source value.
9
+ */
10
+ /** Sources longer than this render as plain text; highlighting cost grows with input. */
11
+ export declare const MAX_HIGHLIGHT_CHARS = 20000;
12
+ export interface CodeHighlight {
13
+ /** Highlighted children, or `null` when the source should render verbatim. */
14
+ nodes: ReactNode[] | null;
15
+ highlighted: boolean;
16
+ }
17
+ /** Highlight a source string without automatic language detection. */
18
+ export declare function highlightCode(value: string, language?: string): CodeHighlight;
19
+ export interface CodeBlockViewProps {
20
+ value: string;
21
+ language?: string;
22
+ mode: 'interactive' | 'static';
23
+ }
24
+ export declare function CodeBlockView({ value, language, mode }: CodeBlockViewProps): ReactElement;
@@ -0,0 +1,51 @@
1
+ import type { LocalDocument, LocalNode } from './types.js';
2
+ /** One rendered reference occurrence and the endnote it points at. */
3
+ export interface LocalFootnoteReferenceSite {
4
+ node: LocalNode;
5
+ /** Unique, instance-scoped DOM id for this occurrence. */
6
+ id: string;
7
+ }
8
+ /** One referenced definition, numbered by first reference order. */
9
+ export interface LocalFootnoteEntry {
10
+ identifier: string;
11
+ /** 1-based number shared by every reference to this identifier. */
12
+ number: number;
13
+ definition: LocalNode;
14
+ /** Instance-scoped DOM id of the endnote list item. */
15
+ id: string;
16
+ references: LocalFootnoteReferenceSite[];
17
+ }
18
+ /** What a single `footnoteReference` node renders as. */
19
+ export interface LocalFootnoteSite {
20
+ /** Unique DOM id of the reference link; empty for an undefined reference. */
21
+ id: string;
22
+ /** The matching entry, or `null` when no definition exists. */
23
+ entry: LocalFootnoteEntry | null;
24
+ /** Original label, shown as `[^label]` for undefined references. */
25
+ label: string;
26
+ }
27
+ export interface LocalFootnoteIndex {
28
+ /** Referenced definitions in first-reference order. */
29
+ entries: LocalFootnoteEntry[];
30
+ siteFor(node: LocalNode): LocalFootnoteSite | undefined;
31
+ }
32
+ /**
33
+ * The parser already normalizes identifiers, but a hand-built tree may carry
34
+ * raw labels. Whitespace runs collapse and case is folded so references and
35
+ * definitions still meet; the renderer never uses this value in HTML.
36
+ */
37
+ export declare function normalizeFootnoteIdentifier(value: string): string;
38
+ /** Normalized, non-empty identifier used to pair references and definitions. */
39
+ export declare function footnoteIdentifier(node: LocalNode): string;
40
+ /** Original label shown to readers; never used to build a DOM id. */
41
+ export declare function footnoteLabelText(node: LocalNode): string;
42
+ /**
43
+ * Collect definitions and references for one document instance.
44
+ *
45
+ * Numbering follows the order references become visible: body references in
46
+ * source order first, then references exposed inside already-numbered endnote
47
+ * bodies. References inside a definition that is never displayed therefore do
48
+ * not create an endnote or a dangling backlink. Duplicate definitions keep the
49
+ * first one; unresolved references render as `[^label]` and are not numbered.
50
+ */
51
+ export declare function collectLocalFootnotes(document: LocalDocument, instanceId: string): LocalFootnoteIndex;
@@ -0,0 +1,21 @@
1
+ import { type RefObject } from 'react';
2
+ /**
3
+ * A Markdown image that opens its original source in a native modal dialog.
4
+ *
5
+ * The trigger is the original `<img>` element, so the rendered markup, URL
6
+ * handling and loading hints stay identical to the plain image. The preview is
7
+ * portalled into the document root only after a user opens it: the root carries
8
+ * the theme tokens and an inline `<dialog>` inside a paragraph would break
9
+ * server rendering and hydration.
10
+ *
11
+ * `static` mode always returns the plain image. In `interactive` mode the image
12
+ * is a button only when it is not already wrapped in a Markdown link; a
13
+ * link-wrapped image keeps the anchor's navigation and has no extra tab stop.
14
+ */
15
+ export declare function ZoomableImage({ src, alt, title, mode, rootRef, }: {
16
+ src: string;
17
+ alt: string;
18
+ title?: string;
19
+ mode: 'interactive' | 'static';
20
+ rootRef: RefObject<HTMLElement | null>;
21
+ }): import("react").JSX.Element;
@@ -46,6 +46,13 @@ export interface LocalNode {
46
46
  alt?: string;
47
47
  lang?: string;
48
48
  align?: ('left' | 'center' | 'right' | null)[];
49
+ /**
50
+ * Normalized footnote identifier shared by `footnoteReference` and
51
+ * `footnoteDefinition` nodes (whitespace collapsed, lowercased).
52
+ */
53
+ identifier?: string;
54
+ /** Original footnote label as written, preserved for display. */
55
+ label?: string;
49
56
  }
50
57
  /**
51
58
  * One read-only document value declared by a top-level `<computed>` or