Skip to content

Commit

Permalink
fix(textAngularSetup) Fix clear formatting functionality when used wi…
Browse files Browse the repository at this point in the history
…th ta-default-wrap=br textAngular#1374 - thanks to damien-otis for this fix.
  • Loading branch information
JoelParke committed Nov 10, 2016
1 parent ca7c53e commit 0e45059
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
19 changes: 13 additions & 6 deletions src/DOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,16 @@ angular.module('textAngular.DOM', ['textAngular.factories'])
// nothing left to do..
return element;
}
var $target = angular.element(options);
$target[0].innerHTML = element.innerHTML;
element.parentNode.insertBefore($target[0], element);
element.parentNode.removeChild(element);
return $target;
if (options === '<br>'){
return element;
}
else {
var $target = angular.element(options);
$target[0].innerHTML = element.innerHTML;
element.parentNode.insertBefore($target[0], element);
element.parentNode.removeChild(element);
return $target;
}
};
return function(taDefaultWrap, topNode){
// NOTE: here we are dealing with the html directly from the browser and not the html the user sees.
Expand Down Expand Up @@ -311,8 +316,10 @@ angular.module('textAngular.DOM', ['textAngular.factories'])
}
}catch(e){}
//console.log('************** selectedElement:', selectedElement);
/* istanbul ignore if: */
if (!selectedElement){return;}
var $selected = angular.element(selectedElement);
var tagName = (selectedElement.tagName && selectedElement.tagName.toLowerCase()) ||
var tagName = (selectedElement && selectedElement.tagName && selectedElement.tagName.toLowerCase()) ||
/* istanbul ignore next: */ "";
if(command.toLowerCase() === 'insertorderedlist' || command.toLowerCase() === 'insertunorderedlist'){
var selfTag = taBrowserTag((command.toLowerCase() === 'insertorderedlist')? 'ol' : 'ul');
Expand Down
3 changes: 2 additions & 1 deletion src/textAngularSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,8 @@ angular.module('textAngularSetup', [])
// check if in list. If not in list then use formatBlock option
if(possibleNodes[0] && possibleNodes[0].tagName.toLowerCase() !== 'li' &&
possibleNodes[0].tagName.toLowerCase() !== 'ol' &&
possibleNodes[0].tagName.toLowerCase() !== 'ul') {
possibleNodes[0].tagName.toLowerCase() !== 'ul' &&
possibleNodes[0].getAttribute("contenteditable") !== "true") {
this.$editor().wrapSelection("formatBlock", "default");
}
restoreSelection();
Expand Down

0 comments on commit 0e45059

Please sign in to comment.