@elementor/editor-app-bar 4.3.0-986 → 4.3.0-988

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -55,7 +55,7 @@ import { EyeIcon } from '@elementor/icons';
55
55
  import { __ } from '@wordpress/i18n';
56
56
 
57
57
  integrationsMenu.registerToggleAction( {
58
- name: 'my-custom-toggle',
58
+ id: 'my-custom-toggle',
59
59
  useProps: () => {
60
60
  const [ isSelected, setIsSelected ] = useState( false );
61
61
 
@@ -78,7 +78,7 @@ import { LinkIcon } from '@elementor/icons';
78
78
  import { __ } from '@wordpress/i18n';
79
79
 
80
80
  integrationsMenu.registerLink( {
81
- name: 'my-custom-link',
81
+ id: 'my-custom-link',
82
82
  props: {
83
83
  title: __( 'My Custom Link', 'elementor' ),
84
84
  icon: LinkIcon,
@@ -100,4 +100,63 @@ integrationsMenu.registerLink( {
100
100
 
101
101
  ### Custom Locations
102
102
 
103
- TBD
103
+ In addition to the menus above, a few locations accept full custom React components via `injectInto*` functions:
104
+
105
+ - `injectIntoPageIndication` - Injects a component next to the document title, in the center of the app bar.
106
+ - `injectIntoResponsive` - Injects a component next to the responsive/breakpoints switcher, in the center of the app bar.
107
+ - `injectIntoPrimaryAction` - Injects a component next to the primary action (e.g. "Publish"/"Save"), on the right side of the app bar.
108
+
109
+ ```tsx
110
+ import { injectIntoPageIndication } from '@elementor/editor-app-bar';
111
+
112
+ injectIntoPageIndication( {
113
+ id: 'my-custom-indication',
114
+ component: () => <div>Custom content</div>,
115
+ options: {
116
+ priority: 10, // Optional, lower value means higher priority. Default is 10.
117
+ },
118
+ } );
119
+ ```
120
+
121
+ > [!NOTE]
122
+ > Both the menus (`registerAction`/`registerLink`/`registerToggleAction`) and the custom locations (`injectInto*`) are reactive:
123
+ > registering an item at any time (including after the editor has already loaded) will make it appear immediately, so
124
+ > plugins that load their scripts after the editor (e.g. Pro plugins, or third-party plugins) don't need to register
125
+ > before the app bar has rendered.
126
+
127
+ ### Registering from outside this repository
128
+
129
+ Third-party plugins (e.g. Elementor Pro, or any WordPress plugin) can register items into the app bar without being
130
+ part of this monorepo's build, by depending on the `elementor-v2-editor-app-bar` script handle and using the
131
+ `elementorV2.editorAppBar` global (which is the same object exported from `@elementor/editor-app-bar`):
132
+
133
+ ```php
134
+ add_action( 'elementor/editor/v2/scripts/enqueue', function () {
135
+ wp_enqueue_script(
136
+ 'my-plugin-editor-app-bar',
137
+ plugins_url( 'assets/editor-app-bar.js', __FILE__ ),
138
+ [ 'elementor-v2-editor-app-bar', 'elementor-v2-ui', 'elementor-v2-icons' ],
139
+ '1.0.0',
140
+ true
141
+ );
142
+ } );
143
+ ```
144
+
145
+ ```js
146
+ // my-plugin-editor-app-bar.js
147
+ if ( window.elementorV2?.editorAppBar ) {
148
+ const { utilitiesMenu } = window.elementorV2.editorAppBar;
149
+
150
+ utilitiesMenu.registerLink( {
151
+ id: 'my-plugin-link',
152
+ props: {
153
+ title: 'My Plugin',
154
+ icon: MyIcon,
155
+ href: 'https://example.com',
156
+ },
157
+ } );
158
+ }
159
+ ```
160
+
161
+ Make sure to always use `id` (not `name`) when registering menu items, and to guard the call with a check for
162
+ `window.elementorV2.editorAppBar`, since script load order across plugins is not guaranteed.