Documentation

Block.Instance

getBlock

Returns the DOM element of the block.

var instance = this.app.block.get();
var $block = instance.getBlock();
$block.css('color', 'red');

getType

Returns the type of the block.

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

getTag

Returns the tag of the block.

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

getHtml

Returns html of the block.

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

getData

Returns properties of the block.

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

getId

Returns id attribute of the block.

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

getNext

Returns the instance of the next block after the current one.

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

getPrev

Returns the instance of the previous block before the current one.

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

getParent

Returns the instance of the parent block of the current one.

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

setSelectAll

Selects all content of the block if it is editable.

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

setData

Sets the properties in the block.

var instance = this.app.block.get();
instance.setData({
    id: 'myid'
});

setHtml

Sets html to the block.

var instance = this.app.block.get();
instance.setHtml('my html');

setId

Sets the ID attribute to the block.

var instance = this.app.block.get();
instance.setId('myid');

setEmpty

Makes the block empty.

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

isType

Arguments
type String, Array

Checks the type of the block.

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

if (instance.isType('paragraph')) { ... }
if (instance.isType(['paragraph', 'heading'])) { ... }

isEmpty

Checks if the block empty.

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

isEditable

Checks if the block editable.

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

isFirstLevel

Checks if the block is the first level element in the content.

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

isAllSelected

Checks if the entire contents of the block is selected.

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

isCaretStart

Checks if the caret at the beginning of the editable block.

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

isCaretEnd

Checks if the caret at the end of the editable block.

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