Skip to content
Merged
Changes from 2 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
16 changes: 16 additions & 0 deletions core/block_svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1720,4 +1720,20 @@ export class BlockSvg
traverseJson(json as unknown as {[key: string]: unknown});
return [json];
}

override jsonInit(json: AnyDuringMigration): void {
super.jsonInit(json);

if (json['classes']) {
let classesToAdd = '';

if (Array.isArray(json['classes'])) {
classesToAdd = json['classes'].join(' ');
} else {
classesToAdd = json['classes'];
}

this.addClass(classesToAdd);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can simplify this using a ternary operator.

Suggested change
let classesToAdd = '';
if (Array.isArray(json['classes'])) {
classesToAdd = json['classes'].join(' ');
} else {
classesToAdd = json['classes'];
}
this.addClass(classesToAdd);
this.addClass(Array.isArray(json['classes']) ? json['classes'].join(' ') : json['classes']);

You'll probably need to run npm run format in the root directory after applying this change to handle the line wrapping.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, thanks for pointing that out! Updated that and formatted using npm run format.

}
}
}