From e3a99a82db8701cd19602d46319992491b0c0e8d Mon Sep 17 00:00:00 2001 From: M Fahru Date: Wed, 4 Oct 2023 10:12:44 -0700 Subject: [PATCH] Merge pull request #15016 from overleaf/mf-remove-editor-left-menu-angular [web] Remove angular editor left menu code GitOrigin-RevId: ad3f16d5a2b98751e2011ab0412e1921dfa37fd0 --- .../app/views/project/editor/left-menu.pug | 327 ------------------ ...eft-menu-clone-project-modal-controller.js | 36 -- .../controllers/modal-controller.js | 26 -- .../left-menu-documentation-controller.js | 10 - .../controllers/hotkeys-modal-controller.js | 26 -- .../word-count-modal-controller.js | 28 -- services/web/frontend/js/ide.js | 5 +- .../controllers/CloneProjectController.js | 21 -- .../CloneProjectModalController.js | 54 --- services/web/frontend/js/ide/clone/index.js | 6 - services/web/frontend/js/ide/hotkeys/index.js | 3 - .../controllers/SettingsController.js | 250 ------------- .../web/frontend/js/ide/settings/index.js | 7 - .../js/ide/settings/services/settings.js | 41 --- .../web/frontend/js/ide/wordcount/index.js | 1 - .../controllers/root-context-controller.js | 2 +- services/web/locales/en.json | 1 - 17 files changed, 2 insertions(+), 842 deletions(-) delete mode 100644 services/web/app/views/project/editor/left-menu.pug delete mode 100644 services/web/frontend/js/features/clone-project-modal/controllers/left-menu-clone-project-modal-controller.js delete mode 100644 services/web/frontend/js/features/dictionary/controllers/modal-controller.js delete mode 100644 services/web/frontend/js/features/editor-left-menu/controllers/left-menu-documentation-controller.js delete mode 100644 services/web/frontend/js/features/hotkeys-modal/controllers/hotkeys-modal-controller.js delete mode 100644 services/web/frontend/js/features/word-count-modal/controllers/word-count-modal-controller.js delete mode 100644 services/web/frontend/js/ide/clone/controllers/CloneProjectController.js delete mode 100644 services/web/frontend/js/ide/clone/controllers/CloneProjectModalController.js delete mode 100644 services/web/frontend/js/ide/clone/index.js delete mode 100644 services/web/frontend/js/ide/hotkeys/index.js delete mode 100644 services/web/frontend/js/ide/settings/controllers/SettingsController.js delete mode 100644 services/web/frontend/js/ide/settings/index.js delete mode 100644 services/web/frontend/js/ide/settings/services/settings.js delete mode 100644 services/web/frontend/js/ide/wordcount/index.js diff --git a/services/web/app/views/project/editor/left-menu.pug b/services/web/app/views/project/editor/left-menu.pug deleted file mode 100644 index 60c1ee6e61..0000000000 --- a/services/web/app/views/project/editor/left-menu.pug +++ /dev/null @@ -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")} - diff --git a/services/web/frontend/js/features/clone-project-modal/controllers/left-menu-clone-project-modal-controller.js b/services/web/frontend/js/features/clone-project-modal/controllers/left-menu-clone-project-modal-controller.js deleted file mode 100644 index beaca13cd1..0000000000 --- a/services/web/frontend/js/features/clone-project-modal/controllers/left-menu-clone-project-modal-controller.js +++ /dev/null @@ -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) - ) -) diff --git a/services/web/frontend/js/features/dictionary/controllers/modal-controller.js b/services/web/frontend/js/features/dictionary/controllers/modal-controller.js deleted file mode 100644 index 83236b2591..0000000000 --- a/services/web/frontend/js/features/dictionary/controllers/modal-controller.js +++ /dev/null @@ -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']) -) diff --git a/services/web/frontend/js/features/editor-left-menu/controllers/left-menu-documentation-controller.js b/services/web/frontend/js/features/editor-left-menu/controllers/left-menu-documentation-controller.js deleted file mode 100644 index 7f0d4798fb..0000000000 --- a/services/web/frontend/js/features/editor-left-menu/controllers/left-menu-documentation-controller.js +++ /dev/null @@ -1,10 +0,0 @@ -import App from '../../../base' - -export default App.controller( - 'LeftMenuDocumentationController', - function ($scope, eventTracking) { - $scope.sendLeftMenuDocumentationEvent = () => { - eventTracking.sendMB('left-menu-documentation-click') - } - } -) diff --git a/services/web/frontend/js/features/hotkeys-modal/controllers/hotkeys-modal-controller.js b/services/web/frontend/js/features/hotkeys-modal/controllers/hotkeys-modal-controller.js deleted file mode 100644 index 43fa47feb6..0000000000 --- a/services/web/frontend/js/features/hotkeys-modal/controllers/hotkeys-modal-controller.js +++ /dev/null @@ -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 - }) - } -}) diff --git a/services/web/frontend/js/features/word-count-modal/controllers/word-count-modal-controller.js b/services/web/frontend/js/features/word-count-modal/controllers/word-count-modal-controller.js deleted file mode 100644 index 84fcfd5dcd..0000000000 --- a/services/web/frontend/js/features/word-count-modal/controllers/word-count-modal-controller.js +++ /dev/null @@ -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) - ) -) diff --git a/services/web/frontend/js/ide.js b/services/web/frontend/js/ide.js index 9225d2965a..bea5d3af1d 100644 --- a/services/web/frontend/js/ide.js +++ b/services/web/frontend/js/ide.js @@ -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' diff --git a/services/web/frontend/js/ide/clone/controllers/CloneProjectController.js b/services/web/frontend/js/ide/clone/controllers/CloneProjectController.js deleted file mode 100644 index 8df47c961b..0000000000 --- a/services/web/frontend/js/ide/clone/controllers/CloneProjectController.js +++ /dev/null @@ -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', - })) -) diff --git a/services/web/frontend/js/ide/clone/controllers/CloneProjectModalController.js b/services/web/frontend/js/ide/clone/controllers/CloneProjectModalController.js deleted file mode 100644 index c7ed185b04..0000000000 --- a/services/web/frontend/js/ide/clone/controllers/CloneProjectModalController.js +++ /dev/null @@ -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')) - } -) diff --git a/services/web/frontend/js/ide/clone/index.js b/services/web/frontend/js/ide/clone/index.js deleted file mode 100644 index 8e23276be2..0000000000 --- a/services/web/frontend/js/ide/clone/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// Angular -import './controllers/CloneProjectController' -import './controllers/CloneProjectModalController' - -// React -import '../../features/clone-project-modal/controllers/left-menu-clone-project-modal-controller' diff --git a/services/web/frontend/js/ide/hotkeys/index.js b/services/web/frontend/js/ide/hotkeys/index.js deleted file mode 100644 index 1034bb05e4..0000000000 --- a/services/web/frontend/js/ide/hotkeys/index.js +++ /dev/null @@ -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' diff --git a/services/web/frontend/js/ide/settings/controllers/SettingsController.js b/services/web/frontend/js/ide/settings/controllers/SettingsController.js deleted file mode 100644 index c4e0b4c6b9..0000000000 --- a/services/web/frontend/js/ide/settings/controllers/SettingsController.js +++ /dev/null @@ -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 - }) - } -) diff --git a/services/web/frontend/js/ide/settings/index.js b/services/web/frontend/js/ide/settings/index.js deleted file mode 100644 index 1cde1c72db..0000000000 --- a/services/web/frontend/js/ide/settings/index.js +++ /dev/null @@ -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' diff --git a/services/web/frontend/js/ide/settings/services/settings.js b/services/web/frontend/js/ide/settings/services/settings.js deleted file mode 100644 index 8b96aeb017..0000000000 --- a/services/web/frontend/js/ide/settings/services/settings.js +++ /dev/null @@ -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) - }, -})) diff --git a/services/web/frontend/js/ide/wordcount/index.js b/services/web/frontend/js/ide/wordcount/index.js deleted file mode 100644 index 0a6113a914..0000000000 --- a/services/web/frontend/js/ide/wordcount/index.js +++ /dev/null @@ -1 +0,0 @@ -import '../../features/word-count-modal/controllers/word-count-modal-controller' diff --git a/services/web/frontend/js/shared/context/controllers/root-context-controller.js b/services/web/frontend/js/shared/context/controllers/root-context-controller.js index 4e393b53a3..19d98e92eb 100644 --- a/services/web/frontend/js/shared/context/controllers/root-context-controller.js +++ b/services/web/frontend/js/shared/context/controllers/root-context-controller.js @@ -4,5 +4,5 @@ import { rootContext } from '../root-context' App.component( 'sharedContextReact', - react2angular(rootContext.component, [], ['ide', 'settings']) + react2angular(rootContext.component, [], ['ide']) ) diff --git a/services/web/locales/en.json b/services/web/locales/en.json index 3c25851157..b11f9b0907 100644 --- a/services/web/locales/en.json +++ b/services/web/locales/en.json @@ -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.",