feat: realtime & auto sync for all users (#944)

This commit is contained in:
Ammar Ahmed
2022-09-20 18:33:55 +05:00
committed by GitHub
parent 0774326941
commit e5e965415d
24 changed files with 337 additions and 88 deletions

View File

@@ -109,6 +109,18 @@ export function useEditorController(update: () => void): EditorController {
const value = message.value;
global.sessionId = message.sessionId;
switch (type) {
case "native:updatehtml": {
htmlContentRef.current = value;
if (!editor) break;
const { from, to } = editor.state.selection;
editor?.commands.setContent(htmlContentRef.current, false);
editor.commands.setTextSelection({
from,
to
});
break;
}
case "native:html":
htmlContentRef.current = value;
update();