@elementor/editor-elements 3.32.0-57 → 3.32.0-59
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 +27 -1
- package/dist/index.d.ts +27 -1
- package/dist/index.js +87 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +83 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
- package/src/hooks/use-element-children.ts +43 -0
- package/src/index.ts +3 -0
- package/src/sync/create-element.ts +46 -0
- package/src/sync/delete-element.ts +20 -0
- package/src/sync/get-container.ts +2 -2
- package/src/sync/types.ts +1 -0
package/dist/index.d.mts
CHANGED
|
@@ -58,6 +58,7 @@ type V1ElementModelProps = {
|
|
|
58
58
|
id: string;
|
|
59
59
|
styles?: Record<StyleDefinitionID, StyleDefinition>;
|
|
60
60
|
elements?: V1Model<V1ElementModelProps>[];
|
|
61
|
+
settings?: V1Model<V1ElementSettingsProps>;
|
|
61
62
|
};
|
|
62
63
|
type V1ElementSettingsProps = Record<string, PropValue>;
|
|
63
64
|
type V1ElementConfig = {
|
|
@@ -93,6 +94,31 @@ declare function useSelectedElement(): {
|
|
|
93
94
|
|
|
94
95
|
declare function useParentElement(elementId: string | null): V1Element | null | undefined;
|
|
95
96
|
|
|
97
|
+
type ElementModel = {
|
|
98
|
+
id: string;
|
|
99
|
+
};
|
|
100
|
+
type ElementChildren = Record<string, ElementModel[]>;
|
|
101
|
+
declare function useElementChildren<T extends ElementChildren>(elementId: ElementID, childrenTypes: (keyof T & string)[]): T;
|
|
102
|
+
|
|
103
|
+
type Options$1 = {
|
|
104
|
+
useHistory?: boolean;
|
|
105
|
+
};
|
|
106
|
+
declare function createElement({ containerId, settings, type, id, options, }: {
|
|
107
|
+
settings: V1ElementSettingsProps;
|
|
108
|
+
type: string;
|
|
109
|
+
containerId: string;
|
|
110
|
+
id?: string;
|
|
111
|
+
options?: Options$1;
|
|
112
|
+
}): V1Element;
|
|
113
|
+
|
|
114
|
+
type Options = {
|
|
115
|
+
useHistory?: boolean;
|
|
116
|
+
};
|
|
117
|
+
declare function deleteElement({ elementId, options }: {
|
|
118
|
+
elementId: string;
|
|
119
|
+
options?: Options;
|
|
120
|
+
}): void;
|
|
121
|
+
|
|
96
122
|
declare function getContainer(id: string): V1Element | null;
|
|
97
123
|
declare const selectElement: (elementId: string) => void;
|
|
98
124
|
|
|
@@ -162,4 +188,4 @@ declare function getAnchoredDescendantId(elementId: string): string | null;
|
|
|
162
188
|
declare function getAnchoredAncestorId(elementId: string): string | null;
|
|
163
189
|
declare function isElementAnchored(elementId: string): boolean;
|
|
164
190
|
|
|
165
|
-
export { type Control, type ControlItem, type ControlLayout, type ControlsSection, type CreateElementStyleArgs, ELEMENT_STYLE_CHANGE_EVENT, type Element, type ElementID, type ElementType, type LinkInLinkRestriction, type UpdateElementSettingsArgs, type UpdateElementStyleArgs, type V1Element, type V1ElementConfig, type V1ElementModelProps, type V1ElementSettingsProps, createElementStyle, deleteElementStyle, getAnchoredAncestorId, getAnchoredDescendantId, getContainer, getCurrentDocumentId, getElementLabel, getElementSetting, getElementSettings, getElementStyles, getElements, getLinkInLinkRestriction, getSelectedElements, getWidgetsCache, isElementAnchored, selectElement, shouldCreateNewLocalStyle, styleRerenderEvents, updateElementSettings, updateElementStyle, useElementSetting, useElementSettings, useElementType, useParentElement, useSelectedElement };
|
|
191
|
+
export { type Control, type ControlItem, type ControlLayout, type ControlsSection, type CreateElementStyleArgs, 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, deleteElement, deleteElementStyle, getAnchoredAncestorId, getAnchoredDescendantId, getContainer, getCurrentDocumentId, getElementLabel, getElementSetting, getElementSettings, getElementStyles, getElements, getLinkInLinkRestriction, getSelectedElements, getWidgetsCache, isElementAnchored, selectElement, shouldCreateNewLocalStyle, styleRerenderEvents, updateElementSettings, updateElementStyle, useElementChildren, useElementSetting, useElementSettings, useElementType, useParentElement, useSelectedElement };
|
package/dist/index.d.ts
CHANGED
|
@@ -58,6 +58,7 @@ type V1ElementModelProps = {
|
|
|
58
58
|
id: string;
|
|
59
59
|
styles?: Record<StyleDefinitionID, StyleDefinition>;
|
|
60
60
|
elements?: V1Model<V1ElementModelProps>[];
|
|
61
|
+
settings?: V1Model<V1ElementSettingsProps>;
|
|
61
62
|
};
|
|
62
63
|
type V1ElementSettingsProps = Record<string, PropValue>;
|
|
63
64
|
type V1ElementConfig = {
|
|
@@ -93,6 +94,31 @@ declare function useSelectedElement(): {
|
|
|
93
94
|
|
|
94
95
|
declare function useParentElement(elementId: string | null): V1Element | null | undefined;
|
|
95
96
|
|
|
97
|
+
type ElementModel = {
|
|
98
|
+
id: string;
|
|
99
|
+
};
|
|
100
|
+
type ElementChildren = Record<string, ElementModel[]>;
|
|
101
|
+
declare function useElementChildren<T extends ElementChildren>(elementId: ElementID, childrenTypes: (keyof T & string)[]): T;
|
|
102
|
+
|
|
103
|
+
type Options$1 = {
|
|
104
|
+
useHistory?: boolean;
|
|
105
|
+
};
|
|
106
|
+
declare function createElement({ containerId, settings, type, id, options, }: {
|
|
107
|
+
settings: V1ElementSettingsProps;
|
|
108
|
+
type: string;
|
|
109
|
+
containerId: string;
|
|
110
|
+
id?: string;
|
|
111
|
+
options?: Options$1;
|
|
112
|
+
}): V1Element;
|
|
113
|
+
|
|
114
|
+
type Options = {
|
|
115
|
+
useHistory?: boolean;
|
|
116
|
+
};
|
|
117
|
+
declare function deleteElement({ elementId, options }: {
|
|
118
|
+
elementId: string;
|
|
119
|
+
options?: Options;
|
|
120
|
+
}): void;
|
|
121
|
+
|
|
96
122
|
declare function getContainer(id: string): V1Element | null;
|
|
97
123
|
declare const selectElement: (elementId: string) => void;
|
|
98
124
|
|
|
@@ -162,4 +188,4 @@ declare function getAnchoredDescendantId(elementId: string): string | null;
|
|
|
162
188
|
declare function getAnchoredAncestorId(elementId: string): string | null;
|
|
163
189
|
declare function isElementAnchored(elementId: string): boolean;
|
|
164
190
|
|
|
165
|
-
export { type Control, type ControlItem, type ControlLayout, type ControlsSection, type CreateElementStyleArgs, ELEMENT_STYLE_CHANGE_EVENT, type Element, type ElementID, type ElementType, type LinkInLinkRestriction, type UpdateElementSettingsArgs, type UpdateElementStyleArgs, type V1Element, type V1ElementConfig, type V1ElementModelProps, type V1ElementSettingsProps, createElementStyle, deleteElementStyle, getAnchoredAncestorId, getAnchoredDescendantId, getContainer, getCurrentDocumentId, getElementLabel, getElementSetting, getElementSettings, getElementStyles, getElements, getLinkInLinkRestriction, getSelectedElements, getWidgetsCache, isElementAnchored, selectElement, shouldCreateNewLocalStyle, styleRerenderEvents, updateElementSettings, updateElementStyle, useElementSetting, useElementSettings, useElementType, useParentElement, useSelectedElement };
|
|
191
|
+
export { type Control, type ControlItem, type ControlLayout, type ControlsSection, type CreateElementStyleArgs, 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, deleteElement, deleteElementStyle, getAnchoredAncestorId, getAnchoredDescendantId, getContainer, getCurrentDocumentId, getElementLabel, getElementSetting, getElementSettings, getElementStyles, getElements, getLinkInLinkRestriction, getSelectedElements, getWidgetsCache, isElementAnchored, selectElement, shouldCreateNewLocalStyle, styleRerenderEvents, updateElementSettings, updateElementStyle, useElementChildren, useElementSetting, useElementSettings, useElementType, useParentElement, useSelectedElement };
|
package/dist/index.js
CHANGED
|
@@ -21,7 +21,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
ELEMENT_STYLE_CHANGE_EVENT: () => ELEMENT_STYLE_CHANGE_EVENT,
|
|
24
|
+
createElement: () => createElement,
|
|
24
25
|
createElementStyle: () => createElementStyle,
|
|
26
|
+
deleteElement: () => deleteElement,
|
|
25
27
|
deleteElementStyle: () => deleteElementStyle,
|
|
26
28
|
getAnchoredAncestorId: () => getAnchoredAncestorId,
|
|
27
29
|
getAnchoredDescendantId: () => getAnchoredDescendantId,
|
|
@@ -41,6 +43,7 @@ __export(index_exports, {
|
|
|
41
43
|
styleRerenderEvents: () => styleRerenderEvents,
|
|
42
44
|
updateElementSettings: () => updateElementSettings,
|
|
43
45
|
updateElementStyle: () => updateElementStyle,
|
|
46
|
+
useElementChildren: () => useElementChildren,
|
|
44
47
|
useElementSetting: () => useElementSetting,
|
|
45
48
|
useElementSettings: () => useElementSettings,
|
|
46
49
|
useElementType: () => useElementType,
|
|
@@ -193,6 +196,76 @@ function useParentElement(elementId) {
|
|
|
193
196
|
);
|
|
194
197
|
}
|
|
195
198
|
|
|
199
|
+
// src/hooks/use-element-children.ts
|
|
200
|
+
var import_editor_v1_adapters6 = require("@elementor/editor-v1-adapters");
|
|
201
|
+
function useElementChildren(elementId, childrenTypes) {
|
|
202
|
+
return (0, import_editor_v1_adapters6.__privateUseListenTo)(
|
|
203
|
+
[
|
|
204
|
+
(0, import_editor_v1_adapters6.v1ReadyEvent)(),
|
|
205
|
+
(0, import_editor_v1_adapters6.commandEndEvent)("document/elements/create"),
|
|
206
|
+
(0, import_editor_v1_adapters6.commandEndEvent)("document/elements/delete"),
|
|
207
|
+
(0, import_editor_v1_adapters6.commandEndEvent)("document/elements/update"),
|
|
208
|
+
(0, import_editor_v1_adapters6.commandEndEvent)("document/elements/set-settings")
|
|
209
|
+
],
|
|
210
|
+
() => {
|
|
211
|
+
const container = getContainer(elementId);
|
|
212
|
+
const children = container?.children || [];
|
|
213
|
+
return childrenTypes.reduce((acc, type) => {
|
|
214
|
+
const childElements = children.filter((child) => child.model?.get("widgetType") === type).map((child) => ({ id: child.id }));
|
|
215
|
+
if (childElements) {
|
|
216
|
+
acc[type] = childElements;
|
|
217
|
+
}
|
|
218
|
+
return acc;
|
|
219
|
+
}, {});
|
|
220
|
+
},
|
|
221
|
+
[elementId]
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// src/sync/create-element.ts
|
|
226
|
+
var import_editor_v1_adapters7 = require("@elementor/editor-v1-adapters");
|
|
227
|
+
function createElement({
|
|
228
|
+
containerId,
|
|
229
|
+
settings,
|
|
230
|
+
type,
|
|
231
|
+
id,
|
|
232
|
+
options
|
|
233
|
+
}) {
|
|
234
|
+
const container = getContainer(containerId);
|
|
235
|
+
const model = createElementModel({ settings, type, id });
|
|
236
|
+
if (!container) {
|
|
237
|
+
throw new Error(`Container with ID "${containerId}" not found`);
|
|
238
|
+
}
|
|
239
|
+
return (0, import_editor_v1_adapters7.__privateRunCommandSync)("document/elements/create", {
|
|
240
|
+
container,
|
|
241
|
+
model,
|
|
242
|
+
options: { edit: false, ...options }
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
function createElementModel({ settings, type, id }) {
|
|
246
|
+
return {
|
|
247
|
+
id,
|
|
248
|
+
elType: "widget",
|
|
249
|
+
widgetType: type,
|
|
250
|
+
settings: {
|
|
251
|
+
...settings
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// src/sync/delete-element.ts
|
|
257
|
+
var import_editor_v1_adapters8 = require("@elementor/editor-v1-adapters");
|
|
258
|
+
function deleteElement({ elementId, options }) {
|
|
259
|
+
const container = getContainer(elementId);
|
|
260
|
+
if (!container) {
|
|
261
|
+
throw new Error(`Element with ID "${elementId}" not found`);
|
|
262
|
+
}
|
|
263
|
+
(0, import_editor_v1_adapters8.__privateRunCommand)("document/elements/delete", {
|
|
264
|
+
container,
|
|
265
|
+
options
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
|
|
196
269
|
// src/sync/get-element-styles.ts
|
|
197
270
|
var getElementStyles = (elementID) => {
|
|
198
271
|
const container = getContainer(elementID);
|
|
@@ -257,7 +330,7 @@ function getCurrentDocumentId() {
|
|
|
257
330
|
}
|
|
258
331
|
|
|
259
332
|
// src/sync/update-element-settings.ts
|
|
260
|
-
var
|
|
333
|
+
var import_editor_v1_adapters9 = require("@elementor/editor-v1-adapters");
|
|
261
334
|
var updateElementSettings = ({ id, props, withHistory = true }) => {
|
|
262
335
|
const container = getContainer(id);
|
|
263
336
|
const args = {
|
|
@@ -265,21 +338,21 @@ var updateElementSettings = ({ id, props, withHistory = true }) => {
|
|
|
265
338
|
settings: { ...props }
|
|
266
339
|
};
|
|
267
340
|
if (withHistory) {
|
|
268
|
-
(0,
|
|
341
|
+
(0, import_editor_v1_adapters9.__privateRunCommandSync)("document/elements/settings", args);
|
|
269
342
|
} else {
|
|
270
|
-
(0,
|
|
343
|
+
(0, import_editor_v1_adapters9.__privateRunCommandSync)("document/elements/set-settings", args, { internal: true });
|
|
271
344
|
}
|
|
272
345
|
};
|
|
273
346
|
|
|
274
347
|
// src/styles/consts.ts
|
|
275
|
-
var
|
|
348
|
+
var import_editor_v1_adapters10 = require("@elementor/editor-v1-adapters");
|
|
276
349
|
var ELEMENT_STYLE_CHANGE_EVENT = "elementor/editor-v2/editor-elements/style";
|
|
277
350
|
var styleRerenderEvents = [
|
|
278
|
-
(0,
|
|
279
|
-
(0,
|
|
280
|
-
(0,
|
|
281
|
-
(0,
|
|
282
|
-
(0,
|
|
351
|
+
(0, import_editor_v1_adapters10.commandEndEvent)("document/elements/create"),
|
|
352
|
+
(0, import_editor_v1_adapters10.commandEndEvent)("document/elements/duplicate"),
|
|
353
|
+
(0, import_editor_v1_adapters10.commandEndEvent)("document/elements/import"),
|
|
354
|
+
(0, import_editor_v1_adapters10.commandEndEvent)("document/elements/paste"),
|
|
355
|
+
(0, import_editor_v1_adapters10.windowEvent)(ELEMENT_STYLE_CHANGE_EVENT)
|
|
283
356
|
];
|
|
284
357
|
|
|
285
358
|
// src/styles/create-element-style.ts
|
|
@@ -288,7 +361,7 @@ var import_editor_styles = require("@elementor/editor-styles");
|
|
|
288
361
|
|
|
289
362
|
// src/styles/mutate-element-styles.ts
|
|
290
363
|
var import_editor_props = require("@elementor/editor-props");
|
|
291
|
-
var
|
|
364
|
+
var import_editor_v1_adapters11 = require("@elementor/editor-v1-adapters");
|
|
292
365
|
function mutateElementStyles(elementId, mutator) {
|
|
293
366
|
const container = getContainer(elementId);
|
|
294
367
|
if (!container) {
|
|
@@ -344,7 +417,7 @@ function getClassesProps(container) {
|
|
|
344
417
|
}
|
|
345
418
|
function notifyChanges() {
|
|
346
419
|
dispatchChangeEvent();
|
|
347
|
-
(0,
|
|
420
|
+
(0, import_editor_v1_adapters11.__privateRunCommandSync)("document/save/set-is-modified", { status: true }, { internal: true });
|
|
348
421
|
}
|
|
349
422
|
function dispatchChangeEvent() {
|
|
350
423
|
window.dispatchEvent(new CustomEvent(ELEMENT_STYLE_CHANGE_EVENT));
|
|
@@ -511,7 +584,9 @@ function isElementorElement(element) {
|
|
|
511
584
|
// Annotate the CommonJS export names for ESM import in node:
|
|
512
585
|
0 && (module.exports = {
|
|
513
586
|
ELEMENT_STYLE_CHANGE_EVENT,
|
|
587
|
+
createElement,
|
|
514
588
|
createElementStyle,
|
|
589
|
+
deleteElement,
|
|
515
590
|
deleteElementStyle,
|
|
516
591
|
getAnchoredAncestorId,
|
|
517
592
|
getAnchoredDescendantId,
|
|
@@ -531,6 +606,7 @@ function isElementorElement(element) {
|
|
|
531
606
|
styleRerenderEvents,
|
|
532
607
|
updateElementSettings,
|
|
533
608
|
updateElementStyle,
|
|
609
|
+
useElementChildren,
|
|
534
610
|
useElementSetting,
|
|
535
611
|
useElementSettings,
|
|
536
612
|
useElementType,
|
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/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/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';\n\n// utils\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';\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 } from './types';\n\nexport function getContainer( id: string ) {\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 { 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 { 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;;;ACAA,IAAAA,6BAAqE;;;ACArE,gCAAkD;AAI3C,SAAS,aAAc,IAAa;AAC1C,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,kCAAAC,qBAAY,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,aAAO,2BAAAC;AAAA,QACN,4CAAiB,gCAAiC;AAAA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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","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/delete-element.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/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 } from './sync/create-element';\nexport { deleteElement } from './sync/delete-element';\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';\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 children = container?.children || [];\n\n\t\t\treturn childrenTypes.reduce( ( acc, type ) => {\n\t\t\t\tconst childElements = children\n\t\t\t\t\t.filter( ( child ) => child.model?.get( 'widgetType' ) === type )\n\t\t\t\t\t.map( ( child ) => ( { id: child.id } ) );\n\n\t\t\t\tif ( childElements ) {\n\t\t\t\t\tacc[ type ] = childElements;\n\t\t\t\t}\n\n\t\t\t\treturn acc;\n\t\t\t}, {} as 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 V1ElementSettingsProps } from './types';\n\ntype Options = {\n\tuseHistory?: boolean;\n};\n\nexport function createElement( {\n\tcontainerId,\n\tsettings,\n\ttype,\n\tid,\n\toptions,\n}: {\n\tsettings: V1ElementSettingsProps;\n\ttype: string;\n\tcontainerId: string;\n\tid?: string;\n\toptions?: Options;\n} ) {\n\tconst container = getContainer( containerId );\n\tconst model = createElementModel( { settings, type, id } );\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\nfunction createElementModel( { settings, type, id }: { settings: V1ElementSettingsProps; type: string; id?: string } ) {\n\treturn {\n\t\tid,\n\t\telType: 'widget',\n\t\twidgetType: type,\n\t\tsettings: {\n\t\t\t...settings,\n\t\t},\n\t};\n}\n","import { __privateRunCommand as runCommand } from '@elementor/editor-v1-adapters';\n\nimport { getContainer } from './get-container';\n\ntype Options = {\n\tuseHistory?: boolean;\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 { 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 { 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;;;ACAA,IAAAA,6BAAqE;;;ACArE,gCAAkD;AAI3C,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AY,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","runCommand","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
|
@@ -142,6 +142,76 @@ function useParentElement(elementId) {
|
|
|
142
142
|
);
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
+
// src/hooks/use-element-children.ts
|
|
146
|
+
import { __privateUseListenTo as useListenTo5, commandEndEvent as commandEndEvent5, v1ReadyEvent } from "@elementor/editor-v1-adapters";
|
|
147
|
+
function useElementChildren(elementId, childrenTypes) {
|
|
148
|
+
return useListenTo5(
|
|
149
|
+
[
|
|
150
|
+
v1ReadyEvent(),
|
|
151
|
+
commandEndEvent5("document/elements/create"),
|
|
152
|
+
commandEndEvent5("document/elements/delete"),
|
|
153
|
+
commandEndEvent5("document/elements/update"),
|
|
154
|
+
commandEndEvent5("document/elements/set-settings")
|
|
155
|
+
],
|
|
156
|
+
() => {
|
|
157
|
+
const container = getContainer(elementId);
|
|
158
|
+
const children = container?.children || [];
|
|
159
|
+
return childrenTypes.reduce((acc, type) => {
|
|
160
|
+
const childElements = children.filter((child) => child.model?.get("widgetType") === type).map((child) => ({ id: child.id }));
|
|
161
|
+
if (childElements) {
|
|
162
|
+
acc[type] = childElements;
|
|
163
|
+
}
|
|
164
|
+
return acc;
|
|
165
|
+
}, {});
|
|
166
|
+
},
|
|
167
|
+
[elementId]
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// src/sync/create-element.ts
|
|
172
|
+
import { __privateRunCommandSync as runCommandSync } from "@elementor/editor-v1-adapters";
|
|
173
|
+
function createElement({
|
|
174
|
+
containerId,
|
|
175
|
+
settings,
|
|
176
|
+
type,
|
|
177
|
+
id,
|
|
178
|
+
options
|
|
179
|
+
}) {
|
|
180
|
+
const container = getContainer(containerId);
|
|
181
|
+
const model = createElementModel({ settings, type, id });
|
|
182
|
+
if (!container) {
|
|
183
|
+
throw new Error(`Container with ID "${containerId}" not found`);
|
|
184
|
+
}
|
|
185
|
+
return runCommandSync("document/elements/create", {
|
|
186
|
+
container,
|
|
187
|
+
model,
|
|
188
|
+
options: { edit: false, ...options }
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
function createElementModel({ settings, type, id }) {
|
|
192
|
+
return {
|
|
193
|
+
id,
|
|
194
|
+
elType: "widget",
|
|
195
|
+
widgetType: type,
|
|
196
|
+
settings: {
|
|
197
|
+
...settings
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// src/sync/delete-element.ts
|
|
203
|
+
import { __privateRunCommand as runCommand2 } from "@elementor/editor-v1-adapters";
|
|
204
|
+
function deleteElement({ elementId, options }) {
|
|
205
|
+
const container = getContainer(elementId);
|
|
206
|
+
if (!container) {
|
|
207
|
+
throw new Error(`Element with ID "${elementId}" not found`);
|
|
208
|
+
}
|
|
209
|
+
runCommand2("document/elements/delete", {
|
|
210
|
+
container,
|
|
211
|
+
options
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
|
|
145
215
|
// src/sync/get-element-styles.ts
|
|
146
216
|
var getElementStyles = (elementID) => {
|
|
147
217
|
const container = getContainer(elementID);
|
|
@@ -206,7 +276,7 @@ function getCurrentDocumentId() {
|
|
|
206
276
|
}
|
|
207
277
|
|
|
208
278
|
// src/sync/update-element-settings.ts
|
|
209
|
-
import { __privateRunCommandSync as
|
|
279
|
+
import { __privateRunCommandSync as runCommandSync2 } from "@elementor/editor-v1-adapters";
|
|
210
280
|
var updateElementSettings = ({ id, props, withHistory = true }) => {
|
|
211
281
|
const container = getContainer(id);
|
|
212
282
|
const args = {
|
|
@@ -214,20 +284,20 @@ var updateElementSettings = ({ id, props, withHistory = true }) => {
|
|
|
214
284
|
settings: { ...props }
|
|
215
285
|
};
|
|
216
286
|
if (withHistory) {
|
|
217
|
-
|
|
287
|
+
runCommandSync2("document/elements/settings", args);
|
|
218
288
|
} else {
|
|
219
|
-
|
|
289
|
+
runCommandSync2("document/elements/set-settings", args, { internal: true });
|
|
220
290
|
}
|
|
221
291
|
};
|
|
222
292
|
|
|
223
293
|
// src/styles/consts.ts
|
|
224
|
-
import { commandEndEvent as
|
|
294
|
+
import { commandEndEvent as commandEndEvent6, windowEvent } from "@elementor/editor-v1-adapters";
|
|
225
295
|
var ELEMENT_STYLE_CHANGE_EVENT = "elementor/editor-v2/editor-elements/style";
|
|
226
296
|
var styleRerenderEvents = [
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
297
|
+
commandEndEvent6("document/elements/create"),
|
|
298
|
+
commandEndEvent6("document/elements/duplicate"),
|
|
299
|
+
commandEndEvent6("document/elements/import"),
|
|
300
|
+
commandEndEvent6("document/elements/paste"),
|
|
231
301
|
windowEvent(ELEMENT_STYLE_CHANGE_EVENT)
|
|
232
302
|
];
|
|
233
303
|
|
|
@@ -239,7 +309,7 @@ import {
|
|
|
239
309
|
|
|
240
310
|
// src/styles/mutate-element-styles.ts
|
|
241
311
|
import { classesPropTypeUtil } from "@elementor/editor-props";
|
|
242
|
-
import { __privateRunCommandSync as
|
|
312
|
+
import { __privateRunCommandSync as runCommandSync3 } from "@elementor/editor-v1-adapters";
|
|
243
313
|
function mutateElementStyles(elementId, mutator) {
|
|
244
314
|
const container = getContainer(elementId);
|
|
245
315
|
if (!container) {
|
|
@@ -295,7 +365,7 @@ function getClassesProps(container) {
|
|
|
295
365
|
}
|
|
296
366
|
function notifyChanges() {
|
|
297
367
|
dispatchChangeEvent();
|
|
298
|
-
|
|
368
|
+
runCommandSync3("document/save/set-is-modified", { status: true }, { internal: true });
|
|
299
369
|
}
|
|
300
370
|
function dispatchChangeEvent() {
|
|
301
371
|
window.dispatchEvent(new CustomEvent(ELEMENT_STYLE_CHANGE_EVENT));
|
|
@@ -461,7 +531,9 @@ function isElementorElement(element) {
|
|
|
461
531
|
}
|
|
462
532
|
export {
|
|
463
533
|
ELEMENT_STYLE_CHANGE_EVENT,
|
|
534
|
+
createElement,
|
|
464
535
|
createElementStyle,
|
|
536
|
+
deleteElement,
|
|
465
537
|
deleteElementStyle,
|
|
466
538
|
getAnchoredAncestorId,
|
|
467
539
|
getAnchoredDescendantId,
|
|
@@ -481,6 +553,7 @@ export {
|
|
|
481
553
|
styleRerenderEvents,
|
|
482
554
|
updateElementSettings,
|
|
483
555
|
updateElementStyle,
|
|
556
|
+
useElementChildren,
|
|
484
557
|
useElementSetting,
|
|
485
558
|
useElementSettings,
|
|
486
559
|
useElementType,
|
package/dist/index.mjs.map
CHANGED
|
@@ -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/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/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 } from './types';\n\nexport function getContainer( id: string ) {\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 { 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 { 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,IAAa;AAC1C,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,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B,gBAAiB,kBAAmB;AAE3D,QAAK,mBAAmB,WAAY;AACnC,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAEO,SAAS,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":["useListenTo","commandEndEvent","useListenTo","commandEndEvent","useListenTo","commandEndEvent","useListenTo","commandEndEvent","useListenTo","commandEndEvent","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/delete-element.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/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 children = container?.children || [];\n\n\t\t\treturn childrenTypes.reduce( ( acc, type ) => {\n\t\t\t\tconst childElements = children\n\t\t\t\t\t.filter( ( child ) => child.model?.get( 'widgetType' ) === type )\n\t\t\t\t\t.map( ( child ) => ( { id: child.id } ) );\n\n\t\t\t\tif ( childElements ) {\n\t\t\t\t\tacc[ type ] = childElements;\n\t\t\t\t}\n\n\t\t\t\treturn acc;\n\t\t\t}, {} as 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 V1ElementSettingsProps } from './types';\n\ntype Options = {\n\tuseHistory?: boolean;\n};\n\nexport function createElement( {\n\tcontainerId,\n\tsettings,\n\ttype,\n\tid,\n\toptions,\n}: {\n\tsettings: V1ElementSettingsProps;\n\ttype: string;\n\tcontainerId: string;\n\tid?: string;\n\toptions?: Options;\n} ) {\n\tconst container = getContainer( containerId );\n\tconst model = createElementModel( { settings, type, id } );\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\nfunction createElementModel( { settings, type, id }: { settings: V1ElementSettingsProps; type: string; id?: string } ) {\n\treturn {\n\t\tid,\n\t\telType: 'widget',\n\t\twidgetType: type,\n\t\tsettings: {\n\t\t\t...settings,\n\t\t},\n\t};\n}\n","import { __privateRunCommand as runCommand } from '@elementor/editor-v1-adapters';\n\nimport { getContainer } from './get-container';\n\ntype Options = {\n\tuseHistory?: boolean;\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 { 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 { 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,qBAAqB,CAAY,WAAsB,gBAA2B;AAC9F,SAAO;AAAA,IACN,gBAAiB,gCAAiC;AAAA,IAClD,MACC,YAAY,OAAoC,CAAE,UAAU,QAAS;AACpE,YAAM,QAAQ,kBAA6B,WAAW,GAAI;AAE1D,UAAK,UAAU,MAAO;AACrB,iBAAU,GAAI,IAAI;AAAA,MACnB;AAEA,aAAO;AAAA,IACR,GAAG,CAAC,CAA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AE,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","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-
|
|
4
|
+
"version": "3.32.0-59",
|
|
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-
|
|
44
|
-
"@elementor/editor-styles": "3.32.0-
|
|
45
|
-
"@elementor/editor-v1-adapters": "3.32.0-
|
|
46
|
-
"@elementor/utils": "3.32.0-
|
|
43
|
+
"@elementor/editor-props": "3.32.0-59",
|
|
44
|
+
"@elementor/editor-styles": "3.32.0-59",
|
|
45
|
+
"@elementor/editor-v1-adapters": "3.32.0-59",
|
|
46
|
+
"@elementor/utils": "3.32.0-59"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"react": "^18.3.1"
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { __privateUseListenTo as useListenTo, commandEndEvent, v1ReadyEvent } from '@elementor/editor-v1-adapters';
|
|
2
|
+
|
|
3
|
+
import { getContainer } from '../sync/get-container';
|
|
4
|
+
import { type ElementID } from '../types';
|
|
5
|
+
|
|
6
|
+
type ElementModel = {
|
|
7
|
+
id: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type ElementChildren = Record< string, ElementModel[] >;
|
|
11
|
+
|
|
12
|
+
export function useElementChildren< T extends ElementChildren >(
|
|
13
|
+
elementId: ElementID,
|
|
14
|
+
childrenTypes: ( keyof T & string )[]
|
|
15
|
+
): T {
|
|
16
|
+
return useListenTo(
|
|
17
|
+
[
|
|
18
|
+
v1ReadyEvent(),
|
|
19
|
+
commandEndEvent( 'document/elements/create' ),
|
|
20
|
+
commandEndEvent( 'document/elements/delete' ),
|
|
21
|
+
commandEndEvent( 'document/elements/update' ),
|
|
22
|
+
commandEndEvent( 'document/elements/set-settings' ),
|
|
23
|
+
],
|
|
24
|
+
() => {
|
|
25
|
+
const container = getContainer( elementId );
|
|
26
|
+
|
|
27
|
+
const children = container?.children || [];
|
|
28
|
+
|
|
29
|
+
return childrenTypes.reduce( ( acc, type ) => {
|
|
30
|
+
const childElements = children
|
|
31
|
+
.filter( ( child ) => child.model?.get( 'widgetType' ) === type )
|
|
32
|
+
.map( ( child ) => ( { id: child.id } ) );
|
|
33
|
+
|
|
34
|
+
if ( childElements ) {
|
|
35
|
+
acc[ type ] = childElements;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return acc;
|
|
39
|
+
}, {} as ElementChildren );
|
|
40
|
+
},
|
|
41
|
+
[ elementId ]
|
|
42
|
+
) as T;
|
|
43
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -7,8 +7,11 @@ export { useElementSetting, useElementSettings } from './hooks/use-element-setti
|
|
|
7
7
|
export { useElementType } from './hooks/use-element-type';
|
|
8
8
|
export { useSelectedElement } from './hooks/use-selected-element';
|
|
9
9
|
export { useParentElement } from './hooks/use-parent-element';
|
|
10
|
+
export { useElementChildren, type ElementChildren } from './hooks/use-element-children';
|
|
10
11
|
|
|
11
12
|
// utils
|
|
13
|
+
export { createElement } from './sync/create-element';
|
|
14
|
+
export { deleteElement } from './sync/delete-element';
|
|
12
15
|
export { getContainer, selectElement } from './sync/get-container';
|
|
13
16
|
export { getElementSetting, getElementSettings } from './sync/get-element-setting';
|
|
14
17
|
export { getElementStyles } from './sync/get-element-styles';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { __privateRunCommandSync as runCommandSync } from '@elementor/editor-v1-adapters';
|
|
2
|
+
|
|
3
|
+
import { getContainer } from './get-container';
|
|
4
|
+
import { type V1Element, type V1ElementSettingsProps } from './types';
|
|
5
|
+
|
|
6
|
+
type Options = {
|
|
7
|
+
useHistory?: boolean;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export function createElement( {
|
|
11
|
+
containerId,
|
|
12
|
+
settings,
|
|
13
|
+
type,
|
|
14
|
+
id,
|
|
15
|
+
options,
|
|
16
|
+
}: {
|
|
17
|
+
settings: V1ElementSettingsProps;
|
|
18
|
+
type: string;
|
|
19
|
+
containerId: string;
|
|
20
|
+
id?: string;
|
|
21
|
+
options?: Options;
|
|
22
|
+
} ) {
|
|
23
|
+
const container = getContainer( containerId );
|
|
24
|
+
const model = createElementModel( { settings, type, id } );
|
|
25
|
+
|
|
26
|
+
if ( ! container ) {
|
|
27
|
+
throw new Error( `Container with ID "${ containerId }" not found` );
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return runCommandSync< V1Element >( 'document/elements/create', {
|
|
31
|
+
container,
|
|
32
|
+
model,
|
|
33
|
+
options: { edit: false, ...options },
|
|
34
|
+
} );
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function createElementModel( { settings, type, id }: { settings: V1ElementSettingsProps; type: string; id?: string } ) {
|
|
38
|
+
return {
|
|
39
|
+
id,
|
|
40
|
+
elType: 'widget',
|
|
41
|
+
widgetType: type,
|
|
42
|
+
settings: {
|
|
43
|
+
...settings,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { __privateRunCommand as runCommand } from '@elementor/editor-v1-adapters';
|
|
2
|
+
|
|
3
|
+
import { getContainer } from './get-container';
|
|
4
|
+
|
|
5
|
+
type Options = {
|
|
6
|
+
useHistory?: boolean;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export function deleteElement( { elementId, options }: { elementId: string; options?: Options } ): void {
|
|
10
|
+
const container = getContainer( elementId );
|
|
11
|
+
|
|
12
|
+
if ( ! container ) {
|
|
13
|
+
throw new Error( `Element with ID "${ elementId }" not found` );
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
runCommand( 'document/elements/delete', {
|
|
17
|
+
container,
|
|
18
|
+
options,
|
|
19
|
+
} );
|
|
20
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __privateRunCommand as runCommand } from '@elementor/editor-v1-adapters';
|
|
2
2
|
|
|
3
|
-
import { type ExtendedWindow } from './types';
|
|
3
|
+
import { type ExtendedWindow, type V1Element } from './types';
|
|
4
4
|
|
|
5
|
-
export function getContainer( id: string ) {
|
|
5
|
+
export function getContainer( id: string ): V1Element | null {
|
|
6
6
|
const extendedWindow = window as unknown as ExtendedWindow;
|
|
7
7
|
const container = extendedWindow.elementor?.getContainer?.( id );
|
|
8
8
|
|
package/src/sync/types.ts
CHANGED
|
@@ -41,6 +41,7 @@ export type V1ElementModelProps = {
|
|
|
41
41
|
id: string;
|
|
42
42
|
styles?: Record< StyleDefinitionID, StyleDefinition >;
|
|
43
43
|
elements?: V1Model< V1ElementModelProps >[];
|
|
44
|
+
settings?: V1Model< V1ElementSettingsProps >;
|
|
44
45
|
};
|
|
45
46
|
|
|
46
47
|
export type V1ElementSettingsProps = Record< string, PropValue >;
|