Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion packages/core/src/api/nodeUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,15 @@ function areBlocksDifferentExcludingChildren<
);
}

const blocksChangedMap = new WeakMap<
Transaction,
{
appendedTransactions: Transaction[];
blocksChanged: BlocksChanged<any, any, any>;
}
>();
const defaultAppendedTransactions: Transaction[] = [];

/**
* Get the blocks that were changed by a transaction.
* @param transaction The transaction to get the changes from.
Expand All @@ -161,8 +170,15 @@ export function getBlocksChangedByTransaction<
SSchema extends StyleSchema = DefaultStyleSchema
>(
transaction: Transaction,
appendedTransactions: Transaction[] = []
appendedTransactions: Transaction[] = defaultAppendedTransactions
): BlocksChanged<BSchema, ISchema, SSchema> {
if (
blocksChangedMap.has(transaction) &&
blocksChangedMap.get(transaction)!.appendedTransactions ===
appendedTransactions
) {
return blocksChangedMap.get(transaction)!.blocksChanged;
}
let source: BlockChangeSource = { type: "local" };

if (transaction.getMeta("paste")) {
Expand Down
Loading