Documentation
Block
format #
value | String Object |
Returns: Array
Apply formatting for block tags, and also set classes, attributes, and styles for them.
If the value
is a string with a tag, then all the selected block tags of the first level and in the tables will be converted to the specified tag, all attributes are keeping.
this.block.format('h1');
If the value
is the object, all selected block tags of the first level and in the tables will be converted to the specified tag with the styles, attributes, and classes that are listed in the object.
Object's arguments:
tag | String |
tag that will formatted block tags |
class | String |
class or classes (space separated) |
style | Object |
style object |
attr | Object |
attribute object |
type | String |
set (by default) - remove all existing values (classes, attributes or style) and set specified values add - add a value without removing the already existing values toggle - if a value exists, remove it, if not add the specified one remove - remove specified values |
var obj = { tag: 'h1' };
var obj = { tag: 'h1', class: 'my-class' }
var obj = { tag: 'h1', class: 'my-class-1 my-class-2' };
var obj = { tag: 'h1', class: 'my-class', style: { color: 'red' } };
var obj = { tag: 'h1', style: { color: 'red', 'font-style': 'italic' } };
var obj = { tag: 'h1', class: 'my-class', attr: { 'data-name': 'my-header' } };
var obj = { tag: 'h1', class: 'my-class', type: 'toggle' };
this.block.format(obj);
clearFormat #
tags (optional) | Array |
Remove all classes, attributes, and styles from the selected block tags. You can specify the argument for which tags to apply the removing of attributes.
this.block.clearFormat();
this.block.clearFormat(['p', 'h1']);
clearStyle #
tags (optional) | Array |
Remove styles from the selected block tags. You can specify the argument for which tags to apply the removing of styles.
this.block.clearStyle();
this.block.clearStyle(['p', 'h1']);
clearClass #
tags (optional) | Array |
Remove classes from the selected block tags. You can specify the argument for which tags to apply the removing of classes.
this.block.clearClass();
this.block.clearClass(['p', 'h1']);
clearAttr #
tags (optional) | Array |
Remove attributes from the selected block tags. You can specify the argument for which tags to apply the removing of attributes.
this.block.clearAttr();
this.block.clearAttr(['p', 'h1']);
add #
value | Object | |
tags (optional) | Array |
Add values without removing the already existing values. You can set the array of tags to which will be applied the formatting.
var args = {
style: { color: 'red', 'font-style': 'italic' }
class: 'my-class-1 my-class-2'
attr: { 'data-name': 'my-name' }
};
this.block.add(args);
this.block.add(args, ['p', 'h1']);
toggle #
value | Object | |
tags (optional) | Array |
If values exists, remove them, if not add the specified ones. You can set the array of tags to which will be applied the formatting.
var args = {
style: { color: 'red', 'font-style': 'italic' }
class: 'my-class-1 my-class-2'
attr: { 'data-name': 'my-name' }
};
this.block.toggle(args);
this.block.toggle(args, ['p', 'h1']);
set #
value | Object | |
tags (optional) | Array |
Remove all existing values (classes, attributes or style) and set specified values. You can set the array of tags to which will be applied the formatting.
var args = {
style: { color: 'red', 'font-style': 'italic' }
class: 'my-class-1 my-class-2'
attr: { 'data-name': 'my-name' }
};
this.block.set(args);
this.block.set(args, ['p', 'h1']);
remove #
value | Object | |
tags (optional) | Array |
Remove specified values. You can set the array of tags to which will be applied the formatting.
var args = {
style: 'color font-style'
class: 'my-class-1 my-class-2'
attr: 'data-name data-toggle'
};
this.block.remove(args);
this.block.remove(args, ['p', 'h1']);