jpuri / draftjs-to-html

Library for converting Draftjs editor content state to HTML

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CustomEntityTransform does not work properly

victors1682 opened this issue · comments

I've been attempting to apply a custom transformation, but I'm facing difficulties in getting it to work. We previously applied the transformation to the same element using 'draft-js' and 'draft-js-export-html'.

Testing

const draftToHtml = require("draftjs-to-html")

const data = {
    blocks: [
      {
        key: '123',
        text: 'My Heading',
        type: 'header-one',
        depth: 0,
        inlineStyleRanges: [],
        entityRanges: [],
        data: {}
      }
    ],
    entityMap: {}
  }
 
  const customEntityTransform = (data) => {
    return "<h1> Transformed: "+data+"</h1>"
  }

  const result = draftToHtml(data, undefined, false, customEntityTransform)

  console.log(result)