Ticket #9080: 9080_3.patch
File 9080_3.patch, 9.7 KB (added by , 11 years ago) |
---|
-
_source/plugins/selection/plugin.js
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
589 589 command : 'selectAll' 590 590 }); 591 591 592 editor.selectionChange = checkSelectionChangeTimeout; 592 /** 593 * Check if to fire the {@link CKEDITOR.editor#selectionChange} event 594 * for the current editor instance. 595 * 596 * @param {Boolean} checkNow Check immediately without any delay. 597 */ 598 editor.selectionChange = function( checkNow ) 599 { 600 ( checkNow ? checkSelectionChange : checkSelectionChangeTimeout ).call( this ); 601 }; 593 602 594 603 // IE9 might cease to work if there's an object selection inside the iframe (#7639). 595 604 CKEDITOR.env.ie9Compat && editor.on( 'destroy', function() -
_source/core/dom/walker.js
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
455 455 456 456 return function( node ) 457 457 { 458 var parent = node.getParent(), 459 isBogus = !CKEDITOR.env.ie ? node.is && node.is( 'br' ) : 458 var isBogus = !CKEDITOR.env.ie ? node.is && node.is( 'br' ) : 460 459 node.getText && tailNbspRegex.test( node.getText() ); 461 460 462 isBogus = isBogus && parent.isBlockBoundary() && !!parent.getLast( nonEmpty ); 461 if ( isBogus ) 462 { 463 var parent = node.getParent(), next = node.getNext( nonEmpty ); 464 isBogus = parent.isBlockBoundary() && 465 ( !next || 466 next.type == CKEDITOR.NODE_ELEMENT && 467 next.isBlockBoundary() ); 468 } 463 469 464 470 return !! ( isReject ^ isBogus ); 465 471 }; -
_source/plugins/indent/plugin.js
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
428 428 } 429 429 } 430 430 }); 431 432 editor.on( 'key', function( evt )433 {434 // Backspace at the beginning of list item should outdent it.435 if ( editor.mode == 'wysiwyg' && evt.data.keyCode == 8 )436 {437 var sel = editor.getSelection(),438 range = sel.getRanges()[ 0 ],439 li;440 441 if ( range.collapsed &&442 ( li = range.startContainer.getAscendant( 'li', 1 ) ) &&443 range.checkBoundaryOfElement( li, CKEDITOR.START ) )444 {445 editor.execCommand( 'outdent' );446 evt.cancel();447 }448 }449 });450 431 }, 451 432 452 433 requires : [ 'domiterator', 'list' ] -
_source/plugins/list/plugin.js
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
681 681 682 682 // For all new lists created, merge into adjacent, same type lists. 683 683 for ( i = 0 ; i < listsCreated.length ; i++ ) 684 { 685 listNode = listsCreated[i]; 686 var mergeSibling, listCommand = this; 687 ( mergeSibling = function( rtl ) 688 { 689 var sibling = listNode[ rtl ? 'getPrevious' : 'getNext' ]( nonEmpty ); 690 if ( sibling && sibling.getName && 691 sibling.getName() == listCommand.type ) 692 { 693 // Move children order by merge direction.(#3820) 694 mergeChildren( listNode, sibling, null, !rtl ); 684 mergeListSiblings( listsCreated[ i ] ); 685 686 // Clean up, restore selection and update toolbar button states. 687 CKEDITOR.dom.element.clearAllMarkers( database ); 688 selection.selectBookmarks( bookmarks ); 689 editor.focus(); 690 } 691 }; 692 693 // Merge list adjacent, of same type lists. 694 function mergeListSiblings( listNode ) 695 { 696 var mergeSibling; 697 ( mergeSibling = function( rtl ) 698 { 699 var sibling = listNode[ rtl ? 'getPrevious' : 'getNext' ]( nonEmpty ); 700 if ( sibling && sibling.is( listNode.getName() ) ) 701 { 702 // Move children order by merge direction.(#3820) 703 mergeChildren( listNode, sibling, null, !rtl ); 695 704 696 697 698 699 700 701 705 listNode.remove(); 706 listNode = sibling; 707 } 708 } )(); 709 mergeSibling( 1 ); 710 } 702 711 703 // Clean up, restore selection and update toolbar button states.704 CKEDITOR.dom.element.clearAllMarkers( database );705 selection.selectBookmarks( bookmarks );706 editor.focus();707 }708 };709 710 712 var dtd = CKEDITOR.dtd; 711 713 var tailNbspRegex = /[\t\r\n ]*(?: |\xa0)$/; 712 714 … … 788 790 var frag = nextCursor.extractContents(); 789 791 790 792 cursor.trim( false, true ); 793 var bm = cursor.createBookmark(); 791 794 792 795 // Kill original bogus; 793 796 var currentPath = new CKEDITOR.dom.elementPath( cursor.startContainer ); … … 829 832 } 830 833 } 831 834 832 833 if( nextCursor.checkStartOfBlock() &&835 // Remove any remaining empty path blocks. 836 while ( nextCursor.checkStartOfBlock() && 834 837 nextCursor.checkEndOfBlock() ) 835 838 { 836 var nextBlock = nextPath.block,837 parentBlock = nextBlock.getParent();839 nextPath = new CKEDITOR.dom.elementPath( nextCursor.startContainer ); 840 var nextBlock = nextPath.block; 838 841 842 nextCursor.moveToPosition( nextBlock, CKEDITOR.POSITION_BEFORE_START ); 839 843 nextBlock.remove(); 840 841 // Remove if the path block container is now empty, e.g. li. 842 if ( parentBlock && 843 !parentBlock.getFirst( nonEmpty ) && 844 !parentBlock.equals( nextPath.blockLimit ) ) 845 { 846 parentBlock.remove(); 847 } 848 } 844 } 849 845 846 // Check if need to further merge with the list resides after the merged block. (#9080) 847 var walkerRng = nextCursor.clone(), body = editor.document.getBody(); 848 walkerRng.setEndAt( body, CKEDITOR.POSITION_BEFORE_END ); 849 var walker = new CKEDITOR.dom.walker( walkerRng ); 850 walker.evaluator = function( node ) { return nonEmpty( node ) && !blockBogus( node ); }; 851 var next = walker.next(); 852 if ( next && next.type == CKEDITOR.NODE_ELEMENT && next.getName() in CKEDITOR.dtd.$list ) 853 mergeListSiblings( next ); 854 855 cursor.moveToBookmark( bm ); 856 850 857 // Make fresh selection. 851 858 cursor.select(); 852 859 860 editor.selectionChange( 1 ); 853 861 editor.fire( 'saveSnapshot' ); 854 862 } 855 863 … … 883 891 editor.on( 'selectionChange', CKEDITOR.tools.bind( onSelectionChange, numberedListCommand ) ); 884 892 editor.on( 'selectionChange', CKEDITOR.tools.bind( onSelectionChange, bulletedListCommand ) ); 885 893 886 // [IE8] Fix "backspace" after list and "del" at the end of list item. (#8248) 887 if ( CKEDITOR.env.ie8Compat ) 888 { 894 // Handled backspace/del key to join list items. (#8248,#9080) 889 895 editor.on( 'key', function( evt ) 890 896 { 891 897 var key = evt.data.keyCode; … … 908 914 909 915 if ( isBackspace ) 910 916 { 911 walker.range.setStartAt( body, CKEDITOR.POSITION_AFTER_START ); 912 walker.range.setEnd( range.startContainer, range.startOffset ); 917 var previous, joinWith; 918 919 var path = new CKEDITOR.dom.elementPath( range.startContainer ); 920 921 // Join a sub list's first line, with the previous visual line in parent. 922 if ( ( previous = path.contains( listNodeNames ) ) && 923 range.checkBoundaryOfElement( previous, CKEDITOR.START ) && 924 ( previous = previous.getParent() ) && previous.is( 'li' ) && 925 ( previous = getSubList( previous ) ) ) 926 { 927 joinWith = previous; 928 previous = previous.getPrevious( nonEmpty ); 929 // Place cursor before the nested list. 930 cursor.moveToPosition( 931 previous && blockBogus( previous ) ? previous : joinWith, 932 CKEDITOR.POSITION_BEFORE_START ); 933 } 934 // Join any line following a list, with the last visual line of the list. 935 else 936 { 937 walker.range.setStartAt( body, CKEDITOR.POSITION_AFTER_START ); 938 walker.range.setEnd( range.startContainer, range.startOffset ); 939 previous = walker.previous(); 913 940 914 var previous = walker.previous();915 916 // Check if cursor collapsed right behind of a list.917 if ( previous &&918 previous.type == CKEDITOR.NODE_ELEMENT &&919 previous.getName() in listNodeNames )920 {921 walker.range.selectNodeContents( previous );922 walker.reset();923 walker.evaluator = isTextBlock;941 if ( previous && previous.type == CKEDITOR.NODE_ELEMENT && 942 ( previous.getName() in listNodeNames || previous.is( 'li' ) ) ) 943 { 944 if ( !previous.is( 'li' ) ) 945 { 946 walker.range.selectNodeContents( previous ); 947 walker.reset(); 948 walker.evaluator = isTextBlock; 949 previous = walker.previous(); 950 } 924 951 925 // Place cursor at the end of previous block. 926 cursor.moveToElementEditEnd( walker.lastForward() ); 952 joinWith = previous; 953 // Place cursor at the end of previous block. 954 cursor.moveToElementEditEnd( joinWith ); 955 } 956 } 957 958 if ( joinWith ) 959 { 927 960 joinNextLineToCursor( editor, cursor, range ); 928 961 evt.cancel(); 929 962 } … … 969 1002 } 970 1003 } 971 1004 } 1005 1006 // The backspace/del could potentially put cursor at a bad position, 1007 // being it handled or not, check immediately the selection to have it fixed. 1008 setTimeout( function() { editor.selectionChange( 1 ); } ); 972 1009 } 973 1010 } ); 974 }975 1011 }, 976 1012 977 1013 afterInit : function ( editor )