|
238 | 238 | * @param {String} text
|
239 | 239 | */
|
240 | 240 | insertText: function( text ) {
|
| 241 | + // Focus the editor before calling transformPlainTextToHtml. (#12726) |
| 242 | + this.editor.focus(); |
241 | 243 | this.insertHtml( this.transformPlainTextToHtml( text ), 'text' );
|
242 | 244 | },
|
243 | 245 |
|
|
283 | 285 | * @param {String} [mode='html'] See {@link CKEDITOR.editor#method-insertHtml}'s param.
|
284 | 286 | */
|
285 | 287 | insertHtmlIntoSelection: function( data, mode ) {
|
| 288 | + var editor = this.editor; |
| 289 | + |
| 290 | + editor.focus(); |
| 291 | + editor.fire( 'saveSnapshot' ); |
| 292 | + |
286 | 293 | // HTML insertion only considers the first range.
|
287 | 294 | // Note: getRanges will be overwritten for tests since we want to test
|
288 |
| - // custom ranges and bypass native selections. |
289 |
| - var range = this.editor.getSelection().getRanges()[ 0 ]; |
290 |
| - |
291 |
| - beforeInsert( this ); |
| 295 | + // custom ranges and bypass native selections. |
| 296 | + var range = editor.getSelection().getRanges()[ 0 ]; |
292 | 297 |
|
293 | 298 | // Default mode is 'html'.
|
294 | 299 | insert( this, mode || 'html', data, range );
|
|
402 | 407 | * @param {CKEDITOR.dom.element} element The element to be inserted.
|
403 | 408 | */
|
404 | 409 | insertElementIntoSelection: function( element ) {
|
| 410 | + var editor = this.editor; |
| 411 | + |
405 | 412 | // Prepare for the insertion. For example - focus editor (#11848).
|
406 |
| - beforeInsert( this ); |
| 413 | + editor.focus(); |
| 414 | + editor.fire( 'saveSnapshot' ); |
407 | 415 |
|
408 |
| - var editor = this.editor, |
409 |
| - enterMode = editor.activeEnterMode, |
| 416 | + var enterMode = editor.activeEnterMode, |
410 | 417 | selection = editor.getSelection(),
|
411 | 418 | range = selection.getRanges()[ 0 ],
|
412 | 419 | elementName = element.getName(),
|
|
2012 | 2019 | return insert;
|
2013 | 2020 | } )();
|
2014 | 2021 |
|
2015 |
| - function beforeInsert( editable ) { |
2016 |
| - // TODO: For unknown reason we must call directly on the editable to put the focus immediately. |
2017 |
| - editable.editor.focus(); |
2018 |
| - |
2019 |
| - editable.editor.fire( 'saveSnapshot' ); |
2020 |
| - } |
2021 |
| - |
2022 | 2022 | function afterInsert( editable ) {
|
2023 | 2023 | var editor = editable.editor;
|
2024 | 2024 |
|
|
0 commit comments