API / @aionbuilders/nabu

NabuEditor

Component Stability: stable
  • Any other attribute (id, class, style, aria-describedby, inputmode, enterkeyhint, autocapitalize, data-*...) goes to the root element, and class is added to nabu-editor. The editor's own attributes and handlers come after them and always win: contenteditable, role, spellcheck, lang, translate, aria-label, aria-labelledby, data-nabu-* and every on* handler cannot be overridden (use label / labelledby, readonly, and the engine options). Events bubble: listen to them on a parent element of the editor.

Related guide: Your first editor →

Usage

Svelte
<script>
  import { NabuEditor } from '@aionbuilders/nabu';
</script>

<NabuEditor />

Props

Props of NabuEditor
PropTypeDefaultDescription
engineoptionalNabunew Nabu()

The editor this component works on (a Nabu instance).

labeloptionalstringn/a

the accessible name of the editor (aria-label on the contenteditable root), e.g. "Chapter text".

labelledbyoptionalstringn/a

the id of the element that names it (aria-labelledby), for a visible <label>. Wins over label for assistive technology when both are set. No role is ever set on an editable root: it would flatten the headings inside.

readonlyoptionalboolean } & HTMLAttributes<HTMLDivElementn/a

show the document without letting anyone edit it. Reactive (toggle it live). When omitted, the editor follows engine.readonly (the readonly option of the engine); when given, it sets engine.readonly.

Source: src/lib/blocks/Nabu.svelte