@elementor/editor-controls 4.1.0-797 → 4.1.0-798
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 +43 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +43 -12
- 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/mention-text-area-control.tsx +32 -11
- package/src/hooks/use-form-field-suggestions.ts +14 -1
package/dist/index.mjs
CHANGED
|
@@ -633,25 +633,30 @@ var MentionWrapper = styled("div")(({ theme }) => ({
|
|
|
633
633
|
"&.p-highlight": {
|
|
634
634
|
backgroundColor: theme.palette.action.selected
|
|
635
635
|
}
|
|
636
|
+
},
|
|
637
|
+
'&[data-single-line="true"] textarea': {
|
|
638
|
+
resize: "none"
|
|
636
639
|
}
|
|
637
640
|
}));
|
|
641
|
+
function createMentionPattern(value, triggerPosition) {
|
|
642
|
+
const escaped = value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
643
|
+
const prefix = "start" === triggerPosition ? "^" : "";
|
|
644
|
+
return new RegExp(`${prefix}@${escaped}(?=\\s|$|[^a-zA-Z0-9_-])`, "g");
|
|
645
|
+
}
|
|
638
646
|
var MentionTextAreaControl = createControl(
|
|
639
|
-
({ placeholder, ariaLabel, suggestions: allSuggestions }) => {
|
|
647
|
+
({ placeholder, ariaLabel, suggestions: allSuggestions, rows = 5, triggerPosition = "auto" }) => {
|
|
640
648
|
const { value, setValue, disabled } = useBoundProp(stringPropTypeUtil4);
|
|
641
649
|
const [filteredSuggestions, setFilteredSuggestions] = useState2([]);
|
|
642
650
|
const transformMentionsToShortcodes = useCallback(
|
|
643
651
|
(text) => {
|
|
644
652
|
let result = text;
|
|
645
653
|
for (const suggestion of allSuggestions) {
|
|
646
|
-
const
|
|
647
|
-
|
|
648
|
-
"g"
|
|
649
|
-
);
|
|
650
|
-
result = result.replace(mentionPattern, `[${suggestion.value}]`);
|
|
654
|
+
const pattern = createMentionPattern(suggestion.value, triggerPosition);
|
|
655
|
+
result = result.replace(pattern, `[${suggestion.value}]`);
|
|
651
656
|
}
|
|
652
657
|
return result;
|
|
653
658
|
},
|
|
654
|
-
[allSuggestions]
|
|
659
|
+
[allSuggestions, triggerPosition]
|
|
655
660
|
);
|
|
656
661
|
const handleChange = useCallback(
|
|
657
662
|
(e) => {
|
|
@@ -663,15 +668,23 @@ var MentionTextAreaControl = createControl(
|
|
|
663
668
|
);
|
|
664
669
|
const handleSearch = useCallback(
|
|
665
670
|
(event) => {
|
|
671
|
+
if ("start" === triggerPosition) {
|
|
672
|
+
const target = event.originalEvent.target;
|
|
673
|
+
const triggerIndex = target.selectionStart - event.query.length - event.trigger.length;
|
|
674
|
+
if (triggerIndex !== 0) {
|
|
675
|
+
setFilteredSuggestions([]);
|
|
676
|
+
return;
|
|
677
|
+
}
|
|
678
|
+
}
|
|
666
679
|
const query = event.query.toLowerCase();
|
|
667
680
|
const filtered = allSuggestions.filter(
|
|
668
681
|
(item) => item.label.toLowerCase().includes(query) || item.value.toLowerCase().includes(query)
|
|
669
682
|
);
|
|
670
683
|
setFilteredSuggestions(filtered);
|
|
671
684
|
},
|
|
672
|
-
[allSuggestions]
|
|
685
|
+
[allSuggestions, triggerPosition]
|
|
673
686
|
);
|
|
674
|
-
return /* @__PURE__ */ React16.createElement(ControlActions, null, /* @__PURE__ */ React16.createElement(MentionWrapper,
|
|
687
|
+
return /* @__PURE__ */ React16.createElement(ControlActions, null, /* @__PURE__ */ React16.createElement(MentionWrapper, { "data-single-line": rows === 1 ? "true" : void 0 }, /* @__PURE__ */ React16.createElement(
|
|
675
688
|
Mention,
|
|
676
689
|
{
|
|
677
690
|
value: value ?? "",
|
|
@@ -680,7 +693,7 @@ var MentionTextAreaControl = createControl(
|
|
|
680
693
|
onSearch: handleSearch,
|
|
681
694
|
field: "value",
|
|
682
695
|
trigger: "@",
|
|
683
|
-
rows
|
|
696
|
+
rows,
|
|
684
697
|
disabled,
|
|
685
698
|
placeholder,
|
|
686
699
|
itemTemplate: SuggestionItem,
|
|
@@ -7592,7 +7605,7 @@ import { getContainer, getSelectedElements as getSelectedElements3 } from "@elem
|
|
|
7592
7605
|
import { isTransformable as isTransformable3 } from "@elementor/editor-props";
|
|
7593
7606
|
import { __privateUseListenTo as useListenTo, commandEndEvent, v1ReadyEvent } from "@elementor/editor-v1-adapters";
|
|
7594
7607
|
var FORM_FIELD_WIDGET_TYPES = ["e-form-input", "e-form-textarea", "e-form-checkbox"];
|
|
7595
|
-
function useFormFieldSuggestions() {
|
|
7608
|
+
function useFormFieldSuggestions(options) {
|
|
7596
7609
|
return useListenTo(
|
|
7597
7610
|
[
|
|
7598
7611
|
v1ReadyEvent(),
|
|
@@ -7616,6 +7629,13 @@ function useFormFieldSuggestions() {
|
|
|
7616
7629
|
if (!widgetType || !FORM_FIELD_WIDGET_TYPES.includes(widgetType)) {
|
|
7617
7630
|
return;
|
|
7618
7631
|
}
|
|
7632
|
+
if (options?.inputType) {
|
|
7633
|
+
const typeProp = child.settings.get("type");
|
|
7634
|
+
const typeValue = isTransformable3(typeProp) ? typeProp.value : typeProp;
|
|
7635
|
+
if (typeValue !== options.inputType) {
|
|
7636
|
+
return;
|
|
7637
|
+
}
|
|
7638
|
+
}
|
|
7619
7639
|
const cssIdProp = child.settings.get("_cssid");
|
|
7620
7640
|
const fieldId = isTransformable3(cssIdProp) ? cssIdProp.value : cssIdProp;
|
|
7621
7641
|
if (fieldId && typeof fieldId === "string") {
|
|
@@ -7673,7 +7693,18 @@ var FromNameField = () => /* @__PURE__ */ React109.createElement(
|
|
|
7673
7693
|
placeholder: __53("What name should appear as the sender?", "elementor")
|
|
7674
7694
|
}
|
|
7675
7695
|
);
|
|
7676
|
-
var ReplyToField = () =>
|
|
7696
|
+
var ReplyToField = () => {
|
|
7697
|
+
const emailSuggestions = useFormFieldSuggestions({ inputType: "email" });
|
|
7698
|
+
return /* @__PURE__ */ React109.createElement(PropKeyProvider, { bind: "reply-to" }, /* @__PURE__ */ React109.createElement(Grid29, { container: true, direction: "column", gap: 0.5 }, /* @__PURE__ */ React109.createElement(Grid29, { item: true }, /* @__PURE__ */ React109.createElement(ControlFormLabel, null, __53("Reply-to", "elementor"))), /* @__PURE__ */ React109.createElement(Grid29, { item: true }, /* @__PURE__ */ React109.createElement(
|
|
7699
|
+
MentionTextAreaControl,
|
|
7700
|
+
{
|
|
7701
|
+
suggestions: emailSuggestions,
|
|
7702
|
+
rows: 1,
|
|
7703
|
+
triggerPosition: "start",
|
|
7704
|
+
placeholder: __53("You can type @ to insert an email field", "elementor")
|
|
7705
|
+
}
|
|
7706
|
+
))));
|
|
7707
|
+
};
|
|
7677
7708
|
var CcField = () => /* @__PURE__ */ React109.createElement(EmailField, { bind: "cc", label: __53("Cc", "elementor") });
|
|
7678
7709
|
var BccField = () => /* @__PURE__ */ React109.createElement(EmailField, { bind: "bcc", label: __53("Bcc", "elementor") });
|
|
7679
7710
|
var MetaDataField = () => /* @__PURE__ */ React109.createElement(PropKeyProvider, { bind: "meta-data" }, /* @__PURE__ */ React109.createElement(Stack17, { gap: 0.5 }, /* @__PURE__ */ React109.createElement(ControlFormLabel, null, __53("Metadata", "elementor")), /* @__PURE__ */ React109.createElement(
|