@elementor/editor-controls 3.35.0-428 → 3.35.0-430
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.d.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +46 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +69 -27
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/components/inline-editor-toolbar.tsx +26 -2
- package/src/components/inline-editor.tsx +5 -1
- package/src/controls/link-control.tsx +35 -1
package/dist/index.d.mts
CHANGED
|
@@ -3,6 +3,7 @@ import { RefObject, ReactNode, FC, PropsWithChildren, ComponentProps, ReactEleme
|
|
|
3
3
|
import { SxProps, SelectProps, UnstableColorFieldProps, ToggleButtonProps, StackProps, PopupState, Theme, FormLabelProps, Grid } from '@elementor/ui';
|
|
4
4
|
import { StringPropValue, PropTypeUtil, PropValue, PropKey, LinkPropValue, TransformablePropValue, PropType, CreateOptions } from '@elementor/editor-props';
|
|
5
5
|
import { StyleDefinitionState } from '@elementor/editor-styles';
|
|
6
|
+
import { ElementID } from '@elementor/editor-elements';
|
|
6
7
|
import { Editor } from '@tiptap/react';
|
|
7
8
|
import * as _elementor_locations from '@elementor/locations';
|
|
8
9
|
|
|
@@ -564,13 +565,15 @@ type InlineEditorProps = {
|
|
|
564
565
|
top: number;
|
|
565
566
|
};
|
|
566
567
|
expectedTag?: string | null;
|
|
568
|
+
elementId?: ElementID;
|
|
567
569
|
};
|
|
568
570
|
declare const InlineEditor: React$1.ForwardRefExoticComponent<InlineEditorProps & React$1.RefAttributes<unknown>>;
|
|
569
571
|
|
|
570
572
|
type InlineEditorToolbarProps = {
|
|
571
573
|
editor: Editor;
|
|
574
|
+
elementId?: ElementID;
|
|
572
575
|
};
|
|
573
|
-
declare const InlineEditorToolbar: ({ editor }: InlineEditorToolbarProps) => React$1.JSX.Element;
|
|
576
|
+
declare const InlineEditorToolbar: ({ editor, elementId }: InlineEditorToolbarProps) => React$1.JSX.Element;
|
|
574
577
|
|
|
575
578
|
type AnyComponentType = ComponentType<any>;
|
|
576
579
|
declare const brandSymbol: unique symbol;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { RefObject, ReactNode, FC, PropsWithChildren, ComponentProps, ReactEleme
|
|
|
3
3
|
import { SxProps, SelectProps, UnstableColorFieldProps, ToggleButtonProps, StackProps, PopupState, Theme, FormLabelProps, Grid } from '@elementor/ui';
|
|
4
4
|
import { StringPropValue, PropTypeUtil, PropValue, PropKey, LinkPropValue, TransformablePropValue, PropType, CreateOptions } from '@elementor/editor-props';
|
|
5
5
|
import { StyleDefinitionState } from '@elementor/editor-styles';
|
|
6
|
+
import { ElementID } from '@elementor/editor-elements';
|
|
6
7
|
import { Editor } from '@tiptap/react';
|
|
7
8
|
import * as _elementor_locations from '@elementor/locations';
|
|
8
9
|
|
|
@@ -564,13 +565,15 @@ type InlineEditorProps = {
|
|
|
564
565
|
top: number;
|
|
565
566
|
};
|
|
566
567
|
expectedTag?: string | null;
|
|
568
|
+
elementId?: ElementID;
|
|
567
569
|
};
|
|
568
570
|
declare const InlineEditor: React$1.ForwardRefExoticComponent<InlineEditorProps & React$1.RefAttributes<unknown>>;
|
|
569
571
|
|
|
570
572
|
type InlineEditorToolbarProps = {
|
|
571
573
|
editor: Editor;
|
|
574
|
+
elementId?: ElementID;
|
|
572
575
|
};
|
|
573
|
-
declare const InlineEditorToolbar: ({ editor }: InlineEditorToolbarProps) => React$1.JSX.Element;
|
|
576
|
+
declare const InlineEditorToolbar: ({ editor, elementId }: InlineEditorToolbarProps) => React$1.JSX.Element;
|
|
574
577
|
|
|
575
578
|
type AnyComponentType = ComponentType<any>;
|
|
576
579
|
declare const brandSymbol: unique symbol;
|
package/dist/index.js
CHANGED
|
@@ -3154,6 +3154,7 @@ var import_editor_props23 = require("@elementor/editor-props");
|
|
|
3154
3154
|
var import_icons15 = require("@elementor/icons");
|
|
3155
3155
|
var import_session = require("@elementor/session");
|
|
3156
3156
|
var import_ui49 = require("@elementor/ui");
|
|
3157
|
+
var import_utils5 = require("@elementor/utils");
|
|
3157
3158
|
var import_i18n23 = require("@wordpress/i18n");
|
|
3158
3159
|
|
|
3159
3160
|
// src/components/restricted-link-infotip.tsx
|
|
@@ -3498,6 +3499,30 @@ var LinkControl = createControl((props) => {
|
|
|
3498
3499
|
} = props || {};
|
|
3499
3500
|
const [linkInLinkRestriction, setLinkInLinkRestriction] = (0, import_react33.useState)((0, import_editor_elements2.getLinkInLinkRestriction)(elementId));
|
|
3500
3501
|
const shouldDisableAddingLink = !isActive && linkInLinkRestriction.shouldRestrict;
|
|
3502
|
+
const debouncedCheckRestriction = (0, import_react33.useMemo)(
|
|
3503
|
+
() => (0, import_utils5.debounce)(() => {
|
|
3504
|
+
const newRestriction = (0, import_editor_elements2.getLinkInLinkRestriction)(elementId);
|
|
3505
|
+
if (newRestriction.shouldRestrict && isActive) {
|
|
3506
|
+
setIsActive(false);
|
|
3507
|
+
}
|
|
3508
|
+
setLinkInLinkRestriction(newRestriction);
|
|
3509
|
+
}, 300),
|
|
3510
|
+
[elementId, isActive]
|
|
3511
|
+
);
|
|
3512
|
+
(0, import_react33.useEffect)(() => {
|
|
3513
|
+
debouncedCheckRestriction();
|
|
3514
|
+
const handleInlineLinkChanged = (event) => {
|
|
3515
|
+
const customEvent = event;
|
|
3516
|
+
if (customEvent.detail.elementId === elementId) {
|
|
3517
|
+
debouncedCheckRestriction();
|
|
3518
|
+
}
|
|
3519
|
+
};
|
|
3520
|
+
window.addEventListener("elementor:inline-link-changed", handleInlineLinkChanged);
|
|
3521
|
+
return () => {
|
|
3522
|
+
window.removeEventListener("elementor:inline-link-changed", handleInlineLinkChanged);
|
|
3523
|
+
debouncedCheckRestriction.cancel();
|
|
3524
|
+
};
|
|
3525
|
+
}, [elementId, debouncedCheckRestriction]);
|
|
3501
3526
|
const onEnabledChange = () => {
|
|
3502
3527
|
setLinkInLinkRestriction((0, import_editor_elements2.getLinkInLinkRestriction)(elementId));
|
|
3503
3528
|
if (linkInLinkRestriction.shouldRestrict && !isActive) {
|
|
@@ -5958,6 +5983,7 @@ function isEmpty(value = "") {
|
|
|
5958
5983
|
// src/components/inline-editor-toolbar.tsx
|
|
5959
5984
|
var React100 = __toESM(require("react"));
|
|
5960
5985
|
var import_react53 = require("react");
|
|
5986
|
+
var import_editor_elements5 = require("@elementor/editor-elements");
|
|
5961
5987
|
var import_icons34 = require("@elementor/icons");
|
|
5962
5988
|
var import_ui86 = require("@elementor/ui");
|
|
5963
5989
|
var import_react54 = require("@tiptap/react");
|
|
@@ -6028,6 +6054,7 @@ var UrlPopover = ({
|
|
|
6028
6054
|
};
|
|
6029
6055
|
|
|
6030
6056
|
// src/components/inline-editor-toolbar.tsx
|
|
6057
|
+
var checkIfElementHasLink = (elementId) => !!(0, import_editor_elements5.getElementSetting)(elementId, "link")?.value?.destination;
|
|
6031
6058
|
var toolbarButtons = {
|
|
6032
6059
|
clear: {
|
|
6033
6060
|
label: (0, import_i18n51.__)("Clear", "elementor"),
|
|
@@ -6094,16 +6121,23 @@ var toolbarButtons = {
|
|
|
6094
6121
|
};
|
|
6095
6122
|
var { clear: clearButton, ...formatButtons } = toolbarButtons;
|
|
6096
6123
|
var possibleFormats = Object.keys(formatButtons);
|
|
6097
|
-
var InlineEditorToolbar = ({ editor }) => {
|
|
6124
|
+
var InlineEditorToolbar = ({ editor, elementId }) => {
|
|
6098
6125
|
const [urlValue, setUrlValue] = (0, import_react53.useState)("");
|
|
6099
6126
|
const [openInNewTab, setOpenInNewTab] = (0, import_react53.useState)(false);
|
|
6100
6127
|
const toolbarRef = (0, import_react53.useRef)(null);
|
|
6101
6128
|
const linkPopupState = (0, import_ui86.usePopupState)({ variant: "popover" });
|
|
6129
|
+
const hasLinkOnElement = elementId ? checkIfElementHasLink(elementId) : false;
|
|
6102
6130
|
const editorState = (0, import_react54.useEditorState)({
|
|
6103
6131
|
editor,
|
|
6104
6132
|
selector: (ctx) => possibleFormats.filter((format) => ctx.editor.isActive(format))
|
|
6105
6133
|
});
|
|
6106
|
-
const formatButtonsList = (0, import_react53.useMemo)(() =>
|
|
6134
|
+
const formatButtonsList = (0, import_react53.useMemo)(() => {
|
|
6135
|
+
const buttons = Object.values(formatButtons);
|
|
6136
|
+
if (hasLinkOnElement) {
|
|
6137
|
+
return buttons.filter((button) => button.action !== "link");
|
|
6138
|
+
}
|
|
6139
|
+
return buttons;
|
|
6140
|
+
}, [hasLinkOnElement]);
|
|
6107
6141
|
const handleLinkClick = () => {
|
|
6108
6142
|
const linkAttrs = editor.getAttributes("link");
|
|
6109
6143
|
setUrlValue(linkAttrs.href || "");
|
|
@@ -6125,6 +6159,13 @@ var InlineEditorToolbar = ({ editor }) => {
|
|
|
6125
6159
|
} else {
|
|
6126
6160
|
editor.chain().focus().unsetLink().run();
|
|
6127
6161
|
}
|
|
6162
|
+
if (elementId) {
|
|
6163
|
+
window.dispatchEvent(
|
|
6164
|
+
new CustomEvent("elementor:inline-link-changed", {
|
|
6165
|
+
detail: { elementId }
|
|
6166
|
+
})
|
|
6167
|
+
);
|
|
6168
|
+
}
|
|
6128
6169
|
linkPopupState.close();
|
|
6129
6170
|
};
|
|
6130
6171
|
React100.useEffect(() => {
|
|
@@ -6254,7 +6295,8 @@ var InlineEditor = (0, import_react55.forwardRef)(
|
|
|
6254
6295
|
sx = {},
|
|
6255
6296
|
onBlur = void 0,
|
|
6256
6297
|
getInitialPopoverPosition = void 0,
|
|
6257
|
-
expectedTag = null
|
|
6298
|
+
expectedTag = null,
|
|
6299
|
+
elementId = void 0
|
|
6258
6300
|
}, ref) => {
|
|
6259
6301
|
const containerRef = (0, import_react55.useRef)(null);
|
|
6260
6302
|
const popupState = (0, import_ui87.usePopupState)({ variant: "popover", disableAutoFocus: true });
|
|
@@ -6388,7 +6430,7 @@ var InlineEditor = (0, import_react55.forwardRef)(
|
|
|
6388
6430
|
anchorOrigin: { vertical: "top", horizontal: "center" },
|
|
6389
6431
|
transformOrigin: { vertical: "bottom", horizontal: "center" }
|
|
6390
6432
|
},
|
|
6391
|
-
/* @__PURE__ */ React101.createElement(InlineEditorToolbar, { editor })
|
|
6433
|
+
/* @__PURE__ */ React101.createElement(InlineEditorToolbar, { editor, elementId })
|
|
6392
6434
|
));
|
|
6393
6435
|
}
|
|
6394
6436
|
);
|