Skip to content

Commit d5cbbc4

Browse files
authored
Fix removing first new line when pasting text on Android mWeb (#672)
1 parent 83fb987 commit d5cbbc4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/web/utils/inputUtils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ function parseInnerHTMLToText(target: MarkdownTextInputElement, cursorPosition:
6565
// If we are operating on the nodes that are children of the MarkdownTextInputElement, we need to add a newline after each
6666
const isTopComponent = node.parentElement?.contentEditable === 'true';
6767
if (isTopComponent) {
68-
// Replaced text is beeing added as text node, so we need to not add the newline before and after it
69-
if (node.nodeType === Node.TEXT_NODE) {
68+
// When inputType is undefined, the first part of the replaced text is added as a text node.
69+
// Because of it, we need to prevent adding new lines in this case
70+
if (!inputType && node.nodeType === Node.TEXT_NODE) {
7071
shouldAddNewline = false;
7172
} else {
7273
const firstChild = node.firstChild as HTMLElement;

0 commit comments

Comments
 (0)