Skip to content

Commit 77b29ed

Browse files
aferciafabiankaegy
authored andcommitted
Move html element help messages to the block library utils. (WordPress#68708)
* Move html element help messages to the block library utils. * Make help message for the div element more generic. Co-authored-by: afercia <afercia@git.wordpress.org> Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org>
1 parent a80930b commit 77b29ed

File tree

7 files changed

+41
-87
lines changed

7 files changed

+41
-87
lines changed

packages/block-library/src/comments/edit/comments-inspector-controls.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,15 @@ import { SelectControl } from '@wordpress/components';
55
import { __ } from '@wordpress/i18n';
66
import { InspectorControls } from '@wordpress/block-editor';
77

8+
/**
9+
* Internal dependencies
10+
*/
11+
import { htmlElementMessages } from '../../utils/messages';
12+
813
export default function CommentsInspectorControls( {
914
attributes: { tagName },
1015
setAttributes,
1116
} ) {
12-
const htmlElementMessages = {
13-
section: __(
14-
"The <section> element should represent a standalone portion of the document that can't be better represented by another element."
15-
),
16-
aside: __(
17-
"The <aside> element should represent a portion of a document whose content is only indirectly related to the document's main content."
18-
),
19-
};
2017
return (
2118
<InspectorControls>
2219
<InspectorControls group="advanced">

packages/block-library/src/cover/edit/inspector-controls.js

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import { COVER_MIN_HEIGHT, mediaPosition } from '../shared';
3636
import { unlock } from '../../lock-unlock';
3737
import { useToolsPanelDropdownMenuProps } from '../../utils/hooks';
3838
import { DEFAULT_MEDIA_SIZE_SLUG } from '../constants';
39+
import { htmlElementMessages } from '../../utils/messages';
3940

4041
const { cleanEmptyObject, ResolutionTool } = unlock( blockEditorPrivateApis );
4142

@@ -183,27 +184,6 @@ export default function CoverInspectorControls( {
183184

184185
const colorGradientSettings = useMultipleOriginColorsAndGradients();
185186

186-
const htmlElementMessages = {
187-
header: __(
188-
'The <header> element should represent introductory content, typically a group of introductory or navigational aids.'
189-
),
190-
main: __(
191-
'The <main> element should be used for the primary content of your document only.'
192-
),
193-
section: __(
194-
"The <section> element should represent a standalone portion of the document that can't be better represented by another element."
195-
),
196-
article: __(
197-
'The <article> element should represent a self-contained, syndicatable portion of the document.'
198-
),
199-
aside: __(
200-
"The <aside> element should represent a portion of a document whose content is only indirectly related to the document's main content."
201-
),
202-
footer: __(
203-
'The <footer> element should represent a footer for its nearest sectioning element (e.g.: <section>, <article>, <main> etc.).'
204-
),
205-
};
206-
207187
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
208188

209189
return (

packages/block-library/src/group/edit.js

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { View } from '@wordpress/primitives';
1818
* Internal dependencies
1919
*/
2020
import GroupPlaceHolder, { useShouldShowPlaceHolder } from './placeholder';
21+
import { htmlElementMessages } from '../utils/messages';
2122

2223
/**
2324
* Render inspector controls for the Group block.
@@ -29,26 +30,6 @@ import GroupPlaceHolder, { useShouldShowPlaceHolder } from './placeholder';
2930
* @return {JSX.Element} The control group.
3031
*/
3132
function GroupEditControls( { tagName, onSelectTagName } ) {
32-
const htmlElementMessages = {
33-
header: __(
34-
'The <header> element should represent introductory content, typically a group of introductory or navigational aids.'
35-
),
36-
main: __(
37-
'The <main> element should be used for the primary content of your document only.'
38-
),
39-
section: __(
40-
"The <section> element should represent a standalone portion of the document that can't be better represented by another element."
41-
),
42-
article: __(
43-
'The <article> element should represent a self-contained, syndicatable portion of the document.'
44-
),
45-
aside: __(
46-
"The <aside> element should represent a portion of a document whose content is only indirectly related to the document's main content."
47-
),
48-
footer: __(
49-
'The <footer> element should represent a footer for its nearest sectioning element (e.g.: <section>, <article>, <main> etc.).'
50-
),
51-
};
5233
return (
5334
<InspectorControls group="advanced">
5435
<SelectControl

packages/block-library/src/query/edit/query-content.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import QueryInspectorControls from './inspector-controls';
2323
import EnhancedPaginationModal from './enhanced-pagination-modal';
2424
import { getQueryContextFromTemplate } from '../utils';
2525
import QueryToolbar from './query-toolbar';
26+
import { htmlElementMessages } from '../../utils/messages';
2627

2728
const DEFAULTS_POSTS_PER_PAGE = 3;
2829

@@ -132,17 +133,6 @@ export default function QueryContent( {
132133
setAttributes( {
133134
displayLayout: { ...displayLayout, ...newDisplayLayout },
134135
} );
135-
const htmlElementMessages = {
136-
main: __(
137-
'The <main> element should be used for the primary content of your document only.'
138-
),
139-
section: __(
140-
"The <section> element should represent a standalone portion of the document that can't be better represented by another element."
141-
),
142-
aside: __(
143-
"The <aside> element should represent a portion of a document whose content is only indirectly related to the document's main content."
144-
),
145-
};
146136

147137
return (
148138
<>

packages/block-library/src/separator/edit.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,7 @@ import { __ } from '@wordpress/i18n';
1919
* Internal dependencies
2020
*/
2121
import useDeprecatedOpacity from './use-deprecated-opacity';
22-
23-
const htmlElementMessages = {
24-
div: __(
25-
'The <div> element should only be used if the separator is a design element that should not be announced.'
26-
),
27-
};
22+
import { htmlElementMessages } from '../utils/messages';
2823

2924
export default function SeparatorEdit( { attributes, setAttributes } ) {
3025
const { backgroundColor, opacity, style, tagName } = attributes;

packages/block-library/src/template-part/edit/advanced-controls.js

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,7 @@ import { useSelect } from '@wordpress/data';
1010
* Internal dependencies
1111
*/
1212
import { TemplatePartImportControls } from './import-controls';
13-
14-
const htmlElementMessages = {
15-
header: __(
16-
'The <header> element should represent introductory content, typically a group of introductory or navigational aids.'
17-
),
18-
main: __(
19-
'The <main> element should be used for the primary content of your document only.'
20-
),
21-
section: __(
22-
"The <section> element should represent a standalone portion of the document that can't be better represented by another element."
23-
),
24-
article: __(
25-
'The <article> element should represent a self-contained, syndicatable portion of the document.'
26-
),
27-
aside: __(
28-
"The <aside> element should represent a portion of a document whose content is only indirectly related to the document's main content."
29-
),
30-
footer: __(
31-
'The <footer> element should represent a footer for its nearest sectioning element (e.g.: <section>, <article>, <main> etc.).'
32-
),
33-
};
13+
import { htmlElementMessages } from '../../utils/messages';
3414

3515
export function TemplatePartAdvancedControls( {
3616
tagName,
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* WordPress dependencies
3+
*/
4+
import { __ } from '@wordpress/i18n';
5+
6+
export const htmlElementMessages = {
7+
article: __(
8+
'The <article> element should represent a self-contained, syndicatable portion of the document.'
9+
),
10+
aside: __(
11+
"The <aside> element should represent a portion of a document whose content is only indirectly related to the document's main content."
12+
),
13+
div: __(
14+
'The <div> element should only be used if the block is a design element with no semantic meaning.'
15+
),
16+
footer: __(
17+
'The <footer> element should represent a footer for its nearest sectioning element (e.g.: <section>, <article>, <main> etc.).'
18+
),
19+
header: __(
20+
'The <header> element should represent introductory content, typically a group of introductory or navigational aids.'
21+
),
22+
main: __(
23+
'The <main> element should be used for the primary content of your document only.'
24+
),
25+
nav: __(
26+
'The <nav> element should be used to identify groups of links that are intended to be used for website or page content navigation.'
27+
),
28+
section: __(
29+
"The <section> element should represent a standalone portion of the document that can't be better represented by another element."
30+
),
31+
};

0 commit comments

Comments
 (0)