@elementor/editor-canvas 3.35.0-470 → 3.35.0-471

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.
@@ -7,7 +7,11 @@ import {
7
7
  } from '@elementor/editor-elements';
8
8
  import { getPropSchemaFromCache, type PropValue, Schema, type TransformablePropValue } from '@elementor/editor-props';
9
9
  import { type CustomCss, getStylesSchema } from '@elementor/editor-styles';
10
+ import { type Utils as IUtils } from '@elementor/editor-variables';
11
+ import { type z } from '@elementor/schema';
10
12
 
13
+ // TODO: see https://elementor.atlassian.net/browse/ED-22513 for better cross-module access
14
+ type XElementor = z.infer< z.ZodAny >;
11
15
  type OwnParams = {
12
16
  elementId: string;
13
17
  elementType: string;
@@ -15,8 +19,14 @@ type OwnParams = {
15
19
  propertyValue: string | PropValue | TransformablePropValue< string, unknown >;
16
20
  };
17
21
 
18
- function resolvePropValue( value: unknown, forceKey?: string ): PropValue {
19
- return Schema.adjustLlmPropValueSchema( value as PropValue, { forceKey } );
22
+ export function resolvePropValue( value: unknown, forceKey?: string ): PropValue {
23
+ // TODO: see https://elementor.atlassian.net/browse/ED-22513 for better cross-module access
24
+ const Utils = ( ( ( window as XElementor ).elementorV2 as XElementor ).editorVariables as XElementor )
25
+ .Utils as typeof IUtils;
26
+ return Schema.adjustLlmPropValueSchema( value as PropValue, {
27
+ forceKey,
28
+ transformers: Utils.globalVariablesLLMResolvers,
29
+ } );
20
30
  }
21
31
 
22
32
  /*
@@ -25,7 +35,6 @@ function resolvePropValue( value: unknown, forceKey?: string ): PropValue {
25
35
  */
26
36
  export const doUpdateElementProperty = ( params: OwnParams ) => {
27
37
  const { elementId, propertyName, propertyValue, elementType } = params;
28
-
29
38
  if ( propertyName === '_styles' ) {
30
39
  const elementStyles = getElementStyles( elementId ) || {};
31
40
  const propertyMapValue = propertyValue as Record< string, PropValue >;
@@ -2,6 +2,8 @@ import { getWidgetsCache } from '@elementor/editor-elements';
2
2
  import { type PropsSchema, type PropValue, Schema } from '@elementor/editor-props';
3
3
  import { getStylesSchema } from '@elementor/editor-styles';
4
4
 
5
+ import { STYLE_SCHEMA_URI } from '../resources/widgets-schema-resource';
6
+
5
7
  let _widgetsSchema: Record< string, PropsSchema > | null = null;
6
8
 
7
9
  type ValidationResult = {
@@ -48,9 +50,14 @@ export const validateInput = {
48
50
  } else if ( ! Schema.isPropKeyConfigurable( propName ) ) {
49
51
  errors.push( `Property "${ propName }" is not configurable.` );
50
52
  } else {
51
- const { valid, jsonSchema } = Schema.validatePropValue( propSchema, propValue as PropValue );
53
+ const { valid } = Schema.validatePropValue( propSchema, propValue as PropValue );
52
54
  if ( ! valid ) {
53
- errors.push( `Invalid property "${ propName }". Expected schema: ${ jsonSchema }` );
55
+ errors.push(
56
+ `Invalid property "${ propName }". Validate input with resource [${ STYLE_SCHEMA_URI.replace(
57
+ '{category}',
58
+ propName
59
+ ) }]`
60
+ );
54
61
  }
55
62
  }
56
63
  } );