Skip to content

Commit f96697e

Browse files
committed
fix(nodeUtil): moved blocks now included in the editor changes
1 parent bd1e6c2 commit f96697e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/core/src/api/nodeUtil.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,22 +184,25 @@ function collectAllBlocks<
184184
{
185185
block: Block<BSchema, ISchema, SSchema>;
186186
parentId: string | undefined;
187+
index: number;
187188
}
188189
> {
189190
const blocks: Record<
190191
string,
191192
{
192193
block: Block<BSchema, ISchema, SSchema>;
193194
parentId: string | undefined;
195+
index: number;
194196
}
195197
> = {};
196198
const pmSchema = getPmSchema(doc);
197-
doc.descendants((node, pos) => {
199+
doc.descendants((node, pos, _, index) => {
198200
if (isNodeBlock(node)) {
199201
const parentId = getParentBlockId(doc, pos);
200202
blocks[node.attrs.id] = {
201203
block: nodeToBlock(node, pmSchema),
202204
parentId,
205+
index,
203206
};
204207
}
205208
return true;
@@ -264,8 +267,9 @@ export function getBlocksChangedByTransaction<
264267
const prev = prevBlocks[id];
265268
const next = nextBlocks[id];
266269
const isParentDifferent = prev.parentId !== next.parentId;
270+
const isIndexDifferent = prev.index !== next.index;
267271

268-
if (isParentDifferent) {
272+
if (isParentDifferent || isIndexDifferent) {
269273
changes.push({
270274
type: "move",
271275
block: next.block,

0 commit comments

Comments
 (0)