Socket
Book a DemoInstallSign in
Socket

@20minutes/draft-convert

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@20minutes/draft-convert

Extensibly serialize & deserialize Draft.js ContentState

3.0.2
latest
Source
npmnpm
Version published
Maintainers
2
Created
Source

@20minutes/draft-convert

Node CI npm version npm downloads

Forked version:

For the official readme, check the official project.

validateHTML (option of convertToHTML)

validateHTML take the final HTML of the current block as parameter and must return a boolean saying if every thing is ok.

We do have some custom entity/block generation and sometimes, the produced HTML might be wrong. So we validate it using ReactDomServer, like:

import ReactDOMServer from 'react-dom/server'
import { Parser as HtmlToReactParser } from 'html-to-react'

// ...

const html = convertToHTML({
  // ...
  validateHTML: (html) => {
    try {
      const htmlToReactParser = HtmlToReactParser()

      ReactDOMServer.renderToString(htmlToReactParser.parse(html))

      return true
    } catch (e) {
      return false
  }
})(editorState.getCurrentContent());

Keywords

draft

FAQs

Package last updated on 01 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.