@elementor/editor-elements 4.4.1 → 4.4.2
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 +5 -35
- package/dist/index.d.ts +5 -35
- package/dist/index.js +22 -105
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -98
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
- package/src/index.ts +0 -7
- package/src/sync/create-element.ts +0 -1
- package/src/sync/create-elements.ts +3 -5
- package/src/sync/delete-element.ts +0 -1
- package/src/sync/duplicate-element.ts +0 -1
- package/src/sync/duplicate-elements.ts +3 -5
- package/src/sync/move-element.ts +0 -1
- package/src/sync/move-elements.ts +2 -5
- package/src/sync/remove-elements.ts +3 -5
- package/src/sync/types.ts +0 -9
- package/src/sync/get-element-widget-markers.ts +0 -41
- package/src/sync/regenerate-local-style-ids.ts +0 -55
package/dist/index.mjs
CHANGED
|
@@ -530,8 +530,7 @@ function deleteElement({ container, options = {} }) {
|
|
|
530
530
|
var createElements = ({
|
|
531
531
|
elements,
|
|
532
532
|
title,
|
|
533
|
-
subtitle = __("Item added", "elementor")
|
|
534
|
-
origin
|
|
533
|
+
subtitle = __("Item added", "elementor")
|
|
535
534
|
}) => {
|
|
536
535
|
const undoableCreate = undoable(
|
|
537
536
|
{
|
|
@@ -545,7 +544,7 @@ var createElements = ({
|
|
|
545
544
|
const element = createElement({
|
|
546
545
|
container: parentContainer,
|
|
547
546
|
...elementParams,
|
|
548
|
-
options: { ...options, useHistory: false
|
|
547
|
+
options: { ...options, useHistory: false }
|
|
549
548
|
});
|
|
550
549
|
createdElements.push({
|
|
551
550
|
container: element,
|
|
@@ -564,7 +563,7 @@ var createElements = ({
|
|
|
564
563
|
if (freshContainer) {
|
|
565
564
|
deleteElement({
|
|
566
565
|
container: freshContainer,
|
|
567
|
-
options: { useHistory: false
|
|
566
|
+
options: { useHistory: false }
|
|
568
567
|
});
|
|
569
568
|
return;
|
|
570
569
|
}
|
|
@@ -579,7 +578,7 @@ var createElements = ({
|
|
|
579
578
|
const element = createElement({
|
|
580
579
|
container: freshParent,
|
|
581
580
|
model,
|
|
582
|
-
options: { ...options, useHistory: false
|
|
581
|
+
options: { ...options, useHistory: false }
|
|
583
582
|
});
|
|
584
583
|
newElements.push({
|
|
585
584
|
container: element,
|
|
@@ -645,8 +644,7 @@ var duplicateElements = ({
|
|
|
645
644
|
title,
|
|
646
645
|
subtitle = __2("Item duplicated", "elementor"),
|
|
647
646
|
onDuplicateElements,
|
|
648
|
-
onRestoreElements
|
|
649
|
-
origin
|
|
647
|
+
onRestoreElements
|
|
650
648
|
}) => {
|
|
651
649
|
const undoableDuplicate = undoable2(
|
|
652
650
|
{
|
|
@@ -660,7 +658,7 @@ var duplicateElements = ({
|
|
|
660
658
|
}
|
|
661
659
|
const duplicatedElement = duplicateElement({
|
|
662
660
|
element: originalContainer,
|
|
663
|
-
options: { useHistory: false
|
|
661
|
+
options: { useHistory: false }
|
|
664
662
|
});
|
|
665
663
|
if (!duplicatedElement.parent) {
|
|
666
664
|
return;
|
|
@@ -683,7 +681,7 @@ var duplicateElements = ({
|
|
|
683
681
|
if (freshContainer) {
|
|
684
682
|
deleteElement({
|
|
685
683
|
container: freshContainer,
|
|
686
|
-
options: { useHistory: false
|
|
684
|
+
options: { useHistory: false }
|
|
687
685
|
});
|
|
688
686
|
return;
|
|
689
687
|
}
|
|
@@ -699,7 +697,7 @@ var duplicateElements = ({
|
|
|
699
697
|
const createdElement = createElement({
|
|
700
698
|
container: freshParent,
|
|
701
699
|
model,
|
|
702
|
-
options: { useHistory: false, clone: false, at
|
|
700
|
+
options: { useHistory: false, clone: false, at }
|
|
703
701
|
});
|
|
704
702
|
duplicatedElements.push({
|
|
705
703
|
container: createdElement,
|
|
@@ -890,74 +888,6 @@ var getElementStyles = (elementID) => {
|
|
|
890
888
|
return container?.model.get("styles") || null;
|
|
891
889
|
};
|
|
892
890
|
|
|
893
|
-
// src/sync/get-element-widget-markers.ts
|
|
894
|
-
import { z } from "@elementor/schema";
|
|
895
|
-
var WIDGET_ID_PATTERN = /^[a-z0-9-]+\/[a-z0-9-]+$/;
|
|
896
|
-
var PART_PATTERN = /^[a-z][a-z0-9_]*$/;
|
|
897
|
-
var MIN_VERSION = 1;
|
|
898
|
-
var WIDGET_MARKER_KEYS = {
|
|
899
|
-
widget: "widget",
|
|
900
|
-
part: "part",
|
|
901
|
-
slot: "slot"
|
|
902
|
-
};
|
|
903
|
-
var widgetMarkerSchema = z.object({
|
|
904
|
-
id: z.string().regex(WIDGET_ID_PATTERN),
|
|
905
|
-
version: z.number().int().min(MIN_VERSION),
|
|
906
|
-
values: z.record(z.unknown()).optional()
|
|
907
|
-
});
|
|
908
|
-
var partSchema = z.string().regex(PART_PATTERN);
|
|
909
|
-
function getContainerWidgetMarker(container) {
|
|
910
|
-
const result = widgetMarkerSchema.safeParse(container?.model.get(WIDGET_MARKER_KEYS.widget));
|
|
911
|
-
if (!result.success) {
|
|
912
|
-
return null;
|
|
913
|
-
}
|
|
914
|
-
return { ...result.data, values: result.data.values ?? {} };
|
|
915
|
-
}
|
|
916
|
-
function getContainerPart(container) {
|
|
917
|
-
const result = partSchema.safeParse(container?.model.get(WIDGET_MARKER_KEYS.part));
|
|
918
|
-
return result.success ? result.data : null;
|
|
919
|
-
}
|
|
920
|
-
function isContainerSlot(container) {
|
|
921
|
-
return true === container?.model.get(WIDGET_MARKER_KEYS.slot) && null !== getContainerPart(container);
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
// src/sync/regenerate-local-style-ids.ts
|
|
925
|
-
import { classesPropTypeUtil } from "@elementor/editor-props";
|
|
926
|
-
function regenerateLocalStyleIds(element) {
|
|
927
|
-
const originalStyles = element.styles;
|
|
928
|
-
if (!originalStyles || Object.keys(originalStyles).length === 0) {
|
|
929
|
-
return { styles: void 0, settings: void 0 };
|
|
930
|
-
}
|
|
931
|
-
const newStyles = {};
|
|
932
|
-
const styleIdMapping = {};
|
|
933
|
-
for (const [originalStyleId, style] of Object.entries(originalStyles)) {
|
|
934
|
-
const newStyleId = generateLocalStyleId(element.id);
|
|
935
|
-
newStyles[newStyleId] = { ...style, id: newStyleId };
|
|
936
|
-
styleIdMapping[originalStyleId] = newStyleId;
|
|
937
|
-
}
|
|
938
|
-
const settings = element.settings;
|
|
939
|
-
if (!settings || Object.keys(settings).length === 0) {
|
|
940
|
-
return { styles: newStyles, settings: void 0 };
|
|
941
|
-
}
|
|
942
|
-
const updatedSettings = { ...settings };
|
|
943
|
-
for (const [propKey, propValue] of Object.entries(updatedSettings)) {
|
|
944
|
-
if (isClassesProp(propValue) && propValue.value.length > 0) {
|
|
945
|
-
const updatedClasses = propValue.value.map((classId) => styleIdMapping[classId] ?? classId);
|
|
946
|
-
updatedSettings[propKey] = classesPropTypeUtil.create(updatedClasses);
|
|
947
|
-
}
|
|
948
|
-
}
|
|
949
|
-
return {
|
|
950
|
-
styles: newStyles,
|
|
951
|
-
settings: updatedSettings
|
|
952
|
-
};
|
|
953
|
-
}
|
|
954
|
-
function isClassesProp(prop) {
|
|
955
|
-
return classesPropTypeUtil.isValid(prop);
|
|
956
|
-
}
|
|
957
|
-
function generateLocalStyleId(elementId) {
|
|
958
|
-
return `e-${elementId}-${generateElementId()}`;
|
|
959
|
-
}
|
|
960
|
-
|
|
961
891
|
// src/sync/get-all-descendants.ts
|
|
962
892
|
function getAllDescendants(container) {
|
|
963
893
|
const children = (container.children ?? []).flatMap((child) => getAllDescendants(child));
|
|
@@ -1033,8 +963,7 @@ var moveElements = ({
|
|
|
1033
963
|
title,
|
|
1034
964
|
subtitle = __3("Elements moved", "elementor"),
|
|
1035
965
|
onMoveElements,
|
|
1036
|
-
onRestoreElements
|
|
1037
|
-
origin
|
|
966
|
+
onRestoreElements
|
|
1038
967
|
}) => {
|
|
1039
968
|
const undoableMove = undoable3(
|
|
1040
969
|
{
|
|
@@ -1058,7 +987,7 @@ var moveElements = ({
|
|
|
1058
987
|
const newElement = moveElement({
|
|
1059
988
|
element: sourceElement,
|
|
1060
989
|
targetContainer: target,
|
|
1061
|
-
options: { ...options, useHistory: false
|
|
990
|
+
options: { ...options, useHistory: false }
|
|
1062
991
|
});
|
|
1063
992
|
movedElements.push({
|
|
1064
993
|
element: newElement,
|
|
@@ -1086,8 +1015,7 @@ var moveElements = ({
|
|
|
1086
1015
|
targetContainer: freshOriginalContainer,
|
|
1087
1016
|
options: {
|
|
1088
1017
|
useHistory: false,
|
|
1089
|
-
at: originalIndex >= 0 ? originalIndex : void 0
|
|
1090
|
-
origin
|
|
1018
|
+
at: originalIndex >= 0 ? originalIndex : void 0
|
|
1091
1019
|
}
|
|
1092
1020
|
});
|
|
1093
1021
|
});
|
|
@@ -1115,7 +1043,7 @@ var moveElements = ({
|
|
|
1115
1043
|
const newElement = moveElement({
|
|
1116
1044
|
element: freshElement,
|
|
1117
1045
|
targetContainer: freshTarget,
|
|
1118
|
-
options: { ...options, useHistory: false
|
|
1046
|
+
options: { ...options, useHistory: false }
|
|
1119
1047
|
});
|
|
1120
1048
|
newMovedElements.push({
|
|
1121
1049
|
element: newElement,
|
|
@@ -1148,8 +1076,7 @@ var removeElements = ({
|
|
|
1148
1076
|
title,
|
|
1149
1077
|
subtitle = __4("Item removed", "elementor"),
|
|
1150
1078
|
onRemoveElements,
|
|
1151
|
-
onRestoreElements
|
|
1152
|
-
origin
|
|
1079
|
+
onRestoreElements
|
|
1153
1080
|
}) => {
|
|
1154
1081
|
const undoableRemove = undoable4(
|
|
1155
1082
|
{
|
|
@@ -1172,7 +1099,7 @@ var removeElements = ({
|
|
|
1172
1099
|
removedElements.forEach(({ container }) => {
|
|
1173
1100
|
deleteElement({
|
|
1174
1101
|
container,
|
|
1175
|
-
options: { useHistory: false
|
|
1102
|
+
options: { useHistory: false }
|
|
1176
1103
|
});
|
|
1177
1104
|
});
|
|
1178
1105
|
return { removedElements };
|
|
@@ -1185,7 +1112,7 @@ var removeElements = ({
|
|
|
1185
1112
|
createElement({
|
|
1186
1113
|
container: freshParent,
|
|
1187
1114
|
model,
|
|
1188
|
-
options: { useHistory: false, at
|
|
1115
|
+
options: { useHistory: false, at }
|
|
1189
1116
|
});
|
|
1190
1117
|
return;
|
|
1191
1118
|
}
|
|
@@ -1201,7 +1128,7 @@ var removeElements = ({
|
|
|
1201
1128
|
if (freshContainer && freshParent) {
|
|
1202
1129
|
deleteElement({
|
|
1203
1130
|
container: freshContainer,
|
|
1204
|
-
options: { useHistory: false
|
|
1131
|
+
options: { useHistory: false }
|
|
1205
1132
|
});
|
|
1206
1133
|
newRemovedElements.push({
|
|
1207
1134
|
container: freshContainer,
|
|
@@ -1419,13 +1346,13 @@ var styleRerenderEvents = [
|
|
|
1419
1346
|
];
|
|
1420
1347
|
|
|
1421
1348
|
// src/styles/create-element-style.ts
|
|
1422
|
-
import { classesPropTypeUtil as
|
|
1349
|
+
import { classesPropTypeUtil as classesPropTypeUtil2 } from "@elementor/editor-props";
|
|
1423
1350
|
import {
|
|
1424
1351
|
generateId
|
|
1425
1352
|
} from "@elementor/editor-styles";
|
|
1426
1353
|
|
|
1427
1354
|
// src/styles/mutate-element-styles.ts
|
|
1428
|
-
import { classesPropTypeUtil
|
|
1355
|
+
import { classesPropTypeUtil } from "@elementor/editor-props";
|
|
1429
1356
|
import { __privateRunCommandSync as runCommandSync7 } from "@elementor/editor-v1-adapters";
|
|
1430
1357
|
function mutateElementStyles(elementId, mutator) {
|
|
1431
1358
|
const container = getContainer(elementId);
|
|
@@ -1480,7 +1407,7 @@ function clearRemovedClasses(container, { oldIds, newIds }) {
|
|
|
1480
1407
|
function getClassesProps(container) {
|
|
1481
1408
|
return Object.entries(container.settings.toJSON()).filter((prop) => {
|
|
1482
1409
|
const [, value] = prop;
|
|
1483
|
-
return
|
|
1410
|
+
return classesPropTypeUtil.isValid(value);
|
|
1484
1411
|
});
|
|
1485
1412
|
}
|
|
1486
1413
|
function notifyChanges() {
|
|
@@ -1519,7 +1446,7 @@ function createElementStyle({
|
|
|
1519
1446
|
}
|
|
1520
1447
|
function addStyleToClassesProp(elementId, classesProp, styleId) {
|
|
1521
1448
|
const base = getElementSetting(elementId, classesProp);
|
|
1522
|
-
const classesPropValue =
|
|
1449
|
+
const classesPropValue = classesPropTypeUtil2.create(
|
|
1523
1450
|
(prev) => {
|
|
1524
1451
|
return [...prev ?? [], styleId];
|
|
1525
1452
|
},
|
|
@@ -1640,7 +1567,6 @@ var playElementInteractions = (elementId, interactionId) => {
|
|
|
1640
1567
|
export {
|
|
1641
1568
|
DEFAULT_STYLE_CLASS_PREFIX,
|
|
1642
1569
|
ELEMENT_STYLE_CHANGE_EVENT,
|
|
1643
|
-
WIDGET_MARKER_KEYS,
|
|
1644
1570
|
addModelToParent,
|
|
1645
1571
|
bindSettingsReconcile,
|
|
1646
1572
|
cloneElementTree,
|
|
@@ -1661,8 +1587,6 @@ export {
|
|
|
1661
1587
|
getAnchoredAncestorId,
|
|
1662
1588
|
getAnchoredDescendantId,
|
|
1663
1589
|
getContainer,
|
|
1664
|
-
getContainerPart,
|
|
1665
|
-
getContainerWidgetMarker,
|
|
1666
1590
|
getCurrentDocumentContainer,
|
|
1667
1591
|
getCurrentDocumentId,
|
|
1668
1592
|
getDefaultStyleTagFromPreviewElement,
|
|
@@ -1683,14 +1607,12 @@ export {
|
|
|
1683
1607
|
getPreviewElementDOM,
|
|
1684
1608
|
getSelectedElements,
|
|
1685
1609
|
getWidgetsCache,
|
|
1686
|
-
isContainerSlot,
|
|
1687
1610
|
isElementAnchored,
|
|
1688
1611
|
moveElement,
|
|
1689
1612
|
moveElements,
|
|
1690
1613
|
parseDefaultStyleTagFromClassList,
|
|
1691
1614
|
playElementInteractions,
|
|
1692
1615
|
reconcileInitialChildren,
|
|
1693
|
-
regenerateLocalStyleIds,
|
|
1694
1616
|
removeElements,
|
|
1695
1617
|
removeModelFromParent,
|
|
1696
1618
|
replaceElement,
|