mirror of
https://github.com/hangeol-chang/obsidian-csv-allinone.git
synced 2026-07-22 05:37:25 +00:00
[FEAT] csv explorer delete 버튼 추가
This commit is contained in:
parent
ecf5a24247
commit
8ced697567
3 changed files with 29 additions and 3 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { App, Modal, TFile } from 'obsidian';
|
||||
import './styles/CSVExplorer.css';
|
||||
|
||||
/*
|
||||
obsidian 탐색기에서 CSV 파일이 표시가 안되기 때문에,\
|
||||
|
|
@ -40,7 +41,26 @@ export default class CSVExplorerModal extends Modal {
|
|||
Object.keys(this.CSVStructure).forEach((folder) => {
|
||||
contentEl.createEl("h3", { text: folder });
|
||||
this.CSVStructure[folder].forEach((file) => {
|
||||
contentEl.createEl("p", { text: file });
|
||||
const fileRow = contentEl.createEl("div", { cls: "file-row"});
|
||||
|
||||
// file name
|
||||
fileRow.createEl("p", { text: file });
|
||||
|
||||
// file delete button
|
||||
const bt = fileRow.createEl("button", { text: "Delete" });
|
||||
bt.addEventListener("click", async () => {
|
||||
const fileToDelete = this.CSVStructure[folder].find(f => f === file);
|
||||
if (fileToDelete) {
|
||||
const filePath = `${folder}/${fileToDelete}`;
|
||||
const fileObj = this.app.vault.getAbstractFileByPath(filePath);
|
||||
if (fileObj && fileObj instanceof TFile) {
|
||||
await this.app.vault.delete(fileObj);
|
||||
// Update the structure after deletion
|
||||
this.CSVStructure[folder] = this.CSVStructure[folder].filter(f => f !== fileToDelete);
|
||||
this.onOpen(); // Refresh the modal content
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,8 +59,6 @@ export const readCSVs_ = async (app: App, filePath: string, filter: string): Pro
|
|||
// filter의 정규식에 맞는 파일들을 읽어와서 return;
|
||||
const vault = app.vault;
|
||||
const files = vault.getFiles();
|
||||
console.log(`readCSVs_ : ${filePath}, filter: ${filter}`);
|
||||
console.log(files);
|
||||
const csvFiles: { key: string; value: CSVTable }[] = [];
|
||||
|
||||
for(const file of files) {
|
||||
|
|
|
|||
8
src/styles/CSVExplorer.css
Normal file
8
src/styles/CSVExplorer.css
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
.file-row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 2px;
|
||||
justify-content: space-between;
|
||||
margin-left: 10px;
|
||||
}
|
||||
Loading…
Reference in a new issue