File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change 3
3
"name" : " editable" ,
4
4
"path" : " lib/index.mjs" ,
5
5
"import" : " { editable }" ,
6
- "limit" : " 3.45 kB"
6
+ "limit" : " 3.5 kB"
7
7
},
8
8
{
9
9
"name" : " Total" ,
10
10
"path" : " lib/index.mjs" ,
11
11
"import" : " *" ,
12
- "limit" : " 4 kB"
12
+ "limit" : " 5 kB"
13
13
}
14
14
]
Original file line number Diff line number Diff line change @@ -228,10 +228,18 @@ export const editable = <T>(
228
228
[ doc , selection ] = flatten ( doc , selection ) ;
229
229
}
230
230
231
- history . set ( [ history . get ( ) [ 0 ] , prevSelection ] ) ;
232
- history . push ( [ doc , selection ] ) ;
233
231
currentSelection = selection ;
234
- onChange ( docToJS ( doc ) ) ;
232
+
233
+ // TODO improve
234
+ const prevDoc = history . get ( ) [ 0 ] ;
235
+ if (
236
+ doc . length !== prevDoc . length ||
237
+ doc . some ( ( l , i ) => l !== prevDoc [ i ] )
238
+ ) {
239
+ history . set ( [ prevDoc , prevSelection ] ) ;
240
+ history . push ( [ doc , selection ] ) ;
241
+ onChange ( docToJS ( doc ) ) ;
242
+ }
235
243
}
236
244
237
245
restoreSelectionOnTimeout ( ) ;
You can’t perform that action at this time.
0 commit comments