@powerduck/md-editor 0.3.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,21 @@
1
1
  import './styles/editor.css';
2
2
  export type EditorMode = 'simple' | 'complex';
3
3
  export type EditorTheme = 'light' | 'dark';
4
+ /** Per-item toolbar override. */
5
+ export interface ToolbarItemOverride {
6
+ /** Show this item. Default: true */
7
+ show?: boolean;
8
+ /** Custom tooltip / aria-label */
9
+ label?: string;
10
+ /** Custom icon as HTML string */
11
+ icon?: string;
12
+ }
13
+ /**
14
+ * Toolbar configuration. Either:
15
+ * - An array of action names to show (include-list), or
16
+ * - A record of action-name -> override for fine-grained control.
17
+ */
18
+ export type ToolbarConfig = string[] | Record<string, ToolbarItemOverride>;
4
19
  export interface MarkdownEditorOptions {
5
20
  /** Initial content */
6
21
  value?: string;
@@ -13,21 +28,20 @@ export interface MarkdownEditorOptions {
13
28
  mindmap?: boolean;
14
29
  /** Enable syntax highlighting for code blocks. Default: true. */
15
30
  codeHighlight?: boolean;
31
+ /** Enable admonition/tip blocks. Default: true. */
32
+ tips?: boolean;
16
33
  /** Show the preview pane. Default: true. */
17
34
  preview?: boolean;
18
35
  onChange?: (value: string) => void;
36
+ /** Configure which toolbar items show, and their labels/icons. */
37
+ toolbar?: ToolbarConfig;
19
38
  /**
20
- * Preview debounce in milliseconds. Defaults to adaptive based on document
21
- * length (see adaptiveDebounceMs). Pass false to disable debounce (not
22
- * recommended for large documents).
39
+ * Hook for image upload. Called when a user pastes, drops, or selects an
40
+ * image file via the image popup. Return a Promise that resolves to the
41
+ * image URL. The URL is inserted as `![alt](url)` at the cursor.
23
42
  */
43
+ onImageUpload?: (file: File) => Promise<string>;
24
44
  renderDebounce?: number | false;
25
- /**
26
- * Auto-preview on every edit. Default: true.
27
- * For very large documents (hundreds of thousands of characters), set to
28
- * false and trigger preview manually via the "Refresh preview" button or
29
- * renderNow() to eliminate all rendering overhead during typing.
30
- */
31
45
  autoPreview?: boolean;
32
46
  }
33
47
  export declare class MarkdownEditor {
@@ -47,17 +61,31 @@ export declare class MarkdownEditor {
47
61
  private autoPreview;
48
62
  private renderDebounceOpt;
49
63
  private onChange?;
64
+ private onImageUpload?;
65
+ private toolbarConfig?;
66
+ private shortcuts;
50
67
  private scheduledRender;
51
68
  private scheduledWait;
52
69
  constructor(container: HTMLElement | string, options?: MarkdownEditorOptions);
53
70
  private buildLayout;
71
+ private isActionVisible;
72
+ private getActionLabel;
73
+ private getActionIcon;
54
74
  private buildToolbar;
55
75
  private buildStatusBar;
76
+ private setupKeyboardShortcuts;
77
+ private executeAction;
56
78
  private showImagePopup;
57
79
  private showVideoPopup;
58
80
  private showYouTubePopup;
81
+ private showTablePopup;
82
+ private generateTable;
83
+ private showHelpPopup;
84
+ private handleImageFile;
85
+ private showTipsPopup;
59
86
  private setupCopyHandler;
60
87
  private insertSnippet;
88
+ private wrapSnippet;
61
89
  private togglePreview;
62
90
  private requestPreviewRender;
63
91
  private renderPreview;
@@ -65,17 +93,15 @@ export declare class MarkdownEditor {
65
93
  getValue(): string;
66
94
  setValue(value: string): void;
67
95
  getHtml(): string;
68
- /** Manually trigger a preview render (use when autoPreview is false). */
69
96
  renderNow(): void;
70
97
  setAutoPreview(auto: boolean): void;
71
- /** Switch between simple and complex modes at runtime. */
72
98
  setMode(mode: EditorMode): void;
73
99
  setTheme(theme: EditorTheme): void;
74
100
  focus(): void;
75
101
  destroy(): void;
76
102
  }
77
103
  export { CodeEditor } from './Editor.js';
78
- export { Renderer, type RendererOptions } from './Renderer.js';
104
+ export { Renderer, renderMarkdown, type RendererOptions } from './Renderer.js';
79
105
  export { Toolbar, type ToolbarAction } from './Toolbar.js';
80
106
  export { StatusBar, countText } from './StatusBar.js';
81
107
  export { IncrementalRenderer } from './perf/IncrementalRenderer.js';
@@ -84,3 +110,4 @@ export { debounce, adaptiveDebounceMs, scheduleIdle, cancelIdle } from './perf/s
84
110
  export { icons, type IconName } from './icons.js';
85
111
  export { Popup, type PopupConfig, type PopupField } from './plugins/popup.js';
86
112
  export { extractYouTubeId, youTubeEmbedMarkdown, imageMarkdown, videoMarkdown, isVideoFile } from './plugins/media.js';
113
+ export { DEFAULT_SHORTCUTS, matchShortcut, formatShortcut, formatShortcutHtml, type ShortcutDef } from './plugins/keyboard.js';