mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-13 17:37:09 +00:00
Merge pull request #2470 from overleaf/cmg-file-tree-highlight
Expand folder to show highlighted file in file tree GitOrigin-RevId: 7fb9174fd71eb362655bcabf2f7884597aebee47
This commit is contained in:
parent
587c4ba129
commit
84f81d0eac
3 changed files with 29 additions and 6 deletions
|
@ -17,7 +17,12 @@ define(['base', 'ide/file-tree/util/iconTypeFromName'], function(
|
|||
App,
|
||||
iconTypeFromName
|
||||
) {
|
||||
App.controller('FileTreeEntityController', function($scope, ide, $modal) {
|
||||
App.controller('FileTreeEntityController', function(
|
||||
$scope,
|
||||
ide,
|
||||
$modal,
|
||||
$element
|
||||
) {
|
||||
$scope.select = function(e) {
|
||||
if (e.ctrlKey || e.metaKey) {
|
||||
e.stopPropagation()
|
||||
|
@ -33,6 +38,17 @@ define(['base', 'ide/file-tree/util/iconTypeFromName'], function(
|
|||
}
|
||||
}
|
||||
|
||||
if ($scope.entity.type === 'doc') {
|
||||
$scope.$watch('entity.selected', function(isSelected) {
|
||||
if (isSelected) {
|
||||
$scope.$emit('entity-file:selected', $scope.entity)
|
||||
$scope.$applyAsync(function() {
|
||||
$element[0].scrollIntoView()
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
$scope.draggableHelper = function() {
|
||||
if (ide.fileTreeManager.multiSelectedCount() > 0) {
|
||||
return $(
|
||||
|
|
|
@ -25,10 +25,16 @@ define(['base'], App =>
|
|||
|
||||
$scope.toggleExpanded = function() {
|
||||
$scope.expanded = !$scope.expanded
|
||||
return localStorage(
|
||||
`folder.${$scope.entity.id}.expanded`,
|
||||
$scope.expanded
|
||||
)
|
||||
$scope._storeCurrentStateInLocalStorage()
|
||||
}
|
||||
|
||||
$scope.$on('entity-file:selected', function() {
|
||||
$scope.expanded = true
|
||||
$scope._storeCurrentStateInLocalStorage()
|
||||
})
|
||||
|
||||
$scope._storeCurrentStateInLocalStorage = function() {
|
||||
localStorage(`folder.${$scope.entity.id}.expanded`, $scope.expanded)
|
||||
}
|
||||
|
||||
$scope.onDrop = function(events, ui) {
|
||||
|
|
|
@ -1017,7 +1017,8 @@ define([
|
|||
}
|
||||
ide.editorManager.openDoc(entity, {
|
||||
gotoLine: line,
|
||||
gotoColumn: column
|
||||
gotoColumn: column,
|
||||
forceReopen: true
|
||||
})
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Add table
Reference in a new issue