Double click code to select it #1793

Closed
opened 2026-02-05 01:53:24 +03:00 by OVERLORD · 1 comment
Owner

Originally created by @ark- on GitHub (Jul 13, 2020).

Description

When double clicking inline code it would be great to select all of the contents of that inline code scope. Ready for copying.

Behavior not required for code blocks as they have their own copy button.

Benefits

A lot of bookstack users use it for documenting their own infrastructure or other software applications and as such a convenience feature such as this helps when copying and pasting inline code blocks.

Hard to provide a measurable benefit. Anecdotally it would have been useful recently when I had to redeploy a service which had a bunch of manual copying settings into a Web GUI.

I also write beginner guides that I share with my friends, there is often a lot of copying and pasting in those scenarios.

Additional context

Below is a script I use in confluence to provide the same feature. It doesn't seem to work in the Custom HTML Head Content of bookstack. Not sure why.

var inline_code_elems = document.getElementsByTagName("code") 

for (var i = 0; i < inline_code_elems.length; i++) {
    inline_code_elems[i].addEventListener('dblclick', hiLite, false);
}

function hiLite(event) {
    var range = document.createRange();
    var selection = window.getSelection();
    range.selectNodeContents(event.target);
    selection.removeAllRanges();
    selection.addRange(range);
    e.stopPropagation();
}


Originally created by @ark- on GitHub (Jul 13, 2020). ## Description When double clicking inline code it would be great to select all of the contents of that inline code scope. Ready for copying. Behavior not required for code blocks as they have their own copy button. ## Benefits A lot of bookstack users use it for documenting their own infrastructure or other software applications and as such a convenience feature such as this helps when copying and pasting inline code blocks. Hard to provide a measurable benefit. Anecdotally it would have been useful recently when I had to redeploy a service which had a bunch of manual copying settings into a Web GUI. I also write beginner guides that I share with my friends, there is often a lot of copying and pasting in those scenarios. ## Additional context Below is a script I use in confluence to provide the same feature. It doesn't seem to work in the `Custom HTML Head Content` of bookstack. Not sure why. ``` javascript var inline_code_elems = document.getElementsByTagName("code") for (var i = 0; i < inline_code_elems.length; i++) { inline_code_elems[i].addEventListener('dblclick', hiLite, false); } function hiLite(event) { var range = document.createRange(); var selection = window.getSelection(); range.selectNodeContents(event.target); selection.removeAllRanges(); selection.addRange(range); e.stopPropagation(); } ```
OVERLORD added the :cat2:🐈 Possible duplicate label 2026-02-05 01:53:24 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Jul 18, 2020):

Hi @ark-,
Thanks for the suggestion.
This is already open under #1612 therefore I'm going to close this off as a duplicate.

@ssddanbrown commented on GitHub (Jul 18, 2020): Hi @ark-, Thanks for the suggestion. This is already open under #1612 therefore I'm going to close this off as a duplicate.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#1793