Use tracked changes and comments from the snapshot (#26267)

GitOrigin-RevId: c2bf0c9c9a5ab4f8837b8712ca549119a31cf067
This commit is contained in:
Alf Eaton
2025-09-05 08:05:56 +00:00
committed by Copybot
parent 19866f48a8
commit 2c1baa717d
21 changed files with 737 additions and 267 deletions
@@ -29,6 +29,10 @@ import {
import { ThreadId } from '../../../../../types/review-panel/review-panel'
import getMeta from '@/utils/meta'
import OError from '@overleaf/o-error'
import {
HistoryOTShareDoc,
ShareLatexOTShareDoc,
} from '../../../../../types/share-doc'
const MAX_PENDING_OP_SIZE = 64
@@ -121,6 +125,27 @@ export class DocumentContainer extends EventEmitter {
this.bindToSocketEvents()
}
get shareDoc() {
if (!this.doc) {
throw new Error('Missing ShareJSDoc')
}
if (!this.doc._doc) {
throw new Error('Missing ShareJS Doc')
}
return this.doc._doc as HistoryOTShareDoc | ShareLatexOTShareDoc
}
isHistoryOT() {
return this.shareDoc.otType === 'history-ot'
}
get historyOTShareDoc() {
if (!this.isHistoryOT()) {
throw new Error('shareDoc is not historyOT')
}
return this.shareDoc as HistoryOTShareDoc
}
attachToCM6(cm6: EditorFacade) {
this.cm6 = cm6
if (this.doc) {
@@ -613,6 +638,9 @@ export class DocumentContainer extends EventEmitter {
this.trigger('op:timeout')
return this.onError(new Error('op timed out'))
})
this.doc.on('ranges:dirty', (...args) => {
return this.trigger('ranges:dirty', ...args)
})
let docChangedTimeout: number | null = null
this.doc.on(