Browse Source

Add run to RTE

pull/5649/head
Artur Arseniev 3 years ago
parent
commit
b580923242
  1. 18
      src/rich_text_editor/index.ts

18
src/rich_text_editor/index.ts

@ -29,6 +29,7 @@
* ## Methods
* * [add](#add)
* * [get](#get)
* * [run](#run)
* * [getAll](#getall)
* * [remove](#remove)
* * [getToolbarEl](#gettoolbarel)
@ -325,6 +326,23 @@ export default class RichTextEditorModule extends Module<RichTextEditorConfig &
return action;
}
/**
* Run action command.
* @param action Action to run
* @example
* const action = rte.get('bold');
* rte.run(action) // or rte.run('bold')
*/
run(action: string | RichTextEditorAction) {
const rte = this.globalRte;
const actionRes = isString(action) ? this.get(action) : action;
if (rte && actionRes) {
actionRes.result(rte, actionRes);
rte.updateActiveActions();
}
}
/**
* Get the toolbar element
* @return {HTMLElement}

Loading…
Cancel
Save