@elementor/editor-controls 4.4.0-1095 → 4.4.0-1097
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 +1249 -833
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1134 -708
- package/dist/index.mjs.map +1 -1
- package/package.json +17 -16
- package/src/controls/icon-library/icon-library-filter.tsx +9 -2
- package/src/controls/icon-library/icon-library-grid.tsx +344 -0
- package/src/controls/icon-library/icon-library-popover.tsx +43 -8
- package/src/controls/icon-library/icon-library-tooltip.ts +1 -0
- package/src/controls/icon-library/icon-library-view-toggle.tsx +104 -0
- package/src/controls/link-control.tsx +18 -8
|
@@ -39,6 +39,8 @@ type LinkSessionValue = {
|
|
|
39
39
|
|
|
40
40
|
export type DestinationProp = LinkPropValue[ 'value' ][ 'destination' ];
|
|
41
41
|
|
|
42
|
+
type ClearActiveLinkWhen = 'restricted' | 'newly-restricted';
|
|
43
|
+
|
|
42
44
|
const SIZE = 'tiny';
|
|
43
45
|
|
|
44
46
|
export const LinkControl = createControl( ( props: Props ) => {
|
|
@@ -63,10 +65,13 @@ export const LinkControl = createControl( ( props: Props ) => {
|
|
|
63
65
|
|
|
64
66
|
const shouldDisableAddingLink = ! isActive && linkInLinkRestriction.shouldRestrict;
|
|
65
67
|
|
|
66
|
-
const
|
|
68
|
+
const syncLinkRestriction = ( clearActiveLinkWhen: ClearActiveLinkWhen = 'restricted' ) => {
|
|
67
69
|
const newRestriction = getLinkInLinkRestriction( elementId, value ?? linkPlaceholder );
|
|
70
|
+
const becameRestricted = newRestriction.shouldRestrict && ! linkInLinkRestriction.shouldRestrict;
|
|
71
|
+
const shouldClearActiveLink =
|
|
72
|
+
clearActiveLinkWhen === 'newly-restricted' ? becameRestricted : newRestriction.shouldRestrict;
|
|
68
73
|
|
|
69
|
-
if (
|
|
74
|
+
if ( shouldClearActiveLink && isActive && ! linkPlaceholder ) {
|
|
70
75
|
setIsActive( false );
|
|
71
76
|
|
|
72
77
|
if ( value !== null ) {
|
|
@@ -75,21 +80,26 @@ export const LinkControl = createControl( ( props: Props ) => {
|
|
|
75
80
|
}
|
|
76
81
|
|
|
77
82
|
setLinkInLinkRestriction( ( prev ) => ( isSameRestriction( prev, newRestriction ) ? prev : newRestriction ) );
|
|
78
|
-
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const debouncedSyncLinkRestriction = useDebouncedCallback(
|
|
86
|
+
( clearActiveLinkWhen: ClearActiveLinkWhen = 'restricted' ) => syncLinkRestriction( clearActiveLinkWhen ),
|
|
87
|
+
300
|
|
88
|
+
);
|
|
79
89
|
|
|
80
90
|
useListenTo(
|
|
81
91
|
commandEndEvent( 'document/elements/set-settings' ),
|
|
82
92
|
() => {
|
|
83
|
-
|
|
93
|
+
debouncedSyncLinkRestriction( 'newly-restricted' );
|
|
84
94
|
},
|
|
85
|
-
[
|
|
95
|
+
[ debouncedSyncLinkRestriction ]
|
|
86
96
|
);
|
|
87
97
|
|
|
88
98
|
useEffect( () => {
|
|
89
|
-
|
|
99
|
+
debouncedSyncLinkRestriction();
|
|
90
100
|
|
|
91
101
|
const handleInlineLinkChanged = () => {
|
|
92
|
-
|
|
102
|
+
debouncedSyncLinkRestriction();
|
|
93
103
|
};
|
|
94
104
|
|
|
95
105
|
window.addEventListener( 'elementor:inline-link-changed', handleInlineLinkChanged );
|
|
@@ -97,7 +107,7 @@ export const LinkControl = createControl( ( props: Props ) => {
|
|
|
97
107
|
return () => {
|
|
98
108
|
window.removeEventListener( 'elementor:inline-link-changed', handleInlineLinkChanged );
|
|
99
109
|
};
|
|
100
|
-
}, [ elementId,
|
|
110
|
+
}, [ elementId, debouncedSyncLinkRestriction ] );
|
|
101
111
|
|
|
102
112
|
const onEnabledChange = () => {
|
|
103
113
|
setLinkInLinkRestriction( getLinkInLinkRestriction( elementId, value ?? linkPlaceholder ) );
|