| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | import { abilityDescriptors, getAbilities } from '@agent/abilities/abilities'; |
| 2 | +import { findBlockEl, scopeOf } from '@agent/lib/block-el'; | |
| 2 | 3 | import { buildBlockSchema } from '@agent/lib/block-schema'; |
| 3 | 4 | import { |
| 4 | 5 | classifyBlockEdit, |
| 5 | 6 | IGNORED_BLOCKS, |
| @@ -4,8 +5,9 @@ | ||
| 4 | 5 | classifyBlockEdit, |
| 5 | 6 | IGNORED_BLOCKS, |
| 6 | 7 | } from '@agent/lib/classify-block-edit'; |
| 7 | 8 | import { getClientTools } from '@agent/lib/client-tools'; |
| 9 | +import { isExtendableHeader } from '@agent/lib/extendable-header'; | |
| 8 | 10 | import { INSERTABLE_BLOCK_TYPES } from '@agent/lib/insertable-blocks'; |
| 9 | 11 | import { ensureCoreBlocksRegistered } from '@agent/lib/register-blocks'; |
| 10 | 12 | import { |
| 11 | 13 | buildSubtreeManifest, |
| @@ -20,11 +22,14 @@ | ||
| 20 | 22 | import { digest } from '@shared/api/digest'; |
| 21 | 23 | import { reqDataBasics } from '@shared/lib/data'; |
| 22 | 24 | import { getBlockType } from '@wordpress/blocks'; |
| 23 | 25 | |
| 26 | +// page-templates:v1 declares that find-blocks and stage-block reach into parts. | |
| 27 | +export const API_FEATURES = ['qa-tool', 'page-templates:v1']; | |
| 28 | + | |
| 24 | 29 | const rootFor = (block) => |
| 25 | 30 | block?.id && block?.target |
| 26 | - ? document.querySelector(`[${block.target}="${block.id}"]`) | |
| 31 | + ? findBlockEl(block.id, document, scopeOf(block)) | |
| 27 | 32 | : null; |
| 28 | 33 | |
| 29 | 34 | // If greater than 5 blocks the agent will narrow the scope |
| 30 | 35 | const EAGER_LOAD_MAX = 5; |
| @@ -106,8 +111,9 @@ | ||
| 106 | 111 | clientTools: getClientTools(), |
| 107 | 112 | messages: messages.slice(-5), |
| 108 | 113 | hasBlock: Boolean(block), // todo: remove this |
| 109 | 114 | blockDetails: block, |
| 115 | + features: API_FEATURES, | |
| 110 | 116 | ...options, |
| 111 | 117 | extra: extra(), |
| 112 | 118 | }), |
| 113 | 119 | }); |
| @@ -165,10 +171,13 @@ | ||
| 165 | 171 | blockTree: isBlockPatching ? subtreeTreeFor(block) : [], |
| 166 | 172 | // The plugin owns the add catalog so old fielded builds are never |
| 167 | 173 | // offered a type they can't build. |
| 168 | 174 | insertableBlockTypes: isBlockPatching ? INSERTABLE_BLOCK_TYPES : [], |
| 175 | + // The patcher writes dead CSS for these switches and claims success. | |
| 176 | + isExtendableHeader: | |
| 177 | + isBlockPatching && block?.template === 'header' && isExtendableHeader(), | |
| 169 | 178 | retry: options?.retry || false, |
| 170 | - features: ['qa-tool'], | |
| 179 | + features: API_FEATURES, | |
| 171 | 180 | extra: extra(), |
| 172 | 181 | }), |
| 173 | 182 | }); |
| 174 | 183 | |