@@ -5,6 +5,7 @@ import {UndEndIterator, type UndEndNext} from '../../../util/iterator';
55import { Inline } from './Inline' ;
66import { formatType , getTag } from '../slice/util' ;
77import { Range } from '../rga/Range' ;
8+ import { stringify } from '../../../json-text/stringify' ;
89import type { Point } from '../rga/Point' ;
910import type { OverlayPoint } from '../overlay/OverlayPoint' ;
1011import type { Printable } from 'tree-dump' ;
@@ -49,7 +50,12 @@ export class Block<T = string, Attr = unknown> extends Range<T> implements IBloc
4950 }
5051
5152 public attr ( ) : Attr | undefined {
52- return this . marker ?. data ( ) as Attr | undefined ;
53+ const path = this . path ;
54+ const length = path . length ;
55+ if ( length === 0 ) return ;
56+ const tagStep = path [ length - 1 ] ;
57+ if ( ! Array . isArray ( tagStep ) ) return ;
58+ return tagStep [ 2 ] as Attr | undefined ;
5359 }
5460
5561 public isLeaf ( ) : boolean {
@@ -197,7 +203,8 @@ export class Block<T = string, Attr = unknown> extends Range<T> implements IBloc
197203 protected toStringHeader ( ) : string {
198204 const hash = `#${ this . hash . toString ( 36 ) . slice ( - 4 ) } ` ;
199205 const tag = this . path . map ( ( step ) => formatType ( step ) ) . join ( '.' ) ;
200- const header = `${ super . toString ( '' , true ) } ${ hash } ${ tag } ` ;
206+ const data = stringify ( this . attr ( ) ) ;
207+ const header = `${ super . toString ( '' , true ) } ${ hash } ${ tag } ${ data } ` ;
201208 return header ;
202209 }
203210
0 commit comments