File tree 1 file changed +21
-0
lines changed
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import type {
12
12
IMapChange ,
13
13
ISharedCell ,
14
14
ISharedNotebook ,
15
+ MapChanges ,
15
16
NotebookChange ,
16
17
SharedCell
17
18
} from './api.js' ;
@@ -516,6 +517,26 @@ export class YNotebook
516
517
return ;
517
518
}
518
519
520
+ if ( metaEvent . keysChanged . has ( 'metadata' ) ) {
521
+ // Handle metadata change when adding/removing the YMap
522
+ const change = metaEvent . changes . keys . get ( 'metadata' ) ;
523
+ if ( change ?. action === 'add' && ! change . oldValue ) {
524
+ const metadataChange : MapChanges = new Map < string , any > ( ) ;
525
+ for ( const key of Object . keys ( this . metadata ) ) {
526
+ metadataChange . set ( key , {
527
+ action : 'add' ,
528
+ oldValue : undefined
529
+ } ) ;
530
+ this . _metadataChanged . emit ( {
531
+ key,
532
+ type : 'add' ,
533
+ newValue : this . getMetadata ( key )
534
+ } ) ;
535
+ }
536
+ this . _changed . emit ( { metadataChange } ) ;
537
+ }
538
+ }
539
+
519
540
if ( metaEvent . keysChanged . has ( 'nbformat' ) ) {
520
541
const change = metaEvent . changes . keys . get ( 'nbformat' ) ;
521
542
const nbformatChanged = {
You can’t perform that action at this time.
0 commit comments