aboutsummaryrefslogtreecommitdiff
path: root/sources/plugins/indentlist
diff options
context:
space:
mode:
Diffstat (limited to 'sources/plugins/indentlist')
-rw-r--r--sources/plugins/indentlist/plugin.js27
1 files changed, 17 insertions, 10 deletions
diff --git a/sources/plugins/indentlist/plugin.js b/sources/plugins/indentlist/plugin.js
index 15c661f..0ee30c0 100644
--- a/sources/plugins/indentlist/plugin.js
+++ b/sources/plugins/indentlist/plugin.js
@@ -35,17 +35,24 @@
35 // Indent and outdent lists with TAB/SHIFT+TAB key. Indenting can 35 // Indent and outdent lists with TAB/SHIFT+TAB key. Indenting can
36 // be done for any list item that isn't the first child of the parent. 36 // be done for any list item that isn't the first child of the parent.
37 editor.on( 'key', function( evt ) { 37 editor.on( 'key', function( evt ) {
38 var path = editor.elementPath();
39
38 if ( editor.mode != 'wysiwyg' ) 40 if ( editor.mode != 'wysiwyg' )
39 return; 41 return;
40 42
41 if ( evt.data.keyCode == this.indentKey ) { 43 if ( evt.data.keyCode == this.indentKey ) {
42 var list = this.getContext( editor.elementPath() ); 44 // Prevent of getting context of empty path (#424)(https://dev.ckeditor.com/ticket/17028).
45 if ( !path ) {
46 return;
47 }
48
49 var list = this.getContext( path );
43 50
44 if ( list ) { 51 if ( list ) {
45 // Don't indent if in first list item of the parent. 52 // Don't indent if in first list item of the parent.
46 // Outdent, however, can always be done to collapse 53 // Outdent, however, can always be done to collapse
47 // the list into a paragraph (div). 54 // the list into a paragraph (div).
48 if ( this.isIndent && CKEDITOR.plugins.indentList.firstItemInPath( this.context, editor.elementPath(), list ) ) 55 if ( this.isIndent && CKEDITOR.plugins.indentList.firstItemInPath( this.context, path, list ) )
49 return; 56 return;
50 57
51 // Exec related global indentation command. Global 58 // Exec related global indentation command. Global
@@ -109,7 +116,8 @@
109 function indentList( editor ) { 116 function indentList( editor ) {
110 var that = this, 117 var that = this,
111 database = this.database, 118 database = this.database,
112 context = this.context; 119 context = this.context,
120 range;
113 121
114 function indent( listNode ) { 122 function indent( listNode ) {
115 // Our starting and ending points of the range might be inside some blocks under a list item... 123 // Our starting and ending points of the range might be inside some blocks under a list item...
@@ -164,7 +172,7 @@
164 172
165 for ( i = startItem.getCustomData( 'listarray_index' ); i <= lastItem.getCustomData( 'listarray_index' ); i++ ) { 173 for ( i = startItem.getCustomData( 'listarray_index' ); i <= lastItem.getCustomData( 'listarray_index' ); i++ ) {
166 listArray[ i ].indent += indentOffset; 174 listArray[ i ].indent += indentOffset;
167 // Make sure the newly created sublist get a brand-new element of the same type. (#5372) 175 // Make sure the newly created sublist get a brand-new element of the same type. (http://dev.ckeditor.com/ticket/5372)
168 if ( indentOffset > 0 ) { 176 if ( indentOffset > 0 ) {
169 var listRoot = listArray[ i ].parent; 177 var listRoot = listArray[ i ].parent;
170 listArray[ i ].parent = new CKEDITOR.dom.element( listRoot.getName(), listRoot.getDocument() ); 178 listArray[ i ].parent = new CKEDITOR.dom.element( listRoot.getName(), listRoot.getDocument() );
@@ -179,7 +187,7 @@
179 var newList = CKEDITOR.plugins.list.arrayToList( listArray, database, null, editor.config.enterMode, listNode.getDirection() ); 187 var newList = CKEDITOR.plugins.list.arrayToList( listArray, database, null, editor.config.enterMode, listNode.getDirection() );
180 188
181 // Avoid nested <li> after outdent even they're visually same, 189 // Avoid nested <li> after outdent even they're visually same,
182 // recording them for later refactoring.(#3982) 190 // recording them for later refactoring.(http://dev.ckeditor.com/ticket/3982)
183 if ( !that.isIndent ) { 191 if ( !that.isIndent ) {
184 var parentLiElement; 192 var parentLiElement;
185 if ( ( parentLiElement = listNode.getParent() ) && parentLiElement.is( 'li' ) ) { 193 if ( ( parentLiElement = listNode.getParent() ) && parentLiElement.is( 'li' ) ) {
@@ -207,7 +215,7 @@
207 // Nest preceding <ul>/<ol> inside current <li> if any. 215 // Nest preceding <ul>/<ol> inside current <li> if any.
208 while ( ( followingList = followingList.getNext() ) && followingList.is && followingList.getName() in context ) { 216 while ( ( followingList = followingList.getNext() ) && followingList.is && followingList.getName() in context ) {
209 // IE requires a filler NBSP for nested list inside empty list item, 217 // IE requires a filler NBSP for nested list inside empty list item,
210 // otherwise the list item will be inaccessiable. (#4476) 218 // otherwise the list item will be inaccessiable. (http://dev.ckeditor.com/ticket/4476)
211 if ( CKEDITOR.env.needsNbspFiller && !li.getFirst( neitherWhitespacesNorBookmark ) ) 219 if ( CKEDITOR.env.needsNbspFiller && !li.getFirst( neitherWhitespacesNorBookmark ) )
212 li.append( range.document.createText( '\u00a0' ) ); 220 li.append( range.document.createText( '\u00a0' ) );
213 221
@@ -226,14 +234,13 @@
226 234
227 var selection = editor.getSelection(), 235 var selection = editor.getSelection(),
228 ranges = selection && selection.getRanges(), 236 ranges = selection && selection.getRanges(),
229 iterator = ranges.createIterator(), 237 iterator = ranges.createIterator();
230 range;
231 238
232 while ( ( range = iterator.getNextRange() ) ) { 239 while ( ( range = iterator.getNextRange() ) ) {
233 var nearestListBlock = range.getCommonAncestor(); 240 var nearestListBlock = range.getCommonAncestor();
234 241
235 while ( nearestListBlock && !( nearestListBlock.type == CKEDITOR.NODE_ELEMENT && context[ nearestListBlock.getName() ] ) ) { 242 while ( nearestListBlock && !( nearestListBlock.type == CKEDITOR.NODE_ELEMENT && context[ nearestListBlock.getName() ] ) ) {
236 // Avoid having plugin propagate to parent of editor in inline mode by canceling the indentation. (#12796) 243 // Avoid having plugin propagate to parent of editor in inline mode by canceling the indentation. (http://dev.ckeditor.com/ticket/12796)
237 if ( editor.editable().equals( nearestListBlock ) ) { 244 if ( editor.editable().equals( nearestListBlock ) ) {
238 nearestListBlock = false; 245 nearestListBlock = false;
239 break; 246 break;
@@ -248,7 +255,7 @@
248 range.setEndAt( nearestListBlock, CKEDITOR.POSITION_BEFORE_END ); 255 range.setEndAt( nearestListBlock, CKEDITOR.POSITION_BEFORE_END );
249 } 256 }
250 257
251 // Avoid having selection enclose the entire list. (#6138) 258 // Avoid having selection enclose the entire list. (http://dev.ckeditor.com/ticket/6138)
252 // [<ul><li>...</li></ul>] =><ul><li>[...]</li></ul> 259 // [<ul><li>...</li></ul>] =><ul><li>[...]</li></ul>
253 if ( !nearestListBlock ) { 260 if ( !nearestListBlock ) {
254 var selectedNode = range.getEnclosedNode(); 261 var selectedNode = range.getEnclosedNode();