8 votes

The unreasonable effectiveness of ProseMirror model in rich text transformation

3 comments

  1. smores
    Link
    This one is a bit niche, even by my usual standards, but if you're interested in strategies for DOM transformations, rich text editing, or EPUBs, maybe this is for you!

    This one is a bit niche, even by my usual standards, but if you're interested in strategies for DOM transformations, rich text editing, or EPUBs, maybe this is for you!

    1 vote
  2. [2]
    skybrian
    Link
    Nice explanation! I came up with a vaguely similar design for converting paragraphs that I want to quote from HTML to Markdown. My bookmarklet uses a RichText class that contains a text string...

    Nice explanation! I came up with a vaguely similar design for converting paragraphs that I want to quote from HTML to Markdown. My bookmarklet uses a RichText class that contains a text string that’s annotated by contiguous spans with marks. Since it works one paragraph at a time, handling multiple nodes like ProseMirror wasn’t needed.

    This is also how Bluesky represents rich text within a post. See here.

    Nit: I think there might be a typo in one of the mappings in the article? “1 → 0, 2 → 3, 3 → 2” seems wrong because it seems like the positions both before and after the mapping should be in order?

    1 vote
    1. smores
      Link Parent
      Thanks! And thanks for that Bluesky link, that is interesting. I think that's similar to how Swift represents rich text, as well. Oh, yup, you're right. That should be 2 -> 1, not 2 -> 3! Thanks...

      Thanks! And thanks for that Bluesky link, that is interesting. I think that's similar to how Swift represents rich text, as well.

      Oh, yup, you're right. That should be 2 -> 1, not 2 -> 3! Thanks for noticing, I'll update in a minute!