@elementor/editor-elements 4.2.0-beta2 → 4.3.0-1001
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 +48 -2
- package/dist/index.d.ts +48 -2
- package/dist/index.js +310 -56
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +291 -43
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -7
- package/src/children-dependencies/bind-settings-reconcile.ts +147 -0
- package/src/children-dependencies/index.ts +4 -0
- package/src/children-dependencies/reconcile-initial-children.ts +59 -0
- package/src/children-dependencies/stash.ts +40 -0
- package/src/children-dependencies/types.ts +20 -0
- package/src/children-dependencies/utils.ts +44 -0
- package/src/index.ts +12 -0
- package/src/sync/get-element-icon.ts +14 -0
- package/src/sync/get-element-title.ts +48 -0
- package/src/sync/resolve-insert-index.ts +34 -0
- package/src/sync/types.ts +12 -0
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PropsSchema, PropValue, SizePropValue, AnyTransformable, Props, LinkPropValue } from '@elementor/editor-props';
|
|
1
|
+
import { PropsSchema, Dependency, PropValue, SizePropValue, AnyTransformable, Props, LinkPropValue } from '@elementor/editor-props';
|
|
2
2
|
import { ClassState, StyleDefinitionID, StyleDefinition, StyleDefinitionVariant } from '@elementor/editor-styles';
|
|
3
3
|
import * as _elementor_editor_v1_adapters from '@elementor/editor-v1-adapters';
|
|
4
4
|
|
|
@@ -58,6 +58,15 @@ type ElementControl = {
|
|
|
58
58
|
type ControlItem = ControlsSection | Control | ElementControl;
|
|
59
59
|
type ControlLayout = 'full' | 'two-columns' | 'custom';
|
|
60
60
|
|
|
61
|
+
type ChildDependencyRule = {
|
|
62
|
+
child_type: string;
|
|
63
|
+
when: Dependency;
|
|
64
|
+
position: ElementPosition;
|
|
65
|
+
stash: boolean;
|
|
66
|
+
default_model: V1ElementData | null;
|
|
67
|
+
};
|
|
68
|
+
type ChildDependenciesConfig = ChildDependencyRule[];
|
|
69
|
+
|
|
61
70
|
type ExtendedWindow = Window & {
|
|
62
71
|
$e?: {
|
|
63
72
|
components?: {
|
|
@@ -203,10 +212,16 @@ type V1ElementModelProps = {
|
|
|
203
212
|
interactions?: string | ElementInteractions;
|
|
204
213
|
isGlobal?: boolean;
|
|
205
214
|
skipDefaultChildren?: boolean;
|
|
215
|
+
hydrateDefaultChildren?: boolean;
|
|
206
216
|
};
|
|
207
217
|
type V1ElementData = Omit<V1ElementModelProps, 'elements'> & {
|
|
208
218
|
elements?: V1ElementData[];
|
|
209
219
|
};
|
|
220
|
+
type ElementPositionKind = 'last' | 'first' | 'index' | 'after_type' | 'before_type';
|
|
221
|
+
type ElementPosition = {
|
|
222
|
+
kind: ElementPositionKind;
|
|
223
|
+
value: number | string | null;
|
|
224
|
+
};
|
|
210
225
|
type V1ElementEditorSettingsProps = {
|
|
211
226
|
title?: string;
|
|
212
227
|
initial_position?: number;
|
|
@@ -234,6 +249,7 @@ type V1ElementConfig<T = object, TChild = unknown> = {
|
|
|
234
249
|
show_in_panel?: boolean;
|
|
235
250
|
allowed_child_types?: string[];
|
|
236
251
|
default_children?: Array<Record<string, TChild>>;
|
|
252
|
+
children_dependencies?: ChildDependencyRule[];
|
|
237
253
|
meta?: {
|
|
238
254
|
[key: string]: string | number | boolean | null | NonNullable<V1ElementConfig['meta']>;
|
|
239
255
|
};
|
|
@@ -245,7 +261,31 @@ type V1Model$1<T> = {
|
|
|
245
261
|
remove?: string[];
|
|
246
262
|
}) => T;
|
|
247
263
|
trigger?: (event: string, ...args: unknown[]) => void;
|
|
264
|
+
on?: (event: string, callback: (...args: unknown[]) => void, context?: unknown) => void;
|
|
265
|
+
off?: (event: string, callback?: (...args: unknown[]) => void, context?: unknown) => void;
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
type ReactiveModel = {
|
|
269
|
+
get: (key: string) => unknown;
|
|
270
|
+
};
|
|
271
|
+
type BindSettingsReconcileArgs = {
|
|
272
|
+
model: ReactiveModel;
|
|
273
|
+
elementConfig: V1ElementConfig | undefined;
|
|
274
|
+
};
|
|
275
|
+
type Detach = () => void;
|
|
276
|
+
declare function bindSettingsReconcile({ model, elementConfig }: BindSettingsReconcileArgs): Detach;
|
|
277
|
+
|
|
278
|
+
declare function evaluateWhen(when: Dependency | undefined, settings: Record<string, PropValue>): boolean;
|
|
279
|
+
|
|
280
|
+
type ReconcileInitialChildrenArgs = {
|
|
281
|
+
elementId: string;
|
|
282
|
+
elementConfig: V1ElementConfig | undefined;
|
|
283
|
+
attributes: {
|
|
284
|
+
elements?: V1ElementData[];
|
|
285
|
+
settings?: V1ElementSettingsProps;
|
|
286
|
+
};
|
|
248
287
|
};
|
|
288
|
+
declare function reconcileInitialChildren({ elementId, elementConfig, attributes, }: ReconcileInitialChildrenArgs): void;
|
|
249
289
|
|
|
250
290
|
type ElementModel = {
|
|
251
291
|
id: string;
|
|
@@ -386,8 +426,12 @@ declare function getCurrentDocumentId(): number | null;
|
|
|
386
426
|
|
|
387
427
|
declare function getElementEditorSettings(elementId: ElementID): V1ElementEditorSettingsProps;
|
|
388
428
|
|
|
429
|
+
declare function getElementIcon(elementId: ElementID): string | null;
|
|
430
|
+
|
|
389
431
|
declare function getElementLabel(elementId?: ElementID): string;
|
|
390
432
|
|
|
433
|
+
declare function getElementTitle(elementId: ElementID): string | null;
|
|
434
|
+
|
|
391
435
|
declare const getElementSetting: <TValue>(elementId: ElementID, settingKey: string) => TValue | null;
|
|
392
436
|
declare const getElementSettings: <TValue>(elementId: ElementID, settingKey: string[]) => Record<string, TValue | null>;
|
|
393
437
|
|
|
@@ -483,6 +527,8 @@ type ReplaceElementArgs = {
|
|
|
483
527
|
};
|
|
484
528
|
declare const replaceElement: ({ currentElementId, newElement, withHistory }: ReplaceElementArgs) => V1Element;
|
|
485
529
|
|
|
530
|
+
declare function resolveInsertIndex(position: ElementPosition, elements: V1ElementData[]): number;
|
|
531
|
+
|
|
486
532
|
declare const updateElementEditorSettings: ({ elementId, settings, }: {
|
|
487
533
|
elementId: string;
|
|
488
534
|
settings: V1ElementModelProps["editor_settings"];
|
|
@@ -548,4 +594,4 @@ declare const updateElementInteractions: ({ elementId, interactions, }: {
|
|
|
548
594
|
}) => void;
|
|
549
595
|
declare const playElementInteractions: (elementId: string, interactionId: string) => void;
|
|
550
596
|
|
|
551
|
-
export { type AnimationPresetPropValue, type BackboneCollection, type BackboneModel, type BooleanPropValue, 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 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, createElement, createElementStyle, createElements, deleteElement, deleteElementStyle, dropElement, duplicateElement, duplicateElements, findChildRecursive, findModelInDocument, generateElementId, getAllDescendants, getAnchoredAncestorId, getAnchoredDescendantId, getContainer, getCurrentDocumentContainer, getCurrentDocumentId, getElementChildren as getElementChildrenWithFallback, getElementEditorSettings, getElementInteractions, getElementLabel, getElementSetting, getElementSettings, getElementStyles, getElementType, getElements, getLinkInLinkRestriction, getSelectedElements, getWidgetsCache, isElementAnchored, moveElement, moveElements, playElementInteractions, removeElements, removeModelFromParent, replaceElement, resolveContainer, selectElement, shouldCreateNewLocalStyle, styleRerenderEvents, updateElementEditorSettings, updateElementInteractions, updateElementSettings, updateElementStyle, useElementChildren, useElementEditorSettings, useParentElement, useSelectedElement, useSelectedElementSettings };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PropsSchema, PropValue, SizePropValue, AnyTransformable, Props, LinkPropValue } from '@elementor/editor-props';
|
|
1
|
+
import { PropsSchema, Dependency, PropValue, SizePropValue, AnyTransformable, Props, LinkPropValue } from '@elementor/editor-props';
|
|
2
2
|
import { ClassState, StyleDefinitionID, StyleDefinition, StyleDefinitionVariant } from '@elementor/editor-styles';
|
|
3
3
|
import * as _elementor_editor_v1_adapters from '@elementor/editor-v1-adapters';
|
|
4
4
|
|
|
@@ -58,6 +58,15 @@ type ElementControl = {
|
|
|
58
58
|
type ControlItem = ControlsSection | Control | ElementControl;
|
|
59
59
|
type ControlLayout = 'full' | 'two-columns' | 'custom';
|
|
60
60
|
|
|
61
|
+
type ChildDependencyRule = {
|
|
62
|
+
child_type: string;
|
|
63
|
+
when: Dependency;
|
|
64
|
+
position: ElementPosition;
|
|
65
|
+
stash: boolean;
|
|
66
|
+
default_model: V1ElementData | null;
|
|
67
|
+
};
|
|
68
|
+
type ChildDependenciesConfig = ChildDependencyRule[];
|
|
69
|
+
|
|
61
70
|
type ExtendedWindow = Window & {
|
|
62
71
|
$e?: {
|
|
63
72
|
components?: {
|
|
@@ -203,10 +212,16 @@ type V1ElementModelProps = {
|
|
|
203
212
|
interactions?: string | ElementInteractions;
|
|
204
213
|
isGlobal?: boolean;
|
|
205
214
|
skipDefaultChildren?: boolean;
|
|
215
|
+
hydrateDefaultChildren?: boolean;
|
|
206
216
|
};
|
|
207
217
|
type V1ElementData = Omit<V1ElementModelProps, 'elements'> & {
|
|
208
218
|
elements?: V1ElementData[];
|
|
209
219
|
};
|
|
220
|
+
type ElementPositionKind = 'last' | 'first' | 'index' | 'after_type' | 'before_type';
|
|
221
|
+
type ElementPosition = {
|
|
222
|
+
kind: ElementPositionKind;
|
|
223
|
+
value: number | string | null;
|
|
224
|
+
};
|
|
210
225
|
type V1ElementEditorSettingsProps = {
|
|
211
226
|
title?: string;
|
|
212
227
|
initial_position?: number;
|
|
@@ -234,6 +249,7 @@ type V1ElementConfig<T = object, TChild = unknown> = {
|
|
|
234
249
|
show_in_panel?: boolean;
|
|
235
250
|
allowed_child_types?: string[];
|
|
236
251
|
default_children?: Array<Record<string, TChild>>;
|
|
252
|
+
children_dependencies?: ChildDependencyRule[];
|
|
237
253
|
meta?: {
|
|
238
254
|
[key: string]: string | number | boolean | null | NonNullable<V1ElementConfig['meta']>;
|
|
239
255
|
};
|
|
@@ -245,7 +261,31 @@ type V1Model$1<T> = {
|
|
|
245
261
|
remove?: string[];
|
|
246
262
|
}) => T;
|
|
247
263
|
trigger?: (event: string, ...args: unknown[]) => void;
|
|
264
|
+
on?: (event: string, callback: (...args: unknown[]) => void, context?: unknown) => void;
|
|
265
|
+
off?: (event: string, callback?: (...args: unknown[]) => void, context?: unknown) => void;
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
type ReactiveModel = {
|
|
269
|
+
get: (key: string) => unknown;
|
|
270
|
+
};
|
|
271
|
+
type BindSettingsReconcileArgs = {
|
|
272
|
+
model: ReactiveModel;
|
|
273
|
+
elementConfig: V1ElementConfig | undefined;
|
|
274
|
+
};
|
|
275
|
+
type Detach = () => void;
|
|
276
|
+
declare function bindSettingsReconcile({ model, elementConfig }: BindSettingsReconcileArgs): Detach;
|
|
277
|
+
|
|
278
|
+
declare function evaluateWhen(when: Dependency | undefined, settings: Record<string, PropValue>): boolean;
|
|
279
|
+
|
|
280
|
+
type ReconcileInitialChildrenArgs = {
|
|
281
|
+
elementId: string;
|
|
282
|
+
elementConfig: V1ElementConfig | undefined;
|
|
283
|
+
attributes: {
|
|
284
|
+
elements?: V1ElementData[];
|
|
285
|
+
settings?: V1ElementSettingsProps;
|
|
286
|
+
};
|
|
248
287
|
};
|
|
288
|
+
declare function reconcileInitialChildren({ elementId, elementConfig, attributes, }: ReconcileInitialChildrenArgs): void;
|
|
249
289
|
|
|
250
290
|
type ElementModel = {
|
|
251
291
|
id: string;
|
|
@@ -386,8 +426,12 @@ declare function getCurrentDocumentId(): number | null;
|
|
|
386
426
|
|
|
387
427
|
declare function getElementEditorSettings(elementId: ElementID): V1ElementEditorSettingsProps;
|
|
388
428
|
|
|
429
|
+
declare function getElementIcon(elementId: ElementID): string | null;
|
|
430
|
+
|
|
389
431
|
declare function getElementLabel(elementId?: ElementID): string;
|
|
390
432
|
|
|
433
|
+
declare function getElementTitle(elementId: ElementID): string | null;
|
|
434
|
+
|
|
391
435
|
declare const getElementSetting: <TValue>(elementId: ElementID, settingKey: string) => TValue | null;
|
|
392
436
|
declare const getElementSettings: <TValue>(elementId: ElementID, settingKey: string[]) => Record<string, TValue | null>;
|
|
393
437
|
|
|
@@ -483,6 +527,8 @@ type ReplaceElementArgs = {
|
|
|
483
527
|
};
|
|
484
528
|
declare const replaceElement: ({ currentElementId, newElement, withHistory }: ReplaceElementArgs) => V1Element;
|
|
485
529
|
|
|
530
|
+
declare function resolveInsertIndex(position: ElementPosition, elements: V1ElementData[]): number;
|
|
531
|
+
|
|
486
532
|
declare const updateElementEditorSettings: ({ elementId, settings, }: {
|
|
487
533
|
elementId: string;
|
|
488
534
|
settings: V1ElementModelProps["editor_settings"];
|
|
@@ -548,4 +594,4 @@ declare const updateElementInteractions: ({ elementId, interactions, }: {
|
|
|
548
594
|
}) => void;
|
|
549
595
|
declare const playElementInteractions: (elementId: string, interactionId: string) => void;
|
|
550
596
|
|
|
551
|
-
export { type AnimationPresetPropValue, type BackboneCollection, type BackboneModel, type BooleanPropValue, 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 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, createElement, createElementStyle, createElements, deleteElement, deleteElementStyle, dropElement, duplicateElement, duplicateElements, findChildRecursive, findModelInDocument, generateElementId, getAllDescendants, getAnchoredAncestorId, getAnchoredDescendantId, getContainer, getCurrentDocumentContainer, getCurrentDocumentId, getElementChildren as getElementChildrenWithFallback, getElementEditorSettings, getElementInteractions, getElementLabel, getElementSetting, getElementSettings, getElementStyles, getElementType, getElements, getLinkInLinkRestriction, getSelectedElements, getWidgetsCache, isElementAnchored, moveElement, moveElements, playElementInteractions, removeElements, removeModelFromParent, replaceElement, resolveContainer, selectElement, shouldCreateNewLocalStyle, styleRerenderEvents, updateElementEditorSettings, updateElementInteractions, updateElementSettings, updateElementStyle, useElementChildren, useElementEditorSettings, useParentElement, useSelectedElement, useSelectedElementSettings };
|
|
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 };
|