mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 06:03:45 +01:00
Store cursor & line position when switching editor
When tearing down the source editor, we need to store the updated cursor position, so that the position can be moved to when opening the rich text editor.
This commit is contained in:
@@ -516,6 +516,7 @@ define [
|
||||
|
||||
scope.$on '$destroy', () ->
|
||||
if scope.sharejsDoc?
|
||||
scope.$broadcast('changeEditor')
|
||||
tearDownSpellCheck()
|
||||
tearDownCursorPosition()
|
||||
detachFromAce(scope.sharejsDoc)
|
||||
|
||||
+7
-3
@@ -3,12 +3,12 @@ define [], () ->
|
||||
constructor: (@$scope, @adapter, @localStorage) ->
|
||||
@$scope.$on 'editorInit', @jumpToPositionInNewDoc
|
||||
|
||||
@$scope.$on 'beforeChangeDocument', () =>
|
||||
@storeCursorPosition()
|
||||
@storeFirstVisibleLine()
|
||||
@$scope.$on 'beforeChangeDocument', @storePositionAndLine
|
||||
|
||||
@$scope.$on 'afterChangeDocument', @jumpToPositionInNewDoc
|
||||
|
||||
@$scope.$on 'changeEditor', @storePositionAndLine
|
||||
|
||||
@$scope.$on "#{@$scope.name}:gotoLine", (e, line, column) =>
|
||||
if line?
|
||||
setTimeout () =>
|
||||
@@ -24,6 +24,10 @@ define [], () ->
|
||||
@$scope.$on "#{@$scope.name}:clearSelection", (e) =>
|
||||
@adapter.clearSelection()
|
||||
|
||||
storePositionAndLine: () =>
|
||||
@storeCursorPosition()
|
||||
@storeFirstVisibleLine()
|
||||
|
||||
jumpToPositionInNewDoc: () =>
|
||||
@doc_id = @$scope.sharejsDoc?.doc_id
|
||||
setTimeout () =>
|
||||
|
||||
Reference in New Issue
Block a user