Skip to main content
The Link extension allows you to create clickable links. Links are rendered as <a> HTML elements with support for various attributes including href, target, rel, class, and title.

Installation

Usage

Configuration Options

If enabled, the extension will automatically add links as you type.
Array<LinkProtocolOptions | string>
default:"[]"
An array of custom protocols to be registered with linkifyjs.
string
default:"'http'"
Default protocol to use when no protocol is specified.
boolean
default:"true"
If enabled, links will be opened on click.
boolean
default:"false"
If enabled, the link will be selected when clicked.
Adds a link to the current selection if the pasted content only contains a URL.
Record<string, any>
HTML attributes to add to the link element.
function
A validation function used for configuring link verification to prevent XSS attacks. Only modify this if you know what you’re doing.
Determines whether a valid link should be automatically linked in the content.

Commands

Set a link mark with the specified attributes. Supports href, target, rel, class, and title attributes.
Toggle a link mark with the specified attributes.
Remove the link mark from the current selection.
The Link extension supports the following attributes:
  • href - The URL the link points to
  • target - Where to open the link (e.g., _blank)
  • rel - The relationship between the current document and the linked document
  • class - CSS class name(s) for the link
  • title - Tooltip text displayed when hovering over the link (added in v3.19.0)

Security

The Link extension includes built-in XSS protection. By default, it only allows safe protocols:
  • http, https
  • ftp, ftps
  • mailto, tel, callto, sms
  • cid, xmpp
You can customize this behavior using the isAllowedUri option, but be careful to maintain security when doing so. When autolink is enabled (default), the extension will automatically create links when you:
  • Type or paste a URL with an explicit protocol (e.g., https://example.com)
  • Type a domain with a TLD (e.g., example.com)
The extension will NOT autolink:
  • IP addresses without a protocol
  • Single-word hostnames without a TLD (e.g., localhost)
  • URLs typed inside inline code marks

Source Code

View the source code on GitHub: