Added support for disabled blocks, throw warning at runtime

This commit is contained in:
Waleed Latif
2025-01-31 18:30:25 -08:00
parent d0a3ad7120
commit ea823539ac
3 changed files with 10 additions and 2 deletions

View File

@@ -320,7 +320,7 @@ export class Executor {
const path = match.slice(1, -1) // remove < and >
const [blockRef, ...pathParts] = path.split('.')
// Try blockRef as ID, then as normalized name
// Try referencing as an ID, then as a normalized name.
let sourceBlock = blockById.get(blockRef)
if (!sourceBlock) {
const normalized = blockRef.toLowerCase().replace(/\s+/g, '')
@@ -332,6 +332,12 @@ export class Executor {
continue
}
// Check if the referenced block is disabled.
if (sourceBlock.enabled === false) {
console.warn(`Block "${sourceBlock.metadata?.title}" is disabled, and block "${block.metadata?.title}" depends on it.`)
continue
}
const sourceState = context.blockStates.get(sourceBlock.id)
if (!sourceState) {
console.warn(`No state found for block ID "${sourceBlock.id}".`)

View File

@@ -53,7 +53,8 @@ export class Serializer {
description: blockConfig.toolbar.description,
category: blockConfig.toolbar.category,
color: blockConfig.toolbar.bgColor
}
},
enabled: block.enabled
}
}

View File

@@ -30,4 +30,5 @@ export interface SerializedBlock {
icon?: string
color?: string
}
enabled: boolean
}