| @@ -1,7 +1,9 @@ | ||
| 1 | 1 | // Patch schema from the block's real `supports` — the model never hand-authors HTML. |
| 2 | 2 | // Structure only: the backend overlays the model-facing field descriptions. |
| 3 | 3 | |
| 4 | +import { SETTING_TEXT_BLOCKS } from '@agent/lib/setting-text-blocks'; | |
| 5 | + | |
| 4 | 6 | const str = { type: 'string' }; |
| 5 | 7 | const obj = (properties) => ({ |
| 6 | 8 | type: 'object', |
| 7 | 9 | additionalProperties: false, |
| @@ -114,8 +116,12 @@ | ||
| 114 | 116 | verticalAlignment: str, |
| 115 | 117 | }); |
| 116 | 118 | }; |
| 117 | 119 | |
| 120 | +// Where a block keeps its editable text, most-specific first: `text` (button), | |
| 121 | +// `content` (paragraph, heading), `label` (menu item, search). | |
| 122 | +export const RICH_TEXT_ATTRIBUTES = ['text', 'content', 'label']; | |
| 123 | + | |
| 118 | 124 | // Identity attributes (ref, id, className, lock, metadata) stay out — |
| 119 | 125 | // bad values there break the block, not just its look. |
| 120 | 126 | const SIMPLE_ATTRIBUTES = [ |
| 121 | 127 | 'level', |
| @@ -150,12 +156,19 @@ | ||
| 150 | 156 | |
| 151 | 157 | const properties = prune({ |
| 152 | 158 | ...simple, |
| 153 | 159 | align: attributes.align ? alignSchema(supports.align) : null, |
| 160 | + // Quote and pullquote align text with an attribute, not a typography support. | |
| 161 | + textAlign: attributes.textAlign | |
| 162 | + ? { type: 'string', enum: ['left', 'center', 'right'] } | |
| 163 | + : null, | |
| 154 | 164 | layout: attributes.layout ? layoutSchema(supports) : null, |
| 155 | - // Rich text lives in `text` (button) or `content` (paragraph, heading, …); | |
| 156 | - // the model always sees `text` — the patcher maps it to the real attribute. | |
| 157 | - text: attributes.text || attributes.content ? str : null, | |
| 165 | + // Model-facing name; block-patch maps it back to the real home. | |
| 166 | + text: | |
| 167 | + RICH_TEXT_ATTRIBUTES.some((name) => attributes[name]) || | |
| 168 | + SETTING_TEXT_BLOCKS[blockType.name] | |
| 169 | + ? str | |
| 170 | + : null, | |
| 158 | 171 | url: attributes.url ? str : null, |
| 159 | 172 | backgroundColor: |
| 160 | 173 | attributes.backgroundColor && colorChannel(supports.color, 'background') |
| 161 | 174 | ? str |