diff --git a/packages/block-library/src/paragraph/deprecated.js b/packages/block-library/src/paragraph/deprecated.js
index c3f18db62d62c..d7871b8854ca3 100644
--- a/packages/block-library/src/paragraph/deprecated.js
+++ b/packages/block-library/src/paragraph/deprecated.js
@@ -12,6 +12,7 @@ import {
} from '@wordpress/element';
import {
getColorClassName,
+ getFontSizeClass,
RichText,
} from '@wordpress/block-editor';
@@ -61,6 +62,54 @@ const blockAttributes = {
};
const deprecated = [
+ {
+ supports,
+ attributes: blockAttributes,
+ save( { attributes } ) {
+ const {
+ align,
+ content,
+ dropCap,
+ backgroundColor,
+ textColor,
+ customBackgroundColor,
+ customTextColor,
+ fontSize,
+ customFontSize,
+ direction,
+ } = attributes;
+
+ const textClass = getColorClassName( 'color', textColor );
+ const backgroundClass = getColorClassName( 'background-color', backgroundColor );
+ const fontSizeClass = getFontSizeClass( fontSize );
+
+ const className = classnames( {
+ 'has-text-color': textColor || customTextColor,
+ 'has-background': backgroundColor || customBackgroundColor,
+ 'has-drop-cap': dropCap,
+ [ fontSizeClass ]: fontSizeClass,
+ [ textClass ]: textClass,
+ [ backgroundClass ]: backgroundClass,
+ } );
+
+ const styles = {
+ backgroundColor: backgroundClass ? undefined : customBackgroundColor,
+ color: textClass ? undefined : customTextColor,
+ fontSize: fontSizeClass ? undefined : customFontSize,
+ textAlign: align,
+ };
+
+ return (
+
+
Guten Berg!
diff --git a/packages/e2e-tests/fixtures/blocks/core__cover.json b/packages/e2e-tests/fixtures/blocks/core__cover.json index 93776fce2cdc0..2092e1fc58a1a 100644 --- a/packages/e2e-tests/fixtures/blocks/core__cover.json +++ b/packages/e2e-tests/fixtures/blocks/core__cover.json @@ -22,7 +22,7 @@ "fontSize": "large" }, "innerBlocks": [], - "originalContent": "\n\t\t\tGuten Berg!\n\t\t
" + "originalContent": "\n\t\t\tGuten Berg!\n\t\t
" } ], "originalContent": "\n\t\t\tGuten Berg!\n\t\t
\n\t\t", + "innerHTML": "\n\t\t\n\t\t\tGuten Berg!\n\t\t
\n\t\t", "innerContent": [ - "\n\t\t\n\t\t\tGuten Berg!\n\t\t
\n\t\t" + "\n\t\t\n\t\t\tGuten Berg!\n\t\t
\n\t\t" ] } ], diff --git a/packages/e2e-tests/fixtures/blocks/core__cover.serialized.html b/packages/e2e-tests/fixtures/blocks/core__cover.serialized.html index 0539f03f168f8..5c22f650550e6 100644 --- a/packages/e2e-tests/fixtures/blocks/core__cover.serialized.html +++ b/packages/e2e-tests/fixtures/blocks/core__cover.serialized.html @@ -1,6 +1,6 @@+
Guten Berg!
Cover Image
+Cover Image
Cover Block
+Cover Block
Cover Block
+Cover Block
+
Guten Berg!
diff --git a/packages/e2e-tests/fixtures/blocks/core__cover__video-overlay.json b/packages/e2e-tests/fixtures/blocks/core__cover__video-overlay.json index f7e2b42ff234c..8e2486b3bc128 100644 --- a/packages/e2e-tests/fixtures/blocks/core__cover__video-overlay.json +++ b/packages/e2e-tests/fixtures/blocks/core__cover__video-overlay.json @@ -23,7 +23,7 @@ "fontSize": "large" }, "innerBlocks": [], - "originalContent": "\n\t\t\tGuten Berg!\n\t\t
" + "originalContent": "\n\t\t\tGuten Berg!\n\t\t
" } ], "originalContent": "\n\t\t\tGuten Berg!\n\t\t
\n\t\t", + "innerHTML": "\n\t\t\n\t\t\tGuten Berg!\n\t\t
\n\t\t", "innerContent": [ - "\n\t\t\n\t\t\tGuten Berg!\n\t\t
\n\t\t" + "\n\t\t\n\t\t\tGuten Berg!\n\t\t
\n\t\t" ] } ], diff --git a/packages/e2e-tests/fixtures/blocks/core__cover__video-overlay.serialized.html b/packages/e2e-tests/fixtures/blocks/core__cover__video-overlay.serialized.html index 831388b0182b8..1a40bd5a65f74 100644 --- a/packages/e2e-tests/fixtures/blocks/core__cover__video-overlay.serialized.html +++ b/packages/e2e-tests/fixtures/blocks/core__cover__video-overlay.serialized.html @@ -1,6 +1,6 @@+
Guten Berg!
+
Guten Berg!
diff --git a/packages/e2e-tests/fixtures/blocks/core__cover__video.json b/packages/e2e-tests/fixtures/blocks/core__cover__video.json index f91f443e785e1..c5a5abeda4916 100644 --- a/packages/e2e-tests/fixtures/blocks/core__cover__video.json +++ b/packages/e2e-tests/fixtures/blocks/core__cover__video.json @@ -22,7 +22,7 @@ "fontSize": "large" }, "innerBlocks": [], - "originalContent": "\n\t\t\tGuten Berg!\n\t\t
" + "originalContent": "\n\t\t\tGuten Berg!\n\t\t
" } ], "originalContent": "\n\t\t\tGuten Berg!\n\t\t
\n\t\t", + "innerHTML": "\n\t\t\n\t\t\tGuten Berg!\n\t\t
\n\t\t", "innerContent": [ - "\n\t\t\n\t\t\tGuten Berg!\n\t\t
\n\t\t" + "\n\t\t\n\t\t\tGuten Berg!\n\t\t
\n\t\t" ] } ], diff --git a/packages/e2e-tests/fixtures/blocks/core__cover__video.serialized.html b/packages/e2e-tests/fixtures/blocks/core__cover__video.serialized.html index 5f23cddf2fa1c..5c155d10fa772 100644 --- a/packages/e2e-tests/fixtures/blocks/core__cover__video.serialized.html +++ b/packages/e2e-tests/fixtures/blocks/core__cover__video.serialized.html @@ -1,6 +1,6 @@+
Guten Berg!
My video
+My video
My video
" + "originalContent": "My video
" } ], "originalContent": "My video
\n\t\t", + "innerHTML": "\n\t\tMy video
\n\t\t", "innerContent": [ - "\n\t\tMy video
\n\t\t" + "\n\t\tMy video
\n\t\t" ] } ], diff --git a/packages/e2e-tests/fixtures/blocks/core__media-text__media-right-custom-width.serialized.html b/packages/e2e-tests/fixtures/blocks/core__media-text__media-right-custom-width.serialized.html index 857ad7de389cd..2c2923b7ecf25 100644 --- a/packages/e2e-tests/fixtures/blocks/core__media-text__media-right-custom-width.serialized.html +++ b/packages/e2e-tests/fixtures/blocks/core__media-text__media-right-custom-width.serialized.html @@ -1,5 +1,5 @@My video
+My video
... like this one, which is separate from the above and right aligned.
+... like this one, which is separate from the above and right aligned.
diff --git a/packages/e2e-tests/fixtures/blocks/core__paragraph__align-right.json b/packages/e2e-tests/fixtures/blocks/core__paragraph__align-right.json index 2ab7bad89f192..d0c3fa1495e3d 100644 --- a/packages/e2e-tests/fixtures/blocks/core__paragraph__align-right.json +++ b/packages/e2e-tests/fixtures/blocks/core__paragraph__align-right.json @@ -9,6 +9,6 @@ "dropCap": false }, "innerBlocks": [], - "originalContent": "... like this one, which is separate from the above and right aligned.
" + "originalContent": "... like this one, which is separate from the above and right aligned.
" } ] diff --git a/packages/e2e-tests/fixtures/blocks/core__paragraph__align-right.parsed.json b/packages/e2e-tests/fixtures/blocks/core__paragraph__align-right.parsed.json index a8f850f47f72b..61859738751fb 100644 --- a/packages/e2e-tests/fixtures/blocks/core__paragraph__align-right.parsed.json +++ b/packages/e2e-tests/fixtures/blocks/core__paragraph__align-right.parsed.json @@ -5,9 +5,9 @@ "align": "right" }, "innerBlocks": [], - "innerHTML": "\n... like this one, which is separate from the above and right aligned.
\n", + "innerHTML": "\n... like this one, which is separate from the above and right aligned.
\n", "innerContent": [ - "\n... like this one, which is separate from the above and right aligned.
\n" + "\n... like this one, which is separate from the above and right aligned.
\n" ] }, { diff --git a/packages/e2e-tests/fixtures/blocks/core__paragraph__align-right.serialized.html b/packages/e2e-tests/fixtures/blocks/core__paragraph__align-right.serialized.html index 3e18265b5c44b..3009f606904f6 100644 --- a/packages/e2e-tests/fixtures/blocks/core__paragraph__align-right.serialized.html +++ b/packages/e2e-tests/fixtures/blocks/core__paragraph__align-right.serialized.html @@ -1,3 +1,3 @@ -... like this one, which is separate from the above and right aligned.
+... like this one, which is separate from the above and right aligned.
diff --git a/packages/e2e-tests/fixtures/blocks/core__paragraph__deprecated-4.html b/packages/e2e-tests/fixtures/blocks/core__paragraph__deprecated-4.html new file mode 100644 index 0000000000000..d41481a57f2e5 --- /dev/null +++ b/packages/e2e-tests/fixtures/blocks/core__paragraph__deprecated-4.html @@ -0,0 +1,3 @@ + +... like this one, which is separate from the above and right aligned.
+ diff --git a/packages/e2e-tests/fixtures/blocks/core__paragraph__deprecated-4.json b/packages/e2e-tests/fixtures/blocks/core__paragraph__deprecated-4.json new file mode 100644 index 0000000000000..2ab7bad89f192 --- /dev/null +++ b/packages/e2e-tests/fixtures/blocks/core__paragraph__deprecated-4.json @@ -0,0 +1,14 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/paragraph", + "isValid": true, + "attributes": { + "align": "right", + "content": "... like this one, which is separate from the above and right aligned.", + "dropCap": false + }, + "innerBlocks": [], + "originalContent": "... like this one, which is separate from the above and right aligned.
" + } +] diff --git a/packages/e2e-tests/fixtures/blocks/core__paragraph__deprecated-4.parsed.json b/packages/e2e-tests/fixtures/blocks/core__paragraph__deprecated-4.parsed.json new file mode 100644 index 0000000000000..a8f850f47f72b --- /dev/null +++ b/packages/e2e-tests/fixtures/blocks/core__paragraph__deprecated-4.parsed.json @@ -0,0 +1,22 @@ +[ + { + "blockName": "core/paragraph", + "attrs": { + "align": "right" + }, + "innerBlocks": [], + "innerHTML": "\n... like this one, which is separate from the above and right aligned.
\n", + "innerContent": [ + "\n... like this one, which is separate from the above and right aligned.
\n" + ] + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n", + "innerContent": [ + "\n" + ] + } +] diff --git a/packages/e2e-tests/fixtures/blocks/core__paragraph__deprecated-4.serialized.html b/packages/e2e-tests/fixtures/blocks/core__paragraph__deprecated-4.serialized.html new file mode 100644 index 0000000000000..3009f606904f6 --- /dev/null +++ b/packages/e2e-tests/fixtures/blocks/core__paragraph__deprecated-4.serialized.html @@ -0,0 +1,3 @@ + +... like this one, which is separate from the above and right aligned.
+ diff --git a/packages/e2e-tests/specs/__snapshots__/block-transforms.test.js.snap b/packages/e2e-tests/specs/__snapshots__/block-transforms.test.js.snap index f1d778e920aeb..3288fac0c027a 100644 --- a/packages/e2e-tests/specs/__snapshots__/block-transforms.test.js.snap +++ b/packages/e2e-tests/specs/__snapshots__/block-transforms.test.js.snap @@ -79,7 +79,7 @@ exports[`Block transforms correctly transform block Heading in fixture core__hea exports[`Block transforms correctly transform block Image in fixture core__image into the Cover block 1`] = ` "... like this one, which is separate from the above and right aligned.
+... like this one, which is separate from the above and right aligned.
+
-
+
- 👋 👋