Skip to content

Commit f8b602a

Browse files
committed
gcoai-stream-to-paragraph-field.js: Fixed an issue with stream to paragraph field not displaying rich text correctly.
1 parent 0514d82 commit f8b602a

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

gc-openai/gcoai-stream-to-paragraph-field.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Instructions:
1212
*
1313
* 1. Install this snippet with our free Custom JavaScript plugin.
14-
* https://gravitywiz.com/gravity-forms-custom-javascript/
14+
* https://gravitywiz.com/gravity-forms-custom-javascript/
1515
*
1616
* 2. Update the variables to match your own field IDs.
1717
*/
@@ -51,11 +51,20 @@ $streamFieldInput.on( 'change', function() {
5151

5252
let $newButton = $streamButton
5353
.clone()
54-
.attr('style', 'margin-top: var(--gf-label-space-primary, 8px);')
55-
.on('click', function() {
56-
$streamButton.trigger('click');
57-
})
58-
.insertAfter($( `#input_GFFORMID_${appendButtonFieldId}` ));
54+
.attr( 'style', 'margin-top: var(--gf-label-space-primary, 8px);' )
55+
.on( 'click', function() {
56+
$streamButton.trigger( 'click' );
57+
} )
58+
.insertAfter( $( `#input_GFFORMID_${appendButtonFieldId}` ) );
59+
60+
$wpEditor = $newButton.parents( '.wp-editor-container' );
61+
if ( $wpEditor.length ) {
62+
$newButton.insertAfter( $wpEditor );
63+
}
64+
65+
$( `#input_GFFORMID_${promptFieldId}` ).on( 'blur', function() {
66+
$streamButton.trigger( 'click' );
67+
} );
5968

6069
$wpEditor = $newButton.parents('.wp-editor-container');
6170
if ($wpEditor.length) {

0 commit comments

Comments
 (0)