Ticket #5145: 5145_6.patch
File 5145_6.patch, 12.2 KB (added by , 14 years ago) |
---|
-
_source/plugins/scayt/plugin.js
10 10 11 11 (function() 12 12 { 13 13 14 var commandName = 'scaytcheck', 14 15 openPage = '', 15 scayt_paused = null; 16 scayt_paused = null, 17 scayt_control_id = null; 16 18 17 19 // Checks if a value exists in an array 18 20 function in_array(needle, haystack) … … 37 39 { 38 40 // Initialise Scayt instance. 39 41 var oParams = {}; 40 oParams.srcNodeRef = editor.document.getWindow().$.frameElement; // Get the iframe. 42 // Get the iframe. 43 oParams.srcNodeRef = editor.document.getWindow().$.frameElement; 41 44 // syntax : AppName.AppVersion@AppRevision 42 45 oParams.assocApp = "CKEDITOR." + CKEDITOR.version + "@" + CKEDITOR.revision; 43 46 oParams.customerid = editor.config.scayt_customerid || "1:WvF0D4-UtPqN1-43nkD4-NKvUm2-daQqk3-LmNiI-z7Ysb4-mwry24-T8YrS3-Q2tpq2"; 44 oParams.customDictionaryIds = editor.config.scayt_customDictionaryIds ;45 oParams.userDictionaryName = editor.config.scayt_userDictionaryName ;47 oParams.customDictionaryIds = editor.config.scayt_customDictionaryIds || ''; 48 oParams.userDictionaryName = editor.config.scayt_userDictionaryName || ''; 46 49 oParams.sLang = editor.config.scayt_sLang || "en_US"; 47 48 if ( CKEDITOR._ scaytParams )50 51 if ( CKEDITOR._.scaytParams ) 49 52 { 50 for ( var k in CKEDITOR._ scaytParams )53 for ( var k in CKEDITOR._.scaytParams ) 51 54 { 52 oParams[ k ] = CKEDITOR._ scaytParams[ k ];55 oParams[ k ] = CKEDITOR._.scaytParams[ k ]; 53 56 } 54 57 } 55 58 59 if ( scayt_control_id ) 60 oParams.id = scayt_control_id; 61 56 62 var scayt_control = new window.scayt( oParams ); 57 63 58 64 // Copy config. … … 72 78 var fTabs = []; 73 79 74 80 for (var i = 0,l=4; i<l; i++) 75 81 fTabs.push( uiTabs[i] && plugin.uiTabs[i] ); 76 82 77 83 plugin.uiTabs = fTabs; 78 84 try { … … 103 109 104 110 editor.on( 'beforeCommandExec', function( ev ) // Disable SCAYT before Source command execution. 105 111 { 112 if ( ev.data.name == 'removeFormat' && editor.mode == 'wysiwyg' ) 113 { 114 115 if (plugin.isScaytEnabled(editor)) 116 window.setTimeout(function(){plugin.getScayt(editor).refresh()},10); 117 118 } 106 119 if ( (ev.data.name == 'source' || ev.data.name == 'newpage') && editor.mode == 'wysiwyg' ) 107 120 { 108 121 var scayt_instanse = plugin.getScayt( editor ); 109 122 if ( scayt_instanse ) 110 123 { 111 124 scayt_paused = scayt_instanse.paused = !scayt_instanse.disabled; 112 scayt_instanse.destroy(); 113 delete plugin.instances[ editor.name ]; 125 scayt_control_id = scayt_instanse.id; 126 scayt_instanse.destroy(true); 127 delete plugin.instances[editor.name]; 114 128 } 115 129 } 116 130 }); … … 118 132 119 133 editor.on( 'destroy', function() 120 134 { 121 plugin.getScayt( editor ).destroy(); 135 scayt_control_id = scayt_instanse.id; 136 plugin.getScayt( editor ).destroy(true); 122 137 }); 123 138 // Listen to data manipulation to reflect scayt markup. 124 139 editor.on( 'afterSetData', function() 125 140 { 126 if ( plugin.isScaytEnabled( editor ) ) 127 plugin.getScayt( editor ).refresh(); 141 if (plugin.isScaytEnabled(editor)) { 142 window.setTimeout(function(){plugin.getScayt(editor).refresh()},10); 143 144 if( !editor.checkDirty() ) 145 setTimeout( function(){ editor.resetDirty(); } ); 146 147 } 128 148 }); 129 149 130 150 // Reload spell-checking for current word after insertion completed. … … 139 159 editor.getSelection().unlock( true ); 140 160 141 161 // Swallow any SCAYT engine errors. 142 try{ 143 scayt_instance.refresh(); 144 }catch( er ) 145 {} 162 window.setTimeout(function(){scayt_instance.refresh()},10); 163 146 164 } 147 165 }, this, null, 50 ); 148 166 … … 158 176 editor.getSelection().unlock( true ); 159 177 160 178 // Swallow any SCAYT engine errors. 161 try{ 162 scayt_instance.refresh(); 163 }catch( er ) 164 {} 179 180 window.setTimeout(function(){scayt_instance.refresh()},10); 181 165 182 } 166 183 }, this, null, 50 ); 167 184 … … 218 235 }, 219 236 loadEngine : function( editor ) 220 237 { 238 if (CKEDITOR.env.opera) 239 return; 221 240 if ( this.engineLoaded === true ) 222 241 return onEngineLoad.apply( editor ); // Add new instance. 223 242 else if ( this.engineLoaded == -1 ) // We are waiting. … … 230 249 }, 231 250 this, 232 251 null, 233 0 ); // First to run. 252 0 253 ); // First to run. 234 254 235 255 this.engineLoaded = -1; // Loading in progress. 236 256 … … 238 258 var protocol = document.location.protocol; 239 259 // Default to 'http' for unknown. 240 260 protocol = protocol.search( /https?:/) != -1? protocol : 'http:'; 241 var baseUrl = "svc.spellchecker.net/spellcheck3 /lf/scayt/scayt21.js";261 var baseUrl = "svc.spellchecker.net/spellcheck31/lf/scayt/scayt22.js"; 242 262 243 263 var scaytUrl = editor.config.scayt_srcUrl || ( protocol + "//" + baseUrl ); 244 264 var scaytConfigBaseUrl = plugin.parseUrl( scaytUrl ).path + "/"; … … 355 375 // string tp array convert 356 376 confuiTabs = confuiTabs.split(","); 357 377 // check array length ! allwaays must be 3 filled with 1 or 0 358 for (var i=0,l=3; i<l; i++){ 378 for (var i=0,l=3; i<l; i++) 379 { 359 380 var flag = parseInt(confuiTabs[i] || "1" ,10); 360 381 uiTabs.push( flag ); 361 382 } … … 457 478 // If the "contextmenu" plugin is loaded, register the listeners. 458 479 if ( editor.contextMenu && editor.addMenuItems ) 459 480 { 460 editor.contextMenu.addListener( function( element)481 editor.contextMenu.addListener( function( ) 461 482 { 462 if ( !( plugin.isScaytEnabled( editor ) && element ) )483 if (!plugin.isScaytEnabled(editor)) 463 484 return null; 464 485 465 486 var scayt_control = plugin.getScayt( editor ), 466 word = scayt_control.getWord( element.$ ); 487 node = scayt_control.getScaytNode(); 488 489 if (!node) 490 return null; 467 491 468 if ( !word ) 492 word = scayt_control.getWord( node ); 493 494 if (!word) 469 495 return null; 470 496 471 497 var sLang = scayt_control.getLang(), 472 498 _r = {}, 473 499 items_suggestion = window.scayt.getSuggestion( word, sLang ); 474 if (!items_suggestion || !items_suggestion.length )500 if (!items_suggestion || !items_suggestion.length) 475 501 return null; 476 502 // Remove unused commands and menuitems 477 503 for ( i in moreSuggestions ) … … 508 534 scayt_control.replace(el, s); 509 535 } 510 536 }; 511 })( element.$, items_suggestion[i] );537 })( node, items_suggestion[i] ); 512 538 513 539 if ( i < maxSuggestions ) 514 540 { … … 546 572 { 547 573 var ignore_command = { 548 574 exec: function(){ 549 scayt_control.ignore( element.$);575 scayt_control.ignore(node); 550 576 } 551 577 }; 552 578 addButtonCommand(editor, 'ignore', editor.lang.scayt.ignore, 'scayt_ignore', ignore_command, 'scayt_control', 1); … … 557 583 { 558 584 var ignore_all_command = { 559 585 exec: function(){ 560 scayt_control.ignoreAll( element.$);586 scayt_control.ignoreAll(node); 561 587 } 562 588 }; 563 589 addButtonCommand(editor, 'ignore_all', editor.lang.scayt.ignoreAll, 'scayt_ignore_all', ignore_all_command, 'scayt_control', 2); … … 568 594 { 569 595 var addword_command = { 570 596 exec: function(){ 571 window.scayt.addWordToUserDictionary( element.$);597 window.scayt.addWordToUserDictionary(node); 572 598 } 573 599 }; 574 600 addButtonCommand(editor, 'add_word', editor.lang.scayt.addWord, 'scayt_add_word', addword_command, 'scayt_control', 3); … … 591 617 command.setState( plugin.isScaytEnabled( editor ) ? CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF ); 592 618 }; 593 619 editor.on( 'showScaytState', showInitialState ); 594 595 620 plugin.loadEngine( editor ); 596 621 } 597 622 } 598 623 }); 599 624 })(); 600 625 601 // TODO: Documentation 602 // CKEDITOR.config.scayt_maxSuggestions 603 // CKEDITOR.config.scayt_autoStartup 626 /** 627 * If enabled (true), turns on SCAYT automatically after loading the editor. 628 * @name CKEDITOR.config.scayt_autoStartup 629 * @type Boolean 630 * @default false 631 * @example 632 * config.scayt_autoStartup = true; 633 */ 634 635 /** 636 * Defines the number of SCAYT suggestions to show in the main context menu. 637 * The possible values are: 638 * <ul> 639 * <li>0 (zero): All suggestions are displayed in the main context menu.</li> 640 * <li>Positive number: The maximum number of suggestions to shown in context 641 * menu. Other entries will be shown in "More Suggestions" sub-menu.</li> 642 * <li>Negative number: No suggestions are shown in the main context menu. All 643 * entries will be listed in the "Suggestions" sub-menu.</li> 644 * </ul> 645 * @name CKEDITOR.config.scayt_maxSuggestions 646 * @type Number 647 * @default 5 648 * @example 649 * // Display only three suggestions in the main context menu. 650 * config.scayt_maxSuggestions = 3; 651 * @example 652 * // Do not show the suggestions directly. 653 * config.scayt_maxSuggestions = -1; 654 */ 655 656 /** 657 * Sets the customer ID for SCAYT. Required for migration from free version 658 * with banner to paid version. 659 * @name CKEDITOR.config.scayt_customerid 660 * @type String 661 * @default '' 662 * @example 663 * // Load SCAYT using my customer ID. 664 * config.scayt_customerid = 'your-encrypted-customer-id'; 665 */ 666 667 /** 668 * Enables/disables the "More Suggestions" sub-menu in the context menu. 669 * The possible values are "on" or "off". 670 * @name CKEDITOR.config.scayt_moreSuggestions 671 * @type String 672 * @default 'on' 673 * @example 674 * // Disables the "More Suggestions" sub-menu. 675 * config.scayt_moreSuggestions = 'off'; 676 */ 677 678 /** 679 * Customizes the display of SCAYT context menu commands ("Add Word", "Ignore" 680 * and "Ignore All"). It must be a string with one or more of the following 681 * words separated by a pipe ("|"): 682 * <ul> 683 * <li>"off": disables all options.</li> 684 * <li>"all": enables all options.</li> 685 * <li>"ignore": enables the "Ignore" option.</li> 686 * <li>"ignoreall": enables the "Ignore All" option.</li> 687 * <li>"add": enables the "Add Word" option.</li> 688 * </ul> 689 * @name CKEDITOR.config.scayt_contextCommands 690 * @type String 691 * @default 'all' 692 * @example 693 * // Show only "Add Word" and "Ignore All" in the context menu. 694 * config.scayt_contextCommands = 'add|ignoreall'; 695 */ 696 697 /** 698 * Sets the default spellchecking language for SCAYT. 699 * @name CKEDITOR.config.scayt_sLang 700 * @type String 701 * @default 'en_US' 702 * @example 703 * // Sets SCAYT to German. 704 * config.scayt_sLang = 'de_DE'; 705 */ 706 707 /** 708 * Sets the visibility of the SCAYT tabs in the settings dialog and toolbar 709 * button. The value must contain a "1" (enabled) or "0" (disabled) number for 710 * each of the following entries, in this precise order, separated by a 711 * comma (","): "Options", "Languages" and "Dictionary". 712 * @name CKEDITOR.config.scayt_uiTabs 713 * @type String 714 * @default '1,1,1' 715 * @example 716 * // Hide the "Languages" tab. 717 * config.scayt_uiTabs = '1,0,1'; 718 */ 719 720 721 /** 722 * Set the URL to SCAYT core. Required to switch to licensed version of SCAYT application. 723 * Further details at http://wiki.spellchecker.net/doku.php?id=3rd:wysiwyg:fckeditor:wscckf3l . 724 * @name CKEDITOR.config.scayt_srcUrl 725 * @type String 726 * @default '' 727 * @example 728 * config.scayt_srcUrl = "http://my-host/spellcheck/lf/scayt/scayt.js"; 729 */ 730 731 /** 732 * Links SCAYT to custom dictionaries. It's a string containing dictionary ids 733 * separared by commas (","). Available only for licensed version. 734 * Further details at http://wiki.spellchecker.net/doku.php?id=custom_dictionary_support . 735 * @name CKEDITOR.config.scayt_customDictionaryIds 736 * @type String 737 * @default '' 738 * @example 739 * config.scayt_customDictionaryIds = '3021,3456,3478"'; 740 */ 741 742 /** 743 * Makes it possible to activate a custom dictionary on SCAYT. The user 744 * dictionary name must be used. Available only for licensed version. 745 * @name CKEDITOR.config.scayt_userDictionaryName 746 * @type String 747 * @default '' 748 * @example 749 * config.scayt_userDictionaryName = 'MyDictionary'; 750 */ 751