(parent, key, value)
| 1266 | // console.log 'Trying to remove', blockType, 'from blockly state', _.cloneDeep(blocklyState), 'with', blocklyState.blocks?.blocks?.length, 'blocks' # debugging |
| 1267 | // Recursively walk through all properties of the blockly state, and transform the ones with type: blockType to be comment blocks |
| 1268 | const transformBlock = function (parent, key, value) { |
| 1269 | if ((value != null ? value.type : undefined) === blockType) { |
| 1270 | // console.log 'Found block of type', blockType, 'at', key, 'in', _.cloneDeep parent |
| 1271 | // console.log 'Replacing with comment block' |
| 1272 | // console.log 'Parent before', _.cloneDeep parent |
| 1273 | parent[key] = { type: 'text', x: value.x, y: value.y, id: value.id, fields: { TEXT: `Missing block ${blockType}` } } |
| 1274 | // console.log 'Parent after', _.cloneDeep parent |
| 1275 | return parent[key] |
| 1276 | } else if (_.isObject(value)) { |
| 1277 | return _.each(value, (v, k) => transformBlock(value, k, v)) |
| 1278 | } |
| 1279 | } |
| 1280 | transformBlock(null, 'blocks', blocklyState.blocks.blocks) |
| 1281 | return blocklyState |
| 1282 | } |
no outgoing calls
no test coverage detected