File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import type {
1212 IMapChange ,
1313 ISharedCell ,
1414 ISharedNotebook ,
15+ MapChanges ,
1516 NotebookChange ,
1617 SharedCell
1718} from './api.js' ;
@@ -516,6 +517,26 @@ export class YNotebook
516517 return ;
517518 }
518519
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+
519540 if ( metaEvent . keysChanged . has ( 'nbformat' ) ) {
520541 const change = metaEvent . changes . keys . get ( 'nbformat' ) ;
521542 const nbformatChanged = {
You can’t perform that action at this time.
0 commit comments