@elementor/editor-elements 3.32.0-86 → 3.32.0-89

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 CHANGED
@@ -62,7 +62,7 @@ type V1ElementModelProps = {
62
62
  id: string;
63
63
  styles?: Record<StyleDefinitionID, StyleDefinition>;
64
64
  elements?: V1Model<V1ElementModelProps>[];
65
- settings?: V1Model<V1ElementSettingsProps>;
65
+ settings?: V1ElementSettingsProps;
66
66
  };
67
67
  type V1ElementSettingsProps = Record<string, PropValue>;
68
68
  type V1ElementConfig = {
@@ -80,7 +80,9 @@ type V1ElementConfig = {
80
80
  type V1Model<T> = {
81
81
  get: <K extends keyof T>(key: K) => T[K];
82
82
  set: <K extends keyof T>(key: K, value: T[K]) => void;
83
- toJSON: () => T;
83
+ toJSON: (options?: {
84
+ remove?: string[];
85
+ }) => T;
84
86
  };
85
87
 
86
88
  declare const useElementSetting: <TValue>(elementId: ElementID, settingKey: string) => TValue | null;
@@ -220,6 +222,13 @@ declare const updateElementSettings: ({ id, props, withHistory }: UpdateElementS
220
222
 
221
223
  declare const generateElementId: () => string;
222
224
 
225
+ type ReplaceElementArgs = {
226
+ currentElement: V1Element;
227
+ newElement: Omit<V1ElementModelProps, 'id'>;
228
+ withHistory?: boolean;
229
+ };
230
+ declare const replaceElement: ({ currentElement, newElement, withHistory }: ReplaceElementArgs) => void;
231
+
223
232
  declare const ELEMENT_STYLE_CHANGE_EVENT = "elementor/editor-v2/editor-elements/style";
224
233
  declare const styleRerenderEvents: (_elementor_editor_v1_adapters.CommandEventDescriptor | _elementor_editor_v1_adapters.WindowEventDescriptor)[];
225
234
 
@@ -264,4 +273,4 @@ declare function getAnchoredDescendantId(elementId: string): string | null;
264
273
  declare function getAnchoredAncestorId(elementId: string): string | null;
265
274
  declare function isElementAnchored(elementId: string): boolean;
266
275
 
267
- export { type Control, type ControlItem, type ControlLayout, type ControlsSection, type CreateElementParams, type CreateElementStyleArgs, type DuplicateElementParams, type DuplicateElementsParams, type DuplicatedElement, type DuplicatedElementsResult, ELEMENT_STYLE_CHANGE_EVENT, type Element, type ElementChildren, type ElementID, type ElementType, type LinkInLinkRestriction, type UpdateElementSettingsArgs, type UpdateElementStyleArgs, type V1Element, type V1ElementConfig, type V1ElementModelProps, type V1ElementSettingsProps, createElement, createElementStyle, createElements, deleteElement, deleteElementStyle, duplicateElement, duplicateElements, generateElementId, getAnchoredAncestorId, getAnchoredDescendantId, getContainer, getCurrentDocumentId, getElementLabel, getElementSetting, getElementSettings, getElementStyles, getElements, getLinkInLinkRestriction, getSelectedElements, getWidgetsCache, isElementAnchored, removeElements, selectElement, shouldCreateNewLocalStyle, styleRerenderEvents, updateElementSettings, updateElementStyle, useElementChildren, useElementSetting, useElementSettings, useElementType, useParentElement, useSelectedElement };
276
+ export { type Control, type ControlItem, type ControlLayout, type ControlsSection, type CreateElementParams, type CreateElementStyleArgs, type DuplicateElementParams, type DuplicateElementsParams, type DuplicatedElement, type DuplicatedElementsResult, ELEMENT_STYLE_CHANGE_EVENT, type Element, type ElementChildren, type ElementID, type ElementType, type LinkInLinkRestriction, type UpdateElementSettingsArgs, type UpdateElementStyleArgs, type V1Element, type V1ElementConfig, type V1ElementModelProps, type V1ElementSettingsProps, createElement, createElementStyle, createElements, deleteElement, deleteElementStyle, duplicateElement, duplicateElements, generateElementId, getAnchoredAncestorId, getAnchoredDescendantId, getContainer, getCurrentDocumentId, getElementLabel, getElementSetting, getElementSettings, getElementStyles, getElements, getLinkInLinkRestriction, getSelectedElements, getWidgetsCache, isElementAnchored, removeElements, replaceElement, selectElement, shouldCreateNewLocalStyle, styleRerenderEvents, updateElementSettings, updateElementStyle, useElementChildren, useElementSetting, useElementSettings, useElementType, useParentElement, useSelectedElement };
package/dist/index.d.ts CHANGED
@@ -62,7 +62,7 @@ type V1ElementModelProps = {
62
62
  id: string;
63
63
  styles?: Record<StyleDefinitionID, StyleDefinition>;
64
64
  elements?: V1Model<V1ElementModelProps>[];
65
- settings?: V1Model<V1ElementSettingsProps>;
65
+ settings?: V1ElementSettingsProps;
66
66
  };
67
67
  type V1ElementSettingsProps = Record<string, PropValue>;
68
68
  type V1ElementConfig = {
@@ -80,7 +80,9 @@ type V1ElementConfig = {
80
80
  type V1Model<T> = {
81
81
  get: <K extends keyof T>(key: K) => T[K];
82
82
  set: <K extends keyof T>(key: K, value: T[K]) => void;
83
- toJSON: () => T;
83
+ toJSON: (options?: {
84
+ remove?: string[];
85
+ }) => T;
84
86
  };
85
87
 
86
88
  declare const useElementSetting: <TValue>(elementId: ElementID, settingKey: string) => TValue | null;
@@ -220,6 +222,13 @@ declare const updateElementSettings: ({ id, props, withHistory }: UpdateElementS
220
222
 
221
223
  declare const generateElementId: () => string;
222
224
 
225
+ type ReplaceElementArgs = {
226
+ currentElement: V1Element;
227
+ newElement: Omit<V1ElementModelProps, 'id'>;
228
+ withHistory?: boolean;
229
+ };
230
+ declare const replaceElement: ({ currentElement, newElement, withHistory }: ReplaceElementArgs) => void;
231
+
223
232
  declare const ELEMENT_STYLE_CHANGE_EVENT = "elementor/editor-v2/editor-elements/style";
224
233
  declare const styleRerenderEvents: (_elementor_editor_v1_adapters.CommandEventDescriptor | _elementor_editor_v1_adapters.WindowEventDescriptor)[];
225
234
 
@@ -264,4 +273,4 @@ declare function getAnchoredDescendantId(elementId: string): string | null;
264
273
  declare function getAnchoredAncestorId(elementId: string): string | null;
265
274
  declare function isElementAnchored(elementId: string): boolean;
266
275
 
267
- export { type Control, type ControlItem, type ControlLayout, type ControlsSection, type CreateElementParams, type CreateElementStyleArgs, type DuplicateElementParams, type DuplicateElementsParams, type DuplicatedElement, type DuplicatedElementsResult, ELEMENT_STYLE_CHANGE_EVENT, type Element, type ElementChildren, type ElementID, type ElementType, type LinkInLinkRestriction, type UpdateElementSettingsArgs, type UpdateElementStyleArgs, type V1Element, type V1ElementConfig, type V1ElementModelProps, type V1ElementSettingsProps, createElement, createElementStyle, createElements, deleteElement, deleteElementStyle, duplicateElement, duplicateElements, generateElementId, getAnchoredAncestorId, getAnchoredDescendantId, getContainer, getCurrentDocumentId, getElementLabel, getElementSetting, getElementSettings, getElementStyles, getElements, getLinkInLinkRestriction, getSelectedElements, getWidgetsCache, isElementAnchored, removeElements, selectElement, shouldCreateNewLocalStyle, styleRerenderEvents, updateElementSettings, updateElementStyle, useElementChildren, useElementSetting, useElementSettings, useElementType, useParentElement, useSelectedElement };
276
+ export { type Control, type ControlItem, type ControlLayout, type ControlsSection, type CreateElementParams, type CreateElementStyleArgs, type DuplicateElementParams, type DuplicateElementsParams, type DuplicatedElement, type DuplicatedElementsResult, ELEMENT_STYLE_CHANGE_EVENT, type Element, type ElementChildren, type ElementID, type ElementType, type LinkInLinkRestriction, type UpdateElementSettingsArgs, type UpdateElementStyleArgs, type V1Element, type V1ElementConfig, type V1ElementModelProps, type V1ElementSettingsProps, createElement, createElementStyle, createElements, deleteElement, deleteElementStyle, duplicateElement, duplicateElements, generateElementId, getAnchoredAncestorId, getAnchoredDescendantId, getContainer, getCurrentDocumentId, getElementLabel, getElementSetting, getElementSettings, getElementStyles, getElements, getLinkInLinkRestriction, getSelectedElements, getWidgetsCache, isElementAnchored, removeElements, replaceElement, selectElement, shouldCreateNewLocalStyle, styleRerenderEvents, updateElementSettings, updateElementStyle, useElementChildren, useElementSetting, useElementSettings, useElementType, useParentElement, useSelectedElement };
package/dist/index.js CHANGED
@@ -43,6 +43,7 @@ __export(index_exports, {
43
43
  getWidgetsCache: () => getWidgetsCache,
44
44
  isElementAnchored: () => isElementAnchored,
45
45
  removeElements: () => removeElements,
46
+ replaceElement: () => replaceElement,
46
47
  selectElement: () => selectElement,
47
48
  shouldCreateNewLocalStyle: () => shouldCreateNewLocalStyle,
48
49
  styleRerenderEvents: () => styleRerenderEvents,
@@ -569,6 +570,24 @@ var generateElementId = () => {
569
570
  return extendedWindow.elementorCommon?.helpers?.getUniqueId?.() ?? `el-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
570
571
  };
571
572
 
573
+ // src/sync/replace-element.ts
574
+ var replaceElement = ({ currentElement, newElement, withHistory = true }) => {
575
+ const parent = getContainer(currentElement.id)?.parent;
576
+ if (!parent) {
577
+ throw new Error(`Parent not found for element ${currentElement.id}. Cannot replace element.`);
578
+ }
579
+ const elementIndex = parent.children?.findIndex((child) => child.id === currentElement.id);
580
+ if (elementIndex === void 0 || elementIndex === -1) {
581
+ throw new Error(`Element ${currentElement.id} not found in parent container. Cannot replace element.`);
582
+ }
583
+ createElement({
584
+ containerId: parent.id,
585
+ model: newElement,
586
+ options: { at: elementIndex, useHistory: withHistory }
587
+ });
588
+ deleteElement({ elementId: currentElement.id, options: { useHistory: withHistory } });
589
+ };
590
+
572
591
  // src/styles/consts.ts
573
592
  var import_editor_v1_adapters13 = require("@elementor/editor-v1-adapters");
574
593
  var ELEMENT_STYLE_CHANGE_EVENT = "elementor/editor-v2/editor-elements/style";
@@ -831,6 +850,7 @@ function isElementorElement(element) {
831
850
  getWidgetsCache,
832
851
  isElementAnchored,
833
852
  removeElements,
853
+ replaceElement,
834
854
  selectElement,
835
855
  shouldCreateNewLocalStyle,
836
856
  styleRerenderEvents,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/hooks/use-element-setting.ts","../src/sync/get-container.ts","../src/sync/get-element-setting.ts","../src/hooks/use-element-type.ts","../src/sync/get-widgets-cache.ts","../src/hooks/use-selected-element.ts","../src/sync/get-selected-elements.ts","../src/hooks/use-parent-element.ts","../src/hooks/use-element-children.ts","../src/sync/create-element.ts","../src/sync/duplicate-element.ts","../src/sync/create-elements.ts","../src/sync/delete-element.ts","../src/sync/duplicate-elements.ts","../src/sync/remove-elements.ts","../src/sync/get-element-styles.ts","../src/errors.ts","../src/sync/get-element-label.ts","../src/sync/get-current-document-container.ts","../src/sync/get-elements.ts","../src/sync/get-current-document-id.ts","../src/sync/update-element-settings.ts","../src/sync/generate-element-id.ts","../src/styles/consts.ts","../src/styles/create-element-style.ts","../src/styles/mutate-element-styles.ts","../src/styles/update-element-style.ts","../src/styles/delete-element-style.ts","../src/link-restriction.ts"],"sourcesContent":["// types\nexport * from './types';\nexport type { V1Element, V1ElementModelProps, V1ElementSettingsProps, V1ElementConfig } from './sync/types';\n\n// hooks\nexport { useElementSetting, useElementSettings } from './hooks/use-element-setting';\nexport { useElementType } from './hooks/use-element-type';\nexport { useSelectedElement } from './hooks/use-selected-element';\nexport { useParentElement } from './hooks/use-parent-element';\nexport { useElementChildren, type ElementChildren } from './hooks/use-element-children';\n\n// utils\nexport { createElement, type CreateElementParams } from './sync/create-element';\nexport { duplicateElement, type DuplicateElementParams } from './sync/duplicate-element';\nexport { createElements } from './sync/create-elements';\nexport {\n\tduplicateElements,\n\ttype DuplicateElementsParams,\n\ttype DuplicatedElement,\n\ttype DuplicatedElementsResult,\n} from './sync/duplicate-elements';\nexport { deleteElement } from './sync/delete-element';\nexport { removeElements } from './sync/remove-elements';\nexport { getContainer, selectElement } from './sync/get-container';\nexport { getElementSetting, getElementSettings } from './sync/get-element-setting';\nexport { getElementStyles } from './sync/get-element-styles';\nexport { getElementLabel } from './sync/get-element-label';\nexport { getElements } from './sync/get-elements';\nexport { getCurrentDocumentId } from './sync/get-current-document-id';\nexport { getSelectedElements } from './sync/get-selected-elements';\nexport { getWidgetsCache } from './sync/get-widgets-cache';\nexport { updateElementSettings, type UpdateElementSettingsArgs } from './sync/update-element-settings';\nexport { generateElementId } from './sync/generate-element-id';\n\nexport { ELEMENT_STYLE_CHANGE_EVENT, styleRerenderEvents } from './styles/consts';\nexport {\n\tcreateElementStyle,\n\tshouldCreateNewLocalStyle,\n\ttype CreateElementStyleArgs,\n} from './styles/create-element-style';\nexport { updateElementStyle, type UpdateElementStyleArgs } from './styles/update-element-style';\nexport { deleteElementStyle } from './styles/delete-element-style';\nexport {\n\tisElementAnchored,\n\tgetAnchoredDescendantId,\n\tgetAnchoredAncestorId,\n\tgetLinkInLinkRestriction,\n\ttype LinkInLinkRestriction,\n} from './link-restriction';\n","import { __privateUseListenTo as useListenTo, commandEndEvent } from '@elementor/editor-v1-adapters';\n\nimport { getElementSetting } from '../sync/get-element-setting';\nimport { type ElementID } from '../types';\n\nexport const useElementSetting = < TValue >( elementId: ElementID, settingKey: string ) => {\n\treturn useListenTo(\n\t\tcommandEndEvent( 'document/elements/set-settings' ),\n\t\t() => getElementSetting< TValue >( elementId, settingKey ),\n\t\t[ elementId, settingKey ]\n\t);\n};\n\nexport const useElementSettings = < TValue >( elementId: ElementID, settingKeys: string[] ) => {\n\treturn useListenTo(\n\t\tcommandEndEvent( 'document/elements/set-settings' ),\n\t\t() =>\n\t\t\tsettingKeys.reduce< Record< string, TValue > >( ( settings, key ) => {\n\t\t\t\tconst value = getElementSetting< TValue >( elementId, key );\n\n\t\t\t\tif ( value !== null ) {\n\t\t\t\t\tsettings[ key ] = value;\n\t\t\t\t}\n\n\t\t\t\treturn settings;\n\t\t\t}, {} ),\n\t\t[ elementId, ...settingKeys ]\n\t);\n};\n","import { __privateRunCommand as runCommand } from '@elementor/editor-v1-adapters';\n\nimport { type ExtendedWindow, type V1Element } from './types';\n\nexport function getContainer( id: string ): V1Element | null {\n\tconst extendedWindow = window as unknown as ExtendedWindow;\n\tconst container = extendedWindow.elementor?.getContainer?.( id );\n\n\treturn container ?? null;\n}\n\nexport const selectElement = ( elementId: string ) => {\n\ttry {\n\t\tconst container = getContainer( elementId );\n\n\t\trunCommand( 'document/elements/select', { container } );\n\t} catch {}\n};\n","import { type ElementID } from '../types';\nimport { getContainer } from './get-container';\n\nexport const getElementSetting = < TValue >( elementId: ElementID, settingKey: string ): TValue | null => {\n\tconst container = getContainer( elementId );\n\n\treturn ( container?.settings?.get( settingKey ) as TValue ) ?? null;\n};\n\nexport const getElementSettings = < TValue >(\n\telementId: ElementID,\n\tsettingKey: string[]\n): Record< string, TValue | null > => {\n\treturn Object.fromEntries( settingKey.map( ( key ) => [ key, getElementSetting( elementId, key ) ] ) );\n};\n","import { __privateUseListenTo as useListenTo, commandEndEvent } from '@elementor/editor-v1-adapters';\n\nimport { getWidgetsCache } from '../sync/get-widgets-cache';\nimport { type ElementType } from '../types';\n\nexport function useElementType( type?: string ) {\n\treturn useListenTo(\n\t\tcommandEndEvent( 'editor/documents/load' ),\n\t\t(): ElementType | null => {\n\t\t\tif ( ! type ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst widgetsCache = getWidgetsCache();\n\t\t\tconst elementType = widgetsCache?.[ type ];\n\n\t\t\tif ( ! elementType?.atomic_controls ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tif ( ! elementType?.atomic_props_schema ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tkey: type,\n\t\t\t\tcontrols: elementType.atomic_controls,\n\t\t\t\tpropsSchema: elementType.atomic_props_schema,\n\t\t\t\tdependenciesPerTargetMapping: elementType.dependencies_per_target_mapping ?? {},\n\t\t\t\ttitle: elementType.title,\n\t\t\t};\n\t\t},\n\t\t[ type ]\n\t);\n}\n","import { type ExtendedWindow } from './types';\n\nexport function getWidgetsCache() {\n\tconst extendedWindow = window as unknown as ExtendedWindow;\n\n\treturn extendedWindow?.elementor?.widgetsCache || null;\n}\n","import { __privateUseListenTo as useListenTo, commandEndEvent } from '@elementor/editor-v1-adapters';\n\nimport { getSelectedElements } from '../sync/get-selected-elements';\nimport { useElementType } from './use-element-type';\n\nexport function useSelectedElement() {\n\tconst elements = useListenTo(\n\t\t[\n\t\t\tcommandEndEvent( 'document/elements/select' ),\n\t\t\tcommandEndEvent( 'document/elements/deselect' ),\n\t\t\tcommandEndEvent( 'document/elements/select-all' ),\n\t\t\tcommandEndEvent( 'document/elements/deselect-all' ),\n\t\t],\n\t\tgetSelectedElements\n\t);\n\n\tconst [ element ] = elements;\n\n\tconst elementType = useElementType( element?.type );\n\n\tif ( elements.length !== 1 || ! elementType ) {\n\t\treturn { element: null, elementType: null };\n\t}\n\n\treturn { element, elementType };\n}\n","import { type Element } from '../types';\nimport { type ExtendedWindow } from './types';\n\nexport function getSelectedElements(): Element[] {\n\tconst extendedWindow = window as unknown as ExtendedWindow;\n\n\tconst selectedElements = extendedWindow.elementor?.selection?.getElements?.() ?? [];\n\n\treturn selectedElements.reduce< Element[] >( ( acc, el ) => {\n\t\tconst type = el.model.get( 'widgetType' ) || el.model.get( 'elType' );\n\n\t\tif ( type ) {\n\t\t\tacc.push( {\n\t\t\t\tid: el.model.get( 'id' ),\n\t\t\t\ttype,\n\t\t\t} );\n\t\t}\n\n\t\treturn acc;\n\t}, [] );\n}\n","import { __privateUseListenTo as useListenTo, commandEndEvent } from '@elementor/editor-v1-adapters';\n\nimport { type ExtendedWindow } from '../sync/types';\n\nexport function useParentElement( elementId: string | null ) {\n\treturn useListenTo(\n\t\t[ commandEndEvent( 'document/elements/create' ) ],\n\t\t() => {\n\t\t\tif ( ! elementId ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst extendedWindow = window as unknown as ExtendedWindow;\n\t\t\tconst element = extendedWindow?.elementor?.getContainer?.( elementId );\n\t\t\tif ( ! element ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\treturn element.parent;\n\t\t},\n\t\t[ elementId ]\n\t);\n}\n","import { __privateUseListenTo as useListenTo, commandEndEvent, v1ReadyEvent } from '@elementor/editor-v1-adapters';\n\nimport { getContainer } from '../sync/get-container';\nimport { type ElementID } from '../types';\n\ntype ElementModel = {\n\tid: string;\n};\n\nexport type ElementChildren = Record< string, ElementModel[] >;\n\nexport function useElementChildren< T extends ElementChildren >(\n\telementId: ElementID,\n\tchildrenTypes: ( keyof T & string )[]\n): T {\n\treturn useListenTo(\n\t\t[\n\t\t\tv1ReadyEvent(),\n\t\t\tcommandEndEvent( 'document/elements/create' ),\n\t\t\tcommandEndEvent( 'document/elements/delete' ),\n\t\t\tcommandEndEvent( 'document/elements/update' ),\n\t\t\tcommandEndEvent( 'document/elements/set-settings' ),\n\t\t],\n\t\t() => {\n\t\t\tconst container = getContainer( elementId );\n\n\t\t\tconst elementChildren = childrenTypes.reduce( ( acc, type ) => {\n\t\t\t\tacc[ type ] = [];\n\n\t\t\t\treturn acc;\n\t\t\t}, {} as ElementChildren );\n\n\t\t\tcontainer?.children?.forEachRecursive?.( ( { model, id } ) => {\n\t\t\t\tconst elType = model.get( 'elType' );\n\n\t\t\t\tif ( elType && elType in elementChildren ) {\n\t\t\t\t\telementChildren[ elType ].push( { id } );\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\treturn elementChildren;\n\t\t},\n\t\t[ elementId ]\n\t) as T;\n}\n","import { __privateRunCommandSync as runCommandSync } from '@elementor/editor-v1-adapters';\n\nimport { getContainer } from './get-container';\nimport { type V1Element, type V1ElementModelProps, type V1ElementSettingsProps } from './types';\n\ntype Options = {\n\tuseHistory?: boolean;\n\tat?: number;\n\tclone?: boolean;\n};\n\nexport type CreateElementParams = {\n\tcontainerId: string;\n\toptions?: Options;\n\tmodel?: Omit< V1ElementModelProps, 'settings' | 'id' > & { settings?: V1ElementSettingsProps; id?: string };\n};\n\nexport function createElement( { containerId, model, options }: CreateElementParams ) {\n\tconst container = getContainer( containerId );\n\n\tif ( ! container ) {\n\t\tthrow new Error( `Container with ID \"${ containerId }\" not found` );\n\t}\n\n\treturn runCommandSync< V1Element >( 'document/elements/create', {\n\t\tcontainer,\n\t\tmodel,\n\t\toptions: { edit: false, ...options },\n\t} );\n}\n","import { createElement } from './create-element';\nimport { getContainer } from './get-container';\nimport { type V1Element } from './types';\n\ntype Options = {\n\tuseHistory?: boolean;\n\tat?: number;\n\tclone?: boolean;\n};\n\nexport type DuplicateElementParams = {\n\telementId: string;\n\toptions?: Options;\n};\n\nexport function duplicateElement( { elementId, options = {} }: DuplicateElementParams ): V1Element {\n\tconst elementToDuplicate = getContainer( elementId );\n\n\tif ( ! elementToDuplicate ) {\n\t\tthrow new Error( `Element with ID \"${ elementId }\" not found` );\n\t}\n\n\tif ( ! elementToDuplicate.parent ) {\n\t\tthrow new Error( `Element with ID \"${ elementId }\" has no parent container` );\n\t}\n\n\tconst parentContainer = elementToDuplicate.parent;\n\tconst elementModel = elementToDuplicate.model.toJSON();\n\n\t// Get the position after the original element (only when cloning)\n\tconst currentIndex = elementToDuplicate.view?._index ?? 0;\n\tconst insertPosition = options.clone !== false ? currentIndex + 1 : undefined;\n\n\treturn createElement( {\n\t\tcontainerId: parentContainer.id,\n\t\tmodel: elementModel,\n\t\toptions: {\n\t\t\tat: insertPosition,\n\t\t\t...options,\n\t\t},\n\t} );\n}\n","import { undoable } from '@elementor/editor-v1-adapters';\nimport { __ } from '@wordpress/i18n';\n\nimport { createElement, type CreateElementParams } from './create-element';\nimport { deleteElement } from './delete-element';\nimport { getContainer } from './get-container';\nimport { type V1ElementModelProps } from './types';\n\ntype CreateNestedElementsParams = {\n\telements: CreateElementParams[];\n\ttitle: string;\n\tsubtitle?: string;\n};\n\ntype CreatedElement = {\n\telementId: string;\n\tmodel: V1ElementModelProps;\n\tcreateParams: CreateElementParams;\n};\n\ntype CreatedElementsResult = {\n\tcreatedElements: CreatedElement[];\n};\n\nexport type { CreateNestedElementsParams, CreatedElement, CreatedElementsResult };\n\nexport const createElements = ( {\n\telements,\n\ttitle,\n\tsubtitle = __( 'Item added', 'elementor' ),\n}: CreateNestedElementsParams ): CreatedElementsResult => {\n\tconst undoableCreate = undoable(\n\t\t{\n\t\t\tdo: ( { elements: elementsParam }: { elements: CreateElementParams[] } ): CreatedElementsResult => {\n\t\t\t\tconst createdElements: CreatedElement[] = [];\n\n\t\t\t\telementsParam.forEach( ( createParams ) => {\n\t\t\t\t\tconst { options, ...elementParams } = createParams;\n\t\t\t\t\tconst element = createElement( {\n\t\t\t\t\t\t...elementParams,\n\t\t\t\t\t\toptions: { ...options, useHistory: false },\n\t\t\t\t\t} );\n\n\t\t\t\t\tconst elementId = element.id;\n\n\t\t\t\t\tcreatedElements.push( {\n\t\t\t\t\t\telementId,\n\t\t\t\t\t\tmodel: element.model?.toJSON() || {},\n\t\t\t\t\t\tcreateParams: {\n\t\t\t\t\t\t\t...createParams,\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\t\t\t\t} );\n\n\t\t\t\treturn { createdElements };\n\t\t\t},\n\t\t\tundo: ( _: { elements: CreateElementParams[] }, { createdElements }: CreatedElementsResult ) => {\n\t\t\t\t// Delete elements in reverse order to avoid dependency issues\n\t\t\t\t[ ...createdElements ].reverse().forEach( ( { elementId } ) => {\n\t\t\t\t\tdeleteElement( {\n\t\t\t\t\t\telementId,\n\t\t\t\t\t\toptions: { useHistory: false },\n\t\t\t\t\t} );\n\t\t\t\t} );\n\t\t\t},\n\t\t\tredo: (\n\t\t\t\t_: { elements: CreateElementParams[] },\n\t\t\t\t{ createdElements }: CreatedElementsResult\n\t\t\t): CreatedElementsResult => {\n\t\t\t\tconst newElements: CreatedElement[] = [];\n\n\t\t\t\tcreatedElements.forEach( ( { createParams, model } ) => {\n\t\t\t\t\tconst element = createElement( {\n\t\t\t\t\t\tcontainerId: createParams.containerId,\n\t\t\t\t\t\tmodel,\n\t\t\t\t\t\toptions: { ...createParams.options, useHistory: false },\n\t\t\t\t\t} );\n\n\t\t\t\t\tconst elementId = element.id;\n\n\t\t\t\t\tconst container = getContainer( elementId );\n\n\t\t\t\t\tif ( container ) {\n\t\t\t\t\t\tnewElements.push( {\n\t\t\t\t\t\t\telementId,\n\t\t\t\t\t\t\tmodel: container.model.toJSON(),\n\t\t\t\t\t\t\tcreateParams,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t} );\n\n\t\t\t\treturn { createdElements: newElements };\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttitle,\n\t\t\tsubtitle,\n\t\t}\n\t);\n\n\treturn undoableCreate( { elements } );\n};\n","import { __privateRunCommand as runCommand } from '@elementor/editor-v1-adapters';\n\nimport { getContainer } from './get-container';\n\ntype Options = {\n\tuseHistory?: boolean;\n\tat?: number;\n};\n\nexport function deleteElement( { elementId, options = {} }: { elementId: string; options?: Options } ): void {\n\tconst container = getContainer( elementId );\n\n\tif ( ! container ) {\n\t\tthrow new Error( `Element with ID \"${ elementId }\" not found` );\n\t}\n\n\trunCommand( 'document/elements/delete', {\n\t\tcontainer,\n\t\toptions,\n\t} );\n}\n","import { undoable } from '@elementor/editor-v1-adapters';\nimport { __ } from '@wordpress/i18n';\n\nimport { createElement } from './create-element';\nimport { deleteElement } from './delete-element';\nimport { duplicateElement } from './duplicate-element';\nimport { getContainer } from './get-container';\nimport { type V1ElementModelProps } from './types';\n\ntype DuplicateElementsParams = {\n\telementIds: string[];\n\ttitle: string;\n\tsubtitle?: string;\n\tonCreate?: ( duplicatedElements: DuplicatedElement[] ) => DuplicatedElement[];\n};\n\ntype DuplicatedElement = {\n\tid: string;\n\tmodel: V1ElementModelProps;\n\toriginalElementId: string;\n\tmodelToRestore?: V1ElementModelProps;\n\tparentContainerId?: string;\n\tat?: number;\n};\n\ntype DuplicatedElementsResult = {\n\tduplicatedElements: DuplicatedElement[];\n};\n\nexport type { DuplicateElementsParams, DuplicatedElement, DuplicatedElementsResult };\n\nexport const duplicateElements = ( {\n\telementIds,\n\ttitle,\n\tsubtitle = __( 'Item duplicated', 'elementor' ),\n\tonCreate,\n}: DuplicateElementsParams ): DuplicatedElementsResult => {\n\tconst undoableDuplicate = undoable(\n\t\t{\n\t\t\tdo: ( { elementIds: elementIdsToDuplicate }: { elementIds: string[] } ): DuplicatedElementsResult => {\n\t\t\t\tconst duplicatedElements: DuplicatedElement[] = elementIdsToDuplicate.reduce( ( acc, elementId ) => {\n\t\t\t\t\tconst originalContainer = getContainer( elementId );\n\n\t\t\t\t\tif ( originalContainer?.parent ) {\n\t\t\t\t\t\tconst duplicatedElement = duplicateElement( {\n\t\t\t\t\t\t\telementId,\n\t\t\t\t\t\t\toptions: { useHistory: false, clone: true },\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\tacc.push( {\n\t\t\t\t\t\t\tid: duplicatedElement.id,\n\t\t\t\t\t\t\tmodel: duplicatedElement.model.toJSON(),\n\t\t\t\t\t\t\toriginalElementId: elementId,\n\t\t\t\t\t\t\tmodelToRestore: duplicatedElement.model.toJSON(),\n\t\t\t\t\t\t\tparentContainerId: duplicatedElement.parent?.id,\n\t\t\t\t\t\t\tat: duplicatedElement.view?._index,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn acc;\n\t\t\t\t}, [] as DuplicatedElement[] );\n\n\t\t\t\treturn { duplicatedElements: onCreate?.( duplicatedElements ) ?? duplicatedElements };\n\t\t\t},\n\t\t\tundo: ( _: { elementIds: string[] }, { duplicatedElements }: DuplicatedElementsResult ) => {\n\t\t\t\t// Delete duplicated elements in reverse order to avoid dependency issues\n\t\t\t\t[ ...duplicatedElements ].reverse().forEach( ( { id } ) => {\n\t\t\t\t\tdeleteElement( {\n\t\t\t\t\t\telementId: id,\n\t\t\t\t\t\toptions: { useHistory: false },\n\t\t\t\t\t} );\n\t\t\t\t} );\n\t\t\t},\n\t\t\tredo: (\n\t\t\t\t_: { elementIds: string[] },\n\t\t\t\t{ duplicatedElements: previousElements }: DuplicatedElementsResult\n\t\t\t): DuplicatedElementsResult => {\n\t\t\t\tconst duplicatedElements: DuplicatedElement[] = previousElements.reduce( ( acc, previousElement ) => {\n\t\t\t\t\tif ( previousElement.modelToRestore && previousElement.parentContainerId ) {\n\t\t\t\t\t\tconst createdElement = createElement( {\n\t\t\t\t\t\t\tcontainerId: previousElement.parentContainerId,\n\t\t\t\t\t\t\tmodel: previousElement.modelToRestore,\n\t\t\t\t\t\t\toptions: {\n\t\t\t\t\t\t\t\tuseHistory: false,\n\t\t\t\t\t\t\t\tclone: false,\n\t\t\t\t\t\t\t\tat: previousElement.at,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\tacc.push( {\n\t\t\t\t\t\t\tid: createdElement.id,\n\t\t\t\t\t\t\tmodel: createdElement.model.toJSON(),\n\t\t\t\t\t\t\toriginalElementId: previousElement.originalElementId,\n\t\t\t\t\t\t\tmodelToRestore: previousElement.modelToRestore,\n\t\t\t\t\t\t\tparentContainerId: previousElement.parentContainerId,\n\t\t\t\t\t\t\tat: previousElement.at,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn acc;\n\t\t\t\t}, [] as DuplicatedElement[] );\n\n\t\t\t\treturn { duplicatedElements: onCreate?.( duplicatedElements ) ?? duplicatedElements };\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttitle,\n\t\t\tsubtitle,\n\t\t}\n\t);\n\n\treturn undoableDuplicate( { elementIds } );\n};\n","import { undoable } from '@elementor/editor-v1-adapters';\nimport { __ } from '@wordpress/i18n';\n\nimport { createElement } from './create-element';\nimport { deleteElement } from './delete-element';\nimport { getContainer } from './get-container';\nimport { type V1Element, type V1ElementModelProps } from './types';\n\ntype RemoveNestedElementsParams = {\n\telementIds: string[];\n\ttitle: string;\n\tsubtitle?: string;\n};\n\ntype RemovedElement = {\n\telementId: string;\n\tmodel: V1ElementModelProps;\n\tparent: V1Element | null;\n\tat: number;\n};\n\ntype RemovedElementsResult = {\n\telementIds: string[];\n\tremovedElements: RemovedElement[];\n};\n\nexport type { RemoveNestedElementsParams, RemovedElement, RemovedElementsResult };\n\nexport const removeElements = ( {\n\telementIds,\n\ttitle,\n\tsubtitle = __( 'Item removed', 'elementor' ),\n}: RemoveNestedElementsParams ): RemovedElementsResult => {\n\tconst undoableRemove = undoable(\n\t\t{\n\t\t\tdo: ( { elementIds: elementIdsParam }: { elementIds: string[] } ): RemovedElementsResult => {\n\t\t\t\tconst removedElements: RemovedElement[] = [];\n\n\t\t\t\telementIdsParam.forEach( ( elementId ) => {\n\t\t\t\t\tconst container = getContainer( elementId );\n\n\t\t\t\t\tif ( container ) {\n\t\t\t\t\t\tconst model = container.model.toJSON();\n\t\t\t\t\t\tconst parent = container.parent;\n\n\t\t\t\t\t\tconst at = container.view?._index ?? 0;\n\n\t\t\t\t\t\tremovedElements.push( {\n\t\t\t\t\t\t\telementId,\n\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\tparent: parent ?? null,\n\t\t\t\t\t\t\tat,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t} );\n\n\t\t\t\telementIdsParam.forEach( ( elementId ) => {\n\t\t\t\t\tdeleteElement( {\n\t\t\t\t\t\telementId,\n\t\t\t\t\t\toptions: { useHistory: false },\n\t\t\t\t\t} );\n\t\t\t\t} );\n\n\t\t\t\treturn { elementIds: elementIdsParam, removedElements };\n\t\t\t},\n\t\t\tundo: ( _: { elementIds: string[] }, { removedElements }: RemovedElementsResult ) => {\n\t\t\t\t// Restore elements in reverse order to maintain proper hierarchy\n\t\t\t\t[ ...removedElements ].reverse().forEach( ( { model, parent, at } ) => {\n\t\t\t\t\tif ( parent && model ) {\n\t\t\t\t\t\tcreateElement( {\n\t\t\t\t\t\t\tcontainerId: parent.id,\n\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\toptions: { useHistory: false, at },\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t},\n\t\t\tredo: (\n\t\t\t\t_: { elementIds: string[] },\n\t\t\t\t{ elementIds: originalElementIds, removedElements }: RemovedElementsResult\n\t\t\t): RemovedElementsResult => {\n\t\t\t\toriginalElementIds.forEach( ( elementId ) => {\n\t\t\t\t\tdeleteElement( {\n\t\t\t\t\t\telementId,\n\t\t\t\t\t\toptions: { useHistory: false },\n\t\t\t\t\t} );\n\t\t\t\t} );\n\n\t\t\t\treturn { elementIds: originalElementIds, removedElements };\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttitle,\n\t\t\tsubtitle,\n\t\t}\n\t);\n\n\treturn undoableRemove( { elementIds } );\n};\n","import { type StyleDefinition } from '@elementor/editor-styles';\n\nimport { type ElementID } from '../types';\nimport { getContainer } from './get-container';\n\nexport const getElementStyles = ( elementID: ElementID ): Record< string, StyleDefinition > | null => {\n\tconst container = getContainer( elementID );\n\n\treturn container?.model.get( 'styles' ) || null;\n};\n","import { createError } from '@elementor/utils';\n\nexport const ElementNotFoundError = createError< { elementId: string } >( {\n\tcode: 'element_not_found',\n\tmessage: 'Element not found.',\n} );\n\nexport const StyleNotFoundError = createError< { styleId: string } >( {\n\tcode: 'style_not_found',\n\tmessage: 'Style not found.',\n} );\n\nexport const ElementTypeNotExistsError = createError< { elementId: string } >( {\n\tcode: 'element_type_not_exists',\n\tmessage: 'Element type does not exist.',\n} );\n\nexport const ElementLabelNotExistsError = createError< { elementType: string } >( {\n\tcode: 'element_label_not_exists',\n\tmessage: 'Element label does not exist.',\n} );\n","import { ElementLabelNotExistsError, ElementTypeNotExistsError } from '../errors';\nimport { getContainer } from '../sync/get-container';\nimport { getWidgetsCache } from '../sync/get-widgets-cache';\nimport { type ElementID } from '../types';\n\nexport function getElementLabel( elementId: ElementID ) {\n\tconst container = getContainer( elementId );\n\n\tconst type = container?.model.get( 'widgetType' ) || container?.model.get( 'elType' );\n\n\tif ( ! type ) {\n\t\tthrow new ElementTypeNotExistsError( { context: { elementId } } );\n\t}\n\n\tconst label = getWidgetsCache()?.[ type ]?.title;\n\n\tif ( ! label ) {\n\t\tthrow new ElementLabelNotExistsError( { context: { elementType: type } } );\n\t}\n\n\treturn label;\n}\n","import { type ExtendedWindow } from './types';\n\nexport default function getCurrentDocumentContainer() {\n\tconst extendedWindow = window as unknown as ExtendedWindow;\n\n\treturn extendedWindow.elementor?.documents?.getCurrent?.()?.container ?? null;\n}\n","import { type ElementID } from '../types';\nimport { getContainer } from './get-container';\nimport getCurrentDocumentContainer from './get-current-document-container';\nimport { type V1Element } from './types';\n\nexport function getElements( root?: ElementID ): V1Element[] {\n\tconst container = root ? getContainer( root ) : getCurrentDocumentContainer();\n\n\tif ( ! container ) {\n\t\treturn [];\n\t}\n\n\tconst children = [ ...( container.model.get( 'elements' ) ?? [] ) ].flatMap( ( childModel ) =>\n\t\tgetElements( childModel.get( 'id' ) )\n\t);\n\n\treturn [ container, ...children ];\n}\n","import { type ExtendedWindow } from './types';\n\nexport function getCurrentDocumentId() {\n\tconst extendedWindow = window as unknown as ExtendedWindow;\n\n\treturn extendedWindow.elementor?.documents?.getCurrentId?.() ?? null;\n}\n","import { type Props } from '@elementor/editor-props';\nimport { __privateRunCommandSync as runCommandSync } from '@elementor/editor-v1-adapters';\n\nimport { type ElementID } from '../types';\nimport { getContainer } from './get-container';\n\nexport type UpdateElementSettingsArgs = {\n\tid: ElementID;\n\tprops: Props;\n\twithHistory?: boolean;\n};\n\nexport const updateElementSettings = ( { id, props, withHistory = true }: UpdateElementSettingsArgs ) => {\n\tconst container = getContainer( id );\n\n\tconst args = {\n\t\tcontainer,\n\t\tsettings: { ...props },\n\t};\n\n\tif ( withHistory ) {\n\t\trunCommandSync( 'document/elements/settings', args );\n\t} else {\n\t\trunCommandSync( 'document/elements/set-settings', args, { internal: true } );\n\t}\n};\n","import { type ExtendedWindow } from './types';\n\nexport const generateElementId = () => {\n\tconst extendedWindow = window as unknown as ExtendedWindow;\n\n\treturn (\n\t\textendedWindow.elementorCommon?.helpers?.getUniqueId?.() ??\n\t\t`el-${ Date.now() }-${ Math.random().toString( 36 ).substring( 2, 9 ) }`\n\t);\n};\n","import { commandEndEvent, windowEvent } from '@elementor/editor-v1-adapters';\n\nexport const ELEMENT_STYLE_CHANGE_EVENT = 'elementor/editor-v2/editor-elements/style';\n\nexport const styleRerenderEvents = [\n\tcommandEndEvent( 'document/elements/create' ),\n\tcommandEndEvent( 'document/elements/duplicate' ),\n\tcommandEndEvent( 'document/elements/import' ),\n\tcommandEndEvent( 'document/elements/paste' ),\n\twindowEvent( ELEMENT_STYLE_CHANGE_EVENT ),\n];\n","import { classesPropTypeUtil } from '@elementor/editor-props';\nimport {\n\tgenerateId,\n\ttype StyleDefinition,\n\ttype StyleDefinitionID,\n\ttype StyleDefinitionVariant,\n} from '@elementor/editor-styles';\n\nimport { getElementSetting } from '../sync/get-element-setting';\nimport { updateElementSettings } from '../sync/update-element-settings';\nimport { type ElementID } from '../types';\nimport { mutateElementStyles } from './mutate-element-styles';\n\nexport type CreateElementStyleArgs = {\n\tstyleId?: StyleDefinitionID;\n\telementId: ElementID;\n\tclassesProp: string;\n\tlabel: string;\n\tmeta: StyleDefinitionVariant[ 'meta' ];\n\tprops: StyleDefinitionVariant[ 'props' ];\n\tcustom_css?: StyleDefinitionVariant[ 'custom_css' ];\n\tadditionalVariants?: StyleDefinitionVariant[];\n};\n\nexport function createElementStyle( {\n\tstyleId,\n\telementId,\n\tclassesProp,\n\tlabel,\n\tmeta,\n\tprops,\n\tcustom_css: customCss = null,\n\tadditionalVariants = [],\n}: CreateElementStyleArgs ): string {\n\tlet id = styleId;\n\n\tmutateElementStyles( elementId, ( styles ) => {\n\t\tid ??= generateId( `e-${ elementId }-`, Object.keys( styles ) );\n\n\t\tconst variants = [ { meta, props, custom_css: customCss }, ...additionalVariants ];\n\n\t\tstyles[ id ] = {\n\t\t\tid,\n\t\t\tlabel,\n\t\t\ttype: 'class',\n\t\t\tvariants,\n\t\t} satisfies StyleDefinition;\n\n\t\taddStyleToClassesProp( elementId, classesProp, id );\n\n\t\treturn styles;\n\t} );\n\n\treturn id as string;\n}\n\nfunction addStyleToClassesProp( elementId: ElementID, classesProp: string, styleId: string ) {\n\tconst base = getElementSetting( elementId, classesProp );\n\n\tconst classesPropValue = classesPropTypeUtil.create(\n\t\t( prev ) => {\n\t\t\treturn [ ...( prev ?? [] ), styleId ];\n\t\t},\n\t\t{ base }\n\t);\n\n\tupdateElementSettings( {\n\t\tid: elementId,\n\t\tprops: {\n\t\t\t[ classesProp ]: classesPropValue,\n\t\t},\n\t\twithHistory: false,\n\t} );\n}\n\nexport function shouldCreateNewLocalStyle< T >(\n\tpayload: { styleId: StyleDefinition[ 'id' ] | null; provider: T | null } | null\n) {\n\treturn ! payload?.styleId && ! payload?.provider;\n}\n","import { classesPropTypeUtil, type ClassesPropValue } from '@elementor/editor-props';\nimport { type StyleDefinition, type StyleDefinitionsMap } from '@elementor/editor-styles';\nimport { __privateRunCommandSync as runCommandSync } from '@elementor/editor-v1-adapters';\n\nimport { ElementNotFoundError } from '../errors';\nimport { getContainer } from '../sync/get-container';\nimport { type V1Element } from '../sync/types';\nimport { updateElementSettings } from '../sync/update-element-settings';\nimport { type ElementID } from '../types';\nimport { ELEMENT_STYLE_CHANGE_EVENT } from './consts';\n\ntype Mutator = ( styles: StyleDefinitionsMap ) => StyleDefinitionsMap;\n\nexport function mutateElementStyles( elementId: ElementID, mutator: Mutator ) {\n\tconst container = getContainer( elementId );\n\n\tif ( ! container ) {\n\t\tthrow new ElementNotFoundError( { context: { elementId } } );\n\t}\n\n\tconst oldIds = Object.keys( container.model.get( 'styles' ) ?? {} );\n\n\tconst styles = mutateStyles( container, mutator );\n\n\tconst newIds = Object.keys( styles );\n\n\tclearRemovedClasses( container, {\n\t\toldIds,\n\t\tnewIds,\n\t} );\n\n\tnotifyChanges();\n\n\treturn styles;\n}\n\nfunction mutateStyles( container: V1Element, mutator: Mutator ) {\n\tconst styles: StyleDefinitionsMap = structuredClone( container.model.get( 'styles' ) ) ?? {};\n\n\tconst entries = Object.entries( mutator( styles ) )\n\t\t.map( ( [ styleId, style ] ) => {\n\t\t\tstyle.variants = removeEmptyVariants( style );\n\n\t\t\treturn [ styleId, style ] as const;\n\t\t} )\n\t\t.filter( ( [ , style ] ) => {\n\t\t\treturn ! isStyleEmpty( style );\n\t\t} );\n\n\tconst mutatedStyles = Object.fromEntries( entries );\n\n\tcontainer.model.set( 'styles', mutatedStyles );\n\n\treturn mutatedStyles;\n}\n\nfunction removeEmptyVariants( style: StyleDefinition ) {\n\treturn style.variants.filter(\n\t\t( { props, custom_css: customCss } ) => Object.keys( props ).length > 0 || customCss?.raw\n\t);\n}\n\nfunction isStyleEmpty( style: StyleDefinition ) {\n\treturn style.variants.length === 0;\n}\n\nfunction clearRemovedClasses( container: V1Element, { oldIds, newIds }: { oldIds: string[]; newIds: string[] } ) {\n\tconst removedIds = oldIds.filter( ( id ) => ! newIds.includes( id ) );\n\tconst classesProps = structuredClone( getClassesProps( container ) );\n\n\tclassesProps.forEach( ( [ , prop ] ) => {\n\t\tprop.value = prop.value.filter( ( value ) => ! removedIds.includes( value ) );\n\t} );\n\n\tupdateElementSettings( {\n\t\tid: container.id,\n\t\tprops: Object.fromEntries( classesProps ),\n\t\twithHistory: false,\n\t} );\n}\n\nfunction getClassesProps( container: V1Element ) {\n\treturn Object.entries( container.settings.toJSON() ).filter( ( prop ): prop is [ string, ClassesPropValue ] => {\n\t\tconst [ , value ] = prop;\n\n\t\treturn classesPropTypeUtil.isValid( value );\n\t} );\n}\n\nfunction notifyChanges() {\n\tdispatchChangeEvent();\n\trunCommandSync( 'document/save/set-is-modified', { status: true }, { internal: true } );\n}\n\nfunction dispatchChangeEvent() {\n\twindow.dispatchEvent( new CustomEvent( ELEMENT_STYLE_CHANGE_EVENT ) );\n}\n","import { mergeProps } from '@elementor/editor-props';\nimport { getVariantByMeta, type StyleDefinition, type StyleDefinitionVariant } from '@elementor/editor-styles';\n\nimport { StyleNotFoundError } from '../errors';\nimport { type ElementID } from '../types';\nimport { mutateElementStyles } from './mutate-element-styles';\n\nexport type UpdateElementStyleArgs = {\n\telementId: ElementID;\n\tstyleId: StyleDefinition[ 'id' ];\n\tmeta: StyleDefinitionVariant[ 'meta' ];\n\tprops: StyleDefinitionVariant[ 'props' ];\n\tcustom_css?: StyleDefinitionVariant[ 'custom_css' ];\n};\n\nexport function updateElementStyle( args: UpdateElementStyleArgs ) {\n\tmutateElementStyles( args.elementId, ( styles ) => {\n\t\tconst style = styles[ args.styleId ];\n\n\t\tif ( ! style ) {\n\t\t\tthrow new StyleNotFoundError( { context: { styleId: args.styleId } } );\n\t\t}\n\n\t\tconst variant = getVariantByMeta( style, args.meta );\n\t\tconst customCss = ( 'custom_css' in args ? args.custom_css : variant?.custom_css ) ?? null;\n\n\t\tif ( variant ) {\n\t\t\tvariant.props = mergeProps( variant.props, args.props );\n\t\t\tvariant.custom_css = customCss?.raw ? customCss : null;\n\t\t} else {\n\t\t\tstyle.variants.push( { meta: args.meta, props: args.props, custom_css: customCss } );\n\t\t}\n\n\t\treturn styles;\n\t} );\n}\n","import { type StyleDefinitionID } from '@elementor/editor-styles';\n\nimport { type ElementID } from '../types';\nimport { mutateElementStyles } from './mutate-element-styles';\n\nexport function deleteElementStyle( elementId: ElementID, styleId: StyleDefinitionID ) {\n\tmutateElementStyles( elementId, ( styles ) => {\n\t\t// The object is deep cloned so mutating it is fine.\n\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\tdelete styles[ styleId ];\n\n\t\treturn styles;\n\t} );\n}\n","import { getContainer } from './sync/get-container';\n\nexport type LinkInLinkRestriction =\n\t| {\n\t\t\tshouldRestrict: true;\n\t\t\treason: 'ancestor' | 'descendant';\n\t\t\telementId: string | null;\n\t }\n\t| {\n\t\t\tshouldRestrict: false;\n\t\t\treason?: never;\n\t\t\telementId?: never;\n\t };\n\nexport function getLinkInLinkRestriction( elementId: string ): LinkInLinkRestriction {\n\tconst anchoredDescendantId = getAnchoredDescendantId( elementId );\n\n\tif ( anchoredDescendantId ) {\n\t\treturn {\n\t\t\tshouldRestrict: true,\n\t\t\treason: 'descendant',\n\t\t\telementId: anchoredDescendantId,\n\t\t};\n\t}\n\n\tconst ancestor = getAnchoredAncestorId( elementId );\n\n\tif ( ancestor ) {\n\t\treturn {\n\t\t\tshouldRestrict: true,\n\t\t\treason: 'ancestor',\n\t\t\telementId: ancestor,\n\t\t};\n\t}\n\n\treturn {\n\t\tshouldRestrict: false,\n\t};\n}\n\nexport function getAnchoredDescendantId( elementId: string ): string | null {\n\tconst element = getElementDOM( elementId );\n\n\tif ( ! element ) {\n\t\treturn null;\n\t}\n\n\tfor ( const childAnchorElement of Array.from( element.querySelectorAll( 'a' ) ) ) {\n\t\t// Ensure the child is not in the current element's scope\n\t\tconst childElementId = findElementIdOf( childAnchorElement );\n\n\t\tif ( childElementId !== elementId ) {\n\t\t\treturn childElementId;\n\t\t}\n\t}\n\n\treturn null;\n}\n\nexport function getAnchoredAncestorId( elementId: string ): string | null {\n\tconst element = getElementDOM( elementId );\n\n\tif ( ! element || element.parentElement === null ) {\n\t\treturn null;\n\t}\n\n\tconst parentAnchor = element.parentElement.closest( 'a' );\n\n\treturn parentAnchor ? findElementIdOf( parentAnchor ) : null;\n}\n\nexport function isElementAnchored( elementId: string ): boolean {\n\tconst element = getElementDOM( elementId );\n\n\tif ( ! element ) {\n\t\treturn false;\n\t}\n\n\tif ( isAnchorTag( element.tagName ) ) {\n\t\treturn true;\n\t}\n\n\treturn doesElementContainAnchor( element );\n}\n\nfunction doesElementContainAnchor( element: Element ): boolean {\n\tfor ( const child of element.children ) {\n\t\tif ( isElementorElement( child ) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( isAnchorTag( child.tagName ) ) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif ( doesElementContainAnchor( child ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\nfunction findElementIdOf( element: Element ): string | null {\n\treturn element.closest< HTMLElement >( '[data-id]' )?.dataset.id || null;\n}\n\nfunction getElementDOM( id: string ) {\n\ttry {\n\t\treturn getContainer( id )?.view?.el || null;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nfunction isAnchorTag( tagName: string ): boolean {\n\treturn tagName.toLowerCase() === 'a';\n}\n\nfunction isElementorElement( element: Element ): boolean {\n\treturn element.hasAttribute( 'data-id' );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,6BA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AS,sBAAuB,WAAmC;AACzE,QAAM,UAAU,cAAe,SAAU;AAEzC,MAAK,CAAE,WAAW,QAAQ,kBAAkB,MAAO;AAClD,WAAO;AAAA,EACR;AAEA,QAAM,eAAe,QAAQ,cAAc,QAAS,GAAI;AAExD,SAAO,eAAe,gBAAiB,YAAa,IAAI;AACzD;AAEO,SAAS,kBAAmB,WAA6B;AAC/D,QAAM,UAAU,cAAe,SAAU;AAEzC,MAAK,CAAE,SAAU;AAChB,WAAO;AAAA,EACR;AAEA,MAAK,YAAa,QAAQ,OAAQ,GAAI;AACrC,WAAO;AAAA,EACR;AAEA,SAAO,yBAA0B,OAAQ;AAC1C;AAEA,SAAS,yBAA0B,SAA4B;AAC9D,aAAY,SAAS,QAAQ,UAAW;AACvC,QAAK,mBAAoB,KAAM,GAAI;AAClC;AAAA,IACD;AAEA,QAAK,YAAa,MAAM,OAAQ,GAAI;AACnC,aAAO;AAAA,IACR;AAEA,QAAK,yBAA0B,KAAM,GAAI;AACxC,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAEA,SAAS,gBAAiB,SAAkC;AAC3D,SAAO,QAAQ,QAAwB,WAAY,GAAG,QAAQ,MAAM;AACrE;AAEA,SAAS,cAAe,IAAa;AACpC,MAAI;AACH,WAAO,aAAc,EAAG,GAAG,MAAM,MAAM;AAAA,EACxC,QAAQ;AACP,WAAO;AAAA,EACR;AACD;AAEA,SAAS,YAAa,SAA2B;AAChD,SAAO,QAAQ,YAAY,MAAM;AAClC;AAEA,SAAS,mBAAoB,SAA4B;AACxD,SAAO,QAAQ,aAAc,SAAU;AACxC;","names":["import_editor_v1_adapters","runCommand","useListenTo","import_editor_v1_adapters","useListenTo","import_editor_v1_adapters","useListenTo","import_editor_v1_adapters","useListenTo","import_editor_v1_adapters","useListenTo","import_editor_v1_adapters","runCommandSync","import_editor_v1_adapters","import_editor_v1_adapters","runCommand","import_editor_v1_adapters","import_i18n","import_editor_v1_adapters","import_i18n","import_editor_v1_adapters","runCommandSync","import_editor_v1_adapters","import_editor_props","import_editor_v1_adapters","runCommandSync","import_editor_props","import_editor_styles"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/hooks/use-element-setting.ts","../src/sync/get-container.ts","../src/sync/get-element-setting.ts","../src/hooks/use-element-type.ts","../src/sync/get-widgets-cache.ts","../src/hooks/use-selected-element.ts","../src/sync/get-selected-elements.ts","../src/hooks/use-parent-element.ts","../src/hooks/use-element-children.ts","../src/sync/create-element.ts","../src/sync/duplicate-element.ts","../src/sync/create-elements.ts","../src/sync/delete-element.ts","../src/sync/duplicate-elements.ts","../src/sync/remove-elements.ts","../src/sync/get-element-styles.ts","../src/errors.ts","../src/sync/get-element-label.ts","../src/sync/get-current-document-container.ts","../src/sync/get-elements.ts","../src/sync/get-current-document-id.ts","../src/sync/update-element-settings.ts","../src/sync/generate-element-id.ts","../src/sync/replace-element.ts","../src/styles/consts.ts","../src/styles/create-element-style.ts","../src/styles/mutate-element-styles.ts","../src/styles/update-element-style.ts","../src/styles/delete-element-style.ts","../src/link-restriction.ts"],"sourcesContent":["// types\nexport * from './types';\nexport type { V1Element, V1ElementModelProps, V1ElementSettingsProps, V1ElementConfig } from './sync/types';\n\n// hooks\nexport { useElementSetting, useElementSettings } from './hooks/use-element-setting';\nexport { useElementType } from './hooks/use-element-type';\nexport { useSelectedElement } from './hooks/use-selected-element';\nexport { useParentElement } from './hooks/use-parent-element';\nexport { useElementChildren, type ElementChildren } from './hooks/use-element-children';\n\n// utils\nexport { createElement, type CreateElementParams } from './sync/create-element';\nexport { duplicateElement, type DuplicateElementParams } from './sync/duplicate-element';\nexport { createElements } from './sync/create-elements';\nexport {\n\tduplicateElements,\n\ttype DuplicateElementsParams,\n\ttype DuplicatedElement,\n\ttype DuplicatedElementsResult,\n} from './sync/duplicate-elements';\nexport { deleteElement } from './sync/delete-element';\nexport { removeElements } from './sync/remove-elements';\nexport { getContainer, selectElement } from './sync/get-container';\nexport { getElementSetting, getElementSettings } from './sync/get-element-setting';\nexport { getElementStyles } from './sync/get-element-styles';\nexport { getElementLabel } from './sync/get-element-label';\nexport { getElements } from './sync/get-elements';\nexport { getCurrentDocumentId } from './sync/get-current-document-id';\nexport { getSelectedElements } from './sync/get-selected-elements';\nexport { getWidgetsCache } from './sync/get-widgets-cache';\nexport { updateElementSettings, type UpdateElementSettingsArgs } from './sync/update-element-settings';\nexport { generateElementId } from './sync/generate-element-id';\nexport { replaceElement } from './sync/replace-element';\n\nexport { ELEMENT_STYLE_CHANGE_EVENT, styleRerenderEvents } from './styles/consts';\nexport {\n\tcreateElementStyle,\n\tshouldCreateNewLocalStyle,\n\ttype CreateElementStyleArgs,\n} from './styles/create-element-style';\nexport { updateElementStyle, type UpdateElementStyleArgs } from './styles/update-element-style';\nexport { deleteElementStyle } from './styles/delete-element-style';\nexport {\n\tisElementAnchored,\n\tgetAnchoredDescendantId,\n\tgetAnchoredAncestorId,\n\tgetLinkInLinkRestriction,\n\ttype LinkInLinkRestriction,\n} from './link-restriction';\n","import { __privateUseListenTo as useListenTo, commandEndEvent } from '@elementor/editor-v1-adapters';\n\nimport { getElementSetting } from '../sync/get-element-setting';\nimport { type ElementID } from '../types';\n\nexport const useElementSetting = < TValue >( elementId: ElementID, settingKey: string ) => {\n\treturn useListenTo(\n\t\tcommandEndEvent( 'document/elements/set-settings' ),\n\t\t() => getElementSetting< TValue >( elementId, settingKey ),\n\t\t[ elementId, settingKey ]\n\t);\n};\n\nexport const useElementSettings = < TValue >( elementId: ElementID, settingKeys: string[] ) => {\n\treturn useListenTo(\n\t\tcommandEndEvent( 'document/elements/set-settings' ),\n\t\t() =>\n\t\t\tsettingKeys.reduce< Record< string, TValue > >( ( settings, key ) => {\n\t\t\t\tconst value = getElementSetting< TValue >( elementId, key );\n\n\t\t\t\tif ( value !== null ) {\n\t\t\t\t\tsettings[ key ] = value;\n\t\t\t\t}\n\n\t\t\t\treturn settings;\n\t\t\t}, {} ),\n\t\t[ elementId, ...settingKeys ]\n\t);\n};\n","import { __privateRunCommand as runCommand } from '@elementor/editor-v1-adapters';\n\nimport { type ExtendedWindow, type V1Element } from './types';\n\nexport function getContainer( id: string ): V1Element | null {\n\tconst extendedWindow = window as unknown as ExtendedWindow;\n\tconst container = extendedWindow.elementor?.getContainer?.( id );\n\n\treturn container ?? null;\n}\n\nexport const selectElement = ( elementId: string ) => {\n\ttry {\n\t\tconst container = getContainer( elementId );\n\n\t\trunCommand( 'document/elements/select', { container } );\n\t} catch {}\n};\n","import { type ElementID } from '../types';\nimport { getContainer } from './get-container';\n\nexport const getElementSetting = < TValue >( elementId: ElementID, settingKey: string ): TValue | null => {\n\tconst container = getContainer( elementId );\n\n\treturn ( container?.settings?.get( settingKey ) as TValue ) ?? null;\n};\n\nexport const getElementSettings = < TValue >(\n\telementId: ElementID,\n\tsettingKey: string[]\n): Record< string, TValue | null > => {\n\treturn Object.fromEntries( settingKey.map( ( key ) => [ key, getElementSetting( elementId, key ) ] ) );\n};\n","import { __privateUseListenTo as useListenTo, commandEndEvent } from '@elementor/editor-v1-adapters';\n\nimport { getWidgetsCache } from '../sync/get-widgets-cache';\nimport { type ElementType } from '../types';\n\nexport function useElementType( type?: string ) {\n\treturn useListenTo(\n\t\tcommandEndEvent( 'editor/documents/load' ),\n\t\t(): ElementType | null => {\n\t\t\tif ( ! type ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst widgetsCache = getWidgetsCache();\n\t\t\tconst elementType = widgetsCache?.[ type ];\n\n\t\t\tif ( ! elementType?.atomic_controls ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tif ( ! elementType?.atomic_props_schema ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tkey: type,\n\t\t\t\tcontrols: elementType.atomic_controls,\n\t\t\t\tpropsSchema: elementType.atomic_props_schema,\n\t\t\t\tdependenciesPerTargetMapping: elementType.dependencies_per_target_mapping ?? {},\n\t\t\t\ttitle: elementType.title,\n\t\t\t};\n\t\t},\n\t\t[ type ]\n\t);\n}\n","import { type ExtendedWindow } from './types';\n\nexport function getWidgetsCache() {\n\tconst extendedWindow = window as unknown as ExtendedWindow;\n\n\treturn extendedWindow?.elementor?.widgetsCache || null;\n}\n","import { __privateUseListenTo as useListenTo, commandEndEvent } from '@elementor/editor-v1-adapters';\n\nimport { getSelectedElements } from '../sync/get-selected-elements';\nimport { useElementType } from './use-element-type';\n\nexport function useSelectedElement() {\n\tconst elements = useListenTo(\n\t\t[\n\t\t\tcommandEndEvent( 'document/elements/select' ),\n\t\t\tcommandEndEvent( 'document/elements/deselect' ),\n\t\t\tcommandEndEvent( 'document/elements/select-all' ),\n\t\t\tcommandEndEvent( 'document/elements/deselect-all' ),\n\t\t],\n\t\tgetSelectedElements\n\t);\n\n\tconst [ element ] = elements;\n\n\tconst elementType = useElementType( element?.type );\n\n\tif ( elements.length !== 1 || ! elementType ) {\n\t\treturn { element: null, elementType: null };\n\t}\n\n\treturn { element, elementType };\n}\n","import { type Element } from '../types';\nimport { type ExtendedWindow } from './types';\n\nexport function getSelectedElements(): Element[] {\n\tconst extendedWindow = window as unknown as ExtendedWindow;\n\n\tconst selectedElements = extendedWindow.elementor?.selection?.getElements?.() ?? [];\n\n\treturn selectedElements.reduce< Element[] >( ( acc, el ) => {\n\t\tconst type = el.model.get( 'widgetType' ) || el.model.get( 'elType' );\n\n\t\tif ( type ) {\n\t\t\tacc.push( {\n\t\t\t\tid: el.model.get( 'id' ),\n\t\t\t\ttype,\n\t\t\t} );\n\t\t}\n\n\t\treturn acc;\n\t}, [] );\n}\n","import { __privateUseListenTo as useListenTo, commandEndEvent } from '@elementor/editor-v1-adapters';\n\nimport { type ExtendedWindow } from '../sync/types';\n\nexport function useParentElement( elementId: string | null ) {\n\treturn useListenTo(\n\t\t[ commandEndEvent( 'document/elements/create' ) ],\n\t\t() => {\n\t\t\tif ( ! elementId ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst extendedWindow = window as unknown as ExtendedWindow;\n\t\t\tconst element = extendedWindow?.elementor?.getContainer?.( elementId );\n\t\t\tif ( ! element ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\treturn element.parent;\n\t\t},\n\t\t[ elementId ]\n\t);\n}\n","import { __privateUseListenTo as useListenTo, commandEndEvent, v1ReadyEvent } from '@elementor/editor-v1-adapters';\n\nimport { getContainer } from '../sync/get-container';\nimport { type ElementID } from '../types';\n\ntype ElementModel = {\n\tid: string;\n};\n\nexport type ElementChildren = Record< string, ElementModel[] >;\n\nexport function useElementChildren< T extends ElementChildren >(\n\telementId: ElementID,\n\tchildrenTypes: ( keyof T & string )[]\n): T {\n\treturn useListenTo(\n\t\t[\n\t\t\tv1ReadyEvent(),\n\t\t\tcommandEndEvent( 'document/elements/create' ),\n\t\t\tcommandEndEvent( 'document/elements/delete' ),\n\t\t\tcommandEndEvent( 'document/elements/update' ),\n\t\t\tcommandEndEvent( 'document/elements/set-settings' ),\n\t\t],\n\t\t() => {\n\t\t\tconst container = getContainer( elementId );\n\n\t\t\tconst elementChildren = childrenTypes.reduce( ( acc, type ) => {\n\t\t\t\tacc[ type ] = [];\n\n\t\t\t\treturn acc;\n\t\t\t}, {} as ElementChildren );\n\n\t\t\tcontainer?.children?.forEachRecursive?.( ( { model, id } ) => {\n\t\t\t\tconst elType = model.get( 'elType' );\n\n\t\t\t\tif ( elType && elType in elementChildren ) {\n\t\t\t\t\telementChildren[ elType ].push( { id } );\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\treturn elementChildren;\n\t\t},\n\t\t[ elementId ]\n\t) as T;\n}\n","import { __privateRunCommandSync as runCommandSync } from '@elementor/editor-v1-adapters';\n\nimport { getContainer } from './get-container';\nimport { type V1Element, type V1ElementModelProps, type V1ElementSettingsProps } from './types';\n\ntype Options = {\n\tuseHistory?: boolean;\n\tat?: number;\n\tclone?: boolean;\n};\n\nexport type CreateElementParams = {\n\tcontainerId: string;\n\toptions?: Options;\n\tmodel?: Omit< V1ElementModelProps, 'settings' | 'id' > & { settings?: V1ElementSettingsProps; id?: string };\n};\n\nexport function createElement( { containerId, model, options }: CreateElementParams ) {\n\tconst container = getContainer( containerId );\n\n\tif ( ! container ) {\n\t\tthrow new Error( `Container with ID \"${ containerId }\" not found` );\n\t}\n\n\treturn runCommandSync< V1Element >( 'document/elements/create', {\n\t\tcontainer,\n\t\tmodel,\n\t\toptions: { edit: false, ...options },\n\t} );\n}\n","import { createElement } from './create-element';\nimport { getContainer } from './get-container';\nimport { type V1Element } from './types';\n\ntype Options = {\n\tuseHistory?: boolean;\n\tat?: number;\n\tclone?: boolean;\n};\n\nexport type DuplicateElementParams = {\n\telementId: string;\n\toptions?: Options;\n};\n\nexport function duplicateElement( { elementId, options = {} }: DuplicateElementParams ): V1Element {\n\tconst elementToDuplicate = getContainer( elementId );\n\n\tif ( ! elementToDuplicate ) {\n\t\tthrow new Error( `Element with ID \"${ elementId }\" not found` );\n\t}\n\n\tif ( ! elementToDuplicate.parent ) {\n\t\tthrow new Error( `Element with ID \"${ elementId }\" has no parent container` );\n\t}\n\n\tconst parentContainer = elementToDuplicate.parent;\n\tconst elementModel = elementToDuplicate.model.toJSON();\n\n\t// Get the position after the original element (only when cloning)\n\tconst currentIndex = elementToDuplicate.view?._index ?? 0;\n\tconst insertPosition = options.clone !== false ? currentIndex + 1 : undefined;\n\n\treturn createElement( {\n\t\tcontainerId: parentContainer.id,\n\t\tmodel: elementModel,\n\t\toptions: {\n\t\t\tat: insertPosition,\n\t\t\t...options,\n\t\t},\n\t} );\n}\n","import { undoable } from '@elementor/editor-v1-adapters';\nimport { __ } from '@wordpress/i18n';\n\nimport { createElement, type CreateElementParams } from './create-element';\nimport { deleteElement } from './delete-element';\nimport { getContainer } from './get-container';\nimport { type V1ElementModelProps } from './types';\n\ntype CreateNestedElementsParams = {\n\telements: CreateElementParams[];\n\ttitle: string;\n\tsubtitle?: string;\n};\n\ntype CreatedElement = {\n\telementId: string;\n\tmodel: V1ElementModelProps;\n\tcreateParams: CreateElementParams;\n};\n\ntype CreatedElementsResult = {\n\tcreatedElements: CreatedElement[];\n};\n\nexport type { CreateNestedElementsParams, CreatedElement, CreatedElementsResult };\n\nexport const createElements = ( {\n\telements,\n\ttitle,\n\tsubtitle = __( 'Item added', 'elementor' ),\n}: CreateNestedElementsParams ): CreatedElementsResult => {\n\tconst undoableCreate = undoable(\n\t\t{\n\t\t\tdo: ( { elements: elementsParam }: { elements: CreateElementParams[] } ): CreatedElementsResult => {\n\t\t\t\tconst createdElements: CreatedElement[] = [];\n\n\t\t\t\telementsParam.forEach( ( createParams ) => {\n\t\t\t\t\tconst { options, ...elementParams } = createParams;\n\t\t\t\t\tconst element = createElement( {\n\t\t\t\t\t\t...elementParams,\n\t\t\t\t\t\toptions: { ...options, useHistory: false },\n\t\t\t\t\t} );\n\n\t\t\t\t\tconst elementId = element.id;\n\n\t\t\t\t\tcreatedElements.push( {\n\t\t\t\t\t\telementId,\n\t\t\t\t\t\tmodel: element.model?.toJSON() || {},\n\t\t\t\t\t\tcreateParams: {\n\t\t\t\t\t\t\t...createParams,\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\t\t\t\t} );\n\n\t\t\t\treturn { createdElements };\n\t\t\t},\n\t\t\tundo: ( _: { elements: CreateElementParams[] }, { createdElements }: CreatedElementsResult ) => {\n\t\t\t\t// Delete elements in reverse order to avoid dependency issues\n\t\t\t\t[ ...createdElements ].reverse().forEach( ( { elementId } ) => {\n\t\t\t\t\tdeleteElement( {\n\t\t\t\t\t\telementId,\n\t\t\t\t\t\toptions: { useHistory: false },\n\t\t\t\t\t} );\n\t\t\t\t} );\n\t\t\t},\n\t\t\tredo: (\n\t\t\t\t_: { elements: CreateElementParams[] },\n\t\t\t\t{ createdElements }: CreatedElementsResult\n\t\t\t): CreatedElementsResult => {\n\t\t\t\tconst newElements: CreatedElement[] = [];\n\n\t\t\t\tcreatedElements.forEach( ( { createParams, model } ) => {\n\t\t\t\t\tconst element = createElement( {\n\t\t\t\t\t\tcontainerId: createParams.containerId,\n\t\t\t\t\t\tmodel,\n\t\t\t\t\t\toptions: { ...createParams.options, useHistory: false },\n\t\t\t\t\t} );\n\n\t\t\t\t\tconst elementId = element.id;\n\n\t\t\t\t\tconst container = getContainer( elementId );\n\n\t\t\t\t\tif ( container ) {\n\t\t\t\t\t\tnewElements.push( {\n\t\t\t\t\t\t\telementId,\n\t\t\t\t\t\t\tmodel: container.model.toJSON(),\n\t\t\t\t\t\t\tcreateParams,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t} );\n\n\t\t\t\treturn { createdElements: newElements };\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttitle,\n\t\t\tsubtitle,\n\t\t}\n\t);\n\n\treturn undoableCreate( { elements } );\n};\n","import { __privateRunCommand as runCommand } from '@elementor/editor-v1-adapters';\n\nimport { getContainer } from './get-container';\n\ntype Options = {\n\tuseHistory?: boolean;\n\tat?: number;\n};\n\nexport function deleteElement( { elementId, options = {} }: { elementId: string; options?: Options } ): void {\n\tconst container = getContainer( elementId );\n\n\tif ( ! container ) {\n\t\tthrow new Error( `Element with ID \"${ elementId }\" not found` );\n\t}\n\n\trunCommand( 'document/elements/delete', {\n\t\tcontainer,\n\t\toptions,\n\t} );\n}\n","import { undoable } from '@elementor/editor-v1-adapters';\nimport { __ } from '@wordpress/i18n';\n\nimport { createElement } from './create-element';\nimport { deleteElement } from './delete-element';\nimport { duplicateElement } from './duplicate-element';\nimport { getContainer } from './get-container';\nimport { type V1ElementModelProps } from './types';\n\ntype DuplicateElementsParams = {\n\telementIds: string[];\n\ttitle: string;\n\tsubtitle?: string;\n\tonCreate?: ( duplicatedElements: DuplicatedElement[] ) => DuplicatedElement[];\n};\n\ntype DuplicatedElement = {\n\tid: string;\n\tmodel: V1ElementModelProps;\n\toriginalElementId: string;\n\tmodelToRestore?: V1ElementModelProps;\n\tparentContainerId?: string;\n\tat?: number;\n};\n\ntype DuplicatedElementsResult = {\n\tduplicatedElements: DuplicatedElement[];\n};\n\nexport type { DuplicateElementsParams, DuplicatedElement, DuplicatedElementsResult };\n\nexport const duplicateElements = ( {\n\telementIds,\n\ttitle,\n\tsubtitle = __( 'Item duplicated', 'elementor' ),\n\tonCreate,\n}: DuplicateElementsParams ): DuplicatedElementsResult => {\n\tconst undoableDuplicate = undoable(\n\t\t{\n\t\t\tdo: ( { elementIds: elementIdsToDuplicate }: { elementIds: string[] } ): DuplicatedElementsResult => {\n\t\t\t\tconst duplicatedElements: DuplicatedElement[] = elementIdsToDuplicate.reduce( ( acc, elementId ) => {\n\t\t\t\t\tconst originalContainer = getContainer( elementId );\n\n\t\t\t\t\tif ( originalContainer?.parent ) {\n\t\t\t\t\t\tconst duplicatedElement = duplicateElement( {\n\t\t\t\t\t\t\telementId,\n\t\t\t\t\t\t\toptions: { useHistory: false, clone: true },\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\tacc.push( {\n\t\t\t\t\t\t\tid: duplicatedElement.id,\n\t\t\t\t\t\t\tmodel: duplicatedElement.model.toJSON(),\n\t\t\t\t\t\t\toriginalElementId: elementId,\n\t\t\t\t\t\t\tmodelToRestore: duplicatedElement.model.toJSON(),\n\t\t\t\t\t\t\tparentContainerId: duplicatedElement.parent?.id,\n\t\t\t\t\t\t\tat: duplicatedElement.view?._index,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn acc;\n\t\t\t\t}, [] as DuplicatedElement[] );\n\n\t\t\t\treturn { duplicatedElements: onCreate?.( duplicatedElements ) ?? duplicatedElements };\n\t\t\t},\n\t\t\tundo: ( _: { elementIds: string[] }, { duplicatedElements }: DuplicatedElementsResult ) => {\n\t\t\t\t// Delete duplicated elements in reverse order to avoid dependency issues\n\t\t\t\t[ ...duplicatedElements ].reverse().forEach( ( { id } ) => {\n\t\t\t\t\tdeleteElement( {\n\t\t\t\t\t\telementId: id,\n\t\t\t\t\t\toptions: { useHistory: false },\n\t\t\t\t\t} );\n\t\t\t\t} );\n\t\t\t},\n\t\t\tredo: (\n\t\t\t\t_: { elementIds: string[] },\n\t\t\t\t{ duplicatedElements: previousElements }: DuplicatedElementsResult\n\t\t\t): DuplicatedElementsResult => {\n\t\t\t\tconst duplicatedElements: DuplicatedElement[] = previousElements.reduce( ( acc, previousElement ) => {\n\t\t\t\t\tif ( previousElement.modelToRestore && previousElement.parentContainerId ) {\n\t\t\t\t\t\tconst createdElement = createElement( {\n\t\t\t\t\t\t\tcontainerId: previousElement.parentContainerId,\n\t\t\t\t\t\t\tmodel: previousElement.modelToRestore,\n\t\t\t\t\t\t\toptions: {\n\t\t\t\t\t\t\t\tuseHistory: false,\n\t\t\t\t\t\t\t\tclone: false,\n\t\t\t\t\t\t\t\tat: previousElement.at,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\tacc.push( {\n\t\t\t\t\t\t\tid: createdElement.id,\n\t\t\t\t\t\t\tmodel: createdElement.model.toJSON(),\n\t\t\t\t\t\t\toriginalElementId: previousElement.originalElementId,\n\t\t\t\t\t\t\tmodelToRestore: previousElement.modelToRestore,\n\t\t\t\t\t\t\tparentContainerId: previousElement.parentContainerId,\n\t\t\t\t\t\t\tat: previousElement.at,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn acc;\n\t\t\t\t}, [] as DuplicatedElement[] );\n\n\t\t\t\treturn { duplicatedElements: onCreate?.( duplicatedElements ) ?? duplicatedElements };\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttitle,\n\t\t\tsubtitle,\n\t\t}\n\t);\n\n\treturn undoableDuplicate( { elementIds } );\n};\n","import { undoable } from '@elementor/editor-v1-adapters';\nimport { __ } from '@wordpress/i18n';\n\nimport { createElement } from './create-element';\nimport { deleteElement } from './delete-element';\nimport { getContainer } from './get-container';\nimport { type V1Element, type V1ElementModelProps } from './types';\n\ntype RemoveNestedElementsParams = {\n\telementIds: string[];\n\ttitle: string;\n\tsubtitle?: string;\n};\n\ntype RemovedElement = {\n\telementId: string;\n\tmodel: V1ElementModelProps;\n\tparent: V1Element | null;\n\tat: number;\n};\n\ntype RemovedElementsResult = {\n\telementIds: string[];\n\tremovedElements: RemovedElement[];\n};\n\nexport type { RemoveNestedElementsParams, RemovedElement, RemovedElementsResult };\n\nexport const removeElements = ( {\n\telementIds,\n\ttitle,\n\tsubtitle = __( 'Item removed', 'elementor' ),\n}: RemoveNestedElementsParams ): RemovedElementsResult => {\n\tconst undoableRemove = undoable(\n\t\t{\n\t\t\tdo: ( { elementIds: elementIdsParam }: { elementIds: string[] } ): RemovedElementsResult => {\n\t\t\t\tconst removedElements: RemovedElement[] = [];\n\n\t\t\t\telementIdsParam.forEach( ( elementId ) => {\n\t\t\t\t\tconst container = getContainer( elementId );\n\n\t\t\t\t\tif ( container ) {\n\t\t\t\t\t\tconst model = container.model.toJSON();\n\t\t\t\t\t\tconst parent = container.parent;\n\n\t\t\t\t\t\tconst at = container.view?._index ?? 0;\n\n\t\t\t\t\t\tremovedElements.push( {\n\t\t\t\t\t\t\telementId,\n\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\tparent: parent ?? null,\n\t\t\t\t\t\t\tat,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t} );\n\n\t\t\t\telementIdsParam.forEach( ( elementId ) => {\n\t\t\t\t\tdeleteElement( {\n\t\t\t\t\t\telementId,\n\t\t\t\t\t\toptions: { useHistory: false },\n\t\t\t\t\t} );\n\t\t\t\t} );\n\n\t\t\t\treturn { elementIds: elementIdsParam, removedElements };\n\t\t\t},\n\t\t\tundo: ( _: { elementIds: string[] }, { removedElements }: RemovedElementsResult ) => {\n\t\t\t\t// Restore elements in reverse order to maintain proper hierarchy\n\t\t\t\t[ ...removedElements ].reverse().forEach( ( { model, parent, at } ) => {\n\t\t\t\t\tif ( parent && model ) {\n\t\t\t\t\t\tcreateElement( {\n\t\t\t\t\t\t\tcontainerId: parent.id,\n\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\toptions: { useHistory: false, at },\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t},\n\t\t\tredo: (\n\t\t\t\t_: { elementIds: string[] },\n\t\t\t\t{ elementIds: originalElementIds, removedElements }: RemovedElementsResult\n\t\t\t): RemovedElementsResult => {\n\t\t\t\toriginalElementIds.forEach( ( elementId ) => {\n\t\t\t\t\tdeleteElement( {\n\t\t\t\t\t\telementId,\n\t\t\t\t\t\toptions: { useHistory: false },\n\t\t\t\t\t} );\n\t\t\t\t} );\n\n\t\t\t\treturn { elementIds: originalElementIds, removedElements };\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttitle,\n\t\t\tsubtitle,\n\t\t}\n\t);\n\n\treturn undoableRemove( { elementIds } );\n};\n","import { type StyleDefinition } from '@elementor/editor-styles';\n\nimport { type ElementID } from '../types';\nimport { getContainer } from './get-container';\n\nexport const getElementStyles = ( elementID: ElementID ): Record< string, StyleDefinition > | null => {\n\tconst container = getContainer( elementID );\n\n\treturn container?.model.get( 'styles' ) || null;\n};\n","import { createError } from '@elementor/utils';\n\nexport const ElementNotFoundError = createError< { elementId: string } >( {\n\tcode: 'element_not_found',\n\tmessage: 'Element not found.',\n} );\n\nexport const StyleNotFoundError = createError< { styleId: string } >( {\n\tcode: 'style_not_found',\n\tmessage: 'Style not found.',\n} );\n\nexport const ElementTypeNotExistsError = createError< { elementId: string } >( {\n\tcode: 'element_type_not_exists',\n\tmessage: 'Element type does not exist.',\n} );\n\nexport const ElementLabelNotExistsError = createError< { elementType: string } >( {\n\tcode: 'element_label_not_exists',\n\tmessage: 'Element label does not exist.',\n} );\n","import { ElementLabelNotExistsError, ElementTypeNotExistsError } from '../errors';\nimport { getContainer } from '../sync/get-container';\nimport { getWidgetsCache } from '../sync/get-widgets-cache';\nimport { type ElementID } from '../types';\n\nexport function getElementLabel( elementId: ElementID ) {\n\tconst container = getContainer( elementId );\n\n\tconst type = container?.model.get( 'widgetType' ) || container?.model.get( 'elType' );\n\n\tif ( ! type ) {\n\t\tthrow new ElementTypeNotExistsError( { context: { elementId } } );\n\t}\n\n\tconst label = getWidgetsCache()?.[ type ]?.title;\n\n\tif ( ! label ) {\n\t\tthrow new ElementLabelNotExistsError( { context: { elementType: type } } );\n\t}\n\n\treturn label;\n}\n","import { type ExtendedWindow } from './types';\n\nexport default function getCurrentDocumentContainer() {\n\tconst extendedWindow = window as unknown as ExtendedWindow;\n\n\treturn extendedWindow.elementor?.documents?.getCurrent?.()?.container ?? null;\n}\n","import { type ElementID } from '../types';\nimport { getContainer } from './get-container';\nimport getCurrentDocumentContainer from './get-current-document-container';\nimport { type V1Element } from './types';\n\nexport function getElements( root?: ElementID ): V1Element[] {\n\tconst container = root ? getContainer( root ) : getCurrentDocumentContainer();\n\n\tif ( ! container ) {\n\t\treturn [];\n\t}\n\n\tconst children = [ ...( container.model.get( 'elements' ) ?? [] ) ].flatMap( ( childModel ) =>\n\t\tgetElements( childModel.get( 'id' ) )\n\t);\n\n\treturn [ container, ...children ];\n}\n","import { type ExtendedWindow } from './types';\n\nexport function getCurrentDocumentId() {\n\tconst extendedWindow = window as unknown as ExtendedWindow;\n\n\treturn extendedWindow.elementor?.documents?.getCurrentId?.() ?? null;\n}\n","import { type Props } from '@elementor/editor-props';\nimport { __privateRunCommandSync as runCommandSync } from '@elementor/editor-v1-adapters';\n\nimport { type ElementID } from '../types';\nimport { getContainer } from './get-container';\n\nexport type UpdateElementSettingsArgs = {\n\tid: ElementID;\n\tprops: Props;\n\twithHistory?: boolean;\n};\n\nexport const updateElementSettings = ( { id, props, withHistory = true }: UpdateElementSettingsArgs ) => {\n\tconst container = getContainer( id );\n\n\tconst args = {\n\t\tcontainer,\n\t\tsettings: { ...props },\n\t};\n\n\tif ( withHistory ) {\n\t\trunCommandSync( 'document/elements/settings', args );\n\t} else {\n\t\trunCommandSync( 'document/elements/set-settings', args, { internal: true } );\n\t}\n};\n","import { type ExtendedWindow } from './types';\n\nexport const generateElementId = () => {\n\tconst extendedWindow = window as unknown as ExtendedWindow;\n\n\treturn (\n\t\textendedWindow.elementorCommon?.helpers?.getUniqueId?.() ??\n\t\t`el-${ Date.now() }-${ Math.random().toString( 36 ).substring( 2, 9 ) }`\n\t);\n};\n","import { createElement } from './create-element';\nimport { deleteElement } from './delete-element';\nimport { getContainer } from './get-container';\nimport { type V1Element, type V1ElementModelProps } from './types';\n\ntype ReplaceElementArgs = {\n\tcurrentElement: V1Element;\n\tnewElement: Omit< V1ElementModelProps, 'id' >;\n\twithHistory?: boolean;\n};\n\nexport const replaceElement = ( { currentElement, newElement, withHistory = true }: ReplaceElementArgs ) => {\n\tconst parent = getContainer( currentElement.id )?.parent;\n\n\tif ( ! parent ) {\n\t\tthrow new Error( `Parent not found for element ${ currentElement.id }. Cannot replace element.` );\n\t}\n\n\tconst elementIndex = parent.children?.findIndex( ( child ) => child.id === currentElement.id );\n\tif ( elementIndex === undefined || elementIndex === -1 ) {\n\t\tthrow new Error( `Element ${ currentElement.id } not found in parent container. Cannot replace element.` );\n\t}\n\n\tcreateElement( {\n\t\tcontainerId: parent.id,\n\t\tmodel: newElement,\n\t\toptions: { at: elementIndex, useHistory: withHistory },\n\t} );\n\n\tdeleteElement( { elementId: currentElement.id, options: { useHistory: withHistory } } );\n};\n","import { commandEndEvent, windowEvent } from '@elementor/editor-v1-adapters';\n\nexport const ELEMENT_STYLE_CHANGE_EVENT = 'elementor/editor-v2/editor-elements/style';\n\nexport const styleRerenderEvents = [\n\tcommandEndEvent( 'document/elements/create' ),\n\tcommandEndEvent( 'document/elements/duplicate' ),\n\tcommandEndEvent( 'document/elements/import' ),\n\tcommandEndEvent( 'document/elements/paste' ),\n\twindowEvent( ELEMENT_STYLE_CHANGE_EVENT ),\n];\n","import { classesPropTypeUtil } from '@elementor/editor-props';\nimport {\n\tgenerateId,\n\ttype StyleDefinition,\n\ttype StyleDefinitionID,\n\ttype StyleDefinitionVariant,\n} from '@elementor/editor-styles';\n\nimport { getElementSetting } from '../sync/get-element-setting';\nimport { updateElementSettings } from '../sync/update-element-settings';\nimport { type ElementID } from '../types';\nimport { mutateElementStyles } from './mutate-element-styles';\n\nexport type CreateElementStyleArgs = {\n\tstyleId?: StyleDefinitionID;\n\telementId: ElementID;\n\tclassesProp: string;\n\tlabel: string;\n\tmeta: StyleDefinitionVariant[ 'meta' ];\n\tprops: StyleDefinitionVariant[ 'props' ];\n\tcustom_css?: StyleDefinitionVariant[ 'custom_css' ];\n\tadditionalVariants?: StyleDefinitionVariant[];\n};\n\nexport function createElementStyle( {\n\tstyleId,\n\telementId,\n\tclassesProp,\n\tlabel,\n\tmeta,\n\tprops,\n\tcustom_css: customCss = null,\n\tadditionalVariants = [],\n}: CreateElementStyleArgs ): string {\n\tlet id = styleId;\n\n\tmutateElementStyles( elementId, ( styles ) => {\n\t\tid ??= generateId( `e-${ elementId }-`, Object.keys( styles ) );\n\n\t\tconst variants = [ { meta, props, custom_css: customCss }, ...additionalVariants ];\n\n\t\tstyles[ id ] = {\n\t\t\tid,\n\t\t\tlabel,\n\t\t\ttype: 'class',\n\t\t\tvariants,\n\t\t} satisfies StyleDefinition;\n\n\t\taddStyleToClassesProp( elementId, classesProp, id );\n\n\t\treturn styles;\n\t} );\n\n\treturn id as string;\n}\n\nfunction addStyleToClassesProp( elementId: ElementID, classesProp: string, styleId: string ) {\n\tconst base = getElementSetting( elementId, classesProp );\n\n\tconst classesPropValue = classesPropTypeUtil.create(\n\t\t( prev ) => {\n\t\t\treturn [ ...( prev ?? [] ), styleId ];\n\t\t},\n\t\t{ base }\n\t);\n\n\tupdateElementSettings( {\n\t\tid: elementId,\n\t\tprops: {\n\t\t\t[ classesProp ]: classesPropValue,\n\t\t},\n\t\twithHistory: false,\n\t} );\n}\n\nexport function shouldCreateNewLocalStyle< T >(\n\tpayload: { styleId: StyleDefinition[ 'id' ] | null; provider: T | null } | null\n) {\n\treturn ! payload?.styleId && ! payload?.provider;\n}\n","import { classesPropTypeUtil, type ClassesPropValue } from '@elementor/editor-props';\nimport { type StyleDefinition, type StyleDefinitionsMap } from '@elementor/editor-styles';\nimport { __privateRunCommandSync as runCommandSync } from '@elementor/editor-v1-adapters';\n\nimport { ElementNotFoundError } from '../errors';\nimport { getContainer } from '../sync/get-container';\nimport { type V1Element } from '../sync/types';\nimport { updateElementSettings } from '../sync/update-element-settings';\nimport { type ElementID } from '../types';\nimport { ELEMENT_STYLE_CHANGE_EVENT } from './consts';\n\ntype Mutator = ( styles: StyleDefinitionsMap ) => StyleDefinitionsMap;\n\nexport function mutateElementStyles( elementId: ElementID, mutator: Mutator ) {\n\tconst container = getContainer( elementId );\n\n\tif ( ! container ) {\n\t\tthrow new ElementNotFoundError( { context: { elementId } } );\n\t}\n\n\tconst oldIds = Object.keys( container.model.get( 'styles' ) ?? {} );\n\n\tconst styles = mutateStyles( container, mutator );\n\n\tconst newIds = Object.keys( styles );\n\n\tclearRemovedClasses( container, {\n\t\toldIds,\n\t\tnewIds,\n\t} );\n\n\tnotifyChanges();\n\n\treturn styles;\n}\n\nfunction mutateStyles( container: V1Element, mutator: Mutator ) {\n\tconst styles: StyleDefinitionsMap = structuredClone( container.model.get( 'styles' ) ) ?? {};\n\n\tconst entries = Object.entries( mutator( styles ) )\n\t\t.map( ( [ styleId, style ] ) => {\n\t\t\tstyle.variants = removeEmptyVariants( style );\n\n\t\t\treturn [ styleId, style ] as const;\n\t\t} )\n\t\t.filter( ( [ , style ] ) => {\n\t\t\treturn ! isStyleEmpty( style );\n\t\t} );\n\n\tconst mutatedStyles = Object.fromEntries( entries );\n\n\tcontainer.model.set( 'styles', mutatedStyles );\n\n\treturn mutatedStyles;\n}\n\nfunction removeEmptyVariants( style: StyleDefinition ) {\n\treturn style.variants.filter(\n\t\t( { props, custom_css: customCss } ) => Object.keys( props ).length > 0 || customCss?.raw\n\t);\n}\n\nfunction isStyleEmpty( style: StyleDefinition ) {\n\treturn style.variants.length === 0;\n}\n\nfunction clearRemovedClasses( container: V1Element, { oldIds, newIds }: { oldIds: string[]; newIds: string[] } ) {\n\tconst removedIds = oldIds.filter( ( id ) => ! newIds.includes( id ) );\n\tconst classesProps = structuredClone( getClassesProps( container ) );\n\n\tclassesProps.forEach( ( [ , prop ] ) => {\n\t\tprop.value = prop.value.filter( ( value ) => ! removedIds.includes( value ) );\n\t} );\n\n\tupdateElementSettings( {\n\t\tid: container.id,\n\t\tprops: Object.fromEntries( classesProps ),\n\t\twithHistory: false,\n\t} );\n}\n\nfunction getClassesProps( container: V1Element ) {\n\treturn Object.entries( container.settings.toJSON() ).filter( ( prop ): prop is [ string, ClassesPropValue ] => {\n\t\tconst [ , value ] = prop;\n\n\t\treturn classesPropTypeUtil.isValid( value );\n\t} );\n}\n\nfunction notifyChanges() {\n\tdispatchChangeEvent();\n\trunCommandSync( 'document/save/set-is-modified', { status: true }, { internal: true } );\n}\n\nfunction dispatchChangeEvent() {\n\twindow.dispatchEvent( new CustomEvent( ELEMENT_STYLE_CHANGE_EVENT ) );\n}\n","import { mergeProps } from '@elementor/editor-props';\nimport { getVariantByMeta, type StyleDefinition, type StyleDefinitionVariant } from '@elementor/editor-styles';\n\nimport { StyleNotFoundError } from '../errors';\nimport { type ElementID } from '../types';\nimport { mutateElementStyles } from './mutate-element-styles';\n\nexport type UpdateElementStyleArgs = {\n\telementId: ElementID;\n\tstyleId: StyleDefinition[ 'id' ];\n\tmeta: StyleDefinitionVariant[ 'meta' ];\n\tprops: StyleDefinitionVariant[ 'props' ];\n\tcustom_css?: StyleDefinitionVariant[ 'custom_css' ];\n};\n\nexport function updateElementStyle( args: UpdateElementStyleArgs ) {\n\tmutateElementStyles( args.elementId, ( styles ) => {\n\t\tconst style = styles[ args.styleId ];\n\n\t\tif ( ! style ) {\n\t\t\tthrow new StyleNotFoundError( { context: { styleId: args.styleId } } );\n\t\t}\n\n\t\tconst variant = getVariantByMeta( style, args.meta );\n\t\tconst customCss = ( 'custom_css' in args ? args.custom_css : variant?.custom_css ) ?? null;\n\n\t\tif ( variant ) {\n\t\t\tvariant.props = mergeProps( variant.props, args.props );\n\t\t\tvariant.custom_css = customCss?.raw ? customCss : null;\n\t\t} else {\n\t\t\tstyle.variants.push( { meta: args.meta, props: args.props, custom_css: customCss } );\n\t\t}\n\n\t\treturn styles;\n\t} );\n}\n","import { type StyleDefinitionID } from '@elementor/editor-styles';\n\nimport { type ElementID } from '../types';\nimport { mutateElementStyles } from './mutate-element-styles';\n\nexport function deleteElementStyle( elementId: ElementID, styleId: StyleDefinitionID ) {\n\tmutateElementStyles( elementId, ( styles ) => {\n\t\t// The object is deep cloned so mutating it is fine.\n\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\tdelete styles[ styleId ];\n\n\t\treturn styles;\n\t} );\n}\n","import { getContainer } from './sync/get-container';\n\nexport type LinkInLinkRestriction =\n\t| {\n\t\t\tshouldRestrict: true;\n\t\t\treason: 'ancestor' | 'descendant';\n\t\t\telementId: string | null;\n\t }\n\t| {\n\t\t\tshouldRestrict: false;\n\t\t\treason?: never;\n\t\t\telementId?: never;\n\t };\n\nexport function getLinkInLinkRestriction( elementId: string ): LinkInLinkRestriction {\n\tconst anchoredDescendantId = getAnchoredDescendantId( elementId );\n\n\tif ( anchoredDescendantId ) {\n\t\treturn {\n\t\t\tshouldRestrict: true,\n\t\t\treason: 'descendant',\n\t\t\telementId: anchoredDescendantId,\n\t\t};\n\t}\n\n\tconst ancestor = getAnchoredAncestorId( elementId );\n\n\tif ( ancestor ) {\n\t\treturn {\n\t\t\tshouldRestrict: true,\n\t\t\treason: 'ancestor',\n\t\t\telementId: ancestor,\n\t\t};\n\t}\n\n\treturn {\n\t\tshouldRestrict: false,\n\t};\n}\n\nexport function getAnchoredDescendantId( elementId: string ): string | null {\n\tconst element = getElementDOM( elementId );\n\n\tif ( ! element ) {\n\t\treturn null;\n\t}\n\n\tfor ( const childAnchorElement of Array.from( element.querySelectorAll( 'a' ) ) ) {\n\t\t// Ensure the child is not in the current element's scope\n\t\tconst childElementId = findElementIdOf( childAnchorElement );\n\n\t\tif ( childElementId !== elementId ) {\n\t\t\treturn childElementId;\n\t\t}\n\t}\n\n\treturn null;\n}\n\nexport function getAnchoredAncestorId( elementId: string ): string | null {\n\tconst element = getElementDOM( elementId );\n\n\tif ( ! element || element.parentElement === null ) {\n\t\treturn null;\n\t}\n\n\tconst parentAnchor = element.parentElement.closest( 'a' );\n\n\treturn parentAnchor ? findElementIdOf( parentAnchor ) : null;\n}\n\nexport function isElementAnchored( elementId: string ): boolean {\n\tconst element = getElementDOM( elementId );\n\n\tif ( ! element ) {\n\t\treturn false;\n\t}\n\n\tif ( isAnchorTag( element.tagName ) ) {\n\t\treturn true;\n\t}\n\n\treturn doesElementContainAnchor( element );\n}\n\nfunction doesElementContainAnchor( element: Element ): boolean {\n\tfor ( const child of element.children ) {\n\t\tif ( isElementorElement( child ) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( isAnchorTag( child.tagName ) ) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif ( doesElementContainAnchor( child ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\nfunction findElementIdOf( element: Element ): string | null {\n\treturn element.closest< HTMLElement >( '[data-id]' )?.dataset.id || null;\n}\n\nfunction getElementDOM( id: string ) {\n\ttry {\n\t\treturn getContainer( id )?.view?.el || null;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nfunction isAnchorTag( tagName: string ): boolean {\n\treturn tagName.toLowerCase() === 'a';\n}\n\nfunction isElementorElement( element: Element ): boolean {\n\treturn element.hasAttribute( 'data-id' );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA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A,SAAO;AACR;AAEA,SAAS,gBAAiB,SAAkC;AAC3D,SAAO,QAAQ,QAAwB,WAAY,GAAG,QAAQ,MAAM;AACrE;AAEA,SAAS,cAAe,IAAa;AACpC,MAAI;AACH,WAAO,aAAc,EAAG,GAAG,MAAM,MAAM;AAAA,EACxC,QAAQ;AACP,WAAO;AAAA,EACR;AACD;AAEA,SAAS,YAAa,SAA2B;AAChD,SAAO,QAAQ,YAAY,MAAM;AAClC;AAEA,SAAS,mBAAoB,SAA4B;AACxD,SAAO,QAAQ,aAAc,SAAU;AACxC;","names":["import_editor_v1_adapters","runCommand","useListenTo","import_editor_v1_adapters","useListenTo","import_editor_v1_adapters","useListenTo","import_editor_v1_adapters","useListenTo","import_editor_v1_adapters","useListenTo","import_editor_v1_adapters","runCommandSync","import_editor_v1_adapters","import_editor_v1_adapters","runCommand","import_editor_v1_adapters","import_i18n","import_editor_v1_adapters","import_i18n","import_editor_v1_adapters","runCommandSync","import_editor_v1_adapters","import_editor_props","import_editor_v1_adapters","runCommandSync","import_editor_props","import_editor_styles"]}
package/dist/index.mjs CHANGED
@@ -510,6 +510,24 @@ var generateElementId = () => {
510
510
  return extendedWindow.elementorCommon?.helpers?.getUniqueId?.() ?? `el-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
511
511
  };
512
512
 
513
+ // src/sync/replace-element.ts
514
+ var replaceElement = ({ currentElement, newElement, withHistory = true }) => {
515
+ const parent = getContainer(currentElement.id)?.parent;
516
+ if (!parent) {
517
+ throw new Error(`Parent not found for element ${currentElement.id}. Cannot replace element.`);
518
+ }
519
+ const elementIndex = parent.children?.findIndex((child) => child.id === currentElement.id);
520
+ if (elementIndex === void 0 || elementIndex === -1) {
521
+ throw new Error(`Element ${currentElement.id} not found in parent container. Cannot replace element.`);
522
+ }
523
+ createElement({
524
+ containerId: parent.id,
525
+ model: newElement,
526
+ options: { at: elementIndex, useHistory: withHistory }
527
+ });
528
+ deleteElement({ elementId: currentElement.id, options: { useHistory: withHistory } });
529
+ };
530
+
513
531
  // src/styles/consts.ts
514
532
  import { commandEndEvent as commandEndEvent6, windowEvent } from "@elementor/editor-v1-adapters";
515
533
  var ELEMENT_STYLE_CHANGE_EVENT = "elementor/editor-v2/editor-elements/style";
@@ -773,6 +791,7 @@ export {
773
791
  getWidgetsCache,
774
792
  isElementAnchored,
775
793
  removeElements,
794
+ replaceElement,
776
795
  selectElement,
777
796
  shouldCreateNewLocalStyle,
778
797
  styleRerenderEvents,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/use-element-setting.ts","../src/sync/get-container.ts","../src/sync/get-element-setting.ts","../src/hooks/use-element-type.ts","../src/sync/get-widgets-cache.ts","../src/hooks/use-selected-element.ts","../src/sync/get-selected-elements.ts","../src/hooks/use-parent-element.ts","../src/hooks/use-element-children.ts","../src/sync/create-element.ts","../src/sync/duplicate-element.ts","../src/sync/create-elements.ts","../src/sync/delete-element.ts","../src/sync/duplicate-elements.ts","../src/sync/remove-elements.ts","../src/sync/get-element-styles.ts","../src/errors.ts","../src/sync/get-element-label.ts","../src/sync/get-current-document-container.ts","../src/sync/get-elements.ts","../src/sync/get-current-document-id.ts","../src/sync/update-element-settings.ts","../src/sync/generate-element-id.ts","../src/styles/consts.ts","../src/styles/create-element-style.ts","../src/styles/mutate-element-styles.ts","../src/styles/update-element-style.ts","../src/styles/delete-element-style.ts","../src/link-restriction.ts"],"sourcesContent":["import { __privateUseListenTo as useListenTo, commandEndEvent } from '@elementor/editor-v1-adapters';\n\nimport { getElementSetting } from '../sync/get-element-setting';\nimport { type ElementID } from '../types';\n\nexport const useElementSetting = < TValue >( elementId: ElementID, settingKey: string ) => {\n\treturn useListenTo(\n\t\tcommandEndEvent( 'document/elements/set-settings' ),\n\t\t() => getElementSetting< TValue >( elementId, settingKey ),\n\t\t[ elementId, settingKey ]\n\t);\n};\n\nexport const useElementSettings = < TValue >( elementId: ElementID, settingKeys: string[] ) => {\n\treturn useListenTo(\n\t\tcommandEndEvent( 'document/elements/set-settings' ),\n\t\t() =>\n\t\t\tsettingKeys.reduce< Record< string, TValue > >( ( settings, key ) => {\n\t\t\t\tconst value = getElementSetting< TValue >( elementId, key );\n\n\t\t\t\tif ( value !== null ) {\n\t\t\t\t\tsettings[ key ] = value;\n\t\t\t\t}\n\n\t\t\t\treturn settings;\n\t\t\t}, {} ),\n\t\t[ elementId, ...settingKeys ]\n\t);\n};\n","import { __privateRunCommand as runCommand } from '@elementor/editor-v1-adapters';\n\nimport { type ExtendedWindow, type V1Element } from './types';\n\nexport function getContainer( id: string ): V1Element | null {\n\tconst extendedWindow = window as unknown as ExtendedWindow;\n\tconst container = extendedWindow.elementor?.getContainer?.( id );\n\n\treturn container ?? null;\n}\n\nexport const selectElement = ( elementId: string ) => {\n\ttry {\n\t\tconst container = getContainer( elementId );\n\n\t\trunCommand( 'document/elements/select', { container } );\n\t} catch {}\n};\n","import { type ElementID } from '../types';\nimport { getContainer } from './get-container';\n\nexport const getElementSetting = < TValue >( elementId: ElementID, settingKey: string ): TValue | null => {\n\tconst container = getContainer( elementId );\n\n\treturn ( container?.settings?.get( settingKey ) as TValue ) ?? null;\n};\n\nexport const getElementSettings = < TValue >(\n\telementId: ElementID,\n\tsettingKey: string[]\n): Record< string, TValue | null > => {\n\treturn Object.fromEntries( settingKey.map( ( key ) => [ key, getElementSetting( elementId, key ) ] ) );\n};\n","import { __privateUseListenTo as useListenTo, commandEndEvent } from '@elementor/editor-v1-adapters';\n\nimport { getWidgetsCache } from '../sync/get-widgets-cache';\nimport { type ElementType } from '../types';\n\nexport function useElementType( type?: string ) {\n\treturn useListenTo(\n\t\tcommandEndEvent( 'editor/documents/load' ),\n\t\t(): ElementType | null => {\n\t\t\tif ( ! type ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst widgetsCache = getWidgetsCache();\n\t\t\tconst elementType = widgetsCache?.[ type ];\n\n\t\t\tif ( ! elementType?.atomic_controls ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tif ( ! elementType?.atomic_props_schema ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tkey: type,\n\t\t\t\tcontrols: elementType.atomic_controls,\n\t\t\t\tpropsSchema: elementType.atomic_props_schema,\n\t\t\t\tdependenciesPerTargetMapping: elementType.dependencies_per_target_mapping ?? {},\n\t\t\t\ttitle: elementType.title,\n\t\t\t};\n\t\t},\n\t\t[ type ]\n\t);\n}\n","import { type ExtendedWindow } from './types';\n\nexport function getWidgetsCache() {\n\tconst extendedWindow = window as unknown as ExtendedWindow;\n\n\treturn extendedWindow?.elementor?.widgetsCache || null;\n}\n","import { __privateUseListenTo as useListenTo, commandEndEvent } from '@elementor/editor-v1-adapters';\n\nimport { getSelectedElements } from '../sync/get-selected-elements';\nimport { useElementType } from './use-element-type';\n\nexport function useSelectedElement() {\n\tconst elements = useListenTo(\n\t\t[\n\t\t\tcommandEndEvent( 'document/elements/select' ),\n\t\t\tcommandEndEvent( 'document/elements/deselect' ),\n\t\t\tcommandEndEvent( 'document/elements/select-all' ),\n\t\t\tcommandEndEvent( 'document/elements/deselect-all' ),\n\t\t],\n\t\tgetSelectedElements\n\t);\n\n\tconst [ element ] = elements;\n\n\tconst elementType = useElementType( element?.type );\n\n\tif ( elements.length !== 1 || ! elementType ) {\n\t\treturn { element: null, elementType: null };\n\t}\n\n\treturn { element, elementType };\n}\n","import { type Element } from '../types';\nimport { type ExtendedWindow } from './types';\n\nexport function getSelectedElements(): Element[] {\n\tconst extendedWindow = window as unknown as ExtendedWindow;\n\n\tconst selectedElements = extendedWindow.elementor?.selection?.getElements?.() ?? [];\n\n\treturn selectedElements.reduce< Element[] >( ( acc, el ) => {\n\t\tconst type = el.model.get( 'widgetType' ) || el.model.get( 'elType' );\n\n\t\tif ( type ) {\n\t\t\tacc.push( {\n\t\t\t\tid: el.model.get( 'id' ),\n\t\t\t\ttype,\n\t\t\t} );\n\t\t}\n\n\t\treturn acc;\n\t}, [] );\n}\n","import { __privateUseListenTo as useListenTo, commandEndEvent } from '@elementor/editor-v1-adapters';\n\nimport { type ExtendedWindow } from '../sync/types';\n\nexport function useParentElement( elementId: string | null ) {\n\treturn useListenTo(\n\t\t[ commandEndEvent( 'document/elements/create' ) ],\n\t\t() => {\n\t\t\tif ( ! elementId ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst extendedWindow = window as unknown as ExtendedWindow;\n\t\t\tconst element = extendedWindow?.elementor?.getContainer?.( elementId );\n\t\t\tif ( ! element ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\treturn element.parent;\n\t\t},\n\t\t[ elementId ]\n\t);\n}\n","import { __privateUseListenTo as useListenTo, commandEndEvent, v1ReadyEvent } from '@elementor/editor-v1-adapters';\n\nimport { getContainer } from '../sync/get-container';\nimport { type ElementID } from '../types';\n\ntype ElementModel = {\n\tid: string;\n};\n\nexport type ElementChildren = Record< string, ElementModel[] >;\n\nexport function useElementChildren< T extends ElementChildren >(\n\telementId: ElementID,\n\tchildrenTypes: ( keyof T & string )[]\n): T {\n\treturn useListenTo(\n\t\t[\n\t\t\tv1ReadyEvent(),\n\t\t\tcommandEndEvent( 'document/elements/create' ),\n\t\t\tcommandEndEvent( 'document/elements/delete' ),\n\t\t\tcommandEndEvent( 'document/elements/update' ),\n\t\t\tcommandEndEvent( 'document/elements/set-settings' ),\n\t\t],\n\t\t() => {\n\t\t\tconst container = getContainer( elementId );\n\n\t\t\tconst elementChildren = childrenTypes.reduce( ( acc, type ) => {\n\t\t\t\tacc[ type ] = [];\n\n\t\t\t\treturn acc;\n\t\t\t}, {} as ElementChildren );\n\n\t\t\tcontainer?.children?.forEachRecursive?.( ( { model, id } ) => {\n\t\t\t\tconst elType = model.get( 'elType' );\n\n\t\t\t\tif ( elType && elType in elementChildren ) {\n\t\t\t\t\telementChildren[ elType ].push( { id } );\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\treturn elementChildren;\n\t\t},\n\t\t[ elementId ]\n\t) as T;\n}\n","import { __privateRunCommandSync as runCommandSync } from '@elementor/editor-v1-adapters';\n\nimport { getContainer } from './get-container';\nimport { type V1Element, type V1ElementModelProps, type V1ElementSettingsProps } from './types';\n\ntype Options = {\n\tuseHistory?: boolean;\n\tat?: number;\n\tclone?: boolean;\n};\n\nexport type CreateElementParams = {\n\tcontainerId: string;\n\toptions?: Options;\n\tmodel?: Omit< V1ElementModelProps, 'settings' | 'id' > & { settings?: V1ElementSettingsProps; id?: string };\n};\n\nexport function createElement( { containerId, model, options }: CreateElementParams ) {\n\tconst container = getContainer( containerId );\n\n\tif ( ! container ) {\n\t\tthrow new Error( `Container with ID \"${ containerId }\" not found` );\n\t}\n\n\treturn runCommandSync< V1Element >( 'document/elements/create', {\n\t\tcontainer,\n\t\tmodel,\n\t\toptions: { edit: false, ...options },\n\t} );\n}\n","import { createElement } from './create-element';\nimport { getContainer } from './get-container';\nimport { type V1Element } from './types';\n\ntype Options = {\n\tuseHistory?: boolean;\n\tat?: number;\n\tclone?: boolean;\n};\n\nexport type DuplicateElementParams = {\n\telementId: string;\n\toptions?: Options;\n};\n\nexport function duplicateElement( { elementId, options = {} }: DuplicateElementParams ): V1Element {\n\tconst elementToDuplicate = getContainer( elementId );\n\n\tif ( ! elementToDuplicate ) {\n\t\tthrow new Error( `Element with ID \"${ elementId }\" not found` );\n\t}\n\n\tif ( ! elementToDuplicate.parent ) {\n\t\tthrow new Error( `Element with ID \"${ elementId }\" has no parent container` );\n\t}\n\n\tconst parentContainer = elementToDuplicate.parent;\n\tconst elementModel = elementToDuplicate.model.toJSON();\n\n\t// Get the position after the original element (only when cloning)\n\tconst currentIndex = elementToDuplicate.view?._index ?? 0;\n\tconst insertPosition = options.clone !== false ? currentIndex + 1 : undefined;\n\n\treturn createElement( {\n\t\tcontainerId: parentContainer.id,\n\t\tmodel: elementModel,\n\t\toptions: {\n\t\t\tat: insertPosition,\n\t\t\t...options,\n\t\t},\n\t} );\n}\n","import { undoable } from '@elementor/editor-v1-adapters';\nimport { __ } from '@wordpress/i18n';\n\nimport { createElement, type CreateElementParams } from './create-element';\nimport { deleteElement } from './delete-element';\nimport { getContainer } from './get-container';\nimport { type V1ElementModelProps } from './types';\n\ntype CreateNestedElementsParams = {\n\telements: CreateElementParams[];\n\ttitle: string;\n\tsubtitle?: string;\n};\n\ntype CreatedElement = {\n\telementId: string;\n\tmodel: V1ElementModelProps;\n\tcreateParams: CreateElementParams;\n};\n\ntype CreatedElementsResult = {\n\tcreatedElements: CreatedElement[];\n};\n\nexport type { CreateNestedElementsParams, CreatedElement, CreatedElementsResult };\n\nexport const createElements = ( {\n\telements,\n\ttitle,\n\tsubtitle = __( 'Item added', 'elementor' ),\n}: CreateNestedElementsParams ): CreatedElementsResult => {\n\tconst undoableCreate = undoable(\n\t\t{\n\t\t\tdo: ( { elements: elementsParam }: { elements: CreateElementParams[] } ): CreatedElementsResult => {\n\t\t\t\tconst createdElements: CreatedElement[] = [];\n\n\t\t\t\telementsParam.forEach( ( createParams ) => {\n\t\t\t\t\tconst { options, ...elementParams } = createParams;\n\t\t\t\t\tconst element = createElement( {\n\t\t\t\t\t\t...elementParams,\n\t\t\t\t\t\toptions: { ...options, useHistory: false },\n\t\t\t\t\t} );\n\n\t\t\t\t\tconst elementId = element.id;\n\n\t\t\t\t\tcreatedElements.push( {\n\t\t\t\t\t\telementId,\n\t\t\t\t\t\tmodel: element.model?.toJSON() || {},\n\t\t\t\t\t\tcreateParams: {\n\t\t\t\t\t\t\t...createParams,\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\t\t\t\t} );\n\n\t\t\t\treturn { createdElements };\n\t\t\t},\n\t\t\tundo: ( _: { elements: CreateElementParams[] }, { createdElements }: CreatedElementsResult ) => {\n\t\t\t\t// Delete elements in reverse order to avoid dependency issues\n\t\t\t\t[ ...createdElements ].reverse().forEach( ( { elementId } ) => {\n\t\t\t\t\tdeleteElement( {\n\t\t\t\t\t\telementId,\n\t\t\t\t\t\toptions: { useHistory: false },\n\t\t\t\t\t} );\n\t\t\t\t} );\n\t\t\t},\n\t\t\tredo: (\n\t\t\t\t_: { elements: CreateElementParams[] },\n\t\t\t\t{ createdElements }: CreatedElementsResult\n\t\t\t): CreatedElementsResult => {\n\t\t\t\tconst newElements: CreatedElement[] = [];\n\n\t\t\t\tcreatedElements.forEach( ( { createParams, model } ) => {\n\t\t\t\t\tconst element = createElement( {\n\t\t\t\t\t\tcontainerId: createParams.containerId,\n\t\t\t\t\t\tmodel,\n\t\t\t\t\t\toptions: { ...createParams.options, useHistory: false },\n\t\t\t\t\t} );\n\n\t\t\t\t\tconst elementId = element.id;\n\n\t\t\t\t\tconst container = getContainer( elementId );\n\n\t\t\t\t\tif ( container ) {\n\t\t\t\t\t\tnewElements.push( {\n\t\t\t\t\t\t\telementId,\n\t\t\t\t\t\t\tmodel: container.model.toJSON(),\n\t\t\t\t\t\t\tcreateParams,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t} );\n\n\t\t\t\treturn { createdElements: newElements };\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttitle,\n\t\t\tsubtitle,\n\t\t}\n\t);\n\n\treturn undoableCreate( { elements } );\n};\n","import { __privateRunCommand as runCommand } from '@elementor/editor-v1-adapters';\n\nimport { getContainer } from './get-container';\n\ntype Options = {\n\tuseHistory?: boolean;\n\tat?: number;\n};\n\nexport function deleteElement( { elementId, options = {} }: { elementId: string; options?: Options } ): void {\n\tconst container = getContainer( elementId );\n\n\tif ( ! container ) {\n\t\tthrow new Error( `Element with ID \"${ elementId }\" not found` );\n\t}\n\n\trunCommand( 'document/elements/delete', {\n\t\tcontainer,\n\t\toptions,\n\t} );\n}\n","import { undoable } from '@elementor/editor-v1-adapters';\nimport { __ } from '@wordpress/i18n';\n\nimport { createElement } from './create-element';\nimport { deleteElement } from './delete-element';\nimport { duplicateElement } from './duplicate-element';\nimport { getContainer } from './get-container';\nimport { type V1ElementModelProps } from './types';\n\ntype DuplicateElementsParams = {\n\telementIds: string[];\n\ttitle: string;\n\tsubtitle?: string;\n\tonCreate?: ( duplicatedElements: DuplicatedElement[] ) => DuplicatedElement[];\n};\n\ntype DuplicatedElement = {\n\tid: string;\n\tmodel: V1ElementModelProps;\n\toriginalElementId: string;\n\tmodelToRestore?: V1ElementModelProps;\n\tparentContainerId?: string;\n\tat?: number;\n};\n\ntype DuplicatedElementsResult = {\n\tduplicatedElements: DuplicatedElement[];\n};\n\nexport type { DuplicateElementsParams, DuplicatedElement, DuplicatedElementsResult };\n\nexport const duplicateElements = ( {\n\telementIds,\n\ttitle,\n\tsubtitle = __( 'Item duplicated', 'elementor' ),\n\tonCreate,\n}: DuplicateElementsParams ): DuplicatedElementsResult => {\n\tconst undoableDuplicate = undoable(\n\t\t{\n\t\t\tdo: ( { elementIds: elementIdsToDuplicate }: { elementIds: string[] } ): DuplicatedElementsResult => {\n\t\t\t\tconst duplicatedElements: DuplicatedElement[] = elementIdsToDuplicate.reduce( ( acc, elementId ) => {\n\t\t\t\t\tconst originalContainer = getContainer( elementId );\n\n\t\t\t\t\tif ( originalContainer?.parent ) {\n\t\t\t\t\t\tconst duplicatedElement = duplicateElement( {\n\t\t\t\t\t\t\telementId,\n\t\t\t\t\t\t\toptions: { useHistory: false, clone: true },\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\tacc.push( {\n\t\t\t\t\t\t\tid: duplicatedElement.id,\n\t\t\t\t\t\t\tmodel: duplicatedElement.model.toJSON(),\n\t\t\t\t\t\t\toriginalElementId: elementId,\n\t\t\t\t\t\t\tmodelToRestore: duplicatedElement.model.toJSON(),\n\t\t\t\t\t\t\tparentContainerId: duplicatedElement.parent?.id,\n\t\t\t\t\t\t\tat: duplicatedElement.view?._index,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn acc;\n\t\t\t\t}, [] as DuplicatedElement[] );\n\n\t\t\t\treturn { duplicatedElements: onCreate?.( duplicatedElements ) ?? duplicatedElements };\n\t\t\t},\n\t\t\tundo: ( _: { elementIds: string[] }, { duplicatedElements }: DuplicatedElementsResult ) => {\n\t\t\t\t// Delete duplicated elements in reverse order to avoid dependency issues\n\t\t\t\t[ ...duplicatedElements ].reverse().forEach( ( { id } ) => {\n\t\t\t\t\tdeleteElement( {\n\t\t\t\t\t\telementId: id,\n\t\t\t\t\t\toptions: { useHistory: false },\n\t\t\t\t\t} );\n\t\t\t\t} );\n\t\t\t},\n\t\t\tredo: (\n\t\t\t\t_: { elementIds: string[] },\n\t\t\t\t{ duplicatedElements: previousElements }: DuplicatedElementsResult\n\t\t\t): DuplicatedElementsResult => {\n\t\t\t\tconst duplicatedElements: DuplicatedElement[] = previousElements.reduce( ( acc, previousElement ) => {\n\t\t\t\t\tif ( previousElement.modelToRestore && previousElement.parentContainerId ) {\n\t\t\t\t\t\tconst createdElement = createElement( {\n\t\t\t\t\t\t\tcontainerId: previousElement.parentContainerId,\n\t\t\t\t\t\t\tmodel: previousElement.modelToRestore,\n\t\t\t\t\t\t\toptions: {\n\t\t\t\t\t\t\t\tuseHistory: false,\n\t\t\t\t\t\t\t\tclone: false,\n\t\t\t\t\t\t\t\tat: previousElement.at,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\tacc.push( {\n\t\t\t\t\t\t\tid: createdElement.id,\n\t\t\t\t\t\t\tmodel: createdElement.model.toJSON(),\n\t\t\t\t\t\t\toriginalElementId: previousElement.originalElementId,\n\t\t\t\t\t\t\tmodelToRestore: previousElement.modelToRestore,\n\t\t\t\t\t\t\tparentContainerId: previousElement.parentContainerId,\n\t\t\t\t\t\t\tat: previousElement.at,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn acc;\n\t\t\t\t}, [] as DuplicatedElement[] );\n\n\t\t\t\treturn { duplicatedElements: onCreate?.( duplicatedElements ) ?? duplicatedElements };\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttitle,\n\t\t\tsubtitle,\n\t\t}\n\t);\n\n\treturn undoableDuplicate( { elementIds } );\n};\n","import { undoable } from '@elementor/editor-v1-adapters';\nimport { __ } from '@wordpress/i18n';\n\nimport { createElement } from './create-element';\nimport { deleteElement } from './delete-element';\nimport { getContainer } from './get-container';\nimport { type V1Element, type V1ElementModelProps } from './types';\n\ntype RemoveNestedElementsParams = {\n\telementIds: string[];\n\ttitle: string;\n\tsubtitle?: string;\n};\n\ntype RemovedElement = {\n\telementId: string;\n\tmodel: V1ElementModelProps;\n\tparent: V1Element | null;\n\tat: number;\n};\n\ntype RemovedElementsResult = {\n\telementIds: string[];\n\tremovedElements: RemovedElement[];\n};\n\nexport type { RemoveNestedElementsParams, RemovedElement, RemovedElementsResult };\n\nexport const removeElements = ( {\n\telementIds,\n\ttitle,\n\tsubtitle = __( 'Item removed', 'elementor' ),\n}: RemoveNestedElementsParams ): RemovedElementsResult => {\n\tconst undoableRemove = undoable(\n\t\t{\n\t\t\tdo: ( { elementIds: elementIdsParam }: { elementIds: string[] } ): RemovedElementsResult => {\n\t\t\t\tconst removedElements: RemovedElement[] = [];\n\n\t\t\t\telementIdsParam.forEach( ( elementId ) => {\n\t\t\t\t\tconst container = getContainer( elementId );\n\n\t\t\t\t\tif ( container ) {\n\t\t\t\t\t\tconst model = container.model.toJSON();\n\t\t\t\t\t\tconst parent = container.parent;\n\n\t\t\t\t\t\tconst at = container.view?._index ?? 0;\n\n\t\t\t\t\t\tremovedElements.push( {\n\t\t\t\t\t\t\telementId,\n\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\tparent: parent ?? null,\n\t\t\t\t\t\t\tat,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t} );\n\n\t\t\t\telementIdsParam.forEach( ( elementId ) => {\n\t\t\t\t\tdeleteElement( {\n\t\t\t\t\t\telementId,\n\t\t\t\t\t\toptions: { useHistory: false },\n\t\t\t\t\t} );\n\t\t\t\t} );\n\n\t\t\t\treturn { elementIds: elementIdsParam, removedElements };\n\t\t\t},\n\t\t\tundo: ( _: { elementIds: string[] }, { removedElements }: RemovedElementsResult ) => {\n\t\t\t\t// Restore elements in reverse order to maintain proper hierarchy\n\t\t\t\t[ ...removedElements ].reverse().forEach( ( { model, parent, at } ) => {\n\t\t\t\t\tif ( parent && model ) {\n\t\t\t\t\t\tcreateElement( {\n\t\t\t\t\t\t\tcontainerId: parent.id,\n\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\toptions: { useHistory: false, at },\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t},\n\t\t\tredo: (\n\t\t\t\t_: { elementIds: string[] },\n\t\t\t\t{ elementIds: originalElementIds, removedElements }: RemovedElementsResult\n\t\t\t): RemovedElementsResult => {\n\t\t\t\toriginalElementIds.forEach( ( elementId ) => {\n\t\t\t\t\tdeleteElement( {\n\t\t\t\t\t\telementId,\n\t\t\t\t\t\toptions: { useHistory: false },\n\t\t\t\t\t} );\n\t\t\t\t} );\n\n\t\t\t\treturn { elementIds: originalElementIds, removedElements };\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttitle,\n\t\t\tsubtitle,\n\t\t}\n\t);\n\n\treturn undoableRemove( { elementIds } );\n};\n","import { type StyleDefinition } from '@elementor/editor-styles';\n\nimport { type ElementID } from '../types';\nimport { getContainer } from './get-container';\n\nexport const getElementStyles = ( elementID: ElementID ): Record< string, StyleDefinition > | null => {\n\tconst container = getContainer( elementID );\n\n\treturn container?.model.get( 'styles' ) || null;\n};\n","import { createError } from '@elementor/utils';\n\nexport const ElementNotFoundError = createError< { elementId: string } >( {\n\tcode: 'element_not_found',\n\tmessage: 'Element not found.',\n} );\n\nexport const StyleNotFoundError = createError< { styleId: string } >( {\n\tcode: 'style_not_found',\n\tmessage: 'Style not found.',\n} );\n\nexport const ElementTypeNotExistsError = createError< { elementId: string } >( {\n\tcode: 'element_type_not_exists',\n\tmessage: 'Element type does not exist.',\n} );\n\nexport const ElementLabelNotExistsError = createError< { elementType: string } >( {\n\tcode: 'element_label_not_exists',\n\tmessage: 'Element label does not exist.',\n} );\n","import { ElementLabelNotExistsError, ElementTypeNotExistsError } from '../errors';\nimport { getContainer } from '../sync/get-container';\nimport { getWidgetsCache } from '../sync/get-widgets-cache';\nimport { type ElementID } from '../types';\n\nexport function getElementLabel( elementId: ElementID ) {\n\tconst container = getContainer( elementId );\n\n\tconst type = container?.model.get( 'widgetType' ) || container?.model.get( 'elType' );\n\n\tif ( ! type ) {\n\t\tthrow new ElementTypeNotExistsError( { context: { elementId } } );\n\t}\n\n\tconst label = getWidgetsCache()?.[ type ]?.title;\n\n\tif ( ! label ) {\n\t\tthrow new ElementLabelNotExistsError( { context: { elementType: type } } );\n\t}\n\n\treturn label;\n}\n","import { type ExtendedWindow } from './types';\n\nexport default function getCurrentDocumentContainer() {\n\tconst extendedWindow = window as unknown as ExtendedWindow;\n\n\treturn extendedWindow.elementor?.documents?.getCurrent?.()?.container ?? null;\n}\n","import { type ElementID } from '../types';\nimport { getContainer } from './get-container';\nimport getCurrentDocumentContainer from './get-current-document-container';\nimport { type V1Element } from './types';\n\nexport function getElements( root?: ElementID ): V1Element[] {\n\tconst container = root ? getContainer( root ) : getCurrentDocumentContainer();\n\n\tif ( ! container ) {\n\t\treturn [];\n\t}\n\n\tconst children = [ ...( container.model.get( 'elements' ) ?? [] ) ].flatMap( ( childModel ) =>\n\t\tgetElements( childModel.get( 'id' ) )\n\t);\n\n\treturn [ container, ...children ];\n}\n","import { type ExtendedWindow } from './types';\n\nexport function getCurrentDocumentId() {\n\tconst extendedWindow = window as unknown as ExtendedWindow;\n\n\treturn extendedWindow.elementor?.documents?.getCurrentId?.() ?? null;\n}\n","import { type Props } from '@elementor/editor-props';\nimport { __privateRunCommandSync as runCommandSync } from '@elementor/editor-v1-adapters';\n\nimport { type ElementID } from '../types';\nimport { getContainer } from './get-container';\n\nexport type UpdateElementSettingsArgs = {\n\tid: ElementID;\n\tprops: Props;\n\twithHistory?: boolean;\n};\n\nexport const updateElementSettings = ( { id, props, withHistory = true }: UpdateElementSettingsArgs ) => {\n\tconst container = getContainer( id );\n\n\tconst args = {\n\t\tcontainer,\n\t\tsettings: { ...props },\n\t};\n\n\tif ( withHistory ) {\n\t\trunCommandSync( 'document/elements/settings', args );\n\t} else {\n\t\trunCommandSync( 'document/elements/set-settings', args, { internal: true } );\n\t}\n};\n","import { type ExtendedWindow } from './types';\n\nexport const generateElementId = () => {\n\tconst extendedWindow = window as unknown as ExtendedWindow;\n\n\treturn (\n\t\textendedWindow.elementorCommon?.helpers?.getUniqueId?.() ??\n\t\t`el-${ Date.now() }-${ Math.random().toString( 36 ).substring( 2, 9 ) }`\n\t);\n};\n","import { commandEndEvent, windowEvent } from '@elementor/editor-v1-adapters';\n\nexport const ELEMENT_STYLE_CHANGE_EVENT = 'elementor/editor-v2/editor-elements/style';\n\nexport const styleRerenderEvents = [\n\tcommandEndEvent( 'document/elements/create' ),\n\tcommandEndEvent( 'document/elements/duplicate' ),\n\tcommandEndEvent( 'document/elements/import' ),\n\tcommandEndEvent( 'document/elements/paste' ),\n\twindowEvent( ELEMENT_STYLE_CHANGE_EVENT ),\n];\n","import { classesPropTypeUtil } from '@elementor/editor-props';\nimport {\n\tgenerateId,\n\ttype StyleDefinition,\n\ttype StyleDefinitionID,\n\ttype StyleDefinitionVariant,\n} from '@elementor/editor-styles';\n\nimport { getElementSetting } from '../sync/get-element-setting';\nimport { updateElementSettings } from '../sync/update-element-settings';\nimport { type ElementID } from '../types';\nimport { mutateElementStyles } from './mutate-element-styles';\n\nexport type CreateElementStyleArgs = {\n\tstyleId?: StyleDefinitionID;\n\telementId: ElementID;\n\tclassesProp: string;\n\tlabel: string;\n\tmeta: StyleDefinitionVariant[ 'meta' ];\n\tprops: StyleDefinitionVariant[ 'props' ];\n\tcustom_css?: StyleDefinitionVariant[ 'custom_css' ];\n\tadditionalVariants?: StyleDefinitionVariant[];\n};\n\nexport function createElementStyle( {\n\tstyleId,\n\telementId,\n\tclassesProp,\n\tlabel,\n\tmeta,\n\tprops,\n\tcustom_css: customCss = null,\n\tadditionalVariants = [],\n}: CreateElementStyleArgs ): string {\n\tlet id = styleId;\n\n\tmutateElementStyles( elementId, ( styles ) => {\n\t\tid ??= generateId( `e-${ elementId }-`, Object.keys( styles ) );\n\n\t\tconst variants = [ { meta, props, custom_css: customCss }, ...additionalVariants ];\n\n\t\tstyles[ id ] = {\n\t\t\tid,\n\t\t\tlabel,\n\t\t\ttype: 'class',\n\t\t\tvariants,\n\t\t} satisfies StyleDefinition;\n\n\t\taddStyleToClassesProp( elementId, classesProp, id );\n\n\t\treturn styles;\n\t} );\n\n\treturn id as string;\n}\n\nfunction addStyleToClassesProp( elementId: ElementID, classesProp: string, styleId: string ) {\n\tconst base = getElementSetting( elementId, classesProp );\n\n\tconst classesPropValue = classesPropTypeUtil.create(\n\t\t( prev ) => {\n\t\t\treturn [ ...( prev ?? [] ), styleId ];\n\t\t},\n\t\t{ base }\n\t);\n\n\tupdateElementSettings( {\n\t\tid: elementId,\n\t\tprops: {\n\t\t\t[ classesProp ]: classesPropValue,\n\t\t},\n\t\twithHistory: false,\n\t} );\n}\n\nexport function shouldCreateNewLocalStyle< T >(\n\tpayload: { styleId: StyleDefinition[ 'id' ] | null; provider: T | null } | null\n) {\n\treturn ! payload?.styleId && ! payload?.provider;\n}\n","import { classesPropTypeUtil, type ClassesPropValue } from '@elementor/editor-props';\nimport { type StyleDefinition, type StyleDefinitionsMap } from '@elementor/editor-styles';\nimport { __privateRunCommandSync as runCommandSync } from '@elementor/editor-v1-adapters';\n\nimport { ElementNotFoundError } from '../errors';\nimport { getContainer } from '../sync/get-container';\nimport { type V1Element } from '../sync/types';\nimport { updateElementSettings } from '../sync/update-element-settings';\nimport { type ElementID } from '../types';\nimport { ELEMENT_STYLE_CHANGE_EVENT } from './consts';\n\ntype Mutator = ( styles: StyleDefinitionsMap ) => StyleDefinitionsMap;\n\nexport function mutateElementStyles( elementId: ElementID, mutator: Mutator ) {\n\tconst container = getContainer( elementId );\n\n\tif ( ! container ) {\n\t\tthrow new ElementNotFoundError( { context: { elementId } } );\n\t}\n\n\tconst oldIds = Object.keys( container.model.get( 'styles' ) ?? {} );\n\n\tconst styles = mutateStyles( container, mutator );\n\n\tconst newIds = Object.keys( styles );\n\n\tclearRemovedClasses( container, {\n\t\toldIds,\n\t\tnewIds,\n\t} );\n\n\tnotifyChanges();\n\n\treturn styles;\n}\n\nfunction mutateStyles( container: V1Element, mutator: Mutator ) {\n\tconst styles: StyleDefinitionsMap = structuredClone( container.model.get( 'styles' ) ) ?? {};\n\n\tconst entries = Object.entries( mutator( styles ) )\n\t\t.map( ( [ styleId, style ] ) => {\n\t\t\tstyle.variants = removeEmptyVariants( style );\n\n\t\t\treturn [ styleId, style ] as const;\n\t\t} )\n\t\t.filter( ( [ , style ] ) => {\n\t\t\treturn ! isStyleEmpty( style );\n\t\t} );\n\n\tconst mutatedStyles = Object.fromEntries( entries );\n\n\tcontainer.model.set( 'styles', mutatedStyles );\n\n\treturn mutatedStyles;\n}\n\nfunction removeEmptyVariants( style: StyleDefinition ) {\n\treturn style.variants.filter(\n\t\t( { props, custom_css: customCss } ) => Object.keys( props ).length > 0 || customCss?.raw\n\t);\n}\n\nfunction isStyleEmpty( style: StyleDefinition ) {\n\treturn style.variants.length === 0;\n}\n\nfunction clearRemovedClasses( container: V1Element, { oldIds, newIds }: { oldIds: string[]; newIds: string[] } ) {\n\tconst removedIds = oldIds.filter( ( id ) => ! newIds.includes( id ) );\n\tconst classesProps = structuredClone( getClassesProps( container ) );\n\n\tclassesProps.forEach( ( [ , prop ] ) => {\n\t\tprop.value = prop.value.filter( ( value ) => ! removedIds.includes( value ) );\n\t} );\n\n\tupdateElementSettings( {\n\t\tid: container.id,\n\t\tprops: Object.fromEntries( classesProps ),\n\t\twithHistory: false,\n\t} );\n}\n\nfunction getClassesProps( container: V1Element ) {\n\treturn Object.entries( container.settings.toJSON() ).filter( ( prop ): prop is [ string, ClassesPropValue ] => {\n\t\tconst [ , value ] = prop;\n\n\t\treturn classesPropTypeUtil.isValid( value );\n\t} );\n}\n\nfunction notifyChanges() {\n\tdispatchChangeEvent();\n\trunCommandSync( 'document/save/set-is-modified', { status: true }, { internal: true } );\n}\n\nfunction dispatchChangeEvent() {\n\twindow.dispatchEvent( new CustomEvent( ELEMENT_STYLE_CHANGE_EVENT ) );\n}\n","import { mergeProps } from '@elementor/editor-props';\nimport { getVariantByMeta, type StyleDefinition, type StyleDefinitionVariant } from '@elementor/editor-styles';\n\nimport { StyleNotFoundError } from '../errors';\nimport { type ElementID } from '../types';\nimport { mutateElementStyles } from './mutate-element-styles';\n\nexport type UpdateElementStyleArgs = {\n\telementId: ElementID;\n\tstyleId: StyleDefinition[ 'id' ];\n\tmeta: StyleDefinitionVariant[ 'meta' ];\n\tprops: StyleDefinitionVariant[ 'props' ];\n\tcustom_css?: StyleDefinitionVariant[ 'custom_css' ];\n};\n\nexport function updateElementStyle( args: UpdateElementStyleArgs ) {\n\tmutateElementStyles( args.elementId, ( styles ) => {\n\t\tconst style = styles[ args.styleId ];\n\n\t\tif ( ! style ) {\n\t\t\tthrow new StyleNotFoundError( { context: { styleId: args.styleId } } );\n\t\t}\n\n\t\tconst variant = getVariantByMeta( style, args.meta );\n\t\tconst customCss = ( 'custom_css' in args ? args.custom_css : variant?.custom_css ) ?? null;\n\n\t\tif ( variant ) {\n\t\t\tvariant.props = mergeProps( variant.props, args.props );\n\t\t\tvariant.custom_css = customCss?.raw ? customCss : null;\n\t\t} else {\n\t\t\tstyle.variants.push( { meta: args.meta, props: args.props, custom_css: customCss } );\n\t\t}\n\n\t\treturn styles;\n\t} );\n}\n","import { type StyleDefinitionID } from '@elementor/editor-styles';\n\nimport { type ElementID } from '../types';\nimport { mutateElementStyles } from './mutate-element-styles';\n\nexport function deleteElementStyle( elementId: ElementID, styleId: StyleDefinitionID ) {\n\tmutateElementStyles( elementId, ( styles ) => {\n\t\t// The object is deep cloned so mutating it is fine.\n\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\tdelete styles[ styleId ];\n\n\t\treturn styles;\n\t} );\n}\n","import { getContainer } from './sync/get-container';\n\nexport type LinkInLinkRestriction =\n\t| {\n\t\t\tshouldRestrict: true;\n\t\t\treason: 'ancestor' | 'descendant';\n\t\t\telementId: string | null;\n\t }\n\t| {\n\t\t\tshouldRestrict: false;\n\t\t\treason?: never;\n\t\t\telementId?: never;\n\t };\n\nexport function getLinkInLinkRestriction( elementId: string ): LinkInLinkRestriction {\n\tconst anchoredDescendantId = getAnchoredDescendantId( elementId );\n\n\tif ( anchoredDescendantId ) {\n\t\treturn {\n\t\t\tshouldRestrict: true,\n\t\t\treason: 'descendant',\n\t\t\telementId: anchoredDescendantId,\n\t\t};\n\t}\n\n\tconst ancestor = getAnchoredAncestorId( elementId );\n\n\tif ( ancestor ) {\n\t\treturn {\n\t\t\tshouldRestrict: true,\n\t\t\treason: 'ancestor',\n\t\t\telementId: ancestor,\n\t\t};\n\t}\n\n\treturn {\n\t\tshouldRestrict: false,\n\t};\n}\n\nexport function getAnchoredDescendantId( elementId: string ): string | null {\n\tconst element = getElementDOM( elementId );\n\n\tif ( ! element ) {\n\t\treturn null;\n\t}\n\n\tfor ( const childAnchorElement of Array.from( element.querySelectorAll( 'a' ) ) ) {\n\t\t// Ensure the child is not in the current element's scope\n\t\tconst childElementId = findElementIdOf( childAnchorElement );\n\n\t\tif ( childElementId !== elementId ) {\n\t\t\treturn childElementId;\n\t\t}\n\t}\n\n\treturn null;\n}\n\nexport function getAnchoredAncestorId( elementId: string ): string | null {\n\tconst element = getElementDOM( elementId );\n\n\tif ( ! element || element.parentElement === null ) {\n\t\treturn null;\n\t}\n\n\tconst parentAnchor = element.parentElement.closest( 'a' );\n\n\treturn parentAnchor ? findElementIdOf( parentAnchor ) : null;\n}\n\nexport function isElementAnchored( elementId: string ): boolean {\n\tconst element = getElementDOM( elementId );\n\n\tif ( ! element ) {\n\t\treturn false;\n\t}\n\n\tif ( isAnchorTag( element.tagName ) ) {\n\t\treturn true;\n\t}\n\n\treturn doesElementContainAnchor( element );\n}\n\nfunction doesElementContainAnchor( element: Element ): boolean {\n\tfor ( const child of element.children ) {\n\t\tif ( isElementorElement( child ) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( isAnchorTag( child.tagName ) ) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif ( doesElementContainAnchor( child ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\nfunction findElementIdOf( element: Element ): string | null {\n\treturn element.closest< HTMLElement >( '[data-id]' )?.dataset.id || null;\n}\n\nfunction getElementDOM( id: string ) {\n\ttry {\n\t\treturn getContainer( id )?.view?.el || null;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nfunction isAnchorTag( tagName: string ): boolean {\n\treturn tagName.toLowerCase() === 'a';\n}\n\nfunction isElementorElement( element: Element ): boolean {\n\treturn element.hasAttribute( 'data-id' );\n}\n"],"mappings":";AAAA,SAAS,wBAAwB,aAAa,uBAAuB;;;ACArE,SAAS,uBAAuB,kBAAkB;AAI3C,SAAS,aAAc,IAA+B;AAC5D,QAAM,iBAAiB;AACvB,QAAM,YAAY,eAAe,WAAW,eAAgB,EAAG;AAE/D,SAAO,aAAa;AACrB;AAEO,IAAM,gBAAgB,CAAE,cAAuB;AACrD,MAAI;AACH,UAAM,YAAY,aAAc,SAAU;AAE1C,eAAY,4BAA4B,EAAE,UAAU,CAAE;AAAA,EACvD,QAAQ;AAAA,EAAC;AACV;;;ACdO,IAAM,oBAAoB,CAAY,WAAsB,eAAuC;AACzG,QAAM,YAAY,aAAc,SAAU;AAE1C,SAAS,WAAW,UAAU,IAAK,UAAW,KAAiB;AAChE;AAEO,IAAM,qBAAqB,CACjC,WACA,eACqC;AACrC,SAAO,OAAO,YAAa,WAAW,IAAK,CAAE,QAAS,CAAE,KAAK,kBAAmB,WAAW,GAAI,CAAE,CAAE,CAAE;AACtG;;;AFTO,IAAM,oBAAoB,CAAY,WAAsB,eAAwB;AAC1F,SAAO;AAAA,I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,QAAK,mBAAoB,KAAM,GAAI;AAClC;AAAA,IACD;AAEA,QAAK,YAAa,MAAM,OAAQ,GAAI;AACnC,aAAO;AAAA,IACR;AAEA,QAAK,yBAA0B,KAAM,GAAI;AACxC,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAEA,SAAS,gBAAiB,SAAkC;AAC3D,SAAO,QAAQ,QAAwB,WAAY,GAAG,QAAQ,MAAM;AACrE;AAEA,SAAS,cAAe,IAAa;AACpC,MAAI;AACH,WAAO,aAAc,EAAG,GAAG,MAAM,MAAM;AAAA,EACxC,QAAQ;AACP,WAAO;AAAA,EACR;AACD;AAEA,SAAS,YAAa,SAA2B;AAChD,SAAO,QAAQ,YAAY,MAAM;AAClC;AAEA,SAAS,mBAAoB,SAA4B;AACxD,SAAO,QAAQ,aAAc,SAAU;AACxC;","names":["useListenTo","commandEndEvent","useListenTo","commandEndEvent","useListenTo","commandEndEvent","useListenTo","commandEndEvent","useListenTo","commandEndEvent","useListenTo","commandEndEvent","useListenTo","commandEndEvent","runCommand","runCommand","undoable","__","__","undoable","undoable","__","__","undoable","runCommandSync","runCommandSync","commandEndEvent","classesPropTypeUtil","runCommandSync","runCommandSync","classesPropTypeUtil"]}
1
+ {"version":3,"sources":["../src/hooks/use-element-setting.ts","../src/sync/get-container.ts","../src/sync/get-element-setting.ts","../src/hooks/use-element-type.ts","../src/sync/get-widgets-cache.ts","../src/hooks/use-selected-element.ts","../src/sync/get-selected-elements.ts","../src/hooks/use-parent-element.ts","../src/hooks/use-element-children.ts","../src/sync/create-element.ts","../src/sync/duplicate-element.ts","../src/sync/create-elements.ts","../src/sync/delete-element.ts","../src/sync/duplicate-elements.ts","../src/sync/remove-elements.ts","../src/sync/get-element-styles.ts","../src/errors.ts","../src/sync/get-element-label.ts","../src/sync/get-current-document-container.ts","../src/sync/get-elements.ts","../src/sync/get-current-document-id.ts","../src/sync/update-element-settings.ts","../src/sync/generate-element-id.ts","../src/sync/replace-element.ts","../src/styles/consts.ts","../src/styles/create-element-style.ts","../src/styles/mutate-element-styles.ts","../src/styles/update-element-style.ts","../src/styles/delete-element-style.ts","../src/link-restriction.ts"],"sourcesContent":["import { __privateUseListenTo as useListenTo, commandEndEvent } from '@elementor/editor-v1-adapters';\n\nimport { getElementSetting } from '../sync/get-element-setting';\nimport { type ElementID } from '../types';\n\nexport const useElementSetting = < TValue >( elementId: ElementID, settingKey: string ) => {\n\treturn useListenTo(\n\t\tcommandEndEvent( 'document/elements/set-settings' ),\n\t\t() => getElementSetting< TValue >( elementId, settingKey ),\n\t\t[ elementId, settingKey ]\n\t);\n};\n\nexport const useElementSettings = < TValue >( elementId: ElementID, settingKeys: string[] ) => {\n\treturn useListenTo(\n\t\tcommandEndEvent( 'document/elements/set-settings' ),\n\t\t() =>\n\t\t\tsettingKeys.reduce< Record< string, TValue > >( ( settings, key ) => {\n\t\t\t\tconst value = getElementSetting< TValue >( elementId, key );\n\n\t\t\t\tif ( value !== null ) {\n\t\t\t\t\tsettings[ key ] = value;\n\t\t\t\t}\n\n\t\t\t\treturn settings;\n\t\t\t}, {} ),\n\t\t[ elementId, ...settingKeys ]\n\t);\n};\n","import { __privateRunCommand as runCommand } from '@elementor/editor-v1-adapters';\n\nimport { type ExtendedWindow, type V1Element } from './types';\n\nexport function getContainer( id: string ): V1Element | null {\n\tconst extendedWindow = window as unknown as ExtendedWindow;\n\tconst container = extendedWindow.elementor?.getContainer?.( id );\n\n\treturn container ?? null;\n}\n\nexport const selectElement = ( elementId: string ) => {\n\ttry {\n\t\tconst container = getContainer( elementId );\n\n\t\trunCommand( 'document/elements/select', { container } );\n\t} catch {}\n};\n","import { type ElementID } from '../types';\nimport { getContainer } from './get-container';\n\nexport const getElementSetting = < TValue >( elementId: ElementID, settingKey: string ): TValue | null => {\n\tconst container = getContainer( elementId );\n\n\treturn ( container?.settings?.get( settingKey ) as TValue ) ?? null;\n};\n\nexport const getElementSettings = < TValue >(\n\telementId: ElementID,\n\tsettingKey: string[]\n): Record< string, TValue | null > => {\n\treturn Object.fromEntries( settingKey.map( ( key ) => [ key, getElementSetting( elementId, key ) ] ) );\n};\n","import { __privateUseListenTo as useListenTo, commandEndEvent } from '@elementor/editor-v1-adapters';\n\nimport { getWidgetsCache } from '../sync/get-widgets-cache';\nimport { type ElementType } from '../types';\n\nexport function useElementType( type?: string ) {\n\treturn useListenTo(\n\t\tcommandEndEvent( 'editor/documents/load' ),\n\t\t(): ElementType | null => {\n\t\t\tif ( ! type ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst widgetsCache = getWidgetsCache();\n\t\t\tconst elementType = widgetsCache?.[ type ];\n\n\t\t\tif ( ! elementType?.atomic_controls ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tif ( ! elementType?.atomic_props_schema ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tkey: type,\n\t\t\t\tcontrols: elementType.atomic_controls,\n\t\t\t\tpropsSchema: elementType.atomic_props_schema,\n\t\t\t\tdependenciesPerTargetMapping: elementType.dependencies_per_target_mapping ?? {},\n\t\t\t\ttitle: elementType.title,\n\t\t\t};\n\t\t},\n\t\t[ type ]\n\t);\n}\n","import { type ExtendedWindow } from './types';\n\nexport function getWidgetsCache() {\n\tconst extendedWindow = window as unknown as ExtendedWindow;\n\n\treturn extendedWindow?.elementor?.widgetsCache || null;\n}\n","import { __privateUseListenTo as useListenTo, commandEndEvent } from '@elementor/editor-v1-adapters';\n\nimport { getSelectedElements } from '../sync/get-selected-elements';\nimport { useElementType } from './use-element-type';\n\nexport function useSelectedElement() {\n\tconst elements = useListenTo(\n\t\t[\n\t\t\tcommandEndEvent( 'document/elements/select' ),\n\t\t\tcommandEndEvent( 'document/elements/deselect' ),\n\t\t\tcommandEndEvent( 'document/elements/select-all' ),\n\t\t\tcommandEndEvent( 'document/elements/deselect-all' ),\n\t\t],\n\t\tgetSelectedElements\n\t);\n\n\tconst [ element ] = elements;\n\n\tconst elementType = useElementType( element?.type );\n\n\tif ( elements.length !== 1 || ! elementType ) {\n\t\treturn { element: null, elementType: null };\n\t}\n\n\treturn { element, elementType };\n}\n","import { type Element } from '../types';\nimport { type ExtendedWindow } from './types';\n\nexport function getSelectedElements(): Element[] {\n\tconst extendedWindow = window as unknown as ExtendedWindow;\n\n\tconst selectedElements = extendedWindow.elementor?.selection?.getElements?.() ?? [];\n\n\treturn selectedElements.reduce< Element[] >( ( acc, el ) => {\n\t\tconst type = el.model.get( 'widgetType' ) || el.model.get( 'elType' );\n\n\t\tif ( type ) {\n\t\t\tacc.push( {\n\t\t\t\tid: el.model.get( 'id' ),\n\t\t\t\ttype,\n\t\t\t} );\n\t\t}\n\n\t\treturn acc;\n\t}, [] );\n}\n","import { __privateUseListenTo as useListenTo, commandEndEvent } from '@elementor/editor-v1-adapters';\n\nimport { type ExtendedWindow } from '../sync/types';\n\nexport function useParentElement( elementId: string | null ) {\n\treturn useListenTo(\n\t\t[ commandEndEvent( 'document/elements/create' ) ],\n\t\t() => {\n\t\t\tif ( ! elementId ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst extendedWindow = window as unknown as ExtendedWindow;\n\t\t\tconst element = extendedWindow?.elementor?.getContainer?.( elementId );\n\t\t\tif ( ! element ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\treturn element.parent;\n\t\t},\n\t\t[ elementId ]\n\t);\n}\n","import { __privateUseListenTo as useListenTo, commandEndEvent, v1ReadyEvent } from '@elementor/editor-v1-adapters';\n\nimport { getContainer } from '../sync/get-container';\nimport { type ElementID } from '../types';\n\ntype ElementModel = {\n\tid: string;\n};\n\nexport type ElementChildren = Record< string, ElementModel[] >;\n\nexport function useElementChildren< T extends ElementChildren >(\n\telementId: ElementID,\n\tchildrenTypes: ( keyof T & string )[]\n): T {\n\treturn useListenTo(\n\t\t[\n\t\t\tv1ReadyEvent(),\n\t\t\tcommandEndEvent( 'document/elements/create' ),\n\t\t\tcommandEndEvent( 'document/elements/delete' ),\n\t\t\tcommandEndEvent( 'document/elements/update' ),\n\t\t\tcommandEndEvent( 'document/elements/set-settings' ),\n\t\t],\n\t\t() => {\n\t\t\tconst container = getContainer( elementId );\n\n\t\t\tconst elementChildren = childrenTypes.reduce( ( acc, type ) => {\n\t\t\t\tacc[ type ] = [];\n\n\t\t\t\treturn acc;\n\t\t\t}, {} as ElementChildren );\n\n\t\t\tcontainer?.children?.forEachRecursive?.( ( { model, id } ) => {\n\t\t\t\tconst elType = model.get( 'elType' );\n\n\t\t\t\tif ( elType && elType in elementChildren ) {\n\t\t\t\t\telementChildren[ elType ].push( { id } );\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\treturn elementChildren;\n\t\t},\n\t\t[ elementId ]\n\t) as T;\n}\n","import { __privateRunCommandSync as runCommandSync } from '@elementor/editor-v1-adapters';\n\nimport { getContainer } from './get-container';\nimport { type V1Element, type V1ElementModelProps, type V1ElementSettingsProps } from './types';\n\ntype Options = {\n\tuseHistory?: boolean;\n\tat?: number;\n\tclone?: boolean;\n};\n\nexport type CreateElementParams = {\n\tcontainerId: string;\n\toptions?: Options;\n\tmodel?: Omit< V1ElementModelProps, 'settings' | 'id' > & { settings?: V1ElementSettingsProps; id?: string };\n};\n\nexport function createElement( { containerId, model, options }: CreateElementParams ) {\n\tconst container = getContainer( containerId );\n\n\tif ( ! container ) {\n\t\tthrow new Error( `Container with ID \"${ containerId }\" not found` );\n\t}\n\n\treturn runCommandSync< V1Element >( 'document/elements/create', {\n\t\tcontainer,\n\t\tmodel,\n\t\toptions: { edit: false, ...options },\n\t} );\n}\n","import { createElement } from './create-element';\nimport { getContainer } from './get-container';\nimport { type V1Element } from './types';\n\ntype Options = {\n\tuseHistory?: boolean;\n\tat?: number;\n\tclone?: boolean;\n};\n\nexport type DuplicateElementParams = {\n\telementId: string;\n\toptions?: Options;\n};\n\nexport function duplicateElement( { elementId, options = {} }: DuplicateElementParams ): V1Element {\n\tconst elementToDuplicate = getContainer( elementId );\n\n\tif ( ! elementToDuplicate ) {\n\t\tthrow new Error( `Element with ID \"${ elementId }\" not found` );\n\t}\n\n\tif ( ! elementToDuplicate.parent ) {\n\t\tthrow new Error( `Element with ID \"${ elementId }\" has no parent container` );\n\t}\n\n\tconst parentContainer = elementToDuplicate.parent;\n\tconst elementModel = elementToDuplicate.model.toJSON();\n\n\t// Get the position after the original element (only when cloning)\n\tconst currentIndex = elementToDuplicate.view?._index ?? 0;\n\tconst insertPosition = options.clone !== false ? currentIndex + 1 : undefined;\n\n\treturn createElement( {\n\t\tcontainerId: parentContainer.id,\n\t\tmodel: elementModel,\n\t\toptions: {\n\t\t\tat: insertPosition,\n\t\t\t...options,\n\t\t},\n\t} );\n}\n","import { undoable } from '@elementor/editor-v1-adapters';\nimport { __ } from '@wordpress/i18n';\n\nimport { createElement, type CreateElementParams } from './create-element';\nimport { deleteElement } from './delete-element';\nimport { getContainer } from './get-container';\nimport { type V1ElementModelProps } from './types';\n\ntype CreateNestedElementsParams = {\n\telements: CreateElementParams[];\n\ttitle: string;\n\tsubtitle?: string;\n};\n\ntype CreatedElement = {\n\telementId: string;\n\tmodel: V1ElementModelProps;\n\tcreateParams: CreateElementParams;\n};\n\ntype CreatedElementsResult = {\n\tcreatedElements: CreatedElement[];\n};\n\nexport type { CreateNestedElementsParams, CreatedElement, CreatedElementsResult };\n\nexport const createElements = ( {\n\telements,\n\ttitle,\n\tsubtitle = __( 'Item added', 'elementor' ),\n}: CreateNestedElementsParams ): CreatedElementsResult => {\n\tconst undoableCreate = undoable(\n\t\t{\n\t\t\tdo: ( { elements: elementsParam }: { elements: CreateElementParams[] } ): CreatedElementsResult => {\n\t\t\t\tconst createdElements: CreatedElement[] = [];\n\n\t\t\t\telementsParam.forEach( ( createParams ) => {\n\t\t\t\t\tconst { options, ...elementParams } = createParams;\n\t\t\t\t\tconst element = createElement( {\n\t\t\t\t\t\t...elementParams,\n\t\t\t\t\t\toptions: { ...options, useHistory: false },\n\t\t\t\t\t} );\n\n\t\t\t\t\tconst elementId = element.id;\n\n\t\t\t\t\tcreatedElements.push( {\n\t\t\t\t\t\telementId,\n\t\t\t\t\t\tmodel: element.model?.toJSON() || {},\n\t\t\t\t\t\tcreateParams: {\n\t\t\t\t\t\t\t...createParams,\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\t\t\t\t} );\n\n\t\t\t\treturn { createdElements };\n\t\t\t},\n\t\t\tundo: ( _: { elements: CreateElementParams[] }, { createdElements }: CreatedElementsResult ) => {\n\t\t\t\t// Delete elements in reverse order to avoid dependency issues\n\t\t\t\t[ ...createdElements ].reverse().forEach( ( { elementId } ) => {\n\t\t\t\t\tdeleteElement( {\n\t\t\t\t\t\telementId,\n\t\t\t\t\t\toptions: { useHistory: false },\n\t\t\t\t\t} );\n\t\t\t\t} );\n\t\t\t},\n\t\t\tredo: (\n\t\t\t\t_: { elements: CreateElementParams[] },\n\t\t\t\t{ createdElements }: CreatedElementsResult\n\t\t\t): CreatedElementsResult => {\n\t\t\t\tconst newElements: CreatedElement[] = [];\n\n\t\t\t\tcreatedElements.forEach( ( { createParams, model } ) => {\n\t\t\t\t\tconst element = createElement( {\n\t\t\t\t\t\tcontainerId: createParams.containerId,\n\t\t\t\t\t\tmodel,\n\t\t\t\t\t\toptions: { ...createParams.options, useHistory: false },\n\t\t\t\t\t} );\n\n\t\t\t\t\tconst elementId = element.id;\n\n\t\t\t\t\tconst container = getContainer( elementId );\n\n\t\t\t\t\tif ( container ) {\n\t\t\t\t\t\tnewElements.push( {\n\t\t\t\t\t\t\telementId,\n\t\t\t\t\t\t\tmodel: container.model.toJSON(),\n\t\t\t\t\t\t\tcreateParams,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t} );\n\n\t\t\t\treturn { createdElements: newElements };\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttitle,\n\t\t\tsubtitle,\n\t\t}\n\t);\n\n\treturn undoableCreate( { elements } );\n};\n","import { __privateRunCommand as runCommand } from '@elementor/editor-v1-adapters';\n\nimport { getContainer } from './get-container';\n\ntype Options = {\n\tuseHistory?: boolean;\n\tat?: number;\n};\n\nexport function deleteElement( { elementId, options = {} }: { elementId: string; options?: Options } ): void {\n\tconst container = getContainer( elementId );\n\n\tif ( ! container ) {\n\t\tthrow new Error( `Element with ID \"${ elementId }\" not found` );\n\t}\n\n\trunCommand( 'document/elements/delete', {\n\t\tcontainer,\n\t\toptions,\n\t} );\n}\n","import { undoable } from '@elementor/editor-v1-adapters';\nimport { __ } from '@wordpress/i18n';\n\nimport { createElement } from './create-element';\nimport { deleteElement } from './delete-element';\nimport { duplicateElement } from './duplicate-element';\nimport { getContainer } from './get-container';\nimport { type V1ElementModelProps } from './types';\n\ntype DuplicateElementsParams = {\n\telementIds: string[];\n\ttitle: string;\n\tsubtitle?: string;\n\tonCreate?: ( duplicatedElements: DuplicatedElement[] ) => DuplicatedElement[];\n};\n\ntype DuplicatedElement = {\n\tid: string;\n\tmodel: V1ElementModelProps;\n\toriginalElementId: string;\n\tmodelToRestore?: V1ElementModelProps;\n\tparentContainerId?: string;\n\tat?: number;\n};\n\ntype DuplicatedElementsResult = {\n\tduplicatedElements: DuplicatedElement[];\n};\n\nexport type { DuplicateElementsParams, DuplicatedElement, DuplicatedElementsResult };\n\nexport const duplicateElements = ( {\n\telementIds,\n\ttitle,\n\tsubtitle = __( 'Item duplicated', 'elementor' ),\n\tonCreate,\n}: DuplicateElementsParams ): DuplicatedElementsResult => {\n\tconst undoableDuplicate = undoable(\n\t\t{\n\t\t\tdo: ( { elementIds: elementIdsToDuplicate }: { elementIds: string[] } ): DuplicatedElementsResult => {\n\t\t\t\tconst duplicatedElements: DuplicatedElement[] = elementIdsToDuplicate.reduce( ( acc, elementId ) => {\n\t\t\t\t\tconst originalContainer = getContainer( elementId );\n\n\t\t\t\t\tif ( originalContainer?.parent ) {\n\t\t\t\t\t\tconst duplicatedElement = duplicateElement( {\n\t\t\t\t\t\t\telementId,\n\t\t\t\t\t\t\toptions: { useHistory: false, clone: true },\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\tacc.push( {\n\t\t\t\t\t\t\tid: duplicatedElement.id,\n\t\t\t\t\t\t\tmodel: duplicatedElement.model.toJSON(),\n\t\t\t\t\t\t\toriginalElementId: elementId,\n\t\t\t\t\t\t\tmodelToRestore: duplicatedElement.model.toJSON(),\n\t\t\t\t\t\t\tparentContainerId: duplicatedElement.parent?.id,\n\t\t\t\t\t\t\tat: duplicatedElement.view?._index,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn acc;\n\t\t\t\t}, [] as DuplicatedElement[] );\n\n\t\t\t\treturn { duplicatedElements: onCreate?.( duplicatedElements ) ?? duplicatedElements };\n\t\t\t},\n\t\t\tundo: ( _: { elementIds: string[] }, { duplicatedElements }: DuplicatedElementsResult ) => {\n\t\t\t\t// Delete duplicated elements in reverse order to avoid dependency issues\n\t\t\t\t[ ...duplicatedElements ].reverse().forEach( ( { id } ) => {\n\t\t\t\t\tdeleteElement( {\n\t\t\t\t\t\telementId: id,\n\t\t\t\t\t\toptions: { useHistory: false },\n\t\t\t\t\t} );\n\t\t\t\t} );\n\t\t\t},\n\t\t\tredo: (\n\t\t\t\t_: { elementIds: string[] },\n\t\t\t\t{ duplicatedElements: previousElements }: DuplicatedElementsResult\n\t\t\t): DuplicatedElementsResult => {\n\t\t\t\tconst duplicatedElements: DuplicatedElement[] = previousElements.reduce( ( acc, previousElement ) => {\n\t\t\t\t\tif ( previousElement.modelToRestore && previousElement.parentContainerId ) {\n\t\t\t\t\t\tconst createdElement = createElement( {\n\t\t\t\t\t\t\tcontainerId: previousElement.parentContainerId,\n\t\t\t\t\t\t\tmodel: previousElement.modelToRestore,\n\t\t\t\t\t\t\toptions: {\n\t\t\t\t\t\t\t\tuseHistory: false,\n\t\t\t\t\t\t\t\tclone: false,\n\t\t\t\t\t\t\t\tat: previousElement.at,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\tacc.push( {\n\t\t\t\t\t\t\tid: createdElement.id,\n\t\t\t\t\t\t\tmodel: createdElement.model.toJSON(),\n\t\t\t\t\t\t\toriginalElementId: previousElement.originalElementId,\n\t\t\t\t\t\t\tmodelToRestore: previousElement.modelToRestore,\n\t\t\t\t\t\t\tparentContainerId: previousElement.parentContainerId,\n\t\t\t\t\t\t\tat: previousElement.at,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn acc;\n\t\t\t\t}, [] as DuplicatedElement[] );\n\n\t\t\t\treturn { duplicatedElements: onCreate?.( duplicatedElements ) ?? duplicatedElements };\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttitle,\n\t\t\tsubtitle,\n\t\t}\n\t);\n\n\treturn undoableDuplicate( { elementIds } );\n};\n","import { undoable } from '@elementor/editor-v1-adapters';\nimport { __ } from '@wordpress/i18n';\n\nimport { createElement } from './create-element';\nimport { deleteElement } from './delete-element';\nimport { getContainer } from './get-container';\nimport { type V1Element, type V1ElementModelProps } from './types';\n\ntype RemoveNestedElementsParams = {\n\telementIds: string[];\n\ttitle: string;\n\tsubtitle?: string;\n};\n\ntype RemovedElement = {\n\telementId: string;\n\tmodel: V1ElementModelProps;\n\tparent: V1Element | null;\n\tat: number;\n};\n\ntype RemovedElementsResult = {\n\telementIds: string[];\n\tremovedElements: RemovedElement[];\n};\n\nexport type { RemoveNestedElementsParams, RemovedElement, RemovedElementsResult };\n\nexport const removeElements = ( {\n\telementIds,\n\ttitle,\n\tsubtitle = __( 'Item removed', 'elementor' ),\n}: RemoveNestedElementsParams ): RemovedElementsResult => {\n\tconst undoableRemove = undoable(\n\t\t{\n\t\t\tdo: ( { elementIds: elementIdsParam }: { elementIds: string[] } ): RemovedElementsResult => {\n\t\t\t\tconst removedElements: RemovedElement[] = [];\n\n\t\t\t\telementIdsParam.forEach( ( elementId ) => {\n\t\t\t\t\tconst container = getContainer( elementId );\n\n\t\t\t\t\tif ( container ) {\n\t\t\t\t\t\tconst model = container.model.toJSON();\n\t\t\t\t\t\tconst parent = container.parent;\n\n\t\t\t\t\t\tconst at = container.view?._index ?? 0;\n\n\t\t\t\t\t\tremovedElements.push( {\n\t\t\t\t\t\t\telementId,\n\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\tparent: parent ?? null,\n\t\t\t\t\t\t\tat,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t} );\n\n\t\t\t\telementIdsParam.forEach( ( elementId ) => {\n\t\t\t\t\tdeleteElement( {\n\t\t\t\t\t\telementId,\n\t\t\t\t\t\toptions: { useHistory: false },\n\t\t\t\t\t} );\n\t\t\t\t} );\n\n\t\t\t\treturn { elementIds: elementIdsParam, removedElements };\n\t\t\t},\n\t\t\tundo: ( _: { elementIds: string[] }, { removedElements }: RemovedElementsResult ) => {\n\t\t\t\t// Restore elements in reverse order to maintain proper hierarchy\n\t\t\t\t[ ...removedElements ].reverse().forEach( ( { model, parent, at } ) => {\n\t\t\t\t\tif ( parent && model ) {\n\t\t\t\t\t\tcreateElement( {\n\t\t\t\t\t\t\tcontainerId: parent.id,\n\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\toptions: { useHistory: false, at },\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t},\n\t\t\tredo: (\n\t\t\t\t_: { elementIds: string[] },\n\t\t\t\t{ elementIds: originalElementIds, removedElements }: RemovedElementsResult\n\t\t\t): RemovedElementsResult => {\n\t\t\t\toriginalElementIds.forEach( ( elementId ) => {\n\t\t\t\t\tdeleteElement( {\n\t\t\t\t\t\telementId,\n\t\t\t\t\t\toptions: { useHistory: false },\n\t\t\t\t\t} );\n\t\t\t\t} );\n\n\t\t\t\treturn { elementIds: originalElementIds, removedElements };\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttitle,\n\t\t\tsubtitle,\n\t\t}\n\t);\n\n\treturn undoableRemove( { elementIds } );\n};\n","import { type StyleDefinition } from '@elementor/editor-styles';\n\nimport { type ElementID } from '../types';\nimport { getContainer } from './get-container';\n\nexport const getElementStyles = ( elementID: ElementID ): Record< string, StyleDefinition > | null => {\n\tconst container = getContainer( elementID );\n\n\treturn container?.model.get( 'styles' ) || null;\n};\n","import { createError } from '@elementor/utils';\n\nexport const ElementNotFoundError = createError< { elementId: string } >( {\n\tcode: 'element_not_found',\n\tmessage: 'Element not found.',\n} );\n\nexport const StyleNotFoundError = createError< { styleId: string } >( {\n\tcode: 'style_not_found',\n\tmessage: 'Style not found.',\n} );\n\nexport const ElementTypeNotExistsError = createError< { elementId: string } >( {\n\tcode: 'element_type_not_exists',\n\tmessage: 'Element type does not exist.',\n} );\n\nexport const ElementLabelNotExistsError = createError< { elementType: string } >( {\n\tcode: 'element_label_not_exists',\n\tmessage: 'Element label does not exist.',\n} );\n","import { ElementLabelNotExistsError, ElementTypeNotExistsError } from '../errors';\nimport { getContainer } from '../sync/get-container';\nimport { getWidgetsCache } from '../sync/get-widgets-cache';\nimport { type ElementID } from '../types';\n\nexport function getElementLabel( elementId: ElementID ) {\n\tconst container = getContainer( elementId );\n\n\tconst type = container?.model.get( 'widgetType' ) || container?.model.get( 'elType' );\n\n\tif ( ! type ) {\n\t\tthrow new ElementTypeNotExistsError( { context: { elementId } } );\n\t}\n\n\tconst label = getWidgetsCache()?.[ type ]?.title;\n\n\tif ( ! label ) {\n\t\tthrow new ElementLabelNotExistsError( { context: { elementType: type } } );\n\t}\n\n\treturn label;\n}\n","import { type ExtendedWindow } from './types';\n\nexport default function getCurrentDocumentContainer() {\n\tconst extendedWindow = window as unknown as ExtendedWindow;\n\n\treturn extendedWindow.elementor?.documents?.getCurrent?.()?.container ?? null;\n}\n","import { type ElementID } from '../types';\nimport { getContainer } from './get-container';\nimport getCurrentDocumentContainer from './get-current-document-container';\nimport { type V1Element } from './types';\n\nexport function getElements( root?: ElementID ): V1Element[] {\n\tconst container = root ? getContainer( root ) : getCurrentDocumentContainer();\n\n\tif ( ! container ) {\n\t\treturn [];\n\t}\n\n\tconst children = [ ...( container.model.get( 'elements' ) ?? [] ) ].flatMap( ( childModel ) =>\n\t\tgetElements( childModel.get( 'id' ) )\n\t);\n\n\treturn [ container, ...children ];\n}\n","import { type ExtendedWindow } from './types';\n\nexport function getCurrentDocumentId() {\n\tconst extendedWindow = window as unknown as ExtendedWindow;\n\n\treturn extendedWindow.elementor?.documents?.getCurrentId?.() ?? null;\n}\n","import { type Props } from '@elementor/editor-props';\nimport { __privateRunCommandSync as runCommandSync } from '@elementor/editor-v1-adapters';\n\nimport { type ElementID } from '../types';\nimport { getContainer } from './get-container';\n\nexport type UpdateElementSettingsArgs = {\n\tid: ElementID;\n\tprops: Props;\n\twithHistory?: boolean;\n};\n\nexport const updateElementSettings = ( { id, props, withHistory = true }: UpdateElementSettingsArgs ) => {\n\tconst container = getContainer( id );\n\n\tconst args = {\n\t\tcontainer,\n\t\tsettings: { ...props },\n\t};\n\n\tif ( withHistory ) {\n\t\trunCommandSync( 'document/elements/settings', args );\n\t} else {\n\t\trunCommandSync( 'document/elements/set-settings', args, { internal: true } );\n\t}\n};\n","import { type ExtendedWindow } from './types';\n\nexport const generateElementId = () => {\n\tconst extendedWindow = window as unknown as ExtendedWindow;\n\n\treturn (\n\t\textendedWindow.elementorCommon?.helpers?.getUniqueId?.() ??\n\t\t`el-${ Date.now() }-${ Math.random().toString( 36 ).substring( 2, 9 ) }`\n\t);\n};\n","import { createElement } from './create-element';\nimport { deleteElement } from './delete-element';\nimport { getContainer } from './get-container';\nimport { type V1Element, type V1ElementModelProps } from './types';\n\ntype ReplaceElementArgs = {\n\tcurrentElement: V1Element;\n\tnewElement: Omit< V1ElementModelProps, 'id' >;\n\twithHistory?: boolean;\n};\n\nexport const replaceElement = ( { currentElement, newElement, withHistory = true }: ReplaceElementArgs ) => {\n\tconst parent = getContainer( currentElement.id )?.parent;\n\n\tif ( ! parent ) {\n\t\tthrow new Error( `Parent not found for element ${ currentElement.id }. Cannot replace element.` );\n\t}\n\n\tconst elementIndex = parent.children?.findIndex( ( child ) => child.id === currentElement.id );\n\tif ( elementIndex === undefined || elementIndex === -1 ) {\n\t\tthrow new Error( `Element ${ currentElement.id } not found in parent container. Cannot replace element.` );\n\t}\n\n\tcreateElement( {\n\t\tcontainerId: parent.id,\n\t\tmodel: newElement,\n\t\toptions: { at: elementIndex, useHistory: withHistory },\n\t} );\n\n\tdeleteElement( { elementId: currentElement.id, options: { useHistory: withHistory } } );\n};\n","import { commandEndEvent, windowEvent } from '@elementor/editor-v1-adapters';\n\nexport const ELEMENT_STYLE_CHANGE_EVENT = 'elementor/editor-v2/editor-elements/style';\n\nexport const styleRerenderEvents = [\n\tcommandEndEvent( 'document/elements/create' ),\n\tcommandEndEvent( 'document/elements/duplicate' ),\n\tcommandEndEvent( 'document/elements/import' ),\n\tcommandEndEvent( 'document/elements/paste' ),\n\twindowEvent( ELEMENT_STYLE_CHANGE_EVENT ),\n];\n","import { classesPropTypeUtil } from '@elementor/editor-props';\nimport {\n\tgenerateId,\n\ttype StyleDefinition,\n\ttype StyleDefinitionID,\n\ttype StyleDefinitionVariant,\n} from '@elementor/editor-styles';\n\nimport { getElementSetting } from '../sync/get-element-setting';\nimport { updateElementSettings } from '../sync/update-element-settings';\nimport { type ElementID } from '../types';\nimport { mutateElementStyles } from './mutate-element-styles';\n\nexport type CreateElementStyleArgs = {\n\tstyleId?: StyleDefinitionID;\n\telementId: ElementID;\n\tclassesProp: string;\n\tlabel: string;\n\tmeta: StyleDefinitionVariant[ 'meta' ];\n\tprops: StyleDefinitionVariant[ 'props' ];\n\tcustom_css?: StyleDefinitionVariant[ 'custom_css' ];\n\tadditionalVariants?: StyleDefinitionVariant[];\n};\n\nexport function createElementStyle( {\n\tstyleId,\n\telementId,\n\tclassesProp,\n\tlabel,\n\tmeta,\n\tprops,\n\tcustom_css: customCss = null,\n\tadditionalVariants = [],\n}: CreateElementStyleArgs ): string {\n\tlet id = styleId;\n\n\tmutateElementStyles( elementId, ( styles ) => {\n\t\tid ??= generateId( `e-${ elementId }-`, Object.keys( styles ) );\n\n\t\tconst variants = [ { meta, props, custom_css: customCss }, ...additionalVariants ];\n\n\t\tstyles[ id ] = {\n\t\t\tid,\n\t\t\tlabel,\n\t\t\ttype: 'class',\n\t\t\tvariants,\n\t\t} satisfies StyleDefinition;\n\n\t\taddStyleToClassesProp( elementId, classesProp, id );\n\n\t\treturn styles;\n\t} );\n\n\treturn id as string;\n}\n\nfunction addStyleToClassesProp( elementId: ElementID, classesProp: string, styleId: string ) {\n\tconst base = getElementSetting( elementId, classesProp );\n\n\tconst classesPropValue = classesPropTypeUtil.create(\n\t\t( prev ) => {\n\t\t\treturn [ ...( prev ?? [] ), styleId ];\n\t\t},\n\t\t{ base }\n\t);\n\n\tupdateElementSettings( {\n\t\tid: elementId,\n\t\tprops: {\n\t\t\t[ classesProp ]: classesPropValue,\n\t\t},\n\t\twithHistory: false,\n\t} );\n}\n\nexport function shouldCreateNewLocalStyle< T >(\n\tpayload: { styleId: StyleDefinition[ 'id' ] | null; provider: T | null } | null\n) {\n\treturn ! payload?.styleId && ! payload?.provider;\n}\n","import { classesPropTypeUtil, type ClassesPropValue } from '@elementor/editor-props';\nimport { type StyleDefinition, type StyleDefinitionsMap } from '@elementor/editor-styles';\nimport { __privateRunCommandSync as runCommandSync } from '@elementor/editor-v1-adapters';\n\nimport { ElementNotFoundError } from '../errors';\nimport { getContainer } from '../sync/get-container';\nimport { type V1Element } from '../sync/types';\nimport { updateElementSettings } from '../sync/update-element-settings';\nimport { type ElementID } from '../types';\nimport { ELEMENT_STYLE_CHANGE_EVENT } from './consts';\n\ntype Mutator = ( styles: StyleDefinitionsMap ) => StyleDefinitionsMap;\n\nexport function mutateElementStyles( elementId: ElementID, mutator: Mutator ) {\n\tconst container = getContainer( elementId );\n\n\tif ( ! container ) {\n\t\tthrow new ElementNotFoundError( { context: { elementId } } );\n\t}\n\n\tconst oldIds = Object.keys( container.model.get( 'styles' ) ?? {} );\n\n\tconst styles = mutateStyles( container, mutator );\n\n\tconst newIds = Object.keys( styles );\n\n\tclearRemovedClasses( container, {\n\t\toldIds,\n\t\tnewIds,\n\t} );\n\n\tnotifyChanges();\n\n\treturn styles;\n}\n\nfunction mutateStyles( container: V1Element, mutator: Mutator ) {\n\tconst styles: StyleDefinitionsMap = structuredClone( container.model.get( 'styles' ) ) ?? {};\n\n\tconst entries = Object.entries( mutator( styles ) )\n\t\t.map( ( [ styleId, style ] ) => {\n\t\t\tstyle.variants = removeEmptyVariants( style );\n\n\t\t\treturn [ styleId, style ] as const;\n\t\t} )\n\t\t.filter( ( [ , style ] ) => {\n\t\t\treturn ! isStyleEmpty( style );\n\t\t} );\n\n\tconst mutatedStyles = Object.fromEntries( entries );\n\n\tcontainer.model.set( 'styles', mutatedStyles );\n\n\treturn mutatedStyles;\n}\n\nfunction removeEmptyVariants( style: StyleDefinition ) {\n\treturn style.variants.filter(\n\t\t( { props, custom_css: customCss } ) => Object.keys( props ).length > 0 || customCss?.raw\n\t);\n}\n\nfunction isStyleEmpty( style: StyleDefinition ) {\n\treturn style.variants.length === 0;\n}\n\nfunction clearRemovedClasses( container: V1Element, { oldIds, newIds }: { oldIds: string[]; newIds: string[] } ) {\n\tconst removedIds = oldIds.filter( ( id ) => ! newIds.includes( id ) );\n\tconst classesProps = structuredClone( getClassesProps( container ) );\n\n\tclassesProps.forEach( ( [ , prop ] ) => {\n\t\tprop.value = prop.value.filter( ( value ) => ! removedIds.includes( value ) );\n\t} );\n\n\tupdateElementSettings( {\n\t\tid: container.id,\n\t\tprops: Object.fromEntries( classesProps ),\n\t\twithHistory: false,\n\t} );\n}\n\nfunction getClassesProps( container: V1Element ) {\n\treturn Object.entries( container.settings.toJSON() ).filter( ( prop ): prop is [ string, ClassesPropValue ] => {\n\t\tconst [ , value ] = prop;\n\n\t\treturn classesPropTypeUtil.isValid( value );\n\t} );\n}\n\nfunction notifyChanges() {\n\tdispatchChangeEvent();\n\trunCommandSync( 'document/save/set-is-modified', { status: true }, { internal: true } );\n}\n\nfunction dispatchChangeEvent() {\n\twindow.dispatchEvent( new CustomEvent( ELEMENT_STYLE_CHANGE_EVENT ) );\n}\n","import { mergeProps } from '@elementor/editor-props';\nimport { getVariantByMeta, type StyleDefinition, type StyleDefinitionVariant } from '@elementor/editor-styles';\n\nimport { StyleNotFoundError } from '../errors';\nimport { type ElementID } from '../types';\nimport { mutateElementStyles } from './mutate-element-styles';\n\nexport type UpdateElementStyleArgs = {\n\telementId: ElementID;\n\tstyleId: StyleDefinition[ 'id' ];\n\tmeta: StyleDefinitionVariant[ 'meta' ];\n\tprops: StyleDefinitionVariant[ 'props' ];\n\tcustom_css?: StyleDefinitionVariant[ 'custom_css' ];\n};\n\nexport function updateElementStyle( args: UpdateElementStyleArgs ) {\n\tmutateElementStyles( args.elementId, ( styles ) => {\n\t\tconst style = styles[ args.styleId ];\n\n\t\tif ( ! style ) {\n\t\t\tthrow new StyleNotFoundError( { context: { styleId: args.styleId } } );\n\t\t}\n\n\t\tconst variant = getVariantByMeta( style, args.meta );\n\t\tconst customCss = ( 'custom_css' in args ? args.custom_css : variant?.custom_css ) ?? null;\n\n\t\tif ( variant ) {\n\t\t\tvariant.props = mergeProps( variant.props, args.props );\n\t\t\tvariant.custom_css = customCss?.raw ? customCss : null;\n\t\t} else {\n\t\t\tstyle.variants.push( { meta: args.meta, props: args.props, custom_css: customCss } );\n\t\t}\n\n\t\treturn styles;\n\t} );\n}\n","import { type StyleDefinitionID } from '@elementor/editor-styles';\n\nimport { type ElementID } from '../types';\nimport { mutateElementStyles } from './mutate-element-styles';\n\nexport function deleteElementStyle( elementId: ElementID, styleId: StyleDefinitionID ) {\n\tmutateElementStyles( elementId, ( styles ) => {\n\t\t// The object is deep cloned so mutating it is fine.\n\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\tdelete styles[ styleId ];\n\n\t\treturn styles;\n\t} );\n}\n","import { getContainer } from './sync/get-container';\n\nexport type LinkInLinkRestriction =\n\t| {\n\t\t\tshouldRestrict: true;\n\t\t\treason: 'ancestor' | 'descendant';\n\t\t\telementId: string | null;\n\t }\n\t| {\n\t\t\tshouldRestrict: false;\n\t\t\treason?: never;\n\t\t\telementId?: never;\n\t };\n\nexport function getLinkInLinkRestriction( elementId: string ): LinkInLinkRestriction {\n\tconst anchoredDescendantId = getAnchoredDescendantId( elementId );\n\n\tif ( anchoredDescendantId ) {\n\t\treturn {\n\t\t\tshouldRestrict: true,\n\t\t\treason: 'descendant',\n\t\t\telementId: anchoredDescendantId,\n\t\t};\n\t}\n\n\tconst ancestor = getAnchoredAncestorId( elementId );\n\n\tif ( ancestor ) {\n\t\treturn {\n\t\t\tshouldRestrict: true,\n\t\t\treason: 'ancestor',\n\t\t\telementId: ancestor,\n\t\t};\n\t}\n\n\treturn {\n\t\tshouldRestrict: false,\n\t};\n}\n\nexport function getAnchoredDescendantId( elementId: string ): string | null {\n\tconst element = getElementDOM( elementId );\n\n\tif ( ! element ) {\n\t\treturn null;\n\t}\n\n\tfor ( const childAnchorElement of Array.from( element.querySelectorAll( 'a' ) ) ) {\n\t\t// Ensure the child is not in the current element's scope\n\t\tconst childElementId = findElementIdOf( childAnchorElement );\n\n\t\tif ( childElementId !== elementId ) {\n\t\t\treturn childElementId;\n\t\t}\n\t}\n\n\treturn null;\n}\n\nexport function getAnchoredAncestorId( elementId: string ): string | null {\n\tconst element = getElementDOM( elementId );\n\n\tif ( ! element || element.parentElement === null ) {\n\t\treturn null;\n\t}\n\n\tconst parentAnchor = element.parentElement.closest( 'a' );\n\n\treturn parentAnchor ? findElementIdOf( parentAnchor ) : null;\n}\n\nexport function isElementAnchored( elementId: string ): boolean {\n\tconst element = getElementDOM( elementId );\n\n\tif ( ! element ) {\n\t\treturn false;\n\t}\n\n\tif ( isAnchorTag( element.tagName ) ) {\n\t\treturn true;\n\t}\n\n\treturn doesElementContainAnchor( element );\n}\n\nfunction doesElementContainAnchor( element: Element ): boolean {\n\tfor ( const child of element.children ) {\n\t\tif ( isElementorElement( child ) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( isAnchorTag( child.tagName ) ) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif ( doesElementContainAnchor( child ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\nfunction findElementIdOf( element: Element ): string | null {\n\treturn element.closest< HTMLElement >( '[data-id]' )?.dataset.id || null;\n}\n\nfunction getElementDOM( id: string ) {\n\ttry {\n\t\treturn getContainer( id )?.view?.el || null;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nfunction isAnchorTag( tagName: string ): boolean {\n\treturn tagName.toLowerCase() === 'a';\n}\n\nfunction isElementorElement( element: Element ): boolean {\n\treturn element.hasAttribute( 'data-id' );\n}\n"],"mappings":";AAAA,SAAS,wBAAwB,aAAa,uBAAuB;;;ACArE,SAAS,uBAAuB,kBAAkB;AAI3C,SAAS,aAAc,IAA+B;AAC5D,QAAM,iBAAiB;AACvB,QAAM,YAAY,eAAe,WAAW,eAAgB,EAAG;AAE/D,SAAO,aAAa;AACrB;AAEO,IAAM,gBAAgB,CAAE,cAAuB;AACrD,MAAI;AACH,UAAM,YAAY,aAAc,SAAU;AAE1C,eAAY,4BAA4B,EAAE,UAAU,CAAE;AAAA,EACvD,QAAQ;AAAA,EAAC;AACV;;;ACdO,IAAM,oBAAoB,CAAY,WAAsB,eAAuC;AACzG,QAAM,YAAY,aAAc,SAAU;AAE1C,SAAS,WAAW,UAAU,IAAK,UAAW,KAAiB;AAChE;AAEO,IAAM,qBAAqB,CACjC,WACA,eACqC;AACrC,SAAO,OAAO,YAAa,WAAW,IAAK,CAAE,QAAS,CAAE,KAAK,kBAAmB,WAAW,GAAI,CAAE,CAAE,CAAE;AACtG;;;AFTO,IAAM,oBAAoB,CAAY,WAAsB,eAAwB;AAC1F,SAAO;AAAA,IACN,gBAAiB,gCAAiC;AAAA,IAClD,MAAM,kBAA6B,WAAW,UAAW;AAAA,IACzD,CAAE,WAAW,UAAW;AAAA,EACzB;AACD;AAEO,IAAM,qBA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AACzE,QAAM,UAAU,cAAe,SAAU;AAEzC,MAAK,CAAE,WAAW,QAAQ,kBAAkB,MAAO;AAClD,WAAO;AAAA,EACR;AAEA,QAAM,eAAe,QAAQ,cAAc,QAAS,GAAI;AAExD,SAAO,eAAe,gBAAiB,YAAa,IAAI;AACzD;AAEO,SAAS,kBAAmB,WAA6B;AAC/D,QAAM,UAAU,cAAe,SAAU;AAEzC,MAAK,CAAE,SAAU;AAChB,WAAO;AAAA,EACR;AAEA,MAAK,YAAa,QAAQ,OAAQ,GAAI;AACrC,WAAO;AAAA,EACR;AAEA,SAAO,yBAA0B,OAAQ;AAC1C;AAEA,SAAS,yBAA0B,SAA4B;AAC9D,aAAY,SAAS,QAAQ,UAAW;AACvC,QAAK,mBAAoB,KAAM,GAAI;AAClC;AAAA,IACD;AAEA,QAAK,YAAa,MAAM,OAAQ,GAAI;AACnC,aAAO;AAAA,IACR;AAEA,QAAK,yBAA0B,KAAM,GAAI;AACxC,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAEA,SAAS,gBAAiB,SAAkC;AAC3D,SAAO,QAAQ,QAAwB,WAAY,GAAG,QAAQ,MAAM;AACrE;AAEA,SAAS,cAAe,IAAa;AACpC,MAAI;AACH,WAAO,aAAc,EAAG,GAAG,MAAM,MAAM;AAAA,EACxC,QAAQ;AACP,WAAO;AAAA,EACR;AACD;AAEA,SAAS,YAAa,SAA2B;AAChD,SAAO,QAAQ,YAAY,MAAM;AAClC;AAEA,SAAS,mBAAoB,SAA4B;AACxD,SAAO,QAAQ,aAAc,SAAU;AACxC;","names":["useListenTo","commandEndEvent","useListenTo","commandEndEvent","useListenTo","commandEndEvent","useListenTo","commandEndEvent","useListenTo","commandEndEvent","useListenTo","commandEndEvent","useListenTo","commandEndEvent","runCommand","runCommand","undoable","__","__","undoable","undoable","__","__","undoable","runCommandSync","runCommandSync","commandEndEvent","classesPropTypeUtil","runCommandSync","runCommandSync","classesPropTypeUtil"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@elementor/editor-elements",
3
3
  "description": "This package contains the elements model for the Elementor editor",
4
- "version": "3.32.0-86",
4
+ "version": "3.32.0-89",
5
5
  "private": false,
6
6
  "author": "Elementor Team",
7
7
  "homepage": "https://elementor.com/",
@@ -40,10 +40,10 @@
40
40
  "dev": "tsup --config=../../tsup.dev.ts"
41
41
  },
42
42
  "dependencies": {
43
- "@elementor/editor-props": "3.32.0-86",
44
- "@elementor/editor-styles": "3.32.0-86",
45
- "@elementor/editor-v1-adapters": "3.32.0-86",
46
- "@elementor/utils": "3.32.0-86",
43
+ "@elementor/editor-props": "3.32.0-89",
44
+ "@elementor/editor-styles": "3.32.0-89",
45
+ "@elementor/editor-v1-adapters": "3.32.0-89",
46
+ "@elementor/utils": "3.32.0-89",
47
47
  "@wordpress/i18n": "^3.1.0"
48
48
  },
49
49
  "peerDependencies": {
package/src/index.ts CHANGED
@@ -31,6 +31,7 @@ export { getSelectedElements } from './sync/get-selected-elements';
31
31
  export { getWidgetsCache } from './sync/get-widgets-cache';
32
32
  export { updateElementSettings, type UpdateElementSettingsArgs } from './sync/update-element-settings';
33
33
  export { generateElementId } from './sync/generate-element-id';
34
+ export { replaceElement } from './sync/replace-element';
34
35
 
35
36
  export { ELEMENT_STYLE_CHANGE_EVENT, styleRerenderEvents } from './styles/consts';
36
37
  export {
@@ -0,0 +1,31 @@
1
+ import { createElement } from './create-element';
2
+ import { deleteElement } from './delete-element';
3
+ import { getContainer } from './get-container';
4
+ import { type V1Element, type V1ElementModelProps } from './types';
5
+
6
+ type ReplaceElementArgs = {
7
+ currentElement: V1Element;
8
+ newElement: Omit< V1ElementModelProps, 'id' >;
9
+ withHistory?: boolean;
10
+ };
11
+
12
+ export const replaceElement = ( { currentElement, newElement, withHistory = true }: ReplaceElementArgs ) => {
13
+ const parent = getContainer( currentElement.id )?.parent;
14
+
15
+ if ( ! parent ) {
16
+ throw new Error( `Parent not found for element ${ currentElement.id }. Cannot replace element.` );
17
+ }
18
+
19
+ const elementIndex = parent.children?.findIndex( ( child ) => child.id === currentElement.id );
20
+ if ( elementIndex === undefined || elementIndex === -1 ) {
21
+ throw new Error( `Element ${ currentElement.id } not found in parent container. Cannot replace element.` );
22
+ }
23
+
24
+ createElement( {
25
+ containerId: parent.id,
26
+ model: newElement,
27
+ options: { at: elementIndex, useHistory: withHistory },
28
+ } );
29
+
30
+ deleteElement( { elementId: currentElement.id, options: { useHistory: withHistory } } );
31
+ };
package/src/sync/types.ts CHANGED
@@ -50,7 +50,7 @@ export type V1ElementModelProps = {
50
50
  id: string;
51
51
  styles?: Record< StyleDefinitionID, StyleDefinition >;
52
52
  elements?: V1Model< V1ElementModelProps >[];
53
- settings?: V1Model< V1ElementSettingsProps >;
53
+ settings?: V1ElementSettingsProps;
54
54
  };
55
55
 
56
56
  export type V1ElementSettingsProps = Record< string, PropValue >;
@@ -71,5 +71,5 @@ export type V1ElementConfig = {
71
71
  type V1Model< T > = {
72
72
  get: < K extends keyof T >( key: K ) => T[ K ];
73
73
  set: < K extends keyof T >( key: K, value: T[ K ] ) => void;
74
- toJSON: () => T;
74
+ toJSON: ( options?: { remove?: string[] } ) => T;
75
75
  };