1.1.8 • Published 7 years ago

final-draft v1.1.8

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

final-draft

npm version

Standard - JavaScript Style Guide

npm.io

final-draft is a Draft.js editor built using draft-js-plugins

Install

npm install final-draft --save

Use

import React, { Component } from 'react'
import { render } from 'react-dom'
import {editorStateFromHtml, editorStateFromRaw} from 'final-draft'
import { Editor } from 'final-draft'

export default class ExampleEditor extends Component {
  constructor(props) {
    super(props)
    this.state = { value: editorStateFromRaw(raw) }
  }

  onChange(value) {
    this.setState({ value })
  }

  render() {
    return (
      <Editor
        editorState={this.state.value}
        placeholder="Text"
        uploadImageCallBack={uploadImageCallBack}
        onChange={::this.onChange} />
    )
  }
}

function uploadImageCallBack(file) {
  return new Promise(
    (resolve, reject) => {
      /* simulate a 2 second call to parse file and return an img src... */
      setTimeout( () => {
        resolve({ src: 'http://imgur.com/yrwFoXT.jpg' });
      }, 2000)
    }
  )
}

Props

plugins (required)

Array of plugins to include, any of the following: imagePlugin, emojiPlugin, hashtagPlugin, inlineToolbarPlugin, linkifyPlugin, mentionPlugin, sideToolbarPlugin, stickerPlugin, undoPlugin, videoPlugin

Styles

Are using styled-components so they should just work 💅 like magic. They append to a <style> tag if you want to be specific.

Development

yarn install
npm run dev
open http://127.0.0.1:3000

License

MIT

1.1.8

7 years ago

1.1.7

7 years ago

1.1.6

7 years ago

1.1.5

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.18

7 years ago

1.0.17

7 years ago

1.0.16

7 years ago

1.0.15

7 years ago

1.0.14

7 years ago

1.0.13

7 years ago

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago