Extensions
floatingMenu
A menu that appears on an empty line.
The "what goes here" affordance: a plus in the margin, or a row of block types beside the caret. Shown when the caret sits in an empty top-level paragraph in a focused editor, and nowhere else.
1 · Install
One package for every extension · there is no @matrajs/floatingMenu 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, floatingMenu } from '@matrajs/core'
const editor = createEditor({
extensions: [document, paragraph, text, floatingMenu({ … })],
element: document.querySelector('#editor'),
})3 · Use it
Nothing to call · this one works once it is in the array. A menu that appears on an empty line.
Options
floatingMenu is a function · call it with an options object.
| Option | Type | What it does |
|---|---|---|
element required | HTMLElement | — |
shouldShow | (editor: Editor) => boolean | When to show it. Default: the caret is in an empty top-level paragraph and the editor has focus. |
placement | 'start' | 'left' | At the start of the line, or in the margin to its left. Default `start`. |
offset | number | — |