Multiple cursors between tabs/windows for same user

Hi there!

Very much a fan of yjs. I am building a collaborative, decentralized document editor and it’s working wonderfully. I am using an editor built with prosemirror, and i am using the webtrc provider. I’ve noticed that when I have the same document open between two tabs, there will be two instances of my same user.

Is there a reliable way to prevent this from happening?

Thanks!

Hi @aulneau,

From a Yjs perspective, every Yjs instance is a different user. In a lot of cases, you want to differentiate between sessions.

If you want to show a list of users, you could simply remove duplicates.

If you want to show only a single cursor location for each user, you could unset the cursors field when the tab is blurred (either if the editor is not active, or if the tab is not actively shown).

on('blur', () => {
  awareness.setLocalStateField('cursor', null)
})
1 Like