@@ -259,13 +259,8 @@ export default class NotebookUtilities {
259259 ) ;
260260 }
261261
262- if ( notebookPanel . model ?. metadata ) {
263- const metadata = notebookPanel . model . metadata as any ;
264- if ( typeof metadata . has === 'function' && metadata . has ( key ) ) {
265- return metadata . get ( key ) ;
266- }
267- // Fallback for different metadata implementations
268- return metadata [ key ] || null ;
262+ if ( notebookPanel . model ) {
263+ return notebookPanel . model . getMetadata ( key ) || null ;
269264 }
270265 return null ;
271266 }
@@ -292,20 +287,12 @@ export default class NotebookUtilities {
292287 ) ;
293288 }
294289
295- if ( ! notebookPanel . model ?. metadata ) {
296- throw new Error ( 'Notebook metadata is not available.' ) ;
290+ if ( ! notebookPanel . model ) {
291+ throw new Error ( 'Notebook model is not available.' ) ;
297292 }
298293
299- const metadata = notebookPanel . model . metadata as any ;
300- let oldVal : any ;
301-
302- if ( typeof metadata . set === 'function' ) {
303- oldVal = metadata . set ( key , value ) ;
304- } else {
305- // Fallback for different metadata implementations
306- oldVal = ( metadata as any ) [ key ] ;
307- ( metadata as any ) [ key ] = value ;
308- }
294+ const oldVal = notebookPanel . model . getMetadata ( key ) ;
295+ notebookPanel . model . setMetadata ( key , value ) ;
309296
310297 if ( save ) {
311298 this . saveNotebook ( notebookPanel ) ;
0 commit comments