Wordpress - 如何在文档侧边栏的模板面板中添加新组件?

问题描述 投票:0回答:1

有没有办法在模板面板中添加 TextControl 组件或任何其他元素?

文档展示了如何在状态和可见性面板中插入项目,但我找不到其他面板的操作方法。

javascript wordpress wordpress-gutenberg gutenberg-blocks
1个回答
0
投票

自发布此问题以来,“模板”部分已移至摘要。扩展 PluginPostStatusInfo 的文档显示了撰写本文时的旧 UI。 WordPress 6.1.1 中的 UI 显示为:

PluginPostStatusInfo
插槽仍然用于将内容附加到 Post/Page > Summary 部分。

例如。添加文本控件:

import { registerPlugin } from '@wordpress/plugins';
import { PluginPostStatusInfo } from '@wordpress/edit-post';
import { TextControl } from '@wordpress/components';

const AddMyTextControl = () => (
    <PluginPostStatusInfo>
        <TextControl
            label="My Text"
            ...
        />
    </PluginPostStatusInfo>
);

registerPlugin('add-my-text-control', { render: AddMyTextControl });
© www.soinside.com 2019 - 2024. All rights reserved.