@@ -25,27 +25,24 @@ var $streamButton = $streamFieldInput.parents( '.gfield' ).find( '.gcoai-tri
2525
2626$streamFieldInput . on ( 'change' , function ( ) {
2727 $input = $ ( `#input_GFFORMID_${ responseFieldId } ` ) ;
28-
29- // Get the value from the stream field
3028 var inputValue = this . value ;
3129
32- // Convert Markdown to HTML only if TinyMCE is available
30+ // Convert Markdown to HTML only if TinyMCE is available.
3331 if ( window . tinyMCE ) {
34- // Convert Markdown to HTML
3532 let formattedValue = inputValue
36- . replace ( / \* \* ( .* ?) \* \* / g, '<strong>$1</strong>' ) // Bold text
37- . replace ( / _ ( .* ?) _ / g, '<em>$1</em>' ) // Italic text with underscores
38- . replace ( / \* ( .* ?) \* / g, '<em>$1</em>' ) // Italic text with asterisks
39- . replace ( / \n / g, "<br>" ) ; // Newlines to <br>
33+ . replace ( / \* \* ( .* ?) \* \* / g, '<strong>$1</strong>' )
34+ . replace ( / _ ( .* ?) _ / g, '<em>$1</em>' )
35+ . replace ( / \* ( .* ?) \* / g, '<em>$1</em>' )
36+ . replace ( / \n / g, "<br>" ) ;
4037
41- // Set HTML content in TinyMCE
38+ // Set HTML content in TinyMCE.
4239 var tiny = tinyMCE . get ( $input . attr ( 'id' ) ) ;
4340 if ( tiny ) {
44- tiny . setContent ( formattedValue ) ;
41+ tiny . setContent ( formattedValue ) ;
4542 }
4643 } else {
47- // If TinyMCE is not available, use plain text
48- $input . val ( inputValue ) ;
44+ // If TinyMCE is not available, use plain text.
45+ $input . val ( inputValu ) ;
4946 }
5047} ) ;
5148
0 commit comments