Added editorutils file with a utility function to convert mimetype to editor modes

This commit is contained in:
Andrew Bastin
2020-02-23 23:23:18 -05:00
parent 6e03c8d236
commit 5936a06ad1

11
functions/editorutils.js Normal file
View File

@@ -0,0 +1,11 @@
const mimeToMode = {
"text/plain": "plain_text",
"text/html": "html",
"application/xml": "xml",
"application/hal+json": "json",
"application/json": "json"
}
export function getEditorLangForMimeType(mimeType) {
return mimeToMode[mimeType] || "plain_text";
}