mirror of
https://github.com/zadam/trilium.git
synced 2025-12-03 22:14:24 +01:00
refactor(markdown_import): deduplicate submit
This commit is contained in:
parent
e07b6cc409
commit
6b18ed6477
@ -34,6 +34,13 @@ export default function MarkdownImportDialog() {
|
||||
}
|
||||
});
|
||||
|
||||
function submit() {
|
||||
setShown(false);
|
||||
if (editorApiRef.current) {
|
||||
convertMarkdownToHtml(text, editorApiRef.current);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Modal
|
||||
className="markdown-import-dialog" title={t("markdown_import.dialog_title")} size="lg"
|
||||
@ -42,12 +49,7 @@ export default function MarkdownImportDialog() {
|
||||
className="markdown-import-button"
|
||||
text={t("markdown_import.import_button")}
|
||||
keyboardShortcut="Ctrl+Enter"
|
||||
onClick={async () => {
|
||||
setShown(false);
|
||||
if (editorApiRef.current) {
|
||||
await convertMarkdownToHtml(text, editorApiRef.current);
|
||||
}
|
||||
}}
|
||||
onClick={submit}
|
||||
/>
|
||||
}
|
||||
onShown={() => markdownImportTextArea.current?.focus()}
|
||||
@ -64,10 +66,7 @@ export default function MarkdownImportDialog() {
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter" && e.ctrlKey) {
|
||||
e.preventDefault();
|
||||
setShown(false);
|
||||
if (editorApiRef.current) {
|
||||
convertMarkdownToHtml(text, editorApiRef.current);
|
||||
}
|
||||
submit();
|
||||
}
|
||||
}}></textarea>
|
||||
</Modal>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user