(type: string)
| 133 | * cluster rendering. |
| 134 | */ |
| 135 | export function getTemplatesForBlock(type: string): ScopedBlockTemplate[] { |
| 136 | const base = stripVersionSuffix(type) |
| 137 | const collected: ScopedBlockTemplate[] = [] |
| 138 | for (const [ownerType, meta] of Object.entries(BLOCK_META_REGISTRY)) { |
| 139 | if (!meta.templates) continue |
| 140 | const ownerBase = stripVersionSuffix(ownerType) |
| 141 | const isOwnerMatch = ownerBase === base |
| 142 | for (const template of meta.templates) { |
| 143 | const isAlsoMatch = |
| 144 | template.alsoIntegrations?.includes(base) || template.alsoIntegrations?.includes(type) |
| 145 | if (!isOwnerMatch && !isAlsoMatch) continue |
| 146 | const others: string[] = [] |
| 147 | if (!isOwnerMatch) others.push(ownerBase) |
| 148 | for (const also of template.alsoIntegrations ?? []) { |
| 149 | const alsoBase = stripVersionSuffix(also) |
| 150 | if (alsoBase !== base && !others.includes(alsoBase)) others.push(alsoBase) |
| 151 | } |
| 152 | collected.push({ ...template, otherBlockTypes: others }) |
| 153 | } |
| 154 | } |
| 155 | return collected |
| 156 | } |
| 157 | |
| 158 | /** |
| 159 | * Popular, ready-to-add skills for a block type. Curated skills live on the |
no test coverage detected