mirror of
https://github.com/ethanolivertroy/obsidian-markitdown.git
synced 2026-07-22 05:41:54 +00:00
Remove preview modal — conversions save directly (ENG-643 reverted)
This commit is contained in:
parent
fb07e1c98b
commit
48cf0c1147
2 changed files with 10 additions and 55 deletions
20
main.ts
20
main.ts
|
|
@ -29,7 +29,6 @@ import { FolderConvertModal } from './src/modals/FolderConvertModal';
|
|||
import { UrlConvertModal } from './src/modals/UrlConvertModal';
|
||||
import { HistoryModal } from './src/modals/HistoryModal';
|
||||
import { SetupModal } from './src/modals/SetupModal';
|
||||
import { PreviewModal } from './src/modals/PreviewModal';
|
||||
|
||||
export default class MarkitdownPlugin extends Plugin {
|
||||
settings: MarkitdownSettings = DEFAULT_SETTINGS;
|
||||
|
|
@ -274,30 +273,11 @@ export default class MarkitdownPlugin extends Plugin {
|
|||
await this.saveSettings();
|
||||
|
||||
if (result.success) {
|
||||
let content: string;
|
||||
try {
|
||||
content = await fs.promises.readFile(outputPath, 'utf-8');
|
||||
} catch {
|
||||
new Notice('Conversion succeeded but could not read output file');
|
||||
return;
|
||||
}
|
||||
|
||||
new PreviewModal(this.app, {
|
||||
content,
|
||||
outputPath,
|
||||
processingTime: result.processingTime ?? 0,
|
||||
onSave: async () => {
|
||||
const msg = result.imagesExtracted
|
||||
? `Converted successfully (${result.imagesExtracted} images extracted)`
|
||||
: 'Converted successfully';
|
||||
new Notice(msg);
|
||||
await this.openConvertedFile(outputPath, vaultPath);
|
||||
},
|
||||
onCancel: async () => {
|
||||
await fs.promises.unlink(outputPath).catch(() => {});
|
||||
new Notice('Conversion discarded');
|
||||
},
|
||||
}).open();
|
||||
} else {
|
||||
new Notice(`Conversion failed: ${result.error}`);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import * as fs from 'fs';
|
|||
import type MarkitdownPlugin from '../../main';
|
||||
import { FILE_INPUT_ACCEPT } from '../utils/fileTypes';
|
||||
import { getVaultBasePath, resolveOutputFolder, resolveFilenameTemplate, toVaultRelative } from '../utils/paths';
|
||||
import { PreviewModal } from './PreviewModal';
|
||||
|
||||
export class FileConvertModal extends Modal {
|
||||
private plugin: MarkitdownPlugin;
|
||||
|
|
@ -68,36 +67,12 @@ export class FileConvertModal extends Modal {
|
|||
const result = await this.plugin.convertExternalFile(tempFilePath, outputPath);
|
||||
|
||||
if (result.success) {
|
||||
// Read the converted output for preview
|
||||
let content: string;
|
||||
try {
|
||||
content = await fs.promises.readFile(outputPath, 'utf-8');
|
||||
} catch {
|
||||
new Notice('Conversion succeeded but could not read output file');
|
||||
convertButton.disabled = false;
|
||||
convertButton.setText('Convert');
|
||||
return;
|
||||
}
|
||||
|
||||
this.close();
|
||||
|
||||
new PreviewModal(this.app, {
|
||||
content,
|
||||
outputPath,
|
||||
processingTime: result.processingTime ?? 0,
|
||||
onSave: async () => {
|
||||
const msg = result.imagesExtracted
|
||||
? `Converted successfully (${result.imagesExtracted} images extracted)`
|
||||
: 'Converted successfully';
|
||||
new Notice(msg);
|
||||
await this.plugin.openConvertedFile(outputPath, vaultPath);
|
||||
},
|
||||
onCancel: async () => {
|
||||
// Discard the converted output file
|
||||
await fs.promises.unlink(outputPath).catch(() => {});
|
||||
new Notice('Conversion discarded');
|
||||
},
|
||||
}).open();
|
||||
this.close();
|
||||
} else {
|
||||
new Notice(`Conversion failed: ${result.error}`);
|
||||
convertButton.disabled = false;
|
||||
|
|
|
|||
Loading…
Reference in a new issue