LinkExtension
Powerful hyperlink functionality for your editor
Add automatic URL detection, manual link creation, and intelligent paste behavior to your LexKit editor. Handle links with ease and provide a seamless editing experience.
Key Features
Everything you need for professional link handling in your editor.
Automatically detects and converts URLs to clickable links as you type, with customizable validation rules.
Smart paste behavior that handles URLs differently based on context - cursor paste vs. selected text replacement.
Full programmatic control with commands for inserting, editing, and removing links through your UI.
Quick Start
Get up and running with LinkExtension in minutes.
Import and configure LinkExtension
Enable automatic URL detection
Smart Paste Behavior
LinkExtension handles URL pasting intelligently based on your selection context.
Paste a URL when no text is selected. Controlled by autoLinkUrls setting.
Paste a URL over selected text. Controlled by linkSelectedTextOnPaste setting.
Try LinkExtension
Interactive demo showcasing LinkExtension features. Try pasting URLs and using the toolbar!
LinkExtension Demo
Try pasting URLs at cursor vs. over selected text
Configuration Options
Customize LinkExtension behavior to match your needs.
| Option | Type | Description |
|---|---|---|
| autoLinkText | boolean | Enable automatic conversion of typed URLs to links. Note: Only affects URLs typed directly in the editor, not pasted content. |
| autoLinkUrls | boolean | Control whether URLs are automatically linked when pasted. When false, pasted URLs remain as plain text. |
| linkSelectedTextOnPaste | boolean | When pasting URLs over selected text, control whether to link the selected text or replace it with the URL. |
| validateUrl | (url: string) ⇒ boolean | Custom validation function for URLs. Return true to accept, false to reject. |
Enable auto-linking for typed URLs
Disable automatic linking for pasted URLs
Control selected text behavior when pasting URLs
Custom URL validation
API Reference
Complete reference for LinkExtension commands and state queries.
insertLink(url?, text?)Insert or apply link to selection. Prompts for URL if not provided.
removeLink()Remove link from current selection.
isLink()Check if current selection is within a link.
Best Practices
Tips for getting the most out of LinkExtension.
Use custom validation to restrict links to trusted domains or enforce HTTPS-only policies.
Combine auto-linking with manual controls. Let users decide when to auto-link vs. manual insertion.
Keep validation functions lightweight. Complex validation can impact typing performance.
Ensure link text is descriptive. Consider adding link previews or validation feedback.