Skip to content

Commit

Permalink
Merge pull request #4150 from systeminit/fix-web-Remove-the-Multiplay…
Browse files Browse the repository at this point in the history
…er-CodeEditor

fix(web): Remove the Multiplayer CodeEditor
  • Loading branch information
stack72 authored Jul 15, 2024
2 parents 10a9278 + b3db800 commit 3072064
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions app/web/src/components/CodeEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ import beautify from "js-beautify";
import * as Y from "yjs";
import { WebsocketProvider } from "y-websocket";
// import { IndexeddbPersistence } from "y-indexeddb";
import { yCollab, yUndoManagerKeymap } from "yjs-codemirror-plugin";
import { yUndoManagerKeymap } from "yjs-codemirror-plugin";
import { useAuthStore } from "@/store/auth.store";
import { useChangeSetsStore } from "@/store/change_sets.store";
import { API_WS_URL } from "@/store/apis";
import { usePresenceStore } from "@/store/presence.store";
// import { API_WS_URL } from "@/store/apis";
// import { usePresenceStore } from "@/store/presence.store";
import {
createTypescriptSource,
GetTooltipFromPos,
Expand Down Expand Up @@ -146,7 +146,7 @@ const styleExtensionCompartment = new Compartment();
const vimCompartment = new Compartment();
const hoverTooltipCompartment = new Compartment();
const removeTooltipOnUpdateCompartment = new Compartment();
const yCompartment = new Compartment();
// const yCompartment = new Compartment();
// Theme / style ///////////////////////////////////////////////////////////////////////////////////////////
const { theme: appTheme } = useTheme();
Expand Down Expand Up @@ -266,16 +266,16 @@ const codeTooltip = {
},
};
const presenceStore = usePresenceStore();
// const presenceStore = usePresenceStore();
function getUserInfo(userId: { id: string }) {
const user = presenceStore.usersById[userId.id];
return {
name: user?.name,
colorLight: user?.color ? `${user.color}30` : undefined,
color: user?.color || undefined,
};
}
// function getUserInfo(userId: { id: string }) {
// const user = presenceStore.usersById[userId.id];
// return {
// name: user?.name,
// colorLight: user?.color ? `${user.color}30` : undefined,
// color: user?.color || undefined,
// };
// }
let wsProvider: WebsocketProvider | undefined;
let yText: Y.Text | undefined;
Expand Down Expand Up @@ -376,27 +376,27 @@ const mountEditor = async () => {
// https://github.com/yjs/y-codemirror.next/issues/8
// https://github.com/yjs/y-codemirror.next/pull/17
const id = `${changeSetsStore.selectedChangeSetId}-${props.id}`;
// const id = `${changeSetsStore.selectedChangeSetId}-${props.id}`;
// const _storageProvider = new IndexeddbPersistence(id, ydoc);
wsProvider?.destroy();
wsProvider = new WebsocketProvider(
`${API_WS_URL}/crdt?token=Bearer+${authStore.selectedWorkspaceToken}&id=${id}`,
id,
ydoc,
);
wsProvider.awareness.setLocalStateField("user", {
id: authStore.user?.pk,
});
// wsProvider?.destroy();
// wsProvider = new WebsocketProvider(
// `${API_WS_URL}/crdt?token=Bearer+${authStore.selectedWorkspaceToken}&id=${id}`,
// id,
// ydoc,
// );
// wsProvider.awareness.setLocalStateField("user", {
// id: authStore.user?.pk,
// });
extensions.push(keymap.of([...yUndoManagerKeymap]));
// const undoManager = new Y.UndoManager(yText);
extensions.push(
yCompartment.of(yCollab(yText, wsProvider.awareness, { getUserInfo })), // , { undoManager })),
);
// extensions.push(
// yCompartment.of(yCollab(yText, wsProvider.awareness, { getUserInfo })), // , { undoManager })),
// );
yText.delete(0, yText.length);
yText.insert(0, props.modelValue);
Expand Down

0 comments on commit 3072064

Please sign in to comment.