-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed yjs. need an express server to handle the websocket connectio…
…n for it to work properly
- Loading branch information
Eivind Fasting
committed
Jun 29, 2024
1 parent
cb5a541
commit bdceb34
Showing
2 changed files
with
20 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import * as Y from 'yjs' | ||
import { WebsocketProvider } from 'y-websocket' | ||
import { MonacoBinding } from 'y-monaco' | ||
import * as monaco from 'monaco-editor' | ||
|
||
export async function setupYjs(editorInstance: monaco.editor.IStandaloneCodeEditor, initialCode: string): Promise<void> { | ||
const ydocument = new Y.Doc() | ||
const provider = new WebsocketProvider( | ||
"ws://127.0.0.1:1234", | ||
"monaco", | ||
ydocument | ||
); | ||
|
||
const ytext = ydocument.getText('monaco'); | ||
//ytext.insert(0, initialCode); | ||
// Bind Yjs to the editor model | ||
new MonacoBinding(ytext, editorInstance.getModel(), new Set([editorInstance]), provider.awareness); | ||
} |