@mdaemon/html-editor 1.0.6 → 1.0.8
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 +65 -6
- package/dist/index.d.ts +72 -2
- package/dist/index.js +1003 -130
- package/dist/index.mjs +1003 -130
- package/dist/styles.css +497 -0
- package/package.json +12 -3
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -89,10 +89,12 @@ const editor = new HTMLEditor(container, {
|
|
|
89
89
|
| `fontSize` | string | - | Default font size |
|
|
90
90
|
| `directionality` | 'ltr' \| 'rtl' | 'ltr' | Text direction |
|
|
91
91
|
| `language` | string | 'en' | UI language code (built-in translations for 31 languages) |
|
|
92
|
-
| `height` | string \| number | 300 | Editor height |
|
|
92
|
+
| `height` | string \| number | 300 | Editor height (fixed) |
|
|
93
|
+
| `min_height` | string \| number | - | Minimum editor height |
|
|
94
|
+
| `max_height` | string \| number | - | Maximum editor height |
|
|
93
95
|
| `auto_focus` | string | - | Auto-focus the editor on init |
|
|
94
|
-
| `skin` | 'oxide' \| 'oxide-dark' | 'oxide' | Theme |
|
|
95
|
-
| `content_css` | 'default' \| 'dark' | 'default' | Content area styling |
|
|
96
|
+
| `skin` | 'oxide' \| 'oxide-dark' \| 'confab' \| 'confab-dark' | 'oxide' | Theme (see Theming section) |
|
|
97
|
+
| `content_css` | 'default' \| 'dark' \| 'confab' \| 'confab-dark' | 'default' | Content area styling |
|
|
96
98
|
| `content_style` | string | - | Custom CSS injected into the content area |
|
|
97
99
|
| `toolbar` | string | *(see Toolbar section)* | Custom toolbar button layout |
|
|
98
100
|
| `toolbar_mode` | 'sliding' \| 'floating' \| 'wrap' | 'wrap' | Toolbar overflow behavior |
|
|
@@ -250,8 +252,8 @@ All built-in toolbar button names that can be used in the `toolbar` config strin
|
|
|
250
252
|
| `image` | Insert image dialog (upload file or enter URL) |
|
|
251
253
|
| `charmap` | Special character picker (currency, math, arrows, symbols, Greek, punctuation) |
|
|
252
254
|
| `emoticons` | Emoji picker with search (smileys, gestures, hearts, objects, symbols, arrows) |
|
|
253
|
-
| `code` |
|
|
254
|
-
| `link` | Insert/
|
|
255
|
+
| `code` | Open HTML source code editor dialog |
|
|
256
|
+
| `link` | Open Insert/Edit Link dialog |
|
|
255
257
|
| `codesample` | Toggle code sample block |
|
|
256
258
|
| `fullscreen` | Toggle fullscreen editing mode |
|
|
257
259
|
| `preview` | Open content preview in a new window |
|
|
@@ -296,6 +298,23 @@ const editor = new HTMLEditor(container, {
|
|
|
296
298
|
});
|
|
297
299
|
```
|
|
298
300
|
|
|
301
|
+
## Source Code Editor
|
|
302
|
+
|
|
303
|
+
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.
|
|
304
|
+
|
|
305
|
+
The dialog inherits the active skin theme — oxide, oxide-dark, confab, and confab-dark are all supported automatically.
|
|
306
|
+
|
|
307
|
+
## Insert/Edit Link
|
|
308
|
+
|
|
309
|
+
The `link` toolbar button opens a modal dialog for inserting or editing hyperlinks with the following fields:
|
|
310
|
+
|
|
311
|
+
- **URL** — the link destination
|
|
312
|
+
- **Text to display** — the visible link text (pre-populated from selection)
|
|
313
|
+
- **Title** — the HTML `title` attribute (shown as a tooltip on hover)
|
|
314
|
+
- **Open link in…** — dropdown to choose between _Current window_ or _New window_ (`target="_blank"`)
|
|
315
|
+
|
|
316
|
+
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.
|
|
317
|
+
|
|
299
318
|
## Search & Replace
|
|
300
319
|
|
|
301
320
|
The `searchreplace` toolbar button (or **Ctrl/Cmd+F**) opens a Find & Replace dialog with:
|
|
@@ -482,6 +501,45 @@ const editor = new HTMLEditor(container, {
|
|
|
482
501
|
});
|
|
483
502
|
```
|
|
484
503
|
|
|
504
|
+
### Confab skin
|
|
505
|
+
|
|
506
|
+
The `confab` and `confab-dark` skins integrate with the WorldClient theming system. They use CSS custom properties from the host application so the editor automatically adapts when the app theme changes.
|
|
507
|
+
|
|
508
|
+
The confab skins also replace the default text/emoji toolbar icons with clean SVG line icons for a more polished look.
|
|
509
|
+
|
|
510
|
+
```typescript
|
|
511
|
+
// Light mode
|
|
512
|
+
const editor = new HTMLEditor(container, {
|
|
513
|
+
skin: 'confab',
|
|
514
|
+
content_css: 'confab',
|
|
515
|
+
});
|
|
516
|
+
|
|
517
|
+
// Dark mode
|
|
518
|
+
const editor = new HTMLEditor(container, {
|
|
519
|
+
skin: 'confab-dark',
|
|
520
|
+
content_css: 'confab-dark',
|
|
521
|
+
});
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
The confab skins expect the following CSS custom properties to be defined by the host application:
|
|
525
|
+
|
|
526
|
+
| Variable | Purpose |
|
|
527
|
+
|----------|---------||
|
|
528
|
+
| `--theme-primary` | Primary brand color (buttons, active states) |
|
|
529
|
+
| `--theme-primary-hover` | Hover state for primary color |
|
|
530
|
+
| `--color-confab-gray-50` to `--color-confab-gray-900` | Gray scale for backgrounds, text, borders |
|
|
531
|
+
| `--color-confab-500` | Focus ring color |
|
|
532
|
+
| `--color-dark-bg-primary` | Dark mode primary background |
|
|
533
|
+
| `--color-dark-bg-secondary` | Dark mode toolbar/panel background |
|
|
534
|
+
| `--color-dark-bg-tertiary` | Dark mode inset/recessed background |
|
|
535
|
+
| `--color-dark-bg-hover` | Dark mode hover state |
|
|
536
|
+
| `--color-dark-text-primary` | Dark mode primary text |
|
|
537
|
+
| `--color-dark-text-secondary` | Dark mode secondary text |
|
|
538
|
+
| `--color-dark-text-muted` | Dark mode muted text |
|
|
539
|
+
| `--color-dark-border` | Dark mode border color |
|
|
540
|
+
|
|
541
|
+
All variables include fallback values so the editor remains usable without the host CSS, though colors may not match the intended design.
|
|
542
|
+
|
|
485
543
|
### Custom content styles
|
|
486
544
|
|
|
487
545
|
Inject additional CSS into the editor content area:
|
|
@@ -498,7 +556,8 @@ The editor DOM uses BEM-style classes you can target for further customization:
|
|
|
498
556
|
|
|
499
557
|
- `.md-editor` — outer wrapper
|
|
500
558
|
- `.md-editor-fullscreen` — applied in fullscreen mode
|
|
501
|
-
- `.md-editor-oxide` / `.md-editor-oxide-dark` — theme variant
|
|
559
|
+
- `.md-editor-oxide` / `.md-editor-oxide-dark` — oxide theme variant
|
|
560
|
+
- `.md-editor-confab` / `.md-editor-confab-dark` — confab theme variant
|
|
502
561
|
- `.md-toolbar` — toolbar container
|
|
503
562
|
- `.md-toolbar-sticky` — sticky toolbar
|
|
504
563
|
- `.md-toolbar-primary` / `.md-toolbar-overflow` — primary and collapsible toolbar rows
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Editor } from '@tiptap/core';
|
|
2
2
|
import { Extension } from '@tiptap/core';
|
|
3
|
+
import { Node as Node_2 } from '@tiptap/core';
|
|
3
4
|
|
|
4
5
|
/** List of all supported locale codes */
|
|
5
6
|
export declare const availableLocales: string[];
|
|
@@ -54,6 +55,13 @@ export declare interface ColorOption {
|
|
|
54
55
|
label?: string;
|
|
55
56
|
}
|
|
56
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Confab icon set — clean SVG stroke icons for the confab and confab-dark skins.
|
|
60
|
+
* All icons use viewBox="0 0 24 24", stroke="currentColor", stroke-width="2".
|
|
61
|
+
* Emoticons and charmap keep their emoji/text icons.
|
|
62
|
+
*/
|
|
63
|
+
export declare const CONFAB_ICONS: IconSet;
|
|
64
|
+
|
|
57
65
|
/**
|
|
58
66
|
* Create a TranslateFunction for a given language code.
|
|
59
67
|
* Returns a function that looks up keys in the locale map,
|
|
@@ -61,6 +69,12 @@ export declare interface ColorOption {
|
|
|
61
69
|
*/
|
|
62
70
|
export declare function createTranslateFunction(code: string): TranslateFunction;
|
|
63
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Default icon set — used by oxide and oxide-dark skins.
|
|
74
|
+
* Text characters and emoji for most buttons, inline SVGs for alignment/image/code.
|
|
75
|
+
*/
|
|
76
|
+
export declare const DEFAULT_ICONS: IconSet;
|
|
77
|
+
|
|
64
78
|
declare type DirtyCallback = (dirty: boolean) => void;
|
|
65
79
|
|
|
66
80
|
/**
|
|
@@ -107,10 +121,12 @@ export declare interface EditorConfig {
|
|
|
107
121
|
directionality?: 'ltr' | 'rtl';
|
|
108
122
|
language?: string;
|
|
109
123
|
height?: string | number;
|
|
124
|
+
min_height?: string | number;
|
|
125
|
+
max_height?: string | number;
|
|
110
126
|
auto_focus?: string;
|
|
111
127
|
setFocus?: string;
|
|
112
|
-
skin?: 'oxide' | 'oxide-dark';
|
|
113
|
-
content_css?: 'default' | 'dark';
|
|
128
|
+
skin?: 'oxide' | 'oxide-dark' | 'confab' | 'confab-dark';
|
|
129
|
+
content_css?: 'default' | 'dark' | 'confab' | 'confab-dark';
|
|
114
130
|
content_style?: string;
|
|
115
131
|
toolbar?: string;
|
|
116
132
|
toolbar_mode?: 'sliding' | 'floating' | 'wrap';
|
|
@@ -271,6 +287,12 @@ export declare class HTMLEditor implements MDHTMLEditor {
|
|
|
271
287
|
isBasicEditor(): boolean;
|
|
272
288
|
}
|
|
273
289
|
|
|
290
|
+
/**
|
|
291
|
+
* MDHTMLEditor Icon Sets
|
|
292
|
+
* Skin-specific icon registries for toolbar buttons
|
|
293
|
+
*/
|
|
294
|
+
export declare type IconSet = Record<string, string>;
|
|
295
|
+
|
|
274
296
|
/**
|
|
275
297
|
* Image upload handler
|
|
276
298
|
*/
|
|
@@ -300,6 +322,29 @@ declare interface LineHeightOptions {
|
|
|
300
322
|
defaultLineHeight: string;
|
|
301
323
|
}
|
|
302
324
|
|
|
325
|
+
export declare class LinkEditor {
|
|
326
|
+
private options;
|
|
327
|
+
private overlay;
|
|
328
|
+
private dialog;
|
|
329
|
+
private urlInput;
|
|
330
|
+
private textInput;
|
|
331
|
+
private titleInput;
|
|
332
|
+
private targetSelect;
|
|
333
|
+
constructor(options: LinkEditorOptions);
|
|
334
|
+
private get tiptap();
|
|
335
|
+
open(): void;
|
|
336
|
+
close(): void;
|
|
337
|
+
private populateFromSelection;
|
|
338
|
+
private save;
|
|
339
|
+
private createDialog;
|
|
340
|
+
destroy(): void;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
export declare interface LinkEditorOptions {
|
|
344
|
+
editor: HTMLEditor;
|
|
345
|
+
trans: (key: string) => string;
|
|
346
|
+
}
|
|
347
|
+
|
|
303
348
|
/**
|
|
304
349
|
* Main HTMLEditor class interface
|
|
305
350
|
*/
|
|
@@ -380,6 +425,27 @@ export declare function setGetFileSrc(fn: (path: string) => string): void;
|
|
|
380
425
|
*/
|
|
381
426
|
export declare function setTranslate(fn: TranslateFunction): void;
|
|
382
427
|
|
|
428
|
+
export declare const SignatureBlock: Node_2<any, any>;
|
|
429
|
+
|
|
430
|
+
export declare class SourceEditor {
|
|
431
|
+
private options;
|
|
432
|
+
private overlay;
|
|
433
|
+
private dialog;
|
|
434
|
+
private textarea;
|
|
435
|
+
constructor(options: SourceEditorOptions);
|
|
436
|
+
private get tiptap();
|
|
437
|
+
open(): void;
|
|
438
|
+
close(): void;
|
|
439
|
+
private save;
|
|
440
|
+
private createDialog;
|
|
441
|
+
destroy(): void;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
export declare interface SourceEditorOptions {
|
|
445
|
+
editor: HTMLEditor;
|
|
446
|
+
trans: (key: string) => string;
|
|
447
|
+
}
|
|
448
|
+
|
|
383
449
|
/**
|
|
384
450
|
* Template object for email templates
|
|
385
451
|
*/
|
|
@@ -409,6 +475,8 @@ export declare class Toolbar {
|
|
|
409
475
|
private emojiPicker;
|
|
410
476
|
private imageUpload;
|
|
411
477
|
private searchReplace;
|
|
478
|
+
private sourceEditor;
|
|
479
|
+
private linkEditor;
|
|
412
480
|
private updateInterval;
|
|
413
481
|
private boundClickHandler;
|
|
414
482
|
private boundKeydownHandler;
|
|
@@ -417,6 +485,7 @@ export declare class Toolbar {
|
|
|
417
485
|
constructor(container: HTMLElement, options: ToolbarOptions);
|
|
418
486
|
private get tiptap();
|
|
419
487
|
private get trans();
|
|
488
|
+
private icon;
|
|
420
489
|
private render;
|
|
421
490
|
private renderGroups;
|
|
422
491
|
private createToggleButton;
|
|
@@ -473,6 +542,7 @@ declare interface ToolbarOptions {
|
|
|
473
542
|
sticky: boolean;
|
|
474
543
|
customButtons: Map<string, ToolbarButtonSpec>;
|
|
475
544
|
config: EditorConfig;
|
|
545
|
+
iconSet: IconSet;
|
|
476
546
|
}
|
|
477
547
|
|
|
478
548
|
/**
|