From 7d39d080f500d45f4602b329d9843719cc418a8e Mon Sep 17 00:00:00 2001 From: zadam Date: Sun, 22 May 2022 14:24:47 +0200 Subject: [PATCH] switching note type will reevalute max content width setting --- src/public/app/widgets/note_wrapper.js | 31 +++++++++++++++++--------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/public/app/widgets/note_wrapper.js b/src/public/app/widgets/note_wrapper.js index 227543c65..80da4558c 100644 --- a/src/public/app/widgets/note_wrapper.js +++ b/src/public/app/widgets/note_wrapper.js @@ -15,25 +15,36 @@ export default class NoteWrapperWidget extends FlexContainer { } setNoteContextEvent({noteContext}) { - this.refresh(noteContext); + this.noteContext = noteContext; + + this.refresh(); } - noteSwitchedAndActivatedEvent({noteContext}) { - this.refresh(noteContext); + noteSwitchedAndActivatedEvent() { + this.refresh(); } - noteSwitchedEvent({noteContext}) { - this.refresh(noteContext); + noteSwitchedEvent() { + this.refresh(); } - activeContextChangedEvent({noteContext}) { - this.refresh(noteContext); + activeContextChangedEvent() { + this.refresh(); } - refresh(noteContext) { + refresh() { + const note = this.noteContext?.note; + this.$widget.toggleClass("full-content-width", - ['image', 'mermaid', 'book', 'render', 'canvas'].includes(noteContext?.note?.type) - || !!noteContext?.note?.hasLabel('fullContentWidth') + ['image', 'mermaid', 'book', 'render', 'canvas'].includes(note?.type) + || !!note?.hasLabel('fullContentWidth') ); } + + async entitiesReloadedEvent({loadResults}) { + // listening on changes of note.type + if (loadResults.isNoteReloaded(this.noteContext?.noteId)) { + this.refresh(); + } + } }