API / @aionbuilders/nabu

RegionsExtension

Function Stability: stable

Regions extension factory (ADR 016, data model of ADR 018): structure a text in divisions. Installs the region container block (its header is its title, its body is its children), the placement / nesting normalizer, and the reactive registry (nabu.regions, also Regions.get(nabu)).

Related guide: Regions →

It also declares the region commands (region:split on Mod-Enter, the protected merges on Backspace / Delete, and the keyless region:insert / move / promote / demote / next / prev / parent: see commands.js) and vetoes any silent text merge into, out of or across a title (onBeforeMerge).

Signature

TypeScript
import { RegionsExtension } from '@aionbuilders/nabu';
TypeScript
function RegionsExtension(options?: object): Extension

Parameters

Parameters of RegionsExtension
ParameterTypeDefaultDescription
optionsoptionalobject{}

types: the region types of the integrator (see types.js: level, label, numbering, fields). Without it, a generic section division over three levels is declared, as the types section-1, section-2, section-3. Throws on an invalid declaration. messages: texts of the commands and of the hold prompt (see messages.js), English by default.

options.messagesoptionalRegionMessagesn/an/a
options.typesoptionalRecord<string, RegionTypeInit>n/an/a

Returns

Extension

Examples

TypeScript
RegionsExtension({
  types: {
    part:    { level: 1, label: 'Part {index}' },
    chapter: { level: 2, label: 'Chapter {index}', numbering: 'document' },
    scene:   { level: 3, fields: { pov: 'text' } },
  },
})

Source: src/lib/blocks/region/region.extension.js:64