mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 07:08:55 +02:00
fix(options): "Override theme fonts" not reflecting immediately
This commit is contained in:
parent
d33162785e
commit
c74f51472e
@ -137,6 +137,12 @@ const CONTENT_WIDGETS: Record<string, (typeof NoteContextAwareWidget)[]> = {
|
||||
]
|
||||
};
|
||||
|
||||
/**
|
||||
* Type widget that displays one or more widgets based on the type of note, generally used for options and other interactive notes such as the backend log.
|
||||
*
|
||||
* One important aspect is that, like its parent {@link TypeWidget}, the content widgets don't receive all events by default and they must be manually added
|
||||
* to the propagation list in {@link TypeWidget.handleEventInChildren}.
|
||||
*/
|
||||
export default class ContentWidgetTypeWidget extends TypeWidget {
|
||||
private $content!: JQuery<HTMLElement>;
|
||||
private widget?: BasicWidget;
|
||||
@ -177,12 +183,4 @@ export default class ContentWidgetTypeWidget extends TypeWidget {
|
||||
}
|
||||
}
|
||||
|
||||
async handleEventInChildren<T extends EventNames>(name: T, data: EventData<T>) {
|
||||
if (this.widget && this.widget.handleEvent) {
|
||||
return this.widget.handleEvent(name, data);
|
||||
}
|
||||
|
||||
return super.handleEventInChildren(name, data);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,9 @@ import type FNote from "../../entities/fnote.js";
|
||||
import type NoteDetailWidget from "../note_detail.js";
|
||||
import type SpacedUpdate from "../../services/spaced_update.js";
|
||||
|
||||
/**
|
||||
* The base class for all the note types.
|
||||
*/
|
||||
export default abstract class TypeWidget extends NoteContextAwareWidget {
|
||||
|
||||
spacedUpdate!: SpacedUpdate;
|
||||
@ -17,7 +20,7 @@ export default abstract class TypeWidget extends NoteContextAwareWidget {
|
||||
return super.doRender();
|
||||
}
|
||||
|
||||
doRefresh(note: FNote | null | undefined) {}
|
||||
doRefresh(note: FNote | null | undefined): void | Promise<void> {}
|
||||
|
||||
async refresh() {
|
||||
const thisWidgetType = (this.constructor as any).getType();
|
||||
@ -61,12 +64,20 @@ export default abstract class TypeWidget extends NoteContextAwareWidget {
|
||||
}
|
||||
}
|
||||
|
||||
// events should be propagated manually to the children widgets
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* By default:
|
||||
*
|
||||
* - `activeContextChanged` is intercepted and converted to a `setNoteContext` event to avoid `refresh()`.
|
||||
* - `entitiesReloaded` and `refreshData` are passed as-is.
|
||||
* - any other event is not passed to the children.
|
||||
*/
|
||||
handleEventInChildren<T extends EventNames>(name: T, data: EventData<T>) {
|
||||
if (["activeContextChanged", "setNoteContext"].includes(name)) {
|
||||
// won't trigger .refresh();
|
||||
return super.handleEventInChildren("setNoteContext", data as EventData<"activeContextChanged">);
|
||||
} else if (name === "entitiesReloaded") {
|
||||
} else if (name === "entitiesReloaded" || name === "refreshData") {
|
||||
return super.handleEventInChildren(name, data);
|
||||
} else {
|
||||
return Promise.resolve();
|
||||
|
Loading…
x
Reference in New Issue
Block a user