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

pull/8301/head
Laurent Cozic 2023-06-10 17:04:45 +01:00
parent e7409145b6
commit 78f3f1c01a
1 changed files with 11 additions and 5 deletions

View File

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