@elementor/editor-elements 4.3.0-999 → 4.3.0-beta2
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 +21 -2
- package/dist/index.d.ts +21 -2
- package/dist/index.js +76 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +72 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
- package/src/hooks/use-element-children.ts +17 -2
- package/src/index.ts +12 -1
- package/src/link-restriction.ts +2 -28
- package/src/styles/mutate-element-styles.ts +5 -0
- package/src/sync/get-preview-element-dom.ts +32 -0
- package/src/sync/types.ts +3 -0
- package/src/utils/get-default-style-tag-from-preview.ts +59 -0
package/dist/index.d.mts
CHANGED
|
@@ -227,6 +227,7 @@ type V1ElementEditorSettingsProps = {
|
|
|
227
227
|
initial_position?: number;
|
|
228
228
|
component_uid?: string;
|
|
229
229
|
grid_outline?: boolean;
|
|
230
|
+
empty_state_preview?: boolean;
|
|
230
231
|
};
|
|
231
232
|
type V1ElementSettingsProps = Record<string, PropValue>;
|
|
232
233
|
type V1ElementConfig<T = object, TChild = unknown> = {
|
|
@@ -253,6 +254,8 @@ type V1ElementConfig<T = object, TChild = unknown> = {
|
|
|
253
254
|
meta?: {
|
|
254
255
|
[key: string]: string | number | boolean | null | NonNullable<V1ElementConfig['meta']>;
|
|
255
256
|
};
|
|
257
|
+
default_html_tag?: string;
|
|
258
|
+
html_tag_follows_link?: boolean;
|
|
256
259
|
} & T;
|
|
257
260
|
type V1Model$1<T> = {
|
|
258
261
|
get: <K extends keyof T>(key: K) => T[K];
|
|
@@ -292,7 +295,17 @@ type ElementModel = {
|
|
|
292
295
|
editorSettings: V1ElementEditorSettingsProps;
|
|
293
296
|
};
|
|
294
297
|
type ElementChildren = Record<string, ElementModel[]>;
|
|
295
|
-
|
|
298
|
+
type UseElementChildrenOptions = {
|
|
299
|
+
/**
|
|
300
|
+
* Let the element itself match a requested parent type. Off by default, because
|
|
301
|
+
* `findChildRecursive` only inspects descendants and existing callers rely on that: an element
|
|
302
|
+
* whose repeater items are its own direct children (e.g. `e-accordion` -> `e-accordion-item`)
|
|
303
|
+
* has no intermediate wrapper to look for, while one that keeps them in a sub-container
|
|
304
|
+
* (e.g. `e-tabs` -> `e-tabs-menu` -> `e-tab`) must not match itself.
|
|
305
|
+
*/
|
|
306
|
+
includeSelfAsParent?: boolean;
|
|
307
|
+
};
|
|
308
|
+
declare function useElementChildren<T extends ElementChildren>(elementId: ElementID, childrenTypes: Record<string, string>, { includeSelfAsParent }?: UseElementChildrenOptions): T;
|
|
296
309
|
|
|
297
310
|
declare const useElementEditorSettings: (elementId: ElementID) => V1ElementEditorSettingsProps;
|
|
298
311
|
|
|
@@ -413,6 +426,8 @@ declare const generateElementId: () => string;
|
|
|
413
426
|
declare function getContainer(id: string): V1Element | null;
|
|
414
427
|
declare const selectElement: (elementId: string) => void;
|
|
415
428
|
|
|
429
|
+
declare function getPreviewElementDOM(id: string): HTMLElement | null;
|
|
430
|
+
|
|
416
431
|
declare function resolveContainer(container: V1Element, id: string): V1Element | null;
|
|
417
432
|
declare function findModelInDocument(id: string): BackboneModel | null;
|
|
418
433
|
declare function addModelToParent(parentId: string, childData: V1ElementModelProps, options?: {
|
|
@@ -588,10 +603,14 @@ declare function updateElementStyle(args: UpdateElementStyleArgs): void;
|
|
|
588
603
|
|
|
589
604
|
declare function getElementInteractions(elementId: ElementID): ElementInteractions | undefined;
|
|
590
605
|
|
|
606
|
+
declare const DEFAULT_STYLE_CLASS_PREFIX = "e-default-";
|
|
607
|
+
declare function parseDefaultStyleTagFromClassList(classList: DOMTokenList): string | null;
|
|
608
|
+
declare function getDefaultStyleTagFromPreviewElement(elementId: string): string | null;
|
|
609
|
+
|
|
591
610
|
declare const updateElementInteractions: ({ elementId, interactions, }: {
|
|
592
611
|
elementId: string;
|
|
593
612
|
interactions: V1ElementModelProps["interactions"];
|
|
594
613
|
}) => void;
|
|
595
614
|
declare const playElementInteractions: (elementId: string, interactionId: string) => void;
|
|
596
615
|
|
|
597
|
-
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, 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 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, getElementChildren as getElementChildrenWithFallback, getElementEditorSettings, getElementIcon, getElementInteractions, getElementLabel, getElementSetting, getElementSettings, getElementStyles, getElementTitle, getElementType, getElements, getLinkInLinkRestriction, getSelectedElements, getWidgetsCache, isElementAnchored, moveElement, moveElements, playElementInteractions, reconcileInitialChildren, removeElements, removeModelFromParent, replaceElement, resolveContainer, resolveInsertIndex, selectElement, shouldCreateNewLocalStyle, styleRerenderEvents, updateElementEditorSettings, updateElementInteractions, updateElementSettings, updateElementStyle, useElementChildren, useElementEditorSettings, useParentElement, useSelectedElement, useSelectedElementSettings };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -227,6 +227,7 @@ type V1ElementEditorSettingsProps = {
|
|
|
227
227
|
initial_position?: number;
|
|
228
228
|
component_uid?: string;
|
|
229
229
|
grid_outline?: boolean;
|
|
230
|
+
empty_state_preview?: boolean;
|
|
230
231
|
};
|
|
231
232
|
type V1ElementSettingsProps = Record<string, PropValue>;
|
|
232
233
|
type V1ElementConfig<T = object, TChild = unknown> = {
|
|
@@ -253,6 +254,8 @@ type V1ElementConfig<T = object, TChild = unknown> = {
|
|
|
253
254
|
meta?: {
|
|
254
255
|
[key: string]: string | number | boolean | null | NonNullable<V1ElementConfig['meta']>;
|
|
255
256
|
};
|
|
257
|
+
default_html_tag?: string;
|
|
258
|
+
html_tag_follows_link?: boolean;
|
|
256
259
|
} & T;
|
|
257
260
|
type V1Model$1<T> = {
|
|
258
261
|
get: <K extends keyof T>(key: K) => T[K];
|
|
@@ -292,7 +295,17 @@ type ElementModel = {
|
|
|
292
295
|
editorSettings: V1ElementEditorSettingsProps;
|
|
293
296
|
};
|
|
294
297
|
type ElementChildren = Record<string, ElementModel[]>;
|
|
295
|
-
|
|
298
|
+
type UseElementChildrenOptions = {
|
|
299
|
+
/**
|
|
300
|
+
* Let the element itself match a requested parent type. Off by default, because
|
|
301
|
+
* `findChildRecursive` only inspects descendants and existing callers rely on that: an element
|
|
302
|
+
* whose repeater items are its own direct children (e.g. `e-accordion` -> `e-accordion-item`)
|
|
303
|
+
* has no intermediate wrapper to look for, while one that keeps them in a sub-container
|
|
304
|
+
* (e.g. `e-tabs` -> `e-tabs-menu` -> `e-tab`) must not match itself.
|
|
305
|
+
*/
|
|
306
|
+
includeSelfAsParent?: boolean;
|
|
307
|
+
};
|
|
308
|
+
declare function useElementChildren<T extends ElementChildren>(elementId: ElementID, childrenTypes: Record<string, string>, { includeSelfAsParent }?: UseElementChildrenOptions): T;
|
|
296
309
|
|
|
297
310
|
declare const useElementEditorSettings: (elementId: ElementID) => V1ElementEditorSettingsProps;
|
|
298
311
|
|
|
@@ -413,6 +426,8 @@ declare const generateElementId: () => string;
|
|
|
413
426
|
declare function getContainer(id: string): V1Element | null;
|
|
414
427
|
declare const selectElement: (elementId: string) => void;
|
|
415
428
|
|
|
429
|
+
declare function getPreviewElementDOM(id: string): HTMLElement | null;
|
|
430
|
+
|
|
416
431
|
declare function resolveContainer(container: V1Element, id: string): V1Element | null;
|
|
417
432
|
declare function findModelInDocument(id: string): BackboneModel | null;
|
|
418
433
|
declare function addModelToParent(parentId: string, childData: V1ElementModelProps, options?: {
|
|
@@ -588,10 +603,14 @@ declare function updateElementStyle(args: UpdateElementStyleArgs): void;
|
|
|
588
603
|
|
|
589
604
|
declare function getElementInteractions(elementId: ElementID): ElementInteractions | undefined;
|
|
590
605
|
|
|
606
|
+
declare const DEFAULT_STYLE_CLASS_PREFIX = "e-default-";
|
|
607
|
+
declare function parseDefaultStyleTagFromClassList(classList: DOMTokenList): string | null;
|
|
608
|
+
declare function getDefaultStyleTagFromPreviewElement(elementId: string): string | null;
|
|
609
|
+
|
|
591
610
|
declare const updateElementInteractions: ({ elementId, interactions, }: {
|
|
592
611
|
elementId: string;
|
|
593
612
|
interactions: V1ElementModelProps["interactions"];
|
|
594
613
|
}) => void;
|
|
595
614
|
declare const playElementInteractions: (elementId: string, interactionId: string) => void;
|
|
596
615
|
|
|
597
|
-
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, 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 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, getElementChildren as getElementChildrenWithFallback, getElementEditorSettings, getElementIcon, getElementInteractions, getElementLabel, getElementSetting, getElementSettings, getElementStyles, getElementTitle, getElementType, getElements, getLinkInLinkRestriction, getSelectedElements, getWidgetsCache, isElementAnchored, moveElement, moveElements, playElementInteractions, reconcileInitialChildren, removeElements, removeModelFromParent, replaceElement, resolveContainer, resolveInsertIndex, selectElement, shouldCreateNewLocalStyle, styleRerenderEvents, updateElementEditorSettings, updateElementInteractions, updateElementSettings, updateElementStyle, useElementChildren, useElementEditorSettings, useParentElement, useSelectedElement, useSelectedElementSettings };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
DEFAULT_STYLE_CLASS_PREFIX: () => DEFAULT_STYLE_CLASS_PREFIX,
|
|
23
24
|
ELEMENT_STYLE_CHANGE_EVENT: () => ELEMENT_STYLE_CHANGE_EVENT,
|
|
24
25
|
addModelToParent: () => addModelToParent,
|
|
25
26
|
bindSettingsReconcile: () => bindSettingsReconcile,
|
|
@@ -41,6 +42,7 @@ __export(index_exports, {
|
|
|
41
42
|
getContainer: () => getContainer,
|
|
42
43
|
getCurrentDocumentContainer: () => getCurrentDocumentContainer,
|
|
43
44
|
getCurrentDocumentId: () => getCurrentDocumentId,
|
|
45
|
+
getDefaultStyleTagFromPreviewElement: () => getDefaultStyleTagFromPreviewElement,
|
|
44
46
|
getElementChildrenWithFallback: () => getElementChildren,
|
|
45
47
|
getElementEditorSettings: () => getElementEditorSettings,
|
|
46
48
|
getElementIcon: () => getElementIcon,
|
|
@@ -53,11 +55,13 @@ __export(index_exports, {
|
|
|
53
55
|
getElementType: () => getElementType,
|
|
54
56
|
getElements: () => getElements,
|
|
55
57
|
getLinkInLinkRestriction: () => getLinkInLinkRestriction,
|
|
58
|
+
getPreviewElementDOM: () => getPreviewElementDOM,
|
|
56
59
|
getSelectedElements: () => getSelectedElements,
|
|
57
60
|
getWidgetsCache: () => getWidgetsCache,
|
|
58
61
|
isElementAnchored: () => isElementAnchored,
|
|
59
62
|
moveElement: () => moveElement,
|
|
60
63
|
moveElements: () => moveElements,
|
|
64
|
+
parseDefaultStyleTagFromClassList: () => parseDefaultStyleTagFromClassList,
|
|
61
65
|
playElementInteractions: () => playElementInteractions,
|
|
62
66
|
reconcileInitialChildren: () => reconcileInitialChildren,
|
|
63
67
|
removeElements: () => removeElements,
|
|
@@ -365,7 +369,7 @@ function toElementModel({ model }) {
|
|
|
365
369
|
editorSettings: model.get("editor_settings") ?? {}
|
|
366
370
|
};
|
|
367
371
|
}
|
|
368
|
-
function useElementChildren(elementId, childrenTypes) {
|
|
372
|
+
function useElementChildren(elementId, childrenTypes, { includeSelfAsParent = false } = {}) {
|
|
369
373
|
return (0, import_editor_v1_adapters2.__privateUseListenTo)(
|
|
370
374
|
[
|
|
371
375
|
(0, import_editor_v1_adapters2.v1ReadyEvent)(),
|
|
@@ -381,7 +385,7 @@ function useElementChildren(elementId, childrenTypes) {
|
|
|
381
385
|
return {};
|
|
382
386
|
}
|
|
383
387
|
const elementChildren = Object.entries(childrenTypes).reduce((acc, [parentType, childType]) => {
|
|
384
|
-
const parent = findChildRecursive(model, (m) => m.get("elType") === parentType);
|
|
388
|
+
const parent = includeSelfAsParent && model.get("elType") === parentType ? { model } : findChildRecursive(model, (m) => m.get("elType") === parentType);
|
|
385
389
|
if (!parent) {
|
|
386
390
|
acc[childType] = [];
|
|
387
391
|
return acc;
|
|
@@ -769,6 +773,26 @@ var duplicateElements = ({
|
|
|
769
773
|
return undoableDuplicate({ elementIds });
|
|
770
774
|
};
|
|
771
775
|
|
|
776
|
+
// src/sync/get-preview-element-dom.ts
|
|
777
|
+
function getPreviewElementDOM(id) {
|
|
778
|
+
try {
|
|
779
|
+
const fromContainer = getContainer(id)?.view?.el;
|
|
780
|
+
if (fromContainer) {
|
|
781
|
+
return fromContainer;
|
|
782
|
+
}
|
|
783
|
+
return queryPreviewDOMByElementId(id);
|
|
784
|
+
} catch {
|
|
785
|
+
return null;
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
function queryPreviewDOMByElementId(id) {
|
|
789
|
+
const previewDocument = window.elementor?.getPreviewContainer?.()?.view?.el?.ownerDocument;
|
|
790
|
+
if (!previewDocument) {
|
|
791
|
+
return null;
|
|
792
|
+
}
|
|
793
|
+
return previewDocument.querySelector(`[data-id="${id}"]`);
|
|
794
|
+
}
|
|
795
|
+
|
|
772
796
|
// src/sync/get-current-document-container.ts
|
|
773
797
|
function getCurrentDocumentContainer() {
|
|
774
798
|
const extendedWindow = window;
|
|
@@ -1290,22 +1314,7 @@ function checkForInlineLink(elementId, resolvedValue) {
|
|
|
1290
1314
|
return element.querySelector(ANCHOR_SELECTOR) !== null;
|
|
1291
1315
|
}
|
|
1292
1316
|
function getElementDOM(id) {
|
|
1293
|
-
|
|
1294
|
-
const fromContainer = getContainer(id)?.view?.el;
|
|
1295
|
-
if (fromContainer) {
|
|
1296
|
-
return fromContainer;
|
|
1297
|
-
}
|
|
1298
|
-
return queryPreviewDOMByElementId(id);
|
|
1299
|
-
} catch {
|
|
1300
|
-
return null;
|
|
1301
|
-
}
|
|
1302
|
-
}
|
|
1303
|
-
function queryPreviewDOMByElementId(id) {
|
|
1304
|
-
const previewDocument = window.elementor?.getPreviewContainer?.()?.view?.el?.ownerDocument;
|
|
1305
|
-
if (!previewDocument) {
|
|
1306
|
-
return null;
|
|
1307
|
-
}
|
|
1308
|
-
return previewDocument.querySelector(`[data-id="${id}"]`);
|
|
1317
|
+
return getPreviewElementDOM(id);
|
|
1309
1318
|
}
|
|
1310
1319
|
function isElementorElement(element) {
|
|
1311
1320
|
return element.hasAttribute("data-id");
|
|
@@ -1366,6 +1375,9 @@ function isStyleEmpty(style) {
|
|
|
1366
1375
|
}
|
|
1367
1376
|
function clearRemovedClasses(container, { oldIds, newIds }) {
|
|
1368
1377
|
const removedIds = oldIds.filter((id) => !newIds.includes(id));
|
|
1378
|
+
if (!removedIds.length) {
|
|
1379
|
+
return;
|
|
1380
|
+
}
|
|
1369
1381
|
const classesProps = structuredClone(getClassesProps(container));
|
|
1370
1382
|
classesProps.forEach(([, prop]) => {
|
|
1371
1383
|
prop.value = prop.value.filter((value) => !removedIds.includes(value));
|
|
@@ -1475,6 +1487,48 @@ function getElementInteractions(elementId) {
|
|
|
1475
1487
|
return interactions;
|
|
1476
1488
|
}
|
|
1477
1489
|
|
|
1490
|
+
// src/utils/get-default-style-tag-from-preview.ts
|
|
1491
|
+
var DEFAULT_STYLE_CLASS_PREFIX = "e-default-";
|
|
1492
|
+
function parseDefaultStyleTagFromClassList(classList) {
|
|
1493
|
+
for (const className of classList) {
|
|
1494
|
+
if (className.startsWith(DEFAULT_STYLE_CLASS_PREFIX)) {
|
|
1495
|
+
return className.slice(DEFAULT_STYLE_CLASS_PREFIX.length);
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1498
|
+
return null;
|
|
1499
|
+
}
|
|
1500
|
+
function getDefaultStyleTagFromPreviewElement(elementId) {
|
|
1501
|
+
const renderRoot = getAtomicElementRenderRoot(elementId);
|
|
1502
|
+
if (!renderRoot) {
|
|
1503
|
+
return null;
|
|
1504
|
+
}
|
|
1505
|
+
return parseDefaultStyleTagFromClassList(renderRoot.classList);
|
|
1506
|
+
}
|
|
1507
|
+
function getAtomicElementRenderRoot(elementId) {
|
|
1508
|
+
const view = getContainerView(elementId);
|
|
1509
|
+
if (view?.getDomElement) {
|
|
1510
|
+
const domElement = view.getDomElement().get?.(0);
|
|
1511
|
+
if (domElement) {
|
|
1512
|
+
return domElement;
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
const wrapper = view?.el ?? getPreviewElementDOM(elementId);
|
|
1516
|
+
if (!wrapper) {
|
|
1517
|
+
return null;
|
|
1518
|
+
}
|
|
1519
|
+
if (wrapper.hasAttribute("data-id")) {
|
|
1520
|
+
return wrapper;
|
|
1521
|
+
}
|
|
1522
|
+
const firstChild = wrapper.firstElementChild;
|
|
1523
|
+
if (firstChild instanceof HTMLElement) {
|
|
1524
|
+
return firstChild;
|
|
1525
|
+
}
|
|
1526
|
+
return wrapper;
|
|
1527
|
+
}
|
|
1528
|
+
function getContainerView(elementId) {
|
|
1529
|
+
return getContainer(elementId)?.view ?? null;
|
|
1530
|
+
}
|
|
1531
|
+
|
|
1478
1532
|
// src/sync/update-element-interactions.ts
|
|
1479
1533
|
var import_editor_v1_adapters19 = require("@elementor/editor-v1-adapters");
|
|
1480
1534
|
var updateElementInteractions = ({
|
|
@@ -1496,6 +1550,7 @@ var playElementInteractions = (elementId, interactionId) => {
|
|
|
1496
1550
|
};
|
|
1497
1551
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1498
1552
|
0 && (module.exports = {
|
|
1553
|
+
DEFAULT_STYLE_CLASS_PREFIX,
|
|
1499
1554
|
ELEMENT_STYLE_CHANGE_EVENT,
|
|
1500
1555
|
addModelToParent,
|
|
1501
1556
|
bindSettingsReconcile,
|
|
@@ -1517,6 +1572,7 @@ var playElementInteractions = (elementId, interactionId) => {
|
|
|
1517
1572
|
getContainer,
|
|
1518
1573
|
getCurrentDocumentContainer,
|
|
1519
1574
|
getCurrentDocumentId,
|
|
1575
|
+
getDefaultStyleTagFromPreviewElement,
|
|
1520
1576
|
getElementChildrenWithFallback,
|
|
1521
1577
|
getElementEditorSettings,
|
|
1522
1578
|
getElementIcon,
|
|
@@ -1529,11 +1585,13 @@ var playElementInteractions = (elementId, interactionId) => {
|
|
|
1529
1585
|
getElementType,
|
|
1530
1586
|
getElements,
|
|
1531
1587
|
getLinkInLinkRestriction,
|
|
1588
|
+
getPreviewElementDOM,
|
|
1532
1589
|
getSelectedElements,
|
|
1533
1590
|
getWidgetsCache,
|
|
1534
1591
|
isElementAnchored,
|
|
1535
1592
|
moveElement,
|
|
1536
1593
|
moveElements,
|
|
1594
|
+
parseDefaultStyleTagFromClassList,
|
|
1537
1595
|
playElementInteractions,
|
|
1538
1596
|
reconcileInitialChildren,
|
|
1539
1597
|
removeElements,
|