-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Web - Chat - Pasted message not always displays no hyperlink format w… #55932
Changes from 2 commits
4886fb1
668e6ae
c97af19
9ed76b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import {useCallback, useEffect} from 'react'; | ||
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) => { | ||
|
@@ -89,9 +90,10 @@ 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) { | ||
const parsedText = isMobile() ? markdownText : Parser.htmlToText(Parser.replace(markdownText)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a comment about why we need to do this and also provide a link to the issue in the comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added comment and mentioned issue number. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! |
||
paste(parsedText); | ||
} | ||
}, | ||
[paste], | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import {Platform} from 'react-native'; | ||
|
||
const isMobile = () => ['ios', 'android'].includes(Platform.OS); | ||
|
||
export default isMobile; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const isMobile = () => /Mobi|Android|iPhone|iPad|iPod|Windows Phone/i.test(navigator?.userAgent || ''); | ||
|
||
export default isMobile; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use
isMobile
from @libs/browser