@elementor/editor-variables 4.2.0-842 → 4.2.0-844
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/dist/index.js +15 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -33
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/components/global-styles-import-listener.tsx +3 -14
- package/src/components/variables-manager/hooks/use-variables-manager-state.ts +16 -2
- package/src/mcp/variables-resource.ts +2 -2
- package/src/storage.ts +3 -1
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/components/variables-manager/variables-manager-panel.tsx
|
|
2
2
|
import * as React14 from "react";
|
|
3
|
-
import { useCallback as useCallback6, useEffect as
|
|
3
|
+
import { useCallback as useCallback6, useEffect as useEffect4, useMemo as useMemo3, useState as useState6 } from "react";
|
|
4
4
|
import { useSuppressedMessage } from "@elementor/editor-current-user";
|
|
5
5
|
import {
|
|
6
6
|
__createPanel as createPanel,
|
|
@@ -310,12 +310,13 @@ var buildOperationsArray = (originalVariables, currentVariables, deletedVariable
|
|
|
310
310
|
// src/storage.ts
|
|
311
311
|
var STORAGE_KEY = "elementor-global-variables";
|
|
312
312
|
var STORAGE_WATERMARK_KEY = "elementor-global-variables-watermark";
|
|
313
|
+
var STORAGE_UPDATED_EVENT = "variables:updated";
|
|
313
314
|
var OP_RW = "RW";
|
|
314
315
|
var OP_RO = "RO";
|
|
315
316
|
var Storage = class {
|
|
316
317
|
state;
|
|
317
318
|
notifyChange() {
|
|
318
|
-
window.dispatchEvent(new Event(
|
|
319
|
+
window.dispatchEvent(new Event(STORAGE_UPDATED_EVENT));
|
|
319
320
|
}
|
|
320
321
|
constructor() {
|
|
321
322
|
this.state = {
|
|
@@ -871,7 +872,7 @@ var useErrorNavigation = () => {
|
|
|
871
872
|
};
|
|
872
873
|
|
|
873
874
|
// src/components/variables-manager/hooks/use-variables-manager-state.ts
|
|
874
|
-
import { useCallback as useCallback3, useState as useState2 } from "react";
|
|
875
|
+
import { useCallback as useCallback3, useEffect, useState as useState2 } from "react";
|
|
875
876
|
|
|
876
877
|
// src/hooks/use-prop-variables.ts
|
|
877
878
|
import { useMemo } from "react";
|
|
@@ -1035,6 +1036,17 @@ var useVariablesManagerState = () => {
|
|
|
1035
1036
|
const [isDirty, setIsDirty] = useState2(false);
|
|
1036
1037
|
const [isSaving, setIsSaving] = useState2(false);
|
|
1037
1038
|
const [searchValue, setSearchValue] = useState2("");
|
|
1039
|
+
useEffect(() => {
|
|
1040
|
+
const handleStorageUpdated = () => {
|
|
1041
|
+
setVariables(getVariables(false));
|
|
1042
|
+
setDeletedVariables([]);
|
|
1043
|
+
setIsDirty(false);
|
|
1044
|
+
};
|
|
1045
|
+
window.addEventListener(STORAGE_UPDATED_EVENT, handleStorageUpdated);
|
|
1046
|
+
return () => {
|
|
1047
|
+
window.removeEventListener(STORAGE_UPDATED_EVENT, handleStorageUpdated);
|
|
1048
|
+
};
|
|
1049
|
+
}, []);
|
|
1038
1050
|
const handleOnChange = useCallback3(
|
|
1039
1051
|
(newVariables) => {
|
|
1040
1052
|
setVariables({ ...variables, ...newVariables });
|
|
@@ -1335,7 +1347,7 @@ var getDefaultName = (variables, baseName) => {
|
|
|
1335
1347
|
|
|
1336
1348
|
// src/components/variables-manager/variables-manager-table.tsx
|
|
1337
1349
|
import * as React13 from "react";
|
|
1338
|
-
import { useEffect as
|
|
1350
|
+
import { useEffect as useEffect3, useRef as useRef6 } from "react";
|
|
1339
1351
|
import {
|
|
1340
1352
|
Table,
|
|
1341
1353
|
TableBody,
|
|
@@ -1460,7 +1472,7 @@ var LabelField = ({
|
|
|
1460
1472
|
|
|
1461
1473
|
// src/components/variables-manager/variable-editable-cell.tsx
|
|
1462
1474
|
import * as React10 from "react";
|
|
1463
|
-
import { useCallback as useCallback5, useEffect, useRef as useRef4, useState as useState5 } from "react";
|
|
1475
|
+
import { useCallback as useCallback5, useEffect as useEffect2, useRef as useRef4, useState as useState5 } from "react";
|
|
1464
1476
|
import { ClickAwayListener, Stack as Stack4 } from "@elementor/ui";
|
|
1465
1477
|
var VariableEditableCell = React10.memo(
|
|
1466
1478
|
({
|
|
@@ -1488,10 +1500,10 @@ var VariableEditableCell = React10.memo(
|
|
|
1488
1500
|
}
|
|
1489
1501
|
setIsEditing(false);
|
|
1490
1502
|
}, [value, onChange, fieldType, labelFieldError, valueFieldError]);
|
|
1491
|
-
|
|
1503
|
+
useEffect2(() => {
|
|
1492
1504
|
onRowRef?.(rowRef?.current);
|
|
1493
1505
|
}, [onRowRef]);
|
|
1494
|
-
|
|
1506
|
+
useEffect2(() => {
|
|
1495
1507
|
if (autoEdit && !isEditing && !disabled) {
|
|
1496
1508
|
setIsEditing(true);
|
|
1497
1509
|
onAutoEditComplete?.();
|
|
@@ -1832,7 +1844,7 @@ var VariablesManagerTable = ({
|
|
|
1832
1844
|
}) => {
|
|
1833
1845
|
const tableContainerRef = useRef6(null);
|
|
1834
1846
|
const variableRowRefs = useRef6(/* @__PURE__ */ new Map());
|
|
1835
|
-
|
|
1847
|
+
useEffect3(() => {
|
|
1836
1848
|
if (autoEditVariableId && tableContainerRef.current) {
|
|
1837
1849
|
const rowElement = variableRowRefs.current.get(autoEditVariableId);
|
|
1838
1850
|
if (rowElement) {
|
|
@@ -2000,7 +2012,7 @@ function VariablesManagerPanelRoot({
|
|
|
2000
2012
|
}
|
|
2001
2013
|
void closePanel();
|
|
2002
2014
|
}, [isDirty, openSaveChangesDialog, closePanel]);
|
|
2003
|
-
|
|
2015
|
+
useEffect4(() => {
|
|
2004
2016
|
if (!embedded || !onExposeCloseAttempt) {
|
|
2005
2017
|
return;
|
|
2006
2018
|
}
|
|
@@ -2351,7 +2363,7 @@ function VariablesManagerPanelRoot({
|
|
|
2351
2363
|
return embedded ? core : /* @__PURE__ */ React14.createElement(ThemeProvider, null, core);
|
|
2352
2364
|
}
|
|
2353
2365
|
var usePreventUnload = (isDirty) => {
|
|
2354
|
-
|
|
2366
|
+
useEffect4(() => {
|
|
2355
2367
|
const handleBeforeUnload = (event) => {
|
|
2356
2368
|
if (isDirty) {
|
|
2357
2369
|
event.preventDefault();
|
|
@@ -2392,18 +2404,11 @@ import { isExperimentActive as isExperimentActive2 } from "@elementor/editor-v1-
|
|
|
2392
2404
|
import { controlActionsMenu } from "@elementor/menus";
|
|
2393
2405
|
|
|
2394
2406
|
// src/components/global-styles-import-listener.tsx
|
|
2395
|
-
import { useEffect as
|
|
2407
|
+
import { useEffect as useEffect5 } from "react";
|
|
2396
2408
|
import { GLOBAL_STYLES_IMPORTED_EVENT } from "@elementor/editor-canvas";
|
|
2397
2409
|
function GlobalStylesImportListener() {
|
|
2398
|
-
|
|
2399
|
-
const handleGlobalStylesImported = (
|
|
2400
|
-
const importedVars = event.detail?.global_variables;
|
|
2401
|
-
if (!importedVars) {
|
|
2402
|
-
return;
|
|
2403
|
-
}
|
|
2404
|
-
if (importedVars.data && typeof importedVars.data === "object") {
|
|
2405
|
-
styleVariablesRepository.update(importedVars.data);
|
|
2406
|
-
}
|
|
2410
|
+
useEffect5(() => {
|
|
2411
|
+
const handleGlobalStylesImported = () => {
|
|
2407
2412
|
service.load();
|
|
2408
2413
|
};
|
|
2409
2414
|
window.addEventListener(GLOBAL_STYLES_IMPORTED_EVENT, handleGlobalStylesImported);
|
|
@@ -2415,7 +2420,7 @@ function GlobalStylesImportListener() {
|
|
|
2415
2420
|
}
|
|
2416
2421
|
|
|
2417
2422
|
// src/components/open-panel-from-event.tsx
|
|
2418
|
-
import { useEffect as
|
|
2423
|
+
import { useEffect as useEffect6, useRef as useRef7, useState as useState7 } from "react";
|
|
2419
2424
|
import {
|
|
2420
2425
|
__privateListenTo as listenTo,
|
|
2421
2426
|
__privateOpenRoute as openRoute,
|
|
@@ -2427,13 +2432,13 @@ function OpenPanelFromEvent() {
|
|
|
2427
2432
|
const { open } = usePanelActions();
|
|
2428
2433
|
const pendingRef = useRef7(false);
|
|
2429
2434
|
const [readyToOpen, setReadyToOpen] = useState7(false);
|
|
2430
|
-
|
|
2435
|
+
useEffect6(() => {
|
|
2431
2436
|
if (readyToOpen) {
|
|
2432
2437
|
setReadyToOpen(false);
|
|
2433
2438
|
open();
|
|
2434
2439
|
}
|
|
2435
2440
|
}, [readyToOpen, open]);
|
|
2436
|
-
|
|
2441
|
+
useEffect6(() => {
|
|
2437
2442
|
return listenTo(routeOpenEvent(DEFAULT_PANEL_ROUTE), () => {
|
|
2438
2443
|
if (pendingRef.current) {
|
|
2439
2444
|
pendingRef.current = false;
|
|
@@ -2441,7 +2446,7 @@ function OpenPanelFromEvent() {
|
|
|
2441
2446
|
}
|
|
2442
2447
|
});
|
|
2443
2448
|
}, []);
|
|
2444
|
-
|
|
2449
|
+
useEffect6(() => {
|
|
2445
2450
|
const handler = () => {
|
|
2446
2451
|
pendingRef.current = true;
|
|
2447
2452
|
openRoute(DEFAULT_PANEL_ROUTE);
|
|
@@ -2453,7 +2458,7 @@ function OpenPanelFromEvent() {
|
|
|
2453
2458
|
}
|
|
2454
2459
|
|
|
2455
2460
|
// src/components/open-panel-from-url.tsx
|
|
2456
|
-
import { useEffect as
|
|
2461
|
+
import { useEffect as useEffect7, useRef as useRef8 } from "react";
|
|
2457
2462
|
import { __privateListenTo as listenTo2, routeOpenEvent as routeOpenEvent2 } from "@elementor/editor-v1-adapters";
|
|
2458
2463
|
var ACTIVE_PANEL_PARAM = "active-panel";
|
|
2459
2464
|
var PANEL_ID = "variables-manager";
|
|
@@ -2461,7 +2466,7 @@ var DEFAULT_PANEL_ROUTE2 = "panel/elements";
|
|
|
2461
2466
|
function OpenPanelFromUrl() {
|
|
2462
2467
|
const { open } = usePanelActions();
|
|
2463
2468
|
const hasOpened = useRef8(false);
|
|
2464
|
-
|
|
2469
|
+
useEffect7(() => {
|
|
2465
2470
|
const urlParams = new URLSearchParams(window.location.search);
|
|
2466
2471
|
const activePanel = urlParams.get(ACTIVE_PANEL_PARAM);
|
|
2467
2472
|
if (activePanel !== PANEL_ID) {
|
|
@@ -2714,7 +2719,7 @@ var VariableCreation = ({ onGoBack, onClose }) => {
|
|
|
2714
2719
|
|
|
2715
2720
|
// src/components/variable-edit.tsx
|
|
2716
2721
|
import * as React19 from "react";
|
|
2717
|
-
import { useEffect as
|
|
2722
|
+
import { useEffect as useEffect8, useState as useState11 } from "react";
|
|
2718
2723
|
import { PopoverContent as PopoverContent2, useBoundProp as useBoundProp5 } from "@elementor/editor-controls";
|
|
2719
2724
|
import { useSuppressedMessage as useSuppressedMessage2 } from "@elementor/editor-current-user";
|
|
2720
2725
|
import { PopoverHeader as PopoverHeader2, SectionPopoverBody as SectionPopoverBody2 } from "@elementor/editor-ui";
|
|
@@ -2791,7 +2796,7 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
2791
2796
|
const userPermissions = usePermissions();
|
|
2792
2797
|
const [value, setValue] = useState11(() => variable.value);
|
|
2793
2798
|
const [label, setLabel] = useState11(() => variable.label);
|
|
2794
|
-
|
|
2799
|
+
useEffect8(() => {
|
|
2795
2800
|
styleVariablesRepository.update({
|
|
2796
2801
|
[editId]: {
|
|
2797
2802
|
...variable,
|
|
@@ -2956,7 +2961,7 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
2956
2961
|
};
|
|
2957
2962
|
|
|
2958
2963
|
// src/components/variables-selection.tsx
|
|
2959
|
-
import { useEffect as
|
|
2964
|
+
import { useEffect as useEffect9, useState as useState12 } from "react";
|
|
2960
2965
|
import * as React21 from "react";
|
|
2961
2966
|
import { trackUpgradePromotionClick as trackUpgradePromotionClick2, trackViewPromotion as trackViewPromotion2 } from "@elementor/editor-controls";
|
|
2962
2967
|
import {
|
|
@@ -3146,7 +3151,7 @@ var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings, disabled =
|
|
|
3146
3151
|
const handleClearSearch = () => {
|
|
3147
3152
|
setSearchValue("");
|
|
3148
3153
|
};
|
|
3149
|
-
|
|
3154
|
+
useEffect9(() => {
|
|
3150
3155
|
if (disabled) {
|
|
3151
3156
|
trackViewPromotion2({
|
|
3152
3157
|
target_name: "variables_popover",
|
|
@@ -3959,7 +3964,7 @@ var initVariablesResource = (variablesMcpEntry, canvasMcpEntry) => {
|
|
|
3959
3964
|
};
|
|
3960
3965
|
}
|
|
3961
3966
|
);
|
|
3962
|
-
window.addEventListener(
|
|
3967
|
+
window.addEventListener(STORAGE_UPDATED_EVENT, notifyGlobalVariablesUpdated);
|
|
3963
3968
|
listenTo3(commandEndEvent("document/save/update"), notifyGlobalVariablesUpdated);
|
|
3964
3969
|
});
|
|
3965
3970
|
};
|
|
@@ -4252,7 +4257,7 @@ function registerVariableTypes() {
|
|
|
4252
4257
|
|
|
4253
4258
|
// src/renderers/style-variables-renderer.tsx
|
|
4254
4259
|
import * as React38 from "react";
|
|
4255
|
-
import { useEffect as
|
|
4260
|
+
import { useEffect as useEffect10, useState as useState20 } from "react";
|
|
4256
4261
|
import {
|
|
4257
4262
|
__privateUseListenTo as useListenTo,
|
|
4258
4263
|
commandEndEvent as commandEndEvent2,
|
|
@@ -4276,7 +4281,7 @@ function usePortalContainer() {
|
|
|
4276
4281
|
}
|
|
4277
4282
|
function useStyleVariables() {
|
|
4278
4283
|
const [variables, setVariables] = useState20({});
|
|
4279
|
-
|
|
4284
|
+
useEffect10(() => {
|
|
4280
4285
|
const unsubscribe = styleVariablesRepository.subscribe(setVariables);
|
|
4281
4286
|
return () => {
|
|
4282
4287
|
unsubscribe();
|