slate-paste-url-imagify

A Slate plugin that converts a selection in a image block element when a URL is pasted from the clipboard.

Usage no npm install needed!

<script type="module">
  import slatePasteUrlImagify from 'https://cdn.skypack.dev/slate-paste-url-imagify';
</script>

README

Slate Paste URL Imagify

Greenkeeper badge version coding style: standard dependencies devDependencies Downloads Travis branch semantic-release

A Slate plugin that converts a selection in a image block element when a URL is pasted from the clipboard.

import PasteUrlImagify from 'slate-paste-url-imagify'
import { Editor } from 'slate-react'

// Add the plugin to your set of plugins...
const plugins = [
  PasteUrlImagify()
]

// And later pass it into the Slate editor...
<Editor
  ...
  plugins={plugins}
/>

This plugin works by taking in options that specify link-related commands and queries to execute when it detects that the user is trying to insert a link (by pasting or drag-dropping). This way you can define the exact behavior you want in the commands, but delegate the detection of links being inserted to the plugin.

Option Type Description
insertPastedImage (default: 'insertPastedImage') String The name of the command that insert image block. It will be passed the url of the image as its argument.
allowedImageTypes (default: ['jpg', 'jpeg', 'png', 'gif', 'svg']) Array List of allowed image extensions.