benjie-git / y-ace

Ace Editor binding for Yjs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

y-ace

Initial example of Ace Editor binding for Yjs v13.4+
Huge thanks to Federico Lorenzi of room.sh for insight on binding Ace with an early 13.0 version of Yjs and Kevin Jahns for the powerful Yjs project!

This binding maps a Y.Text to an Ace instance. It supports syncing of cursors and selection.
Built upon y-quill, with tests currently disabled.

Example

import * as Y from 'yjs'
import { WebrtcProvider } from 'y-webrtc'
import { AceBinding } from 'y-ace'
import Ace from 'ace-builds/src-noconflict/ace'

window.addEventListener('load', () => {
  const ydoc = new Y.Doc()
  const provider = new WebrtcProvider('yjs-ace', ydoc)

  const type = ydoc.getText('ace')
  
  // init Ace
  var editor = Ace.edit('editor')

  // init binding
  const binding = new AceBinding(type, editor, provider.awareness)

Clone/download this repo and run npm install followed by npm run demo for working demo.

License

The MIT License © Kevin Jahns

About

Ace Editor binding for Yjs

License:MIT License


Languages

Language:JavaScript 99.1%Language:HTML 0.9%