A batteries-excluded rich text editor based on Draft.js. :memo::cocktail:
This is a work in progress. It is intended to be integrated into Wagtail. Try a demo now.
Usage
First, grab the package from npm:
npm install --save draftail
npm install --save draft-js@^0.10.0 react@^15.0.0 react-dom@^15.0.0
Then, import the editor and use it in your code. Here is a basic example:
import React from 'react';
import ReactDOM from 'react-dom';
import DraftailEditor, { BLOCK_TYPE, INLINE_STYLE } from 'draftail';
const initialContentState = JSON.parse(sessionStorage.getItem('basic:contentState')) || {};
const onSave = (contentState) => {
sessionStorage.setItem('basic:contentState', JSON.stringify(contentState));
};
const editor = (
<DraftailEditor
rawContentState={initialContentState}
onSave={onSave}
blockTypes={[
{ label: 'H3', type: BLOCK_TYPE.HEADER_THREE },
{ label: 'UL', type: BLOCK_TYPE.UNORDERED_LIST_ITEM, icon: 'icon-list-ul' },
]}
inlineStyles={[
{ label: 'Bold', type: INLINE_STYLE.BOLD, icon: 'icon-bold' },
{ label: 'Italic', type: INLINE_STYLE.ITALIC, icon: 'icon-italic' },
]}
/>
);
ReactDOM.render(editor, document.querySelector('[data-mount-basic]'));
Development
Install
Clone the project on your computer, and install Node. This project also uses nvm.
nvm install
npm install
./.githooks/deploy
touch .env
Working on the project
Everything mentioned in the installation process should already be done.
nvm use
npm run start
npm run lint
npm run test
npm run
Publish
git release vx.y.z
npm run dist
irish-pub
npm publish