@elementor/editor-components 3.35.0-474 → 3.35.0-476
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 +144 -45
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +141 -42
- package/dist/index.mjs.map +1 -1
- package/package.json +22 -22
- package/src/components/edit-component/component-modal.tsx +15 -11
- package/src/components/edit-component/edit-component.tsx +44 -10
- package/src/init.ts +3 -0
- package/src/prevent-non-atomic-nesting.ts +1 -12
- package/src/sync/handle-component-edit-mode-container.ts +114 -0
- package/src/utils/is-editing-component.ts +13 -0
package/dist/index.js
CHANGED
|
@@ -42,7 +42,7 @@ var import_editor_editing_panel8 = require("@elementor/editor-editing-panel");
|
|
|
42
42
|
var import_editor_elements_panel = require("@elementor/editor-elements-panel");
|
|
43
43
|
var import_editor_panels4 = require("@elementor/editor-panels");
|
|
44
44
|
var import_editor_styles_repository2 = require("@elementor/editor-styles-repository");
|
|
45
|
-
var
|
|
45
|
+
var import_editor_v1_adapters13 = require("@elementor/editor-v1-adapters");
|
|
46
46
|
var import_store80 = require("@elementor/store");
|
|
47
47
|
var import_i18n31 = require("@wordpress/i18n");
|
|
48
48
|
|
|
@@ -2967,8 +2967,19 @@ var import_editor_canvas6 = require("@elementor/editor-canvas");
|
|
|
2967
2967
|
var import_editor_elements9 = require("@elementor/editor-elements");
|
|
2968
2968
|
var import_editor_notifications2 = require("@elementor/editor-notifications");
|
|
2969
2969
|
var import_editor_v1_adapters4 = require("@elementor/editor-v1-adapters");
|
|
2970
|
-
var import_store43 = require("@elementor/store");
|
|
2971
2970
|
var import_i18n22 = require("@wordpress/i18n");
|
|
2971
|
+
|
|
2972
|
+
// src/utils/is-editing-component.ts
|
|
2973
|
+
var import_store43 = require("@elementor/store");
|
|
2974
|
+
function isEditingComponent() {
|
|
2975
|
+
const state = (0, import_store43.__getStore)()?.getState();
|
|
2976
|
+
if (!state) {
|
|
2977
|
+
return false;
|
|
2978
|
+
}
|
|
2979
|
+
return selectCurrentComponentId(state) !== null;
|
|
2980
|
+
}
|
|
2981
|
+
|
|
2982
|
+
// src/prevent-non-atomic-nesting.ts
|
|
2972
2983
|
var NON_ATOMIC_ELEMENT_ALERT = {
|
|
2973
2984
|
type: "default",
|
|
2974
2985
|
message: (0, import_i18n22.__)("This widget isn't compatible with components. Use atomic elements instead.", "elementor"),
|
|
@@ -2988,13 +2999,6 @@ function initNonAtomicNestingPrevention() {
|
|
|
2988
2999
|
condition: blockNonAtomicPaste
|
|
2989
3000
|
});
|
|
2990
3001
|
}
|
|
2991
|
-
function isEditingComponent() {
|
|
2992
|
-
const state = (0, import_store43.__getStore)()?.getState();
|
|
2993
|
-
if (!state) {
|
|
2994
|
-
return false;
|
|
2995
|
-
}
|
|
2996
|
-
return selectCurrentComponentId(state) !== null;
|
|
2997
|
-
}
|
|
2998
3002
|
function isElementAtomic(elementType) {
|
|
2999
3003
|
return (0, import_editor_elements9.getElementType)(elementType) !== null;
|
|
3000
3004
|
}
|
|
@@ -3441,7 +3445,7 @@ function useMutationsListener({ element, onChange }) {
|
|
|
3441
3445
|
}
|
|
3442
3446
|
|
|
3443
3447
|
// src/components/edit-component/component-modal.tsx
|
|
3444
|
-
function ComponentModal({
|
|
3448
|
+
function ComponentModal({ topLevelElementDom, onClose }) {
|
|
3445
3449
|
const canvasDocument = useCanvasDocument();
|
|
3446
3450
|
(0, import_react13.useEffect)(() => {
|
|
3447
3451
|
const handleEsc = (event) => {
|
|
@@ -3458,12 +3462,17 @@ function ComponentModal({ element, onClose }) {
|
|
|
3458
3462
|
return null;
|
|
3459
3463
|
}
|
|
3460
3464
|
return (0, import_react_dom.createPortal)(
|
|
3461
|
-
/* @__PURE__ */ React21.createElement(React21.Fragment, null, /* @__PURE__ */ React21.createElement(BlockEditPage, null), /* @__PURE__ */ React21.createElement(Backdrop, { canvas: canvasDocument, element, onClose })),
|
|
3465
|
+
/* @__PURE__ */ React21.createElement(React21.Fragment, null, /* @__PURE__ */ React21.createElement(BlockEditPage, null), /* @__PURE__ */ React21.createElement(Backdrop, { canvas: canvasDocument, element: topLevelElementDom, onClose })),
|
|
3462
3466
|
canvasDocument.body
|
|
3463
3467
|
);
|
|
3464
3468
|
}
|
|
3465
|
-
function Backdrop({
|
|
3469
|
+
function Backdrop({
|
|
3470
|
+
canvas,
|
|
3471
|
+
element,
|
|
3472
|
+
onClose
|
|
3473
|
+
}) {
|
|
3466
3474
|
const rect = useElementRect(element);
|
|
3475
|
+
const clipPath = element ? getRectPath(rect, canvas.defaultView) : void 0;
|
|
3467
3476
|
const backdropStyle = {
|
|
3468
3477
|
position: "fixed",
|
|
3469
3478
|
top: 0,
|
|
@@ -3474,7 +3483,7 @@ function Backdrop({ canvas, element, onClose }) {
|
|
|
3474
3483
|
zIndex: 999,
|
|
3475
3484
|
pointerEvents: "painted",
|
|
3476
3485
|
cursor: "pointer",
|
|
3477
|
-
clipPath
|
|
3486
|
+
clipPath
|
|
3478
3487
|
};
|
|
3479
3488
|
const handleKeyDown = (event) => {
|
|
3480
3489
|
if (event.key === "Enter" || event.key === " ") {
|
|
@@ -3495,11 +3504,7 @@ function Backdrop({ canvas, element, onClose }) {
|
|
|
3495
3504
|
);
|
|
3496
3505
|
}
|
|
3497
3506
|
function getRectPath(rect, viewport) {
|
|
3498
|
-
const { x
|
|
3499
|
-
const x = originalX;
|
|
3500
|
-
const y = originalY;
|
|
3501
|
-
const width = originalWidth;
|
|
3502
|
-
const height = originalHeight;
|
|
3507
|
+
const { x, y, width, height } = rect;
|
|
3503
3508
|
const { innerWidth: vw, innerHeight: vh } = viewport;
|
|
3504
3509
|
const path = `path(evenodd, 'M 0 0
|
|
3505
3510
|
L ${vw} 0
|
|
@@ -3543,11 +3548,11 @@ function EditComponent() {
|
|
|
3543
3548
|
useHandleDocumentSwitches();
|
|
3544
3549
|
const navigateBack = useNavigateBack();
|
|
3545
3550
|
const onClose = (0, import_utils6.throttle)(navigateBack, 100);
|
|
3546
|
-
const
|
|
3547
|
-
if (!
|
|
3551
|
+
const topLevelElementDom = useComponentDOMElement(currentComponentId ?? void 0);
|
|
3552
|
+
if (!currentComponentId) {
|
|
3548
3553
|
return null;
|
|
3549
3554
|
}
|
|
3550
|
-
return /* @__PURE__ */ React22.createElement(ComponentModal, {
|
|
3555
|
+
return /* @__PURE__ */ React22.createElement(ComponentModal, { topLevelElementDom, onClose });
|
|
3551
3556
|
}
|
|
3552
3557
|
function useHandleDocumentSwitches() {
|
|
3553
3558
|
const documentsManager = (0, import_editor_documents11.getV1DocumentsManager)();
|
|
@@ -3562,8 +3567,8 @@ function useHandleDocumentSwitches() {
|
|
|
3562
3567
|
if (currentComponentId) {
|
|
3563
3568
|
apiClient.unlockComponent(currentComponentId);
|
|
3564
3569
|
}
|
|
3565
|
-
const
|
|
3566
|
-
if (!
|
|
3570
|
+
const isComponent2 = nextDocument.config.type === COMPONENT_DOCUMENT_TYPE;
|
|
3571
|
+
if (!isComponent2) {
|
|
3567
3572
|
updateCurrentComponent({ path: [], currentComponentId: null });
|
|
3568
3573
|
return;
|
|
3569
3574
|
}
|
|
@@ -3604,16 +3609,37 @@ function getInstanceTitle(instanceId, path) {
|
|
|
3604
3609
|
const editorSettings = widget?.model?.get?.("editor_settings");
|
|
3605
3610
|
return editorSettings?.title;
|
|
3606
3611
|
}
|
|
3607
|
-
function
|
|
3612
|
+
function useComponentDOMElement(id2) {
|
|
3613
|
+
const { componentContainerDomElement, topLevelElementDom } = getComponentDOMElements(id2);
|
|
3614
|
+
const [currentElementDom, setCurrentElementDom] = (0, import_react14.useState)(topLevelElementDom);
|
|
3615
|
+
(0, import_react14.useEffect)(() => {
|
|
3616
|
+
setCurrentElementDom(topLevelElementDom);
|
|
3617
|
+
}, [topLevelElementDom]);
|
|
3618
|
+
(0, import_react14.useEffect)(() => {
|
|
3619
|
+
if (!componentContainerDomElement) {
|
|
3620
|
+
return;
|
|
3621
|
+
}
|
|
3622
|
+
const mutationObserver = new MutationObserver(() => {
|
|
3623
|
+
const newElementDom = componentContainerDomElement.children[0];
|
|
3624
|
+
setCurrentElementDom(newElementDom);
|
|
3625
|
+
});
|
|
3626
|
+
mutationObserver.observe(componentContainerDomElement, { childList: true });
|
|
3627
|
+
return () => {
|
|
3628
|
+
mutationObserver.disconnect();
|
|
3629
|
+
};
|
|
3630
|
+
}, [componentContainerDomElement]);
|
|
3631
|
+
return currentElementDom;
|
|
3632
|
+
}
|
|
3633
|
+
function getComponentDOMElements(id2) {
|
|
3608
3634
|
if (!id2) {
|
|
3609
|
-
return null;
|
|
3635
|
+
return { componentContainerDomElement: null, topLevelElementDom: null };
|
|
3610
3636
|
}
|
|
3611
3637
|
const documentsManager = (0, import_editor_documents11.getV1DocumentsManager)();
|
|
3612
3638
|
const currentComponent = documentsManager.get(id2);
|
|
3613
|
-
const
|
|
3614
|
-
const
|
|
3615
|
-
const
|
|
3616
|
-
return
|
|
3639
|
+
const componentContainer = currentComponent?.container;
|
|
3640
|
+
const componentContainerDomElement = componentContainer?.view?.el?.children?.[0] ?? null;
|
|
3641
|
+
const topLevelElementDom = componentContainerDomElement?.children[0] ?? null;
|
|
3642
|
+
return { componentContainerDomElement, topLevelElementDom };
|
|
3617
3643
|
}
|
|
3618
3644
|
|
|
3619
3645
|
// src/components/in-edit-mode.tsx
|
|
@@ -4811,8 +4837,8 @@ function extractComponentIdFromModel(model) {
|
|
|
4811
4837
|
if (!model) {
|
|
4812
4838
|
return null;
|
|
4813
4839
|
}
|
|
4814
|
-
const
|
|
4815
|
-
if (!
|
|
4840
|
+
const isComponent2 = model.widgetType === COMPONENT_TYPE;
|
|
4841
|
+
if (!isComponent2) {
|
|
4816
4842
|
return null;
|
|
4817
4843
|
}
|
|
4818
4844
|
return model.settings?.component_instance?.value?.component_id?.value ?? null;
|
|
@@ -5139,13 +5165,85 @@ function collectDeletedElementIds(containers) {
|
|
|
5139
5165
|
return elementIds;
|
|
5140
5166
|
}
|
|
5141
5167
|
|
|
5142
|
-
// src/sync/
|
|
5168
|
+
// src/sync/handle-component-edit-mode-container.ts
|
|
5169
|
+
var import_editor_elements21 = require("@elementor/editor-elements");
|
|
5143
5170
|
var import_editor_v1_adapters10 = require("@elementor/editor-v1-adapters");
|
|
5171
|
+
var V4_DEFAULT_CONTAINER_TYPE = "e-flexbox";
|
|
5172
|
+
function initHandleComponentEditModeContainer() {
|
|
5173
|
+
initRedirectDropIntoComponent();
|
|
5174
|
+
initHandleTopLevelElementDelete();
|
|
5175
|
+
}
|
|
5176
|
+
function initHandleTopLevelElementDelete() {
|
|
5177
|
+
(0, import_editor_v1_adapters10.registerDataHook)("after", "document/elements/delete", (args) => {
|
|
5178
|
+
if (!isEditingComponent()) {
|
|
5179
|
+
return;
|
|
5180
|
+
}
|
|
5181
|
+
const containers = args.containers ?? (args.container ? [args.container] : []);
|
|
5182
|
+
for (const container of containers) {
|
|
5183
|
+
if (!container.parent || !isComponent(container.parent)) {
|
|
5184
|
+
continue;
|
|
5185
|
+
}
|
|
5186
|
+
const component = container.parent;
|
|
5187
|
+
const isComponentEmpty = component.children?.length === 0;
|
|
5188
|
+
if (isComponentEmpty) {
|
|
5189
|
+
createEmptyTopLevelContainer(container.parent);
|
|
5190
|
+
}
|
|
5191
|
+
}
|
|
5192
|
+
});
|
|
5193
|
+
}
|
|
5194
|
+
function initRedirectDropIntoComponent() {
|
|
5195
|
+
(0, import_editor_v1_adapters10.registerDataHook)("dependency", "preview/drop", (args) => {
|
|
5196
|
+
if (!isEditingComponent()) {
|
|
5197
|
+
return true;
|
|
5198
|
+
}
|
|
5199
|
+
const containers = args.containers ?? (args.container ? [args.container] : []);
|
|
5200
|
+
for (const container of containers) {
|
|
5201
|
+
if (!isComponent(container)) {
|
|
5202
|
+
continue;
|
|
5203
|
+
}
|
|
5204
|
+
const { shouldRedirect, container: redirectedContainer } = getComponentContainer(container);
|
|
5205
|
+
if (!shouldRedirect) {
|
|
5206
|
+
continue;
|
|
5207
|
+
}
|
|
5208
|
+
if (args.containers) {
|
|
5209
|
+
const index = args.containers.indexOf(container);
|
|
5210
|
+
args.containers[index] = redirectedContainer;
|
|
5211
|
+
} else {
|
|
5212
|
+
args.container = redirectedContainer;
|
|
5213
|
+
}
|
|
5214
|
+
}
|
|
5215
|
+
return true;
|
|
5216
|
+
});
|
|
5217
|
+
}
|
|
5218
|
+
function createEmptyTopLevelContainer(container) {
|
|
5219
|
+
const newContainer = (0, import_editor_elements21.createElement)({
|
|
5220
|
+
containerId: container.id,
|
|
5221
|
+
model: { elType: V4_DEFAULT_CONTAINER_TYPE }
|
|
5222
|
+
});
|
|
5223
|
+
(0, import_editor_elements21.selectElement)(newContainer.id);
|
|
5224
|
+
}
|
|
5225
|
+
function getComponentContainer(container) {
|
|
5226
|
+
const topLevelElement = container.children?.[0];
|
|
5227
|
+
if (topLevelElement) {
|
|
5228
|
+
return { shouldRedirect: true, container: topLevelElement };
|
|
5229
|
+
}
|
|
5230
|
+
return { shouldRedirect: false, container };
|
|
5231
|
+
}
|
|
5232
|
+
function isComponent(container) {
|
|
5233
|
+
const isDocument = container.id === "document";
|
|
5234
|
+
if (!isDocument) {
|
|
5235
|
+
return false;
|
|
5236
|
+
}
|
|
5237
|
+
return container.document?.config.type === COMPONENT_DOCUMENT_TYPE;
|
|
5238
|
+
}
|
|
5239
|
+
|
|
5240
|
+
// src/sync/load-component-data-after-instance-added.ts
|
|
5241
|
+
var import_editor_v1_adapters11 = require("@elementor/editor-v1-adapters");
|
|
5144
5242
|
function initLoadComponentDataAfterInstanceAdded() {
|
|
5145
|
-
(0,
|
|
5243
|
+
(0, import_editor_v1_adapters11.registerDataHook)("after", "document/elements/paste", (_args, result) => {
|
|
5146
5244
|
load(result);
|
|
5147
5245
|
});
|
|
5148
|
-
(0,
|
|
5246
|
+
(0, import_editor_v1_adapters11.registerDataHook)("after", "document/elements/import", (_args, result) => {
|
|
5149
5247
|
load(result);
|
|
5150
5248
|
});
|
|
5151
5249
|
}
|
|
@@ -5155,17 +5253,17 @@ function load(result) {
|
|
|
5155
5253
|
}
|
|
5156
5254
|
|
|
5157
5255
|
// src/sync/regenerate-override-keys.ts
|
|
5158
|
-
var
|
|
5159
|
-
var
|
|
5256
|
+
var import_editor_elements22 = require("@elementor/editor-elements");
|
|
5257
|
+
var import_editor_v1_adapters12 = require("@elementor/editor-v1-adapters");
|
|
5160
5258
|
var import_utils10 = require("@elementor/utils");
|
|
5161
5259
|
function initRegenerateOverrideKeys() {
|
|
5162
|
-
(0,
|
|
5260
|
+
(0, import_editor_v1_adapters12.registerDataHook)("after", "document/elements/duplicate", (_args, result) => {
|
|
5163
5261
|
regenerateOverrideKeysForContainers(result);
|
|
5164
5262
|
});
|
|
5165
|
-
(0,
|
|
5263
|
+
(0, import_editor_v1_adapters12.registerDataHook)("after", "document/elements/paste", (_args, result) => {
|
|
5166
5264
|
regenerateOverrideKeysForContainers(result);
|
|
5167
5265
|
});
|
|
5168
|
-
(0,
|
|
5266
|
+
(0, import_editor_v1_adapters12.registerDataHook)("after", "document/elements/import", (_args, result) => {
|
|
5169
5267
|
regenerateOverrideKeysForContainers(result);
|
|
5170
5268
|
});
|
|
5171
5269
|
}
|
|
@@ -5176,11 +5274,11 @@ function regenerateOverrideKeysForContainers(result) {
|
|
|
5176
5274
|
});
|
|
5177
5275
|
}
|
|
5178
5276
|
function regenerateOverrideKeysRecursive(elementId) {
|
|
5179
|
-
const container = (0,
|
|
5277
|
+
const container = (0, import_editor_elements22.getContainer)(elementId);
|
|
5180
5278
|
if (!container) {
|
|
5181
5279
|
return;
|
|
5182
5280
|
}
|
|
5183
|
-
(0,
|
|
5281
|
+
(0, import_editor_elements22.getAllDescendants)(container).forEach(regenerateOverrideKeys);
|
|
5184
5282
|
}
|
|
5185
5283
|
function regenerateOverrideKeys(element) {
|
|
5186
5284
|
if (!isComponentInstance(element.model.toJSON())) {
|
|
@@ -5214,7 +5312,7 @@ function regenerateOverrideKeys(element) {
|
|
|
5214
5312
|
}
|
|
5215
5313
|
}
|
|
5216
5314
|
};
|
|
5217
|
-
(0,
|
|
5315
|
+
(0, import_editor_elements22.updateElementSettings)({
|
|
5218
5316
|
id: element.id,
|
|
5219
5317
|
props: { component_instance: newComponentInstance },
|
|
5220
5318
|
withHistory: false
|
|
@@ -5242,14 +5340,14 @@ function init() {
|
|
|
5242
5340
|
COMPONENT_WIDGET_TYPE,
|
|
5243
5341
|
(options) => createComponentType({ ...options, showLockedByModal: openEditModeDialog })
|
|
5244
5342
|
);
|
|
5245
|
-
(0,
|
|
5343
|
+
(0, import_editor_v1_adapters13.registerDataHook)("dependency", "editor/documents/close", (args) => {
|
|
5246
5344
|
const document = (0, import_editor_documents13.getV1CurrentDocument)();
|
|
5247
5345
|
if (document.config.type === COMPONENT_DOCUMENT_TYPE) {
|
|
5248
5346
|
args.mode = "autosave";
|
|
5249
5347
|
}
|
|
5250
5348
|
return true;
|
|
5251
5349
|
});
|
|
5252
|
-
(0,
|
|
5350
|
+
(0, import_editor_v1_adapters13.registerDataHook)("after", "preview/drop", onElementDrop);
|
|
5253
5351
|
window.elementorCommon.__beforeSave = beforeSave;
|
|
5254
5352
|
(0, import_editor_elements_panel.injectTab)({
|
|
5255
5353
|
id: "components",
|
|
@@ -5273,7 +5371,7 @@ function init() {
|
|
|
5273
5371
|
id: "component-panel-header",
|
|
5274
5372
|
component: ComponentPanelHeader
|
|
5275
5373
|
});
|
|
5276
|
-
(0,
|
|
5374
|
+
(0, import_editor_v1_adapters13.registerDataHook)("after", "editor/documents/attach-preview", async () => {
|
|
5277
5375
|
const { id: id2, config } = (0, import_editor_documents13.getV1CurrentDocument)();
|
|
5278
5376
|
if (id2) {
|
|
5279
5377
|
removeComponentStyles(id2);
|
|
@@ -5305,6 +5403,7 @@ function init() {
|
|
|
5305
5403
|
initCircularNestingPrevention();
|
|
5306
5404
|
initNonAtomicNestingPrevention();
|
|
5307
5405
|
initLoadComponentDataAfterInstanceAdded();
|
|
5406
|
+
initHandleComponentEditModeContainer();
|
|
5308
5407
|
}
|
|
5309
5408
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5310
5409
|
0 && (module.exports = {
|