[英]Gutenberg blocks: RichText default value displaying HTML tags
当我在下面的 Gutenberg 块中包含标签时,它会在编辑器和前端输出 HTML 标签。 这只发生在默认文本中——从编辑器中添加链接时,它会正确呈现:
attributes: {
text: {
type: 'array',
source: 'children',
selector: 'p',
default: 'Here is the test <a href="https://example.com">link</a>',
},
}
edit: ({ attributes: { text }, setText ) => {
return <RichText
placeholder="Text..."
tagName="p"
onChange={setText}
value={text}
allowedFormats={['core/bold', 'core/italic', 'core/link']}
/>
}
save: () => {
return <RichText.Content tagName="p" value={text} />
}
输出(包裹在<p>
标签中):
Here is the test <a href="https://example.com">link</a>
曾尝试从古腾堡核心/链接完全复制标记:
default: 'Here is the test <a href="https://example.com">link</a>'
输出(包裹在<p>
标签中):
Here is the test <a href="https://example.com">link</a>
并尝试使用标签作为对象设置默认文本:
default: `Here is the test ${<a href="https://example.com">link</a>}`
输出(包裹在<p>
标签中):
Here is the test [object Object]
我怎样才能得到这个默认文本来输出标签本身?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.