@@ -33,18 +33,22 @@ export const normQuillDelta = delta => {
33
33
*@param {any } quillCursors
34
34
*/
35
35
const updateCursor = ( quillCursors , aw , clientId , doc , type ) => {
36
- if ( aw && aw . cursor && clientId !== doc . clientID ) {
37
- const user = aw . user || { }
38
- const color = user . color || '#ffa500'
39
- const name = user . name || `User:${ clientId } `
40
- quillCursors . createCursor ( clientId . toString ( ) , name , color )
41
- const anchor = Y . createAbsolutePositionFromRelativePosition ( Y . createRelativePositionFromJSON ( aw . cursor . anchor ) , doc )
42
- const head = Y . createAbsolutePositionFromRelativePosition ( Y . createRelativePositionFromJSON ( aw . cursor . head ) , doc )
43
- if ( anchor && head && anchor . type === type ) {
44
- quillCursors . moveCursor ( clientId . toString ( ) , { index :anchor . index , length :head . index - anchor . index } )
36
+ try {
37
+ if ( aw && aw . cursor && clientId !== doc . clientID ) {
38
+ const user = aw . user || { }
39
+ const color = user . color || '#ffa500'
40
+ const name = user . name || `User:${ clientId } `
41
+ quillCursors . createCursor ( clientId . toString ( ) , name , color )
42
+ const anchor = Y . createAbsolutePositionFromRelativePosition ( Y . createRelativePositionFromJSON ( aw . cursor . anchor ) , doc )
43
+ const head = Y . createAbsolutePositionFromRelativePosition ( Y . createRelativePositionFromJSON ( aw . cursor . head ) , doc )
44
+ if ( anchor && head && anchor . type === type ) {
45
+ quillCursors . moveCursor ( clientId . toString ( ) , { index :anchor . index , length :head . index - anchor . index } )
46
+ }
47
+ } else {
48
+ quillCursors . removeCursor ( clientId . toString ( ) )
45
49
}
46
- } else {
47
- quillCursors . removeCursor ( clientId . toString ( ) )
50
+ } catch ( err ) {
51
+ console . error ( err )
48
52
}
49
53
}
50
54
@@ -132,6 +136,10 @@ export class QuillBinding {
132
136
} )
133
137
}
134
138
}
139
+ // update all remote cursor locations
140
+ awareness . getStates ( ) . forEach ( ( aw , clientId ) => {
141
+ updateCursor ( quillCursors , aw , clientId , doc , type )
142
+ } )
135
143
}
136
144
}
137
145
quill . on ( 'editor-change' , this . _quillObserver )