mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-03 14:19:01 +02:00
Only dispatch doc:changed event for insert or delete operations (#23779)
GitOrigin-RevId: b3425d4edffb045b2a15e5fc5cb69210d9e97203
This commit is contained in:
@@ -18,6 +18,7 @@ import {
|
||||
import {
|
||||
isCommentOperation,
|
||||
isDeleteOperation,
|
||||
isEditOperation,
|
||||
isInsertOperation,
|
||||
} from '@/utils/operations'
|
||||
import { decodeUtf8 } from '@/utils/decode-utf8'
|
||||
@@ -584,10 +585,14 @@ export class DocumentContainer extends EventEmitter {
|
||||
window.clearTimeout(docChangedTimeout)
|
||||
}
|
||||
docChangedTimeout = window.setTimeout(() => {
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('doc:changed', { detail: { id: this.doc_id } })
|
||||
)
|
||||
this.ideEventEmitter.emit('doc:changed', { doc_id: this.doc_id })
|
||||
if (ops.some(isEditOperation)) {
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('doc:changed', { detail: { id: this.doc_id } })
|
||||
)
|
||||
this.ideEventEmitter.emit('doc:changed', {
|
||||
doc_id: this.doc_id,
|
||||
})
|
||||
}
|
||||
}, 50)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -15,6 +15,9 @@ export const isCommentOperation = (op: Operation): op is CommentOperation =>
|
||||
export const isDeleteOperation = (op: Operation): op is DeleteOperation =>
|
||||
'd' in op
|
||||
|
||||
export const isEditOperation = (op: Operation): op is EditOperation =>
|
||||
isInsertOperation(op) || isDeleteOperation(op)
|
||||
|
||||
export const isInsertChange = (
|
||||
change: Change<EditOperation>
|
||||
): change is Change<InsertOperation> => isInsertOperation(change.op)
|
||||
|
||||
Reference in New Issue
Block a user