@elementor/editor-components 3.35.0-479 → 3.35.0-480
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 +39 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -28
- package/dist/index.mjs.map +1 -1
- package/package.json +22 -22
- package/src/api.ts +4 -2
- package/src/sync/before-save.ts +24 -5
- package/src/sync/{update-components-before-save.ts → publish-draft-components-in-page-before-save.ts} +1 -1
- package/src/sync/update-archived-component-before-save.ts +3 -2
- package/src/sync/update-component-title-before-save.ts +3 -2
package/dist/index.mjs
CHANGED
|
@@ -70,16 +70,18 @@ var apiClient = {
|
|
|
70
70
|
componentId: componentId.toString()
|
|
71
71
|
}
|
|
72
72
|
}).then((res) => res.data.data),
|
|
73
|
-
updateArchivedComponents: async (componentIds) => await httpService().post(
|
|
73
|
+
updateArchivedComponents: async (componentIds, status) => await httpService().post(
|
|
74
74
|
`${BASE_URL}/archive`,
|
|
75
75
|
{
|
|
76
|
-
componentIds
|
|
76
|
+
componentIds,
|
|
77
|
+
status
|
|
77
78
|
}
|
|
78
79
|
).then((res) => res.data.data),
|
|
79
|
-
updateComponentTitle: (updatedComponentNames) => httpService().post(
|
|
80
|
+
updateComponentTitle: (updatedComponentNames, status) => httpService().post(
|
|
80
81
|
`${BASE_URL}/update-titles`,
|
|
81
82
|
{
|
|
82
|
-
components: updatedComponentNames
|
|
83
|
+
components: updatedComponentNames,
|
|
84
|
+
status
|
|
83
85
|
}
|
|
84
86
|
).then((res) => res.data.data),
|
|
85
87
|
validate: async (payload) => await httpService().post(`${BASE_URL}/create-validate`, payload).then((res) => res.data)
|
|
@@ -5071,6 +5073,21 @@ function updateElementComponentId(elementId, componentId) {
|
|
|
5071
5073
|
});
|
|
5072
5074
|
}
|
|
5073
5075
|
|
|
5076
|
+
// src/sync/publish-draft-components-in-page-before-save.ts
|
|
5077
|
+
import { isDocumentDirty as isDocumentDirty2 } from "@elementor/editor-documents";
|
|
5078
|
+
async function publishDraftComponentsInPageBeforeSave({ status, elements }) {
|
|
5079
|
+
if (status !== "publish") {
|
|
5080
|
+
return;
|
|
5081
|
+
}
|
|
5082
|
+
const documents = await getComponentDocuments(elements);
|
|
5083
|
+
const draftIds = [...documents.values()].filter(isDocumentDirty2).map((document) => document.id);
|
|
5084
|
+
if (draftIds.length === 0) {
|
|
5085
|
+
return;
|
|
5086
|
+
}
|
|
5087
|
+
await apiClient.updateStatuses(draftIds, "publish");
|
|
5088
|
+
draftIds.forEach((id2) => invalidateComponentDocumentData(id2));
|
|
5089
|
+
}
|
|
5090
|
+
|
|
5074
5091
|
// src/sync/set-component-overridable-props-settings-before-save.ts
|
|
5075
5092
|
import { __getState as getState22 } from "@elementor/store";
|
|
5076
5093
|
var setComponentOverridablePropsSettingsBeforeSave = ({
|
|
@@ -5094,13 +5111,13 @@ var failedNotification = (message) => ({
|
|
|
5094
5111
|
message: `Failed to archive components: ${message}`,
|
|
5095
5112
|
id: "failed-archived-components-notification"
|
|
5096
5113
|
});
|
|
5097
|
-
var updateArchivedComponentBeforeSave = async () => {
|
|
5114
|
+
var updateArchivedComponentBeforeSave = async (status) => {
|
|
5098
5115
|
try {
|
|
5099
5116
|
const archivedComponents = selectArchivedThisSession(getState23());
|
|
5100
5117
|
if (!archivedComponents.length) {
|
|
5101
5118
|
return;
|
|
5102
5119
|
}
|
|
5103
|
-
const result = await apiClient.updateArchivedComponents(archivedComponents);
|
|
5120
|
+
const result = await apiClient.updateArchivedComponents(archivedComponents, status);
|
|
5104
5121
|
const failedIds = result.failedIds.join(", ");
|
|
5105
5122
|
if (failedIds) {
|
|
5106
5123
|
notify5(failedNotification(failedIds));
|
|
@@ -5112,43 +5129,37 @@ var updateArchivedComponentBeforeSave = async () => {
|
|
|
5112
5129
|
|
|
5113
5130
|
// src/sync/update-component-title-before-save.ts
|
|
5114
5131
|
import { __dispatch as dispatch18, __getState as getState24 } from "@elementor/store";
|
|
5115
|
-
var updateComponentTitleBeforeSave = async () => {
|
|
5132
|
+
var updateComponentTitleBeforeSave = async (status) => {
|
|
5116
5133
|
const updatedComponentNames = selectUpdatedComponentNames(getState24());
|
|
5117
5134
|
if (!updatedComponentNames.length) {
|
|
5118
5135
|
return;
|
|
5119
5136
|
}
|
|
5120
|
-
const result = await apiClient.updateComponentTitle(updatedComponentNames);
|
|
5137
|
+
const result = await apiClient.updateComponentTitle(updatedComponentNames, status);
|
|
5121
5138
|
if (result.failedIds.length === 0) {
|
|
5122
5139
|
dispatch18(slice.actions.cleanUpdatedComponentNames());
|
|
5123
5140
|
}
|
|
5124
5141
|
};
|
|
5125
5142
|
|
|
5126
|
-
// src/sync/update-components-before-save.ts
|
|
5127
|
-
import { isDocumentDirty as isDocumentDirty2 } from "@elementor/editor-documents";
|
|
5128
|
-
async function updateComponentsBeforeSave({ status, elements }) {
|
|
5129
|
-
if (status !== "publish") {
|
|
5130
|
-
return;
|
|
5131
|
-
}
|
|
5132
|
-
const documents = await getComponentDocuments(elements);
|
|
5133
|
-
const draftIds = [...documents.values()].filter(isDocumentDirty2).map((document) => document.id);
|
|
5134
|
-
if (draftIds.length === 0) {
|
|
5135
|
-
return;
|
|
5136
|
-
}
|
|
5137
|
-
await apiClient.updateStatuses(draftIds, "publish");
|
|
5138
|
-
draftIds.forEach((id2) => invalidateComponentDocumentData(id2));
|
|
5139
|
-
}
|
|
5140
|
-
|
|
5141
5143
|
// src/sync/before-save.ts
|
|
5142
5144
|
var beforeSave = ({ container, status }) => {
|
|
5143
5145
|
const elements = container?.model.get("elements").toJSON?.() ?? [];
|
|
5144
5146
|
return Promise.all([
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
updateComponentsBeforeSave({ elements, status }),
|
|
5148
|
-
setComponentOverridablePropsSettingsBeforeSave({ container }),
|
|
5149
|
-
updateComponentTitleBeforeSave()
|
|
5147
|
+
syncComponents({ elements, status }),
|
|
5148
|
+
setComponentOverridablePropsSettingsBeforeSave({ container })
|
|
5150
5149
|
]);
|
|
5151
5150
|
};
|
|
5151
|
+
var syncComponents = async ({ elements, status }) => {
|
|
5152
|
+
await updateExistingComponentsBeforeSave({ elements, status });
|
|
5153
|
+
await createComponentsBeforeSave({ elements, status });
|
|
5154
|
+
};
|
|
5155
|
+
var updateExistingComponentsBeforeSave = async ({
|
|
5156
|
+
elements,
|
|
5157
|
+
status
|
|
5158
|
+
}) => {
|
|
5159
|
+
await updateComponentTitleBeforeSave(status);
|
|
5160
|
+
await updateArchivedComponentBeforeSave(status);
|
|
5161
|
+
await publishDraftComponentsInPageBeforeSave({ elements, status });
|
|
5162
|
+
};
|
|
5152
5163
|
|
|
5153
5164
|
// src/sync/cleanup-overridable-props-on-delete.ts
|
|
5154
5165
|
import { getAllDescendants as getAllDescendants4 } from "@elementor/editor-elements";
|