@elementor/editor-elements 4.4.0-1112 → 4.4.0-1114
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 +13 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.js +53 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +50 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
- package/src/index.ts +3 -1
- package/src/sync/clone-element-tree.ts +24 -0
- package/src/sync/get-elements.ts +12 -3
- package/src/sync/get-host-document-container.ts +13 -0
- package/src/sync/get-host-document-id.ts +11 -0
- package/src/sync/resolve-element.ts +1 -1
- package/src/sync/types.ts +11 -1
package/dist/index.d.mts
CHANGED
|
@@ -75,6 +75,7 @@ type ExtendedWindow = Window & {
|
|
|
75
75
|
findModelById?: (id: string, collection?: unknown) => BackboneModel | null;
|
|
76
76
|
addModelToParent?: (parentId: string, childData: unknown, options?: {
|
|
77
77
|
at?: number;
|
|
78
|
+
clone?: boolean;
|
|
78
79
|
}) => boolean;
|
|
79
80
|
removeModelFromParent?: (parentId: string, childId: string) => boolean;
|
|
80
81
|
};
|
|
@@ -91,6 +92,10 @@ type ExtendedWindow = Window & {
|
|
|
91
92
|
container: V1Element;
|
|
92
93
|
} | undefined;
|
|
93
94
|
getCurrentId?: () => number;
|
|
95
|
+
getInitialId?: () => number;
|
|
96
|
+
get?: (id: number) => {
|
|
97
|
+
container: V1Element;
|
|
98
|
+
} | undefined;
|
|
94
99
|
};
|
|
95
100
|
getContainer?: (id: string) => V1Element | undefined;
|
|
96
101
|
getPreviewContainer?: () => V1Element | undefined;
|
|
@@ -422,6 +427,9 @@ type DuplicatedElementsResult = {
|
|
|
422
427
|
|
|
423
428
|
declare const duplicateElements: ({ elementIds, title, subtitle, onDuplicateElements, onRestoreElements, }: DuplicateElementsParams) => DuplicatedElementsResult;
|
|
424
429
|
|
|
430
|
+
type CloneableElement = Partial<V1ElementModelProps> | BackboneModel;
|
|
431
|
+
declare function cloneElementTree(item: CloneableElement): V1ElementModelProps;
|
|
432
|
+
|
|
425
433
|
declare const generateElementId: () => string;
|
|
426
434
|
|
|
427
435
|
declare function getContainer(id: string): V1Element | null;
|
|
@@ -433,6 +441,7 @@ declare function resolveContainer(container: V1Element, id: string): V1Element |
|
|
|
433
441
|
declare function findModelInDocument(id: string): BackboneModel | null;
|
|
434
442
|
declare function addModelToParent(parentId: string, childData: V1ElementModelProps, options?: {
|
|
435
443
|
at?: number;
|
|
444
|
+
clone?: boolean;
|
|
436
445
|
}): boolean;
|
|
437
446
|
declare function removeModelFromParent(parentId: string, childId: string): boolean;
|
|
438
447
|
|
|
@@ -465,6 +474,9 @@ declare function findChildRecursive(model: V1Model, predicate: (model: V1Model)
|
|
|
465
474
|
declare function getElementChildren(model: V1Model, predicate?: (model: V1Model) => boolean): ModelResult[];
|
|
466
475
|
|
|
467
476
|
declare function getElements(root?: ElementID): V1Element[];
|
|
477
|
+
declare function getHostDocumentElements(): V1Element[];
|
|
478
|
+
|
|
479
|
+
declare function getHostDocumentId(): number | null;
|
|
468
480
|
|
|
469
481
|
declare function getSelectedElements(): Element[];
|
|
470
482
|
|
|
@@ -614,4 +626,4 @@ declare const updateElementInteractions: ({ elementId, interactions, }: {
|
|
|
614
626
|
}) => void;
|
|
615
627
|
declare const playElementInteractions: (elementId: string, interactionId: string) => void;
|
|
616
628
|
|
|
617
|
-
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, createElement, createElementStyle, createElements, deleteElement, deleteElementStyle, dropElement, duplicateElement, duplicateElements, evaluateWhen, findChildRecursive, findModelInDocument, generateElementId, getAllDescendants, getAnchoredAncestorId, getAnchoredDescendantId, getContainer, getCurrentDocumentContainer, getCurrentDocumentId, getDefaultStyleTagFromPreviewElement, getElementChildren as getElementChildrenWithFallback, getElementEditorSettings, getElementIcon, getElementInteractions, getElementLabel, getElementSetting, getElementSettings, getElementStyles, getElementTitle, getElementType, getElements, 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 };
|
|
629
|
+
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, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -75,6 +75,7 @@ type ExtendedWindow = Window & {
|
|
|
75
75
|
findModelById?: (id: string, collection?: unknown) => BackboneModel | null;
|
|
76
76
|
addModelToParent?: (parentId: string, childData: unknown, options?: {
|
|
77
77
|
at?: number;
|
|
78
|
+
clone?: boolean;
|
|
78
79
|
}) => boolean;
|
|
79
80
|
removeModelFromParent?: (parentId: string, childId: string) => boolean;
|
|
80
81
|
};
|
|
@@ -91,6 +92,10 @@ type ExtendedWindow = Window & {
|
|
|
91
92
|
container: V1Element;
|
|
92
93
|
} | undefined;
|
|
93
94
|
getCurrentId?: () => number;
|
|
95
|
+
getInitialId?: () => number;
|
|
96
|
+
get?: (id: number) => {
|
|
97
|
+
container: V1Element;
|
|
98
|
+
} | undefined;
|
|
94
99
|
};
|
|
95
100
|
getContainer?: (id: string) => V1Element | undefined;
|
|
96
101
|
getPreviewContainer?: () => V1Element | undefined;
|
|
@@ -422,6 +427,9 @@ type DuplicatedElementsResult = {
|
|
|
422
427
|
|
|
423
428
|
declare const duplicateElements: ({ elementIds, title, subtitle, onDuplicateElements, onRestoreElements, }: DuplicateElementsParams) => DuplicatedElementsResult;
|
|
424
429
|
|
|
430
|
+
type CloneableElement = Partial<V1ElementModelProps> | BackboneModel;
|
|
431
|
+
declare function cloneElementTree(item: CloneableElement): V1ElementModelProps;
|
|
432
|
+
|
|
425
433
|
declare const generateElementId: () => string;
|
|
426
434
|
|
|
427
435
|
declare function getContainer(id: string): V1Element | null;
|
|
@@ -433,6 +441,7 @@ declare function resolveContainer(container: V1Element, id: string): V1Element |
|
|
|
433
441
|
declare function findModelInDocument(id: string): BackboneModel | null;
|
|
434
442
|
declare function addModelToParent(parentId: string, childData: V1ElementModelProps, options?: {
|
|
435
443
|
at?: number;
|
|
444
|
+
clone?: boolean;
|
|
436
445
|
}): boolean;
|
|
437
446
|
declare function removeModelFromParent(parentId: string, childId: string): boolean;
|
|
438
447
|
|
|
@@ -465,6 +474,9 @@ declare function findChildRecursive(model: V1Model, predicate: (model: V1Model)
|
|
|
465
474
|
declare function getElementChildren(model: V1Model, predicate?: (model: V1Model) => boolean): ModelResult[];
|
|
466
475
|
|
|
467
476
|
declare function getElements(root?: ElementID): V1Element[];
|
|
477
|
+
declare function getHostDocumentElements(): V1Element[];
|
|
478
|
+
|
|
479
|
+
declare function getHostDocumentId(): number | null;
|
|
468
480
|
|
|
469
481
|
declare function getSelectedElements(): Element[];
|
|
470
482
|
|
|
@@ -614,4 +626,4 @@ declare const updateElementInteractions: ({ elementId, interactions, }: {
|
|
|
614
626
|
}) => void;
|
|
615
627
|
declare const playElementInteractions: (elementId: string, interactionId: string) => void;
|
|
616
628
|
|
|
617
|
-
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, createElement, createElementStyle, createElements, deleteElement, deleteElementStyle, dropElement, duplicateElement, duplicateElements, evaluateWhen, findChildRecursive, findModelInDocument, generateElementId, getAllDescendants, getAnchoredAncestorId, getAnchoredDescendantId, getContainer, getCurrentDocumentContainer, getCurrentDocumentId, getDefaultStyleTagFromPreviewElement, getElementChildren as getElementChildrenWithFallback, getElementEditorSettings, getElementIcon, getElementInteractions, getElementLabel, getElementSetting, getElementSettings, getElementStyles, getElementTitle, getElementType, getElements, 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 };
|
|
629
|
+
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, 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 };
|
package/dist/index.js
CHANGED
|
@@ -24,6 +24,7 @@ __export(index_exports, {
|
|
|
24
24
|
ELEMENT_STYLE_CHANGE_EVENT: () => ELEMENT_STYLE_CHANGE_EVENT,
|
|
25
25
|
addModelToParent: () => addModelToParent,
|
|
26
26
|
bindSettingsReconcile: () => bindSettingsReconcile,
|
|
27
|
+
cloneElementTree: () => cloneElementTree,
|
|
27
28
|
createElement: () => createElement,
|
|
28
29
|
createElementStyle: () => createElementStyle,
|
|
29
30
|
createElements: () => createElements,
|
|
@@ -54,6 +55,8 @@ __export(index_exports, {
|
|
|
54
55
|
getElementTitle: () => getElementTitle,
|
|
55
56
|
getElementType: () => getElementType,
|
|
56
57
|
getElements: () => getElements,
|
|
58
|
+
getHostDocumentElements: () => getHostDocumentElements,
|
|
59
|
+
getHostDocumentId: () => getHostDocumentId,
|
|
57
60
|
getLinkInLinkRestriction: () => getLinkInLinkRestriction,
|
|
58
61
|
getPreviewElementDOM: () => getPreviewElementDOM,
|
|
59
62
|
getSelectedElements: () => getSelectedElements,
|
|
@@ -773,6 +776,25 @@ var duplicateElements = ({
|
|
|
773
776
|
return undoableDuplicate({ elementIds });
|
|
774
777
|
};
|
|
775
778
|
|
|
779
|
+
// src/sync/clone-element-tree.ts
|
|
780
|
+
function isBackboneModel(item) {
|
|
781
|
+
return "toJSON" in item && "get" in item;
|
|
782
|
+
}
|
|
783
|
+
function cloneElementTree(item) {
|
|
784
|
+
const source = isBackboneModel(item) ? item.toJSON() : item;
|
|
785
|
+
return {
|
|
786
|
+
...source,
|
|
787
|
+
id: generateElementId(),
|
|
788
|
+
settings: {
|
|
789
|
+
...source.settings ?? {},
|
|
790
|
+
_element_id: ""
|
|
791
|
+
},
|
|
792
|
+
elements: (source.elements ?? []).map(
|
|
793
|
+
(child) => cloneElementTree(child)
|
|
794
|
+
)
|
|
795
|
+
};
|
|
796
|
+
}
|
|
797
|
+
|
|
776
798
|
// src/sync/get-preview-element-dom.ts
|
|
777
799
|
function getPreviewElementDOM(id) {
|
|
778
800
|
try {
|
|
@@ -906,9 +928,28 @@ function getAllDescendants(container) {
|
|
|
906
928
|
return [container, ...children];
|
|
907
929
|
}
|
|
908
930
|
|
|
931
|
+
// src/sync/get-host-document-id.ts
|
|
932
|
+
function getHostDocumentId() {
|
|
933
|
+
const extendedWindow = window;
|
|
934
|
+
try {
|
|
935
|
+
return extendedWindow.elementor?.documents?.getInitialId?.() ?? null;
|
|
936
|
+
} catch {
|
|
937
|
+
return null;
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
// src/sync/get-host-document-container.ts
|
|
942
|
+
function getHostDocumentContainer() {
|
|
943
|
+
const extendedWindow = window;
|
|
944
|
+
const hostId = getHostDocumentId();
|
|
945
|
+
if (!hostId) {
|
|
946
|
+
return null;
|
|
947
|
+
}
|
|
948
|
+
return extendedWindow.elementor?.documents?.get?.(hostId)?.container ?? null;
|
|
949
|
+
}
|
|
950
|
+
|
|
909
951
|
// src/sync/get-elements.ts
|
|
910
|
-
function
|
|
911
|
-
const container = root ? getContainer(root) : getCurrentDocumentContainer();
|
|
952
|
+
function collectElements(container) {
|
|
912
953
|
if (!container) {
|
|
913
954
|
return [];
|
|
914
955
|
}
|
|
@@ -917,6 +958,13 @@ function getElements(root) {
|
|
|
917
958
|
);
|
|
918
959
|
return [container, ...children];
|
|
919
960
|
}
|
|
961
|
+
function getElements(root) {
|
|
962
|
+
const container = root ? getContainer(root) : getCurrentDocumentContainer();
|
|
963
|
+
return collectElements(container);
|
|
964
|
+
}
|
|
965
|
+
function getHostDocumentElements() {
|
|
966
|
+
return collectElements(getHostDocumentContainer());
|
|
967
|
+
}
|
|
920
968
|
|
|
921
969
|
// src/sync/move-element.ts
|
|
922
970
|
function moveElement({ element, targetContainer, options = {} }) {
|
|
@@ -1554,6 +1602,7 @@ var playElementInteractions = (elementId, interactionId) => {
|
|
|
1554
1602
|
ELEMENT_STYLE_CHANGE_EVENT,
|
|
1555
1603
|
addModelToParent,
|
|
1556
1604
|
bindSettingsReconcile,
|
|
1605
|
+
cloneElementTree,
|
|
1557
1606
|
createElement,
|
|
1558
1607
|
createElementStyle,
|
|
1559
1608
|
createElements,
|
|
@@ -1584,6 +1633,8 @@ var playElementInteractions = (elementId, interactionId) => {
|
|
|
1584
1633
|
getElementTitle,
|
|
1585
1634
|
getElementType,
|
|
1586
1635
|
getElements,
|
|
1636
|
+
getHostDocumentElements,
|
|
1637
|
+
getHostDocumentId,
|
|
1587
1638
|
getLinkInLinkRestriction,
|
|
1588
1639
|
getPreviewElementDOM,
|
|
1589
1640
|
getSelectedElements,
|