@elementor/editor-controls 4.4.0-1096 → 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/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-1096",
4
+ "version": "4.4.0-1097",
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-1096",
44
- "@elementor/editor-elements": "4.4.0-1096",
45
- "@elementor/editor-props": "4.4.0-1096",
46
- "@elementor/editor-responsive": "4.4.0-1096",
47
- "@elementor/editor-ui": "4.4.0-1096",
48
- "@elementor/editor-v1-adapters": "4.4.0-1096",
49
- "@elementor/env": "4.4.0-1096",
50
- "@elementor/events": "4.4.0-1096",
51
- "@elementor/http-client": "4.4.0-1096",
43
+ "@elementor/editor-current-user": "4.4.0-1097",
44
+ "@elementor/editor-elements": "4.4.0-1097",
45
+ "@elementor/editor-props": "4.4.0-1097",
46
+ "@elementor/editor-responsive": "4.4.0-1097",
47
+ "@elementor/editor-ui": "4.4.0-1097",
48
+ "@elementor/editor-v1-adapters": "4.4.0-1097",
49
+ "@elementor/env": "4.4.0-1097",
50
+ "@elementor/events": "4.4.0-1097",
51
+ "@elementor/http-client": "4.4.0-1097",
52
52
  "@elementor/icons": "~1.75.1",
53
- "@elementor/locations": "4.4.0-1096",
54
- "@elementor/query": "4.4.0-1096",
55
- "@elementor/schema": "4.4.0-1096",
56
- "@elementor/session": "4.4.0-1096",
53
+ "@elementor/locations": "4.4.0-1097",
54
+ "@elementor/query": "4.4.0-1097",
55
+ "@elementor/schema": "4.4.0-1097",
56
+ "@elementor/session": "4.4.0-1097",
57
57
  "@elementor/ui": "1.37.5",
58
- "@elementor/utils": "4.4.0-1096",
59
- "@elementor/wp-media": "4.4.0-1096",
58
+ "@elementor/utils": "4.4.0-1097",
59
+ "@elementor/wp-media": "4.4.0-1097",
60
60
  "@monaco-editor/react": "^4.7.0",
61
61
  "@tanstack/react-virtual": "^3.13.3",
62
62
  "@tiptap/extension-bold": "^3.11.1",
@@ -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 debouncedCheckRestriction = useDebouncedCallback( () => {
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 ( newRestriction.shouldRestrict && isActive && ! linkPlaceholder ) {
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
- }, 300 );
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
- debouncedCheckRestriction();
93
+ debouncedSyncLinkRestriction( 'newly-restricted' );
84
94
  },
85
- [ debouncedCheckRestriction ]
95
+ [ debouncedSyncLinkRestriction ]
86
96
  );
87
97
 
88
98
  useEffect( () => {
89
- debouncedCheckRestriction();
99
+ debouncedSyncLinkRestriction();
90
100
 
91
101
  const handleInlineLinkChanged = () => {
92
- debouncedCheckRestriction();
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, debouncedCheckRestriction ] );
110
+ }, [ elementId, debouncedSyncLinkRestriction ] );
101
111
 
102
112
  const onEnabledChange = () => {
103
113
  setLinkInLinkRestriction( getLinkInLinkRestriction( elementId, value ?? linkPlaceholder ) );