remove duplicate Transaction.callAll logic

This commit is contained in:
Kevin Jahns 2023-06-22 17:46:49 +02:00
parent 5d862477cd
commit 942c8a267b

View File

@ -275,11 +275,10 @@ const cleanupTransactions = (transactionCleanups, i) => {
)
fs.push(() => {
// deep observe events
transaction.changedParentTypes.forEach((events, type) =>
fs.push(() => {
transaction.changedParentTypes.forEach((events, type) => {
// We need to think about the possibility that the user transforms the
// Y.Doc in the event.
if (type._item === null || !type._item.deleted) {
if (type._dEH.l.length > 0 && (type._item === null || !type._item.deleted)) {
events = events
.filter(event =>
event.target._item === null || !event.target._item.deleted
@ -287,6 +286,7 @@ const cleanupTransactions = (transactionCleanups, i) => {
events
.forEach(event => {
event.currentTarget = type
// path is relative to the current target
event._path = null
})
// sort events by path length so that top-level events are fired first.
@ -297,9 +297,8 @@ const cleanupTransactions = (transactionCleanups, i) => {
callEventHandlerListeners(type._dEH, events, transaction)
}
})
)
fs.push(() => doc.emit('afterTransaction', [transaction, doc]))
})
fs.push(() => doc.emit('afterTransaction', [transaction, doc]))
callAll(fs, [])
if (transaction._needFormattingCleanup) {
cleanupYTextAfterTransaction(transaction)