Unexpected behavior when pasting image into Markdown Editor #605

Closed
opened 2026-02-04 21:23:43 +03:00 by OVERLORD · 2 comments
Owner

Originally created by @Ethanb00 on GitHub (Mar 16, 2018).

  • BookStack Version (Found in settings, Please don't put 'latest'): 0.20.0
  • PHP Version: PHP 7.0.25-0ubuntu0.16.04.1 (cli) ( NTS )
  • MySQL Version: 10.1.31-MariaDB-1~xenial mariadb.org binary distribution
Expected Behavior

When I paste an image in the Markdown editor, I expect my cursor to end up at the end of the pasted text.

Current Behavior

When I paste an image into the Markdown editor, the cursor goes to the end and then jumps to the middle when the editor adds:

[domain]/uploads/images/gallery/[YYYY-DD-MMM/scaled-840-0/[filename]

The cursor ends up at the 'a' in 'scaled'.

Steps to Reproduce

Using Greenshot, take a screen grab and copy to clipboard. Then paste into the Markdown editor.

issue

Originally created by @Ethanb00 on GitHub (Mar 16, 2018). * BookStack Version *(Found in settings, Please don't put 'latest')*: 0.20.0 * PHP Version: PHP 7.0.25-0ubuntu0.16.04.1 (cli) ( NTS ) * MySQL Version: 10.1.31-MariaDB-1~xenial mariadb.org binary distribution ##### Expected Behavior When I paste an image in the Markdown editor, I expect my cursor to end up at the end of the pasted text. ##### Current Behavior When I paste an image into the Markdown editor, the cursor goes to the end and then jumps to the middle when the editor adds: `[domain]/uploads/images/gallery/[YYYY-DD-MMM/scaled-840-0/[filename]` The cursor ends up at the 'a' in 'scaled'. ##### Steps to Reproduce Using Greenshot, take a screen grab and copy to clipboard. Then paste into the Markdown editor. ![issue](https://user-images.githubusercontent.com/5893479/37541335-a5c29b18-2930-11e8-8ed2-29cd78a91388.gif)
OVERLORD added the 🐛 Bug label 2026-02-04 21:23:43 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Mar 18, 2018):

Thanks for reporting @Ethanb00. I agree the existing behaviour did not make sense. Behind the scenes the cursor was jumping to the end of the line but this would be for the placeholder image that's shown while your image is uploading. Once the image is uploaded the link is replaced, which is a different length, leaving the cursor in the wrong place.

I've updated this for the next release but instead of setting the cursor to the end of the line it will now be placed within the 'alt' section, between the square brackets since this makes sense to me and I think jumping it to the end may lead to unpredictability when factoring in the placeholder image link. Let me know if you think otherwise though.

@ssddanbrown commented on GitHub (Mar 18, 2018): Thanks for reporting @Ethanb00. I agree the existing behaviour did not make sense. Behind the scenes the cursor was jumping to the end of the line but this would be for the placeholder image that's shown while your image is uploading. Once the image is uploaded the link is replaced, which is a different length, leaving the cursor in the wrong place. I've updated this for the next release but instead of setting the cursor to the end of the line it will now be placed within the 'alt' section, between the square brackets since this makes sense to me and I think jumping it to the end may lead to unpredictability when factoring in the placeholder image link. Let me know if you think otherwise though.
Author
Owner

@Ethanb00 commented on GitHub (Mar 19, 2018):

Hi @ssddanbrown. Thanks so much for the quick response. I think that setting the cursor to the alt section makes total sense and is a better place to put it for most users.

I appreciate the quick turnaround on this!! Cheers!

@Ethanb00 commented on GitHub (Mar 19, 2018): Hi @ssddanbrown. Thanks so much for the quick response. I think that setting the cursor to the alt section makes total sense and is a better place to put it for most users. I appreciate the quick turnaround on this!! Cheers!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#605