base.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /* global MathJax */
  2. /* eslint-disable
  3. camelcase,
  4. max-len,
  5. no-useless-escape,
  6. */
  7. // TODO: This file was created by bulk-decaffeinate.
  8. // Fix any style issues and re-enable lint.
  9. /*
  10. * decaffeinate suggestions:
  11. * DS101: Remove unnecessary use of Array.from
  12. * DS102: Remove unnecessary code created because of implicit returns
  13. * DS103: Rewrite code to no longer use __guard__
  14. * DS207: Consider shorter variations of null checks
  15. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  16. */
  17. import './utils/webpack-public-path'
  18. import './libraries'
  19. import './infrastructure/error-reporter'
  20. import './modules/recursionHelper'
  21. import './modules/errorCatcher'
  22. import './modules/localStorage'
  23. import './modules/sessionStorage'
  24. import getMeta from './utils/meta'
  25. const App = angular
  26. .module('SharelatexApp', [
  27. 'ui.bootstrap',
  28. 'autocomplete',
  29. 'RecursionHelper',
  30. 'ng-context-menu',
  31. 'ngSanitize',
  32. 'ipCookie',
  33. 'ErrorCatcher',
  34. 'localStorage',
  35. 'sessionStorage',
  36. 'ui.select',
  37. ])
  38. .config(function ($qProvider, $httpProvider, uiSelectConfig) {
  39. $qProvider.errorOnUnhandledRejections(false)
  40. uiSelectConfig.spinnerClass = 'fa fa-refresh ui-select-spin'
  41. return __guard__(
  42. typeof MathJax !== 'undefined' && MathJax !== null
  43. ? MathJax.Hub
  44. : undefined,
  45. x =>
  46. x.Config({
  47. messageStyle: 'none',
  48. imageFont: null,
  49. // Fast preview, introduced in 2.5, is unhelpful due to extra codemirror refresh
  50. // and disabling it avoids issues with math processing errors
  51. // github.com/overleaf/write_latex/pull/1375
  52. 'fast-preview': { disabled: true },
  53. 'HTML-CSS': {
  54. availableFonts: ['TeX'],
  55. // MathJax's automatic font scaling does not work well when we render math
  56. // that isn't yet on the page, so we disable it and set a global font
  57. // scale factor
  58. scale: 110,
  59. matchFontHeight: false,
  60. },
  61. TeX: {
  62. equationNumbers: { autoNumber: 'AMS' },
  63. useLabelIDs: false,
  64. },
  65. skipStartupTypeset: true,
  66. tex2jax: {
  67. processEscapes: true,
  68. // Dollar delimiters are added by the mathjax directive
  69. inlineMath: [['\\(', '\\)']],
  70. displayMath: [
  71. ['$$', '$$'],
  72. ['\\[', '\\]'],
  73. ],
  74. },
  75. })
  76. )
  77. })
  78. App.run(($rootScope, $templateCache) => {
  79. $rootScope.usersEmail = getMeta('ol-usersEmail')
  80. // UI Select templates are hard-coded and use Glyphicon icons (which we don't import).
  81. // The line below simply overrides the hard-coded template with our own, which is
  82. // basically the same but using Font Awesome icons.
  83. $templateCache.put(
  84. 'bootstrap/match.tpl.html',
  85. '<div class="ui-select-match" ng-hide="$select.open && $select.searchEnabled" ng-disabled="$select.disabled" ng-class="{\'btn-default-focus\':$select.focus}"><span tabindex="-1" class="btn btn-default form-control ui-select-toggle" aria-label="{{ $select.baseTitle }} activate" ng-disabled="$select.disabled" ng-click="$select.activate()" style="outline: 0;"><span ng-show="$select.isEmpty()" class="ui-select-placeholder text-muted">{{$select.placeholder}}</span> <span ng-hide="$select.isEmpty()" class="ui-select-match-text pull-left" ng-class="{\'ui-select-allow-clear\': $select.allowClear && !$select.isEmpty()}" ng-transclude=""></span> <i class="caret pull-right" ng-click="$select.toggle($event)"></i> <a ng-show="$select.allowClear && !$select.isEmpty() && ($select.disabled !== true)" aria-label="{{ $select.baseTitle }} clear" style="margin-right: 10px" ng-click="$select.clear($event)" class="btn btn-xs btn-link pull-right"><i class="fa fa-times" aria-hidden="true"></i></a></span></div>'
  86. )
  87. })
  88. const sl_debugging = window.location.search.match(/debug=true/)
  89. window.sl_debugging = sl_debugging // make a global flag for debugging code
  90. window.sl_console = sl_debugging ? console : { log() {} }
  91. export default App
  92. function __guard__(value, transform) {
  93. return typeof value !== 'undefined' && value !== null
  94. ? transform(value)
  95. : undefined
  96. }