mirror of
https://github.com/hangeol-chang/obsidian-csv-allinone.git
synced 2026-07-22 05:37:25 +00:00
[FIX] capitalize 'csv' change
This commit is contained in:
parent
70716a8a6f
commit
fb9de26a36
10 changed files with 96 additions and 96 deletions
22
README.md
22
README.md
|
|
@ -16,25 +16,25 @@
|
|||
|
||||
- Ctrl + P -> search for 'Create CSV Table'
|
||||
Enter the required data and click Submit as shown below:
|
||||

|
||||

|
||||
|
||||
#### Search CSV Files
|
||||
- UI modifications are planned
|
||||
- Ctrl + P -> search for 'Open CSV Explorer'
|
||||
- You can move or delete CSV files.
|
||||
|
||||

|
||||

|
||||
|
||||
### With DataviewJS
|
||||
|
||||
#### - View as table
|
||||
- Source Code
|
||||
```javascript
|
||||
const csvPlugin = app.plugins.plugins['csv-allinone'];
|
||||
const CSVPlugin = app.plugins.plugins['CSV-allinone'];
|
||||
|
||||
const fileName = "HouseKeeping/t/2025-01.csv";
|
||||
|
||||
csvPlugin.readCSV(app, fileName).then(res => {
|
||||
CSVPlugin.readCSV(app, fileName).then(res => {
|
||||
let headers = []
|
||||
let defaultValues = {}
|
||||
for(const [key, value] of Object.entries(res.headers)) {
|
||||
|
|
@ -52,7 +52,7 @@ csvPlugin.readCSV(app, fileName).then(res => {
|
|||
})
|
||||
```
|
||||
- Result
|
||||

|
||||

|
||||
|
||||
|
||||
#### - Add new data (row)
|
||||
|
|
@ -64,15 +64,15 @@ csvPlugin.readCSV(app, fileName).then(res => {
|
|||
|
||||
- Source Code
|
||||
```javascript
|
||||
const csvPlugin = app.plugins.plugins['csv-allinone'];
|
||||
const CSVPlugin = app.plugins.plugins['CSV-allinone'];
|
||||
const { createButton } = app.plugins.plugins["buttons"];
|
||||
|
||||
const fileName = "HouseKeeping/t/2025-01.csv";
|
||||
const openCsvAppendModal = async(app, headers, f, defaults) => {
|
||||
csvPlugin.openCsvInputModal(app, headers, f, defaults)
|
||||
const openCSVAppendModal = async(app, headers, f, defaults) => {
|
||||
CSVPlugin.openCSVInputModal(app, headers, f, defaults)
|
||||
}
|
||||
|
||||
csvPlugin.readCSV(app, fileName).then(res => {
|
||||
CSVPlugin.readCSV(app, fileName).then(res => {
|
||||
let headers = []
|
||||
let defaultValues = {}
|
||||
for(const [key, value] of Object.entries(res.headers)) {
|
||||
|
|
@ -97,11 +97,11 @@ csvPlugin.readCSV(app, fileName).then(res => {
|
|||
createButton({
|
||||
app, el: this.container,
|
||||
args: {
|
||||
name: "open csv input modal",
|
||||
name: "open CSV input modal",
|
||||
class: ""
|
||||
},
|
||||
clickOverride: {
|
||||
click: openCsvAppendModal,
|
||||
click: openCSVAppendModal,
|
||||
params: [app, res.headers, fileName, defaultValues]
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ SOURCE_FILES = {
|
|||
}
|
||||
|
||||
OBSIDIAN_DIR = os.path.abspath('../obsidian/.obsidian')
|
||||
TARGET_DIR = os.path.join(OBSIDIAN_DIR, 'plugins', 'csv-allinone')
|
||||
TARGET_DIR = os.path.join(OBSIDIAN_DIR, 'plugins', 'CSV-allinone')
|
||||
|
||||
def copy_files():
|
||||
# Obsidian 폴더 확인
|
||||
|
|
@ -17,7 +17,7 @@ def copy_files():
|
|||
print(f"Error: Obsidian directory not found at {OBSIDIAN_DIR}")
|
||||
return
|
||||
|
||||
# csv-allinone 폴더가 없으면 생성
|
||||
# CSV-allinone 폴더가 없으면 생성
|
||||
if not os.path.exists(TARGET_DIR):
|
||||
print(f"Creating target directory: {TARGET_DIR}")
|
||||
os.makedirs(TARGET_DIR, exist_ok=True)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# Obsidian CSV All-in-One
|
||||
> .csv 파일을 생성하고, 내부의 데이터를 수정하고 저장하는 등 csv 관련된 작업을 처리하기 위한 플러그인입니다.
|
||||
> .csv 파일을 생성하고, 내부의 데이터를 수정하고 저장하는 등 CSV 관련된 작업을 처리하기 위한 플러그인입니다.
|
||||
----
|
||||
## Other Language Docs
|
||||
-[english](../README.md)
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
## Brief Notice & Description
|
||||
> 이 플러그인은 dataviewjs를 사용하는 것을 전제로 만들어졌습니다.
|
||||
> csv 파일을 만들고 데이터를 추가하는것을 주 목적으로 제작되었습니다.
|
||||
> CSV 파일을 만들고 데이터를 추가하는것을 주 목적으로 제작되었습니다.
|
||||
|
||||
----
|
||||
## Examples
|
||||
|
|
@ -16,25 +16,25 @@
|
|||
|
||||
- Ctrl + P -> 'Create CSV Table' 검색
|
||||
아래처럼 필요한 데이터를 입력 후 Submit
|
||||

|
||||

|
||||
|
||||
#### Search CSV Files
|
||||
- UI 수정 예정
|
||||
- Ctrl + P -> 'Open CSV Explorer' 검색
|
||||
- csv 파일의 위치 이동, 삭제가 가능.
|
||||
- CSV 파일의 위치 이동, 삭제가 가능.
|
||||
|
||||

|
||||

|
||||
|
||||
### with dataviewjs
|
||||
|
||||
#### - view as table
|
||||
- 소스코드
|
||||
```javascript
|
||||
const csvPlugin = app.plugins.plugins['csv-allinone'];
|
||||
const CSVPlugin = app.plugins.plugins['CSV-allinone'];
|
||||
|
||||
const fileName = "HouseKeeping/t/2025-01.csv";
|
||||
|
||||
csvPlugin.readCSV(app, fileName).then(res => {
|
||||
CSVPlugin.readCSV(app, fileName).then(res => {
|
||||
let headers = []
|
||||
let defaultValues = {}
|
||||
for(const [key, value] of Object.entries(res.headers)) {
|
||||
|
|
@ -52,27 +52,27 @@ csvPlugin.readCSV(app, fileName).then(res => {
|
|||
})
|
||||
```
|
||||
- 결과물
|
||||

|
||||

|
||||
|
||||
|
||||
#### - add new data (row)
|
||||
> buttons 플러그인을 사용합니다.
|
||||
- 기능 설명
|
||||
- 특정 csv 파일에 row를 추가합니다.
|
||||
- 특정 CSV 파일에 row를 추가합니다.
|
||||
- 이미 읽힌 상태의 데이터를 가공하지 않습니다. 실시간 업데이트가 필요하다면, 별도로 파일 업데이트를 await하여 다시 파일을 읽어야합니다.
|
||||
- defaultValue를 입력할 수 있습니다.
|
||||
|
||||
- 소스코드
|
||||
```javascript
|
||||
const csvPlugin = app.plugins.plugins['csv-allinone'];
|
||||
const CSVPlugin = app.plugins.plugins['CSV-allinone'];
|
||||
const { createButton } = app.plugins.plugins["buttons"];
|
||||
|
||||
const fileName = "HouseKeeping/t/2025-01.csv";
|
||||
const openCsvAppendModal = async(app, headers, f, defaults) => {
|
||||
csvPlugin.openCsvInputModal(app, headers, f, defaults)
|
||||
const openCSVAppendModal = async(app, headers, f, defaults) => {
|
||||
CSVPlugin.openCSVInputModal(app, headers, f, defaults)
|
||||
}
|
||||
|
||||
csvPlugin.readCSV(app, fileName).then(res => {
|
||||
CSVPlugin.readCSV(app, fileName).then(res => {
|
||||
let headers = []
|
||||
let defaultValues = {}
|
||||
for(const [key, value] of Object.entries(res.headers)) {
|
||||
|
|
@ -97,11 +97,11 @@ csvPlugin.readCSV(app, fileName).then(res => {
|
|||
createButton({
|
||||
app, el: this.container,
|
||||
args: {
|
||||
name: "open csv input modal",
|
||||
name: "open CSV input modal",
|
||||
class: ""
|
||||
},
|
||||
clickOverride: {
|
||||
click: openCsvAppendModal,
|
||||
click: openCSVAppendModal,
|
||||
params: [app, res.headers, fileName, defaultValues]
|
||||
}
|
||||
})
|
||||
|
|
@ -132,7 +132,7 @@ csvPlugin.readCSV(app, fileName).then(res => {
|
|||
- saveCSV
|
||||
- parameters (app: App, fileName, string, table: SCVTable)
|
||||
- return void
|
||||
> csvtable 정보를 받아서 저장합니다.
|
||||
> CSVtable 정보를 받아서 저장합니다.
|
||||
|
||||
### CSVTable (class)
|
||||
-- class에서 할 수 있는 함수들 작성해둘 것.
|
||||
|
|
@ -145,10 +145,10 @@ csvPlugin.readCSV(app, fileName).then(res => {
|
|||
|
||||
|
||||
## How it work
|
||||
이 플러그인을 이용하여 csv 파일을 생성하면, .csv, .csv.meta의 두 파일을 생성하게 됩니다.
|
||||
원래 존재하던 csv파일을 불러오는 경우에는 임의로 .csv.meta 파일을 생성합니다.
|
||||
이 플러그인을 이용하여 CSV 파일을 생성하면, .csv, .csv.meta의 두 파일을 생성하게 됩니다.
|
||||
원래 존재하던 CSV파일을 불러오는 경우에는 임의로 .csv.meta 파일을 생성합니다.
|
||||
|
||||
csv에는 기본적인 테이블 정보들이, meta 파일에는 csv의 각 column 속성에 대한 정보가 담깁니다.
|
||||
CSV에는 기본적인 테이블 정보들이, meta 파일에는 CSV의 각 column 속성에 대한 정보가 담깁니다.
|
||||
현재(v0.1.0)는 .meta파일에 각 column의 type여부만 저장하지만, 후에는 data/select값 등이 추가되거나, 유효치 지정 등이 들어갈 예정입니다.
|
||||
|
||||
## Contributing
|
||||
|
|
|
|||
52
main.ts
52
main.ts
|
|
@ -2,23 +2,23 @@ import {
|
|||
App, Plugin, PluginSettingTab, Setting,
|
||||
} from 'obsidian';
|
||||
|
||||
import { createCsvInputModal_, createCsvTableView_ } from './src/csvPlugin';
|
||||
import { readCSV_, saveCSV_} from 'src/csvFilemanager';
|
||||
import { createCSVInputModal_, createCSVTableView_ } from './src/CSVPlugin';
|
||||
import { readCSV_, saveCSV_} from 'src/CSVFilemanager';
|
||||
import { CSVTable, Header } from './src/types'
|
||||
import CsvExplorerModal, { getCsvFileStructure } from 'src/csvExplorer';
|
||||
import CsvCreateModal, { createCsvFile_ } from 'src/csvCreator';
|
||||
import CSVExplorerModal, { getCSVFileStructure } from 'src/CSVExplorer';
|
||||
import CSVCreateModal, { createCSVFile_ } from 'src/CSVCreator';
|
||||
|
||||
interface CsvPluginSettings {
|
||||
interface CSVPluginSettings {
|
||||
mySetting: string;
|
||||
}
|
||||
const DEFAULT_SETTINGS: CsvPluginSettings = {
|
||||
const DEFAULT_SETTINGS: CSVPluginSettings = {
|
||||
mySetting: 'default'
|
||||
}
|
||||
|
||||
export default class CsvPlugin extends Plugin {
|
||||
settings: CsvPluginSettings;
|
||||
export default class CSVPlugin extends Plugin {
|
||||
settings: CSVPluginSettings;
|
||||
|
||||
// CsvPlugin.function() 형태로 호출될 함수들.
|
||||
// CSVPlugin.function() 형태로 호출될 함수들.
|
||||
//// filemanager.ts
|
||||
readCSV = async (app: App, fileName: string): Promise<CSVTable | null> => {
|
||||
return readCSV_(app, fileName);
|
||||
|
|
@ -27,40 +27,40 @@ export default class CsvPlugin extends Plugin {
|
|||
return saveCSV_(app, fileName, table);
|
||||
}
|
||||
|
||||
//// csvdisplay.ts
|
||||
openCsvInputModal = async (app: App, headers: Header, fileName: string, defaultValues: {[key: string] : string} = {} ) => {
|
||||
createCsvInputModal_(app, headers, fileName, defaultValues);
|
||||
//// CSVdisplay.ts
|
||||
openCSVInputModal = async (app: App, headers: Header, fileName: string, defaultValues: {[key: string] : string} = {} ) => {
|
||||
createCSVInputModal_(app, headers, fileName, defaultValues);
|
||||
}
|
||||
createCsvTableView = (csvTable: CSVTable): HTMLElement => {
|
||||
return createCsvTableView_(csvTable);
|
||||
createCSVTableView = (CSVTable: CSVTable): HTMLElement => {
|
||||
return createCSVTableView_(CSVTable);
|
||||
}
|
||||
createCsvFile = (filename: string, columnData: Header) => {
|
||||
createCsvFile_(this.app, filename, columnData);
|
||||
createCSVFile = (filename: string, columnData: Header) => {
|
||||
createCSVFile_(this.app, filename, columnData);
|
||||
}
|
||||
|
||||
async onload() {
|
||||
await this.loadSettings();
|
||||
// window에서 독립적으로 실행할 함수들.
|
||||
(window as any).CSVTable = CSVTable;
|
||||
(window as any).csvTable = CSVTable;
|
||||
|
||||
// This adds a settings tab so the user can configure various aspects of the plugin
|
||||
this.addSettingTab(new CsvSettingTab(this.app, this));
|
||||
this.addSettingTab(new CSVSettingTab(this.app, this));
|
||||
|
||||
// commands
|
||||
this.addCommand({
|
||||
id: "create-csv-table",
|
||||
id: "create-CSV-table",
|
||||
name: "Create CSV Table",
|
||||
callback: () => {
|
||||
new CsvCreateModal(this.app).open();
|
||||
new CSVCreateModal(this.app).open();
|
||||
},
|
||||
});
|
||||
|
||||
this.addCommand({
|
||||
id: "open-csv-explorer",
|
||||
id: "open-CSV-explorer",
|
||||
name: "Open CSV Explorer",
|
||||
callback: async () => {
|
||||
const csvStructure = await getCsvFileStructure(this.app);
|
||||
new CsvExplorerModal(this.app, csvStructure).open();
|
||||
const CSVStructure = await getCSVFileStructure(this.app);
|
||||
new CSVExplorerModal(this.app, CSVStructure).open();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -74,10 +74,10 @@ export default class CsvPlugin extends Plugin {
|
|||
}
|
||||
}
|
||||
|
||||
class CsvSettingTab extends PluginSettingTab {
|
||||
plugin: CsvPlugin;
|
||||
class CSVSettingTab extends PluginSettingTab {
|
||||
plugin: CSVPlugin;
|
||||
|
||||
constructor(app: App, plugin: CsvPlugin) {
|
||||
constructor(app: App, plugin: CSVPlugin) {
|
||||
super(app, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
"name": "CSV All-in-One",
|
||||
"version": "0.1.1",
|
||||
"minAppVersion": "1.7.7",
|
||||
"description": "all about csv.",
|
||||
"description": "all about CSV.",
|
||||
"author": "hihangeol",
|
||||
"authorUrl": "https://github.com/Hangeol-Chang",
|
||||
"fundingUrl": "https://buymeacoffee.com/hihangeol",
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
import { App, Modal, Notice, Plugin } from 'obsidian';
|
||||
import './styles/csvCreator.css';
|
||||
import './styles/CSVCreator.css';
|
||||
import { CSVCellType, CSVCellTypeString, Header } from './types';
|
||||
|
||||
// dataviewjs 등으로 자동적으로 파일을 생성하게 할 때 사용할 수 있는 api
|
||||
export const createCsvFile_ = (app: App, filename: string, columnData: Header) : boolean => {
|
||||
export const createCSVFile_ = (app: App, filename: string, columnData: Header) : boolean => {
|
||||
// 수정해야함.
|
||||
// .csv 내용 생성 (헤더만 추가)
|
||||
let csvContent = '';
|
||||
let CSVContent = '';
|
||||
for(const key of Object.keys(columnData)) {
|
||||
csvContent += key + ',';
|
||||
CSVContent += key + ',';
|
||||
}
|
||||
csvContent = csvContent.slice(0, -1) + '\n';
|
||||
CSVContent = CSVContent.slice(0, -1) + '\n';
|
||||
|
||||
// .csv.meta 내용 생성
|
||||
const metaContent = JSON.stringify(columnData, null, 2);
|
||||
|
|
@ -19,7 +19,7 @@ export const createCsvFile_ = (app: App, filename: string, columnData: Header) :
|
|||
const vault = app.vault;
|
||||
|
||||
// .csv 파일 저장
|
||||
vault.adapter.write(`${filename}.csv`, csvContent).then(() => {
|
||||
vault.adapter.write(`${filename}.csv`, CSVContent).then(() => {
|
||||
new Notice(`${filename}.csv file has been created.`);
|
||||
}).catch((err) => {
|
||||
new Notice(`Error occurred while creating .csv file:\n${err}`);
|
||||
|
|
@ -36,7 +36,7 @@ export const createCsvFile_ = (app: App, filename: string, columnData: Header) :
|
|||
return true;
|
||||
}
|
||||
|
||||
export default class CsvCreateModal extends Modal {
|
||||
export default class CSVCreateModal extends Modal {
|
||||
|
||||
columnsWrapper: HTMLElement;
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ export default class CsvCreateModal extends Modal {
|
|||
});
|
||||
}
|
||||
|
||||
createCsvFile() {
|
||||
createCSVFile() {
|
||||
// .csv 파일 생성
|
||||
const { contentEl } = this;
|
||||
|
||||
|
|
@ -163,7 +163,7 @@ export default class CsvCreateModal extends Modal {
|
|||
new Notice('add at least one column');
|
||||
return false;
|
||||
}
|
||||
return createCsvFile_(this.app, fullFilePath, columnData);
|
||||
return createCSVFile_(this.app, fullFilePath, columnData);
|
||||
}
|
||||
|
||||
// common api
|
||||
|
|
@ -216,7 +216,7 @@ export default class CsvCreateModal extends Modal {
|
|||
let buttonEl = contentEl.createEl('button', {text: 'Create'});
|
||||
buttonEl.addEventListener('click', () => {
|
||||
event?.preventDefault();
|
||||
const result = this.createCsvFile();
|
||||
const result = this.createCSVFile();
|
||||
if(result) {
|
||||
this.close();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,34 +1,34 @@
|
|||
import { App, Modal, TFile } from 'obsidian';
|
||||
|
||||
/*
|
||||
obsidian 탐색기에서 csv 파일이 표시가 안되기 때문에,\
|
||||
obsidian 탐색기에서 CSV 파일이 표시가 안되기 때문에,\
|
||||
파일 탐색하고 지우는 용도로 사용.
|
||||
*/
|
||||
export const getCsvFileStructure = async (app: App): Promise<Record<string, string[]>> => {
|
||||
const csvStructure: Record<string, string[]> = {};
|
||||
export const getCSVFileStructure = async (app: App): Promise<Record<string, string[]>> => {
|
||||
const CSVStructure: Record<string, string[]> = {};
|
||||
const files = app.vault.getFiles();
|
||||
|
||||
// Vault 내의 모든 파일 순회
|
||||
files.forEach((file: TFile) => {
|
||||
if (file.extension === "csv") {
|
||||
if (file.extension === "CSV") {
|
||||
if(file.parent) {
|
||||
const folderPath = file.parent.path;
|
||||
if (!csvStructure[folderPath])
|
||||
csvStructure[folderPath] = [];
|
||||
if (!CSVStructure[folderPath])
|
||||
CSVStructure[folderPath] = [];
|
||||
|
||||
csvStructure[folderPath].push(file.name);
|
||||
CSVStructure[folderPath].push(file.name);
|
||||
}
|
||||
}
|
||||
});
|
||||
return csvStructure;
|
||||
return CSVStructure;
|
||||
}
|
||||
|
||||
export default class CsvExplorerModal extends Modal {
|
||||
csvStructure: Record<string, string[]> = {};
|
||||
export default class CSVExplorerModal extends Modal {
|
||||
CSVStructure: Record<string, string[]> = {};
|
||||
|
||||
constructor(app: App, csvStructure: Record<string, string[]>) {
|
||||
constructor(app: App, CSVStructure: Record<string, string[]>) {
|
||||
super(app);
|
||||
this.csvStructure = csvStructure;
|
||||
this.csvStructure = CSVStructure;
|
||||
}
|
||||
|
||||
onOpen() {
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ import { App, Notice, TFile } from 'obsidian';
|
|||
export const readCSV_ = async (app: App, fileName: string): Promise<CSVTable | null> => {
|
||||
if(fileName.endsWith(".csv")) { // 확장자 검사.
|
||||
// read .csv file,
|
||||
const csvContent = await loadFile(app, fileName); // 파일 로드.
|
||||
const CSVContent = await loadFile(app, fileName); // 파일 로드.
|
||||
|
||||
const lines = csvContent.split("\n").map(line => line.trim());
|
||||
const lines = CSVContent.split("\n").map(line => line.trim());
|
||||
const headersString: string[] = lines.shift()?.split(",") ?? [];
|
||||
const rows = lines.map(line => line.split(",").map(cell => cell.trim()));
|
||||
|
||||
|
|
@ -37,7 +37,7 @@ export const readCSV_ = async (app: App, fileName: string): Promise<CSVTable | n
|
|||
|
||||
return await new CSVTable(headers, rows) // CSV 파싱.
|
||||
} else {
|
||||
console.error(`file extension is not csv : ${fileName} (read)`);
|
||||
console.error(`file extension is not CSV : ${fileName} (read)`);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
@ -50,7 +50,7 @@ export const saveCSV_ = async (app: App, fileName: string, table: CSVTable): Pro
|
|||
const header = table.getHeaders();
|
||||
await saveMetaFile(app, `${fileName}.meta`, header);
|
||||
} else {
|
||||
console.error(`file extension is not csv : ${fileName} (save)`);
|
||||
console.error(`file extension is not CSV : ${fileName} (save)`);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { App, Modal } from "obsidian";
|
||||
import { CSVCellType, CSVRow, CSVTable, Header, HeaderContent } from "./types";
|
||||
import { readCSV_, saveCSV_ } from "./csvFilemanager";
|
||||
import './styles/csvPlugin.css';
|
||||
import { readCSV_, saveCSV_ } from "./CSVFilemanager";
|
||||
import './styles/CSVPlugin.css';
|
||||
|
||||
export const createCsvInputModal_ = async (app: App, headers: Header, fileName: string, defaultValues: {[key: string]: string}) => {
|
||||
export const createCSVInputModal_ = async (app: App, headers: Header, fileName: string, defaultValues: {[key: string]: string}) => {
|
||||
const form = generateForm(fileName, headers, defaultValues);
|
||||
|
||||
const modal = new Modal(app);
|
||||
|
|
@ -12,7 +12,7 @@ export const createCsvInputModal_ = async (app: App, headers: Header, fileName:
|
|||
modal.open();
|
||||
|
||||
// 파일을 새로 읽어서, 추가된 라인을 포함 저장.
|
||||
const formElement = modal.contentEl.querySelector('#csv-input-form') as HTMLFormElement;
|
||||
const formElement = modal.contentEl.querySelector('#CSV-input-form') as HTMLFormElement;
|
||||
formElement.addEventListener('submit', async (event) => {
|
||||
event.preventDefault(); // 기본 제출 동작 방지
|
||||
// 입력 값 처리 가져오기.
|
||||
|
|
@ -39,7 +39,7 @@ export const createCsvInputModal_ = async (app: App, headers: Header, fileName:
|
|||
|
||||
const generateForm = (fileName: string, headers: Header, defaultValues: {[key: string]: string}): HTMLFormElement => {
|
||||
const form = document.createElement("form");
|
||||
form.id = "csv-input-form";
|
||||
form.id = "CSV-input-form";
|
||||
|
||||
const fileNameArray = fileName.split('/');
|
||||
const fileNameShort = fileNameArray[fileNameArray.length - 1];
|
||||
|
|
@ -156,9 +156,9 @@ const createInputField = (key: string): HTMLDivElement => {
|
|||
return formGroup;
|
||||
}
|
||||
|
||||
export const createCsvTableView_ = (csvTable: CSVTable): HTMLElement => {
|
||||
const headers = csvTable.getHeaders();
|
||||
const rows = csvTable.getRows();
|
||||
export const createCSVTableView_ = (CSVTable: CSVTable): HTMLElement => {
|
||||
const headers = CSVTable.getHeaders();
|
||||
const rows = CSVTable.getRows();
|
||||
|
||||
// 테이블 래퍼 생성
|
||||
const tableWrapper = document.createElement("div");
|
||||
|
|
|
|||
|
|
@ -124,11 +124,11 @@ export class CSVTable {
|
|||
}
|
||||
|
||||
toCSV(): string {
|
||||
const csvContent = [Object.keys(this.headers).join(",")];
|
||||
const CSVContent = [Object.keys(this.headers).join(",")];
|
||||
for (const row of this.rows) {
|
||||
csvContent.push(row.map(cell => (cell === null ? "" : cell.toString())).join(","));
|
||||
CSVContent.push(row.map(cell => (cell === null ? "" : cell.toString())).join(","));
|
||||
}
|
||||
return csvContent.join("\n");
|
||||
return CSVContent.join("\n");
|
||||
}
|
||||
|
||||
addColumn(columnName: string, columnType: CSVCellType, value: CSVCell = 0): void {
|
||||
|
|
|
|||
Loading…
Reference in a new issue