mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
refactored TabContext => NoteContext
This commit is contained in:
parent
79a85a0aa7
commit
1a0aaf4a30
@ -227,14 +227,14 @@ export default class AttributeEditorWidget extends NoteContextAwareWidget {
|
|||||||
|
|
||||||
// triggered from keyboard shortcut
|
// triggered from keyboard shortcut
|
||||||
addNewLabelEvent({ntxId}) {
|
addNewLabelEvent({ntxId}) {
|
||||||
if (this.isTab(ntxId)) {
|
if (this.isNoteContext(ntxId)) {
|
||||||
this.handleAddNewAttributeCommand('addNewLabel');
|
this.handleAddNewAttributeCommand('addNewLabel');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// triggered from keyboard shortcut
|
// triggered from keyboard shortcut
|
||||||
addNewRelationEvent({ntxId}) {
|
addNewRelationEvent({ntxId}) {
|
||||||
if (this.isTab(ntxId)) {
|
if (this.isNoteContext(ntxId)) {
|
||||||
this.handleAddNewAttributeCommand('addNewRelation');
|
this.handleAddNewAttributeCommand('addNewRelation');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ import BasicWidget from "./basic_widget.js";
|
|||||||
import appContext from "../services/app_context.js";
|
import appContext from "../services/app_context.js";
|
||||||
|
|
||||||
export default class NoteContextAwareWidget extends BasicWidget {
|
export default class NoteContextAwareWidget extends BasicWidget {
|
||||||
isTab(ntxId) {
|
isNoteContext(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);
|
||||||
}
|
}
|
||||||
@ -11,10 +11,6 @@ export default class NoteContextAwareWidget extends BasicWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isTabOrParent(ntxId) {
|
|
||||||
return this.noteContext && (this.noteContext.ntxId === ntxId || this.noteContext.mainNtxId === ntxId);
|
|
||||||
}
|
|
||||||
|
|
||||||
isNote(noteId) {
|
isNote(noteId) {
|
||||||
return this.noteId === noteId;
|
return this.noteId === noteId;
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ export default class NoteContextCachingWidget extends NoteContextAwareWidget {
|
|||||||
|
|
||||||
toggleExt(show) {
|
toggleExt(show) {
|
||||||
for (const ntxId in this.widgets) {
|
for (const ntxId in this.widgets) {
|
||||||
this.widgets[ntxId].toggleExt(show && this.isTab(ntxId));
|
this.widgets[ntxId].toggleExt(show && this.isNoteContext(ntxId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,13 +197,13 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async beforeNoteSwitchEvent({noteContext}) {
|
async beforeNoteSwitchEvent({noteContext}) {
|
||||||
if (this.isTab(noteContext.ntxId)) {
|
if (this.isNoteContext(noteContext.ntxId)) {
|
||||||
await this.spacedUpdate.updateNowIfNecessary();
|
await this.spacedUpdate.updateNowIfNecessary();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async beforeTabRemoveEvent({ntxIds}) {
|
async beforeTabRemoveEvent({ntxIds}) {
|
||||||
if (this.isTab(ntxIds)) {
|
if (this.isNoteContext(ntxIds)) {
|
||||||
await this.spacedUpdate.updateNowIfNecessary();
|
await this.spacedUpdate.updateNowIfNecessary();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -242,7 +242,7 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
hoistedNoteChangedEvent({ntxId}) {
|
hoistedNoteChangedEvent({ntxId}) {
|
||||||
if (this.isTab(ntxId)) {
|
if (this.isNoteContext(ntxId)) {
|
||||||
this.refresh();
|
this.refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -279,13 +279,13 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
textPreviewDisabledEvent({noteContext}) {
|
textPreviewDisabledEvent({noteContext}) {
|
||||||
if (this.isTab(noteContext.ntxId)) {
|
if (this.isNoteContext(noteContext.ntxId)) {
|
||||||
this.refresh();
|
this.refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
codePreviewDisabledEvent({noteContext}) {
|
codePreviewDisabledEvent({noteContext}) {
|
||||||
if (this.isTab(noteContext.ntxId)) {
|
if (this.isNoteContext(noteContext.ntxId)) {
|
||||||
this.refresh();
|
this.refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ export default class NoteListWidget extends NoteContextAwareWidget {
|
|||||||
* it is not intersected (visible) anymore.
|
* it is not intersected (visible) anymore.
|
||||||
*/
|
*/
|
||||||
noteDetailRefreshedEvent({ntxId}) {
|
noteDetailRefreshedEvent({ntxId}) {
|
||||||
if (!this.isTab(ntxId)) {
|
if (!this.isNoteContext(ntxId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,13 +67,13 @@ export default class NoteTitleWidget extends NoteContextAwareWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async beforeNoteSwitchEvent({noteContext}) {
|
async beforeNoteSwitchEvent({noteContext}) {
|
||||||
if (this.isTab(noteContext.ntxId)) {
|
if (this.isNoteContext(noteContext.ntxId)) {
|
||||||
await this.spacedUpdate.updateNowIfNecessary();
|
await this.spacedUpdate.updateNowIfNecessary();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async beforeTabRemoveEvent({ntxIds}) {
|
async beforeTabRemoveEvent({ntxIds}) {
|
||||||
if (this.isTab(ntxIds)) {
|
if (this.isNoteContext(ntxIds)) {
|
||||||
await this.spacedUpdate.updateNowIfNecessary();
|
await this.spacedUpdate.updateNowIfNecessary();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1233,7 +1233,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async hoistedNoteChangedEvent({ntxId}) {
|
async hoistedNoteChangedEvent({ntxId}) {
|
||||||
if (this.isTab(ntxId)) {
|
if (this.isNoteContext(ntxId)) {
|
||||||
this.filterHoistedBranch();
|
this.filterHoistedBranch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ export default class SearchResultWidget extends NoteContextAwareWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
searchRefreshedEvent({ntxId}) {
|
searchRefreshedEvent({ntxId}) {
|
||||||
if (!this.isTab(ntxId)) {
|
if (!this.isNoteContext(ntxId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ export default class SqlResultWidget extends NoteContextAwareWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async sqlQueryResultsEvent({ntxId, results}) {
|
async sqlQueryResultsEvent({ntxId, results}) {
|
||||||
if (!this.isTab(ntxId)) {
|
if (!this.isNoteContext(ntxId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ class ImageTypeWidget extends TypeWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
copyImageToClipboardEvent({ntxId}) {
|
copyImageToClipboardEvent({ntxId}) {
|
||||||
if (!this.isTab(ntxId)) {
|
if (!this.isNoteContext(ntxId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,13 +36,13 @@ export default class TypeWidget extends NoteContextAwareWidget {
|
|||||||
focus() {}
|
focus() {}
|
||||||
|
|
||||||
textPreviewDisabledEvent({noteContext}) {
|
textPreviewDisabledEvent({noteContext}) {
|
||||||
if (this.isTab(noteContext.ntxId)) {
|
if (this.isNoteContext(noteContext.ntxId)) {
|
||||||
this.refresh();
|
this.refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
codePreviewDisabledEvent({noteContext}) {
|
codePreviewDisabledEvent({noteContext}) {
|
||||||
if (this.isTab(noteContext.ntxId)) {
|
if (this.isNoteContext(noteContext.ntxId)) {
|
||||||
this.refresh();
|
this.refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user