danielbucher / geekie-image

DrafJS Plugin that adds image support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

geekie-image

DrafJS Plugin that adds image support.

Basic usage

import React, { ReactElement } from 'react';
import { DraftailEditor as Editor, INLINE_STYLE } from 'draftail';
import createImagePlugin, {
  registerUploadImageTask,
} from '@draft-js-plugins/image';
import 'draftail/dist/draftail.css';

const imagePlugin = createImagePlugin();
const plugins = [imagePlugin];

// Register how to upload the selected image
registerUploadImageTask(() =>
  Promise.resolve('https://picsum.photos/1000/700')
);

const SimpleImageEditor = (): ReactElement => (
  <div>
    <Editor
      topTool
      controls={[imagePlugin.control]}
      inlineStyles={[
        { type: INLINE_STYLE.BOLD },
        { type: INLINE_STYLE.ITALIC },
      ]}
      entityTypes={[imagePlugin.entityType]}
      plugins={plugins}
    />
  </div>
);

export default SimpleImageEditor;

How to pubish

Edit the packages/image/package.json by yourself.

npm run build
cd packages/image && npm publish

About

DrafJS Plugin that adds image support

License:MIT License


Languages

Language:TypeScript 76.1%Language:JavaScript 18.1%Language:CSS 5.0%Language:Shell 0.6%Language:HTML 0.1%