@elementor/editor-elements 4.5.0-1173 → 4.5.0-1174

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 CHANGED
@@ -218,6 +218,13 @@ type V1ElementModelProps = {
218
218
  isGlobal?: boolean;
219
219
  skipDefaultChildren?: boolean;
220
220
  hydrateDefaultChildren?: boolean;
221
+ widget?: V1ElementWidgetMarker;
222
+ part?: string;
223
+ };
224
+ type V1ElementWidgetMarker = {
225
+ id: string;
226
+ version: number;
227
+ values?: Record<string, unknown>;
221
228
  };
222
229
  type V1ElementData = Omit<V1ElementModelProps, 'elements'> & {
223
230
  elements?: V1ElementData[];
@@ -467,6 +474,14 @@ declare const getElementStyles: (elementID: ElementID) => Record<string, StyleDe
467
474
 
468
475
  declare function getElementType(type: string): ElementType | null;
469
476
 
477
+ declare function getElementWidgetMarker(elementId: ElementID): Required<V1ElementWidgetMarker> | null;
478
+ declare function getElementPart(elementId: ElementID): string | null;
479
+
480
+ declare function regenerateLocalStyleIds(element: V1ElementData): {
481
+ styles: Record<StyleDefinitionID, StyleDefinition> | undefined;
482
+ settings: V1ElementSettingsProps | undefined;
483
+ };
484
+
470
485
  declare function getAllDescendants(container: V1Element): V1Element[];
471
486
 
472
487
  type V1Model = V1Element['model'];
@@ -629,4 +644,4 @@ declare const updateElementInteractions: ({ elementId, interactions, }: {
629
644
  }) => void;
630
645
  declare const playElementInteractions: (elementId: string, interactionId: string) => void;
631
646
 
632
- export { type AnimationPresetPropValue, type BackboneCollection, type BackboneModel, type BooleanPropValue, type ChildDependenciesConfig, type ChildDependencyRule, type ConfigPropValue, type Control, type ControlItem, type ControlLayout, type ControlsSection, type CreateElementParams, type CreateElementStyleArgs, DEFAULT_STYLE_CLASS_PREFIX, type DropElementParams, type DuplicateElementParams, type DuplicateElementsParams, type DuplicatedElement, type DuplicatedElementsResult, ELEMENT_STYLE_CHANGE_EVENT, type Element, type ElementChildren, type ElementControl, type ElementID, type ElementInteractions, type ElementModel, type ElementPosition, type ElementPositionKind, type ElementType, type ExcludedBreakpointsPropValue, type ExtendedWindow, type InteractionBreakpointsPropValue, type InteractionItemPropValue, type LinkInLinkRestriction, type ModelResult, type MoveElementParams, type NumberPropValue, type PseudoState, type StringPropValue, type TimingConfigPropValue, type UpdateElementSettingsArgs, type UpdateElementStyleArgs, type UseElementChildrenOptions, type V1Element, type V1ElementConfig, type V1ElementData, type V1ElementEditorSettingsProps, type V1ElementModelProps, type V1ElementSettingsProps, addModelToParent, bindSettingsReconcile, cloneElementTree, createElement, createElementStyle, createElements, deleteElement, deleteElementStyle, dropElement, duplicateElement, duplicateElements, evaluateWhen, findChildRecursive, findClosestContainer, findModelInDocument, generateElementId, getAllDescendants, getAnchoredAncestorId, getAnchoredDescendantId, getContainer, getCurrentDocumentContainer, getCurrentDocumentId, getDefaultStyleTagFromPreviewElement, getElementChildren as getElementChildrenWithFallback, getElementEditorSettings, getElementIcon, getElementInteractions, getElementLabel, getElementSetting, getElementSettings, getElementStyles, getElementTitle, getElementType, getElements, getHostDocumentElements, getHostDocumentId, getLinkInLinkRestriction, getPreviewElementDOM, getSelectedElements, getWidgetsCache, isElementAnchored, moveElement, moveElements, parseDefaultStyleTagFromClassList, playElementInteractions, reconcileInitialChildren, removeElements, removeModelFromParent, replaceElement, resolveContainer, resolveInsertIndex, selectElement, shouldCreateNewLocalStyle, styleRerenderEvents, updateElementEditorSettings, updateElementInteractions, updateElementSettings, updateElementStyle, useElementChildren, useElementEditorSettings, useParentElement, useSelectedElement, useSelectedElementSettings };
647
+ export { type AnimationPresetPropValue, type BackboneCollection, type BackboneModel, type BooleanPropValue, type ChildDependenciesConfig, type ChildDependencyRule, type ConfigPropValue, type Control, type ControlItem, type ControlLayout, type ControlsSection, type CreateElementParams, type CreateElementStyleArgs, DEFAULT_STYLE_CLASS_PREFIX, type DropElementParams, type DuplicateElementParams, type DuplicateElementsParams, type DuplicatedElement, type DuplicatedElementsResult, ELEMENT_STYLE_CHANGE_EVENT, type Element, type ElementChildren, type ElementControl, type ElementID, type ElementInteractions, type ElementModel, type ElementPosition, type ElementPositionKind, type ElementType, type ExcludedBreakpointsPropValue, type ExtendedWindow, type InteractionBreakpointsPropValue, type InteractionItemPropValue, type LinkInLinkRestriction, type ModelResult, type MoveElementParams, type NumberPropValue, type PseudoState, type StringPropValue, type TimingConfigPropValue, type UpdateElementSettingsArgs, type UpdateElementStyleArgs, type UseElementChildrenOptions, type V1Element, type V1ElementConfig, type V1ElementData, type V1ElementEditorSettingsProps, type V1ElementModelProps, type V1ElementSettingsProps, type V1ElementWidgetMarker, addModelToParent, bindSettingsReconcile, cloneElementTree, createElement, createElementStyle, createElements, deleteElement, deleteElementStyle, dropElement, duplicateElement, duplicateElements, evaluateWhen, findChildRecursive, findClosestContainer, findModelInDocument, generateElementId, getAllDescendants, getAnchoredAncestorId, getAnchoredDescendantId, getContainer, getCurrentDocumentContainer, getCurrentDocumentId, getDefaultStyleTagFromPreviewElement, getElementChildren as getElementChildrenWithFallback, getElementEditorSettings, getElementIcon, getElementInteractions, getElementLabel, getElementPart, getElementSetting, getElementSettings, getElementStyles, getElementTitle, getElementType, getElementWidgetMarker, getElements, getHostDocumentElements, getHostDocumentId, getLinkInLinkRestriction, getPreviewElementDOM, getSelectedElements, getWidgetsCache, isElementAnchored, moveElement, moveElements, parseDefaultStyleTagFromClassList, playElementInteractions, reconcileInitialChildren, regenerateLocalStyleIds, removeElements, removeModelFromParent, replaceElement, resolveContainer, resolveInsertIndex, selectElement, shouldCreateNewLocalStyle, styleRerenderEvents, updateElementEditorSettings, updateElementInteractions, updateElementSettings, updateElementStyle, useElementChildren, useElementEditorSettings, useParentElement, useSelectedElement, useSelectedElementSettings };
package/dist/index.d.ts CHANGED
@@ -218,6 +218,13 @@ type V1ElementModelProps = {
218
218
  isGlobal?: boolean;
219
219
  skipDefaultChildren?: boolean;
220
220
  hydrateDefaultChildren?: boolean;
221
+ widget?: V1ElementWidgetMarker;
222
+ part?: string;
223
+ };
224
+ type V1ElementWidgetMarker = {
225
+ id: string;
226
+ version: number;
227
+ values?: Record<string, unknown>;
221
228
  };
222
229
  type V1ElementData = Omit<V1ElementModelProps, 'elements'> & {
223
230
  elements?: V1ElementData[];
@@ -467,6 +474,14 @@ declare const getElementStyles: (elementID: ElementID) => Record<string, StyleDe
467
474
 
468
475
  declare function getElementType(type: string): ElementType | null;
469
476
 
477
+ declare function getElementWidgetMarker(elementId: ElementID): Required<V1ElementWidgetMarker> | null;
478
+ declare function getElementPart(elementId: ElementID): string | null;
479
+
480
+ declare function regenerateLocalStyleIds(element: V1ElementData): {
481
+ styles: Record<StyleDefinitionID, StyleDefinition> | undefined;
482
+ settings: V1ElementSettingsProps | undefined;
483
+ };
484
+
470
485
  declare function getAllDescendants(container: V1Element): V1Element[];
471
486
 
472
487
  type V1Model = V1Element['model'];
@@ -629,4 +644,4 @@ declare const updateElementInteractions: ({ elementId, interactions, }: {
629
644
  }) => void;
630
645
  declare const playElementInteractions: (elementId: string, interactionId: string) => void;
631
646
 
632
- export { type AnimationPresetPropValue, type BackboneCollection, type BackboneModel, type BooleanPropValue, type ChildDependenciesConfig, type ChildDependencyRule, type ConfigPropValue, type Control, type ControlItem, type ControlLayout, type ControlsSection, type CreateElementParams, type CreateElementStyleArgs, DEFAULT_STYLE_CLASS_PREFIX, type DropElementParams, type DuplicateElementParams, type DuplicateElementsParams, type DuplicatedElement, type DuplicatedElementsResult, ELEMENT_STYLE_CHANGE_EVENT, type Element, type ElementChildren, type ElementControl, type ElementID, type ElementInteractions, type ElementModel, type ElementPosition, type ElementPositionKind, type ElementType, type ExcludedBreakpointsPropValue, type ExtendedWindow, type InteractionBreakpointsPropValue, type InteractionItemPropValue, type LinkInLinkRestriction, type ModelResult, type MoveElementParams, type NumberPropValue, type PseudoState, type StringPropValue, type TimingConfigPropValue, type UpdateElementSettingsArgs, type UpdateElementStyleArgs, type UseElementChildrenOptions, type V1Element, type V1ElementConfig, type V1ElementData, type V1ElementEditorSettingsProps, type V1ElementModelProps, type V1ElementSettingsProps, addModelToParent, bindSettingsReconcile, cloneElementTree, createElement, createElementStyle, createElements, deleteElement, deleteElementStyle, dropElement, duplicateElement, duplicateElements, evaluateWhen, findChildRecursive, findClosestContainer, findModelInDocument, generateElementId, getAllDescendants, getAnchoredAncestorId, getAnchoredDescendantId, getContainer, getCurrentDocumentContainer, getCurrentDocumentId, getDefaultStyleTagFromPreviewElement, getElementChildren as getElementChildrenWithFallback, getElementEditorSettings, getElementIcon, getElementInteractions, getElementLabel, getElementSetting, getElementSettings, getElementStyles, getElementTitle, getElementType, getElements, getHostDocumentElements, getHostDocumentId, getLinkInLinkRestriction, getPreviewElementDOM, getSelectedElements, getWidgetsCache, isElementAnchored, moveElement, moveElements, parseDefaultStyleTagFromClassList, playElementInteractions, reconcileInitialChildren, removeElements, removeModelFromParent, replaceElement, resolveContainer, resolveInsertIndex, selectElement, shouldCreateNewLocalStyle, styleRerenderEvents, updateElementEditorSettings, updateElementInteractions, updateElementSettings, updateElementStyle, useElementChildren, useElementEditorSettings, useParentElement, useSelectedElement, useSelectedElementSettings };
647
+ export { type AnimationPresetPropValue, type BackboneCollection, type BackboneModel, type BooleanPropValue, type ChildDependenciesConfig, type ChildDependencyRule, type ConfigPropValue, type Control, type ControlItem, type ControlLayout, type ControlsSection, type CreateElementParams, type CreateElementStyleArgs, DEFAULT_STYLE_CLASS_PREFIX, type DropElementParams, type DuplicateElementParams, type DuplicateElementsParams, type DuplicatedElement, type DuplicatedElementsResult, ELEMENT_STYLE_CHANGE_EVENT, type Element, type ElementChildren, type ElementControl, type ElementID, type ElementInteractions, type ElementModel, type ElementPosition, type ElementPositionKind, type ElementType, type ExcludedBreakpointsPropValue, type ExtendedWindow, type InteractionBreakpointsPropValue, type InteractionItemPropValue, type LinkInLinkRestriction, type ModelResult, type MoveElementParams, type NumberPropValue, type PseudoState, type StringPropValue, type TimingConfigPropValue, type UpdateElementSettingsArgs, type UpdateElementStyleArgs, type UseElementChildrenOptions, type V1Element, type V1ElementConfig, type V1ElementData, type V1ElementEditorSettingsProps, type V1ElementModelProps, type V1ElementSettingsProps, type V1ElementWidgetMarker, addModelToParent, bindSettingsReconcile, cloneElementTree, createElement, createElementStyle, createElements, deleteElement, deleteElementStyle, dropElement, duplicateElement, duplicateElements, evaluateWhen, findChildRecursive, findClosestContainer, findModelInDocument, generateElementId, getAllDescendants, getAnchoredAncestorId, getAnchoredDescendantId, getContainer, getCurrentDocumentContainer, getCurrentDocumentId, getDefaultStyleTagFromPreviewElement, getElementChildren as getElementChildrenWithFallback, getElementEditorSettings, getElementIcon, getElementInteractions, getElementLabel, getElementPart, getElementSetting, getElementSettings, getElementStyles, getElementTitle, getElementType, getElementWidgetMarker, getElements, getHostDocumentElements, getHostDocumentId, getLinkInLinkRestriction, getPreviewElementDOM, getSelectedElements, getWidgetsCache, isElementAnchored, moveElement, moveElements, parseDefaultStyleTagFromClassList, playElementInteractions, reconcileInitialChildren, regenerateLocalStyleIds, removeElements, removeModelFromParent, replaceElement, resolveContainer, resolveInsertIndex, selectElement, shouldCreateNewLocalStyle, styleRerenderEvents, updateElementEditorSettings, updateElementInteractions, updateElementSettings, updateElementStyle, useElementChildren, useElementEditorSettings, useParentElement, useSelectedElement, useSelectedElementSettings };
package/dist/index.js CHANGED
@@ -50,11 +50,13 @@ __export(index_exports, {
50
50
  getElementIcon: () => getElementIcon,
51
51
  getElementInteractions: () => getElementInteractions,
52
52
  getElementLabel: () => getElementLabel,
53
+ getElementPart: () => getElementPart,
53
54
  getElementSetting: () => getElementSetting,
54
55
  getElementSettings: () => getElementSettings,
55
56
  getElementStyles: () => getElementStyles,
56
57
  getElementTitle: () => getElementTitle,
57
58
  getElementType: () => getElementType,
59
+ getElementWidgetMarker: () => getElementWidgetMarker,
58
60
  getElements: () => getElements,
59
61
  getHostDocumentElements: () => getHostDocumentElements,
60
62
  getHostDocumentId: () => getHostDocumentId,
@@ -68,6 +70,7 @@ __export(index_exports, {
68
70
  parseDefaultStyleTagFromClassList: () => parseDefaultStyleTagFromClassList,
69
71
  playElementInteractions: () => playElementInteractions,
70
72
  reconcileInitialChildren: () => reconcileInitialChildren,
73
+ regenerateLocalStyleIds: () => regenerateLocalStyleIds,
71
74
  removeElements: () => removeElements,
72
75
  removeModelFromParent: () => removeModelFromParent,
73
76
  replaceElement: () => replaceElement,
@@ -978,6 +981,66 @@ var getElementStyles = (elementID) => {
978
981
  return container?.model.get("styles") || null;
979
982
  };
980
983
 
984
+ // src/sync/get-element-widget-markers.ts
985
+ var import_schema = require("@elementor/schema");
986
+ var WIDGET_ID_PATTERN = /^[a-z0-9-]+\/[a-z0-9-]+$/;
987
+ var PART_PATTERN = /^[a-z][a-z0-9_]*$/;
988
+ var MIN_VERSION = 1;
989
+ var widgetMarkerSchema = import_schema.z.object({
990
+ id: import_schema.z.string().regex(WIDGET_ID_PATTERN),
991
+ version: import_schema.z.number().int().min(MIN_VERSION),
992
+ values: import_schema.z.record(import_schema.z.unknown()).optional()
993
+ });
994
+ var partSchema = import_schema.z.string().regex(PART_PATTERN);
995
+ function getElementWidgetMarker(elementId) {
996
+ const result = widgetMarkerSchema.safeParse(getContainer(elementId)?.model.get("widget"));
997
+ if (!result.success) {
998
+ return null;
999
+ }
1000
+ return { ...result.data, values: result.data.values ?? {} };
1001
+ }
1002
+ function getElementPart(elementId) {
1003
+ const result = partSchema.safeParse(getContainer(elementId)?.model.get("part"));
1004
+ return result.success ? result.data : null;
1005
+ }
1006
+
1007
+ // src/sync/regenerate-local-style-ids.ts
1008
+ var import_editor_props2 = require("@elementor/editor-props");
1009
+ function regenerateLocalStyleIds(element) {
1010
+ const originalStyles = element.styles;
1011
+ if (!originalStyles || Object.keys(originalStyles).length === 0) {
1012
+ return { styles: void 0, settings: void 0 };
1013
+ }
1014
+ const newStyles = {};
1015
+ const styleIdMapping = {};
1016
+ for (const [originalStyleId, style] of Object.entries(originalStyles)) {
1017
+ const newStyleId = generateLocalStyleId(element.id);
1018
+ newStyles[newStyleId] = { ...style, id: newStyleId };
1019
+ styleIdMapping[originalStyleId] = newStyleId;
1020
+ }
1021
+ const settings = element.settings;
1022
+ if (!settings || Object.keys(settings).length === 0) {
1023
+ return { styles: newStyles, settings: void 0 };
1024
+ }
1025
+ const updatedSettings = { ...settings };
1026
+ for (const [propKey, propValue] of Object.entries(updatedSettings)) {
1027
+ if (isClassesProp(propValue) && propValue.value.length > 0) {
1028
+ const updatedClasses = propValue.value.map((classId) => styleIdMapping[classId] ?? classId);
1029
+ updatedSettings[propKey] = import_editor_props2.classesPropTypeUtil.create(updatedClasses);
1030
+ }
1031
+ }
1032
+ return {
1033
+ styles: newStyles,
1034
+ settings: updatedSettings
1035
+ };
1036
+ }
1037
+ function isClassesProp(prop) {
1038
+ return import_editor_props2.classesPropTypeUtil.isValid(prop);
1039
+ }
1040
+ function generateLocalStyleId(elementId) {
1041
+ return `e-${elementId}-${generateElementId()}`;
1042
+ }
1043
+
981
1044
  // src/sync/get-all-descendants.ts
982
1045
  function getAllDescendants(container) {
983
1046
  const children = (container.children ?? []).flatMap((child) => getAllDescendants(child));
@@ -1436,11 +1499,11 @@ var styleRerenderEvents = [
1436
1499
  ];
1437
1500
 
1438
1501
  // src/styles/create-element-style.ts
1439
- var import_editor_props3 = require("@elementor/editor-props");
1502
+ var import_editor_props4 = require("@elementor/editor-props");
1440
1503
  var import_editor_styles = require("@elementor/editor-styles");
1441
1504
 
1442
1505
  // src/styles/mutate-element-styles.ts
1443
- var import_editor_props2 = require("@elementor/editor-props");
1506
+ var import_editor_props3 = require("@elementor/editor-props");
1444
1507
  var import_editor_v1_adapters18 = require("@elementor/editor-v1-adapters");
1445
1508
  function mutateElementStyles(elementId, mutator) {
1446
1509
  const container = getContainer(elementId);
@@ -1495,7 +1558,7 @@ function clearRemovedClasses(container, { oldIds, newIds }) {
1495
1558
  function getClassesProps(container) {
1496
1559
  return Object.entries(container.settings.toJSON()).filter((prop) => {
1497
1560
  const [, value] = prop;
1498
- return import_editor_props2.classesPropTypeUtil.isValid(value);
1561
+ return import_editor_props3.classesPropTypeUtil.isValid(value);
1499
1562
  });
1500
1563
  }
1501
1564
  function notifyChanges() {
@@ -1534,7 +1597,7 @@ function createElementStyle({
1534
1597
  }
1535
1598
  function addStyleToClassesProp(elementId, classesProp, styleId) {
1536
1599
  const base = getElementSetting(elementId, classesProp);
1537
- const classesPropValue = import_editor_props3.classesPropTypeUtil.create(
1600
+ const classesPropValue = import_editor_props4.classesPropTypeUtil.create(
1538
1601
  (prev) => {
1539
1602
  return [...prev ?? [], styleId];
1540
1603
  },
@@ -1561,7 +1624,7 @@ function deleteElementStyle(elementId, styleId) {
1561
1624
  }
1562
1625
 
1563
1626
  // src/styles/update-element-style.ts
1564
- var import_editor_props4 = require("@elementor/editor-props");
1627
+ var import_editor_props5 = require("@elementor/editor-props");
1565
1628
  var import_editor_styles2 = require("@elementor/editor-styles");
1566
1629
  function updateElementStyle(args) {
1567
1630
  mutateElementStyles(args.elementId, (styles) => {
@@ -1572,7 +1635,7 @@ function updateElementStyle(args) {
1572
1635
  const variant = (0, import_editor_styles2.getVariantByMeta)(style, args.meta);
1573
1636
  const customCss = ("custom_css" in args ? args.custom_css : variant?.custom_css) ?? null;
1574
1637
  if (variant) {
1575
- variant.props = (0, import_editor_props4.mergeProps)(variant.props, args.props);
1638
+ variant.props = (0, import_editor_props5.mergeProps)(variant.props, args.props);
1576
1639
  variant.custom_css = customCss?.raw ? customCss : null;
1577
1640
  } else {
1578
1641
  style.variants.push({ meta: args.meta, props: args.props, custom_css: customCss });
@@ -1684,11 +1747,13 @@ var playElementInteractions = (elementId, interactionId) => {
1684
1747
  getElementIcon,
1685
1748
  getElementInteractions,
1686
1749
  getElementLabel,
1750
+ getElementPart,
1687
1751
  getElementSetting,
1688
1752
  getElementSettings,
1689
1753
  getElementStyles,
1690
1754
  getElementTitle,
1691
1755
  getElementType,
1756
+ getElementWidgetMarker,
1692
1757
  getElements,
1693
1758
  getHostDocumentElements,
1694
1759
  getHostDocumentId,
@@ -1702,6 +1767,7 @@ var playElementInteractions = (elementId, interactionId) => {
1702
1767
  parseDefaultStyleTagFromClassList,
1703
1768
  playElementInteractions,
1704
1769
  reconcileInitialChildren,
1770
+ regenerateLocalStyleIds,
1705
1771
  removeElements,
1706
1772
  removeModelFromParent,
1707
1773
  replaceElement,