Ticket #4666: 4666.patch
File 4666.patch, 3.3 KB (added by , 15 years ago) |
---|
-
_source/plugins/selection/plugin.js
115 115 // than firing the selection change event. 116 116 117 117 var savedRange, 118 saveEnabled; 118 saveEnabled, 119 // Use a light-grey style to mark blurred selection which mimics Firefox and Webkit. 120 highlightStyle = new CKEDITOR.style( { element : 'span', attributes : { 'class' : 'cke_range_mark' } } ); 119 121 120 122 // "onfocusin" is fired before "onfocus". It makes it 121 123 // possible to restore the selection before click 122 124 // events get executed. 123 125 body.on( 'focusin', function( evt ) 124 126 { 127 body.removeClass( 'deactivate' ); 125 128 // If there are elements with layout they fire this event but 126 129 // it must be ignored to allow edit its contents #4682 127 130 if ( evt.data.$.srcElement.nodeName != 'BODY' ) … … 139 142 catch (e) 140 143 {} 141 144 145 // Defers until user selection actually happens inside document, e.g. click. 146 setTimeout( function () 147 { 148 var sel = editor.getSelection(), 149 bm = sel.createBookmarks(); 150 var docRange = new CKEDITOR.dom.range( doc ); 151 docRange.selectNodeContents( doc.getBody() ); 152 highlightStyle.removeFromRange( docRange ); 153 sel.selectBookmarks( bm ); 154 }, 100 ); 155 142 156 savedRange = null; 143 157 } 144 158 }); … … 153 167 154 168 body.on( 'beforedeactivate', function( evt ) 155 169 { 170 body.addClass( 'deactivate' ); 171 156 172 // Ignore this event if it's caused by focus switch between 157 173 // internal editable control type elements, e.g. layouted paragraph. (#4682) 158 174 if ( evt.data.$.toElement ) 159 175 return; 160 176 177 var sel = editor.getSelection(); 178 var isLocked = sel.isLocked; 179 180 isLocked && sel.unlock(); 181 sel.isLocked && sel.unlock(); 182 highlightStyle.apply( doc ); 183 isLocked && sel.lock(); 184 185 // Save may already get disabled, e.g. 'tab' key down, 186 // open it for the last save. 187 saveEnabled = true; 188 saveSelection(); 161 189 // Disable selections from being saved. 162 190 saveEnabled = false; 163 191 }); … … 257 285 }); 258 286 259 287 editor.selectionChange = checkSelectionChangeTimeout; 260 } 261 }); 288 289 if ( CKEDITOR.env.ie ) 290 { 291 editor.addCss( 292 'body.deactivate span.cke_range_mark' + 293 '{' + 294 'background-color: #ADAAAB;' + 295 'color: #fff;' + 296 '}' ); 297 } 298 }, 299 300 afterInit : function( editor ) 301 { 302 if ( !CKEDITOR.env.ie ) 303 return; 304 305 var dataProcessor = editor.dataProcessor, 306 htmlFilter = dataProcessor && dataProcessor.htmlFilter; 307 308 if ( htmlFilter ) 309 { 310 htmlFilter.addRules( 311 { 312 elements : 313 { 314 'span' : function( element ) 315 { 316 if ( element.attributes[ 'class' ] == 'cke_range_mark' ) 317 delete element. name; 318 319 return element; 320 } 321 } 322 }); 323 } 324 } 325 }); 262 326 263 327 /** 264 328 * Gets the current selection from the editing area when in WYSIWYG mode.