diff --git a/core/lib/Drupal/Core/Layout/LayoutDefault.php b/core/lib/Drupal/Core/Layout/LayoutDefault.php index 607b34a48cd91bf740f3e6eda563a8de8b659467..bd3780987a4dd18a7c646f92c1545fd2d4b069e5 100644 --- a/core/lib/Drupal/Core/Layout/LayoutDefault.php +++ b/core/lib/Drupal/Core/Layout/LayoutDefault.php @@ -51,6 +51,7 @@ public function build(array $regions) { $build[$region_name] = $regions[$region_name]; } } + $build['#in_preview'] = $this->inPreview; $build['#settings'] = $this->getConfiguration(); $build['#layout'] = $this->pluginDefinition; $build['#theme'] = $this->pluginDefinition->getThemeHook(); diff --git a/core/modules/block/block.module b/core/modules/block/block.module index 062a6fa9c7d35cfa9af45b2544e202e8339bd0aa..11bb4492b57d9ba8ab8891f15131734b285b1d47 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -246,6 +246,7 @@ function template_preprocess_block(&$variables) { $variables['plugin_id'] = $variables['elements']['#plugin_id']; $variables['base_plugin_id'] = $variables['elements']['#base_plugin_id']; $variables['derivative_plugin_id'] = $variables['elements']['#derivative_plugin_id']; + $variables['in_preview'] = $variables['elements']['#in_preview'] ?? FALSE; $variables['label'] = !empty($variables['configuration']['label_display']) ? $variables['configuration']['label'] : ''; $variables['content'] = $variables['elements']['content']; // A block's label is configuration: it is static. Allow dynamic labels to be diff --git a/core/modules/block/templates/block.html.twig b/core/modules/block/templates/block.html.twig index d880475255d0a2faf6b668649f62124089ad4c39..8fc22725d5fbfe9870c40b3a6a62c74cdf29e1b0 100644 --- a/core/modules/block/templates/block.html.twig +++ b/core/modules/block/templates/block.html.twig @@ -11,6 +11,7 @@ * - label_display: The display settings for the label. * - provider: The module or other provider that provided this block plugin. * - Block plugin specific settings will also be stored here. + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content of this block. * - attributes: array of HTML attributes populated by modules, intended to * be added to the main container tag of this template. diff --git a/core/modules/field_layout/tests/src/Unit/FieldLayoutBuilderTest.php b/core/modules/field_layout/tests/src/Unit/FieldLayoutBuilderTest.php index 8b074d5a071d150aa4a7a5f361903cb5ad730559..431b8c1d35e8bc178e7ac54c22e03125976f96a7 100644 --- a/core/modules/field_layout/tests/src/Unit/FieldLayoutBuilderTest.php +++ b/core/modules/field_layout/tests/src/Unit/FieldLayoutBuilderTest.php @@ -143,6 +143,7 @@ public function testBuildView() { '#markup' => 'Test1', ], ], + '#in_preview' => FALSE, '#settings' => [ 'label' => '', ], @@ -243,6 +244,7 @@ public function testBuildForm() { '#process' => ['\Drupal\Core\Render\Element\RenderElement::processGroup'], '#pre_render' => ['\Drupal\Core\Render\Element\RenderElement::preRenderGroup'], ], + '#in_preview' => FALSE, '#settings' => [ 'label' => '', ], diff --git a/core/modules/layout_builder/layouts/fourcol_section/layout--fourcol-section.html.twig b/core/modules/layout_builder/layouts/fourcol_section/layout--fourcol-section.html.twig index 9a380f76e01dc3d54252c76ed86e4a50fd5b378f..1f08a2ab551c3f99de46b4f99df9e42e532af211 100644 --- a/core/modules/layout_builder/layouts/fourcol_section/layout--fourcol-section.html.twig +++ b/core/modules/layout_builder/layouts/fourcol_section/layout--fourcol-section.html.twig @@ -4,6 +4,7 @@ * Default theme implementation for a four-column 25%-25%-25%-25% layout. * * Available variables: + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content for this layout. * - attributes: HTML attributes for the layout <div>. * diff --git a/core/modules/layout_builder/layouts/threecol_section/layout--threecol-section.html.twig b/core/modules/layout_builder/layouts/threecol_section/layout--threecol-section.html.twig index 1311f28ab2a18bb98e873177804ba5a5dbbb0d42..204a43621dc51745d69ec2c1ab54fc1396b26144 100644 --- a/core/modules/layout_builder/layouts/threecol_section/layout--threecol-section.html.twig +++ b/core/modules/layout_builder/layouts/threecol_section/layout--threecol-section.html.twig @@ -4,6 +4,7 @@ * Default theme implementation for a three-column layout. * * Available variables: + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content for this layout. * - attributes: HTML attributes for the layout <div>. * diff --git a/core/modules/layout_builder/layouts/twocol_section/layout--twocol-section.html.twig b/core/modules/layout_builder/layouts/twocol_section/layout--twocol-section.html.twig index a5d1d36376b75a26b074f5739fde80971c220603..9969f8e57a1dc78468b386e7a19880889d1d287c 100644 --- a/core/modules/layout_builder/layouts/twocol_section/layout--twocol-section.html.twig +++ b/core/modules/layout_builder/layouts/twocol_section/layout--twocol-section.html.twig @@ -4,6 +4,7 @@ * Default theme implementation to display a two-column layout. * * Available variables: + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content for this layout. * - attributes: HTML attributes for the layout <div>. * diff --git a/core/modules/layout_builder/src/EventSubscriber/BlockComponentRenderArray.php b/core/modules/layout_builder/src/EventSubscriber/BlockComponentRenderArray.php index 083de3983d73669c145a0db195081597dc60be2a..7bedf79a5ca40936946d06bccccc5ff92288ee16 100644 --- a/core/modules/layout_builder/src/EventSubscriber/BlockComponentRenderArray.php +++ b/core/modules/layout_builder/src/EventSubscriber/BlockComponentRenderArray.php @@ -124,6 +124,7 @@ public function onBuildRender(SectionComponentBuildRenderArrayEvent $event) { '#plugin_id' => $block->getPluginId(), '#base_plugin_id' => $block->getBaseId(), '#derivative_plugin_id' => $block->getDerivativeId(), + '#in_preview' => $event->inPreview(), '#weight' => $event->getComponent()->getWeight(), ]; diff --git a/core/modules/layout_builder/tests/modules/layout_builder_test/layout_builder_test.module b/core/modules/layout_builder/tests/modules/layout_builder_test/layout_builder_test.module index cd6070f53ff33d4f20ef609513ff335c57b63c60..0ab1298a7a132d65e4fcff3107d7c05317e54874 100644 --- a/core/modules/layout_builder/tests/modules/layout_builder_test/layout_builder_test.module +++ b/core/modules/layout_builder/tests/modules/layout_builder_test/layout_builder_test.module @@ -131,3 +131,14 @@ function layout_builder_test_module_implements_alter(&$implementations, $hook) { ] + $implementations; } } + +/** + * Implements hook_theme(). + */ +function layout_builder_test_theme() { + return [ + 'block__preview_aware_block' => [ + 'base hook' => 'block', + ], + ]; +} diff --git a/core/modules/layout_builder/tests/modules/layout_builder_test/templates/block--preview-aware-block.html.twig b/core/modules/layout_builder/tests/modules/layout_builder_test/templates/block--preview-aware-block.html.twig new file mode 100644 index 0000000000000000000000000000000000000000..fe9ca8e1e4d0d6c44142d06e5e9710f27de95c07 --- /dev/null +++ b/core/modules/layout_builder/tests/modules/layout_builder_test/templates/block--preview-aware-block.html.twig @@ -0,0 +1,5 @@ +{% if in_preview %} + The block template is being previewed. +{% endif %} + +{% include '@block/block.html.twig' %} diff --git a/core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php b/core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php index 24c88e1818667f2d82e49fd24ebe0cc272dfdea8..e3baf8870c1688cc275ed2fe56c317776ff9fb2b 100644 --- a/core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php +++ b/core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php @@ -719,15 +719,47 @@ public function testPreviewAwarePlugins() { $page->pressButton('Add block'); $assert_session->elementExists('css', '.go-birds-preview'); + $assert_session->pageTextContains('The block template is being previewed.'); $assert_session->pageTextContains('This block is being rendered in preview mode.'); $page->pressButton('Save layout'); $this->drupalGet('node/1'); $assert_session->elementNotExists('css', '.go-birds-preview'); + $assert_session->pageTextNotContains('The block template is being previewed.'); $assert_session->pageTextContains('This block is being rendered normally.'); } + /** + * Tests preview-aware templates. + */ + public function testPreviewAwareTemplates() { + $assert_session = $this->assertSession(); + $page = $this->getSession()->getPage(); + + $this->drupalLogin($this->drupalCreateUser([ + 'configure any layout', + 'administer node display', + ])); + + $this->drupalGet('admin/structure/types/manage/bundle_with_section_field/display/default'); + $this->submitForm(['layout[enabled]' => TRUE], 'Save'); + $page->clickLink('Manage layout'); + $page->clickLink('Add section'); + $page->clickLink('1 column layout'); + $page->pressButton('Add section'); + $page->clickLink('Add block'); + $page->clickLink('Preview-aware block'); + $page->pressButton('Add block'); + + $assert_session->pageTextContains('This is a preview, indeed'); + + $page->pressButton('Save layout'); + $this->drupalGet('node/1'); + + $assert_session->pageTextNotContains('This is a preview, indeed'); + } + /** * Tests the interaction between full and default view modes. * diff --git a/core/modules/layout_builder/tests/src/Unit/BlockComponentRenderArrayTest.php b/core/modules/layout_builder/tests/src/Unit/BlockComponentRenderArrayTest.php index 883d3c7d206034d24a06ec8c0801544a0e123d9a..9d797038db2b5c4ddc8978b7ceb024846e6e7c43 100644 --- a/core/modules/layout_builder/tests/src/Unit/BlockComponentRenderArrayTest.php +++ b/core/modules/layout_builder/tests/src/Unit/BlockComponentRenderArrayTest.php @@ -120,6 +120,7 @@ public function testOnBuildRender($refinable_dependent_access) { '#base_plugin_id' => 'block_plugin_id', '#derivative_plugin_id' => NULL, 'content' => $block_content, + '#in_preview' => FALSE, ]; $expected_build_with_expected_cache = $expected_build + [ @@ -195,6 +196,7 @@ public function testOnBuildRenderWithoutPreviewFallbackString($refinable_depende '#base_plugin_id' => 'block_plugin_id', '#derivative_plugin_id' => NULL, 'content' => $block_content, + '#in_preview' => FALSE, ]; $expected_cache = $expected_build + [ @@ -324,6 +326,7 @@ public function testOnBuildRenderInPreview($refinable_dependent_access) { '#attributes' => [ 'data-layout-content-preview-placeholder-label' => $placeholder_label, ], + '#in_preview' => TRUE, ]; $expected_cache = $expected_build + [ @@ -332,6 +335,7 @@ public function testOnBuildRenderInPreview($refinable_dependent_access) { 'tags' => ['test'], 'max-age' => 0, ], + '#in_preview' => TRUE, ]; $subscriber->onBuildRender($event); @@ -383,6 +387,7 @@ public function testOnBuildRenderInPreviewEmptyBuild() { '#attributes' => [ 'data-layout-content-preview-placeholder-label' => $placeholder_string, ], + '#in_preview' => TRUE, ]; $expected_build['content']['#markup'] = $placeholder_string; @@ -392,6 +397,7 @@ public function testOnBuildRenderInPreviewEmptyBuild() { 'tags' => ['test'], 'max-age' => 0, ], + '#in_preview' => TRUE, ]; $subscriber->onBuildRender($event); diff --git a/core/modules/layout_builder/tests/src/Unit/SectionRenderTest.php b/core/modules/layout_builder/tests/src/Unit/SectionRenderTest.php index fe9fbdc35c2164a53b672b0df872641adc85d411..a149ff846753d053a1ae4bfe3729d4894576abbe 100644 --- a/core/modules/layout_builder/tests/src/Unit/SectionRenderTest.php +++ b/core/modules/layout_builder/tests/src/Unit/SectionRenderTest.php @@ -115,6 +115,7 @@ public function testToRenderArray() { 'tags' => [], 'max-age' => -1, ], + '#in_preview' => FALSE, ]; $block = $this->prophesize(BlockPluginInterface::class)->willImplement(PreviewFallbackInterface::class); @@ -198,6 +199,7 @@ public function testToRenderArrayPreview() { 'tags' => [], 'max-age' => 0, ], + '#in_preview' => TRUE, ]; $block = $this->prophesize(BlockPluginInterface::class)->willImplement(PreviewFallbackInterface::class); $this->blockManager->createInstance('block_plugin_id', ['id' => 'block_plugin_id'])->willReturn($block->reveal()); @@ -254,6 +256,7 @@ public function testContextAwareBlock() { 'tags' => [], 'max-age' => -1, ], + '#in_preview' => FALSE, ]; $block = $this->prophesize(BlockPluginInterface::class) diff --git a/core/modules/layout_discovery/layout_discovery.module b/core/modules/layout_discovery/layout_discovery.module index ce08617e025dbb9b10c9e4bdb588ddaef1180b64..efc9d3b30baffa9a1b06bb2d6918ba922ccec615 100644 --- a/core/modules/layout_discovery/layout_discovery.module +++ b/core/modules/layout_discovery/layout_discovery.module @@ -34,11 +34,12 @@ function layout_discovery_theme() { * @param array &$variables * An associative array containing: * - content: An associative array containing the properties of the element. - * Properties used: #settings, #layout. + * Properties used: #settings, #layout, #in_preview. */ function template_preprocess_layout(&$variables) { $variables['settings'] = $variables['content']['#settings'] ?? []; $variables['layout'] = $variables['content']['#layout'] ?? []; + $variables['in_preview'] = $variables['content']['#in_preview'] ?? FALSE; // Create an attributes variable for each region. foreach (Element::children($variables['content']) as $name) { diff --git a/core/modules/layout_discovery/layouts/onecol/layout--onecol.html.twig b/core/modules/layout_discovery/layouts/onecol/layout--onecol.html.twig index 3a7f9934d09971ffb0d812caea966ad8977241de..01d61e009fd984d1897799e0c7ad8abcf167d20f 100644 --- a/core/modules/layout_discovery/layouts/onecol/layout--onecol.html.twig +++ b/core/modules/layout_discovery/layouts/onecol/layout--onecol.html.twig @@ -4,6 +4,7 @@ * Default theme implementation to display a one-column layout. * * Available variables: + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content for this layout. * - attributes: HTML attributes for the layout <div>. * diff --git a/core/modules/layout_discovery/layouts/threecol_25_50_25/layout--threecol-25-50-25.html.twig b/core/modules/layout_discovery/layouts/threecol_25_50_25/layout--threecol-25-50-25.html.twig index e5441d8b6be991c7e65700e2870aeaf2ef7ccb4d..cd226f020190a9b43150da622608c3461d0d2685 100644 --- a/core/modules/layout_discovery/layouts/threecol_25_50_25/layout--threecol-25-50-25.html.twig +++ b/core/modules/layout_discovery/layouts/threecol_25_50_25/layout--threecol-25-50-25.html.twig @@ -7,6 +7,7 @@ * additional areas for the top and the bottom. * * Available variables: + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content for this layout. * - attributes: HTML attributes for the layout <div>. * diff --git a/core/modules/layout_discovery/layouts/threecol_33_34_33/layout--threecol-33-34-33.html.twig b/core/modules/layout_discovery/layouts/threecol_33_34_33/layout--threecol-33-34-33.html.twig index 6445061c04e4b9ea4f5a53f2c01b818692742930..762cece8cf79f3e2371f87f46227a7acc9c7cac8 100644 --- a/core/modules/layout_discovery/layouts/threecol_33_34_33/layout--threecol-33-34-33.html.twig +++ b/core/modules/layout_discovery/layouts/threecol_33_34_33/layout--threecol-33-34-33.html.twig @@ -7,6 +7,7 @@ * additional areas for the top and the bottom. * * Available variables: + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content for this layout. * - attributes: HTML attributes for the layout <div>. * diff --git a/core/modules/layout_discovery/layouts/twocol/layout--twocol.html.twig b/core/modules/layout_discovery/layouts/twocol/layout--twocol.html.twig index 262c657f919ec0225db6edd97a72c3ce09ce6f69..11939907bafdc577ff79147b22bb7864cb189138 100644 --- a/core/modules/layout_discovery/layouts/twocol/layout--twocol.html.twig +++ b/core/modules/layout_discovery/layouts/twocol/layout--twocol.html.twig @@ -4,6 +4,7 @@ * Default theme implementation to display a two-column layout. * * Available variables: + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content for this layout. * - attributes: HTML attributes for the layout <div>. * diff --git a/core/modules/layout_discovery/layouts/twocol_bricks/layout--twocol-bricks.html.twig b/core/modules/layout_discovery/layouts/twocol_bricks/layout--twocol-bricks.html.twig index dc29e03e43027aa3062aedab88e6aa813a142212..f772834f5057ef094faf07acbb245018756034dd 100644 --- a/core/modules/layout_discovery/layouts/twocol_bricks/layout--twocol-bricks.html.twig +++ b/core/modules/layout_discovery/layouts/twocol_bricks/layout--twocol-bricks.html.twig @@ -7,6 +7,7 @@ * the top, bottom and in the middle. * * Available variables: + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content for this layout. * - attributes: HTML attributes for the layout <div>. * diff --git a/core/modules/system/templates/block--system-menu-block.html.twig b/core/modules/system/templates/block--system-menu-block.html.twig index 6113bc2ed8f60931b6aa71d9f6f795f4735bd3c6..1e6c3e020e1b34fcc393bca3139b492f79ae40cf 100644 --- a/core/modules/system/templates/block--system-menu-block.html.twig +++ b/core/modules/system/templates/block--system-menu-block.html.twig @@ -11,6 +11,7 @@ * - label_display: The display settings for the label. * - provider: The module or other provider that provided this block plugin. * - Block plugin specific settings will also be stored here. + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content of this block. * - attributes: HTML attributes for the containing element. * - id: A valid HTML ID and guaranteed unique. diff --git a/core/modules/system/tests/modules/layout_test/templates/layout-test-1col.html.twig b/core/modules/system/tests/modules/layout_test/templates/layout-test-1col.html.twig index 2207e3c71ab1bb70f28a0adbe484697faf34e99c..ab03efabc94b55a97229c236604b00d26c3a2bb5 100644 --- a/core/modules/system/tests/modules/layout_test/templates/layout-test-1col.html.twig +++ b/core/modules/system/tests/modules/layout_test/templates/layout-test-1col.html.twig @@ -5,6 +5,9 @@ */ #} <div{{ attributes.addClass('layout-example-1col', 'clearfix') }}> + {% if in_preview %} + This is a preview, indeed + {% endif %} <div {{ region_attributes.top.addClass('region-top') }}> {{ content.top }} </div> diff --git a/core/profiles/demo_umami/themes/umami/layouts/oneplusfourgrid_section/layout--oneplusfourgrid-section.html.twig b/core/profiles/demo_umami/themes/umami/layouts/oneplusfourgrid_section/layout--oneplusfourgrid-section.html.twig index 5345bcae80bbca01372bf1af457852250b571094..40fc3e770581b3f702eee61f7e18e64652930bfc 100644 --- a/core/profiles/demo_umami/themes/umami/layouts/oneplusfourgrid_section/layout--oneplusfourgrid-section.html.twig +++ b/core/profiles/demo_umami/themes/umami/layouts/oneplusfourgrid_section/layout--oneplusfourgrid-section.html.twig @@ -4,6 +4,7 @@ * Default theme implementation to display a one plus four grid layout. * * Available variables: + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content for this layout. * - attributes: HTML attributes for the layout <div>. * diff --git a/core/profiles/demo_umami/themes/umami/templates/classy/block/block--system-menu-block.html.twig b/core/profiles/demo_umami/themes/umami/templates/classy/block/block--system-menu-block.html.twig index 407f8403fd28c7db920f68ccbd4927bc2bbccb21..db3f9f808815d18c7d48a98d875736aa273b166f 100644 --- a/core/profiles/demo_umami/themes/umami/templates/classy/block/block--system-menu-block.html.twig +++ b/core/profiles/demo_umami/themes/umami/templates/classy/block/block--system-menu-block.html.twig @@ -11,6 +11,7 @@ * - label_display: The display settings for the label. * - provider: The module or other provider that provided this block plugin. * - Block plugin specific settings will also be stored here. + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content of this block. * - attributes: HTML attributes for the containing element. * - id: A valid HTML ID and guaranteed unique. diff --git a/core/profiles/demo_umami/themes/umami/templates/classy/block/block.html.twig b/core/profiles/demo_umami/themes/umami/templates/classy/block/block.html.twig index fd3311be958b9de2fcd17108309c854fdc807217..114d7c4de4f8892648a397b92eed748ec30e9672 100644 --- a/core/profiles/demo_umami/themes/umami/templates/classy/block/block.html.twig +++ b/core/profiles/demo_umami/themes/umami/templates/classy/block/block.html.twig @@ -11,6 +11,7 @@ * - label_display: The display settings for the label. * - provider: The module or other provider that provided this block plugin. * - Block plugin specific settings will also be stored here. + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content of this block. * - attributes: array of HTML attributes populated by modules, intended to * be added to the main container tag of this template. diff --git a/core/profiles/demo_umami/themes/umami/templates/components/banner-block/block--bundle--banner-block.html.twig b/core/profiles/demo_umami/themes/umami/templates/components/banner-block/block--bundle--banner-block.html.twig index 9b13cd68443d2ae8aa4831d13997eb634d17893f..d23cc297bf71c87f57772b222ba1d86ed6dd2b3b 100644 --- a/core/profiles/demo_umami/themes/umami/templates/components/banner-block/block--bundle--banner-block.html.twig +++ b/core/profiles/demo_umami/themes/umami/templates/components/banner-block/block--bundle--banner-block.html.twig @@ -11,6 +11,7 @@ * - label_display: The display settings for the label. * - provider: The module or other provider that provided this block plugin. * - Block plugin specific settings will also be stored here. + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content of this block. * - attributes: array of HTML attributes populated by modules, intended to * be added to the main container tag of this template. diff --git a/core/profiles/demo_umami/themes/umami/templates/components/footer-promo-block/block--bundle--footer-promo-block.html.twig b/core/profiles/demo_umami/themes/umami/templates/components/footer-promo-block/block--bundle--footer-promo-block.html.twig index e90416b9cc0deab1fe2f3d672556eebbb4a5e0ae..489dd0c2e247564bff102ea3014528c2b8b48700 100644 --- a/core/profiles/demo_umami/themes/umami/templates/components/footer-promo-block/block--bundle--footer-promo-block.html.twig +++ b/core/profiles/demo_umami/themes/umami/templates/components/footer-promo-block/block--bundle--footer-promo-block.html.twig @@ -11,6 +11,7 @@ * - label_display: The display settings for the label. * - provider: The module or other provider that provided this block plugin. * - Block plugin specific settings will also be stored here. + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content of this block. * - attributes: array of HTML attributes populated by modules, intended to * be added to the main container tag of this template. diff --git a/core/profiles/demo_umami/themes/umami/templates/components/help-block/block--help.html.twig b/core/profiles/demo_umami/themes/umami/templates/components/help-block/block--help.html.twig index 20e2a4a9aa844f36bf746283b21406ab1360e6f8..a924817e48b70da084d4e4657b7fe30860a64cbb 100644 --- a/core/profiles/demo_umami/themes/umami/templates/components/help-block/block--help.html.twig +++ b/core/profiles/demo_umami/themes/umami/templates/components/help-block/block--help.html.twig @@ -11,6 +11,7 @@ * - label_display: The display settings for the label. * - provider: The module or other provider that provided this block plugin. * - Block plugin specific settings will also be stored here. + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content of this block. * - attributes: array of HTML attributes populated by modules, intended to * be added to the main container tag of this template. diff --git a/core/profiles/demo_umami/themes/umami/templates/components/navigation/block--umami-main-menu.html.twig b/core/profiles/demo_umami/themes/umami/templates/components/navigation/block--umami-main-menu.html.twig index 51174d43c98d8a362cd33b1e133a67f9c8ef4705..ad21956c338c72e4370e30ae1a892251b7479263 100644 --- a/core/profiles/demo_umami/themes/umami/templates/components/navigation/block--umami-main-menu.html.twig +++ b/core/profiles/demo_umami/themes/umami/templates/components/navigation/block--umami-main-menu.html.twig @@ -11,6 +11,7 @@ * - label_display: The display settings for the label. * - provider: The module or other provider that provided this block plugin. * - Block plugin specific settings will also be stored here. + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content of this block. * - attributes: HTML attributes for the containing element. * - id: A valid HTML ID and guaranteed unique. diff --git a/core/profiles/demo_umami/themes/umami/templates/components/search/block--search-form-block.html.twig b/core/profiles/demo_umami/themes/umami/templates/components/search/block--search-form-block.html.twig index 01599d5f7e75f68414f8fd65c44642490d48eaa4..29e828c12e59dca29e8bde42cbcb43d009189e19 100644 --- a/core/profiles/demo_umami/themes/umami/templates/components/search/block--search-form-block.html.twig +++ b/core/profiles/demo_umami/themes/umami/templates/components/search/block--search-form-block.html.twig @@ -11,6 +11,7 @@ * - label_display: The display settings for the label. * - provider: The module or other provider that provided this block plugin. * - Block plugin specific settings will also be stored here. + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content of this block. * - attributes: A list HTML attributes populated by modules, intended to * be added to the main container tag of this template. Includes: diff --git a/core/tests/Drupal/Tests/Core/Layout/LayoutDefaultTest.php b/core/tests/Drupal/Tests/Core/Layout/LayoutDefaultTest.php index af9cc38759bbc2277cdb5305d28f51a4426bf507..30b1471005763302baacfe3d4ac5d02301a2836b 100644 --- a/core/tests/Drupal/Tests/Core/Layout/LayoutDefaultTest.php +++ b/core/tests/Drupal/Tests/Core/Layout/LayoutDefaultTest.php @@ -30,6 +30,7 @@ public function testBuild($regions, $expected) { ], ]); $expected += [ + '#in_preview' => FALSE, '#settings' => [ 'label' => '', ], diff --git a/core/themes/claro/templates/classy/block/block--search-form-block.html.twig b/core/themes/claro/templates/classy/block/block--search-form-block.html.twig index 667202fb6b658bf3b0aae080d6687913074ef6d1..d1cda724ba8739437790d3809dedee5590c25986 100644 --- a/core/themes/claro/templates/classy/block/block--search-form-block.html.twig +++ b/core/themes/claro/templates/classy/block/block--search-form-block.html.twig @@ -11,6 +11,7 @@ * - label_display: The display settings for the label. * - provider: The module or other provider that provided this block plugin. * - Block plugin specific settings will also be stored here. + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content of this block. * - attributes: A list HTML attributes populated by modules, intended to * be added to the main container tag of this template. Includes: diff --git a/core/themes/claro/templates/classy/block/block--system-menu-block.html.twig b/core/themes/claro/templates/classy/block/block--system-menu-block.html.twig index 407f8403fd28c7db920f68ccbd4927bc2bbccb21..db3f9f808815d18c7d48a98d875736aa273b166f 100644 --- a/core/themes/claro/templates/classy/block/block--system-menu-block.html.twig +++ b/core/themes/claro/templates/classy/block/block--system-menu-block.html.twig @@ -11,6 +11,7 @@ * - label_display: The display settings for the label. * - provider: The module or other provider that provided this block plugin. * - Block plugin specific settings will also be stored here. + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content of this block. * - attributes: HTML attributes for the containing element. * - id: A valid HTML ID and guaranteed unique. diff --git a/core/themes/claro/templates/classy/block/block.html.twig b/core/themes/claro/templates/classy/block/block.html.twig index fd3311be958b9de2fcd17108309c854fdc807217..114d7c4de4f8892648a397b92eed748ec30e9672 100644 --- a/core/themes/claro/templates/classy/block/block.html.twig +++ b/core/themes/claro/templates/classy/block/block.html.twig @@ -11,6 +11,7 @@ * - label_display: The display settings for the label. * - provider: The module or other provider that provided this block plugin. * - Block plugin specific settings will also be stored here. + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content of this block. * - attributes: array of HTML attributes populated by modules, intended to * be added to the main container tag of this template. diff --git a/core/themes/olivero/templates/block/block--page-title-block.html.twig b/core/themes/olivero/templates/block/block--page-title-block.html.twig index 64361701688917aeff569a1b40dc3516a00eb281..1cf7bcb0e982a7a97656c81c90e8d2984585806d 100644 --- a/core/themes/olivero/templates/block/block--page-title-block.html.twig +++ b/core/themes/olivero/templates/block/block--page-title-block.html.twig @@ -12,6 +12,7 @@ * - label_display: The display settings for the label. * - provider: The module or other provider that provided this block plugin. * - Block plugin specific settings will also be stored here. + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content of this block. * - attributes: array of HTML attributes populated by modules, intended to * be added to the main container tag of this template. diff --git a/core/themes/olivero/templates/block/block--primary-menu--plugin-id--search-form-block.html.twig b/core/themes/olivero/templates/block/block--primary-menu--plugin-id--search-form-block.html.twig index f6bb1414d7e24e6c8351d086f69d3d448a8bc7d5..529b857ec9793f33bccb723d4b699343922297e1 100644 --- a/core/themes/olivero/templates/block/block--primary-menu--plugin-id--search-form-block.html.twig +++ b/core/themes/olivero/templates/block/block--primary-menu--plugin-id--search-form-block.html.twig @@ -11,6 +11,7 @@ * - label_display: The display settings for the label. * - provider: The module or other provider that provided this block plugin. * - Block plugin specific settings will also be stored here. + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content of this block. * - content_attributes: A list of HTML attributes applied to the main content * - attributes: A list HTML attributes populated by modules, intended to diff --git a/core/themes/olivero/templates/block/block--secondary-menu.html.twig b/core/themes/olivero/templates/block/block--secondary-menu.html.twig index 6c6c77a9b0acdb4b467d751bcf78dc2c5e6e695f..3c03dace1be95b9c8c299124ce6ec222218ce8bb 100644 --- a/core/themes/olivero/templates/block/block--secondary-menu.html.twig +++ b/core/themes/olivero/templates/block/block--secondary-menu.html.twig @@ -11,6 +11,7 @@ * - label_display: The display settings for the label. * - provider: The module or other provider that provided this block plugin. * - Block plugin specific settings will also be stored here. + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content of this block. * - attributes: HTML attributes for the containing element. * - id: A valid HTML ID and guaranteed unique. diff --git a/core/themes/olivero/templates/block/block--system-menu-block.html.twig b/core/themes/olivero/templates/block/block--system-menu-block.html.twig index 1b56b155d0ddc4468781c94f715a8c162cffa48f..9e9c25df6a6299895cb8e3c0e6b4114f86ca492e 100644 --- a/core/themes/olivero/templates/block/block--system-menu-block.html.twig +++ b/core/themes/olivero/templates/block/block--system-menu-block.html.twig @@ -11,6 +11,7 @@ * - label_display: The display settings for the label. * - provider: The module or other provider that provided this block plugin. * - Block plugin specific settings will also be stored here. + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content of this block. * - attributes: HTML attributes for the containing element. * - id: A valid HTML ID and guaranteed unique. diff --git a/core/themes/olivero/templates/block/block.html.twig b/core/themes/olivero/templates/block/block.html.twig index 647fb4e1f7093d6832cc0571982ce684443f826a..6681e1ea851c23b77cf701f0ab367952397fff60 100644 --- a/core/themes/olivero/templates/block/block.html.twig +++ b/core/themes/olivero/templates/block/block.html.twig @@ -12,6 +12,7 @@ * - label_display: The display settings for the label. * - provider: The module or other provider that provided this block plugin. * - Block plugin specific settings will also be stored here. + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content of this block. * - attributes: array of HTML attributes populated by modules, intended to * be added to the main container tag of this template. diff --git a/core/themes/stable9/layouts/layout_builder/fourcol_section/layout--fourcol-section.html.twig b/core/themes/stable9/layouts/layout_builder/fourcol_section/layout--fourcol-section.html.twig index e610278c45e09482feffbc73bb81d2c54b384a8b..0dd0820a7d5bc421be256ad9ef2428abaae85de7 100644 --- a/core/themes/stable9/layouts/layout_builder/fourcol_section/layout--fourcol-section.html.twig +++ b/core/themes/stable9/layouts/layout_builder/fourcol_section/layout--fourcol-section.html.twig @@ -4,6 +4,7 @@ * Theme override for a four-column 25%-25%-25%-25% layout. * * Available variables: + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content for this layout. * - attributes: HTML attributes for the layout <div>. */ diff --git a/core/themes/stable9/layouts/layout_builder/threecol_section/layout--threecol-section.html.twig b/core/themes/stable9/layouts/layout_builder/threecol_section/layout--threecol-section.html.twig index 123acfec3e6009225b117493350bacf3b21634c7..a85b90c127f01fbe573398954236ca8c50e1ad4d 100644 --- a/core/themes/stable9/layouts/layout_builder/threecol_section/layout--threecol-section.html.twig +++ b/core/themes/stable9/layouts/layout_builder/threecol_section/layout--threecol-section.html.twig @@ -4,6 +4,7 @@ * Theme override for a three-column layout. * * Available variables: + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content for this layout. * - attributes: HTML attributes for the layout <div>. */ diff --git a/core/themes/stable9/layouts/layout_builder/twocol_section/layout--twocol-section.html.twig b/core/themes/stable9/layouts/layout_builder/twocol_section/layout--twocol-section.html.twig index d047debe53c34da45207f691b24d67c6d01795a7..dc9ee5ccdc7350c385e99178a69f3a2fc98007e3 100644 --- a/core/themes/stable9/layouts/layout_builder/twocol_section/layout--twocol-section.html.twig +++ b/core/themes/stable9/layouts/layout_builder/twocol_section/layout--twocol-section.html.twig @@ -4,6 +4,7 @@ * Theme override to display a two-column layout. * * Available variables: + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content for this layout. * - attributes: HTML attributes for the layout <div>. */ diff --git a/core/themes/stable9/layouts/layout_discovery/onecol/layout--onecol.html.twig b/core/themes/stable9/layouts/layout_discovery/onecol/layout--onecol.html.twig index 7fe5b121ca8f82b6b6cbe5097fec58fb74202877..f3bda9290c20a26c201044767346e5cbf1fd2c4b 100644 --- a/core/themes/stable9/layouts/layout_discovery/onecol/layout--onecol.html.twig +++ b/core/themes/stable9/layouts/layout_discovery/onecol/layout--onecol.html.twig @@ -4,6 +4,7 @@ * Theme override to display a one-column layout. * * Available variables: + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content for this layout. * - attributes: HTML attributes for the layout <div>. */ diff --git a/core/themes/stable9/layouts/layout_discovery/threecol_25_50_25/layout--threecol-25-50-25.html.twig b/core/themes/stable9/layouts/layout_discovery/threecol_25_50_25/layout--threecol-25-50-25.html.twig index 715470bd061a21c101cbf0250fa6d099a128b306..6829a6e6fed0550d98bcc97c8d2216bd2952574d 100644 --- a/core/themes/stable9/layouts/layout_discovery/threecol_25_50_25/layout--threecol-25-50-25.html.twig +++ b/core/themes/stable9/layouts/layout_discovery/threecol_25_50_25/layout--threecol-25-50-25.html.twig @@ -7,6 +7,7 @@ * additional areas for the top and the bottom. * * Available variables: + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content for this layout. * - attributes: HTML attributes for the layout <div>. */ diff --git a/core/themes/stable9/layouts/layout_discovery/threecol_33_34_33/layout--threecol-33-34-33.html.twig b/core/themes/stable9/layouts/layout_discovery/threecol_33_34_33/layout--threecol-33-34-33.html.twig index f0a541d495818427b593345729133cab82d91b12..43bfe201570d9e0efd6a4c41234a5e0bf7814383 100644 --- a/core/themes/stable9/layouts/layout_discovery/threecol_33_34_33/layout--threecol-33-34-33.html.twig +++ b/core/themes/stable9/layouts/layout_discovery/threecol_33_34_33/layout--threecol-33-34-33.html.twig @@ -7,6 +7,7 @@ * additional areas for the top and the bottom. * * Available variables: + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content for this layout. * - attributes: HTML attributes for the layout <div>. */ diff --git a/core/themes/stable9/layouts/layout_discovery/twocol/layout--twocol.html.twig b/core/themes/stable9/layouts/layout_discovery/twocol/layout--twocol.html.twig index 4de66f048958db290f59738738fb1755d44b5230..c56c36c66b555500dc950de6dc75685ea8d235e3 100644 --- a/core/themes/stable9/layouts/layout_discovery/twocol/layout--twocol.html.twig +++ b/core/themes/stable9/layouts/layout_discovery/twocol/layout--twocol.html.twig @@ -4,6 +4,7 @@ * Theme override to display a two-column layout. * * Available variables: + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content for this layout. * - attributes: HTML attributes for the layout <div>. */ diff --git a/core/themes/stable9/layouts/layout_discovery/twocol_bricks/layout--twocol-bricks.html.twig b/core/themes/stable9/layouts/layout_discovery/twocol_bricks/layout--twocol-bricks.html.twig index 08a0b47920618873e49008f826a0c930e31c0d47..0069dd132e8237eba36a4782141d1eff41d19317 100644 --- a/core/themes/stable9/layouts/layout_discovery/twocol_bricks/layout--twocol-bricks.html.twig +++ b/core/themes/stable9/layouts/layout_discovery/twocol_bricks/layout--twocol-bricks.html.twig @@ -7,6 +7,7 @@ * the top, bottom and in the middle. * * Available variables: + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content for this layout. * - attributes: HTML attributes for the layout <div>. */ diff --git a/core/themes/stable9/templates/block/block--system-menu-block.html.twig b/core/themes/stable9/templates/block/block--system-menu-block.html.twig index e78e1de7f66c984ba0be4ed30d766431b9d33a5f..937c1865eda49ef2bfc15bd6e04a796441d40fd7 100644 --- a/core/themes/stable9/templates/block/block--system-menu-block.html.twig +++ b/core/themes/stable9/templates/block/block--system-menu-block.html.twig @@ -11,6 +11,7 @@ * - label_display: The display settings for the label. * - provider: The module or other provider that provided this block plugin. * - Block plugin specific settings will also be stored here. + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content of this block. * - attributes: HTML attributes for the containing element. * - id: A valid HTML ID and guaranteed unique. diff --git a/core/themes/stable9/templates/block/block.html.twig b/core/themes/stable9/templates/block/block.html.twig index dca6f48fb319e26ad0cb19d31c349915a98535e7..e842e40457664d20f4fa88cdf5c21a927c64e62a 100644 --- a/core/themes/stable9/templates/block/block.html.twig +++ b/core/themes/stable9/templates/block/block.html.twig @@ -11,6 +11,7 @@ * - label_display: The display settings for the label. * - provider: The module or other provider that provided this block plugin. * - Block plugin specific settings will also be stored here. + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content of this block. * - attributes: array of HTML attributes populated by modules, intended to * be added to the main container tag of this template. diff --git a/core/themes/starterkit_theme/templates/block/block--search-form-block.html.twig b/core/themes/starterkit_theme/templates/block/block--search-form-block.html.twig index 667202fb6b658bf3b0aae080d6687913074ef6d1..d1cda724ba8739437790d3809dedee5590c25986 100644 --- a/core/themes/starterkit_theme/templates/block/block--search-form-block.html.twig +++ b/core/themes/starterkit_theme/templates/block/block--search-form-block.html.twig @@ -11,6 +11,7 @@ * - label_display: The display settings for the label. * - provider: The module or other provider that provided this block plugin. * - Block plugin specific settings will also be stored here. + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content of this block. * - attributes: A list HTML attributes populated by modules, intended to * be added to the main container tag of this template. Includes: diff --git a/core/themes/starterkit_theme/templates/block/block--system-menu-block.html.twig b/core/themes/starterkit_theme/templates/block/block--system-menu-block.html.twig index 407f8403fd28c7db920f68ccbd4927bc2bbccb21..db3f9f808815d18c7d48a98d875736aa273b166f 100644 --- a/core/themes/starterkit_theme/templates/block/block--system-menu-block.html.twig +++ b/core/themes/starterkit_theme/templates/block/block--system-menu-block.html.twig @@ -11,6 +11,7 @@ * - label_display: The display settings for the label. * - provider: The module or other provider that provided this block plugin. * - Block plugin specific settings will also be stored here. + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content of this block. * - attributes: HTML attributes for the containing element. * - id: A valid HTML ID and guaranteed unique. diff --git a/core/themes/starterkit_theme/templates/block/block.html.twig b/core/themes/starterkit_theme/templates/block/block.html.twig index fd3311be958b9de2fcd17108309c854fdc807217..114d7c4de4f8892648a397b92eed748ec30e9672 100644 --- a/core/themes/starterkit_theme/templates/block/block.html.twig +++ b/core/themes/starterkit_theme/templates/block/block.html.twig @@ -11,6 +11,7 @@ * - label_display: The display settings for the label. * - provider: The module or other provider that provided this block plugin. * - Block plugin specific settings will also be stored here. + * - in_preview: Whether the plugin is being rendered in preview mode. * - content: The content of this block. * - attributes: array of HTML attributes populated by modules, intended to * be added to the main container tag of this template.