X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Findent%2Fplugin.js;h=1e3ec49dd45698e525abf2308c57a3c51a796c6f;hb=2f22c0c38f17e75be5541089076885442aaa2377;hp=c36370c1d56fa5c6126b8b540a8061cd8efaa94f;hpb=48b1db88210b4160dce439c6e3e32e14af8c106b;p=ckeditor.git diff --git a/_source/plugins/indent/plugin.js b/_source/plugins/indent/plugin.js index c36370c..1e3ec49 100644 --- a/_source/plugins/indent/plugin.js +++ b/_source/plugins/indent/plugin.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2011, 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 */ @@ -15,10 +15,13 @@ For licensing, see LICENSE.html or http://ckeditor.com/license 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 this.setState( CKEDITOR.TRISTATE_OFF ); @@ -26,8 +29,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license if ( !this.useIndentClasses && this.name == 'indent' ) return this.setState( CKEDITOR.TRISTATE_OFF ); - var path = evt.data.path, - firstBlock = path.block || path.blockLimit; if ( !firstBlock ) return this.setState( CKEDITOR.TRISTATE_DISABLED ); @@ -79,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 = { @@ -424,6 +425,25 @@ For licensing, see LICENSE.html or http://ckeditor.com/license } } }); + + editor.on( 'key', function( evt ) + { + // Backspace at the beginning of list item should outdent it. + if ( editor.mode == 'wysiwyg' && evt.data.keyCode == 8 ) + { + var sel = editor.getSelection(), + range = sel.getRanges()[ 0 ], + li; + + if ( range.collapsed && + ( li = range.startContainer.getAscendant( 'li', 1 ) ) && + range.checkBoundaryOfElement( li, CKEDITOR.START ) ) + { + editor.execCommand( 'outdent' ); + evt.cancel(); + } + } + }); }, requires : [ 'domiterator', 'list' ] @@ -453,7 +473,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'];