@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.js
CHANGED
|
@@ -4713,33 +4713,39 @@ var LinkControl = createControl((props) => {
|
|
|
4713
4713
|
(0, import_editor_elements2.getLinkInLinkRestriction)(elementId, value ?? linkPlaceholder)
|
|
4714
4714
|
);
|
|
4715
4715
|
const shouldDisableAddingLink = !isActive && linkInLinkRestriction.shouldRestrict;
|
|
4716
|
-
const
|
|
4716
|
+
const syncLinkRestriction = (clearActiveLinkWhen = "restricted") => {
|
|
4717
4717
|
const newRestriction = (0, import_editor_elements2.getLinkInLinkRestriction)(elementId, value ?? linkPlaceholder);
|
|
4718
|
-
|
|
4718
|
+
const becameRestricted = newRestriction.shouldRestrict && !linkInLinkRestriction.shouldRestrict;
|
|
4719
|
+
const shouldClearActiveLink = clearActiveLinkWhen === "newly-restricted" ? becameRestricted : newRestriction.shouldRestrict;
|
|
4720
|
+
if (shouldClearActiveLink && isActive && !linkPlaceholder) {
|
|
4719
4721
|
setIsActive(false);
|
|
4720
4722
|
if (value !== null) {
|
|
4721
4723
|
setValue(null);
|
|
4722
4724
|
}
|
|
4723
4725
|
}
|
|
4724
4726
|
setLinkInLinkRestriction((prev) => isSameRestriction(prev, newRestriction) ? prev : newRestriction);
|
|
4725
|
-
}
|
|
4727
|
+
};
|
|
4728
|
+
const debouncedSyncLinkRestriction = (0, import_utils5.useDebouncedCallback)(
|
|
4729
|
+
(clearActiveLinkWhen = "restricted") => syncLinkRestriction(clearActiveLinkWhen),
|
|
4730
|
+
300
|
|
4731
|
+
);
|
|
4726
4732
|
(0, import_editor_v1_adapters.__privateUseListenTo)(
|
|
4727
4733
|
(0, import_editor_v1_adapters.commandEndEvent)("document/elements/set-settings"),
|
|
4728
4734
|
() => {
|
|
4729
|
-
|
|
4735
|
+
debouncedSyncLinkRestriction("newly-restricted");
|
|
4730
4736
|
},
|
|
4731
|
-
[
|
|
4737
|
+
[debouncedSyncLinkRestriction]
|
|
4732
4738
|
);
|
|
4733
4739
|
(0, import_react43.useEffect)(() => {
|
|
4734
|
-
|
|
4740
|
+
debouncedSyncLinkRestriction();
|
|
4735
4741
|
const handleInlineLinkChanged = () => {
|
|
4736
|
-
|
|
4742
|
+
debouncedSyncLinkRestriction();
|
|
4737
4743
|
};
|
|
4738
4744
|
window.addEventListener("elementor:inline-link-changed", handleInlineLinkChanged);
|
|
4739
4745
|
return () => {
|
|
4740
4746
|
window.removeEventListener("elementor:inline-link-changed", handleInlineLinkChanged);
|
|
4741
4747
|
};
|
|
4742
|
-
}, [elementId,
|
|
4748
|
+
}, [elementId, debouncedSyncLinkRestriction]);
|
|
4743
4749
|
const onEnabledChange = () => {
|
|
4744
4750
|
setLinkInLinkRestriction((0, import_editor_elements2.getLinkInLinkRestriction)(elementId, value ?? linkPlaceholder));
|
|
4745
4751
|
if (linkInLinkRestriction.shouldRestrict && !isActive) {
|