From 4886fb1ca562e75050dae1776d31d053b8418596 Mon Sep 17 00:00:00 2001 From: Prakash Baskaran Date: Wed, 29 Jan 2025 14:03:58 +0530 Subject: [PATCH] Web - Chat - Pasted message not always displays no hyperlink format when paste as plain text --- src/hooks/useHtmlPaste/index.ts | 6 +++--- src/pages/home/report/ContextMenu/ContextMenuActions.tsx | 6 ++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/hooks/useHtmlPaste/index.ts b/src/hooks/useHtmlPaste/index.ts index 1a7e62f3141e..67f4117d0e6b 100644 --- a/src/hooks/useHtmlPaste/index.ts +++ b/src/hooks/useHtmlPaste/index.ts @@ -89,9 +89,9 @@ const useHtmlPaste: UseHtmlPaste = (textInputRef, preHtmlPasteCallback, isActive */ const handlePastePlainText = useCallback( (event: ClipboardEvent) => { - const plainText = event.clipboardData?.getData('text/plain'); - if (plainText) { - paste(plainText); + const markdownText = event.clipboardData?.getData('text/plain'); + if (markdownText) { + paste(Parser.htmlToText(Parser.replace(markdownText))); } }, [paste], diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index bf5e1b253f3f..694d8eea5ab5 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -119,10 +119,8 @@ function setClipboardMessage(content: string | undefined) { if (!Clipboard.canSetHtml()) { Clipboard.setString(Parser.htmlToMarkdown(content)); } else { - const anchorRegex = CONST.REGEX_LINK_IN_ANCHOR; - const isAnchorTag = anchorRegex.test(content); - const plainText = isAnchorTag ? Parser.htmlToMarkdown(content) : Parser.htmlToText(content); - Clipboard.setHtml(content, plainText); + const markdownText = Parser.htmlToMarkdown(content); + Clipboard.setHtml(content, markdownText); } }