Heading

Editable heading block (heading). Renders as <h1>–<h6> per level (default 2). JSON data: { level: number, content: string, ...common }.

Type: heading · Class: HeadingBlock

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();

getLevel#

Returns the heading level (1–6) stored on the block instance.

Returns: number

block.getLevel();

getData#

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

Returns: object

block.getData();

update#

Applies common fields. When level differs from the current level, replaces the root tag (h1–h6). When content is set, syncs the heading inner HTML.

Parameters:

  • data (object) — object with the keys below
    • level (number) — heading level 1–6 (changes the tag, e.g. h2 → h3)
    • content (string) — inner HTML of the heading
    • id, classname, styles, attrs, … — common block fields (see Common update)

Returns: void

block.update({ level: 3 });

block.update({ content: 'Section title' });

block.update({ level: 2, content: '<em>Revised</em> heading' });