@elementor/editor-variables 4.2.0-880 → 4.2.0-882

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.
@@ -1,46 +0,0 @@
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
- }
@@ -1,40 +0,0 @@
1
- import { useEffect, useRef } from 'react';
2
- import { __privateListenTo as listenTo, routeOpenEvent } from '@elementor/editor-v1-adapters';
3
-
4
- import { usePanelActions } from './variables-manager/variables-manager-panel';
5
-
6
- const ACTIVE_PANEL_PARAM = 'active-panel';
7
- const PANEL_ID = 'variables-manager';
8
- const DEFAULT_PANEL_ROUTE = 'panel/elements';
9
-
10
- export function OpenPanelFromUrl() {
11
- const { open } = usePanelActions();
12
- const hasOpened = useRef( false );
13
-
14
- useEffect( () => {
15
- const urlParams = new URLSearchParams( window.location.search );
16
- const activePanel = urlParams.get( ACTIVE_PANEL_PARAM );
17
-
18
- if ( activePanel !== PANEL_ID ) {
19
- return;
20
- }
21
-
22
- // Listen for the default panel route to open - this signals Elementor initialization is complete
23
- const cleanup = listenTo( routeOpenEvent( DEFAULT_PANEL_ROUTE ), () => {
24
- if ( hasOpened.current ) {
25
- return;
26
- }
27
-
28
- hasOpened.current = true;
29
-
30
- // Open panel after default route is established
31
- requestAnimationFrame( () => {
32
- open();
33
- } );
34
- } );
35
-
36
- return cleanup;
37
- }, [ open ] );
38
-
39
- return null;
40
- }