feat: Add 'reason' field to move event (#6996)

* feat: Add 'reason' field to move event

There are many types of move.  This addition allows one to detect what the reason for each move is.

* Clang formatting.

And unsaved editor tabs.

* Change reason string to array.
This commit is contained in:
Neil Fraser
2023-04-26 00:22:10 +02:00
committed by GitHub
parent 139bc299a0
commit 64aa3e7df4
12 changed files with 71 additions and 16 deletions

View File

@@ -433,7 +433,8 @@ export function domToWorkspace(xml: Element, workspace: Workspace): string[] {
const blockX = parseInt(xmlChildElement.getAttribute('x') ?? '10', 10);
const blockY = parseInt(xmlChildElement.getAttribute('y') ?? '10', 10);
if (!isNaN(blockX) && !isNaN(blockY)) {
block.moveBy(workspace.RTL ? width - blockX : blockX, blockY);
block.moveBy(
workspace.RTL ? width - blockX : blockX, blockY, ['create']);
}
variablesFirst = false;
} else if (name === 'shadow') {
@@ -516,7 +517,7 @@ export function appendDomToWorkspace(
offsetX = workspace.RTL ? topX - newRightX : topX - newLeftX;
for (let i = 0; i < newBlockIds.length; i++) {
const block = workspace.getBlockById(newBlockIds[i]);
block!.moveBy(offsetX, offsetY);
block!.moveBy(offsetX, offsetY, ['create']);
}
}
return newBlockIds;