mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-30 03:32:26 +08:00
refactor(client/ts): port a few more widgets
This commit is contained in:
parent
b69641c0e9
commit
13f7129717
@ -80,6 +80,7 @@ export type CommandMappings = {
|
||||
};
|
||||
closeTocCommand: CommandData;
|
||||
showLaunchBarSubtree: CommandData;
|
||||
showRevisions: CommandData;
|
||||
showOptions: CommandData & {
|
||||
section: string;
|
||||
};
|
||||
|
@ -9,6 +9,6 @@ export default class RevisionsButton extends CommandButtonWidget {
|
||||
}
|
||||
|
||||
isEnabled() {
|
||||
return super.isEnabled() && !["launcher", "doc"].includes(this.note?.type);
|
||||
return super.isEnabled() && !["launcher", "doc"].includes(this.note?.type ?? "");
|
||||
}
|
||||
}
|
@ -1,7 +1,8 @@
|
||||
import type BasicWidget from "../basic_widget.js";
|
||||
import FlexContainer from "./flex_container.js";
|
||||
|
||||
export default class RootContainer extends FlexContainer {
|
||||
constructor(isHorizontalLayout) {
|
||||
export default class RootContainer extends FlexContainer<BasicWidget> {
|
||||
constructor(isHorizontalLayout: boolean) {
|
||||
super(isHorizontalLayout ? "column" : "row");
|
||||
|
||||
this.id("root-widget");
|
@ -3,8 +3,11 @@ import NoteContextAwareWidget from "./note_context_aware_widget.js";
|
||||
const TPL = `<div class="scroll-padding-widget"></div>`;
|
||||
|
||||
export default class ScrollPaddingWidget extends NoteContextAwareWidget {
|
||||
|
||||
private $scrollingContainer!: JQuery<HTMLElement>;
|
||||
|
||||
isEnabled() {
|
||||
return super.isEnabled() && ["text", "code"].includes(this.note?.type);
|
||||
return super.isEnabled() && ["text", "code"].includes(this.note?.type ?? "");
|
||||
}
|
||||
|
||||
doRender() {
|
||||
@ -25,6 +28,6 @@ export default class ScrollPaddingWidget extends NoteContextAwareWidget {
|
||||
refreshHeight() {
|
||||
const containerHeight = this.$scrollingContainer.height();
|
||||
|
||||
this.$widget.css("height", Math.round(containerHeight / 2));
|
||||
this.$widget.css("height", Math.round((containerHeight ?? 0) / 2));
|
||||
}
|
||||
}
|
@ -28,6 +28,10 @@ const TPL = `
|
||||
</div>`;
|
||||
|
||||
export default class ProtectedSessionTypeWidget extends TypeWidget {
|
||||
|
||||
private $passwordForm!: JQuery<HTMLElement>;
|
||||
private $passwordInput!: JQuery<HTMLElement>;
|
||||
|
||||
static getType() {
|
||||
return "protectedSession";
|
||||
}
|
||||
@ -38,7 +42,7 @@ export default class ProtectedSessionTypeWidget extends TypeWidget {
|
||||
this.$passwordInput = this.$widget.find(".protected-session-password");
|
||||
|
||||
this.$passwordForm.on("submit", () => {
|
||||
const password = this.$passwordInput.val();
|
||||
const password = String(this.$passwordInput.val());
|
||||
this.$passwordInput.val("");
|
||||
|
||||
protectedSessionService.setupProtectedSession(password);
|
Loading…
x
Reference in New Issue
Block a user