Remove cursor on blur
benbro opened this issue · 4 comments
When a client remove the focus from the CodeMirror instance the browser remove his cursor but other clients still see his cursor at the same position.
If several people are editing the doc at the same time you'll end up with several cursors you can't remove.
Is it possible to listen to the "blur" even on the CodeMirror editor and send {cursor: false} to other clients?
https://github.com/Operational-Transformation/ot.js/blob/master/lib/codemirror-adapter.js#L14I think that CodeMirror fires the cursorActivity event only when
Thanks
I've pushed a commit that implements your suggestion. If you want to test it, you can clone the ot.js-demo repository and do a cd node_modules && git clone https://github.com/Operational-Transformation/ot.js.git
there. Currently, when the user selects some text and focuses another window, the selected text will disappear from the other user's screens while the user who did the selection can still see it. Do you think that I should fix this?
I've tested the blur on a cursor (with no selection) and it works great.
I think it's important that both users will see exactly the same.
Any blur event will remove the selection not just focus of another window.
If I'm talking on the phone with someone and asking him to look at the text I selected but he doesn't see that because I clicked somewhere else it will be very confusing.
Maybe trigger the blur event in CodeMirrorAdapter only if there is no selection?
I agree with you that the goal should be that all users see the same. There's even one additional case that must be dealt with: if a user makes some edits, focuses another window (thus the focus on the CodeMirror instance is lost and the blur
event fires) and then comes back to the editor window, making the cursor visible again. I think implementing this should be a matter of catching the focus
event and sending the cursor information.