mirror of https://github.com/status-im/codimd.git
Rewrite cursorActivity with multi listener style
- adjust function order to prevent standard lint failure
This commit is contained in:
parent
b86ecb1342
commit
d7c068cbfd
|
@ -2699,10 +2699,23 @@ editorInstance.on('focus', function (cm) {
|
||||||
window.personalInfo['cursor'] = editor.getCursor()
|
window.personalInfo['cursor'] = editor.getCursor()
|
||||||
socket.emit('cursor focus', editor.getCursor())
|
socket.emit('cursor focus', editor.getCursor())
|
||||||
})
|
})
|
||||||
editorInstance.on('cursorActivity', function (cm) {
|
|
||||||
updateStatusBar()
|
const cursorActivity = _.debounce(cursorActivityInner, cursorActivityDebounce)
|
||||||
cursorActivity()
|
|
||||||
})
|
function cursorActivityInner () {
|
||||||
|
if (editorHasFocus() && !Visibility.hidden()) {
|
||||||
|
for (var i = 0; i < window.onlineUsers.length; i++) {
|
||||||
|
if (window.onlineUsers[i].id === window.personalInfo.id) {
|
||||||
|
window.onlineUsers[i].cursor = editor.getCursor()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
window.personalInfo['cursor'] = editor.getCursor()
|
||||||
|
socket.emit('cursor activity', editor.getCursor())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
editorInstance.on('cursorActivity', updateStatusBar)
|
||||||
|
editorInstance.on('cursorActivity', cursorActivity)
|
||||||
|
|
||||||
editorInstance.on('beforeSelectionChange', updateStatusBar)
|
editorInstance.on('beforeSelectionChange', updateStatusBar)
|
||||||
editorInstance.on('beforeSelectionChange', function (doc, selections) {
|
editorInstance.on('beforeSelectionChange', function (doc, selections) {
|
||||||
|
@ -2737,19 +2750,6 @@ editorInstance.on('beforeSelectionChange', function (doc, selections) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
var cursorActivity = _.debounce(cursorActivityInner, cursorActivityDebounce)
|
|
||||||
|
|
||||||
function cursorActivityInner () {
|
|
||||||
if (editorHasFocus() && !Visibility.hidden()) {
|
|
||||||
for (var i = 0; i < window.onlineUsers.length; i++) {
|
|
||||||
if (window.onlineUsers[i].id === window.personalInfo.id) {
|
|
||||||
window.onlineUsers[i].cursor = editor.getCursor()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
window.personalInfo['cursor'] = editor.getCursor()
|
|
||||||
socket.emit('cursor activity', editor.getCursor())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
editorInstance.on('blur', function (cm) {
|
editorInstance.on('blur', function (cm) {
|
||||||
for (var i = 0; i < window.onlineUsers.length; i++) {
|
for (var i = 0; i < window.onlineUsers.length; i++) {
|
||||||
if (window.onlineUsers[i].id === window.personalInfo.id) {
|
if (window.onlineUsers[i].id === window.personalInfo.id) {
|
||||||
|
|
Loading…
Reference in New Issue