diff --git a/src/editor/config/config.js b/src/editor/config/config.js index bd0786b70..a50c31207 100644 --- a/src/editor/config/config.js +++ b/src/editor/config/config.js @@ -96,6 +96,9 @@ module.exports = { // Ending tag for variable inside scripts in Components tagVarEnd: ' ]}', + // Remove empty text nodes when parsed, unless they contain a space + removeEmptyTextNodes: true, + // Return JS of components inside HTML from 'editor.getHtml()' jsInHtml: true, diff --git a/src/editor/index.js b/src/editor/index.js index f5b71ecf8..beb2fc721 100644 --- a/src/editor/index.js +++ b/src/editor/index.js @@ -83,6 +83,7 @@ * @param {Object} [config.domComponents={}] Components configuration, see the relative documentation * @param {Object} [config.panels={}] Panels configuration, see the relative documentation * @param {Object} [config.showDevices=true] If true render a select of available devices inside style manager panel + * @param {Boolean} [config.removeEmptyTextNodes=true] If true, removes empty text nodes when parsed, unless they contain a space * @param {string} [config.defaultCommand='select-comp'] Command to execute when no other command is running * @param {Array} [config.plugins=[]] Array of plugins to execute on start * @param {Object} [config.pluginsOpts={}] Custom options for plugins diff --git a/src/parser/model/ParserHtml.js b/src/parser/model/ParserHtml.js index 021c5dbf9..c07ba3b4b 100644 --- a/src/parser/model/ParserHtml.js +++ b/src/parser/model/ParserHtml.js @@ -57,6 +57,7 @@ module.exports = config => { * @return {Array} */ parseNode(el) { + const config = (c.em && c.em.get('Config')) || {}; const result = []; const nodes = el.childNodes; @@ -152,9 +153,11 @@ module.exports = config => { } // Throw away empty nodes (keep spaces) - const content = node.nodeValue; - if (content != ' ' && !content.trim()) { - continue; + if (config.removeEmptyTextNodes !== false) { + const content = node.nodeValue; + if (content != ' ' && !content.trim()) { + continue; + } } } diff --git a/src/selector_manager/index.js b/src/selector_manager/index.js index 11342bb27..69635c23c 100644 --- a/src/selector_manager/index.js +++ b/src/selector_manager/index.js @@ -73,6 +73,15 @@ module.exports = config => { * @private */ name: 'SelectorManager', + + /** + * Get configuration object + * @return {Object} + * @private + */ + getConfig() { + return c; + }, getConfig() { return c;