@elementor/editor-components 4.0.0-609 → 4.0.0-621

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-components",
3
3
  "description": "Elementor editor components",
4
- "version": "4.0.0-609",
4
+ "version": "4.0.0-621",
5
5
  "private": false,
6
6
  "author": "Elementor Team",
7
7
  "homepage": "https://elementor.com/",
@@ -40,31 +40,31 @@
40
40
  "dev": "tsup --config=../../tsup.dev.ts"
41
41
  },
42
42
  "dependencies": {
43
- "@elementor/editor": "4.0.0-609",
44
- "@elementor/editor-canvas": "4.0.0-609",
45
- "@elementor/editor-controls": "4.0.0-609",
46
- "@elementor/editor-documents": "4.0.0-609",
47
- "@elementor/editor-editing-panel": "4.0.0-609",
48
- "@elementor/editor-elements": "4.0.0-609",
49
- "@elementor/editor-elements-panel": "4.0.0-609",
50
- "@elementor/editor-mcp": "4.0.0-609",
51
- "@elementor/editor-templates": "4.0.0-609",
52
- "@elementor/editor-panels": "4.0.0-609",
53
- "@elementor/editor-props": "4.0.0-609",
54
- "@elementor/editor-styles-repository": "4.0.0-609",
55
- "@elementor/editor-ui": "4.0.0-609",
56
- "@elementor/editor-v1-adapters": "4.0.0-609",
57
- "@elementor/http-client": "4.0.0-609",
43
+ "@elementor/editor": "4.0.0-621",
44
+ "@elementor/editor-canvas": "4.0.0-621",
45
+ "@elementor/editor-controls": "4.0.0-621",
46
+ "@elementor/editor-documents": "4.0.0-621",
47
+ "@elementor/editor-editing-panel": "4.0.0-621",
48
+ "@elementor/editor-elements": "4.0.0-621",
49
+ "@elementor/editor-elements-panel": "4.0.0-621",
50
+ "@elementor/editor-mcp": "4.0.0-621",
51
+ "@elementor/editor-templates": "4.0.0-621",
52
+ "@elementor/editor-panels": "4.0.0-621",
53
+ "@elementor/editor-props": "4.0.0-621",
54
+ "@elementor/editor-styles-repository": "4.0.0-621",
55
+ "@elementor/editor-ui": "4.0.0-621",
56
+ "@elementor/editor-v1-adapters": "4.0.0-621",
57
+ "@elementor/http-client": "4.0.0-621",
58
58
  "@elementor/icons": "^1.68.0",
59
- "@elementor/events": "4.0.0-609",
60
- "@elementor/query": "4.0.0-609",
61
- "@elementor/schema": "4.0.0-609",
62
- "@elementor/store": "4.0.0-609",
59
+ "@elementor/events": "4.0.0-621",
60
+ "@elementor/query": "4.0.0-621",
61
+ "@elementor/schema": "4.0.0-621",
62
+ "@elementor/store": "4.0.0-621",
63
63
  "@elementor/ui": "1.36.17",
64
- "@elementor/utils": "4.0.0-609",
64
+ "@elementor/utils": "4.0.0-621",
65
65
  "@wordpress/i18n": "^5.13.0",
66
- "@elementor/editor-notifications": "4.0.0-609",
67
- "@elementor/editor-current-user": "4.0.0-609"
66
+ "@elementor/editor-notifications": "4.0.0-621",
67
+ "@elementor/editor-current-user": "4.0.0-621"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "react": "^18.3.1",
@@ -16,8 +16,8 @@ import {
16
16
  SettingsField,
17
17
  useElement,
18
18
  } from '@elementor/editor-editing-panel';
19
- import { type Control, getElementType } from '@elementor/editor-elements';
20
- import { type PropType, type PropValue } from '@elementor/editor-props';
19
+ import { type Control, getElementSettings, getElementType } from '@elementor/editor-elements';
20
+ import { type AnyTransformable, type PropType, type PropValue } from '@elementor/editor-props';
21
21
  import { Stack } from '@elementor/ui';
22
22
 
23
23
  import { useControlsByWidgetType } from '../../hooks/use-controls-by-widget-type';
@@ -189,6 +189,8 @@ function OverrideControl( { overridableProp }: InternalProps ) {
189
189
  return null;
190
190
  }
191
191
 
192
+ const settings = getElementSettings< AnyTransformable >( elementId, Object.keys( elementType.propsSchema ) );
193
+
192
194
  const propTypeSchema = createTopLevelObjectType( {
193
195
  schema: {
194
196
  [ overridableProp.overrideKey ]: propType,
@@ -200,7 +202,7 @@ function OverrideControl( { overridableProp }: InternalProps ) {
200
202
  value={ componentOverridablePropTypeUtil.extract( matchingOverride ) ?? undefined }
201
203
  componentInstanceElement={ componentInstanceElement }
202
204
  >
203
- <ElementProvider element={ { id: elementId, type } } elementType={ elementType }>
205
+ <ElementProvider element={ { id: elementId, type } } elementType={ elementType } settings={ settings }>
204
206
  <SettingsField bind={ propKey } propDisplayName={ overridableProp.label }>
205
207
  <PropProvider
206
208
  propType={ propTypeSchema }
@@ -1,12 +1,8 @@
1
1
  import { useElement } from '@elementor/editor-editing-panel';
2
- import { useElementSetting, useSelectedElement } from '@elementor/editor-elements';
3
2
 
4
3
  import { useSanitizeOverridableProps } from '../../hooks/use-sanitize-overridable-props';
5
4
  import { type ComponentInstanceOverridesPropValue } from '../../prop-types/component-instance-overrides-prop-type';
6
- import {
7
- componentInstancePropTypeUtil,
8
- type ComponentInstancePropValue,
9
- } from '../../prop-types/component-instance-prop-type';
5
+ import { componentInstancePropTypeUtil } from '../../prop-types/component-instance-prop-type';
10
6
  import { useComponent } from '../../store/store';
11
7
  import { type Component, type OverridablePropsGroup } from '../../types';
12
8
 
@@ -21,7 +17,7 @@ type InstancePanelData = {
21
17
  };
22
18
 
23
19
  export function useInstancePanelData(): InstancePanelData | null {
24
- const settings = useComponentInstanceSettings();
20
+ const { element, settings } = useComponentInstanceSettings();
25
21
 
26
22
  const componentId = settings?.component_id?.value;
27
23
 
@@ -29,7 +25,7 @@ export function useInstancePanelData(): InstancePanelData | null {
29
25
 
30
26
  const component = useComponent( componentId ?? null );
31
27
 
32
- const componentInstanceId = useSelectedElement()?.element?.id;
28
+ const componentInstanceId = element?.id;
33
29
 
34
30
  const overridableProps = useSanitizeOverridableProps( componentId ?? null, componentInstanceId );
35
31
 
@@ -49,9 +45,7 @@ export function useInstancePanelData(): InstancePanelData | null {
49
45
  }
50
46
 
51
47
  function useComponentInstanceSettings() {
52
- const { element } = useElement();
48
+ const { element, settings } = useElement();
53
49
 
54
- const settings = useElementSetting< ComponentInstancePropValue >( element.id, 'component_instance' );
55
-
56
- return componentInstancePropTypeUtil.extract( settings );
50
+ return { element, settings: componentInstancePropTypeUtil.extract( settings.component_instance ) };
57
51
  }
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  type BackboneModel,
3
3
  type BackboneModelConstructor,
4
+ type ContextMenuAction,
4
5
  type CreateTemplatedElementTypeOptions,
5
6
  createTemplatedElementView,
6
7
  type ElementModel,
@@ -13,6 +14,7 @@ import {
13
14
  import { getCurrentDocument } from '@elementor/editor-documents';
14
15
  import { type V1ElementData } from '@elementor/editor-elements';
15
16
  import { __getState as getState } from '@elementor/store';
17
+ import { hasProInstalled } from '@elementor/utils';
16
18
  import { __ } from '@wordpress/i18n';
17
19
 
18
20
  import { apiClient } from './api';
@@ -25,14 +27,6 @@ import { trackComponentEvent } from './utils/tracking';
25
27
 
26
28
  type ContextMenuEventData = { location: string; secondaryLocation: string; trigger: string };
27
29
 
28
- export type ContextMenuAction = {
29
- name: string;
30
- icon: string;
31
- title: string | ( () => string );
32
- isEnabled: () => boolean;
33
- callback: ( _: unknown, eventData: ContextMenuEventData ) => void;
34
- };
35
-
36
30
  type ContextMenuGroupConfig = {
37
31
  disable: Record< string, string[] >;
38
32
  add: Record< string, { index: number; action: ContextMenuAction } >;
@@ -58,6 +52,8 @@ type ComponentModelInstance = BackboneModel< ComponentModel > & {
58
52
 
59
53
  export const COMPONENT_WIDGET_TYPE = 'e-component';
60
54
 
55
+ const EDIT_COMPONENT_UPGRADE_URL = 'https://go.elementor.com/go-pro-components-edit/';
56
+
61
57
  const updateGroups = ( groups: ContextMenuGroup[], config: ContextMenuGroupConfig ): ContextMenuGroup[] => {
62
58
  const disableMap = new Map( Object.entries( config.disable ?? {} ) );
63
59
  const addMap = new Map( Object.entries( config.add ?? {} ) );
@@ -218,6 +214,11 @@ function createComponentView(
218
214
 
219
215
  _getContextMenuConfig() {
220
216
  const isAdministrator = isUserAdministrator();
217
+ const hasPro = hasProInstalled();
218
+
219
+ const proLabel = __( 'PRO', 'elementor' );
220
+ const badgeClass = 'elementor-context-menu-list__item__shortcut__new-badge';
221
+ const proBadge = `<a href="${ EDIT_COMPONENT_UPGRADE_URL }" target="_blank" onclick="event.stopPropagation()" class="${ badgeClass }">${ proLabel }</a>`;
221
222
 
222
223
  const addedGroup = {
223
224
  general: {
@@ -226,7 +227,8 @@ function createComponentView(
226
227
  name: 'edit component',
227
228
  icon: 'eicon-edit',
228
229
  title: () => __( 'Edit Component', 'elementor' ),
229
- isEnabled: () => true,
230
+ ...( ! hasPro && { shortcut: proBadge, hasShortcutAction: true } ),
231
+ isEnabled: () => hasPro,
230
232
  callback: ( _: unknown, eventData: ContextMenuEventData ) => this.editComponent( eventData ),
231
233
  },
232
234
  },
@@ -253,7 +255,9 @@ function createComponentView(
253
255
  }
254
256
 
255
257
  editComponent( { trigger, location, secondaryLocation }: ContextMenuEventData ) {
256
- if ( this.isComponentCurrentlyEdited() ) {
258
+ const hasPro = hasProInstalled();
259
+
260
+ if ( ! hasPro || this.isComponentCurrentlyEdited() ) {
257
261
  return;
258
262
  }
259
263
 
@@ -275,9 +279,7 @@ function createComponentView(
275
279
  handleDblClick( e: MouseEvent ) {
276
280
  e.stopPropagation();
277
281
 
278
- const isAdministrator = isUserAdministrator();
279
-
280
- if ( ! isAdministrator ) {
282
+ if ( ! isUserAdministrator() || ! hasProInstalled() ) {
281
283
  return;
282
284
  }
283
285
 
@@ -1,6 +1,5 @@
1
1
  import * as React from 'react';
2
- import { ElementProvider, usePanelActions as useEditingPanelActions } from '@elementor/editor-editing-panel';
3
- import { useSelectedElement } from '@elementor/editor-elements';
2
+ import { usePanelActions as useEditingPanelActions } from '@elementor/editor-editing-panel';
4
3
  import { __createPanel as createPanel, Panel } from '@elementor/editor-panels';
5
4
  import { ThemeProvider } from '@elementor/editor-ui';
6
5
  import { Alert, Box, ErrorBoundary } from '@elementor/ui';
@@ -16,27 +15,20 @@ export const { panel, usePanelActions } = createPanel( {
16
15
  } );
17
16
 
18
17
  function ComponentPropertiesPanel() {
19
- const { element, elementType } = useSelectedElement();
20
18
  const { close: closePanel } = usePanelActions();
21
19
  const { open: openEditingPanel } = useEditingPanelActions();
22
20
 
23
- if ( ! element || ! elementType ) {
24
- return null;
25
- }
26
-
27
21
  return (
28
22
  <ThemeProvider>
29
23
  <ErrorBoundary fallback={ <ErrorBoundaryFallback /> }>
30
- <ElementProvider element={ element } elementType={ elementType }>
31
- <Panel>
32
- <ComponentPropertiesPanelContent
33
- onClose={ () => {
34
- closePanel();
35
- openEditingPanel();
36
- } }
37
- />
38
- </Panel>
39
- </ElementProvider>
24
+ <Panel>
25
+ <ComponentPropertiesPanelContent
26
+ onClose={ () => {
27
+ closePanel();
28
+ openEditingPanel();
29
+ } }
30
+ />
31
+ </Panel>
40
32
  </ErrorBoundary>
41
33
  </ThemeProvider>
42
34
  );
@@ -1,26 +0,0 @@
1
- type ExtendedWindow = Window & {
2
- elementor?: {
3
- helpers?: {
4
- hasPro?: () => boolean;
5
- };
6
- };
7
- elementorPro?: {
8
- config?: {
9
- isActive?: boolean;
10
- };
11
- };
12
- };
13
-
14
- export function isProUser(): boolean {
15
- const extendedWindow = window as unknown as ExtendedWindow;
16
-
17
- const hasPro = extendedWindow.elementor?.helpers?.hasPro?.() ?? false;
18
-
19
- if ( ! hasPro ) {
20
- return false;
21
- }
22
-
23
- const isProActive = extendedWindow.elementorPro?.config?.isActive ?? false;
24
-
25
- return isProActive;
26
- }