Skip to content

Commit

Permalink
fix(factories): Add remainder of html string to finalHtml
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Nguyen committed Aug 19, 2016
1 parent d750219 commit 950ed2d
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/textAngular-rangy.min.js

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions dist/textAngular.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ angular.module('textAngular.factories', [])
finalHtml += html.substring(lastIndex, match.index) + appleSpaceVal;
lastIndex = match.index + match[0].length;
}
finalHtml += html.substring(lastIndex);
/* istanbul ignore next: apple-contereted-space span has matched */
if (lastIndex) {
// modified....
Expand Down Expand Up @@ -2752,6 +2753,25 @@ textAngular.directive("textAngular", [
scope.displayElements.text.on('keyup', _keyup);
// stop updating on key up and update the display/model
_keypress = function(event, eventData){
// bug fix for Firefox. If we are selecting a <a> already, any characters will
// be added within the <a> which is bad!
var _selection = taSelection.getSelection();
/* istanbul ignore next: don't see how to test this... */
if (taSelection.getSelectionElement().tagName.toLowerCase() === 'a') {
// check and see if we are at the edge of the <a>
if (_selection.start.element.nodeType === 3 &&
_selection.start.element.textContent.length === _selection.end.offset) {
// we are at the end of the <a>!!!
// so move the selection to after the <a>!!
taSelection.setSelectionAfterElement(taSelection.getSelectionElement());
}
if (_selection.start.element.nodeType === 3 &&
_selection.start.offset === 0) {
// we are at the start of the <a>!!!
// so move the selection before the <a>!!
taSelection.setSelectionBeforeElement(taSelection.getSelectionElement());
}
}
/* istanbul ignore else: this is for catching the jqLite testing*/
if(eventData) angular.extend(event, eventData);
scope.$apply(function(){
Expand Down
6 changes: 3 additions & 3 deletions dist/textAngular.min.js

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions dist/textAngular.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,7 @@ angular.module('textAngular.factories', [])
finalHtml += html.substring(lastIndex, match.index) + appleSpaceVal;
lastIndex = match.index + match[0].length;
}
finalHtml += html.substring(lastIndex);
/* istanbul ignore next: apple-contereted-space span has matched */
if (lastIndex) {
// modified....
Expand Down Expand Up @@ -3648,6 +3649,25 @@ textAngular.directive("textAngular", [
scope.displayElements.text.on('keyup', _keyup);
// stop updating on key up and update the display/model
_keypress = function(event, eventData){
// bug fix for Firefox. If we are selecting a <a> already, any characters will
// be added within the <a> which is bad!
var _selection = taSelection.getSelection();
/* istanbul ignore next: don't see how to test this... */
if (taSelection.getSelectionElement().tagName.toLowerCase() === 'a') {
// check and see if we are at the edge of the <a>
if (_selection.start.element.nodeType === 3 &&
_selection.start.element.textContent.length === _selection.end.offset) {
// we are at the end of the <a>!!!
// so move the selection to after the <a>!!
taSelection.setSelectionAfterElement(taSelection.getSelectionElement());
}
if (_selection.start.element.nodeType === 3 &&
_selection.start.offset === 0) {
// we are at the start of the <a>!!!
// so move the selection before the <a>!!
taSelection.setSelectionBeforeElement(taSelection.getSelectionElement());
}
}
/* istanbul ignore else: this is for catching the jqLite testing*/
if(eventData) angular.extend(event, eventData);
scope.$apply(function(){
Expand Down
1 change: 1 addition & 0 deletions src/factories.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ angular.module('textAngular.factories', [])
finalHtml += html.substring(lastIndex, match.index) + appleSpaceVal;
lastIndex = match.index + match[0].length;
}
finalHtml += html.substring(lastIndex);
/* istanbul ignore next: apple-contereted-space span has matched */
if (lastIndex) {
// modified....
Expand Down

0 comments on commit 950ed2d

Please sign in to comment.