From f3754125aab16bd6e22f49ae6664215c2bbac26a Mon Sep 17 00:00:00 2001 From: Sundeep Chand Date: Tue, 2 Feb 2021 19:47:36 +0530 Subject: [PATCH 1/3] [#1741]-Added xml to Regex --- server/utils/fileUtils.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/server/utils/fileUtils.js b/server/utils/fileUtils.js index f06b846462..a25773fef0 100644 --- a/server/utils/fileUtils.js +++ b/server/utils/fileUtils.js @@ -38,12 +38,13 @@ export const fileExtensionsArray = [ 'mov', 'vert', 'frag', - 'bin' + 'bin', + 'xml' ]; export const mimeTypes = `image/*,audio/*,text/javascript,text/html,text/css, application/json,application/x-font-ttf,application/x-font-truetype,text/plain, -text/csv,.obj,video/webm,video/ogg,video/quicktime,video/mp4`; +text/csv,.obj,video/webm,video/ogg,video/quicktime,video/mp4,application/xml`; export const fileExtensions = fileExtensionsArray .map((ext) => `.${ext}`) @@ -64,10 +65,10 @@ export const MEDIA_FILE_QUOTED_REGEX = new RegExp( export const STRING_REGEX = /(['"])((\\\1|.)*?)\1/gm; // these are files that have to be linked to with a blob url -export const PLAINTEXT_FILE_REGEX = /.+\.(json|txt|csv|vert|frag|tsv)$/i; +export const PLAINTEXT_FILE_REGEX = /.+\.(json|txt|csv|vert|frag|tsv|xml)$/i; // these are files that users would want to edit as text (maybe svg should be here?) -export const TEXT_FILE_REGEX = /.+\.(json|txt|csv|tsv|vert|frag|js|css|html|htm|jsx)$/i; +export const TEXT_FILE_REGEX = /.+\.(json|txt|csv|tsv|vert|frag|js|css|html|htm|jsx|xml)$/i; export const NOT_EXTERNAL_LINK_REGEX = /^(?!(http:\/\/|https:\/\/))/; export const EXTERNAL_LINK_REGEX = /^(http:\/\/|https:\/\/)/; -export const CREATE_FILE_REGEX = /.+\.(json|txt|csv|tsv|js|css|frag|vert)$/i; +export const CREATE_FILE_REGEX = /.+\.(json|txt|csv|tsv|js|css|frag|vert|xml)$/i; From ab802bc6cd77fefec9be20f5f7f02c08840a2a68 Mon Sep 17 00:00:00 2001 From: Sundeep Chand Date: Fri, 5 Feb 2021 00:08:04 +0530 Subject: [PATCH 2/3] [#1741] Added .xml to translations --- translations/locales/en-US/translations.json | 2 +- translations/locales/es-419/translations.json | 2 +- translations/locales/hi/translations.json | 2 +- translations/locales/ja/translations.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/translations/locales/en-US/translations.json b/translations/locales/en-US/translations.json index 6a3505854a..c4766483f3 100644 --- a/translations/locales/en-US/translations.json +++ b/translations/locales/en-US/translations.json @@ -238,7 +238,7 @@ "Title": "Create File", "CloseButtonARIA": "Close New File Modal", "EnterName": "Please enter a name", - "InvalidType": "Invalid file type. Valid extensions are .js, .css, .json, .txt, .csv, .tsv, .frag, and .vert." + "InvalidType": "Invalid file type. Valid extensions are .js, .css, .json, .xml, .txt, .csv, .tsv, .frag, and .vert." }, "NewFileForm": { "AddFileSubmit": "Add File", diff --git a/translations/locales/es-419/translations.json b/translations/locales/es-419/translations.json index 2c4d711eb6..78980f1763 100644 --- a/translations/locales/es-419/translations.json +++ b/translations/locales/es-419/translations.json @@ -238,7 +238,7 @@ "Title": "Crear Archivo", "CloseButtonARIA": "Cerrar diálogo de crear archivo", "EnterName": "Por favor introduce un nombre", - "InvalidType": "Tipo de archivo inválido. Las extensiones válidas son .js, .css, .json, .txt, .csv, .tsv, .frag y .vert." + "InvalidType": "Tipo de archivo inválido. Las extensiones válidas son .js, .css, .json, .xml, .txt, .csv, .tsv, .frag y .vert." }, "NewFileForm": { "AddFileSubmit": "Agregar Archivo", diff --git a/translations/locales/hi/translations.json b/translations/locales/hi/translations.json index dbd33c8507..00cff74228 100644 --- a/translations/locales/hi/translations.json +++ b/translations/locales/hi/translations.json @@ -238,7 +238,7 @@ "Title": "फ़ाइल बनाएँ", "CloseButtonARIA": "नई फ़ाइल मोडल बंद करें", "EnterName": "कृपया एक नाम दर्ज करें", - "InvalidType": "अमान्य फ़ाइल प्रकार। मान्य एक्सटेंशन हैं .js, .css, .json, .txt, .csv, .tsv, .frag, और .vert." + "InvalidType": "अमान्य फ़ाइल प्रकार। मान्य एक्सटेंशन हैं .js, .css, .json, .xml, .txt, .csv, .tsv, .frag, और .vert." }, "NewFileForm": { "AddFileSubmit": "फाइल जोडें", diff --git a/translations/locales/ja/translations.json b/translations/locales/ja/translations.json index 17ce4af396..f29407a0d5 100644 --- a/translations/locales/ja/translations.json +++ b/translations/locales/ja/translations.json @@ -238,7 +238,7 @@ "Title": "ファイル作成", "CloseButtonARIA": "新規ファイルモーダルを閉じる", "EnterName": "ファイル名を入力してください", - "InvalidType": "ファイルタイプが無効です。有効な拡張子は、.js、.css、.json、.txt、.csv、.tsv、.frag、.vertです。" + "InvalidType": "ファイルタイプが無効です。有効な拡張子は、.js、.css、.json、.xml、.txt、.csv、.tsv、.frag、.vertです。" }, "NewFileForm": { "AddFileSubmit": "ファイルを追加", From bed25fecbaeb77b0b25ffedf724ec3c63319fe47 Mon Sep 17 00:00:00 2001 From: Sundeep Chand Date: Mon, 8 Feb 2021 01:28:01 +0530 Subject: [PATCH 3/3] Enabled syntax highlighting for xml --- client/modules/IDE/components/Editor.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/modules/IDE/components/Editor.jsx b/client/modules/IDE/components/Editor.jsx index 58edb2293f..ff8d5c2f8f 100644 --- a/client/modules/IDE/components/Editor.jsx +++ b/client/modules/IDE/components/Editor.jsx @@ -283,7 +283,7 @@ class Editor extends React.Component { mode = 'javascript'; } else if (fileName.match(/.+\.css$/i)) { mode = 'css'; - } else if (fileName.match(/.+\.html$/i)) { + } else if (fileName.match(/.+\.(html|xml)$/i)) { mode = 'htmlmixed'; } else if (fileName.match(/.+\.json$/i)) { mode = 'application/json';