2018-11-05 05:06:39 -05:00
|
|
|
/* eslint-disable
|
|
|
|
camelcase,
|
|
|
|
max-len,
|
|
|
|
no-cond-assign,
|
|
|
|
no-return-assign,
|
|
|
|
no-unused-vars,
|
|
|
|
no-useless-escape,
|
|
|
|
*/
|
|
|
|
// 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
|
|
|
|
* DS103: Rewrite code to no longer use __guard__
|
|
|
|
* DS207: Consider shorter variations of null checks
|
|
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
|
|
*/
|
2020-05-19 05:02:56 -04:00
|
|
|
import App from './base'
|
|
|
|
import FileTreeManager from './ide/file-tree/FileTreeManager'
|
2020-09-03 05:23:34 -04:00
|
|
|
import LoadingManager from './ide/LoadingManager'
|
2020-05-19 05:02:56 -04:00
|
|
|
import ConnectionManager from './ide/connection/ConnectionManager'
|
|
|
|
import EditorManager from './ide/editor/EditorManager'
|
|
|
|
import OnlineUsersManager from './ide/online-users/OnlineUsersManager'
|
|
|
|
import HistoryManager from './ide/history/HistoryManager'
|
|
|
|
import HistoryV2Manager from './ide/history/HistoryV2Manager'
|
|
|
|
import PermissionsManager from './ide/permissions/PermissionsManager'
|
|
|
|
import BinaryFilesManager from './ide/binary-files/BinaryFilesManager'
|
|
|
|
import ReferencesManager from './ide/references/ReferencesManager'
|
|
|
|
import MetadataManager from './ide/metadata/MetadataManager'
|
2022-03-15 08:47:01 -04:00
|
|
|
import './ide/review-panel/ReviewPanelManager'
|
2020-09-01 04:09:04 -04:00
|
|
|
import OutlineManager from './features/outline/outline-manager'
|
2020-05-19 05:02:56 -04:00
|
|
|
import SafariScrollPatcher from './ide/SafariScrollPatcher'
|
|
|
|
import './ide/cobranding/CobrandingDataService'
|
|
|
|
import './ide/settings/index'
|
|
|
|
import './ide/chat/index'
|
|
|
|
import './ide/clone/index'
|
2021-06-10 07:26:04 -04:00
|
|
|
import './ide/file-view/index'
|
2020-05-19 05:02:56 -04:00
|
|
|
import './ide/hotkeys/index'
|
|
|
|
import './ide/wordcount/index'
|
|
|
|
import './ide/directives/layout'
|
|
|
|
import './ide/directives/validFile'
|
2020-07-16 06:09:01 -04:00
|
|
|
import './ide/directives/verticalResizablePanes'
|
2020-05-19 05:02:56 -04:00
|
|
|
import './ide/services/ide'
|
|
|
|
import './directives/focus'
|
|
|
|
import './directives/fineUpload'
|
|
|
|
import './directives/scroll'
|
|
|
|
import './directives/onEnter'
|
|
|
|
import './directives/stopPropagation'
|
|
|
|
import './directives/rightClick'
|
|
|
|
import './directives/expandableTextArea'
|
|
|
|
import './directives/videoPlayState'
|
|
|
|
import './services/queued-http'
|
|
|
|
import './services/validateCaptcha'
|
|
|
|
import './services/validateCaptchaV3'
|
|
|
|
import './services/wait-for'
|
|
|
|
import './filters/formatDate'
|
|
|
|
import './main/event'
|
2021-01-14 10:16:54 -05:00
|
|
|
import './main/account-upgrade-angular'
|
2020-05-19 05:02:56 -04:00
|
|
|
import './main/system-messages'
|
|
|
|
import '../../modules/modules-ide.js'
|
2021-01-27 05:30:55 -05:00
|
|
|
import './shared/context/controllers/root-context-controller'
|
|
|
|
import './features/editor-navigation-toolbar/controllers/editor-navigation-toolbar-controller'
|
2021-09-03 05:06:28 -04:00
|
|
|
import './features/pdf-preview/controllers/pdf-preview-controller'
|
2021-06-07 05:43:26 -04:00
|
|
|
import './features/share-project-modal/controllers/react-share-project-modal-controller'
|
2022-02-21 06:16:49 -05:00
|
|
|
import './features/source-editor/controllers/editor-switch-controller'
|
2022-11-03 10:24:13 -04:00
|
|
|
import './features/source-editor/controllers/cm6-switch-away-survey-controller'
|
2022-11-15 13:10:05 -05:00
|
|
|
import './features/source-editor/controllers/grammarly-warning-controller'
|
2022-07-08 04:15:13 -04:00
|
|
|
import { cleanupServiceWorker } from './utils/service-worker-cleanup'
|
2022-10-12 06:17:24 -04:00
|
|
|
import { reportCM6Perf } from './infrastructure/cm6-performance'
|
2022-12-06 09:52:50 -05:00
|
|
|
import { reportAcePerf } from './ide/editor/ace-performance'
|
2020-12-14 06:44:10 -05:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
App.controller(
|
|
|
|
'IdeController',
|
|
|
|
function (
|
|
|
|
$scope,
|
|
|
|
$timeout,
|
|
|
|
ide,
|
|
|
|
localStorage,
|
|
|
|
eventTracking,
|
|
|
|
metadata,
|
|
|
|
$q,
|
2022-02-08 04:22:06 -05:00
|
|
|
CobrandingDataService,
|
|
|
|
$window
|
2021-04-14 09:17:21 -04:00
|
|
|
) {
|
|
|
|
// Don't freak out if we're already in an apply callback
|
|
|
|
let err, pdfLayout, userAgent
|
|
|
|
$scope.$originalApply = $scope.$apply
|
|
|
|
$scope.$apply = function (fn) {
|
|
|
|
if (fn == null) {
|
|
|
|
fn = function () {}
|
|
|
|
}
|
|
|
|
const phase = this.$root.$$phase
|
|
|
|
if (phase === '$apply' || phase === '$digest') {
|
|
|
|
return fn()
|
|
|
|
} else {
|
|
|
|
return this.$originalApply(fn)
|
|
|
|
}
|
2018-11-07 06:28:56 -05:00
|
|
|
}
|
2020-05-19 05:02:56 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
$scope.state = {
|
|
|
|
loading: true,
|
|
|
|
load_progress: 40,
|
2021-04-27 03:52:58 -04:00
|
|
|
error: null,
|
2021-04-14 09:17:21 -04:00
|
|
|
}
|
|
|
|
$scope.ui = {
|
|
|
|
leftMenuShown: false,
|
|
|
|
view: 'editor',
|
|
|
|
chatOpen: false,
|
|
|
|
pdfLayout: 'sideBySide',
|
|
|
|
pdfHidden: false,
|
|
|
|
pdfWidth: 0,
|
|
|
|
reviewPanelOpen: localStorage(`ui.reviewPanelOpen.${window.project_id}`),
|
|
|
|
miniReviewPanelVisible: false,
|
|
|
|
chatResizerSizeOpen: 7,
|
2021-04-27 03:52:58 -04:00
|
|
|
chatResizerSizeClosed: 0,
|
2021-04-14 09:17:21 -04:00
|
|
|
}
|
|
|
|
$scope.user = window.user
|
|
|
|
|
|
|
|
$scope.settings = window.userSettings
|
|
|
|
$scope.anonymous = window.anonymous
|
|
|
|
$scope.isTokenMember = window.isTokenMember
|
|
|
|
$scope.isRestrictedTokenMember = window.isRestrictedTokenMember
|
|
|
|
|
|
|
|
$scope.cobranding = {
|
|
|
|
isProjectCobranded: CobrandingDataService.isProjectCobranded(),
|
|
|
|
logoImgUrl: CobrandingDataService.getLogoImgUrl(),
|
|
|
|
submitBtnHtml: CobrandingDataService.getSubmitBtnHtml(),
|
|
|
|
brandVariationName: CobrandingDataService.getBrandVariationName(),
|
2021-04-27 03:52:58 -04:00
|
|
|
brandVariationHomeUrl: CobrandingDataService.getBrandVariationHomeUrl(),
|
2021-04-14 09:17:21 -04:00
|
|
|
}
|
2020-05-19 05:02:56 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
$scope.chat = {}
|
2020-05-19 05:02:56 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
ide.toggleReviewPanel = $scope.toggleReviewPanel = function () {
|
2022-06-21 08:15:35 -04:00
|
|
|
$scope.$applyAsync(() => {
|
|
|
|
if (!$scope.project.features.trackChangesVisible) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
$scope.ui.reviewPanelOpen = !$scope.ui.reviewPanelOpen
|
|
|
|
eventTracking.sendMB('rp-toggle-panel', {
|
|
|
|
value: $scope.ui.reviewPanelOpen,
|
|
|
|
})
|
2021-04-14 09:17:21 -04:00
|
|
|
})
|
2018-11-05 05:06:39 -05:00
|
|
|
}
|
2021-04-14 09:17:21 -04:00
|
|
|
|
|
|
|
$scope.$watch('ui.reviewPanelOpen', function (value) {
|
|
|
|
if (value != null) {
|
|
|
|
return localStorage(`ui.reviewPanelOpen.${window.project_id}`, value)
|
|
|
|
}
|
2018-11-05 05:06:39 -05:00
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
$scope.$on('layout:pdf:resize', function (_, layoutState) {
|
|
|
|
$scope.ui.pdfHidden = layoutState.east.initClosed
|
|
|
|
return ($scope.ui.pdfWidth = layoutState.east.size)
|
|
|
|
})
|
2018-11-05 05:06:39 -05:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
$scope.$watch('ui.view', function (newView, oldView) {
|
|
|
|
if (newView !== oldView) {
|
|
|
|
$scope.$broadcast('layout:flat-screen:toggle')
|
|
|
|
}
|
|
|
|
if (newView != null && newView !== 'editor' && newView !== 'pdf') {
|
2021-06-03 09:38:54 -04:00
|
|
|
eventTracking.sendMBOnce(`ide-open-view-${newView}-once`)
|
2021-04-14 09:17:21 -04:00
|
|
|
}
|
|
|
|
})
|
2018-11-05 05:06:39 -05:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
$scope.$watch('ui.chatOpen', function (isOpen) {
|
|
|
|
if (isOpen) {
|
2021-06-03 09:38:54 -04:00
|
|
|
eventTracking.sendMBOnce('ide-open-chat-once')
|
2021-04-14 09:17:21 -04:00
|
|
|
}
|
|
|
|
})
|
2018-11-05 05:06:39 -05:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
$scope.$watch('ui.leftMenuShown', function (isOpen) {
|
|
|
|
if (isOpen) {
|
2021-06-03 09:38:54 -04:00
|
|
|
eventTracking.sendMBOnce('ide-open-left-menu-once')
|
2021-04-14 09:17:21 -04:00
|
|
|
}
|
|
|
|
})
|
2019-02-13 04:02:10 -05:00
|
|
|
|
2021-06-03 09:38:54 -04:00
|
|
|
$scope.trackHover = feature => {
|
2021-04-14 09:17:21 -04:00
|
|
|
eventTracking.sendMBOnce(`ide-hover-${feature}-once`)
|
2021-06-03 09:38:54 -04:00
|
|
|
}
|
2021-04-14 09:17:21 -04:00
|
|
|
// End of tracking code.
|
|
|
|
|
|
|
|
window._ide = ide
|
|
|
|
|
|
|
|
ide.validFileRegex = '^[^*/]*$' // Don't allow * and /
|
|
|
|
|
2021-05-05 09:05:04 -04:00
|
|
|
const useFallbackWebsocket =
|
2021-04-14 09:17:21 -04:00
|
|
|
window.location &&
|
|
|
|
window.location.search &&
|
|
|
|
window.location.search.match(/ws=fallback/)
|
|
|
|
// if we previously failed to load the websocket fall back to null (the siteUrl)
|
|
|
|
ide.wsUrl = useFallbackWebsocket ? null : window.sharelatex.wsUrl || null // websocket url (if defined)
|
|
|
|
|
|
|
|
ide.project_id = $scope.project_id = window.project_id
|
|
|
|
ide.$scope = $scope
|
|
|
|
|
|
|
|
ide.referencesSearchManager = new ReferencesManager(ide, $scope)
|
|
|
|
ide.loadingManager = new LoadingManager($scope)
|
|
|
|
ide.connectionManager = new ConnectionManager(ide, $scope)
|
|
|
|
ide.fileTreeManager = new FileTreeManager(ide, $scope)
|
2021-05-17 07:50:19 -04:00
|
|
|
ide.editorManager = new EditorManager(
|
|
|
|
ide,
|
|
|
|
$scope,
|
|
|
|
localStorage,
|
|
|
|
eventTracking
|
|
|
|
)
|
2021-04-14 09:17:21 -04:00
|
|
|
ide.onlineUsersManager = new OnlineUsersManager(ide, $scope)
|
|
|
|
if (window.data.useV2History) {
|
|
|
|
ide.historyManager = new HistoryV2Manager(ide, $scope, localStorage)
|
|
|
|
} else {
|
|
|
|
ide.historyManager = new HistoryManager(ide, $scope)
|
2018-11-05 05:06:39 -05:00
|
|
|
}
|
2021-04-14 09:17:21 -04:00
|
|
|
ide.permissionsManager = new PermissionsManager(ide, $scope)
|
|
|
|
ide.binaryFilesManager = new BinaryFilesManager(ide, $scope)
|
|
|
|
ide.metadataManager = new MetadataManager(ide, $scope, metadata)
|
|
|
|
ide.outlineManager = new OutlineManager(ide, $scope)
|
|
|
|
|
|
|
|
let inited = false
|
|
|
|
$scope.$on('project:joined', function () {
|
|
|
|
if (inited) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
inited = true
|
|
|
|
if (
|
|
|
|
__guard__(
|
|
|
|
$scope != null ? $scope.project : undefined,
|
|
|
|
x => x.deletedByExternalDataSource
|
|
|
|
)
|
|
|
|
) {
|
|
|
|
ide.showGenericMessageModal(
|
|
|
|
'Project Renamed or Deleted',
|
|
|
|
`\
|
2018-11-05 05:06:39 -05:00
|
|
|
This project has either been renamed or deleted by an external data source such as Dropbox.
|
2020-01-06 10:35:12 -05:00
|
|
|
We don't want to delete your data on Overleaf, so this project still contains your history and collaborators.
|
2018-11-05 05:06:39 -05:00
|
|
|
If the project has been renamed please look in your project list for a new project under the new name.\
|
|
|
|
`
|
2021-04-14 09:17:21 -04:00
|
|
|
)
|
2018-11-05 05:06:39 -05:00
|
|
|
}
|
2021-04-14 09:17:21 -04:00
|
|
|
return $timeout(function () {
|
|
|
|
if ($scope.permissions.write) {
|
|
|
|
let _labelsInitialLoadDone
|
|
|
|
ide.metadataManager.loadProjectMetaFromServer()
|
|
|
|
return (_labelsInitialLoadDone = true)
|
|
|
|
}
|
|
|
|
}, 200)
|
|
|
|
})
|
2018-11-05 05:06:39 -05:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
// Count the first 'doc:opened' as a sign that the ide is loaded
|
|
|
|
// and broadcast a message. This is a good event to listen for
|
|
|
|
// if you want to wait until the ide is fully loaded and initialized
|
|
|
|
let _loaded = false
|
|
|
|
$scope.$on('doc:opened', function () {
|
|
|
|
if (_loaded) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
$scope.$broadcast('ide:loaded')
|
|
|
|
return (_loaded = true)
|
|
|
|
})
|
2018-11-05 05:06:39 -05:00
|
|
|
|
2022-02-08 04:22:06 -05:00
|
|
|
ide.editingSessionHeartbeat = () => {
|
2022-10-12 06:17:24 -04:00
|
|
|
eventTracking.editingSessionHeartbeat(() => {
|
|
|
|
const editorType = ide.editorManager.getEditorType()
|
|
|
|
|
|
|
|
const segmentation = {
|
|
|
|
editorType,
|
|
|
|
}
|
|
|
|
|
|
|
|
if (editorType === 'cm6') {
|
|
|
|
const cm6PerfData = reportCM6Perf()
|
|
|
|
|
|
|
|
// Ignore if no typing has happened
|
|
|
|
if (cm6PerfData.numberOfEntries > 0) {
|
2022-10-28 06:10:38 -04:00
|
|
|
const perfProps = [
|
|
|
|
'Max',
|
|
|
|
'Mean',
|
|
|
|
'Median',
|
|
|
|
'NinetyFifthPercentile',
|
|
|
|
'DocLength',
|
|
|
|
'NumberOfEntries',
|
|
|
|
'MaxUserEventsBetweenDomUpdates',
|
|
|
|
'Grammarly',
|
|
|
|
'SessionLength',
|
|
|
|
'Memory',
|
2022-11-01 06:37:00 -04:00
|
|
|
'Lags',
|
|
|
|
'NonLags',
|
|
|
|
'LongestLag',
|
|
|
|
'MeanLagsPerMeasure',
|
|
|
|
'MeanKeypressesPerMeasure',
|
2022-11-10 07:12:12 -05:00
|
|
|
'MeanKeypressPaint',
|
2022-11-29 05:09:36 -05:00
|
|
|
'LongTasks',
|
|
|
|
'Release',
|
2022-10-28 06:10:38 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
for (const prop of perfProps) {
|
|
|
|
const perfValue =
|
|
|
|
cm6PerfData[prop.charAt(0).toLowerCase() + prop.slice(1)]
|
|
|
|
if (perfValue !== null) {
|
|
|
|
segmentation['cm6Perf' + prop] = perfValue
|
|
|
|
}
|
|
|
|
}
|
2022-10-12 06:17:24 -04:00
|
|
|
}
|
2022-12-06 09:52:50 -05:00
|
|
|
} else if (editorType === 'ace') {
|
|
|
|
const acePerfData = reportAcePerf()
|
|
|
|
|
|
|
|
if (acePerfData.numberOfEntries > 0) {
|
|
|
|
const perfProps = [
|
|
|
|
'NumberOfEntries',
|
|
|
|
'MeanKeypressPaint',
|
|
|
|
'Grammarly',
|
|
|
|
'SessionLength',
|
|
|
|
'Memory',
|
2022-12-08 06:43:55 -05:00
|
|
|
'Lags',
|
|
|
|
'NonLags',
|
|
|
|
'LongestLag',
|
|
|
|
'MeanLagsPerMeasure',
|
|
|
|
'MeanKeypressesPerMeasure',
|
2022-12-06 09:52:50 -05:00
|
|
|
'Release',
|
|
|
|
]
|
|
|
|
|
|
|
|
for (const prop of perfProps) {
|
|
|
|
const perfValue =
|
|
|
|
acePerfData[prop.charAt(0).toLowerCase() + prop.slice(1)]
|
|
|
|
if (perfValue !== null) {
|
|
|
|
segmentation['acePerf' + prop] = perfValue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-10-12 06:17:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return segmentation
|
|
|
|
})
|
2022-02-08 04:22:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
$scope.$on('cursor:editor:update', () => {
|
|
|
|
ide.editingSessionHeartbeat()
|
|
|
|
})
|
|
|
|
$scope.$on('scroll:editor:update', () => {
|
|
|
|
ide.editingSessionHeartbeat()
|
|
|
|
})
|
|
|
|
|
|
|
|
angular.element($window).on('click', ide.editingSessionHeartbeat)
|
|
|
|
|
|
|
|
$scope.$on('$destroy', () =>
|
|
|
|
angular.element($window).off('click', ide.editingSessionHeartbeat)
|
|
|
|
)
|
2021-04-14 09:17:21 -04:00
|
|
|
|
|
|
|
const DARK_THEMES = [
|
|
|
|
'ambiance',
|
|
|
|
'chaos',
|
|
|
|
'clouds_midnight',
|
|
|
|
'cobalt',
|
|
|
|
'idle_fingers',
|
|
|
|
'merbivore',
|
|
|
|
'merbivore_soft',
|
|
|
|
'mono_industrial',
|
|
|
|
'monokai',
|
|
|
|
'pastel_on_dark',
|
|
|
|
'solarized_dark',
|
|
|
|
'terminal',
|
|
|
|
'tomorrow_night',
|
|
|
|
'tomorrow_night_blue',
|
|
|
|
'tomorrow_night_bright',
|
|
|
|
'tomorrow_night_eighties',
|
|
|
|
'twilight',
|
2021-04-27 03:52:58 -04:00
|
|
|
'vibrant_ink',
|
2021-04-14 09:17:21 -04:00
|
|
|
]
|
|
|
|
$scope.darkTheme = false
|
|
|
|
$scope.$watch('settings.editorTheme', function (theme) {
|
|
|
|
if (Array.from(DARK_THEMES).includes(theme)) {
|
|
|
|
return ($scope.darkTheme = true)
|
|
|
|
} else {
|
|
|
|
return ($scope.darkTheme = false)
|
|
|
|
}
|
|
|
|
})
|
2018-11-05 05:06:39 -05:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
ide.localStorage = localStorage
|
2018-11-05 05:06:39 -05:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
ide.browserIsSafari = false
|
2018-11-05 05:06:39 -05:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
$scope.switchToFlatLayout = function (view) {
|
|
|
|
$scope.ui.pdfLayout = 'flat'
|
|
|
|
$scope.ui.view = view
|
|
|
|
return ide.localStorage('pdf.layout', 'flat')
|
2018-11-05 05:06:39 -05:00
|
|
|
}
|
2021-04-14 09:17:21 -04:00
|
|
|
|
|
|
|
$scope.switchToSideBySideLayout = function (view) {
|
|
|
|
$scope.ui.pdfLayout = 'sideBySide'
|
|
|
|
$scope.ui.view = view
|
|
|
|
return localStorage('pdf.layout', 'split')
|
2018-11-05 05:06:39 -05:00
|
|
|
}
|
2020-05-19 05:02:56 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
if ((pdfLayout = localStorage('pdf.layout'))) {
|
|
|
|
if (pdfLayout === 'split') {
|
|
|
|
$scope.switchToSideBySideLayout()
|
|
|
|
}
|
|
|
|
if (pdfLayout === 'flat') {
|
|
|
|
$scope.switchToFlatLayout()
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$scope.switchToSideBySideLayout()
|
|
|
|
}
|
2020-05-19 05:02:56 -04:00
|
|
|
|
2022-05-20 04:15:14 -04:00
|
|
|
// Update ui.pdfOpen when the layout changes.
|
|
|
|
// The east pane should open when the layout changes from "Editor only" or "PDF only" to "Editor & PDF".
|
|
|
|
$scope.$watch('ui.pdfLayout', value => {
|
|
|
|
$scope.ui.pdfOpen = value === 'sideBySide'
|
|
|
|
})
|
|
|
|
|
|
|
|
// Update ui.pdfLayout when the east pane is toggled.
|
|
|
|
// The layout should be set to "Editor & PDF" (sideBySide) when the east pane is opened, and "Editor only" (flat) when the east pane is closed.
|
|
|
|
$scope.$watch('ui.pdfOpen', value => {
|
|
|
|
$scope.ui.pdfLayout = value ? 'sideBySide' : 'flat'
|
|
|
|
if (value) {
|
|
|
|
window.dispatchEvent(new CustomEvent('ui:pdf-open'))
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2022-11-28 06:57:54 -05:00
|
|
|
$scope.handleKeyDown = () => {
|
|
|
|
// unused?
|
2021-09-14 04:54:47 -04:00
|
|
|
}
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
try {
|
|
|
|
;({ userAgent } = navigator)
|
|
|
|
ide.browserIsSafari =
|
|
|
|
userAgent &&
|
|
|
|
/.*Safari\/.*/.test(userAgent) &&
|
|
|
|
!/.*Chrome\/.*/.test(userAgent) &&
|
|
|
|
!/.*Chromium\/.*/.test(userAgent)
|
|
|
|
} catch (error) {
|
|
|
|
err = error
|
|
|
|
console.error(err)
|
|
|
|
}
|
2020-05-19 05:02:56 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
if (ide.browserIsSafari) {
|
|
|
|
ide.safariScrollPatcher = new SafariScrollPatcher($scope)
|
2018-11-05 05:06:39 -05:00
|
|
|
}
|
2020-05-19 05:02:56 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
// Fix Chrome 61 and 62 text-shadow rendering
|
|
|
|
let browserIsChrome61or62 = false
|
|
|
|
try {
|
|
|
|
const chromeVersion =
|
|
|
|
parseFloat(navigator.userAgent.split(' Chrome/')[1]) || null
|
|
|
|
browserIsChrome61or62 = chromeVersion != null
|
|
|
|
if (browserIsChrome61or62) {
|
|
|
|
document.styleSheets[0].insertRule(
|
|
|
|
'.ace_editor.ace_autocomplete .ace_completion-highlight { text-shadow: none !important; font-weight: bold; }',
|
|
|
|
1
|
|
|
|
)
|
|
|
|
}
|
|
|
|
} catch (error1) {
|
|
|
|
err = error1
|
|
|
|
console.error(err)
|
2018-11-05 05:06:39 -05:00
|
|
|
}
|
2021-04-14 09:17:21 -04:00
|
|
|
|
|
|
|
// User can append ?ft=somefeature to url to activate a feature toggle
|
|
|
|
ide.featureToggle = __guard__(
|
|
|
|
__guard__(
|
|
|
|
typeof location !== 'undefined' && location !== null
|
|
|
|
? location.search
|
|
|
|
: undefined,
|
|
|
|
x1 => x1.match(/^\?ft=(\w+)$/)
|
|
|
|
),
|
|
|
|
x => x[1]
|
|
|
|
)
|
|
|
|
|
2022-02-08 04:22:20 -05:00
|
|
|
// Listen for editor:lint event from CM6 linter
|
|
|
|
window.addEventListener('editor:lint', event => {
|
|
|
|
$scope.hasLintingError = event.detail.hasLintingError
|
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
return ide.socket.on('project:publicAccessLevel:changed', data => {
|
|
|
|
if (data.newAccessLevel != null) {
|
|
|
|
ide.$scope.project.publicAccesLevel = data.newAccessLevel
|
|
|
|
return $scope.$digest()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
)
|
2018-11-05 05:06:39 -05:00
|
|
|
|
2022-07-08 04:15:13 -04:00
|
|
|
cleanupServiceWorker()
|
2021-05-17 05:38:18 -04:00
|
|
|
|
2021-12-02 10:18:47 -05:00
|
|
|
angular.module('SharelatexApp').config(function ($provide) {
|
|
|
|
$provide.decorator('$browser', [
|
|
|
|
'$delegate',
|
|
|
|
function ($delegate) {
|
|
|
|
$delegate.onUrlChange = function () {}
|
|
|
|
$delegate.url = function () {
|
|
|
|
return ''
|
|
|
|
}
|
|
|
|
return $delegate
|
|
|
|
},
|
|
|
|
])
|
|
|
|
})
|
2021-11-15 11:33:57 -05:00
|
|
|
|
2020-05-19 05:02:56 -04:00
|
|
|
export default angular.bootstrap(document.body, ['SharelatexApp'])
|
|
|
|
|
2018-11-05 05:06:39 -05:00
|
|
|
function __guard__(value, transform) {
|
|
|
|
return typeof value !== 'undefined' && value !== null
|
|
|
|
? transform(value)
|
|
|
|
: undefined
|
|
|
|
}
|