@elementor/editor-components 4.0.0-670 → 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 CHANGED
@@ -93,7 +93,7 @@ var import_editor_elements_panel = require("@elementor/editor-elements-panel");
93
93
  var import_editor_styles_repository2 = require("@elementor/editor-styles-repository");
94
94
  var import_editor_v1_adapters6 = require("@elementor/editor-v1-adapters");
95
95
  var import_store35 = require("@elementor/store");
96
- var import_i18n12 = require("@wordpress/i18n");
96
+ var import_i18n13 = require("@wordpress/i18n");
97
97
 
98
98
  // src/component-instance-transformer.ts
99
99
  var import_editor_canvas = require("@elementor/editor-canvas");
@@ -2759,6 +2759,12 @@ var componentsStylesProvider = (0, import_editor_styles_repository.createStylesP
2759
2759
 
2760
2760
  // src/sync/publish-draft-components-in-page-before-save.ts
2761
2761
  var import_editor_documents5 = require("@elementor/editor-documents");
2762
+ var import_editor_notifications4 = require("@elementor/editor-notifications");
2763
+ var import_http_client2 = require("@elementor/http-client");
2764
+ var import_i18n12 = require("@wordpress/i18n");
2765
+ var INSUFFICIENT_PERMISSIONS_ERROR_CODE = "insufficient_permissions";
2766
+ var PUBLISH_UPGRADE_URL = "https://go.elementor.com/go-pro-components-edit/";
2767
+ var PUBLISH_UPGRADE_NOTIFICATION_ID = "component-publish-upgrade";
2762
2768
  async function publishDraftComponentsInPageBeforeSave({ status, elements }) {
2763
2769
  if (status !== "publish") {
2764
2770
  return;
@@ -2768,9 +2774,40 @@ async function publishDraftComponentsInPageBeforeSave({ status, elements }) {
2768
2774
  if (draftIds.length === 0) {
2769
2775
  return;
2770
2776
  }
2771
- await apiClient.updateStatuses(draftIds, "publish");
2777
+ try {
2778
+ await apiClient.updateStatuses(draftIds, "publish");
2779
+ } catch (error) {
2780
+ if (isInsufficientPermissionsError(error)) {
2781
+ notifyPublishUpgrade();
2782
+ return;
2783
+ }
2784
+ throw error;
2785
+ }
2772
2786
  draftIds.forEach((id) => (0, import_editor_documents5.invalidateDocumentData)(id));
2773
2787
  }
2788
+ function isInsufficientPermissionsError(error) {
2789
+ return error instanceof import_http_client2.AxiosError && error.response?.data?.code === INSUFFICIENT_PERMISSIONS_ERROR_CODE;
2790
+ }
2791
+ function notifyPublishUpgrade() {
2792
+ (0, import_editor_notifications4.notify)({
2793
+ type: "promotion",
2794
+ id: PUBLISH_UPGRADE_NOTIFICATION_ID,
2795
+ message: (0, import_i18n12.__)(
2796
+ "You have unpublished component on this page. You need a pro version to publish it.",
2797
+ "elementor"
2798
+ ),
2799
+ additionalActionProps: [
2800
+ {
2801
+ size: "small",
2802
+ variant: "contained",
2803
+ color: "promotion",
2804
+ href: PUBLISH_UPGRADE_URL,
2805
+ target: "_blank",
2806
+ children: (0, import_i18n12.__)("Upgrade Now", "elementor")
2807
+ }
2808
+ ]
2809
+ });
2810
+ }
2774
2811
 
2775
2812
  // src/sync/before-save.ts
2776
2813
  var beforeSave = ({ container, status }) => {
@@ -2808,7 +2845,7 @@ function init() {
2808
2845
  window.elementorCommon.__beforeSave = beforeSave;
2809
2846
  (0, import_editor_elements_panel.injectTab)({
2810
2847
  id: "components",
2811
- label: (0, import_i18n12.__)("Components", "elementor"),
2848
+ label: (0, import_i18n13.__)("Components", "elementor"),
2812
2849
  component: Components,
2813
2850
  position: 1
2814
2851
  });