Extension
A named bundle of editor behaviour (see ExtensionInit); the built-in blocks and behaviours are extensions. Build one with
extension(name, init) and pass it to createEditor({ extensions }).
Related guide: Extensions →
Import
import { Extension } from '@aionbuilders/nabu/extend';Constructor
new Extension(name: string, init?: ExtensionInit)| Parameter | Type | Default | Description |
|---|---|---|---|
name | string | n/a | n/a |
initoptional | ExtensionInit | {} | n/a |
Properties
actions
actions: Record<string, (nabu: Nabu, data: any, topic: string) => any>Handlers of the action bus by topic (nabu.exec(topic, data)); several extensions may declare the same topic and all run.
block
block: typeof Block | undefinedThe block class this extension registers.
commandContext
commandContext: ((nabu: Nabu, ctx: CommandContext) => void | Record<string, any>) | undefinedContributes facts to the context given to command when / run functions.
commands
commands: Record<string, CommandDef>The commands this extension declares, by id (see CommandDef).
component
component: Component<any, any, string> | undefinedThe Svelte component that renders the extension's block.
defaultBlock
defaultBlock: booleanWhether block is the editor's default text block.
hooks
hooks: Partial<ExtensionHooks>The hooks of the extension, by name (see ExtensionHooks).
inputRules
inputRules: InputRule[]Text-replacement rules applied while typing (see InputRule).
loroTextStyles
loroTextStyles: Record<string, { expand: 'none' | 'after' | 'before' | 'both' }>Loro text style configuration this extension needs for its marks.
name
name: stringThe extension's name (unique in an editor).
pasteFileHandlers
pasteFileHandlers: PasteFileHandler[]Handlers that make a block of a pasted file (see PasteFileHandler).
pasteInterpreters
pasteInterpreters: PasteInterpreter[]Interpreters of clipboard formats (see PasteInterpreter).
serializers
serializers: Record<string, (nabu: Nabu) => any>Serializers by format name, run by nabu.serialize(format).
slashCommands
slashCommands: SlashCommand[]Entries this extension adds to the slash menu.
Source: src/lib/utils/extensions.js:205