editor

Docs › Text and paragraphs

Links

Add, edit and remove links; new tab, nofollow and linkRel.

Attach an address to text or an image. The link dialog also lets you open it in a new tab and tell search engines not to follow it (nofollow).

Try it

Code for this demo

createEditor('#editor', {
  toolbar: 'bold | link unlink',
  linkRel: 'ugc',
});
  • Select text and press the link button or Ctrl+K. With nothing selected, the dialog also asks for the text to show (empty: the address is used).
  • An address without a scheme like example.com gets https://; name@example.com becomes a mailto: link.
  • Unsafe addresses such as javascript: are refused with a message.
  • The address box suggests bookmarks in the post (places with an id) for #bookmark links (Bookmarks and TOC).
  • Addresses typed in the text become links after a space or Enter (auto link). A pasted address becomes a link too.

New tab and nofollow

"Open in a new tab" adds target="_blank" with rel="noopener noreferrer". The nofollow checkbox adds nofollow to rel. sponsored and ugc set elsewhere are kept.

For boards written by visitors, set linkRel: 'nofollow ugc'. getHTML() adds it to every http(s) link. Only nofollow, sponsored and ugc are accepted; the content being edited is not changed.

Editing and removing

  • With the caret in a link, a small bar shows the address plus open, edit and remove buttons.
  • Ctrl+click opens a link in a new tab; #bookmark links jump to that spot in the post.
  • unlink: with just a caret it removes the whole link; with a selection, only the selected part. The text stays.
  • Selecting an image and adding a link makes the whole image a link (Images).

Presets and phones

link is on the first row of every preset and of the phone toolbar. unlink is in no preset: the link bar and the dialog have remove buttons. The selection toolbar has a link button too.

Saved HTML

<a href="https://82editor.com/">82editor home page</a>
<a href="https://example.com/" target="_blank" rel="nofollow noopener noreferrer">new tab + nofollow</a>
<!-- with linkRel: 'ugc', on output -->
<a href="https://82editor.com/" rel="ugc">82editor home page</a>

Options

NameTypeDefaultDescription
linktoolbar item—Open the link dialog
unlinktoolbar item—Remove a link
linkRelstringnonerel added to every http(s) link on output: nofollow sponsored ugc
autoLinkbooleantrueTyped addresses become links