mirror of
https://github.com/zadam/trilium.git
synced 2025-11-11 15:55:52 +01:00
chore(react): add back Ctrl+Enter for markdown import
This commit is contained in:
37
apps/client/src/widgets/react/Button.tsx
Normal file
37
apps/client/src/widgets/react/Button.tsx
Normal file
@@ -0,0 +1,37 @@
|
||||
import { useEffect, useRef } from "preact/hooks";
|
||||
import shortcuts from "../../services/shortcuts";
|
||||
|
||||
interface ButtonProps {
|
||||
text: string;
|
||||
className?: string;
|
||||
keyboardShortcut?: string;
|
||||
onClick: () => void;
|
||||
}
|
||||
|
||||
export default function Button({ className, text, onClick, keyboardShortcut }: ButtonProps) {
|
||||
const classes: string[] = ["btn"];
|
||||
classes.push("btn-primary");
|
||||
if (className) {
|
||||
classes.push(className);
|
||||
}
|
||||
|
||||
const buttonRef = useRef<HTMLButtonElement>(null);
|
||||
const splitShortcut = (keyboardShortcut ?? "").split("+");
|
||||
|
||||
return (
|
||||
<button
|
||||
className={classes.join(" ")}
|
||||
type="button"
|
||||
onClick={onClick}
|
||||
ref={buttonRef}
|
||||
>
|
||||
{text} {keyboardShortcut && (
|
||||
splitShortcut.map((key, index) => (
|
||||
<>
|
||||
<kbd key={index}>{key.toUpperCase()}</kbd>{ index < splitShortcut.length - 1 ? "+" : "" }
|
||||
</>
|
||||
))
|
||||
)}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user