JSON to client (#5553)

This commit is contained in:
Tom Moor
2024-05-24 08:29:00 -04:00
committed by GitHub
parent e1e8257df7
commit d51267b8bc
71 changed files with 651 additions and 378 deletions

View File

@@ -2,6 +2,7 @@ import "./bootstrap";
import { yDocToProsemirrorJSON } from "@getoutline/y-prosemirror";
import { Node } from "prosemirror-model";
import * as Y from "yjs";
import { ProsemirrorData } from "@shared/types";
import { parser, schema } from "@server/editor";
import { Document } from "@server/models";
@@ -31,7 +32,10 @@ export default async function main(exit = false) {
if ("state" in document && document.state) {
const ydoc = new Y.Doc();
Y.applyUpdate(ydoc, document.state);
document.content = yDocToProsemirrorJSON(ydoc, "default");
document.content = yDocToProsemirrorJSON(
ydoc,
"default"
) as ProsemirrorData;
} else {
const node = parser.parse(document.text) || Node.fromJSON(schema, {});
document.content = node.toJSON();