Merge pull request #4044 from overleaf/as-file-views-text-extension

Pull text extension list from settings, instead of hard-coding it

GitOrigin-RevId: b5ba956b8f065b852a2f5efc1a775ccb70df3226
This commit is contained in:
Jakob Ackermann 2021-05-21 13:32:42 +02:00 committed by Copybot
parent 26dbae7cef
commit 3f1ae7bff2
4 changed files with 70 additions and 34 deletions

View file

@ -90,6 +90,37 @@ window.ExposedSettings = {
maxEntitiesPerProject: 10,
maxUploadSize: 5 * 1024 * 1024,
enableSubscriptions: true,
textExtensions: [
'tex',
'latex',
'sty',
'cls',
'bst',
'bib',
'bibtex',
'txt',
'tikz',
'mtx',
'rtex',
'md',
'asy',
'latexmkrc',
'lbx',
'bbx',
'cbx',
'm',
'lco',
'dtx',
'ins',
'ist',
'def',
'clo',
'ldf',
'rmd',
'lua',
'gv',
'mf',
],
}
window.user = {

View file

@ -1,50 +1,23 @@
import React, { useState } from 'react'
import PropTypes from 'prop-types'
import { useTranslation } from 'react-i18next'
import BinaryFileHeader from './binary-file-header'
import BinaryFileImage from './binary-file-image'
import BinaryFileText from './binary-file-text'
import Icon from '../../../shared/components/icon'
import { useTranslation } from 'react-i18next'
const imageExtensions = ['png', 'jpg', 'jpeg', 'gif']
const textExtensions = [
'tex',
'latex',
'sty',
'cls',
'bst',
'bib',
'bibtex',
'txt',
'tikz',
'mtx',
'rtex',
'md',
'asy',
'latexmkrc',
'lbx',
'bbx',
'cbx',
'm',
'lco',
'dtx',
'ins',
'ist',
'def',
'clo',
'ldf',
'rmd',
'lua',
'gv',
]
const textExtensions = window.ExposedSettings.textExtensions
export default function BinaryFile({ file, storeReferencesKeys }) {
const extension = file.name.split('.').pop().toLowerCase()
const [contentLoading, setContentLoading] = useState(true)
const [hasError, setHasError] = useState(false)
const { t } = useTranslation()
const extension = file.name.split('.').pop().toLowerCase()
const isUnpreviewableFile =
!imageExtensions.includes(extension) && !textExtensions.includes(extension)

View file

@ -1,8 +1,9 @@
import App from '../../../base'
import { react2angular } from 'react2angular'
import BinaryFile from '../components/binary-file'
import _ from 'lodash'
import BinaryFile from '../components/binary-file'
export default App.controller(
'ReactBinaryFileController',
function ($scope, $rootScope) {

View file

@ -23,6 +23,37 @@ window.ExposedSettings = {
maxEntitiesPerProject: 10,
maxUploadSize: 5 * 1024 * 1024,
siteUrl: 'https://www.dev-overleaf.com',
textExtensions: [
'tex',
'latex',
'sty',
'cls',
'bst',
'bib',
'bibtex',
'txt',
'tikz',
'mtx',
'rtex',
'md',
'asy',
'latexmkrc',
'lbx',
'bbx',
'cbx',
'm',
'lco',
'dtx',
'ins',
'ist',
'def',
'clo',
'ldf',
'rmd',
'lua',
'gv',
'mf',
],
}
window.i18n = { currentLangCode: 'en' }