@elementor/editor-controls 4.4.0-1137 → 4.4.0-1138

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@elementor/editor-controls",
3
3
  "description": "This package contains the controls model and utils for the Elementor editor",
4
- "version": "4.4.0-1137",
4
+ "version": "4.4.0-1138",
5
5
  "private": false,
6
6
  "author": "Elementor Team",
7
7
  "homepage": "https://elementor.com/",
@@ -40,23 +40,23 @@
40
40
  "dev": "tsup --config=../../tsup.dev.ts"
41
41
  },
42
42
  "dependencies": {
43
- "@elementor/editor-current-user": "4.4.0-1137",
44
- "@elementor/editor-elements": "4.4.0-1137",
45
- "@elementor/editor-props": "4.4.0-1137",
46
- "@elementor/editor-responsive": "4.4.0-1137",
47
- "@elementor/editor-ui": "4.4.0-1137",
48
- "@elementor/editor-v1-adapters": "4.4.0-1137",
49
- "@elementor/env": "4.4.0-1137",
50
- "@elementor/events": "4.4.0-1137",
51
- "@elementor/http-client": "4.4.0-1137",
43
+ "@elementor/editor-current-user": "4.4.0-1138",
44
+ "@elementor/editor-elements": "4.4.0-1138",
45
+ "@elementor/editor-props": "4.4.0-1138",
46
+ "@elementor/editor-responsive": "4.4.0-1138",
47
+ "@elementor/editor-ui": "4.4.0-1138",
48
+ "@elementor/editor-v1-adapters": "4.4.0-1138",
49
+ "@elementor/env": "4.4.0-1138",
50
+ "@elementor/events": "4.4.0-1138",
51
+ "@elementor/http-client": "4.4.0-1138",
52
52
  "@elementor/icons": "~1.78.1",
53
- "@elementor/locations": "4.4.0-1137",
54
- "@elementor/query": "4.4.0-1137",
55
- "@elementor/schema": "4.4.0-1137",
56
- "@elementor/session": "4.4.0-1137",
53
+ "@elementor/locations": "4.4.0-1138",
54
+ "@elementor/query": "4.4.0-1138",
55
+ "@elementor/schema": "4.4.0-1138",
56
+ "@elementor/session": "4.4.0-1138",
57
57
  "@elementor/ui": "1.41.3",
58
- "@elementor/utils": "4.4.0-1137",
59
- "@elementor/wp-media": "4.4.0-1137",
58
+ "@elementor/utils": "4.4.0-1138",
59
+ "@elementor/wp-media": "4.4.0-1138",
60
60
  "@monaco-editor/react": "^4.7.0",
61
61
  "@tanstack/react-virtual": "^3.13.3",
62
62
  "@tiptap/extension-bold": "^3.11.1",
@@ -56,12 +56,22 @@ type SvgMediaControlProps = {
56
56
 
57
57
  export const SvgMediaControl = createControl( ( { showIconLibrary = false, label }: SvgMediaControlProps ) => {
58
58
  const groupLabel = label ?? __( 'SVG', 'elementor' );
59
- const { value: svgValue, setValue: setSvgValue } = useBoundProp( svgSrcPropTypeUtil );
60
- const { value: iconValue, setValue: setIconValue } = useBoundProp( iconPropTypeUtil );
59
+ const { value: svgValue, setValue: setSvgValue, placeholder: svgPlaceholder } = useBoundProp( svgSrcPropTypeUtil );
60
+ const { value: iconValue, setValue: setIconValue, placeholder: iconPlaceholder } = useBoundProp( iconPropTypeUtil );
61
61
  const id = svgValue?.id;
62
- const url = svgValue?.url;
63
- const { data: attachment, isFetching } = useWpMediaAttachment( id?.value || null );
64
- const src = attachment?.url ?? url?.value ?? null;
62
+
63
+ // Preview only: when there's no own value of either type (e.g. a component instance with no
64
+ // override yet), fall back to the bound placeholder (the inherited/origin value) so the preview
65
+ // isn't broken. If there IS an own value, use it as-is — even if it's only one of the two types —
66
+ // so we never mix an own value with an unrelated inherited placeholder. This never affects what
67
+ // setValue writes.
68
+ const hasOwnValue =
69
+ ( svgValue !== null && svgValue !== undefined ) || ( iconValue !== null && iconValue !== undefined );
70
+ const previewSvgValue = hasOwnValue ? svgValue : svgPlaceholder;
71
+ const previewIconValue = hasOwnValue ? iconValue : iconPlaceholder;
72
+
73
+ const { data: attachment, isFetching } = useWpMediaAttachment( previewSvgValue?.id?.value || null );
74
+ const src = attachment?.url ?? previewSvgValue?.url?.value ?? null;
65
75
  const { data: allowSvgUpload } = useUnfilteredFilesUpload();
66
76
  const [ unfilteredModalOpenState, setUnfilteredModalOpenState ] = useState( false );
67
77
  const iconLibraryPopoverState = usePopupState( { variant: 'popover' } );
@@ -70,9 +80,9 @@ export const SvgMediaControl = createControl( ( { showIconLibrary = false, label
70
80
  const [ iconLibraryAnchor, setIconLibraryAnchor ] = useState< IconLibraryAnchor | null >( null );
71
81
  const { isAdmin } = useCurrentUserCapabilities();
72
82
  const selectedIconClass =
73
- showIconLibrary && typeof iconValue?.value?.value === 'string' ? iconValue.value.value : null;
83
+ showIconLibrary && typeof previewIconValue?.value?.value === 'string' ? previewIconValue.value.value : null;
74
84
  const selectedIconLibrary =
75
- showIconLibrary && typeof iconValue?.library?.value === 'string' ? iconValue.library.value : null;
85
+ showIconLibrary && typeof previewIconValue?.library?.value === 'string' ? previewIconValue.library.value : null;
76
86
 
77
87
  const { open } = useWpMediaFrame( {
78
88
  mediaTypes: [ 'svg' ],