Browse Source

Add remove method to RichTextEditor module

pull/415/head
Artur Arseniev 9 years ago
parent
commit
14423c21b9
  1. 23
      src/rich_text_editor/index.js

23
src/rich_text_editor/index.js

@ -2,6 +2,7 @@
* * [add](#add)
* * [get](#get)
* * [getAll](#getall)
* * [remove](#remove)
* * [getToolbarEl](#gettoolbarel)
*
* This module allows to customize the toolbar of the Rich Text Editor and use commands from the HTML Editing APIs.
@ -167,6 +168,28 @@ module.exports = () => {
return globalRte.getActions();
},
/**
* Remove the action from the toolbar
* @param {string} name
* @return {Object} Removed action
* @example
* const action = rte.remove('bold');
* // {name: 'bold', ...}
*/
remove(name) {
const actions = this.getAll();
const action = this.get(name);
if (action) {
const btn = action.btn;
const index = actions.indexOf(action);
btn.parentNode.removeChild(btn);
actions.splice(index, 1);
}
return action;
},
/**
* Get the toolbar element
* @return {HTMLElement}

Loading…
Cancel
Save