@elementor/editor-canvas 4.2.0-911 → 4.2.0-913
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 +228 -225
- package/dist/index.mjs +115 -112
- package/package.json +18 -18
- package/src/components/grid-outline/__tests__/grid-outline-overlay.test.tsx +2 -2
- package/src/components/grid-outline/__tests__/grid-outline.test.tsx +28 -27
- package/src/components/grid-outline/{grid-outline-line.tsx → grid-outline-cell.tsx} +11 -10
- package/src/components/grid-outline/grid-outline.tsx +10 -20
- package/src/hooks/__tests__/use-grid-tracks.test.ts +57 -35
- package/src/hooks/use-grid-tracks.ts +26 -25
- package/src/utils/__tests__/grid-outline-utils.test.ts +128 -38
- package/src/utils/grid-outline-utils.ts +52 -26
package/dist/index.mjs
CHANGED
|
@@ -360,9 +360,9 @@ import * as React5 from "react";
|
|
|
360
360
|
import { getElements, useSelectedElement } from "@elementor/editor-elements";
|
|
361
361
|
import {
|
|
362
362
|
__privateUseIsRouteActive as useIsRouteActive,
|
|
363
|
-
__privateUseListenTo as
|
|
363
|
+
__privateUseListenTo as useListenTo2,
|
|
364
364
|
useEditMode,
|
|
365
|
-
windowEvent
|
|
365
|
+
windowEvent as windowEvent2
|
|
366
366
|
} from "@elementor/editor-v1-adapters";
|
|
367
367
|
|
|
368
368
|
// src/components/grid-outline/grid-outline-overlay.tsx
|
|
@@ -477,38 +477,54 @@ function useFloatingOnElement({ element, isSelected }) {
|
|
|
477
477
|
}
|
|
478
478
|
|
|
479
479
|
// src/hooks/use-grid-tracks.ts
|
|
480
|
-
import {
|
|
480
|
+
import { useEffect as useEffect4, useState as useState3 } from "react";
|
|
481
|
+
import { ELEMENT_STYLE_CHANGE_EVENT } from "@elementor/editor-elements";
|
|
482
|
+
import { __privateUseListenTo as useListenTo, windowEvent } from "@elementor/editor-v1-adapters";
|
|
481
483
|
|
|
482
484
|
// src/utils/grid-outline-utils.ts
|
|
483
|
-
function
|
|
484
|
-
const { columns, rows, columnGap, rowGap, padding } = tracks;
|
|
485
|
+
function toGridTracks(computedStyle) {
|
|
485
486
|
return {
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
487
|
+
columns: parseTrackList(computedStyle.gridTemplateColumns),
|
|
488
|
+
rows: parseTrackList(computedStyle.gridTemplateRows),
|
|
489
|
+
columnGap: toPx(computedStyle.columnGap),
|
|
490
|
+
rowGap: toPx(computedStyle.rowGap),
|
|
491
|
+
padding: {
|
|
492
|
+
top: toPx(computedStyle.paddingTop),
|
|
493
|
+
right: toPx(computedStyle.paddingRight),
|
|
494
|
+
bottom: toPx(computedStyle.paddingBottom),
|
|
495
|
+
left: toPx(computedStyle.paddingLeft)
|
|
496
|
+
},
|
|
497
|
+
borderColor: computedStyle.getPropertyValue("--e-a-border-color-bold").trim()
|
|
492
498
|
};
|
|
493
499
|
}
|
|
494
|
-
function
|
|
495
|
-
|
|
500
|
+
function computeCellRects(tracks, width, height) {
|
|
501
|
+
const { columns, rows, columnGap, rowGap, padding } = tracks;
|
|
502
|
+
const hasColumns = columns.length > 0;
|
|
503
|
+
const hasRows = rows.length > 0;
|
|
504
|
+
if (!hasColumns && !hasRows) {
|
|
496
505
|
return [];
|
|
497
506
|
}
|
|
498
|
-
const
|
|
507
|
+
const columnSegments = hasColumns ? computeTrackSegments(columns, columnGap, padding.left) : [{ start: padding.left, size: width - padding.left - padding.right }];
|
|
508
|
+
const rowSegments = hasRows ? computeTrackSegments(rows, rowGap, padding.top) : [{ start: padding.top, size: height - padding.top - padding.bottom }];
|
|
509
|
+
const cells = [];
|
|
510
|
+
for (const row of rowSegments) {
|
|
511
|
+
for (const column of columnSegments) {
|
|
512
|
+
cells.push({ x: column.start, y: row.start, width: column.size, height: row.size });
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
return cells;
|
|
516
|
+
}
|
|
517
|
+
function computeTrackSegments(sizes, gap, offset2) {
|
|
518
|
+
const segments = [];
|
|
499
519
|
let cursor = offset2;
|
|
500
520
|
for (let i = 0; i < sizes.length; i++) {
|
|
501
|
-
|
|
502
|
-
boundaries.push(cursor);
|
|
503
|
-
}
|
|
521
|
+
segments.push({ start: cursor, size: sizes[i] });
|
|
504
522
|
cursor += sizes[i];
|
|
505
|
-
|
|
506
|
-
if (i < sizes.length - 1 && gap > 0) {
|
|
523
|
+
if (i < sizes.length - 1) {
|
|
507
524
|
cursor += gap;
|
|
508
|
-
boundaries.push(cursor);
|
|
509
525
|
}
|
|
510
526
|
}
|
|
511
|
-
return
|
|
527
|
+
return segments;
|
|
512
528
|
}
|
|
513
529
|
function snapToHalfPixel(value) {
|
|
514
530
|
return Math.round(value) + 0.5;
|
|
@@ -533,30 +549,27 @@ var EMPTY = {
|
|
|
533
549
|
padding: { top: 0, right: 0, bottom: 0, left: 0 },
|
|
534
550
|
borderColor: ""
|
|
535
551
|
};
|
|
552
|
+
var DEVICE_MODE_CHANGE_EVENT = "elementor/device-mode/change";
|
|
536
553
|
function useGridTracks(element, rect) {
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
554
|
+
const [tracks, setTracks] = useState3(EMPTY);
|
|
555
|
+
const trigger = useListenTo(
|
|
556
|
+
[windowEvent(ELEMENT_STYLE_CHANGE_EVENT), windowEvent(DEVICE_MODE_CHANGE_EVENT)],
|
|
557
|
+
() => ({})
|
|
558
|
+
);
|
|
559
|
+
useEffect4(() => {
|
|
560
|
+
const previewWindow = element?.ownerDocument?.defaultView;
|
|
561
|
+
if (!element || !previewWindow) {
|
|
562
|
+
setTracks(EMPTY);
|
|
563
|
+
return;
|
|
544
564
|
}
|
|
545
|
-
const
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
rowGap: toPx(computedStyle.rowGap),
|
|
551
|
-
padding: {
|
|
552
|
-
top: toPx(computedStyle.paddingTop),
|
|
553
|
-
right: toPx(computedStyle.paddingRight),
|
|
554
|
-
bottom: toPx(computedStyle.paddingBottom),
|
|
555
|
-
left: toPx(computedStyle.paddingLeft)
|
|
556
|
-
},
|
|
557
|
-
borderColor: computedStyle.getPropertyValue("--e-a-border-color-bold").trim()
|
|
565
|
+
const frame = previewWindow.requestAnimationFrame(() => {
|
|
566
|
+
setTracks(toGridTracks(previewWindow.getComputedStyle(element)));
|
|
567
|
+
});
|
|
568
|
+
return () => {
|
|
569
|
+
previewWindow.cancelAnimationFrame(frame);
|
|
558
570
|
};
|
|
559
|
-
}, [element, rect.width, rect.height]);
|
|
571
|
+
}, [element, rect.width, rect.height, trigger]);
|
|
572
|
+
return tracks;
|
|
560
573
|
}
|
|
561
574
|
|
|
562
575
|
// src/components/outline-overlay.tsx
|
|
@@ -565,9 +578,9 @@ import { Box, styled } from "@elementor/ui";
|
|
|
565
578
|
import { FloatingPortal, useHover, useInteractions } from "@floating-ui/react";
|
|
566
579
|
|
|
567
580
|
// src/hooks/use-bind-react-props-to-element.ts
|
|
568
|
-
import { useEffect as
|
|
581
|
+
import { useEffect as useEffect5 } from "react";
|
|
569
582
|
function useBindReactPropsToElement(element, getProps) {
|
|
570
|
-
|
|
583
|
+
useEffect5(() => {
|
|
571
584
|
const el = element;
|
|
572
585
|
const { events, attrs } = groupProps(getProps());
|
|
573
586
|
events.forEach(([eventName, listener]) => el.addEventListener(eventName, listener));
|
|
@@ -650,18 +663,19 @@ var OutlineOverlay = ({ element, isSelected, id, isGlobal = false }) => {
|
|
|
650
663
|
// src/components/grid-outline/grid-outline.tsx
|
|
651
664
|
import * as React3 from "react";
|
|
652
665
|
|
|
653
|
-
// src/components/grid-outline/grid-outline-
|
|
666
|
+
// src/components/grid-outline/grid-outline-cell.tsx
|
|
654
667
|
import * as React2 from "react";
|
|
655
668
|
var FALLBACK_COLOR = "rgba(0, 0, 0, 0.12)";
|
|
656
669
|
var DASH = "2 2";
|
|
657
|
-
function
|
|
670
|
+
function GridOutlineCell({ x, y, width, height, color }) {
|
|
658
671
|
return /* @__PURE__ */ React2.createElement(
|
|
659
|
-
"
|
|
672
|
+
"rect",
|
|
660
673
|
{
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
674
|
+
x,
|
|
675
|
+
y,
|
|
676
|
+
width,
|
|
677
|
+
height,
|
|
678
|
+
fill: "none",
|
|
665
679
|
stroke: color || FALLBACK_COLOR,
|
|
666
680
|
strokeWidth: 1,
|
|
667
681
|
strokeDasharray: DASH,
|
|
@@ -672,7 +686,7 @@ function GridOutlineLine({ x1, x2, y1, y2, color }) {
|
|
|
672
686
|
|
|
673
687
|
// src/components/grid-outline/grid-outline.tsx
|
|
674
688
|
function GridOutline({ tracks, width, height }) {
|
|
675
|
-
const
|
|
689
|
+
const cells = computeCellRects(tracks, width, height);
|
|
676
690
|
return /* @__PURE__ */ React3.createElement(
|
|
677
691
|
"svg",
|
|
678
692
|
{
|
|
@@ -681,25 +695,14 @@ function GridOutline({ tracks, width, height }) {
|
|
|
681
695
|
style: { position: "absolute", inset: 0, overflow: "visible" },
|
|
682
696
|
xmlns: "http://www.w3.org/2000/svg"
|
|
683
697
|
},
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
{
|
|
687
|
-
key: `v-${i}`,
|
|
688
|
-
x1: snapToHalfPixel(x),
|
|
689
|
-
x2: snapToHalfPixel(x),
|
|
690
|
-
y1: top,
|
|
691
|
-
y2: bottom,
|
|
692
|
-
color: tracks.borderColor
|
|
693
|
-
}
|
|
694
|
-
)),
|
|
695
|
-
horizontal.map((y, i) => /* @__PURE__ */ React3.createElement(
|
|
696
|
-
GridOutlineLine,
|
|
698
|
+
cells.map((cell, i) => /* @__PURE__ */ React3.createElement(
|
|
699
|
+
GridOutlineCell,
|
|
697
700
|
{
|
|
698
|
-
key:
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
701
|
+
key: i,
|
|
702
|
+
x: snapToHalfPixel(cell.x),
|
|
703
|
+
y: snapToHalfPixel(cell.y),
|
|
704
|
+
width: Math.round(cell.width),
|
|
705
|
+
height: Math.round(cell.height),
|
|
703
706
|
color: tracks.borderColor
|
|
704
707
|
}
|
|
705
708
|
))
|
|
@@ -770,8 +773,8 @@ function ElementsOverlays() {
|
|
|
770
773
|
});
|
|
771
774
|
}
|
|
772
775
|
function useElementsDom() {
|
|
773
|
-
return
|
|
774
|
-
[
|
|
776
|
+
return useListenTo2(
|
|
777
|
+
[windowEvent2("elementor/editor/element-rendered"), windowEvent2("elementor/editor/element-destroyed")],
|
|
775
778
|
() => {
|
|
776
779
|
return getElements().filter((el) => isV4Element(el.view?.el?.dataset)).map((element) => ({
|
|
777
780
|
id: element.id,
|
|
@@ -791,22 +794,22 @@ function isV4Element(dataset) {
|
|
|
791
794
|
// src/components/interactions-renderer.tsx
|
|
792
795
|
import * as React6 from "react";
|
|
793
796
|
import {
|
|
794
|
-
__privateUseListenTo as
|
|
797
|
+
__privateUseListenTo as useListenTo3,
|
|
795
798
|
commandEndEvent,
|
|
796
799
|
getCanvasIframeDocument
|
|
797
800
|
} from "@elementor/editor-v1-adapters";
|
|
798
801
|
import { Portal } from "@elementor/ui";
|
|
799
802
|
|
|
800
803
|
// src/hooks/use-interactions-items.ts
|
|
801
|
-
import { useEffect as
|
|
804
|
+
import { useEffect as useEffect7, useMemo, useState as useState4 } from "react";
|
|
802
805
|
import { interactionsRepository } from "@elementor/editor-interactions";
|
|
803
806
|
import { registerDataHook } from "@elementor/editor-v1-adapters";
|
|
804
807
|
|
|
805
808
|
// src/hooks/use-on-mount.ts
|
|
806
|
-
import { useEffect as
|
|
809
|
+
import { useEffect as useEffect6, useRef } from "react";
|
|
807
810
|
function useOnMount(cb) {
|
|
808
811
|
const mounted = useRef(false);
|
|
809
|
-
|
|
812
|
+
useEffect6(() => {
|
|
810
813
|
if (!mounted.current) {
|
|
811
814
|
mounted.current = true;
|
|
812
815
|
cb();
|
|
@@ -816,8 +819,8 @@ function useOnMount(cb) {
|
|
|
816
819
|
|
|
817
820
|
// src/hooks/use-interactions-items.ts
|
|
818
821
|
function useInteractionsItems() {
|
|
819
|
-
const [interactionItems, setInteractionItems] =
|
|
820
|
-
const providerAndSubscribers =
|
|
822
|
+
const [interactionItems, setInteractionItems] = useState4({});
|
|
823
|
+
const providerAndSubscribers = useMemo(() => {
|
|
821
824
|
try {
|
|
822
825
|
const providers = interactionsRepository.getProviders();
|
|
823
826
|
const mapped = providers.map((provider) => {
|
|
@@ -834,7 +837,7 @@ function useInteractionsItems() {
|
|
|
834
837
|
return [];
|
|
835
838
|
}
|
|
836
839
|
}, []);
|
|
837
|
-
|
|
840
|
+
useEffect7(() => {
|
|
838
841
|
if (providerAndSubscribers.length === 0) {
|
|
839
842
|
return;
|
|
840
843
|
}
|
|
@@ -865,7 +868,7 @@ function useInteractionsItems() {
|
|
|
865
868
|
});
|
|
866
869
|
});
|
|
867
870
|
});
|
|
868
|
-
return
|
|
871
|
+
return useMemo(() => {
|
|
869
872
|
const result = Object.values(interactionItems).sort(sortByProviderPriority).flatMap(({ items }) => items);
|
|
870
873
|
return result;
|
|
871
874
|
}, [interactionItems]);
|
|
@@ -907,13 +910,13 @@ function InteractionsRenderer() {
|
|
|
907
910
|
));
|
|
908
911
|
}
|
|
909
912
|
function usePortalContainer() {
|
|
910
|
-
return
|
|
913
|
+
return useListenTo3(commandEndEvent("editor/documents/attach-preview"), () => getCanvasIframeDocument()?.head);
|
|
911
914
|
}
|
|
912
915
|
|
|
913
916
|
// src/components/style-renderer.tsx
|
|
914
917
|
import * as React7 from "react";
|
|
915
918
|
import {
|
|
916
|
-
__privateUseListenTo as
|
|
919
|
+
__privateUseListenTo as useListenTo5,
|
|
917
920
|
commandEndEvent as commandEndEvent3,
|
|
918
921
|
getCanvasIframeDocument as getCanvasIframeDocument4
|
|
919
922
|
} from "@elementor/editor-v1-adapters";
|
|
@@ -921,7 +924,7 @@ import { Portal as Portal2 } from "@elementor/ui";
|
|
|
921
924
|
|
|
922
925
|
// src/hooks/use-documents-css-links.ts
|
|
923
926
|
import {
|
|
924
|
-
__privateUseListenTo as
|
|
927
|
+
__privateUseListenTo as useListenTo4,
|
|
925
928
|
commandEndEvent as commandEndEvent2,
|
|
926
929
|
getCanvasIframeDocument as getCanvasIframeDocument2
|
|
927
930
|
} from "@elementor/editor-v1-adapters";
|
|
@@ -930,7 +933,7 @@ var DOCUMENT_WRAPPER_ATTR = "data-elementor-id";
|
|
|
930
933
|
var CSS_LINK_ID_PREFIX = "elementor-post-";
|
|
931
934
|
var CSS_LINK_ID_SUFFIX = "-css";
|
|
932
935
|
function useDocumentsCssLinks() {
|
|
933
|
-
return
|
|
936
|
+
return useListenTo4(commandEndEvent2("editor/documents/attach-preview"), () => {
|
|
934
937
|
const iframeDocument = getCanvasIframeDocument2();
|
|
935
938
|
if (!iframeDocument) {
|
|
936
939
|
return [];
|
|
@@ -971,7 +974,7 @@ function getLinkAttrs(el) {
|
|
|
971
974
|
}
|
|
972
975
|
|
|
973
976
|
// src/hooks/use-style-items.ts
|
|
974
|
-
import { useEffect as
|
|
977
|
+
import { useEffect as useEffect8, useMemo as useMemo4, useRef as useRef2, useState as useState5 } from "react";
|
|
975
978
|
import { useBreakpoints } from "@elementor/editor-responsive";
|
|
976
979
|
import { isClassState } from "@elementor/editor-styles";
|
|
977
980
|
import { stylesRepository as stylesRepository2 } from "@elementor/editor-styles-repository";
|
|
@@ -1033,7 +1036,7 @@ function signalizedProcess(signal, steps = []) {
|
|
|
1033
1036
|
}
|
|
1034
1037
|
|
|
1035
1038
|
// src/hooks/use-style-prop-resolver.ts
|
|
1036
|
-
import { useMemo as
|
|
1039
|
+
import { useMemo as useMemo2 } from "react";
|
|
1037
1040
|
import { getStylesSchema as getStylesSchema2 } from "@elementor/editor-styles";
|
|
1038
1041
|
import { enqueueFont } from "@elementor/editor-v1-adapters";
|
|
1039
1042
|
|
|
@@ -1163,7 +1166,7 @@ var styleTransformersRegistry = createTransformersRegistry();
|
|
|
1163
1166
|
|
|
1164
1167
|
// src/hooks/use-style-prop-resolver.ts
|
|
1165
1168
|
function useStylePropResolver() {
|
|
1166
|
-
return
|
|
1169
|
+
return useMemo2(() => {
|
|
1167
1170
|
return createPropsResolver({
|
|
1168
1171
|
transformers: styleTransformersRegistry,
|
|
1169
1172
|
schema: getStylesSchema2(),
|
|
@@ -1178,7 +1181,7 @@ function useStylePropResolver() {
|
|
|
1178
1181
|
}
|
|
1179
1182
|
|
|
1180
1183
|
// src/hooks/use-style-renderer.ts
|
|
1181
|
-
import { useMemo as
|
|
1184
|
+
import { useMemo as useMemo3 } from "react";
|
|
1182
1185
|
import { useBreakpointsMap } from "@elementor/editor-responsive";
|
|
1183
1186
|
|
|
1184
1187
|
// src/renderers/create-styles-renderer.ts
|
|
@@ -1289,7 +1292,7 @@ function customCssToString(customCss) {
|
|
|
1289
1292
|
var SELECTOR_PREFIX = ".elementor";
|
|
1290
1293
|
function useStyleRenderer(resolve) {
|
|
1291
1294
|
const breakpoints = useBreakpointsMap();
|
|
1292
|
-
return
|
|
1295
|
+
return useMemo3(() => {
|
|
1293
1296
|
return createStylesRenderer({
|
|
1294
1297
|
selectorPrefix: SELECTOR_PREFIX,
|
|
1295
1298
|
breakpoints,
|
|
@@ -1303,9 +1306,9 @@ function useStyleItems() {
|
|
|
1303
1306
|
const resolve = useStylePropResolver();
|
|
1304
1307
|
const renderStyles = useStyleRenderer(resolve);
|
|
1305
1308
|
const breakpoints = useBreakpoints();
|
|
1306
|
-
const [styleItems, setStyleItems] =
|
|
1309
|
+
const [styleItems, setStyleItems] = useState5({});
|
|
1307
1310
|
const styleItemsCacheRef = useRef2(/* @__PURE__ */ new Map());
|
|
1308
|
-
const providerAndSubscribers =
|
|
1311
|
+
const providerAndSubscribers = useMemo4(() => {
|
|
1309
1312
|
const createEmptyCache = () => {
|
|
1310
1313
|
return { orderedIds: [], itemsById: /* @__PURE__ */ new Map() };
|
|
1311
1314
|
};
|
|
@@ -1331,7 +1334,7 @@ function useStyleItems() {
|
|
|
1331
1334
|
})
|
|
1332
1335
|
);
|
|
1333
1336
|
}, [renderStyles]);
|
|
1334
|
-
|
|
1337
|
+
useEffect8(() => {
|
|
1335
1338
|
const unsubscribes = providerAndSubscribers.map(
|
|
1336
1339
|
({ provider, subscriber }) => provider.subscribe(subscriber)
|
|
1337
1340
|
);
|
|
@@ -1346,11 +1349,11 @@ function useStyleItems() {
|
|
|
1346
1349
|
await Promise.all(promises);
|
|
1347
1350
|
});
|
|
1348
1351
|
});
|
|
1349
|
-
const breakpointSorter =
|
|
1352
|
+
const breakpointSorter = useMemo4(
|
|
1350
1353
|
() => createBreakpointSorter(breakpoints.map((breakpoint) => breakpoint.id)),
|
|
1351
1354
|
[breakpoints]
|
|
1352
1355
|
);
|
|
1353
|
-
return
|
|
1356
|
+
return useMemo4(
|
|
1354
1357
|
() => Object.values(styleItems).sort(prioritySorter).flatMap(({ items }) => items).sort(stateSorter).sort(breakpointSorter),
|
|
1355
1358
|
[styleItems, breakpointSorter]
|
|
1356
1359
|
);
|
|
@@ -1495,7 +1498,7 @@ function StyleRenderer() {
|
|
|
1495
1498
|
return /* @__PURE__ */ React7.createElement(Portal2, { container }, filterUniqueStyleDefinitions(styleItems).map((item) => /* @__PURE__ */ React7.createElement("style", { key: `${item.id}-${item.breakpoint}-${item.state ?? "normal"}` }, item.value)), linksAttrs.map((attrs) => /* @__PURE__ */ React7.createElement("link", { ...attrs, key: attrs.id })));
|
|
1496
1499
|
}
|
|
1497
1500
|
function usePortalContainer2() {
|
|
1498
|
-
return
|
|
1501
|
+
return useListenTo5(commandEndEvent3("editor/documents/attach-preview"), () => getCanvasIframeDocument4()?.head);
|
|
1499
1502
|
}
|
|
1500
1503
|
function filterUniqueStyleDefinitions(styleItems) {
|
|
1501
1504
|
const seen = /* @__PURE__ */ new Map();
|
|
@@ -2412,7 +2415,7 @@ function createElementViewClassDeclaration() {
|
|
|
2412
2415
|
}
|
|
2413
2416
|
|
|
2414
2417
|
// src/legacy/create-nested-templated-element-type.ts
|
|
2415
|
-
import { ELEMENT_STYLE_CHANGE_EVENT } from "@elementor/editor-elements";
|
|
2418
|
+
import { ELEMENT_STYLE_CHANGE_EVENT as ELEMENT_STYLE_CHANGE_EVENT2 } from "@elementor/editor-elements";
|
|
2416
2419
|
|
|
2417
2420
|
// src/legacy/create-pending-element.ts
|
|
2418
2421
|
import {
|
|
@@ -2725,7 +2728,7 @@ function createNestedTemplatedElementView({
|
|
|
2725
2728
|
this._initAlpine();
|
|
2726
2729
|
});
|
|
2727
2730
|
this.model.trigger("render:complete");
|
|
2728
|
-
window.dispatchEvent(new CustomEvent(
|
|
2731
|
+
window.dispatchEvent(new CustomEvent(ELEMENT_STYLE_CHANGE_EVENT2));
|
|
2729
2732
|
},
|
|
2730
2733
|
async _renderTemplate() {
|
|
2731
2734
|
const model = this.model;
|
|
@@ -3019,13 +3022,13 @@ var ReplacementBase = class {
|
|
|
3019
3022
|
|
|
3020
3023
|
// src/legacy/replacements/inline-editing/canvas-inline-editor.tsx
|
|
3021
3024
|
import * as React8 from "react";
|
|
3022
|
-
import { useCallback as useCallback2, useEffect as
|
|
3025
|
+
import { useCallback as useCallback2, useEffect as useEffect10, useLayoutEffect, useState as useState7 } from "react";
|
|
3023
3026
|
import { InlineEditor, InlineEditorToolbar } from "@elementor/editor-controls";
|
|
3024
3027
|
import { Box as Box3, ThemeProvider } from "@elementor/ui";
|
|
3025
3028
|
import { autoUpdate as autoUpdate2, flip, FloatingPortal as FloatingPortal3, useFloating as useFloating2 } from "@floating-ui/react";
|
|
3026
3029
|
|
|
3027
3030
|
// src/legacy/replacements/inline-editing/inline-editing-utils.ts
|
|
3028
|
-
import { useCallback, useEffect as
|
|
3031
|
+
import { useCallback, useEffect as useEffect9, useState as useState6 } from "react";
|
|
3029
3032
|
var TOP_BAR_SELECTOR = "#elementor-editor-wrapper-v2";
|
|
3030
3033
|
var NAVIGATOR_SELECTOR = "#elementor-navigator";
|
|
3031
3034
|
var EDITING_PANEL = "#elementor-panel";
|
|
@@ -3057,7 +3060,7 @@ var getInlineEditorElement = (elementWrapper, expectedTag) => {
|
|
|
3057
3060
|
};
|
|
3058
3061
|
var useOnClickOutsideIframe = (handleUnmount) => {
|
|
3059
3062
|
const asyncUnmountInlineEditor = useCallback(() => queueMicrotask(handleUnmount), [handleUnmount]);
|
|
3060
|
-
|
|
3063
|
+
useEffect9(() => {
|
|
3061
3064
|
EDITOR_ELEMENTS_OUT_OF_IFRAME.forEach(
|
|
3062
3065
|
(selector) => document?.querySelector(selector)?.addEventListener("mousedown", asyncUnmountInlineEditor)
|
|
3063
3066
|
);
|
|
@@ -3067,8 +3070,8 @@ var useOnClickOutsideIframe = (handleUnmount) => {
|
|
|
3067
3070
|
}, []);
|
|
3068
3071
|
};
|
|
3069
3072
|
var useRenderToolbar = (ownerDocument, id) => {
|
|
3070
|
-
const [anchor, setAnchor] =
|
|
3071
|
-
|
|
3073
|
+
const [anchor, setAnchor] = useState6(null);
|
|
3074
|
+
useEffect9(() => {
|
|
3072
3075
|
if (!anchor) {
|
|
3073
3076
|
removeToolbarAnchor(ownerDocument, id);
|
|
3074
3077
|
}
|
|
@@ -3162,10 +3165,10 @@ var CanvasInlineEditor = ({
|
|
|
3162
3165
|
setValue,
|
|
3163
3166
|
requestDestroy
|
|
3164
3167
|
}) => {
|
|
3165
|
-
const [active, setActive] =
|
|
3166
|
-
const [editor, setEditor] =
|
|
3168
|
+
const [active, setActive] = useState7(true);
|
|
3169
|
+
const [editor, setEditor] = useState7(null);
|
|
3167
3170
|
const { onSelectionEnd, anchor: toolbarAnchor, clearAnchor } = useRenderToolbar(rootElement.ownerDocument, id);
|
|
3168
|
-
|
|
3171
|
+
useEffect10(() => {
|
|
3169
3172
|
if (!active) {
|
|
3170
3173
|
clearAnchor();
|
|
3171
3174
|
requestDestroy();
|
|
@@ -3176,7 +3179,7 @@ var CanvasInlineEditor = ({
|
|
|
3176
3179
|
setActive(false);
|
|
3177
3180
|
}, []);
|
|
3178
3181
|
useOnClickOutsideIframe(dismiss);
|
|
3179
|
-
|
|
3182
|
+
useEffect10(() => {
|
|
3180
3183
|
const ownerDocument = contentElement.ownerDocument;
|
|
3181
3184
|
const handleClickAway = (event) => {
|
|
3182
3185
|
if (contentElement.contains(event.target)) {
|
|
@@ -3215,8 +3218,8 @@ var InlineEditingOverlay = ({
|
|
|
3215
3218
|
id
|
|
3216
3219
|
}) => {
|
|
3217
3220
|
const inlineEditedElement = getInlineEditorElement(rootElement, expectedTag);
|
|
3218
|
-
const [overlayRefElement, setOverlayElement] =
|
|
3219
|
-
|
|
3221
|
+
const [overlayRefElement, setOverlayElement] = useState7(inlineEditedElement);
|
|
3222
|
+
useEffect10(() => {
|
|
3220
3223
|
setOverlayElement(getInlineEditorElement(rootElement, expectedTag));
|
|
3221
3224
|
}, [expectedTag, rootElement]);
|
|
3222
3225
|
return overlayRefElement ? /* @__PURE__ */ React8.createElement(OutlineOverlay, { element: overlayRefElement, id, isSelected: true }) : null;
|
|
@@ -6030,18 +6033,18 @@ function getRectClipPath(rect, viewport) {
|
|
|
6030
6033
|
|
|
6031
6034
|
// src/hooks/use-canvas-document.ts
|
|
6032
6035
|
import {
|
|
6033
|
-
__privateUseListenTo as
|
|
6036
|
+
__privateUseListenTo as useListenTo6,
|
|
6034
6037
|
commandEndEvent as commandEndEvent8,
|
|
6035
6038
|
getCanvasIframeDocument as getCanvasIframeDocument5
|
|
6036
6039
|
} from "@elementor/editor-v1-adapters";
|
|
6037
6040
|
function useCanvasDocument() {
|
|
6038
|
-
return
|
|
6041
|
+
return useListenTo6(commandEndEvent8("editor/documents/attach-preview"), () => getCanvasIframeDocument5());
|
|
6039
6042
|
}
|
|
6040
6043
|
|
|
6041
6044
|
// src/hooks/use-escape-on-canvas.ts
|
|
6042
|
-
import { useEffect as
|
|
6045
|
+
import { useEffect as useEffect11 } from "react";
|
|
6043
6046
|
function useEscapeOnCanvas(canvasDocument, onEscape) {
|
|
6044
|
-
|
|
6047
|
+
useEffect11(() => {
|
|
6045
6048
|
if (!canvasDocument) {
|
|
6046
6049
|
return;
|
|
6047
6050
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-canvas",
|
|
3
3
|
"description": "Elementor Editor Canvas",
|
|
4
|
-
"version": "4.2.0-
|
|
4
|
+
"version": "4.2.0-913",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Elementor Team",
|
|
7
7
|
"homepage": "https://elementor.com/",
|
|
@@ -37,25 +37,25 @@
|
|
|
37
37
|
"react-dom": "^18.3.1"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@elementor/editor": "4.2.0-
|
|
40
|
+
"@elementor/editor": "4.2.0-913",
|
|
41
41
|
"dompurify": "^3.2.6",
|
|
42
|
-
"@elementor/editor-controls": "4.2.0-
|
|
43
|
-
"@elementor/editor-documents": "4.2.0-
|
|
44
|
-
"@elementor/editor-elements": "4.2.0-
|
|
45
|
-
"@elementor/editor-interactions": "4.2.0-
|
|
46
|
-
"@elementor/editor-mcp": "4.2.0-
|
|
47
|
-
"@elementor/editor-notifications": "4.2.0-
|
|
48
|
-
"@elementor/editor-props": "4.2.0-
|
|
49
|
-
"@elementor/editor-responsive": "4.2.0-
|
|
50
|
-
"@elementor/editor-styles": "4.2.0-
|
|
51
|
-
"@elementor/editor-styles-repository": "4.2.0-
|
|
52
|
-
"@elementor/editor-ui": "4.2.0-
|
|
53
|
-
"@elementor/editor-v1-adapters": "4.2.0-
|
|
54
|
-
"@elementor/schema": "4.2.0-
|
|
55
|
-
"@elementor/twing": "4.2.0-
|
|
42
|
+
"@elementor/editor-controls": "4.2.0-913",
|
|
43
|
+
"@elementor/editor-documents": "4.2.0-913",
|
|
44
|
+
"@elementor/editor-elements": "4.2.0-913",
|
|
45
|
+
"@elementor/editor-interactions": "4.2.0-913",
|
|
46
|
+
"@elementor/editor-mcp": "4.2.0-913",
|
|
47
|
+
"@elementor/editor-notifications": "4.2.0-913",
|
|
48
|
+
"@elementor/editor-props": "4.2.0-913",
|
|
49
|
+
"@elementor/editor-responsive": "4.2.0-913",
|
|
50
|
+
"@elementor/editor-styles": "4.2.0-913",
|
|
51
|
+
"@elementor/editor-styles-repository": "4.2.0-913",
|
|
52
|
+
"@elementor/editor-ui": "4.2.0-913",
|
|
53
|
+
"@elementor/editor-v1-adapters": "4.2.0-913",
|
|
54
|
+
"@elementor/schema": "4.2.0-913",
|
|
55
|
+
"@elementor/twing": "4.2.0-913",
|
|
56
56
|
"@elementor/ui": "1.37.5",
|
|
57
|
-
"@elementor/utils": "4.2.0-
|
|
58
|
-
"@elementor/wp-media": "4.2.0-
|
|
57
|
+
"@elementor/utils": "4.2.0-913",
|
|
58
|
+
"@elementor/wp-media": "4.2.0-913",
|
|
59
59
|
"@floating-ui/react": "^0.27.5",
|
|
60
60
|
"@wordpress/i18n": "^5.13.0"
|
|
61
61
|
},
|
|
@@ -122,7 +122,7 @@ describe( '<GridOutlineOverlay />', () => {
|
|
|
122
122
|
expect( screen.queryByRole( 'presentation' ) ).not.toBeInTheDocument();
|
|
123
123
|
} );
|
|
124
124
|
|
|
125
|
-
it( 'renders one <
|
|
125
|
+
it( 'renders one <rect> per grid cell', () => {
|
|
126
126
|
mockGridOutlineSetting( null );
|
|
127
127
|
jest.mocked( useGridTracks ).mockReturnValue( {
|
|
128
128
|
...NON_EMPTY_TRACKS,
|
|
@@ -136,7 +136,7 @@ describe( '<GridOutlineOverlay />', () => {
|
|
|
136
136
|
|
|
137
137
|
const overlay = screen.getByRole( 'presentation' );
|
|
138
138
|
// eslint-disable-next-line testing-library/no-node-access
|
|
139
|
-
expect( overlay.querySelectorAll( '
|
|
139
|
+
expect( overlay.querySelectorAll( 'rect' ) ).toHaveLength( 3 * 2 );
|
|
140
140
|
} );
|
|
141
141
|
|
|
142
142
|
it( 'mounts inside the canvas wrapper portal', () => {
|