Browse Source

Merge pull request #1010 from tommedema/master

implemented removeEmptyTextNodes boolean, fixes #989
pull/1017/head
Artur Arseniev 9 years ago
committed by GitHub
parent
commit
28c9fe715b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      src/editor/config/config.js
  2. 1
      src/editor/index.js
  3. 9
      src/parser/model/ParserHtml.js

3
src/editor/config/config.js

@ -62,6 +62,9 @@ module.exports = {
// Ending tag for variable inside scripts in Components // Ending tag for variable inside scripts in Components
tagVarEnd: ' ]}', tagVarEnd: ' ]}',
// Remove empty text nodes when parsed, unless they contain a space
removeEmptyTextNodes: true,
// Return JS of components inside HTML from 'editor.getHtml()' // Return JS of components inside HTML from 'editor.getHtml()'
jsInHtml: true, jsInHtml: true,

1
src/editor/index.js

@ -80,6 +80,7 @@
* @param {Object} [config.domComponents={}] Components configuration, see the relative documentation * @param {Object} [config.domComponents={}] Components configuration, see the relative documentation
* @param {Object} [config.panels={}] Panels 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 {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 {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 {Array} [config.plugins=[]] Array of plugins to execute on start
* @param {Object} [config.pluginsOpts={}] Custom options for plugins * @param {Object} [config.pluginsOpts={}] Custom options for plugins

9
src/parser/model/ParserHtml.js

@ -57,6 +57,7 @@ module.exports = config => {
* @return {Array<Object>} * @return {Array<Object>}
*/ */
parseNode(el) { parseNode(el) {
const config = (c.em && c.em.get('Config')) || {};
const result = []; const result = [];
const nodes = el.childNodes; const nodes = el.childNodes;
@ -152,9 +153,11 @@ module.exports = config => {
} }
// Throw away empty nodes (keep spaces) // Throw away empty nodes (keep spaces)
const content = node.nodeValue; if (config.removeEmptyTextNodes !== false) {
if (content != ' ' && !content.trim()) { const content = node.nodeValue;
continue; if (content != ' ' && !content.trim()) {
continue;
}
} }
} }

Loading…
Cancel
Save