Regions
Document-level reactive registry of the regions (ADR 018 §3.4): a pure, derived view over the TREE (stores nothing in
Loro). Lazy and cheap: ONE pass over the root blocks and the bodies of the regions builds everything, and it only re-runs
when the STRUCTURE changes (a region inserted / moved / deleted / retyped, a child added to a region body), not when
text is typed. Obtain it with Regions.get(nabu); RegionsExtension also installs it as nabu.regions.
Related guide: Regions →
Import
import { Regions } from '@aionbuilders/nabu';Constructor
new Regions(nabu: Nabu, config: RegionsConfig)| Parameter | Type | Description |
|---|---|---|
nabu | Nabu | n/a |
config | RegionsConfig | n/a |
Static members
static get()
get(nabu: Nabu): Regions| Parameter | Type | Description |
|---|---|---|
nabu | Nabu | n/a |
Properties
caret
caret: Region | nullThe region that shows the caret: the DEEPEST region holding the selection anchor (a title counts), only while the editor has
the focus. null otherwise. Reactive; computed once for all the regions (each Region.svelte compares itself to it).
config readonly
readonly config: RegionsConfigThe resolved configuration (declared types).
count readonly
readonly count: numberThe number of regions.
list readonly
readonly list: Region[]Every region, in document order (pre-order of the tree).
preamble readonly
readonly preamble: PreambleThe root blocks before the first root region (the whole document when there is no region). They are outside any region.
tree readonly
readonly tree: Region[]The top-level regions; each one holds its children.
Methods
at()
at(target?: Block | { block: Block } | null): Region | nullThe deepest region containing a block: its nearest region ancestor, the block itself when it is a region. target is a
block or an { block } position (as the selection offers); omitted = the block holding the selection anchor. null
outside any region (the preamble) or when there is nothing to resolve.
| Parameter | Type | Description |
|---|---|---|
targetoptional | Block | { block: Block } | null | n/a |
next()
next(region: Region): Region | nullThe region after this one, in document order (a sub-region, then the following sibling…).
| Parameter | Type | Description |
|---|---|---|
region | Region | n/a |
of()
of(block: string | Block): Region | nullThe region of a region block.
| Parameter | Type | Description |
|---|---|---|
block | string | Block | n/a |
parentOf()
parentOf(region: Region): Region | null| Parameter | Type | Description |
|---|---|---|
region | Region | n/a |
prev()
prev(region: Region): Region | nullThe region before this one, in document order.
| Parameter | Type | Description |
|---|---|---|
region | Region | n/a |
start()
start(): voidSystem hook (nabu.systems, called when the editor mounts): follows the focus of the editor, for Regions#caret.
Idempotent.
stop()
stop(): voidSystem hook: stops following the focus.
Source: src/lib/blocks/region/regions.svelte.js:110