17 | | |
| 17 | |
| 18 | /** |
| 19 | * Load the editor and wait for fully interactable. |
| 20 | * @param {Object} elementId |
| 21 | * @param {Object} config |
| 22 | * @param {Object} callback Continuation with {@param editor}. |
| 23 | * @param {Object} context |
| 24 | */ |
| 25 | function prepareEditor( elementId, config, callback, context ) |
| 26 | { |
| 27 | CKEDITOR.on( 'instanceReady', function( evt ) |
| 28 | { |
| 29 | if( evt.editor.name == elementId ) |
| 30 | { |
| 31 | callback.call( context, evt.editor ); |
| 32 | } |
| 33 | }, this ); |
| 34 | editor = CKEDITOR.replace( elementId, config ); |
| 35 | } |
| 36 | |
92 | | |
| 111 | |
| 112 | /** |
| 113 | * Test insertElement on two modes. |
| 114 | */ |
| 115 | test_insertElement: function() |
| 116 | { |
| 117 | prepareEditor( 'editor5' , null , function( editor ){ |
| 118 | this.resume( function(){ |
| 119 | |
| 120 | var element = CKEDITOR.dom.element.createFromHtml( '<table><tr><td>text</td></tr></table>' ), |
| 121 | expected = '<table><tbody><tr><td>text</td></tr></tbody></table>'; |
| 122 | //wysiwyg mode |
| 123 | editor.focus(); |
| 124 | editor.insertElement( element ); |
| 125 | |
| 126 | //Fix enterMode |
| 127 | expected += '<br>'; |
| 128 | assert.areSame( expected, editor.getSnapshot() ); |
| 129 | |
| 130 | //source mode |
| 131 | //sync |
| 132 | editor.setMode( 'source' ); |
| 133 | editor.setData( '' ); |
| 134 | editor.insertElement( element ); |
| 135 | assert.areSame( '' , editor.getSnapshot() ); |
| 136 | } ); |
| 137 | }, this ); |
| 138 | this.wait(); |
| 139 | }, |
| 140 | |