From dd1dc27384db7a51363e9b797799604773cffcd3 Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Fri, 24 Jun 2022 14:14:41 +0100 Subject: [PATCH 1/4] dd caption element --- .../wordpress-6.1/class-wp-theme-json-6-1.php | 25 +++++++++++------- packages/block-editor/src/elements/index.js | 1 + packages/block-library/src/audio/edit.js | 4 +++ packages/block-library/src/audio/save.js | 14 ++++++++-- .../block-library/src/embed/embed-preview.js | 9 ++++++- packages/block-library/src/embed/save.js | 12 +++++++-- .../test/__snapshots__/index.native.js.snap | 2 +- packages/block-library/src/gallery/gallery.js | 11 ++++++-- packages/block-library/src/gallery/save.js | 6 ++++- .../test/__snapshots__/index.native.js.snap | 4 +-- .../src/gallery/v1/gallery-image.js | 4 +++ .../block-library/src/gallery/v1/gallery.js | 10 +++++-- packages/block-library/src/gallery/v1/save.js | 23 +++++++++++++--- packages/block-library/src/image/image.js | 2 ++ packages/block-library/src/image/save.js | 12 +++++++-- .../src/image/test/edit.native.js | 26 +++++++++---------- packages/block-library/src/table/edit.js | 2 ++ packages/block-library/src/table/save.js | 7 ++++- packages/block-library/src/video/edit.js | 4 +++ packages/block-library/src/video/save.js | 12 +++++++-- .../blocks/__snapshots__/table.test.js.snap | 2 +- .../react-native-editor/src/initial-html.js | 6 ++--- .../blocks-raw-handling.test.js.snap | 6 ++--- .../fixtures/blocks/core__embed.html | 2 +- .../fixtures/blocks/core__embed.parsed.json | 4 +-- .../blocks/core__embed.serialized.html | 2 +- .../blocks/core__gallery-with-caption.html | 2 +- .../core__gallery-with-caption.parsed.json | 4 +-- ...core__gallery-with-caption.serialized.html | 2 +- .../blocks/core__image__center-caption.html | 2 +- .../core__image__center-caption.parsed.json | 4 +-- ...ore__image__center-caption.serialized.html | 2 +- .../fixtures/blocks/core__table__caption.html | 2 +- .../blocks/core__table__caption.parsed.json | 4 +-- .../core__table__caption.serialized.html | 2 +- .../blocks/core__table__deprecated-1.html | 2 +- .../blocks/core__table__deprecated-1.json | 6 +---- .../core__table__deprecated-1.parsed.json | 4 +-- .../core__table__deprecated-1.serialized.html | 4 +-- 39 files changed, 176 insertions(+), 76 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 c89309366d2deb..d093480e924e44 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 @@ -25,19 +25,26 @@ class WP_Theme_JSON_6_1 extends WP_Theme_JSON_6_0 { 'link' => array( ':hover', ':focus', ':active' ), ); + /* + * The valid elements that can be found under styles. + * + * @var string[] + */ 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. + '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. + '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. ); const __EXPERIMENTAL_ELEMENT_CLASS_NAMES = array( - 'button' => 'wp-element-button', + 'button' => 'wp-element-button', + 'caption' => 'wp-element-caption', ); /** diff --git a/packages/block-editor/src/elements/index.js b/packages/block-editor/src/elements/index.js index 5d74bb3c0c9962..4cc7893583a118 100644 --- a/packages/block-editor/src/elements/index.js +++ b/packages/block-editor/src/elements/index.js @@ -1,5 +1,6 @@ const ELEMENT_CLASS_NAMES = { button: 'wp-element-button', + caption: 'wp-element-caption', }; export const __experimentalGetElementClassName = ( element ) => { diff --git a/packages/block-library/src/audio/edit.js b/packages/block-library/src/audio/edit.js index 5ad981bab9da50..c220ea33c71fdb 100644 --- a/packages/block-library/src/audio/edit.js +++ b/packages/block-library/src/audio/edit.js @@ -24,6 +24,7 @@ import { RichText, useBlockProps, store as blockEditorStore, + __experimentalGetElementClassName, } from '@wordpress/block-editor'; import { useEffect } from '@wordpress/element'; import { __, _x } from '@wordpress/i18n'; @@ -200,6 +201,9 @@ 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 c938235045b4a7..5fa959375245bf 100644 --- a/packages/block-library/src/embed/embed-preview.js +++ b/packages/block-library/src/embed/embed-preview.js @@ -13,7 +13,11 @@ import classnames from 'classnames/dedupe'; */ import { __, sprintf } from '@wordpress/i18n'; import { Placeholder, SandBox } from '@wordpress/components'; -import { RichText, BlockIcon } from '@wordpress/block-editor'; +import { + RichText, + BlockIcon, + __experimentalGetElementClassName, +} from '@wordpress/block-editor'; import { Component } from '@wordpress/element'; import { createBlock, getDefaultBlockName } from '@wordpress/blocks'; @@ -140,6 +144,9 @@ class EmbedPreview extends Component { { ( ! RichText.isEmpty( caption ) || isSelected ) && ( { ! RichText.isEmpty( caption ) && ( - + ) } ); diff --git a/packages/block-library/src/embed/test/__snapshots__/index.native.js.snap b/packages/block-library/src/embed/test/__snapshots__/index.native.js.snap index 0e85219afb31a1..c3d1da4e4813b5 100644 --- a/packages/block-library/src/embed/test/__snapshots__/index.native.js.snap +++ b/packages/block-library/src/embed/test/__snapshots__/index.native.js.snap @@ -186,6 +186,6 @@ exports[`Embed block sets block caption 1`] = ` "
https://twitter.com/notnownikki -
Caption
+
Caption
" `; diff --git a/packages/block-library/src/gallery/gallery.js b/packages/block-library/src/gallery/gallery.js index 25ce4fa7b9d0ab..b3933e2a1b7b7a 100644 --- a/packages/block-library/src/gallery/gallery.js +++ b/packages/block-library/src/gallery/gallery.js @@ -6,7 +6,11 @@ import classnames from 'classnames'; /** * WordPress dependencies */ -import { RichText, useInnerBlocksProps } from '@wordpress/block-editor'; +import { + RichText, + useInnerBlocksProps, + __experimentalGetElementClassName, +} from '@wordpress/block-editor'; import { VisuallyHidden } from '@wordpress/components'; import { useState, useEffect } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; @@ -82,7 +86,10 @@ export const Gallery = ( props ) => { captionFocused={ captionFocused } onFocusCaption={ onFocusCaption } tagName="figcaption" - className="blocks-gallery-caption" + className={ classnames( + 'blocks-gallery-caption', + __experimentalGetElementClassName( '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 655a1823020fc5..66253001e64182 100644 --- a/packages/block-library/src/gallery/save.js +++ b/packages/block-library/src/gallery/save.js @@ -10,6 +10,7 @@ import { RichText, useBlockProps, useInnerBlocksProps, + __experimentalGetElementClassName, } from '@wordpress/block-editor'; /** @@ -39,7 +40,10 @@ export default function saveWithInnerBlocks( { attributes } ) { { ! RichText.isEmpty( caption ) && ( ) } diff --git a/packages/block-library/src/gallery/test/__snapshots__/index.native.js.snap b/packages/block-library/src/gallery/test/__snapshots__/index.native.js.snap index 1fd4dc765870d0..0a9cb246594e90 100644 --- a/packages/block-library/src/gallery/test/__snapshots__/index.native.js.snap +++ b/packages/block-library/src/gallery/test/__snapshots__/index.native.js.snap @@ -114,14 +114,14 @@ exports[`Gallery block sets caption to gallery 1`] = ` " + " `; exports[`Gallery block sets caption to gallery items 1`] = ` " " `; diff --git a/packages/block-library/src/gallery/v1/gallery-image.js b/packages/block-library/src/gallery/v1/gallery-image.js index 24cb8549d352b0..9520a5ba76349a 100644 --- a/packages/block-library/src/gallery/v1/gallery-image.js +++ b/packages/block-library/src/gallery/v1/gallery-image.js @@ -16,6 +16,7 @@ import { RichText, MediaPlaceholder, store as blockEditorStore, + __experimentalGetElementClassName, } from '@wordpress/block-editor'; import { isBlobURL } from '@wordpress/blob'; import { compose } from '@wordpress/compose'; @@ -245,6 +246,9 @@ class GalleryImage extends Component { { ! isEditing && ( isSelected || caption ) && ( { ) } @@ -72,7 +86,10 @@ 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 8ec14a81d0212b..52fa307cecac80 100644 --- a/packages/block-library/src/image/image.js +++ b/packages/block-library/src/image/image.js @@ -29,6 +29,7 @@ import { BlockAlignmentControl, __experimentalImageEditor as ImageEditor, __experimentalImageEditingProvider as ImageEditingProvider, + __experimentalGetElementClassName, } from '@wordpress/block-editor'; import { useEffect, useMemo, useState, useRef } from '@wordpress/element'; import { __, sprintf, isRTL } from '@wordpress/i18n'; @@ -576,6 +577,7 @@ export default function Image( { { img } { ( ! RichText.isEmpty( caption ) || isSelected ) && ( + ) } ); diff --git a/packages/block-library/src/image/test/edit.native.js b/packages/block-library/src/image/test/edit.native.js index 2803060847bb92..e8b748e95e4302 100644 --- a/packages/block-library/src/image/test/edit.native.js +++ b/packages/block-library/src/image/test/edit.native.js @@ -84,7 +84,7 @@ describe( 'Image Block', () => { -
Mountain
+
Mountain
`; const screen = await initializeEditor( { initialHtml } ); // We must await the image fetch via `getMedia` @@ -100,7 +100,7 @@ describe( 'Image Block', () => { fireEvent.press( screen.getByText( 'None' ) ); const expectedHtml = ` -
Mountain
+
Mountain
`; expect( getEditorHtml() ).toBe( expectedHtml ); } ); @@ -110,7 +110,7 @@ describe( 'Image Block', () => {
-
Mountain
+
Mountain
`; const screen = await initializeEditor( { initialHtml } ); // We must await the image fetch via `getMedia` @@ -126,7 +126,7 @@ describe( 'Image Block', () => { fireEvent.press( screen.getByText( 'Media File' ) ); const expectedHtml = ` -
Mountain
+
Mountain
`; expect( getEditorHtml() ).toBe( expectedHtml ); } ); @@ -136,7 +136,7 @@ describe( 'Image Block', () => {
-
Mountain
+
Mountain
`; const screen = await initializeEditor( { initialHtml } ); // We must await the image fetch via `getMedia` @@ -159,7 +159,7 @@ describe( 'Image Block', () => { fireEvent.press( screen.getByA11yLabel( 'Apply' ) ); const expectedHtml = ` -
Mountain
+
Mountain
`; expect( getEditorHtml() ).toBe( expectedHtml ); } ); @@ -169,7 +169,7 @@ describe( 'Image Block', () => {
-
Mountain
+
Mountain
`; const screen = await initializeEditor( { initialHtml } ); // We must await the image fetch via `getMedia` @@ -197,7 +197,7 @@ describe( 'Image Block', () => { fireEvent.press( screen.getByText( 'Media File' ) ); const expectedHtml = ` -
Mountain
+
Mountain
`; expect( getEditorHtml() ).toBe( expectedHtml ); } ); @@ -209,7 +209,7 @@ describe( 'Image Block', () => { -
Mountain
+
Mountain
`; const screen = await initializeEditor( { initialHtml } ); // We must await the image fetch via `getMedia` @@ -233,7 +233,7 @@ describe( 'Image Block', () => { -
Mountain
+
Mountain
`; const screen = await initializeEditor( { initialHtml } ); // We must await the image fetch via `getMedia` @@ -251,7 +251,7 @@ describe( 'Image Block', () => { fireEvent.press( linkTargetButton ); const expectedHtml = ` -
Mountain
+
Mountain
`; expect( getEditorHtml() ).toBe( expectedHtml ); } ); @@ -263,7 +263,7 @@ describe( 'Image Block', () => { -
Mountain
+
Mountain
`; const screen = await initializeEditor( { initialHtml } ); @@ -282,7 +282,7 @@ describe( 'Image Block', () => { fireEvent.press( linkTargetButton ); const expectedHtml = ` -
Mountain
+
Mountain
`; expect( getEditorHtml() ).toBe( expectedHtml ); } ); diff --git a/packages/block-library/src/table/edit.js b/packages/block-library/src/table/edit.js index 7c39f73c1d0e34..abb6438cb56785 100644 --- a/packages/block-library/src/table/edit.js +++ b/packages/block-library/src/table/edit.js @@ -16,6 +16,7 @@ import { useBlockProps, __experimentalUseColorProps as useColorProps, __experimentalUseBorderProps as useBorderProps, + __experimentalGetElementClassName, } from '@wordpress/block-editor'; import { __ } from '@wordpress/i18n'; import { @@ -509,6 +510,7 @@ function TableEdit( { { ! isEmpty && ( { hasCaption && ( - + ) } ); diff --git a/packages/block-library/src/video/edit.js b/packages/block-library/src/video/edit.js index 27b419d22aa21a..3d6467474ca51f 100644 --- a/packages/block-library/src/video/edit.js +++ b/packages/block-library/src/video/edit.js @@ -26,6 +26,7 @@ import { RichText, useBlockProps, store as blockEditorStore, + __experimentalGetElementClassName, } from '@wordpress/block-editor'; import { useRef, useEffect } from '@wordpress/element'; import { __, sprintf } from '@wordpress/i18n'; @@ -266,6 +267,9 @@ function VideoEdit( { { ( ! RichText.isEmpty( caption ) || isSelected ) && ( ) } { ! RichText.isEmpty( caption ) && ( - + ) } ); diff --git a/packages/e2e-tests/specs/editor/blocks/__snapshots__/table.test.js.snap b/packages/e2e-tests/specs/editor/blocks/__snapshots__/table.test.js.snap index fc9d85e415e5cc..88c72f08983b7a 100644 --- a/packages/e2e-tests/specs/editor/blocks/__snapshots__/table.test.js.snap +++ b/packages/e2e-tests/specs/editor/blocks/__snapshots__/table.test.js.snap @@ -2,7 +2,7 @@ exports[`Table allows a caption to be added 1`] = ` " -
Caption!
+
Caption!
" `; diff --git a/packages/react-native-editor/src/initial-html.js b/packages/react-native-editor/src/initial-html.js index 7c1cb67a5cc9bb..10c580dd9e0b44 100644 --- a/packages/react-native-editor/src/initial-html.js +++ b/packages/react-native-editor/src/initial-html.js @@ -80,7 +80,7 @@ else: -
Mountain
+
Mountain
@@ -88,7 +88,7 @@ else: -
Videos too!
+
Videos too!
@@ -116,7 +116,7 @@ else: - + diff --git a/test/integration/__snapshots__/blocks-raw-handling.test.js.snap b/test/integration/__snapshots__/blocks-raw-handling.test.js.snap index 6e3a6b8a84795f..a06654d89078af 100644 --- a/test/integration/__snapshots__/blocks-raw-handling.test.js.snap +++ b/test/integration/__snapshots__/blocks-raw-handling.test.js.snap @@ -85,19 +85,19 @@ exports[`rawHandler should convert HTML post to blocks with minimal content chan exports[`rawHandler should convert a caption shortcode 1`] = ` " -
\\"\\"
test
+
\\"\\"
test
" `; exports[`rawHandler should convert a caption shortcode with caption 1`] = ` " -
\\"\\"
test
+
\\"\\"
test
" `; exports[`rawHandler should convert a caption shortcode with link 1`] = ` " -
\\"Bell
Bell on wharf in San Francisco
+
\\"Bell
Bell on wharf in San Francisco
" `; diff --git a/test/integration/fixtures/blocks/core__embed.html b/test/integration/fixtures/blocks/core__embed.html index f9a539f22a0c95..5df79b888f32bd 100644 --- a/test/integration/fixtures/blocks/core__embed.html +++ b/test/integration/fixtures/blocks/core__embed.html @@ -3,6 +3,6 @@
https://example.com/
-
Embedded content from an example URL
+
Embedded content from an example URL
diff --git a/test/integration/fixtures/blocks/core__embed.parsed.json b/test/integration/fixtures/blocks/core__embed.parsed.json index e5eb6716d2e732..c75e10780ae144 100644 --- a/test/integration/fixtures/blocks/core__embed.parsed.json +++ b/test/integration/fixtures/blocks/core__embed.parsed.json @@ -5,9 +5,9 @@ "url": "https://example.com/" }, "innerBlocks": [], - "innerHTML": "\n
\n
\n https://example.com/\n
\n
Embedded content from an example URL
\n
\n", + "innerHTML": "\n
\n
\n https://example.com/\n
\n
Embedded content from an example URL
\n
\n", "innerContent": [ - "\n
\n
\n https://example.com/\n
\n
Embedded content from an example URL
\n
\n" + "\n
\n
\n https://example.com/\n
\n
Embedded content from an example URL
\n
\n" ] } ] diff --git a/test/integration/fixtures/blocks/core__embed.serialized.html b/test/integration/fixtures/blocks/core__embed.serialized.html index 3906dd45ee541c..af25e3c4acb671 100644 --- a/test/integration/fixtures/blocks/core__embed.serialized.html +++ b/test/integration/fixtures/blocks/core__embed.serialized.html @@ -1,5 +1,5 @@
https://example.com/ -
Embedded content from an example URL
+
Embedded content from an example URL
diff --git a/test/integration/fixtures/blocks/core__gallery-with-caption.html b/test/integration/fixtures/blocks/core__gallery-with-caption.html index 0ec3003092d8b9..498c7752e3a2f9 100644 --- a/test/integration/fixtures/blocks/core__gallery-with-caption.html +++ b/test/integration/fixtures/blocks/core__gallery-with-caption.html @@ -21,6 +21,6 @@ /> - + diff --git a/test/integration/fixtures/blocks/core__gallery-with-caption.parsed.json b/test/integration/fixtures/blocks/core__gallery-with-caption.parsed.json index bb43e7abcd7f82..9c2b7f082846b1 100644 --- a/test/integration/fixtures/blocks/core__gallery-with-caption.parsed.json +++ b/test/integration/fixtures/blocks/core__gallery-with-caption.parsed.json @@ -42,13 +42,13 @@ ] } ], - "innerHTML": "\n\n\t\n\n\t\n\t\n\n", + "innerHTML": "\n\n\t\n\n\t\n\t\n\n", "innerContent": [ "\n\n\t", null, "\n\n\t", null, - "\n\t\n\n" + "\n\t\n\n" ] } ] diff --git a/test/integration/fixtures/blocks/core__gallery-with-caption.serialized.html b/test/integration/fixtures/blocks/core__gallery-with-caption.serialized.html index f67c8682af23ea..0eeab028d199d2 100644 --- a/test/integration/fixtures/blocks/core__gallery-with-caption.serialized.html +++ b/test/integration/fixtures/blocks/core__gallery-with-caption.serialized.html @@ -5,5 +5,5 @@
Image gallery image
- + diff --git a/test/integration/fixtures/blocks/core__image__center-caption.html b/test/integration/fixtures/blocks/core__image__center-caption.html index 046800a80bc98a..1a221343202d06 100644 --- a/test/integration/fixtures/blocks/core__image__center-caption.html +++ b/test/integration/fixtures/blocks/core__image__center-caption.html @@ -1,3 +1,3 @@ -
Give it a try. Press the "really wide" button on the image toolbar.
+
Give it a try. Press the "really wide" button on the image toolbar.
diff --git a/test/integration/fixtures/blocks/core__image__center-caption.parsed.json b/test/integration/fixtures/blocks/core__image__center-caption.parsed.json index 27b4e57ed45881..1875086370f42f 100644 --- a/test/integration/fixtures/blocks/core__image__center-caption.parsed.json +++ b/test/integration/fixtures/blocks/core__image__center-caption.parsed.json @@ -5,9 +5,9 @@ "align": "center" }, "innerBlocks": [], - "innerHTML": "\n
\"\"
Give it a try. Press the "really wide" button on the image toolbar.
\n", + "innerHTML": "\n
\"\"
Give it a try. Press the "really wide" button on the image toolbar.
\n", "innerContent": [ - "\n
\"\"
Give it a try. Press the "really wide" button on the image toolbar.
\n" + "\n
\"\"
Give it a try. Press the "really wide" button on the image toolbar.
\n" ] } ] diff --git a/test/integration/fixtures/blocks/core__image__center-caption.serialized.html b/test/integration/fixtures/blocks/core__image__center-caption.serialized.html index 785def42a5d91f..75f992e1c441b9 100644 --- a/test/integration/fixtures/blocks/core__image__center-caption.serialized.html +++ b/test/integration/fixtures/blocks/core__image__center-caption.serialized.html @@ -1,3 +1,3 @@ -
Give it a try. Press the "really wide" button on the image toolbar.
+
Give it a try. Press the "really wide" button on the image toolbar.
diff --git a/test/integration/fixtures/blocks/core__table__caption.html b/test/integration/fixtures/blocks/core__table__caption.html index a22436c55bdb1f..110d0695e5a937 100644 --- a/test/integration/fixtures/blocks/core__table__caption.html +++ b/test/integration/fixtures/blocks/core__table__caption.html @@ -1,3 +1,3 @@ -
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
A table for testing
+
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
A table for testing
diff --git a/test/integration/fixtures/blocks/core__table__caption.parsed.json b/test/integration/fixtures/blocks/core__table__caption.parsed.json index 030ced272fcab6..531c2d7e605c6f 100644 --- a/test/integration/fixtures/blocks/core__table__caption.parsed.json +++ b/test/integration/fixtures/blocks/core__table__caption.parsed.json @@ -3,9 +3,9 @@ "blockName": "core/table", "attrs": {}, "innerBlocks": [], - "innerHTML": "\n
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
A table for testing
\n", + "innerHTML": "\n
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
A table for testing
\n", "innerContent": [ - "\n
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
A table for testing
\n" + "\n
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
A table for testing
\n" ] } ] diff --git a/test/integration/fixtures/blocks/core__table__caption.serialized.html b/test/integration/fixtures/blocks/core__table__caption.serialized.html index ff5add7f856b22..66246c83295a9e 100644 --- a/test/integration/fixtures/blocks/core__table__caption.serialized.html +++ b/test/integration/fixtures/blocks/core__table__caption.serialized.html @@ -1,3 +1,3 @@ -
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
A table for testing
+
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
A table for testing
diff --git a/test/integration/fixtures/blocks/core__table__deprecated-1.html b/test/integration/fixtures/blocks/core__table__deprecated-1.html index 3b748a37a4eda1..ee205fffa4010d 100644 --- a/test/integration/fixtures/blocks/core__table__deprecated-1.html +++ b/test/integration/fixtures/blocks/core__table__deprecated-1.html @@ -1,3 +1,3 @@ -
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
Table Caption
+
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
Table Caption
diff --git a/test/integration/fixtures/blocks/core__table__deprecated-1.json b/test/integration/fixtures/blocks/core__table__deprecated-1.json index daa672bebc6789..f7c6f4790244f1 100644 --- a/test/integration/fixtures/blocks/core__table__deprecated-1.json +++ b/test/integration/fixtures/blocks/core__table__deprecated-1.json @@ -138,11 +138,7 @@ } ], "foot": [], - "style": { - "color": { - "background": "#e7f5fe" - } - } + "backgroundColor": "subtle-pale-blue" }, "innerBlocks": [] } diff --git a/test/integration/fixtures/blocks/core__table__deprecated-1.parsed.json b/test/integration/fixtures/blocks/core__table__deprecated-1.parsed.json index d2cfc5e4ca5c0c..3499ffab32b2f3 100644 --- a/test/integration/fixtures/blocks/core__table__deprecated-1.parsed.json +++ b/test/integration/fixtures/blocks/core__table__deprecated-1.parsed.json @@ -5,9 +5,9 @@ "backgroundColor": "subtle-pale-blue" }, "innerBlocks": [], - "innerHTML": "\n
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
Table Caption
\n", + "innerHTML": "\n
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
Table Caption
\n", "innerContent": [ - "\n
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
Table Caption
\n" + "\n
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
Table Caption
\n" ] } ] diff --git a/test/integration/fixtures/blocks/core__table__deprecated-1.serialized.html b/test/integration/fixtures/blocks/core__table__deprecated-1.serialized.html index e3eb1805f8a918..061aa7a2248b10 100644 --- a/test/integration/fixtures/blocks/core__table__deprecated-1.serialized.html +++ b/test/integration/fixtures/blocks/core__table__deprecated-1.serialized.html @@ -1,3 +1,3 @@ - -
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
Table Caption
+ +
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
Table Caption
From 75d16ff58ef8fe968fab7b8c5fb8a5b371949ee9 Mon Sep 17 00:00:00 2001 From: David Calhoun <438664+dcalhoun@users.noreply.github.com> Date: Fri, 24 Jun 2022 10:17:51 -0500 Subject: [PATCH 2/4] test: Revert image caption class name addition for native test fixtures The current save output for native editor Image and Gallery blocks do not expect this class name. I did not identify the exact cause, but this does fix the failing existing tests. --- packages/react-native-editor/src/initial-html.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-native-editor/src/initial-html.js b/packages/react-native-editor/src/initial-html.js index 10c580dd9e0b44..017c991a992cda 100644 --- a/packages/react-native-editor/src/initial-html.js +++ b/packages/react-native-editor/src/initial-html.js @@ -80,7 +80,7 @@ else: -
Mountain
+
Mountain
@@ -116,7 +116,7 @@ else: - + From 9b1625d929a034c9a4e6c19d39efda92ee87df53 Mon Sep 17 00:00:00 2001 From: David Calhoun <438664+dcalhoun@users.noreply.github.com> Date: Fri, 24 Jun 2022 10:52:22 -0500 Subject: [PATCH 3/4] test: Reinstate image caption class name for Image block test fixture The native editor test fixtures includes a Gallery block v1 (which needs to upgraded to v2 at some point). Adding a `wp-element-caption` to this test fixture causes parsing failure. The lack of `wp-element-caption` class name for the Image block causes an unnecessary block update during test runs. The `wp-element-caption` class name was added to the native editor test fixtures for both the Gallery and Image. The addition was only needed for the latter. The previous commit erroneously removed the class name for both. This commit reinstates the class name for the latter. --- packages/react-native-editor/src/initial-html.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-native-editor/src/initial-html.js b/packages/react-native-editor/src/initial-html.js index 017c991a992cda..9c2c53618f428c 100644 --- a/packages/react-native-editor/src/initial-html.js +++ b/packages/react-native-editor/src/initial-html.js @@ -80,7 +80,7 @@ else: -
Mountain
+
Mountain
From 9fbe7ddba69a50684e1ab02c5c13234922859e8b Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Fri, 24 Jun 2022 21:25:19 +0100 Subject: [PATCH 4/4] update snapshot --- .../specs/editor/blocks/__snapshots__/table.test.js.snap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/e2e-tests/specs/editor/blocks/__snapshots__/table.test.js.snap b/packages/e2e-tests/specs/editor/blocks/__snapshots__/table.test.js.snap index 88c72f08983b7a..27f0619a4de248 100644 --- a/packages/e2e-tests/specs/editor/blocks/__snapshots__/table.test.js.snap +++ b/packages/e2e-tests/specs/editor/blocks/__snapshots__/table.test.js.snap @@ -2,7 +2,7 @@ exports[`Table allows a caption to be added 1`] = ` " -
Caption!
+
Caption!
" `;