Links & Anchors
@erag/text-editor-vue provides interactive dialog modals for inserting, editing, and managing hyperlinks and internal page anchors.
Toolbar & Menubar Configuration
Add link and anchor controls to your configuration:
ts
const editorConfig: EditorInit = {
plugins: ['link', 'anchor'],
menubar: ['insert'],
toolbar: 'undo redo | blocks | bold italic | link removeformat',
};Link Insertion & Edit Dialog
Clicking the Link icon in the toolbar or navigating to Insert → Link opens the Link Modal Dialog with the following options:
- URL (
href): Target hyperlink web address or mailto URL. - Text to Display: Text label inserted inside
<a href="...">Text</a>. - Title Attribute: Accessibility tooltip title attribute.
- Open in New Tab (
target="_blank"): Addstarget="_blank"andrel="noopener noreferrer"for external links.
Modifying Existing Links
Positioning your caret inside an existing link and clicking the Link button re-populates the dialog with existing values for quick editing. Click Unlink in the dialog or toolbar to strip the <a> tag while keeping the text intact.
Anchors (anchor)
Anchors create an empty bookmark element with a generated ID. anchor is an Insert-menu action rather than a toolbar keyword.
- Place the caret where the bookmark should live.
- Select Insert → Anchor from the menubar.
- Read the generated
idfrom the HTML source when creating a matching#idlink.
html
<a id="generated-id" name="anchor"></a>