Ticket #5145: 5145_3.patch
File 5145_3.patch, 8.9 KB (added by , 13 years ago) |
---|
-
_source/plugins/scayt/plugin.js
41 41 // syntax : AppName.AppVersion@AppRevision 42 42 oParams.assocApp = "CKEDITOR." + CKEDITOR.version + "@" + CKEDITOR.revision; 43 43 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 ;44 oParams.customDictionaryIds = editor.config.scayt_customDictionaryIds || ''; 45 oParams.userDictionaryName = editor.config.scayt_userDictionaryName || ''; 46 46 oParams.sLang = editor.config.scayt_sLang || "en_US"; 47 47 48 if ( CKEDITOR. _scaytParams )48 if ( CKEDITOR.config._scaytParams ) 49 49 { 50 for ( var k in CKEDITOR. _scaytParams )50 for ( var k in CKEDITOR.config._scaytParams ) 51 51 { 52 oParams[ k ] = CKEDITOR. _scaytParams[ k ];52 oParams[ k ] = CKEDITOR.config._scaytParams[ k ]; 53 53 } 54 54 } 55 55 … … 103 103 104 104 editor.on( 'beforeCommandExec', function( ev ) // Disable SCAYT before Source command execution. 105 105 { 106 if ( ev.data.name == 'removeFormat' && editor.mode == 'wysiwyg' ) 107 { 108 109 if ( plugin.isScaytEnabled( editor ) ) 110 window.setTimeout(function(){plugin.getScayt(editor).refresh()},10); 111 112 } 106 113 if ( (ev.data.name == 'source' || ev.data.name == 'newpage') && editor.mode == 'wysiwyg' ) 107 114 { 108 115 var scayt_instanse = plugin.getScayt( editor ); 109 116 if ( scayt_instanse ) 110 117 { 111 118 scayt_paused = scayt_instanse.paused = !scayt_instanse.disabled; 112 scayt_instanse.destroy( );113 delete plugin.instances[ editor.name];119 scayt_instanse.destroy( true ); 120 delete plugin.instances[editor.name]; 114 121 } 115 122 } 116 123 }); … … 118 125 119 126 editor.on( 'destroy', function() 120 127 { 121 plugin.getScayt( editor ).destroy( );128 plugin.getScayt( editor ).destroy( true ); 122 129 }); 123 130 // Listen to data manipulation to reflect scayt markup. 124 131 editor.on( 'afterSetData', function() 125 132 { 126 133 if ( plugin.isScaytEnabled( editor ) ) 134 { 127 135 plugin.getScayt( editor ).refresh(); 136 137 if( !editor.checkDirty() ) 138 setTimeout( function(){ editor.resetDirty(); } ); 139 } 128 140 }); 129 141 130 142 // Reload spell-checking for current word after insertion completed. … … 218 230 }, 219 231 loadEngine : function( editor ) 220 232 { 233 if ( CKEDITOR.env.opera ) 234 return; 221 235 if ( this.engineLoaded === true ) 222 236 return onEngineLoad.apply( editor ); // Add new instance. 223 237 else if ( this.engineLoaded == -1 ) // We are waiting. … … 238 252 var protocol = document.location.protocol; 239 253 // Default to 'http' for unknown. 240 254 protocol = protocol.search( /https?:/) != -1? protocol : 'http:'; 241 var baseUrl = "svc.spellchecker.net/spellcheck3/lf/scayt/scayt2 1.js";255 var baseUrl = "svc.spellchecker.net/spellcheck3/lf/scayt/scayt22.js"; 242 256 243 257 var scaytUrl = editor.config.scayt_srcUrl || ( protocol + "//" + baseUrl ); 244 258 var scaytConfigBaseUrl = plugin.parseUrl( scaytUrl ).path + "/"; … … 457 471 // If the "contextmenu" plugin is loaded, register the listeners. 458 472 if ( editor.contextMenu && editor.addMenuItems ) 459 473 { 460 editor.contextMenu.addListener( function( element)474 editor.contextMenu.addListener( function() 461 475 { 462 if ( ! ( plugin.isScaytEnabled( editor ) && element ) )476 if ( !plugin.isScaytEnabled( editor ) ) 463 477 return null; 464 478 465 479 var scayt_control = plugin.getScayt( editor ), 466 word = scayt_control.getWord( element.$);480 node = scayt_control.getScaytNode(); 467 481 482 if ( !node ) 483 return null; 484 485 word = scayt_control.getWord( node ); 486 468 487 if ( !word ) 469 488 return null; 470 489 … … 508 527 scayt_control.replace(el, s); 509 528 } 510 529 }; 511 })( element.$, items_suggestion[i] );530 })( node, items_suggestion[i] ); 512 531 513 532 if ( i < maxSuggestions ) 514 533 { … … 546 565 { 547 566 var ignore_command = { 548 567 exec: function(){ 549 scayt_control.ignore( element.$);568 scayt_control.ignore( node ); 550 569 } 551 570 }; 552 571 addButtonCommand(editor, 'ignore', editor.lang.scayt.ignore, 'scayt_ignore', ignore_command, 'scayt_control', 1); … … 557 576 { 558 577 var ignore_all_command = { 559 578 exec: function(){ 560 scayt_control.ignoreAll( element.$);579 scayt_control.ignoreAll( node ); 561 580 } 562 581 }; 563 582 addButtonCommand(editor, 'ignore_all', editor.lang.scayt.ignoreAll, 'scayt_ignore_all', ignore_all_command, 'scayt_control', 2); … … 568 587 { 569 588 var addword_command = { 570 589 exec: function(){ 571 window.scayt.addWordToUserDictionary( element.$);590 window.scayt.addWordToUserDictionary( node ); 572 591 } 573 592 }; 574 593 addButtonCommand(editor, 'add_word', editor.lang.scayt.addWord, 'scayt_add_word', addword_command, 'scayt_control', 3); … … 598 617 }); 599 618 })(); 600 619 601 // TODO: Documentation 602 // CKEDITOR.config.scayt_maxSuggestions 603 // CKEDITOR.config.scayt_autoStartup 620 /** 621 * If enabled (true), turns on SCAYT automatically after loading the editor. 622 * @name CKEDITOR.config.scayt_autoStartup 623 * @type Boolean 624 * @default false 625 * @example 626 * config.scayt_autoStartup = true; 627 */ 628 629 /** 630 * Defines the number of SCAYT suggestions to show in the main context menu. 631 * The possible values are: 632 * <ul> 633 * <li>0 (zero): All suggestions are displayed in the main context menu.</li> 634 * <li>Positive number: The maximum number of suggestions to shown in context 635 * menu. Other entries will be shown in "More Suggestions" sub-menu.</li> 636 * <li>Negative number: No suggestions are shown in the main context menu. All 637 * entries will be listed in the "Suggestions" sub-menu.</li> 638 * </ul> 639 * @name CKEDITOR.config.scayt_maxSuggestions 640 * @type Number 641 * @default 5 642 * @example 643 * // Display only three suggestions in the main context menu. 644 * config.scayt_maxSuggestions = 3; 645 * @example 646 * // Do not show the suggestions directly. 647 * config.scayt_maxSuggestions = -1; 648 */ 649 650 /** 651 * Sets the customer ID for SCAYT. 652 * @name CKEDITOR.config.scayt_customerid 653 * @type String 654 * @default '' 655 * @example 656 * // Load SCAYT using my customer ID. 657 * config.scayt_customerid = 'your-encrypted-customer-id'; 658 */ 659 660 /** 661 * Enables/disables the "More Suggestions" sub-menu in the context menu. 662 * The possible values are "on" or "off". 663 * @name CKEDITOR.config.scayt_moreSuggestions 664 * @type String 665 * @default 'on' 666 * @example 667 * // Disables the "More Suggestions" sub-menu. 668 * config.scayt_moreSuggestions = 'off'; 669 */ 670 671 /** 672 * Customizes the display of SCAYT context menu commands ("Add Word", "Ignore" 673 * and "Ignore All"). It must be a string with one or more of the following 674 * words separated by a pipe ("|"): 675 * <ul> 676 * <li>"off": disables all options.</li> 677 * <li>"all": enables all options.</li> 678 * <li>"ignore": enables the "Ignore" option.</li> 679 * <li>"ignoreall": enables the "Ignore All" option.</li> 680 * <li>"add": enables the "Add Word" option.</li> 681 * </ul> 682 * @name CKEDITOR.config.scayt_contextCommands 683 * @type String 684 * @default 'all' 685 * @example 686 * // Show only "Add Word" and "Ignore All" in the context menu. 687 * config.scayt_contextCommands = 'add|ignoreall'; 688 */ 689 690 /** 691 * Sets the default spellchecking language for SCAYT. 692 * @name CKEDITOR.config.scayt_sLang 693 * @type String 694 * @default 'en_US' 695 * @example 696 * // Sets SCAYT to German. 697 * config.scayt_sLang = 'de_DE'; 698 */ 699 700 /** 701 * Sets the visibility of the SCAYT tabs in the settings dialog and toolbar 702 * button. The value must contain a "1" (enabled) or "0" (disabled) number for 703 * each of the following entries, in this precise order, separated by a 704 * comma (","): "Options", "Languages" and "Dictionary". 705 * @name CKEDITOR.config.scayt_uiTabs 706 * @type String 707 * @default '1,1,1' 708 * @example 709 * // Hide the "Languages" tab. 710 * config.scayt_uiTabs = '1,0,1'; 711 */ 712 713 /** 714 * Links SCAYT to custom dictionaries. It's a string containing dictionary ids 715 * separared by commas (","). 716 * @name CKEDITOR.config.scayt_customDictionaryIds 717 * @type String 718 * @default '' 719 * @example 720 * config.scayt_customDictionaryIds = '3021,3456,3478"'; 721 */ 722 723 /** 724 * Makes it possible to activate a custom dictionary on SCAYT. The user 725 * dictionary name must be used. 726 * @name CKEDITOR.config.scayt_userDictionaryName 727 * @type String 728 * @default '' 729 * @example 730 * config.scayt_userDictionaryName = 'MyDictionary'; 731 */