Fix TimyMCE init when launching DFW and respect wpautop setting there, see #17144

git-svn-id: http://svn.automattic.com/wordpress/trunk@18609 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2011-08-26 19:33:14 +00:00
parent 39ba82bb3f
commit 12c6ba5771
3 changed files with 19 additions and 11 deletions

View File

@ -335,33 +335,39 @@ PubSub.prototype.publish = function( topic, args ) {
});
ps.subscribe( 'shown', function() { // This event occurs after the DFW overlay is shown
var interim_init;
s.visible = true;
// init the standard TinyMCE instance if missing
if ( s.has_tinymce && ! s.is_mce_on ) {
htmled = document.getElementById(s.editor_id), old_val = htmled.value;
htmled.value = switchEditors.wpautop( old_val );
interim_init = function(mce, ed) {
var el = ed.getElement(), old_val = el.value, settings = tinyMCEPreInit.mceInit[s.editor_id];
if ( settings && settings.wpautop && typeof(switchEditors) != 'undefined' )
el.value = switchEditors.wpautop( el.value );
tinyMCE.settings.setup = function(ed) {
ed.onInit.add(function(ed) {
ed.hide();
delete tinyMCE.settings.setup;
ed.getElement().value = old_val;
tinymce.onAddEditor.remove(interim_init);
});
}
};
tinymce.onAddEditor.add(interim_init);
tinyMCE.init(tinyMCEPreInit.mceInit[s.editor_id]);
s.is_mce_on = true;
}
});
ps.subscribe( 'hide', function() { // This event occurs before the overlay blocks DFW.
var htmled_is_hidden = $('#' + s.editor_id).is(':hidden');
// Make sure the correct editor is displaying.
if ( s.has_tinymce && s.mode === 'tinymce' && $('#' + s.editor_id).is(':visible') ) {
if ( s.has_tinymce && s.mode === 'tinymce' && !htmled_is_hidden ) {
switchEditors.go( $('#'+s.editor_id+'-tmce').get(0) );
} else if ( s.mode === 'html' && $('#' + s.editor_id).is(':hidden') ) {
} else if ( s.mode === 'html' && htmled_is_hidden ) {
switchEditors.go( $('#'+s.editor_id+'-html').get(0) );
}
@ -407,7 +413,9 @@ PubSub.prototype.publish = function( topic, args ) {
ed = tinyMCE.get('wp_mce_fullscreen');
if ( from === 'html' && to === 'tinymce' ) {
s.textarea_obj.value = switchEditors.wpautop( s.textarea_obj.value );
if ( tinyMCE.get(s.editor_id).getParam('wpautop') && typeof(switchEditors) != 'undefined' )
s.textarea_obj.value = switchEditors.wpautop( s.textarea_obj.value );
if ( 'undefined' == typeof(ed) )
tinyMCE.execCommand('wpFullScreenInit');

File diff suppressed because one or more lines are too long

View File

@ -86,7 +86,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", array('utils','jquery'), '20110820', 1 );
$scripts->add( 'wp-fullscreen', "/wp-admin/js/wp-fullscreen$suffix.js", array('jquery'), '20110802', 1 );
$scripts->add( 'wp-fullscreen', "/wp-admin/js/wp-fullscreen$suffix.js", array('jquery'), '20110826', 1 );
$scripts->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.6.1');