diff --git a/bin/api-docs/gen-theme-reference.js b/bin/api-docs/gen-theme-reference.js index 2584b1fea2fc86..09c1d36802036f 100644 --- a/bin/api-docs/gen-theme-reference.js +++ b/bin/api-docs/gen-theme-reference.js @@ -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 ) => { diff --git a/schemas/json/theme.json b/schemas/json/theme.json index c10b50e4ee2f19..32b831689b30a4 100644 --- a/schemas/json/theme.json +++ b/schemas/json/theme.json @@ -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", @@ -40,7 +40,11 @@ } }, "additionalProperties": false - }, + } + } + }, + "settingsPropertiesColor": { + "properties": { "color": { "description": "Settings related to colors.", "type": "object", @@ -160,7 +164,12 @@ } }, "additionalProperties": false - }, + } + + } + }, + "settingsPropertiesLayout": { + "properties": { "layout": { "description": "Settings related to layout.", "type": "object", @@ -175,7 +184,12 @@ } }, "additionalProperties": false - }, + } + } + }, + + "settingsPropertiesSpacing":{ + "properties": { "spacing": { "description": "Settings related to spacing.", "type": "object", @@ -208,7 +222,11 @@ } }, "additionalProperties": false - }, + } + } + }, + "settingsPropertiesTypography":{ + "properties": { "typography": { "description": "Settings related to typography.", "type": "object", @@ -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": [ @@ -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" @@ -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" } },