From d4718ba088f18ba9ee7372cea7ee15043a4cebbe Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Thu, 16 Jun 2022 11:32:45 +0100 Subject: [PATCH] add classes the captions --- .../wordpress-6.1/class-wp-theme-json-6-1.php | 14 ++------------ packages/block-library/src/audio/edit.js | 1 + packages/block-library/src/audio/save.js | 6 +++++- packages/block-library/src/embed/embed-preview.js | 1 + packages/block-library/src/embed/save.js | 6 +++++- packages/block-library/src/gallery/gallery.js | 2 +- packages/block-library/src/gallery/save.js | 2 +- .../block-library/src/gallery/v1/gallery-image.js | 1 + packages/block-library/src/gallery/v1/gallery.js | 2 +- packages/block-library/src/gallery/v1/save.js | 4 ++-- packages/block-library/src/image/image.js | 1 + packages/block-library/src/image/save.js | 6 +++++- packages/block-library/src/table/edit.js | 1 + packages/block-library/src/table/save.js | 6 +++++- packages/block-library/src/video/edit.js | 1 + packages/block-library/src/video/save.js | 6 +++++- 16 files changed, 38 insertions(+), 22 deletions(-) diff --git a/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php b/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php index 32ee3cf38ccd9..c7e17d3f623c6 100644 --- a/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php +++ b/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php @@ -15,17 +15,6 @@ * @access private */ class WP_Theme_JSON_6_1 extends WP_Theme_JSON_6_0 { - const ELEMENTS = array( - 'link' => 'a', - 'h1' => 'h1', - 'h2' => 'h2', - 'h3' => 'h3', - 'h4' => 'h4', - 'h5' => 'h5', - 'h6' => 'h6', - 'button' => '.wp-element-button, .wp-block-button__link', // We have the .wp-block-button__link class so that this will target older buttons that have been serialized. - ); - const __EXPERIMENTAL_ELEMENT_CLASS_NAMES = array( 'button' => 'wp-element-button', ); @@ -56,7 +45,8 @@ public static function get_element_class_name( $element ) { 'h4' => 'h4', 'h5' => 'h5', 'h6' => 'h6', - 'caption' => 'figcaption', + 'button' => '.wp-element-button, .wp-block-button__link', // We have the .wp-block-button__link class so that this will target older buttons that have been serialized. + 'caption' => '.wp-element-caption, .wp-block-audio figcaption, .wp-block-embed figcaption, .wp-block-gallery figcaption, .wp-block-image figcaption, .wp-block-table figcaption, .wp-block-video figcaption', // The block classes are necessary to target older content that won't use the new class names. ); /** diff --git a/packages/block-library/src/audio/edit.js b/packages/block-library/src/audio/edit.js index 5ad981bab9da5..a482f568c4b82 100644 --- a/packages/block-library/src/audio/edit.js +++ b/packages/block-library/src/audio/edit.js @@ -200,6 +200,7 @@ function AudioEdit( { { ( ! RichText.isEmpty( caption ) || isSelected ) && ( { ! RichText.isEmpty( caption ) && ( - + ) } ) diff --git a/packages/block-library/src/embed/embed-preview.js b/packages/block-library/src/embed/embed-preview.js index c938235045b4a..4bdd7d0ba9f5f 100644 --- a/packages/block-library/src/embed/embed-preview.js +++ b/packages/block-library/src/embed/embed-preview.js @@ -140,6 +140,7 @@ class EmbedPreview extends Component { { ( ! RichText.isEmpty( caption ) || isSelected ) && ( { ! RichText.isEmpty( caption ) && ( - + ) } ); diff --git a/packages/block-library/src/gallery/gallery.js b/packages/block-library/src/gallery/gallery.js index 25ce4fa7b9d0a..39e13ff73b7db 100644 --- a/packages/block-library/src/gallery/gallery.js +++ b/packages/block-library/src/gallery/gallery.js @@ -82,7 +82,7 @@ export const Gallery = ( props ) => { captionFocused={ captionFocused } onFocusCaption={ onFocusCaption } tagName="figcaption" - className="blocks-gallery-caption" + className="blocks-gallery-caption wp-element-caption" aria-label={ __( 'Gallery caption text' ) } placeholder={ __( 'Write gallery caption…' ) } value={ caption } diff --git a/packages/block-library/src/gallery/save.js b/packages/block-library/src/gallery/save.js index 655a1823020fc..e78df57288b81 100644 --- a/packages/block-library/src/gallery/save.js +++ b/packages/block-library/src/gallery/save.js @@ -39,7 +39,7 @@ export default function saveWithInnerBlocks( { attributes } ) { { ! RichText.isEmpty( caption ) && ( ) } diff --git a/packages/block-library/src/gallery/v1/gallery-image.js b/packages/block-library/src/gallery/v1/gallery-image.js index 24cb8549d352b..c42bf96a808b6 100644 --- a/packages/block-library/src/gallery/v1/gallery-image.js +++ b/packages/block-library/src/gallery/v1/gallery-image.js @@ -245,6 +245,7 @@ class GalleryImage extends Component { { ! isEditing && ( isSelected || caption ) && ( { ) } @@ -72,7 +72,7 @@ export default function saveV1( { attributes } ) { { ! RichText.isEmpty( caption ) && ( ) } diff --git a/packages/block-library/src/image/image.js b/packages/block-library/src/image/image.js index 8ec14a81d0212..5b7a4f3f45e46 100644 --- a/packages/block-library/src/image/image.js +++ b/packages/block-library/src/image/image.js @@ -576,6 +576,7 @@ export default function Image( { { img } { ( ! RichText.isEmpty( caption ) || isSelected ) && ( + ) } ); diff --git a/packages/block-library/src/table/edit.js b/packages/block-library/src/table/edit.js index 7c39f73c1d0e3..dd72b8b543aa4 100644 --- a/packages/block-library/src/table/edit.js +++ b/packages/block-library/src/table/edit.js @@ -509,6 +509,7 @@ function TableEdit( { { ! isEmpty && ( { hasCaption && ( - + ) } ); diff --git a/packages/block-library/src/video/edit.js b/packages/block-library/src/video/edit.js index 27b419d22aa21..91b3528009236 100644 --- a/packages/block-library/src/video/edit.js +++ b/packages/block-library/src/video/edit.js @@ -266,6 +266,7 @@ function VideoEdit( { { ( ! RichText.isEmpty( caption ) || isSelected ) && ( ) } { ! RichText.isEmpty( caption ) && ( - + ) } );