Every extension
field
A blank in a template.
`{{name}}` in a letter is a promise that something will be put there, and as text it is a promise the editor cannot keep: it can be half-deleted into `{{nam}}`, spell-checked, bolded from the middle, and nothing will notice until the letter goes out with braces in it. As an atom it is one thing — the caret steps over it, backspace removes all of it — and filling it is a command rather than a search and replace.
`fillFields` fills the fields in the editor; `fillFieldsIn` does the same to a document as JSON, with no editor and no DOM, which is where a mail merge actually runs.
Adding it
import { createEditor, document, paragraph, text, field } from '@matrajs/core'
const editor = createEditor({
extensions: [document, paragraph, text, field],
element: document.querySelector('#editor'),
})
There is no separate package · field is already in @matrajs/core, and an extension you do not import is not in your bundle. document, paragraph and text are the floor every document needs.
Commands
-
editor.commands.insertField() -
editor.commands.fillFields()
Attributes
-
name -
label
HTML
-
Parses
span[data-field] -
Renders
span