|
155 | 155 | * @see CKEDITOR.editor#insertHtml
|
156 | 156 | */
|
157 | 157 | insertHtml: function( data, mode ) {
|
| 158 | + beforeInsert( this ); |
158 | 159 | // Default mode is 'html'.
|
159 | 160 | insert( this, mode == 'text' ? 'text' : 'html', data );
|
160 | 161 | },
|
|
163 | 164 | * @see CKEDITOR.editor#insertText
|
164 | 165 | */
|
165 | 166 | insertText: function( text ) {
|
| 167 | + beforeInsert( this ); |
| 168 | + |
166 | 169 | var editor = this.editor,
|
167 | 170 | mode = editor.getSelection().getStartElement().hasAscendant( 'pre', true ) ? CKEDITOR.ENTER_BR : editor.config.enterMode,
|
168 | 171 | isEnterBrMode = mode == CKEDITOR.ENTER_BR,
|
|
211 | 214 | * @see CKEDITOR.editor#insertElement
|
212 | 215 | */
|
213 | 216 | insertElement: function( element ) {
|
214 |
| - // TODO this should be gone after refactoring insertElement. |
215 |
| - // TODO: For unknown reason we must call directly on the editable to put the focus immediately. |
216 |
| - this.editor.focus(); |
217 |
| - this.editor.fire( 'saveSnapshot' ); |
| 217 | + beforeInsert( this ); |
218 | 218 |
|
219 | 219 | var editor = this.editor,
|
220 | 220 | enterMode = editor.config.enterMode,
|
|
294 | 294 |
|
295 | 295 | selection.selectRanges( [ range ] );
|
296 | 296 |
|
297 |
| - // TODO this should be gone after refactoring insertElement. |
298 |
| - // Save snaps after the whole execution completed. |
299 |
| - // This's a workaround for make DOM modification's happened after |
300 |
| - // 'insertElement' to be included either, e.g. Form-based dialogs' 'commitContents' |
301 |
| - // call. |
302 |
| - setTimeout( function() { |
303 |
| - editor.fire( 'saveSnapshot' ); |
304 |
| - }, 0 ); |
| 297 | + // Do not scroll after inserting, because Opera may fail on certain element (e.g. iframe/iframe.html). |
| 298 | + afterInsert( this, CKEDITOR.env.opera ); |
305 | 299 | },
|
306 | 300 |
|
307 | 301 | /**
|
|
931 | 925 | // Inserts the given (valid) HTML into the range position (with range content deleted),
|
932 | 926 | // guarantee it's result to be a valid DOM tree.
|
933 | 927 | function insert( editable, type, data ) {
|
934 |
| - beforeInsert( editable ); |
935 |
| - |
936 | 928 | var editor = editable.editor,
|
937 | 929 | doc = editable.getDocument(),
|
938 | 930 | selection = editor.getSelection(),
|
|
993 | 985 | afterInsert( editable );
|
994 | 986 | }
|
995 | 987 |
|
996 |
| - function beforeInsert( editable ) { |
997 |
| - // TODO: For unknown reason we must call directly on the editable to put the focus immediately. |
998 |
| - editable.editor.focus(); |
999 |
| - |
1000 |
| - editable.editor.fire( 'saveSnapshot' ); |
1001 |
| - } |
1002 |
| - |
1003 | 988 | // Prepare range to its data deletion.
|
1004 | 989 | // Delete its contents.
|
1005 | 990 | // Prepare it to insertion.
|
|
1319 | 1304 |
|
1320 | 1305 | }
|
1321 | 1306 |
|
1322 |
| - function afterInsert( editable ) { |
1323 |
| - var editor = editable.editor; |
1324 |
| - |
1325 |
| - // Scroll using selection, not ranges, to affect native pastes. |
1326 |
| - editor.getSelection().scrollIntoView(); |
1327 |
| - |
1328 |
| - // Save snaps after the whole execution completed. |
1329 |
| - // This's a workaround for make DOM modification's happened after |
1330 |
| - // 'insertElement' to be included either, e.g. Form-based dialogs' 'commitContents' |
1331 |
| - // call. |
1332 |
| - setTimeout( function() { |
1333 |
| - editor.fire( 'saveSnapshot' ); |
1334 |
| - }, 0 ); |
1335 |
| - } |
1336 |
| - |
1337 | 1307 | //
|
1338 | 1308 | // HELPERS ------------------------------------------------------------
|
1339 | 1309 | //
|
|
1611 | 1581 | return insert;
|
1612 | 1582 | })();
|
1613 | 1583 |
|
| 1584 | + function beforeInsert( editable ) { |
| 1585 | + // TODO: For unknown reason we must call directly on the editable to put the focus immediately. |
| 1586 | + editable.editor.focus(); |
| 1587 | + |
| 1588 | + editable.editor.fire( 'saveSnapshot' ); |
| 1589 | + } |
| 1590 | + |
| 1591 | + function afterInsert( editable, noScroll ) { |
| 1592 | + var editor = editable.editor; |
| 1593 | + |
| 1594 | + // Scroll using selection, not ranges, to affect native pastes. |
| 1595 | + !noScroll && editor.getSelection().scrollIntoView(); |
| 1596 | + |
| 1597 | + // Save snaps after the whole execution completed. |
| 1598 | + // This's a workaround for make DOM modification's happened after |
| 1599 | + // 'insertElement' to be included either, e.g. Form-based dialogs' 'commitContents' |
| 1600 | + // call. |
| 1601 | + setTimeout( function() { |
| 1602 | + editor.fire( 'saveSnapshot' ); |
| 1603 | + }, 0 ); |
| 1604 | + } |
| 1605 | + |
1614 | 1606 | })();
|
1615 | 1607 |
|
1616 | 1608 | /**
|
|
0 commit comments