Skip to content

Commit

Permalink
Fixed commit and added comment to explain the changes
Browse files Browse the repository at this point in the history
  • Loading branch information
prakashbask committed Feb 6, 2025
1 parent c97af19 commit 9ed76b2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/hooks/useHtmlPaste/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {useCallback, useEffect} from 'react';
import {isMobile} from '@libs/Browser';
import Parser from '@libs/Parser';
import CONST from '@src/CONST';
import isMobile from '@src/utils/isMobile';
import type UseHtmlPaste from './types';

const insertAtCaret = (target: HTMLElement, insertedText: string, maxLength: number) => {
Expand Down Expand Up @@ -91,6 +91,10 @@ 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);
Expand Down

0 comments on commit 9ed76b2

Please sign in to comment.