@elementor/editor-global-classes 3.32.0-38 → 3.32.0-40
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 +19 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/capabilities.ts +1 -1
- package/src/global-classes-styles-provider.ts +24 -3
- package/src/save-global-classes.ts +1 -22
- package/src/sync-with-document-save.ts +10 -0
package/dist/index.js
CHANGED
|
@@ -289,7 +289,7 @@ var globalClassesStylesProvider = (0, import_editor_styles_repository.createStyl
|
|
|
289
289
|
singular: (0, import_i18n.__)("class", "elementor"),
|
|
290
290
|
plural: (0, import_i18n.__)("classes", "elementor")
|
|
291
291
|
},
|
|
292
|
-
subscribe: (cb) => (
|
|
292
|
+
subscribe: (cb) => subscribeWithStates(cb),
|
|
293
293
|
capabilities: getCapabilities(),
|
|
294
294
|
actions: {
|
|
295
295
|
all: () => selectOrderedClasses((0, import_store2.__getState)()),
|
|
@@ -346,6 +346,16 @@ var globalClassesStylesProvider = (0, import_editor_styles_repository.createStyl
|
|
|
346
346
|
}
|
|
347
347
|
}
|
|
348
348
|
});
|
|
349
|
+
var subscribeWithStates = (cb) => {
|
|
350
|
+
let previousState = selectData((0, import_store2.__getState)());
|
|
351
|
+
return (0, import_store2.__subscribeWithSelector)(
|
|
352
|
+
(state) => state.globalClasses,
|
|
353
|
+
(currentState) => {
|
|
354
|
+
cb(previousState.items, currentState.data.items);
|
|
355
|
+
previousState = currentState.data;
|
|
356
|
+
}
|
|
357
|
+
);
|
|
358
|
+
};
|
|
349
359
|
|
|
350
360
|
// src/hooks/use-prefetch-css-class-usage.ts
|
|
351
361
|
var import_query = require("@elementor/query");
|
|
@@ -575,6 +585,7 @@ var useFilters = () => {
|
|
|
575
585
|
|
|
576
586
|
// src/save-global-classes.ts
|
|
577
587
|
var import_store10 = require("@elementor/store");
|
|
588
|
+
var import_utils4 = require("@elementor/utils");
|
|
578
589
|
async function saveGlobalClasses({ context: context2 }) {
|
|
579
590
|
const state = selectData((0, import_store10.__getState)());
|
|
580
591
|
if (context2 === "preview") {
|
|
@@ -599,22 +610,10 @@ function calculateChanges(state, initialData) {
|
|
|
599
610
|
added: stateIds.filter((id2) => !initialDataIds.includes(id2)),
|
|
600
611
|
deleted: initialDataIds.filter((id2) => !stateIds.includes(id2)),
|
|
601
612
|
modified: stateIds.filter((id2) => {
|
|
602
|
-
return id2 in initialData.items && hash(state.items[id2]) !== hash(initialData.items[id2]);
|
|
613
|
+
return id2 in initialData.items && (0, import_utils4.hash)(state.items[id2]) !== (0, import_utils4.hash)(initialData.items[id2]);
|
|
603
614
|
})
|
|
604
615
|
};
|
|
605
616
|
}
|
|
606
|
-
function hash(obj) {
|
|
607
|
-
return JSON.stringify(
|
|
608
|
-
obj,
|
|
609
|
-
(_, value) => isPlainObject(value) ? Object.keys(value).sort().reduce((result, key) => {
|
|
610
|
-
result[key] = value[key];
|
|
611
|
-
return result;
|
|
612
|
-
}, {}) : value
|
|
613
|
-
);
|
|
614
|
-
}
|
|
615
|
-
function isPlainObject(value) {
|
|
616
|
-
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
617
|
-
}
|
|
618
617
|
|
|
619
618
|
// src/components/search-and-filter/components/filter/active-filters.tsx
|
|
620
619
|
var React4 = __toESM(require("react"));
|
|
@@ -1929,6 +1928,7 @@ function PopulateStore() {
|
|
|
1929
1928
|
}
|
|
1930
1929
|
|
|
1931
1930
|
// src/sync-with-document-save.ts
|
|
1931
|
+
var import_editor_current_user2 = require("@elementor/editor-current-user");
|
|
1932
1932
|
var import_editor_documents6 = require("@elementor/editor-documents");
|
|
1933
1933
|
var import_editor_v1_adapters4 = require("@elementor/editor-v1-adapters");
|
|
1934
1934
|
var import_store22 = require("@elementor/store");
|
|
@@ -1947,6 +1947,11 @@ function syncDirtyState() {
|
|
|
1947
1947
|
}
|
|
1948
1948
|
function bindSaveAction() {
|
|
1949
1949
|
(0, import_editor_v1_adapters4.registerDataHook)("after", "document/save/save", (args) => {
|
|
1950
|
+
const user = (0, import_editor_current_user2.getCurrentUser)();
|
|
1951
|
+
const canEdit = user?.capabilities.includes(UPDATE_CLASS_CAPABILITY_KEY);
|
|
1952
|
+
if (!canEdit) {
|
|
1953
|
+
return;
|
|
1954
|
+
}
|
|
1950
1955
|
return saveGlobalClasses({
|
|
1951
1956
|
context: args.status === "publish" ? "frontend" : "preview"
|
|
1952
1957
|
});
|