From 16675cbc378f1188a245165a1476571f1aad22b8 Mon Sep 17 00:00:00 2001 From: Ivan Usenkov Date: Thu, 26 Sep 2019 15:58:55 +0300 Subject: [PATCH 1/2] get content from RTE --- src/dom_components/view/ComponentTextView.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/dom_components/view/ComponentTextView.js b/src/dom_components/view/ComponentTextView.js index 853fffabe..e48316d9c 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); From c2ecf4be86eb042cb744dfce433ef86d5311ca62 Mon Sep 17 00:00:00 2001 From: Tom Sherman Date: Thu, 26 Sep 2019 16:51:05 +0100 Subject: [PATCH 2/2] Guard against parentNode being undefined Fixes #2294 --- src/dom_components/view/ComponentTextView.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/dom_components/view/ComponentTextView.js b/src/dom_components/view/ComponentTextView.js index 853fffabe..8a4393b27 100644 --- a/src/dom_components/view/ComponentTextView.js +++ b/src/dom_components/view/ComponentTextView.js @@ -161,8 +161,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); } } }