Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
    Zach Daniel
    I guess WebRTC is an option, unsure how to go about sending down the result of multiple clients collaborating over WebRTC to the server...
    Will Hawker
    morning all, I have a few outstanding PRs on y-prosemirror, is the repo still maintained? https://github.com/yjs/y-prosemirror/pulls/whawker
    kapil verma

    Hello! I'm having a bit of trouble understanding the actual usage pattern of yjs from a macro standpoint. I'm not using nodejs for my server, but I could theoeretically call out to a managed nodejs process from my backend server, something I've set up for SSR already. I already have websocket connections set up from my clients to my server. Is there some way that I could use yjs on the clients, managed from a non-js server without having to involve nodejs server side?

    @zachdaniel you can take a look at this repo https://github.com/kapv89/yjs-scalable-ws-backend and modify it to interact with an api instead of interacting directly with the db, and then have your actual api-backend in any language of your choice

    Does anyone know why observe would not trigger for a delete call on a YMap?
    Hi all. I was wondering if anyone was using TipTap and found a way around the duplicate text upon initialization issue. I found this yjs/yjs-demos#16 but unfortunately my only option is to read and write the content as HTML.
    2 replies

    That would be surprising to me too! The hard drive is an SSD. Does anyone else have any data on this?

    Related to this, I am using both y-websocket and y-indexeddb. The README says

    A module that contains a simple websocket backend and a websocket client that connects to that backend. The backend can be extended to persist updates in a leveldb database.
    Efficiently persists document updates to the browsers indexeddb database. The document is immediately available and only diffs need to be synced through the network provider.

    from which I concluded that y-indexeddb (which uses the local client) should sync faster than y-websocket (the websocket server is in Ireland and I am in England). But I always find that the websocket provider syncs first, by a few milliseconds. Why?

    The code looks like this (exactTime() yields the time now to the nearest millisecond):

        const doc = new Y.Doc();
        const persistence = new IndexeddbPersistence(room, doc);
        persistence.once('synced', () => {
            console.log(exactTime() + ' local content loaded');
        const wsProvider = new WebsocketProvider(websocket, 'prsm' + room, doc);
        wsProvider.on('sync', () => {
            console.log(exactTime() + ' remote content loaded');
        yNodesMap = doc.getMap('nodes');
        yEdgesMap = doc.getMap('edges');

    Example output:

    09:49:47:513  remote content loaded
    09:49:47:516  local content loaded

    I believe y-websocket implemented with a bug which did not wait both side exchange the initial vector, then sent out the initial empty data to client, then client thought it is "synced" but indeed the server side did not load the yjs doc from leveldb yet.

    Nigel Gilbert
    Interesting idea, but I checked by inserting a debug message inside wsProvider.on('sync', () => {, which confirmed that at the time of the sync event, the remote data had indeed been loaded.
    Hi I'd like to make a custom provider, but the docs seem unfinished. What should the interface be for a provider?
    Hi, is there an easy way to add access control to yjs documents? I.e. certain fields can be modified only by certain users, other users can only read them.
    Sudhanshu Gautam
    Hey, I am using yjs with quill over websockets. I noticed that yjs is ignoring the initial content from Quill and overwriting it with <p><br/></p>, anybody know how to get around this?
    1 reply
    Reyhan Sofian
    hi everyone. I'm using yjs for realtime dashboard using y-websocket. I've been hitting an issue whenever a client refreshes their page, the yjs server will send the last state before the page refresh. is there a way I can avoid this?
    Timo Ylikännö
    Hi all! How come y.js generates massive amount of events while synchronizing data? I'm using yarray and while another changes there are hundreds of observe events. All have same content.
    Hi all. How to delete all records of ydoc, and then write new records?
    Flávio Carvalho

    Hi, is there a way to delete a root type? Can't find a way to do it..

    Essentially the same as:

    const info = ydoc.getMap('info')
    const value = new Y.Array()
    value.insert(0, [1,2,3])
    info.set('foo', value)

    But using a root type:

    const foo = ydoc.getArray('info/foo')
    foo.insert(0, [1,2,3])
    // How to delete when I don't need this array anymore?
    Viktor Qvarfordt
    @ygnoh, did you find a good way for working with input or textarea?
    Jeffrey Schaefer
    hello all! can anyone tell me the idiomatic way to deep clone an xmlelement?
    Jeffrey Schaefer
    to clarify, i have tried using .clone, and reattaching to the current yjs doc, but i only find the top level element. i have tried this with yjs fragments as well and it does not seem to work (although the tests indicate it does, so i must be doing something wrong)
    hey folks, how can I implement (in Prosemirror) conditional rendering of text based on provided data, is there already some plugin doing that? Precisely did it very nicely, looking for something similar. if there is no plugin for that, how to approach it best? screenshot1 screenshoot2
    JS Console App
    Hi, am using codemirror and y-webrtc, the editor works fine with newly created document. But when editing an already saved document, the content gets duplicated double times, is there a way i can set initial data for the new document?
    Yonggoo Noh
    @ViktorQvarfordt NO :(
    Viktor Qvarfordt
    @ygnoh I have some updates for you here https://discuss.yjs.dev/t/yjs-redux-binding/755/2 :)
    Does anyone understand the example here https://docs.yjs.dev/api/shared-types/y.array? My problem is that there is no yarray.set but the example does this
    Hello all! I am using quill with y-websocket, and the backend is nestjs with ws library. Does anyone know if I need the room name of WebsocketProvider to be a document id, then how do I handle it with nestjs WebSocketGateway? Thank you!
    Janis Jendraß
    I have to thank you all for your work and this amazing library. Over the last weeks I've been busy creating a collaborative note graphing application which I plan to release as open source after I cleaned everything up and added the features I'd like to see. If you want to have a look at it, check it out at https://lity.cc It's still buggy and some features need to implemented but maybe your eyes of expertise could see some problems I might not have in mind yet. Thanks and have good time!
    kapil verma
    @justfo890 you'd probably be better off with a separate node.js server handling the y-websocket connections ... check out this repo https://github.com/kapv89/yjs-scalable-ws-backend .. you can easily switch the interaction with db using knex to interaction with an api
    1 reply
    Linh Nguyen
    Hi, I'm using yJS to make a collaborative application to create graphs/flowcharts and want to display different users' cursors with separate colors. I think yjs does offer bindings for text editors like Quill and Monaco but not sure if there is any built in tools that I can use for cursor tracking in collaborative graphing/drawing application? Thank you!
    2 replies
    Nigel Gilbert
    PRSM, a collaborative system mapping tool, has users' cursors with separate colours. You'll find the code for this at https://github.com/micrology/prsm/blob/master/js/prsm.js, line 3697 onwards. I hope it helps.
    1 reply
    Hi all, can someone point me to a current/good example of how to setup persistence on a server? I cant seem to find a recent oen
    Joshua Fontany
    Hi. Is there anything in the Yjs libraries that would allow me to generate a quill-delta-diff of two texts? I need it for my wiki-(editor)-binding.
    Namit Chadha
    @yarnball have you seen? https://github.com/yjs/y-redis
    Stefan de Konink

    I am completely new to Yjs (and to npm etc.) I notice when I try to install y-array and y-text those have dependency issues. Could not resolve dependency: peer yjs@">= 12.3.1 < 13.0.0" from y-array@10.1.4

    Is this a known issue?

    Namit Chadha
    @skinkie i think you just install 'yjs', does that not work?
    @nc I have seen that before, but I didnt know redis could/should be used as storage
    I was thinking more like something SQL right? This will be for large strings? Or is that not generally how it is used
    Will Heslam

    Hello everyone :)
    I've had some trouble getting the subdocs example code to work

    and I suspect it's due to this line:

    It is up to the providers to sync subdocuments.

    as I'm trying to manually sync the two root docs using
    Y.applyUpdateV2(rootDoc2, Y.encodeStateAsUpdateV2(rootDoc1))

    I'm assuming then that I need to use a fully fledged provider that can sync subdocuments properly.
    Looking at the provider list, there doesn't seem to be anything useful for local testing - some kind of in-memory provider (beyond the manual application of updates as in my example above). Is this something that exists, and what have people used instead?
    Would I have to implement it myself, similar to the code at the bottom of the subdocs docs page?
    e.g. doc.on('subdocs', ...
    Am I barking up the wrong tree here and overcomplicating it for myself?

    1 reply
    kapil verma

    Hi all, can someone point me to a current/good example of how to setup persistence on a server? I cant seem to find a recent oen

    @yarnball you can check out this repo - https://github.com/kapv89/yjs-scalable-ws-backend

    Hey all, I don't know if this will be helpful to anyone else but I've open sourced my version of y-websocket with subdocument support. I'll update the example server implementation to make use of the subdoc protocol I added later on but for now a working version is here: https://github.com/DAlperin/y-websocket/blob/master/src/y-websocket.js
    1 reply

    i'm curious if the benefits of the current way of encoding/decoding data (lib0) are significant enough to warrant the added cost in complexity and resistance to adoption in other languages?

    For example, readVarUint:

    numbers < 2^7 is stored in one bytlength
    numbers < 2^14 is stored in two bylength

    That pretty much eliminates using the standard buffer.readUInt8, for example, right?

    so in order for me to safety read the messageType, for example, I have to instantiate a decoder?
    why not just work with buffers, utilizing the standard methods? with something like https://github.com/feross/buffer for the browser?

    i'm trying to understand the reasoning and whether or not a port to go would be feasible.

    uint8 would be a bad example.

    Kevin Jahns

    There are few libraries that do variable-length encoding. buffer.readUint8 still uses 8 bytes for each integer. Furthermore, lib0/encoding also supports other types of efficient encoding and includes a library for RLE encoding. Node libraries are super bloated and have thousands of dependencies from questionable sources. And another thing: lib0 is much more performant than any other alternative. In some cases, lib0 is 1000x faster than alternatives.

    If you are interested in writing a Go binding for Yjs, then I recommend to have a look at the yjs/y-crdt project that already includes some language bindings to other languages. I recommend to join the next Y Community meeting if you have any questions.

    @dmonad thats fair, thank you for the response
    gotta say, you've done awesome work with yjs man.
    Kevin Jahns
    Thanks @chanced
    Philip Aarseth
    What is the best approach to clearing a yMap? seems there is no .clear() function so is looping through really the only alternative?
    @dmonad is it possible for you to export some functions from Item.js , specially redoItem, followRedone, findIndexCleanStart, splitItem. I tried importing them directly from src/internals but i realised I cant make it work since you have placed lots of instanceof Item checks on these functions. The item instances are different for a doc created from the.mjs file and providers and y-prosemirror depend on that mjs file as well, so creating Doc from 'internals.js' does not work. I have re-included the functions thatredoItem and followRedone depend on to fork out just the undomanager. And I dont want to fork yjs repo completely. So if you could export them, that would be great.
    Kevin Jahns
    @wanuj Exporting them means that I'd need to keep compatibility in future releases - and I can't guarantee that. Maybe you can import yjs/src/index instead (use a patch override in your module bundler)?
    @philipaarseth That is correct.