@@ -3,7 +3,7 @@ import {CONST, updateJson, updateNum} from '../../../json-hash/hash';
33import { MarkerOverlayPoint } from '../overlay/MarkerOverlayPoint' ;
44import { UndefEndIter , type UndefIterator } from '../../../util/iterator' ;
55import { Inline } from './Inline' ;
6- import { formatType } from '../slice/util' ;
6+ import { formatType , getTag } from '../slice/util' ;
77import { Range } from '../rga/Range' ;
88import type { Point } from '../rga/Point' ;
99import type { OverlayPoint } from '../overlay/OverlayPoint' ;
@@ -45,11 +45,7 @@ export class Block<T = string, Attr = unknown> extends Range<T> implements IBloc
4545 }
4646
4747 public tag ( ) : number | string {
48- const path = this . path ;
49- const length = path . length ;
50- if ( ! length ) return '' ;
51- const step = path [ length - 1 ] ;
52- return Array . isArray ( step ) ? step [ 0 ] : step ;
48+ return getTag ( this . path ) ;
5349 }
5450
5551 public attr ( ) : Attr | undefined {
@@ -109,15 +105,16 @@ export class Block<T = string, Attr = unknown> extends Range<T> implements IBloc
109105 */
110106 public texts0 ( ) : UndefIterator < Inline < T > > {
111107 const txt = this . txt ;
108+ const overlay = txt . overlay ;
112109 const iterator = this . tuples0 ( ) ;
113110 const start = this . start ;
114111 const end = this . end ;
115- const startIsMarker = txt . overlay . isMarker ( start . id ) ;
116- const endIsMarker = txt . overlay . isMarker ( end . id ) ;
112+ const startIsMarker = overlay . isMarker ( start . id ) ;
113+ const endIsMarker = overlay . isMarker ( end . id ) ;
117114 let isFirst = true ;
118115 let next = iterator ( ) ;
119116 let closed = false ;
120- return ( ) => {
117+ const newIterator : UndefIterator < Inline < T > > = ( ) => {
121118 if ( closed ) return ;
122119 const pair = next ;
123120 next = iterator ( ) ;
@@ -131,6 +128,9 @@ export class Block<T = string, Attr = unknown> extends Range<T> implements IBloc
131128 if ( startIsMarker ) {
132129 point1 = point1 . clone ( ) ;
133130 point1 . step ( 1 ) ;
131+ // Skip condition when inline annotations tarts immediately at th
132+ // beginning of the block.
133+ if ( point1 . cmp ( point2 ) === 0 ) return newIterator ( ) ;
134134 }
135135 }
136136 if ( ! endIsMarker && end . cmpSpatial ( overlayPoint2 ) < 0 ) {
@@ -139,6 +139,7 @@ export class Block<T = string, Attr = unknown> extends Range<T> implements IBloc
139139 }
140140 return new Inline ( txt , overlayPoint1 , overlayPoint2 , point1 , point2 ) ;
141141 } ;
142+ return newIterator ;
142143 }
143144
144145 /**
0 commit comments