From 47566f95f14278bcd4dbca3970cb5c5c040c6fba Mon Sep 17 00:00:00 2001 From: tellthemachines Date: Tue, 4 Apr 2023 13:40:42 +1000 Subject: [PATCH 1/2] Try fixing post editor layout for wide/full Post Content blocks --- .../src/components/visual-editor/index.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/edit-post/src/components/visual-editor/index.js b/packages/edit-post/src/components/visual-editor/index.js index b5ad5ab64ce85..6869c22024f85 100644 --- a/packages/edit-post/src/components/visual-editor/index.js +++ b/packages/edit-post/src/components/visual-editor/index.js @@ -261,7 +261,7 @@ export default function VisualEditor( { styles } ) { postContentAttributes, ] ); - const layout = newestPostContentAttributes?.layout || {}; + const { layout = {}, align = '' } = newestPostContentAttributes || {}; const postContentLayoutClasses = useLayoutClasses( newestPostContentAttributes, @@ -272,7 +272,8 @@ export default function VisualEditor( { styles } ) { { 'is-layout-flow': ! themeSupportsLayout, }, - themeSupportsLayout && postContentLayoutClasses + themeSupportsLayout && postContentLayoutClasses, + align && `align${ align }` ); const postContentLayoutStyles = useLayoutStyles( @@ -327,6 +328,12 @@ export default function VisualEditor( { styles } ) { [ styles ] ); + // Add some styles for alignwide/alignfull Post Content and its children. + const alignCSS = `.is-root-container.alignwide { max-width: var(--wp--style--global--wide-size); margin-left: auto; margin-right: auto;} + .is-root-container.alignwide > :not(.alignleft):not(.alignright) { max-width: var(--wp--style--global--wide-size);} + .is-root-container.alignfull { max-width: none; margin-left: auto; margin-right: auto;} + .is-root-container.alignfull > :not(.alignleft):not(.alignright) { max-width: none;}`; + return ( + { align && ( + + ) } { postContentLayoutStyles && ( Date: Thu, 6 Apr 2023 11:03:00 +1000 Subject: [PATCH 2/2] Alter rules to not affect children of constrained layout --- packages/edit-post/src/components/visual-editor/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/edit-post/src/components/visual-editor/index.js b/packages/edit-post/src/components/visual-editor/index.js index 6869c22024f85..ac8902f6a5f7a 100644 --- a/packages/edit-post/src/components/visual-editor/index.js +++ b/packages/edit-post/src/components/visual-editor/index.js @@ -330,9 +330,9 @@ export default function VisualEditor( { styles } ) { // Add some styles for alignwide/alignfull Post Content and its children. const alignCSS = `.is-root-container.alignwide { max-width: var(--wp--style--global--wide-size); margin-left: auto; margin-right: auto;} - .is-root-container.alignwide > :not(.alignleft):not(.alignright) { max-width: var(--wp--style--global--wide-size);} + .is-root-container.alignwide:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: var(--wp--style--global--wide-size);} .is-root-container.alignfull { max-width: none; margin-left: auto; margin-right: auto;} - .is-root-container.alignfull > :not(.alignleft):not(.alignright) { max-width: none;}`; + .is-root-container.alignfull:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: none;}`; return (