Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/core/src/api/nodeUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,22 +184,25 @@ function collectAllBlocks<
{
block: Block<BSchema, ISchema, SSchema>;
parentId: string | undefined;
index: number;
}
> {
const blocks: Record<
string,
{
block: Block<BSchema, ISchema, SSchema>;
parentId: string | undefined;
index: number;
}
> = {};
const pmSchema = getPmSchema(doc);
doc.descendants((node, pos) => {
doc.descendants((node, pos, _, index) => {
if (isNodeBlock(node)) {
const parentId = getParentBlockId(doc, pos);
blocks[node.attrs.id] = {
block: nodeToBlock(node, pmSchema),
parentId,
index,
};
}
return true;
Expand Down Expand Up @@ -264,8 +267,9 @@ export function getBlocksChangedByTransaction<
const prev = prevBlocks[id];
const next = nextBlocks[id];
const isParentDifferent = prev.parentId !== next.parentId;
const isIndexDifferent = prev.index !== next.index;

if (isParentDifferent) {
if (isParentDifferent || isIndexDifferent) {
changes.push({
type: "move",
block: next.block,
Expand Down