@mdaemon/html-editor 1.4.0 → 1.4.2
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 +3 -1
- package/dist/index.d.ts +31 -0
- package/dist/index.js +3313 -889
- package/dist/index.mjs +3313 -889
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -265,7 +265,7 @@ All built-in toolbar button names that can be used in the `toolbar` config strin
|
|
|
265
265
|
| `removeformat` | Clear all formatting |
|
|
266
266
|
| `copy` | Copy selection |
|
|
267
267
|
| `cut` | Cut selection |
|
|
268
|
-
| `paste` | Paste from clipboard |
|
|
268
|
+
| `paste` | Paste from clipboard (async Clipboard API; prefers HTML, falls back to plain text) |
|
|
269
269
|
| `undo` | Undo last change |
|
|
270
270
|
| `redo` | Redo last undo |
|
|
271
271
|
| `image` | Insert image dialog (upload file or enter URL) |
|
|
@@ -357,6 +357,8 @@ The `link` toolbar button opens a modal dialog for inserting or editing hyperlin
|
|
|
357
357
|
|
|
358
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
359
|
|
|
360
|
+
**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.
|
|
361
|
+
|
|
360
362
|
## Named Anchors
|
|
361
363
|
|
|
362
364
|
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
|
@@ -448,6 +448,14 @@ export declare class LinkEditor {
|
|
|
448
448
|
open(): void;
|
|
449
449
|
close(): void;
|
|
450
450
|
private populateFromSelection;
|
|
451
|
+
/**
|
|
452
|
+
* Ensure a user-entered URL is usable as an href. Domain-like input typed
|
|
453
|
+
* without a scheme (e.g. "www.example.com", "example.com/path") would
|
|
454
|
+
* otherwise resolve as a relative path and produce a broken link, so prepend
|
|
455
|
+
* a default protocol. Anchors (#...), relative/absolute paths, protocol-
|
|
456
|
+
* relative URLs (//host) and anything with an existing scheme are left alone.
|
|
457
|
+
*/
|
|
458
|
+
private normalizeUrl;
|
|
451
459
|
private save;
|
|
452
460
|
private createDialog;
|
|
453
461
|
destroy(): void;
|
|
@@ -697,6 +705,29 @@ export declare class Toolbar {
|
|
|
697
705
|
private toggleOverflow;
|
|
698
706
|
private createButton;
|
|
699
707
|
private createActionButton;
|
|
708
|
+
/**
|
|
709
|
+
* Paste clipboard contents into the editor.
|
|
710
|
+
*
|
|
711
|
+
* `document.execCommand('paste')` is deprecated and blocked by every modern
|
|
712
|
+
* browser (a page is not allowed to silently read the clipboard), so we use
|
|
713
|
+
* the async Clipboard API instead. It prompts the user for clipboard-read
|
|
714
|
+
* permission on first use. We focus the editor *before* awaiting the read —
|
|
715
|
+
* the Clipboard API rejects with "Document is not focused" if the page has
|
|
716
|
+
* lost focus, and focusing first also restores the editor selection so the
|
|
717
|
+
* content lands where the cursor was. HTML is preferred when the clipboard
|
|
718
|
+
* provides it; otherwise we fall back to plain text.
|
|
719
|
+
*
|
|
720
|
+
* Note: some browsers (notably Firefox) block clipboard reads from web pages
|
|
721
|
+
* by default; in that case nothing can be pasted programmatically and the
|
|
722
|
+
* user must use Ctrl/Cmd+V, which the engine handles directly.
|
|
723
|
+
*/
|
|
724
|
+
private pasteFromClipboard;
|
|
725
|
+
/**
|
|
726
|
+
* Reduce a raw `text/html` clipboard payload to the meaningful fragment:
|
|
727
|
+
* unwrap the `<html>/<body>` scaffolding browsers add and drop the
|
|
728
|
+
* `<!--StartFragment-->`/`<!--EndFragment-->` markers and leading `<meta>`.
|
|
729
|
+
*/
|
|
730
|
+
private extractClipboardFragment;
|
|
700
731
|
private createCustomButton;
|
|
701
732
|
private createFontFamilyDropdown;
|
|
702
733
|
private createFontSizeDropdown;
|