mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #15016 from overleaf/mf-remove-editor-left-menu-angular
[web] Remove angular editor left menu code GitOrigin-RevId: ad3f16d5a2b98751e2011ab0412e1921dfa37fd0
This commit is contained in:
parent
217fcf57d1
commit
e3a99a82db
17 changed files with 2 additions and 842 deletions
|
@ -1,327 +0,0 @@
|
|||
aside#left-menu.full-size(
|
||||
ng-class="{ 'shown': ui.leftMenuShown }"
|
||||
ng-cloak
|
||||
)
|
||||
h4 #{translate("download")}
|
||||
|
||||
ul.list-unstyled.nav.nav-downloads.text-center
|
||||
li
|
||||
a(
|
||||
ng-href="/project/{{project_id}}/download/zip"
|
||||
target="_blank"
|
||||
)
|
||||
i.fa.fa-file-archive-o.fa-2x
|
||||
br
|
||||
| #{translate("source")}
|
||||
li
|
||||
a(
|
||||
ng-href="{{pdf.downloadUrl || pdf.url}}"
|
||||
target="_blank"
|
||||
ng-if="pdf.url"
|
||||
)
|
||||
i.fa.fa-file-pdf-o.fa-2x
|
||||
br
|
||||
| PDF
|
||||
div.link-disabled(
|
||||
ng-if="!pdf.url"
|
||||
tooltip=translate('please_compile_pdf_before_download')
|
||||
tooltip-placement="bottom"
|
||||
)
|
||||
i.fa.fa-file-pdf-o.fa-2x
|
||||
br
|
||||
| PDF
|
||||
|
||||
span(ng-show="!anonymous")
|
||||
h4 #{translate("actions")}
|
||||
ul.list-unstyled.nav
|
||||
li(ng-controller="LeftMenuCloneProjectModalController")
|
||||
a(
|
||||
href,
|
||||
ng-click="openCloneProjectModal()"
|
||||
)
|
||||
i.fa.fa-fw.fa-copy
|
||||
| #{translate("copy_project")}
|
||||
|
||||
clone-project-modal(
|
||||
handle-hide="handleHide"
|
||||
open-project="openProject"
|
||||
show="show"
|
||||
)
|
||||
|
||||
!= moduleIncludes("editorLeftMenu:actions", locals)
|
||||
li(ng-controller="WordCountModalController")
|
||||
a(href, ng-if="pdf.url", ng-click="openWordCountModal()")
|
||||
i.fa.fa-fw.fa-eye
|
||||
span #{translate("word_count")}
|
||||
a.link-disabled(href, ng-if="!pdf.url", tooltip=translate('please_compile_pdf_before_word_count'))
|
||||
i.fa.fa-fw.fa-eye
|
||||
span.link-disabled #{translate("word_count")}
|
||||
|
||||
word-count-modal(
|
||||
handle-hide="handleHide"
|
||||
show="show"
|
||||
)
|
||||
|
||||
if (moduleIncludesAvailable("editorLeftMenu:sync"))
|
||||
div(ng-show="!anonymous")
|
||||
h4() #{translate("sync")}
|
||||
!= moduleIncludes("editorLeftMenu:sync", locals)
|
||||
|
||||
if (moduleIncludesAvailable("editorLeftMenu:editing_services"))
|
||||
span(ng-show="!anonymous")
|
||||
h4 #{translate("services")}
|
||||
!= moduleIncludes("editorLeftMenu:editing_services", locals)
|
||||
|
||||
h4(ng-show="!anonymous") #{translate("settings")}
|
||||
form.settings(ng-controller="SettingsController", ng-show="!anonymous")
|
||||
.containter-fluid
|
||||
.form-controls(ng-show="permissions.write")
|
||||
label(for="compiler") #{translate("compiler")}
|
||||
select(
|
||||
name="compiler"
|
||||
ng-model="project.compiler"
|
||||
)
|
||||
option(value='pdflatex') pdfLaTeX
|
||||
option(value='latex') LaTeX
|
||||
option(value='xelatex') XeLaTeX
|
||||
option(value='lualatex') LuaLaTeX
|
||||
|
||||
if (typeof(allowedImageNames) !== 'undefined' && allowedImageNames.length > 0)
|
||||
.form-controls(ng-show="permissions.write")
|
||||
label(for="imageName") #{translate("tex_live_version")}
|
||||
select(
|
||||
name="imageName"
|
||||
ng-model="project.imageName"
|
||||
)
|
||||
each image in allowedImageNames
|
||||
option(value=image.imageName) #{image.imageDesc}
|
||||
|
||||
.form-controls(ng-show="permissions.write")
|
||||
label(for="rootDoc_id") #{translate("main_document")}
|
||||
select(
|
||||
name="rootDoc_id",
|
||||
ng-model="project.rootDoc_id",
|
||||
ng-options="doc.doc.id as doc.path for doc in getValidMainDocs()"
|
||||
)
|
||||
|
||||
.form-controls
|
||||
label(for="spellCheckLanguage") #{translate("spell_check")}
|
||||
select(
|
||||
name="spellCheckLanguage"
|
||||
ng-model="project.spellCheckLanguage"
|
||||
)
|
||||
option(value="") #{translate("off")}
|
||||
optgroup(label="Language")
|
||||
for language in languages
|
||||
option(
|
||||
value=language.code
|
||||
)= language.name
|
||||
|
||||
.form-controls(ng-controller="DictionaryModalController")
|
||||
label #{translate("dictionary")}
|
||||
button.btn.btn-secondary.btn-xs(ng-click="openModal()") #{translate("edit")}
|
||||
|
||||
dictionary-modal(
|
||||
handle-hide="handleHide"
|
||||
show="show"
|
||||
)
|
||||
|
||||
.form-controls
|
||||
label(for="autoComplete") #{translate("auto_complete")}
|
||||
select(
|
||||
name="autoComplete"
|
||||
ng-model="settings.autoComplete"
|
||||
ng-options="o.v as o.n for o in [{ n: 'On', v: true }, { n: 'Off', v: false }]"
|
||||
)
|
||||
|
||||
.form-controls
|
||||
label(for="autoPairDelimiters") #{translate("auto_close_brackets")}
|
||||
select(
|
||||
name="autoPairDelimiters"
|
||||
ng-model="settings.autoPairDelimiters"
|
||||
ng-options="o.v as o.n for o in [{ n: 'On', v: true }, { n: 'Off', v: false }]"
|
||||
)
|
||||
|
||||
.form-controls.code-check-setting
|
||||
label(for="syntaxValidation") #{translate("syntax_validation")}
|
||||
select(
|
||||
name="syntaxValidation"
|
||||
ng-model="settings.syntaxValidation"
|
||||
ng-options="o.v as o.n for o in [{ n: 'On', v: true }, { n: 'Off', v: false }]"
|
||||
)
|
||||
|
||||
.form-controls
|
||||
label(for="editorTheme") #{translate("editor_theme")}
|
||||
select(
|
||||
name="editorTheme"
|
||||
ng-model="settings.editorTheme"
|
||||
)
|
||||
each editorTheme in editorThemes
|
||||
option(value=editorTheme) #{editorTheme.replace(/_/g, ' ')}
|
||||
option(value="—" disabled) —————————————————
|
||||
each editorTheme in legacyEditorThemes
|
||||
option(value=editorTheme) #{editorTheme.replace(/_/g, ' ')} (Legacy)
|
||||
|
||||
if (settings.overleaf != null && !isIEEE(brandVariation))
|
||||
.form-controls
|
||||
label(for="overallTheme") #{translate("overall_theme")}
|
||||
select(
|
||||
name="overallTheme"
|
||||
ng-if="!ui.loadingStyleSheet"
|
||||
ng-model="settings.overallTheme"
|
||||
ng-options="overallTheme.val as overallTheme.name for overallTheme in overallThemesList"
|
||||
)
|
||||
p.loading.pull-right(
|
||||
ng-if="ui.loadingStyleSheet"
|
||||
)
|
||||
i.fa.fa-fw.fa-spin.fa-refresh
|
||||
|
||||
.form-controls(ng-show="!anonymous")
|
||||
label(for="mode") #{translate("keybindings")}
|
||||
select(
|
||||
name="mode"
|
||||
ng-model="settings.mode"
|
||||
)
|
||||
option(value='default') None
|
||||
option(value='vim') Vim
|
||||
option(value='emacs') Emacs
|
||||
|
||||
.form-controls
|
||||
label(for="fontSize") #{translate("font_size")}
|
||||
select(
|
||||
name="fontSize"
|
||||
ng-model="fontSizeAsStr"
|
||||
ng-model-options="{ getterSetter: true }"
|
||||
)
|
||||
each size in ['10','11','12','13','14','16','18','20','22','24']
|
||||
option(value=size) #{size}px
|
||||
|
||||
.form-controls
|
||||
label(for="fontFamily") #{translate("font_family")}
|
||||
select(
|
||||
name="fontFamily"
|
||||
ng-model="settings.fontFamily"
|
||||
)
|
||||
option(value='monaco') Monaco / Menlo / Consolas
|
||||
option(value='lucida') Lucida / Source Code Pro
|
||||
.form-controls
|
||||
label(for="lineHeight") #{translate("line_height")}
|
||||
select(
|
||||
name="lineHeight"
|
||||
ng-model="settings.lineHeight"
|
||||
)
|
||||
each lineHeight in ['compact', 'normal', 'wide']
|
||||
option(value=lineHeight) #{translate(lineHeight)}
|
||||
|
||||
.form-controls
|
||||
label(for="pdfViewer") #{translate("pdf_viewer")}
|
||||
select(
|
||||
name="pdfViewer"
|
||||
ng-model="settings.pdfViewer"
|
||||
)
|
||||
option(value="pdfjs") #{translate("overleaf")}
|
||||
option(value="native") #{translate("browser")}
|
||||
|
||||
h4 #{translate("help")}
|
||||
ul.list-unstyled.nav
|
||||
li(ng-controller="HotkeysModalController")
|
||||
a(ng-click="openHotkeysModal()")
|
||||
i.fa.fa-keyboard-o.fa-fw
|
||||
| #{translate("show_hotkeys")}
|
||||
|
||||
hotkeys-modal(
|
||||
handle-hide="handleHide"
|
||||
show="show"
|
||||
track-changes-visible="trackChangesVisible"
|
||||
is-mac="isMac"
|
||||
new-source-editor="editor.newSourceEditor"
|
||||
)
|
||||
if showSupport
|
||||
li(ng-controller="LeftMenuDocumentationController")
|
||||
a(
|
||||
href='/learn', target="_blank"
|
||||
ng-click="sendLeftMenuDocumentationEvent()"
|
||||
)
|
||||
i.fa.fa-book.fa-fw
|
||||
| #{translate('documentation')}
|
||||
li
|
||||
a(ng-controller="ContactModal", ng-click="contactUsModal()")
|
||||
i.fa.fa-question.fa-fw
|
||||
| #{translate("contact_us")}
|
||||
|
||||
#left-menu-mask(
|
||||
ng-show="ui.leftMenuShown",
|
||||
ng-click="ui.leftMenuShown = false"
|
||||
ng-cloak
|
||||
)
|
||||
|
||||
script(type='text/ng-template', id='cloneProjectModalTemplate')
|
||||
.modal-header
|
||||
h3 #{translate("copy_project")}
|
||||
.modal-body
|
||||
.alert.alert-danger(ng-show="state.error.message") {{ state.error.message}}
|
||||
.alert.alert-danger(ng-show="state.error && !state.error.message") #{translate("generic_something_went_wrong")}
|
||||
form(name="cloneProjectForm", novalidate)
|
||||
.form-group
|
||||
label #{translate("new_name")}
|
||||
input.form-control(
|
||||
type="text",
|
||||
placeholder="New Project Name",
|
||||
required,
|
||||
ng-model="inputs.projectName",
|
||||
on-enter="clone()",
|
||||
focus-on="open"
|
||||
)
|
||||
.modal-footer
|
||||
button.btn.btn-secondary(
|
||||
ng-disabled="state.inflight"
|
||||
ng-click="cancel()"
|
||||
) #{translate("cancel")}
|
||||
button.btn.btn-primary(
|
||||
ng-disabled="cloneProjectForm.$invalid || state.inflight"
|
||||
ng-click="clone()"
|
||||
)
|
||||
span(ng-hide="state.inflight") #{translate("copy")}
|
||||
span(ng-show="state.inflight") #{translate("copying")}…
|
||||
|
||||
script(type='text/ng-template', id='wordCountModalTemplate')
|
||||
.modal-header
|
||||
h3 #{translate("word_count")}
|
||||
.modal-body
|
||||
div(ng-if="status.loading")
|
||||
.loading(ng-show="!status.error && status.loading")
|
||||
i.fa.fa-refresh.fa-spin.fa-fw
|
||||
span #{translate("loading")}…
|
||||
div.pdf-disabled(
|
||||
ng-if="!pdf.url"
|
||||
tooltip=translate('please_compile_pdf_before_word_count')
|
||||
tooltip-placement="bottom"
|
||||
)
|
||||
div(ng-if="!status.loading")
|
||||
.container-fluid
|
||||
.row(ng-show='data.messages.length > 0')
|
||||
.col-xs-12
|
||||
.alert.alert-danger
|
||||
p(style="white-space: pre-wrap") {{data.messages}}
|
||||
.row
|
||||
.col-xs-4
|
||||
.pull-right #{translate("total_words")} :
|
||||
.col-xs-6 {{data.textWords}}
|
||||
.row
|
||||
.col-xs-4
|
||||
.pull-right #{translate("headers")} :
|
||||
.col-xs-6 {{data.headers}}
|
||||
.row
|
||||
.col-xs-4
|
||||
.pull-right #{translate("math_inline")} :
|
||||
.col-xs-6 {{data.mathInline}}
|
||||
.row
|
||||
.col-xs-4
|
||||
.pull-right #{translate("math_display")} :
|
||||
.col-xs-6 {{data.mathDisplay}}
|
||||
.modal-footer
|
||||
button.btn.btn-secondary(
|
||||
ng-disabled="state.inflight"
|
||||
ng-click="cancel()"
|
||||
) #{translate("done")}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
import App from '../../../base'
|
||||
import { react2angular } from 'react2angular'
|
||||
import EditorCloneProjectModalWrapper from '../components/editor-clone-project-modal-wrapper'
|
||||
import { rootContext } from '../../../shared/context/root-context'
|
||||
import { assign } from '../../../shared/components/location'
|
||||
|
||||
export default App.controller(
|
||||
'LeftMenuCloneProjectModalController',
|
||||
function ($scope) {
|
||||
$scope.show = false
|
||||
|
||||
$scope.handleHide = () => {
|
||||
$scope.$applyAsync(() => {
|
||||
$scope.show = false
|
||||
})
|
||||
}
|
||||
|
||||
$scope.openCloneProjectModal = () => {
|
||||
$scope.$applyAsync(() => {
|
||||
$scope.show = true
|
||||
})
|
||||
}
|
||||
|
||||
$scope.openProject = project => {
|
||||
assign(`/project/${project.project_id}`)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
App.component(
|
||||
'cloneProjectModal',
|
||||
react2angular(
|
||||
rootContext.use(EditorCloneProjectModalWrapper),
|
||||
Object.keys(EditorCloneProjectModalWrapper.propTypes)
|
||||
)
|
||||
)
|
|
@ -1,26 +0,0 @@
|
|||
import App from '../../../base'
|
||||
import { react2angular } from 'react2angular'
|
||||
import DictionaryModal from '../components/dictionary-modal'
|
||||
import { rootContext } from '../../../shared/context/root-context'
|
||||
|
||||
export default App.controller('DictionaryModalController', function ($scope) {
|
||||
$scope.show = false
|
||||
|
||||
$scope.handleHide = () => {
|
||||
$scope.$applyAsync(() => {
|
||||
$scope.show = false
|
||||
window.dispatchEvent(new CustomEvent('learnedWords:reset'))
|
||||
})
|
||||
}
|
||||
|
||||
$scope.openModal = () => {
|
||||
$scope.$applyAsync(() => {
|
||||
$scope.show = true
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
App.component(
|
||||
'dictionaryModal',
|
||||
react2angular(rootContext.use(DictionaryModal), ['show', 'handleHide'])
|
||||
)
|
|
@ -1,10 +0,0 @@
|
|||
import App from '../../../base'
|
||||
|
||||
export default App.controller(
|
||||
'LeftMenuDocumentationController',
|
||||
function ($scope, eventTracking) {
|
||||
$scope.sendLeftMenuDocumentationEvent = () => {
|
||||
eventTracking.sendMB('left-menu-documentation-click')
|
||||
}
|
||||
}
|
||||
)
|
|
@ -1,26 +0,0 @@
|
|||
import App from '../../../base'
|
||||
import { react2angular } from 'react2angular'
|
||||
|
||||
import HotkeysModal from '../components/hotkeys-modal'
|
||||
|
||||
App.component('hotkeysModal', react2angular(HotkeysModal, undefined))
|
||||
|
||||
export default App.controller('HotkeysModalController', function ($scope) {
|
||||
$scope.show = false
|
||||
$scope.isMac = /Mac/i.test(navigator.platform)
|
||||
|
||||
$scope.handleHide = () => {
|
||||
$scope.$applyAsync(() => {
|
||||
$scope.show = false
|
||||
})
|
||||
}
|
||||
|
||||
$scope.openHotkeysModal = () => {
|
||||
$scope.$applyAsync(() => {
|
||||
$scope.trackChangesVisible =
|
||||
$scope.project && $scope.project.features.trackChangesVisible
|
||||
|
||||
$scope.show = true
|
||||
})
|
||||
}
|
||||
})
|
|
@ -1,28 +0,0 @@
|
|||
import App from '../../../base'
|
||||
import { react2angular } from 'react2angular'
|
||||
import WordCountModal from '../components/word-count-modal'
|
||||
import { rootContext } from '../../../shared/context/root-context'
|
||||
|
||||
export default App.controller('WordCountModalController', function ($scope) {
|
||||
$scope.show = false
|
||||
|
||||
$scope.handleHide = () => {
|
||||
$scope.$applyAsync(() => {
|
||||
$scope.show = false
|
||||
})
|
||||
}
|
||||
|
||||
$scope.openWordCountModal = () => {
|
||||
$scope.$applyAsync(() => {
|
||||
$scope.show = true
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
App.component(
|
||||
'wordCountModal',
|
||||
react2angular(
|
||||
rootContext.use(WordCountModal),
|
||||
Object.keys(WordCountModal.propTypes)
|
||||
)
|
||||
)
|
|
@ -31,12 +31,8 @@ import './ide/review-panel/ReviewPanelManager'
|
|||
import OutlineManager from './features/outline/outline-manager'
|
||||
import SafariScrollPatcher from './ide/SafariScrollPatcher'
|
||||
import './ide/cobranding/CobrandingDataService'
|
||||
import './ide/settings/index'
|
||||
import './ide/chat/index'
|
||||
import './ide/clone/index'
|
||||
import './ide/file-view/index'
|
||||
import './ide/hotkeys/index'
|
||||
import './ide/wordcount/index'
|
||||
import './ide/toolbar/index'
|
||||
import './ide/directives/layout'
|
||||
import './ide/directives/validFile'
|
||||
|
@ -68,6 +64,7 @@ import './features/source-editor/controllers/cm6-switch-away-survey-controller'
|
|||
import './features/source-editor/controllers/legacy-editor-warning-controller'
|
||||
import './features/history/controllers/history-controller'
|
||||
import './features/history/controllers/history-file-tree-controller'
|
||||
import './features/editor-left-menu/controllers/editor-left-menu-controller'
|
||||
import { cleanupServiceWorker } from './utils/service-worker-cleanup'
|
||||
import { reportCM6Perf } from './infrastructure/cm6-performance'
|
||||
import { reportAcePerf } from './ide/editor/ace-performance'
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
/* eslint-disable
|
||||
no-return-assign,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
import App from '../../../base'
|
||||
|
||||
export default App.controller(
|
||||
'CloneProjectController',
|
||||
($scope, $modal) =>
|
||||
($scope.openCloneProjectModal = () =>
|
||||
$modal.open({
|
||||
templateUrl: 'cloneProjectModalTemplate',
|
||||
controller: 'CloneProjectModalController',
|
||||
}))
|
||||
)
|
|
@ -1,54 +0,0 @@
|
|||
/* eslint-disable
|
||||
max-len,
|
||||
no-return-assign,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
import App from '../../../base'
|
||||
|
||||
export default App.controller(
|
||||
'CloneProjectModalController',
|
||||
function ($scope, $modalInstance, $timeout, $http, ide) {
|
||||
$scope.inputs = { projectName: ide.$scope.project.name + ' (Copy)' }
|
||||
$scope.state = {
|
||||
inflight: false,
|
||||
error: false,
|
||||
}
|
||||
|
||||
$modalInstance.opened.then(() =>
|
||||
$timeout(() => $scope.$broadcast('open'), 200)
|
||||
)
|
||||
|
||||
const cloneProject = cloneName =>
|
||||
$http.post(`/project/${ide.$scope.project._id}/clone`, {
|
||||
_csrf: window.csrfToken,
|
||||
projectName: cloneName,
|
||||
})
|
||||
|
||||
$scope.clone = function () {
|
||||
$scope.state.inflight = true
|
||||
$scope.state.error = false
|
||||
return cloneProject($scope.inputs.projectName)
|
||||
.then(function (response) {
|
||||
const { data } = response
|
||||
return (window.location = `/project/${data.project_id}`)
|
||||
})
|
||||
.catch(function (response) {
|
||||
const { data, status } = response
|
||||
$scope.state.inflight = false
|
||||
if (status === 400) {
|
||||
return ($scope.state.error = { message: data })
|
||||
} else {
|
||||
return ($scope.state.error = true)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return ($scope.cancel = () => $modalInstance.dismiss('cancel'))
|
||||
}
|
||||
)
|
|
@ -1,6 +0,0 @@
|
|||
// Angular
|
||||
import './controllers/CloneProjectController'
|
||||
import './controllers/CloneProjectModalController'
|
||||
|
||||
// React
|
||||
import '../../features/clone-project-modal/controllers/left-menu-clone-project-modal-controller'
|
|
@ -1,3 +0,0 @@
|
|||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
import '../../features/hotkeys-modal/controllers/hotkeys-modal-controller'
|
|
@ -1,250 +0,0 @@
|
|||
import _ from 'lodash'
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
max-len,
|
||||
no-return-assign,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* DS207: Consider shorter variations of null checks
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
import App from '../../../base'
|
||||
import isValidTeXFile from '../../../main/is-valid-tex-file'
|
||||
|
||||
export default App.controller(
|
||||
'SettingsController',
|
||||
function ($scope, settings, ide) {
|
||||
$scope.overallThemesList = window.overallThemes
|
||||
$scope.ui = { loadingStyleSheet: false }
|
||||
|
||||
const _updateCSSFile = function (theme) {
|
||||
$scope.ui.loadingStyleSheet = true
|
||||
const docHeadEl = document.querySelector('head')
|
||||
const oldStyleSheetEl = document.getElementById('main-stylesheet')
|
||||
const newStyleSheetEl = document.createElement('link')
|
||||
newStyleSheetEl.addEventListener('load', e => {
|
||||
return $scope.$applyAsync(() => {
|
||||
$scope.ui.loadingStyleSheet = false
|
||||
return docHeadEl.removeChild(oldStyleSheetEl)
|
||||
})
|
||||
})
|
||||
newStyleSheetEl.setAttribute('rel', 'stylesheet')
|
||||
newStyleSheetEl.setAttribute('id', 'main-stylesheet')
|
||||
newStyleSheetEl.setAttribute('href', theme.path)
|
||||
return docHeadEl.appendChild(newStyleSheetEl)
|
||||
}
|
||||
|
||||
if (!['default', 'vim', 'emacs'].includes($scope.settings.mode)) {
|
||||
$scope.settings.mode = 'default'
|
||||
}
|
||||
|
||||
if (!['pdfjs', 'native'].includes($scope.settings.pdfViewer)) {
|
||||
$scope.settings.pdfViewer = 'pdfjs'
|
||||
}
|
||||
|
||||
if (
|
||||
$scope.settings.fontFamily != null &&
|
||||
!['monaco', 'lucida'].includes($scope.settings.fontFamily)
|
||||
) {
|
||||
delete $scope.settings.fontFamily
|
||||
}
|
||||
|
||||
if (
|
||||
$scope.settings.lineHeight != null &&
|
||||
!['compact', 'normal', 'wide'].includes($scope.settings.lineHeight)
|
||||
) {
|
||||
delete $scope.settings.lineHeight
|
||||
}
|
||||
|
||||
$scope.fontSizeAsStr = function (newVal) {
|
||||
if (newVal != null) {
|
||||
$scope.settings.fontSize = newVal
|
||||
}
|
||||
return $scope.settings.fontSize.toString()
|
||||
}
|
||||
|
||||
$scope.getValidMainDocs = () => {
|
||||
let filteredDocs = []
|
||||
if ($scope.docs) {
|
||||
// Filter the existing docs (editable files) by accepted file extensions.
|
||||
// It's possible that an existing project has an invalid file selected as the main one.
|
||||
// To gracefully handle that case, make sure we also show the current main file (ignoring extension).
|
||||
filteredDocs = $scope.docs.filter(
|
||||
doc =>
|
||||
isValidTeXFile(doc.doc.name) ||
|
||||
$scope.project.rootDoc_id === doc.doc.id
|
||||
)
|
||||
}
|
||||
return filteredDocs
|
||||
}
|
||||
|
||||
$scope.$watch('settings.editorTheme', (editorTheme, oldEditorTheme) => {
|
||||
if (editorTheme !== oldEditorTheme) {
|
||||
return settings.saveSettings({ editorTheme })
|
||||
}
|
||||
})
|
||||
|
||||
$scope.$watch('settings.overallTheme', (overallTheme, oldOverallTheme) => {
|
||||
if (overallTheme !== oldOverallTheme) {
|
||||
const chosenTheme = _.find(
|
||||
$scope.overallThemesList,
|
||||
theme => theme.val === overallTheme
|
||||
)
|
||||
if (chosenTheme != null) {
|
||||
_updateCSSFile(chosenTheme)
|
||||
return settings.saveSettings({ overallTheme })
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
$scope.$watch('settings.fontSize', (fontSize, oldFontSize) => {
|
||||
if (fontSize !== oldFontSize) {
|
||||
return settings.saveSettings({ fontSize: parseInt(fontSize, 10) })
|
||||
}
|
||||
})
|
||||
|
||||
$scope.$watch('settings.mode', (mode, oldMode) => {
|
||||
if (mode !== oldMode) {
|
||||
return settings.saveSettings({ mode })
|
||||
}
|
||||
})
|
||||
|
||||
$scope.$watch('settings.autoComplete', (autoComplete, oldAutoComplete) => {
|
||||
if (autoComplete !== oldAutoComplete) {
|
||||
return settings.saveSettings({ autoComplete })
|
||||
}
|
||||
})
|
||||
|
||||
$scope.$watch(
|
||||
'settings.autoPairDelimiters',
|
||||
(autoPairDelimiters, oldAutoPairDelimiters) => {
|
||||
if (autoPairDelimiters !== oldAutoPairDelimiters) {
|
||||
return settings.saveSettings({ autoPairDelimiters })
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
$scope.$watch('settings.pdfViewer', (pdfViewer, oldPdfViewer) => {
|
||||
if (pdfViewer !== oldPdfViewer) {
|
||||
return settings.saveSettings({ pdfViewer })
|
||||
}
|
||||
})
|
||||
|
||||
$scope.$watch(
|
||||
'settings.syntaxValidation',
|
||||
(syntaxValidation, oldSyntaxValidation) => {
|
||||
if (syntaxValidation !== oldSyntaxValidation) {
|
||||
return settings.saveSettings({ syntaxValidation })
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
$scope.$watch('settings.fontFamily', (fontFamily, oldFontFamily) => {
|
||||
if (fontFamily !== oldFontFamily) {
|
||||
return settings.saveSettings({ fontFamily })
|
||||
}
|
||||
})
|
||||
|
||||
$scope.$watch('settings.lineHeight', (lineHeight, oldLineHeight) => {
|
||||
if (lineHeight !== oldLineHeight) {
|
||||
return settings.saveSettings({ lineHeight })
|
||||
}
|
||||
})
|
||||
|
||||
$scope.$watch('project.spellCheckLanguage', (language, oldLanguage) => {
|
||||
if (this.ignoreUpdates) {
|
||||
return
|
||||
}
|
||||
if (oldLanguage != null && language !== oldLanguage) {
|
||||
settings.saveProjectSettings({ spellCheckLanguage: language })
|
||||
// Also set it as the default for the user
|
||||
return settings.saveSettings({ spellCheckLanguage: language })
|
||||
}
|
||||
})
|
||||
|
||||
$scope.$watch('project.compiler', (compiler, oldCompiler) => {
|
||||
if (this.ignoreUpdates) {
|
||||
return
|
||||
}
|
||||
if (oldCompiler != null && compiler !== oldCompiler) {
|
||||
return settings.saveProjectSettings({ compiler })
|
||||
}
|
||||
})
|
||||
|
||||
$scope.$watch('project.imageName', (imageName, oldImageName) => {
|
||||
if (this.ignoreUpdates) {
|
||||
return
|
||||
}
|
||||
if (oldImageName != null && imageName !== oldImageName) {
|
||||
return settings.saveProjectSettings({ imageName })
|
||||
}
|
||||
})
|
||||
|
||||
let rootDocUpdateFailed = 0
|
||||
$scope.$watch('project.rootDoc_id', (rootDoc_id, oldRootDoc_id) => {
|
||||
if (this.ignoreUpdates) {
|
||||
return
|
||||
}
|
||||
// don't save on initialisation, Angular passes oldRootDoc_id as
|
||||
// undefined in this case.
|
||||
if (typeof oldRootDoc_id === 'undefined') {
|
||||
return
|
||||
}
|
||||
if ($scope.permissionsLevel === 'readOnly') {
|
||||
// The user is unauthorized to persist rootDoc changes.
|
||||
// Use the new value for this very editor session only.
|
||||
return
|
||||
}
|
||||
// otherwise only save changes, null values are allowed
|
||||
if (rootDoc_id !== oldRootDoc_id) {
|
||||
settings
|
||||
.saveProjectSettings({ rootDocId: rootDoc_id })
|
||||
.then(() => {
|
||||
rootDocUpdateFailed = 0
|
||||
})
|
||||
.catch(() => {
|
||||
rootDocUpdateFailed++
|
||||
// Let the login redirect run (if any) and reset afterwards.
|
||||
setTimeout(() => {
|
||||
if (rootDocUpdateFailed > 10) {
|
||||
// We are in a loop of failing updates. Stop now.
|
||||
this.ignoreUpdates = true
|
||||
}
|
||||
$scope.$apply(() => {
|
||||
$scope.project.rootDoc_id = oldRootDoc_id
|
||||
})
|
||||
this.ignoreUpdates = false
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
ide.socket.on('compilerUpdated', compiler => {
|
||||
this.ignoreUpdates = true
|
||||
$scope.$apply(() => {
|
||||
return ($scope.project.compiler = compiler)
|
||||
})
|
||||
return delete this.ignoreUpdates
|
||||
})
|
||||
|
||||
ide.socket.on('imageNameUpdated', imageName => {
|
||||
this.ignoreUpdates = true
|
||||
$scope.$apply(() => {
|
||||
return ($scope.project.imageName = imageName)
|
||||
})
|
||||
return delete this.ignoreUpdates
|
||||
})
|
||||
|
||||
return ide.socket.on('spellCheckLanguageUpdated', languageCode => {
|
||||
this.ignoreUpdates = true
|
||||
$scope.$apply(() => {
|
||||
return ($scope.project.spellCheckLanguage = languageCode)
|
||||
})
|
||||
return delete this.ignoreUpdates
|
||||
})
|
||||
}
|
||||
)
|
|
@ -1,7 +0,0 @@
|
|||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
import './services/settings'
|
||||
import './controllers/SettingsController'
|
||||
import '../../features/dictionary/controllers/modal-controller'
|
||||
import '../../features/editor-left-menu/controllers/editor-left-menu-controller'
|
||||
import '../../features/editor-left-menu/controllers/left-menu-documentation-controller'
|
|
@ -1,41 +0,0 @@
|
|||
/* eslint-disable
|
||||
camelcase,
|
||||
max-len,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS101: Remove unnecessary use of Array.from
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
import App from '../../../base'
|
||||
|
||||
export default App.factory('settings', (ide, eventTracking) => ({
|
||||
saveSettings(data) {
|
||||
// Tracking code.
|
||||
for (const key of Array.from(Object.keys(data))) {
|
||||
const changedSetting = key
|
||||
const changedSettingVal = data[key]
|
||||
eventTracking.sendMB('setting-changed', {
|
||||
changedSetting,
|
||||
changedSettingVal,
|
||||
})
|
||||
}
|
||||
// End of tracking code.
|
||||
|
||||
data._csrf = window.csrfToken
|
||||
return ide.$http.post('/user/settings', data)
|
||||
},
|
||||
|
||||
saveProjectSettings(data) {
|
||||
data._csrf = window.csrfToken
|
||||
return ide.$http.post(`/project/${ide.project_id}/settings`, data)
|
||||
},
|
||||
|
||||
saveProjectAdminSettings(data) {
|
||||
data._csrf = window.csrfToken
|
||||
return ide.$http.post(`/project/${ide.project_id}/settings/admin`, data)
|
||||
},
|
||||
}))
|
|
@ -1 +0,0 @@
|
|||
import '../../features/word-count-modal/controllers/word-count-modal-controller'
|
|
@ -4,5 +4,5 @@ import { rootContext } from '../root-context'
|
|||
|
||||
App.component(
|
||||
'sharedContextReact',
|
||||
react2angular(rootContext.component, [], ['ide', 'settings'])
|
||||
react2angular(rootContext.component, [], ['ide'])
|
||||
)
|
||||
|
|
|
@ -1406,7 +1406,6 @@
|
|||
"reference_search_info_v2": "It’s easy to find your references - you can search by author, title, year or journal. You can still search by citation key too.",
|
||||
"reference_sync": "Reference manager sync",
|
||||
"reference_sync_info": "Manage your reference library in Mendeley or Zotero and link it directly to a .bib file in Overleaf, so you can easily cite anything in your library.",
|
||||
"references_search_hint": "Press CTRL-Space to Search",
|
||||
"refresh": "Refresh",
|
||||
"refresh_page_after_linking_dropbox": "Please refresh this page after linking your account to Dropbox.",
|
||||
"refresh_page_after_starting_free_trial": "Please refresh this page after starting your free trial.",
|
||||
|
|
Loading…
Reference in a new issue