From f2c4ad72d690dbd5c1b8c1156de6b996d6aead43 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Wed, 28 Nov 2012 21:45:10 +0000 Subject: [PATCH] Media in Internet Explorer: ensure we save the caret bookmark for IE in TinyMCE for the right instance, fixes #22446 git-svn-id: https://develop.svn.wordpress.org/trunk@22905 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/js/media-editor.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/wp-includes/js/media-editor.js b/wp-includes/js/media-editor.js index 63610b0dc0..8cd63c9e31 100644 --- a/wp-includes/js/media-editor.js +++ b/wp-includes/js/media-editor.js @@ -509,22 +509,28 @@ }, open: function( id ) { - var workflow; + var workflow, editor; // If an empty `id` is provided, default to `wpActiveEditor`. id = id || wpActiveEditor; - // If that doesn't work, fall back to `tinymce.activeEditor`. - if ( ! id && typeof tinymce !== 'undefined' && tinymce.activeEditor ) - id = id || tinymce.activeEditor.id; + if ( typeof tinymce !== 'undefined' && tinymce.activeEditor ) { + // If that doesn't work, fall back to `tinymce.activeEditor`. + if ( ! id ) { + editor = tinymce.activeEditor; + id = id || editor.id; + } else { + editor = tinymce.get( id ); + } + + // Save a bookmark of the caret position, needed for IE + if ( tinymce.isIE && editor && ! editor.isHidden() ) + editor.windowManager.insertimagebookmark = editor.selection.getBookmark(); + } // Last but not least, fall back to the empty string. id = id || ''; - // Save a bookmark of the caret position, needed for IE - if ( typeof tinymce !== 'undefined' && tinymce.activeEditor && tinymce.isIE && ! tinymce.activeEditor.isHidden() ) - tinymce.activeEditor.windowManager.insertimagebookmark = tinymce.activeEditor.selection.getBookmark(); - workflow = wp.media.editor.get( id ); // If the workflow exists, open it.