Skip to content

Commit

Permalink
Update the anchor to use HelpText
Browse files Browse the repository at this point in the history
  • Loading branch information
enejb committed Jul 7, 2021
1 parent ca68828 commit d9a4fb4
Showing 1 changed file with 34 additions and 17 deletions.
51 changes: 34 additions & 17 deletions packages/block-editor/src/hooks/anchor.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ import { has } from 'lodash';
* WordPress dependencies
*/
import { addFilter } from '@wordpress/hooks';
import { PanelBody, TextControl, ExternalLink } from '@wordpress/components';
import {
PanelBody,
TextControl,
HelpText,
ExternalLink,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { hasBlockSupport } from '@wordpress/blocks';
import { createHigherOrderComponent } from '@wordpress/compose';
Expand Down Expand Up @@ -73,22 +78,6 @@ export const withInspectorControl = createHigherOrderComponent(
<TextControl
className="html-anchor-control"
label={ __( 'HTML anchor' ) }
help={
<>
{ __(
'Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.'
) }{ ' ' }
{
<ExternalLink
href={
'https://wordpress.org/support/article/page-jumps/'
}
>
{ __( 'Learn more about anchors' ) }
</ExternalLink>
}
</>
}
value={ props.attributes.anchor || '' }
placeholder={ ! isWeb ? __( 'Add an anchor' ) : null }
onChange={ ( nextValue ) => {
Expand All @@ -99,6 +88,23 @@ export const withInspectorControl = createHigherOrderComponent(
} }
autoCapitalize="none"
autoComplete="off"
separatorType="none"
help={
isWeb && (
<>
{ __(
'Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.'
) }
<ExternalLink
href={
'https://wordpress.org/support/article/page-jumps/'
}
>
{ __( 'Learn more about anchors' ) }
</ExternalLink>
</>
)
}
/>
);

Expand All @@ -120,6 +126,17 @@ export const withInspectorControl = createHigherOrderComponent(
<InspectorControls>
<PanelBody title={ __( 'Heading settings' ) }>
{ textControl }
<HelpText
url="https://wordpress.org/support/article/page-jumps/"
r
moreLinkText={ __(
'Learn more about anchors'
) }
>
{ __(
'Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.'
) }
</HelpText>
</PanelBody>
</InspectorControls>
) }
Expand Down

0 comments on commit d9a4fb4

Please sign in to comment.