JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.6.3
[ckeditor.git] / _source / plugins / indent / plugin.js
index c36370c..1e3ec49 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.\r
 For licensing, see LICENSE.html or http://ckeditor.com/license\r
 */\r
 \r
@@ -15,10 +15,13 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \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 this.setState( CKEDITOR.TRISTATE_OFF );\r
@@ -26,8 +29,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                if ( !this.useIndentClasses && this.name == 'indent' )\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 this.setState( CKEDITOR.TRISTATE_DISABLED );\r
 \r
@@ -79,7 +80,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
        function isListItem( node )\r
        {\r
-               return node.type = CKEDITOR.NODE_ELEMENT && node.is( 'li' );\r
+               return node.type == CKEDITOR.NODE_ELEMENT && node.is( 'li' );\r
        }\r
 \r
        indentCommand.prototype = {\r
@@ -424,6 +425,25 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                        }\r
                                }\r
                        });\r
+\r
+                       editor.on( 'key', function( evt )\r
+                       {\r
+                               // Backspace at the beginning of  list item should outdent it.\r
+                               if ( editor.mode == 'wysiwyg' && evt.data.keyCode == 8 )\r
+                               {\r
+                                       var sel = editor.getSelection(),\r
+                                               range = sel.getRanges()[ 0 ],\r
+                                               li;\r
+\r
+                                       if ( range.collapsed &&\r
+                                                ( li = range.startContainer.getAscendant( 'li', 1 ) ) &&\r
+                                                range.checkBoundaryOfElement( li, CKEDITOR.START ) )\r
+                                       {\r
+                                               editor.execCommand( 'outdent' );\r
+                                               evt.cancel();\r
+                                       }\r
+                               }\r
+                       });\r
                },\r
 \r
                requires : [ 'domiterator', 'list' ]\r
@@ -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.\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