Skip to content

Commit

Permalink
Fix replacing multiline text by pasting content
Browse files Browse the repository at this point in the history
  • Loading branch information
Skalakid committed Aug 20, 2024
1 parent 4f76598 commit ea8c204
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/web/utils/inputUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,16 @@ function parseInnerHTMLToText(target: MarkdownTextInputElement): string {
// If we are operating on the nodes that are children of the MarkdownTextInputElement, we need to add a newline after each
const isTopComponent = node.parentElement?.contentEditable === 'true';
if (isTopComponent) {
if (shouldAddNewline) {
text += '\n';
// Replaced text is beeing added as text node, so we need to not add the newline before and after it
if (node.nodeType === Node.TEXT_NODE) {
shouldAddNewline = false;
} else {
if (shouldAddNewline) {
text += '\n';
shouldAddNewline = false;
}
shouldAddNewline = true;
}
shouldAddNewline = true;
}

if (node.nodeType === Node.TEXT_NODE) {
Expand Down

0 comments on commit ea8c204

Please sign in to comment.