0.1.6 • Published 5 years ago

html-to-draft v0.1.6

Weekly downloads
108
License
MIT
Repository
github
Last release
5 years ago

html-to-draft

parse html to draft js content state

PRs Welcome GitHub code size in bytes Build Status module formats: cjs, and es NPM JavaScript Style Guide

Tested on latest versions of Firefox, Chrome, Safari

Install

npm install --save html-to-draft

Usage convertFromHtml

This package just contains one method, to convert html to draft js content state. For starters, here's all the type info you need to build custom converters.

convertFromHtml(
  html: string,
  options?: {
    parseBlock?: HTMLElement => TextBlock | AtomicBlock
    parseTextFragment?: HTMLElement => TextFragment
  }
)

type TextFragment = {
  offset: number,
  length: number,
  inlineStyleRanges: ?Array<string>,
  entity: ?{
    type: string,
    data: ?Object,
  }
}


type AtomicBlock = {
  type: 'atomic',
  entity: ?{
    type: string,
    data: ?Object,
  },
  data: ?Object,
}

type TextBlock = {
  type: ?string,
  depth: ?number,
  data: ?Object,
}

License

MIT © tettra

Developed by Julian Krispel

0.1.6

5 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago