Adds content column to documents and revisions as JSON snapshot (#6179)
This commit is contained in:
@@ -41,7 +41,8 @@ export default async function documentCollaborativeUpdater({
|
||||
});
|
||||
|
||||
const state = Y.encodeStateAsUpdate(ydoc);
|
||||
const node = Node.fromJSON(schema, yDocToProsemirrorJSON(ydoc, "default"));
|
||||
const content = yDocToProsemirrorJSON(ydoc, "default");
|
||||
const node = Node.fromJSON(schema, content);
|
||||
const text = serializer.serialize(node, undefined);
|
||||
const isUnchanged = document.text === text;
|
||||
const lastModifiedById = userId ?? document.lastModifiedById;
|
||||
@@ -63,6 +64,7 @@ export default async function documentCollaborativeUpdater({
|
||||
await document.update(
|
||||
{
|
||||
text,
|
||||
content,
|
||||
state: Buffer.from(state),
|
||||
lastModifiedById,
|
||||
collaboratorIds,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Transaction } from "sequelize";
|
||||
import { Optional } from "utility-types";
|
||||
import { Document, Event, User } from "@server/models";
|
||||
import DocumentHelper from "@server/models/helpers/DocumentHelper";
|
||||
import TextHelper from "@server/models/helpers/TextHelper";
|
||||
|
||||
type Props = Optional<
|
||||
Pick<
|
||||
@@ -90,12 +90,12 @@ export default async function documentCreator({
|
||||
sourceMetadata,
|
||||
fullWidth: templateDocument ? templateDocument.fullWidth : fullWidth,
|
||||
emoji: templateDocument ? templateDocument.emoji : emoji,
|
||||
title: DocumentHelper.replaceTemplateVariables(
|
||||
title: TextHelper.replaceTemplateVariables(
|
||||
templateDocument ? templateDocument.title : title,
|
||||
user
|
||||
),
|
||||
text: await DocumentHelper.replaceImagesWithAttachments(
|
||||
DocumentHelper.replaceTemplateVariables(
|
||||
text: await TextHelper.replaceImagesWithAttachments(
|
||||
TextHelper.replaceTemplateVariables(
|
||||
templateDocument ? templateDocument.text : text,
|
||||
user
|
||||
),
|
||||
|
||||
@@ -10,8 +10,8 @@ import parseTitle from "@shared/utils/parseTitle";
|
||||
import { DocumentValidation } from "@shared/validations";
|
||||
import { traceFunction } from "@server/logging/tracing";
|
||||
import { User } from "@server/models";
|
||||
import DocumentHelper from "@server/models/helpers/DocumentHelper";
|
||||
import ProsemirrorHelper from "@server/models/helpers/ProsemirrorHelper";
|
||||
import TextHelper from "@server/models/helpers/TextHelper";
|
||||
import turndownService from "@server/utils/turndown";
|
||||
import { FileImportError, InvalidRequestError } from "../errors";
|
||||
|
||||
@@ -203,7 +203,7 @@ async function documentImporter({
|
||||
// to match our hardbreak parser.
|
||||
text = text.trim().replace(/<br>/gi, "\\n");
|
||||
|
||||
text = await DocumentHelper.replaceImagesWithAttachments(
|
||||
text = await TextHelper.replaceImagesWithAttachments(
|
||||
text,
|
||||
user,
|
||||
ip,
|
||||
|
||||
Reference in New Issue
Block a user