Collaboration - What's the advised way of extracting HTML server-side when saving to DB? #6112
Unanswered
ocostello
asked this question in
Questions & Help
Replies: 1 comment 1 reply
-
I assume you are using Hocuspocus as your YJS websocket backend. Convert the ydoc state to Tiptap JSON using the TiptapTransformer from the import { TiptapTransformer } from '@hocuspocus/transformer';
async onStoreDocument(data: onStoreDocumentPayload) {
const { documentName, document, context } = data;
const tiptapJson = TiptapTransformer.fromYdoc(document, 'default');
} Then pass your Tiptap extensions schema to the const html = generateHTML(tiptapJson, tiptapExtensions); |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Problem
We have a node.js websocket server running to maintain collaboration on-premise in our tiptap editor. When a user leaves the page we want to save the HTML content to a mongodb db but can't tell from the docs how you recommend us to extract this when all we have access to there is the ydoc.
Attempted fixes
There's a method in @tiptap/html -
getHTMLFromFragment
which seems useful but isn't exported, I've copied this code to try and get something working, which seems to operate fine on simple text content but fails whenever the editor contains a list/bullets.Code:
Error:
Summary
It seems like people would often want to be saving HTML content server-side and not have access to the editor instance, what is the standard practise for extracting the HTML (or JSON, seeing as @tiptap/html can convert from that)
Note
I have seen the docs below, but neither answer my usecase:
Beta Was this translation helpful? Give feedback.
All reactions