mirror of
https://github.com/hexastack/hexabot
synced 2024-11-26 05:48:55 +00:00
Merge pull request #271 from Hexastack/270-bug-blockform-dialog-regex-pattern-extra-slashes-bug
fix(frontend): visual editor pattern UI representation
This commit is contained in:
commit
8f7dce8d61
@ -100,6 +100,7 @@
|
||||
"no_content_type": "No content type available, please create one first",
|
||||
"invalid_max_fallback_attempt_limit": "Max fallback attempt limit must have positive value",
|
||||
"regex_is_invalid": "Regex is invalid",
|
||||
"regex_is_empty": "Regex cannot be empty",
|
||||
"attachment_not_found": "Attachment is not found",
|
||||
"title_length_exceeded": "You have reached the maximum length",
|
||||
"no_label_found": "No label found",
|
||||
|
@ -100,6 +100,7 @@
|
||||
"no_content_type": "Il n'y a aucun type de contenu pour le moment, veuillez en ajouter un.",
|
||||
"invalid_max_fallback_attempt_limit": "La limite des tentatives de secours doit être un nombre positif.",
|
||||
"regex_is_invalid": "Le regex est invalide",
|
||||
"regex_is_empty": "Le regex ne peut pas être vide",
|
||||
"attachment_not_found": "La pièce jointe est introuvable",
|
||||
"title_length_exceeded": "Vous avez atteint la longueur maximale",
|
||||
"no_label_found": "Aucune étiquette trouvée",
|
||||
|
@ -265,26 +265,26 @@ const PatternInput: FC<PatternInputProps> = ({
|
||||
) : null}
|
||||
{typeof value === "string" && patternType === "regex" ? (
|
||||
<RegexInput
|
||||
{...registerInput(t("message.regex_is_invalid"), idx, {
|
||||
{...registerInput(t("message.regex_is_empty"), idx, {
|
||||
validate: (pattern) => {
|
||||
try {
|
||||
if (
|
||||
pattern.at(0) === "/" &&
|
||||
pattern.at(-1) === "/" &&
|
||||
typeof pattern === "string"
|
||||
)
|
||||
new RegExp(pattern.slice(1, -1));
|
||||
const parsedPattern = new RegExp(pattern.slice(1, -1));
|
||||
|
||||
if (String(parsedPattern) !== pattern) {
|
||||
throw t("message.regex_is_invalid");
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (_e) {
|
||||
return t("message.regex_is_invalid");
|
||||
}
|
||||
},
|
||||
setValueAs: (v) => `/${v}/`,
|
||||
setValueAs: (v) => (isRegex(v) ? v : `/${v}/`),
|
||||
})}
|
||||
label={t("label.regex")}
|
||||
value={value.slice(1, -1)}
|
||||
onChange={(v) => onChange(v)}
|
||||
required
|
||||
/>
|
||||
) : null}
|
||||
{typeof value === "string" && patternType === "text" ? (
|
||||
|
Loading…
Reference in New Issue
Block a user