diff --git a/src/public/app/services/date_notes.js b/src/public/app/services/date_notes.js index e5d6faf6b..5a1a88ca0 100644 --- a/src/public/app/services/date_notes.js +++ b/src/public/app/services/date_notes.js @@ -27,9 +27,17 @@ async function getYearNote(year) { return await treeCache.getNote(note.noteId); } +/** @return {NoteShort} */ +async function createSqlConsole() { + const note = await server.post('sql-console'); + + return await treeCache.getNote(note.noteId); +} + export default { getTodayNote, getDateNote, getMonthNote, - getYearNote + getYearNote, + createSqlConsole } \ No newline at end of file diff --git a/src/public/app/services/dialog_command_executor.js b/src/public/app/services/dialog_command_executor.js index dda83c95a..084eabccf 100644 --- a/src/public/app/services/dialog_command_executor.js +++ b/src/public/app/services/dialog_command_executor.js @@ -1,5 +1,7 @@ import Component from "../widgets/component.js"; import appContext from "./app_context.js"; +import dateNoteService from "../services/date_notes.js"; +import noteCreateService from "../services/note_create.js"; export default class DialogCommandExecutor extends Component { jumpToNoteCommand() { @@ -54,18 +56,22 @@ export default class DialogCommandExecutor extends Component { } showOptionsCommand() { - import("../dialogs/options.js").then(d => d.showDialog()) + import("../dialogs/options.js").then(d => d.showDialog()); } showHelpCommand() { - import("../dialogs/help.js").then(d => d.showDialog()) + import("../dialogs/help.js").then(d => d.showDialog()); } - showSQLConsoleCommand() { - import("../dialogs/sql_console.js").then(d => d.showDialog()) + async showSQLConsoleCommand() { + const sqlConsoleNote = await dateNoteService.createSqlConsole(); + + const tabContext = await appContext.tabManager.openTabWithNote(sqlConsoleNote.noteId, true); + + appContext.triggerCommand('focusOnDetail', {tabId: tabContext.tabId}); } showBackendLogCommand() { - import("../dialogs/backend_log.js").then(d => d.showDialog()) + import("../dialogs/backend_log.js").then(d => d.showDialog()); } } \ No newline at end of file diff --git a/src/public/app/services/note_create.js b/src/public/app/services/note_create.js index 353bc7a36..152c234d9 100644 --- a/src/public/app/services/note_create.js +++ b/src/public/app/services/note_create.js @@ -16,6 +16,7 @@ async function createNewTopLevelNote() { async function createNote(parentNoteId, options = {}) { options = Object.assign({ activate: true, + focus: 'title', target: 'into' }, options); @@ -39,7 +40,8 @@ async function createNote(parentNoteId, options = {}) { title: newNoteName, content: options.content || "", isProtected: options.isProtected, - type: options.type + type: options.type, + mime: options.mime }); if (options.saveSelection && utils.isCKEditorInitialized()) { @@ -48,12 +50,15 @@ async function createNote(parentNoteId, options = {}) { } if (options.activate) { - await ws.waitForMaxKnownSyncId(); - const activeTabContext = appContext.tabManager.getActiveTabContext(); await activeTabContext.setNote(note.noteId); - appContext.triggerCommand('focusAndSelectTitle'); + if (options.focus === 'title') { + appContext.triggerCommand('focusAndSelectTitle'); + } + else if (options.focus === 'content') { + appContext.triggerCommand('focusOnDetail', {tabId: this.tabId}); + } } return {note, branch}; diff --git a/src/public/app/services/tab_manager.js b/src/public/app/services/tab_manager.js index 5463e295c..b15470f4c 100644 --- a/src/public/app/services/tab_manager.js +++ b/src/public/app/services/tab_manager.js @@ -208,6 +208,8 @@ export default class TabManager extends Component { notePath: tabContext.notePath // resolved note path }); } + + return tabContext; } async activateOrOpenNote(noteId) { diff --git a/src/public/app/widgets/collapsible_widgets/note_info.js b/src/public/app/widgets/collapsible_widgets/note_info.js index e0cb8aaac..a22837006 100644 --- a/src/public/app/widgets/collapsible_widgets/note_info.js +++ b/src/public/app/widgets/collapsible_widgets/note_info.js @@ -4,7 +4,6 @@ const TPL = `