Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convertToHTML Anchor Tag #169

Open
tringas opened this issue Apr 8, 2020 · 1 comment
Open

convertToHTML Anchor Tag #169

tringas opened this issue Apr 8, 2020 · 1 comment

Comments

@tringas
Copy link

tringas commented Apr 8, 2020

Thank you all for your work on this, Btw I don't have experience with Draftjs but I'm successfully using Dante2 on my project, but I'm having one problem with anchor tag when I use convertToHTML they are rendering as unstyled paragraph instead of anchor.

const html = convertToHTML({
  styleToHTML: style => {
    if (style.startsWith("CUSTOM_COLOR_")) {
      return (
        <span
          style={{
            color: style.substr(style.length - 7),
          }}
        />
      )
    }
  },
  blockToHTML: block => {
    if (block.type === "image") {
      return (
        <img src={block.data.url} alt={block.text} />
      )
    }
    if (block.type === "code-block") {
      return (
        <code>
          <pre>{block.text}</pre>
        </code>
      )
  }
},
})(editor.state.editorState._immutable.currentContent)

Is there a easy way I can specify how the anchor tag should looks like I'm doing with images

if (block.type === "image") {
  return (
    <img src={block.data.url} alt={block.text} />
  )
}

thank you

@keerthiyml
Copy link

Hi @tringas Were you able to solve this? I'm facing the same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants