diff --git a/packages/block-editor/src/components/rich-text/index.js b/packages/block-editor/src/components/rich-text/index.js
index 1a6793ca9efe7..a3b7b44e214a5 100644
--- a/packages/block-editor/src/components/rich-text/index.js
+++ b/packages/block-editor/src/components/rich-text/index.js
@@ -13,14 +13,11 @@ import {
createContext,
} from '@wordpress/element';
import { useDispatch, useSelect } from '@wordpress/data';
-import { children as childrenSource } from '@wordpress/blocks';
-import { useInstanceId, useMergeRefs } from '@wordpress/compose';
+import { useMergeRefs } from '@wordpress/compose';
import {
__unstableUseRichText as useRichText,
- __unstableCreateElement,
removeFormat,
} from '@wordpress/rich-text';
-import deprecated from '@wordpress/deprecated';
import { Popover } from '@wordpress/components';
/**
@@ -46,7 +43,7 @@ import { useFirefoxCompat } from './use-firefox-compat';
import FormatEdit from './format-edit';
import { getAllowedFormats } from './utils';
import { Content } from './content';
-import RichTextMultiline from './multiline';
+import { withDeprecations } from './with-deprecations';
export const keyboardShortcutContext = createContext();
export const inputEventContext = createContext();
@@ -387,47 +384,9 @@ export function RichTextWrapper(
);
}
-const ForwardedRichTextWrapper = forwardRef( RichTextWrapper );
-
-function RichTextSwitcher( props, ref ) {
- let value = props.value;
- let onChange = props.onChange;
-
- // Handle deprecated format.
- if ( Array.isArray( value ) ) {
- deprecated( 'wp.blockEditor.RichText value prop as children type', {
- since: '6.1',
- version: '6.3',
- alternative: 'value prop as string',
- link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/',
- } );
-
- value = childrenSource.toHTML( props.value );
- onChange = ( newValue ) =>
- props.onChange(
- childrenSource.fromDOM(
- __unstableCreateElement( document, newValue ).childNodes
- )
- );
- }
-
- const Component = props.multiline
- ? RichTextMultiline
- : ForwardedRichTextWrapper;
- const instanceId = useInstanceId( RichTextSwitcher );
-
- return (
-
- );
-}
-
-const ForwardedRichTextContainer = forwardRef( RichTextSwitcher );
+const ForwardedRichTextContainer = withDeprecations(
+ forwardRef( RichTextWrapper )
+);
ForwardedRichTextContainer.Content = Content;
ForwardedRichTextContainer.isEmpty = ( value ) => {
diff --git a/packages/block-editor/src/components/rich-text/index.native.js b/packages/block-editor/src/components/rich-text/index.native.js
index 9427962eced19..acadfb24a7221 100644
--- a/packages/block-editor/src/components/rich-text/index.native.js
+++ b/packages/block-editor/src/components/rich-text/index.native.js
@@ -39,17 +39,17 @@ import FormatToolbarContainer from './format-toolbar-container';
import { store as blockEditorStore } from '../../store';
import {
addActiveFormats,
- getMultilineTag,
getAllowedFormats,
createLinkInParagraph,
} from './utils';
import EmbedHandlerPicker from './embed-handler-picker';
import { Content } from './content';
import RichText from './native';
+import { withDeprecations } from './with-deprecations';
const classes = 'block-editor-rich-text__editable';
-function RichTextWrapper(
+export function RichTextWrapper(
{
children,
tagName,
@@ -58,7 +58,6 @@ function RichTextWrapper(
value: originalValue,
onChange: originalOnChange,
isSelected: originalIsSelected,
- multiline,
inlineToolbar,
wrapperClassName,
autocompleters,
@@ -80,7 +79,6 @@ function RichTextWrapper(
disableLineBreaks,
unstableOnFocus,
__unstableAllowPrefixTransformations,
- __unstableMultilineRootTag,
// Native props.
__unstableMobileNoFocusOnMount,
deleteEnter,
@@ -179,7 +177,6 @@ function RichTextWrapper(
selectionChange,
__unstableMarkAutomaticChange,
} = useDispatch( blockEditorStore );
- const multilineTag = getMultilineTag( multiline );
const adjustedAllowedFormats = getAllowedFormats( {
allowedFormats,
disableFormats,
@@ -261,10 +258,7 @@ function RichTextWrapper(
if ( ! hasPastedBlocks || ! isEmpty( before ) ) {
blocks.push(
onSplit(
- toHTMLString( {
- value: before,
- multilineTag,
- } ),
+ toHTMLString( { value: before } ),
! isAfterOriginal
)
);
@@ -288,13 +282,7 @@ function RichTextWrapper(
: ! onSplitMiddle || ! isEmpty( after )
) {
blocks.push(
- onSplit(
- toHTMLString( {
- value: after,
- multilineTag,
- } ),
- isAfterOriginal
- )
+ onSplit( toHTMLString( { value: after } ), isAfterOriginal )
);
}
@@ -308,7 +296,7 @@ function RichTextWrapper(
onReplace( blocks, indexToSelect, initialPosition );
},
- [ onReplace, onSplit, multilineTag, onSplitMiddle ]
+ [ onReplace, onSplit, onSplitMiddle ]
);
const onEnter = useCallback(
@@ -370,7 +358,6 @@ function RichTextWrapper(
onReplace,
onSplit,
__unstableMarkAutomaticChange,
- multiline,
splitValue,
onSplitAtEnd,
]
@@ -392,9 +379,6 @@ function RichTextWrapper(
if ( isInternal ) {
const pastedValue = create( {
html,
- multilineTag,
- multilineWrapperTags:
- multilineTag === 'li' ? [ 'ul', 'ol' ] : undefined,
preserveWhiteSpace,
} );
addActiveFormats( pastedValue, activeFormats );
@@ -496,7 +480,6 @@ function RichTextWrapper(
onSplit,
splitValue,
__unstableEmbedURLOnPaste,
- multilineTag,
preserveWhiteSpace,
pastePlainText,
]
@@ -568,7 +551,6 @@ function RichTextWrapper(
onPaste={ onPaste }
__unstableIsSelected={ isSelected }
__unstableInputRule={ inputRule }
- __unstableMultilineTag={ multilineTag }
__unstableOnEnterFormattedText={ enterFormattedText }
__unstableOnExitFormattedText={ exitFormattedText }
__unstableOnCreateUndoLevel={ __unstableMarkLastChangeAsPersistent }
@@ -582,7 +564,6 @@ function RichTextWrapper(
__unstableAllowPrefixTransformations={
__unstableAllowPrefixTransformations
}
- __unstableMultilineRootTag={ __unstableMultilineRootTag }
// Native props.
blockIsSelected={
originalIsSelected !== undefined
@@ -675,7 +656,9 @@ function RichTextWrapper(
);
}
-const ForwardedRichTextContainer = forwardRef( RichTextWrapper );
+const ForwardedRichTextContainer = withDeprecations(
+ forwardRef( RichTextWrapper )
+);
ForwardedRichTextContainer.Content = Content;
diff --git a/packages/block-editor/src/components/rich-text/native/index.native.js b/packages/block-editor/src/components/rich-text/native/index.native.js
index 951d52ece6d69..165316fdbde76 100644
--- a/packages/block-editor/src/components/rich-text/native/index.native.js
+++ b/packages/block-editor/src/components/rich-text/native/index.native.js
@@ -105,27 +105,11 @@ const DEFAULT_FONT_SIZE = 16;
const MIN_LINE_HEIGHT = 1;
export class RichText extends Component {
- constructor( {
- value,
- selectionStart,
- selectionEnd,
- __unstableMultilineTag: multiline,
- } ) {
+ constructor( { value, selectionStart, selectionEnd } ) {
super( ...arguments );
- this.isMultiline = false;
- if ( multiline === true || multiline === 'p' || multiline === 'li' ) {
- this.multilineTag = multiline === true ? 'p' : multiline;
- this.isMultiline = true;
- }
-
- if ( this.multilineTag === 'li' ) {
- this.multilineWrapperTags = [ 'ul', 'ol' ];
- }
-
this.isIOS = Platform.OS === 'ios';
this.createRecord = this.createRecord.bind( this );
- this.restoreParagraphTags = this.restoreParagraphTags.bind( this );
this.onChangeFromAztec = this.onChangeFromAztec.bind( this );
this.onKeyDown = this.onKeyDown.bind( this );
this.handleEnter = this.handleEnter.bind( this );
@@ -223,8 +207,6 @@ export class RichText extends Component {
...create( {
html: this.value,
range: null,
- multilineTag: this.multilineTag,
- multilineWrapperTags: this.multilineWrapperTags,
preserveWhiteSpace,
} ),
};
@@ -235,12 +217,7 @@ export class RichText extends Component {
valueToFormat( value ) {
// Remove the outer root tags.
- return this.removeRootTagsProducedByAztec(
- toHTMLString( {
- value,
- multilineTag: this.multilineTag,
- } )
- );
+ return this.removeRootTagsProducedByAztec( toHTMLString( { value } ) );
}
getActiveFormatNames( record ) {
@@ -357,29 +334,15 @@ export class RichText extends Component {
const contentWithoutRootTag = this.removeRootTagsProducedByAztec(
unescapeSpaces( event.nativeEvent.text )
);
- let formattedContent = contentWithoutRootTag;
- if ( ! this.isIOS ) {
- formattedContent = this.restoreParagraphTags(
- contentWithoutRootTag,
- this.multilineTag
- );
- }
this.debounceCreateUndoLevel();
- const refresh = this.value !== formattedContent;
- this.value = formattedContent;
+ const refresh = this.value !== contentWithoutRootTag;
+ this.value = contentWithoutRootTag;
// We don't want to refresh if our goal is just to create a record.
if ( refresh ) {
- this.props.onChange( formattedContent );
- }
- }
-
- restoreParagraphTags( value, tag ) {
- if ( tag === 'p' && ( ! value || ! value.startsWith( '
' ) ) ) {
- return '
' + value + '
';
+ this.props.onChange( contentWithoutRootTag );
}
- return value;
}
/*
@@ -739,8 +702,6 @@ export class RichText extends Component {
if ( Array.isArray( value ) ) {
return create( {
html: childrenBlock.toHTML( value ),
- multilineTag: this.multilineTag,
- multilineWrapperTags: this.multilineWrapperTags,
preserveWhiteSpace,
} );
}
@@ -748,8 +709,6 @@ export class RichText extends Component {
if ( this.props.format === 'string' ) {
return create( {
html: value,
- multilineTag: this.multilineTag,
- multilineWrapperTags: this.multilineWrapperTags,
preserveWhiteSpace,
} );
}
@@ -1323,7 +1282,7 @@ export class RichText extends Component {
fontWeight={ this.props.fontWeight }
fontStyle={ this.props.fontStyle }
disableEditingMenu={ disableEditingMenu }
- isMultiline={ this.isMultiline }
+ isMultiline={ false }
textAlign={ this.props.textAlign }
{ ...( this.isIOS ? { maxWidth } : {} ) }
minWidth={ minWidth }
diff --git a/packages/block-editor/src/components/rich-text/with-deprecations.js b/packages/block-editor/src/components/rich-text/with-deprecations.js
new file mode 100644
index 0000000000000..8feab2206900a
--- /dev/null
+++ b/packages/block-editor/src/components/rich-text/with-deprecations.js
@@ -0,0 +1,51 @@
+/**
+ * WordPress dependencies
+ */
+import { forwardRef } from '@wordpress/element';
+import { children as childrenSource } from '@wordpress/blocks';
+import { useInstanceId } from '@wordpress/compose';
+import { __unstableCreateElement } from '@wordpress/rich-text';
+import deprecated from '@wordpress/deprecated';
+
+/**
+ * Internal dependencies
+ */
+import RichTextMultiline from './multiline';
+
+export function withDeprecations( Component ) {
+ return forwardRef( ( props, ref ) => {
+ let value = props.value;
+ let onChange = props.onChange;
+
+ // Handle deprecated format.
+ if ( Array.isArray( value ) ) {
+ deprecated( 'wp.blockEditor.RichText value prop as children type', {
+ since: '6.1',
+ version: '6.3',
+ alternative: 'value prop as string',
+ link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/',
+ } );
+
+ value = childrenSource.toHTML( props.value );
+ onChange = ( newValue ) =>
+ props.onChange(
+ childrenSource.fromDOM(
+ __unstableCreateElement( document, newValue ).childNodes
+ )
+ );
+ }
+
+ const NewComponent = props.multiline ? RichTextMultiline : Component;
+ const instanceId = useInstanceId( NewComponent );
+
+ return (
+
+ );
+ } );
+}
diff --git a/packages/editor/src/components/post-title/index.native.js b/packages/editor/src/components/post-title/index.native.js
index 1ec0dd3ade3bf..6d905e743581e 100644
--- a/packages/editor/src/components/post-title/index.native.js
+++ b/packages/editor/src/components/post-title/index.native.js
@@ -155,7 +155,6 @@ class PostTitle extends Component {
tagsToEliminate={ [ 'strong' ] }
unstableOnFocus={ this.props.onSelect }
onBlur={ this.props.onBlur } // Always assign onBlur as a props.
- multiline={ false }
style={ titleStyles }
styles={ styles }
fontSize={ 24 }