Skip to content

Commit

Permalink
Block Library: Replace hardcoded core/paragraph with getDefaultBlockN…
Browse files Browse the repository at this point in the history
…ame in onSplitAtEnd callbacks (#40954)
  • Loading branch information
andrewserong authored May 10, 2022
1 parent f60ca37 commit b7d4f3a
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 22 deletions.
6 changes: 4 additions & 2 deletions packages/block-library/src/audio/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { useEffect } from '@wordpress/element';
import { __, _x } from '@wordpress/i18n';
import { useSelect } from '@wordpress/data';
import { audio as icon } from '@wordpress/icons';
import { createBlock } from '@wordpress/blocks';
import { createBlock, getDefaultBlockName } from '@wordpress/blocks';

/**
* Internal dependencies
Expand Down Expand Up @@ -208,7 +208,9 @@ function AudioEdit( {
}
inlineToolbar
__unstableOnSplitAtEnd={ () =>
insertBlocksAfter( createBlock( 'core/paragraph' ) )
insertBlocksAfter(
createBlock( getDefaultBlockName() )
)
}
/>
) }
Expand Down
6 changes: 4 additions & 2 deletions packages/block-library/src/embed/embed-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { __, sprintf } from '@wordpress/i18n';
import { Placeholder, SandBox } from '@wordpress/components';
import { RichText, BlockIcon } from '@wordpress/block-editor';
import { Component } from '@wordpress/element';
import { createBlock } from '@wordpress/blocks';
import { createBlock, getDefaultBlockName } from '@wordpress/blocks';

/**
* Internal dependencies
Expand Down Expand Up @@ -145,7 +145,9 @@ class EmbedPreview extends Component {
onChange={ onCaptionChange }
inlineToolbar
__unstableOnSplitAtEnd={ () =>
insertBlocksAfter( createBlock( 'core/paragraph' ) )
insertBlocksAfter(
createBlock( getDefaultBlockName() )
)
}
/>
) }
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/gallery/gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { RichText, useInnerBlocksProps } from '@wordpress/block-editor';
import { VisuallyHidden } from '@wordpress/components';
import { useState, useEffect } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { createBlock } from '@wordpress/blocks';
import { createBlock, getDefaultBlockName } from '@wordpress/blocks';
import { View } from '@wordpress/primitives';

const allowedBlocks = [ 'core/image' ];
Expand Down Expand Up @@ -89,7 +89,7 @@ export const Gallery = ( props ) => {
onChange={ ( value ) => setAttributes( { caption: value } ) }
inlineToolbar
__unstableOnSplitAtEnd={ () =>
insertBlocksAfter( createBlock( 'core/paragraph' ) )
insertBlocksAfter( createBlock( getDefaultBlockName() ) )
}
/>
</figure>
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/gallery/v1/gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import classnames from 'classnames';
import { RichText } from '@wordpress/block-editor';
import { VisuallyHidden } from '@wordpress/components';
import { __, sprintf } from '@wordpress/i18n';
import { createBlock } from '@wordpress/blocks';
import { createBlock, getDefaultBlockName } from '@wordpress/blocks';

/**
* Internal dependencies
Expand Down Expand Up @@ -101,7 +101,7 @@ export const Gallery = ( props ) => {
onChange={ ( value ) => setAttributes( { caption: value } ) }
inlineToolbar
__unstableOnSplitAtEnd={ () =>
insertBlocksAfter( createBlock( 'core/paragraph' ) )
insertBlocksAfter( createBlock( getDefaultBlockName() ) )
}
/>
</figure>
Expand Down
10 changes: 8 additions & 2 deletions packages/block-library/src/image/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ import {
import { useEffect, useMemo, useState, useRef } from '@wordpress/element';
import { __, sprintf, isRTL } from '@wordpress/i18n';
import { getFilename } from '@wordpress/url';
import { createBlock, switchToBlockType } from '@wordpress/blocks';
import {
createBlock,
getDefaultBlockName,
switchToBlockType,
} from '@wordpress/blocks';
import { crop, overlayText, upload } from '@wordpress/icons';
import { store as noticesStore } from '@wordpress/notices';
import { store as coreStore } from '@wordpress/core-data';
Expand Down Expand Up @@ -598,7 +602,9 @@ export default function Image( {
}
inlineToolbar
__unstableOnSplitAtEnd={ () =>
insertBlocksAfter( createBlock( 'core/paragraph' ) )
insertBlocksAfter(
createBlock( getDefaultBlockName() )
)
}
/>
) }
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/pullquote/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
RichText,
useBlockProps,
} from '@wordpress/block-editor';
import { createBlock } from '@wordpress/blocks';
import { createBlock, getDefaultBlockName } from '@wordpress/blocks';
import { Platform } from '@wordpress/element';

/**
Expand Down Expand Up @@ -87,7 +87,7 @@ function PullQuoteEdit( {
textAlign="center"
__unstableOnSplitAtEnd={ () =>
insertBlocksAfter(
createBlock( 'core/paragraph' )
createBlock( getDefaultBlockName() )
)
}
/>
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/pullquote/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
getColorObjectByAttributeValues,
__experimentalGetColorClassesAndStyles as getColorClassesAndStyles,
} from '@wordpress/block-editor';
import { createBlock } from '@wordpress/blocks';
import { createBlock, getDefaultBlockName } from '@wordpress/blocks';

/**
* Internal dependencies
Expand Down Expand Up @@ -115,7 +115,7 @@ function PullQuoteEdit( props ) {
textAlign={ textAlign ?? 'center' }
__unstableOnSplitAtEnd={ () =>
insertBlocksAfter(
createBlock( 'core/paragraph' )
createBlock( getDefaultBlockName() )
)
}
/>
Expand Down
6 changes: 4 additions & 2 deletions packages/block-library/src/quote/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
useBlockProps,
} from '@wordpress/block-editor';
import { BlockQuotation } from '@wordpress/components';
import { createBlock } from '@wordpress/blocks';
import { createBlock, getDefaultBlockName } from '@wordpress/blocks';
import { Platform } from '@wordpress/element';

const isWebPlatform = Platform.OS === 'web';
Expand Down Expand Up @@ -102,7 +102,9 @@ export default function QuoteEdit( {
className="wp-block-quote__citation"
textAlign={ align }
__unstableOnSplitAtEnd={ () =>
insertBlocksAfter( createBlock( 'core/paragraph' ) )
insertBlocksAfter(
createBlock( getDefaultBlockName() )
)
}
/>
) }
Expand Down
6 changes: 4 additions & 2 deletions packages/block-library/src/quote/v2/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
} from '@wordpress/block-editor';
import { BlockQuotation } from '@wordpress/components';
import { useDispatch, useSelect, useRegistry } from '@wordpress/data';
import { createBlock } from '@wordpress/blocks';
import { createBlock, getDefaultBlockName } from '@wordpress/blocks';
import { Platform, useEffect } from '@wordpress/element';
import deprecated from '@wordpress/deprecated';

Expand Down Expand Up @@ -128,7 +128,9 @@ export default function QuoteEdit( {
}
className="wp-block-quote__citation"
__unstableOnSplitAtEnd={ () =>
insertBlocksAfter( createBlock( 'core/paragraph' ) )
insertBlocksAfter(
createBlock( getDefaultBlockName() )
)
}
{ ...( ! isWebPlatform ? { textAlign: align } : {} ) }
/>
Expand Down
6 changes: 4 additions & 2 deletions packages/block-library/src/table/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {
tableRowDelete,
table,
} from '@wordpress/icons';
import { createBlock } from '@wordpress/blocks';
import { createBlock, getDefaultBlockName } from '@wordpress/blocks';

/**
* Internal dependencies
Expand Down Expand Up @@ -505,7 +505,9 @@ function TableEdit( {
// Deselect the selected table cell when the caption is focused.
unstableOnFocus={ () => setSelectedCell() }
__unstableOnSplitAtEnd={ () =>
insertBlocksAfter( createBlock( 'core/paragraph' ) )
insertBlocksAfter(
createBlock( getDefaultBlockName() )
)
}
/>
) }
Expand Down
6 changes: 4 additions & 2 deletions packages/block-library/src/video/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { __, sprintf } from '@wordpress/i18n';
import { useInstanceId } from '@wordpress/compose';
import { useSelect } from '@wordpress/data';
import { video as icon } from '@wordpress/icons';
import { createBlock } from '@wordpress/blocks';
import { createBlock, getDefaultBlockName } from '@wordpress/blocks';

/**
* Internal dependencies
Expand Down Expand Up @@ -274,7 +274,9 @@ function VideoEdit( {
}
inlineToolbar
__unstableOnSplitAtEnd={ () =>
insertBlocksAfter( createBlock( 'core/paragraph' ) )
insertBlocksAfter(
createBlock( getDefaultBlockName() )
)
}
/>
) }
Expand Down

0 comments on commit b7d4f3a

Please sign in to comment.