scribe-editor
Advanced tools
Comparing version 0.1.20 to 0.1.21
@@ -5,3 +5,3 @@ { | ||
"lodash-amd": "2.4.1", | ||
"scribe-common": "0.0.4" | ||
"scribe-common": "0.0.11" | ||
}, | ||
@@ -8,0 +8,0 @@ "devDependencies": { |
@@ -0,1 +1,7 @@ | ||
# 0.1.21 | ||
* Fix [Don't insert BR in empty non block elements](https://github.com/guardian/scribe/pull/258) | ||
# 0.1.20 | ||
* Fix [Don't strip nbsps in the transaction manger](https://github.com/guardian/scribe/pull/257) | ||
# 0.1.19 | ||
@@ -2,0 +8,0 @@ * Fix [Release v0.01.18 did not succeed](https://github.com/guardian/scribe/pull/253) |
{ | ||
"name": "scribe-editor", | ||
"version": "0.1.20", | ||
"version": "0.1.21", | ||
"main": "src/scribe.js", | ||
"dependencies": { | ||
"lodash-amd": "~2.4.1", | ||
"scribe-common": "~0.0.4" | ||
"scribe-common": "~0.0.11" | ||
}, | ||
@@ -9,0 +9,0 @@ "devDependencies": { |
@@ -20,2 +20,11 @@ define([ | ||
function parentHasNoTextContent(node) { | ||
if (element.isCaretPositionNode(node)) { | ||
return true; | ||
} else { | ||
return node.parentNode.textContent.trim() === ''; | ||
} | ||
} | ||
function traverse(parentNode) { | ||
@@ -28,5 +37,14 @@ // Instead of TreeWalker, which gets confused when the BR is added to the dom, | ||
function isEmpty(node) { | ||
return node.children.length === 0 | ||
|| (node.children.length === 1 | ||
&& element.isSelectionMarkerNode(node.children[0])); | ||
if ((node.children.length === 0 && element.isBlockElement(node)) | ||
|| (node.children.length === 1 && element.isSelectionMarkerNode(node.children[0]))) { | ||
return true; | ||
} | ||
// Do not insert BR in empty non block elements with parent containing text | ||
if (!element.isBlockElement(node) && node.children.length === 0) { | ||
return parentHasNoTextContent(node); | ||
} | ||
return false; | ||
} | ||
@@ -33,0 +51,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
3688
229202
Updatedscribe-common@~0.0.11