API / @aionbuilders/nabu/extend

Extension

Class Stability: stable

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

TypeScript
import { Extension } from '@aionbuilders/nabu/extend';

Constructor

TypeScript
new Extension(name: string, init?: ExtensionInit)
Parameters of the constructor
ParameterTypeDefaultDescription
namestringn/an/a
initoptionalExtensionInit{}n/a

Properties

actions

TypeScript
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

TypeScript
block: typeof Block | undefined

The block class this extension registers.

commandContext

TypeScript
commandContext: ((nabu: Nabu, ctx: CommandContext) => void | Record<string, any>) | undefined

Contributes facts to the context given to command when / run functions.

commands

TypeScript
commands: Record<string, CommandDef>

The commands this extension declares, by id (see CommandDef).

component

TypeScript
component: Component<any, any, string> | undefined

The Svelte component that renders the extension's block.

defaultBlock

TypeScript
defaultBlock: boolean

Whether block is the editor's default text block.

hooks

TypeScript
hooks: Partial<ExtensionHooks>

The hooks of the extension, by name (see ExtensionHooks).

inputRules

TypeScript
inputRules: InputRule[]

Text-replacement rules applied while typing (see InputRule).

loroTextStyles

TypeScript
loroTextStyles: Record<string, { expand: 'none' | 'after' | 'before' | 'both' }>

Loro text style configuration this extension needs for its marks.

name

TypeScript
name: string

The extension's name (unique in an editor).

pasteFileHandlers

TypeScript
pasteFileHandlers: PasteFileHandler[]

Handlers that make a block of a pasted file (see PasteFileHandler).

pasteInterpreters

TypeScript
pasteInterpreters: PasteInterpreter[]

Interpreters of clipboard formats (see PasteInterpreter).

serializers

TypeScript
serializers: Record<string, (nabu: Nabu) => any>

Serializers by format name, run by nabu.serialize(format).

slashCommands

TypeScript
slashCommands: SlashCommand[]

Entries this extension adds to the slash menu.

Source: src/lib/utils/extensions.js:205