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.app.api('module.block.format', 'h1');
or external call:
$R('#content', 'module.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.app.api('module.block.format', obj);
// or external call:
$R('#content', 'module.block.format', obj);
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.app.api('module.block.add', args);
this.app.api('module.block.add', args, ['p', 'h1']);
// or external call:
$R('#content', 'module.block.add', args);
$R('#content', 'module.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.app.api('module.block.toggle', args);
this.app.api('module.block.toggle', args, ['p', 'h1']);
// or external call:
$R('#content', 'module.block.toggle', args);
$R('#content', 'module.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.app.api('module.block.set', args);
this.app.api('module.block.set', args, ['p', 'h1']);
// or external call:
$R('#content', 'module.block.set', args);
$R('#content', 'module.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.app.api('module.block.remove', args);
this.app.api('module.block.remove', args, ['p', 'h1']);
// or external call:
$R('#content', 'module.block.remove', args);
$R('#content', 'module.block.remove', args, ['p', 'h1']);
clearformat
Remove all attributes from the selected block tags.
this.app.api('module.block.clearformat');
or external call:
$R('#content', 'module.block.clearformat');
clearstyle
Remove the style attribute from the selected block tags.
this.app.api('module.block.clearstyle');
or external call:
$R('#content', 'module.block.clearstyle');
clearclass
Remove the class attribute from the selected block tags.
this.app.api('module.block.clearclass');
or external call:
$R('#content', 'module.block.clearclass');
clearattr
Remove all attributes (excepting class and style) from the selected block tags.
this.app.api('module.block.clearattr);
or external call:
$R('#content', 'module.block.clearattr');