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

Rich text: remove inline display warning #32013

Merged
merged 2 commits into from
May 21, 2021
Merged
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
7 changes: 0 additions & 7 deletions docs/reference-guides/richtext.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,6 @@ wp.blocks.registerBlockType( /* ... */, {

While using the RichText component a number of common issues tend to appear.

### Placeholder Content Separates from the Input

In some cases the placeholder content on RichText can appear separate from the input where you would write your content. This is likely due to one of two reasons:

1. You can't have an element with the CSS `display` property set to `inline`. You will need to set it to `inline-block` or any other value.
2. The `position` CSS property value for the element must be set to `relative` or `absolute` within the admin. If the styles within style.css or editor.css modify the `position` property value for this element, you may see issues with how it displays.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer relevant either. The placeholder is purely text and no longer positioned over the rich text field.


### HTML Formatting Tags Display in the Content

If the HTML tags from text formatting such as `<strong>` or `<em>` are being escaped and displayed on the frontend of the site, this is likely due to an issue in your save function. Make sure your code looks something like `<RichText.Content tagName="h2" value={ heading } />` (ESNext) within your save function instead of simply outputting the value with `<h2>{ heading }</h2>`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ _Required._ Called when the value changes.

### `tagName: String`

_Default: `div`._ The [tag name](https://www.w3.org/TR/html51/syntax.html#tag-name) of the editable element. Elements that display inline are not supported. Set to `inline-block` to use tag names that have `inline` as the default.
_Default: `div`._ The [tag name](https://www.w3.org/TR/html51/syntax.html#tag-name) of the editable element.

### `disableLineBreaks: Boolean`

Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/src/components/rich-text/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ _Required._ Called when the value changes.

### `tagName: String`

_Default: `div`._ The [tag name](https://www.w3.org/TR/html51/syntax.html#tag-name) of the editable element. Elements that display inline are not supported. Set to `inline-block` to use tag names that have `inline` as the default.
_Default: `div`._ The [tag name](https://www.w3.org/TR/html51/syntax.html#tag-name) of the editable element.

### `placeholder: String`

Expand Down
3 changes: 1 addition & 2 deletions packages/block-library/src/file/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,7 @@ function FileEdit( {
) }
<div className={ 'wp-block-file__content-wrapper' }>
<RichText
style={ { display: 'inline-block' } }
tagName="a" // must be block-level or else cursor disappears
tagName="a"
value={ fileName }
placeholder={ __( 'Write file name…' ) }
withoutInteractiveFormatting
Expand Down
1 change: 0 additions & 1 deletion packages/block-library/src/query-pagination-next/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export default function QueryPaginationNextEdit( {
<PlainText
__experimentalVersion={ 2 }
tagName="a"
style={ { display: 'inline-block' } }
aria-label={ __( 'Next page link' ) }
placeholder={ __( 'Next Page' ) }
value={ label }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export default function QueryPaginationPreviousEdit( {
<PlainText
__experimentalVersion={ 2 }
tagName="a"
style={ { display: 'inline-block' } }
aria-label={ __( 'Previous page link' ) }
placeholder={ __( 'Previous Page' ) }
value={ label }
Expand Down
1 change: 0 additions & 1 deletion packages/block-library/src/site-title/edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export default function SiteTitleEdit( {
<TagName { ...blockProps }>
<RichText
tagName="a"
style={ { display: 'inline-block' } }
aria-label={ __( 'Site title text' ) }
placeholder={ __( 'Write site title…' ) }
value={ title }
Expand Down
2 changes: 0 additions & 2 deletions packages/rich-text/src/component/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { apply } from '../to-dom';
import { toHTMLString } from '../to-html-string';
import { useDefaultStyle } from './use-default-style';
import { useBoundaryStyle } from './use-boundary-style';
import { useInlineWarning } from './use-inline-warning';
import { useCopyHandler } from './use-copy-handler';
import { useFormatBoundaries } from './use-format-boundaries';
import { useSelectObject } from './use-select-object';
Expand Down Expand Up @@ -178,7 +177,6 @@ export function useRichText( {
ref,
useDefaultStyle(),
useBoundaryStyle( { record } ),
useInlineWarning(),
useCopyHandler( { record, multilineTag, preserveWhiteSpace } ),
useSelectObject(),
useFormatBoundaries( { record, applyRecord } ),
Expand Down
24 changes: 0 additions & 24 deletions packages/rich-text/src/component/use-inline-warning.js

This file was deleted.