Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    ilovedesert001
    @ilovedesert001
    Yes, I'm implemented with YArray
    Jun-04-2021 20-17-20.gif
    ilovedesert001
    @ilovedesert001
    It seems there is no way to implement this with single integer. after synced , I need cumulative result
    Kevin Jahns
    @dmonad
    Counter CRDTs are super popular. However, I believe that in many cases, you want the replace semantics. If user1 incremented a counter to 4 - because they think that 4 is the correct number. And user2 also increments the counter to 4 (because that other user is making the same calculation), it might be confusing when the conter is incremented to 8 (for no apparent reason)
    ilovedesert001
    @ilovedesert001
    In some case , this might be very useful , like likes , query counters, update counters, etc.
    image.png
    Kevin Jahns
    @dmonad
    Yeah, there are definitely valid use-cases.
    Although, in that use-case, you definitely want to store who pressed the "like button". Otherwise, people could like the same post many times.
    So you also end-up with an array.
    I'm just saying that Y.Array and Y.Map should be preferred in a lot of cases. There are definitely valid use-cases.
    Will Bartlett
    @Bartlett-Will
    Hi All, I'm working with y-websocket right now, and i'm wondering if anyone has experience adding messages to the server. I want clients to be aware when someone adds another "room", so that an added room gets added to other connected clients. Initially I thought i could just use the same WebsocketProvider to wrap the other providers to sync the client state using custom message types. I've gotten started but i keep running into issues with the persistence layer and i feel stuck. Any ideas?
    Will Bartlett
    @Bartlett-Will

    Hi All, I'm working with y-websocket right now, and i'm wondering if anyone has experience adding messages to the server. I want clients to be aware when someone adds another "room", so that an added room gets added to other connected clients. Initially I thought i could just use the same WebsocketProvider to wrap the other providers to sync the client state using custom message types. I've gotten started but i keep running into issues with the persistence layer and i feel stuck. Any ideas?

    The issue is if i just send a regular message like Websocket.send("stateUpdate") the server crashes with an Index out of bounds error.

    Kevin Jahns
    @dmonad
    You can either implement your own protocol based on the binary protocol that Yjs uses (which is fairly complicated) or use subdocument which seem perfect for your usecase https://docs.yjs.dev/api/subdocuments ;)
    Will Bartlett
    @Bartlett-Will
    @dmonad thank you for the quick reply. I saw that in the documentation - but i was thinking it might be overkill. Something simple like the awareness CRDT makes more sense to me. I'm really just trying to maintain a list collaborative of docs, and if someone added a doc, then that gets propagated to everyone.... but now that i type that out it seems like exactly what subdocument documentation is describing haha
    Nigel Gilbert
    @micrology
    Suppose I have a Y.Map and have set up a Y.UndoManager to track updates to it. I now make a series of, for instance, 20 adds, deletes and updates to the Y.Map. Then I decide that I want to undo these most of these changes, back to, say, the 3rd change. I could do this by calling undoManager.undo 17 times, but is there any way to revert straight to the 3rd change (e.g. by saving a pointer to the undoManager state before each change)? The use case is that I want to give the user a menu of the last n changes, so that the user can revert straight back to a previous state, without having to unwind each action one at a time.
    ilovedesert001
    @ilovedesert001

    I'm just saying that Y.Array and Y.Map should be preferred in a lot of cases. There are definitely valid use-cases.

    Indeed , Y.Array is good for now

    Nick Odumo
    @nodumo
    I am working on a PubNub Connector for YJS.
    Where I am having trouble is that YJS , the "Official Connectors", and the Y protocol library making use of array buffers but, PubNub passes data as strings.
    How would you just working around this limitation?
    ilovedesert001
    @ilovedesert001
    you can convert buffer to base64 string ?
    like , interceptor , encode to base64 before data goes to PubNub ,
    after receiving data from PubNub , decode to Yjs's type structs ,
    Will Hawker
    @whawker
    I'm just playing around with YJS map, but I notice there is no clear method, (to empty the map completely) - Is that intentional, as it's not really a CRDT way of doing things?
    Kevin Jahns
    @dmonad
    Right. I just missed that. If you want you could add it in a PR.
    Will Hawker
    @whawker
    ok, would the approach be to use the underlying this._map.clear() method in a transaction? Or to forEach through the keys and delete all of them in a transaction
    Will Hawker
    @whawker
    went with the latter yjs/yjs#309
    Nick Odumo
    @nodumo
    @ilovedesert001 PERFECT
    I will give that a try
    Teemu Koivisto
    @TeemuKoivisto
    Hey @micrology I am actually wondering very similar thing. My use-case is a bit wider; a full track-changes functionality where you can select content and revert changes within that selection. Yet it definitely is not the easiest thing to do.. Even without Yjs using vanilla ProseMirror it requires some heavy lifting to be able to keep track of all changed things and revert them at will. Do Yjs changes have an invert() method, similar to PM steps? Ah now that I read your message more carefully, I see you are not seeking to pick a change and then invert only that one but apply the reset. Can you just generate snapshots after each change, map them to a change in undoHistory, and rollback to that state directly?
    Will Hawker
    @whawker

    Right. I just missed that. If you want you could add it in a PR.

    just curious when the next YJS release might be?

    Kevin Jahns
    @dmonad

    @micrology Sorry, i forgot to answer you. That would be possible. The UndoManager has a undo&redo stack that contains operations that already represent a range of changes (by default capturing all changes within 500ms, with a debounce after each change so that the "recording" stops when you stop typing). You could add a functionality to merge the operations and then hit undo once. You could also open a single transaction and undo 17-times using a helper method.

    @TeemuKoivisto I think you are asking whether it is possible to rewind specific operations - that also should be possible. You need to find the right operation, move it to the top of the stack and then undo that.

    The yjs.dev website contains a Google-Docs like track-changes feature for the Prosemirror editor. It is incomplete and I want to do a rewrite of the functionality. But even in the current state, it works really well. The downside is that it uses more memory than it should, which is the reason for the rewrite. But unless you are writing a book, you should be fine.

    Titanex
    @Titanexx

    Hi, I'm working to adapt a y-prosemirror with the new version of tui.editor. Is it possible to rebuild ydoc('prosemirror') before the editor view ?
    I have always this stacktrace :

    n._item is null
    absolutePositionToRelativePosition lib.js:96
    getRelativeSelection sync-plugin.js:172
    beforeAllTransactions sync-plugin.js:206
    emit observable.js:73
    emit observable.js:73
    transact Transaction.js:386
    toDelta YText.js:981

    I had try to do after it's working but after init, the view isn't sync with the ydoc.

    Kevin Jahns
    @dmonad
    Hi @Titanexx I need information to understand the problem you are facing. You are apparently using relative positions somehow and then the parse failed with the error you posted. Maybe you can post something on discuss.yjs.dev with steps to reproduce.
    Titanex
    @Titanexx
    Yep I will do that.
    Titanex
    @Titanexx
    I have found the guilty : the proxy wrapper added by vue3 reference. I have already create a post on dicuss if you want more info about it.
    The good new is that tui.editor3 is compatible with your work !
    Rishabh Malhotra
    @Rishabh-malhotraa
    Hey, can you add your name in provider.awareness for Monaco editor? If no can you tell me direct me to some example I can follow to manually try to implement it
    Nigel Gilbert
    @micrology

    In the present arrangement of my app, I have two yMaps. One (yMapA) stores objects keyed by their ids. The other (yMapB) stores metadata about the objects, including references to their ids, e.g. which of the objects is currently 'selected' by the user. This all works fine, except when a new client arrives and syncs with the others (using a WebSocketProvider). Mostly, yMapB loads first and then code in yMapB.observe tries to select the referenced objects in yMapA. However, yMapA has not yet been loaded and so this operation fails. Schematically, it looks like this (this is a minimal example simplified from the actual code):

    const doc = new Y.Doc();
    const wsProvider = new WebsocketProvider(websocket, room, doc);
    const yMapA = doc.getMap('A');
    const yMapB = doc.getMap('B');
    wsProvider.on('sync', () => {
            // do something
        }); 
    yMapA.observe((event) => {
        for (let key of event.keysChanged) {
            if (yMapA.has(key)) {
                let obj = yMapA.get(key)
                // add or update local copy  of obj
            }
            else {
                // delete local copy of obj
            }
    })
    yMapB.observe((event) => {
        for (let key of event.keysChanged) {
            let selection = yMapB.get(key);
            selection.forEach((id) => {
                // find object with id
                // mark it as selected
            }
        }
    })

    How should I rewrite this to avoid the problem?

    Nick Odumo
    @nodumo
    Can I get a review of my PubNub Provider.
    I took the copied most of the YDoc WebSocket provider and then modified it to send protocol data as Base64 updates.
    Link to a gist with the code:
    https://gist.github.com/nodumo/75a0fa4a834930e0130cb475568de441
    Kevin Jahns
    @dmonad

    The good new is that tui.editor3 is compatible with your work !

    Sweet :)

    @Rishabh-malhotraa Yes, it's described in the awareness tutorial in docs.yjs.dev. It works the same as the codemirror editor.
    Kevin Jahns
    @dmonad
    @micrology That seems a bit off. When you sync with a server, you should receive all content at once. So both maps should be populated.
    1 reply
    Will Hawker
    @whawker
    just created a PoC with Yjs (via WebRTC), would love any and all feedback https://discuss.yjs.dev/t/prosemirror-yjs-y-webrtc-in-a-serverless-architecture-poc/572
    Jeremy Dombrowski
    @meatflavourdev
    2021-06-15_06-59-07.mkv_snapshot_00.43.115.jpg
    So... you like collab sh*t, eh?
    Jeremy Dombrowski
    @meatflavourdev
    image.png
    just doin some promotion, lol
    Rishabh Malhotra
    @Rishabh-malhotraa

    @Rishabh-malhotraa Yes, it's described in the awareness tutorial in docs.yjs.dev. It works the same as the codemirror editor.

    To what I understand after reading the docs, you have to just edit a portion for y-monaco adapter and I can take the code-mirror adapter as a reference, right?

    Raviteja Lingineni
    @rlingineni
    I was wondering if there were any exposed methods to use yjs kind of like sockets? For example, I want to mark that a button was pressed by all users
    Should I set a key called numClicks on the "awareness" object, and use 'change' event to capture changes
    or is there a better way I can go about it?
    ilovedesert001
    @ilovedesert001
    ERR_DATA_CHANNEL
    Has anyone encountered this error while using webRTC ?
    image.png