@@ -122,6 +122,45 @@ describe('taBind.events', function () {
122
122
} ) ) ;
123
123
} ) ;
124
124
} ) ;
125
+
126
+ describe ( 'on content-editable with ta-unsafe-sanitizer=true attribute' , function ( ) {
127
+ var $rootScope , element , $timeout ;
128
+ beforeEach ( inject ( function ( _$compile_ , _$rootScope_ , _$timeout_ , $document , $window ) {
129
+ $rootScope = _$rootScope_ ;
130
+ $timeout = _$timeout_ ;
131
+ $rootScope . html = '<p>Test Contents</p>' ;
132
+ element = _$compile_ ( '<div contenteditable="true" ta-unsafe-sanitizer="true" ta-bind ng-model="html"></div>' ) ( $rootScope ) ;
133
+ $document . find ( 'body' ) . append ( element ) ;
134
+ $rootScope . $digest ( ) ;
135
+ var sel = $window . rangy . getSelection ( ) ;
136
+ var range = $window . rangy . createRangyRange ( ) ;
137
+ range . selectNodeContents ( element . find ( 'p' ) [ 0 ] ) ;
138
+ sel . setSingleRange ( range ) ;
139
+ } ) ) ;
140
+ afterEach ( function ( ) {
141
+ element . remove ( ) ;
142
+ } ) ;
143
+
144
+ // var text = (e.originalEvent || e).clipboardData.getData('text/plain') || $window.clipboardData.getData('Text');
145
+ describe ( 'should update model from paste keeping all styles' , function ( ) {
146
+ it ( 'non-ie based w/o jquery' , inject ( function ( $window ) {
147
+ element . triggerHandler ( 'paste' , { clipboardData : { types : [ 'text/html' ] , getData : function ( ) { return '<span style="font-size:10px">Test 4 Content</span>' ; } } } ) ;
148
+ $timeout . flush ( ) ;
149
+ $rootScope . $digest ( ) ;
150
+ expect ( $rootScope . html ) . toBe ( '<p><span style="font-size:10px">Test 4 Content</span></p>' ) ;
151
+ } ) ) ;
152
+
153
+ it ( 'non-ie based w/ jquery' , inject ( function ( $window ) {
154
+ element . triggerHandler ( 'paste' , { originalEvent : { clipboardData : { types : [ 'text/html' ] , getData : function ( ) { return '<span style="font-size:10px">Test 4 Content</span>' ; } } } } ) ;
155
+ $timeout . flush ( ) ;
156
+ $rootScope . $digest ( ) ;
157
+ expect ( $rootScope . html ) . toBe ( '<p><span style="font-size:10px">Test 4 Content</span></p>' ) ;
158
+ } ) ) ;
159
+
160
+ } ) ;
161
+
162
+ } ) ;
163
+
125
164
} ) ;
126
165
127
166
describe ( 'emits the ta-drop-event event correctly' , function ( ) {
0 commit comments