@elementor/editor-controls 4.4.0-1136 → 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/dist/index.d.mts +29 -3
- package/dist/index.d.ts +29 -3
- package/dist/index.js +167 -709
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +89 -633
- package/dist/index.mjs.map +1 -1
- package/package.json +16 -16
- package/src/controls/icon-library/icon-library-popover.tsx +4 -4
- package/src/controls/icon-library/icon-library-providers.ts +61 -0
- package/src/controls/svg-media-control.tsx +17 -7
- package/src/controls/svg-media-preview.tsx +5 -4
- package/src/index.ts +8 -1
- package/src/controls/icon-library/custom-icon-libraries.ts +0 -556
- package/src/controls/icon-library/fontello-svg-font.ts +0 -227
- package/src/controls/icon-library/icomoon-selection.ts +0 -104
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-
|
|
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-
|
|
44
|
-
"@elementor/editor-elements": "4.4.0-
|
|
45
|
-
"@elementor/editor-props": "4.4.0-
|
|
46
|
-
"@elementor/editor-responsive": "4.4.0-
|
|
47
|
-
"@elementor/editor-ui": "4.4.0-
|
|
48
|
-
"@elementor/editor-v1-adapters": "4.4.0-
|
|
49
|
-
"@elementor/env": "4.4.0-
|
|
50
|
-
"@elementor/events": "4.4.0-
|
|
51
|
-
"@elementor/http-client": "4.4.0-
|
|
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-
|
|
54
|
-
"@elementor/query": "4.4.0-
|
|
55
|
-
"@elementor/schema": "4.4.0-
|
|
56
|
-
"@elementor/session": "4.4.0-
|
|
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-
|
|
59
|
-
"@elementor/wp-media": "4.4.0-
|
|
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",
|
|
@@ -14,7 +14,6 @@ import { Box, CircularProgress, Divider, Link, Stack, styled, Typography } from
|
|
|
14
14
|
import { useDebounceState } from '@elementor/utils';
|
|
15
15
|
import { __ } from '@wordpress/i18n';
|
|
16
16
|
|
|
17
|
-
import { useCustomIconLibraries } from './custom-icon-libraries';
|
|
18
17
|
import {
|
|
19
18
|
createIconSelectionValue,
|
|
20
19
|
filterFontAwesome7Icons,
|
|
@@ -25,6 +24,7 @@ import {
|
|
|
25
24
|
import { FontAwesomeGlyph } from './font-awesome-glyph';
|
|
26
25
|
import { IconLibraryFilter } from './icon-library-filter';
|
|
27
26
|
import { IconLibraryGrid } from './icon-library-grid';
|
|
27
|
+
import { useIconLibraryProviderIcons } from './icon-library-providers';
|
|
28
28
|
import { type IconLibraryView, IconLibraryViewToggle } from './icon-library-view-toggle';
|
|
29
29
|
import { SvgElementIcon } from './svg-element-icon';
|
|
30
30
|
import { useFontAwesome7Catalog } from './use-font-awesome-7-catalog';
|
|
@@ -85,9 +85,9 @@ export const IconLibraryPopover = ( {
|
|
|
85
85
|
);
|
|
86
86
|
const view = isIconLibraryView( storedView ) ? storedView : DEFAULT_ICON_LIBRARY_VIEW;
|
|
87
87
|
const { data: fontAwesomeIcons = [], isLoading: isFontAwesomeLoading } = useFontAwesome7Catalog( open );
|
|
88
|
-
const { data:
|
|
89
|
-
const isLoading = isFontAwesomeLoading ||
|
|
90
|
-
const icons = useMemo( () => [ ...fontAwesomeIcons, ...
|
|
88
|
+
const { data: providerIcons = [], isLoading: isProviderLoading } = useIconLibraryProviderIcons( open );
|
|
89
|
+
const isLoading = isFontAwesomeLoading || isProviderLoading;
|
|
90
|
+
const icons = useMemo( () => [ ...fontAwesomeIcons, ...providerIcons ], [ providerIcons, fontAwesomeIcons ] );
|
|
91
91
|
|
|
92
92
|
const items = useMemo(
|
|
93
93
|
() => createIconLibraryItems( icons, searchValue, activeLibraries ),
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import { type FontAwesome7Icon } from './font-awesome-7-catalog';
|
|
4
|
+
|
|
5
|
+
export type IconLibraryProviderState = {
|
|
6
|
+
data?: FontAwesome7Icon[];
|
|
7
|
+
isLoading: boolean;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type IconLibraryProvider = {
|
|
11
|
+
id: string;
|
|
12
|
+
useIcons: ( enabled: boolean ) => IconLibraryProviderState;
|
|
13
|
+
resolveSvg?: ( library: string, iconValue: string, signal?: AbortSignal ) => Promise< string | null >;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const providers = new Map< string, IconLibraryProvider >();
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Register before the icon picker mounts. Each picker instance snapshots the providers on mount,
|
|
20
|
+
* so its hook count stays constant; a provider registered later appears on the next mount.
|
|
21
|
+
* @param provider
|
|
22
|
+
*/
|
|
23
|
+
export function registerIconLibraryProvider( provider: IconLibraryProvider ) {
|
|
24
|
+
providers.set( provider.id, provider );
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function unregisterIconLibraryProvider( id: string ) {
|
|
28
|
+
providers.delete( id );
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function useIconLibraryProviderIcons( enabled: boolean ): Required< IconLibraryProviderState > {
|
|
32
|
+
const [ snapshot ] = useState( () => [ ...providers.values() ] );
|
|
33
|
+
const states = snapshot.map( ( provider ) => provider.useIcons( enabled ) );
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
data: states.flatMap( ( state ) => state.data ?? [] ),
|
|
37
|
+
isLoading: states.some( ( state ) => state.isLoading ),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export async function resolveProviderIconSvg(
|
|
42
|
+
library: string,
|
|
43
|
+
iconValue: string,
|
|
44
|
+
signal?: AbortSignal
|
|
45
|
+
): Promise< string | null > {
|
|
46
|
+
for ( const provider of providers.values() ) {
|
|
47
|
+
try {
|
|
48
|
+
const markup = await provider.resolveSvg?.( library, iconValue, signal );
|
|
49
|
+
|
|
50
|
+
if ( markup ) {
|
|
51
|
+
return markup;
|
|
52
|
+
}
|
|
53
|
+
} catch ( error ) {
|
|
54
|
+
if ( signal?.aborted ) {
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
@@ -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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
|
83
|
+
showIconLibrary && typeof previewIconValue?.value?.value === 'string' ? previewIconValue.value.value : null;
|
|
74
84
|
const selectedIconLibrary =
|
|
75
|
-
showIconLibrary && typeof
|
|
85
|
+
showIconLibrary && typeof previewIconValue?.library?.value === 'string' ? previewIconValue.library.value : null;
|
|
76
86
|
|
|
77
87
|
const { open } = useWpMediaFrame( {
|
|
78
88
|
mediaTypes: [ 'svg' ],
|
|
@@ -2,9 +2,9 @@ import * as React from 'react';
|
|
|
2
2
|
import { Box, CardMedia, CircularProgress } from '@elementor/ui';
|
|
3
3
|
import { __ } from '@wordpress/i18n';
|
|
4
4
|
|
|
5
|
-
import { useCustomIconLibraries } from './icon-library/custom-icon-libraries';
|
|
6
5
|
import { findFontAwesome7Icon, type FontAwesome7Icon } from './icon-library/font-awesome-7-catalog';
|
|
7
6
|
import { FontAwesomeGlyph } from './icon-library/font-awesome-glyph';
|
|
7
|
+
import { useIconLibraryProviderIcons } from './icon-library/icon-library-providers';
|
|
8
8
|
import { useFontAwesome7Catalog } from './icon-library/use-font-awesome-7-catalog';
|
|
9
9
|
|
|
10
10
|
const ICON_PREVIEW_SIZE = 50;
|
|
@@ -21,10 +21,11 @@ export const SvgMediaPreview = ( { isFetching, src, iconClassName, iconLibrary }
|
|
|
21
21
|
const shouldLoadIconCatalog = Boolean( iconClassName && iconLibrary );
|
|
22
22
|
const { data: fontAwesomeIcons = [], isLoading: isFontAwesomeLoading } =
|
|
23
23
|
useFontAwesome7Catalog( shouldLoadIconCatalog );
|
|
24
|
-
const { data:
|
|
25
|
-
|
|
24
|
+
const { data: providerIcons = [], isLoading: isProviderLoading } =
|
|
25
|
+
useIconLibraryProviderIcons( shouldLoadIconCatalog );
|
|
26
|
+
const icons = [ ...fontAwesomeIcons, ...providerIcons ];
|
|
26
27
|
const selectedIcon = findFontAwesome7Icon( icons, iconClassName, iconLibrary );
|
|
27
|
-
const isLoadingCatalog = shouldLoadIconCatalog && ( isFontAwesomeLoading ||
|
|
28
|
+
const isLoadingCatalog = shouldLoadIconCatalog && ( isFontAwesomeLoading || isProviderLoading );
|
|
28
29
|
|
|
29
30
|
if ( isFetching || isLoadingCatalog ) {
|
|
30
31
|
return <CircularProgress role="progressbar" />;
|
package/src/index.ts
CHANGED
|
@@ -37,7 +37,14 @@ export { TransformSettingsControl } from './controls/transform-control/transform
|
|
|
37
37
|
export { TransitionRepeaterControl } from './controls/transition-control/transition-repeater-control';
|
|
38
38
|
export { PopoverContent } from './components/popover-content';
|
|
39
39
|
export { enqueueFont } from './controls/font-family-control/enqueue-font';
|
|
40
|
-
export {
|
|
40
|
+
export {
|
|
41
|
+
registerIconLibraryProvider,
|
|
42
|
+
resolveProviderIconSvg,
|
|
43
|
+
unregisterIconLibraryProvider,
|
|
44
|
+
type IconLibraryProvider,
|
|
45
|
+
} from './controls/icon-library/icon-library-providers';
|
|
46
|
+
export { enqueueIconFonts } from './controls/open-icon-library';
|
|
47
|
+
export { type FontAwesome7Icon } from './controls/icon-library/font-awesome-7-catalog';
|
|
41
48
|
export {
|
|
42
49
|
getFontAwesome7IconName,
|
|
43
50
|
resetFontAwesome7IconsCache,
|