Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Rhys Brett-Bowen
    @rhysbrettbowen
    @kapv89 Yep - that's what I was imagining. You could have a YGraph type that was made up of a nodes and edges map that would handle the changes. That would be preferable because if you look at the connector it fires when there are changes to the map. The issue there is that you would still fire the change and it would be picked up by the app that there was an orphaned edge so you would need to instead do the check on the edge before firing off those events. It's all do-able. Could also extract out a tabular data type which allows for columns/rows to be added/removed using similar logic. I think wrapping this logic in as types is probably the way to go. Still in exploration stage but if I get around to writing these I'll make sure to push back upstream
    Rhys Brett-Bowen
    @rhysbrettbowen
    On a different note - how sure are we about undo/redo in y.js? I know it was flawed in quilljs for a while but should have been fixed a couple of years ago: quilljs/quill#2500. When I go to the quill editor on https://docs.yjs.dev/getting-started/a-collaborative-editor I put in "ac" in the top, then in the 2nd one I add "b" int he middle. Then I got back to the first and undo. So far so good. Then redo... "acb".... not quite right though not the worst. However it gets worse if you keep undoing/redoing.
    Namit Chadha
    @nc
    hello has anyone tried writing a yjs connection provider for ... firebase! ?
    ah found this -> yjs/yjs#189
    Namit Chadha
    @nc
    and it works with firebase, pretty easy to setup. if anyone has questions can share
    separately if i have a queue of updates and want to flatten them to save space is there an easy way? and does that then become a snapshot other changes are based off of?
    Sean Zellmer
    @lejeunerenard

    Hey everyone! I have two Yjs docs connected via the webrtc provider sharing a Map type. When I set a property foo on device A, device B updates perfectly. However when I set foo on device B now, it is deleted on A (as shown by my observe event on the Map and the update on the doc). Note the order of changing foo on A & B doesn't make a difference.

    I have tried creating a simple example script but never can reproduce the desync. Any suggestions on how to debug how the two docs get out of sync? Are there any common scenarios that can cause this?

    Sean Zellmer
    @lejeunerenard
    Also note that the first change to foo is an add action according to the observer event's changes. basically whichever device sets it first is the only one that works.
    songispm
    @songispm
    image.png
    I need the source code about Drawing, where can i find it ?
    songispm
    @songispm
    image.png
    what different of these types
    kapil verma
    @kapv89

    separately if i have a queue of updates and want to flatten them to save space is there an easy way? and does that then become a snapshot other changes are based off of?

    @nc the way y-leveldb persistence does it is by merging the updates queue into a single update when fetching the updates from the db. I use the same mechanism in my relational db backed y-websocket backend https://github.com/kapv89/yjs-scalable-ws-backend/blob/main/src/setupWSConnection.ts#L133-L156

    3 replies
    songispm
    @songispm
    image.png
    my data is a JSON tree, what YType should I use ?
    Will Heslam
    @willheslam
    This message was deleted
    Will Heslam
    @willheslam

    Hi Everyone, I've been playing around with yjs and enjoying it so far :)

    I've found that a nested text inside a map behaves differently to a top level text, which is surprising to me.
    Here's the behaviour with two top level texts:

    aText current state aaaaaa
    bText current state bbbbbb
    insert into aText 'AAA" at 2
    insert into bText 'BBB' at 2
    apply updates to both
    adoc latest state bbBBBbbbbaaAAAaaaa
    bdoc latest state bbBBBbbbbaaAAAaaaa

    This makes sense to me - both texts end up with the combined inserts.

    Whereas with a nested text inside a map:

    aMap current state { 'my nested text': 'aaaaaa' }
    bMap current state { 'my nested text': 'bbbbbb' }
    insert into a nested text 'AAA" at 2
    insert into b nested text 'BBB' at 2
    apply updates to both
    aMap latest state { 'my nested text': 'bbBBBbbbb' }
    bMap latest state { 'my nested text': 'bbBBBbbbb' }

    They randomly converge on either the text from A, or B, instead of including the changes from both.

    This makes me feel like I've incorrectly set up my nested text inside my map. Happy to show my code, but I wanted to check as I couldn't find any conclusive statements in the docs beyond my intuition - the nested text state in my second example should end up looking just like the top level text in my first example, right? (otherwise there'd be little point nesting shared types)
    I used the docs for Y.Text that has an example of a nested text for my inspiration, but the docs don't actually show it being updated and being propagated across multiple document instances
    https://docs.yjs.dev/api/shared-types/y.text
    Are there any other examples of nested text in the docs or demos?

    Thanks :)

    Will Heslam
    @willheslam

    I've found that a nested text inside a map behaves differently to a top level text, which is surprising to me.
    Here's the behaviour with two top level texts:

    I solved my problem - it turns out that creating two Texts separately under the same key are treated as completely separate things - the key is not their identity, they are. The only safe way to collaboratively edit the same text is to create it on one document, and replicate it to the others by sending state as an update, then editing it afterwards!

    Thanks, that makes a lot of sense and is something I'll bear in mind for the future!

    Zach Daniel
    @zachdaniel
    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?
    Zach Daniel
    @zachdaniel
    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
    @whawker
    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
    @kapv89

    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

    jessiesanford
    @jessiesanford
    Does anyone know why observe would not trigger for a delete call on a YMap?
    seb001
    @seb001:matrix.org
    [m]
    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
    Ulion
    @ulion

    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

    y-websocket
    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.
    y-indexeddb
    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
    @micrology
    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.
    CRIMX
    @crimx
    Hi I'd like to make a custom provider, but the docs seem unfinished. What should the interface be for a provider?
    Mezriss
    @Mezriss
    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
    @sudhanshu16
    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
    @reyhansofian
    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ö
    @tianyl
    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.
    war1644
    @war1644
    Hi all. How to delete all records of ydoc, and then write new records?
    Flávio Carvalho
    @flaviouk

    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)
    info.delete('foo')

    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
    @ViktorQvarfordt
    @ygnoh, did you find a good way for working with input or textarea?
    Jeffrey Schaefer
    @schwayne:matrix.org
    [m]
    hello all! can anyone tell me the idiomatic way to deep clone an xmlelement?
    Jeffrey Schaefer
    @jephree
    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)
    marek-baranowski
    @marek-baranowski
    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
    @jsconsole-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
    @ygnoh
    @ViktorQvarfordt NO :(
    Viktor Qvarfordt
    @ViktorQvarfordt
    @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
    justfo890
    @justfo890
    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ß
    @rgby_gitlab
    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!
    justfo890
    @justfo890
    kapil verma
    @kapv89
    @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
    @LinhNguyen28
    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
    @micrology
    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
    YarnBall
    @yarnball
    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
    @joshuafontany
    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
    @nc
    @yarnball have you seen? https://github.com/yjs/y-redis