Extensions
trailingNode
Always a paragraph at the end of the document.
A document that ends in a table, an image or a code block has nowhere to put a caret after it, and the only way to write below it is to know the trick. So whenever the last block is anything else, an empty paragraph is added after it — its own transaction, grouped by undo with whatever caused it.
1 · Install
One package for every extension · there is no @matrajs/trailingNode to install.
npm i @matrajs/core2 · 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, trailingNode } from '@matrajs/core'
const editor = createEditor({
extensions: [document, paragraph, text, trailingNode({ … })],
element: document.querySelector('#editor'),
})3 · Use it
Nothing to call · this one works once it is in the array. Always a paragraph at the end of the document.
Options
trailingNode is a function · call it with an options object.
| Option | Type | What it does |
|---|---|---|
node | string | The node kept at the end. Default `paragraph`. |