diff --git a/src/lib/file.ts b/src/lib/file.ts index 107fb3a..9f533da 100644 --- a/src/lib/file.ts +++ b/src/lib/file.ts @@ -24,10 +24,7 @@ export async function showOpenFilePicker() { const selected = await openFile({ multiple: false, directory: false, - filters: [{ - name: "Markdown", - extensions: ["md"] - }] + filters: pickerFilters }) return selected as string @@ -68,52 +65,7 @@ export async function setEditorText(editor: monaco.editor.IStandaloneCodeEditor, export async function showSaveFilePicker() { try { const selected = await saveFile({ - filters: [ - { - name: "Markdown", - extensions: ["md"] - }, - { - name: "Text", - extensions: ["txt"] - }, - { - name: "Shell Script", - extensions: ["sh"] - }, - { - name: "C", - extensions: ["c"] - }, - { - name: "C++", - extensions: ["cpp"] - }, - { - name: "Python", - extensions: ["py"] - }, - { - name: "CSS", - extensions: ["css"] - }, - { - name: "HTML", - extensions: ["html"] - }, - { - name: "JSON", - extensions: ["json"] - }, - { - name: "JavaScript", - extensions: ["js"] - }, - { - name: "TypeScript", - extensions: ["ts"] - } - ] + filters: pickerFilters }) return selected as string @@ -169,6 +121,53 @@ export function getExtension(fname: string) { return fname.slice((Math.max(0, fname.lastIndexOf(".")) || Infinity) + 1); } +export const pickerFilters = [ + { + name: "Markdown", + extensions: ["md"] + }, + { + name: "Text", + extensions: ["txt"] + }, + { + name: "Shell Script", + extensions: ["sh"] + }, + { + name: "C", + extensions: ["c"] + }, + { + name: "C++", + extensions: ["cpp"] + }, + { + name: "Python", + extensions: ["py"] + }, + { + name: "CSS", + extensions: ["css"] + }, + { + name: "HTML", + extensions: ["html"] + }, + { + name: "JSON", + extensions: ["json"] + }, + { + name: "JavaScript", + extensions: ["js"] + }, + { + name: "TypeScript", + extensions: ["ts"] + } +] + export const fileTypes = new Map([ ["txt", "plaintext"], ["sh", "shell"],