)
}
const InsertImageButton = () => {
const editor = useSlateStatic()
return (
)
}
const isImageUrl = (url: string): boolean => {
if (!url) return false
if (!isUrl(url)) return false
const ext = new URL(url).pathname.split('.').pop()
return imageExtensions.includes(ext!)
}
const initialValue: Descendant[] = [
{
type: 'paragraph',
children: [
{
text: 'In addition to nodes that contain editable text, you can also create other types of nodes, like images or videos.',
},
],
},
{
type: 'image',
url: 'https://source.unsplash.com/kFrdX5IeQzI',
children: [{ text: '' }],
},
{
type: 'paragraph',
children: [
{
text: 'This example shows images in action. It features two ways to add images. You can either add an image via the toolbar icon above, or if you want in on a little secret, copy an image URL to your clipboard and paste it anywhere in the editor!',
},
],
},
{
type: 'paragraph',
children: [
{
text: 'You can delete images with the cross in the top left. Try deleting this sheep:',
},
],
},
{
type: 'image',
url: 'https://source.unsplash.com/zOwZKwZOZq8',
children: [{ text: '' }],
},
]
export default ImagesExample