import ReactBasicWidget from "../react/ReactBasicWidget.js"; import Modal from "../react/Modal.jsx"; import { t } from "../../services/i18n.js"; import { ComponentChildren } from "preact"; import { CommandNames } from "../../components/app_context.js"; import RawHtml from "../react/RawHtml.jsx"; import { useEffect, useState } from "preact/hooks"; import keyboard_actions from "../../services/keyboard_actions.js"; import useTriliumEvent from "../react/hooks.jsx"; function HelpDialogComponent() { const [ shown, setShown ] = useState(false); useTriliumEvent("showCheatsheet", () => setShown(true)); return ( setShown(false)} show={shown} >
{t("help.onlyInDesktop")}
); } function KeyboardShortcut({ commands, description }: { commands: CommandNames | CommandNames[], description: string }) { const [ shortcuts, setShortcuts ] = useState([]); useEffect(() => { (async () => { const shortcuts: string[] = []; for (const command of Array.isArray(commands) ? commands : [commands]) { const action = await keyboard_actions.getAction(command); if (action) { shortcuts.push(...(action.effectiveShortcuts ?? [])); } } if (shortcuts.length === 0) { shortcuts.push(t("help.notSet")); } setShortcuts(shortcuts); })(); }, [commands]); return FixedKeyboardShortcut({ keys: shortcuts, description }); } function FixedKeyboardShortcut({ keys, description }: { keys?: string[], description: string }) { return (
  • {keys && keys.map((key, index) => <> {key} {index < keys.length - 1 ? ", " : "" } )} -
  • ); } function Card({ title, children }: { title: string, children: ComponentChildren }) { return (
    {title}

    {children}

    ) } export default class HelpDialog extends ReactBasicWidget { get component() { return ; } }