Yjs Docs
  • Introduction
  • Yjs in the Wild
  • License ❤️
  • 🚲Getting Started
    • A Collaborative Editor
    • Awareness & Presence
    • Offline Support
    • Shared Types
  • 🔥Ecosystem
    • Editor Bindings
      • ProseMirror
      • TipTap
      • Monaco
      • Quill
      • CodeMirror
      • Remirror
      • Milkdown
      • Slate
    • Connection Provider
      • y-websocket
      • y-webrtc
      • y-webxdc
      • y-dat
      • y-sweet
      • Liveblocks
      • SuperViz
    • Database Provider
      • y-indexeddb
      • y-leveldb
      • y-redis
    • Other
      • y-protocols
    • Ports to other languages
  • 🔧API
    • Y.Doc
    • Shared Types
      • Y.Map
      • Y.Array
      • Y.Text
      • Y.XmlFragment
      • Y.XmlElement
      • Y.XmlText
    • Y.UndoManager
    • Y.Event
    • Delta Format
    • Document Updates
    • Y.RelativePosition
    • Awareness
    • Subdocuments
    • Internals
    • FAQ
  • 🧪Tutorials
    • Meshing Providers
    • Persisting the Document to a Central Database
    • Indefinite Scaling with y-redis
    • Lessons Learned
    • Custom Provider
  • 🌎External Resources
    • Talks, Podcasts, and Blogs
    • About CRDTs
    • CRDT Benchmarks
    • Yjs Discussion Board
    • Yjs Chat
    • Kevin's Blog
    • Awesome People ⭐
Powered by GitBook
On this page

Was this helpful?

Edit on Git
  1. Ecosystem
  2. Editor Bindings

Monaco

PreviousTipTapNextQuill

Last updated 4 years ago

Was this helpful?

is the editor that powers VS Code. The extension makes it collaborative.

Setup

import * as Y from 'yjs'
import { WebrtcProvider } from 'y-webrtc'
import { MonacoBinding } from 'y-monaco'

const ydoc = new Y.Doc()
const provider = new WebrtcProvider('monaco', ydoc)
const type = ydoc.getText('monaco')

// There are some steps missing to initialize the editor
// The editor requires a webpack build-step
// See the complete example:
//   https://github.com/yjs/yjs-demos/blob/master/monaco/monaco.js
const editor = monaco.editor.create(
  document.getElementById('monaco-editor'),
  {
    value: '',
    language: 'javascript',
    theme: 'vs-dark'
  }
)
const monacoBinding = new MonacoBinding(
  type,
  editor.getModel(),
  new Set([editor]),
  provider.awareness
)
npm i monaco-editor yjs y-monaco

Live Demo

Unfortunately, we can't show a live-code example on this website because the editor requires a build-step that online-IDEs don't support. Maybe you can give it a try? Anyway, we still have a live demo available on a different website (simply open it in two different tabs).

Demo Code

The repository contains several demos. Simply download the repository you are interested in (e.g. the monaco folder) and run npm install && npm start to run the demo.

🔥
yjs-demos
Monaco
y-monaco
GitHub - yjs/y-monaco: Monaco editor bindings for YjsGitHub
Monaco Editor
Yjs Monaco Example
Live Demo of the y-monaco editor binding
Logo
yjs-demos/monaco at main · yjs/yjs-demosGitHub
Logo