connor-baer / rich-text-to-jsx Goto Github PK
View Code? Open in Web Editor NEW๐ Opinionated JSX renderer for the Contentful rich text field type.
License: MIT License
๐ Opinionated JSX renderer for the Contentful rich text field type.
License: MIT License
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.
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>
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
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.
[Blocks.EMBEDDED_ASSET] not working for images.
I think it has to do with
rich-text-to-jsx/src/rich-text-to-jsx.js
Line 118 in 5096c38
My node structure does not match this pattern, but looks like the following. It is an image asset uploaded to a rich text field:
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
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.