From ed18bfd4e89880eb626e16756bf6ec1ff1b47865 Mon Sep 17 00:00:00 2001 From: Amy Evans Date: Thu, 6 Feb 2025 15:13:16 -0800 Subject: [PATCH] Revert "Merge pull request #55932 from prakashbask/fix/53718" This reverts commit 4987f62f367c5d13be53bcf64bcd058eb5455edd, reversing changes made to beafd488e59870d35d6f05fd8d0e29e6d045aee5. --- src/hooks/useHtmlPaste/index.ts | 12 +++--------- .../home/report/ContextMenu/ContextMenuActions.tsx | 6 ++++-- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/hooks/useHtmlPaste/index.ts b/src/hooks/useHtmlPaste/index.ts index 1a5606ef48ad..1a7e62f3141e 100644 --- a/src/hooks/useHtmlPaste/index.ts +++ b/src/hooks/useHtmlPaste/index.ts @@ -1,5 +1,4 @@ import {useCallback, useEffect} from 'react'; -import {isMobile} from '@libs/Browser'; import Parser from '@libs/Parser'; import CONST from '@src/CONST'; import type UseHtmlPaste from './types'; @@ -90,14 +89,9 @@ const useHtmlPaste: UseHtmlPaste = (textInputRef, preHtmlPasteCallback, isActive */ const handlePastePlainText = useCallback( (event: ClipboardEvent) => { - const markdownText = event.clipboardData?.getData('text/plain'); - // Updated paste logic to address issue #53718 - // When copying from a chat conversation, the clipboard contains markdown-formatted text. - // On desktop web, users have the option to paste as plain text, but this feature is unavailable on mobile web. - // A conditional check is added to determine whether to retain markdown or convert it to plain text based on the platform. - if (markdownText) { - const parsedText = isMobile() ? markdownText : Parser.htmlToText(Parser.replace(markdownText)); - paste(parsedText); + const plainText = event.clipboardData?.getData('text/plain'); + if (plainText) { + paste(plainText); } }, [paste], diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 46e2c814db24..7d8b2f031e3b 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -119,8 +119,10 @@ function setClipboardMessage(content: string | undefined) { if (!Clipboard.canSetHtml()) { Clipboard.setString(Parser.htmlToMarkdown(content)); } else { - const markdownText = Parser.htmlToMarkdown(content); - Clipboard.setHtml(content, markdownText); + 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); } }