set focus on new note when creating
This commit is contained in:
parent
8282643d20
commit
fd7a925338
|
|
@ -1272,6 +1272,7 @@ function noteApp() {
|
||||||
// Reload notes and open the new note
|
// Reload notes and open the new note
|
||||||
await this.loadNotes();
|
await this.loadNotes();
|
||||||
await this.loadNote(data.path);
|
await this.loadNote(data.path);
|
||||||
|
this.focusEditorForNewNote();
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
ErrorHandler.handle('create note from template', error);
|
ErrorHandler.handle('create note from template', error);
|
||||||
|
|
@ -3073,6 +3074,20 @@ function noteApp() {
|
||||||
// UNIFIED CREATION FUNCTIONS (reusable from anywhere)
|
// UNIFIED CREATION FUNCTIONS (reusable from anywhere)
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
|
// Switch to split view (if in preview-only mode) and focus editor for new notes
|
||||||
|
focusEditorForNewNote() {
|
||||||
|
// Only switch if in preview-only mode - don't disturb edit or split mode
|
||||||
|
if (this.viewMode === 'preview') {
|
||||||
|
this.viewMode = 'split';
|
||||||
|
this.saveViewMode();
|
||||||
|
}
|
||||||
|
// Focus the editor after a short delay to ensure DOM is updated
|
||||||
|
this.$nextTick(() => {
|
||||||
|
const editor = document.getElementById('note-editor');
|
||||||
|
if (editor) editor.focus();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
async createNote(folderPath = null, directPath = null) {
|
async createNote(folderPath = null, directPath = null) {
|
||||||
let notePath;
|
let notePath;
|
||||||
|
|
||||||
|
|
@ -3138,6 +3153,7 @@ function noteApp() {
|
||||||
if (folderPart) this.expandedFolders.add(folderPart);
|
if (folderPart) this.expandedFolders.add(folderPart);
|
||||||
await this.loadNotes();
|
await this.loadNotes();
|
||||||
await this.loadNote(notePath);
|
await this.loadNote(notePath);
|
||||||
|
this.focusEditorForNewNote();
|
||||||
} else {
|
} else {
|
||||||
ErrorHandler.handle('create note', new Error('Server returned error'));
|
ErrorHandler.handle('create note', new Error('Server returned error'));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue