@elementor/editor-elements 0.4.1 → 0.5.0
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/CHANGELOG.md +26 -0
- package/dist/index.d.mts +29 -16
- package/dist/index.d.ts +29 -16
- package/dist/index.js +154 -37
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +158 -42
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -4
- package/src/hooks/use-element-style-props.ts +5 -10
- package/src/hooks/use-element-styles.ts +5 -6
- package/src/index.ts +6 -3
- package/src/styles/consts.ts +1 -0
- package/src/styles/create-element-style.ts +51 -0
- package/src/styles/errors.ts +11 -0
- package/src/styles/mutate-element-styles.ts +82 -0
- package/src/styles/update-element-style.ts +50 -0
- package/src/sync/types.ts +4 -1
- package/src/sync/update-element-settings.ts +26 -0
- package/src/sync/update-settings.ts +0 -16
- package/src/sync/update-styles.ts +0 -28
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @elementor/editor-elements
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- f691712: Load element type defaults on editor load.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- b8b2053: Rename default classes to base classes
|
|
12
|
+
- a13a209: Refactor editor-elements to not use the commands
|
|
13
|
+
- Updated dependencies [f1a2ffb]
|
|
14
|
+
- Updated dependencies [a13a209]
|
|
15
|
+
- @elementor/editor-props@0.8.0
|
|
16
|
+
- @elementor/editor-styles@0.5.3
|
|
17
|
+
|
|
18
|
+
## 0.4.2
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [65d3c4c]
|
|
23
|
+
- Updated dependencies [7582ba6]
|
|
24
|
+
- Updated dependencies [7654921]
|
|
25
|
+
- @elementor/editor-v1-adapters@0.9.0
|
|
26
|
+
- @elementor/editor-props@0.7.1
|
|
27
|
+
- @elementor/editor-styles@0.5.2
|
|
28
|
+
|
|
3
29
|
## 0.4.1
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { PropType, PropValue, Props
|
|
1
|
+
import { PropType, PropValue, Props } from '@elementor/editor-props';
|
|
2
2
|
import * as _elementor_editor_styles from '@elementor/editor-styles';
|
|
3
|
-
import { StyleDefinitionID, StyleDefinition,
|
|
3
|
+
import { StyleDefinitionID, StyleDefinition, StyleDefinitionVariant } from '@elementor/editor-styles';
|
|
4
4
|
|
|
5
5
|
type ElementID = string;
|
|
6
6
|
type Element = {
|
|
@@ -37,7 +37,7 @@ type PropsSchema = Record<Control['value']['bind'], PropType>;
|
|
|
37
37
|
type V1Element = {
|
|
38
38
|
id: string;
|
|
39
39
|
model: V1Model<V1ElementModelProps>;
|
|
40
|
-
settings
|
|
40
|
+
settings: V1Model<V1ElementSettingsProps>;
|
|
41
41
|
children?: V1Element[];
|
|
42
42
|
view?: {
|
|
43
43
|
el: HTMLElement;
|
|
@@ -53,6 +53,8 @@ type V1ElementModelProps = {
|
|
|
53
53
|
type V1ElementSettingsProps = Record<string, PropValue>;
|
|
54
54
|
type V1Model<T> = {
|
|
55
55
|
get: <K extends keyof T>(key: K) => T[K];
|
|
56
|
+
set: <K extends keyof T>(key: K, value: T[K]) => void;
|
|
57
|
+
toJSON: () => T;
|
|
56
58
|
};
|
|
57
59
|
|
|
58
60
|
declare function useElementsDomRef(): HTMLElement[];
|
|
@@ -62,14 +64,13 @@ declare const useElementSetting: <TValue>(elementId: ElementID, settingKey: stri
|
|
|
62
64
|
type UseElementStylePropsArgs<T extends Props> = {
|
|
63
65
|
elementID: ElementID;
|
|
64
66
|
styleDefID: StyleDefinitionID | null;
|
|
65
|
-
meta:
|
|
67
|
+
meta: StyleDefinitionVariant['meta'];
|
|
66
68
|
propNames: Array<keyof T & string>;
|
|
67
69
|
};
|
|
68
70
|
type NullableObjectValues<T extends Props> = {
|
|
69
71
|
[K in keyof T]: T[K] | null;
|
|
70
72
|
};
|
|
71
73
|
declare function useElementStyleProps<T extends Props>({ elementID, styleDefID, meta, propNames, }: UseElementStylePropsArgs<T>): NullableObjectValues<T> | null;
|
|
72
|
-
declare function getVariantByMeta(styleDef: StyleDefinition, meta: StyleVariant['meta']): StyleVariant | undefined;
|
|
73
74
|
|
|
74
75
|
declare function useElementStyles(elementId: ElementID): Record<string, _elementor_editor_styles.StyleDefinition>;
|
|
75
76
|
|
|
@@ -97,24 +98,36 @@ declare function getWidgetsCache(): Record<string, {
|
|
|
97
98
|
atomic_controls?: ControlItem[];
|
|
98
99
|
atomic_props_schema?: PropsSchema;
|
|
99
100
|
controls: object;
|
|
101
|
+
base_styles?: _elementor_editor_styles.StyleDefinition[];
|
|
100
102
|
title: string;
|
|
101
103
|
}> | null;
|
|
102
104
|
|
|
103
105
|
declare const isElementInContainer: (element: Element, container: V1Element) => boolean;
|
|
104
106
|
|
|
105
|
-
|
|
107
|
+
type UpdateElementSettingsArgs = {
|
|
106
108
|
id: ElementID;
|
|
107
109
|
props: Props;
|
|
108
|
-
|
|
110
|
+
withHistory?: boolean;
|
|
111
|
+
};
|
|
112
|
+
declare const updateElementSettings: ({ id, props, withHistory }: UpdateElementSettingsArgs) => void;
|
|
109
113
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
declare const ELEMENT_STYLE_CHANGE_EVENT = "elementor/editor-v2/editor-elements/style";
|
|
115
|
+
|
|
116
|
+
type CreateElementStyleArgs = {
|
|
117
|
+
elementId: ElementID;
|
|
118
|
+
classesProp: string;
|
|
119
|
+
label: string;
|
|
120
|
+
meta: StyleDefinitionVariant['meta'];
|
|
121
|
+
props: StyleDefinitionVariant['props'];
|
|
122
|
+
};
|
|
123
|
+
declare function createElementStyle({ elementId, classesProp, label, meta, props }: CreateElementStyleArgs): void;
|
|
124
|
+
|
|
125
|
+
type UpdateElementStyleArgs = {
|
|
126
|
+
elementId: ElementID;
|
|
127
|
+
styleId: StyleDefinition['id'];
|
|
128
|
+
meta: StyleDefinitionVariant['meta'];
|
|
129
|
+
props: StyleDefinitionVariant['props'];
|
|
117
130
|
};
|
|
118
|
-
declare
|
|
131
|
+
declare function updateElementStyle(args: UpdateElementStyleArgs): void;
|
|
119
132
|
|
|
120
|
-
export { type Control, type ControlItem, type ControlsSection, type Element, type ElementID, type ElementType, type PropsSchema, type V1Element, type V1ElementModelProps, type V1ElementSettingsProps, getElementSetting, getElementStyles, getElements, getSelectedElements,
|
|
133
|
+
export { type Control, type ControlItem, type ControlsSection, type CreateElementStyleArgs, ELEMENT_STYLE_CHANGE_EVENT, type Element, type ElementID, type ElementType, type PropsSchema, type UpdateElementSettingsArgs, type UpdateElementStyleArgs, type V1Element, type V1ElementModelProps, type V1ElementSettingsProps, createElementStyle, getElementSetting, getElementStyles, getElements, getSelectedElements, getWidgetsCache, isElementInContainer, updateElementSettings, updateElementStyle, useElementSetting, useElementStyleProps, useElementStyles, useElementType, useElementsDomRef, useParentElement, useSelectedElement };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { PropType, PropValue, Props
|
|
1
|
+
import { PropType, PropValue, Props } from '@elementor/editor-props';
|
|
2
2
|
import * as _elementor_editor_styles from '@elementor/editor-styles';
|
|
3
|
-
import { StyleDefinitionID, StyleDefinition,
|
|
3
|
+
import { StyleDefinitionID, StyleDefinition, StyleDefinitionVariant } from '@elementor/editor-styles';
|
|
4
4
|
|
|
5
5
|
type ElementID = string;
|
|
6
6
|
type Element = {
|
|
@@ -37,7 +37,7 @@ type PropsSchema = Record<Control['value']['bind'], PropType>;
|
|
|
37
37
|
type V1Element = {
|
|
38
38
|
id: string;
|
|
39
39
|
model: V1Model<V1ElementModelProps>;
|
|
40
|
-
settings
|
|
40
|
+
settings: V1Model<V1ElementSettingsProps>;
|
|
41
41
|
children?: V1Element[];
|
|
42
42
|
view?: {
|
|
43
43
|
el: HTMLElement;
|
|
@@ -53,6 +53,8 @@ type V1ElementModelProps = {
|
|
|
53
53
|
type V1ElementSettingsProps = Record<string, PropValue>;
|
|
54
54
|
type V1Model<T> = {
|
|
55
55
|
get: <K extends keyof T>(key: K) => T[K];
|
|
56
|
+
set: <K extends keyof T>(key: K, value: T[K]) => void;
|
|
57
|
+
toJSON: () => T;
|
|
56
58
|
};
|
|
57
59
|
|
|
58
60
|
declare function useElementsDomRef(): HTMLElement[];
|
|
@@ -62,14 +64,13 @@ declare const useElementSetting: <TValue>(elementId: ElementID, settingKey: stri
|
|
|
62
64
|
type UseElementStylePropsArgs<T extends Props> = {
|
|
63
65
|
elementID: ElementID;
|
|
64
66
|
styleDefID: StyleDefinitionID | null;
|
|
65
|
-
meta:
|
|
67
|
+
meta: StyleDefinitionVariant['meta'];
|
|
66
68
|
propNames: Array<keyof T & string>;
|
|
67
69
|
};
|
|
68
70
|
type NullableObjectValues<T extends Props> = {
|
|
69
71
|
[K in keyof T]: T[K] | null;
|
|
70
72
|
};
|
|
71
73
|
declare function useElementStyleProps<T extends Props>({ elementID, styleDefID, meta, propNames, }: UseElementStylePropsArgs<T>): NullableObjectValues<T> | null;
|
|
72
|
-
declare function getVariantByMeta(styleDef: StyleDefinition, meta: StyleVariant['meta']): StyleVariant | undefined;
|
|
73
74
|
|
|
74
75
|
declare function useElementStyles(elementId: ElementID): Record<string, _elementor_editor_styles.StyleDefinition>;
|
|
75
76
|
|
|
@@ -97,24 +98,36 @@ declare function getWidgetsCache(): Record<string, {
|
|
|
97
98
|
atomic_controls?: ControlItem[];
|
|
98
99
|
atomic_props_schema?: PropsSchema;
|
|
99
100
|
controls: object;
|
|
101
|
+
base_styles?: _elementor_editor_styles.StyleDefinition[];
|
|
100
102
|
title: string;
|
|
101
103
|
}> | null;
|
|
102
104
|
|
|
103
105
|
declare const isElementInContainer: (element: Element, container: V1Element) => boolean;
|
|
104
106
|
|
|
105
|
-
|
|
107
|
+
type UpdateElementSettingsArgs = {
|
|
106
108
|
id: ElementID;
|
|
107
109
|
props: Props;
|
|
108
|
-
|
|
110
|
+
withHistory?: boolean;
|
|
111
|
+
};
|
|
112
|
+
declare const updateElementSettings: ({ id, props, withHistory }: UpdateElementSettingsArgs) => void;
|
|
109
113
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
declare const ELEMENT_STYLE_CHANGE_EVENT = "elementor/editor-v2/editor-elements/style";
|
|
115
|
+
|
|
116
|
+
type CreateElementStyleArgs = {
|
|
117
|
+
elementId: ElementID;
|
|
118
|
+
classesProp: string;
|
|
119
|
+
label: string;
|
|
120
|
+
meta: StyleDefinitionVariant['meta'];
|
|
121
|
+
props: StyleDefinitionVariant['props'];
|
|
122
|
+
};
|
|
123
|
+
declare function createElementStyle({ elementId, classesProp, label, meta, props }: CreateElementStyleArgs): void;
|
|
124
|
+
|
|
125
|
+
type UpdateElementStyleArgs = {
|
|
126
|
+
elementId: ElementID;
|
|
127
|
+
styleId: StyleDefinition['id'];
|
|
128
|
+
meta: StyleDefinitionVariant['meta'];
|
|
129
|
+
props: StyleDefinitionVariant['props'];
|
|
117
130
|
};
|
|
118
|
-
declare
|
|
131
|
+
declare function updateElementStyle(args: UpdateElementStyleArgs): void;
|
|
119
132
|
|
|
120
|
-
export { type Control, type ControlItem, type ControlsSection, type Element, type ElementID, type ElementType, type PropsSchema, type V1Element, type V1ElementModelProps, type V1ElementSettingsProps, getElementSetting, getElementStyles, getElements, getSelectedElements,
|
|
133
|
+
export { type Control, type ControlItem, type ControlsSection, type CreateElementStyleArgs, ELEMENT_STYLE_CHANGE_EVENT, type Element, type ElementID, type ElementType, type PropsSchema, type UpdateElementSettingsArgs, type UpdateElementStyleArgs, type V1Element, type V1ElementModelProps, type V1ElementSettingsProps, createElementStyle, getElementSetting, getElementStyles, getElements, getSelectedElements, getWidgetsCache, isElementInContainer, updateElementSettings, updateElementStyle, useElementSetting, useElementStyleProps, useElementStyles, useElementType, useElementsDomRef, useParentElement, useSelectedElement };
|
package/dist/index.js
CHANGED
|
@@ -20,15 +20,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
ELEMENT_STYLE_CHANGE_EVENT: () => ELEMENT_STYLE_CHANGE_EVENT,
|
|
24
|
+
createElementStyle: () => createElementStyle,
|
|
23
25
|
getElementSetting: () => getElementSetting,
|
|
24
26
|
getElementStyles: () => getElementStyles,
|
|
25
27
|
getElements: () => getElements,
|
|
26
28
|
getSelectedElements: () => getSelectedElements,
|
|
27
|
-
getVariantByMeta: () => getVariantByMeta,
|
|
28
29
|
getWidgetsCache: () => getWidgetsCache,
|
|
29
30
|
isElementInContainer: () => isElementInContainer,
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
updateElementSettings: () => updateElementSettings,
|
|
32
|
+
updateElementStyle: () => updateElementStyle,
|
|
32
33
|
useElementSetting: () => useElementSetting,
|
|
33
34
|
useElementStyleProps: () => useElementStyleProps,
|
|
34
35
|
useElementStyles: () => useElementStyles,
|
|
@@ -96,8 +97,12 @@ var useElementSetting = (elementId, settingKey) => {
|
|
|
96
97
|
};
|
|
97
98
|
|
|
98
99
|
// src/hooks/use-element-style-props.ts
|
|
100
|
+
var import_editor_styles = require("@elementor/editor-styles");
|
|
99
101
|
var import_editor_v1_adapters3 = require("@elementor/editor-v1-adapters");
|
|
100
102
|
|
|
103
|
+
// src/styles/consts.ts
|
|
104
|
+
var ELEMENT_STYLE_CHANGE_EVENT = "elementor/editor-v2/editor-elements/style";
|
|
105
|
+
|
|
101
106
|
// src/sync/get-element-styles.ts
|
|
102
107
|
var getElementStyles = (elementID) => {
|
|
103
108
|
const container = getContainer(elementID);
|
|
@@ -112,7 +117,7 @@ function useElementStyleProps({
|
|
|
112
117
|
propNames
|
|
113
118
|
}) {
|
|
114
119
|
return (0, import_editor_v1_adapters3.__privateUseListenTo)(
|
|
115
|
-
(0, import_editor_v1_adapters3.
|
|
120
|
+
(0, import_editor_v1_adapters3.windowEvent)(ELEMENT_STYLE_CHANGE_EVENT),
|
|
116
121
|
() => {
|
|
117
122
|
if (!styleDefID) {
|
|
118
123
|
return null;
|
|
@@ -121,7 +126,7 @@ function useElementStyleProps({
|
|
|
121
126
|
if (!styleDef) {
|
|
122
127
|
return null;
|
|
123
128
|
}
|
|
124
|
-
const variant = getVariantByMeta(styleDef, meta);
|
|
129
|
+
const variant = (0, import_editor_styles.getVariantByMeta)(styleDef, meta);
|
|
125
130
|
return propNames.reduce((acc, key) => {
|
|
126
131
|
acc[key] = variant?.props[key] ?? null;
|
|
127
132
|
return acc;
|
|
@@ -130,20 +135,13 @@ function useElementStyleProps({
|
|
|
130
135
|
[elementID, styleDefID, JSON.stringify(propNames), meta]
|
|
131
136
|
);
|
|
132
137
|
}
|
|
133
|
-
function getVariantByMeta(styleDef, meta) {
|
|
134
|
-
return styleDef.variants.find((variant) => {
|
|
135
|
-
return variant.meta.breakpoint === meta.breakpoint && variant.meta.state === meta.state;
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
138
|
|
|
139
139
|
// src/hooks/use-element-styles.ts
|
|
140
140
|
var import_editor_v1_adapters4 = require("@elementor/editor-v1-adapters");
|
|
141
141
|
function useElementStyles(elementId) {
|
|
142
|
-
return (0, import_editor_v1_adapters4.__privateUseListenTo)(
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
[elementId]
|
|
146
|
-
);
|
|
142
|
+
return (0, import_editor_v1_adapters4.__privateUseListenTo)((0, import_editor_v1_adapters4.windowEvent)(ELEMENT_STYLE_CHANGE_EVENT), () => getElementStyles(elementId) ?? {}, [
|
|
143
|
+
elementId
|
|
144
|
+
]);
|
|
147
145
|
}
|
|
148
146
|
|
|
149
147
|
// src/hooks/use-element-type.ts
|
|
@@ -256,42 +254,161 @@ var isElementInContainer = (element, container) => {
|
|
|
256
254
|
return false;
|
|
257
255
|
};
|
|
258
256
|
|
|
259
|
-
// src/sync/update-settings.ts
|
|
257
|
+
// src/sync/update-element-settings.ts
|
|
260
258
|
var import_editor_v1_adapters8 = require("@elementor/editor-v1-adapters");
|
|
261
|
-
var
|
|
259
|
+
var updateElementSettings = ({ id, props, withHistory = true }) => {
|
|
262
260
|
const container = getContainer(id);
|
|
263
|
-
|
|
261
|
+
const args = {
|
|
264
262
|
container,
|
|
265
|
-
settings: {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
263
|
+
settings: { ...props }
|
|
264
|
+
};
|
|
265
|
+
if (withHistory) {
|
|
266
|
+
(0, import_editor_v1_adapters8.__privateRunCommandSync)("document/elements/settings", args);
|
|
267
|
+
} else {
|
|
268
|
+
(0, import_editor_v1_adapters8.__privateRunCommandSync)("document/elements/set-settings", args, { internal: true });
|
|
269
|
+
}
|
|
269
270
|
};
|
|
270
271
|
|
|
271
|
-
// src/
|
|
272
|
-
var
|
|
273
|
-
var
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
272
|
+
// src/styles/create-element-style.ts
|
|
273
|
+
var import_editor_props2 = require("@elementor/editor-props");
|
|
274
|
+
var import_editor_styles2 = require("@elementor/editor-styles");
|
|
275
|
+
|
|
276
|
+
// src/styles/mutate-element-styles.ts
|
|
277
|
+
var import_editor_props = require("@elementor/editor-props");
|
|
278
|
+
|
|
279
|
+
// src/styles/errors.ts
|
|
280
|
+
var import_utils = require("@elementor/utils");
|
|
281
|
+
var ElementNotFoundError = (0, import_utils.createError)({
|
|
282
|
+
code: "element_not_found",
|
|
283
|
+
message: "Element not found."
|
|
284
|
+
});
|
|
285
|
+
var StyleNotFoundError = (0, import_utils.createError)({
|
|
286
|
+
code: "style_not_found",
|
|
287
|
+
message: "Style not found."
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
// src/styles/mutate-element-styles.ts
|
|
291
|
+
function mutateElementStyles(elementId, mutator) {
|
|
292
|
+
const container = getContainer(elementId);
|
|
293
|
+
if (!container) {
|
|
294
|
+
throw new ElementNotFoundError({ context: { elementId } });
|
|
295
|
+
}
|
|
296
|
+
const styles = mutateStyles(container, mutator);
|
|
297
|
+
removeNonExistingClasses(container, styles);
|
|
298
|
+
dispatchChangeEvent();
|
|
299
|
+
return styles;
|
|
300
|
+
}
|
|
301
|
+
function mutateStyles(container, mutator) {
|
|
302
|
+
const styles = structuredClone(container.model.get("styles")) ?? {};
|
|
303
|
+
const entries = Object.entries(mutator(styles)).map(([styleId, style]) => {
|
|
304
|
+
style.variants = removeEmptyVariants(style);
|
|
305
|
+
return [styleId, style];
|
|
306
|
+
}).filter(([, style]) => {
|
|
307
|
+
return !isStyleEmpty(style);
|
|
282
308
|
});
|
|
283
|
-
|
|
309
|
+
const mutatedStyles = Object.fromEntries(entries);
|
|
310
|
+
container.model.set("styles", mutatedStyles);
|
|
311
|
+
return mutatedStyles;
|
|
312
|
+
}
|
|
313
|
+
function removeEmptyVariants(style) {
|
|
314
|
+
return style.variants.filter(({ props }) => Object.keys(props).length > 0);
|
|
315
|
+
}
|
|
316
|
+
function isStyleEmpty(style) {
|
|
317
|
+
return style.variants.length === 0;
|
|
318
|
+
}
|
|
319
|
+
function removeNonExistingClasses(container, styles) {
|
|
320
|
+
const existingStylesIds = Object.keys(styles);
|
|
321
|
+
const classesProps = structuredClone(getClassesProps(container));
|
|
322
|
+
classesProps.forEach(([, prop]) => {
|
|
323
|
+
prop.value = prop.value.filter((value) => existingStylesIds.includes(value));
|
|
324
|
+
});
|
|
325
|
+
updateElementSettings({
|
|
326
|
+
id: container.id,
|
|
327
|
+
props: Object.fromEntries(classesProps),
|
|
328
|
+
withHistory: false
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
function getClassesProps(container) {
|
|
332
|
+
return Object.entries(container.settings.toJSON()).filter((prop) => {
|
|
333
|
+
const [, value] = prop;
|
|
334
|
+
return import_editor_props.classesPropTypeUtil.isValid(value);
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
function dispatchChangeEvent() {
|
|
338
|
+
window.dispatchEvent(new CustomEvent(ELEMENT_STYLE_CHANGE_EVENT));
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// src/styles/create-element-style.ts
|
|
342
|
+
function createElementStyle({ elementId, classesProp, label, meta, props }) {
|
|
343
|
+
mutateElementStyles(elementId, (styles) => {
|
|
344
|
+
const id = (0, import_editor_styles2.generateId)(`e-${elementId}-`, Object.keys(styles));
|
|
345
|
+
styles[id] = {
|
|
346
|
+
id,
|
|
347
|
+
label,
|
|
348
|
+
type: "class",
|
|
349
|
+
variants: [{ meta, props }]
|
|
350
|
+
};
|
|
351
|
+
addStyleToClassesProp(elementId, classesProp, id);
|
|
352
|
+
return styles;
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
function addStyleToClassesProp(elementId, classesProp, styleId) {
|
|
356
|
+
const base = getElementSetting(elementId, classesProp);
|
|
357
|
+
const classesPropValue = import_editor_props2.classesPropTypeUtil.create(
|
|
358
|
+
(prev) => {
|
|
359
|
+
return [...prev ?? [], styleId];
|
|
360
|
+
},
|
|
361
|
+
{ base }
|
|
362
|
+
);
|
|
363
|
+
updateElementSettings({
|
|
364
|
+
id: elementId,
|
|
365
|
+
props: {
|
|
366
|
+
[classesProp]: classesPropValue
|
|
367
|
+
},
|
|
368
|
+
withHistory: false
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
// src/styles/update-element-style.ts
|
|
373
|
+
var import_editor_styles3 = require("@elementor/editor-styles");
|
|
374
|
+
function updateElementStyle(args) {
|
|
375
|
+
mutateElementStyles(args.elementId, (styles) => {
|
|
376
|
+
const style = styles[args.styleId];
|
|
377
|
+
if (!style) {
|
|
378
|
+
throw new StyleNotFoundError({ context: { styleId: args.styleId } });
|
|
379
|
+
}
|
|
380
|
+
let variant = (0, import_editor_styles3.getVariantByMeta)(style, args.meta);
|
|
381
|
+
if (!variant) {
|
|
382
|
+
variant = { meta: args.meta, props: {} };
|
|
383
|
+
style.variants.push(variant);
|
|
384
|
+
}
|
|
385
|
+
variant.props = mergeVariantProps(variant, args.props);
|
|
386
|
+
return styles;
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
function mergeVariantProps(variant, props) {
|
|
390
|
+
const finalProps = { ...variant.props };
|
|
391
|
+
Object.entries(props).forEach(([key, value]) => {
|
|
392
|
+
if (value === null || value === void 0) {
|
|
393
|
+
delete finalProps[key];
|
|
394
|
+
} else {
|
|
395
|
+
finalProps[key] = value;
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
return finalProps;
|
|
399
|
+
}
|
|
284
400
|
// Annotate the CommonJS export names for ESM import in node:
|
|
285
401
|
0 && (module.exports = {
|
|
402
|
+
ELEMENT_STYLE_CHANGE_EVENT,
|
|
403
|
+
createElementStyle,
|
|
286
404
|
getElementSetting,
|
|
287
405
|
getElementStyles,
|
|
288
406
|
getElements,
|
|
289
407
|
getSelectedElements,
|
|
290
|
-
getVariantByMeta,
|
|
291
408
|
getWidgetsCache,
|
|
292
409
|
isElementInContainer,
|
|
293
|
-
|
|
294
|
-
|
|
410
|
+
updateElementSettings,
|
|
411
|
+
updateElementStyle,
|
|
295
412
|
useElementSetting,
|
|
296
413
|
useElementStyleProps,
|
|
297
414
|
useElementStyles,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/hooks/use-elements-dom-ref.ts","../src/sync/get-current-document-container.ts","../src/hooks/use-element-setting.ts","../src/sync/get-container.ts","../src/sync/get-element-setting.ts","../src/hooks/use-element-style-props.ts","../src/sync/get-element-styles.ts","../src/hooks/use-element-styles.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-elements.ts","../src/sync/is-element-in-container.ts","../src/sync/update-settings.ts","../src/sync/update-styles.ts"],"sourcesContent":["// types\nexport * from './types';\nexport type { V1Element, V1ElementModelProps, V1ElementSettingsProps } from './sync/types';\n\n// hooks\nexport { useElementsDomRef } from './hooks/use-elements-dom-ref';\nexport { useElementSetting } from './hooks/use-element-setting';\nexport { useElementStyleProps, getVariantByMeta } from './hooks/use-element-style-props';\nexport { useElementStyles } from './hooks/use-element-styles';\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 { getElementSetting } from './sync/get-element-setting';\nexport { getElementStyles } from './sync/get-element-styles';\nexport { getElements } from './sync/get-elements';\nexport { getSelectedElements } from './sync/get-selected-elements';\nexport { getWidgetsCache } from './sync/get-widgets-cache';\nexport { isElementInContainer } from './sync/is-element-in-container';\nexport { updateSettings } from './sync/update-settings';\nexport { updateStyle } from './sync/update-styles';\n","import { __privateUseListenTo as useListenTo, windowEvent } from '@elementor/editor-v1-adapters';\n\nimport getCurrentDocumentContainer from '../sync/get-current-document-container';\n\nconst ELEMENTS_DATA_ATTR = 'data-atomic';\n\nexport function useElementsDomRef(): HTMLElement[] {\n\treturn useListenTo(\n\t\t[\n\t\t\twindowEvent( 'elementor/preview/atomic-widget/render' ),\n\t\t\twindowEvent( 'elementor/preview/atomic-widget/destroy' ),\n\t\t\twindowEvent( 'elementor/editor/element-rendered' ),\n\t\t\twindowEvent( 'elementor/editor/element-destroyed' ),\n\t\t],\n\t\t() => getElementsDom()\n\t);\n}\n\nfunction getElementsDom(): HTMLElement[] {\n\tconst root = getCurrentDocumentContainer();\n\n\tif ( ! root?.view ) {\n\t\treturn [];\n\t}\n\n\treturn [ ...root.view.el.querySelectorAll< HTMLElement >( `[${ ELEMENTS_DATA_ATTR }]` ) ];\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 { __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","import { type ExtendedWindow } from './types';\n\nexport default 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","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\tconst value = container?.settings?.get( settingKey ) as TValue;\n\n\treturn value ?? null;\n};\n","import { type Props } from '@elementor/editor-props';\nimport { type StyleDefinition, type StyleDefinitionID, type StyleVariant } from '@elementor/editor-styles';\nimport { __privateUseListenTo as useListenTo, commandEndEvent } from '@elementor/editor-v1-adapters';\n\nimport { getElementStyles } from '../sync/get-element-styles';\nimport { type ElementID } from '../types';\n\nexport type UseElementStylePropsArgs< T extends Props > = {\n\telementID: ElementID;\n\tstyleDefID: StyleDefinitionID | null;\n\tmeta: StyleVariant[ 'meta' ];\n\tpropNames: Array< keyof T & string >;\n};\n\ntype NullableObjectValues< T extends Props > = {\n\t[ K in keyof T ]: T[ K ] | null;\n};\n\nexport function useElementStyleProps< T extends Props >( {\n\telementID,\n\tstyleDefID,\n\tmeta,\n\tpropNames,\n}: UseElementStylePropsArgs< T > ): NullableObjectValues< T > | null {\n\treturn useListenTo(\n\t\tcommandEndEvent( 'document/atomic-widgets/styles' ),\n\t\t() => {\n\t\t\tif ( ! styleDefID ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst styleDef = getElementStyles( elementID )?.[ styleDefID ];\n\n\t\t\tif ( ! styleDef ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst variant = getVariantByMeta( styleDef, meta );\n\n\t\t\treturn propNames.reduce< Record< string, unknown > >( ( acc, key ) => {\n\t\t\t\tacc[ key ] = variant?.props[ key ] ?? null;\n\n\t\t\t\treturn acc;\n\t\t\t}, {} ) as NullableObjectValues< T >;\n\t\t},\n\t\t[ elementID, styleDefID, JSON.stringify( propNames ), meta ]\n\t);\n}\n\nexport function getVariantByMeta( styleDef: StyleDefinition, meta: StyleVariant[ 'meta' ] ) {\n\treturn styleDef.variants.find( ( variant ) => {\n\t\treturn variant.meta.breakpoint === meta.breakpoint && variant.meta.state === meta.state;\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 { __privateUseListenTo as useListenTo, commandEndEvent } from '@elementor/editor-v1-adapters';\n\nimport { getElementStyles } from '../sync/get-element-styles';\nimport { type ElementID } from '../types';\n\nexport function useElementStyles( elementId: ElementID ) {\n\treturn useListenTo(\n\t\tcommandEndEvent( 'document/atomic-widgets/styles' ),\n\t\t() => getElementStyles( elementId ) ?? {},\n\t\t[ elementId ]\n\t);\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\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[ commandEndEvent( 'document/elements/select' ), commandEndEvent( 'document/elements/deselect' ) ],\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 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.children?.flatMap( ( child ) => getElements( child.id ) ) ?? [];\n\n\treturn [ container, ...children ];\n}\n","import { type Element } from '../types';\nimport { type V1Element } from './types';\n\nexport const isElementInContainer = ( element: Element, container: V1Element ): boolean => {\n\tif ( container.model.get( 'id' ) === element.id && container.model.get( 'widgetType' ) === element.type ) {\n\t\treturn true;\n\t}\n\n\tif ( container.children && container.children.length > 0 ) {\n\t\treturn container.children.some( ( child ) => isElementInContainer( element, child ) );\n\t}\n\n\treturn false;\n};\n","import { type Props } from '@elementor/editor-props';\nimport { __privateRunCommand as runCommand } from '@elementor/editor-v1-adapters';\n\nimport { type ElementID } from '../types';\nimport getContainer from './get-container';\n\nexport const updateSettings = ( { id, props }: { id: ElementID; props: Props } ) => {\n\tconst container = getContainer( id );\n\n\trunCommand( 'document/elements/settings', {\n\t\tcontainer,\n\t\tsettings: {\n\t\t\t...props,\n\t\t},\n\t} );\n};\n","import { type PropKey, type Props } from '@elementor/editor-props';\nimport { type StyleDefinitionID, type StyleVariant } from '@elementor/editor-styles';\nimport { __privateRunCommand as runCommand } from '@elementor/editor-v1-adapters';\n\nimport { type ElementID } from '../types';\nimport getContainer from './get-container';\n\nexport type UpdateStyleProps = {\n\telementID: ElementID;\n\tstyleDefID: StyleDefinitionID | null;\n\tmeta: StyleVariant[ 'meta' ];\n\tprops: Props;\n\tbind: PropKey;\n\tlabel?: string;\n};\n\nexport const updateStyle = async ( { elementID, styleDefID, meta, props, bind, label }: UpdateStyleProps ) => {\n\tconst container = getContainer( elementID );\n\n\tawait runCommand( 'document/atomic-widgets/styles', {\n\t\tcontainer,\n\t\tstyleDefID,\n\t\tbind,\n\t\tmeta,\n\t\tprops,\n\t\tlabel,\n\t} );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,gCAAiE;;;ACElD,SAAR,8BAA+C;AACrD,QAAM,iBAAiB;AAEvB,SAAO,eAAe,WAAW,WAAW,aAAa,GAAG,aAAa;AAC1E;;;ADFA,IAAM,qBAAqB;AAEpB,SAAS,oBAAmC;AAClD,aAAO,0BAAAA;AAAA,IACN;AAAA,UACC,uCAAa,wCAAyC;AAAA,UACtD,uCAAa,yCAA0C;AAAA,UACvD,uCAAa,mCAAoC;AAAA,UACjD,uCAAa,oCAAqC;AAAA,IACnD;AAAA,IACA,MAAM,eAAe;AAAA,EACtB;AACD;AAEA,SAAS,iBAAgC;AACxC,QAAM,OAAO,4BAA4B;AAEzC,MAAK,CAAE,MAAM,MAAO;AACnB,WAAO,CAAC;AAAA,EACT;AAEA,SAAO,CAAE,GAAG,KAAK,KAAK,GAAG,iBAAiC,IAAK,kBAAmB,GAAI,CAAE;AACzF;;;AE1BA,IAAAC,6BAAqE;;;ACEtD,SAAR,aAA+B,IAAa;AAClD,QAAM,iBAAiB;AACvB,QAAM,YA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ACZA,IAAAC,6BAAkD;AAK3C,IAAM,iBAAiB,CAAE,EAAE,IAAI,MAAM,MAAwC;AACnF,QAAM,YAAY,aAAc,EAAG;AAEnC,iCAAAC,qBAAY,8BAA8B;AAAA,IACzC;AAAA,IACA,UAAU;AAAA,MACT,GAAG;AAAA,IACJ;AAAA,EACD,CAAE;AACH;;;ACbA,IAAAC,6BAAkD;AAc3C,IAAM,cAAc,OAAQ,EAAE,WAAW,YAAY,MAAM,OAAO,MAAM,MAAM,MAAyB;AAC7G,QAAM,YAAY,aAAc,SAAU;AAE1C,YAAM,2BAAAC,qBAAY,kCAAkC;AAAA,IACnD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AACH;","names":["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","useListenTo","import_editor_v1_adapters","useListenTo","import_editor_v1_adapters","runCommand","import_editor_v1_adapters","runCommand"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/hooks/use-elements-dom-ref.ts","../src/sync/get-current-document-container.ts","../src/hooks/use-element-setting.ts","../src/sync/get-container.ts","../src/sync/get-element-setting.ts","../src/hooks/use-element-style-props.ts","../src/styles/consts.ts","../src/sync/get-element-styles.ts","../src/hooks/use-element-styles.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-elements.ts","../src/sync/is-element-in-container.ts","../src/sync/update-element-settings.ts","../src/styles/create-element-style.ts","../src/styles/mutate-element-styles.ts","../src/styles/errors.ts","../src/styles/update-element-style.ts"],"sourcesContent":["// types\nexport * from './types';\nexport type { V1Element, V1ElementModelProps, V1ElementSettingsProps } from './sync/types';\n\n// hooks\nexport { useElementsDomRef } from './hooks/use-elements-dom-ref';\nexport { useElementSetting } from './hooks/use-element-setting';\nexport { useElementStyleProps } from './hooks/use-element-style-props';\nexport { useElementStyles } from './hooks/use-element-styles';\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 { getElementSetting } from './sync/get-element-setting';\nexport { getElementStyles } from './sync/get-element-styles';\nexport { getElements } from './sync/get-elements';\nexport { getSelectedElements } from './sync/get-selected-elements';\nexport { getWidgetsCache } from './sync/get-widgets-cache';\nexport { isElementInContainer } from './sync/is-element-in-container';\nexport { updateElementSettings, type UpdateElementSettingsArgs } from './sync/update-element-settings';\n\nexport { ELEMENT_STYLE_CHANGE_EVENT } from './styles/consts';\nexport { createElementStyle, type CreateElementStyleArgs } from './styles/create-element-style';\nexport { updateElementStyle, type UpdateElementStyleArgs } from './styles/update-element-style';\n","import { __privateUseListenTo as useListenTo, windowEvent } from '@elementor/editor-v1-adapters';\n\nimport getCurrentDocumentContainer from '../sync/get-current-document-container';\n\nconst ELEMENTS_DATA_ATTR = 'data-atomic';\n\nexport function useElementsDomRef(): HTMLElement[] {\n\treturn useListenTo(\n\t\t[\n\t\t\twindowEvent( 'elementor/preview/atomic-widget/render' ),\n\t\t\twindowEvent( 'elementor/preview/atomic-widget/destroy' ),\n\t\t\twindowEvent( 'elementor/editor/element-rendered' ),\n\t\t\twindowEvent( 'elementor/editor/element-destroyed' ),\n\t\t],\n\t\t() => getElementsDom()\n\t);\n}\n\nfunction getElementsDom(): HTMLElement[] {\n\tconst root = getCurrentDocumentContainer();\n\n\tif ( ! root?.view ) {\n\t\treturn [];\n\t}\n\n\treturn [ ...root.view.el.querySelectorAll< HTMLElement >( `[${ ELEMENTS_DATA_ATTR }]` ) ];\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 { __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","import { type ExtendedWindow } from './types';\n\nexport default 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","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\tconst value = container?.settings?.get( settingKey ) as TValue;\n\n\treturn value ?? null;\n};\n","import { type Props } from '@elementor/editor-props';\nimport { getVariantByMeta, type StyleDefinitionID, type StyleDefinitionVariant } from '@elementor/editor-styles';\nimport { __privateUseListenTo as useListenTo, windowEvent } from '@elementor/editor-v1-adapters';\n\nimport { ELEMENT_STYLE_CHANGE_EVENT } from '../styles/consts';\nimport { getElementStyles } from '../sync/get-element-styles';\nimport { type ElementID } from '../types';\n\nexport type UseElementStylePropsArgs< T extends Props > = {\n\telementID: ElementID;\n\tstyleDefID: StyleDefinitionID | null;\n\tmeta: StyleDefinitionVariant[ 'meta' ];\n\tpropNames: Array< keyof T & string >;\n};\n\ntype NullableObjectValues< T extends Props > = {\n\t[ K in keyof T ]: T[ K ] | null;\n};\n\nexport function useElementStyleProps< T extends Props >( {\n\telementID,\n\tstyleDefID,\n\tmeta,\n\tpropNames,\n}: UseElementStylePropsArgs< T > ): NullableObjectValues< T > | null {\n\treturn useListenTo(\n\t\twindowEvent( ELEMENT_STYLE_CHANGE_EVENT ),\n\t\t() => {\n\t\t\tif ( ! styleDefID ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst styleDef = getElementStyles( elementID )?.[ styleDefID ];\n\n\t\t\tif ( ! styleDef ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst variant = getVariantByMeta( styleDef, meta );\n\n\t\t\treturn propNames.reduce< Record< string, unknown > >( ( acc, key ) => {\n\t\t\t\tacc[ key ] = variant?.props[ key ] ?? null;\n\n\t\t\t\treturn acc;\n\t\t\t}, {} ) as NullableObjectValues< T >;\n\t\t},\n\t\t[ elementID, styleDefID, JSON.stringify( propNames ), meta ]\n\t);\n}\n","export const ELEMENT_STYLE_CHANGE_EVENT = 'elementor/editor-v2/editor-elements/style';\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 { __privateUseListenTo as useListenTo, windowEvent } from '@elementor/editor-v1-adapters';\n\nimport { ELEMENT_STYLE_CHANGE_EVENT } from '../styles/consts';\nimport { getElementStyles } from '../sync/get-element-styles';\nimport { type ElementID } from '../types';\n\nexport function useElementStyles( elementId: ElementID ) {\n\treturn useListenTo( windowEvent( ELEMENT_STYLE_CHANGE_EVENT ), () => getElementStyles( elementId ) ?? {}, [\n\t\telementId,\n\t] );\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\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[ commandEndEvent( 'document/elements/select' ), commandEndEvent( 'document/elements/deselect' ) ],\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 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.children?.flatMap( ( child ) => getElements( child.id ) ) ?? [];\n\n\treturn [ container, ...children ];\n}\n","import { type Element } from '../types';\nimport { type V1Element } from './types';\n\nexport const isElementInContainer = ( element: Element, container: V1Element ): boolean => {\n\tif ( container.model.get( 'id' ) === element.id && container.model.get( 'widgetType' ) === element.type ) {\n\t\treturn true;\n\t}\n\n\tif ( container.children && container.children.length > 0 ) {\n\t\treturn container.children.some( ( child ) => isElementInContainer( element, child ) );\n\t}\n\n\treturn false;\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 { classesPropTypeUtil } from '@elementor/editor-props';\nimport { generateId, type StyleDefinition, type StyleDefinitionVariant } 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\telementId: ElementID;\n\tclassesProp: string;\n\tlabel: string;\n\tmeta: StyleDefinitionVariant[ 'meta' ];\n\tprops: StyleDefinitionVariant[ 'props' ];\n};\n\nexport function createElementStyle( { elementId, classesProp, label, meta, props }: CreateElementStyleArgs ) {\n\tmutateElementStyles( elementId, ( styles ) => {\n\t\tconst id = generateId( `e-${ elementId }-`, Object.keys( styles ) );\n\n\t\tstyles[ id ] = {\n\t\t\tid,\n\t\t\tlabel,\n\t\t\ttype: 'class',\n\t\t\tvariants: [ { meta, props } ],\n\t\t} satisfies StyleDefinition;\n\n\t\taddStyleToClassesProp( elementId, classesProp, id );\n\n\t\treturn styles;\n\t} );\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","import { classesPropTypeUtil, type ClassesPropValue } from '@elementor/editor-props';\nimport { type StyleDefinition, type StyleDefinitionsMap } from '@elementor/editor-styles';\n\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';\nimport { ElementNotFoundError } from './errors';\n\nexport type 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 styles = mutateStyles( container, mutator );\n\n\tremoveNonExistingClasses( container, styles );\n\n\tdispatchChangeEvent();\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( ( { props } ) => Object.keys( props ).length > 0 );\n}\n\nfunction isStyleEmpty( style: StyleDefinition ) {\n\treturn style.variants.length === 0;\n}\n\nfunction removeNonExistingClasses( container: V1Element, styles: StyleDefinitionsMap ) {\n\tconst existingStylesIds = Object.keys( styles );\n\tconst classesProps = structuredClone( getClassesProps( container ) );\n\n\tclassesProps.forEach( ( [ , prop ] ) => {\n\t\tprop.value = prop.value.filter( ( value ) => existingStylesIds.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 dispatchChangeEvent() {\n\twindow.dispatchEvent( new CustomEvent( ELEMENT_STYLE_CHANGE_EVENT ) );\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","import { type Props } from '@elementor/editor-props';\nimport { getVariantByMeta, type StyleDefinition, type StyleDefinitionVariant } from '@elementor/editor-styles';\n\nimport { type ElementID } from '../types';\nimport { StyleNotFoundError } from './errors';\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};\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\tlet variant = getVariantByMeta( style, args.meta );\n\n\t\tif ( ! variant ) {\n\t\t\tvariant = { meta: args.meta, props: {} };\n\n\t\t\tstyle.variants.push( variant );\n\t\t}\n\n\t\tvariant.props = mergeVariantProps( variant, args.props );\n\n\t\treturn styles;\n\t} );\n}\n\nfunction mergeVariantProps( variant: StyleDefinitionVariant, props: Props ) {\n\tconst finalProps = { ...variant.props };\n\n\tObject.entries( props ).forEach( ( [ key, value ] ) => {\n\t\tif ( value === null || value === undefined ) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\t\tdelete finalProps[ key ];\n\t\t} else {\n\t\t\tfinalProps[ key ] = value;\n\t\t}\n\t} );\n\n\treturn finalProps;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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AAU;AAChB,gBAAU,EAAE,MAAM,KAAK,MAAM,OAAO,CAAC,EAAE;AAEvC,YAAM,SAAS,KAAM,OAAQ;AAAA,IAC9B;AAEA,YAAQ,QAAQ,kBAAmB,SAAS,KAAK,KAAM;AAEvD,WAAO;AAAA,EACR,CAAE;AACH;AAEA,SAAS,kBAAmB,SAAiC,OAAe;AAC3E,QAAM,aAAa,EAAE,GAAG,QAAQ,MAAM;AAEtC,SAAO,QAAS,KAAM,EAAE,QAAS,CAAE,CAAE,KAAK,KAAM,MAAO;AACtD,QAAK,UAAU,QAAQ,UAAU,QAAY;AAE5C,aAAO,WAAY,GAAI;AAAA,IACxB,OAAO;AACN,iBAAY,GAAI,IAAI;AAAA,IACrB;AAAA,EACD,CAAE;AAEF,SAAO;AACR;","names":["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","useListenTo","import_editor_v1_adapters","useListenTo","import_editor_v1_adapters","runCommandSync","import_editor_props","import_editor_styles","import_editor_styles"]}
|