@elementor/editor-elements 0.4.2 → 0.5.1
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 +30 -26
- package/dist/index.d.ts +30 -26
- package/dist/index.js +153 -66
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +159 -73
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -4
- package/src/hooks/use-element-styles.ts +3 -6
- package/src/index.ts +5 -3
- package/src/styles/consts.ts +9 -0
- package/src/styles/create-element-style.ts +51 -0
- package/src/styles/errors.ts +11 -0
- package/src/styles/mutate-element-styles.ts +89 -0
- package/src/styles/update-element-style.ts +33 -0
- package/src/sync/types.ts +4 -1
- package/src/sync/update-element-settings.ts +26 -0
- package/src/hooks/use-element-style-props.ts +0 -54
- 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.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d61b1bc: Added a new event to update the elements styles repository + organized all events in a central location
|
|
8
|
+
- b34f498: Fix global class styles not updating
|
|
9
|
+
- Updated dependencies [a8b60c9]
|
|
10
|
+
- Updated dependencies [b34f498]
|
|
11
|
+
- @elementor/editor-v1-adapters@0.9.1
|
|
12
|
+
- @elementor/editor-styles@0.5.4
|
|
13
|
+
|
|
14
|
+
## 0.5.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- f691712: Load element type defaults on editor load.
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- b8b2053: Rename default classes to base classes
|
|
23
|
+
- a13a209: Refactor editor-elements to not use the commands
|
|
24
|
+
- Updated dependencies [f1a2ffb]
|
|
25
|
+
- Updated dependencies [a13a209]
|
|
26
|
+
- @elementor/editor-props@0.8.0
|
|
27
|
+
- @elementor/editor-styles@0.5.3
|
|
28
|
+
|
|
3
29
|
## 0.4.2
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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
|
+
import * as _elementor_editor_v1_adapters from '@elementor/editor-v1-adapters';
|
|
4
5
|
|
|
5
6
|
type ElementID = string;
|
|
6
7
|
type Element = {
|
|
@@ -37,7 +38,7 @@ type PropsSchema = Record<Control['value']['bind'], PropType>;
|
|
|
37
38
|
type V1Element = {
|
|
38
39
|
id: string;
|
|
39
40
|
model: V1Model<V1ElementModelProps>;
|
|
40
|
-
settings
|
|
41
|
+
settings: V1Model<V1ElementSettingsProps>;
|
|
41
42
|
children?: V1Element[];
|
|
42
43
|
view?: {
|
|
43
44
|
el: HTMLElement;
|
|
@@ -53,24 +54,14 @@ type V1ElementModelProps = {
|
|
|
53
54
|
type V1ElementSettingsProps = Record<string, PropValue>;
|
|
54
55
|
type V1Model<T> = {
|
|
55
56
|
get: <K extends keyof T>(key: K) => T[K];
|
|
57
|
+
set: <K extends keyof T>(key: K, value: T[K]) => void;
|
|
58
|
+
toJSON: () => T;
|
|
56
59
|
};
|
|
57
60
|
|
|
58
61
|
declare function useElementsDomRef(): HTMLElement[];
|
|
59
62
|
|
|
60
63
|
declare const useElementSetting: <TValue>(elementId: ElementID, settingKey: string) => TValue | null;
|
|
61
64
|
|
|
62
|
-
type UseElementStylePropsArgs<T extends Props> = {
|
|
63
|
-
elementID: ElementID;
|
|
64
|
-
styleDefID: StyleDefinitionID | null;
|
|
65
|
-
meta: StyleVariant['meta'];
|
|
66
|
-
propNames: Array<keyof T & string>;
|
|
67
|
-
};
|
|
68
|
-
type NullableObjectValues<T extends Props> = {
|
|
69
|
-
[K in keyof T]: T[K] | null;
|
|
70
|
-
};
|
|
71
|
-
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
65
|
declare function useElementStyles(elementId: ElementID): Record<string, _elementor_editor_styles.StyleDefinition>;
|
|
75
66
|
|
|
76
67
|
declare function useElementType(type?: string): ElementType | null;
|
|
@@ -97,24 +88,37 @@ declare function getWidgetsCache(): Record<string, {
|
|
|
97
88
|
atomic_controls?: ControlItem[];
|
|
98
89
|
atomic_props_schema?: PropsSchema;
|
|
99
90
|
controls: object;
|
|
91
|
+
base_styles?: _elementor_editor_styles.StyleDefinition[];
|
|
100
92
|
title: string;
|
|
101
93
|
}> | null;
|
|
102
94
|
|
|
103
95
|
declare const isElementInContainer: (element: Element, container: V1Element) => boolean;
|
|
104
96
|
|
|
105
|
-
|
|
97
|
+
type UpdateElementSettingsArgs = {
|
|
106
98
|
id: ElementID;
|
|
107
99
|
props: Props;
|
|
108
|
-
|
|
100
|
+
withHistory?: boolean;
|
|
101
|
+
};
|
|
102
|
+
declare const updateElementSettings: ({ id, props, withHistory }: UpdateElementSettingsArgs) => void;
|
|
109
103
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
label
|
|
104
|
+
declare const ELEMENT_STYLE_CHANGE_EVENT = "elementor/editor-v2/editor-elements/style";
|
|
105
|
+
declare const styleRerenderEvents: (_elementor_editor_v1_adapters.CommandEventDescriptor | _elementor_editor_v1_adapters.WindowEventDescriptor)[];
|
|
106
|
+
|
|
107
|
+
type CreateElementStyleArgs = {
|
|
108
|
+
elementId: ElementID;
|
|
109
|
+
classesProp: string;
|
|
110
|
+
label: string;
|
|
111
|
+
meta: StyleDefinitionVariant['meta'];
|
|
112
|
+
props: StyleDefinitionVariant['props'];
|
|
113
|
+
};
|
|
114
|
+
declare function createElementStyle({ elementId, classesProp, label, meta, props }: CreateElementStyleArgs): void;
|
|
115
|
+
|
|
116
|
+
type UpdateElementStyleArgs = {
|
|
117
|
+
elementId: ElementID;
|
|
118
|
+
styleId: StyleDefinition['id'];
|
|
119
|
+
meta: StyleDefinitionVariant['meta'];
|
|
120
|
+
props: StyleDefinitionVariant['props'];
|
|
117
121
|
};
|
|
118
|
-
declare
|
|
122
|
+
declare function updateElementStyle(args: UpdateElementStyleArgs): void;
|
|
119
123
|
|
|
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,
|
|
124
|
+
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, styleRerenderEvents, updateElementSettings, updateElementStyle, useElementSetting, useElementStyles, useElementType, useElementsDomRef, useParentElement, useSelectedElement };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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
|
+
import * as _elementor_editor_v1_adapters from '@elementor/editor-v1-adapters';
|
|
4
5
|
|
|
5
6
|
type ElementID = string;
|
|
6
7
|
type Element = {
|
|
@@ -37,7 +38,7 @@ type PropsSchema = Record<Control['value']['bind'], PropType>;
|
|
|
37
38
|
type V1Element = {
|
|
38
39
|
id: string;
|
|
39
40
|
model: V1Model<V1ElementModelProps>;
|
|
40
|
-
settings
|
|
41
|
+
settings: V1Model<V1ElementSettingsProps>;
|
|
41
42
|
children?: V1Element[];
|
|
42
43
|
view?: {
|
|
43
44
|
el: HTMLElement;
|
|
@@ -53,24 +54,14 @@ type V1ElementModelProps = {
|
|
|
53
54
|
type V1ElementSettingsProps = Record<string, PropValue>;
|
|
54
55
|
type V1Model<T> = {
|
|
55
56
|
get: <K extends keyof T>(key: K) => T[K];
|
|
57
|
+
set: <K extends keyof T>(key: K, value: T[K]) => void;
|
|
58
|
+
toJSON: () => T;
|
|
56
59
|
};
|
|
57
60
|
|
|
58
61
|
declare function useElementsDomRef(): HTMLElement[];
|
|
59
62
|
|
|
60
63
|
declare const useElementSetting: <TValue>(elementId: ElementID, settingKey: string) => TValue | null;
|
|
61
64
|
|
|
62
|
-
type UseElementStylePropsArgs<T extends Props> = {
|
|
63
|
-
elementID: ElementID;
|
|
64
|
-
styleDefID: StyleDefinitionID | null;
|
|
65
|
-
meta: StyleVariant['meta'];
|
|
66
|
-
propNames: Array<keyof T & string>;
|
|
67
|
-
};
|
|
68
|
-
type NullableObjectValues<T extends Props> = {
|
|
69
|
-
[K in keyof T]: T[K] | null;
|
|
70
|
-
};
|
|
71
|
-
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
65
|
declare function useElementStyles(elementId: ElementID): Record<string, _elementor_editor_styles.StyleDefinition>;
|
|
75
66
|
|
|
76
67
|
declare function useElementType(type?: string): ElementType | null;
|
|
@@ -97,24 +88,37 @@ declare function getWidgetsCache(): Record<string, {
|
|
|
97
88
|
atomic_controls?: ControlItem[];
|
|
98
89
|
atomic_props_schema?: PropsSchema;
|
|
99
90
|
controls: object;
|
|
91
|
+
base_styles?: _elementor_editor_styles.StyleDefinition[];
|
|
100
92
|
title: string;
|
|
101
93
|
}> | null;
|
|
102
94
|
|
|
103
95
|
declare const isElementInContainer: (element: Element, container: V1Element) => boolean;
|
|
104
96
|
|
|
105
|
-
|
|
97
|
+
type UpdateElementSettingsArgs = {
|
|
106
98
|
id: ElementID;
|
|
107
99
|
props: Props;
|
|
108
|
-
|
|
100
|
+
withHistory?: boolean;
|
|
101
|
+
};
|
|
102
|
+
declare const updateElementSettings: ({ id, props, withHistory }: UpdateElementSettingsArgs) => void;
|
|
109
103
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
label
|
|
104
|
+
declare const ELEMENT_STYLE_CHANGE_EVENT = "elementor/editor-v2/editor-elements/style";
|
|
105
|
+
declare const styleRerenderEvents: (_elementor_editor_v1_adapters.CommandEventDescriptor | _elementor_editor_v1_adapters.WindowEventDescriptor)[];
|
|
106
|
+
|
|
107
|
+
type CreateElementStyleArgs = {
|
|
108
|
+
elementId: ElementID;
|
|
109
|
+
classesProp: string;
|
|
110
|
+
label: string;
|
|
111
|
+
meta: StyleDefinitionVariant['meta'];
|
|
112
|
+
props: StyleDefinitionVariant['props'];
|
|
113
|
+
};
|
|
114
|
+
declare function createElementStyle({ elementId, classesProp, label, meta, props }: CreateElementStyleArgs): void;
|
|
115
|
+
|
|
116
|
+
type UpdateElementStyleArgs = {
|
|
117
|
+
elementId: ElementID;
|
|
118
|
+
styleId: StyleDefinition['id'];
|
|
119
|
+
meta: StyleDefinitionVariant['meta'];
|
|
120
|
+
props: StyleDefinitionVariant['props'];
|
|
117
121
|
};
|
|
118
|
-
declare
|
|
122
|
+
declare function updateElementStyle(args: UpdateElementStyleArgs): void;
|
|
119
123
|
|
|
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,
|
|
124
|
+
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, styleRerenderEvents, updateElementSettings, updateElementStyle, useElementSetting, useElementStyles, useElementType, useElementsDomRef, useParentElement, useSelectedElement };
|
package/dist/index.js
CHANGED
|
@@ -20,17 +20,18 @@ 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
|
+
styleRerenderEvents: () => styleRerenderEvents,
|
|
32
|
+
updateElementSettings: () => updateElementSettings,
|
|
33
|
+
updateElementStyle: () => updateElementStyle,
|
|
32
34
|
useElementSetting: () => useElementSetting,
|
|
33
|
-
useElementStyleProps: () => useElementStyleProps,
|
|
34
35
|
useElementStyles: () => useElementStyles,
|
|
35
36
|
useElementType: () => useElementType,
|
|
36
37
|
useElementsDomRef: () => useElementsDomRef,
|
|
@@ -95,8 +96,17 @@ var useElementSetting = (elementId, settingKey) => {
|
|
|
95
96
|
);
|
|
96
97
|
};
|
|
97
98
|
|
|
98
|
-
// src/hooks/use-element-
|
|
99
|
+
// src/hooks/use-element-styles.ts
|
|
100
|
+
var import_editor_v1_adapters4 = require("@elementor/editor-v1-adapters");
|
|
101
|
+
|
|
102
|
+
// src/styles/consts.ts
|
|
99
103
|
var import_editor_v1_adapters3 = require("@elementor/editor-v1-adapters");
|
|
104
|
+
var ELEMENT_STYLE_CHANGE_EVENT = "elementor/editor-v2/editor-elements/style";
|
|
105
|
+
var styleRerenderEvents = [
|
|
106
|
+
(0, import_editor_v1_adapters3.commandEndEvent)("document/elements/create"),
|
|
107
|
+
(0, import_editor_v1_adapters3.commandEndEvent)("editor/documents/attach-preview"),
|
|
108
|
+
(0, import_editor_v1_adapters3.windowEvent)(ELEMENT_STYLE_CHANGE_EVENT)
|
|
109
|
+
];
|
|
100
110
|
|
|
101
111
|
// src/sync/get-element-styles.ts
|
|
102
112
|
var getElementStyles = (elementID) => {
|
|
@@ -104,46 +114,9 @@ var getElementStyles = (elementID) => {
|
|
|
104
114
|
return container?.model.get("styles") || null;
|
|
105
115
|
};
|
|
106
116
|
|
|
107
|
-
// src/hooks/use-element-style-props.ts
|
|
108
|
-
function useElementStyleProps({
|
|
109
|
-
elementID,
|
|
110
|
-
styleDefID,
|
|
111
|
-
meta,
|
|
112
|
-
propNames
|
|
113
|
-
}) {
|
|
114
|
-
return (0, import_editor_v1_adapters3.__privateUseListenTo)(
|
|
115
|
-
(0, import_editor_v1_adapters3.commandEndEvent)("document/atomic-widgets/styles"),
|
|
116
|
-
() => {
|
|
117
|
-
if (!styleDefID) {
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
|
-
const styleDef = getElementStyles(elementID)?.[styleDefID];
|
|
121
|
-
if (!styleDef) {
|
|
122
|
-
return null;
|
|
123
|
-
}
|
|
124
|
-
const variant = getVariantByMeta(styleDef, meta);
|
|
125
|
-
return propNames.reduce((acc, key) => {
|
|
126
|
-
acc[key] = variant?.props[key] ?? null;
|
|
127
|
-
return acc;
|
|
128
|
-
}, {});
|
|
129
|
-
},
|
|
130
|
-
[elementID, styleDefID, JSON.stringify(propNames), meta]
|
|
131
|
-
);
|
|
132
|
-
}
|
|
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
|
-
|
|
139
117
|
// src/hooks/use-element-styles.ts
|
|
140
|
-
var import_editor_v1_adapters4 = require("@elementor/editor-v1-adapters");
|
|
141
118
|
function useElementStyles(elementId) {
|
|
142
|
-
return (0, import_editor_v1_adapters4.__privateUseListenTo)(
|
|
143
|
-
(0, import_editor_v1_adapters4.commandEndEvent)("document/atomic-widgets/styles"),
|
|
144
|
-
() => getElementStyles(elementId) ?? {},
|
|
145
|
-
[elementId]
|
|
146
|
-
);
|
|
119
|
+
return (0, import_editor_v1_adapters4.__privateUseListenTo)(styleRerenderEvents, () => getElementStyles(elementId) ?? {}, [elementId]);
|
|
147
120
|
}
|
|
148
121
|
|
|
149
122
|
// src/hooks/use-element-type.ts
|
|
@@ -256,44 +229,158 @@ var isElementInContainer = (element, container) => {
|
|
|
256
229
|
return false;
|
|
257
230
|
};
|
|
258
231
|
|
|
259
|
-
// src/sync/update-settings.ts
|
|
232
|
+
// src/sync/update-element-settings.ts
|
|
260
233
|
var import_editor_v1_adapters8 = require("@elementor/editor-v1-adapters");
|
|
261
|
-
var
|
|
234
|
+
var updateElementSettings = ({ id, props, withHistory = true }) => {
|
|
262
235
|
const container = getContainer(id);
|
|
263
|
-
|
|
236
|
+
const args = {
|
|
264
237
|
container,
|
|
265
|
-
settings: {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
238
|
+
settings: { ...props }
|
|
239
|
+
};
|
|
240
|
+
if (withHistory) {
|
|
241
|
+
(0, import_editor_v1_adapters8.__privateRunCommandSync)("document/elements/settings", args);
|
|
242
|
+
} else {
|
|
243
|
+
(0, import_editor_v1_adapters8.__privateRunCommandSync)("document/elements/set-settings", args, { internal: true });
|
|
244
|
+
}
|
|
269
245
|
};
|
|
270
246
|
|
|
271
|
-
// src/
|
|
272
|
-
var
|
|
273
|
-
var
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
247
|
+
// src/styles/create-element-style.ts
|
|
248
|
+
var import_editor_props2 = require("@elementor/editor-props");
|
|
249
|
+
var import_editor_styles = require("@elementor/editor-styles");
|
|
250
|
+
|
|
251
|
+
// src/styles/mutate-element-styles.ts
|
|
252
|
+
var import_editor_props = require("@elementor/editor-props");
|
|
253
|
+
|
|
254
|
+
// src/styles/errors.ts
|
|
255
|
+
var import_utils = require("@elementor/utils");
|
|
256
|
+
var ElementNotFoundError = (0, import_utils.createError)({
|
|
257
|
+
code: "element_not_found",
|
|
258
|
+
message: "Element not found."
|
|
259
|
+
});
|
|
260
|
+
var StyleNotFoundError = (0, import_utils.createError)({
|
|
261
|
+
code: "style_not_found",
|
|
262
|
+
message: "Style not found."
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
// src/styles/mutate-element-styles.ts
|
|
266
|
+
function mutateElementStyles(elementId, mutator) {
|
|
267
|
+
const container = getContainer(elementId);
|
|
268
|
+
if (!container) {
|
|
269
|
+
throw new ElementNotFoundError({ context: { elementId } });
|
|
270
|
+
}
|
|
271
|
+
const oldIds = Object.keys(container.model.get("styles") ?? {});
|
|
272
|
+
const styles = mutateStyles(container, mutator);
|
|
273
|
+
const newIds = Object.keys(styles);
|
|
274
|
+
clearRemovedClasses(container, {
|
|
275
|
+
oldIds,
|
|
276
|
+
newIds
|
|
282
277
|
});
|
|
283
|
-
|
|
278
|
+
dispatchChangeEvent();
|
|
279
|
+
return styles;
|
|
280
|
+
}
|
|
281
|
+
function mutateStyles(container, mutator) {
|
|
282
|
+
const styles = structuredClone(container.model.get("styles")) ?? {};
|
|
283
|
+
const entries = Object.entries(mutator(styles)).map(([styleId, style]) => {
|
|
284
|
+
style.variants = removeEmptyVariants(style);
|
|
285
|
+
return [styleId, style];
|
|
286
|
+
}).filter(([, style]) => {
|
|
287
|
+
return !isStyleEmpty(style);
|
|
288
|
+
});
|
|
289
|
+
const mutatedStyles = Object.fromEntries(entries);
|
|
290
|
+
container.model.set("styles", mutatedStyles);
|
|
291
|
+
return mutatedStyles;
|
|
292
|
+
}
|
|
293
|
+
function removeEmptyVariants(style) {
|
|
294
|
+
return style.variants.filter(({ props }) => Object.keys(props).length > 0);
|
|
295
|
+
}
|
|
296
|
+
function isStyleEmpty(style) {
|
|
297
|
+
return style.variants.length === 0;
|
|
298
|
+
}
|
|
299
|
+
function clearRemovedClasses(container, { oldIds, newIds }) {
|
|
300
|
+
const removedIds = oldIds.filter((id) => !newIds.includes(id));
|
|
301
|
+
const classesProps = structuredClone(getClassesProps(container));
|
|
302
|
+
classesProps.forEach(([, prop]) => {
|
|
303
|
+
prop.value = prop.value.filter((value) => !removedIds.includes(value));
|
|
304
|
+
});
|
|
305
|
+
updateElementSettings({
|
|
306
|
+
id: container.id,
|
|
307
|
+
props: Object.fromEntries(classesProps),
|
|
308
|
+
withHistory: false
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
function getClassesProps(container) {
|
|
312
|
+
return Object.entries(container.settings.toJSON()).filter((prop) => {
|
|
313
|
+
const [, value] = prop;
|
|
314
|
+
return import_editor_props.classesPropTypeUtil.isValid(value);
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
function dispatchChangeEvent() {
|
|
318
|
+
window.dispatchEvent(new CustomEvent(ELEMENT_STYLE_CHANGE_EVENT));
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// src/styles/create-element-style.ts
|
|
322
|
+
function createElementStyle({ elementId, classesProp, label, meta, props }) {
|
|
323
|
+
mutateElementStyles(elementId, (styles) => {
|
|
324
|
+
const id = (0, import_editor_styles.generateId)(`e-${elementId}-`, Object.keys(styles));
|
|
325
|
+
styles[id] = {
|
|
326
|
+
id,
|
|
327
|
+
label,
|
|
328
|
+
type: "class",
|
|
329
|
+
variants: [{ meta, props }]
|
|
330
|
+
};
|
|
331
|
+
addStyleToClassesProp(elementId, classesProp, id);
|
|
332
|
+
return styles;
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
function addStyleToClassesProp(elementId, classesProp, styleId) {
|
|
336
|
+
const base = getElementSetting(elementId, classesProp);
|
|
337
|
+
const classesPropValue = import_editor_props2.classesPropTypeUtil.create(
|
|
338
|
+
(prev) => {
|
|
339
|
+
return [...prev ?? [], styleId];
|
|
340
|
+
},
|
|
341
|
+
{ base }
|
|
342
|
+
);
|
|
343
|
+
updateElementSettings({
|
|
344
|
+
id: elementId,
|
|
345
|
+
props: {
|
|
346
|
+
[classesProp]: classesPropValue
|
|
347
|
+
},
|
|
348
|
+
withHistory: false
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// src/styles/update-element-style.ts
|
|
353
|
+
var import_editor_props3 = require("@elementor/editor-props");
|
|
354
|
+
var import_editor_styles2 = require("@elementor/editor-styles");
|
|
355
|
+
function updateElementStyle(args) {
|
|
356
|
+
mutateElementStyles(args.elementId, (styles) => {
|
|
357
|
+
const style = styles[args.styleId];
|
|
358
|
+
if (!style) {
|
|
359
|
+
throw new StyleNotFoundError({ context: { styleId: args.styleId } });
|
|
360
|
+
}
|
|
361
|
+
const variant = (0, import_editor_styles2.getVariantByMeta)(style, args.meta);
|
|
362
|
+
if (variant) {
|
|
363
|
+
variant.props = (0, import_editor_props3.mergeProps)(variant.props, args.props);
|
|
364
|
+
} else {
|
|
365
|
+
style.variants.push({ meta: args.meta, props: args.props });
|
|
366
|
+
}
|
|
367
|
+
return styles;
|
|
368
|
+
});
|
|
369
|
+
}
|
|
284
370
|
// Annotate the CommonJS export names for ESM import in node:
|
|
285
371
|
0 && (module.exports = {
|
|
372
|
+
ELEMENT_STYLE_CHANGE_EVENT,
|
|
373
|
+
createElementStyle,
|
|
286
374
|
getElementSetting,
|
|
287
375
|
getElementStyles,
|
|
288
376
|
getElements,
|
|
289
377
|
getSelectedElements,
|
|
290
|
-
getVariantByMeta,
|
|
291
378
|
getWidgetsCache,
|
|
292
379
|
isElementInContainer,
|
|
293
|
-
|
|
294
|
-
|
|
380
|
+
styleRerenderEvents,
|
|
381
|
+
updateElementSettings,
|
|
382
|
+
updateElementStyle,
|
|
295
383
|
useElementSetting,
|
|
296
|
-
useElementStyleProps,
|
|
297
384
|
useElementStyles,
|
|
298
385
|
useElementType,
|
|
299
386
|
useElementsDomRef,
|
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,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A,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-styles.ts","../src/styles/consts.ts","../src/sync/get-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 { 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, styleRerenderEvents } 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 { __privateUseListenTo as useListenTo } from '@elementor/editor-v1-adapters';\n\nimport { styleRerenderEvents } from '../styles/consts';\nimport { getElementStyles } from '../sync/get-element-styles';\nimport { type ElementID } from '../types';\n\nexport function useElementStyles( elementId: ElementID ) {\n\treturn useListenTo( styleRerenderEvents, () => getElementStyles( elementId ) ?? {}, [ elementId ] );\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( 'editor/documents/attach-preview' ),\n\twindowEvent( ELEMENT_STYLE_CHANGE_EVENT ),\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 { 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 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\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 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 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 { mergeProps } 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\tconst variant = getVariantByMeta( style, args.meta );\n\n\t\tif ( variant ) {\n\t\t\tvariant.props = mergeProps( variant.props, args.props );\n\t\t} else {\n\t\t\tstyle.variants.push( { meta: args.meta, props: args.props } );\n\t\t}\n\n\t\treturn styles;\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;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;A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G;AAElD,WAAO;AAAA,EACR,CAAE;AACH;AAEA,SAAS,sBAAuB,WAAsB,aAAqB,SAAkB;AAC5F,QAAM,OAAO,kBAAmB,WAAW,WAAY;AAEvD,QAAM,mBAAmB,yCAAoB;AAAA,IAC5C,CAAE,SAAU;AACX,aAAO,CAAE,GAAK,QAAQ,CAAC,GAAK,OAAQ;AAAA,IACrC;AAAA,IACA,EAAE,KAAK;AAAA,EACR;AAEA,wBAAuB;AAAA,IACtB,IAAI;AAAA,IACJ,OAAO;AAAA,MACN,CAAE,WAAY,GAAG;AAAA,IAClB;AAAA,IACA,aAAa;AAAA,EACd,CAAE;AACH;;;AGlDA,IAAAC,uBAA2B;AAC3B,IAAAC,wBAAoF;AAa7E,SAAS,mBAAoB,MAA+B;AAClE,sBAAqB,KAAK,WAAW,CAAE,WAAY;AAClD,UAAM,QAAQ,OAAQ,KAAK,OAAQ;AAEnC,QAAK,CAAE,OAAQ;AACd,YAAM,IAAI,mBAAoB,EAAE,SAAS,EAAE,SAAS,KAAK,QAAQ,EAAE,CAAE;AAAA,IACtE;AAEA,UAAM,cAAU,wCAAkB,OAAO,KAAK,IAAK;AAEnD,QAAK,SAAU;AACd,cAAQ,YAAQ,iCAAY,QAAQ,OAAO,KAAK,KAAM;AAAA,IACvD,OAAO;AACN,YAAM,SAAS,KAAM,EAAE,MAAM,KAAK,MAAM,OAAO,KAAK,MAAM,CAAE;AAAA,IAC7D;AAEA,WAAO;AAAA,EACR,CAAE;AACH;","names":["useListenTo","import_editor_v1_adapters","useListenTo","import_editor_v1_adapters","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_props","import_editor_styles"]}
|