Edit Confluence page question
Asked by Iro Karavasili:

Hi all,  

A Confluence user has the question below:  

"When I edit a lengthy confluence page I press update and then manually scroll back to the place where I have edited it.   
Any workaround so I will be back at the same place where I was before?"  

Could you, please, give me some help with this one?  

Thank you in advance,  
Iro


Answers:
author: Fabienne Gerhard
body: Hi [@Iro Karavasili](/t5/user/viewprofilepage/user-id/1605208) - I'm totally with you according this problem. On one of the latest AUG an Addon was shown that may help you [Diary for Confluence](https://marketplace.atlassian.com/apps/1218275/diary-for-confluence?hosting=server&tab=overview).

Haven't tried it yet but it let's you edit content without using the editor but it looked useful on first look


author: CARLISLE
body: I agree this is an issue, even if you are using the keyboard command e to move to the EDIT mode. It is still frustrating.


author: Tobias Anstett _K15t_
body: Hi [@Iro Karavasili](/t5/user/viewprofilepage/user-id/1605208),

The only workaround I could imagine is using some javascript.

Navigate to the **Administration Console** \> **Custom HTML** and edit the **At end of the body** section. Here you can add custom JS to implement your requirement.

For example you could use

```
<script>
if (sessionStorage.getItem(window.location)) {
 window.scrollTo(0, sessionStorage.getItem(window.location));
 sessionStorage.clear();
}

document.onkeyup = function(event){
 var event = event || window.event;
 if(event.altKey && event.which == 69) {
 sessionStorage.setItem(window.location, window.scrollY);
 
 e = $.Event('keypress');
 e.which= 69;
 $('body').trigger(e);
 
 return false;
 }
}
</script>
```

<br />

**This will add an additional keyboard shortcut ALT+E** which will remember the location before going to the editor. Furthermore it tries to recover the scroll position after the editor was closed.

Best, Tobias

comments: author: CARLISLE
body: Tobias!

Thanks very much! I just invented another button myself with an addition of a multilevel list function. Great job and I will implement with our team!


author: Tobias Anstett _K15t_
body: You are welcome -- feel free to vote for the answer ;)


author: CARLISLE
body: We implemented this tool in a test environment and we are testing it today again. It seems to jump to the top of the page instead of the exact cursor location at this point. We are still researching. I will vote when it functions and is complete.

:)


author: Tobias Anstett _K15t_
body: Just to make sure I really implemented what you were looking for:

1. when you use the keyboard shortcut ALT+E in page view the current location of your screen Y position is saved (not the mouse cursor)
2. the editor is opened as usual at top position (no scrolling here)
3. after save you return to the page view which is then scrolled to the previous stored Y position.

I tested it in the latest Chrome version. Furthermore there is a edge case with the current script as window.location is used as a key. If it is not running replace this by 'scroll' . The ' are important.

Best, Tobias


author: CARLISLE
body: *I see what you mean on this one.*

*I wonder if this Edit button is on a time variable for authentication. (i.e. the mathematics of it all - the Edit feature closes after about 5 minutes - so it would just be a setting on the time).*

*For instance, then we would just keep the edit button open and not close the authentication for security to save time scrolling excessively?*


author: Tobias Anstett _K15t_
body: In JavaScript the SessionStorage is different from a "session" in Confluence/Tomcat/Java.

The SessionStorage is terminated by closing the corresponding tab or browser window (or as I did clearing it inside the code).

Best, Tobias


author: CARLISLE
body: I am working on a custom solution for this one. When the save button is closed in the form, then it needs to stay open (i.e. where the cursor is located),

++Example :++

* Edit button pushed - open editing
* Save button pushed - closed editing

The problem is scrolling excessively to return to the line where editing takes place.


author: Tobias Anstett _K15t_
body: > When the save button is closed in the form, then it needs to stay open (i.e. where the cursor is located),

What do you mean?


Tags: confluence-server

server