Sanity.io code input – 如何为突出显示的行添加输入字段?
Sanity.io code input – how to add an input field for highlighted lines?
我一直在尝试将 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,
}
},
],
};
我很乐意接受任何建议。
您可以通过单击左侧的行号来突出显示一行。可以添加到文档中:)
我一直在尝试将 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,
}
},
],
};
我很乐意接受任何建议。
您可以通过单击左侧的行号来突出显示一行。可以添加到文档中:)