Skip to content

Instantiate EditorState from HTML #2

Open
@rpellerin

Description

@rpellerin

Hi,
Thanks for developing such a useful library!
My question might seem dumb but I can't figure how to do it... How can I generate an EditorState out of exported HTML, which preserves inline styles?

I use the following chunk of code to get HTML from an editorState, which works perfectly:

import { stateToHTML } from 'draft-js-export-html'

const inlineStyles = exporter(editorState)
const content = editorState.getCurrentContent()
const html = stateToHTML(content, { inlineStyles })

But then, when I do:

import { stateFromHTML } from 'draft-js-import-html'

EditorState.createWithContent(stateFromHTML("<p><span style="font-size: 34px">yo</span></p> "))

I lose the font-size. Any hints?
Thanks a lot!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions