1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Desktop: Fixes #2573: Improved detection of selected text when applying formatting (#2582)

* fixes #2573 

This fixes the bug with spaces

* Update NoteText.jsx
This commit is contained in:
Rishabh Malhotra 2020-02-27 05:48:57 +05:30 committed by GitHub
parent 1d284a3528
commit 4840671f0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1435,9 +1435,17 @@ class NoteTextComponent extends React.Component {
let selectedStrings = byLine ? selectedLines.split(/\r?\n/) : [selectedLines];
newBody = this.state.note.body.substr(0, selection.start);
for (let i = 0; i < selectedStrings.length; i++) {
newBody += string1 + selectedStrings[i] + string2;
if (byLine == false) {
let start = selectedStrings[i].search(/[^\s]/);
let end = selectedStrings[i].search(/[^\s](?=[\s]*$)/);
newBody += selectedStrings[i].substr(0, start) + string1 + selectedStrings[i].substr(start, end - start + 1) + string2 + selectedStrings[i].substr(end + 1);
if (this.state.note.body.substr(selection.end) === '') newBody = newBody.trim();
} else { newBody += string1 + selectedStrings[i] + string2; }
}
newBody += this.state.note.body.substr(selection.end);
const r = this.selectionRange_;