@elementor/editor-global-classes 4.3.0-991 → 4.3.0-993
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 +124 -122
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +122 -120
- package/dist/index.mjs.map +1 -1
- package/package.json +21 -21
- package/src/components/class-manager/class-manager-panel.tsx +7 -2
package/dist/index.js
CHANGED
|
@@ -563,10 +563,119 @@ var useFilters = () => {
|
|
|
563
563
|
}, [filters, allFilters]);
|
|
564
564
|
};
|
|
565
565
|
|
|
566
|
+
// src/load-existing-classes.ts
|
|
567
|
+
var import_store10 = require("@elementor/store");
|
|
568
|
+
|
|
569
|
+
// src/load-document-classes.ts
|
|
570
|
+
var import_editor_documents2 = require("@elementor/editor-documents");
|
|
571
|
+
var import_store8 = require("@elementor/store");
|
|
572
|
+
|
|
573
|
+
// src/utils/create-labels-for-classes.ts
|
|
574
|
+
function createLabelsForClasses(entries) {
|
|
575
|
+
return Object.fromEntries(entries.map((e) => [e.id, e.label]));
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
// src/load-document-classes.ts
|
|
579
|
+
function styleDefinitionsMapWithoutNull(map) {
|
|
580
|
+
return Object.fromEntries(
|
|
581
|
+
Object.entries(map).filter(
|
|
582
|
+
(entry) => entry[1] !== null
|
|
583
|
+
)
|
|
584
|
+
);
|
|
585
|
+
}
|
|
586
|
+
function resetGlobalClassesState(globalOrder, classLabels) {
|
|
587
|
+
(0, import_store8.__dispatch)(
|
|
588
|
+
slice.actions.load({
|
|
589
|
+
preview: { items: {}, order: globalOrder },
|
|
590
|
+
frontend: { items: {}, order: globalOrder },
|
|
591
|
+
classLabels
|
|
592
|
+
})
|
|
593
|
+
);
|
|
594
|
+
}
|
|
595
|
+
async function loadCurrentDocumentClasses() {
|
|
596
|
+
const [previewIndexRes, frontendIndexRes] = await Promise.all([
|
|
597
|
+
apiClient.all("preview"),
|
|
598
|
+
apiClient.all("frontend")
|
|
599
|
+
]);
|
|
600
|
+
const previewIndex = previewIndexRes.data.data;
|
|
601
|
+
const frontendIndex = frontendIndexRes.data.data;
|
|
602
|
+
const classLabels = createLabelsForClasses(previewIndex);
|
|
603
|
+
const previewOrder = previewIndex.map((e) => e.id);
|
|
604
|
+
const frontendOrder = frontendIndex.map((e) => e.id);
|
|
605
|
+
resetGlobalClassesState(previewOrder, classLabels);
|
|
606
|
+
const postId = (0, import_editor_documents2.getCurrentDocument)()?.id;
|
|
607
|
+
if (!postId) {
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
const [previewPostRes, frontendPostRes] = await Promise.all([
|
|
611
|
+
apiClient.getStylesForPost(postId, "preview"),
|
|
612
|
+
apiClient.getStylesForPost(postId, "frontend")
|
|
613
|
+
]);
|
|
614
|
+
const previewItems = styleDefinitionsMapWithoutNull(previewPostRes.data.data);
|
|
615
|
+
const frontendItems = styleDefinitionsMapWithoutNull(frontendPostRes.data.data);
|
|
616
|
+
(0, import_store8.__dispatch)(
|
|
617
|
+
slice.actions.load({
|
|
618
|
+
preview: { items: previewItems, order: previewOrder },
|
|
619
|
+
frontend: { items: frontendItems, order: frontendOrder },
|
|
620
|
+
classLabels
|
|
621
|
+
})
|
|
622
|
+
);
|
|
623
|
+
}
|
|
624
|
+
async function addDocumentClasses(documentId) {
|
|
625
|
+
const [previewPostRes, frontendPostRes] = await Promise.all([
|
|
626
|
+
apiClient.getStylesForPost(documentId, "preview"),
|
|
627
|
+
apiClient.getStylesForPost(documentId, "frontend")
|
|
628
|
+
]);
|
|
629
|
+
const previewItems = styleDefinitionsMapWithoutNull(previewPostRes.data.data);
|
|
630
|
+
const frontendItems = styleDefinitionsMapWithoutNull(frontendPostRes.data.data);
|
|
631
|
+
(0, import_store8.__dispatch)(
|
|
632
|
+
slice.actions.mergeExistingClasses({
|
|
633
|
+
preview: previewItems,
|
|
634
|
+
frontend: frontendItems
|
|
635
|
+
})
|
|
636
|
+
);
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
// src/load-existing-classes.ts
|
|
640
|
+
var pendingLoad = null;
|
|
641
|
+
var pendingIds = /* @__PURE__ */ new Set();
|
|
642
|
+
async function loadExistingClasses(classIds) {
|
|
643
|
+
const existingClasses = selectGlobalClasses((0, import_store10.__getState)());
|
|
644
|
+
const missingIds = classIds.filter((id) => !(id in existingClasses));
|
|
645
|
+
if (missingIds.length === 0) {
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
missingIds.forEach((id) => pendingIds.add(id));
|
|
649
|
+
if (pendingLoad) {
|
|
650
|
+
await pendingLoad;
|
|
651
|
+
return loadExistingClasses(classIds);
|
|
652
|
+
}
|
|
653
|
+
pendingLoad = fetchAndMergeClasses();
|
|
654
|
+
try {
|
|
655
|
+
await pendingLoad;
|
|
656
|
+
} finally {
|
|
657
|
+
pendingLoad = null;
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
async function fetchAndMergeClasses() {
|
|
661
|
+
const idsToFetch = Array.from(pendingIds);
|
|
662
|
+
pendingIds.clear();
|
|
663
|
+
if (idsToFetch.length === 0) {
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
666
|
+
const [previewResponse, frontendResponse] = await Promise.all([
|
|
667
|
+
apiClient.getStylesByIds(idsToFetch, "preview"),
|
|
668
|
+
apiClient.getStylesByIds(idsToFetch, "frontend")
|
|
669
|
+
]);
|
|
670
|
+
const previewItems = styleDefinitionsMapWithoutNull(previewResponse.data.data);
|
|
671
|
+
const frontendItems = styleDefinitionsMapWithoutNull(frontendResponse.data.data);
|
|
672
|
+
(0, import_store10.__dispatch)(slice.actions.mergeExistingClasses({ preview: previewItems, frontend: frontendItems }));
|
|
673
|
+
}
|
|
674
|
+
|
|
566
675
|
// src/save-global-classes.tsx
|
|
567
676
|
var React3 = __toESM(require("react"));
|
|
568
677
|
var import_editor_ui2 = require("@elementor/editor-ui");
|
|
569
|
-
var
|
|
678
|
+
var import_store14 = require("@elementor/store");
|
|
570
679
|
var import_utils4 = require("@elementor/utils");
|
|
571
680
|
|
|
572
681
|
// src/components/class-manager/duplicate-label-dialog.tsx
|
|
@@ -671,7 +780,7 @@ var DuplicateLabelDialog = ({
|
|
|
671
780
|
|
|
672
781
|
// src/utils/tracking.ts
|
|
673
782
|
var import_events = require("@elementor/events");
|
|
674
|
-
var
|
|
783
|
+
var import_store12 = require("@elementor/store");
|
|
675
784
|
var trackGlobalClasses = async (payload) => {
|
|
676
785
|
const { runAction } = payload;
|
|
677
786
|
const data = await getSanitizedData(payload);
|
|
@@ -786,7 +895,7 @@ var extractCssClassData = (classId) => {
|
|
|
786
895
|
return { classTitle };
|
|
787
896
|
};
|
|
788
897
|
var getCssClass = (classId) => {
|
|
789
|
-
const state = (0,
|
|
898
|
+
const state = (0, import_store12.__getState)();
|
|
790
899
|
const cssClass = selectClass(state, classId);
|
|
791
900
|
if (cssClass) {
|
|
792
901
|
return cssClass;
|
|
@@ -820,10 +929,10 @@ var getRemovedInfo = (classId) => {
|
|
|
820
929
|
|
|
821
930
|
// src/save-global-classes.tsx
|
|
822
931
|
async function saveGlobalClasses2({ context: context2, onApprove }) {
|
|
823
|
-
const state = selectData((0,
|
|
932
|
+
const state = selectData((0, import_store14.__getState)());
|
|
824
933
|
const apiAction = context2 === "preview" ? apiClient.saveDraft : apiClient.publish;
|
|
825
934
|
const currentContext = context2 === "preview" ? selectPreviewInitialData : selectFrontendInitialData;
|
|
826
|
-
const changes = calculateChanges(state, currentContext((0,
|
|
935
|
+
const changes = calculateChanges(state, currentContext((0, import_store14.__getState)()));
|
|
827
936
|
const touchedIds = [...changes.added, ...changes.modified];
|
|
828
937
|
const touchedItems = Object.fromEntries(
|
|
829
938
|
touchedIds.map((id) => [id, state.items[id]]).filter(([, v]) => v)
|
|
@@ -833,10 +942,10 @@ async function saveGlobalClasses2({ context: context2, onApprove }) {
|
|
|
833
942
|
order: state.order,
|
|
834
943
|
changes
|
|
835
944
|
});
|
|
836
|
-
(0,
|
|
945
|
+
(0, import_store14.__dispatch)(slice.actions.reset({ context: context2 }));
|
|
837
946
|
window.dispatchEvent(new CustomEvent("classes:updated", { detail: { context: context2 } }));
|
|
838
947
|
if (response?.data?.data?.code === API_ERROR_CODES.DUPLICATED_LABEL) {
|
|
839
|
-
(0,
|
|
948
|
+
(0, import_store14.__dispatch)(slice.actions.updateMultiple(response.data.data.modifiedLabels));
|
|
840
949
|
trackGlobalClasses({
|
|
841
950
|
event: "classPublishConflict",
|
|
842
951
|
numOfConflicts: Object.keys(response.data.data.modifiedLabels).length
|
|
@@ -1159,14 +1268,14 @@ var IntroductionContent = () => {
|
|
|
1159
1268
|
};
|
|
1160
1269
|
|
|
1161
1270
|
// src/components/class-manager/delete-class.ts
|
|
1162
|
-
var
|
|
1271
|
+
var import_store16 = require("@elementor/store");
|
|
1163
1272
|
var isDeleted = false;
|
|
1164
1273
|
var deleteClass = (id) => {
|
|
1165
1274
|
trackGlobalClasses({
|
|
1166
1275
|
event: "classDeleted",
|
|
1167
1276
|
classId: id,
|
|
1168
1277
|
runAction: () => {
|
|
1169
|
-
(0,
|
|
1278
|
+
(0, import_store16.__dispatch)(slice.actions.delete(id));
|
|
1170
1279
|
isDeleted = true;
|
|
1171
1280
|
}
|
|
1172
1281
|
});
|
|
@@ -1190,120 +1299,11 @@ var import_react_virtual = require("@tanstack/react-virtual");
|
|
|
1190
1299
|
var import_i18n12 = require("@wordpress/i18n");
|
|
1191
1300
|
|
|
1192
1301
|
// src/hooks/use-ordered-classes.ts
|
|
1193
|
-
var
|
|
1302
|
+
var import_store18 = require("@elementor/store");
|
|
1194
1303
|
var useOrderedClasses = () => {
|
|
1195
|
-
return (0,
|
|
1304
|
+
return (0, import_store18.__useSelector)(selectOrderedClasses);
|
|
1196
1305
|
};
|
|
1197
1306
|
|
|
1198
|
-
// src/load-existing-classes.ts
|
|
1199
|
-
var import_store18 = require("@elementor/store");
|
|
1200
|
-
|
|
1201
|
-
// src/load-document-classes.ts
|
|
1202
|
-
var import_editor_documents2 = require("@elementor/editor-documents");
|
|
1203
|
-
var import_store16 = require("@elementor/store");
|
|
1204
|
-
|
|
1205
|
-
// src/utils/create-labels-for-classes.ts
|
|
1206
|
-
function createLabelsForClasses(entries) {
|
|
1207
|
-
return Object.fromEntries(entries.map((e) => [e.id, e.label]));
|
|
1208
|
-
}
|
|
1209
|
-
|
|
1210
|
-
// src/load-document-classes.ts
|
|
1211
|
-
function styleDefinitionsMapWithoutNull(map) {
|
|
1212
|
-
return Object.fromEntries(
|
|
1213
|
-
Object.entries(map).filter(
|
|
1214
|
-
(entry) => entry[1] !== null
|
|
1215
|
-
)
|
|
1216
|
-
);
|
|
1217
|
-
}
|
|
1218
|
-
function resetGlobalClassesState(globalOrder, classLabels) {
|
|
1219
|
-
(0, import_store16.__dispatch)(
|
|
1220
|
-
slice.actions.load({
|
|
1221
|
-
preview: { items: {}, order: globalOrder },
|
|
1222
|
-
frontend: { items: {}, order: globalOrder },
|
|
1223
|
-
classLabels
|
|
1224
|
-
})
|
|
1225
|
-
);
|
|
1226
|
-
}
|
|
1227
|
-
async function loadCurrentDocumentClasses() {
|
|
1228
|
-
const [previewIndexRes, frontendIndexRes] = await Promise.all([
|
|
1229
|
-
apiClient.all("preview"),
|
|
1230
|
-
apiClient.all("frontend")
|
|
1231
|
-
]);
|
|
1232
|
-
const previewIndex = previewIndexRes.data.data;
|
|
1233
|
-
const frontendIndex = frontendIndexRes.data.data;
|
|
1234
|
-
const classLabels = createLabelsForClasses(previewIndex);
|
|
1235
|
-
const previewOrder = previewIndex.map((e) => e.id);
|
|
1236
|
-
const frontendOrder = frontendIndex.map((e) => e.id);
|
|
1237
|
-
resetGlobalClassesState(previewOrder, classLabels);
|
|
1238
|
-
const postId = (0, import_editor_documents2.getCurrentDocument)()?.id;
|
|
1239
|
-
if (!postId) {
|
|
1240
|
-
return;
|
|
1241
|
-
}
|
|
1242
|
-
const [previewPostRes, frontendPostRes] = await Promise.all([
|
|
1243
|
-
apiClient.getStylesForPost(postId, "preview"),
|
|
1244
|
-
apiClient.getStylesForPost(postId, "frontend")
|
|
1245
|
-
]);
|
|
1246
|
-
const previewItems = styleDefinitionsMapWithoutNull(previewPostRes.data.data);
|
|
1247
|
-
const frontendItems = styleDefinitionsMapWithoutNull(frontendPostRes.data.data);
|
|
1248
|
-
(0, import_store16.__dispatch)(
|
|
1249
|
-
slice.actions.load({
|
|
1250
|
-
preview: { items: previewItems, order: previewOrder },
|
|
1251
|
-
frontend: { items: frontendItems, order: frontendOrder },
|
|
1252
|
-
classLabels
|
|
1253
|
-
})
|
|
1254
|
-
);
|
|
1255
|
-
}
|
|
1256
|
-
async function addDocumentClasses(documentId) {
|
|
1257
|
-
const [previewPostRes, frontendPostRes] = await Promise.all([
|
|
1258
|
-
apiClient.getStylesForPost(documentId, "preview"),
|
|
1259
|
-
apiClient.getStylesForPost(documentId, "frontend")
|
|
1260
|
-
]);
|
|
1261
|
-
const previewItems = styleDefinitionsMapWithoutNull(previewPostRes.data.data);
|
|
1262
|
-
const frontendItems = styleDefinitionsMapWithoutNull(frontendPostRes.data.data);
|
|
1263
|
-
(0, import_store16.__dispatch)(
|
|
1264
|
-
slice.actions.mergeExistingClasses({
|
|
1265
|
-
preview: previewItems,
|
|
1266
|
-
frontend: frontendItems
|
|
1267
|
-
})
|
|
1268
|
-
);
|
|
1269
|
-
}
|
|
1270
|
-
|
|
1271
|
-
// src/load-existing-classes.ts
|
|
1272
|
-
var pendingLoad = null;
|
|
1273
|
-
var pendingIds = /* @__PURE__ */ new Set();
|
|
1274
|
-
async function loadExistingClasses(classIds) {
|
|
1275
|
-
const existingClasses = selectGlobalClasses((0, import_store18.__getState)());
|
|
1276
|
-
const missingIds = classIds.filter((id) => !(id in existingClasses));
|
|
1277
|
-
if (missingIds.length === 0) {
|
|
1278
|
-
return;
|
|
1279
|
-
}
|
|
1280
|
-
missingIds.forEach((id) => pendingIds.add(id));
|
|
1281
|
-
if (pendingLoad) {
|
|
1282
|
-
await pendingLoad;
|
|
1283
|
-
return loadExistingClasses(classIds);
|
|
1284
|
-
}
|
|
1285
|
-
pendingLoad = fetchAndMergeClasses();
|
|
1286
|
-
try {
|
|
1287
|
-
await pendingLoad;
|
|
1288
|
-
} finally {
|
|
1289
|
-
pendingLoad = null;
|
|
1290
|
-
}
|
|
1291
|
-
}
|
|
1292
|
-
async function fetchAndMergeClasses() {
|
|
1293
|
-
const idsToFetch = Array.from(pendingIds);
|
|
1294
|
-
pendingIds.clear();
|
|
1295
|
-
if (idsToFetch.length === 0) {
|
|
1296
|
-
return;
|
|
1297
|
-
}
|
|
1298
|
-
const [previewResponse, frontendResponse] = await Promise.all([
|
|
1299
|
-
apiClient.getStylesByIds(idsToFetch, "preview"),
|
|
1300
|
-
apiClient.getStylesByIds(idsToFetch, "frontend")
|
|
1301
|
-
]);
|
|
1302
|
-
const previewItems = styleDefinitionsMapWithoutNull(previewResponse.data.data);
|
|
1303
|
-
const frontendItems = styleDefinitionsMapWithoutNull(frontendResponse.data.data);
|
|
1304
|
-
(0, import_store18.__dispatch)(slice.actions.mergeExistingClasses({ preview: previewItems, frontend: frontendItems }));
|
|
1305
|
-
}
|
|
1306
|
-
|
|
1307
1307
|
// src/components/class-manager/class-item.tsx
|
|
1308
1308
|
var React15 = __toESM(require("react"));
|
|
1309
1309
|
var import_react7 = require("react");
|
|
@@ -2294,7 +2294,8 @@ function ClassManagerPanelContent({
|
|
|
2294
2294
|
unblockPanelInteractions();
|
|
2295
2295
|
};
|
|
2296
2296
|
}, []);
|
|
2297
|
-
const handleStopSync = (0, import_react10.useCallback)((classId) => {
|
|
2297
|
+
const handleStopSync = (0, import_react10.useCallback)(async (classId) => {
|
|
2298
|
+
await loadExistingClasses([classId]);
|
|
2298
2299
|
(0, import_store22.__dispatch)(
|
|
2299
2300
|
slice.actions.update({
|
|
2300
2301
|
style: {
|
|
@@ -2306,7 +2307,8 @@ function ClassManagerPanelContent({
|
|
|
2306
2307
|
trackGlobalClasses({ event: "classSyncToV3", classId, action: "unsync" });
|
|
2307
2308
|
setStopSyncConfirmation(null);
|
|
2308
2309
|
}, []);
|
|
2309
|
-
const handleStartSync = (0, import_react10.useCallback)((classId) => {
|
|
2310
|
+
const handleStartSync = (0, import_react10.useCallback)(async (classId) => {
|
|
2311
|
+
await loadExistingClasses([classId]);
|
|
2310
2312
|
(0, import_store22.__dispatch)(
|
|
2311
2313
|
slice.actions.update({
|
|
2312
2314
|
style: {
|