2020-06-29 09:05:08 -04:00
|
|
|
import App from '../../../base'
|
2020-09-01 04:09:04 -04:00
|
|
|
import OutlinePane from '../components/outline-pane'
|
2020-06-29 09:05:08 -04:00
|
|
|
import { react2angular } from 'react2angular'
|
2020-12-14 06:44:10 -05:00
|
|
|
import { rootContext } from '../../../shared/context/root-context'
|
2020-06-29 09:05:08 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
App.controller('OutlineController', function ($scope, ide, eventTracking) {
|
2020-06-29 09:05:08 -04:00
|
|
|
$scope.isTexFile = false
|
|
|
|
$scope.outline = []
|
2020-07-16 10:04:04 -04:00
|
|
|
$scope.eventTracking = eventTracking
|
2020-06-29 09:05:08 -04:00
|
|
|
|
2022-11-03 08:43:59 -04:00
|
|
|
function shouldShowOutline() {
|
|
|
|
if ($scope.editor.showRichText) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return !$scope.editor.newSourceEditor
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.show = shouldShowOutline()
|
|
|
|
|
|
|
|
$scope.$watch('editor.newSourceEditor', function () {
|
|
|
|
$scope.show = shouldShowOutline()
|
|
|
|
})
|
|
|
|
|
|
|
|
$scope.$watch('editor.showRichText', function () {
|
|
|
|
$scope.show = shouldShowOutline()
|
|
|
|
})
|
|
|
|
|
2020-06-29 09:05:08 -04:00
|
|
|
$scope.$on('outline-manager:outline-changed', onOutlineChange)
|
|
|
|
|
|
|
|
function onOutlineChange(e, outlineInfo) {
|
|
|
|
$scope.$applyAsync(() => {
|
|
|
|
$scope.isTexFile = outlineInfo.isTexFile
|
|
|
|
$scope.outline = outlineInfo.outline
|
2020-07-28 05:37:46 -04:00
|
|
|
$scope.highlightedLine = outlineInfo.highlightedLine
|
2020-06-29 09:05:08 -04:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-08-24 08:20:54 -04:00
|
|
|
$scope.jumpToLine = (lineNo, syncToPdf) => {
|
|
|
|
ide.outlineManager.jumpToLine(lineNo, syncToPdf)
|
2020-07-16 10:04:04 -04:00
|
|
|
eventTracking.sendMB('outline-jump-to-line')
|
2020-06-29 09:05:08 -04:00
|
|
|
}
|
2020-07-16 06:09:01 -04:00
|
|
|
|
|
|
|
$scope.onToggle = isOpen => {
|
|
|
|
$scope.$applyAsync(() => {
|
|
|
|
$scope.$emit('outline-toggled', isOpen)
|
|
|
|
})
|
|
|
|
}
|
2020-06-29 09:05:08 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
// Wrap React component as Angular component. Only needed for "top-level" component
|
2020-12-14 06:44:10 -05:00
|
|
|
App.component(
|
|
|
|
'outlinePane',
|
|
|
|
react2angular(rootContext.use(OutlinePane), [
|
|
|
|
'outline',
|
|
|
|
'jumpToLine',
|
|
|
|
'highlightedLine',
|
|
|
|
'eventTracking',
|
|
|
|
'onToggle',
|
2021-04-27 03:52:58 -04:00
|
|
|
'isTexFile',
|
2022-11-03 08:43:59 -04:00
|
|
|
'show',
|
2020-12-14 06:44:10 -05:00
|
|
|
])
|
|
|
|
)
|