From 5936a06ad18e31862af6991845233b557f11b5ae Mon Sep 17 00:00:00 2001 From: Andrew Bastin Date: Sun, 23 Feb 2020 23:23:18 -0500 Subject: [PATCH] Added editorutils file with a utility function to convert mimetype to editor modes --- functions/editorutils.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 functions/editorutils.js diff --git a/functions/editorutils.js b/functions/editorutils.js new file mode 100644 index 000000000..c8e14a5f9 --- /dev/null +++ b/functions/editorutils.js @@ -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"; +}