diff --git a/src/dom_components/view/ComponentTextView.js b/src/dom_components/view/ComponentTextView.js index 9a1fd14bb..92905daa1 100644 --- a/src/dom_components/view/ComponentTextView.js +++ b/src/dom_components/view/ComponentTextView.js @@ -69,13 +69,28 @@ export default ComponentView.extend({ this.toggleEvents(); }, + /** + * get content from RTE + * @return string + */ + getContent() { + const { rte } = this; + let content = ''; + if(rte.activeRte && typeof rte.activeRte.getContent === 'function') { + content = rte.activeRte.getContent(); + } else { + content = this.getChildrenContainer().innerHTML; + } + return content; + }, + /** * Merge content from the DOM to the model */ syncContent(opts = {}) { const { model, rte, rteEnabled } = this; if (!rteEnabled && !opts.force) return; - const content = this.getChildrenContainer().innerHTML; + const content = this.getContent(); const comps = model.components(); const contentOpt = { fromDisable: 1, ...opts }; comps.length && comps.reset(null, opts); @@ -162,8 +177,9 @@ export default ComponentView.extend({ while (el) { el.draggable = enable ? !1 : !0; + // Note: el.parentNode is sometimes null here el = el.parentNode; - el.tagName == 'BODY' && (el = 0); + el && el.tagName == 'BODY' && (el = 0); } } }