-
Notifications
You must be signed in to change notification settings - Fork 381
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't allow multiple CTA / attachment block to be pasted. (#3601)
- Loading branch information
1 parent
80430f5
commit b3149bc
Showing
6 changed files
with
72 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 0 additions & 40 deletions
40
assets/src/stories-editor/helpers/ensureAllowedBlocksOnPaste.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 0 additions & 40 deletions
40
assets/src/stories-editor/helpers/test/ensureAllowedBlocksOnPaste.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { getBlockType } from '@wordpress/blocks'; | ||
import { __, sprintf } from '@wordpress/i18n'; | ||
import { useDispatch } from '@wordpress/data'; | ||
|
||
/** | ||
* A hook to display a paste error message. | ||
* | ||
* @return {Function} Returns a function to display a paste error message. | ||
*/ | ||
const useDisplayPasteError = () => { | ||
const { createErrorNotice } = useDispatch( 'core/notices' ); | ||
|
||
return ( name ) => { | ||
const blockType = getBlockType( name ); | ||
const removeMessage = sprintf( | ||
// translators: %s: Type of block (i.e. Text, Image etc) | ||
__( 'Unable to paste %s block.', 'amp' ), | ||
blockType.title | ||
); | ||
createErrorNotice( | ||
removeMessage, | ||
{ | ||
type: 'snackbar', | ||
isDismissible: true, | ||
} | ||
); | ||
}; | ||
}; | ||
|
||
export default useDisplayPasteError; |