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 (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
className="markdown-import-dialog" title={t("markdown_import.dialog_title")} size="lg"
|
className="markdown-import-dialog" title={t("markdown_import.dialog_title")} size="lg"
|
||||||
@ -42,12 +49,7 @@ export default function MarkdownImportDialog() {
|
|||||||
className="markdown-import-button"
|
className="markdown-import-button"
|
||||||
text={t("markdown_import.import_button")}
|
text={t("markdown_import.import_button")}
|
||||||
keyboardShortcut="Ctrl+Enter"
|
keyboardShortcut="Ctrl+Enter"
|
||||||
onClick={async () => {
|
onClick={submit}
|
||||||
setShown(false);
|
|
||||||
if (editorApiRef.current) {
|
|
||||||
await convertMarkdownToHtml(text, editorApiRef.current);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
onShown={() => markdownImportTextArea.current?.focus()}
|
onShown={() => markdownImportTextArea.current?.focus()}
|
||||||
@ -64,10 +66,7 @@ export default function MarkdownImportDialog() {
|
|||||||
onKeyDown={(e) => {
|
onKeyDown={(e) => {
|
||||||
if (e.key === "Enter" && e.ctrlKey) {
|
if (e.key === "Enter" && e.ctrlKey) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
setShown(false);
|
submit();
|
||||||
if (editorApiRef.current) {
|
|
||||||
convertMarkdownToHtml(text, editorApiRef.current);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}}></textarea>
|
}}></textarea>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user