fix: Various fixes for collaborative editing beta (#2586)

This commit is contained in:
Tom Moor
2021-09-15 23:27:22 -07:00
committed by GitHub
parent cde2909296
commit 27736f66ef
7 changed files with 30 additions and 16 deletions

View File

@ -150,7 +150,7 @@
"react-window": "^1.8.6", "react-window": "^1.8.6",
"reakit": "^1.3.8", "reakit": "^1.3.8",
"regenerator-runtime": "^0.13.7", "regenerator-runtime": "^0.13.7",
"rich-markdown-editor": "^11.17.6", "rich-markdown-editor": "^11.17.7",
"semver": "^7.3.2", "semver": "^7.3.2",
"sequelize": "^6.3.4", "sequelize": "^6.3.4",
"sequelize-cli": "^6.2.0", "sequelize-cli": "^6.2.0",

View File

@ -2,18 +2,18 @@
import Logger from "../logging/logger"; import Logger from "../logging/logger";
export default class CollaborationLogger { export default class CollaborationLogger {
async onCreateDocument(data: { documentName: string }) { async onCreateDocument(data: { documentName: string }) {
Logger.info("collaboration", `Created document "${data.documentName}"`); Logger.info("hocuspocus", `Created document "${data.documentName}"`);
} }
async onConnect(data: { documentName: string }) { 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 }) { async onDisconnect(data: { documentName: string }) {
Logger.info("collaboration", `Connection to "${data.documentName}" closed`); Logger.info("hocuspocus", `Connection to "${data.documentName}" closed`);
} }
async onUpgrade() { async onUpgrade() {
Logger.info("collaboration", "Upgrading connection"); Logger.info("hocuspocus", "Upgrading connection");
} }
} }

View File

@ -29,16 +29,13 @@ export default class Persistence {
if (document.state) { if (document.state) {
const ydoc = new Y.Doc(); const ydoc = new Y.Doc();
Logger.info( Logger.info("database", `Document ${documentId} is in database state`);
"collaboration",
`Document ${documentId} is in database state`
);
Y.applyUpdate(ydoc, document.state); Y.applyUpdate(ydoc, document.state);
return ydoc; return ydoc;
} }
Logger.info( Logger.info(
"collaboration", "database",
`Document ${documentId} is not in state, creating from markdown` `Document ${documentId} is not in state, creating from markdown`
); );
const ydoc = markdownToYDoc(document.text, fieldName); const ydoc = markdownToYDoc(document.text, fieldName);
@ -60,7 +57,7 @@ export default class Persistence {
}) => { }) => {
const [, documentId] = documentName.split("."); const [, documentId] = documentName.split(".");
Logger.info("collaboration", `Persisting ${documentId}`); Logger.info("database", `Persisting ${documentId}`);
await documentUpdater({ await documentUpdater({
documentId, documentId,

View File

@ -9,7 +9,7 @@ const isProduction = env.NODE_ENV === "production";
type LogCategory = type LogCategory =
| "lifecycle" | "lifecycle"
| "collaboration" | "hocuspocus"
| "http" | "http"
| "commands" | "commands"
| "processor" | "processor"

View File

@ -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");
},
};

View File

@ -17,6 +17,7 @@ router.post("team.update", auth(), async (ctx) => {
sharing, sharing,
guestSignin, guestSignin,
documentEmbeds, documentEmbeds,
collaborativeEditing,
} = ctx.body; } = ctx.body;
const user = ctx.state.user; const user = ctx.state.user;
const team = await Team.findByPk(user.teamId); 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 (documentEmbeds !== undefined) team.documentEmbeds = documentEmbeds;
if (guestSignin !== undefined) team.guestSignin = guestSignin; if (guestSignin !== undefined) team.guestSignin = guestSignin;
if (avatarUrl !== undefined) team.avatarUrl = avatarUrl; if (avatarUrl !== undefined) team.avatarUrl = avatarUrl;
if (collaborativeEditing !== undefined) {
team.collaborativeEditing = collaborativeEditing;
}
const changes = team.changed(); const changes = team.changed();
const data = {}; const data = {};

View File

@ -12482,10 +12482,10 @@ retry-as-promised@^3.2.0:
dependencies: dependencies:
any-promise "^1.3.0" any-promise "^1.3.0"
rich-markdown-editor@^11.17.6: rich-markdown-editor@^11.17.7:
version "11.17.6" version "11.17.7"
resolved "https://registry.yarnpkg.com/rich-markdown-editor/-/rich-markdown-editor-11.17.6.tgz#c524ba03a3e331105c5e2a927e6359efd034295c" resolved "https://registry.yarnpkg.com/rich-markdown-editor/-/rich-markdown-editor-11.17.7.tgz#833b9532812a361a9cf4f7752e4e75c6b4bff9e4"
integrity sha512-lZ6gZ+C10SclOM28m1b6rElBoaylpkifGc7KJfd+rOqyFsFu1kX3RMCm2R8X2keVjTz3d0zhZ3eHNvoOaICXoQ== integrity sha512-SFIMDz8xOrasOMeMiPyFShlldd3ta1TsIe9F4M3Gkej9UxGDsjBUbKux8NGEssZrxgYNxIh9GMYgM3+IJv+/1g==
dependencies: dependencies:
copy-to-clipboard "^3.0.8" copy-to-clipboard "^3.0.8"
lodash "^4.17.11" lodash "^4.17.11"