From 6c6946b9683cfd909a077a394509d0bec7bf912c Mon Sep 17 00:00:00 2001 From: Tobias Andersen Date: Fri, 2 Dec 2016 18:41:33 +0100 Subject: [PATCH] Add convertToHTML example for version 0.9.1 (#833) * Add convertFromHTML example for 0.9.1 * Update docs with convertFromHTML example * Remove image from convertFromHTML example in 0-9-1 * Update 0.9.1 convertFromHTML example to use the old Entity API * Fix link to convertToHTML example in docs --- docs/APIReference-Data-Conversion.md | 10 +- .../draft-0-9-1/convertFromHTML/convert.html | 145 ++++++++++++++++++ 2 files changed, 148 insertions(+), 7 deletions(-) create mode 100644 examples/draft-0-9-1/convertFromHTML/convert.html diff --git a/docs/APIReference-Data-Conversion.md b/docs/APIReference-Data-Conversion.md index a67aceea81..4624d25481 100644 --- a/docs/APIReference-Data-Conversion.md +++ b/docs/APIReference-Data-Conversion.md @@ -51,18 +51,14 @@ other usage within an application. ``` const sampleMarkup = 'Bold text, Italic text

' + - 'Example link

' + - ''; + 'Example link'; const blocksFromHTML = convertFromHTML(sampleMarkup); -const state = ContentState.createFromBlockArray( - blocksFromHTML.contentBlocks, - blocksFromHTML.entityMap, -); +const state = ContentState.createFromBlockArray(blocksFromHTML); this.state = { editorState: EditorState.createWithContent(state), }; ``` -Given an HTML fragment, convert it to an array of `ContentBlock` objects. Construct content state from the array of block elements and then update the editor state with it. Full example available [here](https://github.com/facebook/draft-js/blob/8ac72f723fb2d9102db833a9b060dfd66df65652/examples/draft-0-9-1/convertFromHTML/convert.html). +Given an HTML fragment, convert it to an array of `ContentBlock` objects. Construct content state from the array of block elements and then update the editor state with it. Full example available [here](https://github.com/facebook/draft-js/tree/master/examples/draft-0-9-1/convertToHTML). diff --git a/examples/draft-0-9-1/convertFromHTML/convert.html b/examples/draft-0-9-1/convertFromHTML/convert.html new file mode 100644 index 0000000000..e21b734c27 --- /dev/null +++ b/examples/draft-0-9-1/convertFromHTML/convert.html @@ -0,0 +1,145 @@ + + + + + + Draft • Convert from HTML + + + +
+ + + + + + + +