Skip to content

Commit e71e6eb

Browse files
committed
feat: added debug code
1 parent 6aee108 commit e71e6eb

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

src/extensions/markdown/Lists/commands.ts

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -164,25 +164,39 @@ export function sinkOnlySelectedListItem(itemType: NodeType): Command {
164164

165165
for (const [startPos, endPos] of listItemsPoses) {
166166
const mappedStart = tr.mapping.map(startPos);
167-
const nodeStart = tr.doc.nodeAt(mappedStart);
168-
169167
const mappedEnd = tr.mapping.map(endPos);
170-
// const nodeEnd = tr.doc.nodeAt(mappedEnd);
171168

172-
console.log('startPos ---->', startPos);
173-
console.log('endPos ---->', endPos);
169+
console.log('startPos: endPos', startPos, endPos);
170+
console.log('mapped startPos: endPos ', mappedStart, mappedEnd);
171+
172+
let j = 0;
173+
while (j < tr.doc.nodeSize - 1) {
174+
const node = tr.doc.nodeAt(j);
175+
console.log('node', j, node?.type.name);
176+
j++;
177+
}
178+
179+
const start = startPos;
180+
const end = endPos;
174181

175-
console.log('mapped startPos ---->', mappedStart);
176-
console.log('mapped endPos ---->', mappedEnd);
182+
const startNode = tr.doc.nodeAt(start);
183+
console.log('[startNode]', startNode?.type, 'startNode size', startNode?.nodeSize);
184+
console.log(
185+
'[start, end]',
186+
start,
187+
end,
188+
'start + nodeSize',
189+
start + (startNode?.nodeSize ?? 0),
190+
);
177191

178-
console.log('nodeStart ---->', nodeStart?.type.name);
192+
const $start = tr.doc.resolve(start);
193+
const $end = tr.doc.resolve(end);
179194

180-
const $mappedStart = tr.doc.resolve(mappedStart);
181-
const $mappedEnd = tr.doc.resolve(mappedEnd);
182-
const range = $mappedStart.blockRange($mappedEnd);
195+
console.log('[$start, $end]', $start.pos, $end.pos, 'j:', j);
196+
const range = $start.blockRange($end);
183197

184198
if (range) {
185-
console.log('sink ---->', range.start, range.end, range);
199+
console.log('[sink ---->]', range.start, range.end, range);
186200
sink(tr, range, itemType);
187201
}
188202
}

0 commit comments

Comments
 (0)