1.1.8 • Published 9 years ago

final-draft v1.1.8

Weekly downloads
2
License
MIT
Repository
github
Last release
9 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

9 years ago

1.1.7

10 years ago

1.1.6

10 years ago

1.1.5

10 years ago

1.1.4

10 years ago

1.1.3

10 years ago

1.1.2

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.18

10 years ago

1.0.17

10 years ago

1.0.16

10 years ago

1.0.15

10 years ago

1.0.14

10 years ago

1.0.13

10 years ago

1.0.12

10 years ago

1.0.11

10 years ago

1.0.10

10 years ago

1.0.9

10 years ago

1.0.8

10 years ago

1.0.7

10 years ago

1.0.6

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago