2 Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.
\r
3 For licensing, see LICENSE.html or http://ckeditor.com/license
\r
7 * @fileOverview Spell Check As You Type (SCAYT).
\r
8 * Button name : Scayt.
\r
13 var commandName = 'scaytcheck',
\r
16 // Checks if a value exists in an array
\r
17 function in_array( needle, haystack )
\r
21 for ( key in haystack )
\r
23 if ( haystack[ key ] == needle )
\r
32 var onEngineLoad = function()
\r
36 var createInstance = function() // Create new instance every time Document is created.
\r
38 if( plugin.instances[ editor.name ] )
\r
39 plugin.instances[ editor.name ].destroy();
\r
41 var config = editor.config;
\r
42 // Initialise Scayt instance.
\r
45 oParams.srcNodeRef = editor.document.getWindow().$.frameElement;
\r
46 // syntax : AppName.AppVersion@AppRevision
\r
47 oParams.assocApp = 'CKEDITOR.' + CKEDITOR.version + '@' + CKEDITOR.revision;
\r
48 oParams.customerid = config.scayt_customerid || '1:WvF0D4-UtPqN1-43nkD4-NKvUm2-daQqk3-LmNiI-z7Ysb4-mwry24-T8YrS3-Q2tpq2';
\r
49 oParams.customDictionaryIds = config.scayt_customDictionaryIds || '';
\r
50 oParams.userDictionaryName = config.scayt_userDictionaryName || '';
\r
51 oParams.sLang = config.scayt_sLang || 'en_US';
\r
53 // Introduce SCAYT onLoad callback. (#5632)
\r
54 oParams.onLoad = function()
\r
56 // Draw down word marker to avoid being covered by background-color style.(#5466)
\r
57 if ( !( CKEDITOR.env.ie && CKEDITOR.env.version < 8 ) )
\r
58 this.addStyle( this.selectorCss(), 'padding-bottom: 2px !important;' );
\r
60 // Call scayt_control.focus when SCAYT loaded
\r
61 // and only if editor has focus and scayt control creates at first time (#5720)
\r
62 if ( editor.focusManager.hasFocus && !plugin.isControlRestored( editor ) )
\r
67 oParams.onBeforeChange = function()
\r
69 if ( plugin.getScayt( editor ) && !editor.checkDirty() )
\r
70 setTimeout( function(){ editor.resetDirty(); }, 0 );
\r
73 var scayt_custom_params = window.scayt_custom_params;
\r
74 if ( typeof scayt_custom_params == 'object' )
\r
76 for ( var k in scayt_custom_params )
\r
77 oParams[ k ] = scayt_custom_params[ k ];
\r
79 // needs for restoring a specific scayt control settings
\r
80 if ( plugin.getControlId( editor ) )
\r
81 oParams.id = plugin.getControlId( editor );
\r
83 var scayt_control = new window.scayt( oParams );
\r
84 scayt_control.afterMarkupRemove.push( function( node )
\r
86 ( new CKEDITOR.dom.element( node, scayt_control.document ) ).mergeSiblings();
\r
90 var lastInstance = plugin.instances[ editor.name ];
\r
93 scayt_control.sLang = lastInstance.sLang;
\r
94 scayt_control.option( lastInstance.option() );
\r
95 scayt_control.paused = lastInstance.paused;
\r
98 plugin.instances[ editor.name ] = scayt_control;
\r
101 scayt_control.setDisabled( plugin.isPaused( editor ) === false );
\r
104 editor.fire( 'showScaytState' );
\r
107 editor.on( 'contentDom', function(ev)
\r
111 editor.on( 'contentDomUnload', function()
\r
114 var scripts = CKEDITOR.document.getElementsByTag( 'script' ),
\r
115 scaytIdRegex = /^dojoIoScript(\d+)$/i,
\r
116 scaytSrcRegex = /^https?:\/\/svc\.webspellchecker\.net\/spellcheck\/script\/ssrv\.cgi/i;
\r
118 for ( var i=0; i < scripts.count(); i++ )
\r
120 var script = scripts.getItem( i ),
\r
121 id = script.getId(),
\r
122 src = script.getAttribute( 'src' );
\r
124 if ( id && src && id.match( scaytIdRegex ) && src.match( scaytSrcRegex ))
\r
129 editor.on( 'beforeCommandExec', function( ev ) // Disable SCAYT before Source command execution.
\r
131 if ( ev.data.name == 'source' && editor.mode == 'source' )
\r
132 plugin.markControlRestore( editor );
\r
135 editor.on( 'afterCommandExec', function( ev )
\r
137 if ( !plugin.isScaytEnabled( editor ) )
\r
140 if ( editor.mode == 'wysiwyg' && ( ev.data.name == 'undo' || ev.data.name == 'redo' ) )
\r
141 window.setTimeout( function() { plugin.getScayt( editor ).refresh(); }, 10 );
\r
143 editor.on( 'destroy', function( ev )
\r
145 var editor = ev.editor,
\r
146 scayt_instance = plugin.getScayt( editor );
\r
148 // SCAYT instance might already get destroyed by mode switch (#5744).
\r
149 if ( !scayt_instance )
\r
152 delete plugin.instances[ editor.name ];
\r
153 // store a control id for restore a specific scayt control settings
\r
154 plugin.setControlId( editor, scayt_instance.id );
\r
155 scayt_instance.destroy( true );
\r
157 //#9439 after SetData method fires contentDom event and SCAYT create additional instanse
\r
158 // This way we should destroy SCAYT on setData event when contenteditable Iframe was re-created
\r
159 editor.on( 'setData', function( ev )
\r
161 var scayt_instance = plugin.getScayt( editor );
\r
162 if ( scayt_instance )
\r
164 plugin.setPaused( editor, !scayt_instance.disabled );
\r
165 // store a control id for restore a specific scayt control settings
\r
166 plugin.setControlId( editor, scayt_instance.id );
\r
167 scayt_instance.destroy( true );
\r
168 delete plugin.instances[ editor.name ];
\r
172 // Reload spell-checking for current word after insertion completed.
\r
173 editor.on( 'insertElement', function()
\r
175 var scayt_instance = plugin.getScayt( editor );
\r
176 if ( plugin.isScaytEnabled( editor ) )
\r
178 // Unlock the selection before reload, SCAYT will take
\r
179 // care selection update.
\r
180 if ( CKEDITOR.env.ie )
\r
181 editor.getSelection().unlock( true );
\r
183 // Return focus to the editor and refresh SCAYT markup (#5573).
\r
184 window.setTimeout( function()
\r
186 scayt_instance.focus();
\r
187 scayt_instance.refresh();
\r
190 }, this, null, 50 );
\r
192 editor.on( 'insertHtml', function()
\r
194 var scayt_instance = plugin.getScayt( editor );
\r
195 if ( plugin.isScaytEnabled( editor ) )
\r
197 // Unlock the selection before reload, SCAYT will take
\r
198 // care selection update.
\r
199 if ( CKEDITOR.env.ie )
\r
200 editor.getSelection().unlock( true );
\r
202 // Return focus to the editor (#5573)
\r
203 // Refresh SCAYT markup
\r
204 window.setTimeout( function()
\r
206 scayt_instance.focus();
\r
207 scayt_instance.refresh();
\r
210 }, this, null, 50 );
\r
212 editor.on( 'scaytDialog', function( ev ) // Communication with dialog.
\r
214 ev.data.djConfig = window.djConfig;
\r
215 ev.data.scayt_control = plugin.getScayt( editor );
\r
216 ev.data.tab = openPage;
\r
217 ev.data.scayt = window.scayt;
\r
220 var dataProcessor = editor.dataProcessor,
\r
221 htmlFilter = dataProcessor && dataProcessor.htmlFilter;
\r
225 htmlFilter.addRules(
\r
229 span : function( element )
\r
231 if ( element.attributes[ 'data-scayt_word' ]
\r
232 && element.attributes[ 'data-scaytid' ] )
\r
234 delete element.name; // Write children, but don't write this node.
\r
243 // Override Image.equals method avoid CK snapshot module to add SCAYT markup to snapshots. (#5546)
\r
244 var undoImagePrototype = CKEDITOR.plugins.undo.Image.prototype;
\r
245 undoImagePrototype.equals = CKEDITOR.tools.override( undoImagePrototype.equals, function( org )
\r
247 return function( otherImage )
\r
249 var thisContents = this.contents,
\r
250 otherContents = otherImage.contents;
\r
251 var scayt_instance = plugin.getScayt( this.editor );
\r
252 // Making the comparison based on content without SCAYT word markers.
\r
253 if ( scayt_instance && plugin.isScaytReady( this.editor ) )
\r
255 // scayt::reset might return value undefined. (#5742)
\r
256 this.contents = scayt_instance.reset( thisContents ) || '';
\r
257 otherImage.contents = scayt_instance.reset( otherContents ) || '';
\r
260 var retval = org.apply( this, arguments );
\r
262 this.contents = thisContents;
\r
263 otherImage.contents = otherContents;
\r
268 if ( editor.document )
\r
272 CKEDITOR.plugins.scayt =
\r
274 engineLoaded : false,
\r
276 // Data storage for SCAYT control, based on editor instances
\r
278 setControlInfo : function( editor, o )
\r
280 if ( editor && editor.name && typeof ( this.controlInfo[ editor.name ] ) != 'object' )
\r
281 this.controlInfo[ editor.name ] = {};
\r
283 for ( var infoOpt in o )
\r
284 this.controlInfo[ editor.name ][ infoOpt ] = o[ infoOpt ];
\r
286 isControlRestored : function( editor )
\r
290 this.controlInfo[ editor.name ] )
\r
292 return this.controlInfo[ editor.name ].restored ;
\r
296 markControlRestore : function( editor )
\r
298 this.setControlInfo( editor, { restored:true } );
\r
300 setControlId: function( editor, id )
\r
302 this.setControlInfo( editor, { id:id } );
\r
304 getControlId: function( editor )
\r
308 this.controlInfo[ editor.name ] &&
\r
309 this.controlInfo[ editor.name ].id )
\r
311 return this.controlInfo[ editor.name ].id;
\r
315 setPaused: function( editor , bool )
\r
317 this.setControlInfo( editor, { paused:bool } );
\r
319 isPaused: function( editor )
\r
323 this.controlInfo[editor.name] )
\r
325 return this.controlInfo[editor.name].paused;
\r
329 getScayt : function( editor )
\r
331 return this.instances[ editor.name ];
\r
333 isScaytReady : function( editor )
\r
335 return this.engineLoaded === true &&
\r
336 'undefined' !== typeof window.scayt && this.getScayt( editor );
\r
338 isScaytEnabled : function( editor )
\r
340 var scayt_instance = this.getScayt( editor );
\r
341 return ( scayt_instance ) ? scayt_instance.disabled === false : false;
\r
343 getUiTabs : function( editor )
\r
347 // read UI tabs value from config
\r
348 var configUiTabs = editor.config.scayt_uiTabs || "1,1,1";
\r
350 // convert string to array
\r
351 configUiTabs = configUiTabs.split( ',' );
\r
353 // "About us" should be always shown for standard config
\r
354 configUiTabs[3] = "1";
\r
356 for ( var i = 0; i < 4; i++ ) {
\r
357 uiTabs[i] = (typeof window.scayt != "undefined" && typeof window.scayt.uiTags != "undefined")
\r
358 ? (parseInt(configUiTabs[i],10) && window.scayt.uiTags[i])
\r
359 : parseInt(configUiTabs[i],10);
\r
363 loadEngine : function( editor )
\r
365 // SCAYT doesn't work with Firefox2, Opera and AIR.
\r
366 if ( CKEDITOR.env.gecko && CKEDITOR.env.version < 10900 || CKEDITOR.env.opera || CKEDITOR.env.air )
\r
367 return editor.fire( 'showScaytState' );
\r
369 if ( this.engineLoaded === true )
\r
371 return onEngineLoad.apply( editor );
\r
373 // Add new instance.
\r
374 else if ( this.engineLoaded == -1 )
\r
375 { // We are waiting.
\r
376 return CKEDITOR.on( 'scaytReady', function(){ onEngineLoad.apply( editor ); } ); // Use function(){} to avoid rejection as duplicate.
\r
379 CKEDITOR.on( 'scaytReady', onEngineLoad, editor );
\r
380 CKEDITOR.on( 'scaytReady', function()
\r
382 this.engineLoaded = true;
\r
387 ); // First to run.
\r
389 this.engineLoaded = -1; // Loading in progress.
\r
391 // compose scayt url
\r
392 var protocol = document.location.protocol;
\r
393 // Default to 'http' for unknown.
\r
394 protocol = protocol.search( /https?:/) != -1? protocol : 'http:';
\r
395 var baseUrl = 'svc.webspellchecker.net/scayt26/loader__base.js';
\r
397 var scaytUrl = editor.config.scayt_srcUrl || ( protocol + '//' + baseUrl );
\r
398 var scaytConfigBaseUrl = plugin.parseUrl( scaytUrl ).path + '/';
\r
400 if( window.scayt == undefined )
\r
402 CKEDITOR._djScaytConfig =
\r
404 baseUrl: scaytConfigBaseUrl,
\r
409 CKEDITOR.fireOnce( 'scaytReady' );
\r
414 // Append javascript code.
\r
415 CKEDITOR.document.getHead().append(
\r
416 CKEDITOR.document.createElement( 'script',
\r
420 type : 'text/javascript',
\r
429 CKEDITOR.fireOnce( 'scaytReady' );
\r
434 parseUrl : function ( data )
\r
437 if ( data.match && ( match = data.match(/(.*)[\/\\](.*?\.\w+)$/) ) )
\r
438 return { path: match[1], file: match[2] };
\r
444 var plugin = CKEDITOR.plugins.scayt;
\r
446 // Context menu constructing.
\r
447 var addButtonCommand = function( editor, buttonName, buttonLabel, commandName, command, menugroup, menuOrder )
\r
449 editor.addCommand( commandName, command );
\r
451 // If the "menu" plugin is loaded, register the menu item.
\r
452 editor.addMenuItem( commandName,
\r
454 label : buttonLabel,
\r
455 command : commandName,
\r
461 var commandDefinition =
\r
463 preserveState : true,
\r
464 editorFocus : false,
\r
467 exec: function( editor )
\r
469 if ( plugin.isScaytReady( editor ) )
\r
471 var isEnabled = plugin.isScaytEnabled( editor );
\r
473 this.setState( isEnabled ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_ON );
\r
475 var scayt_control = plugin.getScayt( editor );
\r
476 // the place where the status of editor focus should be restored
\r
477 // after there will be ability to store its state before SCAYT button click
\r
478 // if (storedFocusState is focused )
\r
479 // scayt_control.focus();
\r
481 // now focus is set certainly
\r
482 scayt_control.focus();
\r
483 scayt_control.setDisabled( isEnabled );
\r
485 else if ( !editor.config.scayt_autoStartup && plugin.engineLoaded >= 0 ) // Load first time
\r
487 this.setState( CKEDITOR.TRISTATE_DISABLED );
\r
488 plugin.loadEngine( editor );
\r
493 // Add scayt plugin.
\r
494 CKEDITOR.plugins.add( 'scayt',
\r
496 requires : [ 'menubutton' ],
\r
498 beforeInit : function( editor )
\r
500 var items_order = editor.config.scayt_contextMenuItemsOrder
\r
501 || 'suggest|moresuggest|control',
\r
502 items_order_str = "";
\r
504 items_order = items_order.split( '|' );
\r
506 if ( items_order && items_order.length )
\r
508 for ( var pos = 0 ; pos < items_order.length ; pos++ )
\r
509 items_order_str += 'scayt_' + items_order[ pos ] + ( items_order.length != parseInt( pos, 10 ) + 1 ? ',' : '' );
\r
512 // Put it on top of all context menu items (#5717)
\r
513 editor.config.menu_groups = items_order_str + ',' + editor.config.menu_groups;
\r
516 init : function( editor )
\r
518 // Delete span[data-scaytid] when text pasting in editor (#6921)
\r
519 var dataFilter = editor.dataProcessor && editor.dataProcessor.dataFilter;
\r
520 var dataFilterRules =
\r
524 span : function( element )
\r
526 var attrs = element.attributes;
\r
527 if ( attrs && attrs[ 'data-scaytid' ] )
\r
528 delete element.name;
\r
532 dataFilter && dataFilter.addRules( dataFilterRules );
\r
534 var moreSuggestions = {},
\r
535 mainSuggestions = {};
\r
538 var command = editor.addCommand( commandName, commandDefinition );
\r
540 // Add Options dialog.
\r
541 CKEDITOR.dialog.add( commandName, CKEDITOR.getUrl( this.path + 'dialogs/options.js' ) );
\r
543 var uiTabs = plugin.getUiTabs( editor );
\r
545 var menuGroup = 'scaytButton';
\r
546 editor.addMenuGroup( menuGroup );
\r
547 // combine menu items to render
\r
548 var uiMenuItems = {};
\r
550 var lang = editor.lang.scayt;
\r
553 uiMenuItems.scaytToggle =
\r
555 label : lang.enable,
\r
556 command : commandName,
\r
560 if ( uiTabs[0] == 1 )
\r
561 uiMenuItems.scaytOptions =
\r
563 label : lang.options,
\r
565 onClick : function()
\r
567 openPage = 'options';
\r
568 editor.openDialog( commandName );
\r
572 if ( uiTabs[1] == 1 )
\r
573 uiMenuItems.scaytLangs =
\r
575 label : lang.langs,
\r
577 onClick : function()
\r
579 openPage = 'langs';
\r
580 editor.openDialog( commandName );
\r
583 if ( uiTabs[2] == 1 )
\r
584 uiMenuItems.scaytDict =
\r
586 label : lang.dictionariesTab,
\r
588 onClick : function()
\r
590 openPage = 'dictionaries';
\r
591 editor.openDialog( commandName );
\r
595 uiMenuItems.scaytAbout =
\r
597 label : editor.lang.scayt.about,
\r
599 onClick : function()
\r
601 openPage = 'about';
\r
602 editor.openDialog( commandName );
\r
606 editor.addMenuItems( uiMenuItems );
\r
608 editor.ui.add( 'Scayt', CKEDITOR.UI_MENUBUTTON,
\r
610 label : lang.title,
\r
611 title : CKEDITOR.env.opera ? lang.opera_title : lang.title,
\r
612 className : 'cke_button_scayt',
\r
613 modes : { wysiwyg : 1 },
\r
614 onRender: function()
\r
616 command.on( 'state', function()
\r
618 this.setState( command.state );
\r
622 onMenu : function()
\r
624 var isEnabled = plugin.isScaytEnabled( editor );
\r
626 editor.getMenuItem( 'scaytToggle' ).label = lang[ isEnabled ? 'disable' : 'enable' ];
\r
628 var uiTabs = plugin.getUiTabs( editor );
\r
631 scaytToggle : CKEDITOR.TRISTATE_OFF,
\r
632 scaytOptions : isEnabled && uiTabs[0] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED,
\r
633 scaytLangs : isEnabled && uiTabs[1] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED,
\r
634 scaytDict : isEnabled && uiTabs[2] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED,
\r
635 scaytAbout : isEnabled && uiTabs[3] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED
\r
640 // If the "contextmenu" plugin is loaded, register the listeners.
\r
641 if ( editor.contextMenu && editor.addMenuItems )
\r
643 editor.contextMenu.addListener( function( element, selection )
\r
645 if ( !plugin.isScaytEnabled( editor )
\r
646 || selection.getRanges()[ 0 ].checkReadOnly() )
\r
649 var scayt_control = plugin.getScayt( editor ),
\r
650 node = scayt_control.getScaytNode();
\r
655 var word = scayt_control.getWord( node );
\r
660 var sLang = scayt_control.getLang(),
\r
661 items_suggestion = window.scayt.getSuggestion( word, sLang );
\r
662 // Remove unused commands and menuitems
\r
663 for ( var m in moreSuggestions )
\r
665 delete editor._.menuItems[ m ];
\r
666 delete editor._.commands[ m ];
\r
668 for ( m in mainSuggestions )
\r
670 delete editor._.menuItems[ m ];
\r
671 delete editor._.commands[ m ];
\r
673 moreSuggestions = {}; // Reset items.
\r
674 mainSuggestions = {};
\r
676 var moreSuggestionsUnable = editor.config.scayt_moreSuggestions || 'on';
\r
677 var moreSuggestionsUnableAdded = false;
\r
679 var maxSuggestions = editor.config.scayt_maxSuggestions;
\r
680 ( typeof maxSuggestions != 'number' ) && ( maxSuggestions = 5 );
\r
681 !maxSuggestions && ( maxSuggestions = items_suggestion.length );
\r
683 var contextCommands = editor.config.scayt_contextCommands || 'all';
\r
684 contextCommands = contextCommands.split( '|' );
\r
686 if ( items_suggestion && items_suggestion.length ) {
\r
687 for ( var i = 0, l = items_suggestion.length; i < l; i += 1 )
\r
689 var commandName = 'scayt_suggestion_' + items_suggestion[i].replace( ' ', '_' );
\r
690 var exec = ( function( el, s )
\r
695 scayt_control.replace(el, s);
\r
698 })( node, items_suggestion[i] );
\r
700 if ( i < maxSuggestions )
\r
702 addButtonCommand( editor, 'button_' + commandName, items_suggestion[i],
\r
703 commandName, exec, 'scayt_suggest', i + 1 );
\r
704 mainSuggestions[ commandName ] = CKEDITOR.TRISTATE_OFF;
\r
706 else if ( moreSuggestionsUnable == 'on' )
\r
708 addButtonCommand( editor, 'button_' + commandName, items_suggestion[i],
\r
709 commandName, exec, 'scayt_moresuggest', i + 1 );
\r
710 moreSuggestions[ commandName ] = CKEDITOR.TRISTATE_OFF;
\r
711 moreSuggestionsUnableAdded = true;
\r
715 if ( moreSuggestionsUnableAdded )
\r
717 // Register the More suggestions group;
\r
718 editor.addMenuItem( 'scayt_moresuggest',
\r
720 label : editor.lang.scayt.moreSuggestions,
\r
721 group : 'scayt_moresuggest',
\r
723 getItems : function()
\r
725 return moreSuggestions;
\r
728 mainSuggestions[ 'scayt_moresuggest' ] = CKEDITOR.TRISTATE_OFF;
\r
732 // "No suggestions" feature
\r
733 editor.addMenuItem( 'scayt_nosuggest',
\r
735 label : editor.lang.scayt.noSuggestions ? editor.lang.scayt.noSuggestions : (editor.lang.spellCheck.noSuggestions ? editor.lang.spellCheck.noSuggestions : 'No suggestions'),
\r
736 group : 'scayt_suggest',
\r
739 mainSuggestions[ 'scayt_nosuggest' ] = CKEDITOR.TRISTATE_OFF;
\r
742 if ( in_array( 'all', contextCommands ) || in_array( 'ignore', contextCommands) )
\r
744 var ignore_command = {
\r
746 scayt_control.ignore( node );
\r
749 addButtonCommand( editor, 'ignore', lang.ignore, 'scayt_ignore', ignore_command, 'scayt_control', 1 );
\r
750 mainSuggestions[ 'scayt_ignore' ] = CKEDITOR.TRISTATE_OFF;
\r
753 if ( in_array( 'all', contextCommands ) || in_array( 'ignoreall', contextCommands ) )
\r
755 var ignore_all_command = {
\r
757 scayt_control.ignoreAll( node );
\r
760 addButtonCommand(editor, 'ignore_all', lang.ignoreAll, 'scayt_ignore_all', ignore_all_command, 'scayt_control', 2);
\r
761 mainSuggestions['scayt_ignore_all'] = CKEDITOR.TRISTATE_OFF;
\r
764 if ( in_array( 'all', contextCommands ) || in_array( 'add', contextCommands ) )
\r
766 var addword_command = {
\r
768 window.scayt.addWordToUserDictionary( node );
\r
771 addButtonCommand(editor, 'add_word', lang.addWord, 'scayt_add_word', addword_command, 'scayt_control', 3);
\r
772 mainSuggestions['scayt_add_word'] = CKEDITOR.TRISTATE_OFF;
\r
775 if ( scayt_control.fireOnContextMenu )
\r
776 scayt_control.fireOnContextMenu( editor );
\r
778 return mainSuggestions;
\r
782 var showInitialState = function()
\r
784 editor.removeListener( 'showScaytState', showInitialState );
\r
786 if ( !CKEDITOR.env.opera && !CKEDITOR.env.air )
\r
787 command.setState( plugin.isScaytEnabled( editor ) ? CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF );
\r
789 command.setState( CKEDITOR.TRISTATE_DISABLED );
\r
792 editor.on( 'showScaytState', showInitialState );
\r
794 if ( CKEDITOR.env.opera || CKEDITOR.env.air )
\r
796 editor.on( 'instanceReady', function()
\r
798 showInitialState();
\r
803 if ( editor.config.scayt_autoStartup )
\r
805 editor.on( 'instanceReady', function()
\r
807 plugin.loadEngine( editor );
\r
812 afterInit : function( editor )
\r
814 // Prevent word marker line from displaying in elements path and been removed when cleaning format. (#3570) (#4125)
\r
815 var elementsPathFilters,
\r
816 scaytFilter = function( element )
\r
818 if ( element.hasAttribute( 'data-scaytid' ) )
\r
822 if ( editor._.elementsPath && ( elementsPathFilters = editor._.elementsPath.filters ) )
\r
823 elementsPathFilters.push( scaytFilter );
\r
825 editor.addRemoveFormatFilter && editor.addRemoveFormatFilter( scaytFilter );
\r
832 * If enabled (set to <code>true</code>), turns on SCAYT automatically
\r
833 * after loading the editor.
\r
834 * @name CKEDITOR.config.scayt_autoStartup
\r
836 * @default <code>false</code>
\r
838 * config.scayt_autoStartup = true;
\r
842 * Defines the number of SCAYT suggestions to show in the main context menu.
\r
843 * Possible values are:
\r
845 * <li><code>0</code> (zero) – All suggestions are displayed in the main context menu.</li>
\r
846 * <li>Positive number – The maximum number of suggestions to show in the context
\r
847 * menu. Other entries will be shown in the "More Suggestions" sub-menu.</li>
\r
848 * <li>Negative number – No suggestions are shown in the main context menu. All
\r
849 * entries will be listed in the the "Suggestions" sub-menu.</li>
\r
851 * @name CKEDITOR.config.scayt_maxSuggestions
\r
853 * @default <code>5</code>
\r
855 * // Display only three suggestions in the main context menu.
\r
856 * config.scayt_maxSuggestions = 3;
\r
858 * // Do not show the suggestions directly.
\r
859 * config.scayt_maxSuggestions = -1;
\r
863 * Sets the customer ID for SCAYT. Required for migration from free,
\r
864 * ad-supported version to paid, ad-free version.
\r
865 * @name CKEDITOR.config.scayt_customerid
\r
867 * @default <code>''</code>
\r
869 * // Load SCAYT using my customer ID.
\r
870 * config.scayt_customerid = 'your-encrypted-customer-id';
\r
874 * Enables/disables the "More Suggestions" sub-menu in the context menu.
\r
875 * Possible values are <code>on</code> and <code>off</code>.
\r
876 * @name CKEDITOR.config.scayt_moreSuggestions
\r
878 * @default <code>'on'</code>
\r
880 * // Disables the "More Suggestions" sub-menu.
\r
881 * config.scayt_moreSuggestions = 'off';
\r
885 * Customizes the display of SCAYT context menu commands ("Add Word", "Ignore"
\r
886 * and "Ignore All"). This must be a string with one or more of the following
\r
887 * words separated by a pipe character ("|"):
\r
889 * <li><code>off</code> – disables all options.</li>
\r
890 * <li><code>all</code> – enables all options.</li>
\r
891 * <li><code>ignore</code> – enables the "Ignore" option.</li>
\r
892 * <li><code>ignoreall</code> – enables the "Ignore All" option.</li>
\r
893 * <li><code>add</code> – enables the "Add Word" option.</li>
\r
895 * @name CKEDITOR.config.scayt_contextCommands
\r
897 * @default <code>'all'</code>
\r
899 * // Show only "Add Word" and "Ignore All" in the context menu.
\r
900 * config.scayt_contextCommands = 'add|ignoreall';
\r
904 * Sets the default spell checking language for SCAYT. Possible values are:
\r
905 * <code>en_US</code>, <code>en_GB</code>, <code>pt_BR</code>, <code>da_DK</code>,
\r
906 * <code>nl_NL</code>, <code>en_CA</code>, <code>fi_FI</code>, <code>fr_FR</code>,
\r
907 * <code>fr_CA</code>, <code>de_DE</code>, <code>el_GR</code>, <code>it_IT</code>,
\r
908 * <code>nb_NO</code>, <code>pt_PT</code>, <code>es_ES</code>, <code>sv_SE</code>.
\r
909 * @name CKEDITOR.config.scayt_sLang
\r
911 * @default <code>'en_US'</code>
\r
913 * // Sets SCAYT to German.
\r
914 * config.scayt_sLang = 'de_DE';
\r
918 * Sets the visibility of particular tabs in the SCAYT dialog window and toolbar
\r
919 * button. This setting must contain a <code>1</code> (enabled) or <code>0</code>
\r
920 * (disabled) value for each of the following entries, in this precise order,
\r
921 * separated by a comma (","): "Options", "Languages", and "Dictionary".
\r
922 * @name CKEDITOR.config.scayt_uiTabs
\r
924 * @default <code>'1,1,1'</code>
\r
926 * // Hides the "Languages" tab.
\r
927 * config.scayt_uiTabs = '1,0,1';
\r
932 * Sets the URL to SCAYT core. Required to switch to the licensed version of SCAYT application.
\r
933 * Further details available at
\r
934 * <a href="http://wiki.webspellchecker.net/doku.php?id=migration:hosredfreetolicensedck">
\r
935 * http://wiki.webspellchecker.net/doku.php?id=migration:hosredfreetolicensedck</a>.
\r
936 * @name CKEDITOR.config.scayt_srcUrl
\r
938 * @default <code>''</code>
\r
940 * config.scayt_srcUrl = "http://my-host/spellcheck/lf/scayt/scayt.js";
\r
944 * Links SCAYT to custom dictionaries. This is a string containing dictionary IDs
\r
945 * separared by commas (","). Available only for the licensed version.
\r
946 * Further details at
\r
947 * <a href="http://wiki.webspellchecker.net/doku.php?id=installationandconfiguration:customdictionaries:licensed">
\r
948 * http://wiki.webspellchecker.net/doku.php?id=installationandconfiguration:customdictionaries:licensed</a>.
\r
949 * @name CKEDITOR.config.scayt_customDictionaryIds
\r
951 * @default <code>''</code>
\r
953 * config.scayt_customDictionaryIds = '3021,3456,3478"';
\r
957 * Makes it possible to activate a custom dictionary in SCAYT. The user
\r
958 * dictionary name must be used. Available only for the licensed version.
\r
959 * @name CKEDITOR.config.scayt_userDictionaryName
\r
961 * @default <code>''</code>
\r
963 * config.scayt_userDictionaryName = 'MyDictionary';
\r
967 * Defines the order SCAYT context menu items by groups.
\r
968 * This must be a string with one or more of the following
\r
969 * words separated by a pipe character ("|"):
\r
971 * <li><code>suggest</code> – main suggestion word list,</li>
\r
972 * <li><code>moresuggest</code> – more suggestions word list,</li>
\r
973 * <li><code>control</code> – SCAYT commands, such as "Ignore" and "Add Word".</li>
\r
976 * @name CKEDITOR.config.scayt_contextMenuItemsOrder
\r
978 * @default <code>'suggest|moresuggest|control'</code>
\r
980 * config.scayt_contextMenuItemsOrder = 'moresuggest|control|suggest';
\r