X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Findent%2Fplugin.js;h=7b28c773c845ac89928617ffcd20a6fd2958ab14;hb=6e682412d5cc0dfaedb376482e585bf2989c6863;hp=c49ce882832188b5b1c876898cd5a5d9d2762a6b;hpb=614511639979907ceb0da3614122a4d8eb963ad4;p=ckeditor.git diff --git a/_source/plugins/indent/plugin.js b/_source/plugins/indent/plugin.js index c49ce88..7b28c77 100644 --- a/_source/plugins/indent/plugin.js +++ b/_source/plugins/indent/plugin.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -9,33 +9,28 @@ For licensing, see LICENSE.html or http://ckeditor.com/license (function() { - var listNodeNames = { ol : 1, ul : 1 }; - - var isNotWhitespaces = CKEDITOR.dom.walker.whitespaces( true ), + var listNodeNames = { ol : 1, ul : 1 }, + isNotWhitespaces = CKEDITOR.dom.walker.whitespaces( true ), isNotBookmark = CKEDITOR.dom.walker.bookmark( false, true ); - function setState( editor, state ) - { - editor.getCommand( this.name ).setState( state ); - } - function onSelectionChange( evt ) { - var editor = evt.editor; + if ( evt.editor.readOnly ) + return null; - var elementPath = evt.data.path, - list = elementPath && elementPath.contains( listNodeNames ); + var editor = evt.editor, + elementPath = evt.data.path, + list = elementPath && elementPath.contains( listNodeNames ), + firstBlock = elementPath.block || elementPath.blockLimit; if ( list ) - return setState.call( this, editor, CKEDITOR.TRISTATE_OFF ); + return this.setState( CKEDITOR.TRISTATE_OFF ); if ( !this.useIndentClasses && this.name == 'indent' ) - return setState.call( this, editor, CKEDITOR.TRISTATE_OFF ); + return this.setState( CKEDITOR.TRISTATE_OFF ); - var path = evt.data.path, - firstBlock = path.block || path.blockLimit; if ( !firstBlock ) - return setState.call( this, editor, CKEDITOR.TRISTATE_DISABLED ); + return this.setState( CKEDITOR.TRISTATE_DISABLED ); if ( this.useIndentClasses ) { @@ -48,8 +43,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license } if ( ( this.name == 'outdent' && !indentStep ) || ( this.name == 'indent' && indentStep == editor.config.indentClasses.length ) ) - return setState.call( this, editor, CKEDITOR.TRISTATE_DISABLED ); - return setState.call( this, editor, CKEDITOR.TRISTATE_OFF ); + return this.setState( CKEDITOR.TRISTATE_DISABLED ); + return this.setState( CKEDITOR.TRISTATE_OFF ); } else { @@ -57,8 +52,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license if ( isNaN( indent ) ) indent = 0; if ( indent <= 0 ) - return setState.call( this, editor, CKEDITOR.TRISTATE_DISABLED ); - return setState.call( this, editor, CKEDITOR.TRISTATE_OFF ); + return this.setState( CKEDITOR.TRISTATE_DISABLED ); + return this.setState( CKEDITOR.TRISTATE_OFF ); } } @@ -85,7 +80,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license function isListItem( node ) { - return node.type = CKEDITOR.NODE_ELEMENT && node.is( 'li' ); + return node.type == CKEDITOR.NODE_ELEMENT && node.is( 'li' ); } indentCommand.prototype = { @@ -147,8 +142,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { 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() ); + if ( indentOffset > 0 ) + { + var listRoot = listArray[ i ].parent; + listArray[ i ].parent = new CKEDITOR.dom.element( listRoot.getName(), listRoot.getDocument() ); + } } for ( i = lastItem.getCustomData( 'listarray_index' ) + 1 ; @@ -215,7 +213,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license iterator.enforceRealBlocks = true; iterator.enlargeBr = enterMode != CKEDITOR.ENTER_BR; var block; - while ( ( block = iterator.getNextParagraph() ) ) + while ( ( block = iterator.getNextParagraph( enterMode == CKEDITOR.ENTER_P ? 'p' : 'div' ) ) ) indentElement( block ); } @@ -354,10 +352,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license init : function( editor ) { // Register commands. - var indent = new indentCommand( editor, 'indent' ), - outdent = new indentCommand( editor, 'outdent' ); - editor.addCommand( 'indent', indent ); - editor.addCommand( 'outdent', outdent ); + var indent = editor.addCommand( 'indent', new indentCommand( editor, 'indent' ) ), + outdent = editor.addCommand( 'outdent', new indentCommand( editor, 'outdent' ) ); // Register the toolbar buttons. editor.ui.addButton( 'Indent', @@ -461,7 +457,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license * and instead the {@link #indentUnit} and {@link #indentOffset} properties will be used. * @name CKEDITOR.config.indentClasses * @type Array - * default null + * @default null * @example * // Use the classes 'Indent1', 'Indent2', 'Indent3' * config.indentClasses = ['Indent1', 'Indent2', 'Indent3'];