mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-20 22:21:20 +02:00
Added isImageUrl validation to button, added alert when not image (#3933)
* Added isImageUrl validation to button, added alert when not image * Fixed lint error
This commit is contained in:
@@ -116,7 +116,10 @@ const InsertImageButton = () => {
|
|||||||
onMouseDown={event => {
|
onMouseDown={event => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
const url = window.prompt('Enter the URL of the image:')
|
const url = window.prompt('Enter the URL of the image:')
|
||||||
if (!url) return
|
if (url && !isImageUrl(url)) {
|
||||||
|
alert('URL is not an image')
|
||||||
|
return
|
||||||
|
}
|
||||||
insertImage(editor, url)
|
insertImage(editor, url)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
Reference in New Issue
Block a user