0.2.2 • Published 6 years ago

slate-auto-replace-iframe v0.2.2

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

slate-auto-replace-iframe

A Slate plugin to replace matching text with iframes. This is triggered upon the Enter button on a block that matches a regular expression. For example, if you copy/paste a Youtube link into a block and then press Enter, that block will be transformed from the URL into the iframe text.

View Demo ⬈

import AutoIframeReplace from 'slate-auto-replace-iframe';
import { Editor } from 'slate-react';

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

// And later pass it into the Slate editor...
<Editor
  ...
  plugins={plugins}
/>
OptionTypeDescription
iframeProvidersMapObjectAn optional object where the key is some string and the value is an object with regex and getIframeSrc keys. regex should be a Regular Expression and getIframeSrc should be a function taking in a single parameter, the result of matching the block text with the regex. This defaults to a map containing some common providers - Youtube, Vimeo, and Twitch.
ignoreInFunction Array StringAn optional block matcher to ignore triggers inside. If passed an array or string it will match by node.type.
onlyInFunction Array StringAn optional block matcher to only replace triggers inside. If passed an array or string it will match by node.type.
0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.1

6 years ago