/**\r
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.\r
+ * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.\r
* For licensing, see LICENSE.md or http://ckeditor.com/license\r
*/\r
\r
// Indent and outdent lists with TAB/SHIFT+TAB key. Indenting can\r
// be done for any list item that isn't the first child of the parent.\r
editor.on( 'key', function( evt ) {\r
+ var path = editor.elementPath();\r
+\r
if ( editor.mode != 'wysiwyg' )\r
return;\r
\r
if ( evt.data.keyCode == this.indentKey ) {\r
- var list = this.getContext( editor.elementPath() );\r
+ // Prevent of getting context of empty path (#424)(https://dev.ckeditor.com/ticket/17028).\r
+ if ( !path ) {\r
+ return;\r
+ }\r
+\r
+ var list = this.getContext( path );\r
\r
if ( list ) {\r
// Don't indent if in first list item of the parent.\r
// Outdent, however, can always be done to collapse\r
// the list into a paragraph (div).\r
- if ( this.isIndent && CKEDITOR.plugins.indentList.firstItemInPath( this.context, editor.elementPath(), list ) )\r
+ if ( this.isIndent && CKEDITOR.plugins.indentList.firstItemInPath( this.context, path, list ) )\r
return;\r
\r
// Exec related global indentation command. Global\r
function indentList( editor ) {\r
var that = this,\r
database = this.database,\r
- context = this.context;\r
+ context = this.context,\r
+ range;\r
\r
function indent( listNode ) {\r
// Our starting and ending points of the range might be inside some blocks under a list item...\r
\r
for ( i = startItem.getCustomData( 'listarray_index' ); i <= lastItem.getCustomData( 'listarray_index' ); i++ ) {\r
listArray[ i ].indent += indentOffset;\r
- // Make sure the newly created sublist get a brand-new element of the same type. (#5372)\r
+ // Make sure the newly created sublist get a brand-new element of the same type. (http://dev.ckeditor.com/ticket/5372)\r
if ( indentOffset > 0 ) {\r
var listRoot = listArray[ i ].parent;\r
listArray[ i ].parent = new CKEDITOR.dom.element( listRoot.getName(), listRoot.getDocument() );\r
var newList = CKEDITOR.plugins.list.arrayToList( listArray, database, null, editor.config.enterMode, listNode.getDirection() );\r
\r
// Avoid nested <li> after outdent even they're visually same,\r
- // recording them for later refactoring.(#3982)\r
+ // recording them for later refactoring.(http://dev.ckeditor.com/ticket/3982)\r
if ( !that.isIndent ) {\r
var parentLiElement;\r
if ( ( parentLiElement = listNode.getParent() ) && parentLiElement.is( 'li' ) ) {\r
// Nest preceding <ul>/<ol> inside current <li> if any.\r
while ( ( followingList = followingList.getNext() ) && followingList.is && followingList.getName() in context ) {\r
// IE requires a filler NBSP for nested list inside empty list item,\r
- // otherwise the list item will be inaccessiable. (#4476)\r
+ // otherwise the list item will be inaccessiable. (http://dev.ckeditor.com/ticket/4476)\r
if ( CKEDITOR.env.needsNbspFiller && !li.getFirst( neitherWhitespacesNorBookmark ) )\r
li.append( range.document.createText( '\u00a0' ) );\r
\r
\r
var selection = editor.getSelection(),\r
ranges = selection && selection.getRanges(),\r
- iterator = ranges.createIterator(),\r
- range;\r
+ iterator = ranges.createIterator();\r
\r
while ( ( range = iterator.getNextRange() ) ) {\r
var nearestListBlock = range.getCommonAncestor();\r
\r
while ( nearestListBlock && !( nearestListBlock.type == CKEDITOR.NODE_ELEMENT && context[ nearestListBlock.getName() ] ) ) {\r
- // Avoid having plugin propagate to parent of editor in inline mode by canceling the indentation. (#12796)\r
+ // Avoid having plugin propagate to parent of editor in inline mode by canceling the indentation. (http://dev.ckeditor.com/ticket/12796)\r
if ( editor.editable().equals( nearestListBlock ) ) {\r
nearestListBlock = false;\r
break;\r
range.setEndAt( nearestListBlock, CKEDITOR.POSITION_BEFORE_END );\r
}\r
\r
- // Avoid having selection enclose the entire list. (#6138)\r
+ // Avoid having selection enclose the entire list. (http://dev.ckeditor.com/ticket/6138)\r
// [<ul><li>...</li></ul>] =><ul><li>[...]</li></ul>\r
if ( !nearestListBlock ) {\r
var selectedNode = range.getEnclosedNode();\r