@elementor/editor-components 4.0.0-671 → 4.0.0-672
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 +40 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +23 -23
- package/src/sync/publish-draft-components-in-page-before-save.ts +42 -1
package/dist/index.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import { injectTab } from "@elementor/editor-elements-panel";
|
|
|
10
10
|
import { stylesRepository } from "@elementor/editor-styles-repository";
|
|
11
11
|
import { registerDataHook as registerDataHook2 } from "@elementor/editor-v1-adapters";
|
|
12
12
|
import { __registerSlice as registerSlice } from "@elementor/store";
|
|
13
|
-
import { __ as
|
|
13
|
+
import { __ as __13 } from "@wordpress/i18n";
|
|
14
14
|
|
|
15
15
|
// src/component-instance-transformer.ts
|
|
16
16
|
import { createTransformer } from "@elementor/editor-canvas";
|
|
@@ -2696,6 +2696,12 @@ var componentsStylesProvider = createStylesProvider({
|
|
|
2696
2696
|
|
|
2697
2697
|
// src/sync/publish-draft-components-in-page-before-save.ts
|
|
2698
2698
|
import { invalidateDocumentData as invalidateDocumentData2, isDocumentDirty as isDocumentDirty2 } from "@elementor/editor-documents";
|
|
2699
|
+
import { notify as notify4 } from "@elementor/editor-notifications";
|
|
2700
|
+
import { AxiosError } from "@elementor/http-client";
|
|
2701
|
+
import { __ as __12 } from "@wordpress/i18n";
|
|
2702
|
+
var INSUFFICIENT_PERMISSIONS_ERROR_CODE = "insufficient_permissions";
|
|
2703
|
+
var PUBLISH_UPGRADE_URL = "https://go.elementor.com/go-pro-components-edit/";
|
|
2704
|
+
var PUBLISH_UPGRADE_NOTIFICATION_ID = "component-publish-upgrade";
|
|
2699
2705
|
async function publishDraftComponentsInPageBeforeSave({ status, elements }) {
|
|
2700
2706
|
if (status !== "publish") {
|
|
2701
2707
|
return;
|
|
@@ -2705,9 +2711,40 @@ async function publishDraftComponentsInPageBeforeSave({ status, elements }) {
|
|
|
2705
2711
|
if (draftIds.length === 0) {
|
|
2706
2712
|
return;
|
|
2707
2713
|
}
|
|
2708
|
-
|
|
2714
|
+
try {
|
|
2715
|
+
await apiClient.updateStatuses(draftIds, "publish");
|
|
2716
|
+
} catch (error) {
|
|
2717
|
+
if (isInsufficientPermissionsError(error)) {
|
|
2718
|
+
notifyPublishUpgrade();
|
|
2719
|
+
return;
|
|
2720
|
+
}
|
|
2721
|
+
throw error;
|
|
2722
|
+
}
|
|
2709
2723
|
draftIds.forEach((id) => invalidateDocumentData2(id));
|
|
2710
2724
|
}
|
|
2725
|
+
function isInsufficientPermissionsError(error) {
|
|
2726
|
+
return error instanceof AxiosError && error.response?.data?.code === INSUFFICIENT_PERMISSIONS_ERROR_CODE;
|
|
2727
|
+
}
|
|
2728
|
+
function notifyPublishUpgrade() {
|
|
2729
|
+
notify4({
|
|
2730
|
+
type: "promotion",
|
|
2731
|
+
id: PUBLISH_UPGRADE_NOTIFICATION_ID,
|
|
2732
|
+
message: __12(
|
|
2733
|
+
"You have unpublished component on this page. You need a pro version to publish it.",
|
|
2734
|
+
"elementor"
|
|
2735
|
+
),
|
|
2736
|
+
additionalActionProps: [
|
|
2737
|
+
{
|
|
2738
|
+
size: "small",
|
|
2739
|
+
variant: "contained",
|
|
2740
|
+
color: "promotion",
|
|
2741
|
+
href: PUBLISH_UPGRADE_URL,
|
|
2742
|
+
target: "_blank",
|
|
2743
|
+
children: __12("Upgrade Now", "elementor")
|
|
2744
|
+
}
|
|
2745
|
+
]
|
|
2746
|
+
});
|
|
2747
|
+
}
|
|
2711
2748
|
|
|
2712
2749
|
// src/sync/before-save.ts
|
|
2713
2750
|
var beforeSave = ({ container, status }) => {
|
|
@@ -2745,7 +2782,7 @@ function init() {
|
|
|
2745
2782
|
window.elementorCommon.__beforeSave = beforeSave;
|
|
2746
2783
|
injectTab({
|
|
2747
2784
|
id: "components",
|
|
2748
|
-
label:
|
|
2785
|
+
label: __13("Components", "elementor"),
|
|
2749
2786
|
component: Components,
|
|
2750
2787
|
position: 1
|
|
2751
2788
|
});
|