Skip to content

Commit

Permalink
Web - Chat - Pasted message not always displays no hyperlink format w…
Browse files Browse the repository at this point in the history
…hen paste as plain text
  • Loading branch information
prakashbask committed Jan 31, 2025
1 parent 49128c8 commit 4886fb1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/hooks/useHtmlPaste/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
6 changes: 2 additions & 4 deletions src/pages/home/report/ContextMenu/ContextMenuActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 4886fb1

Please sign in to comment.