X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Findent%2Fplugin.js;h=80fc71da023d751337a48cc82ad1d5764c37a894;hb=f8fc585c18d287eb325c575596d183122486b641;hp=025002543a9e51e7416bc1d4d834c34ed11a4a4c;hpb=941b0a9ba4e673e292510d80a5a86806994b8ea6;p=ckeditor.git diff --git a/_source/plugins/indent/plugin.js b/_source/plugins/indent/plugin.js index 0250025..80fc71d 100644 --- a/_source/plugins/indent/plugin.js +++ b/_source/plugins/indent/plugin.js @@ -11,6 +11,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { var listNodeNames = { ol : 1, ul : 1 }; + var isNotWhitespaces = CKEDITOR.dom.walker.whitespaces( true ), + isNotBookmark = CKEDITOR.dom.walker.bookmark( false, true ); + function setState( editor, state ) { editor.getCommand( this.name ).setState( state ); @@ -18,38 +21,13 @@ For licensing, see LICENSE.html or http://ckeditor.com/license function onSelectionChange( evt ) { - var elements = evt.data.path.elements, - listNode, listItem, - editor = evt.editor; + var editor = evt.editor; - for ( var i = 0 ; i < elements.length ; i++ ) - { - if ( elements[i].getName() == 'li' ) - { - listItem = elements[i]; - continue; - } - if ( listNodeNames[ elements[i].getName() ] ) - { - listNode = elements[i]; - break; - } - } + var elementPath = evt.data.path, + list = elementPath && elementPath.contains( listNodeNames ); - if ( listNode ) - { - if ( this.name == 'outdent' ) + if ( list ) return setState.call( this, editor, CKEDITOR.TRISTATE_OFF ); - else - { - while ( listItem && ( listItem = listItem.getPrevious( CKEDITOR.dom.walker.whitespaces( true ) ) ) ) - { - if ( listItem.getName && listItem.getName() == 'li' ) - return setState.call( this, editor, CKEDITOR.TRISTATE_OFF ); - } - return setState.call( this, editor, CKEDITOR.TRISTATE_DISABLED ); - } - } if ( !this.useIndentClasses && this.name == 'indent' ) return setState.call( this, editor, CKEDITOR.TRISTATE_OFF ); @@ -135,8 +113,14 @@ For licensing, see LICENSE.html or http://ckeditor.com/license // Apply indenting or outdenting on the array. var baseIndent = listArray[ lastItem.getCustomData( 'listarray_index' ) ].indent; - for ( i = startItem.getCustomData( 'listarray_index' ) ; i <= lastItem.getCustomData( 'listarray_index' ) ; i++ ) - listArray[i].indent += indentOffset; + for ( i = startItem.getCustomData( 'listarray_index' ); i <= lastItem.getCustomData( 'listarray_index' ); i++ ) + { + listArray[ i ].indent += indentOffset; + // Make sure the newly created sublist get a brand-new element of the same type. (#5372) + var listRoot = listArray[ i ].parent; + listArray[ i ].parent = new CKEDITOR.dom.element( listRoot.getName(), listRoot.getDocument() ); + } + for ( i = lastItem.getCustomData( 'listarray_index' ) + 1 ; i < listArray.length && listArray[i].indent > baseIndent ; i++ ) listArray[i].indent += indentOffset; @@ -159,7 +143,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license for ( i = count - 1 ; i >= 0 ; i-- ) { - if( ( child = children.getItem( i ) ) && child.is && child.is( 'li' ) ) + if ( ( child = children.getItem( i ) ) && child.is && child.is( 'li' ) ) pendingLis.push( child ); } } @@ -177,10 +161,15 @@ For licensing, see LICENSE.html or http://ckeditor.com/license followingList = li; // Nest preceding