Documentation / API Reference


get #

Returns instance of selected block.

let instance =;

See more about Block.Instance API.

set #

element Node, Element, DomElement of the block
caret (optional)StringPlace the caret at the beginning or end of the editable block

Sets the selected block.;, 'start');, 'end');

unset #

Unsets the selected block.;

remove #

  • params Object

Removes the selected block.;

Turn off the selection of the next/previous element of the removed block.{ traverse: false });

duplicate #

Duplicates the selected block.;

create #

Creates an empty paragraph block.

let instance =;

Alternative, create a block by the type with app.create, for example:

let type = 'text';
let instance ='block.' + type);

change #

instance ObjectInstance of the block.

Removes the selected block and adds a new one to its place.

let type = 'heading';
let instance ='block.' + type);;

insert #

params Object

This method adds a block depending on the caret or the specified position.

// create block
let instance ='block.text');

// add{ instance: instance });

By default, the caret will be placed at the end of the added block. To set the caret to the beginning, you can pass the parameter caret with the value start.

// create block
let $source = this.dom('<p>').html('Hello world!');
let instance ='block.text', $source);

// add and set caret at start{ instance: instance, caret: 'start' });

The method automatically detects the position of the block to be added, depending on what is currently selected in the content. You can manually specify a position, for example to add a new block before the current one.

// create block
let instance ='block.text');

// add before selected block{ instance: instance, position: 'before' });

These options are available for specifying the position:

  • before — before the current block
  • after — after the current block

moveUp #

Moves the selected block up.;

moveDown #

Moves the selected block down.;

getData #

Returns properties of the selected block.

let data =;

setData #

Sets the properties in the selected block.{
    id: 'myid'