Ticket #4650: 4650_2.patch
File 4650_2.patch, 5.4 KB (added by , 13 years ago) |
---|
-
_source/plugins/link/plugin.js
98 98 // If the "contextmenu" plugin is loaded, register the listeners. 99 99 if ( editor.contextMenu ) 100 100 { 101 editor.contextMenu.addListener( function( element, selection )101 editor.contextMenu.addListener( function( startElement, selection ) 102 102 { 103 var element = selection.getSelectedElement(); 104 103 105 if ( !element ) 104 106 return null; 105 107 -
_source/plugins/selection/plugin.js
625 625 { 626 626 range.optimize(); 627 627 628 // Decrease the range content to exclude particial629 // selected node on the start which doesn't have630 // visual impact. ( #3231 )631 while( true )632 {633 var startContainer = range.startContainer,634 startOffset = range.startOffset;635 // Limit the fix only to non-block elements.(#3950)636 if ( startOffset == ( startContainer.getChildCount ?637 startContainer.getChildCount() : startContainer.getLength() )638 && !startContainer.isBlockBoundary() )639 range.setStartAfter( startContainer );640 else break;641 }642 643 628 node = range.startContainer; 644 629 645 630 if ( node.type != CKEDITOR.NODE_ELEMENT ) … … 695 680 if ( cache.selectedElement !== undefined ) 696 681 return cache.selectedElement; 697 682 698 var node; 683 var node, 684 type = this.getType(); 699 685 700 if ( t his.getType()== CKEDITOR.SELECTION_ELEMENT )686 if ( type == CKEDITOR.SELECTION_ELEMENT ) 701 687 { 702 688 var sel = this.getNative(); 703 689 … … 714 700 var range = sel.getRangeAt( 0 ); 715 701 node = range.startContainer.childNodes[ range.startOffset ]; 716 702 } 703 704 node = new CKEDITOR.dom.element( node ); 717 705 } 706 // Somtimes browser lies on selection type (e.g. text[<img />]), figure it 707 // out by further checking the range. 708 else if ( type == CKEDITOR.SELECTION_TEXT ) 709 { 710 var range = this.getRanges()[ 0 ]; 711 range.optimize(); 712 var selectedStartNode = range.getTouchedStartNode(), 713 selectedEndNode = range.getTouchedEndNode(); 718 714 719 return cache.selectedElement = ( node ? new CKEDITOR.dom.element( node ) : null ); 715 if ( selectedStartNode.equals( selectedEndNode ) ) 716 node = selectedEndNode; 717 } 718 719 return ( cache.selectedElement = node && node.type == CKEDITOR.NODE_ELEMENT ? node : null ); 720 720 }, 721 721 722 722 lock : function() 723 723 { 724 724 // Call all cacheable function. 725 this.getRanges();726 this.getStartElement();727 725 this.getSelectedElement(); 726 this.getStartElement(); 727 this.getRanges(); 728 728 729 729 // The native selection is not available when locked. 730 730 this._.cache.nativeSel = {}; -
_source/core/dom/range.js
666 666 }, 667 667 668 668 /** 669 * Transforms the startContainer and endContainer properties from text 670 * nodes to element nodes, whenever possible. This is actually possible 671 * if either of the boundary containers point to a text node, and its 672 * offset is set to zero, or after the last char in the node. 669 * Perform structural changes to the range which don't have visual impacts.. 670 * <ul> 671 * <li>Transforms the start/end containers from text nodes to element nodes, 672 * whenever possible. This will happen if either of the boundary containers 673 * point to a text node, and its offset is set to zero, or after the last char in the node.</li> 674 * <li>Shrink either the start boundary which is at the end of any inline elements, 675 * or the end boundary which is at the front of line elements, by moving 676 * range container out of them util any block-level element are met.</li> 673 677 */ 674 678 optimize : function() 675 679 { … … 682 686 this.setStartBefore( container ); 683 687 else if ( offset >= container.getLength() ) 684 688 this.setStartAfter( container ); 689 690 this.optimize(); 685 691 } 692 else 693 { 694 // Decrease the range content to exclude particial 695 // selected node on the start which doesn't have 696 // visual impact. ( #3231 ) 697 while( true ) 698 { 699 // Limit the fix only to non-block elements.(#3950) 700 if ( offset == container.getChildCount() 701 && !container.isBlockBoundary() ) 702 this.setStartAfter( container ); 703 else break; 686 704 705 container = this.startContainer; 706 offset = this.startOffset; 707 } 708 } 709 687 710 container = this.endContainer; 688 711 offset = this.endOffset; 689 712 … … 693 716 this.setEndBefore( container ); 694 717 else if ( offset >= container.getLength() ) 695 718 this.setEndAfter( container ); 719 720 this.optimize(); 696 721 } 722 else 723 { 724 while( true ) 725 { 726 if ( offset == 0 727 && !container.isBlockBoundary() ) 728 this.setStartBefore( container ); 729 else break; 730 731 container = this.startContainer; 732 offset = this.startOffset; 733 } 734 } 697 735 }, 698 736 699 737 /**