@@ -99,7 +99,7 @@ export type BlocksChanged<
99
99
BSchema extends BlockSchema = DefaultBlockSchema ,
100
100
ISchema extends InlineContentSchema = DefaultInlineContentSchema ,
101
101
SSchema extends StyleSchema = DefaultStyleSchema
102
- > = Array <
102
+ > = ReadonlyArray <
103
103
{
104
104
/**
105
105
* The affected block.
@@ -149,6 +149,15 @@ function areBlocksDifferentExcludingChildren<
149
149
) ;
150
150
}
151
151
152
+ const blocksChangedMap = new WeakMap <
153
+ Transaction ,
154
+ {
155
+ appendedTransactions : Transaction [ ] ;
156
+ blocksChanged : BlocksChanged < any , any , any > ;
157
+ }
158
+ > ( ) ;
159
+ const defaultAppendedTransactions : Transaction [ ] = [ ] ;
160
+
152
161
/**
153
162
* Get the blocks that were changed by a transaction.
154
163
* @param transaction The transaction to get the changes from.
@@ -161,8 +170,15 @@ export function getBlocksChangedByTransaction<
161
170
SSchema extends StyleSchema = DefaultStyleSchema
162
171
> (
163
172
transaction : Transaction ,
164
- appendedTransactions : Transaction [ ] = [ ]
173
+ appendedTransactions : Transaction [ ] = defaultAppendedTransactions
165
174
) : BlocksChanged < BSchema , ISchema , SSchema > {
175
+ if (
176
+ blocksChangedMap . has ( transaction ) &&
177
+ blocksChangedMap . get ( transaction ) ! . appendedTransactions ===
178
+ appendedTransactions
179
+ ) {
180
+ return blocksChangedMap . get ( transaction ) ! . blocksChanged ;
181
+ }
166
182
let source : BlockChangeSource = { type : "local" } ;
167
183
168
184
if ( transaction . getMeta ( "paste" ) ) {
0 commit comments