Skip to content

Commit

Permalink
Use hidden textarea to save comments in production html
Browse files Browse the repository at this point in the history
  • Loading branch information
cbravobernal committed Nov 18, 2023
1 parent d7e9608 commit 942f25b
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions lib/experimental/interactivity-api/directive-processing.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ function gutenberg_mark_interactive_block_children( $parsed_block, $source_block
}
add_filter( 'render_block_data', 'gutenberg_mark_interactive_block_children', 100, 3 );


/**
* Add a marker indicating if the block is interactive or not.
* core/interactivity-wrapper if it is interactive.
Expand Down Expand Up @@ -107,23 +106,22 @@ function gutenberg_mark_block_interactivity( $block_content, $block, $block_inst
WP_Directive_Processor::unmark_children_of_interactive_block();

/**
* Debugging purposes only. It seems that comments are being stripped.
* Debugging purposes only. Nested comments are not allowed.
* We wrap a hidden textarea to save the block content delimited
* by comments so we can later process it.
*/
return sprintf(
'<br class="non-interactive-start" /> %s <br class="non-interactive-end" />',
// '<!-- wp:non-interactivity-wrapper {"blockName":"%s"} -->%s<!-- /wp:non-interactivity-wrapper -->',
// $block['blockName'],
$block_content
);
return get_comment_delimited_block_content(
'core/interactivity-wrapper',
array(
'blockName' => $block['blockName'],
'<textarea style="display:none"> %1s </textarea> %2s',
get_comment_delimited_block_content(
'core/non-interactivity-wrapper',
array(
'blockName' => $block['blockName'],
// We can put extra information about the block here.
),
$block_content
),
$block_content
);

}

return $block_content;
Expand Down

0 comments on commit 942f25b

Please sign in to comment.