Extensions
focus
A class on the block the caret is in.
What a focus mode dims everything else against, and what a block toolbar anchors to. A decoration rather than an attribute, so the document never knows which block was being looked at.
1 · Install
One package for every extension · there is no @matrajs/focus 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, focus } from '@matrajs/core'
const editor = createEditor({
extensions: [document, paragraph, text, focus({ … })],
element: document.querySelector('#editor'),
})3 · Use it
Nothing to call · this one works once it is in the array. A class on the block the caret is in.
Options
focus is a function · call it with an options object.
| Option | Type | What it does |
|---|---|---|
className | string | The class put on the block the caret is in. Default `has-focus`. |
ancestors | boolean | Also mark every ancestor block — the list around the item. Default false. |