overleaf/services/web/frontend/js/ide/outline/controllers/OutlineController.js
Paulo Jorge Reis 4b90b09365 Merge pull request #2987 from overleaf/ta-outline-tracking
Add Event Tracking to Outline

GitOrigin-RevId: 239430ef0ff6ff67bf7c90291969cd28efde0d4a
2020-07-17 02:07:06 +00:00

32 lines
934 B
JavaScript

import App from '../../../base'
import OutlinePane from '../components/OutlinePane'
import { react2angular } from 'react2angular'
App.controller('OutlineController', function($scope, ide, eventTracking) {
$scope.isTexFile = false
$scope.outline = []
$scope.eventTracking = eventTracking
$scope.$on('outline-manager:outline-changed', onOutlineChange)
function onOutlineChange(e, outlineInfo) {
$scope.$applyAsync(() => {
$scope.isTexFile = outlineInfo.isTexFile
$scope.outline = outlineInfo.outline
})
}
$scope.jumpToLine = lineNo => {
ide.outlineManager.jumpToLine(lineNo)
eventTracking.sendMB('outline-jump-to-line')
}
$scope.onToggle = isOpen => {
$scope.$applyAsync(() => {
$scope.$emit('outline-toggled', isOpen)
})
}
})
// Wrap React component as Angular component. Only needed for "top-level" component
App.component('outlinePane', react2angular(OutlinePane))