@elementor/editor-controls 4.1.0-797 → 4.1.0-799
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 +51 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +59 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/controls/email-form-action-control.tsx +21 -1
- package/src/controls/image-media-control.tsx +11 -1
- package/src/controls/mention-text-area-control.tsx +32 -11
- package/src/hooks/use-form-field-suggestions.ts +14 -1
package/dist/index.d.mts
CHANGED
|
@@ -40,12 +40,15 @@ type Suggestion = {
|
|
|
40
40
|
value: string;
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
+
type TriggerPosition = 'start' | 'auto';
|
|
43
44
|
type Props$b = {
|
|
44
45
|
placeholder?: string;
|
|
45
46
|
ariaLabel?: string;
|
|
46
47
|
suggestions: Suggestion[];
|
|
48
|
+
rows?: number;
|
|
49
|
+
triggerPosition?: TriggerPosition;
|
|
47
50
|
};
|
|
48
|
-
declare const MentionTextAreaControl: ControlComponent$1<({ placeholder, ariaLabel, suggestions: allSuggestions }: Props$b) => React$1.JSX.Element>;
|
|
51
|
+
declare const MentionTextAreaControl: ControlComponent$1<({ placeholder, ariaLabel, suggestions: allSuggestions, rows, triggerPosition }: Props$b) => React$1.JSX.Element>;
|
|
49
52
|
|
|
50
53
|
declare const lengthUnits: readonly ["px", "%", "em", "rem", "vw", "vh", "ch"];
|
|
51
54
|
declare const angleUnits: readonly ["deg", "rad", "grad", "turn"];
|
package/dist/index.d.ts
CHANGED
|
@@ -40,12 +40,15 @@ type Suggestion = {
|
|
|
40
40
|
value: string;
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
+
type TriggerPosition = 'start' | 'auto';
|
|
43
44
|
type Props$b = {
|
|
44
45
|
placeholder?: string;
|
|
45
46
|
ariaLabel?: string;
|
|
46
47
|
suggestions: Suggestion[];
|
|
48
|
+
rows?: number;
|
|
49
|
+
triggerPosition?: TriggerPosition;
|
|
47
50
|
};
|
|
48
|
-
declare const MentionTextAreaControl: ControlComponent$1<({ placeholder, ariaLabel, suggestions: allSuggestions }: Props$b) => React$1.JSX.Element>;
|
|
51
|
+
declare const MentionTextAreaControl: ControlComponent$1<({ placeholder, ariaLabel, suggestions: allSuggestions, rows, triggerPosition }: Props$b) => React$1.JSX.Element>;
|
|
49
52
|
|
|
50
53
|
declare const lengthUnits: readonly ["px", "%", "em", "rem", "vw", "vh", "ch"];
|
|
51
54
|
declare const angleUnits: readonly ["deg", "rad", "grad", "turn"];
|
package/dist/index.js
CHANGED
|
@@ -511,6 +511,7 @@ var ImageMediaControl = createControl(({ mediaTypes = ["image"] }) => {
|
|
|
511
511
|
mediaTypes,
|
|
512
512
|
multiple: false,
|
|
513
513
|
selected: id?.value || null,
|
|
514
|
+
allowUrlImport: true,
|
|
514
515
|
onSelect: (selectedAttachment) => {
|
|
515
516
|
setValue({
|
|
516
517
|
id: {
|
|
@@ -519,6 +520,12 @@ var ImageMediaControl = createControl(({ mediaTypes = ["image"] }) => {
|
|
|
519
520
|
},
|
|
520
521
|
url: null
|
|
521
522
|
});
|
|
523
|
+
},
|
|
524
|
+
onSelectUrl: (selectedUrl) => {
|
|
525
|
+
setValue({
|
|
526
|
+
id: null,
|
|
527
|
+
url: import_editor_props.urlPropTypeUtil.create(selectedUrl)
|
|
528
|
+
});
|
|
522
529
|
}
|
|
523
530
|
});
|
|
524
531
|
return /* @__PURE__ */ React11.createElement(ControlActions, null, /* @__PURE__ */ React11.createElement(import_ui4.Card, { variant: "outlined" }, /* @__PURE__ */ React11.createElement(import_ui4.CardMedia, { image: src, sx: { height: propType.meta.isDynamic ? 134 : 150 } }, isFetching ? /* @__PURE__ */ React11.createElement(import_ui4.Stack, { justifyContent: "center", alignItems: "center", width: "100%", height: "100%" }, /* @__PURE__ */ React11.createElement(import_ui4.CircularProgress, null)) : /* @__PURE__ */ React11.createElement(React11.Fragment, null)), /* @__PURE__ */ React11.createElement(import_ui4.CardOverlay, null, /* @__PURE__ */ React11.createElement(import_ui4.Stack, { gap: 1 }, /* @__PURE__ */ React11.createElement(
|
|
@@ -540,7 +547,7 @@ var ImageMediaControl = createControl(({ mediaTypes = ["image"] }) => {
|
|
|
540
547
|
onClick: () => open({ mode: "upload" })
|
|
541
548
|
},
|
|
542
549
|
(0, import_i18n.__)("Upload", "elementor")
|
|
543
|
-
)))));
|
|
550
|
+
), /* @__PURE__ */ React11.createElement(import_ui4.Button, { size: "tiny", variant: "text", color: "inherit", onClick: () => open({ mode: "url" }) }, (0, import_i18n.__)("Insert from URL", "elementor"))))));
|
|
544
551
|
});
|
|
545
552
|
|
|
546
553
|
// src/controls/select-control.tsx
|
|
@@ -748,25 +755,30 @@ var MentionWrapper = (0, import_ui9.styled)("div")(({ theme }) => ({
|
|
|
748
755
|
"&.p-highlight": {
|
|
749
756
|
backgroundColor: theme.palette.action.selected
|
|
750
757
|
}
|
|
758
|
+
},
|
|
759
|
+
'&[data-single-line="true"] textarea': {
|
|
760
|
+
resize: "none"
|
|
751
761
|
}
|
|
752
762
|
}));
|
|
763
|
+
function createMentionPattern(value, triggerPosition) {
|
|
764
|
+
const escaped = value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
765
|
+
const prefix = "start" === triggerPosition ? "^" : "";
|
|
766
|
+
return new RegExp(`${prefix}@${escaped}(?=\\s|$|[^a-zA-Z0-9_-])`, "g");
|
|
767
|
+
}
|
|
753
768
|
var MentionTextAreaControl = createControl(
|
|
754
|
-
({ placeholder, ariaLabel, suggestions: allSuggestions }) => {
|
|
769
|
+
({ placeholder, ariaLabel, suggestions: allSuggestions, rows = 5, triggerPosition = "auto" }) => {
|
|
755
770
|
const { value, setValue, disabled } = useBoundProp(import_editor_props6.stringPropTypeUtil);
|
|
756
771
|
const [filteredSuggestions, setFilteredSuggestions] = (0, import_react7.useState)([]);
|
|
757
772
|
const transformMentionsToShortcodes = (0, import_react7.useCallback)(
|
|
758
773
|
(text) => {
|
|
759
774
|
let result = text;
|
|
760
775
|
for (const suggestion of allSuggestions) {
|
|
761
|
-
const
|
|
762
|
-
|
|
763
|
-
"g"
|
|
764
|
-
);
|
|
765
|
-
result = result.replace(mentionPattern, `[${suggestion.value}]`);
|
|
776
|
+
const pattern = createMentionPattern(suggestion.value, triggerPosition);
|
|
777
|
+
result = result.replace(pattern, `[${suggestion.value}]`);
|
|
766
778
|
}
|
|
767
779
|
return result;
|
|
768
780
|
},
|
|
769
|
-
[allSuggestions]
|
|
781
|
+
[allSuggestions, triggerPosition]
|
|
770
782
|
);
|
|
771
783
|
const handleChange = (0, import_react7.useCallback)(
|
|
772
784
|
(e) => {
|
|
@@ -778,15 +790,23 @@ var MentionTextAreaControl = createControl(
|
|
|
778
790
|
);
|
|
779
791
|
const handleSearch = (0, import_react7.useCallback)(
|
|
780
792
|
(event) => {
|
|
793
|
+
if ("start" === triggerPosition) {
|
|
794
|
+
const target = event.originalEvent.target;
|
|
795
|
+
const triggerIndex = target.selectionStart - event.query.length - event.trigger.length;
|
|
796
|
+
if (triggerIndex !== 0) {
|
|
797
|
+
setFilteredSuggestions([]);
|
|
798
|
+
return;
|
|
799
|
+
}
|
|
800
|
+
}
|
|
781
801
|
const query = event.query.toLowerCase();
|
|
782
802
|
const filtered = allSuggestions.filter(
|
|
783
803
|
(item) => item.label.toLowerCase().includes(query) || item.value.toLowerCase().includes(query)
|
|
784
804
|
);
|
|
785
805
|
setFilteredSuggestions(filtered);
|
|
786
806
|
},
|
|
787
|
-
[allSuggestions]
|
|
807
|
+
[allSuggestions, triggerPosition]
|
|
788
808
|
);
|
|
789
|
-
return /* @__PURE__ */ React16.createElement(ControlActions, null, /* @__PURE__ */ React16.createElement(MentionWrapper,
|
|
809
|
+
return /* @__PURE__ */ React16.createElement(ControlActions, null, /* @__PURE__ */ React16.createElement(MentionWrapper, { "data-single-line": rows === 1 ? "true" : void 0 }, /* @__PURE__ */ React16.createElement(
|
|
790
810
|
import_mention.Mention,
|
|
791
811
|
{
|
|
792
812
|
value: value ?? "",
|
|
@@ -795,7 +815,7 @@ var MentionTextAreaControl = createControl(
|
|
|
795
815
|
onSearch: handleSearch,
|
|
796
816
|
field: "value",
|
|
797
817
|
trigger: "@",
|
|
798
|
-
rows
|
|
818
|
+
rows,
|
|
799
819
|
disabled,
|
|
800
820
|
placeholder,
|
|
801
821
|
itemTemplate: SuggestionItem,
|
|
@@ -7606,7 +7626,7 @@ var import_editor_elements6 = require("@elementor/editor-elements");
|
|
|
7606
7626
|
var import_editor_props57 = require("@elementor/editor-props");
|
|
7607
7627
|
var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
|
|
7608
7628
|
var FORM_FIELD_WIDGET_TYPES = ["e-form-input", "e-form-textarea", "e-form-checkbox"];
|
|
7609
|
-
function useFormFieldSuggestions() {
|
|
7629
|
+
function useFormFieldSuggestions(options) {
|
|
7610
7630
|
return (0, import_editor_v1_adapters.__privateUseListenTo)(
|
|
7611
7631
|
[
|
|
7612
7632
|
(0, import_editor_v1_adapters.v1ReadyEvent)(),
|
|
@@ -7630,6 +7650,13 @@ function useFormFieldSuggestions() {
|
|
|
7630
7650
|
if (!widgetType || !FORM_FIELD_WIDGET_TYPES.includes(widgetType)) {
|
|
7631
7651
|
return;
|
|
7632
7652
|
}
|
|
7653
|
+
if (options?.inputType) {
|
|
7654
|
+
const typeProp = child.settings.get("type");
|
|
7655
|
+
const typeValue = (0, import_editor_props57.isTransformable)(typeProp) ? typeProp.value : typeProp;
|
|
7656
|
+
if (typeValue !== options.inputType) {
|
|
7657
|
+
return;
|
|
7658
|
+
}
|
|
7659
|
+
}
|
|
7633
7660
|
const cssIdProp = child.settings.get("_cssid");
|
|
7634
7661
|
const fieldId = (0, import_editor_props57.isTransformable)(cssIdProp) ? cssIdProp.value : cssIdProp;
|
|
7635
7662
|
if (fieldId && typeof fieldId === "string") {
|
|
@@ -7687,7 +7714,18 @@ var FromNameField = () => /* @__PURE__ */ React109.createElement(
|
|
|
7687
7714
|
placeholder: (0, import_i18n53.__)("What name should appear as the sender?", "elementor")
|
|
7688
7715
|
}
|
|
7689
7716
|
);
|
|
7690
|
-
var ReplyToField = () =>
|
|
7717
|
+
var ReplyToField = () => {
|
|
7718
|
+
const emailSuggestions = useFormFieldSuggestions({ inputType: "email" });
|
|
7719
|
+
return /* @__PURE__ */ React109.createElement(PropKeyProvider, { bind: "reply-to" }, /* @__PURE__ */ React109.createElement(import_ui93.Grid, { container: true, direction: "column", gap: 0.5 }, /* @__PURE__ */ React109.createElement(import_ui93.Grid, { item: true }, /* @__PURE__ */ React109.createElement(ControlFormLabel, null, (0, import_i18n53.__)("Reply-to", "elementor"))), /* @__PURE__ */ React109.createElement(import_ui93.Grid, { item: true }, /* @__PURE__ */ React109.createElement(
|
|
7720
|
+
MentionTextAreaControl,
|
|
7721
|
+
{
|
|
7722
|
+
suggestions: emailSuggestions,
|
|
7723
|
+
rows: 1,
|
|
7724
|
+
triggerPosition: "start",
|
|
7725
|
+
placeholder: (0, import_i18n53.__)("You can type @ to insert an email field", "elementor")
|
|
7726
|
+
}
|
|
7727
|
+
))));
|
|
7728
|
+
};
|
|
7691
7729
|
var CcField = () => /* @__PURE__ */ React109.createElement(EmailField, { bind: "cc", label: (0, import_i18n53.__)("Cc", "elementor") });
|
|
7692
7730
|
var BccField = () => /* @__PURE__ */ React109.createElement(EmailField, { bind: "bcc", label: (0, import_i18n53.__)("Bcc", "elementor") });
|
|
7693
7731
|
var MetaDataField = () => /* @__PURE__ */ React109.createElement(PropKeyProvider, { bind: "meta-data" }, /* @__PURE__ */ React109.createElement(import_ui93.Stack, { gap: 0.5 }, /* @__PURE__ */ React109.createElement(ControlFormLabel, null, (0, import_i18n53.__)("Metadata", "elementor")), /* @__PURE__ */ React109.createElement(
|