feat: Add a generator for all fields on a block. (#8667)

* feat: Add a generator for all fields on a block.

* chore: Add docstring.
This commit is contained in:
Aaron Dodson
2025-01-06 11:30:22 -08:00
committed by GitHub
parent 503cd0073f
commit 956f272da0
4 changed files with 48 additions and 58 deletions

View File

@@ -261,13 +261,9 @@ function saveIcons(block: Block, state: State, doFullSerialization: boolean) {
*/
function saveFields(block: Block, state: State, doFullSerialization: boolean) {
const fields = Object.create(null);
for (let i = 0; i < block.inputList.length; i++) {
const input = block.inputList[i];
for (let j = 0; j < input.fieldRow.length; j++) {
const field = input.fieldRow[j];
if (field.isSerializable()) {
fields[field.name!] = field.saveState(doFullSerialization);
}
for (const field of block.getFields()) {
if (field.isSerializable()) {
fields[field.name!] = field.saveState(doFullSerialization);
}
}
if (Object.keys(fields).length) {