Extensions

autolink

Behaviour takes options 0.35 kB gzipped

URLs become links as they are typed and as they are pasted.

Typing: once a space follows something that looks like a URL, the URL gets the link mark and the space is inserted as usual. Pasting a URL over a selection links the selection to it; pasting one with nothing selected inserts it already linked. Needs the `link` mark in the editor.

1 · Install

One package for every extension · there is no @matrajs/autolink to install.

npm i @matrajs/core

2 · Add it to the editor

Import it and put it in the extensions array. That array is the whole feature list: what is not in it is not in your bundle and not in the document's schema.

import { createEditor, document, paragraph, text, autolink } from '@matrajs/core'

const editor = createEditor({
  extensions: [document, paragraph, text, autolink({ … })],
  element: document.querySelector('#editor'),
})

3 · Use it

Nothing to call · this one works once it is in the array. URLs become links as they are typed and as they are pasted.

Options

autolink is a function · call it with an options object.

Option Type What it does
onPaste boolean Turn a pasted URL into a link, or link the selection to it. Default true.
onType boolean Turn a URL into a link once a space is typed after it. Default true.

← All 83 extensions

Edit this page on GitHub