Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions src/plugins/cursor-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,27 +241,26 @@ export const yCursorPlugin = (
head
})
}
} else if (
current.cursor != null &&
relativePositionToAbsolutePosition(
ystate.doc,
ystate.type,
Y.createRelativePositionFromJSON(current.cursor.anchor),
ystate.binding.mapping
) !== null
) {
// delete cursor information if current cursor information is owned by this editor binding
}
}

const unsetCursorInfo = () => {
const current = awareness.getLocalState() || {}

if (current[cursorStateField]) {
awareness.setLocalStateField(cursorStateField, null)
}
}

awareness.on('change', awarenessListener)
view.dom.addEventListener('focusin', updateCursorInfo)
view.dom.addEventListener('focusout', updateCursorInfo)
view.dom.addEventListener('focusout', unsetCursorInfo)

return {
update: updateCursorInfo,
destroy: () => {
view.dom.removeEventListener('focusin', updateCursorInfo)
view.dom.removeEventListener('focusout', updateCursorInfo)
view.dom.removeEventListener('focusout', unsetCursorInfo)
awareness.off('change', awarenessListener)
awareness.setLocalStateField(cursorStateField, null)
}
Expand Down