Skip to content

Commit

Permalink
RichText: remove __unstableOnSplitMiddle (#54183)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix authored Sep 5, 2023
1 parent bafaa37 commit 8581c6d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 23 deletions.
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

0 comments on commit 8581c6d

Please sign in to comment.