@mdaemon/html-editor 1.4.1 → 1.5.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 +4 -1
- package/dist/index.d.ts +32 -0
- package/dist/index.js +3317 -889
- package/dist/index.mjs +3317 -889
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -77,6 +77,7 @@ const editor = new HTMLEditor(container, {
|
|
|
77
77
|
| `basicEditor` | boolean | false | Use simplified toolbar for notes/tasks |
|
|
78
78
|
| `readonly` | boolean | false | Start the editor in read-only mode (see `setReadOnly`) |
|
|
79
79
|
| `forced_root_block` | 'p' \| 'div' | 'p' | Block element produced on Enter. `'div'` gives CKEditor `ENTER_DIV` parity |
|
|
80
|
+
| `trailingNode` | boolean | false | Append an empty trailing paragraph when the document ends in a block node (table, image, code block) so the cursor can be placed after it |
|
|
80
81
|
| `includeTemplates` | boolean | false | Show template dropdown |
|
|
81
82
|
| `templates` | Template[] | [] | Array of templates |
|
|
82
83
|
| `dropbox` | boolean | false | Enable Dropbox integration |
|
|
@@ -265,7 +266,7 @@ All built-in toolbar button names that can be used in the `toolbar` config strin
|
|
|
265
266
|
| `removeformat` | Clear all formatting |
|
|
266
267
|
| `copy` | Copy selection |
|
|
267
268
|
| `cut` | Cut selection |
|
|
268
|
-
| `paste` | Paste from clipboard |
|
|
269
|
+
| `paste` | Paste from clipboard (async Clipboard API; prefers HTML, falls back to plain text) |
|
|
269
270
|
| `undo` | Undo last change |
|
|
270
271
|
| `redo` | Redo last undo |
|
|
271
272
|
| `image` | Insert image dialog (upload file or enter URL) |
|
|
@@ -357,6 +358,8 @@ The `link` toolbar button opens a modal dialog for inserting or editing hyperlin
|
|
|
357
358
|
|
|
358
359
|
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
|
|
|
361
|
+
**URL normalization:** a URL entered without a scheme that looks like a bare domain (e.g. `www.example.com` or `example.com/path`) is saved with `http://` prepended, so it resolves as an external link instead of a broken relative path. URLs that already carry a scheme (`https:`, `mailto:`, `tel:`, `ftp:`, …), anchors (`#section`), absolute/relative paths (`/`, `./`, `../`), and protocol-relative URLs (`//host`) are left exactly as typed.
|
|
362
|
+
|
|
360
363
|
## Named Anchors
|
|
361
364
|
|
|
362
365
|
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.
|
package/dist/index.d.ts
CHANGED
|
@@ -172,6 +172,7 @@ export declare interface EditorConfig {
|
|
|
172
172
|
* 'p' (default) emits <p>; 'div' emits <div> (CKEditor ENTER_DIV parity).
|
|
173
173
|
*/
|
|
174
174
|
forced_root_block?: 'p' | 'div';
|
|
175
|
+
trailingNode?: boolean;
|
|
175
176
|
includeTemplates?: boolean;
|
|
176
177
|
templates?: Template[];
|
|
177
178
|
dropbox?: boolean;
|
|
@@ -448,6 +449,14 @@ export declare class LinkEditor {
|
|
|
448
449
|
open(): void;
|
|
449
450
|
close(): void;
|
|
450
451
|
private populateFromSelection;
|
|
452
|
+
/**
|
|
453
|
+
* Ensure a user-entered URL is usable as an href. Domain-like input typed
|
|
454
|
+
* without a scheme (e.g. "www.example.com", "example.com/path") would
|
|
455
|
+
* otherwise resolve as a relative path and produce a broken link, so prepend
|
|
456
|
+
* a default protocol. Anchors (#...), relative/absolute paths, protocol-
|
|
457
|
+
* relative URLs (//host) and anything with an existing scheme are left alone.
|
|
458
|
+
*/
|
|
459
|
+
private normalizeUrl;
|
|
451
460
|
private save;
|
|
452
461
|
private createDialog;
|
|
453
462
|
destroy(): void;
|
|
@@ -697,6 +706,29 @@ export declare class Toolbar {
|
|
|
697
706
|
private toggleOverflow;
|
|
698
707
|
private createButton;
|
|
699
708
|
private createActionButton;
|
|
709
|
+
/**
|
|
710
|
+
* Paste clipboard contents into the editor.
|
|
711
|
+
*
|
|
712
|
+
* `document.execCommand('paste')` is deprecated and blocked by every modern
|
|
713
|
+
* browser (a page is not allowed to silently read the clipboard), so we use
|
|
714
|
+
* the async Clipboard API instead. It prompts the user for clipboard-read
|
|
715
|
+
* permission on first use. We focus the editor *before* awaiting the read —
|
|
716
|
+
* the Clipboard API rejects with "Document is not focused" if the page has
|
|
717
|
+
* lost focus, and focusing first also restores the editor selection so the
|
|
718
|
+
* content lands where the cursor was. HTML is preferred when the clipboard
|
|
719
|
+
* provides it; otherwise we fall back to plain text.
|
|
720
|
+
*
|
|
721
|
+
* Note: some browsers (notably Firefox) block clipboard reads from web pages
|
|
722
|
+
* by default; in that case nothing can be pasted programmatically and the
|
|
723
|
+
* user must use Ctrl/Cmd+V, which the engine handles directly.
|
|
724
|
+
*/
|
|
725
|
+
private pasteFromClipboard;
|
|
726
|
+
/**
|
|
727
|
+
* Reduce a raw `text/html` clipboard payload to the meaningful fragment:
|
|
728
|
+
* unwrap the `<html>/<body>` scaffolding browsers add and drop the
|
|
729
|
+
* `<!--StartFragment-->`/`<!--EndFragment-->` markers and leading `<meta>`.
|
|
730
|
+
*/
|
|
731
|
+
private extractClipboardFragment;
|
|
700
732
|
private createCustomButton;
|
|
701
733
|
private createFontFamilyDropdown;
|
|
702
734
|
private createFontSizeDropdown;
|