Ability to copy issue title for futher usage #11853

Closed
opened 2025-11-02 09:49:44 -06:00 by GiteaMirror · 6 comments
Owner

Originally created by @fairking on GitHub (Oct 14, 2023).

Feature Description

It would be nice to have an ability to copy the issue so it can be used as a branch name or anything else like release notes or a reference in other discussions or topics:

For example the following title Create owner on init #13 could be rather like #13 Create owner on init and have an ability to copy it to the clipboard as it is: #13 Create owner on init so it can be used anywhere else.

The copied to clipboard value could also be a formatted url version. So when pasted in WYSIWYG/Markdown it will be an url instead <a href="url">#13 Create owner on init</a> [#13 Create owner on init](url). But still pasted as plain text in regular text fields.

Note: I would prefer to move the #ID to the front of the title.

Originally created by @fairking on GitHub (Oct 14, 2023). ### Feature Description It would be nice to have an ability to copy the issue so it can be used as a branch name or anything else like release notes or a reference in other discussions or topics: For example the following title `Create owner on init #13` could be rather like `#13 Create owner on init` and have an ability to copy it to the clipboard as it is: `#13 Create owner on init` so it can be used anywhere else. The copied to clipboard value could also be a formatted url version. So when pasted in WYSIWYG/Markdown it will be an url instead `<a href="url">#13 Create owner on init</a>` `[#13 Create owner on init](url)`. But still pasted as plain text in regular text fields. Note: I would prefer to move the #ID to the front of the title.
GiteaMirror added the type/proposal label 2025-11-02 09:49:44 -06:00
Author
Owner

@JakobDev commented on GitHub (Oct 14, 2023):

Why don't you just copy the title as any other text?

@JakobDev commented on GitHub (Oct 14, 2023): Why don't you just copy the title as any other text?
Author
Owner

@fairking commented on GitHub (Dec 21, 2023):

Why don't you just copy the title as any other text?

The way how it works now is awful. IMHO.

  1. Select and Ctrl+C requires two clicks.
  2. The Reference number should be at the beginning, so if I paste it anywhere (as a "create branch name" or as a reference in the issue) it will work everywhere.

image

image

image

image

image

image

@fairking commented on GitHub (Dec 21, 2023): > Why don't you just copy the title as any other text? The way how it works now is awful. IMHO. 1. Select and Ctrl+C requires two clicks. 1. The Reference number should be at the beginning, so if I paste it anywhere (as a "create branch name" or as a reference in the issue) it will work everywhere. ![image](https://github.com/go-gitea/gitea/assets/13495631/8bc6a18f-2677-4b9b-9867-ed2aecba57a3) ![image](https://github.com/go-gitea/gitea/assets/13495631/f73405e6-0e8f-4e7f-abc9-896ab3d7f72b) ![image](https://github.com/go-gitea/gitea/assets/13495631/201d8595-4cb2-47ce-b9f7-b89efb761481) ![image](https://github.com/go-gitea/gitea/assets/13495631/9454c95d-012d-479c-8de5-414a1c67f378) ![image](https://github.com/go-gitea/gitea/assets/13495631/6f1d93e1-b836-4868-8ffe-fef067e5d8b0) ![image](https://github.com/go-gitea/gitea/assets/13495631/3269e7ee-f2b3-477b-b0f2-b597dfbfdda0)
Author
Owner

@wxiaoguang commented on GitHub (Apr 5, 2025):

This feature request is too specific for the workflow you described.

If you really need this feature, you could add some custom JS scripts into the custom tmpl to create your own "copy" button.

The current format title #num also follows GitHub's design, so I guess most users would like to keep it as-is.


As now, it seems that there is no more user requesting this feature. Since Gitea focuses on the features for majority users, so I think this proposal could be closed as "not planned" at the moment, feel free to reopen if there are more users having interests in it.

@wxiaoguang commented on GitHub (Apr 5, 2025): This feature request is too specific for the workflow you described. If you really need this feature, you could add some custom JS scripts into the custom tmpl to create your own "copy" button. The current format `title #num` also follows GitHub's design, so I guess most users would like to keep it as-is. ---- As now, it seems that there is no more user requesting this feature. Since Gitea focuses on the features for majority users, so I think this proposal could be closed as "not planned" at the moment, feel free to reopen if there are more users having interests in it.
Author
Owner

@fairking commented on GitHub (Apr 5, 2025):

@JakobDev >> Why don't you just copy the title as any other text?

Too many clicks. On mobile it is even more annoying. So you must literally slide the mouse right keeping the button clicked. Not user friendly.

@wxiaoguang >> This feature request is too specific for the workflow you described.

Everyone has such workflow, just to grab the issue title and paste it in chat, timesheet, release notes, progress report, and many other apps you use to manage and track your development.

@wxiaoguang >> The current format title #num also follows GitHub's design.

I am not sure about the github. Are you going to copy everything github does? If it fails gitea will fail too?

  1. In real world every numbered item has a number first and the title second. Eg. #15 User Settings Implementation.
  2. When I look at the title it is hard to find the number because it could be in every position of the line depending on the title length.
  3. Pasting titles into the project planner makes it hard to search by number.

Example of the Progress report issued to the user:

Image

Also, in some magic way the browser title looks the way how it should be:

Image

@wxiaoguang >> If you really need this feature, you could add some custom JS scripts into the custom tmpl to create your own "copy" button.

Is there any docs how to do that? I cannot find anything in the Project/Repo Settings.

@fairking commented on GitHub (Apr 5, 2025): @JakobDev >> Why don't you just copy the title as any other text? Too many clicks. On mobile it is even more annoying. So you must literally slide the mouse right keeping the button clicked. Not user friendly. @wxiaoguang >> This feature request is too specific for the workflow you described. Everyone has such workflow, just to grab the issue title and paste it in chat, timesheet, release notes, progress report, and many other apps you use to manage and track your development. @wxiaoguang >> The current format title #num also follows GitHub's design. I am not sure about the github. Are you going to copy everything github does? If it fails gitea will fail too? 1. In real world every numbered item has a number first and the title second. Eg. `#15 User Settings Implementation`. 2. When I look at the title it is hard to find the number because it could be in every position of the line depending on the title length. 3. Pasting titles into the project planner makes it hard to search by number. Example of the Progress report issued to the user: ![Image](https://github.com/user-attachments/assets/77776a3b-6acc-4c3d-8c59-cdf26424c74b) Also, in some magic way the browser title looks the way how it should be: ![Image](https://github.com/user-attachments/assets/05ba8899-268d-4f95-bb05-17af6911f163) @wxiaoguang >> If you really need this feature, you could add some custom JS scripts into the custom tmpl to create your own "copy" button. Is there any docs how to do that? I cannot find anything in the Project/Repo Settings.
Author
Owner

@TheFox0x7 commented on GitHub (Apr 5, 2025):

You can find how to customize templates here: https://docs.gitea.com/administration/customizing-gitea

@TheFox0x7 commented on GitHub (Apr 5, 2025): You can find how to customize templates here: https://docs.gitea.com/administration/customizing-gitea
Author
Owner

@fairking commented on GitHub (Apr 5, 2025):

Thank you @TheFox0x7

I managed to add a copy button.

So for others if they need it:

  1. Go to gitea Site Administration -> Configuration -> Summary page and check your custom directory, it must be something like: Custom File Root Path: /var/lib/gitea/custom.
  2. Create a new file /templates/custom/header.tmpl, so the full path will be /var/lib/gitea/custom/templates/custom/header.tmpl.
  3. Add the following javascript into the header.tmpl file:
<script>
document.addEventListener("DOMContentLoaded", function(event) {
    const btns = document.getElementsByClassName("issue-title-buttons");
    if (btns.length) {
        const copy_link = createButton();
        copy_link.addEventListener('click', function() { 
            const title = document.querySelector("#issue-title-display h1");
            if (title) {
                const t1 = title.childNodes[0].textContent.replace(/[\n\r\t]/gm, "");
                const t2 = title.childNodes[1].innerText;
                copyToClipboard(t2 + ' ' + t1);
            }
        }, false);
        btns[0].prepend(copy_link);
    }

    function createButton() {
        var btn = document.createElement("a");
        btn.role = "button";
        btn.classList.add("ui", "small", "basic", "button");
        btn.innerText = "Copy";
        return btn
    }

    const copyToClipboard = (text) => {
        const textArea = document.createElement('textarea');
        textArea.value = text;
        document.body.appendChild(textArea);
        textArea.select();
        document.execCommand('copy');
        document.body.removeChild(textArea);
    }
});
</script>
  1. Restart the gitea: systemctl restart gitea.
  2. Refresh the gitea issue page, You should see the following copy button:

Image

@fairking commented on GitHub (Apr 5, 2025): Thank you @TheFox0x7 I managed to add a copy button. So for others if they need it: 1. Go to gitea Site Administration -> Configuration -> Summary page and check your custom directory, it must be something like: Custom File Root Path: `/var/lib/gitea/custom`. 2. Create a new file `/templates/custom/header.tmpl`, so the full path will be `/var/lib/gitea/custom/templates/custom/header.tmpl`. 3. Add the following javascript into the `header.tmpl` file: ``` js <script> document.addEventListener("DOMContentLoaded", function(event) { const btns = document.getElementsByClassName("issue-title-buttons"); if (btns.length) { const copy_link = createButton(); copy_link.addEventListener('click', function() { const title = document.querySelector("#issue-title-display h1"); if (title) { const t1 = title.childNodes[0].textContent.replace(/[\n\r\t]/gm, ""); const t2 = title.childNodes[1].innerText; copyToClipboard(t2 + ' ' + t1); } }, false); btns[0].prepend(copy_link); } function createButton() { var btn = document.createElement("a"); btn.role = "button"; btn.classList.add("ui", "small", "basic", "button"); btn.innerText = "Copy"; return btn } const copyToClipboard = (text) => { const textArea = document.createElement('textarea'); textArea.value = text; document.body.appendChild(textArea); textArea.select(); document.execCommand('copy'); document.body.removeChild(textArea); } }); </script> ``` 4. Restart the gitea: `systemctl restart gitea`. 5. Refresh the gitea issue page, You should see the following copy button: ![Image](https://github.com/user-attachments/assets/17fe4844-9c8c-4a0c-bd3d-19c42f6cdea9)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#11853