Skip to content

Commit b4483fb

Browse files
committed
fix: broaden Gboard multi-line paste workaround to all mobile browsers
The existing workaround for Gboard clipboard history stripping line breaks only applied to mobile WebViews. However, the same issue occurs on regular mobile browsers (e.g., Chrome on Android with Gboard). Removed the isWebView check so the manual multi-line paste handling applies to all mobile environments, not just WebViews.
1 parent 547c587 commit b4483fb

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

src/lib/components/common/RichTextInput.svelte

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,20 +1005,15 @@
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 browsers/WebViews that strip line breaks when
1009+
// pasting from clipboard suggestions (e.g., Gboard clipboard history).
1010+
// This applies to all mobile environments, not just WebViews, because
1011+
// Gboard on regular mobile Chrome exhibits the same issue.
10101012
const isMobile = /Android|iPhone|iPad|iPod|Windows Phone/i.test(
10111013
navigator.userAgent
10121014
);
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')) {
1015+
1016+
if (isMobile && plainText.includes('\n')) {
10221017
// Manually deconstruct the pasted text and insert it with hard breaks
10231018
// to preserve the multi-line formatting.
10241019
const { state, dispatch } = view;

0 commit comments

Comments
 (0)