From f026afacd6a2179053fe8b88153b278d84e6e4aa Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Wed, 28 Jul 2021 07:29:40 +0200 Subject: [PATCH] Add `editor.getEditing` method --- src/editor/index.js | 14 ++++++++++++++ src/editor/model/Editor.js | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/src/editor/index.js b/src/editor/index.js index ba247eb9d..1620b6e02 100644 --- a/src/editor/index.js +++ b/src/editor/index.js @@ -416,6 +416,20 @@ export default (config = {}) => { return this; }, + /** + * Returns, if active, the Component enabled in rich text editing mode. + * @returns {Component|null} + * @example + * const textComp = editor.getEditing(); + * if (textComp) { + * console.log('HTML: ', textComp.toHTML()); + * } + */ + getEditing() { + const res = em.getEditing(); + return (res && res.model) || null; + }, + /** * Set device to the editor. If the device exists it will * change the canvas to the proper width diff --git a/src/editor/model/Editor.js b/src/editor/model/Editor.js index 79c475d6d..87a55e380 100644 --- a/src/editor/model/Editor.js +++ b/src/editor/model/Editor.js @@ -807,6 +807,10 @@ export default Backbone.Model.extend({ .attr(this.attrsOrig); }, + getEditing() { + return this.get('editing'); + }, + setEditing(value) { this.set('editing', value); return this;