@elementor/editor-interactions 4.0.0-591 → 4.0.0-598

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.
@@ -2,7 +2,6 @@ import { getCurrentDocumentId, getElementInteractions, getElements } from '@elem
2
2
  import { __privateListenTo as listenTo, windowEvent } from '@elementor/editor-v1-adapters';
3
3
 
4
4
  import { createInteractionsProvider } from '../utils/create-interactions-provider';
5
- import { normalizeInteractions } from './utils/normalize-interactions';
6
5
 
7
6
  export const ELEMENTS_INTERACTIONS_PROVIDER_KEY_PREFIX = 'document-elements-interactions-';
8
7
 
@@ -37,12 +36,10 @@ export const documentElementsInteractionsProvider = createInteractionsProvider(
37
36
  return filtered.map( ( element ) => {
38
37
  const interactions = getElementInteractions( element.id );
39
38
 
40
- const normalizedInteractions = normalizeInteractions( interactions );
41
-
42
39
  return {
43
40
  elementId: element.id,
44
41
  dataId: element.id,
45
- interactions: normalizedInteractions || { version: 1, items: [] },
42
+ interactions: interactions || { version: 1, items: [] },
46
43
  };
47
44
  } );
48
45
  },
@@ -1,65 +0,0 @@
1
- import { type Unit } from '@elementor/editor-controls';
2
- import { type ElementInteractions } from '@elementor/editor-elements';
3
- import {
4
- isTransformable,
5
- numberPropTypeUtil,
6
- type PropValue,
7
- type SizePropValue,
8
- type TransformablePropValue,
9
- } from '@elementor/editor-props';
10
-
11
- import { convertTimeUnit } from '../../utils/time-conversion';
12
-
13
- type Normalizer = ( value: TransformablePropValue< string > ) => PropValue;
14
-
15
- const FIELD_NORMALIZERS: Record< string, Normalizer > = {
16
- size: ( value ) => {
17
- const sizeProp = value as SizePropValue;
18
- const { size, unit } = sizeProp.value;
19
- const numberPropValue = convertTimeUnit( size as number, unit as Unit, 'ms' );
20
-
21
- return numberPropTypeUtil.create( numberPropValue );
22
- },
23
- };
24
-
25
- export const normalizeInteractions = ( interactions?: ElementInteractions ): ElementInteractions | undefined => {
26
- if ( ! interactions ) {
27
- return;
28
- }
29
-
30
- if ( interactions.items.length === 0 ) {
31
- return interactions;
32
- }
33
-
34
- return {
35
- ...interactions,
36
- items: interactions.items.map( normalizeNode ),
37
- } as ElementInteractions;
38
- };
39
-
40
- const normalizeNode = ( node: PropValue ): PropValue => {
41
- if ( Array.isArray( node ) ) {
42
- return node.map( normalizeNode );
43
- }
44
-
45
- if ( node !== null && typeof node === 'object' ) {
46
- if ( isTransformable( node ) && node.value !== undefined ) {
47
- const normalizer = FIELD_NORMALIZERS[ node.$$type ];
48
-
49
- if ( normalizer ) {
50
- return normalizer( node as TransformablePropValue< string > );
51
- }
52
- }
53
-
54
- const typedNode = node as Record< string, unknown >;
55
- const out: Record< string, PropValue > = {};
56
-
57
- for ( const k in typedNode ) {
58
- out[ k ] = normalizeNode( typedNode[ k ] as PropValue );
59
- }
60
-
61
- return out;
62
- }
63
-
64
- return node;
65
- };