Skip to content

Commit 6ad9051

Browse files
committed
feat: fix characters in editor
1 parent a38aa17 commit 6ad9051

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

apps/frontend/src/components/launches/general.preview.component.tsx

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,7 @@ export const GeneralPreviewComponent: FC<{
1717
const mediaDir = useMediaDirectory();
1818

1919
const renderContent = topValue.map((p) => {
20-
const newContent = stripHtmlValidation('html', p.content, true)
21-
.replace(/(@.+?)(\s)/gi, (match, match1, match2) => {
22-
return `<span class="font-bold" style="color: #ae8afc">${match1.trim()}${match2}</span>`;
23-
})
24-
.replace(/@\[(.+?)]\((.+?)\)/gi, (match, name, id) => {
25-
return `<span class="font-bold" style="color: #ae8afc">@${name}</span>`;
26-
});
20+
const newContent = stripHtmlValidation('normal', p.content, true);
2721

2822
const { start, end } = textSlicer(
2923
integration?.identifier || '',
@@ -32,14 +26,30 @@ export const GeneralPreviewComponent: FC<{
3226
);
3327

3428
const finalValue =
35-
newContent.slice(start, end) +
29+
newContent
30+
.slice(start, end)
31+
.replace(/(@.+?)(\s)/gi, (match, match1, match2) => {
32+
return `<span class="font-bold" style="color: #ae8afc">${match1.trim()}${match2}</span>`;
33+
})
34+
.replace(/@\[(.+?)]\((.+?)\)/gi, (match, name, id) => {
35+
return `<span class="font-bold" style="color: #ae8afc">@${name}</span>`;
36+
}) +
3637
`<mark class="bg-red-500" data-tooltip-id="tooltip" data-tooltip-content="This text will be cropped">` +
37-
newContent.slice(end) +
38+
newContent
39+
.slice(end)
40+
.replace(/(@.+?)(\s)/gi, (match, match1, match2) => {
41+
return `<span class="font-bold" style="color: #ae8afc">${match1.trim()}${match2}</span>`;
42+
})
43+
.replace(/@\[(.+?)]\((.+?)\)/gi, (match, name, id) => {
44+
return `<span class="font-bold" style="color: #ae8afc">@${name}</span>`;
45+
}) +
3846
`</mark>`;
3947

4048
return { text: finalValue, images: p.image };
4149
});
4250

51+
console.log(renderContent);
52+
4353
return (
4454
<div className={clsx('w-full md:w-[555px] px-[16px]')}>
4555
<div className="w-full h-full relative flex flex-col">
@@ -103,7 +113,11 @@ export const GeneralPreviewComponent: FC<{
103113
</div>
104114
</div>
105115
<div
106-
className={clsx('text-wrap whitespace-pre', 'preview', interClass)}
116+
className={clsx(
117+
'text-wrap whitespace-pre',
118+
'preview',
119+
interClass
120+
)}
107121
dangerouslySetInnerHTML={{
108122
__html: value.text,
109123
}}

apps/frontend/src/components/new-launch/editor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ export const Editor: FC<{
539539
const { getRootProps, isDragActive } = useDropzone({ onDrop });
540540

541541
const valueWithoutHtml = useMemo(() => {
542-
return stripHtmlValidation('normal', props.value || '', false, true);
542+
return stripHtmlValidation('normal', props.value || '', true);
543543
}, [props.value]);
544544

545545
const addText = useCallback(

apps/frontend/src/components/new-launch/manage.modal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export const ManageModal: FC<AddEditModalProps> = (props) => {
147147
return p.values.some((a: any) => {
148148
return (
149149
countCharacters(
150-
stripHtmlValidation('normal', a.content),
150+
stripHtmlValidation('normal', a.content, true),
151151
p?.integration?.identifier || ''
152152
) === 0 && a.media?.length === 0
153153
);

0 commit comments

Comments
 (0)