Ticket #9439: 9439.patch
File 9439.patch, 4.1 KB (added by , 8 years ago) |
---|
-
_source/plugins/scayt/plugin.js
35 35 36 36 var createInstance = function() // Create new instance every time Document is created. 37 37 { 38 if(typeof plugin.instances[ editor.name ] != 'undefined' || plugin.instances[ editor.name ] != null) 39 { 40 plugin.instances[ editor.name ].destroy(); 41 } 38 42 var config = editor.config; 39 43 // Initialise Scayt instance. 40 44 var oParams = {}; … … 78 82 oParams.id = plugin.getControlId( editor ); 79 83 80 84 var scayt_control = new window.scayt( oParams ); 81 82 85 scayt_control.afterMarkupRemove.push( function( node ) 83 86 { 84 87 ( new CKEDITOR.dom.element( node, scayt_control.document ) ).mergeSiblings(); … … 102 105 editor.fire( 'showScaytState' ); 103 106 }; 104 107 105 editor.on( 'contentDom', createInstance ); 108 editor.on( 'contentDom', function(ev) 109 { 110 createInstance(); 111 }); 106 112 editor.on( 'contentDomUnload', function() 107 113 { 108 114 // Remove scripts. … … 123 129 124 130 editor.on( 'beforeCommandExec', function( ev ) // Disable SCAYT before Source command execution. 125 131 { 126 if ( ( ev.data.name == 'source' || ev.data.name == 'newpage' ) && editor.mode == 'wysiwyg' ) 127 { 128 var scayt_instance = plugin.getScayt( editor ); 129 if ( scayt_instance ) 130 { 131 plugin.setPaused( editor, !scayt_instance.disabled ); 132 // store a control id for restore a specific scayt control settings 133 plugin.setControlId( editor, scayt_instance.id ); 134 scayt_instance.destroy( true ); 135 delete plugin.instances[ editor.name ]; 136 } 137 } 138 // Catch on source mode switch off (#5720) 139 else if ( ev.data.name == 'source' && editor.mode == 'source' ) 132 if ( ev.data.name == 'source' && editor.mode == 'source' ) 140 133 plugin.markControlRestore( editor ); 141 134 }); 142 135 … … 148 141 if ( editor.mode == 'wysiwyg' && ( ev.data.name == 'undo' || ev.data.name == 'redo' ) ) 149 142 window.setTimeout( function() { plugin.getScayt( editor ).refresh(); }, 10 ); 150 143 }); 151 152 144 editor.on( 'destroy', function( ev ) 153 145 { 154 146 var editor = ev.editor, … … 163 155 plugin.setControlId( editor, scayt_instance.id ); 164 156 scayt_instance.destroy( true ); 165 157 }); 166 167 // Listen to data manipulation to reflect scayt markup.168 editor.on( ' afterSetData', function()158 //#9439 after SetData method fires contentDom event and SCAYT create additional instanse 159 // This way we should destroy SCAYT on setData event when contenteditable Iframe was re-created 160 editor.on( 'setData', function( ev ) 169 161 { 170 if ( plugin.isScaytEnabled( editor ) ) { 171 window.setTimeout( function() 172 { 173 var instance = plugin.getScayt( editor ); 174 instance && instance.refresh(); 175 }, 10 ); 176 } 162 var scayt_instance = plugin.getScayt( editor ); 163 if ( scayt_instance ) 164 { 165 plugin.setPaused( editor, !scayt_instance.disabled ); 166 // store a control id for restore a specific scayt control settings 167 plugin.setControlId( editor, scayt_instance.id ); 168 scayt_instance.destroy( true ); 169 delete plugin.instances[ editor.name ]; 170 } 177 171 }); 178 172 179 173 // Reload spell-checking for current word after insertion completed. … … 374 368 return editor.fire( 'showScaytState' ); 375 369 376 370 if ( this.engineLoaded === true ) 377 return onEngineLoad.apply( editor ); // Add new instance. 378 else if ( this.engineLoaded == -1 ) // We are waiting. 371 { 372 return onEngineLoad.apply( editor ); 373 } 374 // Add new instance. 375 else if ( this.engineLoaded == -1 ) 376 { // We are waiting. 379 377 return CKEDITOR.on( 'scaytReady', function(){ onEngineLoad.apply( editor ); } ); // Use function(){} to avoid rejection as duplicate. 378 } 380 379 381 380 CKEDITOR.on( 'scaytReady', onEngineLoad, editor ); 382 381 CKEDITOR.on( 'scaytReady', function() … … 427 426 ); 428 427 } 429 428 else 429 { 430 430 CKEDITOR.fireOnce( 'scaytReady' ); 431 } 431 432 432 433 return null; 433 434 },