Skip to main content

injectContentManagerComponent() 已移除

🌐 injectContentManagerComponent() removed

在 Strapi 5 中,injectContentManagerComponent 方法被移除,因为内容管理器现在是一个插件。管理面板 API 方法被 getPlugin('content-manager').injectComponent() 替代。

🌐 In Strapi 5, the injectContentManagerComponent method is removed because the Content Manager is now a plugin. The Admin Panel API method is replaced by getPlugin('content-manager').injectComponent().

此页面是重大更改数据库的一部分,提供关于重大更改的信息以及从 Strapi v4 迁移到 Strapi 5 的附加说明。

🌐 This page is part of the breaking changes database and provides information about the breaking change and additional instructions to migrate from Strapi v4 to Strapi 5.

 Is this breaking change affecting plugins?Yes
 Is this breaking change automatically handled by a codemod?No

重大变更描述

🌐 Breaking change description

在 Strapi v4 中

组件注入内容管理器如下:

🌐 A component is injected into the Content Manager as follows:

app.injectContentManagerComponent('editView', 'right-links', {
name: 'PreviewButton',
Component: () => (
<Button onClick={() => window.alert('Not here, The preview is.')}>Preview</Button>
),
});

在 Strapi 5 中

组件注入内容管理器如下:

🌐 A component is injected into the Content Manager as follows:

app.getPlugin('content-manager').injectComponent('editView', 'right-links', {
name: 'PreviewButton',
Component: () => (
<Button onClick={() => window.alert('Not here, The preview is.')}>Preview</Button>
),
});

迁移步骤

🌐 Migration steps

将你的插件 index.ts 文件从:

🌐 Change your plugin index.ts file from:

app.injectContentManagerComponent()

到以下:

🌐 to the following:

app.getPlugin('content-manager').injectComponent()