@elementor/editor-components 3.35.0-485 → 3.35.0-487
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/dist/index.js +37 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +22 -22
- package/src/components/create-component-form/create-component-form.tsx +48 -13
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-
|
|
4
|
+
"version": "3.35.0-487",
|
|
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-
|
|
44
|
-
"@elementor/editor-canvas": "3.35.0-
|
|
45
|
-
"@elementor/editor-controls": "3.35.0-
|
|
46
|
-
"@elementor/editor-documents": "3.35.0-
|
|
47
|
-
"@elementor/editor-editing-panel": "3.35.0-
|
|
48
|
-
"@elementor/editor-elements": "3.35.0-
|
|
49
|
-
"@elementor/editor-elements-panel": "3.35.0-
|
|
50
|
-
"@elementor/editor-mcp": "3.35.0-
|
|
51
|
-
"@elementor/editor-panels": "3.35.0-
|
|
52
|
-
"@elementor/editor-props": "3.35.0-
|
|
53
|
-
"@elementor/editor-styles-repository": "3.35.0-
|
|
54
|
-
"@elementor/editor-ui": "3.35.0-
|
|
55
|
-
"@elementor/editor-v1-adapters": "3.35.0-
|
|
56
|
-
"@elementor/http-client": "3.35.0-
|
|
43
|
+
"@elementor/editor": "3.35.0-487",
|
|
44
|
+
"@elementor/editor-canvas": "3.35.0-487",
|
|
45
|
+
"@elementor/editor-controls": "3.35.0-487",
|
|
46
|
+
"@elementor/editor-documents": "3.35.0-487",
|
|
47
|
+
"@elementor/editor-editing-panel": "3.35.0-487",
|
|
48
|
+
"@elementor/editor-elements": "3.35.0-487",
|
|
49
|
+
"@elementor/editor-elements-panel": "3.35.0-487",
|
|
50
|
+
"@elementor/editor-mcp": "3.35.0-487",
|
|
51
|
+
"@elementor/editor-panels": "3.35.0-487",
|
|
52
|
+
"@elementor/editor-props": "3.35.0-487",
|
|
53
|
+
"@elementor/editor-styles-repository": "3.35.0-487",
|
|
54
|
+
"@elementor/editor-ui": "3.35.0-487",
|
|
55
|
+
"@elementor/editor-v1-adapters": "3.35.0-487",
|
|
56
|
+
"@elementor/http-client": "3.35.0-487",
|
|
57
57
|
"@elementor/icons": "^1.63.0",
|
|
58
|
-
"@elementor/mixpanel": "3.35.0-
|
|
59
|
-
"@elementor/query": "3.35.0-
|
|
60
|
-
"@elementor/schema": "3.35.0-
|
|
61
|
-
"@elementor/store": "3.35.0-
|
|
58
|
+
"@elementor/mixpanel": "3.35.0-487",
|
|
59
|
+
"@elementor/query": "3.35.0-487",
|
|
60
|
+
"@elementor/schema": "3.35.0-487",
|
|
61
|
+
"@elementor/store": "3.35.0-487",
|
|
62
62
|
"@elementor/ui": "1.36.17",
|
|
63
|
-
"@elementor/utils": "3.35.0-
|
|
63
|
+
"@elementor/utils": "3.35.0-487",
|
|
64
64
|
"@wordpress/i18n": "^5.13.0",
|
|
65
|
-
"@elementor/editor-notifications": "3.35.0-
|
|
66
|
-
"@elementor/editor-current-user": "3.35.0-
|
|
65
|
+
"@elementor/editor-notifications": "3.35.0-487",
|
|
66
|
+
"@elementor/editor-current-user": "3.35.0-487"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
69
|
"react": "^18.3.1",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import { getElementLabel, type V1ElementData } from '@elementor/editor-elements';
|
|
4
|
-
import { notify } from '@elementor/editor-notifications';
|
|
4
|
+
import { type NotificationData, notify } from '@elementor/editor-notifications';
|
|
5
5
|
import { Form as FormElement, ThemeProvider } from '@elementor/editor-ui';
|
|
6
6
|
import { ComponentsIcon } from '@elementor/icons';
|
|
7
7
|
import { __getState as getState } from '@elementor/store';
|
|
@@ -29,6 +29,8 @@ type SaveAsComponentEventData = {
|
|
|
29
29
|
options?: ContextMenuEventOptions;
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
+
const MAX_COMPONENTS = 100;
|
|
33
|
+
|
|
32
34
|
export function CreateComponentForm() {
|
|
33
35
|
const [ element, setElement ] = useState< {
|
|
34
36
|
element: V1ElementData;
|
|
@@ -36,6 +38,7 @@ export function CreateComponentForm() {
|
|
|
36
38
|
} | null >( null );
|
|
37
39
|
|
|
38
40
|
const [ anchorPosition, setAnchorPosition ] = useState< { top: number; left: number } >();
|
|
41
|
+
const { components } = useComponents();
|
|
39
42
|
|
|
40
43
|
const eventData = useRef< ComponentEventData | null >( null );
|
|
41
44
|
|
|
@@ -43,17 +46,10 @@ export function CreateComponentForm() {
|
|
|
43
46
|
const OPEN_SAVE_AS_COMPONENT_FORM_EVENT = 'elementor/editor/open-save-as-component-form';
|
|
44
47
|
|
|
45
48
|
const openPopup = ( event: CustomEvent< SaveAsComponentEventData > ) => {
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
if (
|
|
49
|
-
notify(
|
|
50
|
-
type: 'default',
|
|
51
|
-
message: __(
|
|
52
|
-
'Components require atomic elements only. Remove widgets to create this component.',
|
|
53
|
-
'elementor'
|
|
54
|
-
),
|
|
55
|
-
id: 'non-atomic-element-save-blocked',
|
|
56
|
-
} );
|
|
49
|
+
const { shouldOpen, notification } = shouldOpenForm( event.detail.element, components?.length ?? 0 );
|
|
50
|
+
|
|
51
|
+
if ( ! shouldOpen ) {
|
|
52
|
+
notify( notification );
|
|
57
53
|
return;
|
|
58
54
|
}
|
|
59
55
|
|
|
@@ -73,7 +69,7 @@ export function CreateComponentForm() {
|
|
|
73
69
|
return () => {
|
|
74
70
|
window.removeEventListener( OPEN_SAVE_AS_COMPONENT_FORM_EVENT, openPopup as EventListener );
|
|
75
71
|
};
|
|
76
|
-
}, [] );
|
|
72
|
+
}, [ components?.length ] );
|
|
77
73
|
|
|
78
74
|
const handleSave = async ( values: ComponentFormValues ) => {
|
|
79
75
|
try {
|
|
@@ -148,6 +144,45 @@ export function CreateComponentForm() {
|
|
|
148
144
|
);
|
|
149
145
|
}
|
|
150
146
|
|
|
147
|
+
type ShouldOpenFormResult =
|
|
148
|
+
| { shouldOpen: true; notification: null }
|
|
149
|
+
| { shouldOpen: false; notification: NotificationData };
|
|
150
|
+
|
|
151
|
+
function shouldOpenForm( element: V1ElementData, componentsCount: number ): ShouldOpenFormResult {
|
|
152
|
+
const nonAtomicElements = findNonAtomicElementsInElement( element );
|
|
153
|
+
|
|
154
|
+
if ( nonAtomicElements.length > 0 ) {
|
|
155
|
+
return {
|
|
156
|
+
shouldOpen: false,
|
|
157
|
+
notification: {
|
|
158
|
+
type: 'default',
|
|
159
|
+
message: __(
|
|
160
|
+
'Components require atomic elements only. Remove widgets to create this component.',
|
|
161
|
+
'elementor'
|
|
162
|
+
),
|
|
163
|
+
id: 'non-atomic-element-save-blocked',
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if ( componentsCount >= MAX_COMPONENTS ) {
|
|
169
|
+
return {
|
|
170
|
+
shouldOpen: false,
|
|
171
|
+
notification: {
|
|
172
|
+
type: 'default',
|
|
173
|
+
/* translators: %s is the maximum number of components */
|
|
174
|
+
message: __(
|
|
175
|
+
`You've reached the limit of %s components. Please remove an existing one to create a new component.`,
|
|
176
|
+
'elementor'
|
|
177
|
+
).replace( '%s', MAX_COMPONENTS.toString() ),
|
|
178
|
+
id: 'maximum-number-of-components-exceeded',
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return { shouldOpen: true, notification: null };
|
|
184
|
+
}
|
|
185
|
+
|
|
151
186
|
const FONT_SIZE = 'tiny';
|
|
152
187
|
|
|
153
188
|
const Form = ( {
|