@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/dist/index.js +14 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +16 -16
- package/src/controls/link-control.tsx +18 -8
package/dist/index.mjs
CHANGED
|
@@ -4633,33 +4633,39 @@ var LinkControl = createControl((props) => {
|
|
|
4633
4633
|
getLinkInLinkRestriction(elementId, value ?? linkPlaceholder)
|
|
4634
4634
|
);
|
|
4635
4635
|
const shouldDisableAddingLink = !isActive && linkInLinkRestriction.shouldRestrict;
|
|
4636
|
-
const
|
|
4636
|
+
const syncLinkRestriction = (clearActiveLinkWhen = "restricted") => {
|
|
4637
4637
|
const newRestriction = getLinkInLinkRestriction(elementId, value ?? linkPlaceholder);
|
|
4638
|
-
|
|
4638
|
+
const becameRestricted = newRestriction.shouldRestrict && !linkInLinkRestriction.shouldRestrict;
|
|
4639
|
+
const shouldClearActiveLink = clearActiveLinkWhen === "newly-restricted" ? becameRestricted : newRestriction.shouldRestrict;
|
|
4640
|
+
if (shouldClearActiveLink && isActive && !linkPlaceholder) {
|
|
4639
4641
|
setIsActive(false);
|
|
4640
4642
|
if (value !== null) {
|
|
4641
4643
|
setValue(null);
|
|
4642
4644
|
}
|
|
4643
4645
|
}
|
|
4644
4646
|
setLinkInLinkRestriction((prev) => isSameRestriction(prev, newRestriction) ? prev : newRestriction);
|
|
4645
|
-
}
|
|
4647
|
+
};
|
|
4648
|
+
const debouncedSyncLinkRestriction = useDebouncedCallback(
|
|
4649
|
+
(clearActiveLinkWhen = "restricted") => syncLinkRestriction(clearActiveLinkWhen),
|
|
4650
|
+
300
|
|
4651
|
+
);
|
|
4646
4652
|
useListenTo(
|
|
4647
4653
|
commandEndEvent("document/elements/set-settings"),
|
|
4648
4654
|
() => {
|
|
4649
|
-
|
|
4655
|
+
debouncedSyncLinkRestriction("newly-restricted");
|
|
4650
4656
|
},
|
|
4651
|
-
[
|
|
4657
|
+
[debouncedSyncLinkRestriction]
|
|
4652
4658
|
);
|
|
4653
4659
|
useEffect14(() => {
|
|
4654
|
-
|
|
4660
|
+
debouncedSyncLinkRestriction();
|
|
4655
4661
|
const handleInlineLinkChanged = () => {
|
|
4656
|
-
|
|
4662
|
+
debouncedSyncLinkRestriction();
|
|
4657
4663
|
};
|
|
4658
4664
|
window.addEventListener("elementor:inline-link-changed", handleInlineLinkChanged);
|
|
4659
4665
|
return () => {
|
|
4660
4666
|
window.removeEventListener("elementor:inline-link-changed", handleInlineLinkChanged);
|
|
4661
4667
|
};
|
|
4662
|
-
}, [elementId,
|
|
4668
|
+
}, [elementId, debouncedSyncLinkRestriction]);
|
|
4663
4669
|
const onEnabledChange = () => {
|
|
4664
4670
|
setLinkInLinkRestriction(getLinkInLinkRestriction(elementId, value ?? linkPlaceholder));
|
|
4665
4671
|
if (linkInLinkRestriction.shouldRestrict && !isActive) {
|