Fixed content not being colored on genericModal
This commit is contained in:
parent
036f77fde2
commit
acd2e4daed
1 changed files with 15 additions and 18 deletions
|
|
@ -90,23 +90,7 @@ export default function GenericModal({
|
||||||
setWordsHighlight(filteredWordsHighlight);
|
setWordsHighlight(filteredWordsHighlight);
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
const coloredContent = (typeof inputValue === "string" ? inputValue : "")
|
||||||
if (type === TypeModal.PROMPT && inputValue && inputValue != "") {
|
|
||||||
checkVariables(inputValue);
|
|
||||||
}
|
|
||||||
}, [inputValue, type]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (typeof value === "string") setInputValue(value);
|
|
||||||
}, [value, modalOpen]);
|
|
||||||
let coloredContent = inputValue || "";
|
|
||||||
// Check if coloredContent is a string
|
|
||||||
// calling toString on undefined will throw an error
|
|
||||||
// so we need to check if it is a string first
|
|
||||||
if (typeof coloredContent !== "string") {
|
|
||||||
coloredContent = "";
|
|
||||||
}
|
|
||||||
coloredContent
|
|
||||||
.replace(/</g, "<")
|
.replace(/</g, "<")
|
||||||
.replace(/>/g, ">")
|
.replace(/>/g, ">")
|
||||||
.replace(regexHighlight, (match, p1, p2) => {
|
.replace(regexHighlight, (match, p1, p2) => {
|
||||||
|
|
@ -123,6 +107,17 @@ export default function GenericModal({
|
||||||
return match;
|
return match;
|
||||||
})
|
})
|
||||||
.replace(/\n/g, "<br />");
|
.replace(/\n/g, "<br />");
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (type === TypeModal.PROMPT && inputValue && inputValue != "") {
|
||||||
|
checkVariables(inputValue);
|
||||||
|
}
|
||||||
|
}, [inputValue, type]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (typeof value === "string") setInputValue(value);
|
||||||
|
}, [value, modalOpen]);
|
||||||
|
|
||||||
function getClassByNumberLength(): string {
|
function getClassByNumberLength(): string {
|
||||||
let sumOfCaracteres: number = 0;
|
let sumOfCaracteres: number = 0;
|
||||||
wordsHighlight.forEach((element) => {
|
wordsHighlight.forEach((element) => {
|
||||||
|
|
@ -188,7 +183,9 @@ export default function GenericModal({
|
||||||
open={modalOpen}
|
open={modalOpen}
|
||||||
setOpen={setModalOpen}
|
setOpen={setModalOpen}
|
||||||
>
|
>
|
||||||
<BaseModal.Trigger disable={disabled} asChild>{children}</BaseModal.Trigger>
|
<BaseModal.Trigger disable={disabled} asChild>
|
||||||
|
{children}
|
||||||
|
</BaseModal.Trigger>
|
||||||
<BaseModal.Header
|
<BaseModal.Header
|
||||||
description={(() => {
|
description={(() => {
|
||||||
switch (myModalTitle) {
|
switch (myModalTitle) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue