@elementor/editor-controls 4.0.0-669 → 4.0.0-671
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 +16 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/hooks/use-font-families.ts +22 -25
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.0.0-
|
|
4
|
+
"version": "4.0.0-671",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Elementor Team",
|
|
7
7
|
"homepage": "https://elementor.com/",
|
|
@@ -40,22 +40,22 @@
|
|
|
40
40
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@elementor/editor-current-user": "4.0.0-
|
|
44
|
-
"@elementor/editor-elements": "4.0.0-
|
|
45
|
-
"@elementor/editor-props": "4.0.0-
|
|
46
|
-
"@elementor/editor-responsive": "4.0.0-
|
|
47
|
-
"@elementor/editor-ui": "4.0.0-
|
|
48
|
-
"@elementor/editor-v1-adapters": "4.0.0-
|
|
49
|
-
"@elementor/env": "4.0.0-
|
|
50
|
-
"@elementor/http-client": "4.0.0-
|
|
43
|
+
"@elementor/editor-current-user": "4.0.0-671",
|
|
44
|
+
"@elementor/editor-elements": "4.0.0-671",
|
|
45
|
+
"@elementor/editor-props": "4.0.0-671",
|
|
46
|
+
"@elementor/editor-responsive": "4.0.0-671",
|
|
47
|
+
"@elementor/editor-ui": "4.0.0-671",
|
|
48
|
+
"@elementor/editor-v1-adapters": "4.0.0-671",
|
|
49
|
+
"@elementor/env": "4.0.0-671",
|
|
50
|
+
"@elementor/http-client": "4.0.0-671",
|
|
51
51
|
"@elementor/icons": "^1.68.0",
|
|
52
|
-
"@elementor/locations": "4.0.0-
|
|
53
|
-
"@elementor/events": "4.0.0-
|
|
54
|
-
"@elementor/query": "4.0.0-
|
|
55
|
-
"@elementor/session": "4.0.0-
|
|
52
|
+
"@elementor/locations": "4.0.0-671",
|
|
53
|
+
"@elementor/events": "4.0.0-671",
|
|
54
|
+
"@elementor/query": "4.0.0-671",
|
|
55
|
+
"@elementor/session": "4.0.0-671",
|
|
56
56
|
"@elementor/ui": "1.36.17",
|
|
57
|
-
"@elementor/utils": "4.0.0-
|
|
58
|
-
"@elementor/wp-media": "4.0.0-
|
|
57
|
+
"@elementor/utils": "4.0.0-671",
|
|
58
|
+
"@elementor/wp-media": "4.0.0-671",
|
|
59
59
|
"@wordpress/i18n": "^5.13.0",
|
|
60
60
|
"@monaco-editor/react": "^4.7.0",
|
|
61
61
|
"dayjs": "^1.11.18",
|
|
@@ -1,52 +1,49 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
|
-
import { getElementorConfig
|
|
3
|
-
import { __ } from '@wordpress/i18n';
|
|
2
|
+
import { getElementorConfig } from '@elementor/editor-v1-adapters';
|
|
4
3
|
|
|
5
4
|
import { type FontCategory } from '../controls/font-family-control/font-family-control';
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
googlefonts: __( 'Google Fonts', 'elementor' ),
|
|
6
|
+
type FontControlConfig = {
|
|
7
|
+
groups?: Record< string, string >;
|
|
8
|
+
options?: Record< string, string >;
|
|
11
9
|
};
|
|
12
10
|
|
|
13
|
-
const
|
|
11
|
+
const getFontControlConfig = (): FontControlConfig => {
|
|
14
12
|
const { controls } = getElementorConfig();
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if ( ! options ) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return options;
|
|
14
|
+
return controls?.font ?? {};
|
|
23
15
|
};
|
|
24
16
|
|
|
25
17
|
export const useFontFamilies = () => {
|
|
26
|
-
const
|
|
18
|
+
const { groups, options } = getFontControlConfig();
|
|
27
19
|
|
|
28
20
|
return useMemo( () => {
|
|
29
|
-
|
|
21
|
+
if ( ! groups || ! options ) {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const groupKeys = Object.keys( groups );
|
|
26
|
+
const groupIndexMap = new Map( groupKeys.map( ( key, index ) => [ key, index ] ) );
|
|
30
27
|
|
|
31
|
-
return Object.entries(
|
|
28
|
+
return Object.entries( options )
|
|
32
29
|
.reduce< FontCategory[] >( ( acc, [ font, category ] ) => {
|
|
33
|
-
|
|
30
|
+
const groupIndex = groupIndexMap.get( category );
|
|
31
|
+
|
|
32
|
+
if ( groupIndex === undefined ) {
|
|
34
33
|
return acc;
|
|
35
34
|
}
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
acc[ categoryIndex ] = {
|
|
41
|
-
label: supportedCategories[ category as SupportedFonts ],
|
|
36
|
+
if ( ! acc[ groupIndex ] ) {
|
|
37
|
+
acc[ groupIndex ] = {
|
|
38
|
+
label: groups[ category ],
|
|
42
39
|
fonts: [],
|
|
43
40
|
};
|
|
44
41
|
}
|
|
45
42
|
|
|
46
|
-
acc[
|
|
43
|
+
acc[ groupIndex ].fonts.push( font );
|
|
47
44
|
|
|
48
45
|
return acc;
|
|
49
46
|
}, [] )
|
|
50
47
|
.filter( Boolean );
|
|
51
|
-
}, [
|
|
48
|
+
}, [ groups, options ] );
|
|
52
49
|
};
|