Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update theme.json schema to allow for per-block management of settings. #36746

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion bin/api-docs/gen-theme-reference.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,15 @@ ${ markupFn( data ) }
let autogen = '';

// Settings
const settings = themejson.definitions.settingsProperties.properties;
const settings = Object.entries( themejson.definitions )
.filter( ( [ settingsKey ] ) =>
/^settingsProperties(?!Complete)\w+$/.test( settingsKey )
)
.reduce(
( settingsObj, [ , { properties } ] ) =>
Object.assign( settingsObj, properties ),
{}
);
const settingSections = keys( settings );
autogen += '## Settings' + '\n\n';
settingSections.forEach( ( section ) => {
Expand Down
69 changes: 61 additions & 8 deletions schemas/json/theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"createTheme": "https://developer.wordpress.org/block-editor/how-to-guides/themes/create-block-theme/",
"reference": "https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-json/"
},
"settingsProperties": {
"settingsPropertiesBorder": {
"properties": {
"appearanceTools": {
"description": "Setting that enables the following UI tools:\n\n- border: color, radius, style, width\n- color: link\n- spacing: blockGap, margin, padding\n- typography: lineHeight",
Expand Down Expand Up @@ -40,7 +40,11 @@
}
},
"additionalProperties": false
},
}
}
},
"settingsPropertiesColor": {
"properties": {
"color": {
"description": "Settings related to colors.",
"type": "object",
Expand Down Expand Up @@ -160,7 +164,12 @@
}
},
"additionalProperties": false
},
}

}
},
"settingsPropertiesLayout": {
"properties": {
"layout": {
"description": "Settings related to layout.",
"type": "object",
Expand All @@ -175,7 +184,12 @@
}
},
"additionalProperties": false
},
}
}
},

"settingsPropertiesSpacing":{
"properties": {
"spacing": {
"description": "Settings related to spacing.",
"type": "object",
Expand Down Expand Up @@ -208,7 +222,11 @@
}
},
"additionalProperties": false
},
}
}
},
"settingsPropertiesTypography":{
"properties": {
"typography": {
"description": "Settings related to typography.",
"type": "object",
Expand Down Expand Up @@ -299,13 +317,27 @@
}
},
"additionalProperties": false
},
}
}
},
"settingsPropertiesCustom": {
"properties": {
"custom": {
"description": "Generate custom CSS custom properties of the form `--wp--custom--{key}--{nested-key}: {value};`. `camelCased` keys are transformed to `kebab-case` as to follow the CSS property naming schema. Keys at different depth levels are separated by `--`, so keys should not include `--` in the name.",
"$ref": "#/definitions/settingsCustomAdditionalProperties"
}
}
},
"settingsProperties": {
"allOf":[
{ "$ref": "#/definitions/settingsPropertiesBorder" },
{ "$ref": "#/definitions/settingsPropertiesColor" },
{ "$ref": "#/definitions/settingsPropertiesLayout" },
{ "$ref": "#/definitions/settingsPropertiesSpacing" },
{ "$ref": "#/definitions/settingsPropertiesTypography" },
{ "$ref": "#/definitions/settingsPropertiesCustom" }
]
},
"settingsPropertiesComplete": {
"type": "object",
"allOf": [
Expand Down Expand Up @@ -338,7 +370,28 @@
"$ref": "#/definitions/settingsPropertiesComplete"
},
"core/button": {
"$ref": "#/definitions/settingsPropertiesComplete"
"allOf":[
{
"properties": {
"border": {
"description": "Settings related to borders.\nGutenberg plugin required.",
"type": "object",
"properties": {
"radius": {
"description": "Allow users to set custom border radius.\nGutenberg plugin required.",
"type": "boolean",
"default": false
}
}
}
}
},
{ "$ref": "#/definitions/settingsPropertiesColor" },
{ "$ref": "#/definitions/settingsPropertiesLayout" },
{ "$ref": "#/definitions/settingsPropertiesSpacing" },
{ "$ref": "#/definitions/settingsPropertiesTypography" },
{ "$ref": "#/definitions/settingsPropertiesCustom" }
]
},
"core/buttons": {
"$ref": "#/definitions/settingsPropertiesComplete"
Expand Down Expand Up @@ -579,7 +632,7 @@
}
},
"patternProperties": {
"^[a-z][a-z0-9-]*/[a-z][a-z0-9-]*$": {
"^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$": {
"$ref": "#/definitions/settingsPropertiesComplete"
}
},
Expand Down