buttondown / roadmap

Buttondown's public roadmap
53 stars 0 forks source link

Fancy mode breaks on inline images inside wrapped paragraphs. #3247

Open jmduke opened 2 months ago

jmduke commented 2 months ago

Consider the following:

<p class="foo">
  <img src="..." />
</p>

This currently will not render in Fancy Mode, and saving it will destroy the image. Why?

Because we've explicitly chosen to not allow inline images.

"Okay," you say, "but why does the class matter?"

Part of the rendering pipeline for Fancy Mode is running the content through marked, and one of the things we explicitly compile are isolated images within an empty p tag:

      // tiptap doesn’t recognize images wrapped in <p>, so we remove the <p> wrappers around <img>.
      .replace(/<p><img (.+?)><\/p>/g, "<img $1 />")

There are a number of paths here:

  1. Allow inline images and just have them be read-only.
  2. Warn loudly before loading Fancy Mode for these cases
  3. Other stuff.
rknightuk commented 2 months ago

@jmduke Hey Justin did you get a chance to look at this at all?

jmduke commented 2 months ago

@rknightuk Gah I promised you that it would be fixed by Saturday and the nit was not, in fact, fixed by Saturday. Deepest apologies: I will, as penance, fix it this evening and shoot you a reproduction.

jmduke commented 2 months ago

Okay, a good path forward will be bumping our version of tiptap to 2.5 so we can take advantage of richer error handling, and then I think just loudly fail with a prompt to drop down to Markdown.

Robb, this won't be fixed by tonight just because we need to test the minor version bump but if you remove the app-icons class in the short term you should be able to avoid the issue entirely.

rknightuk commented 2 months ago

Is there anything we can do temporarily that isn't removing the class - because we're using RSS import that class is used to style stuff on the web version?

jmduke commented 2 months ago

Yup — just don't toggle into Fancy Mode. As long as you look at the email in Markdown, you'll be fine.

rknightuk commented 2 months ago

Ah okay, we'll do that then 👍