Skip to content

Create function for transforming JSON state to text representation #1428

@vpontis

Description

@vpontis

The problem I am facing
I let my users send newsletters to their audience (think Substack).

We store their custom rich text body as JSON and then when we want to send the email, we need to convert the message into HTML and text.

The solution I would like
I would like a function generateText that converts a JSON state to text.

This could be done in two ways:

  • the function generateText looks at nodes and converts them to text
  • we add a toText option on every Node / Mark in the schema and call that in order to convert a node to text

Alternatives I have considered

I am not using TipTap yet, but I wrote my own wrapper around ProseMirror and created this file to serialize our JSON state to HTML / text — https://gist.github.com/vpontis/e5e373ea9950b413c18c867a5aedf352

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions