I am using sunEditor-react to get HTML files into a text editor. I got the HTML value and displayed inside the editor successfully.
The purpose of this to edit the HTML file in the frontend. But when I am getting the HTML template, there are some places I need to highlight and show.
I need to highlight the text inside curly brackets {}.
Can any explain me how can I do this using CSS or a function to highlight the values inside {}.
This is my current class.
import { useState } from 'react';
import SunEditor from 'suneditor-react';
import { useLocale } from 'hooks/useLocale/useLocale';
import { Button, Heading, Loader, Typography } from 'ui/atoms';
import 'suneditor/dist/css/suneditor.min.css';
import { useStyles } from './Edit.styles';
import { EditProps } from './Edit.types';
import { EditWarning } from './editWarning/EditWarning';
export const EMAIL_EDIT_WARNING_COOKIE_KEY = 'emailEditWarning';
export const Edit = ({ title, defaultTemplate }: EditProps) => {
const classes = useStyles();
const { formatMessage } = useLocale();
const [htmlData, setHtmlData] = useState(defaultTemplate?.html);
if (!defaultTemplate) {
return <Loader className={classes.loader} />;
}
function reset() {
setHtmlData(defaultTemplate?.html);
}
return (
<>
<div className={classes.button}>
<Button type="button" onClick={reset}>
{formatMessage({ id: 'event.emails.edit.reset' })}
</Button>
</div>
<div className={classes.container}>
<Heading variant="h4" bold className={classes.title}>
{formatMessage({ id: 'event.emails.edit.title' })}
</Heading>
<Typography variant="h5" className={classes.subtitle}>
{title}
</Typography>
<EditWarning name={EMAIL_EDIT_WARNING_COOKIE_KEY}>
<div>{formatMessage({ id: 'event.emails.edit.warning_message' })}</div>
<div>{formatMessage({ id: 'event.emails.edit.warning_note' })}</div>
</EditWarning>
</div>
<SunEditor
width="100%"
height="100%"
autoFocus={true}
setContents={htmlData}
/>
</>
); };
I need to add css to to highlight all the values inside curly brackets {}.
Here I need to highlight {{FULL_NAME}} and {{{event_name}}}.
How can I do this using CSS or any function in react?
Can any one please give a solution for this? I am trying this more than a week to get a solution?
