1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-26 22:41:17 +02:00

Mobile: Fixed text update issue when attaching a file to an empty note

This commit is contained in:
Laurent Cozic
2023-06-10 17:04:45 +01:00
parent e7409145b6
commit 78f3f1c01a

View File

@@ -694,12 +694,18 @@ class NoteScreenComponent extends BaseScreenComponent {
const newNote = { ...this.state.note }; const newNote = { ...this.state.note };
if (this.state.mode === 'edit' && !!this.selection) { if (this.state.mode === 'edit') {
const newText = `\n${resourceTag}\n`; let newText = '';
const prefix = newNote.body.substring(0, this.selection.start); if (this.selection) {
const suffix = newNote.body.substring(this.selection.end); newText = `\n${resourceTag}\n`;
newNote.body = `${prefix}${newText}${suffix}`; const prefix = newNote.body.substring(0, this.selection.start);
const suffix = newNote.body.substring(this.selection.end);
newNote.body = `${prefix}${newText}${suffix}`;
} else {
newText = `\n${resourceTag}`;
newNote.body = `${newNote.body}\n${newText}`;
}
if (this.useEditorBeta()) { if (this.useEditorBeta()) {
// The beta editor needs to be explicitly informed of changes // The beta editor needs to be explicitly informed of changes