@elementor/editor-elements 4.3.0-1041 → 4.3.0-1043
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 +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +71 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +67 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
- package/src/index.ts +6 -0
- package/src/link-restriction.ts +2 -28
- package/src/sync/get-preview-element-dom.ts +32 -0
- package/src/utils/get-default-style-tag-from-preview.ts +59 -0
package/dist/index.d.mts
CHANGED
|
@@ -414,6 +414,8 @@ declare const generateElementId: () => string;
|
|
|
414
414
|
declare function getContainer(id: string): V1Element | null;
|
|
415
415
|
declare const selectElement: (elementId: string) => void;
|
|
416
416
|
|
|
417
|
+
declare function getPreviewElementDOM(id: string): HTMLElement | null;
|
|
418
|
+
|
|
417
419
|
declare function resolveContainer(container: V1Element, id: string): V1Element | null;
|
|
418
420
|
declare function findModelInDocument(id: string): BackboneModel | null;
|
|
419
421
|
declare function addModelToParent(parentId: string, childData: V1ElementModelProps, options?: {
|
|
@@ -589,10 +591,14 @@ declare function updateElementStyle(args: UpdateElementStyleArgs): void;
|
|
|
589
591
|
|
|
590
592
|
declare function getElementInteractions(elementId: ElementID): ElementInteractions | undefined;
|
|
591
593
|
|
|
594
|
+
declare const DEFAULT_STYLE_CLASS_PREFIX = "e-default-";
|
|
595
|
+
declare function parseDefaultStyleTagFromClassList(classList: DOMTokenList): string | null;
|
|
596
|
+
declare function getDefaultStyleTagFromPreviewElement(elementId: string): string | null;
|
|
597
|
+
|
|
592
598
|
declare const updateElementInteractions: ({ elementId, interactions, }: {
|
|
593
599
|
elementId: string;
|
|
594
600
|
interactions: V1ElementModelProps["interactions"];
|
|
595
601
|
}) => void;
|
|
596
602
|
declare const playElementInteractions: (elementId: string, interactionId: string) => void;
|
|
597
603
|
|
|
598
|
-
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 };
|
|
604
|
+
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 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
|
@@ -414,6 +414,8 @@ declare const generateElementId: () => string;
|
|
|
414
414
|
declare function getContainer(id: string): V1Element | null;
|
|
415
415
|
declare const selectElement: (elementId: string) => void;
|
|
416
416
|
|
|
417
|
+
declare function getPreviewElementDOM(id: string): HTMLElement | null;
|
|
418
|
+
|
|
417
419
|
declare function resolveContainer(container: V1Element, id: string): V1Element | null;
|
|
418
420
|
declare function findModelInDocument(id: string): BackboneModel | null;
|
|
419
421
|
declare function addModelToParent(parentId: string, childData: V1ElementModelProps, options?: {
|
|
@@ -589,10 +591,14 @@ declare function updateElementStyle(args: UpdateElementStyleArgs): void;
|
|
|
589
591
|
|
|
590
592
|
declare function getElementInteractions(elementId: ElementID): ElementInteractions | undefined;
|
|
591
593
|
|
|
594
|
+
declare const DEFAULT_STYLE_CLASS_PREFIX = "e-default-";
|
|
595
|
+
declare function parseDefaultStyleTagFromClassList(classList: DOMTokenList): string | null;
|
|
596
|
+
declare function getDefaultStyleTagFromPreviewElement(elementId: string): string | null;
|
|
597
|
+
|
|
592
598
|
declare const updateElementInteractions: ({ elementId, interactions, }: {
|
|
593
599
|
elementId: string;
|
|
594
600
|
interactions: V1ElementModelProps["interactions"];
|
|
595
601
|
}) => void;
|
|
596
602
|
declare const playElementInteractions: (elementId: string, interactionId: string) => void;
|
|
597
603
|
|
|
598
|
-
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 };
|
|
604
|
+
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 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,
|
|
@@ -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");
|
|
@@ -1475,6 +1484,48 @@ function getElementInteractions(elementId) {
|
|
|
1475
1484
|
return interactions;
|
|
1476
1485
|
}
|
|
1477
1486
|
|
|
1487
|
+
// src/utils/get-default-style-tag-from-preview.ts
|
|
1488
|
+
var DEFAULT_STYLE_CLASS_PREFIX = "e-default-";
|
|
1489
|
+
function parseDefaultStyleTagFromClassList(classList) {
|
|
1490
|
+
for (const className of classList) {
|
|
1491
|
+
if (className.startsWith(DEFAULT_STYLE_CLASS_PREFIX)) {
|
|
1492
|
+
return className.slice(DEFAULT_STYLE_CLASS_PREFIX.length);
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
return null;
|
|
1496
|
+
}
|
|
1497
|
+
function getDefaultStyleTagFromPreviewElement(elementId) {
|
|
1498
|
+
const renderRoot = getAtomicElementRenderRoot(elementId);
|
|
1499
|
+
if (!renderRoot) {
|
|
1500
|
+
return null;
|
|
1501
|
+
}
|
|
1502
|
+
return parseDefaultStyleTagFromClassList(renderRoot.classList);
|
|
1503
|
+
}
|
|
1504
|
+
function getAtomicElementRenderRoot(elementId) {
|
|
1505
|
+
const view = getContainerView(elementId);
|
|
1506
|
+
if (view?.getDomElement) {
|
|
1507
|
+
const domElement = view.getDomElement().get?.(0);
|
|
1508
|
+
if (domElement) {
|
|
1509
|
+
return domElement;
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
const wrapper = view?.el ?? getPreviewElementDOM(elementId);
|
|
1513
|
+
if (!wrapper) {
|
|
1514
|
+
return null;
|
|
1515
|
+
}
|
|
1516
|
+
if (wrapper.hasAttribute("data-id")) {
|
|
1517
|
+
return wrapper;
|
|
1518
|
+
}
|
|
1519
|
+
const firstChild = wrapper.firstElementChild;
|
|
1520
|
+
if (firstChild instanceof HTMLElement) {
|
|
1521
|
+
return firstChild;
|
|
1522
|
+
}
|
|
1523
|
+
return wrapper;
|
|
1524
|
+
}
|
|
1525
|
+
function getContainerView(elementId) {
|
|
1526
|
+
return getContainer(elementId)?.view ?? null;
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1478
1529
|
// src/sync/update-element-interactions.ts
|
|
1479
1530
|
var import_editor_v1_adapters19 = require("@elementor/editor-v1-adapters");
|
|
1480
1531
|
var updateElementInteractions = ({
|
|
@@ -1496,6 +1547,7 @@ var playElementInteractions = (elementId, interactionId) => {
|
|
|
1496
1547
|
};
|
|
1497
1548
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1498
1549
|
0 && (module.exports = {
|
|
1550
|
+
DEFAULT_STYLE_CLASS_PREFIX,
|
|
1499
1551
|
ELEMENT_STYLE_CHANGE_EVENT,
|
|
1500
1552
|
addModelToParent,
|
|
1501
1553
|
bindSettingsReconcile,
|
|
@@ -1517,6 +1569,7 @@ var playElementInteractions = (elementId, interactionId) => {
|
|
|
1517
1569
|
getContainer,
|
|
1518
1570
|
getCurrentDocumentContainer,
|
|
1519
1571
|
getCurrentDocumentId,
|
|
1572
|
+
getDefaultStyleTagFromPreviewElement,
|
|
1520
1573
|
getElementChildrenWithFallback,
|
|
1521
1574
|
getElementEditorSettings,
|
|
1522
1575
|
getElementIcon,
|
|
@@ -1529,11 +1582,13 @@ var playElementInteractions = (elementId, interactionId) => {
|
|
|
1529
1582
|
getElementType,
|
|
1530
1583
|
getElements,
|
|
1531
1584
|
getLinkInLinkRestriction,
|
|
1585
|
+
getPreviewElementDOM,
|
|
1532
1586
|
getSelectedElements,
|
|
1533
1587
|
getWidgetsCache,
|
|
1534
1588
|
isElementAnchored,
|
|
1535
1589
|
moveElement,
|
|
1536
1590
|
moveElements,
|
|
1591
|
+
parseDefaultStyleTagFromClassList,
|
|
1537
1592
|
playElementInteractions,
|
|
1538
1593
|
reconcileInitialChildren,
|
|
1539
1594
|
removeElements,
|