Skip to content

Commit

Permalink
Support edit in vscode for csv.
Browse files Browse the repository at this point in the history
  • Loading branch information
cweijan committed Mar 5, 2024
1 parent f650423 commit 489ce51
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@
"priority": "option",
"selector": [
{
"filenamePattern": "*.class"
"filenamePattern": "file:/**/*.class"
}
]
}
Expand Down
9 changes: 7 additions & 2 deletions resource/excel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function loadSheet(buffer, ext) {
const ab = new Uint8Array(buffer).buffer
const wb = ext.toLowerCase() == ".csv" ? XLSX.read(new TextDecoder("utf-8").decode(ab), { type: "string", raw: true }) : XLSX.read(ab, { type: "array" });
var { sheets, maxLength, maxCols } = convert(wb);
sheetIns = sheetIns|| x_spreadsheet("#xspreadsheet", {
sheetIns = sheetIns || x_spreadsheet("#xspreadsheet", {
row: {
len: maxLength + 50,
height: 30,
Expand All @@ -46,6 +46,12 @@ function loadSheet(buffer, ext) {
}
})
sheetIns.loadData(sheets);
const child = document.querySelector('.x-spreadsheet-toolbar-btns>div:nth-child(3)>.x-spreadsheet-icon');
child.innerHTML = '<svg height="18" viewBox="-11.9 -2 1003.9 995.6" width="18" xmlns="http://www.w3.org/2000/svg"><path d="m12.1 353.9s-24-17.3 4.8-40.4l67.1-60s19.2-20.2 39.5-2.6l619.2 468.8v224.8s-.3 35.3-45.6 31.4z" fill="#2489ca"/><path d="m171.7 498.8-159.6 145.1s-16.4 12.2 0 34l74.1 67.4s17.6 18.9 43.6-2.6l169.2-128.3z" fill="#1070b3"/><path d="m451.9 500 292.7-223.5-1.9-223.6s-12.5-48.8-54.2-23.4l-389.5 354.5z" fill="#0877b9"/><path d="m697.1 976.2c17 17.4 37.6 11.7 37.6 11.7l228.1-112.4c29.2-19.9 25.1-44.6 25.1-44.6v-671.2c0-29.5-30.2-39.7-30.2-39.7l-197.7-95.3c-43.2-26.7-71.5 4.8-71.5 4.8s36.4-26.2 54.2 23.4v887.5c0 6.1-1.3 12.1-3.9 17.5-5.2 10.5-16.5 20.3-43.6 16.2z" fill="#3c99d4"/></svg>'
child.onclick = e => {
handler.emit("editInVSCode", true)
e.stopPropagation();
}
})();
}

Expand All @@ -54,7 +60,6 @@ vscodeEvent.emit("init")
vscodeEvent.on("open", ({ path, ext }) => {
extName = ext.replace('.', '');
fetch(path).then(response => response.arrayBuffer()).then(res => { loadSheet(res, ext) })
console.log(path)
}).on("saveDone", () => {
notie.alert({ type: 1, text: 'Save Success!' })
})
Expand Down
2 changes: 1 addition & 1 deletion resource/vditor/icon/vscode.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 489ce51

Please sign in to comment.