@synclineapi/mdx-editor 0.1.2 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +403 -139
- package/dist/core/config/EditorConfig.d.ts +5 -0
- package/dist/core/config/defaults.d.ts +33 -0
- package/dist/core/config/index.d.ts +2 -0
- package/dist/core/dom/editor-pane.d.ts +7 -0
- package/dist/core/dom/editor-root.d.ts +8 -0
- package/dist/core/dom/index.d.ts +11 -0
- package/dist/core/dom/preview-pane.d.ts +5 -0
- package/dist/core/dom/skip-link.d.ts +1 -0
- package/dist/core/dom/status-bar.d.ts +13 -0
- package/dist/core/dom/toolbar-dom.d.ts +5 -0
- package/dist/core/editor.d.ts +139 -7
- package/dist/core/mdx-themes.d.ts +3 -0
- package/dist/core/platform.d.ts +31 -0
- package/dist/core/plugin-manager.d.ts +1 -24
- package/dist/core/plugins/PluginContext.d.ts +26 -0
- package/dist/core/plugins/PluginManager.d.ts +41 -0
- package/dist/core/plugins/index.d.ts +3 -0
- package/dist/core/renderer/CodeRenderer.d.ts +4 -0
- package/dist/core/renderer/ListRenderer.d.ts +5 -0
- package/dist/core/renderer/MarkdownRenderer.d.ts +7 -0
- package/dist/core/renderer/MdxValidator.d.ts +3 -0
- package/dist/core/renderer/Renderer.d.ts +10 -0
- package/dist/core/renderer/TableRenderer.d.ts +4 -0
- package/dist/core/renderer/index.d.ts +7 -0
- package/dist/core/renderer/sanitize.d.ts +1 -0
- package/dist/core/renderer.d.ts +6 -31
- package/dist/core/toolbar.d.ts +1 -0
- package/dist/core/types.d.ts +150 -2
- package/dist/core/ui/AutocompleteController.d.ts +58 -0
- package/dist/core/ui/DropdownController.d.ts +8 -0
- package/dist/core/ui/FindReplaceController.d.ts +60 -0
- package/dist/core/ui/LineNumberController.d.ts +218 -0
- package/dist/core/ui/ModeController.d.ts +9 -0
- package/dist/core/ui/PreviewController.d.ts +13 -0
- package/dist/core/ui/ResponsiveController.d.ts +30 -0
- package/dist/core/ui/SplitterController.d.ts +31 -0
- package/dist/core/ui/StatusBarController.d.ts +16 -0
- package/dist/core/ui/ThemeController.d.ts +8 -0
- package/dist/core/ui/ToolbarController.d.ts +10 -0
- package/dist/core/ui/UIController.d.ts +43 -0
- package/dist/core/ui/index.d.ts +12 -0
- package/dist/index.d.ts +29 -1
- package/dist/plugins/basic-formatting/index.d.ts +1 -0
- package/dist/plugins/callouts/index.d.ts +1 -0
- package/dist/plugins/diagrams/index.d.ts +1 -0
- package/dist/plugins/index.d.ts +1 -11
- package/dist/plugins/layout/index.d.ts +3 -0
- package/dist/plugins/lists/index.d.ts +1 -0
- package/dist/plugins/media/index.d.ts +2 -0
- package/dist/plugins/token-utils.d.ts +49 -0
- package/dist/plugins/utilities/index.d.ts +5 -0
- package/dist/style.css +1 -1
- package/dist/syncline-mdx-editor.js +9628 -1835
- package/dist/syncline-mdx-editor.umd.cjs +988 -90
- package/package.json +5 -4
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { EditorConfig, EditorMode } from '../types';
|
|
2
|
+
export declare const DEFAULT_MODE: EditorMode;
|
|
3
|
+
export declare const DEFAULT_PLACEHOLDER = "Start writing markdown...";
|
|
4
|
+
export declare const DEFAULT_PREVIEW_DELAY = 150;
|
|
5
|
+
export declare const DEFAULT_FEATURES: {
|
|
6
|
+
readonly lineNumbers: false;
|
|
7
|
+
readonly wordCount: true;
|
|
8
|
+
readonly lineCount: true;
|
|
9
|
+
readonly modeSwitcher: true;
|
|
10
|
+
readonly statusBar: true;
|
|
11
|
+
readonly autoPreview: true;
|
|
12
|
+
readonly previewDelay: 150;
|
|
13
|
+
readonly spellcheck: false;
|
|
14
|
+
readonly autocomplete: false;
|
|
15
|
+
readonly dragAndDrop: true;
|
|
16
|
+
readonly pasteImages: false;
|
|
17
|
+
readonly keyboardShortcuts: true;
|
|
18
|
+
readonly autoSave: false;
|
|
19
|
+
readonly autoSaveKey: "smdx-autosave";
|
|
20
|
+
readonly autofocus: false;
|
|
21
|
+
readonly vimMode: false;
|
|
22
|
+
readonly history: {
|
|
23
|
+
readonly maxSize: 100;
|
|
24
|
+
readonly debounce: 300;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export declare const DEFAULT_LAYOUT: {
|
|
28
|
+
readonly splitterPosition: 50;
|
|
29
|
+
readonly minEditorWidth: 200;
|
|
30
|
+
readonly minPreviewWidth: 200;
|
|
31
|
+
readonly resizableSplitter: true;
|
|
32
|
+
};
|
|
33
|
+
export declare function resolveDefaults(config: Partial<EditorConfig>): EditorConfig;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { createEditorRoot } from './editor-root';
|
|
2
|
+
export type { EditorRootElements } from './editor-root';
|
|
3
|
+
export { createEditorPane } from './editor-pane';
|
|
4
|
+
export type { EditorPaneElements } from './editor-pane';
|
|
5
|
+
export { createPreviewPane } from './preview-pane';
|
|
6
|
+
export type { PreviewPaneElements } from './preview-pane';
|
|
7
|
+
export { createToolbarDOM } from './toolbar-dom';
|
|
8
|
+
export type { ToolbarDOMElements } from './toolbar-dom';
|
|
9
|
+
export { createStatusBar } from './status-bar';
|
|
10
|
+
export type { StatusBarConfig, StatusBarElements } from './status-bar';
|
|
11
|
+
export { createSkipLink } from './skip-link';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createSkipLink(targetId: string): HTMLAnchorElement;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface StatusBarConfig {
|
|
2
|
+
showWordCount?: boolean;
|
|
3
|
+
showLineCount?: boolean;
|
|
4
|
+
showModeSwitcher?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface StatusBarElements {
|
|
7
|
+
bar: HTMLDivElement;
|
|
8
|
+
wordCount: HTMLSpanElement;
|
|
9
|
+
lineCount: HTMLSpanElement;
|
|
10
|
+
charCount: HTMLSpanElement;
|
|
11
|
+
modeSwitcher: HTMLDivElement;
|
|
12
|
+
}
|
|
13
|
+
export declare function createStatusBar(config?: StatusBarConfig): StatusBarElements;
|
package/dist/core/editor.d.ts
CHANGED
|
@@ -1,33 +1,155 @@
|
|
|
1
|
-
import { EditorConfig, EditorAPI, EditorPlugin, EditorMode, SelectionState } from './types';
|
|
1
|
+
import { EditorConfig, EditorAPI, EditorPlugin, EditorMode, SelectionState, PluginTokenProvider } from './types';
|
|
2
|
+
import { CompletionItem } from '@synclineapi/editor';
|
|
2
3
|
export declare class SynclineMDXEditor implements EditorAPI {
|
|
3
4
|
private root;
|
|
4
5
|
private toolbarEl;
|
|
6
|
+
private toolbarLeft;
|
|
7
|
+
private modeArea;
|
|
8
|
+
/** Container div where SynclineEditor mounts its DOM. */
|
|
9
|
+
private editorHost;
|
|
10
|
+
/** Hidden textarea kept for getTextarea() API compatibility. */
|
|
11
|
+
private textarea;
|
|
5
12
|
private editorPane;
|
|
6
13
|
private previewPane;
|
|
7
|
-
private textarea;
|
|
8
14
|
private previewContent;
|
|
9
15
|
private statusBar;
|
|
16
|
+
private tocContainer;
|
|
17
|
+
private tocCollapsed;
|
|
18
|
+
private splitterController;
|
|
19
|
+
/** The SynclineEditor instance (from editor/ folder). */
|
|
20
|
+
private codeEditor;
|
|
21
|
+
/** Watches .smdx-dark class changes to swap the code-editor theme in real time. */
|
|
22
|
+
private themeObserver;
|
|
10
23
|
private events;
|
|
11
24
|
private pluginManager;
|
|
12
25
|
private toolbar;
|
|
13
26
|
private renderer;
|
|
14
|
-
private history;
|
|
15
27
|
private mode;
|
|
16
28
|
private config;
|
|
17
29
|
private renderTimer;
|
|
18
|
-
private historyTimer;
|
|
19
30
|
private _destroyed;
|
|
20
31
|
constructor(config: EditorConfig);
|
|
21
32
|
private init;
|
|
33
|
+
/**
|
|
34
|
+
* Returns true only when an explicit `smdx-dark` class is present on the
|
|
35
|
+
* editor root, a parent element, or the document/body.
|
|
36
|
+
* Deliberately ignores OS-level prefers-color-scheme so that the theme
|
|
37
|
+
* follows the toolbar toggle button, not the system setting.
|
|
38
|
+
*/
|
|
39
|
+
private isDarkMode;
|
|
40
|
+
/**
|
|
41
|
+
* Apply the correct light/dark code-editor theme AND token colours.
|
|
42
|
+
* Called automatically whenever the `.smdx-dark` class changes on any
|
|
43
|
+
* ancestor element. Can also be called programmatically when the host app
|
|
44
|
+
* switches themes via means other than a CSS class toggle (e.g. data-theme
|
|
45
|
+
* attribute, CSS variable override, or a custom theme API).
|
|
46
|
+
*/
|
|
47
|
+
syncCodeEditorTheme(): void;
|
|
48
|
+
/** Observe class / data-theme mutations on the root / document so we can
|
|
49
|
+
* swap code-editor themes live.
|
|
50
|
+
*
|
|
51
|
+
* Walks every ancestor from `this.root` up to `<html>` inclusive so that
|
|
52
|
+
* toggling `.smdx-dark` OR `data-theme` on ANY containing element is caught
|
|
53
|
+
* and forwarded to `syncCodeEditorTheme()`. This covers:
|
|
54
|
+
* - CSS class toggles (.smdx-dark on root, body, or html)
|
|
55
|
+
* - data-theme attribute patterns (Next.js, Nuxt, Tailwind dark-mode)
|
|
56
|
+
* - app-shell / modal wrapper patterns
|
|
57
|
+
*/
|
|
58
|
+
private setupThemeObserver;
|
|
59
|
+
/** Completions registered directly by the consumer via `registerAutoComplete()`. */
|
|
60
|
+
private _userCompletions;
|
|
61
|
+
/** Token providers registered directly by the consumer via `registerSyntaxHighlighter()`. */
|
|
62
|
+
private _userTokenProviders;
|
|
63
|
+
private mountCodeEditor;
|
|
64
|
+
/**
|
|
65
|
+
* Rebuilds the full completions list pushed into the SynclineEditor.
|
|
66
|
+
*
|
|
67
|
+
* Merge order:
|
|
68
|
+
* 1. Built-in MDX completions — tags, attributes
|
|
69
|
+
* 2. Built-in MDX snippets — toolbar-matched snippet bodies
|
|
70
|
+
* 3. Plugin completions — each registered plugin's items
|
|
71
|
+
* 4. User completions — items added via `registerAutoComplete()`
|
|
72
|
+
*
|
|
73
|
+
* Called automatically after every `registerPlugin` / `unregisterPlugin`
|
|
74
|
+
* and every `registerAutoComplete()` call.
|
|
75
|
+
*/
|
|
76
|
+
private _refreshCompletions;
|
|
77
|
+
/**
|
|
78
|
+
* Register one or more custom autocomplete items on top of the built-in
|
|
79
|
+
* MDX completions. Items appear in the popup immediately and persist for
|
|
80
|
+
* the lifetime of the editor instance.
|
|
81
|
+
*
|
|
82
|
+
* Use `kind: 'snip'` with a `body` template for snippet expansion — Tab
|
|
83
|
+
* or clicking the item inserts the full body with the cursor placed at
|
|
84
|
+
* the first `$1` tab stop.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts
|
|
88
|
+
* editor.registerAutoComplete([
|
|
89
|
+
* {
|
|
90
|
+
* label: 'mycard',
|
|
91
|
+
* kind: 'snip',
|
|
92
|
+
* detail: '<MyCard> component',
|
|
93
|
+
* description: 'Inserts a custom card block.',
|
|
94
|
+
* body: '<MyCard title="$1">\n $2\n</MyCard>',
|
|
95
|
+
* },
|
|
96
|
+
* { label: 'MyCard', kind: 'cls', detail: 'component' },
|
|
97
|
+
* ]);
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
registerAutoComplete(items: CompletionItem | CompletionItem[]): void;
|
|
101
|
+
/**
|
|
102
|
+
* Rebuilds the composed `provideTokens` function pushed into the
|
|
103
|
+
* SynclineEditor, merging:
|
|
104
|
+
* 1. Built-in MDX base tokeniser (headings, bold, italic, links, etc.)
|
|
105
|
+
* 2. Plugin token providers — each registered plugin's `provideTokens`
|
|
106
|
+
* 3. User token providers — added via `registerSyntaxHighlighter()`
|
|
107
|
+
*
|
|
108
|
+
* Called automatically after every `registerPlugin` / `unregisterPlugin`
|
|
109
|
+
* and every `registerSyntaxHighlighter()` call.
|
|
110
|
+
*/
|
|
111
|
+
private _refreshTokenProvider;
|
|
112
|
+
/**
|
|
113
|
+
* Register one or more custom syntax token providers on top of the
|
|
114
|
+
* built-in MDX tokeniser and any plugin-contributed providers.
|
|
115
|
+
*
|
|
116
|
+
* Each provider is called on every visible line in the code editor and
|
|
117
|
+
* may return `TokenSegment` objects covering the character ranges that
|
|
118
|
+
* should receive custom syntax colouring. The result is LRU-cached by
|
|
119
|
+
* the underlying `SynclineEditor`.
|
|
120
|
+
*
|
|
121
|
+
* Providers added here are equivalent to declaring `provideTokens` on a
|
|
122
|
+
* custom `EditorPlugin` — use whichever is more convenient.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```ts
|
|
126
|
+
* editor.registerSyntaxHighlighter((line, _lang) => {
|
|
127
|
+
* const segs: TokenSegment[] = [];
|
|
128
|
+
* // Highlight <MyBlock component names
|
|
129
|
+
* for (const m of line.matchAll(/<\/?( MyBlock)(?=[\s>/])/g)) {
|
|
130
|
+
* const s = m.index! + 1 + (m[0][1] === '/' ? 1 : 0);
|
|
131
|
+
* segs.push({ cls: 'cls', start: s, end: s + 'MyBlock'.length });
|
|
132
|
+
* }
|
|
133
|
+
* return segs;
|
|
134
|
+
* });
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
registerSyntaxHighlighter(fn: PluginTokenProvider | PluginTokenProvider[]): void;
|
|
22
138
|
private buildDOM;
|
|
139
|
+
/** Convert a flat character offset to { row, col } in the document. */
|
|
140
|
+
private offsetToPos;
|
|
141
|
+
/** Convert { row, col } to a flat character offset. */
|
|
142
|
+
private posToOffset;
|
|
23
143
|
private registerPlugins;
|
|
24
144
|
private getDefaultToolbar;
|
|
25
|
-
private onInput;
|
|
26
|
-
private onKeyDown;
|
|
27
145
|
private matchShortcut;
|
|
28
|
-
private onSelectionChange;
|
|
29
146
|
private scheduleRender;
|
|
147
|
+
private getCursorPosition;
|
|
30
148
|
private updateStatusBar;
|
|
149
|
+
private updateModeButtons;
|
|
150
|
+
private buildTocPanel;
|
|
151
|
+
refreshToc(): void;
|
|
152
|
+
toggleToc(): void;
|
|
31
153
|
getValue(): string;
|
|
32
154
|
setValue(value: string): void;
|
|
33
155
|
insertText(text: string): void;
|
|
@@ -57,5 +179,15 @@ export declare class SynclineMDXEditor implements EditorAPI {
|
|
|
57
179
|
insertAt(position: number, text: string): void;
|
|
58
180
|
getWordCount(): number;
|
|
59
181
|
getLineCount(): number;
|
|
182
|
+
setLineNumbers(enabled: boolean): void;
|
|
183
|
+
jumpToLine(lineNumber: number): void;
|
|
60
184
|
private applyTheme;
|
|
185
|
+
/**
|
|
186
|
+
* Directly set a `ThemeDefinition` on the embedded code editor.
|
|
187
|
+
* Use this when you need to apply a theme that cannot be expressed via
|
|
188
|
+
* CSS class toggles — e.g. a fully custom colour palette loaded at runtime.
|
|
189
|
+
* Passing `null` reverts the code editor to the default MDX light/dark theme
|
|
190
|
+
* derived from the current `.smdx-dark` class state.
|
|
191
|
+
*/
|
|
192
|
+
setCodeEditorTheme(theme: import('@synclineapi/editor').ThemeDefinition | null): void;
|
|
61
193
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform detection utilities for cross-platform shortcut label formatting.
|
|
3
|
+
*
|
|
4
|
+
* Shortcut labels are stored in Mac notation (⌘, ⇧, ⌥).
|
|
5
|
+
* On Windows/Linux these Unicode symbols are converted to readable text
|
|
6
|
+
* (Ctrl+, Shift+, Alt+) so users see the correct key names for their OS.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Returns true when running on macOS.
|
|
10
|
+
* Tries the modern `navigator.userAgentData.platform` first, then falls back
|
|
11
|
+
* to the legacy `navigator.platform` and `navigator.userAgent`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isMac(): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Converts a shortcut label to the correct format for the current platform.
|
|
16
|
+
*
|
|
17
|
+
* On macOS, text modifiers are converted to Unicode symbols (e.g. "Ctrl+B" → "⌘B").
|
|
18
|
+
* On Windows/Linux, Unicode symbols are replaced with their keyboard text
|
|
19
|
+
* equivalents (e.g. "⌘B" → "Ctrl+B", "⌘⇧X" → "Ctrl+Shift+X").
|
|
20
|
+
*
|
|
21
|
+
* Substitutions applied on macOS (case-insensitive):
|
|
22
|
+
* Ctrl+ → ⌘
|
|
23
|
+
* Shift+ → ⇧
|
|
24
|
+
* Alt+ → ⌥
|
|
25
|
+
*
|
|
26
|
+
* Substitutions applied on Windows/Linux:
|
|
27
|
+
* ⌘ → Ctrl+
|
|
28
|
+
* ⇧ → Shift+
|
|
29
|
+
* ⌥ → Alt+
|
|
30
|
+
*/
|
|
31
|
+
export declare function formatShortcutLabel(label: string): string;
|
|
@@ -1,24 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { EventEmitter } from './events';
|
|
3
|
-
export declare class PluginManager {
|
|
4
|
-
private editorApi;
|
|
5
|
-
private plugins;
|
|
6
|
-
private toolbarItems;
|
|
7
|
-
private shortcuts;
|
|
8
|
-
private renderers;
|
|
9
|
-
private parsers;
|
|
10
|
-
private styleElements;
|
|
11
|
-
private events;
|
|
12
|
-
constructor(editorApi: EditorAPI, events: EventEmitter);
|
|
13
|
-
register(plugin: EditorPlugin): Promise<void>;
|
|
14
|
-
unregister(name: string): void;
|
|
15
|
-
getToolbarItem(id: string): ToolbarItemConfig | undefined;
|
|
16
|
-
getAllToolbarItems(): Map<string, ToolbarItemConfig>;
|
|
17
|
-
getShortcuts(): ShortcutConfig[];
|
|
18
|
-
getRenderers(): RendererConfig[];
|
|
19
|
-
getParsers(): ParserConfig[];
|
|
20
|
-
hasPlugin(name: string): boolean;
|
|
21
|
-
private createContext;
|
|
22
|
-
private injectStyles;
|
|
23
|
-
destroy(): void;
|
|
24
|
-
}
|
|
1
|
+
export { PluginManager } from './plugins/PluginManager';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { EditorAPI, ToolbarItemConfig, ShortcutConfig, RendererConfig, ParserConfig, EventHandler, PluginTokenProvider } from '../types';
|
|
2
|
+
export interface PluginContextOptions {
|
|
3
|
+
editor: EditorAPI;
|
|
4
|
+
registerToolbarItem: (item: ToolbarItemConfig) => void;
|
|
5
|
+
registerShortcut: (shortcut: ShortcutConfig) => void;
|
|
6
|
+
registerRenderer: (renderer: RendererConfig) => void;
|
|
7
|
+
registerParser: (parser: ParserConfig) => void;
|
|
8
|
+
injectStyles: (css: string) => void;
|
|
9
|
+
emit: (event: string, data?: unknown) => void;
|
|
10
|
+
on: (event: string, handler: EventHandler) => void;
|
|
11
|
+
off: (event: string, handler: EventHandler) => void;
|
|
12
|
+
registerTokenProvider: (fn: PluginTokenProvider) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare class PluginContext {
|
|
15
|
+
readonly editor: EditorAPI;
|
|
16
|
+
readonly registerToolbarItem: (item: ToolbarItemConfig) => void;
|
|
17
|
+
readonly registerShortcut: (shortcut: ShortcutConfig) => void;
|
|
18
|
+
readonly registerRenderer: (renderer: RendererConfig) => void;
|
|
19
|
+
readonly registerParser: (parser: ParserConfig) => void;
|
|
20
|
+
readonly injectStyles: (css: string) => void;
|
|
21
|
+
readonly emit: (event: string, data?: unknown) => void;
|
|
22
|
+
readonly on: (event: string, handler: EventHandler) => void;
|
|
23
|
+
readonly off: (event: string, handler: EventHandler) => void;
|
|
24
|
+
readonly registerTokenProvider: (fn: PluginTokenProvider) => void;
|
|
25
|
+
constructor(options: PluginContextOptions);
|
|
26
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { EditorPlugin, ToolbarItemConfig, ShortcutConfig, RendererConfig, ParserConfig, EditorAPI, CompletionItem, PluginTokenProvider } from '../types';
|
|
2
|
+
import { EventEmitter } from '../events';
|
|
3
|
+
export declare class PluginManager {
|
|
4
|
+
private editorApi;
|
|
5
|
+
private plugins;
|
|
6
|
+
private toolbarItems;
|
|
7
|
+
private shortcuts;
|
|
8
|
+
private renderers;
|
|
9
|
+
private parsers;
|
|
10
|
+
private styleElements;
|
|
11
|
+
private events;
|
|
12
|
+
/** All completion items contributed by plugins, keyed by plugin name. */
|
|
13
|
+
private completionsByPlugin;
|
|
14
|
+
/** All token providers contributed by plugins, keyed by plugin name. */
|
|
15
|
+
private tokenProvidersByPlugin;
|
|
16
|
+
constructor(editorApi: EditorAPI, events: EventEmitter);
|
|
17
|
+
register(plugin: EditorPlugin): Promise<void>;
|
|
18
|
+
unregister(name: string): void;
|
|
19
|
+
getToolbarItem(id: string): ToolbarItemConfig | undefined;
|
|
20
|
+
getAllToolbarItems(): Map<string, ToolbarItemConfig>;
|
|
21
|
+
getShortcuts(): ShortcutConfig[];
|
|
22
|
+
getRenderers(): RendererConfig[];
|
|
23
|
+
getParsers(): ParserConfig[];
|
|
24
|
+
/**
|
|
25
|
+
* Returns the flat list of all completion items contributed by every
|
|
26
|
+
* currently-registered plugin (both static `completions` declarations and
|
|
27
|
+
* items added dynamically via `ctx.registerCompletion()`).
|
|
28
|
+
*/
|
|
29
|
+
getCompletions(): CompletionItem[];
|
|
30
|
+
/**
|
|
31
|
+
* Returns the flat list of all token provider functions contributed by every
|
|
32
|
+
* currently-registered plugin (both static `provideTokens` declarations and
|
|
33
|
+
* providers added dynamically via `ctx.registerTokenProvider()`).
|
|
34
|
+
*/
|
|
35
|
+
getTokenProviders(): PluginTokenProvider[];
|
|
36
|
+
hasPlugin(name: string): boolean;
|
|
37
|
+
getPlugin(name: string): EditorPlugin | undefined;
|
|
38
|
+
private createContext;
|
|
39
|
+
private injectStyles;
|
|
40
|
+
destroy(): void;
|
|
41
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RendererConfig, ParserConfig } from '../types';
|
|
2
|
+
export declare class Renderer {
|
|
3
|
+
private renderers;
|
|
4
|
+
private parsers;
|
|
5
|
+
private markdownRenderer;
|
|
6
|
+
private mdxValidator;
|
|
7
|
+
setRenderers(renderers: RendererConfig[]): void;
|
|
8
|
+
setParsers(parsers: ParserConfig[]): void;
|
|
9
|
+
render(source: string): Promise<string>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { Renderer } from './Renderer';
|
|
2
|
+
export { MarkdownRenderer } from './MarkdownRenderer';
|
|
3
|
+
export { CodeRenderer } from './CodeRenderer';
|
|
4
|
+
export { TableRenderer } from './TableRenderer';
|
|
5
|
+
export { ListRenderer } from './ListRenderer';
|
|
6
|
+
export { MdxValidator } from './MdxValidator';
|
|
7
|
+
export { sanitizeHtml } from './sanitize';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { sanitizeHtml } from '../sanitize';
|
package/dist/core/renderer.d.ts
CHANGED
|
@@ -1,31 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export declare class Renderer {
|
|
8
|
-
private renderers;
|
|
9
|
-
private parsers;
|
|
10
|
-
setRenderers(renderers: RendererConfig[]): void;
|
|
11
|
-
setParsers(parsers: ParserConfig[]): void;
|
|
12
|
-
render(source: string): Promise<string>;
|
|
13
|
-
private applyParsers;
|
|
14
|
-
private applyRenderers;
|
|
15
|
-
/**
|
|
16
|
-
* Lightweight built-in markdown renderer.
|
|
17
|
-
* Handles standard markdown without external deps.
|
|
18
|
-
*/
|
|
19
|
-
private renderMarkdown;
|
|
20
|
-
private renderTables;
|
|
21
|
-
private parseTableRow;
|
|
22
|
-
private isListItem;
|
|
23
|
-
private buildNestedList;
|
|
24
|
-
private renderNestedLists;
|
|
25
|
-
private escapeHtml;
|
|
26
|
-
/**
|
|
27
|
-
* Validate MDX component tags — detect unclosed or mismatched tags.
|
|
28
|
-
* Only checks PascalCase tags (MDX components), not standard HTML.
|
|
29
|
-
*/
|
|
30
|
-
private validateMdxTags;
|
|
31
|
-
}
|
|
1
|
+
export { Renderer } from './renderer/Renderer';
|
|
2
|
+
export { MarkdownRenderer } from './renderer/MarkdownRenderer';
|
|
3
|
+
export { CodeRenderer } from './renderer/CodeRenderer';
|
|
4
|
+
export { TableRenderer } from './renderer/TableRenderer';
|
|
5
|
+
export { ListRenderer } from './renderer/ListRenderer';
|
|
6
|
+
export { MdxValidator } from './renderer/MdxValidator';
|