refactor(client/ts): port a few more widgets

This commit is contained in:
Elian Doran 2025-02-11 19:04:27 +02:00
parent b69641c0e9
commit 13f7129717
No known key found for this signature in database
6 changed files with 15 additions and 6 deletions

View File

@ -80,6 +80,7 @@ export type CommandMappings = {
}; };
closeTocCommand: CommandData; closeTocCommand: CommandData;
showLaunchBarSubtree: CommandData; showLaunchBarSubtree: CommandData;
showRevisions: CommandData;
showOptions: CommandData & { showOptions: CommandData & {
section: string; section: string;
}; };

View File

@ -9,6 +9,6 @@ export default class RevisionsButton extends CommandButtonWidget {
} }
isEnabled() { isEnabled() {
return super.isEnabled() && !["launcher", "doc"].includes(this.note?.type); return super.isEnabled() && !["launcher", "doc"].includes(this.note?.type ?? "");
} }
} }

View File

@ -1,7 +1,8 @@
import type BasicWidget from "../basic_widget.js";
import FlexContainer from "./flex_container.js"; import FlexContainer from "./flex_container.js";
export default class RootContainer extends FlexContainer { export default class RootContainer extends FlexContainer<BasicWidget> {
constructor(isHorizontalLayout) { constructor(isHorizontalLayout: boolean) {
super(isHorizontalLayout ? "column" : "row"); super(isHorizontalLayout ? "column" : "row");
this.id("root-widget"); this.id("root-widget");

View File

@ -3,8 +3,11 @@ import NoteContextAwareWidget from "./note_context_aware_widget.js";
const TPL = `<div class="scroll-padding-widget"></div>`; const TPL = `<div class="scroll-padding-widget"></div>`;
export default class ScrollPaddingWidget extends NoteContextAwareWidget { export default class ScrollPaddingWidget extends NoteContextAwareWidget {
private $scrollingContainer!: JQuery<HTMLElement>;
isEnabled() { isEnabled() {
return super.isEnabled() && ["text", "code"].includes(this.note?.type); return super.isEnabled() && ["text", "code"].includes(this.note?.type ?? "");
} }
doRender() { doRender() {
@ -25,6 +28,6 @@ export default class ScrollPaddingWidget extends NoteContextAwareWidget {
refreshHeight() { refreshHeight() {
const containerHeight = this.$scrollingContainer.height(); const containerHeight = this.$scrollingContainer.height();
this.$widget.css("height", Math.round(containerHeight / 2)); this.$widget.css("height", Math.round((containerHeight ?? 0) / 2));
} }
} }

View File

@ -28,6 +28,10 @@ const TPL = `
</div>`; </div>`;
export default class ProtectedSessionTypeWidget extends TypeWidget { export default class ProtectedSessionTypeWidget extends TypeWidget {
private $passwordForm!: JQuery<HTMLElement>;
private $passwordInput!: JQuery<HTMLElement>;
static getType() { static getType() {
return "protectedSession"; return "protectedSession";
} }
@ -38,7 +42,7 @@ export default class ProtectedSessionTypeWidget extends TypeWidget {
this.$passwordInput = this.$widget.find(".protected-session-password"); this.$passwordInput = this.$widget.find(".protected-session-password");
this.$passwordForm.on("submit", () => { this.$passwordForm.on("submit", () => {
const password = this.$passwordInput.val(); const password = String(this.$passwordInput.val());
this.$passwordInput.val(""); this.$passwordInput.val("");
protectedSessionService.setupProtectedSession(password); protectedSessionService.setupProtectedSession(password);