mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-19 16:15:25 +00:00
Improve collaborator cursor positioning (#14145)
GitOrigin-RevId: c43f0877700381279c2f79699ea3963c3e9c12b3
This commit is contained in:
parent
c37b87e254
commit
1f173010c7
1 changed files with 9 additions and 1 deletions
|
@ -1,8 +1,10 @@
|
|||
import {
|
||||
MapMode,
|
||||
RangeSet,
|
||||
RangeValue,
|
||||
StateEffect,
|
||||
StateField,
|
||||
Transaction,
|
||||
TransactionSpec,
|
||||
} from '@codemirror/state'
|
||||
import {
|
||||
|
@ -67,9 +69,15 @@ export const cursorHighlights = () => {
|
|||
}
|
||||
|
||||
class HighlightRangeValue extends RangeValue {
|
||||
mapMode = MapMode.Simple
|
||||
|
||||
constructor(public highlight: Highlight) {
|
||||
super()
|
||||
}
|
||||
|
||||
eq(other: HighlightRangeValue) {
|
||||
return other.highlight === this.highlight
|
||||
}
|
||||
}
|
||||
|
||||
const cursorHighlightsState = StateField.define<RangeSet<HighlightRangeValue>>({
|
||||
|
@ -101,7 +109,7 @@ const cursorHighlightsState = StateField.define<RangeSet<HighlightRangeValue>>({
|
|||
}
|
||||
}
|
||||
|
||||
if (tr.docChanged) {
|
||||
if (tr.docChanged && !tr.annotation(Transaction.remote)) {
|
||||
value = value.map(tr.changes)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue