Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(import): expose Shrink images toggle in Obsidian import dialog
Elian Doran19851dce4ca2
diff --git a/apps/client/src/widgets/dialogs/import/obsidian.tsx b/apps/client/src/widgets/dialogs/import/obsidian.tsxindex bebb1511dd..1aa7c84b2c 100644--- a/apps/client/src/widgets/dialogs/import/obsidian.tsx+++ b/apps/client/src/widgets/dialogs/import/obsidian.tsx@@ -5,11 +5,15 @@ import importService from "../../../services/import.js";import Button from "../../react/Button.js";import { Card, CardSection } from "../../react/Card.js";import FileDropZone from "../../react/FileDropZone.js";+import { useTriliumOptionBool } from "../../react/hooks.js";+import { OptionsRowWithToggle } from "../../type_widgets/options/components/OptionsRow.js";import iconUrl from "./icons/obsidian.svg?url";import type { ImportProvider, ImportProviderPanelProps } from "./types.js";function ObsidianPanel({ parentNoteId, closeDialog, setFooter }: ImportProviderPanelProps) {const [file, setFile] = useState<File | null>(null);+ const [compressImages] = useTriliumOptionBool("compressImages");+ const [shrinkImages, setShrinkImages] = useState(compressImages);const onChange = useCallback((files: FileList | null) => setFile(files?.[0] ?? null), []);@@ -24,8 +28,8 @@ function ObsidianPanel({ parentNoteId, closeDialog, setFooter }: ImportProviderP// uploadFiles surfaces any upload error via its own toast; swallow the rejection so this void-ed// call doesn't raise an unhandled rejection.closeDialog();- await importService.uploadFiles("notes", parentNoteId, [file], { format: "obsidian", safeImport: "true", shrinkImages: "false" }).catch(() => {});- }, [file, parentNoteId, closeDialog]);+ await importService.uploadFiles("notes", parentNoteId, [file], { format: "obsidian", safeImport: "true", shrinkImages: shrinkImages ? "true" : "false" }).catch(() => {});+ }, [file, shrinkImages, parentNoteId, closeDialog]);// Keep the latest import handler in a ref so the footer effect depends only on `file` being present,// never on doImport's identity — otherwise re-pushing the footer on every change would loop with the@@ -49,6 +53,14 @@ function ObsidianPanel({ parentNoteId, closeDialog, setFooter }: ImportProviderP<CardSection><p className="import-files-description">{t("obsidian_import.description_long")}</p><FileDropZone onChange={onChange} />+ <OptionsRowWithToggle+ name="shrink-images"+ label={t("import.shrinkImages")}+ description={t("import.shrinkImagesProviderTooltip")}+ currentValue={compressImages && shrinkImages}+ onChange={setShrinkImages}+ disabled={!compressImages}+ /></CardSection></Card>);