Skip to content

Commit ece8af9

Browse files
committed
gw-rich-text-html-fields.php: Added support to switch between visual and text mode.
1 parent 183e85f commit ece8af9

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

gravity-forms/gw-rich-text-html-fields.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
*
1010
* @todo
1111
* 1. Add merge tag selector.
12-
* 2. Allow switching to text mode: window.switchEditors.go( 'rich_field_content', mode )
13-
* 3. Add support for inserting images.
12+
* 2. Add support for inserting images.
1413
*/
1514

1615
add_action( 'admin_init', function() {
@@ -68,8 +67,16 @@
6867
} );
6968
} );
7069
jQuery( document).on( 'tinymce-editor-setup', function ( event, editor ) {
71-
if ( editor.id === 'field_rich_content' ) {
70+
var editorId = 'field_rich_content';
71+
if ( editor.id === editorId ) {
7272
editor.settings.toolbar1 = 'bold,italic,underline,bullist,numlist,alignleft,aligncenter,alignright,link';
73+
74+
// Switch to visual/text mode.
75+
jQuery(`#wp-${editorId}-wrap .switch-tmce, #wp-${editorId}-wrap .switch-html`).on('click', function() {
76+
var mode = jQuery(this).hasClass('switch-tmce') ? 'tmce' : 'html';
77+
78+
window.switchEditors.go(editorId, mode);
79+
});
7380
}
7481
} );
7582
</script>

0 commit comments

Comments
 (0)