@elementor/editor-elements 4.0.0-607 → 4.0.0-619

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { PropsSchema, PropValue, SizePropValue, Props, LinkPropValue } from '@elementor/editor-props';
1
+ import { PropsSchema, PropValue, SizePropValue, AnyTransformable, Props, LinkPropValue } from '@elementor/editor-props';
2
2
  import { ClassState, StyleDefinitionID, StyleDefinition, StyleDefinitionVariant } from '@elementor/editor-styles';
3
3
  import * as _elementor_editor_v1_adapters from '@elementor/editor-v1-adapters';
4
4
 
@@ -219,18 +219,26 @@ declare function useElementChildren<T extends ElementChildren>(elementId: Elemen
219
219
 
220
220
  declare const useElementEditorSettings: (elementId: ElementID) => V1ElementEditorSettingsProps;
221
221
 
222
- declare const useElementSetting: <TValue>(elementId: ElementID, settingKey: string) => TValue | null;
223
- declare const useElementSettings: <TValue>(elementId: ElementID, settingKeys: string[]) => Record<string, TValue>;
224
-
225
222
  declare function useParentElement(elementId: string | null): any;
226
223
 
227
224
  declare function useSelectedElement(): {
225
+ element: Element;
226
+ elementType: ElementType;
227
+ } | {
228
228
  element: null;
229
229
  elementType: null;
230
- } | {
230
+ };
231
+
232
+ type UseSelectedElementSettingsResult<TValue> = {
231
233
  element: Element;
232
234
  elementType: ElementType;
235
+ settings: Record<string, TValue | null>;
236
+ } | {
237
+ element: null;
238
+ elementType: null;
239
+ settings: null;
233
240
  };
241
+ declare function useSelectedElementSettings<TValue = AnyTransformable>(): UseSelectedElementSettingsResult<TValue>;
234
242
 
235
243
  type Options$4 = {
236
244
  useHistory?: boolean;
@@ -489,4 +497,4 @@ declare const updateElementInteractions: ({ elementId, interactions, }: {
489
497
  }) => void;
490
498
  declare const playElementInteractions: (elementId: string, interactionId: string) => void;
491
499
 
492
- export { type AnimationPresetPropValue, type BooleanPropValue, type ConfigPropValue, type Control, type ControlItem, type ControlLayout, type ControlsSection, type CreateElementParams, type CreateElementStyleArgs, type DropElementParams, type DuplicateElementParams, type DuplicateElementsParams, type DuplicatedElement, type DuplicatedElementsResult, ELEMENT_STYLE_CHANGE_EVENT, type Element, type ElementChildren, type ElementControl, type ElementID, type ElementInteractions, type ElementModel, type ElementType, type ExcludedBreakpointsPropValue, type ExtendedWindow, type InteractionBreakpointsPropValue, type InteractionItemPropValue, type LinkInLinkRestriction, type ModelResult, type MoveElementParams, type NumberPropValue, type PseudoState, type StringPropValue, type TimingConfigPropValue, type UpdateElementSettingsArgs, type UpdateElementStyleArgs, type V1Element, type V1ElementConfig, type V1ElementData, type V1ElementEditorSettingsProps, type V1ElementModelProps, type V1ElementSettingsProps, createElement, createElementStyle, createElements, deleteElement, deleteElementStyle, dropElement, duplicateElement, duplicateElements, findChildRecursive, generateElementId, getAllDescendants, getAnchoredAncestorId, getAnchoredDescendantId, getContainer, getCurrentDocumentContainer, getCurrentDocumentId, getElementChildren as getElementChildrenWithFallback, getElementEditorSettings, getElementInteractions, getElementLabel, getElementSetting, getElementSettings, getElementStyles, getElementType, getElements, getLinkInLinkRestriction, getSelectedElements, getWidgetsCache, isElementAnchored, moveElement, moveElements, playElementInteractions, removeElements, replaceElement, selectElement, shouldCreateNewLocalStyle, styleRerenderEvents, updateElementEditorSettings, updateElementInteractions, updateElementSettings, updateElementStyle, useElementChildren, useElementEditorSettings, useElementInteractions, useElementSetting, useElementSettings, useParentElement, useSelectedElement };
500
+ export { type AnimationPresetPropValue, type BooleanPropValue, type ConfigPropValue, type Control, type ControlItem, type ControlLayout, type ControlsSection, type CreateElementParams, type CreateElementStyleArgs, type DropElementParams, type DuplicateElementParams, type DuplicateElementsParams, type DuplicatedElement, type DuplicatedElementsResult, ELEMENT_STYLE_CHANGE_EVENT, type Element, type ElementChildren, type ElementControl, type ElementID, type ElementInteractions, type ElementModel, type ElementType, type ExcludedBreakpointsPropValue, type ExtendedWindow, type InteractionBreakpointsPropValue, type InteractionItemPropValue, type LinkInLinkRestriction, type ModelResult, type MoveElementParams, type NumberPropValue, type PseudoState, type StringPropValue, type TimingConfigPropValue, type UpdateElementSettingsArgs, type UpdateElementStyleArgs, type V1Element, type V1ElementConfig, type V1ElementData, type V1ElementEditorSettingsProps, type V1ElementModelProps, type V1ElementSettingsProps, createElement, createElementStyle, createElements, deleteElement, deleteElementStyle, dropElement, duplicateElement, duplicateElements, findChildRecursive, generateElementId, getAllDescendants, getAnchoredAncestorId, getAnchoredDescendantId, getContainer, getCurrentDocumentContainer, getCurrentDocumentId, getElementChildren as getElementChildrenWithFallback, getElementEditorSettings, getElementInteractions, getElementLabel, getElementSetting, getElementSettings, getElementStyles, getElementType, getElements, getLinkInLinkRestriction, getSelectedElements, getWidgetsCache, isElementAnchored, moveElement, moveElements, playElementInteractions, removeElements, replaceElement, selectElement, shouldCreateNewLocalStyle, styleRerenderEvents, updateElementEditorSettings, updateElementInteractions, updateElementSettings, updateElementStyle, useElementChildren, useElementEditorSettings, useElementInteractions, useParentElement, useSelectedElement, useSelectedElementSettings };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { PropsSchema, PropValue, SizePropValue, Props, LinkPropValue } from '@elementor/editor-props';
1
+ import { PropsSchema, PropValue, SizePropValue, AnyTransformable, Props, LinkPropValue } from '@elementor/editor-props';
2
2
  import { ClassState, StyleDefinitionID, StyleDefinition, StyleDefinitionVariant } from '@elementor/editor-styles';
3
3
  import * as _elementor_editor_v1_adapters from '@elementor/editor-v1-adapters';
4
4
 
@@ -219,18 +219,26 @@ declare function useElementChildren<T extends ElementChildren>(elementId: Elemen
219
219
 
220
220
  declare const useElementEditorSettings: (elementId: ElementID) => V1ElementEditorSettingsProps;
221
221
 
222
- declare const useElementSetting: <TValue>(elementId: ElementID, settingKey: string) => TValue | null;
223
- declare const useElementSettings: <TValue>(elementId: ElementID, settingKeys: string[]) => Record<string, TValue>;
224
-
225
222
  declare function useParentElement(elementId: string | null): any;
226
223
 
227
224
  declare function useSelectedElement(): {
225
+ element: Element;
226
+ elementType: ElementType;
227
+ } | {
228
228
  element: null;
229
229
  elementType: null;
230
- } | {
230
+ };
231
+
232
+ type UseSelectedElementSettingsResult<TValue> = {
231
233
  element: Element;
232
234
  elementType: ElementType;
235
+ settings: Record<string, TValue | null>;
236
+ } | {
237
+ element: null;
238
+ elementType: null;
239
+ settings: null;
233
240
  };
241
+ declare function useSelectedElementSettings<TValue = AnyTransformable>(): UseSelectedElementSettingsResult<TValue>;
234
242
 
235
243
  type Options$4 = {
236
244
  useHistory?: boolean;
@@ -489,4 +497,4 @@ declare const updateElementInteractions: ({ elementId, interactions, }: {
489
497
  }) => void;
490
498
  declare const playElementInteractions: (elementId: string, interactionId: string) => void;
491
499
 
492
- export { type AnimationPresetPropValue, type BooleanPropValue, type ConfigPropValue, type Control, type ControlItem, type ControlLayout, type ControlsSection, type CreateElementParams, type CreateElementStyleArgs, type DropElementParams, type DuplicateElementParams, type DuplicateElementsParams, type DuplicatedElement, type DuplicatedElementsResult, ELEMENT_STYLE_CHANGE_EVENT, type Element, type ElementChildren, type ElementControl, type ElementID, type ElementInteractions, type ElementModel, type ElementType, type ExcludedBreakpointsPropValue, type ExtendedWindow, type InteractionBreakpointsPropValue, type InteractionItemPropValue, type LinkInLinkRestriction, type ModelResult, type MoveElementParams, type NumberPropValue, type PseudoState, type StringPropValue, type TimingConfigPropValue, type UpdateElementSettingsArgs, type UpdateElementStyleArgs, type V1Element, type V1ElementConfig, type V1ElementData, type V1ElementEditorSettingsProps, type V1ElementModelProps, type V1ElementSettingsProps, createElement, createElementStyle, createElements, deleteElement, deleteElementStyle, dropElement, duplicateElement, duplicateElements, findChildRecursive, generateElementId, getAllDescendants, getAnchoredAncestorId, getAnchoredDescendantId, getContainer, getCurrentDocumentContainer, getCurrentDocumentId, getElementChildren as getElementChildrenWithFallback, getElementEditorSettings, getElementInteractions, getElementLabel, getElementSetting, getElementSettings, getElementStyles, getElementType, getElements, getLinkInLinkRestriction, getSelectedElements, getWidgetsCache, isElementAnchored, moveElement, moveElements, playElementInteractions, removeElements, replaceElement, selectElement, shouldCreateNewLocalStyle, styleRerenderEvents, updateElementEditorSettings, updateElementInteractions, updateElementSettings, updateElementStyle, useElementChildren, useElementEditorSettings, useElementInteractions, useElementSetting, useElementSettings, useParentElement, useSelectedElement };
500
+ export { type AnimationPresetPropValue, type BooleanPropValue, type ConfigPropValue, type Control, type ControlItem, type ControlLayout, type ControlsSection, type CreateElementParams, type CreateElementStyleArgs, type DropElementParams, type DuplicateElementParams, type DuplicateElementsParams, type DuplicatedElement, type DuplicatedElementsResult, ELEMENT_STYLE_CHANGE_EVENT, type Element, type ElementChildren, type ElementControl, type ElementID, type ElementInteractions, type ElementModel, type ElementType, type ExcludedBreakpointsPropValue, type ExtendedWindow, type InteractionBreakpointsPropValue, type InteractionItemPropValue, type LinkInLinkRestriction, type ModelResult, type MoveElementParams, type NumberPropValue, type PseudoState, type StringPropValue, type TimingConfigPropValue, type UpdateElementSettingsArgs, type UpdateElementStyleArgs, type V1Element, type V1ElementConfig, type V1ElementData, type V1ElementEditorSettingsProps, type V1ElementModelProps, type V1ElementSettingsProps, createElement, createElementStyle, createElements, deleteElement, deleteElementStyle, dropElement, duplicateElement, duplicateElements, findChildRecursive, generateElementId, getAllDescendants, getAnchoredAncestorId, getAnchoredDescendantId, getContainer, getCurrentDocumentContainer, getCurrentDocumentId, getElementChildren as getElementChildrenWithFallback, getElementEditorSettings, getElementInteractions, getElementLabel, getElementSetting, getElementSettings, getElementStyles, getElementType, getElements, getLinkInLinkRestriction, getSelectedElements, getWidgetsCache, isElementAnchored, moveElement, moveElements, playElementInteractions, removeElements, replaceElement, selectElement, shouldCreateNewLocalStyle, styleRerenderEvents, updateElementEditorSettings, updateElementInteractions, updateElementSettings, updateElementStyle, useElementChildren, useElementEditorSettings, useElementInteractions, useParentElement, useSelectedElement, useSelectedElementSettings };
package/dist/index.js CHANGED
@@ -65,10 +65,9 @@ __export(index_exports, {
65
65
  useElementChildren: () => useElementChildren,
66
66
  useElementEditorSettings: () => useElementEditorSettings,
67
67
  useElementInteractions: () => useElementInteractions,
68
- useElementSetting: () => useElementSetting,
69
- useElementSettings: () => useElementSettings,
70
68
  useParentElement: () => useParentElement,
71
- useSelectedElement: () => useSelectedElement
69
+ useSelectedElement: () => useSelectedElement,
70
+ useSelectedElementSettings: () => useSelectedElementSettings
72
71
  });
73
72
  module.exports = __toCommonJS(index_exports);
74
73
 
@@ -165,45 +164,11 @@ var useElementEditorSettings = (elementId) => {
165
164
  );
166
165
  };
167
166
 
168
- // src/hooks/use-element-setting.ts
169
- var import_editor_v1_adapters4 = require("@elementor/editor-v1-adapters");
170
-
171
- // src/sync/get-element-setting.ts
172
- var getElementSetting = (elementId, settingKey) => {
173
- const container = getContainer(elementId);
174
- return container?.settings?.get(settingKey) ?? null;
175
- };
176
- var getElementSettings = (elementId, settingKey) => {
177
- return Object.fromEntries(settingKey.map((key) => [key, getElementSetting(elementId, key)]));
178
- };
179
-
180
- // src/hooks/use-element-setting.ts
181
- var useElementSetting = (elementId, settingKey) => {
182
- return (0, import_editor_v1_adapters4.__privateUseListenTo)(
183
- (0, import_editor_v1_adapters4.commandEndEvent)("document/elements/set-settings"),
184
- () => getElementSetting(elementId, settingKey),
185
- [elementId, settingKey]
186
- );
187
- };
188
- var useElementSettings = (elementId, settingKeys) => {
189
- return (0, import_editor_v1_adapters4.__privateUseListenTo)(
190
- (0, import_editor_v1_adapters4.commandEndEvent)("document/elements/set-settings"),
191
- () => settingKeys.reduce((settings, key) => {
192
- const value = getElementSetting(elementId, key);
193
- if (value !== null) {
194
- settings[key] = value;
195
- }
196
- return settings;
197
- }, {}),
198
- [elementId, settingKeys.join(",")]
199
- );
200
- };
201
-
202
167
  // src/hooks/use-parent-element.ts
203
- var import_editor_v1_adapters5 = require("@elementor/editor-v1-adapters");
168
+ var import_editor_v1_adapters4 = require("@elementor/editor-v1-adapters");
204
169
  function useParentElement(elementId) {
205
- return (0, import_editor_v1_adapters5.__privateUseListenTo)(
206
- [(0, import_editor_v1_adapters5.commandEndEvent)("document/elements/create")],
170
+ return (0, import_editor_v1_adapters4.__privateUseListenTo)(
171
+ [(0, import_editor_v1_adapters4.commandEndEvent)("document/elements/create")],
207
172
  () => {
208
173
  if (!elementId) {
209
174
  return null;
@@ -220,7 +185,7 @@ function useParentElement(elementId) {
220
185
  }
221
186
 
222
187
  // src/hooks/use-selected-element.ts
223
- var import_editor_v1_adapters6 = require("@elementor/editor-v1-adapters");
188
+ var import_editor_v1_adapters5 = require("@elementor/editor-v1-adapters");
224
189
 
225
190
  // src/sync/get-widgets-cache.ts
226
191
  function getWidgetsCache() {
@@ -267,24 +232,64 @@ function getSelectedElements() {
267
232
  return acc;
268
233
  }, []);
269
234
  }
235
+ function getSelectedElement() {
236
+ const elements = getSelectedElements();
237
+ const [element] = elements;
238
+ const elementType = getElementType(element?.type);
239
+ if (elements.length !== 1 || !elementType || !element) {
240
+ return { element: null, elementType: null };
241
+ }
242
+ return { element, elementType };
243
+ }
270
244
 
271
245
  // src/hooks/use-selected-element.ts
272
246
  function useSelectedElement() {
273
- const elements = (0, import_editor_v1_adapters6.__privateUseListenTo)(
247
+ return (0, import_editor_v1_adapters5.__privateUseListenTo)(
248
+ [
249
+ (0, import_editor_v1_adapters5.commandEndEvent)("document/elements/select"),
250
+ (0, import_editor_v1_adapters5.commandEndEvent)("document/elements/deselect"),
251
+ (0, import_editor_v1_adapters5.commandEndEvent)("document/elements/select-all"),
252
+ (0, import_editor_v1_adapters5.commandEndEvent)("document/elements/deselect-all")
253
+ ],
254
+ getSelectedElement
255
+ );
256
+ }
257
+
258
+ // src/hooks/use-selected-element-settings.ts
259
+ var import_editor_v1_adapters6 = require("@elementor/editor-v1-adapters");
260
+
261
+ // src/sync/get-element-setting.ts
262
+ var getElementSetting = (elementId, settingKey) => {
263
+ const container = getContainer(elementId);
264
+ return container?.settings?.get(settingKey) ?? null;
265
+ };
266
+ var getElementSettings = (elementId, settingKey) => {
267
+ return Object.fromEntries(settingKey.map((key) => [key, getElementSetting(elementId, key)]));
268
+ };
269
+
270
+ // src/hooks/use-selected-element-settings.ts
271
+ function useSelectedElementSettings() {
272
+ return (0, import_editor_v1_adapters6.__privateUseListenTo)(
274
273
  [
275
274
  (0, import_editor_v1_adapters6.commandEndEvent)("document/elements/select"),
276
275
  (0, import_editor_v1_adapters6.commandEndEvent)("document/elements/deselect"),
277
276
  (0, import_editor_v1_adapters6.commandEndEvent)("document/elements/select-all"),
278
- (0, import_editor_v1_adapters6.commandEndEvent)("document/elements/deselect-all")
277
+ (0, import_editor_v1_adapters6.commandEndEvent)("document/elements/deselect-all"),
278
+ (0, import_editor_v1_adapters6.commandEndEvent)("document/elements/set-settings")
279
279
  ],
280
- getSelectedElements
280
+ () => {
281
+ const { element, elementType } = getSelectedElement();
282
+ if (!element || !elementType) {
283
+ return { element: null, elementType: null, settings: null };
284
+ }
285
+ const settings = getElementSettings(element.id, Object.keys(elementType.propsSchema));
286
+ return {
287
+ element,
288
+ elementType,
289
+ settings
290
+ };
291
+ }
281
292
  );
282
- const [element] = elements;
283
- const elementType = getElementType(element?.type);
284
- if (elements.length !== 1 || !elementType) {
285
- return { element: null, elementType: null };
286
- }
287
- return { element, elementType };
288
293
  }
289
294
 
290
295
  // src/sync/create-element.ts
@@ -1191,9 +1196,8 @@ var playElementInteractions = (elementId, interactionId) => {
1191
1196
  useElementChildren,
1192
1197
  useElementEditorSettings,
1193
1198
  useElementInteractions,
1194
- useElementSetting,
1195
- useElementSettings,
1196
1199
  useParentElement,
1197
- useSelectedElement
1200
+ useSelectedElement,
1201
+ useSelectedElementSettings
1198
1202
  });
1199
1203
  //# sourceMappingURL=index.js.map