Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Rename HTMLElementSelectControl to HTMLElementControl
  • Loading branch information
Sukhendu2002 committed Apr 16, 2025
commit 0bc2a8733b0a5ada69173f4b9f9fd430996a42af
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# HTML Element Select Control
# HTML Element Control

A specialized component for selecting HTML elements with validation to prevent duplicate `<main>` elements.

The `HTMLElementSelectControl` is an extension of the WordPress `SelectControl` component that adds validation to prevent duplicate `<main>` HTML elements. This component is designed to help ensure valid HTML structure and improve accessibility in content created with the WordPress block editor.
The `HTMLElementControl` provides a way to select HTML elements with validation to prevent duplicate `<main>` elements. This component is designed to help ensure valid HTML structure and improve accessibility in content created with the WordPress block editor.

> **Note:** This component is available via private APIs using the unlock pattern. It is not directly exposed as a public API.

Expand All @@ -14,14 +14,14 @@ The `HTMLElementSelectControl` is an extension of the WordPress `SelectControl`
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
import { unlock } from './lock-unlock';

const { HTMLElementSelectControl } = unlock( blockEditorPrivateApis );
const { HTMLElementControl } = unlock( blockEditorPrivateApis );

function MyBlockEdit( { attributes, setAttributes, clientId } ) {
const { tagName } = attributes;

return (
<InspectorControls group="advanced">
<HTMLElementSelectControl
<HTMLElementControl
tagName={ tagName }
onChange={ ( value ) => setAttributes( { tagName: value } ) }
clientId={ clientId }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { htmlElementMessages } from './messages';
*
* @return {Component} The HTML element select control with validation.
*/
export default function HTMLElementSelectControl( {
export default function HTMLElementControl( {
tagName,
onChange,
clientId,
Expand Down
4 changes: 2 additions & 2 deletions packages/block-editor/src/private-apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import useBlockDisplayTitle from './components/block-title/use-block-display-tit
import TabbedSidebar from './components/tabbed-sidebar';
import CommentIconSlotFill from './components/collab/block-comment-icon-slot';
import CommentIconToolbarSlotFill from './components/collab/block-comment-icon-toolbar-slot';
import HTMLElementSelectControl from './components/html-element-select-control';
import HTMLElementControl from './components/html-element-control';
/**
* Private @wordpress/block-editor APIs.
*/
Expand Down Expand Up @@ -81,7 +81,7 @@ lock( privateApis, {
TextAlignmentControl,
usesContextKey,
useFlashEditableBlocks,
HTMLElementSelectControl,
HTMLElementControl,
useZoomOut,
globalStylesDataKey,
globalStylesLinksDataKey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
*/
import { unlock } from '../../lock-unlock';

const { HTMLElementSelectControl } = unlock( blockEditorPrivateApis );
const { HTMLElementControl } = unlock( blockEditorPrivateApis );

export default function CommentsInspectorControls( {
attributes: { tagName },
Expand All @@ -22,7 +22,7 @@ export default function CommentsInspectorControls( {
return (
<InspectorControls>
<InspectorControls group="advanced">
<HTMLElementSelectControl
<HTMLElementControl
tagName={ tagName }
onChange={ ( value ) =>
setAttributes( { tagName: value } )
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/cover/edit/inspector-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { unlock } from '../../lock-unlock';
import { useToolsPanelDropdownMenuProps } from '../../utils/hooks';
import { DEFAULT_MEDIA_SIZE_SLUG } from '../constants';

const { cleanEmptyObject, ResolutionTool, HTMLElementSelectControl } = unlock(
const { cleanEmptyObject, ResolutionTool, HTMLElementControl } = unlock(
blockEditorPrivateApis
);

Expand Down Expand Up @@ -421,7 +421,7 @@ export default function CoverInspectorControls( {
</ToolsPanelItem>
</InspectorControls>
<InspectorControls group="advanced">
<HTMLElementSelectControl
<HTMLElementControl
tagName={ tagName }
onChange={ ( value ) =>
setAttributes( { tagName: value } )
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/group/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { View } from '@wordpress/primitives';
import GroupPlaceHolder, { useShouldShowPlaceHolder } from './placeholder';
import { unlock } from '../lock-unlock';

const { HTMLElementSelectControl } = unlock( blockEditorPrivateApis );
const { HTMLElementControl } = unlock( blockEditorPrivateApis );

/**
* Render inspector controls for the Group block.
Expand All @@ -35,7 +35,7 @@ const { HTMLElementSelectControl } = unlock( blockEditorPrivateApis );
function GroupEditControls( { tagName, onSelectTagName, clientId } ) {
return (
<InspectorControls group="advanced">
<HTMLElementSelectControl
<HTMLElementControl
tagName={ tagName }
onChange={ onSelectTagName }
clientId={ clientId }
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/query/edit/query-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import EnhancedPaginationModal from './enhanced-pagination-modal';
import { getQueryContextFromTemplate } from '../utils';
import QueryToolbar from './query-toolbar';

const { HTMLElementSelectControl } = unlock( blockEditorPrivateApis );
const { HTMLElementControl } = unlock( blockEditorPrivateApis );

const DEFAULTS_POSTS_PER_PAGE = 3;

Expand Down Expand Up @@ -149,7 +149,7 @@ export default function QueryContent( {
<QueryToolbar attributes={ attributes } clientId={ clientId } />
</BlockControls>
<InspectorControls group="advanced">
<HTMLElementSelectControl
<HTMLElementControl
tagName={ TagName }
onChange={ ( value ) =>
setAttributes( { tagName: value } )
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/separator/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { __ } from '@wordpress/i18n';
import useDeprecatedOpacity from './use-deprecated-opacity';
import { unlock } from '../lock-unlock';

const { HTMLElementSelectControl } = unlock( blockEditorPrivateApis );
const { HTMLElementControl } = unlock( blockEditorPrivateApis );

export default function SeparatorEdit( {
attributes,
Expand Down Expand Up @@ -59,7 +59,7 @@ export default function SeparatorEdit( {
return (
<>
<InspectorControls group="advanced">
<HTMLElementSelectControl
<HTMLElementControl
tagName={ tagName }
onChange={ ( value ) =>
setAttributes( { tagName: value } )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
import { TemplatePartImportControls } from './import-controls';
import { unlock } from '../../lock-unlock';

const { HTMLElementSelectControl } = unlock( blockEditorPrivateApis );
const { HTMLElementControl } = unlock( blockEditorPrivateApis );

export function TemplatePartAdvancedControls( {
tagName,
Expand Down Expand Up @@ -77,7 +77,7 @@ export function TemplatePartAdvancedControls( {
/>
</>
) }
<HTMLElementSelectControl
<HTMLElementControl
tagName={ tagName || '' }
onChange={ ( value ) => setAttributes( { tagName: value } ) }
clientId={ clientId }
Expand Down
Loading