Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post Content: Update placeholder when editing template #58361

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 12 additions & 17 deletions packages/block-library/src/post-content/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
store as coreStore,
} from '@wordpress/core-data';
import { useSelect } from '@wordpress/data';
import { Placeholder } from '@wordpress/components';

/**
* Internal dependencies
*/
Expand Down Expand Up @@ -104,25 +106,18 @@ function Content( props ) {
);
}

function Placeholder( { layoutClassNames } ) {
function PostContentPlaceholder( { layoutClassNames } ) {
const blockProps = useBlockProps( { className: layoutClassNames } );
return (
<div { ...blockProps }>
<p>
{ __(
'This is the Content block, it will display all the blocks in any single post or page.'
) }
</p>
<p>
{ __(
'That might be a simple arrangement like consecutive paragraphs in a blog post, or a more elaborate composition that includes image galleries, videos, tables, columns, and any other block types.'
) }
</p>
<p>
{ __(
'If there are any Custom Post Types registered at your site, the Content block can display the contents of those entries as well.'
) }
</p>
<Placeholder
className="wp-block-post-content__placeholder"
withIllustration
>
<p>
{ __( 'This block will be replaced with your content.' ) }
</p>
</Placeholder>
</div>
);
}
Expand Down Expand Up @@ -157,7 +152,7 @@ export default function PostContentEdit( {
layoutClassNames={ layoutClassNames }
/>
) : (
<Placeholder layoutClassNames={ layoutClassNames } />
<PostContentPlaceholder layoutClassNames={ layoutClassNames } />
) }
</RecursionProvider>
);
Expand Down
23 changes: 20 additions & 3 deletions packages/block-library/src/post-content/editor.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
// Disable text selection in the post content placeholder.
.wp-block-post-content.wp-block-post-content {
user-select: none;
.wp-block-post-content__placeholder {
&.has-illustration::before {
background: none;
border: 1px solid currentColor;
}

.components-placeholder__illustration {
opacity: 0.1;
}

.components-placeholder__fieldset {
align-self: center;
font-family: inherit;
font-size: inherit;

p {
font-family: inherit;
font-size: inherit;
}
}
}
8 changes: 3 additions & 5 deletions test/e2e/specs/site-editor/pages.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
.getByRole( 'document', {
name: 'Block: Content',
} )
.getByRole( 'document', {
name: 'Empty block; start writing or type forward slash to choose a block',
.getByRole( 'button', {
name: 'Start blank',
} )
.click();

Check failure on line 29 in test/e2e/specs/site-editor/pages.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 6

[chromium] › site-editor/pages.spec.js:93:2 › Pages › create a new page

1) [chromium] › site-editor/pages.spec.js:93:2 › Pages › create a new page, edit template and toggle page template preview TimeoutError: locator.click: Timeout 10000ms exceeded. =========================== logs =========================== waiting for frameLocator('[name="editor-canvas"]').getByRole('document', { name: 'Block: Content' }).getByRole('button', { name: 'Start blank' }) ============================================================ 27 | name: 'Start blank', 28 | } ) > 29 | .click(); | ^ 30 | 31 | // Insert into Page Content using default block. 32 | await editor.canvas at addPageContent (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/pages.spec.js:29:4) at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/pages.spec.js:99:9

Check failure on line 29 in test/e2e/specs/site-editor/pages.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 6

[chromium] › site-editor/pages.spec.js:93:2 › Pages › create a new page

1) [chromium] › site-editor/pages.spec.js:93:2 › Pages › create a new page, edit template and toggle page template preview Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── TimeoutError: locator.click: Timeout 10000ms exceeded. =========================== logs =========================== waiting for frameLocator('[name="editor-canvas"]').getByRole('document', { name: 'Block: Content' }).getByRole('button', { name: 'Start blank' }) ============================================================ 27 | name: 'Start blank', 28 | } ) > 29 | .click(); | ^ 30 | 31 | // Insert into Page Content using default block. 32 | await editor.canvas at addPageContent (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/pages.spec.js:29:4) at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/pages.spec.js:99:9

Check failure on line 29 in test/e2e/specs/site-editor/pages.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 6

[chromium] › site-editor/pages.spec.js:93:2 › Pages › create a new page

1) [chromium] › site-editor/pages.spec.js:93:2 › Pages › create a new page, edit template and toggle page template preview Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── TimeoutError: locator.click: Timeout 10000ms exceeded. =========================== logs =========================== waiting for frameLocator('[name="editor-canvas"]').getByRole('document', { name: 'Block: Content' }).getByRole('button', { name: 'Start blank' }) ============================================================ 27 | name: 'Start blank', 28 | } ) > 29 | .click(); | ^ 30 | 31 | // Insert into Page Content using default block. 32 | await editor.canvas at addPageContent (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/pages.spec.js:29:4) at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/pages.spec.js:99:9

// Insert into Page Content using default block.
await editor.canvas
Expand Down Expand Up @@ -124,9 +124,7 @@
editor.canvas.getByRole( 'document', {
name: 'Block: Content',
} )
).toContainText(
'This is the Content block, it will display all the blocks in any single post or page.'
);
).toContainText( 'This block will be replaced with your content.' );
await expect(
page.locator(
'role=button[name="Dismiss this notice"i] >> text="Editing template. Changes made here affect all posts and pages that use the template."'
Expand Down
Loading