Media in Internet Explorer: ensure we save the caret bookmark for IE in TinyMCE for the right instance, fixes #22446

git-svn-id: http://core.svn.wordpress.org/trunk@22905 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2012-11-28 21:45:10 +00:00
parent 01e11b6b23
commit 632d0a0571
1 changed files with 14 additions and 8 deletions

View File

@ -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.