Skip to content

Commit

Permalink
Merge pull request #56535 from Expensify/amy-revert-55932
Browse files Browse the repository at this point in the history
[CP Staging] Revert "Merge pull request #55932 from prakashbask/fix/53718"
  • Loading branch information
amyevans authored Feb 7, 2025
2 parents e7b38b9 + ed18bfd commit c912900
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
12 changes: 3 additions & 9 deletions src/hooks/useHtmlPaste/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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],
Expand Down
6 changes: 4 additions & 2 deletions src/pages/home/report/ContextMenu/ContextMenuActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit c912900

Please sign in to comment.