自定义古腾堡块在添加到编辑器时专注于内部块
Custom Gutenberg block focuses on inner block when added to the editor
我创建了一个带有嵌套内部块的自定义古腾堡块。编辑功能如下所示:
edit: (props) => {
<div className="custom-block">
<InnerBlocks
template={[
[ 'core/columns', {'className': 'page-layout-columns columns is-multiline'}, [
[ 'core/column', {'className': 'column is-two-thirds-desktop is-full-tablet is-full-mobile page-layout-main'},[['core/paragraph', {'placeholder': 'Main content area. Start typing to add content, or remove this default paragraph block and then add new blocks.'}]] ],
[ 'core/column', {'className': 'column is-one-quarter-desktop is-full-tablet is-full-mobile page-layout-sidebar'},[['core/paragraph', {'placeholder': 'Sidebar content area. Start typing to add content, or remove this default paragraph block and then add new blocks.'}]]],
]
]]}
/>
</div>}
当这个块被添加到编辑器时,核心列块而不是块包装器被聚焦。我应该怎么做才能使块包装器成为初始焦点?非常感谢任何意见。
谢谢!
对于那些也有这个问题的人,有一个 属性
templateInsertUpdatesSelection={ false }
可以删除列块上的自动对焦。
我创建了一个带有嵌套内部块的自定义古腾堡块。编辑功能如下所示:
edit: (props) => {
<div className="custom-block">
<InnerBlocks
template={[
[ 'core/columns', {'className': 'page-layout-columns columns is-multiline'}, [
[ 'core/column', {'className': 'column is-two-thirds-desktop is-full-tablet is-full-mobile page-layout-main'},[['core/paragraph', {'placeholder': 'Main content area. Start typing to add content, or remove this default paragraph block and then add new blocks.'}]] ],
[ 'core/column', {'className': 'column is-one-quarter-desktop is-full-tablet is-full-mobile page-layout-sidebar'},[['core/paragraph', {'placeholder': 'Sidebar content area. Start typing to add content, or remove this default paragraph block and then add new blocks.'}]]],
]
]]}
/>
</div>}
当这个块被添加到编辑器时,核心列块而不是块包装器被聚焦。我应该怎么做才能使块包装器成为初始焦点?非常感谢任何意见。 谢谢!
对于那些也有这个问题的人,有一个 属性 templateInsertUpdatesSelection={ false } 可以删除列块上的自动对焦。