Skip to content

Commit 5ee9296

Browse files
committed
chore: added debug code
1 parent 0147671 commit 5ee9296

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

src/extensions/markdown/Lists/commands.ts

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,28 +138,47 @@ function liftNestedLists(
138138
listType: NodeType,
139139
liPos: number,
140140
): void {
141+
console.log('[liftNestedLists] entered with liPos:', liPos);
141142
const movedItem = tr.doc.nodeAt(liPos);
143+
console.log('[liftNestedLists] movedItem at liPos:', movedItem);
142144
if (!movedItem) return;
143145

144146
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);
146148
if (child.type === listType) {
147-
const nestedStart = liPos + 1 + offset; // +1 to move inside <li> content
149+
const nestedStart = liPos + 1 + offset;
148150
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+
);
154173
if (liftRange) {
155174
const target = liftTarget(liftRange);
175+
console.log('[liftNestedLists] lift target depth:', target);
156176
if (target !== null) {
157177
console.log(
158-
'[sink] lifting nested list',
159-
'range:',
178+
'[liftNestedLists] performing tr.lift on range:',
160179
liftRange.start,
161180
liftRange.end,
162-
'target depth:',
181+
'with target depth:',
163182
target,
164183
);
165184
tr.lift(liftRange, target);

0 commit comments

Comments
 (0)