From 942f25b21984115dd1500cc4760ac34356a903f5 Mon Sep 17 00:00:00 2001 From: Carlos Bravo Date: Sat, 18 Nov 2023 15:53:11 +0100 Subject: [PATCH] Use hidden textarea to save comments in production html --- .../directive-processing.php | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/lib/experimental/interactivity-api/directive-processing.php b/lib/experimental/interactivity-api/directive-processing.php index 2850840c4f9e5..28d42553f9ca2 100644 --- a/lib/experimental/interactivity-api/directive-processing.php +++ b/lib/experimental/interactivity-api/directive-processing.php @@ -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. @@ -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( - '
%s
', - // '%s', - // $block['blockName'], - $block_content - ); - return get_comment_delimited_block_content( - 'core/interactivity-wrapper', - array( - 'blockName' => $block['blockName'], + ' %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;