@elementor/editor-app-bar

中文文档
4.4.1发布于 2026/11/16GPL-3.0-or-laterTypeScriptESM + CJS构建来源已验证近 30 天下载 1.1万

App Bar extension for @elementor/editor

原始使用文档
文档目录4 节
  1. Usage
  2. Menus
  3. Custom Locations
  4. Registering from outside this repository

Editor App Bar

[!WARNING] Please refrain from accessing or depending on functions and variables starting with double underscores, as they are subject to change without notice. Naming convention involving double underscores (__) as a prefix to indicate that a function or variable is meant for internal use and should not be accessed or relied upon by third-party developers.

Usage

Menus

There are 5 types of menus:

  • mainMenu - Provides access to the main features and functionality of the application. Represented by an Elementor logo that changes to a hamburger.
  • toolsMenu - A menu where the user can access various editing tools (e.g. "add widget", "structure", etc.) for manipulating the data or interface in some way. This section may contain a limited number of buttons for common tools, as well as a dropdown menu for accessing additional ones.
  • utilitiesMenu - A menu where the user can access various utility features that are not directly related to the main functionality of the application. This may include options for accessing the finder, getting help, or accessing other miscellaneous features.
  • documentOptionsMenu - A menu where the user can access various options for saving the document. This may include options for saving as draft or conditional options related to the document (e.g. "display conditions", etc.).
  • integrationsMenu - A sub-menu inside the mainMenu where the user can access various options for integrating with other services. This may include options for connecting to a third-party service or accessing other miscellaneous features.

Each menu contains a list of items, each item can be:

  • Action - A button that performs an action.
  • Link - A link that navigates to a different page.
  • ToggleAction - A button that toggles between two states (checked or unchecked).

Let's extend the integrationsMenu with multiple examples that will cover all the types of items:

Action

import { integrationsMenu } from '@elementor/editor-app-bar';
import { PlusIcon } from '@elementor/icons';
import { __ } from '@wordpress/i18n';

integrationsMenu.registerAction( {
    id: 'example-action-id',
    props: {
        title: __( 'My Custom Action', 'elementor' ),
        icon: PlusIcon, // A react component that renders an SVG icon
        disabled: false, // Optional
        onClick: () => alert( 'Custom action triggered!' ), // Optional
    }
} );    

ToggleAction

import { integrationsMenu } from '@elementor/editor-app-bar';
import { EyeIcon } from '@elementor/icons';
import { __ } from '@wordpress/i18n';

integrationsMenu.registerToggleAction( {
    id: 'my-custom-toggle',
    useProps: () => {
        const [ isSelected, setIsSelected ] = useState( false );

        return {
            title: __( 'My Custom Toggle', 'elementor' ),
            icon: EyeIcon,
            selected: isSelected, // Optional
            onClick: () => setIsSelected( ( prev ) => ! prev ), // Optional
            disabled: false, // Optional
        };
    },
} );
import { integrationsMenu } from '@elementor/editor-app-bar';
import { LinkIcon } from '@elementor/icons';
import { __ } from '@wordpress/i18n';

integrationsMenu.registerLink( {
    id: 'my-custom-link',
    props: {
        title: __( 'My Custom Link', 'elementor' ),
        icon: LinkIcon,
        href: 'https://elementor.com', // Optional
        target: '_blank', // Optional
    },
} );

[!NOTE] You can use either props or useProps (depending on your need) for all the items types:

  • props - An object with the action props.
  • useProps - A React hook that returns the action props and lets you make the props reactive.

[!NOTE] The icon property can be any React component that renders an SVG icon, it is recommended to use SVGIcon from @elementor/ui

Custom Locations

In addition to the menus above, a few locations accept full custom React components via injectInto* functions:

  • injectIntoPageIndication - Injects a component next to the document title, in the center of the app bar.
  • injectIntoResponsive - Injects a component next to the responsive/breakpoints switcher, in the center of the app bar.
  • injectIntoPrimaryAction - Injects a component next to the primary action (e.g. "Publish"/"Save"), on the right side of the app bar.
import { injectIntoPageIndication } from '@elementor/editor-app-bar';

injectIntoPageIndication( {
    id: 'my-custom-indication',
    component: () => <div>Custom content</div>,
    options: {
        priority: 10, // Optional, lower value means higher priority. Default is 10.
    },
} );

[!NOTE] Both the menus (registerAction/registerLink/registerToggleAction) and the custom locations (injectInto*) are reactive: registering an item at any time (including after the editor has already loaded) will make it appear immediately, so plugins that load their scripts after the editor (e.g. Pro plugins, or third-party plugins) don't need to register before the app bar has rendered.

Registering from outside this repository

Third-party plugins (e.g. Elementor Pro, or any WordPress plugin) can register items into the app bar without being part of this monorepo's build, by depending on the elementor-v2-editor-app-bar script handle and using the elementorV2.editorAppBar global (which is the same object exported from @elementor/editor-app-bar):

add_action( 'elementor/editor/v2/scripts/enqueue', function () {
    wp_enqueue_script(
        'my-plugin-editor-app-bar',
        plugins_url( 'assets/editor-app-bar.js', __FILE__ ),
        [ 'elementor-v2-editor-app-bar', 'elementor-v2-ui', 'elementor-v2-icons' ],
        '1.0.0',
        true
    );
} );
// my-plugin-editor-app-bar.js
if ( window.elementorV2?.editorAppBar ) {
    const { utilitiesMenu } = window.elementorV2.editorAppBar;

    utilitiesMenu.registerLink( {
        id: 'my-plugin-link',
        props: {
            title: 'My Plugin',
            icon: MyIcon,
            href: 'https://example.com',
        },
    } );
}

Make sure to always use id (not name) when registering menu items, and to guard the call with a check for window.elementorV2.editorAppBar, since script load order across plugins is not guaranteed.

版本与发布记录

@elementor/editor-app-bar 共发布 1,185 个版本,首次发布于 2023/04/30;过去 12 个月发布了 858 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
4.4.1latest2026/11/16今天
4.5.0-1192build2026/11/16今天
4.5.0-11912026/11/16今天
4.5.0-11902026/11/16今天
4.5.0-11892026/11/16今天
4.5.0-11882026/11/151 天前

其他发布通道:manual → 4.1.0-manual,4.2-beta1 → 4.2.0-beta1,beta → 4.4.0-beta3,build → 4.5.0-1192。

关于 @elementor/editor-app-bar 的常见问题

@elementor/editor-app-bar 是什么?

App Bar extension for @elementor/editor

如何安装 @elementor/editor-app-bar?

在项目目录运行 npm install @elementor/editor-app-bar,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^18.3.1)、react-dom(^18.3.1)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@elementor/editor-app-bar 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@elementor/editor-app-bar 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@elementor/editor-app-bar 可以商用吗?

@elementor/editor-app-bar 使用 GPL-3.0-or-later 许可。强 Copyleft:分发包含该代码的软件时,整个作品需以 GPL-3.0 兼容许可开源,并附带专利与反锁定条款。仅内部使用不触发此义务。以上为概括,不构成法律意见,请以许可原文为准。

@elementor/editor-app-bar 的下载量有多少?

根据 npm 官方下载统计,@elementor/editor-app-bar 在 2026/10/14 – 2026/11/12 这 30 天内被下载 11,370 次,日均约 379 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@elementor/editor-app-bar 还在维护吗?

最新版本 4.4.1 发布于 2026/11/16(今天);至今共发布 1185 个版本,其中过去 12 个月发布了 858 个;首次发布于 2023/04/30。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。