Giter VIP home page Giter VIP logo

rich-text-to-jsx's People

Contributors

connor-baer avatar dependabot[bot] avatar github-actions[bot] avatar jayakrishnanamburu avatar zallek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

rich-text-to-jsx's Issues

Parse RTF string to JSX

Summarize the question

Will it work for a rtf string for example like this? {\\rtf1\\ansi\\b hi there\\b0}

Because I tried to do it like this:

const convertToPlain = rtf => { let plain = richTextToJsx(rtf); return plain; };

The output is null.

Context

Im trying to parse the rtf string into a jsx/html format. I expect the output to be like this
<p><strong>hi there</strong></p>

Specifications

  • Version:
  • Browser:
  • OS:

Make the lib compatible with Google Translate

Purpose

Make the lib compatible with Google Translate

When Google Translate a web page, it replaces text nodes with <font> tags containing translations while React keeps references to the text nodes that are no longer in the DOM tree. Leading to React error and a blank page.

More info here

Approach & Changes

When facing the following paragraph

{
  "nodeType": "paragraph",
  "content": [
    {
      "nodeType": "text",
      "value": "Welcome",
      "marks": [],
      "data": {}
    },
    {
      "nodeType": "hyperlink",
      "content": [
        {
          "nodeType": "text",
          "value": "Something",
          "marks": [],
          "data": {}
        }
      ],
      "data": {
        "uri": "foo"
      }
    }
  ],
  "data": {}
}

The lib currently renders the following. Therefore Google Translate will replace Welcome by <font>Bienvenue</font> leading to a React error on the next update.

<p>
  Welcome
  <a>Something</a>
</p>

As shown in this article, to solve the issue, we should render the following so that Google Transform will replace <span>Welcome</span> by <span>Bienvenue</span> preventing bugs as the DOM tree isn't changed.

<p>
  <span>Welcome</span>
  <a>Something</a>
</p>

The current behavior is due to this line.
It would be great if we could override the text render when no marks.

Thanks.

Plans for table types support

Purpose

I'm using this library to render the rich text from some content from Contentful and saw that the table related node types are not yet supported. Any plans to support them in the near future?

Thank you!

Additional Context

Screenshot 2023-11-15 at 11 22 50

[Blocks.EMBEDDED_ASSET] not working for images

[Blocks.EMBEDDED_ASSET] not working for images.

I think it has to do with

const contentType = get(data, 'target.contentType');
.

My node structure does not match this pattern, but looks like the following. It is an image asset uploaded to a rich text field:

2019-01-31_16-40-36

My goal is to pull the id (contentful_id) out of data.target.sys and then use to query for that image and produce a fluid image for gatsby-image.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.