+ var current_anchor = sel.anchorNode;
+ if (this.classList.contains('on')) { // toggle off
+ if (this.action_block.subtag) {
+ // unwrap
+ var main_node = get_contenteditable_subnode(current_anchor);
+ $(current_anchor).detach().insertAfter(main_node);
+ } else {
+ document.execCommand('formatBlock', false, 'p');
+ current_anchor = sel.anchorNode;
+ }
+ } else {
+ action = this.action_block.subtag || this.action_block.tag;
+ if (this.action_block.subtag) {
+ // enclose current tag into a new parent;
+ var new_parent = document.createElement(this.action_block.tag);
+ new_parent.className = this.action_block.klass;
+ $(current_anchor).wrap(new_parent);
+ } else {
+ document.execCommand('formatBlock', false, this.action_block.tag);
+ sel.anchorNode.className = this.action_block.klass;
+ current_anchor = sel.anchorNode;
+ }