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

RichText: remove __unstableOnSplitMiddle #54183

Merged
merged 1 commit into from
Sep 5, 2023
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
3 changes: 0 additions & 3 deletions packages/block-editor/src/components/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ function RichTextWrapper(
onMerge,
onSplit,
__unstableOnSplitAtEnd: onSplitAtEnd,
__unstableOnSplitMiddle: onSplitMiddle,
identifier,
preserveWhiteSpace,
__unstablePastePlainText: pastePlainText,
Expand Down Expand Up @@ -380,7 +379,6 @@ function RichTextWrapper(
tagName,
onReplace,
onSplit,
onSplitMiddle,
__unstableEmbedURLOnPaste,
multilineTag,
preserveWhiteSpace,
Expand All @@ -396,7 +394,6 @@ function RichTextWrapper(
value,
onReplace,
onSplit,
onSplitMiddle,
multilineTag,
onChange,
disableLineBreaks,
Expand Down
21 changes: 7 additions & 14 deletions packages/block-editor/src/components/rich-text/split-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export function splitValue( {
pastedBlocks = [],
onReplace,
onSplit,
onSplitMiddle,
multilineTag,
} ) {
if ( ! onReplace || ! onSplit ) {
Expand All @@ -35,8 +34,8 @@ export function splitValue( {

// Create a block with the content before the caret if there's no pasted
// blocks, or if there are pasted blocks and the value is not empty. We do
// not want a leading empty block on paste, but we do if split with e.g. the
// enter key.
// not want a leading empty block on paste, but we do if we split with e.g.
// the enter key.
if ( ! hasPastedBlocks || ! isEmpty( before ) ) {
blocks.push(
onSplit(
Expand All @@ -53,19 +52,13 @@ export function splitValue( {
if ( hasPastedBlocks ) {
blocks.push( ...pastedBlocks );
lastPastedBlockIndex += pastedBlocks.length;
} else if ( onSplitMiddle ) {
blocks.push( onSplitMiddle() );
}

// If there's pasted blocks, append a block with non empty content / after
// the caret. Otherwise, do append an empty block if there is no
// `onSplitMiddle` prop, but if there is and the content is empty, the
// middle block is enough to set focus in.
if (
hasPastedBlocks
? ! isEmpty( after )
: ! onSplitMiddle || ! isEmpty( after )
) {
// Create a block with the content after the caret if there's no pasted
// blocks, or if there are pasted blocks and the value is not empty. We do
// not want a trailing empty block on paste, but we do if we split with e.g.
// the enter key.
if ( ! hasPastedBlocks || ! isEmpty( after ) ) {
blocks.push(
onSplit(
toHTMLString( {
Expand Down
3 changes: 0 additions & 3 deletions packages/block-editor/src/components/rich-text/use-enter.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export function useEnter( props ) {
value,
onReplace,
onSplit,
onSplitMiddle,
multilineTag,
onChange,
disableLineBreaks,
Expand Down Expand Up @@ -78,7 +77,6 @@ export function useEnter( props ) {
value: _value,
onReplace,
onSplit,
onSplitMiddle,
multilineTag,
} );
} else {
Expand All @@ -100,7 +98,6 @@ export function useEnter( props ) {
value: _value,
onReplace,
onSplit,
onSplitMiddle,
multilineTag,
} );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export function usePasteHandler( props ) {
tagName,
onReplace,
onSplit,
onSplitMiddle,
__unstableEmbedURLOnPaste,
multilineTag,
preserveWhiteSpace,
Expand Down Expand Up @@ -179,7 +178,6 @@ export function usePasteHandler( props ) {
pastedBlocks: blocks,
onReplace,
onSplit,
onSplitMiddle,
multilineTag,
} );
}
Expand Down Expand Up @@ -239,7 +237,6 @@ export function usePasteHandler( props ) {
pastedBlocks: content,
onReplace,
onSplit,
onSplitMiddle,
multilineTag,
} );
}
Expand Down
Loading