Skip to content

Commit 950ed2d

Browse files
author
Dan Nguyen
committed
fix(factories): Add remainder of html string to finalHtml
1 parent d750219 commit 950ed2d

File tree

5 files changed

+45
-4
lines changed

5 files changed

+45
-4
lines changed

dist/textAngular-rangy.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/textAngular.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ angular.module('textAngular.factories', [])
237237
finalHtml += html.substring(lastIndex, match.index) + appleSpaceVal;
238238
lastIndex = match.index + match[0].length;
239239
}
240+
finalHtml += html.substring(lastIndex);
240241
/* istanbul ignore next: apple-contereted-space span has matched */
241242
if (lastIndex) {
242243
// modified....
@@ -2752,6 +2753,25 @@ textAngular.directive("textAngular", [
27522753
scope.displayElements.text.on('keyup', _keyup);
27532754
// stop updating on key up and update the display/model
27542755
_keypress = function(event, eventData){
2756+
// bug fix for Firefox. If we are selecting a <a> already, any characters will
2757+
// be added within the <a> which is bad!
2758+
var _selection = taSelection.getSelection();
2759+
/* istanbul ignore next: don't see how to test this... */
2760+
if (taSelection.getSelectionElement().tagName.toLowerCase() === 'a') {
2761+
// check and see if we are at the edge of the <a>
2762+
if (_selection.start.element.nodeType === 3 &&
2763+
_selection.start.element.textContent.length === _selection.end.offset) {
2764+
// we are at the end of the <a>!!!
2765+
// so move the selection to after the <a>!!
2766+
taSelection.setSelectionAfterElement(taSelection.getSelectionElement());
2767+
}
2768+
if (_selection.start.element.nodeType === 3 &&
2769+
_selection.start.offset === 0) {
2770+
// we are at the start of the <a>!!!
2771+
// so move the selection before the <a>!!
2772+
taSelection.setSelectionBeforeElement(taSelection.getSelectionElement());
2773+
}
2774+
}
27552775
/* istanbul ignore else: this is for catching the jqLite testing*/
27562776
if(eventData) angular.extend(event, eventData);
27572777
scope.$apply(function(){

dist/textAngular.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/textAngular.umd.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,6 +1133,7 @@ angular.module('textAngular.factories', [])
11331133
finalHtml += html.substring(lastIndex, match.index) + appleSpaceVal;
11341134
lastIndex = match.index + match[0].length;
11351135
}
1136+
finalHtml += html.substring(lastIndex);
11361137
/* istanbul ignore next: apple-contereted-space span has matched */
11371138
if (lastIndex) {
11381139
// modified....
@@ -3648,6 +3649,25 @@ textAngular.directive("textAngular", [
36483649
scope.displayElements.text.on('keyup', _keyup);
36493650
// stop updating on key up and update the display/model
36503651
_keypress = function(event, eventData){
3652+
// bug fix for Firefox. If we are selecting a <a> already, any characters will
3653+
// be added within the <a> which is bad!
3654+
var _selection = taSelection.getSelection();
3655+
/* istanbul ignore next: don't see how to test this... */
3656+
if (taSelection.getSelectionElement().tagName.toLowerCase() === 'a') {
3657+
// check and see if we are at the edge of the <a>
3658+
if (_selection.start.element.nodeType === 3 &&
3659+
_selection.start.element.textContent.length === _selection.end.offset) {
3660+
// we are at the end of the <a>!!!
3661+
// so move the selection to after the <a>!!
3662+
taSelection.setSelectionAfterElement(taSelection.getSelectionElement());
3663+
}
3664+
if (_selection.start.element.nodeType === 3 &&
3665+
_selection.start.offset === 0) {
3666+
// we are at the start of the <a>!!!
3667+
// so move the selection before the <a>!!
3668+
taSelection.setSelectionBeforeElement(taSelection.getSelectionElement());
3669+
}
3670+
}
36513671
/* istanbul ignore else: this is for catching the jqLite testing*/
36523672
if(eventData) angular.extend(event, eventData);
36533673
scope.$apply(function(){

src/factories.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ angular.module('textAngular.factories', [])
4747
finalHtml += html.substring(lastIndex, match.index) + appleSpaceVal;
4848
lastIndex = match.index + match[0].length;
4949
}
50+
finalHtml += html.substring(lastIndex);
5051
/* istanbul ignore next: apple-contereted-space span has matched */
5152
if (lastIndex) {
5253
// modified....

0 commit comments

Comments
 (0)