From 254f4dee3f3ca6367d0ed4742cdf3904e2deab4c Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Sat, 18 Apr 2020 00:18:39 +0200 Subject: [PATCH] Add getModelsFromEl for reference --- src/dom_components/view/ComponentTextView.js | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/dom_components/view/ComponentTextView.js b/src/dom_components/view/ComponentTextView.js index 438f5eef4..f5223e49d 100644 --- a/src/dom_components/view/ComponentTextView.js +++ b/src/dom_components/view/ComponentTextView.js @@ -137,6 +137,27 @@ export default ComponentView.extend({ } }, + getModelsFromEl(el) { + const result = []; + const children = (el || this.el).childNodes; + + for (let index = 0; index < children.length; index++) { + const child = children[index]; + const model = child.__cashData && child.__cashData.model; + + if (model) { + model.components = this.getModelsFromEl(child); + if (model.get('content')) { + model.attributes.content = child.textContent; + } + // TODO add attributes; + result.push(model); + } + } + + return result; + }, + /** * Callback on input event * @param {Event} e