From b15b3d6ac59e26810b5c1c0e3d1a4e19321f9d10 Mon Sep 17 00:00:00 2001 From: mic704b Date: Thu, 6 Feb 2020 17:38:17 +1100 Subject: [PATCH] Desktop: Do not select pasted text no matter the paste method (#2431) --- ElectronClient/app/gui/NoteText.jsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ElectronClient/app/gui/NoteText.jsx b/ElectronClient/app/gui/NoteText.jsx index 7abec28021..2baea847d4 100644 --- a/ElectronClient/app/gui/NoteText.jsx +++ b/ElectronClient/app/gui/NoteText.jsx @@ -1406,7 +1406,7 @@ class NoteTextComponent extends React.Component { } editorPasteText() { - this.wrapSelectionWithStrings('', '', '', clipboard.readText()); + this.wrapSelectionWithStrings(clipboard.readText(), '', '', ''); } selectionRangePreviousLine() { @@ -1425,7 +1425,7 @@ class NoteTextComponent extends React.Component { return this.selectionRange_ ? this.rangeToTextOffsets(this.selectionRange_, this.state.note.body) : null; } - wrapSelectionWithStrings(string1, string2 = '', defaultText = '', replacementText = '', byLine=false) { + wrapSelectionWithStrings(string1, string2 = '', defaultText = '', replacementText = null, byLine = false) { if (!this.rawEditor() || !this.state.note) return; const selection = this.textOffsetSelection(); @@ -1433,7 +1433,7 @@ class NoteTextComponent extends React.Component { let newBody = this.state.note.body; if (selection && selection.start !== selection.end) { - const selectedLines = replacementText ? replacementText : this.state.note.body.substr(selection.start, selection.end - selection.start); + const selectedLines = replacementText !== null ? replacementText : this.state.note.body.substr(selection.start, selection.end - selection.start); let selectedStrings = byLine ? selectedLines.split(/\r?\n/) : [selectedLines]; newBody = this.state.note.body.substr(0, selection.start); @@ -1456,7 +1456,7 @@ class NoteTextComponent extends React.Component { column: r.end.column + str1Split[str1Split.length - 1].length }, }; - if (replacementText) { + if (replacementText !== null) { const diff = replacementText.length - (selection.end - selection.start); newRange.end.column += diff; } @@ -1472,7 +1472,7 @@ class NoteTextComponent extends React.Component { editor.focus(); }); } else { - let middleText = replacementText ? replacementText : defaultText; + let middleText = replacementText !== null ? replacementText : defaultText; const textOffset = this.currentTextOffset(); const s1 = this.state.note.body.substr(0, textOffset); const s2 = this.state.note.body.substr(textOffset); @@ -1550,7 +1550,7 @@ class NoteTextComponent extends React.Component { if (!range || (range.start.row === range.end.row && !this.selectionRangeCurrentLine())) { newLine = ''; } - this.wrapSelectionWithStrings(newLine + string1, string2, defaultText, '', byLine); + this.wrapSelectionWithStrings(newLine + string1, string2, defaultText, null, byLine); } commandTextCheckbox() {