@elementor/editor-variables 4.2.0-842 → 4.2.0-843
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.js
CHANGED
|
@@ -334,12 +334,13 @@ var buildOperationsArray = (originalVariables, currentVariables, deletedVariable
|
|
|
334
334
|
// src/storage.ts
|
|
335
335
|
var STORAGE_KEY = "elementor-global-variables";
|
|
336
336
|
var STORAGE_WATERMARK_KEY = "elementor-global-variables-watermark";
|
|
337
|
+
var STORAGE_UPDATED_EVENT = "variables:updated";
|
|
337
338
|
var OP_RW = "RW";
|
|
338
339
|
var OP_RO = "RO";
|
|
339
340
|
var Storage = class {
|
|
340
341
|
state;
|
|
341
342
|
notifyChange() {
|
|
342
|
-
window.dispatchEvent(new Event(
|
|
343
|
+
window.dispatchEvent(new Event(STORAGE_UPDATED_EVENT));
|
|
343
344
|
}
|
|
344
345
|
constructor() {
|
|
345
346
|
this.state = {
|
|
@@ -1059,6 +1060,17 @@ var useVariablesManagerState = () => {
|
|
|
1059
1060
|
const [isDirty, setIsDirty] = (0, import_react5.useState)(false);
|
|
1060
1061
|
const [isSaving, setIsSaving] = (0, import_react5.useState)(false);
|
|
1061
1062
|
const [searchValue, setSearchValue] = (0, import_react5.useState)("");
|
|
1063
|
+
(0, import_react5.useEffect)(() => {
|
|
1064
|
+
const handleStorageUpdated = () => {
|
|
1065
|
+
setVariables(getVariables(false));
|
|
1066
|
+
setDeletedVariables([]);
|
|
1067
|
+
setIsDirty(false);
|
|
1068
|
+
};
|
|
1069
|
+
window.addEventListener(STORAGE_UPDATED_EVENT, handleStorageUpdated);
|
|
1070
|
+
return () => {
|
|
1071
|
+
window.removeEventListener(STORAGE_UPDATED_EVENT, handleStorageUpdated);
|
|
1072
|
+
};
|
|
1073
|
+
}, []);
|
|
1062
1074
|
const handleOnChange = (0, import_react5.useCallback)(
|
|
1063
1075
|
(newVariables) => {
|
|
1064
1076
|
setVariables({ ...variables, ...newVariables });
|
|
@@ -2412,14 +2424,7 @@ var import_react14 = require("react");
|
|
|
2412
2424
|
var import_editor_canvas4 = require("@elementor/editor-canvas");
|
|
2413
2425
|
function GlobalStylesImportListener() {
|
|
2414
2426
|
(0, import_react14.useEffect)(() => {
|
|
2415
|
-
const handleGlobalStylesImported = (
|
|
2416
|
-
const importedVars = event.detail?.global_variables;
|
|
2417
|
-
if (!importedVars) {
|
|
2418
|
-
return;
|
|
2419
|
-
}
|
|
2420
|
-
if (importedVars.data && typeof importedVars.data === "object") {
|
|
2421
|
-
styleVariablesRepository.update(importedVars.data);
|
|
2422
|
-
}
|
|
2427
|
+
const handleGlobalStylesImported = () => {
|
|
2423
2428
|
service.load();
|
|
2424
2429
|
};
|
|
2425
2430
|
window.addEventListener(import_editor_canvas4.GLOBAL_STYLES_IMPORTED_EVENT, handleGlobalStylesImported);
|
|
@@ -3956,7 +3961,7 @@ var initVariablesResource = (variablesMcpEntry, canvasMcpEntry) => {
|
|
|
3956
3961
|
};
|
|
3957
3962
|
}
|
|
3958
3963
|
);
|
|
3959
|
-
window.addEventListener(
|
|
3964
|
+
window.addEventListener(STORAGE_UPDATED_EVENT, notifyGlobalVariablesUpdated);
|
|
3960
3965
|
(0, import_editor_v1_adapters6.__privateListenTo)((0, import_editor_v1_adapters6.commandEndEvent)("document/save/update"), notifyGlobalVariablesUpdated);
|
|
3961
3966
|
});
|
|
3962
3967
|
};
|