diff --git a/src/dom_components/view/ComponentTextView.js b/src/dom_components/view/ComponentTextView.js index 853fffabe..c983f366a 100644 --- a/src/dom_components/view/ComponentTextView.js +++ b/src/dom_components/view/ComponentTextView.js @@ -71,13 +71,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); @@ -161,8 +176,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); } } }