$block #

Access to the Dom of the block element.

var html = this.app.block.$block.html();

get #

Get instance of the active block.

var instance = this.app.block.get();

set #

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

Set the active block.

this.app.block.set(element);
this.app.block.set(element, 'start');
this.app.block.set(element, 'end');

unset #

Unset the active block.

this.app.block.unset();

remove #

  • traverse (optional) Boolean
    • Turn off the selection of the parent element of the removed block.

Remove the active block.

this.app.block.remove();

duplicate #

Duplicate the active block.

this.app.block.duplicate();

next #

Get the next block element of the active block.

var $el = this.app.block.next();

prev #

Get the previous block element of the active block.

var $el = this.app.block.prev();

create #

Create a block instance depend on the plaintext setting. If the plaintext markup false the method creates a paragraph block otherwise creates a text block.

var instance = this.app.block.create();

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

var type = 'layer';
var instance = this.app.create('block.' + type);

add #

Arguments
instance ObjectInstance of the block.
position (optional)StringAdding position.
active (optional) BooleanSet the block active.

Add an instance of the block to content.

var type = 'layer';
var instance = this.app.create('block.' + type);

// add a block after or before the active element
// depends on the caret position
this.app.block.add(instance, 'after');
this.app.block.add(instance, 'before');

// add a block to the beginning of the editor content
this.app.block.add(instance, 'start');

// do not set the added block active
this.app.block.add(instance, 'after', false);

change #

Arguments
instance ObjectInstance of the block.
active (optional) BooleanSet the block active.

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

var type = 'layer';
var instance = this.app.create('block.' + type);

this.app.block.change(instance);

// do not set the new block active
this.app.block.change(instance, false);

instance.isEmpty #

Check if the active block empty.

var instance = this.app.block.get();
var is = instance.isEmpty();

instance.isEditable #

Check if the active block editable.

var instance = this.app.block.get();
var is = instance.isEditable();

instance.isControls #

Check if the active block has the control bar.

var instance = this.app.block.get();
var is = instance.isControls();

instance.isFirstLevel #

Check if the active block is the first level element in the content.

var instance = this.app.block.get();
var is = instance.isFirstLevel();

instance.isSelectedAll #

Check if the entire contents of the active block is selected.

var instance = this.app.block.get();
var is = instance.isSelectedAll();

instance.isStart #

Check if the caret at the beginning of the active editable block.

var instance = this.app.block.get();
var is = instance.isStart();

instance.isEnd #

Check if the caret at the end of the active editable block.

var instance = this.app.block.get();
var is = instance.isEnd();

instance.getType #

Gets the type of the active block.

var instance = this.app.block.get();
var type = instance.getType();

instance.getTag #

Gets the tag of the active block.

var instance = this.app.block.get();
var tag = instance.getTag();

instance.empty #

Makes the active block empty.

var instance = this.app.block.get();
instance.empty();

instance.format #

Formats the active block to the specified type and tag.

var instance = this.app.block.get();
instance.format({ tag: 'h1', block: 'heading' });

This method supports the following tags and blocks:

  • paragraph (p)
    • formats to the text block if the plaintext markup is turned on.
  • heading (h1..h2)
  • list (ul/ol)