fix: Various fixes for collaborative editing beta (#2586)
This commit is contained in:
@@ -2,18 +2,18 @@
|
||||
import Logger from "../logging/logger";
|
||||
export default class CollaborationLogger {
|
||||
async onCreateDocument(data: { documentName: string }) {
|
||||
Logger.info("collaboration", `Created document "${data.documentName}"`);
|
||||
Logger.info("hocuspocus", `Created document "${data.documentName}"`);
|
||||
}
|
||||
|
||||
async onConnect(data: { documentName: string }) {
|
||||
Logger.info("collaboration", `New connection to "${data.documentName}"`);
|
||||
Logger.info("hocuspocus", `New connection to "${data.documentName}"`);
|
||||
}
|
||||
|
||||
async onDisconnect(data: { documentName: string }) {
|
||||
Logger.info("collaboration", `Connection to "${data.documentName}" closed`);
|
||||
Logger.info("hocuspocus", `Connection to "${data.documentName}" closed`);
|
||||
}
|
||||
|
||||
async onUpgrade() {
|
||||
Logger.info("collaboration", "Upgrading connection");
|
||||
Logger.info("hocuspocus", "Upgrading connection");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,16 +29,13 @@ export default class Persistence {
|
||||
|
||||
if (document.state) {
|
||||
const ydoc = new Y.Doc();
|
||||
Logger.info(
|
||||
"collaboration",
|
||||
`Document ${documentId} is in database state`
|
||||
);
|
||||
Logger.info("database", `Document ${documentId} is in database state`);
|
||||
Y.applyUpdate(ydoc, document.state);
|
||||
return ydoc;
|
||||
}
|
||||
|
||||
Logger.info(
|
||||
"collaboration",
|
||||
"database",
|
||||
`Document ${documentId} is not in state, creating from markdown`
|
||||
);
|
||||
const ydoc = markdownToYDoc(document.text, fieldName);
|
||||
@@ -60,7 +57,7 @@ export default class Persistence {
|
||||
}) => {
|
||||
const [, documentId] = documentName.split(".");
|
||||
|
||||
Logger.info("collaboration", `Persisting ${documentId}`);
|
||||
Logger.info("database", `Persisting ${documentId}`);
|
||||
|
||||
await documentUpdater({
|
||||
documentId,
|
||||
|
||||
@@ -9,7 +9,7 @@ const isProduction = env.NODE_ENV === "production";
|
||||
|
||||
type LogCategory =
|
||||
| "lifecycle"
|
||||
| "collaboration"
|
||||
| "hocuspocus"
|
||||
| "http"
|
||||
| "commands"
|
||||
| "processor"
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
up: async (queryInterface, Sequelize) => {
|
||||
await queryInterface.addColumn("collections", "state", {
|
||||
type: Sequelize.BLOB,
|
||||
});
|
||||
},
|
||||
|
||||
down: async (queryInterface, Sequelize) => {
|
||||
await queryInterface.removeColumn("collections", "state");
|
||||
},
|
||||
};
|
||||
@@ -17,6 +17,7 @@ router.post("team.update", auth(), async (ctx) => {
|
||||
sharing,
|
||||
guestSignin,
|
||||
documentEmbeds,
|
||||
collaborativeEditing,
|
||||
} = ctx.body;
|
||||
const user = ctx.state.user;
|
||||
const team = await Team.findByPk(user.teamId);
|
||||
@@ -31,6 +32,9 @@ router.post("team.update", auth(), async (ctx) => {
|
||||
if (documentEmbeds !== undefined) team.documentEmbeds = documentEmbeds;
|
||||
if (guestSignin !== undefined) team.guestSignin = guestSignin;
|
||||
if (avatarUrl !== undefined) team.avatarUrl = avatarUrl;
|
||||
if (collaborativeEditing !== undefined) {
|
||||
team.collaborativeEditing = collaborativeEditing;
|
||||
}
|
||||
|
||||
const changes = team.changed();
|
||||
const data = {};
|
||||
|
||||
Reference in New Issue
Block a user