@elementor/editor-controls 4.2.0-886 → 4.2.0-887
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 +44 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +83 -59
- package/dist/index.mjs.map +1 -1
- package/package.json +16 -16
- package/src/components/restricted-link-infotip.tsx +35 -9
- package/src/controls/link-control.tsx +28 -20
package/dist/index.js
CHANGED
|
@@ -4276,6 +4276,7 @@ var React73 = __toESM(require("react"));
|
|
|
4276
4276
|
var import_react43 = require("react");
|
|
4277
4277
|
var import_editor_elements2 = require("@elementor/editor-elements");
|
|
4278
4278
|
var import_editor_props28 = require("@elementor/editor-props");
|
|
4279
|
+
var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
|
|
4279
4280
|
var import_icons17 = require("@elementor/icons");
|
|
4280
4281
|
var import_session = require("@elementor/session");
|
|
4281
4282
|
var import_ui55 = require("@elementor/ui");
|
|
@@ -4302,12 +4303,25 @@ var INFOTIP_CONTENT = {
|
|
|
4302
4303
|
"elementor"
|
|
4303
4304
|
)
|
|
4304
4305
|
};
|
|
4306
|
+
function isTargetInCurrentDocument(elementId) {
|
|
4307
|
+
if (!elementId) {
|
|
4308
|
+
return false;
|
|
4309
|
+
}
|
|
4310
|
+
const el = (0, import_editor_elements.getContainer)(elementId)?.view?.el;
|
|
4311
|
+
if (!el) {
|
|
4312
|
+
return false;
|
|
4313
|
+
}
|
|
4314
|
+
const targetDocId = el.closest("[data-elementor-id]")?.getAttribute("data-elementor-id");
|
|
4315
|
+
const currentDocId = String((0, import_editor_elements.getCurrentDocumentId)() ?? "");
|
|
4316
|
+
return !!(targetDocId && currentDocId && targetDocId === currentDocId);
|
|
4317
|
+
}
|
|
4305
4318
|
var RestrictedLinkInfotip = ({
|
|
4306
4319
|
linkInLinkRestriction,
|
|
4307
4320
|
isVisible,
|
|
4308
4321
|
children
|
|
4309
4322
|
}) => {
|
|
4310
4323
|
const { shouldRestrict, reason, elementId } = linkInLinkRestriction;
|
|
4324
|
+
const showTakeMeThereCta = !!(elementId && isTargetInCurrentDocument(elementId));
|
|
4311
4325
|
const handleTakeMeClick = () => {
|
|
4312
4326
|
if (elementId) {
|
|
4313
4327
|
(0, import_editor_elements.selectElement)(elementId);
|
|
@@ -4319,7 +4333,7 @@ var RestrictedLinkInfotip = ({
|
|
|
4319
4333
|
color: "secondary",
|
|
4320
4334
|
icon: /* @__PURE__ */ React69.createElement(import_icons14.InfoCircleFilledIcon, null),
|
|
4321
4335
|
size: "small",
|
|
4322
|
-
action: /* @__PURE__ */ React69.createElement(
|
|
4336
|
+
action: showTakeMeThereCta ? /* @__PURE__ */ React69.createElement(
|
|
4323
4337
|
import_ui52.AlertAction,
|
|
4324
4338
|
{
|
|
4325
4339
|
sx: { width: "fit-content" },
|
|
@@ -4328,7 +4342,7 @@ var RestrictedLinkInfotip = ({
|
|
|
4328
4342
|
onClick: handleTakeMeClick
|
|
4329
4343
|
},
|
|
4330
4344
|
(0, import_i18n23.__)("Take me there", "elementor")
|
|
4331
|
-
)
|
|
4345
|
+
) : void 0
|
|
4332
4346
|
},
|
|
4333
4347
|
/* @__PURE__ */ React69.createElement(import_ui52.AlertTitle, null, (0, import_i18n23.__)("Nested links", "elementor")),
|
|
4334
4348
|
/* @__PURE__ */ React69.createElement(import_ui52.Box, { component: "span" }, INFOTIP_CONTENT[reason ?? "descendant"], " ", /* @__PURE__ */ React69.createElement(import_ui52.Link, { href: learnMoreButton.href, target: "_blank", color: "info.main" }, learnMoreButton.label))
|
|
@@ -4654,28 +4668,31 @@ var LinkControl = createControl((props) => {
|
|
|
4654
4668
|
(0, import_editor_elements2.getLinkInLinkRestriction)(elementId, value ?? linkPlaceholder)
|
|
4655
4669
|
);
|
|
4656
4670
|
const shouldDisableAddingLink = !isActive && linkInLinkRestriction.shouldRestrict;
|
|
4657
|
-
const debouncedCheckRestriction = (0,
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4671
|
+
const debouncedCheckRestriction = (0, import_utils5.useDebouncedCallback)(() => {
|
|
4672
|
+
const newRestriction = (0, import_editor_elements2.getLinkInLinkRestriction)(elementId, value ?? linkPlaceholder);
|
|
4673
|
+
if (newRestriction.shouldRestrict && isActive && !linkPlaceholder) {
|
|
4674
|
+
setIsActive(false);
|
|
4675
|
+
if (value !== null) {
|
|
4676
|
+
setValue(null);
|
|
4662
4677
|
}
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4678
|
+
}
|
|
4679
|
+
setLinkInLinkRestriction((prev) => isSameRestriction(prev, newRestriction) ? prev : newRestriction);
|
|
4680
|
+
}, 300);
|
|
4681
|
+
(0, import_editor_v1_adapters.__privateUseListenTo)(
|
|
4682
|
+
(0, import_editor_v1_adapters.commandEndEvent)("document/elements/set-settings"),
|
|
4683
|
+
() => {
|
|
4684
|
+
debouncedCheckRestriction();
|
|
4685
|
+
},
|
|
4686
|
+
[debouncedCheckRestriction]
|
|
4666
4687
|
);
|
|
4667
4688
|
(0, import_react43.useEffect)(() => {
|
|
4668
4689
|
debouncedCheckRestriction();
|
|
4669
|
-
const handleInlineLinkChanged = (
|
|
4670
|
-
|
|
4671
|
-
if (customEvent.detail.elementId === elementId) {
|
|
4672
|
-
debouncedCheckRestriction();
|
|
4673
|
-
}
|
|
4690
|
+
const handleInlineLinkChanged = () => {
|
|
4691
|
+
debouncedCheckRestriction();
|
|
4674
4692
|
};
|
|
4675
4693
|
window.addEventListener("elementor:inline-link-changed", handleInlineLinkChanged);
|
|
4676
4694
|
return () => {
|
|
4677
4695
|
window.removeEventListener("elementor:inline-link-changed", handleInlineLinkChanged);
|
|
4678
|
-
debouncedCheckRestriction.cancel();
|
|
4679
4696
|
};
|
|
4680
4697
|
}, [elementId, debouncedCheckRestriction]);
|
|
4681
4698
|
const onEnabledChange = () => {
|
|
@@ -4736,6 +4753,9 @@ var LinkControl = createControl((props) => {
|
|
|
4736
4753
|
}
|
|
4737
4754
|
)), /* @__PURE__ */ React73.createElement(PropKeyProvider, { bind: "isTargetBlank" }, /* @__PURE__ */ React73.createElement(import_ui55.Grid, { container: true, alignItems: "center", flexWrap: "nowrap", justifyContent: "space-between" }, /* @__PURE__ */ React73.createElement(import_ui55.Grid, { item: true }, /* @__PURE__ */ React73.createElement(ControlFormLabel, null, (0, import_i18n25.__)("Open in a new tab", "elementor"))), /* @__PURE__ */ React73.createElement(import_ui55.Grid, { item: true, sx: { marginInlineEnd: -1 } }, /* @__PURE__ */ React73.createElement(SwitchControl, null))))))));
|
|
4738
4755
|
});
|
|
4756
|
+
function isSameRestriction(a, b) {
|
|
4757
|
+
return a.shouldRestrict === b.shouldRestrict && a.reason === b.reason && a.elementId === b.elementId;
|
|
4758
|
+
}
|
|
4739
4759
|
|
|
4740
4760
|
// src/controls/html-tag-control.tsx
|
|
4741
4761
|
var React75 = __toESM(require("react"));
|
|
@@ -8176,7 +8196,7 @@ var import_i18n57 = require("@wordpress/i18n");
|
|
|
8176
8196
|
// src/hooks/use-form-field-suggestions.ts
|
|
8177
8197
|
var import_editor_elements7 = require("@elementor/editor-elements");
|
|
8178
8198
|
var import_editor_props64 = require("@elementor/editor-props");
|
|
8179
|
-
var
|
|
8199
|
+
var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
|
|
8180
8200
|
var FORM_FIELD_WIDGET_TYPES = [
|
|
8181
8201
|
"e-form-input",
|
|
8182
8202
|
"e-form-textarea",
|
|
@@ -8187,12 +8207,12 @@ var FORM_FIELD_WIDGET_TYPES = [
|
|
|
8187
8207
|
"e-form-time-picker"
|
|
8188
8208
|
];
|
|
8189
8209
|
function useFormFieldSuggestions(options) {
|
|
8190
|
-
return (0,
|
|
8210
|
+
return (0, import_editor_v1_adapters2.__privateUseListenTo)(
|
|
8191
8211
|
[
|
|
8192
|
-
(0,
|
|
8193
|
-
(0,
|
|
8194
|
-
(0,
|
|
8195
|
-
(0,
|
|
8212
|
+
(0, import_editor_v1_adapters2.v1ReadyEvent)(),
|
|
8213
|
+
(0, import_editor_v1_adapters2.commandEndEvent)("document/elements/create"),
|
|
8214
|
+
(0, import_editor_v1_adapters2.commandEndEvent)("document/elements/delete"),
|
|
8215
|
+
(0, import_editor_v1_adapters2.commandEndEvent)("document/elements/set-settings")
|
|
8196
8216
|
],
|
|
8197
8217
|
() => {
|
|
8198
8218
|
const selectedElements = (0, import_editor_elements7.getSelectedElements)();
|
|
@@ -9239,9 +9259,9 @@ var hasValue = (value) => {
|
|
|
9239
9259
|
|
|
9240
9260
|
// src/hooks/use-font-families.ts
|
|
9241
9261
|
var import_react79 = require("react");
|
|
9242
|
-
var
|
|
9262
|
+
var import_editor_v1_adapters3 = require("@elementor/editor-v1-adapters");
|
|
9243
9263
|
var getFontControlConfig = () => {
|
|
9244
|
-
const { controls } = (0,
|
|
9264
|
+
const { controls } = (0, import_editor_v1_adapters3.getElementorConfig)();
|
|
9245
9265
|
return controls?.font ?? {};
|
|
9246
9266
|
};
|
|
9247
9267
|
var useFontFamilies = () => {
|