@@ -886,7 +886,7 @@ angular.module('textAngular.taBind', ['textAngular.factories', 'textAngular.DOM'
886
886
if ( ! _isReadonly && _isContentEditable ) {
887
887
var content = ngModel . $undoManager . undo ( ) ;
888
888
if ( typeof content !== "undefined" && content !== null ) {
889
- element [ 0 ] . innerHTML = content ;
889
+ _setInnerHTML ( content ) ;
890
890
_setViewValue ( content , false ) ;
891
891
/* istanbul ignore else: browser catch */
892
892
if ( element [ 0 ] . childNodes . length ) taSelection . setSelectionToElementEnd ( element [ 0 ] . childNodes [ element [ 0 ] . childNodes . length - 1 ] ) ;
@@ -900,7 +900,7 @@ angular.module('textAngular.taBind', ['textAngular.factories', 'textAngular.DOM'
900
900
if ( ! _isReadonly && _isContentEditable ) {
901
901
var content = ngModel . $undoManager . redo ( ) ;
902
902
if ( typeof content !== "undefined" && content !== null ) {
903
- element [ 0 ] . innerHTML = content ;
903
+ _setInnerHTML ( content ) ;
904
904
_setViewValue ( content , false ) ;
905
905
/* istanbul ignore else: browser catch */
906
906
if ( element [ 0 ] . childNodes . length ) taSelection . setSelectionToElementEnd ( element [ 0 ] . childNodes [ element [ 0 ] . childNodes . length - 1 ] ) ;
@@ -924,6 +924,7 @@ angular.module('textAngular.taBind', ['textAngular.factories', 'textAngular.DOM'
924
924
if ( ngModel . $viewValue !== '' ) ngModel . $setViewValue ( '' ) ;
925
925
if ( triggerUndo && ngModel . $undoManager . current ( ) !== '' ) ngModel . $undoManager . push ( '' ) ;
926
926
} else {
927
+ _reApplyOnSelectorHandlers ( ) ;
927
928
if ( ngModel . $viewValue !== _val ) {
928
929
ngModel . $setViewValue ( _val ) ;
929
930
if ( triggerUndo ) ngModel . $undoManager . push ( _val ) ;
@@ -1209,7 +1210,7 @@ angular.module('textAngular.taBind', ['textAngular.factories', 'textAngular.DOM'
1209
1210
}
1210
1211
var val = _compileHtml ( ) ;
1211
1212
if ( _defaultVal !== '' && val . trim ( ) === '' ) {
1212
- element [ 0 ] . innerHTML = _defaultVal ;
1213
+ _setInnerHTML ( _defaultVal ) ;
1213
1214
taSelection . setSelectionToElementStart ( element . children ( ) [ 0 ] ) ;
1214
1215
}
1215
1216
var triggerUndo = _lastKey !== event . keyCode && UNDO_TRIGGER_KEYS . test ( event . keyCode ) ;
@@ -1306,7 +1307,6 @@ angular.module('textAngular.taBind', ['textAngular.factories', 'textAngular.DOM'
1306
1307
$timeout ( function ( ) {
1307
1308
dropFired = false ;
1308
1309
_setViewValue ( ) ;
1309
- _reApplyOnSelectorHandlers ( ) ;
1310
1310
} , 100 ) ;
1311
1311
}
1312
1312
} ;
@@ -1548,7 +1548,7 @@ textAngular.directive("textAngular", [
1548
1548
// shim the .one till fixed
1549
1549
var _func = function ( ) {
1550
1550
_element . off ( event , _func ) ;
1551
- action ( ) ;
1551
+ action . apply ( this , arguments ) ;
1552
1552
} ;
1553
1553
_element . on ( event , _func ) ;
1554
1554
} , 100 ) ;
@@ -1634,7 +1634,7 @@ textAngular.directive("textAngular", [
1634
1634
scope . displayElements . popover . css ( 'display' , 'block' ) ;
1635
1635
scope . reflowPopover ( _el ) ;
1636
1636
$animate . addClass ( scope . displayElements . popover , 'in' ) ;
1637
- oneEvent ( element , 'click keyup' , function ( ) { scope . hidePopover ( ) ; } ) ;
1637
+ oneEvent ( $document . find ( 'body' ) , 'click keyup' , function ( ) { scope . hidePopover ( ) ; } ) ;
1638
1638
} ;
1639
1639
scope . reflowPopover = function ( _el ) {
1640
1640
/* istanbul ignore if: catches only if near bottom of editor */
@@ -1697,38 +1697,24 @@ textAngular.directive("textAngular", [
1697
1697
x : Math . max ( 0 , startPosition . width + ( event . clientX - startPosition . x ) ) ,
1698
1698
y : Math . max ( 0 , startPosition . height + ( event . clientY - startPosition . y ) )
1699
1699
} ;
1700
- var applyImageSafeCSS = function ( _el , css ) {
1701
- _el = angular . element ( _el ) ;
1702
- if ( _el [ 0 ] . tagName . toLowerCase ( ) === 'img' ) {
1703
- if ( css . height ) {
1704
- _el . attr ( 'height' , css . height ) ;
1705
- delete css . height ;
1706
- }
1707
- if ( css . width ) {
1708
- _el . attr ( 'width' , css . width ) ;
1709
- delete css . width ;
1710
- }
1711
- }
1712
- _el . css ( css ) ;
1713
- } ;
1700
+
1714
1701
if ( event . shiftKey ) {
1715
1702
// keep ratio
1716
1703
var newRatio = pos . y / pos . x ;
1717
- applyImageSafeCSS ( _el , {
1718
- width : ratio > newRatio ? pos . x : pos . y / ratio ,
1719
- height : ratio > newRatio ? pos . x * ratio : pos . y
1720
- } ) ;
1721
- } else {
1722
- applyImageSafeCSS ( _el , {
1723
- width : pos . x ,
1724
- height : pos . y
1725
- } ) ;
1704
+ pos . x = ratio > newRatio ? pos . x : pos . y / ratio ;
1705
+ pos . y = ratio > newRatio ? pos . x * ratio : pos . y ;
1726
1706
}
1707
+ el = angular . element ( _el ) ;
1708
+ el . attr ( 'height' , Math . max ( 0 , pos . y ) ) ;
1709
+ el . attr ( 'width' , Math . max ( 0 , pos . x ) ) ;
1710
+
1727
1711
// reflow the popover tooltip
1728
1712
scope . reflowResizeOverlay ( _el ) ;
1729
1713
} ;
1730
1714
$document . find ( 'body' ) . on ( 'mousemove' , mousemove ) ;
1731
- oneEvent ( scope . displayElements . resize . overlay , 'mouseup' , function ( ) {
1715
+ oneEvent ( $document . find ( 'body' ) , 'mouseup' , function ( event ) {
1716
+ event . preventDefault ( ) ;
1717
+ event . stopPropagation ( ) ;
1732
1718
$document . find ( 'body' ) . off ( 'mousemove' , mousemove ) ;
1733
1719
scope . showPopover ( _el ) ;
1734
1720
} ) ;
@@ -1739,7 +1725,7 @@ textAngular.directive("textAngular", [
1739
1725
scope . displayElements . resize . anchors [ 3 ] . on ( 'mousedown' , resizeMouseDown ) ;
1740
1726
1741
1727
scope . reflowResizeOverlay ( _el ) ;
1742
- oneEvent ( element , 'click' , function ( ) { scope . hideResizeOverlay ( ) ; } ) ;
1728
+ oneEvent ( $document . find ( 'body' ) , 'click' , function ( ) { scope . hideResizeOverlay ( ) ; } ) ;
1743
1729
} ;
1744
1730
/* istanbul ignore next: pretty sure phantomjs won't test this */
1745
1731
scope . hideResizeOverlay = function ( ) {
0 commit comments