@@ -3,7 +3,7 @@ import {CONST, updateJson, updateNum} from '../../../json-hash/hash';
3
3
import { MarkerOverlayPoint } from '../overlay/MarkerOverlayPoint' ;
4
4
import { UndefEndIter , type UndefIterator } from '../../../util/iterator' ;
5
5
import { Inline } from './Inline' ;
6
- import { formatType } from '../slice/util' ;
6
+ import { formatType , getTag } from '../slice/util' ;
7
7
import { Range } from '../rga/Range' ;
8
8
import type { Point } from '../rga/Point' ;
9
9
import type { OverlayPoint } from '../overlay/OverlayPoint' ;
@@ -45,11 +45,7 @@ export class Block<T = string, Attr = unknown> extends Range<T> implements IBloc
45
45
}
46
46
47
47
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 ) ;
53
49
}
54
50
55
51
public attr ( ) : Attr | undefined {
@@ -109,15 +105,16 @@ export class Block<T = string, Attr = unknown> extends Range<T> implements IBloc
109
105
*/
110
106
public texts0 ( ) : UndefIterator < Inline < T > > {
111
107
const txt = this . txt ;
108
+ const overlay = txt . overlay ;
112
109
const iterator = this . tuples0 ( ) ;
113
110
const start = this . start ;
114
111
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 ) ;
117
114
let isFirst = true ;
118
115
let next = iterator ( ) ;
119
116
let closed = false ;
120
- return ( ) => {
117
+ const newIterator : UndefIterator < Inline < T > > = ( ) => {
121
118
if ( closed ) return ;
122
119
const pair = next ;
123
120
next = iterator ( ) ;
@@ -131,6 +128,9 @@ export class Block<T = string, Attr = unknown> extends Range<T> implements IBloc
131
128
if ( startIsMarker ) {
132
129
point1 = point1 . clone ( ) ;
133
130
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 ( ) ;
134
134
}
135
135
}
136
136
if ( ! endIsMarker && end . cmpSpatial ( overlayPoint2 ) < 0 ) {
@@ -139,6 +139,7 @@ export class Block<T = string, Attr = unknown> extends Range<T> implements IBloc
139
139
}
140
140
return new Inline ( txt , overlayPoint1 , overlayPoint2 , point1 , point2 ) ;
141
141
} ;
142
+ return newIterator ;
142
143
}
143
144
144
145
/**
0 commit comments