From e16e817747a5c79f2322e66513f97c9c21c0bc14 Mon Sep 17 00:00:00 2001 From: Aman Harwara Date: Tue, 16 Nov 2021 19:19:28 +0530 Subject: [PATCH] fix: Remove HTML tags before counting words for a note (#739) --- app/assets/javascripts/components/NotesOptions.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/components/NotesOptions.tsx b/app/assets/javascripts/components/NotesOptions.tsx index d500decfa..125cbe7d0 100644 --- a/app/assets/javascripts/components/NotesOptions.tsx +++ b/app/assets/javascripts/components/NotesOptions.tsx @@ -44,8 +44,11 @@ const countNoteAttributes = (text: string) => { paragraphs: 'N/A', }; } catch { + const removeTags = text.replace(/<[^>]*>/g," ").replace(/\s+/g, ' ').trim(); + text = removeTags; + const characters = text.length; - const words = text.match(/[\w’'-]+\b/g)?.length; + const words = text.split(" ")?.length; const paragraphs = text.replace(/\n$/gm, '').split(/\n/).length; return {