Skip to content

Build your personal knowledge base with Trilium Notes

feat(import): merge service import into the file import dialog

Elian Doranae523b7ed7f4
diff --git a/apps/client/src/components/app_context.ts b/apps/client/src/components/app_context.ts
index c8a6861c71..02a0c2d8ad 100644
--- a/apps/client/src/components/app_context.ts
+++ b/apps/client/src/components/app_context.ts
@@ -144,7 +144,6 @@ export type CommandMappings = {
showConfirmDialog: ConfirmWithMessageOptions;
showRecentChanges: CommandData & { ancestorNoteId: string };
showImportDialog: CommandData & { noteId: string };
- showImportProviderDialog: CommandData & { noteId: string };
openNewNoteSplit: NoteCommandData;
openInWindow: NoteCommandData;
openInPopup: CommandData & { noteIdOrPath: string; };
diff --git a/apps/client/src/layouts/layout_commons.tsx b/apps/client/src/layouts/layout_commons.tsx
index 1c7d181679..0557deea98 100644
--- a/apps/client/src/layouts/layout_commons.tsx
+++ b/apps/client/src/layouts/layout_commons.tsx
@@ -24,8 +24,7 @@ export function applyModals(rootContainer: RootContainer) {
.child(<LazyDialog triggerEvents={["showAddLinkDialog"]} loader={() => import("../widgets/dialogs/add_link.js")} />)
.child(<LazyDialog triggerEvents={["cloneNoteIdsTo"]} loader={() => import("../widgets/dialogs/clone_to.js")} />)
.child(<LazyDialog triggerEvents={["moveBranchIdsTo"]} loader={() => import("../widgets/dialogs/move_to.js")} />)
- .child(<LazyDialog triggerEvents={["showImportDialog"]} loader={() => import("../widgets/dialogs/import.js")} />)
- .child(<LazyDialog triggerEvents={["showImportProviderDialog"]} loader={() => import("../widgets/dialogs/import_provider.js")} />)
+ .child(<LazyDialog triggerEvents={["showImportDialog"]} loader={() => import("../widgets/dialogs/import/import_dialog.js")} />)
.child(<LazyDialog triggerEvents={["showExportDialog"]} loader={() => import("../widgets/dialogs/export.js")} />)
.child(<LazyDialog triggerEvents={["showPasteMarkdownDialog"]} loader={() => import("../widgets/dialogs/markdown_import.js")} />)
.child(<LazyDialog triggerEvents={["showProtectedSessionPasswordDialog"]} loader={() => import("../widgets/dialogs/protected_session_password.js")} />)
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index 8a29e0cf86..5c4b87088e 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -201,6 +201,8 @@
},
"import": {
"importIntoNote": "Import into note",
+ "cardName": "Files & other formats",
+ "cardDescription": "ZIP, ENEX, OPML, Markdown, HTML, images and more",
"chooseImportFile": "Choose import file",
"importDescription": "Content of the selected file(s) will be imported as child note(s) into",
"importZipRecommendation": "When importing a ZIP file, the note hierarchy will reflect the subdirectory structure within the archive.",
@@ -229,7 +231,6 @@
"successful": "Import finished successfully."
},
"import_provider": {
- "title": "Import from a service",
"choose_provider": "Choose a service above to import from."
},
"onenote_import": {
@@ -860,7 +861,6 @@
"open_note_custom": "Open note custom",
"open_note_on_server": "Open note on server",
"import_files": "Import files",
- "import_from_service": "Import from a service…",
"export_note": "Export note",
"delete_note": "Delete note",
"print_note": "Print note...",
diff --git a/apps/client/src/widgets/dialogs/import.tsx b/apps/client/src/widgets/dialogs/import.tsx
deleted file mode 100644
index df05c1ff06..0000000000
--- a/apps/client/src/widgets/dialogs/import.tsx
+++ /dev/null
@@ -1,109 +0,0 @@
-import { useState } from "preact/hooks";
-import { t } from "../../services/i18n";
-import tree from "../../services/tree";
-import Button from "../react/Button";
-import FormCheckbox from "../react/FormCheckbox";
-import FormFileUpload from "../react/FormFileUpload";
-import FormGroup, { FormMultiGroup } from "../react/FormGroup";
-import Modal from "../react/Modal";
-import RawHtml from "../react/RawHtml";
-import importService, { UploadFilesOptions } from "../../services/import";
-import { useTriliumEvent, useTriliumOptionBool } from "../react/hooks";
-
-export default function ImportDialog() {
- const [ compressImages ] = useTriliumOptionBool("compressImages");
- const [ parentNoteId, setParentNoteId ] = useState<string>();
- const [ noteTitle, setNoteTitle ] = useState<string>();
- const [ files, setFiles ] = useState<FileList | null>(null);
- const [ safeImport, setSafeImport ] = useState(true);
- const [ explodeArchives, setExplodeArchives ] = useState(true);
- const [ shrinkImages, setShrinkImages ] = useState(compressImages);
- const [ textImportedAsText, setTextImportedAsText ] = useState(true);
- const [ codeImportedAsCode, setCodeImportedAsCode ] = useState(true);
- const [ spreadsheetImportedAsSpreadsheet, setSpreadsheetImportedAsSpreadsheet ] = useState(true);
- const [ replaceUnderscoresWithSpaces, setReplaceUnderscoresWithSpaces ] = useState(true);
- const [ shown, setShown ] = useState(false);
-
- useTriliumEvent("showImportDialog", ({ noteId }) => {
- setParentNoteId(noteId);
- tree.getNoteTitle(noteId).then(setNoteTitle);
- setShown(true);
- });
-
- return (
- <Modal
- className="import-dialog"
- size="lg"
- title={t("import.importIntoNote")}
- onSubmit={async () => {
- if (!files || !parentNoteId) {
- return;
- }
-
- const options: UploadFilesOptions = {
- safeImport: boolToString(safeImport),
- shrinkImages: boolToString(shrinkImages),
- textImportedAsText: boolToString(textImportedAsText),
- codeImportedAsCode: boolToString(codeImportedAsCode),
- spreadsheetImportedAsSpreadsheet: boolToString(spreadsheetImportedAsSpreadsheet),
- explodeArchives: boolToString(explodeArchives),
- replaceUnderscoresWithSpaces: boolToString(replaceUnderscoresWithSpaces)
- };
-
- setShown(false);
- await importService.uploadFiles("notes", parentNoteId, Array.from(files), options);
- }}
- onHidden={() => {
- setShown(false);
- setFiles(null);
- }}
- footer={<Button text={t("import.import")} kind="primary" disabled={!files} />}
- show={shown}
- >
- <FormGroup name="files" label={t("import.chooseImportFile")} description={
- <>
- {t("import.importDescription")} <strong>{ noteTitle }</strong>.<br />
- {t("import.importZipRecommendation")}
- </>
- }>
- <FormFileUpload multiple onChange={setFiles} />
- </FormGroup>
-
- <FormMultiGroup label={t("import.options")}>
- <FormCheckbox
- name="safe-import" hint={t("import.safeImportTooltip")} label={t("import.safeImport")}
- currentValue={safeImport} onChange={setSafeImport}
- />
- <FormCheckbox
- name="explode-archives" hint={t("import.explodeArchivesTooltip")} label={<RawHtml html={t("import.explodeArchives")} />}
- currentValue={explodeArchives} onChange={setExplodeArchives}
- />
- <FormCheckbox
- name="shrink-images" hint={t("import.shrinkImagesTooltip")} label={t("import.shrinkImages")}
- currentValue={compressImages && shrinkImages} onChange={setShrinkImages}
- disabled={!compressImages}
- />
- <FormCheckbox
- name="text-imported-as-text" label={t("import.textImportedAsText")}
- currentValue={textImportedAsText} onChange={setTextImportedAsText}
- />
- <FormCheckbox
- name="code-imported-as-code" label={<RawHtml html={t("import.codeImportedAsCode")} />}
- currentValue={codeImportedAsCode} onChange={setCodeImportedAsCode}
- />
- <FormCheckbox
- name="spreadsheet-imported-as-spreadsheet" label={t("import.spreadsheetImportedAsSpreadsheet")}
- currentValue={spreadsheetImportedAsSpreadsheet} onChange={setSpreadsheetImportedAsSpreadsheet}
- />
- <FormCheckbox
- name="replace-underscores-with-spaces" label={t("import.replaceUnderscoresWithSpaces")}
- currentValue={replaceUnderscoresWithSpaces} onChange={setReplaceUnderscoresWithSpaces}
- />
- </FormMultiGroup>
- </Modal>
- );
-}
-
-function boolToString(value: boolean) {
- return value ? "true" : "false";
-}
diff --git a/apps/client/src/widgets/dialogs/import_providers/anytype.tsx b/apps/client/src/widgets/dialogs/import/anytype.tsx
similarity index 100%
rename from apps/client/src/widgets/dialogs/import_providers/anytype.tsx
rename to apps/client/src/widgets/dialogs/import/anytype.tsx
diff --git a/apps/client/src/widgets/dialogs/import_providers/evernote.tsx b/apps/client/src/widgets/dialogs/import/evernote.tsx
similarity index 100%
rename from apps/client/src/widgets/dialogs/import_providers/evernote.tsx
rename to apps/client/src/widgets/dialogs/import/evernote.tsx
diff --git a/apps/client/src/widgets/dialogs/import/files.tsx b/apps/client/src/widgets/dialogs/import/files.tsx
new file mode 100644
index 0000000000..ca523369e2
--- /dev/null
+++ b/apps/client/src/widgets/dialogs/import/files.tsx
@@ -0,0 +1,123 @@
+import { useCallback, useEffect, useRef, useState } from "preact/hooks";
+
+import { t } from "../../../services/i18n.js";
+import importService, { type UploadFilesOptions } from "../../../services/import.js";
+import tree from "../../../services/tree.js";
+import Button from "../../react/Button.js";
+import FormCheckbox from "../../react/FormCheckbox.js";
+import FormFileUpload from "../../react/FormFileUpload.js";
+import FormGroup, { FormMultiGroup } from "../../react/FormGroup.js";
+import { useTriliumOptionBool } from "../../react/hooks.js";
+import RawHtml from "../../react/RawHtml.js";
+import type { ImportProvider, ImportProviderPanelProps } from "./types.js";
+
+function FilesPanel({ parentNoteId, closeDialog, setFooter }: ImportProviderPanelProps) {
+ const [compressImages] = useTriliumOptionBool("compressImages");
+ const [noteTitle, setNoteTitle] = useState<string>();
+ const [files, setFiles] = useState<FileList | null>(null);
+ const [safeImport, setSafeImport] = useState(true);
+ const [explodeArchives, setExplodeArchives] = useState(true);
+ const [shrinkImages, setShrinkImages] = useState(compressImages);
+ const [textImportedAsText, setTextImportedAsText] = useState(true);
+ const [codeImportedAsCode, setCodeImportedAsCode] = useState(true);
+ const [spreadsheetImportedAsSpreadsheet, setSpreadsheetImportedAsSpreadsheet] = useState(true);
+ const [replaceUnderscoresWithSpaces, setReplaceUnderscoresWithSpaces] = useState(true);
+
+ useEffect(() => {
+ void tree.getNoteTitle(parentNoteId).then(setNoteTitle);
+ }, [parentNoteId]);
+
+ const doImport = useCallback(async () => {
+ if (!files) {
+ return;
+ }
+
+ const options: UploadFilesOptions = {
+ safeImport: boolToString(safeImport),
+ shrinkImages: boolToString(shrinkImages),
+ textImportedAsText: boolToString(textImportedAsText),
+ codeImportedAsCode: boolToString(codeImportedAsCode),
+ spreadsheetImportedAsSpreadsheet: boolToString(spreadsheetImportedAsSpreadsheet),
+ explodeArchives: boolToString(explodeArchives),
+ replaceUnderscoresWithSpaces: boolToString(replaceUnderscoresWithSpaces)
+ };
+
+ // Close immediately and let the shared import toasts (registered in import.ts) report progress,
+ // completion and any error. Swallow the rejection so this void-ed call doesn't raise an unhandled
+ // rejection.
+ closeDialog();
+ await importService.uploadFiles("notes", parentNoteId, Array.from(files), options).catch(() => {});
+ }, [files, safeImport, shrinkImages, textImportedAsText, codeImportedAsCode, spreadsheetImportedAsSpreadsheet, explodeArchives, replaceUnderscoresWithSpaces, parentNoteId, closeDialog]);
+
+ // Keep the latest import handler in a ref so the footer effect depends only on whether files are
+ // selected, never on doImport's identity — otherwise re-pushing the footer on every option toggle
+ // would loop with the parent re-rendering us back (see the other panels for the same reasoning).
+ const doImportRef = useRef(doImport);
+ doImportRef.current = doImport;
+
+ useEffect(() => {
+ setFooter(
+ <Button text={t("import.import")} kind="primary" disabled={!files} onClick={() => void doImportRef.current()} />
+ );
+ }, [files, setFooter]);
+
+ return (
+ <div className="files-panel">
+ <FormGroup name="files" label={t("import.chooseImportFile")} description={
+ <>
+ {t("import.importDescription")} <strong>{noteTitle}</strong>.<br />
+ {t("import.importZipRecommendation")}
+ </>
+ }>
+ <FormFileUpload multiple onChange={setFiles} />
+ </FormGroup>
+
+ <FormMultiGroup label={t("import.options")}>
+ <FormCheckbox
+ name="safe-import" hint={t("import.safeImportTooltip")} label={t("import.safeImport")}
+ currentValue={safeImport} onChange={setSafeImport}
+ />
+ <FormCheckbox
+ name="explode-archives" hint={t("import.explodeArchivesTooltip")} label={<RawHtml html={t("import.explodeArchives")} />}
+ currentValue={explodeArchives} onChange={setExplodeArchives}
+ />
+ <FormCheckbox
+ name="shrink-images" hint={t("import.shrinkImagesTooltip")} label={t("import.shrinkImages")}
+ currentValue={compressImages && shrinkImages} onChange={setShrinkImages}
+ disabled={!compressImages}
+ />
+ <FormCheckbox
+ name="text-imported-as-text" label={t("import.textImportedAsText")}
+ currentValue={textImportedAsText} onChange={setTextImportedAsText}
+ />
+ <FormCheckbox
+ name="code-imported-as-code" label={<RawHtml html={t("import.codeImportedAsCode")} />}
+ currentValue={codeImportedAsCode} onChange={setCodeImportedAsCode}
+ />
+ <FormCheckbox
+ name="spreadsheet-imported-as-spreadsheet" label={t("import.spreadsheetImportedAsSpreadsheet")}
+ currentValue={spreadsheetImportedAsSpreadsheet} onChange={setSpreadsheetImportedAsSpreadsheet}
+ />
+ <FormCheckbox
+ name="replace-underscores-with-spaces" label={t("import.replaceUnderscoresWithSpaces")}
+ currentValue={replaceUnderscoresWithSpaces} onChange={setReplaceUnderscoresWithSpaces}
+ />
+ </FormMultiGroup>
+ </div>
+ );
+}
+
+function boolToString(value: boolean) {
+ return value ? "true" : "false";
+}
+
+const provider: ImportProvider = {
+ id: "files",
+ group: "local",
+ name: t("import.cardName"),
+ icon: "bx bx-import",
+ description: t("import.cardDescription"),
+ Panel: FilesPanel
+};
+
+export default provider;
diff --git a/apps/client/src/widgets/dialogs/import_providers/icons/anytype.svg b/apps/client/src/widgets/dialogs/import/icons/anytype.svg
similarity index 100%
rename from apps/client/src/widgets/dialogs/import_providers/icons/anytype.svg
rename to apps/client/src/widgets/dialogs/import/icons/anytype.svg
diff --git a/apps/client/src/widgets/dialogs/import_providers/icons/evernote.svg b/apps/client/src/widgets/dialogs/import/icons/evernote.svg
similarity index 100%
rename from apps/client/src/widgets/dialogs/import_providers/icons/evernote.svg
rename to apps/client/src/widgets/dialogs/import/icons/evernote.svg
diff --git a/apps/client/src/widgets/dialogs/import_providers/icons/keep.svg b/apps/client/src/widgets/dialogs/import/icons/keep.svg
similarity index 100%
rename from apps/client/src/widgets/dialogs/import_providers/icons/keep.svg
rename to apps/client/src/widgets/dialogs/import/icons/keep.svg
diff --git a/apps/client/src/widgets/dialogs/import_providers/icons/notion.svg b/apps/client/src/widgets/dialogs/import/icons/notion.svg
similarity index 100%
rename from apps/client/src/widgets/dialogs/import_providers/icons/notion.svg
rename to apps/client/src/widgets/dialogs/import/icons/notion.svg
diff --git a/apps/client/src/widgets/dialogs/import_providers/icons/onenote.svg b/apps/client/src/widgets/dialogs/import/icons/onenote.svg
similarity index 100%
rename from apps/client/src/widgets/dialogs/import_providers/icons/onenote.svg
rename to apps/client/src/widgets/dialogs/import/icons/onenote.svg
diff --git a/apps/client/src/widgets/dialogs/import_provider.css b/apps/client/src/widgets/dialogs/import/import_dialog.css
similarity index 84%
rename from apps/client/src/widgets/dialogs/import_provider.css
rename to apps/client/src/widgets/dialogs/import/import_dialog.css
index df07efda9e..d06e4aead1 100644
--- a/apps/client/src/widgets/dialogs/import_provider.css
+++ b/apps/client/src/widgets/dialogs/import/import_dialog.css
@@ -3,6 +3,16 @@
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 0.75em;
+ }
+
+ /* Local file import is grouped on its own, full-width, beneath the service grid. */
+ .import-provider-local {
+ display: flex;
+ flex-direction: column;
+ gap: 0.75em;
+ margin-top: 1em;
+ padding-top: 1em;
+ border-top: 1px solid var(--main-border-color);
margin-bottom: 1.5em;
}
@@ -38,6 +48,13 @@
mask: var(--provider-icon) center / contain no-repeat;
}
+ /* Boxicons-based card icon (used by providers that supply `icon` instead of `iconUrl`). */
+ .import-provider-card-bxicon {
+ flex-shrink: 0;
+ font-size: 1.5em;
+ line-height: 1;
+ }
+
.import-provider-card-text {
display: flex;
flex-direction: column;
diff --git a/apps/client/src/widgets/dialogs/import/import_dialog.tsx b/apps/client/src/widgets/dialogs/import/import_dialog.tsx
new file mode 100644
index 0000000000..6d51e8141a
--- /dev/null
+++ b/apps/client/src/widgets/dialogs/import/import_dialog.tsx
@@ -0,0 +1,89 @@
+import "./import_dialog.css";
+
+import type { ComponentChildren } from "preact";
+import { useCallback, useState } from "preact/hooks";
+
+import { t } from "../../../services/i18n.js";
+import { useTriliumEvent } from "../../react/hooks.js";
+import Modal from "../../react/Modal.js";
+import { importProviders } from "./index.js";
+import type { ImportProvider } from "./types.js";
+
+/**
+ * Unified import dialog. The top shows a picker of registered {@link importProviders} as selectable
+ * cards: external services in a grid, with local file import grouped full-width beneath them and
+ * selected by default. The chosen provider's panel renders below, driving its own flow (file
+ * selection, auth, progress). Add new sources by registering them in `index.ts`.
+ */
+export default function ImportDialog() {
+ const [parentNoteId, setParentNoteId] = useState<string>();
+ const [providerId, setProviderId] = useState<string>();
+ const [footer, setFooter] = useState<ComponentChildren>(null);
+ const [shown, setShown] = useState(false);
+
+ useTriliumEvent("showImportDialog", ({ noteId }) => {
+ setParentNoteId(noteId);
+ setProviderId(defaultProviderId);
+ setFooter(null);
+ setShown(true);
+ });
+
+ const provider = importProviders.find((p) => p.id === providerId);
+
+ // Stable so the chosen provider's panel can safely memoize on it (an inline arrow would change every
+ // render, defeating the panel's useCallback/useEffect dependencies).
+ const closeDialog = useCallback(() => setShown(false), []);
+
+ return (
+ <Modal
+ className="import-provider-dialog"
+ size="lg"
+ scrollable
+ title={t("import.importIntoNote")}
+ footer={footer}
+ footerAlignment="between"
+ onHidden={() => setShown(false)}
+ show={shown}
+ >
+ <div className="import-provider-picker">
+ {serviceProviders.map((p) => (
+ <ImportProviderCard key={p.id} provider={p} selected={p.id === providerId} onSelect={() => setProviderId(p.id)} />
+ ))}
+ </div>
+
+ {localProviders.length > 0 && (
+ <div className="import-provider-local">
+ {localProviders.map((p) => (
+ <ImportProviderCard key={p.id} provider={p} selected={p.id === providerId} onSelect={() => setProviderId(p.id)} />
+ ))}
+ </div>
+ )}
+
+ <div className="import-provider-panel">
+ {provider && parentNoteId
+ ? <provider.Panel key={provider.id} parentNoteId={parentNoteId} closeDialog={closeDialog} setFooter={setFooter} />
+ : <p className="import-provider-hint">{t("import_provider.choose_provider")}</p>}
+ </div>
+ </Modal>
+ );
+}
+
+// Services fill the card grid; local file import is grouped full-width beneath them and is the default
+// selection (the dialog's primary path). Computed once — the registry is static.
+const serviceProviders = importProviders.filter((p) => p.group !== "local");
+const localProviders = importProviders.filter((p) => p.group === "local");
+const defaultProviderId = (localProviders[0] ?? importProviders[0])?.id;
+
+function ImportProviderCard({ provider, selected, onSelect }: { provider: ImportProvider; selected: boolean; onSelect: () => void }) {
+ return (
+ <button type="button" className={`import-provider-card ${selected ? "selected" : ""}`} onClick={onSelect}>
+ {provider.iconUrl
+ ? <span className="import-provider-card-icon" style={{ "--provider-icon": `url("${provider.iconUrl}")` }} />
+ : <span className={`import-provider-card-bxicon ${provider.icon ?? ""}`} />}
+ <span className="import-provider-card-text">
+ <span className="import-provider-card-name">{provider.name}</span>
+ <span className="import-provider-card-description">{provider.description}</span>
+ </span>
+ </button>
+ );
+}
diff --git a/apps/client/src/widgets/dialogs/import_providers/index.ts b/apps/client/src/widgets/dialogs/import/index.ts
similarity index 54%
rename from apps/client/src/widgets/dialogs/import_providers/index.ts
rename to apps/client/src/widgets/dialogs/import/index.ts
index 6ee50af95f..8e1bff3c9d 100644
--- a/apps/client/src/widgets/dialogs/import_providers/index.ts
+++ b/apps/client/src/widgets/dialogs/import/index.ts
@@ -1,14 +1,16 @@
import anytypeProvider from "./anytype.js";
import evernoteProvider from "./evernote.js";
+import filesProvider from "./files.js";
import keepProvider from "./keep.js";
import notionProvider from "./notion.js";
import oneNoteProvider from "./onenote.js";
import type { ImportProvider } from "./types.js";
/**
- * Registry of available import providers. Append new providers here; the generic import dialog
- * renders the picker and each provider's panel automatically.
+ * Registry of available import providers. Append new providers here; the import dialog renders the
+ * picker (services in a grid, local file import grouped full-width beneath) and each provider's panel
+ * automatically.
*/
-export const importProviders: ImportProvider[] = [oneNoteProvider, notionProvider, keepProvider, evernoteProvider, anytypeProvider];
+export const importProviders: ImportProvider[] = [filesProvider, oneNoteProvider, notionProvider, keepProvider, evernoteProvider, anytypeProvider];
export type { ImportProvider, ImportProviderPanelProps } from "./types.js";
diff --git a/apps/client/src/widgets/dialogs/import_providers/keep.tsx b/apps/client/src/widgets/dialogs/import/keep.tsx
similarity index 100%
rename from apps/client/src/widgets/dialogs/import_providers/keep.tsx
rename to apps/client/src/widgets/dialogs/import/keep.tsx
diff --git a/apps/client/src/widgets/dialogs/import_providers/notion.tsx b/apps/client/src/widgets/dialogs/import/notion.tsx
similarity index 100%
rename from apps/client/src/widgets/dialogs/import_providers/notion.tsx
rename to apps/client/src/widgets/dialogs/import/notion.tsx
diff --git a/apps/client/src/widgets/dialogs/import_providers/onenote.tsx b/apps/client/src/widgets/dialogs/import/onenote.tsx
similarity index 100%
rename from apps/client/src/widgets/dialogs/import_providers/onenote.tsx
rename to apps/client/src/widgets/dialogs/import/onenote.tsx
diff --git a/apps/client/src/widgets/dialogs/import_providers/types.ts b/apps/client/src/widgets/dialogs/import/types.ts
similarity index 72%
rename from apps/client/src/widgets/dialogs/import_providers/types.ts
rename to apps/client/src/widgets/dialogs/import/types.ts
index 5565d14763..b7782f7afd 100644
--- a/apps/client/src/widgets/dialogs/import_providers/types.ts
+++ b/apps/client/src/widgets/dialogs/import/types.ts
@@ -18,10 +18,14 @@ export interface ImportProvider {
id: string;
/** Human-readable name shown in the provider picker. */
name: string;
- /** URL of the provider's logo (an imported SVG, e.g. `import iconUrl from "./icons/notion.svg?url"`). Rendered monochrome via a CSS mask so it adapts to the theme. */
- iconUrl: string;
+ /** URL of the provider's logo (an imported SVG, e.g. `import iconUrl from "./icons/notion.svg?url"`). Rendered monochrome via a CSS mask so it adapts to the theme. Provide either this or {@link icon}. */
+ iconUrl?: string;
+ /** Boxicons class (e.g. `"bx bx-import"`) shown in place of {@link iconUrl}. Provide either this or `iconUrl`. */
+ icon?: string;
/** One-line description shown under the name. */
description: string;
+ /** Visual grouping in the picker: `"service"` (the default) appears in the card grid; `"local"` (file upload) is shown full-width, grouped beneath the services and selected by default. */
+ group?: "service" | "local";
/** The component rendered once this provider is chosen; it drives its own multi-step flow. */
Panel: ComponentType<ImportProviderPanelProps>;
}
diff --git a/apps/client/src/widgets/dialogs/import_provider.tsx b/apps/client/src/widgets/dialogs/import_provider.tsx
deleted file mode 100644
index bea96102a9..0000000000
--- a/apps/client/src/widgets/dialogs/import_provider.tsx
+++ /dev/null
@@ -1,71 +0,0 @@
-import "./import_provider.css";
-
-import type { ComponentChildren } from "preact";
-import { useCallback, useState } from "preact/hooks";
-
-import { t } from "../../services/i18n.js";
-import { useTriliumEvent } from "../react/hooks.js";
-import Modal from "../react/Modal.js";
-import { importProviders } from "./import_providers/index.js";
-
-/**
- * Generic "import from a service" dialog. It is provider-agnostic: the top of the dialog shows a picker
- * of registered {@link importProviders} as selectable cards, and the chosen provider's panel renders
- * directly below it, driving its own flow (auth, selection, progress). Add new sources by registering
- * them in `import_providers`.
- */
-export default function ImportProviderDialog() {
- const [parentNoteId, setParentNoteId] = useState<string>();
- const [providerId, setProviderId] = useState<string>();
- const [footer, setFooter] = useState<ComponentChildren>(null);
- const [shown, setShown] = useState(false);
-
- useTriliumEvent("showImportProviderDialog", ({ noteId }) => {
- setParentNoteId(noteId);
- setProviderId(undefined);
- setFooter(null);
- setShown(true);
- });
-
- const provider = importProviders.find((p) => p.id === providerId);
-
- // Stable so the chosen provider's panel can safely memoize on it (an inline arrow would change every
- // render, defeating the panel's useCallback/useEffect dependencies).
- const closeDialog = useCallback(() => setShown(false), []);
-
- return (
- <Modal
- className="import-provider-dialog"
- size="lg"
- scrollable
- title={t("import_provider.title")}
- footer={footer}
- footerAlignment="between"
- onHidden={() => setShown(false)}
- show={shown}
- >
- <div className="import-provider-picker">
- {importProviders.map((p) => (
- <button
- type="button"
- className={`import-provider-card ${p.id === providerId ? "selected" : ""}`}
- key={p.id}
- onClick={() => setProviderId(p.id)}
- >
- <span className="import-provider-card-icon" style={{ "--provider-icon": `url("${p.iconUrl}")` }} />
- <span className="import-provider-card-text">
- <span className="import-provider-card-name">{p.name}</span>
- <span className="import-provider-card-description">{p.description}</span>
- </span>
- </button>
- ))}
- </div>
-
- <div className="import-provider-panel">
- {provider && parentNoteId
- ? <provider.Panel key={provider.id} parentNoteId={parentNoteId} closeDialog={closeDialog} setFooter={setFooter} />
- : <p className="import-provider-hint">{t("import_provider.choose_provider")}</p>}
- </div>
- </Modal>
- );
-}
diff --git a/apps/client/src/widgets/ribbon/NoteActions.tsx b/apps/client/src/widgets/ribbon/NoteActions.tsx
index d48511257f..bd0f30147a 100644
--- a/apps/client/src/widgets/ribbon/NoteActions.tsx
+++ b/apps/client/src/widgets/ribbon/NoteActions.tsx
@@ -148,9 +148,6 @@ export function NoteContextMenu({ note, noteContext, itemsAtStart, itemsNearNote
<CommandItem icon="bx bx-import" text={t("note_actions.import_files")}
disabled={isInOptionsOrHelp || note.type === "search"}
command={() => parentComponent?.triggerCommand("showImportDialog", { noteId: note.noteId })} />
- <CommandItem icon="bx bx-cloud-download" text={t("note_actions.import_from_service")}
- disabled={isInOptionsOrHelp || note.type === "search"}
- command={() => parentComponent?.triggerCommand("showImportProviderDialog", { noteId: note.noteId })} />
<CommandItem icon="bx bx-export" text={t("note_actions.export_note")}
disabled={isInOptionsOrHelp || note.noteId === "_backendLog"}
command={() => noteContext?.notePath && parentComponent?.triggerCommand("showExportDialog", {