aboutsummaryrefslogtreecommitdiff
path: root/sources/plugins/div/dialogs
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2017-12-04 18:55:29 +0100
committerIsmaël Bouya <ismael.bouya@normalesup.org>2017-12-04 18:55:29 +0100
commit1794320dcfdfcd19572fb1676294f9853a6bbc20 (patch)
treea4c9e978947d6930d50391747382d7f95a5863e3 /sources/plugins/div/dialogs
parent7183f6a6a21ad9124e70c997e0168459f377a9f2 (diff)
downloadludivine-ckeditor-component-master.tar.gz
ludivine-ckeditor-component-master.tar.zst
ludivine-ckeditor-component-master.zip
Update to 4.7.3HEAD4.7.3master
Diffstat (limited to 'sources/plugins/div/dialogs')
-rw-r--r--sources/plugins/div/dialogs/div.js34
1 files changed, 27 insertions, 7 deletions
diff --git a/sources/plugins/div/dialogs/div.js b/sources/plugins/div/dialogs/div.js
index 140424f..73dde56 100644
--- a/sources/plugins/div/dialogs/div.js
+++ b/sources/plugins/div/dialogs/div.js
@@ -44,7 +44,7 @@
44 var container = editor.elementPath( element ).blockLimit; 44 var container = editor.elementPath( element ).blockLimit;
45 45
46 // Never consider read-only (i.e. contenteditable=false) element as 46 // Never consider read-only (i.e. contenteditable=false) element as
47 // a first div limit (#11083). 47 // a first div limit (http://dev.ckeditor.com/ticket/11083).
48 if ( container.isReadOnly() ) 48 if ( container.isReadOnly() )
49 container = container.getParent(); 49 container = container.getParent();
50 50
@@ -131,12 +131,24 @@
131 var ancestor, divElement; 131 var ancestor, divElement;
132 132
133 for ( i = 0; i < blockGroups.length; i++ ) { 133 for ( i = 0; i < blockGroups.length; i++ ) {
134 // Sometimes we could get empty block group if all elements inside it
135 // don't have parent's nodes (http://dev.ckeditor.com/ticket/13585).
136 if ( !blockGroups[ i ].length ) {
137 continue;
138 }
139
134 var currentNode = blockGroups[ i ][ 0 ]; 140 var currentNode = blockGroups[ i ][ 0 ];
135 141
136 // Calculate the common parent node of all contained elements. 142 // Calculate the common parent node of all contained elements.
137 ancestor = currentNode.getParent(); 143 ancestor = currentNode.getParent();
138 for ( j = 1; j < blockGroups[ i ].length; j++ ) 144 for ( j = 1; j < blockGroups[ i ].length; j++ ) {
139 ancestor = ancestor.getCommonAncestor( blockGroups[ i ][ j ] ); 145 ancestor = ancestor.getCommonAncestor( blockGroups[ i ][ j ] );
146 }
147
148 // If there is no ancestor, mark editable as one (http://dev.ckeditor.com/ticket/13585).
149 if ( !ancestor ) {
150 ancestor = editor.editable();
151 }
140 152
141 divElement = new CKEDITOR.dom.element( 'div', editor.document ); 153 divElement = new CKEDITOR.dom.element( 'div', editor.document );
142 154
@@ -144,8 +156,10 @@
144 for ( j = 0; j < blockGroups[ i ].length; j++ ) { 156 for ( j = 0; j < blockGroups[ i ].length; j++ ) {
145 currentNode = blockGroups[ i ][ j ]; 157 currentNode = blockGroups[ i ][ j ];
146 158
147 while ( !currentNode.getParent().equals( ancestor ) ) 159 // Check if the currentNode has a parent before attempting to operate on it (http://dev.ckeditor.com/ticket/13585).
160 while ( currentNode.getParent() && !currentNode.getParent().equals( ancestor ) ) {
148 currentNode = currentNode.getParent(); 161 currentNode = currentNode.getParent();
162 }
149 163
150 // This could introduce some duplicated elements in array. 164 // This could introduce some duplicated elements in array.
151 blockGroups[ i ][ j ] = currentNode; 165 blockGroups[ i ][ j ] = currentNode;
@@ -160,8 +174,9 @@
160 currentNode.is && CKEDITOR.dom.element.setMarker( database, currentNode, 'block_processed', true ); 174 currentNode.is && CKEDITOR.dom.element.setMarker( database, currentNode, 'block_processed', true );
161 175
162 // Establish new container, wrapping all elements in this group. 176 // Establish new container, wrapping all elements in this group.
163 if ( !j ) 177 if ( !j ) {
164 divElement.insertBefore( currentNode ); 178 divElement.insertBefore( currentNode );
179 }
165 180
166 divElement.append( currentNode ); 181 divElement.append( currentNode );
167 } 182 }
@@ -192,8 +207,13 @@
192 lastDivLimit = limit; 207 lastDivLimit = limit;
193 groups.push( [] ); 208 groups.push( [] );
194 } 209 }
195 groups[ groups.length - 1 ].push( block ); 210
211 // Sometimes we got nodes that are not inside the DOM, which causes error (http://dev.ckeditor.com/ticket/13585).
212 if ( block.getParent() ) {
213 groups[ groups.length - 1 ].push( block );
214 }
196 } 215 }
216
197 return groups; 217 return groups;
198 } 218 }
199 219
@@ -368,7 +388,7 @@
368 // it if no options are available at all. 388 // it if no options are available at all.
369 stylesField[ stylesField.items.length > 1 ? 'enable' : 'disable' ](); 389 stylesField[ stylesField.items.length > 1 ? 'enable' : 'disable' ]();
370 390
371 // Now setup the field value manually if dialog was opened on element. (#9689) 391 // Now setup the field value manually if dialog was opened on element. (http://dev.ckeditor.com/ticket/9689)
372 setTimeout( function() { 392 setTimeout( function() {
373 dialog._element && stylesField.setup( dialog._element ); 393 dialog._element && stylesField.setup( dialog._element );
374 }, 0 ); 394 }, 0 );
@@ -402,7 +422,7 @@
402 this.hide(); 422 this.hide();
403 }, 423 },
404 onHide: function() { 424 onHide: function() {
405 // Remove style only when editing existing DIV. (#6315) 425 // Remove style only when editing existing DIV. (http://dev.ckeditor.com/ticket/6315)
406 if ( command == 'editdiv' ) 426 if ( command == 'editdiv' )
407 this._element.removeCustomData( 'elementStyle' ); 427 this._element.removeCustomData( 'elementStyle' );
408 delete this._element; 428 delete this._element;