@elementor/editor-canvas 4.2.0-946 → 4.2.0-beta2
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.d.mts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +406 -242
- package/dist/index.mjs +336 -173
- package/package.json +20 -19
- package/src/__tests__/parse-xml.ts +2 -0
- package/src/components/__tests__/elements-overlays.test.tsx +7 -0
- package/src/components/elements-overlays.tsx +17 -6
- package/src/components/grid-outline/__tests__/grid-outline-overlay.test.tsx +13 -15
- package/src/components/grid-outline/grid-empty-cell-positioner.tsx +46 -0
- package/src/components/grid-outline/grid-outline-overlay.tsx +3 -4
- package/src/components/grid-outline/grid-outline.tsx +11 -1
- package/src/components/grid-outline/index.ts +1 -0
- package/src/components/outline-overlay.tsx +9 -2
- package/src/composition-builder/composition-builder.ts +12 -0
- package/src/form-structure/__tests__/form-structure-utils.test.ts +218 -0
- package/src/form-structure/enforce-form-ancestor-commands.ts +11 -4
- package/src/form-structure/utils.ts +47 -0
- package/src/index.ts +1 -0
- package/src/mcp/tools/build-composition/tool.ts +58 -2
- package/src/mcp/tools/configure-element/tool.ts +3 -0
- package/src/types/element-overlay.ts +2 -0
- package/src/utils/__tests__/outline-offset-utils.test.ts +39 -0
- package/src/utils/outline-offset-utils.ts +11 -0
- package/src/utils/tracking.ts +14 -0
package/dist/index.js
CHANGED
|
@@ -33,6 +33,7 @@ __export(index_exports, {
|
|
|
33
33
|
BREAKPOINTS_SCHEMA_FULL_URI: () => BREAKPOINTS_SCHEMA_FULL_URI,
|
|
34
34
|
BREAKPOINTS_SCHEMA_URI: () => BREAKPOINTS_SCHEMA_URI,
|
|
35
35
|
DOCUMENT_STRUCTURE_URI: () => DOCUMENT_STRUCTURE_URI,
|
|
36
|
+
ELEMENT_ADDED_EVENT: () => ELEMENT_ADDED_EVENT,
|
|
36
37
|
GLOBAL_STYLES_IMPORTED_EVENT: () => GLOBAL_STYLES_IMPORTED_EVENT,
|
|
37
38
|
SpotlightBackdrop: () => SpotlightBackdrop,
|
|
38
39
|
UnknownStyleStateError: () => UnknownStyleStateError,
|
|
@@ -396,7 +397,7 @@ var convertCssToAtomic = async (style) => {
|
|
|
396
397
|
|
|
397
398
|
// src/init.tsx
|
|
398
399
|
var import_editor = require("@elementor/editor");
|
|
399
|
-
var
|
|
400
|
+
var import_editor_mcp6 = require("@elementor/editor-mcp");
|
|
400
401
|
|
|
401
402
|
// src/components/classes-rename.tsx
|
|
402
403
|
var import_react = require("react");
|
|
@@ -445,12 +446,8 @@ var React7 = __toESM(require("react"));
|
|
|
445
446
|
var import_editor_elements5 = require("@elementor/editor-elements");
|
|
446
447
|
var import_editor_v1_adapters3 = require("@elementor/editor-v1-adapters");
|
|
447
448
|
|
|
448
|
-
// src/components/grid-outline/grid-
|
|
449
|
-
var
|
|
450
|
-
var import_editor_elements4 = require("@elementor/editor-elements");
|
|
451
|
-
var import_editor_props2 = require("@elementor/editor-props");
|
|
452
|
-
var import_ui2 = require("@elementor/ui");
|
|
453
|
-
var import_react10 = require("@floating-ui/react");
|
|
449
|
+
// src/components/grid-outline/grid-empty-cell-positioner.tsx
|
|
450
|
+
var import_react5 = require("react");
|
|
454
451
|
|
|
455
452
|
// src/hooks/use-element-rect.ts
|
|
456
453
|
var import_react2 = require("react");
|
|
@@ -515,49 +512,8 @@ function useMutationsListener({ element, onChange }) {
|
|
|
515
512
|
}, [element, onChange]);
|
|
516
513
|
}
|
|
517
514
|
|
|
518
|
-
// src/hooks/use-floating-on-element.ts
|
|
519
|
-
var import_react3 = require("react");
|
|
520
|
-
var import_react4 = require("@floating-ui/react");
|
|
521
|
-
function useFloatingOnElement({ element, isSelected }) {
|
|
522
|
-
const [isOpen, setIsOpen] = (0, import_react3.useState)(false);
|
|
523
|
-
const sizeModifier = 2;
|
|
524
|
-
const { refs, floatingStyles, context } = (0, import_react4.useFloating)({
|
|
525
|
-
// Must be controlled for interactions (like hover) to work.
|
|
526
|
-
open: isOpen || isSelected,
|
|
527
|
-
onOpenChange: setIsOpen,
|
|
528
|
-
whileElementsMounted: import_react4.autoUpdate,
|
|
529
|
-
middleware: [
|
|
530
|
-
// Match the floating element's size to the reference element.
|
|
531
|
-
(0, import_react4.size)(() => {
|
|
532
|
-
return {
|
|
533
|
-
apply({ elements, rects }) {
|
|
534
|
-
Object.assign(elements.floating.style, {
|
|
535
|
-
width: `${rects.reference.width + sizeModifier}px`,
|
|
536
|
-
height: `${rects.reference.height + sizeModifier}px`
|
|
537
|
-
});
|
|
538
|
-
}
|
|
539
|
-
};
|
|
540
|
-
}),
|
|
541
|
-
// Center the floating element on the reference element.
|
|
542
|
-
(0, import_react4.offset)(({ rects }) => -rects.reference.height / 2 - rects.floating.height / 2)
|
|
543
|
-
]
|
|
544
|
-
});
|
|
545
|
-
(0, import_react3.useEffect)(() => {
|
|
546
|
-
refs.setReference(element);
|
|
547
|
-
}, [element, refs]);
|
|
548
|
-
return {
|
|
549
|
-
isVisible: isOpen || isSelected,
|
|
550
|
-
context,
|
|
551
|
-
floating: {
|
|
552
|
-
setRef: refs.setFloating,
|
|
553
|
-
ref: refs.floating,
|
|
554
|
-
styles: floatingStyles
|
|
555
|
-
}
|
|
556
|
-
};
|
|
557
|
-
}
|
|
558
|
-
|
|
559
515
|
// src/hooks/use-grid-tracks.ts
|
|
560
|
-
var
|
|
516
|
+
var import_react4 = require("react");
|
|
561
517
|
var import_editor_elements3 = require("@elementor/editor-elements");
|
|
562
518
|
var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
|
|
563
519
|
|
|
@@ -644,10 +600,10 @@ function toPx(value) {
|
|
|
644
600
|
}
|
|
645
601
|
|
|
646
602
|
// src/hooks/use-grid-children.ts
|
|
647
|
-
var
|
|
603
|
+
var import_react3 = require("react");
|
|
648
604
|
function useGridChildren(element) {
|
|
649
|
-
const [signal, setSignal] = (0,
|
|
650
|
-
(0,
|
|
605
|
+
const [signal, setSignal] = (0, import_react3.useState)(0);
|
|
606
|
+
(0, import_react3.useEffect)(() => {
|
|
651
607
|
if (!element) {
|
|
652
608
|
return;
|
|
653
609
|
}
|
|
@@ -694,13 +650,13 @@ var EMPTY = {
|
|
|
694
650
|
};
|
|
695
651
|
var DEVICE_MODE_CHANGE_EVENT = "elementor/device-mode/change";
|
|
696
652
|
function useGridTracks(element, rect) {
|
|
697
|
-
const [tracks, setTracks] = (0,
|
|
653
|
+
const [tracks, setTracks] = (0, import_react4.useState)(EMPTY);
|
|
698
654
|
const trigger = (0, import_editor_v1_adapters2.__privateUseListenTo)(
|
|
699
655
|
[(0, import_editor_v1_adapters2.windowEvent)(import_editor_elements3.ELEMENT_STYLE_CHANGE_EVENT), (0, import_editor_v1_adapters2.windowEvent)(DEVICE_MODE_CHANGE_EVENT)],
|
|
700
656
|
() => ({})
|
|
701
657
|
);
|
|
702
658
|
const childrenTrigger = useGridChildren(element);
|
|
703
|
-
(0,
|
|
659
|
+
(0, import_react4.useEffect)(() => {
|
|
704
660
|
const previewWindow = element?.ownerDocument?.defaultView;
|
|
705
661
|
if (!element || !previewWindow) {
|
|
706
662
|
setTracks(EMPTY);
|
|
@@ -716,98 +672,6 @@ function useGridTracks(element, rect) {
|
|
|
716
672
|
return tracks;
|
|
717
673
|
}
|
|
718
674
|
|
|
719
|
-
// src/components/outline-overlay.tsx
|
|
720
|
-
var React = __toESM(require("react"));
|
|
721
|
-
var import_ui = require("@elementor/ui");
|
|
722
|
-
var import_react8 = require("@floating-ui/react");
|
|
723
|
-
|
|
724
|
-
// src/hooks/use-bind-react-props-to-element.ts
|
|
725
|
-
var import_react7 = require("react");
|
|
726
|
-
function useBindReactPropsToElement(element, getProps) {
|
|
727
|
-
(0, import_react7.useEffect)(() => {
|
|
728
|
-
const el = element;
|
|
729
|
-
const { events, attrs } = groupProps(getProps());
|
|
730
|
-
events.forEach(([eventName, listener]) => el.addEventListener(eventName, listener));
|
|
731
|
-
attrs.forEach(([attrName, attrValue]) => el.setAttribute(attrName, attrValue));
|
|
732
|
-
return () => {
|
|
733
|
-
events.forEach(([eventName, listener]) => el.removeEventListener(eventName, listener));
|
|
734
|
-
attrs.forEach(([attrName]) => el.removeAttribute(attrName));
|
|
735
|
-
};
|
|
736
|
-
}, [getProps, element]);
|
|
737
|
-
}
|
|
738
|
-
function groupProps(props) {
|
|
739
|
-
const eventRegex = /^on(?=[A-Z])/;
|
|
740
|
-
return Object.entries(props).reduce(
|
|
741
|
-
(acc, [propName, propValue]) => {
|
|
742
|
-
if (!eventRegex.test(propName)) {
|
|
743
|
-
acc.attrs.push([propName, propValue]);
|
|
744
|
-
return acc;
|
|
745
|
-
}
|
|
746
|
-
const eventName = propName.replace(eventRegex, "").toLowerCase();
|
|
747
|
-
const listener = propValue;
|
|
748
|
-
acc.events.push([eventName, listener]);
|
|
749
|
-
return acc;
|
|
750
|
-
},
|
|
751
|
-
{
|
|
752
|
-
events: [],
|
|
753
|
-
attrs: []
|
|
754
|
-
}
|
|
755
|
-
);
|
|
756
|
-
}
|
|
757
|
-
|
|
758
|
-
// src/hooks/use-has-overlapping.ts
|
|
759
|
-
var possibleOverlappingSelectors = [".e-off-canvas"];
|
|
760
|
-
var useHasOverlapping = () => {
|
|
761
|
-
const preview = window.elementor?.$preview?.[0];
|
|
762
|
-
if (!preview) {
|
|
763
|
-
return false;
|
|
764
|
-
}
|
|
765
|
-
const hasOverlapping = possibleOverlappingSelectors.map((selector) => Array.from(preview?.contentWindow?.document.body.querySelectorAll(selector) ?? [])).flat().some(
|
|
766
|
-
(elem) => elem.checkVisibility({
|
|
767
|
-
opacityProperty: true,
|
|
768
|
-
visibilityProperty: true,
|
|
769
|
-
contentVisibilityAuto: true
|
|
770
|
-
})
|
|
771
|
-
);
|
|
772
|
-
return hasOverlapping;
|
|
773
|
-
};
|
|
774
|
-
|
|
775
|
-
// src/components/outline-overlay.tsx
|
|
776
|
-
var CANVAS_WRAPPER_ID = "elementor-preview-responsive-wrapper";
|
|
777
|
-
var OverlayBox = (0, import_ui.styled)(import_ui.Box, {
|
|
778
|
-
shouldForwardProp: (prop) => prop !== "isSelected" && prop !== "isSmallerOffset" && prop !== "isGlobal"
|
|
779
|
-
})(
|
|
780
|
-
({ theme, isSelected, isSmallerOffset, isGlobal }) => ({
|
|
781
|
-
outline: `${isSelected ? "2px" : "1px"} solid ${isGlobal ? theme.palette.global.main : theme.palette.primary.light}`,
|
|
782
|
-
outlineOffset: isSelected && !isSmallerOffset ? "-2px" : "-1px",
|
|
783
|
-
pointerEvents: "none"
|
|
784
|
-
})
|
|
785
|
-
);
|
|
786
|
-
var OutlineOverlay = ({ element, isSelected, id, isGlobal = false }) => {
|
|
787
|
-
const { context, floating, isVisible } = useFloatingOnElement({ element, isSelected });
|
|
788
|
-
const { getFloatingProps, getReferenceProps } = (0, import_react8.useInteractions)([(0, import_react8.useHover)(context)]);
|
|
789
|
-
const hasOverlapping = useHasOverlapping();
|
|
790
|
-
useBindReactPropsToElement(element, getReferenceProps);
|
|
791
|
-
const isSmallerOffset = element.offsetHeight <= 1;
|
|
792
|
-
return isVisible && !hasOverlapping && /* @__PURE__ */ React.createElement(import_react8.FloatingPortal, { id: CANVAS_WRAPPER_ID }, /* @__PURE__ */ React.createElement(
|
|
793
|
-
OverlayBox,
|
|
794
|
-
{
|
|
795
|
-
ref: floating.setRef,
|
|
796
|
-
isSelected,
|
|
797
|
-
isGlobal,
|
|
798
|
-
style: floating.styles,
|
|
799
|
-
"data-element-overlay": id,
|
|
800
|
-
role: "presentation",
|
|
801
|
-
isSmallerOffset,
|
|
802
|
-
...getFloatingProps()
|
|
803
|
-
}
|
|
804
|
-
));
|
|
805
|
-
};
|
|
806
|
-
|
|
807
|
-
// src/components/grid-outline/grid-outline.tsx
|
|
808
|
-
var React5 = __toESM(require("react"));
|
|
809
|
-
var import_react9 = require("react");
|
|
810
|
-
|
|
811
675
|
// src/utils/find-first-empty-cell.ts
|
|
812
676
|
function findFirstEmptyCell(element, columnCount, rowCount) {
|
|
813
677
|
if (!element || columnCount === 0 || rowCount === 0) {
|
|
@@ -970,6 +834,194 @@ function scanFirstEmpty(matrix, flowsByColumn) {
|
|
|
970
834
|
return null;
|
|
971
835
|
}
|
|
972
836
|
|
|
837
|
+
// src/components/grid-outline/grid-empty-cell-positioner.tsx
|
|
838
|
+
var CSS_VAR_ROW = "--e-grid-empty-cell-row";
|
|
839
|
+
var CSS_VAR_COL = "--e-grid-empty-cell-col";
|
|
840
|
+
var CSS_VAR_VISIBILITY = "--e-grid-empty-cell-visibility";
|
|
841
|
+
var clearGridEmptyCellStyles = (target) => {
|
|
842
|
+
target.style.removeProperty(CSS_VAR_ROW);
|
|
843
|
+
target.style.removeProperty(CSS_VAR_COL);
|
|
844
|
+
target.style.removeProperty(CSS_VAR_VISIBILITY);
|
|
845
|
+
};
|
|
846
|
+
var GridEmptyCellPositioner = ({ element }) => {
|
|
847
|
+
const rect = useElementRect(element);
|
|
848
|
+
const tracks = useGridTracks(element, rect);
|
|
849
|
+
(0, import_react5.useEffect)(() => {
|
|
850
|
+
if (!element) {
|
|
851
|
+
return;
|
|
852
|
+
}
|
|
853
|
+
const firstEmpty = findFirstEmptyCell(element, tracks.columns.length, tracks.rows.length);
|
|
854
|
+
if (!firstEmpty) {
|
|
855
|
+
element.style.removeProperty(CSS_VAR_ROW);
|
|
856
|
+
element.style.removeProperty(CSS_VAR_COL);
|
|
857
|
+
element.style.setProperty(CSS_VAR_VISIBILITY, "hidden");
|
|
858
|
+
return () => clearGridEmptyCellStyles(element);
|
|
859
|
+
}
|
|
860
|
+
element.style.setProperty(CSS_VAR_ROW, String(firstEmpty.row + 1));
|
|
861
|
+
element.style.setProperty(CSS_VAR_COL, String(firstEmpty.col + 1));
|
|
862
|
+
element.style.setProperty(CSS_VAR_VISIBILITY, "visible");
|
|
863
|
+
return () => {
|
|
864
|
+
clearGridEmptyCellStyles(element);
|
|
865
|
+
};
|
|
866
|
+
}, [element, tracks]);
|
|
867
|
+
return null;
|
|
868
|
+
};
|
|
869
|
+
|
|
870
|
+
// src/components/grid-outline/grid-outline-overlay.tsx
|
|
871
|
+
var React6 = __toESM(require("react"));
|
|
872
|
+
var import_editor_elements4 = require("@elementor/editor-elements");
|
|
873
|
+
var import_ui2 = require("@elementor/ui");
|
|
874
|
+
var import_react11 = require("@floating-ui/react");
|
|
875
|
+
|
|
876
|
+
// src/hooks/use-floating-on-element.ts
|
|
877
|
+
var import_react6 = require("react");
|
|
878
|
+
var import_react7 = require("@floating-ui/react");
|
|
879
|
+
function useFloatingOnElement({ element, isSelected }) {
|
|
880
|
+
const [isOpen, setIsOpen] = (0, import_react6.useState)(false);
|
|
881
|
+
const sizeModifier = 2;
|
|
882
|
+
const { refs, floatingStyles, context } = (0, import_react7.useFloating)({
|
|
883
|
+
// Must be controlled for interactions (like hover) to work.
|
|
884
|
+
open: isOpen || isSelected,
|
|
885
|
+
onOpenChange: setIsOpen,
|
|
886
|
+
whileElementsMounted: import_react7.autoUpdate,
|
|
887
|
+
middleware: [
|
|
888
|
+
// Match the floating element's size to the reference element.
|
|
889
|
+
(0, import_react7.size)(() => {
|
|
890
|
+
return {
|
|
891
|
+
apply({ elements, rects }) {
|
|
892
|
+
Object.assign(elements.floating.style, {
|
|
893
|
+
width: `${rects.reference.width + sizeModifier}px`,
|
|
894
|
+
height: `${rects.reference.height + sizeModifier}px`
|
|
895
|
+
});
|
|
896
|
+
}
|
|
897
|
+
};
|
|
898
|
+
}),
|
|
899
|
+
// Center the floating element on the reference element.
|
|
900
|
+
(0, import_react7.offset)(({ rects }) => -rects.reference.height / 2 - rects.floating.height / 2)
|
|
901
|
+
]
|
|
902
|
+
});
|
|
903
|
+
(0, import_react6.useEffect)(() => {
|
|
904
|
+
refs.setReference(element);
|
|
905
|
+
}, [element, refs]);
|
|
906
|
+
return {
|
|
907
|
+
isVisible: isOpen || isSelected,
|
|
908
|
+
context,
|
|
909
|
+
floating: {
|
|
910
|
+
setRef: refs.setFloating,
|
|
911
|
+
ref: refs.floating,
|
|
912
|
+
styles: floatingStyles
|
|
913
|
+
}
|
|
914
|
+
};
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
// src/components/outline-overlay.tsx
|
|
918
|
+
var React = __toESM(require("react"));
|
|
919
|
+
var import_ui = require("@elementor/ui");
|
|
920
|
+
var import_react9 = require("@floating-ui/react");
|
|
921
|
+
|
|
922
|
+
// src/hooks/use-bind-react-props-to-element.ts
|
|
923
|
+
var import_react8 = require("react");
|
|
924
|
+
function useBindReactPropsToElement(element, getProps) {
|
|
925
|
+
(0, import_react8.useEffect)(() => {
|
|
926
|
+
const el = element;
|
|
927
|
+
const { events, attrs } = groupProps(getProps());
|
|
928
|
+
events.forEach(([eventName, listener]) => el.addEventListener(eventName, listener));
|
|
929
|
+
attrs.forEach(([attrName, attrValue]) => el.setAttribute(attrName, attrValue));
|
|
930
|
+
return () => {
|
|
931
|
+
events.forEach(([eventName, listener]) => el.removeEventListener(eventName, listener));
|
|
932
|
+
attrs.forEach(([attrName]) => el.removeAttribute(attrName));
|
|
933
|
+
};
|
|
934
|
+
}, [getProps, element]);
|
|
935
|
+
}
|
|
936
|
+
function groupProps(props) {
|
|
937
|
+
const eventRegex = /^on(?=[A-Z])/;
|
|
938
|
+
return Object.entries(props).reduce(
|
|
939
|
+
(acc, [propName, propValue]) => {
|
|
940
|
+
if (!eventRegex.test(propName)) {
|
|
941
|
+
acc.attrs.push([propName, propValue]);
|
|
942
|
+
return acc;
|
|
943
|
+
}
|
|
944
|
+
const eventName = propName.replace(eventRegex, "").toLowerCase();
|
|
945
|
+
const listener = propValue;
|
|
946
|
+
acc.events.push([eventName, listener]);
|
|
947
|
+
return acc;
|
|
948
|
+
},
|
|
949
|
+
{
|
|
950
|
+
events: [],
|
|
951
|
+
attrs: []
|
|
952
|
+
}
|
|
953
|
+
);
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
// src/hooks/use-has-overlapping.ts
|
|
957
|
+
var possibleOverlappingSelectors = [".e-off-canvas"];
|
|
958
|
+
var useHasOverlapping = () => {
|
|
959
|
+
const preview = window.elementor?.$preview?.[0];
|
|
960
|
+
if (!preview) {
|
|
961
|
+
return false;
|
|
962
|
+
}
|
|
963
|
+
const hasOverlapping = possibleOverlappingSelectors.map((selector) => Array.from(preview?.contentWindow?.document.body.querySelectorAll(selector) ?? [])).flat().some(
|
|
964
|
+
(elem) => elem.checkVisibility({
|
|
965
|
+
opacityProperty: true,
|
|
966
|
+
visibilityProperty: true,
|
|
967
|
+
contentVisibilityAuto: true
|
|
968
|
+
})
|
|
969
|
+
);
|
|
970
|
+
return hasOverlapping;
|
|
971
|
+
};
|
|
972
|
+
|
|
973
|
+
// src/utils/outline-offset-utils.ts
|
|
974
|
+
var THIN_ELEMENT_MAX_HEIGHT_PX = 1;
|
|
975
|
+
var SMALLER_OUTLINE_OFFSET_WIDGET_TYPES = /* @__PURE__ */ new Set(["e-form-input"]);
|
|
976
|
+
function shouldUseSmallerOutlineOffset(element, widgetType) {
|
|
977
|
+
if (element.offsetHeight <= THIN_ELEMENT_MAX_HEIGHT_PX) {
|
|
978
|
+
return true;
|
|
979
|
+
}
|
|
980
|
+
return widgetType !== void 0 && SMALLER_OUTLINE_OFFSET_WIDGET_TYPES.has(widgetType);
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
// src/components/outline-overlay.tsx
|
|
984
|
+
var CANVAS_WRAPPER_ID = "elementor-preview-responsive-wrapper";
|
|
985
|
+
var OverlayBox = (0, import_ui.styled)(import_ui.Box, {
|
|
986
|
+
shouldForwardProp: (prop) => prop !== "isSelected" && prop !== "isSmallerOffset" && prop !== "isGlobal"
|
|
987
|
+
})(
|
|
988
|
+
({ theme, isSelected, isSmallerOffset, isGlobal }) => ({
|
|
989
|
+
outline: `${isSelected ? "2px" : "1px"} solid ${isGlobal ? theme.palette.global.main : theme.palette.primary.light}`,
|
|
990
|
+
outlineOffset: isSelected && !isSmallerOffset ? "-2px" : "-1px",
|
|
991
|
+
pointerEvents: "none"
|
|
992
|
+
})
|
|
993
|
+
);
|
|
994
|
+
var OutlineOverlay = ({
|
|
995
|
+
element,
|
|
996
|
+
isSelected,
|
|
997
|
+
id,
|
|
998
|
+
isGlobal = false,
|
|
999
|
+
widgetType
|
|
1000
|
+
}) => {
|
|
1001
|
+
const { context, floating, isVisible } = useFloatingOnElement({ element, isSelected });
|
|
1002
|
+
const { getFloatingProps, getReferenceProps } = (0, import_react9.useInteractions)([(0, import_react9.useHover)(context)]);
|
|
1003
|
+
const hasOverlapping = useHasOverlapping();
|
|
1004
|
+
useBindReactPropsToElement(element, getReferenceProps);
|
|
1005
|
+
const isSmallerOffset = shouldUseSmallerOutlineOffset(element, widgetType);
|
|
1006
|
+
return isVisible && !hasOverlapping && /* @__PURE__ */ React.createElement(import_react9.FloatingPortal, { id: CANVAS_WRAPPER_ID }, /* @__PURE__ */ React.createElement(
|
|
1007
|
+
OverlayBox,
|
|
1008
|
+
{
|
|
1009
|
+
ref: floating.setRef,
|
|
1010
|
+
isSelected,
|
|
1011
|
+
isGlobal,
|
|
1012
|
+
style: floating.styles,
|
|
1013
|
+
"data-element-overlay": id,
|
|
1014
|
+
role: "presentation",
|
|
1015
|
+
isSmallerOffset,
|
|
1016
|
+
...getFloatingProps()
|
|
1017
|
+
}
|
|
1018
|
+
));
|
|
1019
|
+
};
|
|
1020
|
+
|
|
1021
|
+
// src/components/grid-outline/grid-outline.tsx
|
|
1022
|
+
var React5 = __toESM(require("react"));
|
|
1023
|
+
var import_react10 = require("react");
|
|
1024
|
+
|
|
973
1025
|
// src/components/grid-outline/cell.tsx
|
|
974
1026
|
var React2 = __toESM(require("react"));
|
|
975
1027
|
var FALLBACK_COLOR = "rgba(0, 0, 0, 0.12)";
|
|
@@ -1077,10 +1129,17 @@ var renderLines = (tracks, width, height) => {
|
|
|
1077
1129
|
))
|
|
1078
1130
|
];
|
|
1079
1131
|
};
|
|
1132
|
+
var isDragActiveFromDom = (element) => {
|
|
1133
|
+
return Boolean(
|
|
1134
|
+
element?.querySelector(
|
|
1135
|
+
".e-dragging-over, .elementor-dragging-on-child, .elementor-draggable-over, .elementor-widget-placeholder, .elementor-sortable-placeholder"
|
|
1136
|
+
)
|
|
1137
|
+
);
|
|
1138
|
+
};
|
|
1080
1139
|
function GridOutline({ element, tracks, width, height }) {
|
|
1081
|
-
const cells = (0,
|
|
1140
|
+
const cells = (0, import_react10.useMemo)(() => computeCellRects(tracks, width, height), [tracks, width, height]);
|
|
1082
1141
|
const hasGap = tracks.columnGap > 0 || tracks.rowGap > 0;
|
|
1083
|
-
const firstEmpty = (0,
|
|
1142
|
+
const firstEmpty = (0, import_react10.useMemo)(
|
|
1084
1143
|
() => findFirstEmptyCell(element, tracks.columns.length, tracks.rows.length),
|
|
1085
1144
|
[element, tracks]
|
|
1086
1145
|
);
|
|
@@ -1094,13 +1153,13 @@ function GridOutline({ element, tracks, width, height }) {
|
|
|
1094
1153
|
xmlns: "http://www.w3.org/2000/svg"
|
|
1095
1154
|
},
|
|
1096
1155
|
hasGap ? renderCells(cells, tracks.borderColor) : renderLines(tracks, width, height)
|
|
1097
|
-
), emptyCellRect && /* @__PURE__ */ React5.createElement(FirstEmptyCell, { rect: emptyCellRect, color: tracks.borderColor }));
|
|
1156
|
+
), emptyCellRect && !isDragActiveFromDom(element) && /* @__PURE__ */ React5.createElement(FirstEmptyCell, { rect: emptyCellRect, color: tracks.borderColor }));
|
|
1098
1157
|
}
|
|
1099
1158
|
|
|
1100
1159
|
// src/components/grid-outline/grid-outline-overlay.tsx
|
|
1101
1160
|
var GridOutlineOverlay = ({ element, id, isSelected }) => {
|
|
1102
|
-
const
|
|
1103
|
-
const enabled =
|
|
1161
|
+
const settings = (0, import_editor_elements4.useElementEditorSettings)(id);
|
|
1162
|
+
const enabled = settings?.grid_outline;
|
|
1104
1163
|
const rect = useElementRect(element);
|
|
1105
1164
|
const tracks = useGridTracks(element, rect);
|
|
1106
1165
|
const { floating } = useFloatingOnElement({ element, isSelected });
|
|
@@ -1110,7 +1169,7 @@ var GridOutlineOverlay = ({ element, id, isSelected }) => {
|
|
|
1110
1169
|
if (tracks.columns.length === 0 && tracks.rows.length === 0) {
|
|
1111
1170
|
return null;
|
|
1112
1171
|
}
|
|
1113
|
-
return /* @__PURE__ */ React6.createElement(
|
|
1172
|
+
return /* @__PURE__ */ React6.createElement(import_react11.FloatingPortal, { id: CANVAS_WRAPPER_ID }, /* @__PURE__ */ React6.createElement(
|
|
1114
1173
|
import_ui2.Box,
|
|
1115
1174
|
{
|
|
1116
1175
|
ref: floating.setRef,
|
|
@@ -1123,15 +1182,22 @@ var GridOutlineOverlay = ({ element, id, isSelected }) => {
|
|
|
1123
1182
|
};
|
|
1124
1183
|
|
|
1125
1184
|
// src/components/elements-overlays.tsx
|
|
1185
|
+
var hasGridStyleDisplay = (element) => {
|
|
1186
|
+
return element.computedStyleMap().get("display")?.toString() === "grid";
|
|
1187
|
+
};
|
|
1126
1188
|
var ELEMENTS_DATA_ATTR = "atomic";
|
|
1127
1189
|
var overlayRegistry = [
|
|
1128
1190
|
{
|
|
1129
1191
|
component: OutlineOverlay,
|
|
1130
1192
|
shouldRender: () => true
|
|
1131
1193
|
},
|
|
1194
|
+
{
|
|
1195
|
+
component: GridEmptyCellPositioner,
|
|
1196
|
+
shouldRender: ({ element }) => hasGridStyleDisplay(element)
|
|
1197
|
+
},
|
|
1132
1198
|
{
|
|
1133
1199
|
component: GridOutlineOverlay,
|
|
1134
|
-
shouldRender: ({
|
|
1200
|
+
shouldRender: ({ isSelected, element }) => isSelected && hasGridStyleDisplay(element)
|
|
1135
1201
|
}
|
|
1136
1202
|
];
|
|
1137
1203
|
function ElementsOverlays() {
|
|
@@ -1144,17 +1210,18 @@ function ElementsOverlays() {
|
|
|
1144
1210
|
if (!isActive) {
|
|
1145
1211
|
return null;
|
|
1146
1212
|
}
|
|
1147
|
-
return elements.map(({ id, domElement, isGlobal }) => {
|
|
1213
|
+
return elements.map(({ id, domElement, isGlobal, widgetType }) => {
|
|
1148
1214
|
const isSelected = selected.element?.id === id;
|
|
1149
1215
|
return overlayRegistry.map(
|
|
1150
|
-
({ shouldRender, component: Overlay }, index) => shouldRender({ id, element: domElement, isSelected }) && /* @__PURE__ */ React7.createElement(
|
|
1216
|
+
({ shouldRender, component: Overlay }, index) => shouldRender({ id, element: domElement, isSelected, widgetType }) && /* @__PURE__ */ React7.createElement(
|
|
1151
1217
|
Overlay,
|
|
1152
1218
|
{
|
|
1153
1219
|
key: `${id}-${index}`,
|
|
1154
1220
|
id,
|
|
1155
1221
|
element: domElement,
|
|
1156
1222
|
isSelected,
|
|
1157
|
-
isGlobal
|
|
1223
|
+
isGlobal,
|
|
1224
|
+
widgetType
|
|
1158
1225
|
}
|
|
1159
1226
|
)
|
|
1160
1227
|
);
|
|
@@ -1167,7 +1234,8 @@ function useElementsDom() {
|
|
|
1167
1234
|
return (0, import_editor_elements5.getElements)().filter((el) => isV4Element(el.view?.el?.dataset)).map((element) => ({
|
|
1168
1235
|
id: element.id,
|
|
1169
1236
|
domElement: element.view?.getDomElement?.()?.get?.(0),
|
|
1170
|
-
isGlobal: element.model.get("isGlobal") ?? false
|
|
1237
|
+
isGlobal: element.model.get("isGlobal") ?? false,
|
|
1238
|
+
widgetType: element.model.get("widgetType")
|
|
1171
1239
|
})).filter((item) => !!item.domElement);
|
|
1172
1240
|
}
|
|
1173
1241
|
);
|
|
@@ -1185,15 +1253,15 @@ var import_editor_v1_adapters5 = require("@elementor/editor-v1-adapters");
|
|
|
1185
1253
|
var import_ui3 = require("@elementor/ui");
|
|
1186
1254
|
|
|
1187
1255
|
// src/hooks/use-interactions-items.ts
|
|
1188
|
-
var
|
|
1256
|
+
var import_react13 = require("react");
|
|
1189
1257
|
var import_editor_interactions = require("@elementor/editor-interactions");
|
|
1190
1258
|
var import_editor_v1_adapters4 = require("@elementor/editor-v1-adapters");
|
|
1191
1259
|
|
|
1192
1260
|
// src/hooks/use-on-mount.ts
|
|
1193
|
-
var
|
|
1261
|
+
var import_react12 = require("react");
|
|
1194
1262
|
function useOnMount(cb) {
|
|
1195
|
-
const mounted = (0,
|
|
1196
|
-
(0,
|
|
1263
|
+
const mounted = (0, import_react12.useRef)(false);
|
|
1264
|
+
(0, import_react12.useEffect)(() => {
|
|
1197
1265
|
if (!mounted.current) {
|
|
1198
1266
|
mounted.current = true;
|
|
1199
1267
|
cb();
|
|
@@ -1203,8 +1271,8 @@ function useOnMount(cb) {
|
|
|
1203
1271
|
|
|
1204
1272
|
// src/hooks/use-interactions-items.ts
|
|
1205
1273
|
function useInteractionsItems() {
|
|
1206
|
-
const [interactionItems, setInteractionItems] = (0,
|
|
1207
|
-
const providerAndSubscribers = (0,
|
|
1274
|
+
const [interactionItems, setInteractionItems] = (0, import_react13.useState)({});
|
|
1275
|
+
const providerAndSubscribers = (0, import_react13.useMemo)(() => {
|
|
1208
1276
|
try {
|
|
1209
1277
|
const providers = import_editor_interactions.interactionsRepository.getProviders();
|
|
1210
1278
|
const mapped = providers.map((provider) => {
|
|
@@ -1221,7 +1289,7 @@ function useInteractionsItems() {
|
|
|
1221
1289
|
return [];
|
|
1222
1290
|
}
|
|
1223
1291
|
}, []);
|
|
1224
|
-
(0,
|
|
1292
|
+
(0, import_react13.useEffect)(() => {
|
|
1225
1293
|
if (providerAndSubscribers.length === 0) {
|
|
1226
1294
|
return;
|
|
1227
1295
|
}
|
|
@@ -1252,7 +1320,7 @@ function useInteractionsItems() {
|
|
|
1252
1320
|
});
|
|
1253
1321
|
});
|
|
1254
1322
|
});
|
|
1255
|
-
return (0,
|
|
1323
|
+
return (0, import_react13.useMemo)(() => {
|
|
1256
1324
|
const result = Object.values(interactionItems).sort(sortByProviderPriority).flatMap(({ items }) => items);
|
|
1257
1325
|
return result;
|
|
1258
1326
|
}, [interactionItems]);
|
|
@@ -1350,7 +1418,7 @@ function getLinkAttrs(el) {
|
|
|
1350
1418
|
}
|
|
1351
1419
|
|
|
1352
1420
|
// src/hooks/use-style-items.ts
|
|
1353
|
-
var
|
|
1421
|
+
var import_react16 = require("react");
|
|
1354
1422
|
var import_editor_responsive2 = require("@elementor/editor-responsive");
|
|
1355
1423
|
var import_editor_styles3 = require("@elementor/editor-styles");
|
|
1356
1424
|
var import_editor_styles_repository2 = require("@elementor/editor-styles-repository");
|
|
@@ -1412,12 +1480,12 @@ function signalizedProcess(signal, steps = []) {
|
|
|
1412
1480
|
}
|
|
1413
1481
|
|
|
1414
1482
|
// src/hooks/use-style-prop-resolver.ts
|
|
1415
|
-
var
|
|
1483
|
+
var import_react14 = require("react");
|
|
1416
1484
|
var import_editor_styles = require("@elementor/editor-styles");
|
|
1417
1485
|
var import_editor_v1_adapters8 = require("@elementor/editor-v1-adapters");
|
|
1418
1486
|
|
|
1419
1487
|
// src/renderers/create-props-resolver.ts
|
|
1420
|
-
var
|
|
1488
|
+
var import_editor_props2 = require("@elementor/editor-props");
|
|
1421
1489
|
|
|
1422
1490
|
// src/renderers/multi-props.ts
|
|
1423
1491
|
var isMultiProps = (propValue) => {
|
|
@@ -1455,7 +1523,7 @@ function createPropsResolver({ transformers, schema: initialSchema, onPropResolv
|
|
|
1455
1523
|
if (value === null || value === void 0) {
|
|
1456
1524
|
return null;
|
|
1457
1525
|
}
|
|
1458
|
-
if (!(0,
|
|
1526
|
+
if (!(0, import_editor_props2.isTransformable)(value)) {
|
|
1459
1527
|
return value;
|
|
1460
1528
|
}
|
|
1461
1529
|
if (depth > TRANSFORM_DEPTH_LIMIT) {
|
|
@@ -1513,13 +1581,13 @@ function createPropsResolver({ transformers, schema: initialSchema, onPropResolv
|
|
|
1513
1581
|
}
|
|
1514
1582
|
|
|
1515
1583
|
// src/renderers/enqueue-font-from-style-prop.ts
|
|
1516
|
-
var
|
|
1584
|
+
var import_editor_props3 = require("@elementor/editor-props");
|
|
1517
1585
|
var maybeEnqueueFontFromStyleProp = (propType, propValue, enqueue) => {
|
|
1518
|
-
if (!(0,
|
|
1586
|
+
if (!(0, import_editor_props3.isTransformable)(propValue) || propValue.disabled) {
|
|
1519
1587
|
return;
|
|
1520
1588
|
}
|
|
1521
1589
|
const typeKey = propType.kind === "union" ? propValue.$$type : propType.key;
|
|
1522
|
-
const propTypeUtil = (0,
|
|
1590
|
+
const propTypeUtil = (0, import_editor_props3.getPropSchemaFromCache)(typeKey);
|
|
1523
1591
|
if (!propTypeUtil || !("getEnqueueFontFamily" in propTypeUtil) || typeof propTypeUtil.getEnqueueFontFamily !== "function") {
|
|
1524
1592
|
return;
|
|
1525
1593
|
}
|
|
@@ -1561,7 +1629,7 @@ var styleTransformersRegistry = createTransformersRegistry();
|
|
|
1561
1629
|
|
|
1562
1630
|
// src/hooks/use-style-prop-resolver.ts
|
|
1563
1631
|
function useStylePropResolver() {
|
|
1564
|
-
return (0,
|
|
1632
|
+
return (0, import_react14.useMemo)(() => {
|
|
1565
1633
|
return createPropsResolver({
|
|
1566
1634
|
transformers: styleTransformersRegistry,
|
|
1567
1635
|
schema: (0, import_editor_styles.getStylesSchema)(),
|
|
@@ -1573,7 +1641,7 @@ function useStylePropResolver() {
|
|
|
1573
1641
|
}
|
|
1574
1642
|
|
|
1575
1643
|
// src/hooks/use-style-renderer.ts
|
|
1576
|
-
var
|
|
1644
|
+
var import_react15 = require("react");
|
|
1577
1645
|
var import_editor_responsive = require("@elementor/editor-responsive");
|
|
1578
1646
|
|
|
1579
1647
|
// src/renderers/create-styles-renderer.ts
|
|
@@ -1682,7 +1750,7 @@ function customCssToString(customCss) {
|
|
|
1682
1750
|
var SELECTOR_PREFIX = ".elementor";
|
|
1683
1751
|
function useStyleRenderer(resolve) {
|
|
1684
1752
|
const breakpoints = (0, import_editor_responsive.useBreakpointsMap)();
|
|
1685
|
-
return (0,
|
|
1753
|
+
return (0, import_react15.useMemo)(() => {
|
|
1686
1754
|
return createStylesRenderer({
|
|
1687
1755
|
selectorPrefix: SELECTOR_PREFIX,
|
|
1688
1756
|
breakpoints,
|
|
@@ -1696,9 +1764,9 @@ function useStyleItems() {
|
|
|
1696
1764
|
const resolve = useStylePropResolver();
|
|
1697
1765
|
const renderStyles = useStyleRenderer(resolve);
|
|
1698
1766
|
const breakpoints = (0, import_editor_responsive2.useBreakpoints)();
|
|
1699
|
-
const [styleItems, setStyleItems] = (0,
|
|
1700
|
-
const styleItemsCacheRef = (0,
|
|
1701
|
-
const providerAndSubscribers = (0,
|
|
1767
|
+
const [styleItems, setStyleItems] = (0, import_react16.useState)({});
|
|
1768
|
+
const styleItemsCacheRef = (0, import_react16.useRef)(/* @__PURE__ */ new Map());
|
|
1769
|
+
const providerAndSubscribers = (0, import_react16.useMemo)(() => {
|
|
1702
1770
|
const createEmptyCache = () => {
|
|
1703
1771
|
return { orderedIds: [], itemsById: /* @__PURE__ */ new Map() };
|
|
1704
1772
|
};
|
|
@@ -1724,7 +1792,7 @@ function useStyleItems() {
|
|
|
1724
1792
|
})
|
|
1725
1793
|
);
|
|
1726
1794
|
}, [renderStyles]);
|
|
1727
|
-
(0,
|
|
1795
|
+
(0, import_react16.useEffect)(() => {
|
|
1728
1796
|
const unsubscribes = providerAndSubscribers.map(
|
|
1729
1797
|
({ provider, subscriber }) => provider.subscribe(subscriber)
|
|
1730
1798
|
);
|
|
@@ -1739,11 +1807,11 @@ function useStyleItems() {
|
|
|
1739
1807
|
await Promise.all(promises);
|
|
1740
1808
|
});
|
|
1741
1809
|
});
|
|
1742
|
-
const breakpointSorter = (0,
|
|
1810
|
+
const breakpointSorter = (0, import_react16.useMemo)(
|
|
1743
1811
|
() => createBreakpointSorter(breakpoints.map((breakpoint) => breakpoint.id)),
|
|
1744
1812
|
[breakpoints]
|
|
1745
1813
|
);
|
|
1746
|
-
return (0,
|
|
1814
|
+
return (0, import_react16.useMemo)(
|
|
1747
1815
|
() => Object.values(styleItems).sort(prioritySorter).flatMap(({ items }) => items).sort(stateSorter).sort(breakpointSorter),
|
|
1748
1816
|
[styleItems, breakpointSorter]
|
|
1749
1817
|
);
|
|
@@ -1980,6 +2048,46 @@ function clipboardRootsAreAtomicForms(elements) {
|
|
|
1980
2048
|
}
|
|
1981
2049
|
return elements.every((el) => getClipboardElementType(el) === FORM_ELEMENT_TYPE);
|
|
1982
2050
|
}
|
|
2051
|
+
function hasFormAncestor(node) {
|
|
2052
|
+
return node.closest(FORM_ELEMENT_TYPE) !== null;
|
|
2053
|
+
}
|
|
2054
|
+
function collectFormAncestorErrors(xml) {
|
|
2055
|
+
const errors = [];
|
|
2056
|
+
for (const node of xml.querySelectorAll("*")) {
|
|
2057
|
+
if (!FORM_FIELD_ELEMENT_TYPES.has(node.tagName.toLowerCase())) {
|
|
2058
|
+
continue;
|
|
2059
|
+
}
|
|
2060
|
+
if (hasFormAncestor(node)) {
|
|
2061
|
+
continue;
|
|
2062
|
+
}
|
|
2063
|
+
const id = node.getAttribute("configuration-id");
|
|
2064
|
+
errors.push(
|
|
2065
|
+
`<${node.tagName}${id ? ` configuration-id="${id}"` : ""}> must be nested inside <e-form> (any ancestor depth is allowed).`
|
|
2066
|
+
);
|
|
2067
|
+
}
|
|
2068
|
+
return errors;
|
|
2069
|
+
}
|
|
2070
|
+
function collectSubmitButtonErrors(xml) {
|
|
2071
|
+
const errors = [];
|
|
2072
|
+
for (const form of xml.querySelectorAll("e-form")) {
|
|
2073
|
+
const submitButtons = form.querySelectorAll("e-form-submit-button");
|
|
2074
|
+
if (submitButtons.length === 0) {
|
|
2075
|
+
errors.push(`<e-form> has no <e-form-submit-button>.`);
|
|
2076
|
+
} else if (submitButtons.length > 1) {
|
|
2077
|
+
errors.push(`<e-form> has ${submitButtons.length} submit buttons \u2014 only 1 is allowed.`);
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
return errors;
|
|
2081
|
+
}
|
|
2082
|
+
function collectEmptyMessageErrors(xml) {
|
|
2083
|
+
const errors = [];
|
|
2084
|
+
for (const node of xml.querySelectorAll("e-form-success-message, e-form-error-message")) {
|
|
2085
|
+
if (node.children.length === 0) {
|
|
2086
|
+
errors.push(`<${node.tagName}> must have at least one child element (e.g. <e-atomic-paragraph>).`);
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
return errors;
|
|
2090
|
+
}
|
|
1983
2091
|
|
|
1984
2092
|
// src/form-structure/enforce-form-ancestor-commands.ts
|
|
1985
2093
|
var FORM_FIELDS_OUTSIDE_ALERT = {
|
|
@@ -2006,7 +2114,8 @@ function blockFormFieldCreate(args) {
|
|
|
2006
2114
|
if (!elementType || !FORM_FIELD_ELEMENT_TYPES.has(elementType)) {
|
|
2007
2115
|
return false;
|
|
2008
2116
|
}
|
|
2009
|
-
|
|
2117
|
+
const containers = args.containers ?? [args.container];
|
|
2118
|
+
if (containers.some((container) => !isWithinForm(container))) {
|
|
2010
2119
|
handleBlockedFormField();
|
|
2011
2120
|
return true;
|
|
2012
2121
|
}
|
|
@@ -2014,10 +2123,10 @@ function blockFormFieldCreate(args) {
|
|
|
2014
2123
|
}
|
|
2015
2124
|
function blockFormFieldMove(args) {
|
|
2016
2125
|
const { containers = [args.container], target } = args;
|
|
2017
|
-
const
|
|
2018
|
-
(container) => container ? hasElementTypes(container, FORM_FIELD_ELEMENT_TYPES) : false
|
|
2126
|
+
const hasLooseFormFields = containers.some(
|
|
2127
|
+
(container) => container ? !hasElementType(container, FORM_ELEMENT_TYPE) && hasElementTypes(container, FORM_FIELD_ELEMENT_TYPES) : false
|
|
2019
2128
|
);
|
|
2020
|
-
if (
|
|
2129
|
+
if (hasLooseFormFields && !isWithinForm(target) && !movedContainersIncludeAtomicFormRoot(containers)) {
|
|
2021
2130
|
handleBlockedFormField();
|
|
2022
2131
|
return true;
|
|
2023
2132
|
}
|
|
@@ -3375,7 +3484,7 @@ var import_client = require("react-dom/client");
|
|
|
3375
3484
|
// src/legacy/replacements/inline-editing/inline-editing-elements.tsx
|
|
3376
3485
|
var React11 = __toESM(require("react"));
|
|
3377
3486
|
var import_editor_elements9 = require("@elementor/editor-elements");
|
|
3378
|
-
var
|
|
3487
|
+
var import_editor_props5 = require("@elementor/editor-props");
|
|
3379
3488
|
var import_editor_v1_adapters13 = require("@elementor/editor-v1-adapters");
|
|
3380
3489
|
var import_i18n3 = require("@wordpress/i18n");
|
|
3381
3490
|
|
|
@@ -3423,13 +3532,13 @@ var ReplacementBase = class {
|
|
|
3423
3532
|
|
|
3424
3533
|
// src/legacy/replacements/inline-editing/canvas-inline-editor.tsx
|
|
3425
3534
|
var React10 = __toESM(require("react"));
|
|
3426
|
-
var
|
|
3535
|
+
var import_react18 = require("react");
|
|
3427
3536
|
var import_editor_controls2 = require("@elementor/editor-controls");
|
|
3428
3537
|
var import_ui5 = require("@elementor/ui");
|
|
3429
|
-
var
|
|
3538
|
+
var import_react19 = require("@floating-ui/react");
|
|
3430
3539
|
|
|
3431
3540
|
// src/legacy/replacements/inline-editing/inline-editing-utils.ts
|
|
3432
|
-
var
|
|
3541
|
+
var import_react17 = require("react");
|
|
3433
3542
|
var TOP_BAR_SELECTOR = "#elementor-editor-wrapper-v2";
|
|
3434
3543
|
var NAVIGATOR_SELECTOR = "#elementor-navigator";
|
|
3435
3544
|
var EDITING_PANEL = "#elementor-panel";
|
|
@@ -3460,8 +3569,8 @@ var getInlineEditorElement = (elementWrapper, expectedTag) => {
|
|
|
3460
3569
|
return !expectedTag ? null : elementWrapper.querySelector(expectedTag);
|
|
3461
3570
|
};
|
|
3462
3571
|
var useOnClickOutsideIframe = (handleUnmount) => {
|
|
3463
|
-
const asyncUnmountInlineEditor = (0,
|
|
3464
|
-
(0,
|
|
3572
|
+
const asyncUnmountInlineEditor = (0, import_react17.useCallback)(() => queueMicrotask(handleUnmount), [handleUnmount]);
|
|
3573
|
+
(0, import_react17.useEffect)(() => {
|
|
3465
3574
|
EDITOR_ELEMENTS_OUT_OF_IFRAME.forEach(
|
|
3466
3575
|
(selector) => document?.querySelector(selector)?.addEventListener("mousedown", asyncUnmountInlineEditor)
|
|
3467
3576
|
);
|
|
@@ -3471,8 +3580,8 @@ var useOnClickOutsideIframe = (handleUnmount) => {
|
|
|
3471
3580
|
}, []);
|
|
3472
3581
|
};
|
|
3473
3582
|
var useRenderToolbar = (ownerDocument, id) => {
|
|
3474
|
-
const [anchor, setAnchor] = (0,
|
|
3475
|
-
(0,
|
|
3583
|
+
const [anchor, setAnchor] = (0, import_react17.useState)(null);
|
|
3584
|
+
(0, import_react17.useEffect)(() => {
|
|
3476
3585
|
if (!anchor) {
|
|
3477
3586
|
removeToolbarAnchor(ownerDocument, id);
|
|
3478
3587
|
}
|
|
@@ -3486,7 +3595,7 @@ var useRenderToolbar = (ownerDocument, id) => {
|
|
|
3486
3595
|
setAnchor(null);
|
|
3487
3596
|
}
|
|
3488
3597
|
};
|
|
3489
|
-
const clearAnchor = (0,
|
|
3598
|
+
const clearAnchor = (0, import_react17.useCallback)(() => {
|
|
3490
3599
|
setAnchor(null);
|
|
3491
3600
|
}, []);
|
|
3492
3601
|
return { onSelectionEnd, anchor, clearAnchor };
|
|
@@ -3566,21 +3675,21 @@ var CanvasInlineEditor = ({
|
|
|
3566
3675
|
setValue,
|
|
3567
3676
|
requestDestroy
|
|
3568
3677
|
}) => {
|
|
3569
|
-
const [active, setActive] = (0,
|
|
3570
|
-
const [editor, setEditor] = (0,
|
|
3678
|
+
const [active, setActive] = (0, import_react18.useState)(true);
|
|
3679
|
+
const [editor, setEditor] = (0, import_react18.useState)(null);
|
|
3571
3680
|
const { onSelectionEnd, anchor: toolbarAnchor, clearAnchor } = useRenderToolbar(rootElement.ownerDocument, id);
|
|
3572
|
-
(0,
|
|
3681
|
+
(0, import_react18.useEffect)(() => {
|
|
3573
3682
|
if (!active) {
|
|
3574
3683
|
clearAnchor();
|
|
3575
3684
|
requestDestroy();
|
|
3576
3685
|
}
|
|
3577
3686
|
}, [active, clearAnchor, requestDestroy]);
|
|
3578
|
-
const dismiss = (0,
|
|
3687
|
+
const dismiss = (0, import_react18.useCallback)(() => {
|
|
3579
3688
|
setEditor(null);
|
|
3580
3689
|
setActive(false);
|
|
3581
3690
|
}, []);
|
|
3582
3691
|
useOnClickOutsideIframe(dismiss);
|
|
3583
|
-
(0,
|
|
3692
|
+
(0, import_react18.useEffect)(() => {
|
|
3584
3693
|
const ownerDocument = contentElement.ownerDocument;
|
|
3585
3694
|
const handleClickAway = (event) => {
|
|
3586
3695
|
if (contentElement.contains(event.target)) {
|
|
@@ -3619,25 +3728,25 @@ var InlineEditingOverlay = ({
|
|
|
3619
3728
|
id
|
|
3620
3729
|
}) => {
|
|
3621
3730
|
const inlineEditedElement = getInlineEditorElement(rootElement, expectedTag);
|
|
3622
|
-
const [overlayRefElement, setOverlayElement] = (0,
|
|
3623
|
-
(0,
|
|
3731
|
+
const [overlayRefElement, setOverlayElement] = (0, import_react18.useState)(inlineEditedElement);
|
|
3732
|
+
(0, import_react18.useEffect)(() => {
|
|
3624
3733
|
setOverlayElement(getInlineEditorElement(rootElement, expectedTag));
|
|
3625
3734
|
}, [expectedTag, rootElement]);
|
|
3626
3735
|
return overlayRefElement ? /* @__PURE__ */ React10.createElement(OutlineOverlay, { element: overlayRefElement, id, isSelected: true }) : null;
|
|
3627
3736
|
};
|
|
3628
3737
|
var InlineEditingToolbar = ({ anchor, editor, id }) => {
|
|
3629
|
-
const { refs, floatingStyles } = (0,
|
|
3738
|
+
const { refs, floatingStyles } = (0, import_react19.useFloating)({
|
|
3630
3739
|
placement: "top",
|
|
3631
3740
|
strategy: "fixed",
|
|
3632
3741
|
transform: false,
|
|
3633
|
-
whileElementsMounted:
|
|
3634
|
-
middleware: [horizontalShifterMiddleware, (0,
|
|
3742
|
+
whileElementsMounted: import_react19.autoUpdate,
|
|
3743
|
+
middleware: [horizontalShifterMiddleware, (0, import_react19.flip)()]
|
|
3635
3744
|
});
|
|
3636
|
-
(0,
|
|
3745
|
+
(0, import_react18.useLayoutEffect)(() => {
|
|
3637
3746
|
refs.setReference(anchor);
|
|
3638
3747
|
return () => refs.setReference(null);
|
|
3639
3748
|
}, [anchor, refs]);
|
|
3640
|
-
return /* @__PURE__ */ React10.createElement(
|
|
3749
|
+
return /* @__PURE__ */ React10.createElement(import_react19.FloatingPortal, { id: CANVAS_WRAPPER_ID }, /* @__PURE__ */ React10.createElement(
|
|
3641
3750
|
import_ui5.Box,
|
|
3642
3751
|
{
|
|
3643
3752
|
ref: refs.setFloating,
|
|
@@ -3652,11 +3761,11 @@ var InlineEditingToolbar = ({ anchor, editor, id }) => {
|
|
|
3652
3761
|
};
|
|
3653
3762
|
|
|
3654
3763
|
// src/legacy/replacements/inline-editing/inline-editing-eligibility.ts
|
|
3655
|
-
var
|
|
3764
|
+
var import_editor_props4 = require("@elementor/editor-props");
|
|
3656
3765
|
var hasKey = (propType) => {
|
|
3657
3766
|
return "key" in propType;
|
|
3658
3767
|
};
|
|
3659
|
-
var TEXT_PROP_TYPE_KEYS = /* @__PURE__ */ new Set([
|
|
3768
|
+
var TEXT_PROP_TYPE_KEYS = /* @__PURE__ */ new Set([import_editor_props4.htmlV3PropTypeUtil.key, import_editor_props4.stringPropTypeUtil.key]);
|
|
3660
3769
|
var isCoreTextPropTypeKey = (key) => {
|
|
3661
3770
|
return TEXT_PROP_TYPE_KEYS.has(key);
|
|
3662
3771
|
};
|
|
@@ -3676,7 +3785,7 @@ var isInlineEditingAllowed = ({ rawValue, propTypeFromSchema }) => {
|
|
|
3676
3785
|
if (rawValue === null || rawValue === void 0) {
|
|
3677
3786
|
return isAllowedBySchema(propTypeFromSchema);
|
|
3678
3787
|
}
|
|
3679
|
-
return
|
|
3788
|
+
return import_editor_props4.htmlV3PropTypeUtil.isValid(rawValue) || import_editor_props4.stringPropTypeUtil.isValid(rawValue);
|
|
3680
3789
|
};
|
|
3681
3790
|
|
|
3682
3791
|
// src/legacy/replacements/inline-editing/inline-editing-elements.tsx
|
|
@@ -3761,15 +3870,15 @@ var InlineEditingReplacement = class extends ReplacementBase {
|
|
|
3761
3870
|
}
|
|
3762
3871
|
getExtractedContentValue() {
|
|
3763
3872
|
const propValue = this.getInlineEditablePropValue();
|
|
3764
|
-
const extracted =
|
|
3765
|
-
return
|
|
3873
|
+
const extracted = import_editor_props5.htmlV3PropTypeUtil.extract(propValue);
|
|
3874
|
+
return import_editor_props5.stringPropTypeUtil.extract(extracted?.content ?? null) ?? "";
|
|
3766
3875
|
}
|
|
3767
3876
|
setContentValue(value) {
|
|
3768
3877
|
const settingKey = this.getInlineEditablePropertyName();
|
|
3769
3878
|
const html = value || "";
|
|
3770
|
-
const parsed = (0,
|
|
3771
|
-
const valueToSave =
|
|
3772
|
-
content: parsed.content ?
|
|
3879
|
+
const parsed = (0, import_editor_props5.parseHtmlChildren)(html);
|
|
3880
|
+
const valueToSave = import_editor_props5.htmlV3PropTypeUtil.create({
|
|
3881
|
+
content: parsed.content ? import_editor_props5.stringPropTypeUtil.create(parsed.content) : null,
|
|
3773
3882
|
children: parsed.children
|
|
3774
3883
|
});
|
|
3775
3884
|
(0, import_editor_v1_adapters13.undoable)(
|
|
@@ -3800,7 +3909,7 @@ var InlineEditingReplacement = class extends ReplacementBase {
|
|
|
3800
3909
|
return null;
|
|
3801
3910
|
}
|
|
3802
3911
|
if (propType.kind === "union") {
|
|
3803
|
-
const textKeys = [
|
|
3912
|
+
const textKeys = [import_editor_props5.htmlV3PropTypeUtil.key, import_editor_props5.stringPropTypeUtil.key];
|
|
3804
3913
|
for (const key of textKeys) {
|
|
3805
3914
|
if (propType.prop_types[key]) {
|
|
3806
3915
|
return key;
|
|
@@ -3829,7 +3938,7 @@ var InlineEditingReplacement = class extends ReplacementBase {
|
|
|
3829
3938
|
getExpectedTag() {
|
|
3830
3939
|
const tagPropType = this.getTagPropType();
|
|
3831
3940
|
const tagSettingKey = "tag";
|
|
3832
|
-
return
|
|
3941
|
+
return import_editor_props5.stringPropTypeUtil.extract(this.getSetting(tagSettingKey) ?? null) ?? import_editor_props5.stringPropTypeUtil.extract(tagPropType?.default ?? null) ?? null;
|
|
3833
3942
|
}
|
|
3834
3943
|
getTagPropType() {
|
|
3835
3944
|
const propsSchema = (0, import_editor_elements9.getElementType)(this.type)?.propsSchema;
|
|
@@ -4056,7 +4165,7 @@ function createNestedTemplatedType(type, renderer, element) {
|
|
|
4056
4165
|
}
|
|
4057
4166
|
|
|
4058
4167
|
// src/legacy/tabs-model-extensions.ts
|
|
4059
|
-
var
|
|
4168
|
+
var import_editor_props6 = require("@elementor/editor-props");
|
|
4060
4169
|
var tabModelExtensions = {
|
|
4061
4170
|
modifyDefaultChildren(elements) {
|
|
4062
4171
|
if (!Array.isArray(elements) || elements.length === 0) {
|
|
@@ -4072,8 +4181,8 @@ var tabModelExtensions = {
|
|
|
4072
4181
|
...paragraphElement,
|
|
4073
4182
|
settings: {
|
|
4074
4183
|
...paragraphElement.settings,
|
|
4075
|
-
paragraph:
|
|
4076
|
-
content:
|
|
4184
|
+
paragraph: import_editor_props6.htmlV3PropTypeUtil.create({
|
|
4185
|
+
content: import_editor_props6.stringPropTypeUtil.create(`Tab ${position}`),
|
|
4077
4186
|
children: []
|
|
4078
4187
|
})
|
|
4079
4188
|
}
|
|
@@ -4086,7 +4195,7 @@ function initTabsModelExtensions() {
|
|
|
4086
4195
|
}
|
|
4087
4196
|
|
|
4088
4197
|
// src/mcp/canvas-mcp.ts
|
|
4089
|
-
var
|
|
4198
|
+
var import_editor_props11 = require("@elementor/editor-props");
|
|
4090
4199
|
|
|
4091
4200
|
// src/mcp/resources/available-widgets-resource.ts
|
|
4092
4201
|
var import_editor_v1_adapters15 = require("@elementor/editor-v1-adapters");
|
|
@@ -4238,7 +4347,7 @@ function extractElementData(element) {
|
|
|
4238
4347
|
}
|
|
4239
4348
|
|
|
4240
4349
|
// src/mcp/resources/dynamic-tags-resource.ts
|
|
4241
|
-
var
|
|
4350
|
+
var import_editor_props7 = require("@elementor/editor-props");
|
|
4242
4351
|
|
|
4243
4352
|
// src/mcp/utils/resolve-dynamic-tag.ts
|
|
4244
4353
|
var import_editor_v1_adapters17 = require("@elementor/editor-v1-adapters");
|
|
@@ -4306,7 +4415,7 @@ var defaultSettingValue = (propType) => {
|
|
|
4306
4415
|
var DYNAMIC_TAGS_URI = "elementor://dynamic-tags";
|
|
4307
4416
|
var settingsSchema = (propsSchema) => {
|
|
4308
4417
|
return Object.fromEntries(
|
|
4309
|
-
Object.entries(propsSchema ?? {}).filter(([key]) => !OMITTED_DYNAMIC_SETTING_KEYS.includes(key)).map(([key, propType]) => [key,
|
|
4418
|
+
Object.entries(propsSchema ?? {}).filter(([key]) => !OMITTED_DYNAMIC_SETTING_KEYS.includes(key)).map(([key, propType]) => [key, import_editor_props7.Schema.propTypeToJsonSchema(propType)])
|
|
4310
4419
|
);
|
|
4311
4420
|
};
|
|
4312
4421
|
var buildDynamicTagsList = () => {
|
|
@@ -4656,13 +4765,14 @@ function getElementDisplayName(container) {
|
|
|
4656
4765
|
// src/mcp/tools/build-composition/tool.ts
|
|
4657
4766
|
var import_editor_documents3 = require("@elementor/editor-documents");
|
|
4658
4767
|
var import_editor_elements16 = require("@elementor/editor-elements");
|
|
4768
|
+
var import_editor_mcp3 = require("@elementor/editor-mcp");
|
|
4659
4769
|
|
|
4660
4770
|
// src/composition-builder/composition-builder.ts
|
|
4661
4771
|
var import_editor_elements15 = require("@elementor/editor-elements");
|
|
4662
4772
|
|
|
4663
4773
|
// src/mcp/utils/do-update-element-property.ts
|
|
4664
4774
|
var import_editor_elements14 = require("@elementor/editor-elements");
|
|
4665
|
-
var
|
|
4775
|
+
var import_editor_props8 = require("@elementor/editor-props");
|
|
4666
4776
|
var import_editor_styles4 = require("@elementor/editor-styles");
|
|
4667
4777
|
var import_editor_v1_adapters21 = require("@elementor/editor-v1-adapters");
|
|
4668
4778
|
|
|
@@ -4739,7 +4849,7 @@ var LOCAL_STYLE_META = {
|
|
|
4739
4849
|
};
|
|
4740
4850
|
function resolvePropValue(value, forceKey) {
|
|
4741
4851
|
const Utils = window.elementorV2.editorVariables.Utils;
|
|
4742
|
-
return
|
|
4852
|
+
return import_editor_props8.Schema.adjustLlmPropValueSchema(value, {
|
|
4743
4853
|
forceKey,
|
|
4744
4854
|
transformers: {
|
|
4745
4855
|
...Utils.globalVariablesLLMResolvers,
|
|
@@ -4798,7 +4908,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
4798
4908
|
}
|
|
4799
4909
|
if (propertyRawSchema.kind === "plain") {
|
|
4800
4910
|
if (typeof propertyMapValue[stylePropName] !== "object") {
|
|
4801
|
-
const propUtil = (0,
|
|
4911
|
+
const propUtil = (0, import_editor_props8.getPropSchemaFromCache)(propertyRawSchema.key);
|
|
4802
4912
|
if (propUtil) {
|
|
4803
4913
|
const plainValue = propUtil.create(propertyMapValue[stylePropName]);
|
|
4804
4914
|
propertyMapValue[stylePropName] = plainValue;
|
|
@@ -4851,7 +4961,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
4851
4961
|
}
|
|
4852
4962
|
const propKey = elementPropSchema[propertyName].key;
|
|
4853
4963
|
const value = resolvePropValue(propertyValue, propKey);
|
|
4854
|
-
const { valid, jsonSchema } =
|
|
4964
|
+
const { valid, jsonSchema } = import_editor_props8.Schema.validatePropValue(elementPropSchema[propertyName], propertyValue);
|
|
4855
4965
|
if (!valid) {
|
|
4856
4966
|
throw new Error(
|
|
4857
4967
|
`Invalid PropValue for elementId: ${elementId}. PropKey: ${propKey}, PropValue: ${JSON.stringify(
|
|
@@ -5122,6 +5232,11 @@ var CompositionBuilder = class _CompositionBuilder {
|
|
|
5122
5232
|
throw new Error(`Invalid element structure:
|
|
5123
5233
|
${childTypeErrors.join("\n")}`);
|
|
5124
5234
|
}
|
|
5235
|
+
const formErrors = [
|
|
5236
|
+
...collectFormAncestorErrors(this.xml),
|
|
5237
|
+
...collectSubmitButtonErrors(this.xml),
|
|
5238
|
+
...collectEmptyMessageErrors(this.xml)
|
|
5239
|
+
];
|
|
5125
5240
|
const children = Array.from(this.xml.children);
|
|
5126
5241
|
for (const childNode of children) {
|
|
5127
5242
|
const modelTree = this.buildModelTree(childNode, widgetsCache);
|
|
@@ -5156,11 +5271,18 @@ ${childTypeErrors.join("\n")}`);
|
|
|
5156
5271
|
return {
|
|
5157
5272
|
configErrors,
|
|
5158
5273
|
styleErrors,
|
|
5274
|
+
formErrors,
|
|
5159
5275
|
rootContainers: [...this.rootContainers]
|
|
5160
5276
|
};
|
|
5161
5277
|
}
|
|
5162
5278
|
};
|
|
5163
5279
|
|
|
5280
|
+
// src/utils/tracking.ts
|
|
5281
|
+
var import_events = require("@elementor/events");
|
|
5282
|
+
var trackCanvasEvent = (data) => {
|
|
5283
|
+
(0, import_events.trackEvent)(data);
|
|
5284
|
+
};
|
|
5285
|
+
|
|
5164
5286
|
// src/mcp/utils/get-composition-target-container.ts
|
|
5165
5287
|
var import_editor_documents2 = require("@elementor/editor-documents");
|
|
5166
5288
|
function getCompositionTargetContainer(documentContainer, documentType) {
|
|
@@ -5408,6 +5530,7 @@ function serializeWrapped(doc, rootElement, wrapperConfigId) {
|
|
|
5408
5530
|
}
|
|
5409
5531
|
|
|
5410
5532
|
// src/mcp/tools/build-composition/tool.ts
|
|
5533
|
+
var ELEMENT_ADDED_EVENT = "elementor/canvas/element-added";
|
|
5411
5534
|
var initBuildCompositionsTool = (reg) => {
|
|
5412
5535
|
const { addTool, resource } = reg;
|
|
5413
5536
|
resource(
|
|
@@ -5459,12 +5582,28 @@ var initBuildCompositionsTool = (reg) => {
|
|
|
5459
5582
|
compositionBuilder.setElementConfig(elementConfig);
|
|
5460
5583
|
compositionBuilder.setStylesConfig(stylesConfig);
|
|
5461
5584
|
compositionBuilder.setCustomCSS(customCSS);
|
|
5462
|
-
const {
|
|
5585
|
+
const {
|
|
5586
|
+
configErrors,
|
|
5587
|
+
formErrors,
|
|
5588
|
+
rootContainers: generatedRootContainers
|
|
5589
|
+
} = await compositionBuilder.build(targetContainer);
|
|
5463
5590
|
rootContainers.push(...generatedRootContainers);
|
|
5464
5591
|
generatedXML = new XMLSerializer().serializeToString(compositionBuilder.getXML());
|
|
5592
|
+
rootContainers.forEach((container) => {
|
|
5593
|
+
const elementData = container.model?.toJSON();
|
|
5594
|
+
if (elementData) {
|
|
5595
|
+
onElementAdded(elementData);
|
|
5596
|
+
}
|
|
5597
|
+
});
|
|
5598
|
+
Object.values(stylesConfig).forEach((styleValue) => {
|
|
5599
|
+
(0, import_editor_mcp3.dispatchMcpStylesAppliedEvent)({ styleValue });
|
|
5600
|
+
});
|
|
5465
5601
|
if (configErrors.length) {
|
|
5466
5602
|
errors.push(...configErrors.map((msg) => new Error(msg)));
|
|
5467
5603
|
}
|
|
5604
|
+
if (formErrors.length) {
|
|
5605
|
+
errors.push(...formErrors.map((msg) => new Error(msg)));
|
|
5606
|
+
}
|
|
5468
5607
|
} catch (error) {
|
|
5469
5608
|
errors.push(error);
|
|
5470
5609
|
}
|
|
@@ -5554,16 +5693,39 @@ function assertCompositionXmlUsesV4WidgetsOnly(xmlStructure) {
|
|
|
5554
5693
|
}
|
|
5555
5694
|
}
|
|
5556
5695
|
}
|
|
5696
|
+
function onElementAdded(element) {
|
|
5697
|
+
const elType = element.elType ?? "";
|
|
5698
|
+
const widgetType = element.widgetType ?? "";
|
|
5699
|
+
const elementName = elType === "widget" ? widgetType : elType;
|
|
5700
|
+
trackCanvasEvent({
|
|
5701
|
+
eventName: "add_element",
|
|
5702
|
+
executed_by: "mcp_tool",
|
|
5703
|
+
element_name: elementName,
|
|
5704
|
+
element_type: elType,
|
|
5705
|
+
widget_type: widgetType
|
|
5706
|
+
});
|
|
5707
|
+
const event = {
|
|
5708
|
+
element,
|
|
5709
|
+
executedBy: "mcp_tool"
|
|
5710
|
+
};
|
|
5711
|
+
window.dispatchEvent(new CustomEvent(ELEMENT_ADDED_EVENT, { detail: event }));
|
|
5712
|
+
if (element.elements?.length) {
|
|
5713
|
+
element.elements?.forEach((childElement) => {
|
|
5714
|
+
onElementAdded(childElement);
|
|
5715
|
+
});
|
|
5716
|
+
}
|
|
5717
|
+
}
|
|
5557
5718
|
|
|
5558
5719
|
// src/mcp/tools/configure-element/tool.ts
|
|
5559
5720
|
var import_editor_elements17 = require("@elementor/editor-elements");
|
|
5560
|
-
var
|
|
5721
|
+
var import_editor_mcp5 = require("@elementor/editor-mcp");
|
|
5722
|
+
var import_editor_props9 = require("@elementor/editor-props");
|
|
5561
5723
|
|
|
5562
5724
|
// src/mcp/tools/configure-element/prompt.ts
|
|
5563
|
-
var
|
|
5725
|
+
var import_editor_mcp4 = require("@elementor/editor-mcp");
|
|
5564
5726
|
var CONFIGURE_ELEMENT_GUIDE_URI = "elementor://canvas/tools/configure-element-guide";
|
|
5565
5727
|
var generatePrompt2 = () => {
|
|
5566
|
-
const configureElementToolPrompt = (0,
|
|
5728
|
+
const configureElementToolPrompt = (0, import_editor_mcp4.toolPrompts)("configure-element");
|
|
5567
5729
|
configureElementToolPrompt.description(`
|
|
5568
5730
|
Configure an existing element on the page.
|
|
5569
5731
|
|
|
@@ -5746,7 +5908,7 @@ var initConfigureElementTool = (reg) => {
|
|
|
5746
5908
|
const propertiesToUpdate = resolveCanonicalPropKeys(elementType, propertiesToChange);
|
|
5747
5909
|
const toUpdate = Object.entries(propertiesToUpdate);
|
|
5748
5910
|
for (const [propertyName, propertyValue] of toUpdate) {
|
|
5749
|
-
if (!
|
|
5911
|
+
if (!import_editor_props9.Schema.isPropKeyConfigurable(propertyName)) {
|
|
5750
5912
|
throw new Error(`Not allowed to update ${propertyName}`);
|
|
5751
5913
|
}
|
|
5752
5914
|
try {
|
|
@@ -5795,6 +5957,7 @@ async function applyStyleFromCss(opts) {
|
|
|
5795
5957
|
propertyValue: styleValue,
|
|
5796
5958
|
customCssWriteMode: "merge-with-stored"
|
|
5797
5959
|
});
|
|
5960
|
+
(0, import_editor_mcp5.dispatchMcpStylesAppliedEvent)({ styleValue });
|
|
5798
5961
|
} catch (error) {
|
|
5799
5962
|
throw new Error(
|
|
5800
5963
|
createUpdateErrorMessage({
|
|
@@ -5822,7 +5985,7 @@ Provide styling as raw CSS via the "style" parameter (a flat map of CSS property
|
|
|
5822
5985
|
|
|
5823
5986
|
// src/mcp/tools/get-element-config/tool.ts
|
|
5824
5987
|
var import_editor_elements18 = require("@elementor/editor-elements");
|
|
5825
|
-
var
|
|
5988
|
+
var import_editor_props10 = require("@elementor/editor-props");
|
|
5826
5989
|
var import_schema5 = require("@elementor/schema");
|
|
5827
5990
|
var schema = {
|
|
5828
5991
|
elementId: import_schema5.z.string()
|
|
@@ -5879,7 +6042,7 @@ var initGetElementConfigTool = (reg) => {
|
|
|
5879
6042
|
}
|
|
5880
6043
|
const propValues = {};
|
|
5881
6044
|
const stylePropValues = {};
|
|
5882
|
-
|
|
6045
|
+
import_editor_props10.Schema.configurableKeys(propSchema).forEach((key) => {
|
|
5883
6046
|
propValues[key] = structuredClone(elementRawSettings.get(key));
|
|
5884
6047
|
});
|
|
5885
6048
|
const elementStyles = (0, import_editor_elements18.getElementStyles)(elementId) || {};
|
|
@@ -5915,7 +6078,7 @@ var initGetElementConfigTool = (reg) => {
|
|
|
5915
6078
|
|
|
5916
6079
|
// src/mcp/canvas-mcp.ts
|
|
5917
6080
|
var initCanvasMcp = (reg) => {
|
|
5918
|
-
|
|
6081
|
+
import_editor_props11.Schema.setDynamicTagNamesResolver(getDynamicTagNamesByCategories);
|
|
5919
6082
|
initWidgetsSchemaResource(reg);
|
|
5920
6083
|
initAvailableWidgetsResource(reg);
|
|
5921
6084
|
initDocumentStructureResource(reg);
|
|
@@ -6122,12 +6285,12 @@ function shouldBlock(sourceElements, targetElements) {
|
|
|
6122
6285
|
|
|
6123
6286
|
// src/style-commands/paste-style.ts
|
|
6124
6287
|
var import_editor_elements22 = require("@elementor/editor-elements");
|
|
6125
|
-
var
|
|
6288
|
+
var import_editor_props13 = require("@elementor/editor-props");
|
|
6126
6289
|
var import_editor_v1_adapters24 = require("@elementor/editor-v1-adapters");
|
|
6127
6290
|
|
|
6128
6291
|
// src/utils/command-utils.ts
|
|
6129
6292
|
var import_editor_elements20 = require("@elementor/editor-elements");
|
|
6130
|
-
var
|
|
6293
|
+
var import_editor_props12 = require("@elementor/editor-props");
|
|
6131
6294
|
var import_i18n5 = require("@wordpress/i18n");
|
|
6132
6295
|
function hasAtomicWidgets(args) {
|
|
6133
6296
|
const { containers = [args.container] } = args;
|
|
@@ -6145,7 +6308,7 @@ function getClassesProp(container) {
|
|
|
6145
6308
|
return null;
|
|
6146
6309
|
}
|
|
6147
6310
|
const [propKey] = Object.entries(propsSchema).find(
|
|
6148
|
-
([, propType]) => propType.kind === "plain" && propType.key ===
|
|
6311
|
+
([, propType]) => propType.kind === "plain" && propType.key === import_editor_props12.CLASSES_PROP_KEY
|
|
6149
6312
|
) ?? [];
|
|
6150
6313
|
return propKey ?? null;
|
|
6151
6314
|
}
|
|
@@ -6294,8 +6457,8 @@ function pasteClasses(containers, classes) {
|
|
|
6294
6457
|
return;
|
|
6295
6458
|
}
|
|
6296
6459
|
const classesSetting = (0, import_editor_elements22.getElementSetting)(container.id, classesProp);
|
|
6297
|
-
const currentClasses =
|
|
6298
|
-
const newClasses =
|
|
6460
|
+
const currentClasses = import_editor_props13.classesPropTypeUtil.extract(classesSetting) ?? [];
|
|
6461
|
+
const newClasses = import_editor_props13.classesPropTypeUtil.create(Array.from(/* @__PURE__ */ new Set([...classes, ...currentClasses])));
|
|
6299
6462
|
(0, import_editor_elements22.updateElementSettings)({
|
|
6300
6463
|
id: container.id,
|
|
6301
6464
|
props: { [classesProp]: newClasses }
|
|
@@ -6406,7 +6569,7 @@ function init() {
|
|
|
6406
6569
|
component: ClassesRename
|
|
6407
6570
|
});
|
|
6408
6571
|
initCanvasMcp(
|
|
6409
|
-
(0,
|
|
6572
|
+
(0, import_editor_mcp6.getMCPByDomain)("canvas", {
|
|
6410
6573
|
instructions: `Everything related to V4 ( Atomic ) canvas.
|
|
6411
6574
|
# Canvas workflow for new compositions
|
|
6412
6575
|
- Configure elements settings and styles
|
|
@@ -6515,9 +6678,9 @@ function useCanvasDocument() {
|
|
|
6515
6678
|
}
|
|
6516
6679
|
|
|
6517
6680
|
// src/hooks/use-escape-on-canvas.ts
|
|
6518
|
-
var
|
|
6681
|
+
var import_react20 = require("react");
|
|
6519
6682
|
function useEscapeOnCanvas(canvasDocument, onEscape) {
|
|
6520
|
-
(0,
|
|
6683
|
+
(0, import_react20.useEffect)(() => {
|
|
6521
6684
|
if (!canvasDocument) {
|
|
6522
6685
|
return;
|
|
6523
6686
|
}
|
|
@@ -6557,6 +6720,7 @@ function hasDoAfterRender(view) {
|
|
|
6557
6720
|
BREAKPOINTS_SCHEMA_FULL_URI,
|
|
6558
6721
|
BREAKPOINTS_SCHEMA_URI,
|
|
6559
6722
|
DOCUMENT_STRUCTURE_URI,
|
|
6723
|
+
ELEMENT_ADDED_EVENT,
|
|
6560
6724
|
GLOBAL_STYLES_IMPORTED_EVENT,
|
|
6561
6725
|
SpotlightBackdrop,
|
|
6562
6726
|
UnknownStyleStateError,
|