@elementor/editor-components 3.33.0-235 → 3.33.0-236
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 +378 -97
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +362 -77
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/components/components-tab/components-item.tsx +11 -2
- package/src/components/create-component-form/utils/replace-element-with-component.ts +3 -1
- package/src/components/edit-component/component-modal.tsx +134 -0
- package/src/components/edit-component/edit-component.tsx +119 -0
- package/src/create-component-type.ts +8 -2
- package/src/hooks/use-canvas-document.ts +6 -0
- package/src/hooks/use-element-rect.ts +81 -0
- package/src/init.ts +9 -2
- package/src/store/load-components-styles.ts +3 -3
- package/src/store/store.ts +9 -0
- package/src/types.ts +0 -11
package/dist/index.mjs
CHANGED
|
@@ -7,9 +7,9 @@ import {
|
|
|
7
7
|
import { getV1CurrentDocument } from "@elementor/editor-documents";
|
|
8
8
|
import { injectTab } from "@elementor/editor-elements-panel";
|
|
9
9
|
import { stylesRepository } from "@elementor/editor-styles-repository";
|
|
10
|
-
import { __privateListenTo as
|
|
10
|
+
import { __privateListenTo as listenTo2, commandStartEvent, registerDataHook } from "@elementor/editor-v1-adapters";
|
|
11
11
|
import { __registerSlice as registerSlice } from "@elementor/store";
|
|
12
|
-
import { __ as
|
|
12
|
+
import { __ as __8 } from "@wordpress/i18n";
|
|
13
13
|
|
|
14
14
|
// src/component-id-transformer.ts
|
|
15
15
|
import { createTransformer } from "@elementor/editor-canvas";
|
|
@@ -128,6 +128,14 @@ var selectUnpublishedComponents = createSelector(
|
|
|
128
128
|
selectUnpublishedData,
|
|
129
129
|
(unpublishedData) => unpublishedData
|
|
130
130
|
);
|
|
131
|
+
var selectComponentsObject = createSelector(
|
|
132
|
+
selectData,
|
|
133
|
+
selectUnpublishedData,
|
|
134
|
+
(data, unpublishedData) => data.concat(unpublishedData).reduce((acc, component) => {
|
|
135
|
+
acc[component.id] = component;
|
|
136
|
+
return acc;
|
|
137
|
+
}, {})
|
|
138
|
+
);
|
|
131
139
|
var selectLoadIsPending = createSelector(selectLoadStatus, (status) => status === "pending");
|
|
132
140
|
var selectLoadIsError = createSelector(selectLoadStatus, (status) => status === "error");
|
|
133
141
|
var selectStyles = (state) => state[SLICE_NAME].styles ?? {};
|
|
@@ -222,6 +230,58 @@ import { dropElement } from "@elementor/editor-elements";
|
|
|
222
230
|
import { ComponentsIcon } from "@elementor/icons";
|
|
223
231
|
import { Box as Box2, ListItemButton, ListItemIcon, ListItemText, Typography } from "@elementor/ui";
|
|
224
232
|
|
|
233
|
+
// src/store/load-components-styles.ts
|
|
234
|
+
import { __dispatch as dispatch, __getState as getState2 } from "@elementor/store";
|
|
235
|
+
|
|
236
|
+
// src/utils/get-component-ids.ts
|
|
237
|
+
import { isTransformable } from "@elementor/editor-props";
|
|
238
|
+
var getComponentIds = (elements) => {
|
|
239
|
+
return elements.flatMap((element) => {
|
|
240
|
+
const ids = [];
|
|
241
|
+
const type = element.widgetType || element.elType;
|
|
242
|
+
if (type === "e-component" && element.settings?.component && isTransformable(element.settings?.component)) {
|
|
243
|
+
ids.push(element.settings.component.value);
|
|
244
|
+
}
|
|
245
|
+
if (element.elements) {
|
|
246
|
+
ids.push(...getComponentIds(element.elements));
|
|
247
|
+
}
|
|
248
|
+
return ids;
|
|
249
|
+
});
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
// src/store/load-components-styles.ts
|
|
253
|
+
async function loadComponentsStyles(elements) {
|
|
254
|
+
const componentIds = Array.from(new Set(getComponentIds(elements)));
|
|
255
|
+
if (!componentIds.length) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
const knownComponents = selectStyles(getState2());
|
|
259
|
+
const unknownComponentIds = componentIds.filter((id) => !knownComponents[id]);
|
|
260
|
+
if (!unknownComponentIds.length) {
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
addComponentStyles(unknownComponentIds);
|
|
264
|
+
}
|
|
265
|
+
async function addComponentStyles(ids) {
|
|
266
|
+
const newComponents = await loadStyles(ids);
|
|
267
|
+
addStyles(newComponents);
|
|
268
|
+
Object.values(newComponents).forEach(([, data]) => {
|
|
269
|
+
loadComponentsStyles(data.elements ?? []);
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
async function loadStyles(ids) {
|
|
273
|
+
return Promise.all(ids.map(async (id) => [id, await apiClient.getComponentConfig(id)]));
|
|
274
|
+
}
|
|
275
|
+
function addStyles(data) {
|
|
276
|
+
const styles = Object.fromEntries(
|
|
277
|
+
data.map(([componentId, componentData]) => [componentId, extractStyles(componentData)])
|
|
278
|
+
);
|
|
279
|
+
dispatch(slice.actions.addStyles(styles));
|
|
280
|
+
}
|
|
281
|
+
function extractStyles(element) {
|
|
282
|
+
return [...Object.values(element.styles ?? {}), ...(element.elements ?? []).flatMap(extractStyles)];
|
|
283
|
+
}
|
|
284
|
+
|
|
225
285
|
// src/utils/get-container-for-new-element.ts
|
|
226
286
|
import {
|
|
227
287
|
getContainer,
|
|
@@ -293,12 +353,16 @@ var ComponentItem = ({ component }) => {
|
|
|
293
353
|
const handleClick = () => {
|
|
294
354
|
addComponentToPage(componentModel);
|
|
295
355
|
};
|
|
356
|
+
const handleDragEnd = () => {
|
|
357
|
+
loadComponentsStyles([componentModel]);
|
|
358
|
+
endDragElementFromPanel();
|
|
359
|
+
};
|
|
296
360
|
return /* @__PURE__ */ React3.createElement(
|
|
297
361
|
ListItemButton,
|
|
298
362
|
{
|
|
299
363
|
draggable: true,
|
|
300
364
|
onDragStart: () => startDragElementFromPanel(componentModel),
|
|
301
|
-
onDragEnd:
|
|
365
|
+
onDragEnd: handleDragEnd,
|
|
302
366
|
shape: "rounded",
|
|
303
367
|
sx: { border: "solid 1px", borderColor: "divider", py: 0.5, px: 1 }
|
|
304
368
|
},
|
|
@@ -315,6 +379,7 @@ var addComponentToPage = (model) => {
|
|
|
315
379
|
if (!container) {
|
|
316
380
|
throw new Error(`Can't find container to drop new component instance at`);
|
|
317
381
|
}
|
|
382
|
+
loadComponentsStyles([model]);
|
|
318
383
|
dropElement({
|
|
319
384
|
containerId: container.id,
|
|
320
385
|
model,
|
|
@@ -707,31 +772,295 @@ var generateTempId = () => {
|
|
|
707
772
|
return Date.now() + Math.floor(Math.random() * 1e6);
|
|
708
773
|
};
|
|
709
774
|
|
|
710
|
-
// src/components/
|
|
775
|
+
// src/components/edit-component/edit-component.tsx
|
|
776
|
+
import * as React9 from "react";
|
|
777
|
+
import { useCallback, useEffect as useEffect4, useState as useState4 } from "react";
|
|
778
|
+
import { getV1DocumentsManager } from "@elementor/editor-documents";
|
|
779
|
+
import {
|
|
780
|
+
__privateListenTo as listenTo,
|
|
781
|
+
__privateRunCommand as runCommand,
|
|
782
|
+
commandEndEvent as commandEndEvent2
|
|
783
|
+
} from "@elementor/editor-v1-adapters";
|
|
784
|
+
import { __useSelector as useSelector2 } from "@elementor/store";
|
|
785
|
+
|
|
786
|
+
// src/components/edit-component/component-modal.tsx
|
|
711
787
|
import * as React8 from "react";
|
|
788
|
+
import { useEffect as useEffect3 } from "react";
|
|
789
|
+
import { createPortal } from "react-dom";
|
|
790
|
+
import { __ as __5 } from "@wordpress/i18n";
|
|
791
|
+
|
|
792
|
+
// src/hooks/use-canvas-document.ts
|
|
793
|
+
import { getCanvasIframeDocument } from "@elementor/editor-canvas";
|
|
794
|
+
import { __privateUseListenTo as useListenTo, commandEndEvent } from "@elementor/editor-v1-adapters";
|
|
795
|
+
function useCanvasDocument() {
|
|
796
|
+
return useListenTo(commandEndEvent("editor/documents/attach-preview"), () => getCanvasIframeDocument());
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
// src/hooks/use-element-rect.ts
|
|
800
|
+
import { useEffect as useEffect2, useState as useState3 } from "react";
|
|
801
|
+
import { throttle } from "@elementor/utils";
|
|
802
|
+
function useElementRect(element) {
|
|
803
|
+
const [rect, setRect] = useState3(new DOMRect(0, 0, 0, 0));
|
|
804
|
+
const onChange = throttle(
|
|
805
|
+
() => {
|
|
806
|
+
setRect(element?.getBoundingClientRect() ?? new DOMRect(0, 0, 0, 0));
|
|
807
|
+
},
|
|
808
|
+
20,
|
|
809
|
+
true
|
|
810
|
+
);
|
|
811
|
+
useScrollListener({ element, onChange });
|
|
812
|
+
useResizeListener({ element, onChange });
|
|
813
|
+
useMutationsListener({ element, onChange });
|
|
814
|
+
useEffect2(
|
|
815
|
+
() => () => {
|
|
816
|
+
onChange.cancel();
|
|
817
|
+
},
|
|
818
|
+
[onChange]
|
|
819
|
+
);
|
|
820
|
+
return rect;
|
|
821
|
+
}
|
|
822
|
+
function useScrollListener({ element, onChange }) {
|
|
823
|
+
useEffect2(() => {
|
|
824
|
+
if (!element) {
|
|
825
|
+
return;
|
|
826
|
+
}
|
|
827
|
+
const win = element.ownerDocument?.defaultView;
|
|
828
|
+
win?.addEventListener("scroll", onChange, { passive: true });
|
|
829
|
+
return () => {
|
|
830
|
+
win?.removeEventListener("scroll", onChange);
|
|
831
|
+
};
|
|
832
|
+
}, [element, onChange]);
|
|
833
|
+
}
|
|
834
|
+
function useResizeListener({ element, onChange }) {
|
|
835
|
+
useEffect2(() => {
|
|
836
|
+
if (!element) {
|
|
837
|
+
return;
|
|
838
|
+
}
|
|
839
|
+
const resizeObserver = new ResizeObserver(onChange);
|
|
840
|
+
resizeObserver.observe(element);
|
|
841
|
+
const win = element.ownerDocument?.defaultView;
|
|
842
|
+
win?.addEventListener("resize", onChange, { passive: true });
|
|
843
|
+
return () => {
|
|
844
|
+
resizeObserver.disconnect();
|
|
845
|
+
win?.removeEventListener("resize", onChange);
|
|
846
|
+
};
|
|
847
|
+
}, [element, onChange]);
|
|
848
|
+
}
|
|
849
|
+
function useMutationsListener({ element, onChange }) {
|
|
850
|
+
useEffect2(() => {
|
|
851
|
+
if (!element) {
|
|
852
|
+
return;
|
|
853
|
+
}
|
|
854
|
+
const mutationObserver = new MutationObserver(onChange);
|
|
855
|
+
mutationObserver.observe(element, { childList: true, subtree: true });
|
|
856
|
+
return () => {
|
|
857
|
+
mutationObserver.disconnect();
|
|
858
|
+
};
|
|
859
|
+
}, [element, onChange]);
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
// src/components/edit-component/component-modal.tsx
|
|
863
|
+
function ComponentModal({ element, onClose }) {
|
|
864
|
+
const canvasDocument = useCanvasDocument();
|
|
865
|
+
useEffect3(() => {
|
|
866
|
+
const handleEsc = (event) => {
|
|
867
|
+
if (event.key === "Escape") {
|
|
868
|
+
onClose();
|
|
869
|
+
}
|
|
870
|
+
};
|
|
871
|
+
canvasDocument?.body.addEventListener("keydown", handleEsc);
|
|
872
|
+
return () => {
|
|
873
|
+
canvasDocument?.body.removeEventListener("keydown", handleEsc);
|
|
874
|
+
};
|
|
875
|
+
}, [canvasDocument, onClose]);
|
|
876
|
+
if (!canvasDocument?.body) {
|
|
877
|
+
return null;
|
|
878
|
+
}
|
|
879
|
+
return createPortal(
|
|
880
|
+
/* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement(BlockEditPage, null), /* @__PURE__ */ React8.createElement(Backdrop, { canvas: canvasDocument, element, onClose })),
|
|
881
|
+
canvasDocument.body
|
|
882
|
+
);
|
|
883
|
+
}
|
|
884
|
+
function Backdrop({ canvas, element, onClose }) {
|
|
885
|
+
const rect = useElementRect(element);
|
|
886
|
+
const backdropStyle = {
|
|
887
|
+
position: "fixed",
|
|
888
|
+
top: 0,
|
|
889
|
+
left: 0,
|
|
890
|
+
width: "100vw",
|
|
891
|
+
height: "100vh",
|
|
892
|
+
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
893
|
+
zIndex: 999,
|
|
894
|
+
pointerEvents: "painted",
|
|
895
|
+
cursor: "pointer",
|
|
896
|
+
clipPath: getRoundedRectPath(rect, canvas.defaultView, 5)
|
|
897
|
+
};
|
|
898
|
+
const handleKeyDown = (event) => {
|
|
899
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
900
|
+
event.preventDefault();
|
|
901
|
+
onClose();
|
|
902
|
+
}
|
|
903
|
+
};
|
|
904
|
+
return /* @__PURE__ */ React8.createElement(
|
|
905
|
+
"div",
|
|
906
|
+
{
|
|
907
|
+
style: backdropStyle,
|
|
908
|
+
onClick: onClose,
|
|
909
|
+
onKeyDown: handleKeyDown,
|
|
910
|
+
role: "button",
|
|
911
|
+
tabIndex: 0,
|
|
912
|
+
"aria-label": __5("Exit component editing mode", "elementor")
|
|
913
|
+
}
|
|
914
|
+
);
|
|
915
|
+
}
|
|
916
|
+
function getRoundedRectPath(rect, viewport, borderRadius) {
|
|
917
|
+
const padding = borderRadius / 2;
|
|
918
|
+
const { x: originalX, y: originalY, width: originalWidth, height: originalHeight } = rect;
|
|
919
|
+
const x = originalX - padding;
|
|
920
|
+
const y = originalY - padding;
|
|
921
|
+
const width = originalWidth + 2 * padding;
|
|
922
|
+
const height = originalHeight + 2 * padding;
|
|
923
|
+
const radius = Math.min(borderRadius, width / 2, height / 2);
|
|
924
|
+
const { innerWidth: vw, innerHeight: vh } = viewport;
|
|
925
|
+
const path = `path(evenodd, 'M 0 0
|
|
926
|
+
L ${vw} 0
|
|
927
|
+
L ${vw} ${vh}
|
|
928
|
+
L 0 ${vh}
|
|
929
|
+
Z
|
|
930
|
+
M ${x + radius} ${y}
|
|
931
|
+
L ${x + width - radius} ${y}
|
|
932
|
+
A ${radius} ${radius} 0 0 1 ${x + width} ${y + radius}
|
|
933
|
+
L ${x + width} ${y + height - radius}
|
|
934
|
+
A ${radius} ${radius} 0 0 1 ${x + width - radius} ${y + height}
|
|
935
|
+
L ${x + radius} ${y + height}
|
|
936
|
+
A ${radius} ${radius} 0 0 1 ${x} ${y + height - radius}
|
|
937
|
+
L ${x} ${y + radius}
|
|
938
|
+
A ${radius} ${radius} 0 0 1 ${x + radius} ${y}
|
|
939
|
+
Z'
|
|
940
|
+
)`;
|
|
941
|
+
return path.replace(/\s{2,}/g, " ");
|
|
942
|
+
}
|
|
943
|
+
function BlockEditPage() {
|
|
944
|
+
const blockV3DocumentHandlesStyles = `
|
|
945
|
+
.elementor-editor-active {
|
|
946
|
+
& .elementor-section-wrap.ui-sortable {
|
|
947
|
+
display: contents;
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
& *[data-editable-elementor-document]:not(.elementor-edit-mode):hover {
|
|
951
|
+
& .elementor-document-handle:not(.elementor-document-save-back-handle) {
|
|
952
|
+
display: none;
|
|
953
|
+
|
|
954
|
+
&::before,
|
|
955
|
+
& .elementor-document-handle__inner {
|
|
956
|
+
display: none;
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
`;
|
|
962
|
+
return /* @__PURE__ */ React8.createElement("style", { "data-e-style-id": "e-block-v3-document-handles-styles" }, blockV3DocumentHandlesStyles);
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
// src/components/edit-component/edit-component.tsx
|
|
966
|
+
function EditComponent() {
|
|
967
|
+
const [componentsPath, setComponentsPath] = useState4([]);
|
|
968
|
+
useHandleDocumentSwitches(componentsPath, setComponentsPath);
|
|
969
|
+
const onBack = useNavigateBack(componentsPath);
|
|
970
|
+
const currentItem = componentsPath.at(-1);
|
|
971
|
+
const { component: currentComponent } = currentItem ?? {};
|
|
972
|
+
const widget = currentComponent?.container;
|
|
973
|
+
const container = widget?.view?.el?.children?.[0] ?? null;
|
|
974
|
+
const elementDom = container?.children[0];
|
|
975
|
+
if (!elementDom) {
|
|
976
|
+
return null;
|
|
977
|
+
}
|
|
978
|
+
return /* @__PURE__ */ React9.createElement(ComponentModal, { element: elementDom, onClose: onBack });
|
|
979
|
+
}
|
|
980
|
+
function useHandleDocumentSwitches(path, setPath) {
|
|
981
|
+
const components = useSelector2(selectComponentsObject);
|
|
982
|
+
const documentsManager = getV1DocumentsManager();
|
|
983
|
+
useEffect4(
|
|
984
|
+
() => listenTo(commandEndEvent2("editor/documents/attach-preview"), () => {
|
|
985
|
+
const { component: currentComponent } = path.at(-1) ?? {};
|
|
986
|
+
const { id: currentComponentId } = currentComponent ?? {};
|
|
987
|
+
const nextDocument = documentsManager.getCurrent();
|
|
988
|
+
if (nextDocument.id === currentComponentId) {
|
|
989
|
+
return;
|
|
990
|
+
}
|
|
991
|
+
if (currentComponentId) {
|
|
992
|
+
apiClient.unlockComponent(currentComponentId);
|
|
993
|
+
}
|
|
994
|
+
const isComponent = !!components?.[nextDocument.id];
|
|
995
|
+
if (!isComponent) {
|
|
996
|
+
setPath([]);
|
|
997
|
+
return;
|
|
998
|
+
}
|
|
999
|
+
setPath(getUpdatedComponentPath(path, nextDocument));
|
|
1000
|
+
}),
|
|
1001
|
+
[path, setPath, components, documentsManager]
|
|
1002
|
+
);
|
|
1003
|
+
}
|
|
1004
|
+
function getUpdatedComponentPath(path, nextDocument) {
|
|
1005
|
+
const componentIndex = path.findIndex(({ component }) => component.id === nextDocument.id);
|
|
1006
|
+
if (componentIndex >= 0) {
|
|
1007
|
+
return path.slice(0, componentIndex + 1);
|
|
1008
|
+
}
|
|
1009
|
+
return [
|
|
1010
|
+
...path,
|
|
1011
|
+
{
|
|
1012
|
+
instanceId: nextDocument?.container.view?.el?.dataset.id,
|
|
1013
|
+
component: nextDocument
|
|
1014
|
+
}
|
|
1015
|
+
];
|
|
1016
|
+
}
|
|
1017
|
+
function useNavigateBack(path) {
|
|
1018
|
+
const documentsManager = getV1DocumentsManager();
|
|
1019
|
+
return useCallback(() => {
|
|
1020
|
+
const { component: prevComponent, instanceId: prevComponentInstanceId } = path.at(-2) ?? {};
|
|
1021
|
+
const { id: prevComponentId } = prevComponent ?? {};
|
|
1022
|
+
const switchToDocument = (id, selector) => {
|
|
1023
|
+
runCommand("editor/documents/switch", {
|
|
1024
|
+
id,
|
|
1025
|
+
selector,
|
|
1026
|
+
mode: "autosave",
|
|
1027
|
+
setAsInitial: false,
|
|
1028
|
+
shouldScroll: false
|
|
1029
|
+
});
|
|
1030
|
+
};
|
|
1031
|
+
if (prevComponentId && prevComponentInstanceId) {
|
|
1032
|
+
switchToDocument(prevComponentId, `[data-id="${prevComponentInstanceId}"]`);
|
|
1033
|
+
return;
|
|
1034
|
+
}
|
|
1035
|
+
switchToDocument(documentsManager.getInitialId());
|
|
1036
|
+
}, [path, documentsManager]);
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
// src/components/in-edit-mode.tsx
|
|
1040
|
+
import * as React10 from "react";
|
|
712
1041
|
import { closeDialog, openDialog } from "@elementor/editor-ui";
|
|
713
1042
|
import { InfoCircleFilledIcon } from "@elementor/icons";
|
|
714
1043
|
import { Box as Box5, Button as Button2, DialogActions, DialogContent, DialogHeader, Icon as Icon2, Stack as Stack5, Typography as Typography4 } from "@elementor/ui";
|
|
715
|
-
import { __ as
|
|
1044
|
+
import { __ as __6 } from "@wordpress/i18n";
|
|
716
1045
|
var openEditModeDialog = (lockedBy) => {
|
|
717
1046
|
openDialog({
|
|
718
|
-
component: /* @__PURE__ */
|
|
1047
|
+
component: /* @__PURE__ */ React10.createElement(EditModeDialog, { lockedBy })
|
|
719
1048
|
});
|
|
720
1049
|
};
|
|
721
1050
|
var EditModeDialog = ({ lockedBy }) => {
|
|
722
|
-
const content =
|
|
723
|
-
return /* @__PURE__ */
|
|
1051
|
+
const content = __6("%s is currently editing this document", "elementor").replace("%s", lockedBy);
|
|
1052
|
+
return /* @__PURE__ */ React10.createElement(React10.Fragment, null, /* @__PURE__ */ React10.createElement(DialogHeader, { logo: false }, /* @__PURE__ */ React10.createElement(Box5, { display: "flex", alignItems: "center", gap: 1 }, /* @__PURE__ */ React10.createElement(Icon2, { color: "secondary" }, /* @__PURE__ */ React10.createElement(InfoCircleFilledIcon, { fontSize: "medium" })), /* @__PURE__ */ React10.createElement(Typography4, { variant: "subtitle1" }, content))), /* @__PURE__ */ React10.createElement(DialogContent, null, /* @__PURE__ */ React10.createElement(Stack5, { spacing: 2, direction: "column" }, /* @__PURE__ */ React10.createElement(Typography4, { variant: "body2" }, __6(
|
|
724
1053
|
"You can wait for them to finish or reach out to coordinate your changes together.",
|
|
725
1054
|
"elementor"
|
|
726
|
-
)), /* @__PURE__ */
|
|
1055
|
+
)), /* @__PURE__ */ React10.createElement(DialogActions, null, /* @__PURE__ */ React10.createElement(Button2, { color: "secondary", variant: "contained", onClick: closeDialog }, __6("Close", "elementor"))))));
|
|
727
1056
|
};
|
|
728
1057
|
|
|
729
1058
|
// src/create-component-type.ts
|
|
730
1059
|
import {
|
|
731
1060
|
createTemplatedElementView
|
|
732
1061
|
} from "@elementor/editor-canvas";
|
|
733
|
-
import { __privateRunCommand as
|
|
734
|
-
import { __ as
|
|
1062
|
+
import { __privateRunCommand as runCommand2 } from "@elementor/editor-v1-adapters";
|
|
1063
|
+
import { __ as __7 } from "@wordpress/i18n";
|
|
735
1064
|
var TYPE = "e-component";
|
|
736
1065
|
function createComponentType(options) {
|
|
737
1066
|
const legacyWindow = window;
|
|
@@ -782,7 +1111,7 @@ function createComponentView(options) {
|
|
|
782
1111
|
{
|
|
783
1112
|
name: "edit component",
|
|
784
1113
|
icon: "eicon-edit",
|
|
785
|
-
title: () =>
|
|
1114
|
+
title: () => __7("Edit Component", "elementor"),
|
|
786
1115
|
isEnabled: () => true,
|
|
787
1116
|
callback: () => this.switchDocument()
|
|
788
1117
|
}
|
|
@@ -798,18 +1127,22 @@ function createComponentView(options) {
|
|
|
798
1127
|
if (!isAllowedToSwitchDocument) {
|
|
799
1128
|
options.showLockedByModal?.(lockedBy || "");
|
|
800
1129
|
} else {
|
|
801
|
-
|
|
1130
|
+
runCommand2("editor/documents/switch", {
|
|
802
1131
|
id: this.getComponentId()?.value,
|
|
803
1132
|
mode: "autosave",
|
|
804
|
-
selector: `[data-id="${this.model.get("id")}"]
|
|
1133
|
+
selector: `[data-id="${this.model.get("id")}"]`,
|
|
1134
|
+
shouldScroll: false
|
|
805
1135
|
});
|
|
806
|
-
apiClient.lockComponent(this.getComponentId()?.value);
|
|
807
1136
|
}
|
|
808
1137
|
}
|
|
1138
|
+
handleDblClick(e) {
|
|
1139
|
+
e.stopPropagation();
|
|
1140
|
+
this.switchDocument();
|
|
1141
|
+
}
|
|
809
1142
|
events() {
|
|
810
1143
|
return {
|
|
811
1144
|
...super.events(),
|
|
812
|
-
dblclick: this.
|
|
1145
|
+
dblclick: this.handleDblClick
|
|
813
1146
|
};
|
|
814
1147
|
}
|
|
815
1148
|
attributes() {
|
|
@@ -834,18 +1167,18 @@ function setInactiveRecursively(model) {
|
|
|
834
1167
|
}
|
|
835
1168
|
|
|
836
1169
|
// src/populate-store.ts
|
|
837
|
-
import { useEffect as
|
|
838
|
-
import { __dispatch as
|
|
1170
|
+
import { useEffect as useEffect5 } from "react";
|
|
1171
|
+
import { __dispatch as dispatch2 } from "@elementor/store";
|
|
839
1172
|
function PopulateStore() {
|
|
840
|
-
|
|
841
|
-
|
|
1173
|
+
useEffect5(() => {
|
|
1174
|
+
dispatch2(loadComponents());
|
|
842
1175
|
}, []);
|
|
843
1176
|
return null;
|
|
844
1177
|
}
|
|
845
1178
|
|
|
846
1179
|
// src/store/components-styles-provider.ts
|
|
847
1180
|
import { createStylesProvider } from "@elementor/editor-styles-repository";
|
|
848
|
-
import { __getState as
|
|
1181
|
+
import { __getState as getState3, __subscribeWithSelector as subscribeWithSelector } from "@elementor/store";
|
|
849
1182
|
var componentsStylesProvider = createStylesProvider({
|
|
850
1183
|
key: "components-styles",
|
|
851
1184
|
priority: 100,
|
|
@@ -857,66 +1190,14 @@ var componentsStylesProvider = createStylesProvider({
|
|
|
857
1190
|
),
|
|
858
1191
|
actions: {
|
|
859
1192
|
all: () => {
|
|
860
|
-
return selectFlatStyles(
|
|
1193
|
+
return selectFlatStyles(getState3());
|
|
861
1194
|
},
|
|
862
1195
|
get: (id) => {
|
|
863
|
-
return selectFlatStyles(
|
|
1196
|
+
return selectFlatStyles(getState3()).find((style) => style.id === id) ?? null;
|
|
864
1197
|
}
|
|
865
1198
|
}
|
|
866
1199
|
});
|
|
867
1200
|
|
|
868
|
-
// src/store/load-components-styles.ts
|
|
869
|
-
import { __dispatch as dispatch2, __getState as getState3 } from "@elementor/store";
|
|
870
|
-
|
|
871
|
-
// src/utils/get-component-ids.ts
|
|
872
|
-
import { isTransformable } from "@elementor/editor-props";
|
|
873
|
-
var getComponentIds = (elements) => {
|
|
874
|
-
return elements.flatMap((element) => {
|
|
875
|
-
const ids = [];
|
|
876
|
-
const type = element.widgetType || element.elType;
|
|
877
|
-
if (type === "e-component" && element.settings?.component && isTransformable(element.settings?.component)) {
|
|
878
|
-
ids.push(element.settings.component.value);
|
|
879
|
-
}
|
|
880
|
-
if (element.elements) {
|
|
881
|
-
ids.push(...getComponentIds(element.elements));
|
|
882
|
-
}
|
|
883
|
-
return ids;
|
|
884
|
-
});
|
|
885
|
-
};
|
|
886
|
-
|
|
887
|
-
// src/store/load-components-styles.ts
|
|
888
|
-
async function loadComponentsStyles(elements) {
|
|
889
|
-
const componentIds = Array.from(new Set(getComponentIds(elements)));
|
|
890
|
-
if (!componentIds.length) {
|
|
891
|
-
return;
|
|
892
|
-
}
|
|
893
|
-
const knownComponents = selectStyles(getState3());
|
|
894
|
-
const unknownComponentIds = componentIds.filter((id) => !knownComponents[id]);
|
|
895
|
-
if (!unknownComponentIds.length) {
|
|
896
|
-
return;
|
|
897
|
-
}
|
|
898
|
-
addComponentStyles(unknownComponentIds);
|
|
899
|
-
}
|
|
900
|
-
async function addComponentStyles(ids) {
|
|
901
|
-
const newComponents = await loadStyles(ids);
|
|
902
|
-
addStyles(newComponents);
|
|
903
|
-
Object.values(newComponents).forEach(([, data]) => {
|
|
904
|
-
loadComponentsStyles(data.elements);
|
|
905
|
-
});
|
|
906
|
-
}
|
|
907
|
-
async function loadStyles(ids) {
|
|
908
|
-
return Promise.all(ids.map(async (id) => [id, await apiClient.getComponentConfig(id)]));
|
|
909
|
-
}
|
|
910
|
-
function addStyles(data) {
|
|
911
|
-
const styles = Object.fromEntries(
|
|
912
|
-
data.map(([componentId, componentData]) => [componentId, extractStyles(componentData)])
|
|
913
|
-
);
|
|
914
|
-
dispatch2(slice.actions.addStyles(styles));
|
|
915
|
-
}
|
|
916
|
-
function extractStyles(element) {
|
|
917
|
-
return [...Object.values(element.styles ?? {}), ...(element.elements ?? []).flatMap(extractStyles)];
|
|
918
|
-
}
|
|
919
|
-
|
|
920
1201
|
// src/store/remove-component-styles.ts
|
|
921
1202
|
import { __dispatch as dispatch3 } from "@elementor/store";
|
|
922
1203
|
function removeComponentStyles(id) {
|
|
@@ -1016,7 +1297,7 @@ function init() {
|
|
|
1016
1297
|
window.elementorCommon.__beforeSave = beforeSave;
|
|
1017
1298
|
injectTab({
|
|
1018
1299
|
id: "components",
|
|
1019
|
-
label:
|
|
1300
|
+
label: __8("Components", "elementor"),
|
|
1020
1301
|
component: Components
|
|
1021
1302
|
});
|
|
1022
1303
|
injectIntoTop({
|
|
@@ -1027,7 +1308,11 @@ function init() {
|
|
|
1027
1308
|
id: "components-populate-store",
|
|
1028
1309
|
component: PopulateStore
|
|
1029
1310
|
});
|
|
1030
|
-
|
|
1311
|
+
injectIntoTop({
|
|
1312
|
+
id: "edit-component",
|
|
1313
|
+
component: EditComponent
|
|
1314
|
+
});
|
|
1315
|
+
listenTo2(commandStartEvent("editor/documents/attach-preview"), () => {
|
|
1031
1316
|
const { id, config } = getV1CurrentDocument();
|
|
1032
1317
|
if (id) {
|
|
1033
1318
|
removeComponentStyles(id);
|