@@ -138,28 +138,47 @@ function liftNestedLists(
138
138
listType : NodeType ,
139
139
liPos : number ,
140
140
) : void {
141
+ console . log ( '[liftNestedLists] entered with liPos:' , liPos ) ;
141
142
const movedItem = tr . doc . nodeAt ( liPos ) ;
143
+ console . log ( '[liftNestedLists] movedItem at liPos:' , movedItem ) ;
142
144
if ( ! movedItem ) return ;
143
145
144
146
movedItem . forEach ( ( child , offset ) => {
145
- // Detect nested list nodes of the same type (i.e., another bullet_list or ordered_list)
147
+ console . log ( '[liftNestedLists] inspecting child at offset' , offset , 'node:' , child ) ;
146
148
if ( child . type === listType ) {
147
- const nestedStart = liPos + 1 + offset ; // +1 to move inside <li> content
149
+ const nestedStart = liPos + 1 + offset ;
148
150
const nestedEnd = nestedStart + child . nodeSize ;
149
-
150
- const $nestedStart = tr . doc . resolve ( nestedStart + 1 ) ; // first node inside nested list
151
- const $nestedEnd = tr . doc . resolve ( nestedEnd - 1 ) ; // last node inside nested list
152
-
153
- const liftRange = $nestedStart . blockRange ( $nestedEnd , ( node ) => node . type === itemType ) ;
151
+ console . log (
152
+ '[liftNestedLists] nested list span start/end:' ,
153
+ nestedStart ,
154
+ nestedEnd ,
155
+ 'child.nodeSize:' ,
156
+ child . nodeSize ,
157
+ ) ;
158
+
159
+ const $nestedStart = tr . doc . resolve ( nestedStart + 1 ) ;
160
+ const $nestedEnd = tr . doc . resolve ( nestedEnd - 1 ) ;
161
+ console . log (
162
+ '[liftNestedLists] resolving range with $nestedStart.pos:' ,
163
+ $nestedStart . pos ,
164
+ '$nestedEnd.pos:' ,
165
+ $nestedEnd . pos ,
166
+ ) ;
167
+
168
+ const liftRange = $nestedStart . blockRange ( $nestedEnd , ( node ) => node . type === listType ) ;
169
+ console . log (
170
+ '[liftNestedLists] liftRange:' ,
171
+ liftRange ? { start : liftRange . start , end : liftRange . end } : null ,
172
+ ) ;
154
173
if ( liftRange ) {
155
174
const target = liftTarget ( liftRange ) ;
175
+ console . log ( '[liftNestedLists] lift target depth:' , target ) ;
156
176
if ( target !== null ) {
157
177
console . log (
158
- '[sink] lifting nested list' ,
159
- 'range:' ,
178
+ '[liftNestedLists] performing tr.lift on range:' ,
160
179
liftRange . start ,
161
180
liftRange . end ,
162
- 'target depth:' ,
181
+ 'with target depth:' ,
163
182
target ,
164
183
) ;
165
184
tr . lift ( liftRange , target ) ;
0 commit comments