From 6ad90518388801a9ad84ba25d20773baf34bdd40 Mon Sep 17 00:00:00 2001 From: Nevo David Date: Mon, 21 Jul 2025 16:54:33 +0700 Subject: [PATCH] feat: fix characters in editor --- .../launches/general.preview.component.tsx | 34 +++++++++++++------ .../src/components/new-launch/editor.tsx | 2 +- .../components/new-launch/manage.modal.tsx | 2 +- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/apps/frontend/src/components/launches/general.preview.component.tsx b/apps/frontend/src/components/launches/general.preview.component.tsx index f4a74c63..51ff2ac8 100644 --- a/apps/frontend/src/components/launches/general.preview.component.tsx +++ b/apps/frontend/src/components/launches/general.preview.component.tsx @@ -17,13 +17,7 @@ export const GeneralPreviewComponent: FC<{ const mediaDir = useMediaDirectory(); const renderContent = topValue.map((p) => { - const newContent = stripHtmlValidation('html', p.content, true) - .replace(/(@.+?)(\s)/gi, (match, match1, match2) => { - return `${match1.trim()}${match2}`; - }) - .replace(/@\[(.+?)]\((.+?)\)/gi, (match, name, id) => { - return `@${name}`; - }); + const newContent = stripHtmlValidation('normal', p.content, true); const { start, end } = textSlicer( integration?.identifier || '', @@ -32,14 +26,30 @@ export const GeneralPreviewComponent: FC<{ ); const finalValue = - newContent.slice(start, end) + + newContent + .slice(start, end) + .replace(/(@.+?)(\s)/gi, (match, match1, match2) => { + return `${match1.trim()}${match2}`; + }) + .replace(/@\[(.+?)]\((.+?)\)/gi, (match, name, id) => { + return `@${name}`; + }) + `` + - newContent.slice(end) + + newContent + .slice(end) + .replace(/(@.+?)(\s)/gi, (match, match1, match2) => { + return `${match1.trim()}${match2}`; + }) + .replace(/@\[(.+?)]\((.+?)\)/gi, (match, name, id) => { + return `@${name}`; + }) + ``; return { text: finalValue, images: p.image }; }); + console.log(renderContent); + return (
@@ -103,7 +113,11 @@ export const GeneralPreviewComponent: FC<{
{ - return stripHtmlValidation('normal', props.value || '', false, true); + return stripHtmlValidation('normal', props.value || '', true); }, [props.value]); const addText = useCallback( diff --git a/apps/frontend/src/components/new-launch/manage.modal.tsx b/apps/frontend/src/components/new-launch/manage.modal.tsx index 87d07a5a..27e35673 100644 --- a/apps/frontend/src/components/new-launch/manage.modal.tsx +++ b/apps/frontend/src/components/new-launch/manage.modal.tsx @@ -147,7 +147,7 @@ export const ManageModal: FC = (props) => { return p.values.some((a: any) => { return ( countCharacters( - stripHtmlValidation('normal', a.content), + stripHtmlValidation('normal', a.content, true), p?.integration?.identifier || '' ) === 0 && a.media?.length === 0 );