refactor(react/widgets): typings for dynamic require + solve type errors

This commit is contained in:
Elian Doran
2025-08-29 19:29:15 +03:00
parent 3fd7afbb57
commit ab48a28635
7 changed files with 19 additions and 21 deletions

View File

@@ -55,7 +55,7 @@ export class TypedBasicWidget<T extends TypedComponent<any>> extends TypedCompon
* @param components the components to be added as children to this component provided the condition is truthy.
* @returns self for chaining.
*/
optChild(condition: boolean, ...components: T[]) {
optChild(condition: boolean, ...components: (T | VNode)[]) {
if (condition) {
return this.child(...components);
} else {

View File

@@ -4,15 +4,7 @@ import treeService from "../../services/tree.js";
import ButtonFromNoteWidget from "./button_from_note.js";
import type FNote from "../../entities/fnote.js";
import type { CommandNames } from "../../components/app_context.js";
interface WebContents {
history: string[];
getActiveIndex(): number;
clearHistory(): void;
canGoBack(): boolean;
canGoForward(): boolean;
goToIndex(index: string): void;
}
import type { WebContents } from "electron";
interface ContextMenuItem {
title: string;
@@ -51,14 +43,14 @@ export default class HistoryNavigationButton extends ButtonFromNoteWidget {
async showContextMenu(e: JQuery.ContextMenuEvent) {
e.preventDefault();
if (!this.webContents || this.webContents.history.length < 2) {
if (!this.webContents || this.webContents.navigationHistory.length() < 2) {
return;
}
let items: ContextMenuItem[] = [];
const activeIndex = this.webContents.getActiveIndex();
const history = this.webContents.history;
const history = this.webContents.navigationHistory;
const activeIndex = history.getActiveIndex();
for (const idx in history) {
const url = history[idx];

View File

@@ -516,7 +516,7 @@ export function useStaticTooltip(elRef: RefObject<Element>, config?: Partial<Too
}, [ elRef, config ]);
}
export function useStaticTooltipWithKeyboardShortcut(elRef: RefObject<Element>, title: string, actionName: KeyboardActionNames) {
export function useStaticTooltipWithKeyboardShortcut(elRef: RefObject<Element>, title: string, actionName: KeyboardActionNames | undefined) {
const [ keyboardShortcut, setKeyboardShortcut ] = useState<string[]>();
useStaticTooltip(elRef, {
title: keyboardShortcut?.length ? `${title} (${keyboardShortcut?.join(",")})` : title