Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion src/engine/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const domToBlock = function (blockDOM, blocks, isTopBlock, parent) {
}
case 'comment':
{
block.comment = xmlChild.attribs.id;
block.comment = `${block.id}_comment`;
break;
}
case 'value':
Expand Down
10 changes: 9 additions & 1 deletion src/serialization/sb3.js
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,14 @@ const deserializeBlocks = function (blocks) {
block.id = blockId; // add id back to block since it wasn't serialized
block.inputs = deserializeInputs(block.inputs, blockId, blocks);
block.fields = deserializeFields(block.fields);

if (block.comment) {
// Pre-Blockly v12 Scratch used arbitrary IDs for block comments.
// Newer versions use an ID based on the parent block's ID instead,
// so disregard the actual saved value and replace it with the
// synthesized one.
block.comment = `${block.id}_comment`;
}
}
return blocks;
};
Expand Down Expand Up @@ -1047,7 +1055,7 @@ const parseScratchObject = function (object, runtime, extensions, zip, assets) {
for (const commentId in object.comments) {
const comment = object.comments[commentId];
const newComment = new Comment(
commentId,
comment.blockId ? `${comment.blockId}_comment` : commentId,
comment.text,
comment.x,
comment.y,
Expand Down