diff --git a/services/web/app/src/Features/Uploads/FileTypeManager.js b/services/web/app/src/Features/Uploads/FileTypeManager.js
index 15319bb180..0df4707281 100644
--- a/services/web/app/src/Features/Uploads/FileTypeManager.js
+++ b/services/web/app/src/Features/Uploads/FileTypeManager.js
@@ -13,6 +13,7 @@ const fileIgnoreMatcher = new Minimatch(Settings.fileIgnorePattern, {
const FileTypeManager = {
TEXT_EXTENSIONS: new Set(Settings.textExtensions.map(ext => `.${ext}`)),
+ EDITABLE_FILENAMES: Settings.editableFilenames,
MAX_TEXT_FILE_SIZE: 1 * 1024 * 1024, // 1 MB
@@ -108,7 +109,7 @@ function _isTextFilename(filename) {
const extension = Path.extname(filename).toLowerCase()
return (
FileTypeManager.TEXT_EXTENSIONS.has(extension) ||
- filename.match(/^(\.)?latexmkrc$/)
+ FileTypeManager.EDITABLE_FILENAMES.includes(filename.toLowerCase())
)
}
diff --git a/services/web/app/src/infrastructure/ExpressLocals.js b/services/web/app/src/infrastructure/ExpressLocals.js
index 1b0dc0d76a..e03e4d5c3a 100644
--- a/services/web/app/src/infrastructure/ExpressLocals.js
+++ b/services/web/app/src/infrastructure/ExpressLocals.js
@@ -397,6 +397,7 @@ module.exports = function (webRouter, privateApiRouter, publicApiRouter) {
recaptchaSiteKeyV3: Settings.recaptcha?.siteKeyV3,
recaptchaDisabled: Settings.recaptcha?.disabled,
textExtensions: Settings.textExtensions,
+ editableFilenames: Settings.editableFilenames,
validRootDocExtensions: Settings.validRootDocExtensions,
sentryAllowedOriginRegex: Settings.sentry.allowedOriginRegex,
sentryDsn: Settings.sentry.publicDSN,
diff --git a/services/web/config/settings.defaults.js b/services/web/config/settings.defaults.js
index 5dbb753931..f110b7db90 100644
--- a/services/web/config/settings.defaults.js
+++ b/services/web/config/settings.defaults.js
@@ -44,7 +44,6 @@ const defaultTextExtensions = [
'rtex',
'md',
'asy',
- 'latexmkrc',
'lbx',
'bbx',
'cbx',
@@ -62,6 +61,8 @@ const defaultTextExtensions = [
'mf',
'yml',
'yaml',
+ 'lhs',
+ 'mk',
]
const parseTextExtensions = function (extensions) {
@@ -676,6 +677,9 @@ module.exports = {
parseTextExtensions(process.env.ADDITIONAL_TEXT_EXTENSIONS)
),
+ // case-insensitive file names that is editable (doc) in the editor
+ editableFilenames: ['latexmkrc', '.latexmkrc', 'makefile', 'gnumakefile'],
+
fileIgnorePattern:
process.env.FILE_IGNORE_PATTERN ||
'**/{{__MACOSX,.git,.texpadtmp,.R}{,/**},.!(latexmkrc),*.{dvi,aux,log,toc,out,pdfsync,synctex,synctex(busy),fdb_latexmk,fls,nlo,ind,glo,gls,glg,bbl,blg,doc,docx,gz,swp}}',
diff --git a/services/web/frontend/js/features/file-view/components/file-view.jsx b/services/web/frontend/js/features/file-view/components/file-view.jsx
index b74ffc5144..4a17ac3128 100644
--- a/services/web/frontend/js/features/file-view/components/file-view.jsx
+++ b/services/web/frontend/js/features/file-view/components/file-view.jsx
@@ -15,11 +15,17 @@ export default function FileView({ file }) {
const { t } = useTranslation()
- const { textExtensions } = window.ExposedSettings
+ const { textExtensions, editableFilenames } = window.ExposedSettings
const extension = file.name.split('.').pop().toLowerCase()
- const isUnpreviewableFile =
- !imageExtensions.includes(extension) && !textExtensions.includes(extension)
+
+ const isEditableTextFile =
+ textExtensions.includes(extension) ||
+ editableFilenames.includes(file.name.toLowerCase())
+
+ const isImageFile = imageExtensions.includes(extension)
+
+ const isUnpreviewableFile = !isEditableTextFile && !isImageFile
const handleLoad = useCallback(() => {
setContentLoading(false)
@@ -35,7 +41,7 @@ export default function FileView({ file }) {
const content = (
<>
- {imageExtensions.includes(extension) && (
+ {isImageFile && (
)}
- {textExtensions.includes(extension) && (
+ {isEditableTextFile && (
)}
>
diff --git a/services/web/frontend/stories/decorators/scope.tsx b/services/web/frontend/stories/decorators/scope.tsx
index 45e710fbc1..a9b67f9dd1 100644
--- a/services/web/frontend/stories/decorators/scope.tsx
+++ b/services/web/frontend/stories/decorators/scope.tsx
@@ -168,7 +168,6 @@ const initialize = () => {
'rtex',
'md',
'asy',
- 'latexmkrc',
'lbx',
'bbx',
'cbx',
@@ -184,7 +183,10 @@ const initialize = () => {
'lua',
'gv',
'mf',
+ 'lhs',
+ 'mk',
],
+ editableFilenames: ['latexmkrc', '.latexmkrc', 'makefile', 'gnumakefile'],
validRootDocExtensions: ['tex', 'Rtex', 'ltx', 'Rnw'],
}
diff --git a/services/web/test/frontend/bootstrap.js b/services/web/test/frontend/bootstrap.js
index 878a29fb9f..1451f8e074 100644
--- a/services/web/test/frontend/bootstrap.js
+++ b/services/web/test/frontend/bootstrap.js
@@ -46,7 +46,6 @@ window.ExposedSettings = {
'rtex',
'md',
'asy',
- 'latexmkrc',
'lbx',
'bbx',
'cbx',
@@ -62,7 +61,10 @@ window.ExposedSettings = {
'lua',
'gv',
'mf',
+ 'lhs',
+ 'mk',
],
+ editableFilenames: ['latexmkrc', '.latexmkrc', 'makefile', 'gnumakefile'],
}
window.i18n = { currentLangCode: 'en' }
diff --git a/services/web/test/unit/src/Uploads/FileSystemImportManagerTests.js b/services/web/test/unit/src/Uploads/FileSystemImportManagerTests.js
index c2650955db..fb0a2ad2be 100644
--- a/services/web/test/unit/src/Uploads/FileSystemImportManagerTests.js
+++ b/services/web/test/unit/src/Uploads/FileSystemImportManagerTests.js
@@ -28,6 +28,12 @@ describe('FileSystemImportManager', function () {
requires: {
'@overleaf/settings': {
textExtensions: ['tex', 'txt'],
+ editableFilenames: [
+ 'latexmkrc',
+ '.latexmkrc',
+ 'makefile',
+ 'gnumakefile',
+ ],
fileIgnorePattern: Settings.fileIgnorePattern, // use the real pattern from the default settings
},
'../Editor/EditorController': this.EditorController,
diff --git a/services/web/test/unit/src/Uploads/FileTypeManagerTests.js b/services/web/test/unit/src/Uploads/FileTypeManagerTests.js
index 66f06b9ed1..e9b3330965 100644
--- a/services/web/test/unit/src/Uploads/FileTypeManagerTests.js
+++ b/services/web/test/unit/src/Uploads/FileTypeManagerTests.js
@@ -90,6 +90,10 @@ describe('FileTypeManager', function () {
'/file.m',
'/something/file.m',
'/file.TEX',
+ '/file.lhs',
+ '/makefile',
+ '/Makefile',
+ '/GNUMakefile',
]
TEXT_FILENAMES.forEach(filename => {
it(`should classify ${filename} as text`, function (done) {
diff --git a/services/web/types/exposed-settings.ts b/services/web/types/exposed-settings.ts
index 415ccd0948..3c09cf14aa 100644
--- a/services/web/types/exposed-settings.ts
+++ b/services/web/types/exposed-settings.ts
@@ -38,6 +38,7 @@ export type ExposedSettings = {
sentryRelease?: string
siteUrl: string
textExtensions: string[]
+ editableFilenames: string[]
validRootDocExtensions: string[]
templateLinks?: TemplateLink[]
labsEnabled: boolean