@mdaemon/html-editor 1.2.1 → 1.4.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 +106 -3
- package/dist/index.d.ts +223 -0
- package/dist/index.js +2643 -73
- package/dist/index.mjs +2643 -73
- package/dist/styles.css +236 -0
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -75,6 +75,8 @@ const editor = new HTMLEditor(container, {
|
|
|
75
75
|
| Option | Type | Default | Description |
|
|
76
76
|
|--------|------|---------|-------------|
|
|
77
77
|
| `basicEditor` | boolean | false | Use simplified toolbar for notes/tasks |
|
|
78
|
+
| `readonly` | boolean | false | Start the editor in read-only mode (see `setReadOnly`) |
|
|
79
|
+
| `forced_root_block` | 'p' \| 'div' | 'p' | Block element produced on Enter. `'div'` gives CKEditor `ENTER_DIV` parity |
|
|
78
80
|
| `includeTemplates` | boolean | false | Show template dropdown |
|
|
79
81
|
| `templates` | Template[] | [] | Array of templates |
|
|
80
82
|
| `dropbox` | boolean | false | Enable Dropbox integration |
|
|
@@ -83,8 +85,15 @@ const editor = new HTMLEditor(container, {
|
|
|
83
85
|
| `images_upload_base_path` | string | '/' | Base path prefix for uploaded image URLs |
|
|
84
86
|
| `images_upload_max_size` | number | 10485760 | Maximum upload file size in bytes (default 10 MB) |
|
|
85
87
|
| `images_upload_headers` | Record\<string, string\> | - | Custom HTTP headers for upload requests |
|
|
88
|
+
| `images_file_types` | string | *(permissive)* | Comma/space-separated accepted extensions (e.g. `'jpg,jpeg,png,gif,bmp'`). Restricts uploads when set |
|
|
89
|
+
| `images_upload_validate` | (file: File) => string \| null | - | Pre-upload hook; return a message to reject the file, or null to allow |
|
|
90
|
+
| `images_upload_error` | (message: string) => void | - | Caller-supplied alert for drag-drop/paste upload rejections & failures (no dialog to show errors in) |
|
|
86
91
|
| `font_family_formats` | string | *(TinyMCE defaults)* | Semicolon-separated font list (`Name=family,...`) |
|
|
87
92
|
| `font_size_formats` | string | '8pt 9pt 10pt 12pt 14pt 18pt 24pt 36pt' | Space-separated font sizes |
|
|
93
|
+
| `font_names` | string | - | CKEditor alias for `font_family_formats` |
|
|
94
|
+
| `fontSize_sizes` | string | - | CKEditor alias for `font_size_formats` |
|
|
95
|
+
| `block_formats` | string | 'Paragraph=p;Heading 1=h1;…' | Block-format dropdown definitions (`blocks` button) |
|
|
96
|
+
| `style_formats` | StyleFormat[] | *(subset)* | Named styles for the Styles dropdown (`styles` button) |
|
|
88
97
|
| `fontName` | string | - | Default font family |
|
|
89
98
|
| `fontSize` | string | - | Default font size |
|
|
90
99
|
| `directionality` | 'ltr' \| 'rtl' | 'ltr' | Text direction |
|
|
@@ -104,6 +113,7 @@ const editor = new HTMLEditor(container, {
|
|
|
104
113
|
| `convert_unsafe_embeds` | boolean | true | Sanitize embedded content |
|
|
105
114
|
| `format_empty_lines` | boolean | true | Format empty lines |
|
|
106
115
|
| `paste_from_office` | boolean | true | Clean and preserve formatting when pasting from Microsoft Word and Excel |
|
|
116
|
+
| `speech_to_text` | boolean | true | Enable Speech to Text and Dictate toolbar buttons (requires Web Speech API: Chrome, Edge, Safari) |
|
|
107
117
|
| `setup` | (editor) => void | - | Callback invoked before init — use to register custom buttons |
|
|
108
118
|
|
|
109
119
|
### Toolbar Toggle
|
|
@@ -131,6 +141,8 @@ If your custom toolbar string contains no `||`, all buttons render in a single f
|
|
|
131
141
|
- `execCommand(cmd: string, ui?: boolean, value?: any): boolean` - Execute editor command
|
|
132
142
|
- `isDirty(): boolean` - Check if content has changed
|
|
133
143
|
- `setDirty(state: boolean): void` - Set dirty state
|
|
144
|
+
- `setReadOnly(state: boolean): void` - Toggle read-only mode (disables editing and dims the toolbar)
|
|
145
|
+
- `isReadOnly(): boolean` - Check if the editor is read-only
|
|
134
146
|
- `focus(): void` - Focus the editor
|
|
135
147
|
- `hasFocus(): boolean` - Check if editor has focus
|
|
136
148
|
- `setLanguage(code: string): void` - Change UI language at runtime (rebuilds toolbar)
|
|
@@ -229,6 +241,8 @@ All built-in toolbar button names that can be used in the `toolbar` config strin
|
|
|
229
241
|
| `italic` | Toggle italic |
|
|
230
242
|
| `underline` | Toggle underline |
|
|
231
243
|
| `strikethrough` | Toggle strikethrough |
|
|
244
|
+
| `subscript` | Toggle subscript |
|
|
245
|
+
| `superscript` | Toggle superscript |
|
|
232
246
|
| `bullist` | Toggle bullet list |
|
|
233
247
|
| `numlist` | Toggle numbered list |
|
|
234
248
|
| `outdent` | Decrease indent |
|
|
@@ -237,6 +251,10 @@ All built-in toolbar button names that can be used in the `toolbar` config strin
|
|
|
237
251
|
| `fontfamily` | Font family dropdown |
|
|
238
252
|
| `fontsize` | Font size dropdown |
|
|
239
253
|
| `lineheight` | Line height dropdown (1, 1.2, 1.4, 1.6, 2) |
|
|
254
|
+
| `blocks` | Block format dropdown (Paragraph, Heading 1–6; alias `formatselect`) |
|
|
255
|
+
| `styles` | Named styles dropdown (configurable via `style_formats`) |
|
|
256
|
+
| `table` | Table dropdown (insert table + row/column/cell operations) |
|
|
257
|
+
| `hr` | Insert horizontal rule |
|
|
240
258
|
| `template` | Template dropdown (requires `includeTemplates: true`) |
|
|
241
259
|
| `alignleft` | Align left |
|
|
242
260
|
| `aligncenter` | Align center |
|
|
@@ -255,10 +273,14 @@ All built-in toolbar button names that can be used in the `toolbar` config strin
|
|
|
255
273
|
| `emoticons` | Emoji picker with search (smileys, gestures, hearts, objects, symbols, arrows) |
|
|
256
274
|
| `code` | Open HTML source code editor dialog |
|
|
257
275
|
| `link` | Open Insert/Edit Link dialog |
|
|
276
|
+
| `unlink` | Remove the link at the cursor |
|
|
277
|
+
| `anchor` | Insert a named anchor (`<a id>` target) |
|
|
258
278
|
| `codesample` | Toggle code sample block |
|
|
259
279
|
| `fullscreen` | Toggle fullscreen editing mode |
|
|
260
280
|
| `preview` | Open content preview in a new window |
|
|
261
281
|
| `searchreplace` | Open Find & Replace dialog |
|
|
282
|
+
| `speechtotext` | Open Speech to Text dialog (browser support required) |
|
|
283
|
+
| `dictate` | Toggle inline dictation — inserts speech directly at cursor (browser support required) |
|
|
262
284
|
| `ltr` | Set text direction to left-to-right |
|
|
263
285
|
| `rtl` | Set text direction to right-to-left |
|
|
264
286
|
|
|
@@ -267,13 +289,13 @@ All built-in toolbar button names that can be used in the `toolbar` config strin
|
|
|
267
289
|
**Full toolbar** (default when `basicEditor: false`):
|
|
268
290
|
|
|
269
291
|
```
|
|
270
|
-
bold italic underline strikethrough | bullist numlist outdent indent blockquote | fontfamily fontsize
|
|
292
|
+
bold italic underline strikethrough subscript superscript | blocks styles | bullist numlist outdent indent blockquote | fontfamily fontsize | lineheight alignleft aligncenter alignright alignjustify | forecolor backcolor | removeformat copy cut paste | undo redo | image table charmap emoticons hr | fullscreen preview | code link unlink anchor codesample | ltr rtl | searchreplace
|
|
271
293
|
```
|
|
272
294
|
|
|
273
295
|
**Basic toolbar** (when `basicEditor: true`):
|
|
274
296
|
|
|
275
297
|
```
|
|
276
|
-
bold italic underline strikethrough | bullist numlist outdent indent | fontfamily fontsize blockquote
|
|
298
|
+
bold italic underline strikethrough subscript superscript | bullist numlist outdent indent | fontfamily fontsize blockquote | lineheight alignleft aligncenter alignright alignjustify | forecolor backcolor | removeformat copy cut paste | undo redo | charmap emoticons | link unlink | ltr rtl | searchreplace
|
|
277
299
|
```
|
|
278
300
|
|
|
279
301
|
## Image Upload
|
|
@@ -299,6 +321,25 @@ const editor = new HTMLEditor(container, {
|
|
|
299
321
|
});
|
|
300
322
|
```
|
|
301
323
|
|
|
324
|
+
### Restricting file types and rejecting uploads
|
|
325
|
+
|
|
326
|
+
`images_file_types` restricts which extensions are accepted (matched against the
|
|
327
|
+
file name, falling back to MIME for clipboard pastes that have no name). The
|
|
328
|
+
`images_upload_validate` hook runs before every upload — return a message to
|
|
329
|
+
reject the file. For drag-drop and clipboard-paste uploads there is no dialog to
|
|
330
|
+
show the message in, so rejections and failures are routed to `images_upload_error`
|
|
331
|
+
(supply your own alert/notification — the CKEditor `simpleuploads` `newAlert` flow).
|
|
332
|
+
|
|
333
|
+
```typescript
|
|
334
|
+
const editor = new HTMLEditor(container, {
|
|
335
|
+
images_upload_url: '/api/upload',
|
|
336
|
+
images_file_types: 'jpg,jpeg,png,gif,bmp', // CKEditor simpleuploads parity
|
|
337
|
+
images_upload_validate: (file) =>
|
|
338
|
+
file.size === 0 ? 'Empty files are not allowed' : null,
|
|
339
|
+
images_upload_error: (message) => myApp.showAlert(message),
|
|
340
|
+
});
|
|
341
|
+
```
|
|
342
|
+
|
|
302
343
|
## Source Code Editor
|
|
303
344
|
|
|
304
345
|
The `code` toolbar button opens a modal dialog for viewing and editing the raw HTML source of the editor content. The dialog features a full-size monospace textarea with the current HTML, **Cancel** and **Save** buttons, and supports Escape to close and Tab to indent.
|
|
@@ -314,7 +355,69 @@ The `link` toolbar button opens a modal dialog for inserting or editing hyperlin
|
|
|
314
355
|
- **Title** — the HTML `title` attribute (shown as a tooltip on hover)
|
|
315
356
|
- **Open link in…** — dropdown to choose between _Current window_ or _New window_ (`target="_blank"`)
|
|
316
357
|
|
|
317
|
-
When editing an existing link, all fields are pre-populated from the current link attributes. Clearing the URL and saving removes the link. The dialog inherits the active skin theme.
|
|
358
|
+
When editing an existing link, all fields are pre-populated from the current link attributes. Clearing the URL and saving removes the link. The dialog inherits the active skin theme. The separate `unlink` toolbar button removes the link at the cursor without opening the dialog.
|
|
359
|
+
|
|
360
|
+
## Named Anchors
|
|
361
|
+
|
|
362
|
+
The `anchor` toolbar button opens a dialog to insert a named anchor — an `<a id="name">` target for in-page linking. The anchor name is required and may not contain spaces. Existing anchors in loaded content (`<a id>` with no `href`) are preserved through the editor's parse/serialize cycle.
|
|
363
|
+
|
|
364
|
+
```typescript
|
|
365
|
+
// Programmatic insertion via the TipTap command:
|
|
366
|
+
editor.getTipTap()?.commands.setAnchor('section-1');
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
## Tables
|
|
370
|
+
|
|
371
|
+
The `table` toolbar button is a dropdown that inserts a table and edits the one under the cursor:
|
|
372
|
+
|
|
373
|
+
- **Insert table** — inserts a 3×3 table with a header row.
|
|
374
|
+
- **Insert/delete row**, **Insert/delete column**, **Merge cells**, **Split cell**, **Toggle header row**, **Delete table**.
|
|
375
|
+
|
|
376
|
+
Tables are resizable by dragging column borders.
|
|
377
|
+
|
|
378
|
+
## Block & Style Formats
|
|
379
|
+
|
|
380
|
+
- The `blocks` button (alias `formatselect`) is a block-format dropdown — Paragraph and Heading 1–6 by default. Customize it with `block_formats` (TinyMCE syntax):
|
|
381
|
+
|
|
382
|
+
```typescript
|
|
383
|
+
const editor = new HTMLEditor(container, {
|
|
384
|
+
block_formats: 'Paragraph=p;Title=h1;Subtitle=h2',
|
|
385
|
+
});
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
- The `styles` button is a named-styles dropdown driven by `style_formats` (CKEditor `stylesSet`-compatible). Each entry applies a block element and/or inline color/background/class to the selection:
|
|
389
|
+
|
|
390
|
+
```typescript
|
|
391
|
+
const editor = new HTMLEditor(container, {
|
|
392
|
+
style_formats: [
|
|
393
|
+
{ title: 'Blue Title', block: 'h3', styles: { color: 'Blue' } },
|
|
394
|
+
{ title: 'Marker', inline: 'span', styles: { 'background-color': 'Yellow' } },
|
|
395
|
+
{ title: 'Callout', inline: 'span', classes: 'callout' },
|
|
396
|
+
],
|
|
397
|
+
});
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
> Note: block elements map to headings/paragraph, `color`/`background-color` map to the editor's text-color/highlight marks, and `classes` apply a CSS class to the selection. Arbitrary element wrapping from CKEditor's stylesSet (e.g. `big`, `tt`, `cite`) is not supported by the underlying TipTap schema.
|
|
401
|
+
|
|
402
|
+
## Read-Only Mode
|
|
403
|
+
|
|
404
|
+
Start the editor read-only with `readonly: true`, or toggle it at runtime. Read-only mode disables editing and dims/blocks the toolbar.
|
|
405
|
+
|
|
406
|
+
```typescript
|
|
407
|
+
const editor = new HTMLEditor(container, { readonly: true });
|
|
408
|
+
|
|
409
|
+
editor.setReadOnly(false); // make editable
|
|
410
|
+
editor.setReadOnly(true); // back to read-only
|
|
411
|
+
console.log(editor.isReadOnly());
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
## Enter Behavior (`forced_root_block`)
|
|
415
|
+
|
|
416
|
+
By default, pressing Enter creates a new `<p>` block. Set `forced_root_block: 'div'` for CKEditor `ENTER_DIV` parity, so new blocks (and the serialized output) use `<div>` instead. The `<div id="signature">` signature block is still preserved in either mode.
|
|
417
|
+
|
|
418
|
+
```typescript
|
|
419
|
+
const editor = new HTMLEditor(container, { forced_root_block: 'div' });
|
|
420
|
+
```
|
|
318
421
|
|
|
319
422
|
## Search & Replace
|
|
320
423
|
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,34 @@ import { Editor } from '@tiptap/core';
|
|
|
2
2
|
import { Extension } from '@tiptap/core';
|
|
3
3
|
import { Node as Node_2 } from '@tiptap/core';
|
|
4
4
|
|
|
5
|
+
export declare const Anchor: Node_2<AnchorOptions, any>;
|
|
6
|
+
|
|
7
|
+
export declare class AnchorDialog {
|
|
8
|
+
private options;
|
|
9
|
+
private overlay;
|
|
10
|
+
private dialog;
|
|
11
|
+
private nameInput;
|
|
12
|
+
private errorEl;
|
|
13
|
+
constructor(options: AnchorDialogOptions);
|
|
14
|
+
private get tiptap();
|
|
15
|
+
open(): void;
|
|
16
|
+
close(): void;
|
|
17
|
+
private clearError;
|
|
18
|
+
private showError;
|
|
19
|
+
private save;
|
|
20
|
+
private createDialog;
|
|
21
|
+
destroy(): void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export declare interface AnchorDialogOptions {
|
|
25
|
+
editor: HTMLEditor;
|
|
26
|
+
trans: (key: string) => string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export declare interface AnchorOptions {
|
|
30
|
+
HTMLAttributes: Record<string, unknown>;
|
|
31
|
+
}
|
|
32
|
+
|
|
5
33
|
/** List of all supported locale codes */
|
|
6
34
|
export declare const availableLocales: string[];
|
|
7
35
|
|
|
@@ -75,6 +103,37 @@ export declare function createTranslateFunction(code: string): TranslateFunction
|
|
|
75
103
|
*/
|
|
76
104
|
export declare const DEFAULT_ICONS: IconSet;
|
|
77
105
|
|
|
106
|
+
export declare class Dictation {
|
|
107
|
+
private options;
|
|
108
|
+
private recognition;
|
|
109
|
+
private _isActive;
|
|
110
|
+
private restartTimer;
|
|
111
|
+
private interimStart;
|
|
112
|
+
private interimLength;
|
|
113
|
+
constructor(options: DictationOptions);
|
|
114
|
+
get isActive(): boolean;
|
|
115
|
+
toggle(): void;
|
|
116
|
+
start(): void;
|
|
117
|
+
stop(): void;
|
|
118
|
+
destroy(): void;
|
|
119
|
+
private getSpeechLang;
|
|
120
|
+
private handleResult;
|
|
121
|
+
/** Replace the current interim text in the editor with new interim text */
|
|
122
|
+
private replaceInterim;
|
|
123
|
+
/** Remove interim text without inserting anything */
|
|
124
|
+
private clearInterim;
|
|
125
|
+
private needsLeadingSpace;
|
|
126
|
+
private handleError;
|
|
127
|
+
private handleEnd;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export declare interface DictationOptions {
|
|
131
|
+
editor: HTMLEditor;
|
|
132
|
+
trans: (key: string) => string;
|
|
133
|
+
/** Called when dictation starts or stops so the toolbar can update the button state */
|
|
134
|
+
onStateChange?: (isActive: boolean) => void;
|
|
135
|
+
}
|
|
136
|
+
|
|
78
137
|
declare type DirtyCallback = (dirty: boolean) => void;
|
|
79
138
|
|
|
80
139
|
/**
|
|
@@ -106,6 +165,13 @@ export declare interface DropboxFile {
|
|
|
106
165
|
*/
|
|
107
166
|
export declare interface EditorConfig {
|
|
108
167
|
basicEditor?: boolean;
|
|
168
|
+
/** Start the editor in read-only mode. */
|
|
169
|
+
readonly?: boolean;
|
|
170
|
+
/**
|
|
171
|
+
* Root block element produced when the user presses Enter.
|
|
172
|
+
* 'p' (default) emits <p>; 'div' emits <div> (CKEditor ENTER_DIV parity).
|
|
173
|
+
*/
|
|
174
|
+
forced_root_block?: 'p' | 'div';
|
|
109
175
|
includeTemplates?: boolean;
|
|
110
176
|
templates?: Template[];
|
|
111
177
|
dropbox?: boolean;
|
|
@@ -114,10 +180,36 @@ export declare interface EditorConfig {
|
|
|
114
180
|
images_upload_base_path?: string;
|
|
115
181
|
images_upload_max_size?: number;
|
|
116
182
|
images_upload_headers?: Record<string, string>;
|
|
183
|
+
/**
|
|
184
|
+
* Comma- or space-separated list of accepted image file extensions
|
|
185
|
+
* (e.g. 'jpg,jpeg,png,gif,bmp'). When set, restricts uploads to these
|
|
186
|
+
* types. When omitted, the default permissive set is used.
|
|
187
|
+
*/
|
|
188
|
+
images_file_types?: string;
|
|
189
|
+
/**
|
|
190
|
+
* Optional validation hook run before an image upload starts. Return a
|
|
191
|
+
* non-null string to reject the file (the string is shown via
|
|
192
|
+
* images_upload_error / the dialog). Return null to allow.
|
|
193
|
+
*/
|
|
194
|
+
images_upload_validate?: (file: File) => string | null;
|
|
195
|
+
/**
|
|
196
|
+
* Caller-supplied alert/notification used to report upload rejections and
|
|
197
|
+
* failures from drag-drop / paste (which have no dialog to show errors in).
|
|
198
|
+
* Mirrors the CKEditor simpleuploads newAlert flow.
|
|
199
|
+
*/
|
|
200
|
+
images_upload_error?: (message: string) => void;
|
|
117
201
|
font_family_formats?: string;
|
|
118
202
|
font_size_formats?: string;
|
|
203
|
+
/** CKEditor alias for font_size_formats (space-separated sizes). */
|
|
204
|
+
fontSize_sizes?: string;
|
|
205
|
+
/** CKEditor alias for font_family_formats (semicolon list). */
|
|
206
|
+
font_names?: string;
|
|
119
207
|
fontName?: string;
|
|
120
208
|
fontSize?: string;
|
|
209
|
+
/** Block format dropdown definitions, TinyMCE-style 'Paragraph=p;Heading 1=h1;...'. */
|
|
210
|
+
block_formats?: string;
|
|
211
|
+
/** Named style definitions for the Styles dropdown (CKEditor stylesSet-compatible). */
|
|
212
|
+
style_formats?: StyleFormat[];
|
|
121
213
|
directionality?: 'ltr' | 'rtl';
|
|
122
214
|
language?: string;
|
|
123
215
|
height?: string | number;
|
|
@@ -139,6 +231,7 @@ export declare interface EditorConfig {
|
|
|
139
231
|
quickbars_image_toolbar?: boolean;
|
|
140
232
|
quickbars_insert_toolbar?: boolean;
|
|
141
233
|
paste_from_office?: boolean;
|
|
234
|
+
speech_to_text?: boolean;
|
|
142
235
|
browser_spellcheck?: boolean;
|
|
143
236
|
elementpath?: boolean;
|
|
144
237
|
entity_encoding?: 'raw' | 'named' | 'numeric';
|
|
@@ -269,6 +362,12 @@ export declare class HTMLEditor implements MDHTMLEditor {
|
|
|
269
362
|
execCommand(command: string, _ui?: boolean, value?: unknown): boolean;
|
|
270
363
|
isDirty(): boolean;
|
|
271
364
|
setDirty(state: boolean): void;
|
|
365
|
+
/**
|
|
366
|
+
* Toggle read-only mode. Disables editing and dims the toolbar.
|
|
367
|
+
* Mirrors CKEditor's editor.setReadOnly(bool).
|
|
368
|
+
*/
|
|
369
|
+
setReadOnly(state: boolean): void;
|
|
370
|
+
isReadOnly(): boolean;
|
|
272
371
|
focus(): void;
|
|
273
372
|
hasFocus(): boolean;
|
|
274
373
|
on<K extends keyof EditorEventMap>(event: K, callback: EditorEventMap[K]): void;
|
|
@@ -316,6 +415,17 @@ export declare interface ImageUploadResult {
|
|
|
316
415
|
*/
|
|
317
416
|
declare type InitCallback = (editor: MDHTMLEditor) => void;
|
|
318
417
|
|
|
418
|
+
export declare const InlineStyle: Extension<InlineStyleOptions, any>;
|
|
419
|
+
|
|
420
|
+
export declare interface InlineStyleOptions {
|
|
421
|
+
types: string[];
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Check if the Web Speech API is available in the current browser
|
|
426
|
+
*/
|
|
427
|
+
export declare function isSpeechRecognitionSupported(): boolean;
|
|
428
|
+
|
|
319
429
|
export declare type LanguageChangeCallback = (code: string) => void;
|
|
320
430
|
|
|
321
431
|
export declare const LineHeight: Extension<LineHeightOptions, any>;
|
|
@@ -362,6 +472,8 @@ export declare interface MDHTMLEditor {
|
|
|
362
472
|
execCommand(command: string, ui?: boolean, value?: unknown): boolean;
|
|
363
473
|
isDirty(): boolean;
|
|
364
474
|
setDirty(state: boolean): void;
|
|
475
|
+
setReadOnly(state: boolean): void;
|
|
476
|
+
isReadOnly(): boolean;
|
|
365
477
|
focus(): void;
|
|
366
478
|
hasFocus(): boolean;
|
|
367
479
|
on<K extends keyof EditorEventMap>(event: K, callback: EditorEventMap[K]): void;
|
|
@@ -461,6 +573,73 @@ export declare interface SourceEditorOptions {
|
|
|
461
573
|
trans: (key: string) => string;
|
|
462
574
|
}
|
|
463
575
|
|
|
576
|
+
export declare class SpeechToText {
|
|
577
|
+
private options;
|
|
578
|
+
private overlay;
|
|
579
|
+
private dialog;
|
|
580
|
+
private recognition;
|
|
581
|
+
private isListening;
|
|
582
|
+
private finalTranscript;
|
|
583
|
+
private interimTranscript;
|
|
584
|
+
private lastConfidence;
|
|
585
|
+
private restartTimer;
|
|
586
|
+
private transcriptArea;
|
|
587
|
+
private confidenceEl;
|
|
588
|
+
private statusEl;
|
|
589
|
+
private startStopBtn;
|
|
590
|
+
private insertBtn;
|
|
591
|
+
private clearBtn;
|
|
592
|
+
private languageSelect;
|
|
593
|
+
constructor(options: SpeechToTextOptions);
|
|
594
|
+
open(): void;
|
|
595
|
+
close(): void;
|
|
596
|
+
destroy(): void;
|
|
597
|
+
private get editorLanguage();
|
|
598
|
+
private getDefaultSpeechLang;
|
|
599
|
+
private createDialog;
|
|
600
|
+
private toggleRecognition;
|
|
601
|
+
private startRecognition;
|
|
602
|
+
private handleResult;
|
|
603
|
+
private handleError;
|
|
604
|
+
private handleEnd;
|
|
605
|
+
private stopRecognition;
|
|
606
|
+
private updateButtonState;
|
|
607
|
+
private setStatus;
|
|
608
|
+
private updateTranscriptDisplay;
|
|
609
|
+
private updateConfidenceDisplay;
|
|
610
|
+
private insertTranscript;
|
|
611
|
+
private clearTranscript;
|
|
612
|
+
private escapeHtml;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
export declare interface SpeechToTextOptions {
|
|
616
|
+
editor: HTMLEditor;
|
|
617
|
+
trans: (key: string) => string;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* Named style definition for the Styles dropdown.
|
|
622
|
+
* CKEditor stylesSet-compatible shape. Either `inline` or `block` identifies
|
|
623
|
+
* how the style is applied; `element` is the legacy/CKEditor tag name and is
|
|
624
|
+
* treated as inline unless `block` is set.
|
|
625
|
+
*/
|
|
626
|
+
export declare interface StyleFormat {
|
|
627
|
+
/** Display name in the Styles dropdown. */
|
|
628
|
+
title: string;
|
|
629
|
+
/** Inline element to apply (e.g. 'span'). */
|
|
630
|
+
inline?: string;
|
|
631
|
+
/** Block element to apply (e.g. 'h3', 'p'). */
|
|
632
|
+
block?: string;
|
|
633
|
+
/** CKEditor-style element name (mapped to inline unless block is set). */
|
|
634
|
+
element?: string;
|
|
635
|
+
/** Inline CSS styles to apply (e.g. { color: 'Blue' }). */
|
|
636
|
+
styles?: Record<string, string>;
|
|
637
|
+
/** Space-separated CSS class names to apply. */
|
|
638
|
+
classes?: string;
|
|
639
|
+
/** HTML attributes to apply (e.g. { dir: 'rtl' }). */
|
|
640
|
+
attributes?: Record<string, string>;
|
|
641
|
+
}
|
|
642
|
+
|
|
464
643
|
/**
|
|
465
644
|
* Template object for email templates
|
|
466
645
|
*/
|
|
@@ -493,6 +672,9 @@ export declare class Toolbar {
|
|
|
493
672
|
private searchReplace;
|
|
494
673
|
private sourceEditor;
|
|
495
674
|
private linkEditor;
|
|
675
|
+
private anchorDialog;
|
|
676
|
+
private speechToText;
|
|
677
|
+
private dictation;
|
|
496
678
|
private updateInterval;
|
|
497
679
|
private boundClickHandler;
|
|
498
680
|
private boundKeydownHandler;
|
|
@@ -520,6 +702,17 @@ export declare class Toolbar {
|
|
|
520
702
|
private createFontSizeDropdown;
|
|
521
703
|
private createLineHeightDropdown;
|
|
522
704
|
private createTemplateDropdown;
|
|
705
|
+
private createFormatDropdown;
|
|
706
|
+
private getStyleFormats;
|
|
707
|
+
private createStylesDropdown;
|
|
708
|
+
/**
|
|
709
|
+
* Apply a StyleFormat to the current selection. Block elements map to
|
|
710
|
+
* heading/paragraph; color and background map to the existing Color /
|
|
711
|
+
* Highlight marks; classes map to the InlineStyle textStyle class.
|
|
712
|
+
* (Arbitrary element wrapping from CKEditor stylesSet is not supported.)
|
|
713
|
+
*/
|
|
714
|
+
private applyStyleFormat;
|
|
715
|
+
private createTableDropdown;
|
|
523
716
|
/**
|
|
524
717
|
* Position a fixed-position menu below its trigger button.
|
|
525
718
|
* Uses getBoundingClientRect so the menu escapes any overflow:hidden ancestor.
|
|
@@ -534,9 +727,17 @@ export declare class Toolbar {
|
|
|
534
727
|
private updateButtonStates;
|
|
535
728
|
private openImageDialog;
|
|
536
729
|
private openLinkDialog;
|
|
730
|
+
private openAnchorDialog;
|
|
731
|
+
/**
|
|
732
|
+
* Enable or disable the whole toolbar (used for read-only mode).
|
|
733
|
+
* Blocks pointer interaction and dims the toolbar via CSS.
|
|
734
|
+
*/
|
|
735
|
+
setEnabled(enabled: boolean): void;
|
|
537
736
|
private openCharMap;
|
|
538
737
|
private openEmojiPicker;
|
|
539
738
|
private openSearchReplace;
|
|
739
|
+
private openSpeechToText;
|
|
740
|
+
private toggleDictation;
|
|
540
741
|
private openSourceCode;
|
|
541
742
|
private openPreview;
|
|
542
743
|
private toggleFullscreen;
|
|
@@ -641,3 +842,25 @@ declare module '@tiptap/core' {
|
|
|
641
842
|
};
|
|
642
843
|
}
|
|
643
844
|
}
|
|
845
|
+
|
|
846
|
+
|
|
847
|
+
declare module '@tiptap/core' {
|
|
848
|
+
interface Commands<ReturnType> {
|
|
849
|
+
anchor: {
|
|
850
|
+
/** Insert a named anchor at the cursor. */
|
|
851
|
+
setAnchor: (name: string) => ReturnType;
|
|
852
|
+
};
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
|
|
857
|
+
declare module '@tiptap/core' {
|
|
858
|
+
interface Commands<ReturnType> {
|
|
859
|
+
inlineStyle: {
|
|
860
|
+
/** Apply a CSS class to the current selection via the textStyle mark. */
|
|
861
|
+
setInlineClass: (className: string) => ReturnType;
|
|
862
|
+
/** Remove the textStyle class. */
|
|
863
|
+
unsetInlineClass: () => ReturnType;
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
}
|