Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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