🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@20minutes/draft-convert

Package Overview
Dependencies
Maintainers
2
Versions
4
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

Source
npmnpm
Version
3.0.2
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