Ticket #5145: 5145_8.patch
File 5145_8.patch, 11.4 KB (added by , 13 years ago) |
---|
-
_source/plugins/scayt/plugin.js
12 12 { 13 13 var commandName = 'scaytcheck', 14 14 openPage = '', 15 scayt_paused = null; 15 scayt_paused = null, 16 scayt_control_id = null; 16 17 17 18 // Checks if a value exists in an array 18 19 function in_array(needle, haystack) … … 37 38 { 38 39 // Initialise Scayt instance. 39 40 var oParams = {}; 40 oParams.srcNodeRef = editor.document.getWindow().$.frameElement; // Get the iframe. 41 // Get the iframe. 42 oParams.srcNodeRef = editor.document.getWindow().$.frameElement; 41 43 // syntax : AppName.AppVersion@AppRevision 42 44 oParams.assocApp = "CKEDITOR." + CKEDITOR.version + "@" + CKEDITOR.revision; 43 45 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 ;46 oParams.customDictionaryIds = editor.config.scayt_customDictionaryIds || ''; 47 oParams.userDictionaryName = editor.config.scayt_userDictionaryName || ''; 46 48 oParams.sLang = editor.config.scayt_sLang || "en_US"; 47 49 48 50 … … 54 56 oParams[ k ] = scayt_custom_params[ k ]; 55 57 } 56 58 } 57 59 60 if ( scayt_control_id ) 61 oParams.id = scayt_control_id; 62 58 63 var scayt_control = new window.scayt( oParams ); 59 64 60 65 // Copy config. … … 74 79 var fTabs = []; 75 80 76 81 for (var i = 0,l=4; i<l; i++) 77 82 fTabs.push( uiTabs[i] && plugin.uiTabs[i] ); 78 83 79 84 plugin.uiTabs = fTabs; 80 85 try { … … 111 116 if ( scayt_instanse ) 112 117 { 113 118 scayt_paused = scayt_instanse.paused = !scayt_instanse.disabled; 114 scayt_instanse.destroy(); 119 scayt_control_id = scayt_instanse.id; 120 scayt_instanse.destroy( true ); 115 121 delete plugin.instances[ editor.name ]; 116 122 } 117 123 } … … 120 126 121 127 editor.on( 'destroy', function() 122 128 { 123 plugin.getScayt( editor ).destroy(); 129 scayt_control_id = scayt_instanse.id; 130 plugin.getScayt( editor ).destroy( true ); 124 131 }); 125 132 // Listen to data manipulation to reflect scayt markup. 126 133 editor.on( 'afterSetData', function() 127 134 { 128 if ( plugin.isScaytEnabled( editor ) ) 129 plugin.getScayt( editor ).refresh(); 135 if ( plugin.isScaytEnabled( editor ) ) { 136 window.setTimeout( function(){ plugin.getScayt( editor ).refresh() }, 10 ); 137 } 130 138 }); 131 139 132 140 // Reload spell-checking for current word after insertion completed. … … 141 149 editor.getSelection().unlock( true ); 142 150 143 151 // Swallow any SCAYT engine errors. 144 try{ 145 scayt_instance.refresh(); 146 }catch( er ) 147 {} 152 window.setTimeout( function(){ scayt_instance.refresh() }, 10 ); 148 153 } 149 154 }, this, null, 50 ); 150 155 … … 160 165 editor.getSelection().unlock( true ); 161 166 162 167 // Swallow any SCAYT engine errors. 163 try{ 164 scayt_instance.refresh(); 165 }catch( er ) 166 {} 168 169 window.setTimeout( function(){ scayt_instance.refresh() },10 ); 170 167 171 } 168 172 }, this, null, 50 ); 169 173 … … 220 224 }, 221 225 loadEngine : function( editor ) 222 226 { 227 // SCAYT doesn't work with Opera. 228 if ( CKEDITOR.env.opera ) 229 return; 223 230 if ( this.engineLoaded === true ) 224 231 return onEngineLoad.apply( editor ); // Add new instance. 225 232 else if ( this.engineLoaded == -1 ) // We are waiting. … … 232 239 }, 233 240 this, 234 241 null, 235 0 ); // First to run. 242 0 243 ); // First to run. 236 244 237 245 this.engineLoaded = -1; // Loading in progress. 238 246 … … 240 248 var protocol = document.location.protocol; 241 249 // Default to 'http' for unknown. 242 250 protocol = protocol.search( /https?:/) != -1? protocol : 'http:'; 243 var baseUrl = "svc.spellchecker.net/spellcheck3 /lf/scayt/scayt21.js";251 var baseUrl = "svc.spellchecker.net/spellcheck31/lf/scayt/scayt22.js"; 244 252 245 253 var scaytUrl = editor.config.scayt_srcUrl || ( protocol + "//" + baseUrl ); 246 254 var scaytConfigBaseUrl = plugin.parseUrl( scaytUrl ).path + "/"; … … 357 365 // string tp array convert 358 366 confuiTabs = confuiTabs.split(","); 359 367 // check array length ! allwaays must be 3 filled with 1 or 0 360 for (var i=0,l=3; i<l; i++){ 368 for (var i=0,l=3; i<l; i++) 369 { 361 370 var flag = parseInt(confuiTabs[i] || "1" ,10); 362 371 uiTabs.push( flag ); 363 372 } … … 459 468 // If the "contextmenu" plugin is loaded, register the listeners. 460 469 if ( editor.contextMenu && editor.addMenuItems ) 461 470 { 462 editor.contextMenu.addListener( function( element)471 editor.contextMenu.addListener( function( ) 463 472 { 464 if ( ! ( plugin.isScaytEnabled( editor ) && element) )473 if ( !plugin.isScaytEnabled( editor ) ) 465 474 return null; 466 475 467 476 var scayt_control = plugin.getScayt( editor ), 468 word = scayt_control.getWord( element.$ ); 469 477 node = scayt_control.getScaytNode(); 478 479 if ( !node ) 480 return null; 481 482 var word = scayt_control.getWord( node ); 483 470 484 if ( !word ) 471 485 return null; 472 486 473 487 var sLang = scayt_control.getLang(), 474 488 _r = {}, 475 489 items_suggestion = window.scayt.getSuggestion( word, sLang ); 476 if ( !items_suggestion || !items_suggestion.length )490 if ( !items_suggestion || !items_suggestion.length ) 477 491 return null; 478 492 // Remove unused commands and menuitems 479 493 for ( i in moreSuggestions ) … … 510 524 scayt_control.replace(el, s); 511 525 } 512 526 }; 513 })( element.$, items_suggestion[i] );527 })( node, items_suggestion[i] ); 514 528 515 529 if ( i < maxSuggestions ) 516 530 { … … 548 562 { 549 563 var ignore_command = { 550 564 exec: function(){ 551 scayt_control.ignore( element.$);565 scayt_control.ignore( node ); 552 566 } 553 567 }; 554 568 addButtonCommand(editor, 'ignore', editor.lang.scayt.ignore, 'scayt_ignore', ignore_command, 'scayt_control', 1); … … 559 573 { 560 574 var ignore_all_command = { 561 575 exec: function(){ 562 scayt_control.ignoreAll( element.$);576 scayt_control.ignoreAll( node ); 563 577 } 564 578 }; 565 579 addButtonCommand(editor, 'ignore_all', editor.lang.scayt.ignoreAll, 'scayt_ignore_all', ignore_all_command, 'scayt_control', 2); … … 570 584 { 571 585 var addword_command = { 572 586 exec: function(){ 573 window.scayt.addWordToUserDictionary( element.$);587 window.scayt.addWordToUserDictionary( node ); 574 588 } 575 589 }; 576 590 addButtonCommand(editor, 'add_word', editor.lang.scayt.addWord, 'scayt_add_word', addword_command, 'scayt_control', 3); … … 593 607 command.setState( plugin.isScaytEnabled( editor ) ? CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF ); 594 608 }; 595 609 editor.on( 'showScaytState', showInitialState ); 596 597 610 plugin.loadEngine( editor ); 598 611 } 599 612 … … 612 625 }); 613 626 })(); 614 627 615 // TODO: Documentation 616 // CKEDITOR.config.scayt_maxSuggestions 617 // CKEDITOR.config.scayt_autoStartup 628 /** 629 * If enabled (true), turns on SCAYT automatically after loading the editor. 630 * @name CKEDITOR.config.scayt_autoStartup 631 * @type Boolean 632 * @default false 633 * @example 634 * config.scayt_autoStartup = true; 635 */ 636 637 /** 638 * Defines the number of SCAYT suggestions to show in the main context menu. 639 * The possible values are: 640 * <ul> 641 * <li>0 (zero): All suggestions are displayed in the main context menu.</li> 642 * <li>Positive number: The maximum number of suggestions to shown in context 643 * menu. Other entries will be shown in "More Suggestions" sub-menu.</li> 644 * <li>Negative number: No suggestions are shown in the main context menu. All 645 * entries will be listed in the "Suggestions" sub-menu.</li> 646 * </ul> 647 * @name CKEDITOR.config.scayt_maxSuggestions 648 * @type Number 649 * @default 5 650 * @example 651 * // Display only three suggestions in the main context menu. 652 * config.scayt_maxSuggestions = 3; 653 * @example 654 * // Do not show the suggestions directly. 655 * config.scayt_maxSuggestions = -1; 656 */ 657 658 /** 659 * Sets the customer ID for SCAYT. Required for migration from free version 660 * with banner to paid version. 661 * @name CKEDITOR.config.scayt_customerid 662 * @type String 663 * @default '' 664 * @example 665 * // Load SCAYT using my customer ID. 666 * config.scayt_customerid = 'your-encrypted-customer-id'; 667 */ 668 669 /** 670 * Enables/disables the "More Suggestions" sub-menu in the context menu. 671 * The possible values are "on" or "off". 672 * @name CKEDITOR.config.scayt_moreSuggestions 673 * @type String 674 * @default 'on' 675 * @example 676 * // Disables the "More Suggestions" sub-menu. 677 * config.scayt_moreSuggestions = 'off'; 678 */ 679 680 /** 681 * Customizes the display of SCAYT context menu commands ("Add Word", "Ignore" 682 * and "Ignore All"). It must be a string with one or more of the following 683 * words separated by a pipe ("|"): 684 * <ul> 685 * <li>"off": disables all options.</li> 686 * <li>"all": enables all options.</li> 687 * <li>"ignore": enables the "Ignore" option.</li> 688 * <li>"ignoreall": enables the "Ignore All" option.</li> 689 * <li>"add": enables the "Add Word" option.</li> 690 * </ul> 691 * @name CKEDITOR.config.scayt_contextCommands 692 * @type String 693 * @default 'all' 694 * @example 695 * // Show only "Add Word" and "Ignore All" in the context menu. 696 * config.scayt_contextCommands = 'add|ignoreall'; 697 */ 698 699 /** 700 * Sets the default spellchecking language for SCAYT. 701 * @name CKEDITOR.config.scayt_sLang 702 * @type String 703 * @default 'en_US' 704 * @example 705 * // Sets SCAYT to German. 706 * config.scayt_sLang = 'de_DE'; 707 */ 708 709 /** 710 * Sets the visibility of the SCAYT tabs in the settings dialog and toolbar 711 * button. The value must contain a "1" (enabled) or "0" (disabled) number for 712 * each of the following entries, in this precise order, separated by a 713 * comma (","): "Options", "Languages" and "Dictionary". 714 * @name CKEDITOR.config.scayt_uiTabs 715 * @type String 716 * @default '1,1,1' 717 * @example 718 * // Hide the "Languages" tab. 719 * config.scayt_uiTabs = '1,0,1'; 720 */ 721 722 723 /** 724 * Set the URL to SCAYT core. Required to switch to licensed version of SCAYT application. 725 * Further details at http://wiki.spellchecker.net/doku.php?id=3rd:wysiwyg:fckeditor:wscckf3l . 726 * @name CKEDITOR.config.scayt_srcUrl 727 * @type String 728 * @default '' 729 * @example 730 * config.scayt_srcUrl = "http://my-host/spellcheck/lf/scayt/scayt.js"; 731 */ 732 733 /** 734 * Links SCAYT to custom dictionaries. It's a string containing dictionary ids 735 * separared by commas (","). Available only for licensed version. 736 * Further details at http://wiki.spellchecker.net/doku.php?id=custom_dictionary_support . 737 * @name CKEDITOR.config.scayt_customDictionaryIds 738 * @type String 739 * @default '' 740 * @example 741 * config.scayt_customDictionaryIds = '3021,3456,3478"'; 742 */ 743 744 /** 745 * Makes it possible to activate a custom dictionary on SCAYT. The user 746 * dictionary name must be used. Available only for licensed version. 747 * @name CKEDITOR.config.scayt_userDictionaryName 748 * @type String 749 * @default '' 750 * @example 751 * config.scayt_userDictionaryName = 'MyDictionary'; 752 */ 753