@elementor/editor-canvas 4.2.0-926 → 4.2.0-928
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 +277 -77
- package/dist/index.mjs +251 -51
- package/package.json +18 -18
- package/src/components/grid-outline/__tests__/grid-outline.test.tsx +62 -2
- package/src/components/grid-outline/first-empty-cell.tsx +38 -0
- package/src/components/grid-outline/grid-outline-overlay.tsx +1 -1
- package/src/components/grid-outline/grid-outline.tsx +29 -13
- package/src/hooks/use-toolbar-rect.ts +30 -0
- package/src/legacy/create-pro-promotion-nested-type.ts +9 -6
- package/src/utils/__tests__/find-first-empty-cell.test.ts +132 -0
- package/src/utils/clip-path-cutout.ts +11 -0
- package/src/utils/find-first-empty-cell.ts +226 -0
package/dist/index.js
CHANGED
|
@@ -422,16 +422,16 @@ var renameClass = (oldClassName, newClassName) => {
|
|
|
422
422
|
};
|
|
423
423
|
|
|
424
424
|
// src/components/elements-overlays.tsx
|
|
425
|
-
var
|
|
425
|
+
var React7 = __toESM(require("react"));
|
|
426
426
|
var import_editor_elements5 = require("@elementor/editor-elements");
|
|
427
427
|
var import_editor_v1_adapters3 = require("@elementor/editor-v1-adapters");
|
|
428
428
|
|
|
429
429
|
// src/components/grid-outline/grid-outline-overlay.tsx
|
|
430
|
-
var
|
|
430
|
+
var React6 = __toESM(require("react"));
|
|
431
431
|
var import_editor_elements4 = require("@elementor/editor-elements");
|
|
432
432
|
var import_editor_props2 = require("@elementor/editor-props");
|
|
433
433
|
var import_ui2 = require("@elementor/ui");
|
|
434
|
-
var
|
|
434
|
+
var import_react10 = require("@floating-ui/react");
|
|
435
435
|
|
|
436
436
|
// src/hooks/use-element-rect.ts
|
|
437
437
|
var import_react2 = require("react");
|
|
@@ -786,7 +786,170 @@ var OutlineOverlay = ({ element, isSelected, id, isGlobal = false }) => {
|
|
|
786
786
|
};
|
|
787
787
|
|
|
788
788
|
// src/components/grid-outline/grid-outline.tsx
|
|
789
|
-
var
|
|
789
|
+
var React5 = __toESM(require("react"));
|
|
790
|
+
var import_react9 = require("react");
|
|
791
|
+
|
|
792
|
+
// src/utils/find-first-empty-cell.ts
|
|
793
|
+
function findFirstEmptyCell(element, columnCount, rowCount) {
|
|
794
|
+
if (!element || columnCount === 0 || rowCount === 0) {
|
|
795
|
+
return null;
|
|
796
|
+
}
|
|
797
|
+
const previewWindow = element.ownerDocument?.defaultView;
|
|
798
|
+
if (!previewWindow) {
|
|
799
|
+
return null;
|
|
800
|
+
}
|
|
801
|
+
const containerStyle = previewWindow.getComputedStyle(element);
|
|
802
|
+
const flowsByColumn = containerStyle.gridAutoFlow.trim().startsWith("column");
|
|
803
|
+
const matrix = Array.from({ length: rowCount }, () => new Array(columnCount).fill(false));
|
|
804
|
+
const explicit = [];
|
|
805
|
+
const autoPlaced = [];
|
|
806
|
+
for (const child of Array.from(element.children)) {
|
|
807
|
+
if (!child.classList.contains("elementor-element")) {
|
|
808
|
+
continue;
|
|
809
|
+
}
|
|
810
|
+
const style = previewWindow.getComputedStyle(child);
|
|
811
|
+
if (style.display === "none") {
|
|
812
|
+
continue;
|
|
813
|
+
}
|
|
814
|
+
const col = resolvePlacement(style.gridColumnStart, style.gridColumnEnd);
|
|
815
|
+
const row = resolvePlacement(style.gridRowStart, style.gridRowEnd);
|
|
816
|
+
if (col.start !== null || row.start !== null) {
|
|
817
|
+
explicit.push({ col: col.start, colSpan: col.span, row: row.start, rowSpan: row.span });
|
|
818
|
+
} else {
|
|
819
|
+
autoPlaced.push({ colSpan: col.span, rowSpan: row.span });
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
for (const child of explicit) {
|
|
823
|
+
fillMatrix(matrix, child.col ?? 0, child.row ?? 0, child.colSpan, child.rowSpan);
|
|
824
|
+
}
|
|
825
|
+
for (const child of autoPlaced) {
|
|
826
|
+
const slot = findNextFreeSlot(matrix, child.colSpan, child.rowSpan, flowsByColumn);
|
|
827
|
+
if (slot) {
|
|
828
|
+
fillMatrix(matrix, slot.col, slot.row, child.colSpan, child.rowSpan);
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
return scanFirstEmpty(matrix, flowsByColumn);
|
|
832
|
+
}
|
|
833
|
+
function resolvePlacement(startRaw, endRaw) {
|
|
834
|
+
const start = parseLineValue(startRaw);
|
|
835
|
+
const end = parseLineValue(endRaw);
|
|
836
|
+
if (typeof start === "number") {
|
|
837
|
+
const zeroIndexedStart = start - 1;
|
|
838
|
+
if (typeof end === "number") {
|
|
839
|
+
return { start: zeroIndexedStart, span: Math.max(1, end - start) };
|
|
840
|
+
}
|
|
841
|
+
if (isSpan(end)) {
|
|
842
|
+
return { start: zeroIndexedStart, span: end.n };
|
|
843
|
+
}
|
|
844
|
+
return { start: zeroIndexedStart, span: 1 };
|
|
845
|
+
}
|
|
846
|
+
if (isSpan(start)) {
|
|
847
|
+
if (typeof end === "number") {
|
|
848
|
+
const zeroIndexedStart = end - 1 - start.n;
|
|
849
|
+
return { start: zeroIndexedStart >= 0 ? zeroIndexedStart : null, span: start.n };
|
|
850
|
+
}
|
|
851
|
+
return { start: null, span: start.n };
|
|
852
|
+
}
|
|
853
|
+
if (typeof end === "number") {
|
|
854
|
+
const zeroIndexedStart = end - 2;
|
|
855
|
+
return { start: zeroIndexedStart >= 0 ? zeroIndexedStart : null, span: 1 };
|
|
856
|
+
}
|
|
857
|
+
if (isSpan(end)) {
|
|
858
|
+
return { start: null, span: end.n };
|
|
859
|
+
}
|
|
860
|
+
return { start: null, span: 1 };
|
|
861
|
+
}
|
|
862
|
+
function parseLineValue(raw) {
|
|
863
|
+
const trimmed = raw.trim();
|
|
864
|
+
if (trimmed === "" || trimmed === "auto") {
|
|
865
|
+
return "auto";
|
|
866
|
+
}
|
|
867
|
+
const spanMatch = trimmed.match(/^span\s+(\d+)$/);
|
|
868
|
+
if (spanMatch) {
|
|
869
|
+
const n = parseInt(spanMatch[1], 10);
|
|
870
|
+
return { kind: "span", n: Math.max(1, n) };
|
|
871
|
+
}
|
|
872
|
+
const parsed = parseInt(trimmed, 10);
|
|
873
|
+
if (Number.isFinite(parsed) && parsed > 0) {
|
|
874
|
+
return parsed;
|
|
875
|
+
}
|
|
876
|
+
return "auto";
|
|
877
|
+
}
|
|
878
|
+
function isSpan(value) {
|
|
879
|
+
return typeof value === "object" && value !== null && "kind" in value && value.kind === "span";
|
|
880
|
+
}
|
|
881
|
+
function fillMatrix(matrix, col, row, colSpan, rowSpan) {
|
|
882
|
+
const rows = matrix.length;
|
|
883
|
+
const cols = rows > 0 ? matrix[0].length : 0;
|
|
884
|
+
const startRow = Math.max(0, row);
|
|
885
|
+
const startCol = Math.max(0, col);
|
|
886
|
+
const endRow = Math.min(rows, row + rowSpan);
|
|
887
|
+
const endCol = Math.min(cols, col + colSpan);
|
|
888
|
+
for (let r = startRow; r < endRow; r++) {
|
|
889
|
+
for (let c = startCol; c < endCol; c++) {
|
|
890
|
+
matrix[r][c] = true;
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
function findNextFreeSlot(matrix, colSpan, rowSpan, flowsByColumn) {
|
|
895
|
+
const rows = matrix.length;
|
|
896
|
+
const cols = rows > 0 ? matrix[0].length : 0;
|
|
897
|
+
const maxCol = cols - colSpan;
|
|
898
|
+
const maxRow = rows - rowSpan;
|
|
899
|
+
if (maxCol < 0 || maxRow < 0) {
|
|
900
|
+
return null;
|
|
901
|
+
}
|
|
902
|
+
if (flowsByColumn) {
|
|
903
|
+
for (let col = 0; col <= maxCol; col++) {
|
|
904
|
+
for (let row = 0; row <= maxRow; row++) {
|
|
905
|
+
if (canFit(matrix, col, row, colSpan, rowSpan)) {
|
|
906
|
+
return { row, col };
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
} else {
|
|
911
|
+
for (let row = 0; row <= maxRow; row++) {
|
|
912
|
+
for (let col = 0; col <= maxCol; col++) {
|
|
913
|
+
if (canFit(matrix, col, row, colSpan, rowSpan)) {
|
|
914
|
+
return { row, col };
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
return null;
|
|
920
|
+
}
|
|
921
|
+
function canFit(matrix, col, row, colSpan, rowSpan) {
|
|
922
|
+
for (let r = row; r < row + rowSpan; r++) {
|
|
923
|
+
for (let c = col; c < col + colSpan; c++) {
|
|
924
|
+
if (matrix[r][c]) {
|
|
925
|
+
return false;
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
return true;
|
|
930
|
+
}
|
|
931
|
+
function scanFirstEmpty(matrix, flowsByColumn) {
|
|
932
|
+
const rows = matrix.length;
|
|
933
|
+
const cols = rows > 0 ? matrix[0].length : 0;
|
|
934
|
+
if (flowsByColumn) {
|
|
935
|
+
for (let col = 0; col < cols; col++) {
|
|
936
|
+
for (let row = 0; row < rows; row++) {
|
|
937
|
+
if (!matrix[row][col]) {
|
|
938
|
+
return { row, col };
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
} else {
|
|
943
|
+
for (let row = 0; row < rows; row++) {
|
|
944
|
+
for (let col = 0; col < cols; col++) {
|
|
945
|
+
if (!matrix[row][col]) {
|
|
946
|
+
return { row, col };
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
return null;
|
|
952
|
+
}
|
|
790
953
|
|
|
791
954
|
// src/components/grid-outline/cell.tsx
|
|
792
955
|
var React2 = __toESM(require("react"));
|
|
@@ -808,11 +971,40 @@ function Cell({ x, y, width, height, color }) {
|
|
|
808
971
|
);
|
|
809
972
|
}
|
|
810
973
|
|
|
811
|
-
// src/components/grid-outline/
|
|
974
|
+
// src/components/grid-outline/first-empty-cell.tsx
|
|
812
975
|
var React3 = __toESM(require("react"));
|
|
976
|
+
var GLYPH_SIZE = 19;
|
|
977
|
+
function FirstEmptyCell({ rect, color }) {
|
|
978
|
+
const size2 = Math.min(GLYPH_SIZE, rect.width, rect.height);
|
|
979
|
+
if (size2 <= 0) {
|
|
980
|
+
return null;
|
|
981
|
+
}
|
|
982
|
+
const centerX = rect.x + rect.width / 2;
|
|
983
|
+
const centerY = rect.y + rect.height / 2;
|
|
984
|
+
return /* @__PURE__ */ React3.createElement(
|
|
985
|
+
"i",
|
|
986
|
+
{
|
|
987
|
+
className: "eicon-plus",
|
|
988
|
+
"aria-hidden": "true",
|
|
989
|
+
style: {
|
|
990
|
+
position: "absolute",
|
|
991
|
+
left: centerX,
|
|
992
|
+
top: centerY,
|
|
993
|
+
transform: "translate(-50%, -50%)",
|
|
994
|
+
fontSize: size2,
|
|
995
|
+
color,
|
|
996
|
+
lineHeight: 1,
|
|
997
|
+
pointerEvents: "none"
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
);
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
// src/components/grid-outline/line.tsx
|
|
1004
|
+
var React4 = __toESM(require("react"));
|
|
813
1005
|
var FALLBACK_COLOR2 = "rgba(0, 0, 0, 0.12)";
|
|
814
1006
|
function Line({ x1, y1, x2, y2, color }) {
|
|
815
|
-
return /* @__PURE__ */
|
|
1007
|
+
return /* @__PURE__ */ React4.createElement(
|
|
816
1008
|
"line",
|
|
817
1009
|
{
|
|
818
1010
|
x1,
|
|
@@ -828,7 +1020,7 @@ function Line({ x1, y1, x2, y2, color }) {
|
|
|
828
1020
|
}
|
|
829
1021
|
|
|
830
1022
|
// src/components/grid-outline/grid-outline.tsx
|
|
831
|
-
var renderCells = (
|
|
1023
|
+
var renderCells = (cells, color) => cells.map((cell, i) => /* @__PURE__ */ React5.createElement(
|
|
832
1024
|
Cell,
|
|
833
1025
|
{
|
|
834
1026
|
key: i,
|
|
@@ -836,13 +1028,13 @@ var renderCells = (tracks, width, height) => computeCellRects(tracks, width, hei
|
|
|
836
1028
|
y: snapToHalfPixel(cell.y),
|
|
837
1029
|
width: Math.round(cell.width),
|
|
838
1030
|
height: Math.round(cell.height),
|
|
839
|
-
color
|
|
1031
|
+
color
|
|
840
1032
|
}
|
|
841
1033
|
));
|
|
842
1034
|
var renderLines = (tracks, width, height) => {
|
|
843
1035
|
const { vertical, horizontal } = computeGridLines(tracks, width, height);
|
|
844
1036
|
return [
|
|
845
|
-
...vertical.map((line, i) => /* @__PURE__ */
|
|
1037
|
+
...vertical.map((line, i) => /* @__PURE__ */ React5.createElement(
|
|
846
1038
|
Line,
|
|
847
1039
|
{
|
|
848
1040
|
key: `v${i}`,
|
|
@@ -853,7 +1045,7 @@ var renderLines = (tracks, width, height) => {
|
|
|
853
1045
|
color: tracks.borderColor
|
|
854
1046
|
}
|
|
855
1047
|
)),
|
|
856
|
-
...horizontal.map((line, i) => /* @__PURE__ */
|
|
1048
|
+
...horizontal.map((line, i) => /* @__PURE__ */ React5.createElement(
|
|
857
1049
|
Line,
|
|
858
1050
|
{
|
|
859
1051
|
key: `h${i}`,
|
|
@@ -866,9 +1058,15 @@ var renderLines = (tracks, width, height) => {
|
|
|
866
1058
|
))
|
|
867
1059
|
];
|
|
868
1060
|
};
|
|
869
|
-
function GridOutline({ tracks, width, height }) {
|
|
1061
|
+
function GridOutline({ element, tracks, width, height }) {
|
|
1062
|
+
const cells = (0, import_react9.useMemo)(() => computeCellRects(tracks, width, height), [tracks, width, height]);
|
|
870
1063
|
const hasGap = tracks.columnGap > 0 || tracks.rowGap > 0;
|
|
871
|
-
|
|
1064
|
+
const firstEmpty = (0, import_react9.useMemo)(
|
|
1065
|
+
() => findFirstEmptyCell(element, tracks.columns.length, tracks.rows.length),
|
|
1066
|
+
[element, tracks]
|
|
1067
|
+
);
|
|
1068
|
+
const emptyCellRect = firstEmpty && tracks.columns.length > 0 ? cells[firstEmpty.row * tracks.columns.length + firstEmpty.col] : null;
|
|
1069
|
+
return /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement(
|
|
872
1070
|
"svg",
|
|
873
1071
|
{
|
|
874
1072
|
width,
|
|
@@ -876,8 +1074,8 @@ function GridOutline({ tracks, width, height }) {
|
|
|
876
1074
|
style: { position: "absolute", inset: 0, overflow: "visible" },
|
|
877
1075
|
xmlns: "http://www.w3.org/2000/svg"
|
|
878
1076
|
},
|
|
879
|
-
hasGap ? renderCells(
|
|
880
|
-
);
|
|
1077
|
+
hasGap ? renderCells(cells, tracks.borderColor) : renderLines(tracks, width, height)
|
|
1078
|
+
), emptyCellRect && /* @__PURE__ */ React5.createElement(FirstEmptyCell, { rect: emptyCellRect, color: tracks.borderColor }));
|
|
881
1079
|
}
|
|
882
1080
|
|
|
883
1081
|
// src/components/grid-outline/grid-outline-overlay.tsx
|
|
@@ -893,7 +1091,7 @@ var GridOutlineOverlay = ({ element, id, isSelected }) => {
|
|
|
893
1091
|
if (tracks.columns.length === 0 && tracks.rows.length === 0) {
|
|
894
1092
|
return null;
|
|
895
1093
|
}
|
|
896
|
-
return /* @__PURE__ */
|
|
1094
|
+
return /* @__PURE__ */ React6.createElement(import_react10.FloatingPortal, { id: CANVAS_WRAPPER_ID }, /* @__PURE__ */ React6.createElement(
|
|
897
1095
|
import_ui2.Box,
|
|
898
1096
|
{
|
|
899
1097
|
ref: floating.setRef,
|
|
@@ -901,7 +1099,7 @@ var GridOutlineOverlay = ({ element, id, isSelected }) => {
|
|
|
901
1099
|
"data-grid-outline": id,
|
|
902
1100
|
role: "presentation"
|
|
903
1101
|
},
|
|
904
|
-
/* @__PURE__ */
|
|
1102
|
+
/* @__PURE__ */ React6.createElement(GridOutline, { element, tracks, width: rect.width, height: rect.height })
|
|
905
1103
|
));
|
|
906
1104
|
};
|
|
907
1105
|
|
|
@@ -930,7 +1128,7 @@ function ElementsOverlays() {
|
|
|
930
1128
|
return elements.map(({ id, domElement, isGlobal }) => {
|
|
931
1129
|
const isSelected = selected.element?.id === id;
|
|
932
1130
|
return overlayRegistry.map(
|
|
933
|
-
({ shouldRender, component: Overlay }, index) => shouldRender({ id, element: domElement, isSelected }) && /* @__PURE__ */
|
|
1131
|
+
({ shouldRender, component: Overlay }, index) => shouldRender({ id, element: domElement, isSelected }) && /* @__PURE__ */ React7.createElement(
|
|
934
1132
|
Overlay,
|
|
935
1133
|
{
|
|
936
1134
|
key: `${id}-${index}`,
|
|
@@ -963,20 +1161,20 @@ function isV4Element(dataset) {
|
|
|
963
1161
|
}
|
|
964
1162
|
|
|
965
1163
|
// src/components/interactions-renderer.tsx
|
|
966
|
-
var
|
|
1164
|
+
var React8 = __toESM(require("react"));
|
|
967
1165
|
var import_editor_v1_adapters5 = require("@elementor/editor-v1-adapters");
|
|
968
1166
|
var import_ui3 = require("@elementor/ui");
|
|
969
1167
|
|
|
970
1168
|
// src/hooks/use-interactions-items.ts
|
|
971
|
-
var
|
|
1169
|
+
var import_react12 = require("react");
|
|
972
1170
|
var import_editor_interactions = require("@elementor/editor-interactions");
|
|
973
1171
|
var import_editor_v1_adapters4 = require("@elementor/editor-v1-adapters");
|
|
974
1172
|
|
|
975
1173
|
// src/hooks/use-on-mount.ts
|
|
976
|
-
var
|
|
1174
|
+
var import_react11 = require("react");
|
|
977
1175
|
function useOnMount(cb) {
|
|
978
|
-
const mounted = (0,
|
|
979
|
-
(0,
|
|
1176
|
+
const mounted = (0, import_react11.useRef)(false);
|
|
1177
|
+
(0, import_react11.useEffect)(() => {
|
|
980
1178
|
if (!mounted.current) {
|
|
981
1179
|
mounted.current = true;
|
|
982
1180
|
cb();
|
|
@@ -986,8 +1184,8 @@ function useOnMount(cb) {
|
|
|
986
1184
|
|
|
987
1185
|
// src/hooks/use-interactions-items.ts
|
|
988
1186
|
function useInteractionsItems() {
|
|
989
|
-
const [interactionItems, setInteractionItems] = (0,
|
|
990
|
-
const providerAndSubscribers = (0,
|
|
1187
|
+
const [interactionItems, setInteractionItems] = (0, import_react12.useState)({});
|
|
1188
|
+
const providerAndSubscribers = (0, import_react12.useMemo)(() => {
|
|
991
1189
|
try {
|
|
992
1190
|
const providers = import_editor_interactions.interactionsRepository.getProviders();
|
|
993
1191
|
const mapped = providers.map((provider) => {
|
|
@@ -1004,7 +1202,7 @@ function useInteractionsItems() {
|
|
|
1004
1202
|
return [];
|
|
1005
1203
|
}
|
|
1006
1204
|
}, []);
|
|
1007
|
-
(0,
|
|
1205
|
+
(0, import_react12.useEffect)(() => {
|
|
1008
1206
|
if (providerAndSubscribers.length === 0) {
|
|
1009
1207
|
return;
|
|
1010
1208
|
}
|
|
@@ -1035,7 +1233,7 @@ function useInteractionsItems() {
|
|
|
1035
1233
|
});
|
|
1036
1234
|
});
|
|
1037
1235
|
});
|
|
1038
|
-
return (0,
|
|
1236
|
+
return (0, import_react12.useMemo)(() => {
|
|
1039
1237
|
const result = Object.values(interactionItems).sort(sortByProviderPriority).flatMap(({ items }) => items);
|
|
1040
1238
|
return result;
|
|
1041
1239
|
}, [interactionItems]);
|
|
@@ -1065,7 +1263,7 @@ function InteractionsRenderer() {
|
|
|
1065
1263
|
return null;
|
|
1066
1264
|
}
|
|
1067
1265
|
const interactionsData = JSON.stringify(Array.isArray(interactionItems) ? interactionItems : []);
|
|
1068
|
-
return /* @__PURE__ */
|
|
1266
|
+
return /* @__PURE__ */ React8.createElement(import_ui3.Portal, { container }, /* @__PURE__ */ React8.createElement(
|
|
1069
1267
|
"script",
|
|
1070
1268
|
{
|
|
1071
1269
|
type: "application/json",
|
|
@@ -1081,7 +1279,7 @@ function usePortalContainer() {
|
|
|
1081
1279
|
}
|
|
1082
1280
|
|
|
1083
1281
|
// src/components/style-renderer.tsx
|
|
1084
|
-
var
|
|
1282
|
+
var React9 = __toESM(require("react"));
|
|
1085
1283
|
var import_editor_v1_adapters10 = require("@elementor/editor-v1-adapters");
|
|
1086
1284
|
var import_ui4 = require("@elementor/ui");
|
|
1087
1285
|
|
|
@@ -1133,7 +1331,7 @@ function getLinkAttrs(el) {
|
|
|
1133
1331
|
}
|
|
1134
1332
|
|
|
1135
1333
|
// src/hooks/use-style-items.ts
|
|
1136
|
-
var
|
|
1334
|
+
var import_react15 = require("react");
|
|
1137
1335
|
var import_editor_responsive2 = require("@elementor/editor-responsive");
|
|
1138
1336
|
var import_editor_styles4 = require("@elementor/editor-styles");
|
|
1139
1337
|
var import_editor_styles_repository2 = require("@elementor/editor-styles-repository");
|
|
@@ -1195,7 +1393,7 @@ function signalizedProcess(signal, steps = []) {
|
|
|
1195
1393
|
}
|
|
1196
1394
|
|
|
1197
1395
|
// src/hooks/use-style-prop-resolver.ts
|
|
1198
|
-
var
|
|
1396
|
+
var import_react13 = require("react");
|
|
1199
1397
|
var import_editor_styles2 = require("@elementor/editor-styles");
|
|
1200
1398
|
var import_editor_v1_adapters8 = require("@elementor/editor-v1-adapters");
|
|
1201
1399
|
|
|
@@ -1323,7 +1521,7 @@ var styleTransformersRegistry = createTransformersRegistry();
|
|
|
1323
1521
|
|
|
1324
1522
|
// src/hooks/use-style-prop-resolver.ts
|
|
1325
1523
|
function useStylePropResolver() {
|
|
1326
|
-
return (0,
|
|
1524
|
+
return (0, import_react13.useMemo)(() => {
|
|
1327
1525
|
return createPropsResolver({
|
|
1328
1526
|
transformers: styleTransformersRegistry,
|
|
1329
1527
|
schema: (0, import_editor_styles2.getStylesSchema)(),
|
|
@@ -1338,7 +1536,7 @@ function useStylePropResolver() {
|
|
|
1338
1536
|
}
|
|
1339
1537
|
|
|
1340
1538
|
// src/hooks/use-style-renderer.ts
|
|
1341
|
-
var
|
|
1539
|
+
var import_react14 = require("react");
|
|
1342
1540
|
var import_editor_responsive = require("@elementor/editor-responsive");
|
|
1343
1541
|
|
|
1344
1542
|
// src/renderers/create-styles-renderer.ts
|
|
@@ -1447,7 +1645,7 @@ function customCssToString(customCss) {
|
|
|
1447
1645
|
var SELECTOR_PREFIX = ".elementor";
|
|
1448
1646
|
function useStyleRenderer(resolve) {
|
|
1449
1647
|
const breakpoints = (0, import_editor_responsive.useBreakpointsMap)();
|
|
1450
|
-
return (0,
|
|
1648
|
+
return (0, import_react14.useMemo)(() => {
|
|
1451
1649
|
return createStylesRenderer({
|
|
1452
1650
|
selectorPrefix: SELECTOR_PREFIX,
|
|
1453
1651
|
breakpoints,
|
|
@@ -1461,9 +1659,9 @@ function useStyleItems() {
|
|
|
1461
1659
|
const resolve = useStylePropResolver();
|
|
1462
1660
|
const renderStyles = useStyleRenderer(resolve);
|
|
1463
1661
|
const breakpoints = (0, import_editor_responsive2.useBreakpoints)();
|
|
1464
|
-
const [styleItems, setStyleItems] = (0,
|
|
1465
|
-
const styleItemsCacheRef = (0,
|
|
1466
|
-
const providerAndSubscribers = (0,
|
|
1662
|
+
const [styleItems, setStyleItems] = (0, import_react15.useState)({});
|
|
1663
|
+
const styleItemsCacheRef = (0, import_react15.useRef)(/* @__PURE__ */ new Map());
|
|
1664
|
+
const providerAndSubscribers = (0, import_react15.useMemo)(() => {
|
|
1467
1665
|
const createEmptyCache = () => {
|
|
1468
1666
|
return { orderedIds: [], itemsById: /* @__PURE__ */ new Map() };
|
|
1469
1667
|
};
|
|
@@ -1489,7 +1687,7 @@ function useStyleItems() {
|
|
|
1489
1687
|
})
|
|
1490
1688
|
);
|
|
1491
1689
|
}, [renderStyles]);
|
|
1492
|
-
(0,
|
|
1690
|
+
(0, import_react15.useEffect)(() => {
|
|
1493
1691
|
const unsubscribes = providerAndSubscribers.map(
|
|
1494
1692
|
({ provider, subscriber }) => provider.subscribe(subscriber)
|
|
1495
1693
|
);
|
|
@@ -1504,11 +1702,11 @@ function useStyleItems() {
|
|
|
1504
1702
|
await Promise.all(promises);
|
|
1505
1703
|
});
|
|
1506
1704
|
});
|
|
1507
|
-
const breakpointSorter = (0,
|
|
1705
|
+
const breakpointSorter = (0, import_react15.useMemo)(
|
|
1508
1706
|
() => createBreakpointSorter(breakpoints.map((breakpoint) => breakpoint.id)),
|
|
1509
1707
|
[breakpoints]
|
|
1510
1708
|
);
|
|
1511
|
-
return (0,
|
|
1709
|
+
return (0, import_react15.useMemo)(
|
|
1512
1710
|
() => Object.values(styleItems).sort(prioritySorter).flatMap(({ items }) => items).sort(stateSorter).sort(breakpointSorter),
|
|
1513
1711
|
[styleItems, breakpointSorter]
|
|
1514
1712
|
);
|
|
@@ -1650,7 +1848,7 @@ function StyleRenderer() {
|
|
|
1650
1848
|
if (!container) {
|
|
1651
1849
|
return null;
|
|
1652
1850
|
}
|
|
1653
|
-
return /* @__PURE__ */
|
|
1851
|
+
return /* @__PURE__ */ React9.createElement(import_ui4.Portal, { container }, filterUniqueStyleDefinitions(styleItems).map((item) => /* @__PURE__ */ React9.createElement("style", { key: `${item.id}-${item.breakpoint}-${item.state ?? "normal"}` }, item.value)), linksAttrs.map((attrs) => /* @__PURE__ */ React9.createElement("link", { ...attrs, key: attrs.id })));
|
|
1654
1852
|
}
|
|
1655
1853
|
function usePortalContainer2() {
|
|
1656
1854
|
return (0, import_editor_v1_adapters10.__privateUseListenTo)((0, import_editor_v1_adapters10.commandEndEvent)("editor/documents/attach-preview"), () => (0, import_editor_v1_adapters10.getCanvasIframeDocument)()?.head);
|
|
@@ -3082,8 +3280,10 @@ function createPromotionView(BaseView) {
|
|
|
3082
3280
|
return class extends BaseView {
|
|
3083
3281
|
_afterRender() {
|
|
3084
3282
|
super._afterRender();
|
|
3085
|
-
|
|
3086
|
-
|
|
3283
|
+
const removeBtnSelector = ".e-pro-promotion-placeholder__remove-btn";
|
|
3284
|
+
const unlockBtnSelector = ".e-pro-promotion-placeholder__unlock-btn";
|
|
3285
|
+
this.$el.off("click", removeBtnSelector);
|
|
3286
|
+
this.$el.on("click", removeBtnSelector, (e) => {
|
|
3087
3287
|
e.preventDefault();
|
|
3088
3288
|
e.stopPropagation();
|
|
3089
3289
|
window.$e.run(
|
|
@@ -3091,8 +3291,8 @@ function createPromotionView(BaseView) {
|
|
|
3091
3291
|
{ container: this.container }
|
|
3092
3292
|
);
|
|
3093
3293
|
});
|
|
3094
|
-
this.$el.off("click",
|
|
3095
|
-
this.$el.on("click",
|
|
3294
|
+
this.$el.off("click", unlockBtnSelector);
|
|
3295
|
+
this.$el.on("click", unlockBtnSelector, (e) => {
|
|
3096
3296
|
e.stopPropagation();
|
|
3097
3297
|
});
|
|
3098
3298
|
}
|
|
@@ -3110,8 +3310,8 @@ function createPromotionView(BaseView) {
|
|
|
3110
3310
|
}
|
|
3111
3311
|
onDestroy(...args) {
|
|
3112
3312
|
super.onDestroy(...args);
|
|
3113
|
-
this.$el.off("click", ".e-
|
|
3114
|
-
this.$el.off("click", ".e-
|
|
3313
|
+
this.$el.off("click", ".e-pro-promotion-placeholder__remove-btn");
|
|
3314
|
+
this.$el.off("click", ".e-pro-promotion-placeholder__unlock-btn");
|
|
3115
3315
|
}
|
|
3116
3316
|
};
|
|
3117
3317
|
}
|
|
@@ -3120,7 +3320,7 @@ function createPromotionView(BaseView) {
|
|
|
3120
3320
|
var import_client = require("react-dom/client");
|
|
3121
3321
|
|
|
3122
3322
|
// src/legacy/replacements/inline-editing/inline-editing-elements.tsx
|
|
3123
|
-
var
|
|
3323
|
+
var React11 = __toESM(require("react"));
|
|
3124
3324
|
var import_editor_elements9 = require("@elementor/editor-elements");
|
|
3125
3325
|
var import_editor_props5 = require("@elementor/editor-props");
|
|
3126
3326
|
var import_editor_v1_adapters13 = require("@elementor/editor-v1-adapters");
|
|
@@ -3169,14 +3369,14 @@ var ReplacementBase = class {
|
|
|
3169
3369
|
};
|
|
3170
3370
|
|
|
3171
3371
|
// src/legacy/replacements/inline-editing/canvas-inline-editor.tsx
|
|
3172
|
-
var
|
|
3173
|
-
var
|
|
3372
|
+
var React10 = __toESM(require("react"));
|
|
3373
|
+
var import_react17 = require("react");
|
|
3174
3374
|
var import_editor_controls2 = require("@elementor/editor-controls");
|
|
3175
3375
|
var import_ui5 = require("@elementor/ui");
|
|
3176
|
-
var
|
|
3376
|
+
var import_react18 = require("@floating-ui/react");
|
|
3177
3377
|
|
|
3178
3378
|
// src/legacy/replacements/inline-editing/inline-editing-utils.ts
|
|
3179
|
-
var
|
|
3379
|
+
var import_react16 = require("react");
|
|
3180
3380
|
var TOP_BAR_SELECTOR = "#elementor-editor-wrapper-v2";
|
|
3181
3381
|
var NAVIGATOR_SELECTOR = "#elementor-navigator";
|
|
3182
3382
|
var EDITING_PANEL = "#elementor-panel";
|
|
@@ -3207,8 +3407,8 @@ var getInlineEditorElement = (elementWrapper, expectedTag) => {
|
|
|
3207
3407
|
return !expectedTag ? null : elementWrapper.querySelector(expectedTag);
|
|
3208
3408
|
};
|
|
3209
3409
|
var useOnClickOutsideIframe = (handleUnmount) => {
|
|
3210
|
-
const asyncUnmountInlineEditor = (0,
|
|
3211
|
-
(0,
|
|
3410
|
+
const asyncUnmountInlineEditor = (0, import_react16.useCallback)(() => queueMicrotask(handleUnmount), [handleUnmount]);
|
|
3411
|
+
(0, import_react16.useEffect)(() => {
|
|
3212
3412
|
EDITOR_ELEMENTS_OUT_OF_IFRAME.forEach(
|
|
3213
3413
|
(selector) => document?.querySelector(selector)?.addEventListener("mousedown", asyncUnmountInlineEditor)
|
|
3214
3414
|
);
|
|
@@ -3218,8 +3418,8 @@ var useOnClickOutsideIframe = (handleUnmount) => {
|
|
|
3218
3418
|
}, []);
|
|
3219
3419
|
};
|
|
3220
3420
|
var useRenderToolbar = (ownerDocument, id) => {
|
|
3221
|
-
const [anchor, setAnchor] = (0,
|
|
3222
|
-
(0,
|
|
3421
|
+
const [anchor, setAnchor] = (0, import_react16.useState)(null);
|
|
3422
|
+
(0, import_react16.useEffect)(() => {
|
|
3223
3423
|
if (!anchor) {
|
|
3224
3424
|
removeToolbarAnchor(ownerDocument, id);
|
|
3225
3425
|
}
|
|
@@ -3233,7 +3433,7 @@ var useRenderToolbar = (ownerDocument, id) => {
|
|
|
3233
3433
|
setAnchor(null);
|
|
3234
3434
|
}
|
|
3235
3435
|
};
|
|
3236
|
-
const clearAnchor = (0,
|
|
3436
|
+
const clearAnchor = (0, import_react16.useCallback)(() => {
|
|
3237
3437
|
setAnchor(null);
|
|
3238
3438
|
}, []);
|
|
3239
3439
|
return { onSelectionEnd, anchor, clearAnchor };
|
|
@@ -3313,21 +3513,21 @@ var CanvasInlineEditor = ({
|
|
|
3313
3513
|
setValue,
|
|
3314
3514
|
requestDestroy
|
|
3315
3515
|
}) => {
|
|
3316
|
-
const [active, setActive] = (0,
|
|
3317
|
-
const [editor, setEditor] = (0,
|
|
3516
|
+
const [active, setActive] = (0, import_react17.useState)(true);
|
|
3517
|
+
const [editor, setEditor] = (0, import_react17.useState)(null);
|
|
3318
3518
|
const { onSelectionEnd, anchor: toolbarAnchor, clearAnchor } = useRenderToolbar(rootElement.ownerDocument, id);
|
|
3319
|
-
(0,
|
|
3519
|
+
(0, import_react17.useEffect)(() => {
|
|
3320
3520
|
if (!active) {
|
|
3321
3521
|
clearAnchor();
|
|
3322
3522
|
requestDestroy();
|
|
3323
3523
|
}
|
|
3324
3524
|
}, [active, clearAnchor, requestDestroy]);
|
|
3325
|
-
const dismiss = (0,
|
|
3525
|
+
const dismiss = (0, import_react17.useCallback)(() => {
|
|
3326
3526
|
setEditor(null);
|
|
3327
3527
|
setActive(false);
|
|
3328
3528
|
}, []);
|
|
3329
3529
|
useOnClickOutsideIframe(dismiss);
|
|
3330
|
-
(0,
|
|
3530
|
+
(0, import_react17.useEffect)(() => {
|
|
3331
3531
|
const ownerDocument = contentElement.ownerDocument;
|
|
3332
3532
|
const handleClickAway = (event) => {
|
|
3333
3533
|
if (contentElement.contains(event.target)) {
|
|
@@ -3341,7 +3541,7 @@ var CanvasInlineEditor = ({
|
|
|
3341
3541
|
if (!active) {
|
|
3342
3542
|
return null;
|
|
3343
3543
|
}
|
|
3344
|
-
return /* @__PURE__ */
|
|
3544
|
+
return /* @__PURE__ */ React10.createElement(import_ui5.ThemeProvider, null, /* @__PURE__ */ React10.createElement(InlineEditingOverlay, { expectedTag, rootElement, id }), /* @__PURE__ */ React10.createElement(
|
|
3345
3545
|
import_editor_controls2.InlineEditor,
|
|
3346
3546
|
{
|
|
3347
3547
|
onEditorCreate: setEditor,
|
|
@@ -3358,7 +3558,7 @@ var CanvasInlineEditor = ({
|
|
|
3358
3558
|
autofocus: true,
|
|
3359
3559
|
onSelectionEnd
|
|
3360
3560
|
}
|
|
3361
|
-
), toolbarAnchor && editor && /* @__PURE__ */
|
|
3561
|
+
), toolbarAnchor && editor && /* @__PURE__ */ React10.createElement(InlineEditingToolbar, { anchor: toolbarAnchor, editor, id }));
|
|
3362
3562
|
};
|
|
3363
3563
|
var InlineEditingOverlay = ({
|
|
3364
3564
|
expectedTag,
|
|
@@ -3366,25 +3566,25 @@ var InlineEditingOverlay = ({
|
|
|
3366
3566
|
id
|
|
3367
3567
|
}) => {
|
|
3368
3568
|
const inlineEditedElement = getInlineEditorElement(rootElement, expectedTag);
|
|
3369
|
-
const [overlayRefElement, setOverlayElement] = (0,
|
|
3370
|
-
(0,
|
|
3569
|
+
const [overlayRefElement, setOverlayElement] = (0, import_react17.useState)(inlineEditedElement);
|
|
3570
|
+
(0, import_react17.useEffect)(() => {
|
|
3371
3571
|
setOverlayElement(getInlineEditorElement(rootElement, expectedTag));
|
|
3372
3572
|
}, [expectedTag, rootElement]);
|
|
3373
|
-
return overlayRefElement ? /* @__PURE__ */
|
|
3573
|
+
return overlayRefElement ? /* @__PURE__ */ React10.createElement(OutlineOverlay, { element: overlayRefElement, id, isSelected: true }) : null;
|
|
3374
3574
|
};
|
|
3375
3575
|
var InlineEditingToolbar = ({ anchor, editor, id }) => {
|
|
3376
|
-
const { refs, floatingStyles } = (0,
|
|
3576
|
+
const { refs, floatingStyles } = (0, import_react18.useFloating)({
|
|
3377
3577
|
placement: "top",
|
|
3378
3578
|
strategy: "fixed",
|
|
3379
3579
|
transform: false,
|
|
3380
|
-
whileElementsMounted:
|
|
3381
|
-
middleware: [horizontalShifterMiddleware, (0,
|
|
3580
|
+
whileElementsMounted: import_react18.autoUpdate,
|
|
3581
|
+
middleware: [horizontalShifterMiddleware, (0, import_react18.flip)()]
|
|
3382
3582
|
});
|
|
3383
|
-
(0,
|
|
3583
|
+
(0, import_react17.useLayoutEffect)(() => {
|
|
3384
3584
|
refs.setReference(anchor);
|
|
3385
3585
|
return () => refs.setReference(null);
|
|
3386
3586
|
}, [anchor, refs]);
|
|
3387
|
-
return /* @__PURE__ */
|
|
3587
|
+
return /* @__PURE__ */ React10.createElement(import_react18.FloatingPortal, { id: CANVAS_WRAPPER_ID }, /* @__PURE__ */ React10.createElement(
|
|
3388
3588
|
import_ui5.Box,
|
|
3389
3589
|
{
|
|
3390
3590
|
ref: refs.setFloating,
|
|
@@ -3394,7 +3594,7 @@ var InlineEditingToolbar = ({ anchor, editor, id }) => {
|
|
|
3394
3594
|
pointerEvents: "none"
|
|
3395
3595
|
}
|
|
3396
3596
|
},
|
|
3397
|
-
/* @__PURE__ */
|
|
3597
|
+
/* @__PURE__ */ React10.createElement(import_editor_controls2.InlineEditorToolbar, { editor, elementId: id })
|
|
3398
3598
|
));
|
|
3399
3599
|
};
|
|
3400
3600
|
|
|
@@ -3603,7 +3803,7 @@ var InlineEditingReplacement = class extends ReplacementBase {
|
|
|
3603
3803
|
contentElement.innerHTML = "";
|
|
3604
3804
|
this.editing = true;
|
|
3605
3805
|
this.reactRoot.render(
|
|
3606
|
-
/* @__PURE__ */
|
|
3806
|
+
/* @__PURE__ */ React11.createElement(
|
|
3607
3807
|
CanvasInlineEditor,
|
|
3608
3808
|
{
|
|
3609
3809
|
elementClasses,
|
|
@@ -6247,7 +6447,7 @@ var getLegacyPanelElementView = ({ settings, ...rest }) => {
|
|
|
6247
6447
|
var GLOBAL_STYLES_IMPORTED_EVENT = "elementor/global-styles/imported";
|
|
6248
6448
|
|
|
6249
6449
|
// src/components/spotlight-backdrop.tsx
|
|
6250
|
-
var
|
|
6450
|
+
var React12 = __toESM(require("react"));
|
|
6251
6451
|
function SpotlightBackdrop({ canvas, element, onExit, ariaLabel }) {
|
|
6252
6452
|
const rect = useElementRect(element);
|
|
6253
6453
|
const clipPath = element ? getRectClipPath(rect, canvas.defaultView) : void 0;
|
|
@@ -6269,7 +6469,7 @@ function SpotlightBackdrop({ canvas, element, onExit, ariaLabel }) {
|
|
|
6269
6469
|
onExit();
|
|
6270
6470
|
}
|
|
6271
6471
|
};
|
|
6272
|
-
return /* @__PURE__ */
|
|
6472
|
+
return /* @__PURE__ */ React12.createElement(
|
|
6273
6473
|
"div",
|
|
6274
6474
|
{
|
|
6275
6475
|
style: backdropStyle,
|
|
@@ -6294,9 +6494,9 @@ function useCanvasDocument() {
|
|
|
6294
6494
|
}
|
|
6295
6495
|
|
|
6296
6496
|
// src/hooks/use-escape-on-canvas.ts
|
|
6297
|
-
var
|
|
6497
|
+
var import_react19 = require("react");
|
|
6298
6498
|
function useEscapeOnCanvas(canvasDocument, onEscape) {
|
|
6299
|
-
(0,
|
|
6499
|
+
(0, import_react19.useEffect)(() => {
|
|
6300
6500
|
if (!canvasDocument) {
|
|
6301
6501
|
return;
|
|
6302
6502
|
}
|