Skip to content

WYSIWYG editor ​

A rich-text field: formatted text that is edited in place, as a whole.

entityelements-wysiwygfield--defaultOpen in Storybook ↗

When to use ​

  • Long, formatted text: descriptions, transcriptions, annotations.
  • Text that tags other records inline, such as people or places.

When not to use ​

  • Short plain text: use a field row with a text input.
  • Titles and identifiers: they are plain text.

Anatomy ​

  1. Label line: the label, then what the field offers: the on-screen keyboard button (while editing, when the field has keyboard layouts), the transliteration toggle (at rest), the language picker, and the actions. At rest the action is a pencil in --color-text-subtle; while editing it is ✓ (commit) and × (secondary). They sit on the label line so they stay in view however long the text is.
  2. Toolbar (while editing): the buttons the field's extensions provide. The full set is Paragraph, H1–H6, bullet list, ordered list, code block, Blockquote, horizontal rule, Hard break, B and I. A field with tagging adds Tag or a button per tagging flow. The button for the current format is filled with the accent colour.
  3. Content: the editor, with a --color-border-default border on --radius-input. Editable content gets the --color-surface-editable-hover wash on hover.
  4. Under the content (while editing): an error message in --color-danger when saving fails, and the hint Ctrl+Enter saves · Esc cancels in --text-hint, --color-text-muted.

Variants ​

VariantWhereWhat changes
Fieldin a panel's field listlabel line like a field row, content below
Panela field shown as its own panela header with the label as title and the actions on the right; a taller editor
Line numberstranscriptionsa number before each paragraph
Multilingualfields with a value per languagea language picker; while editing, a chip names the language being edited
entityelements-wysiwygfield--panelOpen in Storybook ↗

Transliteration shows the text in another script, such as Latin for Arabic text. It only changes the view: it is hidden while editing, and editing starts from the stored text.

The on-screen keyboard inserts characters at the cursor, for scripts and diacritics a regular keyboard lacks. Which layouts it offers is configured per field.

States ​

StateWhat you seeTrigger
Resting, editablecontent and a pencil; hover wash on the content—
Resting, read-onlycontent onlyno edit permission, or the field is locked
Editingtoolbar, ✓ and ×, the hint; the editor has a focus borderthe pencil, or a click on the content
Savinga spinner in place of ✓ and ×✓, Ctrl+Enter, or leaving a changed field
ErrorSaving failed, try again under the content; the editor stays openthe save fails
Savedread-only again; Saved is announcedthe save succeeds
entityelements-wysiwygfield--statesOpen in Storybook ↗
entityelements-wysiwygfield--editingOpen in Storybook ↗
entityelements-wysiwygfield--savingOpen in Storybook ↗
entityelements-wysiwygfield--save-failedOpen in Storybook ↗

Keyboard & accessibility ​

KeyWhile editing
Enternew paragraph
Ctrl/Cmd+Entersaves
Escapecancels and restores the text from before editing
Ctrl/Cmd+B, Ctrl/Cmd+Ibold, italic
  • Leaving the field saves it: a click outside, or Tab to something outside. An unchanged editor just closes. The toolbar, tag suggestions and the field's own dialogs count as inside.
  • A click on a tagged record opens that record instead of starting editing, and selecting text doesn't start editing either.
  • Only one field is edited at a time; opening another one saves this one first.
  • The pencil is named {label}, edit; ✓ and × are named Save {label} and Cancel {label}.
  • A save is announced in a role="status" region; an error is a role="alert".

Content ​

  • Keep the toolbar to what the field needs: configure only the extensions it uses.
  • Saving sends only this field, in the language being edited.
  • Translation keys: inline-edit.save, inline-edit.cancel, inline-edit.edit-field, inline-edit.hint-textarea, inline-edit.saved, inline-edit.save-failed.

Field row · Inline editor · Text input · Tooltip

Powered by Elody - Open Source Semantic Data Platform