-
Notifications
You must be signed in to change notification settings - Fork 6
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
Figure element breaks the paragraphs structure (empty <p></p> artifact) #83
Comments
This is the doc array for one of the nodes that doesn't render:
As compared to one that renders as expected:
So this offers a clue sense since the element where the text is rendered without a tag consists of two nodes: image and text. Only the image node renders correctly. The text doesn't render. |
Hi @leancept, thank you for using the package, let's break it down where is the issue. I have tried to do reproducible https://stackblitz.com/edit/github-w6ndeh?file=src%2Fpages%2Findex.astro,src%2Fstoryblok%2FRichText.astro,src%2Fcomponents%2FImageWithCaption.astro,src%2Fstoryblok%2FButton.astro I have tried both ways - with package and with no package. Both times I got same additional So I went into other tool just to render this HTML:
see https://jsfiddle.net/edvinasjurele/ztu617xv/ ❌ , and I can reproduce same issue outside of storyblok-rich-text-astro-renderer package: This implies that having ConclusionsI am certain that the browser itself do not like Cure (partial) from consumer sideLooking into your Change
and that should improve things from consumer side a little bit. But it does solve the issue entirely. Bug on the library sideI have tried to do the minimal repro: https://stackblitz.com/edit/github-rh6lpz-tueqzc?file=src%2Fcomponents%2FPictureWithCaption.astro,src%2Fstoryblok%2FRichText.astro and it indeed has same issue This is something to address. The question is how? |
I am highly doubtful if the package should handle the The problem you bump into is the same as Here is what I would suggest:Leave rich text built-in However, in case that does not work for you and you still need
Let me know if that works for you @leancept ? |
However I do not see an issue with this structure: you can always add a class to change behaviour of your element: |
The structure is correct HTML, true. However, I made it to show that the rendering issue isn't dependent on the markup of the Astro component I made. The problem with having unwrapped text following every image is that it's not styled. The output I need is for text following an image is wrapped in a p. So instead of what I get now:
I'd like:
This issue seems triggered when a text node follows an image node in the SB editor in my setup where I use a custom Astro component for images. When text follows an image in the SB editor, it groups them in the doc array. Simply pressing enter to insert an empty paragraph after every image in the SB editor fixes it. |
This is what's going on here:
There are three solutions:
I want to avoid SB-specific solutions as much as possible to ease a future content migration so number 3 isn't ideal. Anyway, thank you for the help debugging. I'll figure out a solution. Shame it's so difficult to render Storyblok content as accessible HTML5. The SB RTE should support |
Storyblok's default rich-text rendering renders image captions as a title attribute, so I used your project to define my own image component using figure and figcaption, like so:
ImageWithCaption.astro
and
article.astro
Problem is, when the rich text content is rendered, the node that follows an image node doesn't get rendered, instead the text content is output as-is. This is typically a paragraph, so it can be worked around with CSS by giving it as the same appearance as a p tag:
If you add an empty paragraph under the image in Storyblok's rich-text editor, the text is rendered as a paragraph using a p tag – which is what's expected:
Not sure if this is a bug in this project or if my code is at fault.
The text was updated successfully, but these errors were encountered: