diff --git a/src/public/app/dialogs/jump_to_note.js b/src/public/app/dialogs/jump_to_note.js index 286e1b163..0d9fb13cf 100644 --- a/src/public/app/dialogs/jump_to_note.js +++ b/src/public/app/dialogs/jump_to_note.js @@ -20,7 +20,7 @@ export async function showDialog() { return false; } - appContext.tabManager.getActiveNoteContext().setNote(suggestion.notePath); + appContext.tabManager.getActiveContext().setNote(suggestion.notePath); }); // if you open the Jump To dialog soon after using it previously it can often mean that you diff --git a/src/public/app/dialogs/link_map.js b/src/public/app/dialogs/link_map.js index af78c8b1e..bf3832e11 100644 --- a/src/public/app/dialogs/link_map.js +++ b/src/public/app/dialogs/link_map.js @@ -27,7 +27,7 @@ export async function showDialog() { } $dialog.on('shown.bs.modal', () => { - const note = appContext.tabManager.getActiveTabNote(); + const note = appContext.tabManager.getActiveContextNote(); linkMapService = new LinkMapService(note, $linkMapContainer, getOptions()); linkMapService.render(); diff --git a/src/public/app/dialogs/markdown_import.js b/src/public/app/dialogs/markdown_import.js index 0261ac0aa..6faa7737f 100644 --- a/src/public/app/dialogs/markdown_import.js +++ b/src/public/app/dialogs/markdown_import.js @@ -29,7 +29,7 @@ async function convertMarkdownToHtml(text) { } export async function importMarkdownInline() { - if (appContext.tabManager.getActiveTabNoteType() !== 'text') { + if (appContext.tabManager.getActiveContextNoteType() !== 'text') { return; } @@ -58,4 +58,4 @@ $importButton.on('click', sendForm); $dialog.on('shown.bs.modal', () => $importTextarea.trigger('focus')); -utils.bindElShortcut($dialog, 'ctrl+return', sendForm); \ No newline at end of file +utils.bindElShortcut($dialog, 'ctrl+return', sendForm); diff --git a/src/public/app/dialogs/note_info.js b/src/public/app/dialogs/note_info.js index fb3acaef8..9d6da1139 100644 --- a/src/public/app/dialogs/note_info.js +++ b/src/public/app/dialogs/note_info.js @@ -12,7 +12,7 @@ const $okButton = $("#note-info-ok-button"); export async function showDialog() { utils.openDialog($dialog); - const activeNoteContext = appContext.tabManager.getActiveNoteContext(); + const activeNoteContext = appContext.tabManager.getActiveContext(); const {note} = activeNoteContext; const noteComplement = await activeNoteContext.getNoteComplement(); diff --git a/src/public/app/dialogs/note_revisions.js b/src/public/app/dialogs/note_revisions.js index 5bb4fa9f9..19da96cc8 100644 --- a/src/public/app/dialogs/note_revisions.js +++ b/src/public/app/dialogs/note_revisions.js @@ -27,7 +27,7 @@ let note; let noteRevisionId; export async function showCurrentNoteRevisions() { - await showNoteRevisionsDialog(appContext.tabManager.getActiveTabNoteId()); + await showNoteRevisionsDialog(appContext.tabManager.getActiveContextNoteId()); } export async function showNoteRevisionsDialog(noteId, noteRevisionId) { @@ -41,7 +41,7 @@ async function loadNoteRevisions(noteId, noteRevId) { $content.empty(); $titleButtons.empty(); - note = appContext.tabManager.getActiveTabNote(); + note = appContext.tabManager.getActiveContextNote(); revisionItems = await server.get(`notes/${noteId}/revisions`); for (const item of revisionItems) { diff --git a/src/public/app/dialogs/note_source.js b/src/public/app/dialogs/note_source.js index 85d6e945d..d3ed8bc98 100644 --- a/src/public/app/dialogs/note_source.js +++ b/src/public/app/dialogs/note_source.js @@ -7,7 +7,7 @@ const $noteSource = $("#note-source"); export async function showDialog() { utils.openDialog($dialog); - const noteCompletement = await appContext.tabManager.getActiveNoteContext().getNoteComplement(); + const noteCompletement = await appContext.tabManager.getActiveContext().getNoteComplement(); $noteSource.text(formatHtml(noteCompletement.content)); } diff --git a/src/public/app/dialogs/recent_changes.js b/src/public/app/dialogs/recent_changes.js index 5a9f04ba3..6e08e6ff6 100644 --- a/src/public/app/dialogs/recent_changes.js +++ b/src/public/app/dialogs/recent_changes.js @@ -56,7 +56,7 @@ export async function showDialog(ancestorNoteId) { await froca.reloadNotes([change.noteId]); - appContext.tabManager.getActiveNoteContext().setNote(change.noteId); + appContext.tabManager.getActiveContext().setNote(change.noteId); } }); diff --git a/src/public/app/layouts/desktop_layout.js b/src/public/app/layouts/desktop_layout.js index c65f04b76..510fae8b1 100644 --- a/src/public/app/layouts/desktop_layout.js +++ b/src/public/app/layouts/desktop_layout.js @@ -5,7 +5,7 @@ import TitleBarButtonsWidget from "../widgets/title_bar_buttons.js"; import StandardTopWidget from "../widgets/standard_top_widget.js"; import SidePaneContainer from "../widgets/containers/side_pane_container.js"; import NoteTreeWidget from "../widgets/note_tree.js"; -import TabCachingWidget from "../widgets/tab_caching_widget.js"; +import NoteContextCachingWidget from "../widgets/note_context_caching_widget.js"; import NotePathsWidget from "../widgets/note_paths.js"; import NoteTitleWidget from "../widgets/note_title.js"; import OwnedAttributeListWidget from "../widgets/type_property_widgets/owned_attribute_list.js"; diff --git a/src/public/app/services/app_context.js b/src/public/app/services/app_context.js index 11aaccf2e..133ee5b8e 100644 --- a/src/public/app/services/app_context.js +++ b/src/public/app/services/app_context.js @@ -161,7 +161,7 @@ $(window).on('hashchange', function() { return; } - appContext.tabManager.switchToTab(ntxId, notePath); + appContext.tabManager.switchToNoteContext(ntxId, notePath); } }); diff --git a/src/public/app/services/entrypoints.js b/src/public/app/services/entrypoints.js index 3ff478862..bf19a284c 100644 --- a/src/public/app/services/entrypoints.js +++ b/src/public/app/services/entrypoints.js @@ -74,17 +74,17 @@ export default class Entrypoints extends Component { await ws.waitForMaxKnownEntityChangeId(); - const hoistedNoteId = appContext.tabManager.getActiveNoteContext() - ? appContext.tabManager.getActiveNoteContext().hoistedNoteId + const hoistedNoteId = appContext.tabManager.getActiveContext() + ? appContext.tabManager.getActiveContext().hoistedNoteId : 'root'; - await appContext.tabManager.openTabWithNote(note.noteId, true, null, hoistedNoteId); + await appContext.tabManager.openContextWithNote(note.noteId, true, null, hoistedNoteId); appContext.triggerEvent('focusAndSelectTitle'); } async toggleNoteHoistingCommand() { - const noteContext = appContext.tabManager.getActiveNoteContext(); + const noteContext = appContext.tabManager.getActiveContext(); if (noteContext.note.noteId === noteContext.hoistedNoteId) { await noteContext.unhoist(); @@ -95,7 +95,7 @@ export default class Entrypoints extends Component { } async hoistNoteCommand({noteId}) { - const noteContext = appContext.tabManager.getActiveNoteContext(); + const noteContext = appContext.tabManager.getActiveContext(); if (noteContext.hoistedNoteId !== noteId) { await noteContext.setHoistedNoteId(noteId); @@ -103,7 +103,7 @@ export default class Entrypoints extends Component { } async unhoistCommand() { - const activeNoteContext = appContext.tabManager.getActiveNoteContext(); + const activeNoteContext = appContext.tabManager.getActiveContext(); if (activeNoteContext) { activeNoteContext.unhoist(); @@ -194,7 +194,7 @@ export default class Entrypoints extends Component { } async runActiveNoteCommand() { - const noteContext = appContext.tabManager.getActiveNoteContext(); + const noteContext = appContext.tabManager.getActiveContext(); const note = noteContext.note; // ctrl+enter is also used elsewhere so make sure we're running only when appropriate @@ -220,7 +220,7 @@ export default class Entrypoints extends Component { $(".tooltip").removeClass("show"); } - tabNoteSwitchedEvent() { + noteSwitchedEvent() { this.hideAllTooltips(); } diff --git a/src/public/app/services/frontend_script_api.js b/src/public/app/services/frontend_script_api.js index 04f5ccff5..43b4cf76a 100644 --- a/src/public/app/services/frontend_script_api.js +++ b/src/public/app/services/frontend_script_api.js @@ -10,8 +10,8 @@ import searchService from './search.js'; import CollapsibleWidget from '../widgets/collapsible_widget.js'; import ws from "./ws.js"; import appContext from "./app_context.js"; -import TabAwareWidget from "../widgets/tab_aware_widget.js"; -import TabCachingWidget from "../widgets/tab_caching_widget.js"; +import NoteContextAwareWidget from "../widgets/note_context_aware_widget.js"; +import NoteContextCachingWidget from "../widgets/note_context_caching_widget.js"; import BasicWidget from "../widgets/basic_widget.js"; /** @@ -39,11 +39,11 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain /** @property {CollapsibleWidget} */ this.CollapsibleWidget = CollapsibleWidget; - /** @property {TabAwareWidget} */ - this.TabAwareWidget = TabAwareWidget; + /** @property {NoteContextAwareWidget} */ + this.TabAwareWidget = NoteContextAwareWidget; - /** @property {TabCachingWidget} */ - this.TabCachingWidget = TabCachingWidget; + /** @property {NoteContextCachingWidget} */ + this.TabCachingWidget = NoteContextCachingWidget; /** @property {BasicWidget} */ this.BasicWidget = BasicWidget; @@ -56,7 +56,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain * @returns {Promise} */ this.activateNote = async notePath => { - await appContext.tabManager.getActiveNoteContext().setNote(notePath); + await appContext.tabManager.getActiveContext().setNote(notePath); }; /** @@ -68,7 +68,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain this.activateNewNote = async notePath => { await ws.waitForMaxKnownEntityChangeId(); - await appContext.tabManager.getActiveNoteContext().setNote(notePath); + await appContext.tabManager.getActiveContext().setNote(notePath); appContext.triggerEvent('focusAndSelectTitle'); }; @@ -82,7 +82,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain this.openTabWithNote = async (notePath, activate) => { await ws.waitForMaxKnownEntityChangeId(); - await appContext.tabManager.openTabWithNote(notePath, activate); + await appContext.tabManager.openContextWithNote(notePath, activate); if (activate) { appContext.triggerEvent('focusAndSelectTitle'); @@ -313,7 +313,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain * @method * @returns {NoteShort} active note (loaded into right pane) */ - this.getActiveTabNote = () => appContext.tabManager.getActiveTabNote(); + this.getActiveTabNote = () => appContext.tabManager.getActiveContextNote(); /** * See https://ckeditor.com/docs/ckeditor5/latest/api/module_core_editor_editor-Editor.html for a documentation on the returned instance. @@ -327,7 +327,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain * @method * @returns {Promise} returns note path of active note or null if there isn't active note */ - this.getActiveTabNotePath = () => appContext.tabManager.getActiveTabNotePath(); + this.getActiveTabNotePath = () => appContext.tabManager.getActiveContextNotePath(); /** * @method @@ -340,7 +340,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain * @method */ this.protectActiveNote = async () => { - const activeNote = appContext.tabManager.getActiveTabNote(); + const activeNote = appContext.tabManager.getActiveContextNote(); await protectedSessionService.protectNote(activeNote.noteId, true, false); }; @@ -406,7 +406,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain * @return {Promise} */ this.setHoistedNoteId = (noteId) => { - const activeNoteContext = appContext.tabManager.getActiveNoteContext(); + const activeNoteContext = appContext.tabManager.getActiveContext(); if (activeNoteContext) { activeNoteContext.setHoistedNoteId(noteId); diff --git a/src/public/app/services/glob.js b/src/public/app/services/glob.js index f91a48148..6819763da 100644 --- a/src/public/app/services/glob.js +++ b/src/public/app/services/glob.js @@ -16,7 +16,7 @@ function setupGlobs() { window.glob.getHeaders = server.getHeaders; // required for ESLint plugin and CKEditor - window.glob.getActiveTabNote = () => appContext.tabManager.getActiveTabNote(); + window.glob.getActiveTabNote = () => appContext.tabManager.getActiveContextNote(); window.glob.requireLibrary = libraryLoader.requireLibrary; window.glob.ESLINT = libraryLoader.ESLINT; window.glob.appContext = appContext; // for debugging diff --git a/src/public/app/services/hoisted_note.js b/src/public/app/services/hoisted_note.js index 785908e39..f3403a760 100644 --- a/src/public/app/services/hoisted_note.js +++ b/src/public/app/services/hoisted_note.js @@ -2,13 +2,13 @@ import appContext from "./app_context.js"; import treeService from "./tree.js"; function getHoistedNoteId() { - const activeNoteContext = appContext.tabManager.getActiveNoteContext(); + const activeNoteContext = appContext.tabManager.getActiveContext(); return activeNoteContext ? activeNoteContext.hoistedNoteId : 'root'; } async function unhoist() { - const activeNoteContext = appContext.tabManager.getActiveNoteContext(); + const activeNoteContext = appContext.tabManager.getActiveContext(); if (activeNoteContext) { await activeNoteContext.unhoist(); diff --git a/src/public/app/services/import.js b/src/public/app/services/import.js index b5ae40b84..26eb86f7c 100644 --- a/src/public/app/services/import.js +++ b/src/public/app/services/import.js @@ -64,7 +64,7 @@ ws.subscribeToMessages(async message => { toastService.showPersistent(toast); if (message.result.importedNoteId) { - await appContext.tabManager.getActiveNoteContext().setNote(message.result.importedNoteId); + await appContext.tabManager.getActiveContext().setNote(message.result.importedNoteId); } } }); diff --git a/src/public/app/services/keyboard_actions.js b/src/public/app/services/keyboard_actions.js index c91c00f98..077fbd49d 100644 --- a/src/public/app/services/keyboard_actions.js +++ b/src/public/app/services/keyboard_actions.js @@ -43,7 +43,7 @@ getActionsForScope("window").then(actions => { server.get('keyboard-shortcuts-for-notes').then(shortcutForNotes => { for (const shortcut in shortcutForNotes) { utils.bindGlobalShortcut(shortcut, async () => { - appContext.tabManager.getActiveNoteContext().setNote(shortcutForNotes[shortcut]); + appContext.tabManager.getActiveContext().setNote(shortcutForNotes[shortcut]); }); } }); diff --git a/src/public/app/services/link.js b/src/public/app/services/link.js index e36ee6f05..71625f37c 100644 --- a/src/public/app/services/link.js +++ b/src/public/app/services/link.js @@ -85,11 +85,11 @@ function goToLink(e) { const noteContext = ntxId ? appContext.tabManager.getNoteContextById(ntxId) - : appContext.tabManager.getActiveNoteContext(); + : appContext.tabManager.getActiveContext(); noteContext.setNote(notePath).then(() => { - if (noteContext !== appContext.tabManager.getActiveNoteContext()) { - appContext.tabManager.activateTab(noteContext.ntxId); + if (noteContext !== appContext.tabManager.getActiveContext()) { + appContext.tabManager.activateNoteContext(noteContext.ntxId); } }); } diff --git a/src/public/app/services/main_tree_executors.js b/src/public/app/services/main_tree_executors.js index 3204746fe..ab67e3368 100644 --- a/src/public/app/services/main_tree_executors.js +++ b/src/public/app/services/main_tree_executors.js @@ -27,7 +27,7 @@ export default class MainTreeExecutors extends Component { } async createNoteIntoCommand() { - const activeNoteContext = appContext.tabManager.getActiveNoteContext(); + const activeNoteContext = appContext.tabManager.getActiveContext(); if (!activeNoteContext) { return; diff --git a/src/public/app/services/note_autocomplete.js b/src/public/app/services/note_autocomplete.js index cdcda872b..495342ca0 100644 --- a/src/public/app/services/note_autocomplete.js +++ b/src/public/app/services/note_autocomplete.js @@ -31,7 +31,7 @@ async function autocompleteSourceForCKEditor(queryText) { } async function autocompleteSource(term, cb, options = {}) { - const activeNoteId = appContext.tabManager.getActiveTabNoteId(); + const activeNoteId = appContext.tabManager.getActiveContextNoteId(); let results = await server.get('autocomplete' + '?query=' + encodeURIComponent(term) diff --git a/src/public/app/services/tab_context.js b/src/public/app/services/note_context.js similarity index 97% rename from src/public/app/services/tab_context.js rename to src/public/app/services/note_context.js index 4aa9b54ea..6c9ba346b 100644 --- a/src/public/app/services/tab_context.js +++ b/src/public/app/services/note_context.js @@ -20,7 +20,7 @@ class NoteContext extends Component { } setEmpty() { - this.triggerEvent('tabNoteSwitched', { + this.triggerEvent('noteSwitched', { noteContext: this, notePath: this.notePath }); @@ -48,7 +48,7 @@ class NoteContext extends Component { protectedSessionHolder.touchProtectedSessionIfNecessary(this.note); if (triggerSwitchEvent) { - await this.triggerEvent('tabNoteSwitched', { + await this.triggerEvent('noteSwitched', { noteContext: this, notePath: this.notePath }); @@ -180,7 +180,7 @@ class NoteContext extends Component { this.noteId = null; this.notePath = null; - this.triggerEvent('tabNoteSwitched', { + this.triggerEvent('noteSwitched', { noteContext: this, notePath: this.notePath }); diff --git a/src/public/app/services/note_create.js b/src/public/app/services/note_create.js index ba5ad2de2..641b5e377 100644 --- a/src/public/app/services/note_create.js +++ b/src/public/app/services/note_create.js @@ -20,7 +20,7 @@ async function createNote(parentNotePath, options = {}) { options.isProtected = false; } - if (appContext.tabManager.getActiveTabNoteType() !== 'text') { + if (appContext.tabManager.getActiveContextNoteType() !== 'text') { options.saveSelection = false; } @@ -48,7 +48,7 @@ async function createNote(parentNotePath, options = {}) { await ws.waitForMaxKnownEntityChangeId(); if (options.activate) { - const activeNoteContext = appContext.tabManager.getActiveNoteContext(); + const activeNoteContext = appContext.tabManager.getActiveContext(); await activeNoteContext.setNote(`${parentNotePath}/${note.noteId}`); if (options.focus === 'title') { @@ -90,7 +90,7 @@ async function duplicateSubtree(noteId, parentNotePath) { await ws.waitForMaxKnownEntityChangeId(); - const activeNoteContext = appContext.tabManager.getActiveNoteContext(); + const activeNoteContext = appContext.tabManager.getActiveContext(); activeNoteContext.setNote(`${parentNotePath}/${note.noteId}`); const origNote = await froca.getNote(noteId); diff --git a/src/public/app/services/root_command_executor.js b/src/public/app/services/root_command_executor.js index 66683d0a5..ee6f1d6dd 100644 --- a/src/public/app/services/root_command_executor.js +++ b/src/public/app/services/root_command_executor.js @@ -35,7 +35,7 @@ export default class RootCommandExecutor extends Component { } async editBranchPrefixCommand() { - const notePath = appContext.tabManager.getActiveTabNotePath(); + const notePath = appContext.tabManager.getActiveContextNotePath(); if (notePath) { const editBranchPrefixDialog = await import("../dialogs/branch_prefix.js"); @@ -64,7 +64,7 @@ export default class RootCommandExecutor extends Component { async showSQLConsoleCommand() { const sqlConsoleNote = await dateNoteService.createSqlConsole(); - const noteContext = await appContext.tabManager.openTabWithNote(sqlConsoleNote.noteId, true); + const noteContext = await appContext.tabManager.openContextWithNote(sqlConsoleNote.noteId, true); appContext.triggerEvent('focusOnDetail', {ntxId: noteContext.ntxId}); } @@ -72,7 +72,7 @@ export default class RootCommandExecutor extends Component { async searchNotesCommand({searchString, ancestorNoteId}) { const searchNote = await dateNoteService.createSearchNote({searchString, ancestorNoteId}); - const noteContext = await appContext.tabManager.openTabWithNote(searchNote.noteId, true); + const noteContext = await appContext.tabManager.openContextWithNote(searchNote.noteId, true); appContext.triggerCommand('focusOnSearchDefinition', {ntxId: noteContext.ntxId}); } @@ -88,7 +88,7 @@ export default class RootCommandExecutor extends Component { } openNoteExternallyCommand() { - const noteId = appContext.tabManager.getActiveTabNoteId(); + const noteId = appContext.tabManager.getActiveContextNoteId(); if (noteId) { openService.openNoteExternally(noteId); diff --git a/src/public/app/services/server.js b/src/public/app/services/server.js index a80947b83..f7e229b02 100644 --- a/src/public/app/services/server.js +++ b/src/public/app/services/server.js @@ -4,7 +4,7 @@ const REQUEST_LOGGING_ENABLED = false; async function getHeaders(headers) { const appContext = (await import('./app_context.js')).default; - const activeNoteContext = appContext.tabManager ? appContext.tabManager.getActiveNoteContext() : null; + const activeNoteContext = appContext.tabManager ? appContext.tabManager.getActiveContext() : null; // headers need to be lowercase because node.js automatically converts them to lower case // also avoiding using underscores instead of dashes since nginx filters them out by default diff --git a/src/public/app/services/tab_manager.js b/src/public/app/services/tab_manager.js index 7b3a0b05a..99b7b4461 100644 --- a/src/public/app/services/tab_manager.js +++ b/src/public/app/services/tab_manager.js @@ -5,7 +5,7 @@ import options from "./options.js"; import froca from "./froca.js"; import treeService from "./tree.js"; import utils from "./utils.js"; -import NoteContext from "./tab_context.js"; +import NoteContext from "./note_context.js"; import appContext from "./app_context.js"; export default class TabManager extends Component { @@ -104,12 +104,12 @@ export default class TabManager extends Component { await this.tabsUpdate.allowUpdateWithoutChange(async () => { for (const tab of filteredTabs) { - await this.openTabWithNote(tab.notePath, tab.active, tab.ntxId, tab.hoistedNoteId, tab.mainNtxId); + await this.openContextWithNote(tab.notePath, tab.active, tab.ntxId, tab.hoistedNoteId, tab.mainNtxId); } }); } - tabNoteSwitchedEvent({noteContext}) { + noteSwitchedEvent({noteContext}) { if (noteContext.isActive()) { this.setCurrentNotePathToHash(); } @@ -118,7 +118,7 @@ export default class TabManager extends Component { } setCurrentNotePathToHash() { - const activeNoteContext = this.getActiveNoteContext(); + const activeNoteContext = this.getActiveContext(); if (window.history.length === 0 // first history entry || (activeNoteContext && activeNoteContext.notePath !== treeService.getHashValueFromAddress()[0])) { @@ -155,50 +155,50 @@ export default class TabManager extends Component { } /** @returns {NoteContext} */ - getActiveNoteContext() { + getActiveContext() { return this.activeTabId ? this.getNoteContextById(this.activeTabId) : null; } /** @returns {string|null} */ - getActiveTabNotePath() { - const activeContext = this.getActiveNoteContext(); + getActiveContextNotePath() { + const activeContext = this.getActiveContext(); return activeContext ? activeContext.notePath : null; } /** @return {NoteShort} */ - getActiveTabNote() { - const activeContext = this.getActiveNoteContext(); + getActiveContextNote() { + const activeContext = this.getActiveContext(); return activeContext ? activeContext.note : null; } /** @return {string|null} */ - getActiveTabNoteId() { - const activeNote = this.getActiveTabNote(); + getActiveContextNoteId() { + const activeNote = this.getActiveContextNote(); return activeNote ? activeNote.noteId : null; } /** @return {string|null} */ - getActiveTabNoteType() { - const activeNote = this.getActiveTabNote(); + getActiveContextNoteType() { + const activeNote = this.getActiveContextNote(); return activeNote ? activeNote.type : null; } - async switchToTab(ntxId, notePath) { + async switchToNoteContext(ntxId, notePath) { const noteContext = this.noteContexts.find(nc => nc.ntxId === ntxId) || await this.openEmptyTab(); - this.activateTab(noteContext.ntxId); + this.activateNoteContext(noteContext.ntxId); await noteContext.setNote(notePath); } async openAndActivateEmptyTab() { const noteContext = await this.openEmptyTab(); - await this.activateTab(noteContext.ntxId); + await this.activateNoteContext(noteContext.ntxId); await noteContext.setEmpty(); } @@ -214,7 +214,7 @@ export default class TabManager extends Component { this.child(noteContext); - await this.triggerEvent('newTabOpened', {noteContext}); + await this.triggerEvent('newNoteContextCreated', {noteContext}); return noteContext; } @@ -223,7 +223,7 @@ export default class TabManager extends Component { * If the requested notePath is within current note hoisting scope then keep the note hoisting also for the new tab. */ async openTabWithNoteWithHoisting(notePath) { - const noteContext = this.getActiveNoteContext(); + const noteContext = this.getActiveContext(); let hoistedNoteId = 'root'; if (noteContext) { @@ -234,10 +234,10 @@ export default class TabManager extends Component { } } - return this.openTabWithNote(notePath, false, null, hoistedNoteId); + return this.openContextWithNote(notePath, false, null, hoistedNoteId); } - async openTabWithNote(notePath, activate, ntxId, hoistedNoteId = 'root', mainNtxId = null) { + async openContextWithNote(notePath, activate, ntxId, hoistedNoteId = 'root', mainNtxId = null) { const noteContext = await this.openEmptyTab(ntxId, hoistedNoteId, mainNtxId); if (notePath) { @@ -245,9 +245,9 @@ export default class TabManager extends Component { } if (activate) { - this.activateTab(noteContext.ntxId, false); + this.activateNoteContext(noteContext.ntxId, false); - await this.triggerEvent('tabNoteSwitchedAndActivated', { + await this.triggerEvent('noteSwitchedAndActivated', { noteContext, notePath: noteContext.notePath // resolved note path }); @@ -259,7 +259,7 @@ export default class TabManager extends Component { async activateOrOpenNote(noteId) { for (const noteContext of this.getNoteContexts()) { if (noteContext.note && noteContext.note.noteId === noteId) { - this.activateTab(noteContext.ntxId); + this.activateNoteContext(noteContext.ntxId); return; } @@ -267,10 +267,10 @@ export default class TabManager extends Component { // if no tab with this note has been found we'll create new tab - await this.openTabWithNote(noteId, true); + await this.openContextWithNote(noteId, true); } - activateTab(ntxId, triggerEvent = true) { + activateNoteContext(ntxId, triggerEvent = true) { if (ntxId === this.activeTabId) { return; } @@ -288,7 +288,7 @@ export default class TabManager extends Component { this.setCurrentNotePathToHash(); } - async removeTab(ntxId) { + async removeNoteContext(ntxId) { const mainNoteContextToRemove = this.getNoteContextById(ntxId).getMainNoteContext(); // close dangling autocompletes after closing the tab @@ -314,7 +314,7 @@ export default class TabManager extends Component { this.children = this.children.filter(nc => !ntxIdsToRemove.includes(nc.ntxId)); - this.triggerEvent('tabRemoved', {ntxIds: ntxIdsToRemove}); + this.triggerEvent('noteContextRemoved', {ntxIds: ntxIdsToRemove}); this.tabsUpdate.scheduleUpdate(); } @@ -335,18 +335,18 @@ export default class TabManager extends Component { const oldIdx = this.mainNoteContexts.findIndex(nc => nc.ntxId === this.activeTabId); const newActiveTabId = this.mainNoteContexts[oldIdx === this.noteContexts.length - 1 ? 0 : oldIdx + 1].ntxId; - this.activateTab(newActiveTabId); + this.activateNoteContext(newActiveTabId); } activatePreviousTabCommand() { const oldIdx = this.mainNoteContexts.findIndex(nc => nc.ntxId === this.activeTabId); const newActiveTabId = this.mainNoteContexts[oldIdx === 0 ? this.noteContexts.length - 1 : oldIdx - 1].ntxId; - this.activateTab(newActiveTabId); + this.activateNoteContext(newActiveTabId); } closeActiveTabCommand() { - this.removeTab(this.activeTabId); + this.removeNoteContext(this.activeTabId); } beforeUnloadEvent() { @@ -361,14 +361,14 @@ export default class TabManager extends Component { async removeAllTabsCommand() { for (const ntxIdToRemove of this.noteContexts.map(nc => nc.ntxId)) { - await this.removeTab(ntxIdToRemove); + await this.removeNoteContext(ntxIdToRemove); } } async removeAllTabsExceptForThisCommand({ntxId}) { for (const ntxIdToRemove of this.noteContexts.map(nc => nc.ntxId)) { if (ntxIdToRemove !== ntxId) { - await this.removeTab(ntxIdToRemove); + await this.removeNoteContext(ntxIdToRemove); } } } @@ -376,7 +376,7 @@ export default class TabManager extends Component { moveTabToNewWindowCommand({ntxId}) { const {notePath, hoistedNoteId} = this.getNoteContextById(ntxId); - this.removeTab(ntxId); + this.removeNoteContext(ntxId); this.triggerCommand('openInWindow', {notePath, hoistedNoteId}); } diff --git a/src/public/app/services/tree_context_menu.js b/src/public/app/services/tree_context_menu.js index f7d22a455..393d8c879 100644 --- a/src/public/app/services/tree_context_menu.js +++ b/src/public/app/services/tree_context_menu.js @@ -39,7 +39,7 @@ class TreeContextMenu { const note = await froca.getNote(this.node.data.noteId); const branch = froca.getBranch(this.node.data.branchId); const isNotRoot = note.noteId !== 'root'; - const isHoisted = note.noteId === appContext.tabManager.getActiveNoteContext().hoistedNoteId; + const isHoisted = note.noteId === appContext.tabManager.getActiveContext().hoistedNoteId; const parentNote = isNotRoot ? await froca.getNote(branch.parentNoteId) : null; // some actions don't support multi-note so they are disabled when notes are selected diff --git a/src/public/app/widgets/attribute_widgets/attribute_detail.js b/src/public/app/widgets/attribute_widgets/attribute_detail.js index b99e590aa..5d9e2f481 100644 --- a/src/public/app/widgets/attribute_widgets/attribute_detail.js +++ b/src/public/app/widgets/attribute_widgets/attribute_detail.js @@ -5,7 +5,7 @@ import linkService from "../../services/link.js"; import attributeAutocompleteService from "../../services/attribute_autocomplete.js"; import noteAutocompleteService from "../../services/note_autocomplete.js"; import promotedAttributeDefinitionParser from '../../services/promoted_attribute_definition_parser.js'; -import TabAwareWidget from "../tab_aware_widget.js"; +import NoteContextAwareWidget from "../note_context_aware_widget.js"; import SpacedUpdate from "../../services/spaced_update.js"; import utils from "../../services/utils.js"; @@ -222,7 +222,7 @@ const ATTR_HELP = { } }; -export default class AttributeDetailWidget extends TabAwareWidget { +export default class AttributeDetailWidget extends NoteContextAwareWidget { async refresh() { // switching note/tab should close the widget diff --git a/src/public/app/widgets/attribute_widgets/attribute_editor.js b/src/public/app/widgets/attribute_widgets/attribute_editor.js index 0de1222d9..4c1ac360d 100644 --- a/src/public/app/widgets/attribute_widgets/attribute_editor.js +++ b/src/public/app/widgets/attribute_widgets/attribute_editor.js @@ -1,4 +1,4 @@ -import TabAwareWidget from "../tab_aware_widget.js"; +import NoteContextAwareWidget from "../note_context_aware_widget.js"; import noteAutocompleteService from "../../services/note_autocomplete.js"; import server from "../../services/server.js"; import contextMenuService from "../../services/context_menu.js"; @@ -176,7 +176,7 @@ const editorConfig = { mention: mentionSetup }; -export default class AttributeEditorWidget extends TabAwareWidget { +export default class AttributeEditorWidget extends NoteContextAwareWidget { constructor(attributeDetailWidget) { super(); diff --git a/src/public/app/widgets/collapsible_widget.js b/src/public/app/widgets/collapsible_widget.js index 047c9b627..cea9a86bd 100644 --- a/src/public/app/widgets/collapsible_widget.js +++ b/src/public/app/widgets/collapsible_widget.js @@ -1,4 +1,4 @@ -import TabAwareWidget from "./tab_aware_widget.js"; +import NoteContextAwareWidget from "./note_context_aware_widget.js"; import options from "../services/options.js"; const WIDGET_TPL = ` @@ -29,7 +29,7 @@ const WIDGET_TPL = ` `; -export default class CollapsibleWidget extends TabAwareWidget { +export default class CollapsibleWidget extends NoteContextAwareWidget { get widgetTitle() { return "Untitled widget"; } get headerActions() { return []; } diff --git a/src/public/app/widgets/collapsible_widgets/calendar.js b/src/public/app/widgets/collapsible_widgets/calendar.js index 4a6931947..d5586590e 100644 --- a/src/public/app/widgets/collapsible_widgets/calendar.js +++ b/src/public/app/widgets/collapsible_widgets/calendar.js @@ -56,7 +56,7 @@ export default class CalendarWidget extends CollapsibleWidget { const note = await dateNoteService.getDateNote(date); if (note) { - appContext.tabManager.getActiveNoteContext().setNote(note.noteId); + appContext.tabManager.getActiveContext().setNote(note.noteId); } else { alert("Cannot find day note"); diff --git a/src/public/app/widgets/containers/collapsible_section_container.js b/src/public/app/widgets/containers/collapsible_section_container.js index ea546af70..0a1de28b4 100644 --- a/src/public/app/widgets/containers/collapsible_section_container.js +++ b/src/public/app/widgets/containers/collapsible_section_container.js @@ -1,4 +1,4 @@ -import TabAwareWidget from "../tab_aware_widget.js"; +import NoteContextAwareWidget from "../note_context_aware_widget.js"; const TPL = `
@@ -57,7 +57,7 @@ const TPL = `
`; -export default class CollapsibleSectionContainer extends TabAwareWidget { +export default class CollapsibleSectionContainer extends NoteContextAwareWidget { constructor() { super(); diff --git a/src/public/app/widgets/containers/pane_container.js b/src/public/app/widgets/containers/pane_container.js index 236210be5..78c944dbc 100644 --- a/src/public/app/widgets/containers/pane_container.js +++ b/src/public/app/widgets/containers/pane_container.js @@ -14,14 +14,14 @@ export default class PaneContainer extends FlexContainer { this.css('flex-grow', '1'); } - async newTabOpenedEvent({noteContext}) { + async newNoteContextCreatedEvent({noteContext}) { const widget = this.widgetFactory(); const $renderedWidget = widget.render(); $renderedWidget.attr("data-tab-id", noteContext.ntxId); - $renderedWidget.on('click', () => appContext.tabManager.activateTab(noteContext.ntxId)); + $renderedWidget.on('click', () => appContext.tabManager.activateNoteContext(noteContext.ntxId)); this.$widget.append($renderedWidget); @@ -35,9 +35,9 @@ export default class PaneContainer extends FlexContainer { } async openNewPaneCommand() { - const noteContext = await appContext.tabManager.openEmptyTab(null, 'root', appContext.tabManager.getActiveNoteContext().ntxId); + const noteContext = await appContext.tabManager.openEmptyTab(null, 'root', appContext.tabManager.getActiveContext().ntxId); - await appContext.tabManager.activateTab(noteContext.ntxId); + await appContext.tabManager.activateNoteContext(noteContext.ntxId); await noteContext.setEmpty(); } @@ -49,7 +49,7 @@ export default class PaneContainer extends FlexContainer { toggleInt(show) {} // not needed toggleExt(show) { - const activeTabId = appContext.tabManager.getActiveNoteContext().getMainNoteContext().ntxId; + const activeTabId = appContext.tabManager.getActiveContext().getMainNoteContext().ntxId; for (const ntxId in this.widgets) { const noteContext = appContext.tabManager.getNoteContextById(ntxId); @@ -69,7 +69,7 @@ export default class PaneContainer extends FlexContainer { * activation further note switches are always propagated to the tabs. */ handleEventInChildren(name, data) { - if (['tabNoteSwitched', 'tabNoteSwitchedAndActivated'].includes(name)) { + if (['noteSwitched', 'noteSwitchedAndActivated'].includes(name)) { // this event is propagated only to the widgets of a particular tab const widget = this.widgets[data.noteContext.ntxId]; @@ -79,7 +79,7 @@ export default class PaneContainer extends FlexContainer { const promises = []; - if (appContext.tabManager.getActiveNoteContext().getMainNoteContext() === data.noteContext.getMainNoteContext()) { + if (appContext.tabManager.getActiveContext().getMainNoteContext() === data.noteContext.getMainNoteContext()) { promises.push(widget.handleEvent('activeTabChanged', data)); } @@ -95,14 +95,14 @@ export default class PaneContainer extends FlexContainer { continue; } - if (subNoteContext === data.noteContext && (subWidget.hasBeenAlreadyShown || name === 'tabNoteSwitchedAndActivated')) { + if (subNoteContext === data.noteContext && (subWidget.hasBeenAlreadyShown || name === 'noteSwitchedAndActivated')) { subWidget.hasBeenAlreadyShown = true; - promises.push(widget.handleEvent('tabNoteSwitched', data)); + promises.push(widget.handleEvent('noteSwitched', data)); } } - if (name === 'tabNoteSwitchedAndActivated') { + if (name === 'noteSwitchedAndActivated') { this.toggleExt(true); } diff --git a/src/public/app/widgets/containers/root_container.js b/src/public/app/widgets/containers/root_container.js index 76ae978b9..e2c353e8a 100644 --- a/src/public/app/widgets/containers/root_container.js +++ b/src/public/app/widgets/containers/root_container.js @@ -12,7 +12,7 @@ export default class RootContainer extends FlexContainer { refresh() { this.$widget.removeClass(); // remove all classes - const note = appContext.tabManager.getActiveTabNote(); + const note = appContext.tabManager.getActiveContextNote(); if (note) { this.$widget.addClass(note.getCssClass()); @@ -41,7 +41,7 @@ export default class RootContainer extends FlexContainer { this.setZenMode(!this.isZenModeActive); } - tabNoteSwitchedEvent() { + noteSwitchedEvent() { this.refresh(); } @@ -49,7 +49,7 @@ export default class RootContainer extends FlexContainer { this.refresh(); } - tabNoteSwitchedAndActivatedEvent() { + noteSwitchedAndActivatedEvent() { this.refresh(); } diff --git a/src/public/app/widgets/containers/scrolling_container.js b/src/public/app/widgets/containers/scrolling_container.js index f69d5dad6..b9329ebe7 100644 --- a/src/public/app/widgets/containers/scrolling_container.js +++ b/src/public/app/widgets/containers/scrolling_container.js @@ -7,7 +7,7 @@ export default class ScrollingContainer extends Container { this.css('height: 100%; overflow: auto;'); } - async tabNoteSwitchedEvent({noteContext, notePath}) { + async noteSwitchedEvent({noteContext, notePath}) { // if notePath does not match then the noteContext has been switched to another note in the mean time if (noteContext.notePath === notePath) { this.$widget.scrollTop(0); diff --git a/src/public/app/widgets/mobile_widgets/mobile_detail_menu.js b/src/public/app/widgets/mobile_widgets/mobile_detail_menu.js index 4b59cfab1..be20afe75 100644 --- a/src/public/app/widgets/mobile_widgets/mobile_detail_menu.js +++ b/src/public/app/widgets/mobile_widgets/mobile_detail_menu.js @@ -13,7 +13,7 @@ class MobileDetailMenuWidget extends BasicWidget { this.overflowing(); this.$widget.on("click", async e => { - const note = appContext.tabManager.getActiveTabNote(); + const note = appContext.tabManager.getActiveContextNote(); contextMenu.show({ x: e.pageX, @@ -26,10 +26,10 @@ class MobileDetailMenuWidget extends BasicWidget { ], selectMenuItemHandler: async ({command}) => { if (command === "insertChildNote") { - noteCreateService.createNote(appContext.tabManager.getActiveTabNotePath()); + noteCreateService.createNote(appContext.tabManager.getActiveContextNotePath()); } else if (command === "delete") { - const notePath = appContext.tabManager.getActiveTabNotePath(); + const notePath = appContext.tabManager.getActiveContextNotePath(); const branchId = await treeService.getBranchIdFromNotePath(notePath); if (!branchId) { diff --git a/src/public/app/widgets/note_actions.js b/src/public/app/widgets/note_actions.js index 224f67b4e..879f11e06 100644 --- a/src/public/app/widgets/note_actions.js +++ b/src/public/app/widgets/note_actions.js @@ -1,4 +1,4 @@ -import TabAwareWidget from "./tab_aware_widget.js"; +import NoteContextAwareWidget from "./note_context_aware_widget.js"; import protectedSessionService from "../services/protected_session.js"; import utils from "../services/utils.js"; @@ -100,7 +100,7 @@ const TPL = ` `; -export default class NoteActionsWidget extends TabAwareWidget { +export default class NoteActionsWidget extends NoteContextAwareWidget { doRender() { this.$widget = $(TPL); this.overflowing(); diff --git a/src/public/app/widgets/tab_aware_widget.js b/src/public/app/widgets/note_context_aware_widget.js similarity index 91% rename from src/public/app/widgets/tab_aware_widget.js rename to src/public/app/widgets/note_context_aware_widget.js index ccf8bd7d3..9f9dce144 100644 --- a/src/public/app/widgets/tab_aware_widget.js +++ b/src/public/app/widgets/note_context_aware_widget.js @@ -1,7 +1,7 @@ import BasicWidget from "./basic_widget.js"; import appContext from "../services/app_context.js"; -export default class TabAwareWidget extends BasicWidget { +export default class NoteContextAwareWidget extends BasicWidget { isTab(ntxId) { if (Array.isArray(ntxId)) { return this.noteContext && ntxId.includes(this.noteContext.ntxId); @@ -59,7 +59,7 @@ export default class TabAwareWidget extends BasicWidget { async refreshWithNote(note) {} - async tabNoteSwitchedEvent({noteContext, notePath}) { + async noteSwitchedEvent({noteContext, notePath}) { // if notePath does not match then the noteContext has been switched to another note in the mean time if (noteContext.notePath === notePath) { await this.noteSwitched(); @@ -81,7 +81,7 @@ export default class TabAwareWidget extends BasicWidget { } // when note is both switched and activated, this should not produce double refresh - async tabNoteSwitchedAndActivatedEvent({noteContext, notePath}) { + async noteSwitchedAndActivatedEvent({noteContext, notePath}) { this.noteContext = noteContext; // if notePath does not match then the noteContext has been switched to another note in the mean time @@ -107,7 +107,7 @@ export default class TabAwareWidget extends BasicWidget { async lazyLoadedEvent() { if (!this.noteContext) { // has not been loaded yet - this.noteContext = appContext.tabManager.getActiveNoteContext(); + this.noteContext = appContext.tabManager.getActiveContext(); } await this.refresh(); diff --git a/src/public/app/widgets/tab_caching_widget.js b/src/public/app/widgets/note_context_caching_widget.js similarity index 87% rename from src/public/app/widgets/tab_caching_widget.js rename to src/public/app/widgets/note_context_caching_widget.js index a259d3320..1dd1f479d 100644 --- a/src/public/app/widgets/tab_caching_widget.js +++ b/src/public/app/widgets/note_context_caching_widget.js @@ -1,7 +1,7 @@ -import TabAwareWidget from "./tab_aware_widget.js"; +import NoteContextAwareWidget from "./note_context_aware_widget.js"; import keyboardActionsService from "../services/keyboard_actions.js"; -export default class TabCachingWidget extends TabAwareWidget { +export default class NoteContextCachingWidget extends NoteContextAwareWidget { constructor(widgetFactory) { super(); @@ -13,7 +13,7 @@ export default class TabCachingWidget extends TabAwareWidget { return this.$widget = $(` `; -export default class NoteIconWidget extends TabAwareWidget { +export default class NoteIconWidget extends NoteContextAwareWidget { doRender() { this.$widget = $(TPL); this.overflowing(); diff --git a/src/public/app/widgets/note_list.js b/src/public/app/widgets/note_list.js index b80cf288d..5107a82f4 100644 --- a/src/public/app/widgets/note_list.js +++ b/src/public/app/widgets/note_list.js @@ -1,4 +1,4 @@ -import TabAwareWidget from "./tab_aware_widget.js"; +import NoteContextAwareWidget from "./note_context_aware_widget.js"; import NoteListRenderer from "../services/note_list_renderer.js"; const TPL = ` @@ -20,7 +20,7 @@ const TPL = ` `; -export default class NoteListWidget extends TabAwareWidget { +export default class NoteListWidget extends NoteContextAwareWidget { isEnabled() { return super.isEnabled() && ['book', 'text', 'code'].includes(this.note.type) diff --git a/src/public/app/widgets/note_paths.js b/src/public/app/widgets/note_paths.js index d18a664af..017ecb7bc 100644 --- a/src/public/app/widgets/note_paths.js +++ b/src/public/app/widgets/note_paths.js @@ -1,4 +1,4 @@ -import TabAwareWidget from "./tab_aware_widget.js"; +import NoteContextAwareWidget from "./note_context_aware_widget.js"; import treeService from "../services/tree.js"; import linkService from "../services/link.js"; @@ -36,7 +36,7 @@ const TPL = ` `; -export default class NotePathsWidget extends TabAwareWidget { +export default class NotePathsWidget extends NoteContextAwareWidget { doRender() { this.$widget = $(TPL); this.overflowing(); diff --git a/src/public/app/widgets/note_title.js b/src/public/app/widgets/note_title.js index 5d72725a0..6314a7e4f 100644 --- a/src/public/app/widgets/note_title.js +++ b/src/public/app/widgets/note_title.js @@ -1,4 +1,4 @@ -import TabAwareWidget from "./tab_aware_widget.js"; +import NoteContextAwareWidget from "./note_context_aware_widget.js"; import utils from "../services/utils.js"; import protectedSessionHolder from "../services/protected_session_holder.js"; import server from "../services/server.js"; @@ -27,7 +27,7 @@ const TPL = ` `; -export default class NoteTitleWidget extends TabAwareWidget { +export default class NoteTitleWidget extends NoteContextAwareWidget { constructor() { super(); diff --git a/src/public/app/widgets/note_tree.js b/src/public/app/widgets/note_tree.js index b4debd422..7d5362409 100644 --- a/src/public/app/widgets/note_tree.js +++ b/src/public/app/widgets/note_tree.js @@ -5,7 +5,7 @@ import contextMenu from "../services/context_menu.js"; import froca from "../services/froca.js"; import branchService from "../services/branches.js"; import ws from "../services/ws.js"; -import TabAwareWidget from "./tab_aware_widget.js"; +import NoteContextAwareWidget from "./note_context_aware_widget.js"; import server from "../services/server.js"; import noteCreateService from "../services/note_create.js"; import toastService from "../services/toast.js"; @@ -197,7 +197,7 @@ const TPL = ` const MAX_SEARCH_RESULTS_IN_TREE = 100; -export default class NoteTreeWidget extends TabAwareWidget { +export default class NoteTreeWidget extends NoteContextAwareWidget { constructor(treeName) { super(); @@ -395,7 +395,7 @@ export default class NoteTreeWidget extends TabAwareWidget { const notePath = treeService.getNotePath(data.node); - const activeNoteContext = appContext.tabManager.getActiveNoteContext(); + const activeNoteContext = appContext.tabManager.getActiveContext(); await activeNoteContext.setNote(notePath); if (utils.isMobile()) { @@ -525,7 +525,7 @@ export default class NoteTreeWidget extends TabAwareWidget { } const note = await froca.getNote(node.data.noteId); - const activeNoteContext = appContext.tabManager.getActiveNoteContext(); + const activeNoteContext = appContext.tabManager.getActiveContext(); const $span = $(node.span); @@ -810,7 +810,7 @@ export default class NoteTreeWidget extends TabAwareWidget { } async scrollToActiveNoteEvent() { - const activeContext = appContext.tabManager.getActiveNoteContext(); + const activeContext = appContext.tabManager.getActiveContext(); if (activeContext && activeContext.notePath) { this.tree.$container.focus(); @@ -1162,7 +1162,7 @@ export default class NoteTreeWidget extends TabAwareWidget { // this should be done by NoteContext / TabManager and note tree should only listen to // changes in active note and just set the "active" state // We don't await since that can bring up infinite cycles when e.g. custom widget does some backend requests which wait for max sync ID processed - appContext.tabManager.getActiveNoteContext().setNote(nextNotePath).then(() => { + appContext.tabManager.getActiveContext().setNote(nextNotePath).then(() => { const newActiveNode = this.getActiveNode(); // return focus if the previously active node was also focused diff --git a/src/public/app/widgets/note_type.js b/src/public/app/widgets/note_type.js index 28759c1f3..038d6c23a 100644 --- a/src/public/app/widgets/note_type.js +++ b/src/public/app/widgets/note_type.js @@ -1,6 +1,6 @@ import server from '../services/server.js'; import mimeTypesService from '../services/mime_types.js'; -import TabAwareWidget from "./tab_aware_widget.js"; +import NoteContextAwareWidget from "./note_context_aware_widget.js"; const NOTE_TYPES = [ { type: "file", title: "File", selectable: false }, @@ -31,7 +31,7 @@ const TPL = ` `; -export default class NoteTypeWidget extends TabAwareWidget { +export default class NoteTypeWidget extends NoteContextAwareWidget { doRender() { this.$widget = $(TPL); this.overflowing(); diff --git a/src/public/app/widgets/note_update_status.js b/src/public/app/widgets/note_update_status.js index 36f0f11a2..dfbc8cab7 100644 --- a/src/public/app/widgets/note_update_status.js +++ b/src/public/app/widgets/note_update_status.js @@ -1,4 +1,4 @@ -import TabAwareWidget from "./tab_aware_widget.js"; +import NoteContextAwareWidget from "./note_context_aware_widget.js"; import server from "../services/server.js"; import fileWatcher from "../services/file_watcher.js"; @@ -19,7 +19,7 @@ const TPL = ` `; -export default class NoteUpdateStatusWidget extends TabAwareWidget { +export default class NoteUpdateStatusWidget extends NoteContextAwareWidget { isEnabled() { return super.isEnabled() && !!fileWatcher.getFileModificationStatus(this.noteId); diff --git a/src/public/app/widgets/quick_search.js b/src/public/app/widgets/quick_search.js index 23bf9e64d..d398fd784 100644 --- a/src/public/app/widgets/quick_search.js +++ b/src/public/app/widgets/quick_search.js @@ -98,13 +98,13 @@ export default class QuickSearchWidget extends BasicWidget { if (!e.target || e.target.nodeName !== 'A') { // click on the link is handled by link handling but we want the whole item clickable - appContext.tabManager.getActiveNoteContext().setNote(note.noteId); + appContext.tabManager.getActiveContext().setNote(note.noteId); } }); utils.bindElShortcut($link, 'return', () => { this.$dropdownToggle.dropdown("hide"); - appContext.tabManager.getActiveNoteContext().setNote(note.noteId); + appContext.tabManager.getActiveContext().setNote(note.noteId); }); this.$dropdownMenu.append($link); @@ -131,7 +131,7 @@ export default class QuickSearchWidget extends BasicWidget { async showInFullSearch() { const searchNote = await dateNotesService.createSearchNote({searchString: this.$searchString.val()}); - await appContext.tabManager.getActiveNoteContext().setNote(searchNote.noteId); + await appContext.tabManager.getActiveContext().setNote(searchNote.noteId); } quickSearchEvent() { diff --git a/src/public/app/widgets/search_result.js b/src/public/app/widgets/search_result.js index 2290e9887..a4a9c944d 100644 --- a/src/public/app/widgets/search_result.js +++ b/src/public/app/widgets/search_result.js @@ -1,4 +1,4 @@ -import TabAwareWidget from "./tab_aware_widget.js"; +import NoteContextAwareWidget from "./note_context_aware_widget.js"; import NoteListRenderer from "../services/note_list_renderer.js"; const TPL = ` @@ -33,7 +33,7 @@ const TPL = ` `; -export default class SearchResultWidget extends TabAwareWidget { +export default class SearchResultWidget extends NoteContextAwareWidget { isEnabled() { return super.isEnabled() && this.note.type === 'search'; diff --git a/src/public/app/widgets/similar_notes.js b/src/public/app/widgets/similar_notes.js index 95356ef4a..a23c8bb2e 100644 --- a/src/public/app/widgets/similar_notes.js +++ b/src/public/app/widgets/similar_notes.js @@ -1,7 +1,7 @@ import linkService from "../services/link.js"; import server from "../services/server.js"; import froca from "../services/froca.js"; -import TabAwareWidget from "./tab_aware_widget.js"; +import NoteContextAwareWidget from "./note_context_aware_widget.js"; import options from "../services/options.js"; const TPL = ` @@ -39,7 +39,7 @@ const TPL = ` `; -export default class SimilarNotesWidget extends TabAwareWidget { +export default class SimilarNotesWidget extends NoteContextAwareWidget { isEnabled() { return super.isEnabled() && this.note.type !== 'search' diff --git a/src/public/app/widgets/sql_result.js b/src/public/app/widgets/sql_result.js index 784d3d872..4fed6803e 100644 --- a/src/public/app/widgets/sql_result.js +++ b/src/public/app/widgets/sql_result.js @@ -1,4 +1,4 @@ -import TabAwareWidget from "./tab_aware_widget.js"; +import NoteContextAwareWidget from "./note_context_aware_widget.js"; const TPL = `
@@ -11,7 +11,7 @@ const TPL = `
`; -export default class SqlResultWidget extends TabAwareWidget { +export default class SqlResultWidget extends NoteContextAwareWidget { isEnabled() { return this.note && this.note.mime === 'text/x-sqlite;schema=trilium' diff --git a/src/public/app/widgets/sql_table_schemas.js b/src/public/app/widgets/sql_table_schemas.js index 039eaf01e..5fdf08c51 100644 --- a/src/public/app/widgets/sql_table_schemas.js +++ b/src/public/app/widgets/sql_table_schemas.js @@ -1,4 +1,4 @@ -import TabAwareWidget from "./tab_aware_widget.js"; +import NoteContextAwareWidget from "./note_context_aware_widget.js"; import treeService from "../services/tree.js"; import linkService from "../services/link.js"; import hoistedNoteService from "../services/hoisted_note.js"; @@ -33,7 +33,7 @@ const TPL = ` `; -export default class SqlTableSchemasWidget extends TabAwareWidget { +export default class SqlTableSchemasWidget extends NoteContextAwareWidget { isEnabled() { return this.note && this.note.mime === 'text/x-sqlite;schema=trilium' diff --git a/src/public/app/widgets/tab_row.js b/src/public/app/widgets/tab_row.js index ca56ea377..6fd35c1f5 100644 --- a/src/public/app/widgets/tab_row.js +++ b/src/public/app/widgets/tab_row.js @@ -409,13 +409,13 @@ export default class TabRowWidget extends BasicWidget { closeActiveTabCommand({$el}) { const ntxId = $el.closest(".note-tab").attr('data-tab-id'); - appContext.tabManager.removeTab(ntxId); + appContext.tabManager.removeNoteContext(ntxId); } setTabCloseEvent($tab) { $tab.on('mousedown', e => { if (e.which === 2) { - appContext.tabManager.removeTab($tab.attr('data-tab-id')); + appContext.tabManager.removeNoteContext($tab.attr('data-tab-id')); return true; // event has been handled } @@ -427,7 +427,7 @@ export default class TabRowWidget extends BasicWidget { } activeTabChangedEvent() { - let activeNoteContext = appContext.tabManager.getActiveNoteContext(); + let activeNoteContext = appContext.tabManager.getActiveContext(); if (!activeNoteContext) { return; @@ -444,7 +444,7 @@ export default class TabRowWidget extends BasicWidget { if (tabEl) tabEl.setAttribute('active', ''); } - newTabOpenedEvent({noteContext}) { + newNoteContextCreatedEvent({noteContext}) { if (!noteContext.mainNtxId) { this.addTab(noteContext.ntxId); } @@ -478,7 +478,7 @@ export default class TabRowWidget extends BasicWidget { return $tab.attr('data-tab-id'); } - tabRemovedEvent({ntxIds}) { + noteContextRemovedEvent({ntxIds}) { for (const ntxId of ntxIds) { this.removeTab(ntxId); } @@ -517,7 +517,7 @@ export default class TabRowWidget extends BasicWidget { this.draggabillies.push(draggabilly); draggabilly.on('pointerDown', _ => { - appContext.tabManager.activateTab(tabEl.getAttribute('data-tab-id')); + appContext.tabManager.activateNoteContext(tabEl.getAttribute('data-tab-id')); }); draggabilly.on('dragStart', _ => { @@ -611,13 +611,13 @@ export default class TabRowWidget extends BasicWidget { return closestIndex; }; - tabNoteSwitchedAndActivatedEvent({noteContext}) { + noteSwitchedAndActivatedEvent({noteContext}) { this.activeTabChangedEvent(); this.updateTabById(noteContext.mainNtxId || noteContext.ntxId); } - tabNoteSwitchedEvent({noteContext}) { + noteSwitchedEvent({noteContext}) { this.updateTabById(noteContext.mainNtxId || noteContext.ntxId); } diff --git a/src/public/app/widgets/type_property_widgets/file_properties.js b/src/public/app/widgets/type_property_widgets/file_properties.js index cf0398222..517eabbf1 100644 --- a/src/public/app/widgets/type_property_widgets/file_properties.js +++ b/src/public/app/widgets/type_property_widgets/file_properties.js @@ -1,5 +1,5 @@ import server from "../../services/server.js"; -import TabAwareWidget from "../tab_aware_widget.js"; +import NoteContextAwareWidget from "../note_context_aware_widget.js"; import toastService from "../../services/toast.js"; import openService from "../../services/open.js"; import utils from "../../services/utils.js"; @@ -54,7 +54,7 @@ const TPL = ` `; -export default class FilePropertiesWidget extends TabAwareWidget { +export default class FilePropertiesWidget extends NoteContextAwareWidget { static getType() { return "file"; } isEnabled() { diff --git a/src/public/app/widgets/type_property_widgets/image_properties.js b/src/public/app/widgets/type_property_widgets/image_properties.js index ef713b331..b72b0e126 100644 --- a/src/public/app/widgets/type_property_widgets/image_properties.js +++ b/src/public/app/widgets/type_property_widgets/image_properties.js @@ -1,5 +1,5 @@ import server from "../../services/server.js"; -import TabAwareWidget from "../tab_aware_widget.js"; +import NoteContextAwareWidget from "../note_context_aware_widget.js"; import toastService from "../../services/toast.js"; import openService from "../../services/open.js"; import utils from "../../services/utils.js"; @@ -36,7 +36,7 @@ const TPL = ` `; -export default class ImagePropertiesWidget extends TabAwareWidget { +export default class ImagePropertiesWidget extends NoteContextAwareWidget { static getType() { return "image"; } isEnabled() { diff --git a/src/public/app/widgets/type_property_widgets/inherited_attribute_list.js b/src/public/app/widgets/type_property_widgets/inherited_attribute_list.js index 32fbfb8c7..96f15f0c5 100644 --- a/src/public/app/widgets/type_property_widgets/inherited_attribute_list.js +++ b/src/public/app/widgets/type_property_widgets/inherited_attribute_list.js @@ -1,4 +1,4 @@ -import TabAwareWidget from "../tab_aware_widget.js"; +import NoteContextAwareWidget from "../note_context_aware_widget.js"; import AttributeDetailWidget from "../attribute_widgets/attribute_detail.js"; import attributeRenderer from "../../services/attribute_renderer.js"; @@ -20,7 +20,7 @@ const TPL = `
`; -export default class InheritedAttributesWidget extends TabAwareWidget { +export default class InheritedAttributesWidget extends NoteContextAwareWidget { constructor() { super(); diff --git a/src/public/app/widgets/type_property_widgets/note_properties.js b/src/public/app/widgets/type_property_widgets/note_properties.js index 506eb62ec..6870f0dbc 100644 --- a/src/public/app/widgets/type_property_widgets/note_properties.js +++ b/src/public/app/widgets/type_property_widgets/note_properties.js @@ -1,4 +1,4 @@ -import TabAwareWidget from "../tab_aware_widget.js"; +import NoteContextAwareWidget from "../note_context_aware_widget.js"; const TPL = `
@@ -14,7 +14,7 @@ const TPL = `
`; -export default class NotePropertiesWidget extends TabAwareWidget { +export default class NotePropertiesWidget extends NoteContextAwareWidget { static getType() { return "note-properties"; } isEnabled() { diff --git a/src/public/app/widgets/type_property_widgets/owned_attribute_list.js b/src/public/app/widgets/type_property_widgets/owned_attribute_list.js index 0ac92854d..41ceff51e 100644 --- a/src/public/app/widgets/type_property_widgets/owned_attribute_list.js +++ b/src/public/app/widgets/type_property_widgets/owned_attribute_list.js @@ -1,4 +1,4 @@ -import TabAwareWidget from "../tab_aware_widget.js"; +import NoteContextAwareWidget from "../note_context_aware_widget.js"; import AttributeDetailWidget from "../attribute_widgets/attribute_detail.js"; import AttributeEditorWidget from "../attribute_widgets/attribute_editor.js"; @@ -21,7 +21,7 @@ const TPL = ` `; -export default class OwnedAttributeListWidget extends TabAwareWidget { +export default class OwnedAttributeListWidget extends NoteContextAwareWidget { constructor() { super(); diff --git a/src/public/app/widgets/type_property_widgets/promoted_attributes.js b/src/public/app/widgets/type_property_widgets/promoted_attributes.js index 80b54ab02..27d13d286 100644 --- a/src/public/app/widgets/type_property_widgets/promoted_attributes.js +++ b/src/public/app/widgets/type_property_widgets/promoted_attributes.js @@ -2,7 +2,7 @@ import server from "../../services/server.js"; import ws from "../../services/ws.js"; import treeService from "../../services/tree.js"; import noteAutocompleteService from "../../services/note_autocomplete.js"; -import TabAwareWidget from "../tab_aware_widget.js"; +import NoteContextAwareWidget from "../note_context_aware_widget.js"; const TPL = `
@@ -34,7 +34,7 @@ const TPL = `
`; -export default class PromotedAttributesWidget extends TabAwareWidget { +export default class PromotedAttributesWidget extends NoteContextAwareWidget { doRender() { this.$widget = $(TPL); this.overflowing(); diff --git a/src/public/app/widgets/type_property_widgets/search_definition.js b/src/public/app/widgets/type_property_widgets/search_definition.js index 8681c10c5..41b983aa2 100644 --- a/src/public/app/widgets/type_property_widgets/search_definition.js +++ b/src/public/app/widgets/type_property_widgets/search_definition.js @@ -1,5 +1,5 @@ import server from "../../services/server.js"; -import TabAwareWidget from "../tab_aware_widget.js"; +import NoteContextAwareWidget from "../note_context_aware_widget.js"; import froca from "../../services/froca.js"; import ws from "../../services/ws.js"; import toastService from "../../services/toast.js"; @@ -199,7 +199,7 @@ for (const clazz of [ ACTION_CLASSES[clazz.actionName] = clazz; } -export default class SearchDefinitionWidget extends TabAwareWidget { +export default class SearchDefinitionWidget extends NoteContextAwareWidget { static getType() { return "search"; } isEnabled() { diff --git a/src/public/app/widgets/type_widgets/abstract_text_type_widget.js b/src/public/app/widgets/type_widgets/abstract_text_type_widget.js index db98d6c78..9a9e633db 100644 --- a/src/public/app/widgets/type_widgets/abstract_text_type_widget.js +++ b/src/public/app/widgets/type_widgets/abstract_text_type_widget.js @@ -23,7 +23,7 @@ export default class AbstractTextTypeWidget extends TypeWidget { const noteId = this.getNoteIdFromImage(imgSrc); if (noteId) { - appContext.tabManager.getActiveNoteContext().setNote(noteId); + appContext.tabManager.getActiveContext().setNote(noteId); } else { window.open(imgSrc, '_blank'); } diff --git a/src/public/app/widgets/type_widgets/empty.js b/src/public/app/widgets/type_widgets/empty.js index 62ffd876b..d0335322b 100644 --- a/src/public/app/widgets/type_widgets/empty.js +++ b/src/public/app/widgets/type_widgets/empty.js @@ -61,7 +61,7 @@ export default class EmptyTypeWidget extends TypeWidget { return false; } - appContext.tabManager.getActiveNoteContext().setNote(suggestion.notePath); + appContext.tabManager.getActiveContext().setNote(suggestion.notePath); }); noteAutocompleteService.showRecentNotes(this.$autoComplete); diff --git a/src/public/app/widgets/type_widgets/type_widget.js b/src/public/app/widgets/type_widgets/type_widget.js index b75ba2573..eae9465f9 100644 --- a/src/public/app/widgets/type_widgets/type_widget.js +++ b/src/public/app/widgets/type_widgets/type_widget.js @@ -1,6 +1,6 @@ -import TabAwareWidget from "../tab_aware_widget.js"; +import NoteContextAwareWidget from "../note_context_aware_widget.js"; -export default class TypeWidget extends TabAwareWidget { +export default class TypeWidget extends NoteContextAwareWidget { // for overriding static getType() {}