Discussions related to Shared Editing, Distributed Apps, and Yjs. Questions about Yjs should go to discuss.yjs.dev. Bug reports to the issue tracker.
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.
if I specify an origin for a Y.doc.transact, e.g.
const ydoc = new Y.Doc();
const ymap = ydoc.getMap('mymap');
ydoc.transact(() => {ymap.set('foo', 'bar')}, 'myOrigin')
and, using a WebSocket provider, use ymap.observe(event)
on another client, the value of event.transaction.origin
is not the expected myOrigin
, but WebsocketProvider {....}
. How can I get the origin I provided to ydoc.transact
to appear in the second client as the origin of the transaction?
Hi @micrology, if the update message from the first client is received by the second client, then the y-websocket provider will apply the message to the document. Hence, the origin is the provider. The transaction-origin concept only works locally. It is useful to determine where a change comes from so you can filter specific changes depending on where they come from (e.g. when implementing a 2-way binding).
@compwiz737:matrix.org you could implement something like this using the y-websocket server and an undo-manager (track and revert the changes that you want to undo). The authorative y-websocket server could also just filter messages if a client has only read-only access to a document.
@ellern you could look up how to install a typescript extension to webpack (maybe a babel plugin, but other people probably have better advice as I'm also not using webpack).
Hi @dmonad Yes, I concluded that the origin is always the provider and cannot be reassigned. But I am still keen to label a transaction with the client that originated it. I note that the transaction object has a meta field, which is a map, but it doesn't seem to be possible for a client to set the map (am I right?). Can you think of any other way of labelling a transaction with the originating client, such that the originating client Id would be visible to peers that observe the transaction?
That's not possible unformutately, as changes from multiple clients are often bundled. Then you could use something like the versioning approach that allows you to store which user created which content.
y-protocols
instead?
Hello everyone :)
I've just started with yjs and have found it amazing! I'm particularly interested in the subdocuments feature, but i'm facing some issues with the example in the docs (https://docs.yjs.dev/api/subdocuments) - it doesn't seem to be working right.
Here's what the docs say
A new feature that was introduced in Yjs@13.4.0 is that all documents are given a GUID. The documents are identified with GUIDs and used as a room-name to sync documents. This allows you to duplicate data in the document structure.
Here's some sample code:
const rootDoc = new Y.Doc();const doc = new Y.Doc(); doc.getMap().set("data", "some initial data");
rootDoc.getMap().set("file.txt", doc);
const copy = new Y.Doc({ guid: doc.guid });
rootDoc.getMap().set("copy.txt", copy);
console.log(copy.getMap().get("data"));
console.log(doc.getMap().get("data"));
Here's the output:
undefined
some initial data
Shouldn't the output be the same? Or did I miss something here? Any help is appreciated! Thank you.
i have built an application in which users can create diagrams for a specific domain, and work on them collaboratively. This application uses yjs + y-websocket for this. Awareness is used heavily for different features.
I want to build a feature where a diagram can be made accessible publically, but everyone viewing the diagram loads a local copy of the diagram and can interact with it.
I want to re-use the core engine which is used by the diagram editor, and load the yDoc in it. The problem is that awareness is used to keep track of collaborator cursor, object drags, object highlights and so on.
I want an awareness implementation that operates locally. Is there some way to make this work?
i have built an application in which users can create diagrams for a specific domain, and work on them collaboratively. This application uses yjs + y-websocket for this. Awareness is used heavily for different features.
I want to build a feature where a diagram can be made accessible publically, but everyone viewing the diagram loads a local copy of the diagram and can interact with it.
I want to re-use the core engine which is used by the diagram editor, and load the yDoc in it. The problem is that awareness is used to keep track of collaborator cursor, object drags, object highlights and so on.
I want an awareness implementation that operates locally. Is there some way to make this work?
by the way I managed to do this by building a local-awareness-provider :)
js/prsm.js
)
webrtc
provider btw, can't find much info on its events