@elementor/editor-elements 0.5.0 → 0.5.2
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 +30 -0
- package/dist/index.d.mts +13 -17
- package/dist/index.d.ts +13 -17
- package/dist/index.js +88 -72
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +96 -80
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -5
- package/src/errors.ts +21 -0
- package/src/hooks/use-element-styles.ts +3 -5
- package/src/index.ts +3 -2
- package/src/styles/consts.ts +8 -0
- package/src/styles/create-element-style.ts +20 -3
- package/src/styles/delete-element-style.ts +14 -0
- package/src/styles/mutate-element-styles.ts +20 -7
- package/src/styles/update-element-style.ts +7 -24
- package/src/sync/get-element-label.ts +22 -0
- package/src/sync/types.ts +3 -3
- package/src/types.ts +1 -3
- package/src/hooks/use-element-style-props.ts +0 -49
- package/src/styles/errors.ts +0 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @elementor/editor-elements
|
|
2
2
|
|
|
3
|
+
## 0.5.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e441663: Fix disabled publish button on style change.
|
|
8
|
+
- da38fa9: Remove unused exports and add missing dependencies.
|
|
9
|
+
- ad6fde0: Support history actions in style changes
|
|
10
|
+
- Updated dependencies [c9133d7]
|
|
11
|
+
- Updated dependencies [86863c1]
|
|
12
|
+
- Updated dependencies [da38fa9]
|
|
13
|
+
- Updated dependencies [9ca4eab]
|
|
14
|
+
- Updated dependencies [15c964f]
|
|
15
|
+
- Updated dependencies [ad6fde0]
|
|
16
|
+
- Updated dependencies [b8e2a85]
|
|
17
|
+
- @elementor/editor-props@0.9.0
|
|
18
|
+
- @elementor/editor-v1-adapters@0.10.0
|
|
19
|
+
- @elementor/utils@0.3.1
|
|
20
|
+
- @elementor/editor-styles@0.5.5
|
|
21
|
+
|
|
22
|
+
## 0.5.1
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- d61b1bc: Added a new event to update the elements styles repository + organized all events in a central location
|
|
27
|
+
- b34f498: Fix global class styles not updating
|
|
28
|
+
- Updated dependencies [a8b60c9]
|
|
29
|
+
- Updated dependencies [b34f498]
|
|
30
|
+
- @elementor/editor-v1-adapters@0.9.1
|
|
31
|
+
- @elementor/editor-styles@0.5.4
|
|
32
|
+
|
|
3
33
|
## 0.5.0
|
|
4
34
|
|
|
5
35
|
### Minor Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _elementor_editor_props from '@elementor/editor-props';
|
|
2
|
+
import { PropsSchema, PropValue, Props } from '@elementor/editor-props';
|
|
2
3
|
import * as _elementor_editor_styles from '@elementor/editor-styles';
|
|
3
4
|
import { StyleDefinitionID, StyleDefinition, StyleDefinitionVariant } from '@elementor/editor-styles';
|
|
5
|
+
import * as _elementor_editor_v1_adapters from '@elementor/editor-v1-adapters';
|
|
4
6
|
|
|
5
7
|
type ElementID = string;
|
|
6
8
|
type Element = {
|
|
@@ -32,7 +34,6 @@ type Control = {
|
|
|
32
34
|
};
|
|
33
35
|
};
|
|
34
36
|
type ControlItem = ControlsSection | Control;
|
|
35
|
-
type PropsSchema = Record<Control['value']['bind'], PropType>;
|
|
36
37
|
|
|
37
38
|
type V1Element = {
|
|
38
39
|
id: string;
|
|
@@ -61,17 +62,6 @@ declare function useElementsDomRef(): HTMLElement[];
|
|
|
61
62
|
|
|
62
63
|
declare const useElementSetting: <TValue>(elementId: ElementID, settingKey: string) => TValue | null;
|
|
63
64
|
|
|
64
|
-
type UseElementStylePropsArgs<T extends Props> = {
|
|
65
|
-
elementID: ElementID;
|
|
66
|
-
styleDefID: StyleDefinitionID | null;
|
|
67
|
-
meta: StyleDefinitionVariant['meta'];
|
|
68
|
-
propNames: Array<keyof T & string>;
|
|
69
|
-
};
|
|
70
|
-
type NullableObjectValues<T extends Props> = {
|
|
71
|
-
[K in keyof T]: T[K] | null;
|
|
72
|
-
};
|
|
73
|
-
declare function useElementStyleProps<T extends Props>({ elementID, styleDefID, meta, propNames, }: UseElementStylePropsArgs<T>): NullableObjectValues<T> | null;
|
|
74
|
-
|
|
75
65
|
declare function useElementStyles(elementId: ElementID): Record<string, _elementor_editor_styles.StyleDefinition>;
|
|
76
66
|
|
|
77
67
|
declare function useElementType(type?: string): ElementType | null;
|
|
@@ -90,15 +80,17 @@ declare const getElementSetting: <TValue>(elementId: ElementID, settingKey: stri
|
|
|
90
80
|
|
|
91
81
|
declare const getElementStyles: (elementID: ElementID) => Record<string, StyleDefinition> | null;
|
|
92
82
|
|
|
83
|
+
declare function getElementLabel(elementId: ElementID): string;
|
|
84
|
+
|
|
93
85
|
declare function getElements(root?: ElementID): V1Element[];
|
|
94
86
|
|
|
95
87
|
declare function getSelectedElements(): Element[];
|
|
96
88
|
|
|
97
89
|
declare function getWidgetsCache(): Record<string, {
|
|
98
90
|
atomic_controls?: ControlItem[];
|
|
99
|
-
atomic_props_schema?: PropsSchema;
|
|
91
|
+
atomic_props_schema?: _elementor_editor_props.PropsSchema;
|
|
100
92
|
controls: object;
|
|
101
|
-
base_styles?: _elementor_editor_styles.StyleDefinition
|
|
93
|
+
base_styles?: Record<string, _elementor_editor_styles.StyleDefinition>;
|
|
102
94
|
title: string;
|
|
103
95
|
}> | null;
|
|
104
96
|
|
|
@@ -112,15 +104,17 @@ type UpdateElementSettingsArgs = {
|
|
|
112
104
|
declare const updateElementSettings: ({ id, props, withHistory }: UpdateElementSettingsArgs) => void;
|
|
113
105
|
|
|
114
106
|
declare const ELEMENT_STYLE_CHANGE_EVENT = "elementor/editor-v2/editor-elements/style";
|
|
107
|
+
declare const styleRerenderEvents: (_elementor_editor_v1_adapters.CommandEventDescriptor | _elementor_editor_v1_adapters.WindowEventDescriptor)[];
|
|
115
108
|
|
|
116
109
|
type CreateElementStyleArgs = {
|
|
110
|
+
styleId?: StyleDefinitionID;
|
|
117
111
|
elementId: ElementID;
|
|
118
112
|
classesProp: string;
|
|
119
113
|
label: string;
|
|
120
114
|
meta: StyleDefinitionVariant['meta'];
|
|
121
115
|
props: StyleDefinitionVariant['props'];
|
|
122
116
|
};
|
|
123
|
-
declare function createElementStyle({ elementId, classesProp, label, meta, props }: CreateElementStyleArgs):
|
|
117
|
+
declare function createElementStyle({ styleId, elementId, classesProp, label, meta, props, }: CreateElementStyleArgs): string;
|
|
124
118
|
|
|
125
119
|
type UpdateElementStyleArgs = {
|
|
126
120
|
elementId: ElementID;
|
|
@@ -130,4 +124,6 @@ type UpdateElementStyleArgs = {
|
|
|
130
124
|
};
|
|
131
125
|
declare function updateElementStyle(args: UpdateElementStyleArgs): void;
|
|
132
126
|
|
|
133
|
-
|
|
127
|
+
declare function deleteElementStyle(elementId: ElementID, styleId: StyleDefinitionID): void;
|
|
128
|
+
|
|
129
|
+
export { type Control, type ControlItem, type ControlsSection, type CreateElementStyleArgs, ELEMENT_STYLE_CHANGE_EVENT, type Element, type ElementID, type ElementType, type UpdateElementSettingsArgs, type UpdateElementStyleArgs, type V1Element, type V1ElementModelProps, type V1ElementSettingsProps, createElementStyle, deleteElementStyle, getElementLabel, getElementSetting, getElementStyles, getElements, getSelectedElements, getWidgetsCache, isElementInContainer, styleRerenderEvents, updateElementSettings, updateElementStyle, useElementSetting, useElementStyles, useElementType, useElementsDomRef, useParentElement, useSelectedElement };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _elementor_editor_props from '@elementor/editor-props';
|
|
2
|
+
import { PropsSchema, PropValue, Props } from '@elementor/editor-props';
|
|
2
3
|
import * as _elementor_editor_styles from '@elementor/editor-styles';
|
|
3
4
|
import { StyleDefinitionID, StyleDefinition, StyleDefinitionVariant } from '@elementor/editor-styles';
|
|
5
|
+
import * as _elementor_editor_v1_adapters from '@elementor/editor-v1-adapters';
|
|
4
6
|
|
|
5
7
|
type ElementID = string;
|
|
6
8
|
type Element = {
|
|
@@ -32,7 +34,6 @@ type Control = {
|
|
|
32
34
|
};
|
|
33
35
|
};
|
|
34
36
|
type ControlItem = ControlsSection | Control;
|
|
35
|
-
type PropsSchema = Record<Control['value']['bind'], PropType>;
|
|
36
37
|
|
|
37
38
|
type V1Element = {
|
|
38
39
|
id: string;
|
|
@@ -61,17 +62,6 @@ declare function useElementsDomRef(): HTMLElement[];
|
|
|
61
62
|
|
|
62
63
|
declare const useElementSetting: <TValue>(elementId: ElementID, settingKey: string) => TValue | null;
|
|
63
64
|
|
|
64
|
-
type UseElementStylePropsArgs<T extends Props> = {
|
|
65
|
-
elementID: ElementID;
|
|
66
|
-
styleDefID: StyleDefinitionID | null;
|
|
67
|
-
meta: StyleDefinitionVariant['meta'];
|
|
68
|
-
propNames: Array<keyof T & string>;
|
|
69
|
-
};
|
|
70
|
-
type NullableObjectValues<T extends Props> = {
|
|
71
|
-
[K in keyof T]: T[K] | null;
|
|
72
|
-
};
|
|
73
|
-
declare function useElementStyleProps<T extends Props>({ elementID, styleDefID, meta, propNames, }: UseElementStylePropsArgs<T>): NullableObjectValues<T> | null;
|
|
74
|
-
|
|
75
65
|
declare function useElementStyles(elementId: ElementID): Record<string, _elementor_editor_styles.StyleDefinition>;
|
|
76
66
|
|
|
77
67
|
declare function useElementType(type?: string): ElementType | null;
|
|
@@ -90,15 +80,17 @@ declare const getElementSetting: <TValue>(elementId: ElementID, settingKey: stri
|
|
|
90
80
|
|
|
91
81
|
declare const getElementStyles: (elementID: ElementID) => Record<string, StyleDefinition> | null;
|
|
92
82
|
|
|
83
|
+
declare function getElementLabel(elementId: ElementID): string;
|
|
84
|
+
|
|
93
85
|
declare function getElements(root?: ElementID): V1Element[];
|
|
94
86
|
|
|
95
87
|
declare function getSelectedElements(): Element[];
|
|
96
88
|
|
|
97
89
|
declare function getWidgetsCache(): Record<string, {
|
|
98
90
|
atomic_controls?: ControlItem[];
|
|
99
|
-
atomic_props_schema?: PropsSchema;
|
|
91
|
+
atomic_props_schema?: _elementor_editor_props.PropsSchema;
|
|
100
92
|
controls: object;
|
|
101
|
-
base_styles?: _elementor_editor_styles.StyleDefinition
|
|
93
|
+
base_styles?: Record<string, _elementor_editor_styles.StyleDefinition>;
|
|
102
94
|
title: string;
|
|
103
95
|
}> | null;
|
|
104
96
|
|
|
@@ -112,15 +104,17 @@ type UpdateElementSettingsArgs = {
|
|
|
112
104
|
declare const updateElementSettings: ({ id, props, withHistory }: UpdateElementSettingsArgs) => void;
|
|
113
105
|
|
|
114
106
|
declare const ELEMENT_STYLE_CHANGE_EVENT = "elementor/editor-v2/editor-elements/style";
|
|
107
|
+
declare const styleRerenderEvents: (_elementor_editor_v1_adapters.CommandEventDescriptor | _elementor_editor_v1_adapters.WindowEventDescriptor)[];
|
|
115
108
|
|
|
116
109
|
type CreateElementStyleArgs = {
|
|
110
|
+
styleId?: StyleDefinitionID;
|
|
117
111
|
elementId: ElementID;
|
|
118
112
|
classesProp: string;
|
|
119
113
|
label: string;
|
|
120
114
|
meta: StyleDefinitionVariant['meta'];
|
|
121
115
|
props: StyleDefinitionVariant['props'];
|
|
122
116
|
};
|
|
123
|
-
declare function createElementStyle({ elementId, classesProp, label, meta, props }: CreateElementStyleArgs):
|
|
117
|
+
declare function createElementStyle({ styleId, elementId, classesProp, label, meta, props, }: CreateElementStyleArgs): string;
|
|
124
118
|
|
|
125
119
|
type UpdateElementStyleArgs = {
|
|
126
120
|
elementId: ElementID;
|
|
@@ -130,4 +124,6 @@ type UpdateElementStyleArgs = {
|
|
|
130
124
|
};
|
|
131
125
|
declare function updateElementStyle(args: UpdateElementStyleArgs): void;
|
|
132
126
|
|
|
133
|
-
|
|
127
|
+
declare function deleteElementStyle(elementId: ElementID, styleId: StyleDefinitionID): void;
|
|
128
|
+
|
|
129
|
+
export { type Control, type ControlItem, type ControlsSection, type CreateElementStyleArgs, ELEMENT_STYLE_CHANGE_EVENT, type Element, type ElementID, type ElementType, type UpdateElementSettingsArgs, type UpdateElementStyleArgs, type V1Element, type V1ElementModelProps, type V1ElementSettingsProps, createElementStyle, deleteElementStyle, getElementLabel, getElementSetting, getElementStyles, getElements, getSelectedElements, getWidgetsCache, isElementInContainer, styleRerenderEvents, updateElementSettings, updateElementStyle, useElementSetting, useElementStyles, useElementType, useElementsDomRef, useParentElement, useSelectedElement };
|
package/dist/index.js
CHANGED
|
@@ -22,16 +22,18 @@ var index_exports = {};
|
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
ELEMENT_STYLE_CHANGE_EVENT: () => ELEMENT_STYLE_CHANGE_EVENT,
|
|
24
24
|
createElementStyle: () => createElementStyle,
|
|
25
|
+
deleteElementStyle: () => deleteElementStyle,
|
|
26
|
+
getElementLabel: () => getElementLabel,
|
|
25
27
|
getElementSetting: () => getElementSetting,
|
|
26
28
|
getElementStyles: () => getElementStyles,
|
|
27
29
|
getElements: () => getElements,
|
|
28
30
|
getSelectedElements: () => getSelectedElements,
|
|
29
31
|
getWidgetsCache: () => getWidgetsCache,
|
|
30
32
|
isElementInContainer: () => isElementInContainer,
|
|
33
|
+
styleRerenderEvents: () => styleRerenderEvents,
|
|
31
34
|
updateElementSettings: () => updateElementSettings,
|
|
32
35
|
updateElementStyle: () => updateElementStyle,
|
|
33
36
|
useElementSetting: () => useElementSetting,
|
|
34
|
-
useElementStyleProps: () => useElementStyleProps,
|
|
35
37
|
useElementStyles: () => useElementStyles,
|
|
36
38
|
useElementType: () => useElementType,
|
|
37
39
|
useElementsDomRef: () => useElementsDomRef,
|
|
@@ -96,12 +98,17 @@ var useElementSetting = (elementId, settingKey) => {
|
|
|
96
98
|
);
|
|
97
99
|
};
|
|
98
100
|
|
|
99
|
-
// src/hooks/use-element-
|
|
100
|
-
var
|
|
101
|
-
var import_editor_v1_adapters3 = require("@elementor/editor-v1-adapters");
|
|
101
|
+
// src/hooks/use-element-styles.ts
|
|
102
|
+
var import_editor_v1_adapters4 = require("@elementor/editor-v1-adapters");
|
|
102
103
|
|
|
103
104
|
// src/styles/consts.ts
|
|
105
|
+
var import_editor_v1_adapters3 = require("@elementor/editor-v1-adapters");
|
|
104
106
|
var ELEMENT_STYLE_CHANGE_EVENT = "elementor/editor-v2/editor-elements/style";
|
|
107
|
+
var styleRerenderEvents = [
|
|
108
|
+
(0, import_editor_v1_adapters3.commandEndEvent)("document/elements/create"),
|
|
109
|
+
(0, import_editor_v1_adapters3.commandEndEvent)("editor/documents/attach-preview"),
|
|
110
|
+
(0, import_editor_v1_adapters3.windowEvent)(ELEMENT_STYLE_CHANGE_EVENT)
|
|
111
|
+
];
|
|
105
112
|
|
|
106
113
|
// src/sync/get-element-styles.ts
|
|
107
114
|
var getElementStyles = (elementID) => {
|
|
@@ -109,39 +116,9 @@ var getElementStyles = (elementID) => {
|
|
|
109
116
|
return container?.model.get("styles") || null;
|
|
110
117
|
};
|
|
111
118
|
|
|
112
|
-
// src/hooks/use-element-style-props.ts
|
|
113
|
-
function useElementStyleProps({
|
|
114
|
-
elementID,
|
|
115
|
-
styleDefID,
|
|
116
|
-
meta,
|
|
117
|
-
propNames
|
|
118
|
-
}) {
|
|
119
|
-
return (0, import_editor_v1_adapters3.__privateUseListenTo)(
|
|
120
|
-
(0, import_editor_v1_adapters3.windowEvent)(ELEMENT_STYLE_CHANGE_EVENT),
|
|
121
|
-
() => {
|
|
122
|
-
if (!styleDefID) {
|
|
123
|
-
return null;
|
|
124
|
-
}
|
|
125
|
-
const styleDef = getElementStyles(elementID)?.[styleDefID];
|
|
126
|
-
if (!styleDef) {
|
|
127
|
-
return null;
|
|
128
|
-
}
|
|
129
|
-
const variant = (0, import_editor_styles.getVariantByMeta)(styleDef, meta);
|
|
130
|
-
return propNames.reduce((acc, key) => {
|
|
131
|
-
acc[key] = variant?.props[key] ?? null;
|
|
132
|
-
return acc;
|
|
133
|
-
}, {});
|
|
134
|
-
},
|
|
135
|
-
[elementID, styleDefID, JSON.stringify(propNames), meta]
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
119
|
// src/hooks/use-element-styles.ts
|
|
140
|
-
var import_editor_v1_adapters4 = require("@elementor/editor-v1-adapters");
|
|
141
120
|
function useElementStyles(elementId) {
|
|
142
|
-
return (0, import_editor_v1_adapters4.__privateUseListenTo)(
|
|
143
|
-
elementId
|
|
144
|
-
]);
|
|
121
|
+
return (0, import_editor_v1_adapters4.__privateUseListenTo)(styleRerenderEvents, () => getElementStyles(elementId) ?? {}, [elementId]);
|
|
145
122
|
}
|
|
146
123
|
|
|
147
124
|
// src/hooks/use-element-type.ts
|
|
@@ -233,6 +210,39 @@ function useParentElement(elementId) {
|
|
|
233
210
|
);
|
|
234
211
|
}
|
|
235
212
|
|
|
213
|
+
// src/errors.ts
|
|
214
|
+
var import_utils = require("@elementor/utils");
|
|
215
|
+
var ElementNotFoundError = (0, import_utils.createError)({
|
|
216
|
+
code: "element_not_found",
|
|
217
|
+
message: "Element not found."
|
|
218
|
+
});
|
|
219
|
+
var StyleNotFoundError = (0, import_utils.createError)({
|
|
220
|
+
code: "style_not_found",
|
|
221
|
+
message: "Style not found."
|
|
222
|
+
});
|
|
223
|
+
var ElementTypeNotExistsError = (0, import_utils.createError)({
|
|
224
|
+
code: "element_type_not_exists",
|
|
225
|
+
message: "Element type does not exist."
|
|
226
|
+
});
|
|
227
|
+
var ElementLabelNotExistsError = (0, import_utils.createError)({
|
|
228
|
+
code: "element_label_not_exists",
|
|
229
|
+
message: "Element label does not exist."
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
// src/sync/get-element-label.ts
|
|
233
|
+
function getElementLabel(elementId) {
|
|
234
|
+
const container = getContainer(elementId);
|
|
235
|
+
const type = container?.model.get("widgetType") || container?.model.get("elType");
|
|
236
|
+
if (!type) {
|
|
237
|
+
throw new ElementTypeNotExistsError({ context: { elementId } });
|
|
238
|
+
}
|
|
239
|
+
const label = getWidgetsCache()?.[type]?.title;
|
|
240
|
+
if (!label) {
|
|
241
|
+
throw new ElementLabelNotExistsError({ context: { elementType: type } });
|
|
242
|
+
}
|
|
243
|
+
return label;
|
|
244
|
+
}
|
|
245
|
+
|
|
236
246
|
// src/sync/get-elements.ts
|
|
237
247
|
function getElements(root) {
|
|
238
248
|
const container = root ? getContainer(root) : getCurrentDocumentContainer();
|
|
@@ -271,31 +281,24 @@ var updateElementSettings = ({ id, props, withHistory = true }) => {
|
|
|
271
281
|
|
|
272
282
|
// src/styles/create-element-style.ts
|
|
273
283
|
var import_editor_props2 = require("@elementor/editor-props");
|
|
274
|
-
var
|
|
284
|
+
var import_editor_styles = require("@elementor/editor-styles");
|
|
275
285
|
|
|
276
286
|
// src/styles/mutate-element-styles.ts
|
|
277
287
|
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
|
|
288
|
+
var import_editor_v1_adapters9 = require("@elementor/editor-v1-adapters");
|
|
291
289
|
function mutateElementStyles(elementId, mutator) {
|
|
292
290
|
const container = getContainer(elementId);
|
|
293
291
|
if (!container) {
|
|
294
292
|
throw new ElementNotFoundError({ context: { elementId } });
|
|
295
293
|
}
|
|
294
|
+
const oldIds = Object.keys(container.model.get("styles") ?? {});
|
|
296
295
|
const styles = mutateStyles(container, mutator);
|
|
297
|
-
|
|
298
|
-
|
|
296
|
+
const newIds = Object.keys(styles);
|
|
297
|
+
clearRemovedClasses(container, {
|
|
298
|
+
oldIds,
|
|
299
|
+
newIds
|
|
300
|
+
});
|
|
301
|
+
notifyChanges();
|
|
299
302
|
return styles;
|
|
300
303
|
}
|
|
301
304
|
function mutateStyles(container, mutator) {
|
|
@@ -316,11 +319,11 @@ function removeEmptyVariants(style) {
|
|
|
316
319
|
function isStyleEmpty(style) {
|
|
317
320
|
return style.variants.length === 0;
|
|
318
321
|
}
|
|
319
|
-
function
|
|
320
|
-
const
|
|
322
|
+
function clearRemovedClasses(container, { oldIds, newIds }) {
|
|
323
|
+
const removedIds = oldIds.filter((id) => !newIds.includes(id));
|
|
321
324
|
const classesProps = structuredClone(getClassesProps(container));
|
|
322
325
|
classesProps.forEach(([, prop]) => {
|
|
323
|
-
prop.value = prop.value.filter((value) =>
|
|
326
|
+
prop.value = prop.value.filter((value) => !removedIds.includes(value));
|
|
324
327
|
});
|
|
325
328
|
updateElementSettings({
|
|
326
329
|
id: container.id,
|
|
@@ -334,14 +337,26 @@ function getClassesProps(container) {
|
|
|
334
337
|
return import_editor_props.classesPropTypeUtil.isValid(value);
|
|
335
338
|
});
|
|
336
339
|
}
|
|
340
|
+
function notifyChanges() {
|
|
341
|
+
dispatchChangeEvent();
|
|
342
|
+
(0, import_editor_v1_adapters9.__privateRunCommandSync)("document/save/set-is-modified", { status: true }, { internal: true });
|
|
343
|
+
}
|
|
337
344
|
function dispatchChangeEvent() {
|
|
338
345
|
window.dispatchEvent(new CustomEvent(ELEMENT_STYLE_CHANGE_EVENT));
|
|
339
346
|
}
|
|
340
347
|
|
|
341
348
|
// src/styles/create-element-style.ts
|
|
342
|
-
function createElementStyle({
|
|
349
|
+
function createElementStyle({
|
|
350
|
+
styleId,
|
|
351
|
+
elementId,
|
|
352
|
+
classesProp,
|
|
353
|
+
label,
|
|
354
|
+
meta,
|
|
355
|
+
props
|
|
356
|
+
}) {
|
|
357
|
+
let id = styleId;
|
|
343
358
|
mutateElementStyles(elementId, (styles) => {
|
|
344
|
-
|
|
359
|
+
id ??= (0, import_editor_styles.generateId)(`e-${elementId}-`, Object.keys(styles));
|
|
345
360
|
styles[id] = {
|
|
346
361
|
id,
|
|
347
362
|
label,
|
|
@@ -351,6 +366,7 @@ function createElementStyle({ elementId, classesProp, label, meta, props }) {
|
|
|
351
366
|
addStyleToClassesProp(elementId, classesProp, id);
|
|
352
367
|
return styles;
|
|
353
368
|
});
|
|
369
|
+
return id;
|
|
354
370
|
}
|
|
355
371
|
function addStyleToClassesProp(elementId, classesProp, styleId) {
|
|
356
372
|
const base = getElementSetting(elementId, classesProp);
|
|
@@ -370,47 +386,47 @@ function addStyleToClassesProp(elementId, classesProp, styleId) {
|
|
|
370
386
|
}
|
|
371
387
|
|
|
372
388
|
// src/styles/update-element-style.ts
|
|
373
|
-
var
|
|
389
|
+
var import_editor_props3 = require("@elementor/editor-props");
|
|
390
|
+
var import_editor_styles2 = require("@elementor/editor-styles");
|
|
374
391
|
function updateElementStyle(args) {
|
|
375
392
|
mutateElementStyles(args.elementId, (styles) => {
|
|
376
393
|
const style = styles[args.styleId];
|
|
377
394
|
if (!style) {
|
|
378
395
|
throw new StyleNotFoundError({ context: { styleId: args.styleId } });
|
|
379
396
|
}
|
|
380
|
-
|
|
381
|
-
if (
|
|
382
|
-
variant =
|
|
383
|
-
|
|
397
|
+
const variant = (0, import_editor_styles2.getVariantByMeta)(style, args.meta);
|
|
398
|
+
if (variant) {
|
|
399
|
+
variant.props = (0, import_editor_props3.mergeProps)(variant.props, args.props);
|
|
400
|
+
} else {
|
|
401
|
+
style.variants.push({ meta: args.meta, props: args.props });
|
|
384
402
|
}
|
|
385
|
-
variant.props = mergeVariantProps(variant, args.props);
|
|
386
403
|
return styles;
|
|
387
404
|
});
|
|
388
405
|
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
finalProps[key] = value;
|
|
396
|
-
}
|
|
406
|
+
|
|
407
|
+
// src/styles/delete-element-style.ts
|
|
408
|
+
function deleteElementStyle(elementId, styleId) {
|
|
409
|
+
mutateElementStyles(elementId, (styles) => {
|
|
410
|
+
delete styles[styleId];
|
|
411
|
+
return styles;
|
|
397
412
|
});
|
|
398
|
-
return finalProps;
|
|
399
413
|
}
|
|
400
414
|
// Annotate the CommonJS export names for ESM import in node:
|
|
401
415
|
0 && (module.exports = {
|
|
402
416
|
ELEMENT_STYLE_CHANGE_EVENT,
|
|
403
417
|
createElementStyle,
|
|
418
|
+
deleteElementStyle,
|
|
419
|
+
getElementLabel,
|
|
404
420
|
getElementSetting,
|
|
405
421
|
getElementStyles,
|
|
406
422
|
getElements,
|
|
407
423
|
getSelectedElements,
|
|
408
424
|
getWidgetsCache,
|
|
409
425
|
isElementInContainer,
|
|
426
|
+
styleRerenderEvents,
|
|
410
427
|
updateElementSettings,
|
|
411
428
|
updateElementStyle,
|
|
412
429
|
useElementSetting,
|
|
413
|
-
useElementStyleProps,
|
|
414
430
|
useElementStyles,
|
|
415
431
|
useElementType,
|
|
416
432
|
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/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;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,gCAAiE;;;ACElD,SAAR,8BAA+C;AACrD,QAAM,iBA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M,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"]}
|
|
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/errors.ts","../src/sync/get-element-label.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/update-element-style.ts","../src/styles/delete-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 { getElementLabel } from './sync/get-element-label';\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';\nexport { deleteElementStyle } from './styles/delete-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 { createError } from '@elementor/utils';\n\nexport const ElementNotFoundError = createError< { elementId: string } >( {\n\tcode: 'element_not_found',\n\tmessage: 'Element not found.',\n} );\n\nexport const StyleNotFoundError = createError< { styleId: string } >( {\n\tcode: 'style_not_found',\n\tmessage: 'Style not found.',\n} );\n\nexport const ElementTypeNotExistsError = createError< { elementId: string } >( {\n\tcode: 'element_type_not_exists',\n\tmessage: 'Element type does not exist.',\n} );\n\nexport const ElementLabelNotExistsError = createError< { elementType: string } >( {\n\tcode: 'element_label_not_exists',\n\tmessage: 'Element label does not exist.',\n} );\n","import { ElementLabelNotExistsError, ElementTypeNotExistsError } from '../errors';\nimport getContainer from '../sync/get-container';\nimport { getWidgetsCache } from '../sync/get-widgets-cache';\nimport { type ElementID } from '../types';\n\nexport function getElementLabel( elementId: ElementID ) {\n\tconst container = getContainer( elementId );\n\n\tconst type = container?.model.get( 'widgetType' ) || container?.model.get( 'elType' );\n\n\tif ( ! type ) {\n\t\tthrow new ElementTypeNotExistsError( { context: { elementId } } );\n\t}\n\n\tconst label = getWidgetsCache()?.[ type ]?.title;\n\n\tif ( ! label ) {\n\t\tthrow new ElementLabelNotExistsError( { context: { elementType: type } } );\n\t}\n\n\treturn label;\n}\n","import { type 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 {\n\tgenerateId,\n\ttype StyleDefinition,\n\ttype StyleDefinitionID,\n\ttype StyleDefinitionVariant,\n} from '@elementor/editor-styles';\n\nimport { getElementSetting } from '../sync/get-element-setting';\nimport { updateElementSettings } from '../sync/update-element-settings';\nimport { type ElementID } from '../types';\nimport { mutateElementStyles } from './mutate-element-styles';\n\nexport type CreateElementStyleArgs = {\n\tstyleId?: StyleDefinitionID;\n\telementId: ElementID;\n\tclassesProp: string;\n\tlabel: string;\n\tmeta: StyleDefinitionVariant[ 'meta' ];\n\tprops: StyleDefinitionVariant[ 'props' ];\n};\n\nexport function createElementStyle( {\n\tstyleId,\n\telementId,\n\tclassesProp,\n\tlabel,\n\tmeta,\n\tprops,\n}: CreateElementStyleArgs ): string {\n\tlet id = styleId;\n\n\tmutateElementStyles( elementId, ( styles ) => {\n\t\tid ??= 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\treturn id as string;\n}\n\nfunction addStyleToClassesProp( elementId: ElementID, classesProp: string, styleId: string ) {\n\tconst base = getElementSetting( elementId, classesProp );\n\n\tconst classesPropValue = classesPropTypeUtil.create(\n\t\t( prev ) => {\n\t\t\treturn [ ...( prev ?? [] ), styleId ];\n\t\t},\n\t\t{ base }\n\t);\n\n\tupdateElementSettings( {\n\t\tid: elementId,\n\t\tprops: {\n\t\t\t[ classesProp ]: classesPropValue,\n\t\t},\n\t\twithHistory: false,\n\t} );\n}\n","import { classesPropTypeUtil, type ClassesPropValue } from '@elementor/editor-props';\nimport { type StyleDefinition, type StyleDefinitionsMap } from '@elementor/editor-styles';\nimport { __privateRunCommandSync as runCommandSync } from '@elementor/editor-v1-adapters';\n\nimport { ElementNotFoundError } from '../errors';\nimport getContainer from '../sync/get-container';\nimport { type V1Element } from '../sync/types';\nimport { updateElementSettings } from '../sync/update-element-settings';\nimport { type ElementID } from '../types';\nimport { ELEMENT_STYLE_CHANGE_EVENT } from './consts';\n\ntype Mutator = ( styles: StyleDefinitionsMap ) => StyleDefinitionsMap;\n\nexport function mutateElementStyles( elementId: ElementID, mutator: Mutator ) {\n\tconst container = getContainer( elementId );\n\n\tif ( ! container ) {\n\t\tthrow new ElementNotFoundError( { context: { elementId } } );\n\t}\n\n\tconst oldIds = Object.keys( container.model.get( 'styles' ) ?? {} );\n\n\tconst styles = mutateStyles( container, mutator );\n\n\tconst newIds = Object.keys( styles );\n\n\tclearRemovedClasses( container, {\n\t\toldIds,\n\t\tnewIds,\n\t} );\n\n\tnotifyChanges();\n\n\treturn styles;\n}\n\nfunction mutateStyles( container: V1Element, mutator: Mutator ) {\n\tconst styles: StyleDefinitionsMap = structuredClone( container.model.get( 'styles' ) ) ?? {};\n\n\tconst entries = Object.entries( mutator( styles ) )\n\t\t.map( ( [ styleId, style ] ) => {\n\t\t\tstyle.variants = removeEmptyVariants( style );\n\n\t\t\treturn [ styleId, style ] as const;\n\t\t} )\n\t\t.filter( ( [ , style ] ) => {\n\t\t\treturn ! isStyleEmpty( style );\n\t\t} );\n\n\tconst mutatedStyles = Object.fromEntries( entries );\n\n\tcontainer.model.set( 'styles', mutatedStyles );\n\n\treturn mutatedStyles;\n}\n\nfunction removeEmptyVariants( style: StyleDefinition ) {\n\treturn style.variants.filter( ( { 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 notifyChanges() {\n\tdispatchChangeEvent();\n\trunCommandSync( 'document/save/set-is-modified', { status: true }, { internal: true } );\n}\n\nfunction dispatchChangeEvent() {\n\twindow.dispatchEvent( new CustomEvent( ELEMENT_STYLE_CHANGE_EVENT ) );\n}\n","import { mergeProps } from '@elementor/editor-props';\nimport { getVariantByMeta, type StyleDefinition, type StyleDefinitionVariant } from '@elementor/editor-styles';\n\nimport { StyleNotFoundError } from '../errors';\nimport { type ElementID } from '../types';\nimport { mutateElementStyles } from './mutate-element-styles';\n\nexport type UpdateElementStyleArgs = {\n\telementId: ElementID;\n\tstyleId: StyleDefinition[ 'id' ];\n\tmeta: StyleDefinitionVariant[ 'meta' ];\n\tprops: StyleDefinitionVariant[ 'props' ];\n};\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","import { type StyleDefinitionID } from '@elementor/editor-styles';\n\nimport { type ElementID } from '../types';\nimport { mutateElementStyles } from './mutate-element-styles';\n\nexport function deleteElementStyle( elementId: ElementID, styleId: StyleDefinitionID ) {\n\tmutateElementStyles( elementId, ( styles ) => {\n\t\t// The object is deep cloned so mutating it is fine.\n\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\tdelete styles[ styleId ];\n\n\t\treturn styles;\n\t} );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;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,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;;;AEnEA,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;;;AC3BO,SAAS,mBAAoB,WAAsB,SAA6B;AACtF,sBAAqB,WAAW,CAAE,WAAY;AAG7C,WAAO,OAAQ,OAAQ;AAEvB,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_v1_adapters","runCommandSync","import_editor_props","import_editor_styles"]}
|