switching note type will reevalute max content width setting

This commit is contained in:
zadam 2022-05-22 14:24:47 +02:00
parent 13ccd2ba67
commit 7d39d080f5

View File

@ -15,25 +15,36 @@ export default class NoteWrapperWidget extends FlexContainer {
} }
setNoteContextEvent({noteContext}) { setNoteContextEvent({noteContext}) {
this.refresh(noteContext); this.noteContext = noteContext;
this.refresh();
} }
noteSwitchedAndActivatedEvent({noteContext}) { noteSwitchedAndActivatedEvent() {
this.refresh(noteContext); this.refresh();
} }
noteSwitchedEvent({noteContext}) { noteSwitchedEvent() {
this.refresh(noteContext); this.refresh();
} }
activeContextChangedEvent({noteContext}) { activeContextChangedEvent() {
this.refresh(noteContext); this.refresh();
} }
refresh(noteContext) { refresh() {
const note = this.noteContext?.note;
this.$widget.toggleClass("full-content-width", this.$widget.toggleClass("full-content-width",
['image', 'mermaid', 'book', 'render', 'canvas'].includes(noteContext?.note?.type) ['image', 'mermaid', 'book', 'render', 'canvas'].includes(note?.type)
|| !!noteContext?.note?.hasLabel('fullContentWidth') || !!note?.hasLabel('fullContentWidth')
); );
} }
async entitiesReloadedEvent({loadResults}) {
// listening on changes of note.type
if (loadResults.isNoteReloaded(this.noteContext?.noteId)) {
this.refresh();
}
}
} }