You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-08-13 22:12:50 +02:00
* Appliying changes * Update NoteText.jsx
This commit is contained in:
@@ -1461,12 +1461,17 @@ class NoteTextComponent extends React.Component {
|
|||||||
|
|
||||||
newBody = this.state.note.body.substr(0, selection.start);
|
newBody = this.state.note.body.substr(0, selection.start);
|
||||||
|
|
||||||
|
let startCursorPos, endCursorPos;
|
||||||
|
|
||||||
for (let i = 0; i < selectedStrings.length; i++) {
|
for (let i = 0; i < selectedStrings.length; i++) {
|
||||||
if (byLine == false) {
|
if (byLine == false) {
|
||||||
const start = selectedStrings[i].search(/[^\s]/);
|
const start = selectedStrings[i].search(/[^\s]/);
|
||||||
const end = selectedStrings[i].search(/[^\s](?=[\s]*$)/);
|
const 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);
|
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();
|
// Getting position for correcting offset in highlighted text when surrounded by white spaces
|
||||||
|
startCursorPos = this.textOffsetToCursorPosition(selection.start + start, newBody);
|
||||||
|
endCursorPos = this.textOffsetToCursorPosition(selection.start + end + 1, newBody);
|
||||||
|
|
||||||
} else { newBody += string1 + selectedStrings[i] + string2; }
|
} else { newBody += string1 + selectedStrings[i] + string2; }
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1480,12 +1485,24 @@ class NoteTextComponent extends React.Component {
|
|||||||
|
|
||||||
// Add the number of newlines to the row
|
// Add the number of newlines to the row
|
||||||
// and add the length of the final line to the column (for strings with no newlines this is the string length)
|
// and add the length of the final line to the column (for strings with no newlines this is the string length)
|
||||||
const newRange = {
|
|
||||||
start: { row: r.start.row + str1Split.length - 1,
|
let newRange = {};
|
||||||
column: r.start.column + str1Split[str1Split.length - 1].length },
|
if (!byLine) {
|
||||||
end: { row: r.end.row + str1Split.length - 1,
|
// Correcting offset in Highlighted text when surrounded by white spaces
|
||||||
column: r.end.column + str1Split[str1Split.length - 1].length },
|
newRange = {
|
||||||
};
|
start: { row: startCursorPos.row,
|
||||||
|
column: startCursorPos.column + string1.length },
|
||||||
|
end: { row: endCursorPos.row,
|
||||||
|
column: endCursorPos.column + string1.length },
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
newRange = {
|
||||||
|
start: { row: r.start.row + str1Split.length - 1,
|
||||||
|
column: r.start.column + str1Split[str1Split.length - 1].length },
|
||||||
|
end: { row: r.end.row + str1Split.length - 1,
|
||||||
|
column: r.end.column + str1Split[str1Split.length - 1].length },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (replacementText !== null) {
|
if (replacementText !== null) {
|
||||||
const diff = replacementText.length - (selection.end - selection.start);
|
const diff = replacementText.length - (selection.end - selection.start);
|
||||||
@@ -1623,7 +1640,7 @@ class NoteTextComponent extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
commandTextHeading() {
|
commandTextHeading() {
|
||||||
this.addListItem('## ');
|
this.addListItem('## ','','', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
commandTextHorizontalRule() {
|
commandTextHorizontalRule() {
|
||||||
|
Reference in New Issue
Block a user