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;
|
closeTocCommand: CommandData;
|
||||||
showLaunchBarSubtree: CommandData;
|
showLaunchBarSubtree: CommandData;
|
||||||
|
showRevisions: CommandData;
|
||||||
showOptions: CommandData & {
|
showOptions: CommandData & {
|
||||||
section: string;
|
section: string;
|
||||||
};
|
};
|
||||||
|
@ -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 ?? "");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -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");
|
@ -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));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -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);
|
Loading…
x
Reference in New Issue
Block a user