/*\r
-Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
For licensing, see LICENSE.html or http://ckeditor.com/license\r
*/\r
\r
\r
(function()\r
{\r
- var listNodeNames = { ol : 1, ul : 1 };\r
-\r
- var isNotWhitespaces = CKEDITOR.dom.walker.whitespaces( true ),\r
+ var listNodeNames = { ol : 1, ul : 1 },\r
+ isNotWhitespaces = CKEDITOR.dom.walker.whitespaces( true ),\r
isNotBookmark = CKEDITOR.dom.walker.bookmark( false, true );\r
\r
- function setState( editor, state )\r
- {\r
- editor.getCommand( this.name ).setState( state );\r
- }\r
-\r
function onSelectionChange( evt )\r
{\r
- var editor = evt.editor;\r
+ if ( evt.editor.readOnly )\r
+ return null;\r
\r
- var elementPath = evt.data.path,\r
- list = elementPath && elementPath.contains( listNodeNames );\r
+ var editor = evt.editor,\r
+ elementPath = evt.data.path,\r
+ list = elementPath && elementPath.contains( listNodeNames ),\r
+ firstBlock = elementPath.block || elementPath.blockLimit;\r
\r
if ( list )\r
- return setState.call( this, editor, CKEDITOR.TRISTATE_OFF );\r
+ return this.setState( CKEDITOR.TRISTATE_OFF );\r
\r
if ( !this.useIndentClasses && this.name == 'indent' )\r
- return setState.call( this, editor, CKEDITOR.TRISTATE_OFF );\r
+ return this.setState( CKEDITOR.TRISTATE_OFF );\r
\r
- var path = evt.data.path,\r
- firstBlock = path.block || path.blockLimit;\r
if ( !firstBlock )\r
- return setState.call( this, editor, CKEDITOR.TRISTATE_DISABLED );\r
+ return this.setState( CKEDITOR.TRISTATE_DISABLED );\r
\r
if ( this.useIndentClasses )\r
{\r
}\r
if ( ( this.name == 'outdent' && !indentStep ) ||\r
( this.name == 'indent' && indentStep == editor.config.indentClasses.length ) )\r
- return setState.call( this, editor, CKEDITOR.TRISTATE_DISABLED );\r
- return setState.call( this, editor, CKEDITOR.TRISTATE_OFF );\r
+ return this.setState( CKEDITOR.TRISTATE_DISABLED );\r
+ return this.setState( CKEDITOR.TRISTATE_OFF );\r
}\r
else\r
{\r
if ( isNaN( indent ) )\r
indent = 0;\r
if ( indent <= 0 )\r
- return setState.call( this, editor, CKEDITOR.TRISTATE_DISABLED );\r
- return setState.call( this, editor, CKEDITOR.TRISTATE_OFF );\r
+ return this.setState( CKEDITOR.TRISTATE_DISABLED );\r
+ return this.setState( CKEDITOR.TRISTATE_OFF );\r
}\r
}\r
\r
iterator.enforceRealBlocks = true;\r
iterator.enlargeBr = enterMode != CKEDITOR.ENTER_BR;\r
var block;\r
- while ( ( block = iterator.getNextParagraph() ) )\r
+ while ( ( block = iterator.getNextParagraph( enterMode == CKEDITOR.ENTER_P ? 'p' : 'div' ) ) )\r
indentElement( block );\r
}\r
\r
init : function( editor )\r
{\r
// Register commands.\r
- var indent = new indentCommand( editor, 'indent' ),\r
- outdent = new indentCommand( editor, 'outdent' );\r
- editor.addCommand( 'indent', indent );\r
- editor.addCommand( 'outdent', outdent );\r
+ var indent = editor.addCommand( 'indent', new indentCommand( editor, 'indent' ) ),\r
+ outdent = editor.addCommand( 'outdent', new indentCommand( editor, 'outdent' ) );\r
\r
// Register the toolbar buttons.\r
editor.ui.addButton( 'Indent',\r
* and instead the {@link #indentUnit} and {@link #indentOffset} properties will be used.\r
* @name CKEDITOR.config.indentClasses\r
* @type Array\r
- * default null\r
+ * @default null\r
* @example\r
* // Use the classes 'Indent1', 'Indent2', 'Indent3'\r
* config.indentClasses = ['Indent1', 'Indent2', 'Indent3'];\r