From 66e97d4f75fbeb325f15311a7058b0a805f30b76 Mon Sep 17 00:00:00 2001 From: Sayed Taqui Date: Thu, 21 Jul 2016 00:45:08 +0530 Subject: [PATCH 1/6] Fix editor text not persistent issue across all posts and post types --- js/customize-post-section.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/js/customize-post-section.js b/js/customize-post-section.js index ea9af37..b22d102 100644 --- a/js/customize-post-section.js +++ b/js/customize-post-section.js @@ -554,7 +554,12 @@ * to the post setting. */ control.editorExpanded.bind( function( expanded ) { - var editor, textarea = $( '#customize-posts-content' ); + var editor, textarea = $( '#customize-posts-content' ), + tinymceContentWrap = $( '#wp-customize-posts-content-wrap' ), + tmceTab = $( '#customize-posts-content-tmce' ), + htmlTab = $( '#customize-posts-content-html' ), + htmlSelectedClass = 'customize-posts-content-html-selected'; + editor = tinyMCE.get( 'customize-posts-content' ); control.updateEditorToggleExpandButtonLabel( expanded ); $( document.body ).toggleClass( 'customize-posts-content-editor-pane-open', expanded ); @@ -564,6 +569,9 @@ editor.on( 'input change keyup', control.onVisualEditorChange ); textarea.on( 'input', control.onTextEditorChange ); control.resizeEditor( window.innerHeight - editorPane.height() ); + if ( editorPane.hasClass( htmlSelectedClass ) ) { + htmlTab.click(); + } } else { editor.off( 'input change keyup', control.onVisualEditorChange ); textarea.off( 'input', control.onTextEditorChange ); @@ -573,6 +581,13 @@ $( '.mce-active' ).click(); preview.css( 'bottom', '' ); collapse.css( 'bottom', '' ); + + if ( tinymceContentWrap.hasClass( 'html-active' ) ) { + tmceTab.click(); + editorPane.addClass( htmlSelectedClass ); + } else{ + editorPane.removeClass( htmlSelectedClass ); + } } } ); From 63c69beff4cbca2840ec410f3f2b67a5a2845bef Mon Sep 17 00:00:00 2001 From: Sayed Taqui Date: Thu, 21 Jul 2016 01:01:04 +0530 Subject: [PATCH 2/6] Fix else spacing --- js/customize-post-section.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/customize-post-section.js b/js/customize-post-section.js index b22d102..23db976 100644 --- a/js/customize-post-section.js +++ b/js/customize-post-section.js @@ -585,7 +585,7 @@ if ( tinymceContentWrap.hasClass( 'html-active' ) ) { tmceTab.click(); editorPane.addClass( htmlSelectedClass ); - } else{ + } else { editorPane.removeClass( htmlSelectedClass ); } } From 96a4f89645d93bee78a6c5a823726a0a724fe8f9 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Thu, 21 Jul 2016 17:53:34 -0700 Subject: [PATCH 3/6] Revert "Fix else spacing" This reverts commit 63c69beff4cbca2840ec410f3f2b67a5a2845bef. --- js/customize-post-section.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/customize-post-section.js b/js/customize-post-section.js index 23db976..b22d102 100644 --- a/js/customize-post-section.js +++ b/js/customize-post-section.js @@ -585,7 +585,7 @@ if ( tinymceContentWrap.hasClass( 'html-active' ) ) { tmceTab.click(); editorPane.addClass( htmlSelectedClass ); - } else { + } else{ editorPane.removeClass( htmlSelectedClass ); } } From d02082c5507fbf6a37e98a44fb3354e2a4a6cacb Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Thu, 21 Jul 2016 17:53:37 -0700 Subject: [PATCH 4/6] Revert "Fix editor text not persistent issue across all posts and post types" This reverts commit 66e97d4f75fbeb325f15311a7058b0a805f30b76. --- js/customize-post-section.js | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/js/customize-post-section.js b/js/customize-post-section.js index b22d102..ea9af37 100644 --- a/js/customize-post-section.js +++ b/js/customize-post-section.js @@ -554,12 +554,7 @@ * to the post setting. */ control.editorExpanded.bind( function( expanded ) { - var editor, textarea = $( '#customize-posts-content' ), - tinymceContentWrap = $( '#wp-customize-posts-content-wrap' ), - tmceTab = $( '#customize-posts-content-tmce' ), - htmlTab = $( '#customize-posts-content-html' ), - htmlSelectedClass = 'customize-posts-content-html-selected'; - + var editor, textarea = $( '#customize-posts-content' ); editor = tinyMCE.get( 'customize-posts-content' ); control.updateEditorToggleExpandButtonLabel( expanded ); $( document.body ).toggleClass( 'customize-posts-content-editor-pane-open', expanded ); @@ -569,9 +564,6 @@ editor.on( 'input change keyup', control.onVisualEditorChange ); textarea.on( 'input', control.onTextEditorChange ); control.resizeEditor( window.innerHeight - editorPane.height() ); - if ( editorPane.hasClass( htmlSelectedClass ) ) { - htmlTab.click(); - } } else { editor.off( 'input change keyup', control.onVisualEditorChange ); textarea.off( 'input', control.onTextEditorChange ); @@ -581,13 +573,6 @@ $( '.mce-active' ).click(); preview.css( 'bottom', '' ); collapse.css( 'bottom', '' ); - - if ( tinymceContentWrap.hasClass( 'html-active' ) ) { - tmceTab.click(); - editorPane.addClass( htmlSelectedClass ); - } else{ - editorPane.removeClass( htmlSelectedClass ); - } } } ); From f0dcc6520fe11a2b569eca4442c4d620b179b4d1 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Thu, 21 Jul 2016 17:54:18 -0700 Subject: [PATCH 5/6] Set textarea contents if editor is not active or visible --- js/customize-post-section.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/js/customize-post-section.js b/js/customize-post-section.js index ea9af37..3bc746c 100644 --- a/js/customize-post-section.js +++ b/js/customize-post-section.js @@ -543,7 +543,11 @@ 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 { + $( '#customize-posts-content' ).val( newPostData.post_content ); + } control.editorSyncSuspended = false; } } ); From 543860b80e0220015ea2668145f7a02a72c8db63 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Thu, 21 Jul 2016 18:04:13 -0700 Subject: [PATCH 6/6] Set textarea contents if editor is not active or visible when expanding content --- js/customize-post-section.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/js/customize-post-section.js b/js/customize-post-section.js index 3bc746c..af2ab5b 100644 --- a/js/customize-post-section.js +++ b/js/customize-post-section.js @@ -539,14 +539,14 @@ * 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' ); if ( editor && ! editor.isHidden() ) { editor.setContent( wp.editor.autop( newPostData.post_content ) ); } else { - $( '#customize-posts-content' ).val( newPostData.post_content ); + textarea.val( newPostData.post_content ); } control.editorSyncSuspended = false; } @@ -564,7 +564,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() );