@mdaemon/html-editor 1.2.0 → 1.3.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/README.md CHANGED
@@ -104,6 +104,7 @@ const editor = new HTMLEditor(container, {
104
104
  | `convert_unsafe_embeds` | boolean | true | Sanitize embedded content |
105
105
  | `format_empty_lines` | boolean | true | Format empty lines |
106
106
  | `paste_from_office` | boolean | true | Clean and preserve formatting when pasting from Microsoft Word and Excel |
107
+ | `speech_to_text` | boolean | true | Enable Speech to Text and Dictate toolbar buttons (requires Web Speech API: Chrome, Edge, Safari) |
107
108
  | `setup` | (editor) => void | - | Callback invoked before init — use to register custom buttons |
108
109
 
109
110
  ### Toolbar Toggle
@@ -259,6 +260,8 @@ All built-in toolbar button names that can be used in the `toolbar` config strin
259
260
  | `fullscreen` | Toggle fullscreen editing mode |
260
261
  | `preview` | Open content preview in a new window |
261
262
  | `searchreplace` | Open Find & Replace dialog |
263
+ | `speechtotext` | Open Speech to Text dialog (browser support required) |
264
+ | `dictate` | Toggle inline dictation — inserts speech directly at cursor (browser support required) |
262
265
  | `ltr` | Set text direction to left-to-right |
263
266
  | `rtl` | Set text direction to right-to-left |
264
267
 
package/dist/index.d.ts CHANGED
@@ -75,6 +75,37 @@ export declare function createTranslateFunction(code: string): TranslateFunction
75
75
  */
76
76
  export declare const DEFAULT_ICONS: IconSet;
77
77
 
78
+ export declare class Dictation {
79
+ private options;
80
+ private recognition;
81
+ private _isActive;
82
+ private restartTimer;
83
+ private interimStart;
84
+ private interimLength;
85
+ constructor(options: DictationOptions);
86
+ get isActive(): boolean;
87
+ toggle(): void;
88
+ start(): void;
89
+ stop(): void;
90
+ destroy(): void;
91
+ private getSpeechLang;
92
+ private handleResult;
93
+ /** Replace the current interim text in the editor with new interim text */
94
+ private replaceInterim;
95
+ /** Remove interim text without inserting anything */
96
+ private clearInterim;
97
+ private needsLeadingSpace;
98
+ private handleError;
99
+ private handleEnd;
100
+ }
101
+
102
+ export declare interface DictationOptions {
103
+ editor: HTMLEditor;
104
+ trans: (key: string) => string;
105
+ /** Called when dictation starts or stops so the toolbar can update the button state */
106
+ onStateChange?: (isActive: boolean) => void;
107
+ }
108
+
78
109
  declare type DirtyCallback = (dirty: boolean) => void;
79
110
 
80
111
  /**
@@ -139,6 +170,7 @@ export declare interface EditorConfig {
139
170
  quickbars_image_toolbar?: boolean;
140
171
  quickbars_insert_toolbar?: boolean;
141
172
  paste_from_office?: boolean;
173
+ speech_to_text?: boolean;
142
174
  browser_spellcheck?: boolean;
143
175
  elementpath?: boolean;
144
176
  entity_encoding?: 'raw' | 'named' | 'numeric';
@@ -316,6 +348,11 @@ export declare interface ImageUploadResult {
316
348
  */
317
349
  declare type InitCallback = (editor: MDHTMLEditor) => void;
318
350
 
351
+ /**
352
+ * Check if the Web Speech API is available in the current browser
353
+ */
354
+ export declare function isSpeechRecognitionSupported(): boolean;
355
+
319
356
  export declare type LanguageChangeCallback = (code: string) => void;
320
357
 
321
358
  export declare const LineHeight: Extension<LineHeightOptions, any>;
@@ -461,6 +498,50 @@ export declare interface SourceEditorOptions {
461
498
  trans: (key: string) => string;
462
499
  }
463
500
 
501
+ export declare class SpeechToText {
502
+ private options;
503
+ private overlay;
504
+ private dialog;
505
+ private recognition;
506
+ private isListening;
507
+ private finalTranscript;
508
+ private interimTranscript;
509
+ private lastConfidence;
510
+ private restartTimer;
511
+ private transcriptArea;
512
+ private confidenceEl;
513
+ private statusEl;
514
+ private startStopBtn;
515
+ private insertBtn;
516
+ private clearBtn;
517
+ private languageSelect;
518
+ constructor(options: SpeechToTextOptions);
519
+ open(): void;
520
+ close(): void;
521
+ destroy(): void;
522
+ private get editorLanguage();
523
+ private getDefaultSpeechLang;
524
+ private createDialog;
525
+ private toggleRecognition;
526
+ private startRecognition;
527
+ private handleResult;
528
+ private handleError;
529
+ private handleEnd;
530
+ private stopRecognition;
531
+ private updateButtonState;
532
+ private setStatus;
533
+ private updateTranscriptDisplay;
534
+ private updateConfidenceDisplay;
535
+ private insertTranscript;
536
+ private clearTranscript;
537
+ private escapeHtml;
538
+ }
539
+
540
+ export declare interface SpeechToTextOptions {
541
+ editor: HTMLEditor;
542
+ trans: (key: string) => string;
543
+ }
544
+
464
545
  /**
465
546
  * Template object for email templates
466
547
  */
@@ -493,6 +574,8 @@ export declare class Toolbar {
493
574
  private searchReplace;
494
575
  private sourceEditor;
495
576
  private linkEditor;
577
+ private speechToText;
578
+ private dictation;
496
579
  private updateInterval;
497
580
  private boundClickHandler;
498
581
  private boundKeydownHandler;
@@ -537,6 +620,8 @@ export declare class Toolbar {
537
620
  private openCharMap;
538
621
  private openEmojiPicker;
539
622
  private openSearchReplace;
623
+ private openSpeechToText;
624
+ private toggleDictation;
540
625
  private openSourceCode;
541
626
  private openPreview;
542
627
  private toggleFullscreen;