编辑器控件
编辑器控件是指在主题内通过 schema tag 定义的 settings 属性,这些属性定义的控件类型会展示在主题编辑器中。
基础控件类型
标准属性
以下是每个编辑器控件的标准属性。根据控件类型的不同,会有额外的专有属性。
| 属性 | 描述 | 是否必填 |
|---|---|---|
| type | 控件类型 | 是 |
| id | 配置 ID,用于访问配置值 | 是 |
| label | 配置标签,将呈现在主题编辑器中 | 是 |
| default | 配置的默认值 | 否 |
| info | 配置的提示信息 | 否 |
text
此类型的控件会输出一个单行文本输入框。
额外属性:
| 属性 | 描述 | 是否必填 |
|---|---|---|
| placeholder | 输入框的占位文本 | 否 |
此控件可用于单行文本的输入,例如组件的标题。
示例代码:
{
"name": "My Section",
"settings": [
{
"type": "text",
"id": "title",
"label": "Title",
"default": "my section title",
"placeholder": "please enter title"
}
],
"presets": [
{
"name": "My Section"
}
]
}
输出:

当访问此控件的配置值时,数据以 string 类型的形式返回。
textarea
此类型的控件会输出一个多行文本输入框。
额外属性:
| 属性 | 描述 | 是否必填 |
|---|---|---|
| placeholder | 输入框占位文本 | 否 |
| limit | 文本输入最大长度 | 否 |
此控件可用于多行文本的输入,例如组件的内容。
示例代码:
{
"name": "My Section",
"settings": [
{
"type": "textarea",
"id": "content",
"label": "Content",
"default": "my section content",
"placeholder": "please enter content",
"limit": 500
}
],
"presets": [
{
"name": "My Section"
}
]
}
输出:

当访问此控件的配置值时,数据以 string 类型的形式返回。
richtext
此类型的控件会输出一个富文本输入框。会输出具有以下基本格式的文本:
- 加粗文本
- 斜体文本
- 超链接
- 段落
此控件可用于多类型内容的正文文本展示,例如博客文章的正文。
示例代码:
{
"name": "My Section",
"settings": [
{
"type": "richtext",
"id": "content",
"label": "Content",
"default": "content"
}
],
"presets": [
{
"name": "My Section"
}
]
}
输出:

当访问此控件的配置值时,数据以 string 类型的形式返回。
range
此控件会输出一个滑动控制器。
额外属性:
| 属性 | 描述 | 是否必填 |
|---|---|---|
| min | 最小值 | 是 |
| max | 最大值 | 是 |
| step | 滑块步长,设置的值必须大于 0,并且可被最大值和最小值的差值整除。 | 是 |
| unit | 输入值的单位。此单位将展示在控件上 | 否 |
- default 属性是必填的。
- min、max、step 和 unit 属性必须是数字类型。
此控件可用于调整多个数值,例如组件的宽度。
示例代码:
{
"name": "My Section",
"settings": [
{
"type": "range",
"id": "width",
"label": "Width",
"default": 100,
"min": 100,
"max": 1000,
"step": 10,
"unit": "px"
}
],
"presets": [
{
"name": "My Section"
}
]
}
输出:

当访问此控件的配置值时,数据以 string 类型的形式返回。
select
此控件会输出一个下拉选择框。
额外属性:
| 属性 | 描述 | 是否必填 |
|---|---|---|
| options | 选项数组,数组的每项包括 • label:名称• value:值 | 是 |
此控件可用于选项数量多的单选场景,例如图标选择。
示例代码:
{
"name": "My Section",
"settings": [
{
"type": "select",
"id": "icon",
"label": "Icon",
"default": "none",
"options": [
{
"label": "none",
"value": "none"
},
{
"label": "pay",
"value": "pay"
},
{
"label": "package",
"value": "package"
},
{
"label": "email",
"value": "email"
},
{
"label": "position",
"value": "position"
},
{
"label": "customer",
"value": "customer"
},
{
"label": "chat",
"value": "chat"
},
{
"label": "gift",
"value": "gift"
},
{
"label": "phone",
"value": "phone"
},
{
"label": "faq",
"value": "faq"
},
{
"label": "logistics",
"value": "logistics"
},
{
"label": "discount",
"value": "discount"
}
]
}
],
"presets": [
{
"name": "My Section"
}
]
}
输出:

当访问此控件的配置值时,数据以 string 类型的形式返回。
switch
此控件会输出一个开关控件。
此控件可用于切换功能的开启和关闭,例如是否展示国家选择器。
如果没有指定 default 的值,则默认为 false。
示例代码:
{
"name": "My Section",
"settings": [
{
"type": "switch",
"id": "show_country_selector",
"label": "Show country selector",
"default": true
}
],
"presets": [
{
"name": "My Section"
}
]
}
输出:

当访问此控件的配置值时,数据以 boolean 类型的形式返回。
text_align
此控件会输出一个文本在水平方向上对齐方式的选择控件。
此控件可用于文本对齐方式,例如标题在水平方向上的对齐方式。
示例代码:
{
"name": "My Section",
"settings": [
{
"type": "text_align",
"id": "text_align",
"label": "Text align",
"default": "left"
}
],
"presets": [
{
"name": "My Section"
}
]
}
输出:

当访问此控件的配置值时,数据以 string 类型的形式返回。
此控件返回的枚举值如下,也是 default 属性可以设置的值:
- left
- center
- right
vertical_align
此控件会输出一个垂直方向上对齐方式的选择控件。
此控件可用于垂直交叉轴上元素的对齐方式,例如组件区块之间的对齐方式。
示例代码:
{
"name": "My Section",
"settings": [
{
"type": "vertical_align",
"id": "vertical_align",
"label": "Vertical align",
"default": "top"
}
],
"presets": [
{
"name": "My Section"
}
]
}
输出:

当访问此控件的配置值时,数据以 string 类型的形式返回。
此控件返回的枚举值如下,也是 default 属性可以设置的值:
- top
- middle
- bottom
horizontal_align
此控件会输出一个水平方向上对齐方式的选择控件。
此控件可用于水平主轴上元素的对齐方式,例如组件区块之间的对齐方式。
示例代码:
{
"name": "My Section",
"settings": [
{
"type": "horizontal_align",
"id": "horizontal_align",
"label": "Horizontal align",
"default": "left"
}
],
"presets": [
{
"name": "My Section"
}
]
}
输出:

当访问此控件的配置值时,数据以 string 类型的形式返回。
此控件返回的枚举值如下,也是 default 属性可以设置的值:
- left
- center
- right
url
此类型的控件会输出一个统一的 URL 配置器,供商家在构建在线商店时配置跳转目标。
商家可以在输入框中输入外部的 URL、相对路径,或是一个电话拨号。同时,商家也可以在下拉选择器中选择其网站内的预设页面。
支持页面的枚举如下:
- 首页
- 商品分类页
- 商品详情页
- 自定义页面
- 政策页
- 博客集合页面
- 博客文章页
- 个人中心页
- 购物车页
示例代码:
{
"name": "My Section",
"settings": [
{
"type": "url",
"id": "url",
"label": "Url"
},
{
"type": "url",
"id": "tel",
"label": "Tel"
}
],
"presets": [
{
"name": "My Section",
"settings": {
"tel": "tel:+86123456789"
}
}
]
}
输出:

当访问此控件的配置值时,数据会以以下形式之一返回:
- 字符串 (String):商家直接在输入框中填写的 URL 字符串。例如,
tel:+1123-***-7890或https://example.com。 - 资源对象 (Resource object):商家在下拉选择器中选择预设页面时,系统会返回一个包含页面类型和 ID 的结构化对象。
- 空字符串 (Empty string):如果商家没有输入任何内容或选择任何页面,则返回空字符串。
color
此类型的控件会输出一个颜色选择器控件。
你可以在输入框中输入颜色色值,或者使用颜色面板选择器来选择所需要的颜色。
此控件可用于控制元素的各种颜色,例如页面背景颜色。
示例代码:
{
"name": "My Section",
"settings": [
{
"type": "color",
"id": "text_color",
"label": "Text color",
"default": "#ffffff"
}
],
"presets": [
{
"name": "My Section"
}
]
}
输出:

当访问此控件的配置值时,数据会以以下形式之一返回:
- color object
- 如果未进行选择,则返回空。
color_background
此类型的控件会输出一个渐变颜色选择器控件。
你可以在控件中选择预设的渐变颜色方案,也可以自行调整渐变颜色方案。
此控件可用于控制元素的渐变背景颜色,例如页面背景颜色。
示例代码:
{
"name": "My Section",
"settings": [
{
"type": "color_background",
"id": "color_background",
"label": "Background color",
"default": ""
}
],
"presets": [
{
"name": "My Section"
}
]
}
此控件的 default 属性设置为空字符串,会以无颜色的进行展示。
输出:

当访问此控件的配置值时,数据会以 CSS 代码中的线性渐变或者径向渐变返回:
color_scheme
此类型的控件会输出一个包含所有可用主题配色方案的选择器,并展示所选配色方案的预览效果。
选择器中的主题配色方案通过 color_scheme_group 设置项进行定义。
你可以将配色方案应用到全局主题配置、组件和区块中。
示例代码:
{
"name": "My Section",
"settings": [
{
"type": "color_scheme",
"id": "color_scheme",
"label": "Color scheme",
"default": "scheme-1"
}
],
"presets": [
{
"name": "My Section"
}
]
}
输出:

在访问此控件设置的值时,SHOPLINE 会从 color_scheme_group 中返回选中的 color_scheme object。
color_scheme_group
此类型的控件会输出一个颜色方案,你可以通过此控件修改主题的配色方案。
颜色方案中定义的颜色只能 在 settings.schema.json 中添加。
{
"type": "color_scheme_group",
"id": "color_schemes",
"definition": [
{
"type": "color_background",
"id": "color_background",
"label": "t:settings_schema.color.settings.color_schemes.definition_0.label",
"default": "#F3F2E0"
},
{
"type": "color",
"id": "color_text",
"label": "t:settings_schema.color.settings.color_schemes.definition_1.label",
"default": "#3D3819"
},
{
"type": "color",
"id": "color_light_text",
"label": "t:settings_schema.color.settings.color_schemes.definition_2.label",
"default": "#726C4A"
},
{
"type": "color",
"id": "color_entry_line",
"label": "t:settings_schema.color.settings.color_schemes.definition_3.label",
"default": "#DDDDDD"
},
{
"type": "color",
"id": "color_button_background",
"label": "t:settings_schema.color.settings.color_schemes.definition_4.label",
"default": "#3D3819"
},
{
"type": "color",
"id": "color_button_text",
"label": "t:settings_schema.color.settings.color_schemes.definition_5.label",
"default": "#F3F2E0"
},
{
"type": "color",
"id": "color_button_secondary_background",
"label": "t:settings_schema.color.settings.color_schemes.definition_6.label",
"default": "#F3F2E0"
},
{
"type": "color",
"id": "color_button_secondary_text",
"label": "t:settings_schema.color.settings.color_schemes.definition_7.label",
"default": "#3D3819"
},
{
"type": "color",
"id": "color_button_secondary_border",
"label": "t:settings_schema.color.settings.color_schemes.definition_8.label",
"default": "#726C4A"
},
{
"type": "color",
"id": "color_button_text_link",
"label": "t:settings_schema.color.settings.color_schemes.definition_9.label",
"default": "#3D3819"
}
],
"role": {
"text": "color_text",
"background": {
"solid": "color_background"
},
"primary_button": "color_button_background",
"primary_button_border": "color_entry_line",
"secondary_button": "color_button_secondary_background",
"secondary_button_border": "color_button_secondary_border"
}
}
输出:

在 definition 中定义颜色控件,颜色控件的类型仅支持以下类型:
- color
- color_background
role 字段会输出配色方案的预览。每个字段代表预览图上的位置,每个字段的值是在 definition 里面定义控件的 id 值。

role 字段定义规则:
| Role 字段 | 类型 | 描述 | 是否必填 |
|---|---|---|---|
| background | • string • { solid: string; gradient: string; } | 渲染背景颜色 | 是 |
| text | string | 渲染文本颜色 | 是 |
| primary_button | string | 渲染文本下方第一个按钮颜色 | 是 |
| secondary_button | string | 渲染文本下方第二个按钮颜色 | 是 |
| primary_button_border | string | 渲染文本下方第一个按钮的边框颜色 | 是 |
| secondary_button_border | string | 渲染文本下方第二个按钮的边框颜色 | 是 |
image
此类型的控件会输出一个图片选择器。
此控件可以直接选择 SHOPLINE 商家后台图片库内的图片,并且可以选择上传新的图片。
示例代码:
{
"name": "My Section",
"settings": [
{
"type": "image",
"id": "image",
"label": "Image"
}
],
"presets": [
{
"name": "My Section"
}
]
}
输出:
