@elementor/editor-components 4.0.0-650 → 4.0.0-660
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 +84 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +80 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +23 -23
- package/src/extended/shortcuts/create-component-shortcut.ts +121 -0
- package/src/extended/store/actions/create-unpublished-component.ts +1 -1
- package/src/extended/utils/replace-element-with-component.ts +3 -3
- package/src/init.ts +5 -0
package/dist/index.js
CHANGED
|
@@ -92,7 +92,7 @@ var import_editor_elements_panel2 = require("@elementor/editor-elements-panel");
|
|
|
92
92
|
var import_editor_styles_repository2 = require("@elementor/editor-styles-repository");
|
|
93
93
|
var import_editor_v1_adapters13 = require("@elementor/editor-v1-adapters");
|
|
94
94
|
var import_store44 = require("@elementor/store");
|
|
95
|
-
var
|
|
95
|
+
var import_utils13 = require("@elementor/utils");
|
|
96
96
|
var import_i18n33 = require("@wordpress/i18n");
|
|
97
97
|
|
|
98
98
|
// src/component-instance-transformer.ts
|
|
@@ -3914,9 +3914,9 @@ var import_i18n24 = require("@wordpress/i18n");
|
|
|
3914
3914
|
|
|
3915
3915
|
// src/extended/utils/replace-element-with-component.ts
|
|
3916
3916
|
var import_editor_elements11 = require("@elementor/editor-elements");
|
|
3917
|
-
var replaceElementWithComponent =
|
|
3918
|
-
return
|
|
3919
|
-
|
|
3917
|
+
var replaceElementWithComponent = (element, component) => {
|
|
3918
|
+
return (0, import_editor_elements11.replaceElement)({
|
|
3919
|
+
currentElementId: element.id,
|
|
3920
3920
|
newElement: createComponentModel2(component),
|
|
3921
3921
|
withHistory: false
|
|
3922
3922
|
});
|
|
@@ -3947,7 +3947,7 @@ async function createUnpublishedComponent({
|
|
|
3947
3947
|
overridableProps
|
|
3948
3948
|
});
|
|
3949
3949
|
componentsActions.addCreatedThisSession(generatedUid);
|
|
3950
|
-
const componentInstance =
|
|
3950
|
+
const componentInstance = replaceElementWithComponent(element, componentBase);
|
|
3951
3951
|
trackComponentEvent({
|
|
3952
3952
|
action: "created",
|
|
3953
3953
|
source,
|
|
@@ -4186,7 +4186,7 @@ function CreateComponentForm() {
|
|
|
4186
4186
|
const { components } = useComponents();
|
|
4187
4187
|
const eventData = (0, import_react15.useRef)(null);
|
|
4188
4188
|
(0, import_react15.useEffect)(() => {
|
|
4189
|
-
const
|
|
4189
|
+
const OPEN_SAVE_AS_COMPONENT_FORM_EVENT2 = "elementor/editor/open-save-as-component-form";
|
|
4190
4190
|
const openPopup = (event) => {
|
|
4191
4191
|
const { shouldOpen, notification } = shouldOpenForm(event.detail.element, components?.length ?? 0);
|
|
4192
4192
|
if (!shouldOpen) {
|
|
@@ -4202,9 +4202,9 @@ function CreateComponentForm() {
|
|
|
4202
4202
|
...eventData.current
|
|
4203
4203
|
});
|
|
4204
4204
|
};
|
|
4205
|
-
window.addEventListener(
|
|
4205
|
+
window.addEventListener(OPEN_SAVE_AS_COMPONENT_FORM_EVENT2, openPopup);
|
|
4206
4206
|
return () => {
|
|
4207
|
-
window.removeEventListener(
|
|
4207
|
+
window.removeEventListener(OPEN_SAVE_AS_COMPONENT_FORM_EVENT2, openPopup);
|
|
4208
4208
|
};
|
|
4209
4209
|
}, [components?.length]);
|
|
4210
4210
|
const handleSave = async (values) => {
|
|
@@ -5789,6 +5789,76 @@ function initExtended() {
|
|
|
5789
5789
|
});
|
|
5790
5790
|
}
|
|
5791
5791
|
|
|
5792
|
+
// src/extended/shortcuts/create-component-shortcut.ts
|
|
5793
|
+
var import_editor_elements20 = require("@elementor/editor-elements");
|
|
5794
|
+
var import_utils12 = require("@elementor/utils");
|
|
5795
|
+
var CREATE_COMPONENT_SHORTCUT_KEYS = "ctrl+shift+k";
|
|
5796
|
+
var OPEN_SAVE_AS_COMPONENT_FORM_EVENT = "elementor/editor/open-save-as-component-form";
|
|
5797
|
+
function isCreateComponentAllowed() {
|
|
5798
|
+
const selectedElements = (0, import_editor_elements20.getSelectedElements)();
|
|
5799
|
+
if (selectedElements.length !== 1) {
|
|
5800
|
+
return { allowed: false };
|
|
5801
|
+
}
|
|
5802
|
+
const element = selectedElements[0];
|
|
5803
|
+
const elementType = (0, import_editor_elements20.getElementType)(element.type);
|
|
5804
|
+
if (!elementType) {
|
|
5805
|
+
return { allowed: false };
|
|
5806
|
+
}
|
|
5807
|
+
if (!(0, import_utils12.isProActive)()) {
|
|
5808
|
+
return { allowed: false };
|
|
5809
|
+
}
|
|
5810
|
+
const widgetsCache = (0, import_editor_elements20.getWidgetsCache)();
|
|
5811
|
+
const elementConfig = widgetsCache?.[element.type];
|
|
5812
|
+
if (!elementConfig?.atomic_props_schema || !elementConfig?.show_in_panel || elementConfig?.elType === "widget") {
|
|
5813
|
+
return { allowed: false };
|
|
5814
|
+
}
|
|
5815
|
+
const legacyWindow = window;
|
|
5816
|
+
const container = legacyWindow.elementor.getContainer(element.id);
|
|
5817
|
+
if (!container || container.isLocked()) {
|
|
5818
|
+
return { allowed: false };
|
|
5819
|
+
}
|
|
5820
|
+
return { allowed: true, container };
|
|
5821
|
+
}
|
|
5822
|
+
function triggerCreateComponentForm(container) {
|
|
5823
|
+
const legacyWindow = window;
|
|
5824
|
+
const elementRect = container.view.el.getBoundingClientRect();
|
|
5825
|
+
const iframeRect = legacyWindow.elementor.$preview[0].getBoundingClientRect();
|
|
5826
|
+
const anchorPosition = {
|
|
5827
|
+
left: iframeRect.left + elementRect.left + elementRect.width / 2,
|
|
5828
|
+
top: iframeRect.top + elementRect.top
|
|
5829
|
+
};
|
|
5830
|
+
window.dispatchEvent(
|
|
5831
|
+
new CustomEvent(OPEN_SAVE_AS_COMPONENT_FORM_EVENT, {
|
|
5832
|
+
detail: {
|
|
5833
|
+
element: container.model.toJSON({ remove: ["default"] }),
|
|
5834
|
+
anchorPosition,
|
|
5835
|
+
options: {
|
|
5836
|
+
trigger: "keyboard",
|
|
5837
|
+
location: "canvas",
|
|
5838
|
+
secondaryLocation: "canvasElement"
|
|
5839
|
+
}
|
|
5840
|
+
}
|
|
5841
|
+
})
|
|
5842
|
+
);
|
|
5843
|
+
}
|
|
5844
|
+
function initCreateComponentShortcut() {
|
|
5845
|
+
const legacyWindow = window;
|
|
5846
|
+
legacyWindow.$e.shortcuts.register(CREATE_COMPONENT_SHORTCUT_KEYS, {
|
|
5847
|
+
callback: () => {
|
|
5848
|
+
const result = isCreateComponentAllowed();
|
|
5849
|
+
if (!result.allowed) {
|
|
5850
|
+
return;
|
|
5851
|
+
}
|
|
5852
|
+
triggerCreateComponentForm(result.container);
|
|
5853
|
+
},
|
|
5854
|
+
dependency: () => {
|
|
5855
|
+
const result = isCreateComponentAllowed();
|
|
5856
|
+
return result.allowed;
|
|
5857
|
+
},
|
|
5858
|
+
exclude: ["input"]
|
|
5859
|
+
});
|
|
5860
|
+
}
|
|
5861
|
+
|
|
5792
5862
|
// src/populate-store.ts
|
|
5793
5863
|
var import_react21 = require("react");
|
|
5794
5864
|
var import_store37 = require("@elementor/store");
|
|
@@ -5800,7 +5870,7 @@ function PopulateStore() {
|
|
|
5800
5870
|
}
|
|
5801
5871
|
|
|
5802
5872
|
// src/prevent-circular-nesting.ts
|
|
5803
|
-
var
|
|
5873
|
+
var import_editor_elements21 = require("@elementor/editor-elements");
|
|
5804
5874
|
var import_editor_notifications5 = require("@elementor/editor-notifications");
|
|
5805
5875
|
var import_editor_v1_adapters11 = require("@elementor/editor-v1-adapters");
|
|
5806
5876
|
var import_store38 = require("@elementor/store");
|
|
@@ -5895,7 +5965,7 @@ function blockCircularMove(args) {
|
|
|
5895
5965
|
if (!container) {
|
|
5896
5966
|
return false;
|
|
5897
5967
|
}
|
|
5898
|
-
const allElements = (0,
|
|
5968
|
+
const allElements = (0, import_editor_elements21.getAllDescendants)(container);
|
|
5899
5969
|
return allElements.some((element) => {
|
|
5900
5970
|
const componentId = extractComponentIdFromContainer(element);
|
|
5901
5971
|
if (componentId === null) {
|
|
@@ -6017,9 +6087,12 @@ function init() {
|
|
|
6017
6087
|
import_editor_canvas8.settingsTransformersRegistry.register("override", componentOverrideTransformer);
|
|
6018
6088
|
initCircularNestingPrevention();
|
|
6019
6089
|
initLoadComponentDataAfterInstanceAdded();
|
|
6020
|
-
if (!!window.elementorPro && !(0,
|
|
6090
|
+
if (!!window.elementorPro && !(0, import_utils13.isProAtLeast)(PRO_EXTENDED_MIGRATION_VERSION)) {
|
|
6021
6091
|
initExtended();
|
|
6022
6092
|
}
|
|
6093
|
+
if (!!window.elementorPro) {
|
|
6094
|
+
initCreateComponentShortcut();
|
|
6095
|
+
}
|
|
6023
6096
|
}
|
|
6024
6097
|
// Annotate the CommonJS export names for ESM import in node:
|
|
6025
6098
|
0 && (module.exports = {
|