@elementor/editor-components 3.35.0-419 → 3.35.0-420

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": "3.35.0-419",
4
+ "version": "3.35.0-420",
5
5
  "private": false,
6
6
  "author": "Elementor Team",
7
7
  "homepage": "https://elementor.com/",
@@ -40,30 +40,30 @@
40
40
  "dev": "tsup --config=../../tsup.dev.ts"
41
41
  },
42
42
  "dependencies": {
43
- "@elementor/editor": "3.35.0-419",
44
- "@elementor/editor-canvas": "3.35.0-419",
45
- "@elementor/editor-controls": "3.35.0-419",
46
- "@elementor/editor-documents": "3.35.0-419",
47
- "@elementor/editor-editing-panel": "3.35.0-419",
48
- "@elementor/editor-elements": "3.35.0-419",
49
- "@elementor/editor-elements-panel": "3.35.0-419",
50
- "@elementor/editor-mcp": "3.35.0-419",
51
- "@elementor/editor-panels": "3.35.0-419",
52
- "@elementor/editor-props": "3.35.0-419",
53
- "@elementor/editor-styles-repository": "3.35.0-419",
54
- "@elementor/editor-ui": "3.35.0-419",
55
- "@elementor/editor-v1-adapters": "3.35.0-419",
56
- "@elementor/http-client": "3.35.0-419",
43
+ "@elementor/editor": "3.35.0-420",
44
+ "@elementor/editor-canvas": "3.35.0-420",
45
+ "@elementor/editor-controls": "3.35.0-420",
46
+ "@elementor/editor-documents": "3.35.0-420",
47
+ "@elementor/editor-editing-panel": "3.35.0-420",
48
+ "@elementor/editor-elements": "3.35.0-420",
49
+ "@elementor/editor-elements-panel": "3.35.0-420",
50
+ "@elementor/editor-mcp": "3.35.0-420",
51
+ "@elementor/editor-panels": "3.35.0-420",
52
+ "@elementor/editor-props": "3.35.0-420",
53
+ "@elementor/editor-styles-repository": "3.35.0-420",
54
+ "@elementor/editor-ui": "3.35.0-420",
55
+ "@elementor/editor-v1-adapters": "3.35.0-420",
56
+ "@elementor/http-client": "3.35.0-420",
57
57
  "@elementor/icons": "^1.63.0",
58
- "@elementor/mixpanel": "3.35.0-419",
59
- "@elementor/query": "3.35.0-419",
60
- "@elementor/schema": "3.35.0-419",
61
- "@elementor/store": "3.35.0-419",
58
+ "@elementor/mixpanel": "3.35.0-420",
59
+ "@elementor/query": "3.35.0-420",
60
+ "@elementor/schema": "3.35.0-420",
61
+ "@elementor/store": "3.35.0-420",
62
62
  "@elementor/ui": "1.36.17",
63
- "@elementor/utils": "3.35.0-419",
63
+ "@elementor/utils": "3.35.0-420",
64
64
  "@wordpress/i18n": "^5.13.0",
65
- "@elementor/editor-notifications": "3.35.0-419",
66
- "@elementor/editor-current-user": "3.35.0-419"
65
+ "@elementor/editor-notifications": "3.35.0-420",
66
+ "@elementor/editor-current-user": "3.35.0-420"
67
67
  },
68
68
  "peerDependencies": {
69
69
  "react": "^18.3.1",
@@ -4,13 +4,16 @@ import { getElementLabel, type V1ElementData } from '@elementor/editor-elements'
4
4
  import { notify } from '@elementor/editor-notifications';
5
5
  import { Form as FormElement, ThemeProvider } from '@elementor/editor-ui';
6
6
  import { StarIcon } from '@elementor/icons';
7
+ import { __getState as getState } from '@elementor/store';
7
8
  import { Alert, Button, FormLabel, Grid, Popover, Snackbar, Stack, TextField, Typography } from '@elementor/ui';
8
9
  import { __ } from '@wordpress/i18n';
9
10
 
10
11
  import { useComponents } from '../../hooks/use-components';
11
12
  import { findNonAtomicElementsInElement } from '../../prevent-non-atomic-nesting';
12
13
  import { createUnpublishedComponent } from '../../store/actions/create-unpublished-component';
13
- import { type ComponentFormValues } from '../../types';
14
+ import { selectComponentByUid } from '../../store/store';
15
+ import { type ComponentFormValues, type PublishedComponent } from '../../types';
16
+ import { switchToComponent } from '../../utils/switch-to-component';
14
17
  import { trackComponentEvent } from '../../utils/tracking';
15
18
  import { useForm } from './hooks/use-form';
16
19
  import { createBaseComponentSchema, createSubmitComponentSchema } from './utils/component-form-schema';
@@ -79,13 +82,25 @@ export function CreateComponentForm() {
79
82
  };
80
83
  }, [] );
81
84
 
82
- const handleSave = ( values: ComponentFormValues ) => {
85
+ const handleSave = async ( values: ComponentFormValues ) => {
83
86
  try {
84
87
  if ( ! element ) {
85
88
  throw new Error( `Can't save element as component: element not found` );
86
89
  }
87
90
 
88
- const uid = createUnpublishedComponent( values.componentName, element.element, eventData.current );
91
+ const { uid, instanceId } = await createUnpublishedComponent(
92
+ values.componentName,
93
+ element.element,
94
+ eventData.current
95
+ );
96
+
97
+ const publishedComponentId = ( selectComponentByUid( getState(), uid ) as PublishedComponent )?.id;
98
+
99
+ if ( publishedComponentId ) {
100
+ switchToComponent( publishedComponentId, instanceId );
101
+ } else {
102
+ throw new Error( 'Failed to find published component' );
103
+ }
89
104
 
90
105
  setResultNotification( {
91
106
  show: true,
@@ -9,8 +9,8 @@ type ComponentInstanceParams = {
9
9
  overridableProps?: OverridableProps;
10
10
  };
11
11
 
12
- export const replaceElementWithComponent = ( element: V1ElementData, component: ComponentInstanceParams ) => {
13
- replaceElement( {
12
+ export const replaceElementWithComponent = async ( element: V1ElementData, component: ComponentInstanceParams ) => {
13
+ return await replaceElement( {
14
14
  currentElement: element,
15
15
  newElement: createComponentModel( component ),
16
16
  withHistory: false,
@@ -9,7 +9,7 @@ import { type OverridableProps } from '../../types';
9
9
  import { trackComponentEvent } from '../../utils/tracking';
10
10
  import { slice } from '../store';
11
11
 
12
- export function createUnpublishedComponent(
12
+ export async function createUnpublishedComponent(
13
13
  name: string,
14
14
  element: V1ElementData,
15
15
  eventData: ComponentEventData | null,
@@ -28,7 +28,7 @@ export function createUnpublishedComponent(
28
28
 
29
29
  dispatch( slice.actions.addCreatedThisSession( generatedUid ) );
30
30
 
31
- replaceElementWithComponent( element, componentBase );
31
+ const componentInstance = await replaceElementWithComponent( element, componentBase );
32
32
 
33
33
  trackComponentEvent( {
34
34
  action: 'created',
@@ -37,7 +37,7 @@ export function createUnpublishedComponent(
37
37
  ...eventData,
38
38
  } );
39
39
 
40
- runCommand( 'document/save/auto' );
40
+ await runCommand( 'document/save/auto' );
41
41
 
42
- return generatedUid;
42
+ return { uid: generatedUid, instanceId: componentInstance.id };
43
43
  }