Skip to content

Commit c1f34ac

Browse files
committed
fix: Gboard multi-line paste on mobile
- Apply mobile paste fix for all mobile devices, not just WebViews - This fixes Gboard multi-line paste issues on Chrome for Android
1 parent 405fae5 commit c1f34ac

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

src/lib/components/common/RichTextInput.svelte

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,20 +1005,13 @@
10051005
return true;
10061006
}
10071007
1008-
// Workaround for mobile WebViews that strip line breaks when pasting from
1009-
// clipboard suggestions (e.g., Gboard clipboard history).
1008+
// Workaround for mobile keyboards (e.g., Gboard) that may strip line breaks
1009+
// when pasting multi-line text from clipboard suggestions.
10101010
const isMobile = /Android|iPhone|iPad|iPod|Windows Phone/i.test(
10111011
navigator.userAgent
10121012
);
1013-
const isWebView =
1014-
typeof window !== 'undefined' &&
1015-
(/wv/i.test(navigator.userAgent) || // Standard Android WebView flag
1016-
(navigator.userAgent.includes('Android') &&
1017-
!navigator.userAgent.includes('Chrome')) || // Other generic Android WebViews
1018-
(navigator.userAgent.includes('Safari') &&
1019-
!navigator.userAgent.includes('Version'))); // iOS WebView (in-app browsers)
1020-
1021-
if (isMobile && isWebView && plainText.includes('\n')) {
1013+
1014+
if (isMobile && plainText.includes('\n')) {
10221015
// Manually deconstruct the pasted text and insert it with hard breaks
10231016
// to preserve the multi-line formatting.
10241017
const { state, dispatch } = view;

0 commit comments

Comments
 (0)