@elementor/editor-elements 4.3.3 → 4.3.5
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 +15 -1
- package/dist/index.d.ts +15 -1
- package/dist/index.js +96 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +93 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
- package/src/children-dependencies/bind-settings-reconcile.ts +48 -0
- package/src/children-dependencies/reconcile-initial-children.ts +16 -0
- 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 +13 -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;
|
|
@@ -228,6 +233,7 @@ type V1ElementEditorSettingsProps = {
|
|
|
228
233
|
component_uid?: string;
|
|
229
234
|
grid_outline?: boolean;
|
|
230
235
|
empty_state_preview?: boolean;
|
|
236
|
+
decorative?: boolean;
|
|
231
237
|
};
|
|
232
238
|
type V1ElementSettingsProps = Record<string, PropValue>;
|
|
233
239
|
type V1ElementConfig<T = object, TChild = unknown> = {
|
|
@@ -242,6 +248,7 @@ type V1ElementConfig<T = object, TChild = unknown> = {
|
|
|
242
248
|
dependencies_per_target_mapping?: Record<string, string[]>;
|
|
243
249
|
twig_templates?: Record<string, string>;
|
|
244
250
|
twig_main_template?: string;
|
|
251
|
+
template_context?: Record<string, unknown>;
|
|
245
252
|
base_styles?: Record<string, StyleDefinition>;
|
|
246
253
|
base_styles_dictionary?: Record<string, string>;
|
|
247
254
|
base_settings?: Record<string, PropValue>;
|
|
@@ -421,6 +428,9 @@ type DuplicatedElementsResult = {
|
|
|
421
428
|
|
|
422
429
|
declare const duplicateElements: ({ elementIds, title, subtitle, onDuplicateElements, onRestoreElements, }: DuplicateElementsParams) => DuplicatedElementsResult;
|
|
423
430
|
|
|
431
|
+
type CloneableElement = Partial<V1ElementModelProps> | BackboneModel;
|
|
432
|
+
declare function cloneElementTree(item: CloneableElement): V1ElementModelProps;
|
|
433
|
+
|
|
424
434
|
declare const generateElementId: () => string;
|
|
425
435
|
|
|
426
436
|
declare function getContainer(id: string): V1Element | null;
|
|
@@ -432,6 +442,7 @@ declare function resolveContainer(container: V1Element, id: string): V1Element |
|
|
|
432
442
|
declare function findModelInDocument(id: string): BackboneModel | null;
|
|
433
443
|
declare function addModelToParent(parentId: string, childData: V1ElementModelProps, options?: {
|
|
434
444
|
at?: number;
|
|
445
|
+
clone?: boolean;
|
|
435
446
|
}): boolean;
|
|
436
447
|
declare function removeModelFromParent(parentId: string, childId: string): boolean;
|
|
437
448
|
|
|
@@ -464,6 +475,9 @@ declare function findChildRecursive(model: V1Model, predicate: (model: V1Model)
|
|
|
464
475
|
declare function getElementChildren(model: V1Model, predicate?: (model: V1Model) => boolean): ModelResult[];
|
|
465
476
|
|
|
466
477
|
declare function getElements(root?: ElementID): V1Element[];
|
|
478
|
+
declare function getHostDocumentElements(): V1Element[];
|
|
479
|
+
|
|
480
|
+
declare function getHostDocumentId(): number | null;
|
|
467
481
|
|
|
468
482
|
declare function getSelectedElements(): Element[];
|
|
469
483
|
|
|
@@ -613,4 +627,4 @@ declare const updateElementInteractions: ({ elementId, interactions, }: {
|
|
|
613
627
|
}) => void;
|
|
614
628
|
declare const playElementInteractions: (elementId: string, interactionId: string) => void;
|
|
615
629
|
|
|
616
|
-
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 };
|
|
630
|
+
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;
|
|
@@ -228,6 +233,7 @@ type V1ElementEditorSettingsProps = {
|
|
|
228
233
|
component_uid?: string;
|
|
229
234
|
grid_outline?: boolean;
|
|
230
235
|
empty_state_preview?: boolean;
|
|
236
|
+
decorative?: boolean;
|
|
231
237
|
};
|
|
232
238
|
type V1ElementSettingsProps = Record<string, PropValue>;
|
|
233
239
|
type V1ElementConfig<T = object, TChild = unknown> = {
|
|
@@ -242,6 +248,7 @@ type V1ElementConfig<T = object, TChild = unknown> = {
|
|
|
242
248
|
dependencies_per_target_mapping?: Record<string, string[]>;
|
|
243
249
|
twig_templates?: Record<string, string>;
|
|
244
250
|
twig_main_template?: string;
|
|
251
|
+
template_context?: Record<string, unknown>;
|
|
245
252
|
base_styles?: Record<string, StyleDefinition>;
|
|
246
253
|
base_styles_dictionary?: Record<string, string>;
|
|
247
254
|
base_settings?: Record<string, PropValue>;
|
|
@@ -421,6 +428,9 @@ type DuplicatedElementsResult = {
|
|
|
421
428
|
|
|
422
429
|
declare const duplicateElements: ({ elementIds, title, subtitle, onDuplicateElements, onRestoreElements, }: DuplicateElementsParams) => DuplicatedElementsResult;
|
|
423
430
|
|
|
431
|
+
type CloneableElement = Partial<V1ElementModelProps> | BackboneModel;
|
|
432
|
+
declare function cloneElementTree(item: CloneableElement): V1ElementModelProps;
|
|
433
|
+
|
|
424
434
|
declare const generateElementId: () => string;
|
|
425
435
|
|
|
426
436
|
declare function getContainer(id: string): V1Element | null;
|
|
@@ -432,6 +442,7 @@ declare function resolveContainer(container: V1Element, id: string): V1Element |
|
|
|
432
442
|
declare function findModelInDocument(id: string): BackboneModel | null;
|
|
433
443
|
declare function addModelToParent(parentId: string, childData: V1ElementModelProps, options?: {
|
|
434
444
|
at?: number;
|
|
445
|
+
clone?: boolean;
|
|
435
446
|
}): boolean;
|
|
436
447
|
declare function removeModelFromParent(parentId: string, childId: string): boolean;
|
|
437
448
|
|
|
@@ -464,6 +475,9 @@ declare function findChildRecursive(model: V1Model, predicate: (model: V1Model)
|
|
|
464
475
|
declare function getElementChildren(model: V1Model, predicate?: (model: V1Model) => boolean): ModelResult[];
|
|
465
476
|
|
|
466
477
|
declare function getElements(root?: ElementID): V1Element[];
|
|
478
|
+
declare function getHostDocumentElements(): V1Element[];
|
|
479
|
+
|
|
480
|
+
declare function getHostDocumentId(): number | null;
|
|
467
481
|
|
|
468
482
|
declare function getSelectedElements(): Element[];
|
|
469
483
|
|
|
@@ -613,4 +627,4 @@ declare const updateElementInteractions: ({ elementId, interactions, }: {
|
|
|
613
627
|
}) => void;
|
|
614
628
|
declare const playElementInteractions: (elementId: string, interactionId: string) => void;
|
|
615
629
|
|
|
616
|
-
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 };
|
|
630
|
+
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,
|
|
@@ -261,6 +264,7 @@ function attachChildFromRule(parentId, rule, stash) {
|
|
|
261
264
|
const currentChildren = getDirectChildData(parent);
|
|
262
265
|
const alreadyPresent = currentChildren.some((child) => child.elType === rule.child_type);
|
|
263
266
|
if (alreadyPresent) {
|
|
267
|
+
placeAnchoredChild(parentId, rule);
|
|
264
268
|
return;
|
|
265
269
|
}
|
|
266
270
|
const { modelData, wasStashed } = resolveChildModelData(parentId, rule, stash);
|
|
@@ -290,6 +294,36 @@ function detachChildFromRule(parentId, rule, stash) {
|
|
|
290
294
|
}
|
|
291
295
|
requestNavigatorRefresh(parentId);
|
|
292
296
|
}
|
|
297
|
+
function placeAnchoredChild(parentId, rule) {
|
|
298
|
+
if (rule.position.kind !== "after_type" && rule.position.kind !== "before_type") {
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
let parent;
|
|
302
|
+
try {
|
|
303
|
+
parent = getContainer(parentId) ?? void 0;
|
|
304
|
+
} catch {
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
const collection = parent?.model?.get?.("elements");
|
|
308
|
+
const models = collection?.models;
|
|
309
|
+
if (!models || !collection?.remove || !collection?.add) {
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
const existingIndex = models.findIndex((model2) => model2.get("elType") === rule.child_type);
|
|
313
|
+
if (existingIndex < 0) {
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
const siblings = models.map((model2) => ({ elType: model2.get("elType") }));
|
|
317
|
+
const remaining = siblings.filter((_, index) => index !== existingIndex);
|
|
318
|
+
const insertAt = resolveInsertIndex(rule.position, remaining);
|
|
319
|
+
if (insertAt === existingIndex) {
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
const model = models[existingIndex];
|
|
323
|
+
collection.remove(model, { silent: true });
|
|
324
|
+
collection.add(model, { at: insertAt, silent: true });
|
|
325
|
+
requestNavigatorRefresh(parentId);
|
|
326
|
+
}
|
|
293
327
|
function requestNavigatorRefresh(parentId) {
|
|
294
328
|
if (typeof window === "undefined" || typeof window.dispatchEvent !== "function") {
|
|
295
329
|
return;
|
|
@@ -321,6 +355,15 @@ function reconcileInitialChildren({
|
|
|
321
355
|
const isMet = evaluateWhen(rule.when, settings);
|
|
322
356
|
const existingIndex = elements.findIndex((element) => element.elType === rule.child_type);
|
|
323
357
|
const isPresent = existingIndex >= 0;
|
|
358
|
+
if (isMet && isPresent && isAnchoredPosition(rule.position.kind)) {
|
|
359
|
+
const remaining = elements.filter((_, index) => index !== existingIndex);
|
|
360
|
+
const insertAt = resolveInsertIndex(rule.position, remaining);
|
|
361
|
+
if (insertAt !== existingIndex) {
|
|
362
|
+
const [moved] = elements.splice(existingIndex, 1);
|
|
363
|
+
elements.splice(insertAt, 0, moved);
|
|
364
|
+
}
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
324
367
|
if (isMet && !isPresent) {
|
|
325
368
|
const { modelData, wasStashed } = resolveChildModelData(elementId, rule, stash);
|
|
326
369
|
const insertAt = resolveInsertIndex(rule.position, elements);
|
|
@@ -339,6 +382,9 @@ function reconcileInitialChildren({
|
|
|
339
382
|
});
|
|
340
383
|
attributes.elements = elements;
|
|
341
384
|
}
|
|
385
|
+
function isAnchoredPosition(kind) {
|
|
386
|
+
return kind === "after_type" || kind === "before_type";
|
|
387
|
+
}
|
|
342
388
|
|
|
343
389
|
// src/hooks/use-element-children.ts
|
|
344
390
|
var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
|
|
@@ -773,6 +819,25 @@ var duplicateElements = ({
|
|
|
773
819
|
return undoableDuplicate({ elementIds });
|
|
774
820
|
};
|
|
775
821
|
|
|
822
|
+
// src/sync/clone-element-tree.ts
|
|
823
|
+
function isBackboneModel(item) {
|
|
824
|
+
return "toJSON" in item && "get" in item;
|
|
825
|
+
}
|
|
826
|
+
function cloneElementTree(item) {
|
|
827
|
+
const source = isBackboneModel(item) ? item.toJSON() : item;
|
|
828
|
+
return {
|
|
829
|
+
...source,
|
|
830
|
+
id: generateElementId(),
|
|
831
|
+
settings: {
|
|
832
|
+
...source.settings ?? {},
|
|
833
|
+
_element_id: ""
|
|
834
|
+
},
|
|
835
|
+
elements: (source.elements ?? []).map(
|
|
836
|
+
(child) => cloneElementTree(child)
|
|
837
|
+
)
|
|
838
|
+
};
|
|
839
|
+
}
|
|
840
|
+
|
|
776
841
|
// src/sync/get-preview-element-dom.ts
|
|
777
842
|
function getPreviewElementDOM(id) {
|
|
778
843
|
try {
|
|
@@ -906,9 +971,28 @@ function getAllDescendants(container) {
|
|
|
906
971
|
return [container, ...children];
|
|
907
972
|
}
|
|
908
973
|
|
|
974
|
+
// src/sync/get-host-document-id.ts
|
|
975
|
+
function getHostDocumentId() {
|
|
976
|
+
const extendedWindow = window;
|
|
977
|
+
try {
|
|
978
|
+
return extendedWindow.elementor?.documents?.getInitialId?.() ?? null;
|
|
979
|
+
} catch {
|
|
980
|
+
return null;
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
// src/sync/get-host-document-container.ts
|
|
985
|
+
function getHostDocumentContainer() {
|
|
986
|
+
const extendedWindow = window;
|
|
987
|
+
const hostId = getHostDocumentId();
|
|
988
|
+
if (!hostId) {
|
|
989
|
+
return null;
|
|
990
|
+
}
|
|
991
|
+
return extendedWindow.elementor?.documents?.get?.(hostId)?.container ?? null;
|
|
992
|
+
}
|
|
993
|
+
|
|
909
994
|
// src/sync/get-elements.ts
|
|
910
|
-
function
|
|
911
|
-
const container = root ? getContainer(root) : getCurrentDocumentContainer();
|
|
995
|
+
function collectElements(container) {
|
|
912
996
|
if (!container) {
|
|
913
997
|
return [];
|
|
914
998
|
}
|
|
@@ -917,6 +1001,13 @@ function getElements(root) {
|
|
|
917
1001
|
);
|
|
918
1002
|
return [container, ...children];
|
|
919
1003
|
}
|
|
1004
|
+
function getElements(root) {
|
|
1005
|
+
const container = root ? getContainer(root) : getCurrentDocumentContainer();
|
|
1006
|
+
return collectElements(container);
|
|
1007
|
+
}
|
|
1008
|
+
function getHostDocumentElements() {
|
|
1009
|
+
return collectElements(getHostDocumentContainer());
|
|
1010
|
+
}
|
|
920
1011
|
|
|
921
1012
|
// src/sync/move-element.ts
|
|
922
1013
|
function moveElement({ element, targetContainer, options = {} }) {
|
|
@@ -1554,6 +1645,7 @@ var playElementInteractions = (elementId, interactionId) => {
|
|
|
1554
1645
|
ELEMENT_STYLE_CHANGE_EVENT,
|
|
1555
1646
|
addModelToParent,
|
|
1556
1647
|
bindSettingsReconcile,
|
|
1648
|
+
cloneElementTree,
|
|
1557
1649
|
createElement,
|
|
1558
1650
|
createElementStyle,
|
|
1559
1651
|
createElements,
|
|
@@ -1584,6 +1676,8 @@ var playElementInteractions = (elementId, interactionId) => {
|
|
|
1584
1676
|
getElementTitle,
|
|
1585
1677
|
getElementType,
|
|
1586
1678
|
getElements,
|
|
1679
|
+
getHostDocumentElements,
|
|
1680
|
+
getHostDocumentId,
|
|
1587
1681
|
getLinkInLinkRestriction,
|
|
1588
1682
|
getPreviewElementDOM,
|
|
1589
1683
|
getSelectedElements,
|