event fixes WIP

This commit is contained in:
zadam 2020-03-06 23:34:39 +01:00
parent e10d23289e
commit 091eb8f791
5 changed files with 9 additions and 11 deletions

View File

@ -4,12 +4,12 @@ import utils from "../services/utils.js";
const $dialog = $("#note-source-dialog");
const $noteSource = $("#note-source");
export function showDialog() {
export async function showDialog() {
utils.openDialog($dialog);
const noteText = appContext.tabManager.getActiveTabNote().content;
const noteCompletement = await appContext.tabManager.getActiveTabContext().getNoteComplement();
$noteSource.text(formatHtml(noteText));
$noteSource.text(formatHtml(noteCompletement.content));
}
function formatHtml(str) {

View File

@ -102,8 +102,7 @@ export default class NoteDetailWidget extends TabAwareWidget {
const typeWidget = this.typeWidgets[this.type] = new clazz();
typeWidget.spacedUpdate = this.spacedUpdate;
this.child(typeWidget);
typeWidget.setParent(this);
const $renderedWidget = typeWidget.render();
keyboardActionsService.updateDisplayedShortcuts($renderedWidget);
@ -112,10 +111,7 @@ export default class NoteDetailWidget extends TabAwareWidget {
await typeWidget.handleEvent('setTabContext', {tabContext: this.tabContext});
typeWidget.handleEvent('tabNoteSwitched', {
tabId: this.tabContext.tabId,
notePath: this.notePath
});
this.child(typeWidget);
}
this.setupClasses();

View File

@ -421,7 +421,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
collapseTreeCommand() { this.collapseTree(); }
isEnabled() {
return this.tabContext && this.tabContext.isActive();
return !!this.tabContext;
}
async refresh() {

View File

@ -80,6 +80,8 @@ export default class TabAwareWidget extends BasicWidget {
setTabContextEvent({tabContext}) {
/** @var {TabContext} */
this.tabContext = tabContext;
this.refresh();
}
async newTabOpenedEvent({tabContext}) {

View File

@ -143,7 +143,7 @@ export default class TextTypeWidget extends TypeWidget {
async doRefresh(note) {
this.textEditor.isReadOnly = await note.hasLabel('readOnly');
const noteComplement = await this.tabContext.getNoteComplement();
const noteComplement = await treeCache.getNoteComplement(note.noteId);
await this.spacedUpdate.allowUpdateWithoutChange(() => {
this.textEditor.setData(noteComplement.content);