medium-draft
medium-draft copied to clipboard
How Can I get html content
I use plugin draft-js-import-html https://github.com/sstur/draft-js-import-html
but I cannot get tag , cannot get Image content
I have been getting a lot of questions for the above feature. I will create a medium-draft-exporter project for the same use case and will update here.
@brijeshb42 what's with medium-draft-exporter now?
Just use draft-js-export-html with options
const contentState = this.state.editorState.getCurrentContent();
const options = {
blockRenderers: {
'atomic:image': (block) => {
const data = block.getData();
const src = data.get("src");
const caption = block.getText();
return `<figure><img src="${src}"/><figcaption>${caption}</figcaption></figure>`;
},
},
};
const html = stateToHTML(contentState, options);
As of version 0.4.1, medium-draft-exporter is part of the project. See the docs here.