【发布时间】:2021-01-24 07:14:57
【问题描述】:
我一直在尝试将 highlightedLines 字段添加到 Sanity.io 代码输入。我发现的唯一文档在模块的npm page 上,并且有一个示例数据模型:
{
_type: 'code',
language: 'js',
highlightedLines: [1, 2], // <--- I need to have this field accessible in sanity studio
code: 'const foo = "bar"\nconsole.log(foo.toUpperCase())\n// BAR'
}
我尝试(天真地)将fields: { foo: "array" } 属性添加到blockContent.js 中的“代码块”对象,但随后工作室没有编译,抛出Cannot override 'fields' of subtypes of "object" 错误。
我是否需要从code 创建新类型并分别用其他字段装饰它?
// current blockContent.js
export default {
title: "Block Content",
name: "blockContent",
type: "array",
of: [
{
// ...
{
type: "image",
options: { hotspot: true },
},
{
title: "Code block",
name: "code",
type: "code",
options: {
withFilename: true,
}
},
],
};
我很乐意接受任何建议。
【问题讨论】:
标签: javascript user-input sanity