@elementor/editor-variables 4.0.0-659 → 4.0.0-660

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elementor/editor-variables",
3
- "version": "4.0.0-659",
3
+ "version": "4.0.0-660",
4
4
  "private": false,
5
5
  "author": "Elementor Team",
6
6
  "homepage": "https://elementor.com/",
@@ -39,22 +39,22 @@
39
39
  "dev": "tsup --config=../../tsup.dev.ts"
40
40
  },
41
41
  "dependencies": {
42
- "@elementor/editor": "4.0.0-659",
43
- "@elementor/editor-canvas": "4.0.0-659",
44
- "@elementor/editor-controls": "4.0.0-659",
45
- "@elementor/editor-current-user": "4.0.0-659",
46
- "@elementor/editor-mcp": "4.0.0-659",
47
- "@elementor/editor-panels": "4.0.0-659",
48
- "@elementor/editor-props": "4.0.0-659",
49
- "@elementor/editor-ui": "4.0.0-659",
50
- "@elementor/editor-v1-adapters": "4.0.0-659",
51
- "@elementor/menus": "4.0.0-659",
52
- "@elementor/http-client": "4.0.0-659",
42
+ "@elementor/editor": "4.0.0-660",
43
+ "@elementor/editor-canvas": "4.0.0-660",
44
+ "@elementor/editor-controls": "4.0.0-660",
45
+ "@elementor/editor-current-user": "4.0.0-660",
46
+ "@elementor/editor-mcp": "4.0.0-660",
47
+ "@elementor/editor-panels": "4.0.0-660",
48
+ "@elementor/editor-props": "4.0.0-660",
49
+ "@elementor/editor-ui": "4.0.0-660",
50
+ "@elementor/editor-v1-adapters": "4.0.0-660",
51
+ "@elementor/menus": "4.0.0-660",
52
+ "@elementor/http-client": "4.0.0-660",
53
53
  "@elementor/icons": "^1.68.0",
54
- "@elementor/events": "4.0.0-659",
55
- "@elementor/schema": "4.0.0-659",
54
+ "@elementor/events": "4.0.0-660",
55
+ "@elementor/schema": "4.0.0-660",
56
56
  "@elementor/ui": "1.37.2",
57
- "@elementor/utils": "4.0.0-659",
57
+ "@elementor/utils": "4.0.0-660",
58
58
  "@wordpress/i18n": "^5.13.0"
59
59
  },
60
60
  "peerDependencies": {
@@ -0,0 +1,46 @@
1
+ import { useEffect, useRef, useState } from 'react';
2
+ import {
3
+ __privateListenTo as listenTo,
4
+ __privateOpenRoute as openRoute,
5
+ routeOpenEvent,
6
+ } from '@elementor/editor-v1-adapters';
7
+
8
+ import { usePanelActions } from './variables-manager/variables-manager-panel';
9
+
10
+ const EVENT_NAME = 'elementor/open-variables-manager';
11
+ const DEFAULT_PANEL_ROUTE = 'panel/elements/categories';
12
+
13
+ export function OpenPanelFromEvent() {
14
+ const { open } = usePanelActions();
15
+ const pendingRef = useRef( false );
16
+ const [ readyToOpen, setReadyToOpen ] = useState( false );
17
+
18
+ useEffect( () => {
19
+ if ( readyToOpen ) {
20
+ setReadyToOpen( false );
21
+ open();
22
+ }
23
+ }, [ readyToOpen, open ] );
24
+
25
+ useEffect( () => {
26
+ return listenTo( routeOpenEvent( DEFAULT_PANEL_ROUTE ), () => {
27
+ if ( pendingRef.current ) {
28
+ pendingRef.current = false;
29
+ setReadyToOpen( true );
30
+ }
31
+ } );
32
+ }, [] );
33
+
34
+ useEffect( () => {
35
+ const handler = () => {
36
+ pendingRef.current = true;
37
+ openRoute( DEFAULT_PANEL_ROUTE );
38
+ };
39
+
40
+ window.addEventListener( EVENT_NAME, handler );
41
+
42
+ return () => window.removeEventListener( EVENT_NAME, handler );
43
+ }, [] );
44
+
45
+ return null;
46
+ }
package/src/init.ts CHANGED
@@ -4,6 +4,7 @@ import { __registerPanel as registerPanel } from '@elementor/editor-panels';
4
4
  import { isTransformable, type PropValue } from '@elementor/editor-props';
5
5
  import { controlActionsMenu } from '@elementor/menus';
6
6
 
7
+ import { OpenPanelFromEvent } from './components/open-panel-from-event';
7
8
  import { OpenPanelFromUrl } from './components/open-panel-from-url';
8
9
  import { panel } from './components/variables-manager/variables-manager-panel';
9
10
  import { VariableControl } from './controls/variable-control';
@@ -56,6 +57,11 @@ export function init() {
56
57
  component: OpenPanelFromUrl,
57
58
  } );
58
59
 
60
+ injectIntoLogic( {
61
+ id: 'variables-open-panel-from-event',
62
+ component: OpenPanelFromEvent,
63
+ } );
64
+
59
65
  registerPanel( panel );
60
66
  }
61
67