mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 04:51:31 +08:00 
			
		
		
		
	refactored TabContext => NoteContext
This commit is contained in:
		
							parent
							
								
									274cf7312c
								
							
						
					
					
						commit
						79a85a0aa7
					
				| @ -20,7 +20,7 @@ export async function showDialog() { | |||||||
|                 return false; |                 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
 |     // if you open the Jump To dialog soon after using it previously it can often mean that you
 | ||||||
|  | |||||||
| @ -27,7 +27,7 @@ export async function showDialog() { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| $dialog.on('shown.bs.modal', () => { | $dialog.on('shown.bs.modal', () => { | ||||||
|     const note = appContext.tabManager.getActiveTabNote(); |     const note = appContext.tabManager.getActiveContextNote(); | ||||||
| 
 | 
 | ||||||
|     linkMapService = new LinkMapService(note, $linkMapContainer, getOptions()); |     linkMapService = new LinkMapService(note, $linkMapContainer, getOptions()); | ||||||
|     linkMapService.render(); |     linkMapService.render(); | ||||||
|  | |||||||
| @ -29,7 +29,7 @@ async function convertMarkdownToHtml(text) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export async function importMarkdownInline() { | export async function importMarkdownInline() { | ||||||
|     if (appContext.tabManager.getActiveTabNoteType() !== 'text') { |     if (appContext.tabManager.getActiveContextNoteType() !== 'text') { | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -58,4 +58,4 @@ $importButton.on('click', sendForm); | |||||||
| 
 | 
 | ||||||
| $dialog.on('shown.bs.modal', () => $importTextarea.trigger('focus')); | $dialog.on('shown.bs.modal', () => $importTextarea.trigger('focus')); | ||||||
| 
 | 
 | ||||||
| utils.bindElShortcut($dialog, 'ctrl+return', sendForm); | utils.bindElShortcut($dialog, 'ctrl+return', sendForm); | ||||||
|  | |||||||
| @ -12,7 +12,7 @@ const $okButton = $("#note-info-ok-button"); | |||||||
| export async function showDialog() { | export async function showDialog() { | ||||||
|     utils.openDialog($dialog); |     utils.openDialog($dialog); | ||||||
| 
 | 
 | ||||||
|     const activeNoteContext = appContext.tabManager.getActiveNoteContext(); |     const activeNoteContext = appContext.tabManager.getActiveContext(); | ||||||
|     const {note} = activeNoteContext; |     const {note} = activeNoteContext; | ||||||
|     const noteComplement = await activeNoteContext.getNoteComplement(); |     const noteComplement = await activeNoteContext.getNoteComplement(); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -27,7 +27,7 @@ let note; | |||||||
| let noteRevisionId; | let noteRevisionId; | ||||||
| 
 | 
 | ||||||
| export async function showCurrentNoteRevisions() { | export async function showCurrentNoteRevisions() { | ||||||
|     await showNoteRevisionsDialog(appContext.tabManager.getActiveTabNoteId()); |     await showNoteRevisionsDialog(appContext.tabManager.getActiveContextNoteId()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export async function showNoteRevisionsDialog(noteId, noteRevisionId) { | export async function showNoteRevisionsDialog(noteId, noteRevisionId) { | ||||||
| @ -41,7 +41,7 @@ async function loadNoteRevisions(noteId, noteRevId) { | |||||||
|     $content.empty(); |     $content.empty(); | ||||||
|     $titleButtons.empty(); |     $titleButtons.empty(); | ||||||
| 
 | 
 | ||||||
|     note = appContext.tabManager.getActiveTabNote(); |     note = appContext.tabManager.getActiveContextNote(); | ||||||
|     revisionItems = await server.get(`notes/${noteId}/revisions`); |     revisionItems = await server.get(`notes/${noteId}/revisions`); | ||||||
| 
 | 
 | ||||||
|     for (const item of revisionItems) { |     for (const item of revisionItems) { | ||||||
|  | |||||||
| @ -7,7 +7,7 @@ const $noteSource = $("#note-source"); | |||||||
| export async function showDialog() { | export async function showDialog() { | ||||||
|     utils.openDialog($dialog); |     utils.openDialog($dialog); | ||||||
| 
 | 
 | ||||||
|     const noteCompletement = await appContext.tabManager.getActiveNoteContext().getNoteComplement(); |     const noteCompletement = await appContext.tabManager.getActiveContext().getNoteComplement(); | ||||||
| 
 | 
 | ||||||
|     $noteSource.text(formatHtml(noteCompletement.content)); |     $noteSource.text(formatHtml(noteCompletement.content)); | ||||||
| } | } | ||||||
|  | |||||||
| @ -56,7 +56,7 @@ export async function showDialog(ancestorNoteId) { | |||||||
| 
 | 
 | ||||||
|                                 await froca.reloadNotes([change.noteId]); |                                 await froca.reloadNotes([change.noteId]); | ||||||
| 
 | 
 | ||||||
|                                 appContext.tabManager.getActiveNoteContext().setNote(change.noteId); |                                 appContext.tabManager.getActiveContext().setNote(change.noteId); | ||||||
|                             } |                             } | ||||||
|                         }); |                         }); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -5,7 +5,7 @@ import TitleBarButtonsWidget from "../widgets/title_bar_buttons.js"; | |||||||
| import StandardTopWidget from "../widgets/standard_top_widget.js"; | import StandardTopWidget from "../widgets/standard_top_widget.js"; | ||||||
| import SidePaneContainer from "../widgets/containers/side_pane_container.js"; | import SidePaneContainer from "../widgets/containers/side_pane_container.js"; | ||||||
| import NoteTreeWidget from "../widgets/note_tree.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 NotePathsWidget from "../widgets/note_paths.js"; | ||||||
| import NoteTitleWidget from "../widgets/note_title.js"; | import NoteTitleWidget from "../widgets/note_title.js"; | ||||||
| import OwnedAttributeListWidget from "../widgets/type_property_widgets/owned_attribute_list.js"; | import OwnedAttributeListWidget from "../widgets/type_property_widgets/owned_attribute_list.js"; | ||||||
|  | |||||||
| @ -161,7 +161,7 @@ $(window).on('hashchange', function() { | |||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         appContext.tabManager.switchToTab(ntxId, notePath); |         appContext.tabManager.switchToNoteContext(ntxId, notePath); | ||||||
|     } |     } | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -74,17 +74,17 @@ export default class Entrypoints extends Component { | |||||||
| 
 | 
 | ||||||
|         await ws.waitForMaxKnownEntityChangeId(); |         await ws.waitForMaxKnownEntityChangeId(); | ||||||
| 
 | 
 | ||||||
|         const hoistedNoteId = appContext.tabManager.getActiveNoteContext() |         const hoistedNoteId = appContext.tabManager.getActiveContext() | ||||||
|             ? appContext.tabManager.getActiveNoteContext().hoistedNoteId |             ? appContext.tabManager.getActiveContext().hoistedNoteId | ||||||
|             : 'root'; |             : 'root'; | ||||||
| 
 | 
 | ||||||
|         await appContext.tabManager.openTabWithNote(note.noteId, true, null, hoistedNoteId); |         await appContext.tabManager.openContextWithNote(note.noteId, true, null, hoistedNoteId); | ||||||
| 
 | 
 | ||||||
|         appContext.triggerEvent('focusAndSelectTitle'); |         appContext.triggerEvent('focusAndSelectTitle'); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async toggleNoteHoistingCommand() { |     async toggleNoteHoistingCommand() { | ||||||
|         const noteContext = appContext.tabManager.getActiveNoteContext(); |         const noteContext = appContext.tabManager.getActiveContext(); | ||||||
| 
 | 
 | ||||||
|         if (noteContext.note.noteId === noteContext.hoistedNoteId) { |         if (noteContext.note.noteId === noteContext.hoistedNoteId) { | ||||||
|             await noteContext.unhoist(); |             await noteContext.unhoist(); | ||||||
| @ -95,7 +95,7 @@ export default class Entrypoints extends Component { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async hoistNoteCommand({noteId}) { |     async hoistNoteCommand({noteId}) { | ||||||
|         const noteContext = appContext.tabManager.getActiveNoteContext(); |         const noteContext = appContext.tabManager.getActiveContext(); | ||||||
| 
 | 
 | ||||||
|         if (noteContext.hoistedNoteId !== noteId) { |         if (noteContext.hoistedNoteId !== noteId) { | ||||||
|             await noteContext.setHoistedNoteId(noteId); |             await noteContext.setHoistedNoteId(noteId); | ||||||
| @ -103,7 +103,7 @@ export default class Entrypoints extends Component { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async unhoistCommand() { |     async unhoistCommand() { | ||||||
|         const activeNoteContext = appContext.tabManager.getActiveNoteContext(); |         const activeNoteContext = appContext.tabManager.getActiveContext(); | ||||||
| 
 | 
 | ||||||
|         if (activeNoteContext) { |         if (activeNoteContext) { | ||||||
|             activeNoteContext.unhoist(); |             activeNoteContext.unhoist(); | ||||||
| @ -194,7 +194,7 @@ export default class Entrypoints extends Component { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async runActiveNoteCommand() { |     async runActiveNoteCommand() { | ||||||
|         const noteContext = appContext.tabManager.getActiveNoteContext(); |         const noteContext = appContext.tabManager.getActiveContext(); | ||||||
|         const note = noteContext.note; |         const note = noteContext.note; | ||||||
| 
 | 
 | ||||||
|         // ctrl+enter is also used elsewhere so make sure we're running only when appropriate
 |         // 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"); |         $(".tooltip").removeClass("show"); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     tabNoteSwitchedEvent() { |     noteSwitchedEvent() { | ||||||
|         this.hideAllTooltips(); |         this.hideAllTooltips(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -10,8 +10,8 @@ import searchService from './search.js'; | |||||||
| import CollapsibleWidget from '../widgets/collapsible_widget.js'; | import CollapsibleWidget from '../widgets/collapsible_widget.js'; | ||||||
| import ws from "./ws.js"; | import ws from "./ws.js"; | ||||||
| import appContext from "./app_context.js"; | import appContext from "./app_context.js"; | ||||||
| import TabAwareWidget from "../widgets/tab_aware_widget.js"; | import NoteContextAwareWidget from "../widgets/note_context_aware_widget.js"; | ||||||
| import TabCachingWidget from "../widgets/tab_caching_widget.js"; | import NoteContextCachingWidget from "../widgets/note_context_caching_widget.js"; | ||||||
| import BasicWidget from "../widgets/basic_widget.js"; | import BasicWidget from "../widgets/basic_widget.js"; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
| @ -39,11 +39,11 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain | |||||||
|     /** @property {CollapsibleWidget} */ |     /** @property {CollapsibleWidget} */ | ||||||
|     this.CollapsibleWidget = CollapsibleWidget; |     this.CollapsibleWidget = CollapsibleWidget; | ||||||
| 
 | 
 | ||||||
|     /** @property {TabAwareWidget} */ |     /** @property {NoteContextAwareWidget} */ | ||||||
|     this.TabAwareWidget = TabAwareWidget; |     this.TabAwareWidget = NoteContextAwareWidget; | ||||||
| 
 | 
 | ||||||
|     /** @property {TabCachingWidget} */ |     /** @property {NoteContextCachingWidget} */ | ||||||
|     this.TabCachingWidget = TabCachingWidget; |     this.TabCachingWidget = NoteContextCachingWidget; | ||||||
| 
 | 
 | ||||||
|     /** @property {BasicWidget} */ |     /** @property {BasicWidget} */ | ||||||
|     this.BasicWidget = BasicWidget; |     this.BasicWidget = BasicWidget; | ||||||
| @ -56,7 +56,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain | |||||||
|      * @returns {Promise<void>} |      * @returns {Promise<void>} | ||||||
|      */ |      */ | ||||||
|     this.activateNote = async notePath => { |     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 => { |     this.activateNewNote = async notePath => { | ||||||
|         await ws.waitForMaxKnownEntityChangeId(); |         await ws.waitForMaxKnownEntityChangeId(); | ||||||
| 
 | 
 | ||||||
|         await appContext.tabManager.getActiveNoteContext().setNote(notePath); |         await appContext.tabManager.getActiveContext().setNote(notePath); | ||||||
|         appContext.triggerEvent('focusAndSelectTitle'); |         appContext.triggerEvent('focusAndSelectTitle'); | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
| @ -82,7 +82,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain | |||||||
|     this.openTabWithNote = async (notePath, activate) => { |     this.openTabWithNote = async (notePath, activate) => { | ||||||
|         await ws.waitForMaxKnownEntityChangeId(); |         await ws.waitForMaxKnownEntityChangeId(); | ||||||
| 
 | 
 | ||||||
|         await appContext.tabManager.openTabWithNote(notePath, activate); |         await appContext.tabManager.openContextWithNote(notePath, activate); | ||||||
| 
 | 
 | ||||||
|         if (activate) { |         if (activate) { | ||||||
|             appContext.triggerEvent('focusAndSelectTitle'); |             appContext.triggerEvent('focusAndSelectTitle'); | ||||||
| @ -313,7 +313,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain | |||||||
|      * @method |      * @method | ||||||
|      * @returns {NoteShort} active note (loaded into right pane) |      * @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.
 |      * 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 |      * @method | ||||||
|      * @returns {Promise<string|null>} returns note path of active note or null if there isn't active note |      * @returns {Promise<string|null>} 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 |      * @method | ||||||
| @ -340,7 +340,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain | |||||||
|      * @method |      * @method | ||||||
|      */ |      */ | ||||||
|     this.protectActiveNote = async () => { |     this.protectActiveNote = async () => { | ||||||
|         const activeNote = appContext.tabManager.getActiveTabNote(); |         const activeNote = appContext.tabManager.getActiveContextNote(); | ||||||
| 
 | 
 | ||||||
|         await protectedSessionService.protectNote(activeNote.noteId, true, false); |         await protectedSessionService.protectNote(activeNote.noteId, true, false); | ||||||
|     }; |     }; | ||||||
| @ -406,7 +406,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain | |||||||
|      * @return {Promise} |      * @return {Promise} | ||||||
|      */ |      */ | ||||||
|     this.setHoistedNoteId = (noteId) => { |     this.setHoistedNoteId = (noteId) => { | ||||||
|         const activeNoteContext = appContext.tabManager.getActiveNoteContext(); |         const activeNoteContext = appContext.tabManager.getActiveContext(); | ||||||
| 
 | 
 | ||||||
|         if (activeNoteContext) { |         if (activeNoteContext) { | ||||||
|             activeNoteContext.setHoistedNoteId(noteId); |             activeNoteContext.setHoistedNoteId(noteId); | ||||||
|  | |||||||
| @ -16,7 +16,7 @@ function setupGlobs() { | |||||||
|     window.glob.getHeaders = server.getHeaders; |     window.glob.getHeaders = server.getHeaders; | ||||||
| 
 | 
 | ||||||
|     // required for ESLint plugin and CKEditor
 |     // 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.requireLibrary = libraryLoader.requireLibrary; | ||||||
|     window.glob.ESLINT = libraryLoader.ESLINT; |     window.glob.ESLINT = libraryLoader.ESLINT; | ||||||
|     window.glob.appContext = appContext; // for debugging
 |     window.glob.appContext = appContext; // for debugging
 | ||||||
|  | |||||||
| @ -2,13 +2,13 @@ import appContext from "./app_context.js"; | |||||||
| import treeService from "./tree.js"; | import treeService from "./tree.js"; | ||||||
| 
 | 
 | ||||||
| function getHoistedNoteId() { | function getHoistedNoteId() { | ||||||
|     const activeNoteContext = appContext.tabManager.getActiveNoteContext(); |     const activeNoteContext = appContext.tabManager.getActiveContext(); | ||||||
| 
 | 
 | ||||||
|     return activeNoteContext ? activeNoteContext.hoistedNoteId : 'root'; |     return activeNoteContext ? activeNoteContext.hoistedNoteId : 'root'; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| async function unhoist() { | async function unhoist() { | ||||||
|     const activeNoteContext = appContext.tabManager.getActiveNoteContext(); |     const activeNoteContext = appContext.tabManager.getActiveContext(); | ||||||
| 
 | 
 | ||||||
|     if (activeNoteContext) { |     if (activeNoteContext) { | ||||||
|         await activeNoteContext.unhoist(); |         await activeNoteContext.unhoist(); | ||||||
|  | |||||||
| @ -64,7 +64,7 @@ ws.subscribeToMessages(async message => { | |||||||
|         toastService.showPersistent(toast); |         toastService.showPersistent(toast); | ||||||
| 
 | 
 | ||||||
|         if (message.result.importedNoteId) { |         if (message.result.importedNoteId) { | ||||||
|             await appContext.tabManager.getActiveNoteContext().setNote(message.result.importedNoteId); |             await appContext.tabManager.getActiveContext().setNote(message.result.importedNoteId); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| }); | }); | ||||||
|  | |||||||
| @ -43,7 +43,7 @@ getActionsForScope("window").then(actions => { | |||||||
| server.get('keyboard-shortcuts-for-notes').then(shortcutForNotes => { | server.get('keyboard-shortcuts-for-notes').then(shortcutForNotes => { | ||||||
| 	for (const shortcut in shortcutForNotes) { | 	for (const shortcut in shortcutForNotes) { | ||||||
| 		utils.bindGlobalShortcut(shortcut, async () => { | 		utils.bindGlobalShortcut(shortcut, async () => { | ||||||
| 			appContext.tabManager.getActiveNoteContext().setNote(shortcutForNotes[shortcut]); | 			appContext.tabManager.getActiveContext().setNote(shortcutForNotes[shortcut]); | ||||||
| 		}); | 		}); | ||||||
| 	} | 	} | ||||||
| }); | }); | ||||||
|  | |||||||
| @ -85,11 +85,11 @@ function goToLink(e) { | |||||||
| 
 | 
 | ||||||
|             const noteContext = ntxId |             const noteContext = ntxId | ||||||
|                 ? appContext.tabManager.getNoteContextById(ntxId) |                 ? appContext.tabManager.getNoteContextById(ntxId) | ||||||
|                 : appContext.tabManager.getActiveNoteContext(); |                 : appContext.tabManager.getActiveContext(); | ||||||
| 
 | 
 | ||||||
|             noteContext.setNote(notePath).then(() => { |             noteContext.setNote(notePath).then(() => { | ||||||
|                 if (noteContext !== appContext.tabManager.getActiveNoteContext()) { |                 if (noteContext !== appContext.tabManager.getActiveContext()) { | ||||||
|                     appContext.tabManager.activateTab(noteContext.ntxId); |                     appContext.tabManager.activateNoteContext(noteContext.ntxId); | ||||||
|                 } |                 } | ||||||
|             }); |             }); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -27,7 +27,7 @@ export default class MainTreeExecutors extends Component { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async createNoteIntoCommand() { |     async createNoteIntoCommand() { | ||||||
|         const activeNoteContext = appContext.tabManager.getActiveNoteContext(); |         const activeNoteContext = appContext.tabManager.getActiveContext(); | ||||||
| 
 | 
 | ||||||
|         if (!activeNoteContext) { |         if (!activeNoteContext) { | ||||||
|             return; |             return; | ||||||
|  | |||||||
| @ -31,7 +31,7 @@ async function autocompleteSourceForCKEditor(queryText) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| async function autocompleteSource(term, cb, options = {}) { | async function autocompleteSource(term, cb, options = {}) { | ||||||
|     const activeNoteId = appContext.tabManager.getActiveTabNoteId(); |     const activeNoteId = appContext.tabManager.getActiveContextNoteId(); | ||||||
| 
 | 
 | ||||||
|     let results = await server.get('autocomplete' |     let results = await server.get('autocomplete' | ||||||
|             + '?query=' + encodeURIComponent(term) |             + '?query=' + encodeURIComponent(term) | ||||||
|  | |||||||
| @ -20,7 +20,7 @@ class NoteContext extends Component { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     setEmpty() { |     setEmpty() { | ||||||
|         this.triggerEvent('tabNoteSwitched', { |         this.triggerEvent('noteSwitched', { | ||||||
|             noteContext: this, |             noteContext: this, | ||||||
|             notePath: this.notePath |             notePath: this.notePath | ||||||
|         }); |         }); | ||||||
| @ -48,7 +48,7 @@ class NoteContext extends Component { | |||||||
|         protectedSessionHolder.touchProtectedSessionIfNecessary(this.note); |         protectedSessionHolder.touchProtectedSessionIfNecessary(this.note); | ||||||
| 
 | 
 | ||||||
|         if (triggerSwitchEvent) { |         if (triggerSwitchEvent) { | ||||||
|             await this.triggerEvent('tabNoteSwitched', { |             await this.triggerEvent('noteSwitched', { | ||||||
|                 noteContext: this, |                 noteContext: this, | ||||||
|                 notePath: this.notePath |                 notePath: this.notePath | ||||||
|             }); |             }); | ||||||
| @ -180,7 +180,7 @@ class NoteContext extends Component { | |||||||
|                 this.noteId = null; |                 this.noteId = null; | ||||||
|                 this.notePath = null; |                 this.notePath = null; | ||||||
| 
 | 
 | ||||||
|                 this.triggerEvent('tabNoteSwitched', { |                 this.triggerEvent('noteSwitched', { | ||||||
|                     noteContext: this, |                     noteContext: this, | ||||||
|                     notePath: this.notePath |                     notePath: this.notePath | ||||||
|                 }); |                 }); | ||||||
| @ -20,7 +20,7 @@ async function createNote(parentNotePath, options = {}) { | |||||||
|         options.isProtected = false; |         options.isProtected = false; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (appContext.tabManager.getActiveTabNoteType() !== 'text') { |     if (appContext.tabManager.getActiveContextNoteType() !== 'text') { | ||||||
|         options.saveSelection = false; |         options.saveSelection = false; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -48,7 +48,7 @@ async function createNote(parentNotePath, options = {}) { | |||||||
|     await ws.waitForMaxKnownEntityChangeId(); |     await ws.waitForMaxKnownEntityChangeId(); | ||||||
| 
 | 
 | ||||||
|     if (options.activate) { |     if (options.activate) { | ||||||
|         const activeNoteContext = appContext.tabManager.getActiveNoteContext(); |         const activeNoteContext = appContext.tabManager.getActiveContext(); | ||||||
|         await activeNoteContext.setNote(`${parentNotePath}/${note.noteId}`); |         await activeNoteContext.setNote(`${parentNotePath}/${note.noteId}`); | ||||||
| 
 | 
 | ||||||
|         if (options.focus === 'title') { |         if (options.focus === 'title') { | ||||||
| @ -90,7 +90,7 @@ async function duplicateSubtree(noteId, parentNotePath) { | |||||||
| 
 | 
 | ||||||
|     await ws.waitForMaxKnownEntityChangeId(); |     await ws.waitForMaxKnownEntityChangeId(); | ||||||
| 
 | 
 | ||||||
|     const activeNoteContext = appContext.tabManager.getActiveNoteContext(); |     const activeNoteContext = appContext.tabManager.getActiveContext(); | ||||||
|     activeNoteContext.setNote(`${parentNotePath}/${note.noteId}`); |     activeNoteContext.setNote(`${parentNotePath}/${note.noteId}`); | ||||||
| 
 | 
 | ||||||
|     const origNote = await froca.getNote(noteId); |     const origNote = await froca.getNote(noteId); | ||||||
|  | |||||||
| @ -35,7 +35,7 @@ export default class RootCommandExecutor extends Component { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async editBranchPrefixCommand() { |     async editBranchPrefixCommand() { | ||||||
|         const notePath = appContext.tabManager.getActiveTabNotePath(); |         const notePath = appContext.tabManager.getActiveContextNotePath(); | ||||||
| 
 | 
 | ||||||
|         if (notePath) { |         if (notePath) { | ||||||
|             const editBranchPrefixDialog = await import("../dialogs/branch_prefix.js"); |             const editBranchPrefixDialog = await import("../dialogs/branch_prefix.js"); | ||||||
| @ -64,7 +64,7 @@ export default class RootCommandExecutor extends Component { | |||||||
|     async showSQLConsoleCommand() { |     async showSQLConsoleCommand() { | ||||||
|         const sqlConsoleNote = await dateNoteService.createSqlConsole(); |         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}); |         appContext.triggerEvent('focusOnDetail', {ntxId: noteContext.ntxId}); | ||||||
|     } |     } | ||||||
| @ -72,7 +72,7 @@ export default class RootCommandExecutor extends Component { | |||||||
|     async searchNotesCommand({searchString, ancestorNoteId}) { |     async searchNotesCommand({searchString, ancestorNoteId}) { | ||||||
|         const searchNote = await dateNoteService.createSearchNote({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}); |         appContext.triggerCommand('focusOnSearchDefinition', {ntxId: noteContext.ntxId}); | ||||||
|     } |     } | ||||||
| @ -88,7 +88,7 @@ export default class RootCommandExecutor extends Component { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     openNoteExternallyCommand() { |     openNoteExternallyCommand() { | ||||||
|         const noteId = appContext.tabManager.getActiveTabNoteId(); |         const noteId = appContext.tabManager.getActiveContextNoteId(); | ||||||
| 
 | 
 | ||||||
|         if (noteId) { |         if (noteId) { | ||||||
|             openService.openNoteExternally(noteId); |             openService.openNoteExternally(noteId); | ||||||
|  | |||||||
| @ -4,7 +4,7 @@ const REQUEST_LOGGING_ENABLED = false; | |||||||
| 
 | 
 | ||||||
| async function getHeaders(headers) { | async function getHeaders(headers) { | ||||||
|     const appContext = (await import('./app_context.js')).default; |     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
 |     // 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
 |     // also avoiding using underscores instead of dashes since nginx filters them out by default
 | ||||||
|  | |||||||
| @ -5,7 +5,7 @@ import options from "./options.js"; | |||||||
| import froca from "./froca.js"; | import froca from "./froca.js"; | ||||||
| import treeService from "./tree.js"; | import treeService from "./tree.js"; | ||||||
| import utils from "./utils.js"; | import utils from "./utils.js"; | ||||||
| import NoteContext from "./tab_context.js"; | import NoteContext from "./note_context.js"; | ||||||
| import appContext from "./app_context.js"; | import appContext from "./app_context.js"; | ||||||
| 
 | 
 | ||||||
| export default class TabManager extends Component { | export default class TabManager extends Component { | ||||||
| @ -104,12 +104,12 @@ export default class TabManager extends Component { | |||||||
| 
 | 
 | ||||||
|         await this.tabsUpdate.allowUpdateWithoutChange(async () => { |         await this.tabsUpdate.allowUpdateWithoutChange(async () => { | ||||||
|             for (const tab of filteredTabs) { |             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()) { |         if (noteContext.isActive()) { | ||||||
|             this.setCurrentNotePathToHash(); |             this.setCurrentNotePathToHash(); | ||||||
|         } |         } | ||||||
| @ -118,7 +118,7 @@ export default class TabManager extends Component { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     setCurrentNotePathToHash() { |     setCurrentNotePathToHash() { | ||||||
|         const activeNoteContext = this.getActiveNoteContext(); |         const activeNoteContext = this.getActiveContext(); | ||||||
| 
 | 
 | ||||||
|         if (window.history.length === 0 // first history entry
 |         if (window.history.length === 0 // first history entry
 | ||||||
|             || (activeNoteContext && activeNoteContext.notePath !== treeService.getHashValueFromAddress()[0])) { |             || (activeNoteContext && activeNoteContext.notePath !== treeService.getHashValueFromAddress()[0])) { | ||||||
| @ -155,50 +155,50 @@ export default class TabManager extends Component { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** @returns {NoteContext} */ |     /** @returns {NoteContext} */ | ||||||
|     getActiveNoteContext() { |     getActiveContext() { | ||||||
|         return this.activeTabId |         return this.activeTabId | ||||||
|             ? this.getNoteContextById(this.activeTabId) |             ? this.getNoteContextById(this.activeTabId) | ||||||
|             : null; |             : null; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** @returns {string|null} */ |     /** @returns {string|null} */ | ||||||
|     getActiveTabNotePath() { |     getActiveContextNotePath() { | ||||||
|         const activeContext = this.getActiveNoteContext(); |         const activeContext = this.getActiveContext(); | ||||||
|         return activeContext ? activeContext.notePath : null; |         return activeContext ? activeContext.notePath : null; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** @return {NoteShort} */ |     /** @return {NoteShort} */ | ||||||
|     getActiveTabNote() { |     getActiveContextNote() { | ||||||
|         const activeContext = this.getActiveNoteContext(); |         const activeContext = this.getActiveContext(); | ||||||
|         return activeContext ? activeContext.note : null; |         return activeContext ? activeContext.note : null; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** @return {string|null} */ |     /** @return {string|null} */ | ||||||
|     getActiveTabNoteId() { |     getActiveContextNoteId() { | ||||||
|         const activeNote = this.getActiveTabNote(); |         const activeNote = this.getActiveContextNote(); | ||||||
| 
 | 
 | ||||||
|         return activeNote ? activeNote.noteId : null; |         return activeNote ? activeNote.noteId : null; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** @return {string|null} */ |     /** @return {string|null} */ | ||||||
|     getActiveTabNoteType() { |     getActiveContextNoteType() { | ||||||
|         const activeNote = this.getActiveTabNote(); |         const activeNote = this.getActiveContextNote(); | ||||||
| 
 | 
 | ||||||
|         return activeNote ? activeNote.type : null; |         return activeNote ? activeNote.type : null; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async switchToTab(ntxId, notePath) { |     async switchToNoteContext(ntxId, notePath) { | ||||||
|         const noteContext = this.noteContexts.find(nc => nc.ntxId === ntxId) |         const noteContext = this.noteContexts.find(nc => nc.ntxId === ntxId) | ||||||
|             || await this.openEmptyTab(); |             || await this.openEmptyTab(); | ||||||
| 
 | 
 | ||||||
|         this.activateTab(noteContext.ntxId); |         this.activateNoteContext(noteContext.ntxId); | ||||||
|         await noteContext.setNote(notePath); |         await noteContext.setNote(notePath); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async openAndActivateEmptyTab() { |     async openAndActivateEmptyTab() { | ||||||
|         const noteContext = await this.openEmptyTab(); |         const noteContext = await this.openEmptyTab(); | ||||||
| 
 | 
 | ||||||
|         await this.activateTab(noteContext.ntxId); |         await this.activateNoteContext(noteContext.ntxId); | ||||||
| 
 | 
 | ||||||
|         await noteContext.setEmpty(); |         await noteContext.setEmpty(); | ||||||
|     } |     } | ||||||
| @ -214,7 +214,7 @@ export default class TabManager extends Component { | |||||||
| 
 | 
 | ||||||
|         this.child(noteContext); |         this.child(noteContext); | ||||||
| 
 | 
 | ||||||
|         await this.triggerEvent('newTabOpened', {noteContext}); |         await this.triggerEvent('newNoteContextCreated', {noteContext}); | ||||||
| 
 | 
 | ||||||
|         return 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. |      * If the requested notePath is within current note hoisting scope then keep the note hoisting also for the new tab. | ||||||
|      */ |      */ | ||||||
|     async openTabWithNoteWithHoisting(notePath) { |     async openTabWithNoteWithHoisting(notePath) { | ||||||
|         const noteContext = this.getActiveNoteContext(); |         const noteContext = this.getActiveContext(); | ||||||
|         let hoistedNoteId = 'root'; |         let hoistedNoteId = 'root'; | ||||||
| 
 | 
 | ||||||
|         if (noteContext) { |         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); |         const noteContext = await this.openEmptyTab(ntxId, hoistedNoteId, mainNtxId); | ||||||
| 
 | 
 | ||||||
|         if (notePath) { |         if (notePath) { | ||||||
| @ -245,9 +245,9 @@ export default class TabManager extends Component { | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (activate) { |         if (activate) { | ||||||
|             this.activateTab(noteContext.ntxId, false); |             this.activateNoteContext(noteContext.ntxId, false); | ||||||
| 
 | 
 | ||||||
|             await this.triggerEvent('tabNoteSwitchedAndActivated', { |             await this.triggerEvent('noteSwitchedAndActivated', { | ||||||
|                 noteContext, |                 noteContext, | ||||||
|                 notePath: noteContext.notePath // resolved note path
 |                 notePath: noteContext.notePath // resolved note path
 | ||||||
|             }); |             }); | ||||||
| @ -259,7 +259,7 @@ export default class TabManager extends Component { | |||||||
|     async activateOrOpenNote(noteId) { |     async activateOrOpenNote(noteId) { | ||||||
|         for (const noteContext of this.getNoteContexts()) { |         for (const noteContext of this.getNoteContexts()) { | ||||||
|             if (noteContext.note && noteContext.note.noteId === noteId) { |             if (noteContext.note && noteContext.note.noteId === noteId) { | ||||||
|                 this.activateTab(noteContext.ntxId); |                 this.activateNoteContext(noteContext.ntxId); | ||||||
| 
 | 
 | ||||||
|                 return; |                 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
 |         // 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) { |         if (ntxId === this.activeTabId) { | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| @ -288,7 +288,7 @@ export default class TabManager extends Component { | |||||||
|         this.setCurrentNotePathToHash(); |         this.setCurrentNotePathToHash(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async removeTab(ntxId) { |     async removeNoteContext(ntxId) { | ||||||
|         const mainNoteContextToRemove = this.getNoteContextById(ntxId).getMainNoteContext(); |         const mainNoteContextToRemove = this.getNoteContextById(ntxId).getMainNoteContext(); | ||||||
| 
 | 
 | ||||||
|         // close dangling autocompletes after closing the tab
 |         // 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.children = this.children.filter(nc => !ntxIdsToRemove.includes(nc.ntxId)); | ||||||
| 
 | 
 | ||||||
|         this.triggerEvent('tabRemoved', {ntxIds: ntxIdsToRemove}); |         this.triggerEvent('noteContextRemoved', {ntxIds: ntxIdsToRemove}); | ||||||
| 
 | 
 | ||||||
|         this.tabsUpdate.scheduleUpdate(); |         this.tabsUpdate.scheduleUpdate(); | ||||||
|     } |     } | ||||||
| @ -335,18 +335,18 @@ export default class TabManager extends Component { | |||||||
|         const oldIdx = this.mainNoteContexts.findIndex(nc => nc.ntxId === this.activeTabId); |         const oldIdx = this.mainNoteContexts.findIndex(nc => nc.ntxId === this.activeTabId); | ||||||
|         const newActiveTabId = this.mainNoteContexts[oldIdx === this.noteContexts.length - 1 ? 0 : oldIdx + 1].ntxId; |         const newActiveTabId = this.mainNoteContexts[oldIdx === this.noteContexts.length - 1 ? 0 : oldIdx + 1].ntxId; | ||||||
| 
 | 
 | ||||||
|         this.activateTab(newActiveTabId); |         this.activateNoteContext(newActiveTabId); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     activatePreviousTabCommand() { |     activatePreviousTabCommand() { | ||||||
|         const oldIdx = this.mainNoteContexts.findIndex(nc => nc.ntxId === this.activeTabId); |         const oldIdx = this.mainNoteContexts.findIndex(nc => nc.ntxId === this.activeTabId); | ||||||
|         const newActiveTabId = this.mainNoteContexts[oldIdx === 0 ? this.noteContexts.length - 1 : oldIdx - 1].ntxId; |         const newActiveTabId = this.mainNoteContexts[oldIdx === 0 ? this.noteContexts.length - 1 : oldIdx - 1].ntxId; | ||||||
| 
 | 
 | ||||||
|         this.activateTab(newActiveTabId); |         this.activateNoteContext(newActiveTabId); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     closeActiveTabCommand() { |     closeActiveTabCommand() { | ||||||
|         this.removeTab(this.activeTabId); |         this.removeNoteContext(this.activeTabId); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     beforeUnloadEvent() { |     beforeUnloadEvent() { | ||||||
| @ -361,14 +361,14 @@ export default class TabManager extends Component { | |||||||
| 
 | 
 | ||||||
|     async removeAllTabsCommand() { |     async removeAllTabsCommand() { | ||||||
|         for (const ntxIdToRemove of this.noteContexts.map(nc => nc.ntxId)) { |         for (const ntxIdToRemove of this.noteContexts.map(nc => nc.ntxId)) { | ||||||
|             await this.removeTab(ntxIdToRemove); |             await this.removeNoteContext(ntxIdToRemove); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async removeAllTabsExceptForThisCommand({ntxId}) { |     async removeAllTabsExceptForThisCommand({ntxId}) { | ||||||
|         for (const ntxIdToRemove of this.noteContexts.map(nc => nc.ntxId)) { |         for (const ntxIdToRemove of this.noteContexts.map(nc => nc.ntxId)) { | ||||||
|             if (ntxIdToRemove !== ntxId) { |             if (ntxIdToRemove !== ntxId) { | ||||||
|                 await this.removeTab(ntxIdToRemove); |                 await this.removeNoteContext(ntxIdToRemove); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @ -376,7 +376,7 @@ export default class TabManager extends Component { | |||||||
|     moveTabToNewWindowCommand({ntxId}) { |     moveTabToNewWindowCommand({ntxId}) { | ||||||
|         const {notePath, hoistedNoteId} = this.getNoteContextById(ntxId); |         const {notePath, hoistedNoteId} = this.getNoteContextById(ntxId); | ||||||
| 
 | 
 | ||||||
|         this.removeTab(ntxId); |         this.removeNoteContext(ntxId); | ||||||
| 
 | 
 | ||||||
|         this.triggerCommand('openInWindow', {notePath, hoistedNoteId}); |         this.triggerCommand('openInWindow', {notePath, hoistedNoteId}); | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -39,7 +39,7 @@ class TreeContextMenu { | |||||||
|         const note = await froca.getNote(this.node.data.noteId); |         const note = await froca.getNote(this.node.data.noteId); | ||||||
|         const branch = froca.getBranch(this.node.data.branchId); |         const branch = froca.getBranch(this.node.data.branchId); | ||||||
|         const isNotRoot = note.noteId !== 'root'; |         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; |         const parentNote = isNotRoot ? await froca.getNote(branch.parentNoteId) : null; | ||||||
| 
 | 
 | ||||||
|         // some actions don't support multi-note so they are disabled when notes are selected
 |         // some actions don't support multi-note so they are disabled when notes are selected
 | ||||||
|  | |||||||
| @ -5,7 +5,7 @@ import linkService from "../../services/link.js"; | |||||||
| import attributeAutocompleteService from "../../services/attribute_autocomplete.js"; | import attributeAutocompleteService from "../../services/attribute_autocomplete.js"; | ||||||
| import noteAutocompleteService from "../../services/note_autocomplete.js"; | import noteAutocompleteService from "../../services/note_autocomplete.js"; | ||||||
| import promotedAttributeDefinitionParser from '../../services/promoted_attribute_definition_parser.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 SpacedUpdate from "../../services/spaced_update.js"; | ||||||
| import utils from "../../services/utils.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() { |     async refresh() { | ||||||
|         // switching note/tab should close the widget
 |         // switching note/tab should close the widget
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -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 noteAutocompleteService from "../../services/note_autocomplete.js"; | ||||||
| import server from "../../services/server.js"; | import server from "../../services/server.js"; | ||||||
| import contextMenuService from "../../services/context_menu.js"; | import contextMenuService from "../../services/context_menu.js"; | ||||||
| @ -176,7 +176,7 @@ const editorConfig = { | |||||||
|     mention: mentionSetup |     mention: mentionSetup | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export default class AttributeEditorWidget extends TabAwareWidget { | export default class AttributeEditorWidget extends NoteContextAwareWidget { | ||||||
|     constructor(attributeDetailWidget) { |     constructor(attributeDetailWidget) { | ||||||
|         super(); |         super(); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -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"; | import options from "../services/options.js"; | ||||||
| 
 | 
 | ||||||
| const WIDGET_TPL = ` | const WIDGET_TPL = ` | ||||||
| @ -29,7 +29,7 @@ const WIDGET_TPL = ` | |||||||
|     </div> |     </div> | ||||||
| </div>`; | </div>`; | ||||||
| 
 | 
 | ||||||
| export default class CollapsibleWidget extends TabAwareWidget { | export default class CollapsibleWidget extends NoteContextAwareWidget { | ||||||
|     get widgetTitle() { return "Untitled widget"; } |     get widgetTitle() { return "Untitled widget"; } | ||||||
| 
 | 
 | ||||||
|     get headerActions() { return []; } |     get headerActions() { return []; } | ||||||
|  | |||||||
| @ -56,7 +56,7 @@ export default class CalendarWidget extends CollapsibleWidget { | |||||||
|             const note = await dateNoteService.getDateNote(date); |             const note = await dateNoteService.getDateNote(date); | ||||||
| 
 | 
 | ||||||
|             if (note) { |             if (note) { | ||||||
|                 appContext.tabManager.getActiveNoteContext().setNote(note.noteId); |                 appContext.tabManager.getActiveContext().setNote(note.noteId); | ||||||
|             } |             } | ||||||
|             else { |             else { | ||||||
|                 alert("Cannot find day note"); |                 alert("Cannot find day note"); | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| import TabAwareWidget from "../tab_aware_widget.js"; | import NoteContextAwareWidget from "../note_context_aware_widget.js"; | ||||||
| 
 | 
 | ||||||
| const TPL = ` | const TPL = ` | ||||||
| <div class="section-container"> | <div class="section-container"> | ||||||
| @ -57,7 +57,7 @@ const TPL = ` | |||||||
|     <div class="section-body-container"></div> |     <div class="section-body-container"></div> | ||||||
| </div>`; | </div>`; | ||||||
| 
 | 
 | ||||||
| export default class CollapsibleSectionContainer extends TabAwareWidget { | export default class CollapsibleSectionContainer extends NoteContextAwareWidget { | ||||||
|     constructor() { |     constructor() { | ||||||
|         super(); |         super(); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -14,14 +14,14 @@ export default class PaneContainer extends FlexContainer { | |||||||
|         this.css('flex-grow', '1'); |         this.css('flex-grow', '1'); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async newTabOpenedEvent({noteContext}) { |     async newNoteContextCreatedEvent({noteContext}) { | ||||||
|         const widget = this.widgetFactory(); |         const widget = this.widgetFactory(); | ||||||
| 
 | 
 | ||||||
|         const $renderedWidget = widget.render(); |         const $renderedWidget = widget.render(); | ||||||
| 
 | 
 | ||||||
|         $renderedWidget.attr("data-tab-id", noteContext.ntxId); |         $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); |         this.$widget.append($renderedWidget); | ||||||
| 
 | 
 | ||||||
| @ -35,9 +35,9 @@ export default class PaneContainer extends FlexContainer { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async openNewPaneCommand() { |     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(); |         await noteContext.setEmpty(); | ||||||
|     } |     } | ||||||
| @ -49,7 +49,7 @@ export default class PaneContainer extends FlexContainer { | |||||||
|     toggleInt(show) {} // not needed
 |     toggleInt(show) {} // not needed
 | ||||||
| 
 | 
 | ||||||
|     toggleExt(show) { |     toggleExt(show) { | ||||||
|         const activeTabId = appContext.tabManager.getActiveNoteContext().getMainNoteContext().ntxId; |         const activeTabId = appContext.tabManager.getActiveContext().getMainNoteContext().ntxId; | ||||||
| 
 | 
 | ||||||
|         for (const ntxId in this.widgets) { |         for (const ntxId in this.widgets) { | ||||||
|             const noteContext = appContext.tabManager.getNoteContextById(ntxId); |             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. |      * activation further note switches are always propagated to the tabs. | ||||||
|      */ |      */ | ||||||
|     handleEventInChildren(name, data) { |     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
 |             // this event is propagated only to the widgets of a particular tab
 | ||||||
|             const widget = this.widgets[data.noteContext.ntxId]; |             const widget = this.widgets[data.noteContext.ntxId]; | ||||||
| 
 | 
 | ||||||
| @ -79,7 +79,7 @@ export default class PaneContainer extends FlexContainer { | |||||||
| 
 | 
 | ||||||
|             const promises = []; |             const promises = []; | ||||||
| 
 | 
 | ||||||
|             if (appContext.tabManager.getActiveNoteContext().getMainNoteContext() === data.noteContext.getMainNoteContext()) { |             if (appContext.tabManager.getActiveContext().getMainNoteContext() === data.noteContext.getMainNoteContext()) { | ||||||
|                 promises.push(widget.handleEvent('activeTabChanged', data)); |                 promises.push(widget.handleEvent('activeTabChanged', data)); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
| @ -95,14 +95,14 @@ export default class PaneContainer extends FlexContainer { | |||||||
|                     continue; |                     continue; | ||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|                 if (subNoteContext === data.noteContext && (subWidget.hasBeenAlreadyShown || name === 'tabNoteSwitchedAndActivated')) { |                 if (subNoteContext === data.noteContext && (subWidget.hasBeenAlreadyShown || name === 'noteSwitchedAndActivated')) { | ||||||
|                     subWidget.hasBeenAlreadyShown = true; |                     subWidget.hasBeenAlreadyShown = true; | ||||||
| 
 | 
 | ||||||
|                     promises.push(widget.handleEvent('tabNoteSwitched', data)); |                     promises.push(widget.handleEvent('noteSwitched', data)); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             if (name === 'tabNoteSwitchedAndActivated') { |             if (name === 'noteSwitchedAndActivated') { | ||||||
|                 this.toggleExt(true); |                 this.toggleExt(true); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -12,7 +12,7 @@ export default class RootContainer extends FlexContainer { | |||||||
| 
 | 
 | ||||||
|     refresh() { |     refresh() { | ||||||
|         this.$widget.removeClass(); // remove all classes
 |         this.$widget.removeClass(); // remove all classes
 | ||||||
|         const note = appContext.tabManager.getActiveTabNote(); |         const note = appContext.tabManager.getActiveContextNote(); | ||||||
| 
 | 
 | ||||||
|         if (note) { |         if (note) { | ||||||
|             this.$widget.addClass(note.getCssClass()); |             this.$widget.addClass(note.getCssClass()); | ||||||
| @ -41,7 +41,7 @@ export default class RootContainer extends FlexContainer { | |||||||
|         this.setZenMode(!this.isZenModeActive); |         this.setZenMode(!this.isZenModeActive); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     tabNoteSwitchedEvent() { |     noteSwitchedEvent() { | ||||||
|         this.refresh(); |         this.refresh(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -49,7 +49,7 @@ export default class RootContainer extends FlexContainer { | |||||||
|         this.refresh(); |         this.refresh(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     tabNoteSwitchedAndActivatedEvent() { |     noteSwitchedAndActivatedEvent() { | ||||||
|         this.refresh(); |         this.refresh(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -7,7 +7,7 @@ export default class ScrollingContainer extends Container { | |||||||
|         this.css('height: 100%; overflow: auto;'); |         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 notePath does not match then the noteContext has been switched to another note in the mean time
 | ||||||
|         if (noteContext.notePath === notePath) { |         if (noteContext.notePath === notePath) { | ||||||
|             this.$widget.scrollTop(0); |             this.$widget.scrollTop(0); | ||||||
|  | |||||||
| @ -13,7 +13,7 @@ class MobileDetailMenuWidget extends BasicWidget { | |||||||
|         this.overflowing(); |         this.overflowing(); | ||||||
| 
 | 
 | ||||||
|         this.$widget.on("click", async e => { |         this.$widget.on("click", async e => { | ||||||
|             const note = appContext.tabManager.getActiveTabNote(); |             const note = appContext.tabManager.getActiveContextNote(); | ||||||
| 
 | 
 | ||||||
|             contextMenu.show({ |             contextMenu.show({ | ||||||
|                 x: e.pageX, |                 x: e.pageX, | ||||||
| @ -26,10 +26,10 @@ class MobileDetailMenuWidget extends BasicWidget { | |||||||
|                 ], |                 ], | ||||||
|                 selectMenuItemHandler: async ({command}) => { |                 selectMenuItemHandler: async ({command}) => { | ||||||
|                     if (command === "insertChildNote") { |                     if (command === "insertChildNote") { | ||||||
|                         noteCreateService.createNote(appContext.tabManager.getActiveTabNotePath()); |                         noteCreateService.createNote(appContext.tabManager.getActiveContextNotePath()); | ||||||
|                     } |                     } | ||||||
|                     else if (command === "delete") { |                     else if (command === "delete") { | ||||||
|                         const notePath = appContext.tabManager.getActiveTabNotePath(); |                         const notePath = appContext.tabManager.getActiveContextNotePath(); | ||||||
|                         const branchId = await treeService.getBranchIdFromNotePath(notePath); |                         const branchId = await treeService.getBranchIdFromNotePath(notePath); | ||||||
| 
 | 
 | ||||||
|                         if (!branchId) { |                         if (!branchId) { | ||||||
|  | |||||||
| @ -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 protectedSessionService from "../services/protected_session.js"; | ||||||
| import utils from "../services/utils.js"; | import utils from "../services/utils.js"; | ||||||
| 
 | 
 | ||||||
| @ -100,7 +100,7 @@ const TPL = ` | |||||||
|     </div> |     </div> | ||||||
| </div>`; | </div>`; | ||||||
| 
 | 
 | ||||||
| export default class NoteActionsWidget extends TabAwareWidget { | export default class NoteActionsWidget extends NoteContextAwareWidget { | ||||||
|     doRender() { |     doRender() { | ||||||
|         this.$widget = $(TPL); |         this.$widget = $(TPL); | ||||||
|         this.overflowing(); |         this.overflowing(); | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| import BasicWidget from "./basic_widget.js"; | import BasicWidget from "./basic_widget.js"; | ||||||
| import appContext from "../services/app_context.js"; | import appContext from "../services/app_context.js"; | ||||||
| 
 | 
 | ||||||
| export default class TabAwareWidget extends BasicWidget { | export default class NoteContextAwareWidget extends BasicWidget { | ||||||
|     isTab(ntxId) { |     isTab(ntxId) { | ||||||
|         if (Array.isArray(ntxId)) { |         if (Array.isArray(ntxId)) { | ||||||
|             return this.noteContext && ntxId.includes(this.noteContext.ntxId); |             return this.noteContext && ntxId.includes(this.noteContext.ntxId); | ||||||
| @ -59,7 +59,7 @@ export default class TabAwareWidget extends BasicWidget { | |||||||
| 
 | 
 | ||||||
|     async refreshWithNote(note) {} |     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 notePath does not match then the noteContext has been switched to another note in the mean time
 | ||||||
|         if (noteContext.notePath === notePath) { |         if (noteContext.notePath === notePath) { | ||||||
|             await this.noteSwitched(); |             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
 |     // when note is both switched and activated, this should not produce double refresh
 | ||||||
|     async tabNoteSwitchedAndActivatedEvent({noteContext, notePath}) { |     async noteSwitchedAndActivatedEvent({noteContext, notePath}) { | ||||||
|         this.noteContext = noteContext; |         this.noteContext = noteContext; | ||||||
| 
 | 
 | ||||||
|         // if notePath does not match then the noteContext has been switched to another note in the mean time
 |         // 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() { |     async lazyLoadedEvent() { | ||||||
|         if (!this.noteContext) { // has not been loaded yet
 |         if (!this.noteContext) { // has not been loaded yet
 | ||||||
|             this.noteContext = appContext.tabManager.getActiveNoteContext(); |             this.noteContext = appContext.tabManager.getActiveContext(); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         await this.refresh(); |         await this.refresh(); | ||||||
| @ -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"; | import keyboardActionsService from "../services/keyboard_actions.js"; | ||||||
| 
 | 
 | ||||||
| export default class TabCachingWidget extends TabAwareWidget { | export default class NoteContextCachingWidget extends NoteContextAwareWidget { | ||||||
|     constructor(widgetFactory) { |     constructor(widgetFactory) { | ||||||
|         super(); |         super(); | ||||||
| 
 | 
 | ||||||
| @ -13,7 +13,7 @@ export default class TabCachingWidget extends TabAwareWidget { | |||||||
|         return this.$widget = $(`<div class="marker" style="display: none;">`); |         return this.$widget = $(`<div class="marker" style="display: none;">`); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async newTabOpenedEvent({noteContext}) { |     async newNoteContextCreatedEvent({noteContext}) { | ||||||
|         const {ntxId} = noteContext; |         const {ntxId} = noteContext; | ||||||
| 
 | 
 | ||||||
|         if (this.widgets[ntxId]) { |         if (this.widgets[ntxId]) { | ||||||
| @ -34,7 +34,7 @@ export default class TabCachingWidget extends TabAwareWidget { | |||||||
|         this.child(this.widgets[ntxId]); // add as child only once it is ready (rendered with noteContext)
 |         this.child(this.widgets[ntxId]); // add as child only once it is ready (rendered with noteContext)
 | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     tabRemovedEvent({ntxIds}) { |     noteContextRemovedEvent({ntxIds}) { | ||||||
|         for (const ntxId of ntxIds) { |         for (const ntxId of ntxIds) { | ||||||
|             const widget = this.widgets[ntxId]; |             const widget = this.widgets[ntxId]; | ||||||
| 
 | 
 | ||||||
| @ -65,7 +65,7 @@ export default class TabCachingWidget extends TabAwareWidget { | |||||||
|      * activation further note switches are always propagated to the tabs. |      * activation further note switches are always propagated to the tabs. | ||||||
|      */ |      */ | ||||||
|     handleEventInChildren(name, data) { |     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
 |             // this event is propagated only to the widgets of a particular tab
 | ||||||
|             let widget = this.widgets[data.noteContext.ntxId]; |             let widget = this.widgets[data.noteContext.ntxId]; | ||||||
| 
 | 
 | ||||||
| @ -73,10 +73,10 @@ export default class TabCachingWidget extends TabAwareWidget { | |||||||
|                 widget = this.widgets[data.noteContext.mainNtxId]; |                 widget = this.widgets[data.noteContext.mainNtxId]; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             if (widget && (widget.hasBeenAlreadyShown || name === 'tabNoteSwitchedAndActivated')) { |             if (widget && (widget.hasBeenAlreadyShown || name === 'noteSwitchedAndActivated')) { | ||||||
|                 widget.hasBeenAlreadyShown = true; |                 widget.hasBeenAlreadyShown = true; | ||||||
| 
 | 
 | ||||||
|                 return widget.handleEvent('tabNoteSwitched', data); |                 return widget.handleEvent('noteSwitched', data); | ||||||
|             } |             } | ||||||
|             else { |             else { | ||||||
|                 return Promise.resolve(); |                 return Promise.resolve(); | ||||||
| @ -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 utils from "../services/utils.js"; | ||||||
| import protectedSessionHolder from "../services/protected_session_holder.js"; | import protectedSessionHolder from "../services/protected_session_holder.js"; | ||||||
| import SpacedUpdate from "../services/spaced_update.js"; | import SpacedUpdate from "../services/spaced_update.js"; | ||||||
| @ -48,7 +48,7 @@ const typeWidgetClasses = { | |||||||
|     'book': BookTypeWidget |     'book': BookTypeWidget | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export default class NoteDetailWidget extends TabAwareWidget { | export default class NoteDetailWidget extends NoteContextAwareWidget { | ||||||
|     constructor() { |     constructor() { | ||||||
|         super(); |         super(); | ||||||
| 
 | 
 | ||||||
| @ -82,7 +82,7 @@ export default class NoteDetailWidget extends TabAwareWidget { | |||||||
|         this.$widget.on("dragleave", e => e.preventDefault()); |         this.$widget.on("dragleave", e => e.preventDefault()); | ||||||
| 
 | 
 | ||||||
|         this.$widget.on("drop", async e => { |         this.$widget.on("drop", async e => { | ||||||
|             const activeNote = appContext.tabManager.getActiveTabNote(); |             const activeNote = appContext.tabManager.getActiveContextNote(); | ||||||
| 
 | 
 | ||||||
|             if (!activeNote) { |             if (!activeNote) { | ||||||
|                 return; |                 return; | ||||||
| @ -122,7 +122,7 @@ export default class NoteDetailWidget extends TabAwareWidget { | |||||||
|             await typeWidget.handleEvent('setNoteContext', {noteContext: this.noteContext}); |             await typeWidget.handleEvent('setNoteContext', {noteContext: this.noteContext}); | ||||||
| 
 | 
 | ||||||
|             // this is happening in update() so note has been already set and we need to reflect this
 |             // this is happening in update() so note has been already set and we need to reflect this
 | ||||||
|             await typeWidget.handleEvent('tabNoteSwitched', { |             await typeWidget.handleEvent('noteSwitched', { | ||||||
|                 noteContext: this.noteContext, |                 noteContext: this.noteContext, | ||||||
|                 notePath: this.noteContext.notePath |                 notePath: this.noteContext.notePath | ||||||
|             }); |             }); | ||||||
| @ -291,14 +291,14 @@ export default class NoteDetailWidget extends TabAwareWidget { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async cutIntoNoteCommand() { |     async cutIntoNoteCommand() { | ||||||
|         const note = appContext.tabManager.getActiveTabNote(); |         const note = appContext.tabManager.getActiveContextNote(); | ||||||
| 
 | 
 | ||||||
|         if (!note) { |         if (!note) { | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // without await as this otherwise causes deadlock through component mutex
 |         // without await as this otherwise causes deadlock through component mutex
 | ||||||
|         noteCreateService.createNote(appContext.tabManager.getActiveTabNotePath(), { |         noteCreateService.createNote(appContext.tabManager.getActiveContextNotePath(), { | ||||||
|             isProtected: note.isProtected, |             isProtected: note.isProtected, | ||||||
|             saveSelection: true |             saveSelection: true | ||||||
|         }); |         }); | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| import TabAwareWidget from "./tab_aware_widget.js"; | import NoteContextAwareWidget from "./note_context_aware_widget.js"; | ||||||
| import attributeService from "../services/attributes.js"; | import attributeService from "../services/attributes.js"; | ||||||
| 
 | 
 | ||||||
| const TPL = ` | const TPL = ` | ||||||
| @ -75,7 +75,7 @@ const TPL = ` | |||||||
|     </div> |     </div> | ||||||
| </div>`; | </div>`; | ||||||
| 
 | 
 | ||||||
| export default class NoteIconWidget extends TabAwareWidget { | export default class NoteIconWidget extends NoteContextAwareWidget { | ||||||
|     doRender() { |     doRender() { | ||||||
|         this.$widget = $(TPL); |         this.$widget = $(TPL); | ||||||
|         this.overflowing(); |         this.overflowing(); | ||||||
|  | |||||||
| @ -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"; | import NoteListRenderer from "../services/note_list_renderer.js"; | ||||||
| 
 | 
 | ||||||
| const TPL = ` | const TPL = ` | ||||||
| @ -20,7 +20,7 @@ const TPL = ` | |||||||
|     </div> |     </div> | ||||||
| </div>`; | </div>`; | ||||||
| 
 | 
 | ||||||
| export default class NoteListWidget extends TabAwareWidget { | export default class NoteListWidget extends NoteContextAwareWidget { | ||||||
|     isEnabled() { |     isEnabled() { | ||||||
|         return super.isEnabled() |         return super.isEnabled() | ||||||
|             && ['book', 'text', 'code'].includes(this.note.type) |             && ['book', 'text', 'code'].includes(this.note.type) | ||||||
|  | |||||||
| @ -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 treeService from "../services/tree.js"; | ||||||
| import linkService from "../services/link.js"; | import linkService from "../services/link.js"; | ||||||
| 
 | 
 | ||||||
| @ -36,7 +36,7 @@ const TPL = ` | |||||||
|     </ul> |     </ul> | ||||||
| </div>`; | </div>`; | ||||||
| 
 | 
 | ||||||
| export default class NotePathsWidget extends TabAwareWidget { | export default class NotePathsWidget extends NoteContextAwareWidget { | ||||||
|     doRender() { |     doRender() { | ||||||
|         this.$widget = $(TPL); |         this.$widget = $(TPL); | ||||||
|         this.overflowing(); |         this.overflowing(); | ||||||
|  | |||||||
| @ -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 utils from "../services/utils.js"; | ||||||
| import protectedSessionHolder from "../services/protected_session_holder.js"; | import protectedSessionHolder from "../services/protected_session_holder.js"; | ||||||
| import server from "../services/server.js"; | import server from "../services/server.js"; | ||||||
| @ -27,7 +27,7 @@ const TPL = ` | |||||||
|     <input autocomplete="off" value="" placeholder="type note's title here..." class="note-title" tabindex="100"> |     <input autocomplete="off" value="" placeholder="type note's title here..." class="note-title" tabindex="100"> | ||||||
| </div>`; | </div>`; | ||||||
| 
 | 
 | ||||||
| export default class NoteTitleWidget extends TabAwareWidget { | export default class NoteTitleWidget extends NoteContextAwareWidget { | ||||||
|     constructor() { |     constructor() { | ||||||
|         super(); |         super(); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -5,7 +5,7 @@ import contextMenu from "../services/context_menu.js"; | |||||||
| import froca from "../services/froca.js"; | import froca from "../services/froca.js"; | ||||||
| import branchService from "../services/branches.js"; | import branchService from "../services/branches.js"; | ||||||
| import ws from "../services/ws.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 server from "../services/server.js"; | ||||||
| import noteCreateService from "../services/note_create.js"; | import noteCreateService from "../services/note_create.js"; | ||||||
| import toastService from "../services/toast.js"; | import toastService from "../services/toast.js"; | ||||||
| @ -197,7 +197,7 @@ const TPL = ` | |||||||
| 
 | 
 | ||||||
| const MAX_SEARCH_RESULTS_IN_TREE = 100; | const MAX_SEARCH_RESULTS_IN_TREE = 100; | ||||||
| 
 | 
 | ||||||
| export default class NoteTreeWidget extends TabAwareWidget { | export default class NoteTreeWidget extends NoteContextAwareWidget { | ||||||
|     constructor(treeName) { |     constructor(treeName) { | ||||||
|         super(); |         super(); | ||||||
| 
 | 
 | ||||||
| @ -395,7 +395,7 @@ export default class NoteTreeWidget extends TabAwareWidget { | |||||||
| 
 | 
 | ||||||
|                 const notePath = treeService.getNotePath(data.node); |                 const notePath = treeService.getNotePath(data.node); | ||||||
| 
 | 
 | ||||||
|                 const activeNoteContext = appContext.tabManager.getActiveNoteContext(); |                 const activeNoteContext = appContext.tabManager.getActiveContext(); | ||||||
|                 await activeNoteContext.setNote(notePath); |                 await activeNoteContext.setNote(notePath); | ||||||
| 
 | 
 | ||||||
|                 if (utils.isMobile()) { |                 if (utils.isMobile()) { | ||||||
| @ -525,7 +525,7 @@ export default class NoteTreeWidget extends TabAwareWidget { | |||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|                 const note = await froca.getNote(node.data.noteId); |                 const note = await froca.getNote(node.data.noteId); | ||||||
|                 const activeNoteContext = appContext.tabManager.getActiveNoteContext(); |                 const activeNoteContext = appContext.tabManager.getActiveContext(); | ||||||
| 
 | 
 | ||||||
|                 const $span = $(node.span); |                 const $span = $(node.span); | ||||||
| 
 | 
 | ||||||
| @ -810,7 +810,7 @@ export default class NoteTreeWidget extends TabAwareWidget { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async scrollToActiveNoteEvent() { |     async scrollToActiveNoteEvent() { | ||||||
|         const activeContext = appContext.tabManager.getActiveNoteContext(); |         const activeContext = appContext.tabManager.getActiveContext(); | ||||||
| 
 | 
 | ||||||
|         if (activeContext && activeContext.notePath) { |         if (activeContext && activeContext.notePath) { | ||||||
|             this.tree.$container.focus(); |             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
 |                     //        this should be done by NoteContext / TabManager and note tree should only listen to
 | ||||||
|                     //        changes in active note and just set the "active" state
 |                     //        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
 |                     // 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(); |                         const newActiveNode = this.getActiveNode(); | ||||||
| 
 | 
 | ||||||
|                         // return focus if the previously active node was also focused
 |                         // return focus if the previously active node was also focused
 | ||||||
|  | |||||||
| @ -1,6 +1,6 @@ | |||||||
| import server from '../services/server.js'; | import server from '../services/server.js'; | ||||||
| import mimeTypesService from '../services/mime_types.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 = [ | const NOTE_TYPES = [ | ||||||
|     { type: "file", title: "File", selectable: false }, |     { type: "file", title: "File", selectable: false }, | ||||||
| @ -31,7 +31,7 @@ const TPL = ` | |||||||
| </div> | </div> | ||||||
| `;
 | `;
 | ||||||
| 
 | 
 | ||||||
| export default class NoteTypeWidget extends TabAwareWidget { | export default class NoteTypeWidget extends NoteContextAwareWidget { | ||||||
|     doRender() { |     doRender() { | ||||||
|         this.$widget = $(TPL); |         this.$widget = $(TPL); | ||||||
|         this.overflowing(); |         this.overflowing(); | ||||||
|  | |||||||
| @ -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 server from "../services/server.js"; | ||||||
| import fileWatcher from "../services/file_watcher.js"; | import fileWatcher from "../services/file_watcher.js"; | ||||||
| 
 | 
 | ||||||
| @ -19,7 +19,7 @@ const TPL = ` | |||||||
|     </div> |     </div> | ||||||
| </div>`; | </div>`; | ||||||
| 
 | 
 | ||||||
| export default class NoteUpdateStatusWidget extends TabAwareWidget { | export default class NoteUpdateStatusWidget extends NoteContextAwareWidget { | ||||||
|     isEnabled() { |     isEnabled() { | ||||||
|         return super.isEnabled() |         return super.isEnabled() | ||||||
|             && !!fileWatcher.getFileModificationStatus(this.noteId); |             && !!fileWatcher.getFileModificationStatus(this.noteId); | ||||||
|  | |||||||
| @ -98,13 +98,13 @@ export default class QuickSearchWidget extends BasicWidget { | |||||||
| 
 | 
 | ||||||
|                 if (!e.target || e.target.nodeName !== 'A') { |                 if (!e.target || e.target.nodeName !== 'A') { | ||||||
|                     // click on the link is handled by link handling but we want the whole item clickable
 |                     // 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', () => { |             utils.bindElShortcut($link, 'return', () => { | ||||||
|                 this.$dropdownToggle.dropdown("hide"); |                 this.$dropdownToggle.dropdown("hide"); | ||||||
| 
 | 
 | ||||||
|                 appContext.tabManager.getActiveNoteContext().setNote(note.noteId); |                 appContext.tabManager.getActiveContext().setNote(note.noteId); | ||||||
|             }); |             }); | ||||||
| 
 | 
 | ||||||
|             this.$dropdownMenu.append($link); |             this.$dropdownMenu.append($link); | ||||||
| @ -131,7 +131,7 @@ export default class QuickSearchWidget extends BasicWidget { | |||||||
|     async showInFullSearch() { |     async showInFullSearch() { | ||||||
|         const searchNote = await dateNotesService.createSearchNote({searchString: this.$searchString.val()}); |         const searchNote = await dateNotesService.createSearchNote({searchString: this.$searchString.val()}); | ||||||
| 
 | 
 | ||||||
|         await appContext.tabManager.getActiveNoteContext().setNote(searchNote.noteId); |         await appContext.tabManager.getActiveContext().setNote(searchNote.noteId); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     quickSearchEvent() { |     quickSearchEvent() { | ||||||
|  | |||||||
| @ -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"; | import NoteListRenderer from "../services/note_list_renderer.js"; | ||||||
| 
 | 
 | ||||||
| const TPL = ` | const TPL = ` | ||||||
| @ -33,7 +33,7 @@ const TPL = ` | |||||||
|     </div> |     </div> | ||||||
| </div>`; | </div>`; | ||||||
| 
 | 
 | ||||||
| export default class SearchResultWidget extends TabAwareWidget { | export default class SearchResultWidget extends NoteContextAwareWidget { | ||||||
|     isEnabled() { |     isEnabled() { | ||||||
|         return super.isEnabled() |         return super.isEnabled() | ||||||
|             && this.note.type === 'search'; |             && this.note.type === 'search'; | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| import linkService from "../services/link.js"; | import linkService from "../services/link.js"; | ||||||
| import server from "../services/server.js"; | import server from "../services/server.js"; | ||||||
| import froca from "../services/froca.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"; | import options from "../services/options.js"; | ||||||
| 
 | 
 | ||||||
| const TPL = ` | const TPL = ` | ||||||
| @ -39,7 +39,7 @@ const TPL = ` | |||||||
| </div> | </div> | ||||||
| `;
 | `;
 | ||||||
| 
 | 
 | ||||||
| export default class SimilarNotesWidget extends TabAwareWidget { | export default class SimilarNotesWidget extends NoteContextAwareWidget { | ||||||
|     isEnabled() { |     isEnabled() { | ||||||
|         return super.isEnabled() |         return super.isEnabled() | ||||||
|             && this.note.type !== 'search' |             && this.note.type !== 'search' | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| import TabAwareWidget from "./tab_aware_widget.js"; | import NoteContextAwareWidget from "./note_context_aware_widget.js"; | ||||||
| 
 | 
 | ||||||
| const TPL = ` | const TPL = ` | ||||||
| <div class="sql-result-widget"> | <div class="sql-result-widget"> | ||||||
| @ -11,7 +11,7 @@ const TPL = ` | |||||||
|     <div class="sql-console-result-container"></div> |     <div class="sql-console-result-container"></div> | ||||||
| </div>`; | </div>`; | ||||||
| 
 | 
 | ||||||
| export default class SqlResultWidget extends TabAwareWidget { | export default class SqlResultWidget extends NoteContextAwareWidget { | ||||||
|     isEnabled() { |     isEnabled() { | ||||||
|         return this.note |         return this.note | ||||||
|             && this.note.mime === 'text/x-sqlite;schema=trilium' |             && this.note.mime === 'text/x-sqlite;schema=trilium' | ||||||
|  | |||||||
| @ -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 treeService from "../services/tree.js"; | ||||||
| import linkService from "../services/link.js"; | import linkService from "../services/link.js"; | ||||||
| import hoistedNoteService from "../services/hoisted_note.js"; | import hoistedNoteService from "../services/hoisted_note.js"; | ||||||
| @ -33,7 +33,7 @@ const TPL = ` | |||||||
|     <span class="sql-table-schemas"></span> |     <span class="sql-table-schemas"></span> | ||||||
| </div>`; | </div>`; | ||||||
| 
 | 
 | ||||||
| export default class SqlTableSchemasWidget extends TabAwareWidget { | export default class SqlTableSchemasWidget extends NoteContextAwareWidget { | ||||||
|     isEnabled() { |     isEnabled() { | ||||||
|         return this.note |         return this.note | ||||||
|             && this.note.mime === 'text/x-sqlite;schema=trilium' |             && this.note.mime === 'text/x-sqlite;schema=trilium' | ||||||
|  | |||||||
| @ -409,13 +409,13 @@ export default class TabRowWidget extends BasicWidget { | |||||||
|     closeActiveTabCommand({$el}) { |     closeActiveTabCommand({$el}) { | ||||||
|         const ntxId = $el.closest(".note-tab").attr('data-tab-id'); |         const ntxId = $el.closest(".note-tab").attr('data-tab-id'); | ||||||
| 
 | 
 | ||||||
|         appContext.tabManager.removeTab(ntxId); |         appContext.tabManager.removeNoteContext(ntxId); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     setTabCloseEvent($tab) { |     setTabCloseEvent($tab) { | ||||||
|         $tab.on('mousedown', e => { |         $tab.on('mousedown', e => { | ||||||
|             if (e.which === 2) { |             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
 |                 return true; // event has been handled
 | ||||||
|             } |             } | ||||||
| @ -427,7 +427,7 @@ export default class TabRowWidget extends BasicWidget { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     activeTabChangedEvent() { |     activeTabChangedEvent() { | ||||||
|         let activeNoteContext = appContext.tabManager.getActiveNoteContext(); |         let activeNoteContext = appContext.tabManager.getActiveContext(); | ||||||
| 
 | 
 | ||||||
|         if (!activeNoteContext) { |         if (!activeNoteContext) { | ||||||
|             return; |             return; | ||||||
| @ -444,7 +444,7 @@ export default class TabRowWidget extends BasicWidget { | |||||||
|         if (tabEl) tabEl.setAttribute('active', ''); |         if (tabEl) tabEl.setAttribute('active', ''); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     newTabOpenedEvent({noteContext}) { |     newNoteContextCreatedEvent({noteContext}) { | ||||||
|         if (!noteContext.mainNtxId) { |         if (!noteContext.mainNtxId) { | ||||||
|             this.addTab(noteContext.ntxId); |             this.addTab(noteContext.ntxId); | ||||||
|         } |         } | ||||||
| @ -478,7 +478,7 @@ export default class TabRowWidget extends BasicWidget { | |||||||
|         return $tab.attr('data-tab-id'); |         return $tab.attr('data-tab-id'); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     tabRemovedEvent({ntxIds}) { |     noteContextRemovedEvent({ntxIds}) { | ||||||
|         for (const ntxId of ntxIds) { |         for (const ntxId of ntxIds) { | ||||||
|             this.removeTab(ntxId); |             this.removeTab(ntxId); | ||||||
|         } |         } | ||||||
| @ -517,7 +517,7 @@ export default class TabRowWidget extends BasicWidget { | |||||||
|             this.draggabillies.push(draggabilly); |             this.draggabillies.push(draggabilly); | ||||||
| 
 | 
 | ||||||
|             draggabilly.on('pointerDown', _ => { |             draggabilly.on('pointerDown', _ => { | ||||||
|                 appContext.tabManager.activateTab(tabEl.getAttribute('data-tab-id')); |                 appContext.tabManager.activateNoteContext(tabEl.getAttribute('data-tab-id')); | ||||||
|             }); |             }); | ||||||
| 
 | 
 | ||||||
|             draggabilly.on('dragStart', _ => { |             draggabilly.on('dragStart', _ => { | ||||||
| @ -611,13 +611,13 @@ export default class TabRowWidget extends BasicWidget { | |||||||
|         return closestIndex; |         return closestIndex; | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     tabNoteSwitchedAndActivatedEvent({noteContext}) { |     noteSwitchedAndActivatedEvent({noteContext}) { | ||||||
|         this.activeTabChangedEvent(); |         this.activeTabChangedEvent(); | ||||||
| 
 | 
 | ||||||
|         this.updateTabById(noteContext.mainNtxId || noteContext.ntxId); |         this.updateTabById(noteContext.mainNtxId || noteContext.ntxId); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     tabNoteSwitchedEvent({noteContext}) { |     noteSwitchedEvent({noteContext}) { | ||||||
|         this.updateTabById(noteContext.mainNtxId || noteContext.ntxId); |         this.updateTabById(noteContext.mainNtxId || noteContext.ntxId); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| import server from "../../services/server.js"; | 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 toastService from "../../services/toast.js"; | ||||||
| import openService from "../../services/open.js"; | import openService from "../../services/open.js"; | ||||||
| import utils from "../../services/utils.js"; | import utils from "../../services/utils.js"; | ||||||
| @ -54,7 +54,7 @@ const TPL = ` | |||||||
|     </table> |     </table> | ||||||
| </div>`; | </div>`; | ||||||
| 
 | 
 | ||||||
| export default class FilePropertiesWidget extends TabAwareWidget { | export default class FilePropertiesWidget extends NoteContextAwareWidget { | ||||||
|     static getType() { return "file"; } |     static getType() { return "file"; } | ||||||
| 
 | 
 | ||||||
|     isEnabled() { |     isEnabled() { | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| import server from "../../services/server.js"; | 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 toastService from "../../services/toast.js"; | ||||||
| import openService from "../../services/open.js"; | import openService from "../../services/open.js"; | ||||||
| import utils from "../../services/utils.js"; | import utils from "../../services/utils.js"; | ||||||
| @ -36,7 +36,7 @@ const TPL = ` | |||||||
|     <input type="file" class="image-upload-new-revision-input" style="display: none"> |     <input type="file" class="image-upload-new-revision-input" style="display: none"> | ||||||
| </div>`; | </div>`; | ||||||
| 
 | 
 | ||||||
| export default class ImagePropertiesWidget extends TabAwareWidget { | export default class ImagePropertiesWidget extends NoteContextAwareWidget { | ||||||
|     static getType() { return "image"; } |     static getType() { return "image"; } | ||||||
| 
 | 
 | ||||||
|     isEnabled() { |     isEnabled() { | ||||||
|  | |||||||
| @ -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 AttributeDetailWidget from "../attribute_widgets/attribute_detail.js"; | ||||||
| import attributeRenderer from "../../services/attribute_renderer.js"; | import attributeRenderer from "../../services/attribute_renderer.js"; | ||||||
| 
 | 
 | ||||||
| @ -20,7 +20,7 @@ const TPL = ` | |||||||
|     <div class="inherited-attributes-container"></div> |     <div class="inherited-attributes-container"></div> | ||||||
| </div>`; | </div>`; | ||||||
| 
 | 
 | ||||||
| export default class InheritedAttributesWidget extends TabAwareWidget { | export default class InheritedAttributesWidget extends NoteContextAwareWidget { | ||||||
|     constructor() { |     constructor() { | ||||||
|         super(); |         super(); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| import TabAwareWidget from "../tab_aware_widget.js"; | import NoteContextAwareWidget from "../note_context_aware_widget.js"; | ||||||
| 
 | 
 | ||||||
| const TPL = ` | const TPL = ` | ||||||
| <div class="note-properties-widget"> | <div class="note-properties-widget"> | ||||||
| @ -14,7 +14,7 @@ const TPL = ` | |||||||
|     </div> |     </div> | ||||||
| </div>`; | </div>`; | ||||||
| 
 | 
 | ||||||
| export default class NotePropertiesWidget extends TabAwareWidget { | export default class NotePropertiesWidget extends NoteContextAwareWidget { | ||||||
|     static getType() { return "note-properties"; } |     static getType() { return "note-properties"; } | ||||||
| 
 | 
 | ||||||
|     isEnabled() { |     isEnabled() { | ||||||
|  | |||||||
| @ -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 AttributeDetailWidget from "../attribute_widgets/attribute_detail.js"; | ||||||
| import AttributeEditorWidget from "../attribute_widgets/attribute_editor.js"; | import AttributeEditorWidget from "../attribute_widgets/attribute_editor.js"; | ||||||
| 
 | 
 | ||||||
| @ -21,7 +21,7 @@ const TPL = ` | |||||||
| </div> | </div> | ||||||
| `;
 | `;
 | ||||||
| 
 | 
 | ||||||
| export default class OwnedAttributeListWidget extends TabAwareWidget { | export default class OwnedAttributeListWidget extends NoteContextAwareWidget { | ||||||
|     constructor() { |     constructor() { | ||||||
|         super(); |         super(); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -2,7 +2,7 @@ import server from "../../services/server.js"; | |||||||
| import ws from "../../services/ws.js"; | import ws from "../../services/ws.js"; | ||||||
| import treeService from "../../services/tree.js"; | import treeService from "../../services/tree.js"; | ||||||
| import noteAutocompleteService from "../../services/note_autocomplete.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 = ` | const TPL = ` | ||||||
| <div> | <div> | ||||||
| @ -34,7 +34,7 @@ const TPL = ` | |||||||
| </div> | </div> | ||||||
| `;
 | `;
 | ||||||
| 
 | 
 | ||||||
| export default class PromotedAttributesWidget extends TabAwareWidget { | export default class PromotedAttributesWidget extends NoteContextAwareWidget { | ||||||
|     doRender() { |     doRender() { | ||||||
|         this.$widget = $(TPL); |         this.$widget = $(TPL); | ||||||
|         this.overflowing(); |         this.overflowing(); | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| import server from "../../services/server.js"; | 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 froca from "../../services/froca.js"; | ||||||
| import ws from "../../services/ws.js"; | import ws from "../../services/ws.js"; | ||||||
| import toastService from "../../services/toast.js"; | import toastService from "../../services/toast.js"; | ||||||
| @ -199,7 +199,7 @@ for (const clazz of [ | |||||||
|     ACTION_CLASSES[clazz.actionName] = clazz; |     ACTION_CLASSES[clazz.actionName] = clazz; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export default class SearchDefinitionWidget extends TabAwareWidget { | export default class SearchDefinitionWidget extends NoteContextAwareWidget { | ||||||
|     static getType() { return "search"; } |     static getType() { return "search"; } | ||||||
| 
 | 
 | ||||||
|     isEnabled() { |     isEnabled() { | ||||||
|  | |||||||
| @ -23,7 +23,7 @@ export default class AbstractTextTypeWidget extends TypeWidget { | |||||||
|         const noteId = this.getNoteIdFromImage(imgSrc); |         const noteId = this.getNoteIdFromImage(imgSrc); | ||||||
| 
 | 
 | ||||||
|         if (noteId) { |         if (noteId) { | ||||||
|             appContext.tabManager.getActiveNoteContext().setNote(noteId); |             appContext.tabManager.getActiveContext().setNote(noteId); | ||||||
|         } else { |         } else { | ||||||
|             window.open(imgSrc, '_blank'); |             window.open(imgSrc, '_blank'); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -61,7 +61,7 @@ export default class EmptyTypeWidget extends TypeWidget { | |||||||
|                     return false; |                     return false; | ||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|                 appContext.tabManager.getActiveNoteContext().setNote(suggestion.notePath); |                 appContext.tabManager.getActiveContext().setNote(suggestion.notePath); | ||||||
|             }); |             }); | ||||||
| 
 | 
 | ||||||
|         noteAutocompleteService.showRecentNotes(this.$autoComplete); |         noteAutocompleteService.showRecentNotes(this.$autoComplete); | ||||||
|  | |||||||
| @ -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
 |     // for overriding
 | ||||||
|     static getType() {} |     static getType() {} | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam