List

List block (list). Renders as <ul> or <ol> with list-item children. JSON data: { items: [{ content, items? }], numbered?: boolean, ...common }.

Type: list · Class: ListBlock

Access:

app.block.get()
app.blocks.findByEl(el)
app.blocks.create(type)

App code:

const block = app.block.get();

Plugin:

const block = this.app.block.get();

getData#

Returns the serializable JSON data object for this block, including type-specific fields.

Returns: object

block.getData();

getItemBlocks#

Returns item blocks.

Parameters:

  • types (Array) — block types filter

Returns: Array

block.getItemBlocks(/* … */);

getItems#

Returns serialized list items as an array of { content, items? } objects, including nested sublists.

Returns: Array<object>

block.getItems();

update#

Applies common fields. May switch <ul>/<ol> via numbered or type, and rebuilds all items when items is an array.

Parameters:

  • data (object) — object with the keys below
    • numbered (boolean) — true → <ol>, false → <ul>
    • type (string) — 'ul' or 'ol' (alternative to numbered)
    • items (Array) — replaces list items; each item is { content: string, items?: Array } (nested sublists via items)
    • id, classname, styles, attrs, … — common block fields (see Common update)

Returns: void

block.update({ numbered: true });

block.update({ type: 'ul' });

block.update({
    items: [
        { content: 'First' },
        { content: 'Second', items: [{ content: 'Nested' }] }
    ]
});

block.update({
    numbered: true,
    items: [{ content: 'Step one' }, { content: 'Step two' }]
});

getTopLevelListRoot#

Walks up from this block's element and returns the outermost <ul> or <ol> ancestor inside the editor (including nested lists).

Parameters:

  • editable (HTMLElement | null) — optional editor root that bounds the walk (defaults to app.host.getEditor())

Returns: HTMLElement | null

block.getTopLevelListRoot();
block.getTopLevelListRoot(app.host.getEditor());