/*\r
-Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.\r
For licensing, see LICENSE.html or http://ckeditor.com/license\r
*/\r
\r
\r
var createInstance = function() // Create new instance every time Document is created.\r
{\r
+ if( plugin.instances[ editor.name ] )\r
+ plugin.instances[ editor.name ].destroy();\r
+\r
var config = editor.config;\r
// Initialise Scayt instance.\r
var oParams = {};\r
oParams.id = plugin.getControlId( editor );\r
\r
var scayt_control = new window.scayt( oParams );\r
-\r
scayt_control.afterMarkupRemove.push( function( node )\r
{\r
( new CKEDITOR.dom.element( node, scayt_control.document ) ).mergeSiblings();\r
editor.fire( 'showScaytState' );\r
};\r
\r
- editor.on( 'contentDom', createInstance );\r
+ editor.on( 'contentDom', function(ev)\r
+ {\r
+ createInstance();\r
+ });\r
editor.on( 'contentDomUnload', function()\r
{\r
// Remove scripts.\r
\r
editor.on( 'beforeCommandExec', function( ev ) // Disable SCAYT before Source command execution.\r
{\r
- if ( ( ev.data.name == 'source' || ev.data.name == 'newpage' ) && editor.mode == 'wysiwyg' )\r
- {\r
- var scayt_instance = plugin.getScayt( editor );\r
- if ( scayt_instance )\r
- {\r
- plugin.setPaused( editor, !scayt_instance.disabled );\r
- // store a control id for restore a specific scayt control settings\r
- plugin.setControlId( editor, scayt_instance.id );\r
- scayt_instance.destroy( true );\r
- delete plugin.instances[ editor.name ];\r
- }\r
- }\r
- // Catch on source mode switch off (#5720)\r
- else if ( ev.data.name == 'source' && editor.mode == 'source' )\r
+ if ( ev.data.name == 'source' && editor.mode == 'source' )\r
plugin.markControlRestore( editor );\r
});\r
\r
if ( editor.mode == 'wysiwyg' && ( ev.data.name == 'undo' || ev.data.name == 'redo' ) )\r
window.setTimeout( function() { plugin.getScayt( editor ).refresh(); }, 10 );\r
});\r
-\r
editor.on( 'destroy', function( ev )\r
{\r
var editor = ev.editor,\r
plugin.setControlId( editor, scayt_instance.id );\r
scayt_instance.destroy( true );\r
});\r
-\r
- // Listen to data manipulation to reflect scayt markup.\r
- editor.on( 'afterSetData', function()\r
+ //#9439 after SetData method fires contentDom event and SCAYT create additional instanse\r
+ // This way we should destroy SCAYT on setData event when contenteditable Iframe was re-created\r
+ editor.on( 'setData', function( ev )\r
{\r
- if ( plugin.isScaytEnabled( editor ) ) {\r
- window.setTimeout( function()\r
- {\r
- var instance = plugin.getScayt( editor );\r
- instance && instance.refresh();\r
- }, 10 );\r
- }\r
+ var scayt_instance = plugin.getScayt( editor );\r
+ if ( scayt_instance )\r
+ {\r
+ plugin.setPaused( editor, !scayt_instance.disabled );\r
+ // store a control id for restore a specific scayt control settings\r
+ plugin.setControlId( editor, scayt_instance.id );\r
+ scayt_instance.destroy( true );\r
+ delete plugin.instances[ editor.name ];\r
+ }\r
});\r
\r
// Reload spell-checking for current word after insertion completed.\r
return editor.fire( 'showScaytState' );\r
\r
if ( this.engineLoaded === true )\r
- return onEngineLoad.apply( editor ); // Add new instance.\r
- else if ( this.engineLoaded == -1 ) // We are waiting.\r
+ {\r
+ return onEngineLoad.apply( editor );\r
+ }\r
+ // Add new instance.\r
+ else if ( this.engineLoaded == -1 )\r
+ { // We are waiting.\r
return CKEDITOR.on( 'scaytReady', function(){ onEngineLoad.apply( editor ); } ); // Use function(){} to avoid rejection as duplicate.\r
+ }\r
\r
CKEDITOR.on( 'scaytReady', onEngineLoad, editor );\r
CKEDITOR.on( 'scaytReady', function()\r
);\r
}\r
else\r
+ {\r
CKEDITOR.fireOnce( 'scaytReady' );\r
+ }\r
\r
return null;\r
},\r
return null;\r
\r
var sLang = scayt_control.getLang(),\r
- _r = {},\r
items_suggestion = window.scayt.getSuggestion( word, sLang );\r
- if ( !items_suggestion || !items_suggestion.length )\r
- return null;\r
// Remove unused commands and menuitems\r
for ( var m in moreSuggestions )\r
{\r
var contextCommands = editor.config.scayt_contextCommands || 'all';\r
contextCommands = contextCommands.split( '|' );\r
\r
- for ( var i = 0, l = items_suggestion.length; i < l; i += 1 )\r
- {\r
- var commandName = 'scayt_suggestion_' + items_suggestion[i].replace( ' ', '_' );\r
- var exec = ( function( el, s )\r
- {\r
- return {\r
- exec: function()\r
- {\r
- scayt_control.replace( el, s );\r
- }\r
- };\r
- })( node, items_suggestion[i] );\r
-\r
- if ( i < maxSuggestions )\r
+ if ( items_suggestion && items_suggestion.length ) {\r
+ for ( var i = 0, l = items_suggestion.length; i < l; i += 1 )\r
{\r
- addButtonCommand( editor, 'button_' + commandName, items_suggestion[i],\r
- commandName, exec, 'scayt_suggest', i + 1 );\r
- _r[ commandName ] = CKEDITOR.TRISTATE_OFF;\r
- mainSuggestions[ commandName ] = CKEDITOR.TRISTATE_OFF;\r
+ var commandName = 'scayt_suggestion_' + items_suggestion[i].replace( ' ', '_' );\r
+ var exec = ( function( el, s )\r
+ {\r
+ return {\r
+ exec: function()\r
+ {\r
+ scayt_control.replace(el, s);\r
+ }\r
+ };\r
+ })( node, items_suggestion[i] );\r
+\r
+ if ( i < maxSuggestions )\r
+ {\r
+ addButtonCommand( editor, 'button_' + commandName, items_suggestion[i],\r
+ commandName, exec, 'scayt_suggest', i + 1 );\r
+ mainSuggestions[ commandName ] = CKEDITOR.TRISTATE_OFF;\r
+ }\r
+ else if ( moreSuggestionsUnable == 'on' )\r
+ {\r
+ addButtonCommand( editor, 'button_' + commandName, items_suggestion[i],\r
+ commandName, exec, 'scayt_moresuggest', i + 1 );\r
+ moreSuggestions[ commandName ] = CKEDITOR.TRISTATE_OFF;\r
+ moreSuggestionsUnableAdded = true;\r
+ }\r
}\r
- else if ( moreSuggestionsUnable == 'on' )\r
+\r
+ if ( moreSuggestionsUnableAdded )\r
{\r
- addButtonCommand( editor, 'button_' + commandName, items_suggestion[i],\r
- commandName, exec, 'scayt_moresuggest', i + 1 );\r
- moreSuggestions[ commandName ] = CKEDITOR.TRISTATE_OFF;\r
- moreSuggestionsUnableAdded = true;\r
+ // Register the More suggestions group;\r
+ editor.addMenuItem( 'scayt_moresuggest',\r
+ {\r
+ label : editor.lang.scayt.moreSuggestions,\r
+ group : 'scayt_moresuggest',\r
+ order : 10,\r
+ getItems : function()\r
+ {\r
+ return moreSuggestions;\r
+ }\r
+ });\r
+ mainSuggestions[ 'scayt_moresuggest' ] = CKEDITOR.TRISTATE_OFF;\r
}\r
}\r
-\r
- if ( moreSuggestionsUnableAdded )\r
- {\r
- // Register the More suggestions group;\r
- editor.addMenuItem( 'scayt_moresuggest',\r
+ else {\r
+ // "No suggestions" feature\r
+ editor.addMenuItem( 'scayt_nosuggest',\r
{\r
- label : lang.moreSuggestions,\r
- group : 'scayt_moresuggest',\r
- order : 10,\r
- getItems : function()\r
- {\r
- return moreSuggestions;\r
- }\r
+ label : editor.lang.scayt.noSuggestions ? editor.lang.scayt.noSuggestions : (editor.lang.spellCheck.noSuggestions ? editor.lang.spellCheck.noSuggestions : 'No suggestions'),\r
+ group : 'scayt_suggest',\r
+ order : 1\r
});\r
- mainSuggestions[ 'scayt_moresuggest' ] = CKEDITOR.TRISTATE_OFF;\r
+ mainSuggestions[ 'scayt_nosuggest' ] = CKEDITOR.TRISTATE_OFF;\r
}\r
\r
if ( in_array( 'all', contextCommands ) || in_array( 'ignore', contextCommands) )\r