Skip to content

How to handle copy & paste when using a ReactNodeView with NodeViewContent #4831

Discussion options

You must be logged in to vote

For anyone who ends up here, I ended up solving it with the following,

parseHTML() {
    return [
      {
        tag: 'div[data-type="callout"]',
        getContent: (node, schema) => {
          // Convert HTML into TipTap JSON
          const json = generateJSON(
            (node as HTMLElement).getAttribute("html") || "",
            extensions
          )

          // Create a Fragment from the JSON content
          const fragment = Fragment.fromJSON(schema, json.content)

          // Return this Fragment as the Node contents
          return fragment
        },
      },
    ]
  },

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by thefinnomenon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant