Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Fix editor text not persistent issue across all posts and post types #198

Merged
merged 7 commits into from
Jul 22, 2016
14 changes: 11 additions & 3 deletions js/customize-post-section.js
Original file line number Diff line number Diff line change
Expand Up @@ -558,11 +558,15 @@
* Update the editor when the setting changes its state.
*/
setting.bind( function( newPostData, oldPostData ) {
var editor;
var editor, textarea = $( '#customize-posts-content' );
if ( control.editorExpanded.get() && ! control.editorSyncSuspended && newPostData.post_content !== oldPostData.post_content ) {
control.editorSyncSuspended = true;
editor = tinyMCE.get( 'customize-posts-content' );
editor.setContent( wp.editor.autop( newPostData.post_content ) );
if ( editor && ! editor.isHidden() ) {
editor.setContent( wp.editor.autop( newPostData.post_content ) );
} else {
textarea.val( newPostData.post_content );
}
control.editorSyncSuspended = false;
}
} );
Expand All @@ -579,7 +583,11 @@
$( document.body ).toggleClass( 'customize-posts-content-editor-pane-open', expanded );

if ( expanded ) {
editor.setContent( wp.editor.autop( setting().post_content ) );
if ( editor && ! editor.isHidden() ) {
editor.setContent( wp.editor.autop( setting().post_content ) );
} else {
textarea.val( setting().post_content );
}
editor.on( 'input change keyup', control.onVisualEditorChange );
textarea.on( 'input', control.onTextEditorChange );
control.resizeEditor( window.innerHeight - editorPane.height() );
Expand Down