feat(stories): enable rich text in story editor#1327
Conversation
jboolean
left a comment
There was a problem hiding this comment.
Thanks for trying this out! I'm seeing some immediate problems on the preview branch
- The overflow behavior of the editor changed
Here it is before:
https://github.com/user-attachments/assets/70fc90fd-c0a3-4957-b581-3ee975223df9
And now:
https://github.com/user-attachments/assets/577bba55-9703-4a2a-8d8a-036126e37887
I tried to render an existing story with a url in it to see if the url worked (photo: nynyma_rec0040_1_00998_0026).
Rendering before:

The url is not clickable and the line breaks are missing.
I noticed that it persists in html rather than markdown. I think Markdown is a better choice here
- It is a much simpler format. We only needs links and basic formatting. Html is overly complex for our needs.
- Markdown is a simple, human readable format. Persisted content where the user has not added any formatting is cluttered with p tags.
- Markdown is backwards compatible with plaintext. Meaning, the plaintext content we already have can be rendered as markdown. Especially if users used links, they can be rendered, as can basic formatting like underscores and asterisks.
- Not a trap door. A markdown renderer can be removed and the content still looks good. HTML would require a migration.
- Security. I'm sure tiptap renderer has xss mitigations, but it still makes me nervous about what happens if a story is submitted (especially bypassing the editor) with script tags, images, etc. I feel more confident in React's built-in escapes that are currently used on the plaintext content. fwiw I did try to put it script and img tags and the tiptap renderer stripped them out, and the header rendered as a p.
I see tiptap does support markdown to some extent.
I think it's also worth looking at react-markdown for rendering. If you enable the gfm (Github flavored markdown) plugin in react-markdown it appears to enable auto-linking. It also support allow-listing tags.
Thanks for finding a good story for testing compatibility, I was having a hard time finding something more complex to see how tiptap would handle it. I mostly reached for Tiptap because it's a library I have experience using :D I'll take a look at react-markdown, thanks for the thorough feedback! |
- use `Markdown` component from react-markdown to convert markdown text -> HTML nodes - limit to only basic elements, no headings, strikethroughs, etc. allowed - add logic to automatically transform plain URLs into markdown links when story is rendered - add custom <a> tag implementation for react-markdown to make sure links always open in new tabs
01dc9d2 to
3bc4249
Compare
|
Sorry for the delay here @jboolean! Reworked this to be a lot more simple and use just
I'm kind of torn on whether or not I should add to the Any thoughts? |




TextAreacomponent with customTipTapEditorcomponent for story editingrel="noopener noreferrer nofollow" target="_blank"attributes by default, see Link extension docsTipTapEditorwith editing disabled to render story html inStorycomponent