mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 02:45:54 +01:00
refactroring WIP
This commit is contained in:
@@ -28,21 +28,8 @@ class TabContext extends Component {
|
||||
this.tabRow = tabRow;
|
||||
this.tabId = state.tabId || utils.randomString(4);
|
||||
this.$tab = $(this.tabRow.addTab(this.tabId));
|
||||
this.initialized = false;
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
async initTabContent() {
|
||||
if (this.initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.initialized = true;
|
||||
|
||||
this.$tabContent = $("<div>"); // FIXME
|
||||
|
||||
this.noteChangeDisabled = false;
|
||||
this.isNoteChanged = false;
|
||||
this.attributes = new Attributes(this.appContext, this);
|
||||
|
||||
this.children.push(this.attributes);
|
||||
@@ -77,35 +64,15 @@ class TabContext extends Component {
|
||||
|
||||
bundleService.executeRelationBundles(this.note, 'runOnNoteView', this);
|
||||
|
||||
// after loading new note make sure editor is scrolled to the top
|
||||
// FIXME
|
||||
//this.getComponent().scrollToTop();
|
||||
|
||||
appContext.trigger('activeNoteChanged');
|
||||
}
|
||||
|
||||
async show() {
|
||||
if (!this.initialized) {
|
||||
await this.initTabContent();
|
||||
|
||||
if (this.notePath) {
|
||||
await this.setNote(this.notePath);
|
||||
}
|
||||
else {
|
||||
// FIXME
|
||||
await this.renderComponent(); // render empty page
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async renderComponent(disableAutoBook = false) {
|
||||
// FIXME
|
||||
await this.setNote(this.notePath);
|
||||
}
|
||||
|
||||
hide() {
|
||||
if (this.initialized) {
|
||||
this.$tabContent.hide();
|
||||
}
|
||||
// FIXME
|
||||
}
|
||||
|
||||
isActive() {
|
||||
@@ -124,14 +91,6 @@ class TabContext extends Component {
|
||||
this.$tab.addClass(utils.getMimeTypeClass(this.note.mime));
|
||||
}
|
||||
|
||||
getComponent() {
|
||||
// FIXME
|
||||
}
|
||||
|
||||
getComponentType(disableAutoBook) {
|
||||
// FIXME
|
||||
}
|
||||
|
||||
async activate() {
|
||||
await this.tabRow.activateTab(this.$tab[0]);
|
||||
}
|
||||
@@ -176,35 +135,6 @@ class TabContext extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
noteChanged() {
|
||||
if (this.noteChangeDisabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.isNoteChanged = true;
|
||||
|
||||
// FIXME: trigger noteChanged event
|
||||
//this.$savedIndicator.fadeOut();
|
||||
}
|
||||
|
||||
async remove() {
|
||||
if (this.$tabContent) {
|
||||
// sometimes there are orphan autocompletes after closing the tab
|
||||
this.cleanup();
|
||||
|
||||
await this.saveNoteIfChanged();
|
||||
this.$tabContent.remove();
|
||||
}
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
if (this.$tabContent && utils.isDesktop()) {
|
||||
this.$tabContent.find('.aa-input').autocomplete('close');
|
||||
|
||||
$('.note-tooltip').remove();
|
||||
}
|
||||
}
|
||||
|
||||
getTabState() {
|
||||
if (!this.notePath) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user