feat: add copy to clipboard functionality to bookmarks editor

This commit is contained in:
Lukas 2025-08-01 12:28:08 +02:00
parent a5d219ed05
commit d2b39118c8
No known key found for this signature in database
3 changed files with 22 additions and 0 deletions

View File

@ -1859,6 +1859,8 @@ editTableOfContents.replaceExisting=Replace existing bookmarks (uncheck to appen
editTableOfContents.editorTitle=Bookmark Editor
editTableOfContents.editorDesc=Add and arrange bookmarks below. Click + to add child bookmarks.
editTableOfContents.addBookmark=Add New Bookmark
editTableOfContents.copyBookmarks=Copy
editTableOfContents.copyBookmarksHint=Copy bookmark data as string
editTableOfContents.desc.1=This tool allows you to add or edit the table of contents (bookmarks) in a PDF document.
editTableOfContents.desc.2=You can create a hierarchical structure by adding child bookmarks to parent bookmarks.
editTableOfContents.desc.3=Each bookmark requires a title and target page number.

View File

@ -597,6 +597,20 @@ document.addEventListener('DOMContentLoaded', function() {
updateEmptyStateButton();
}
// Add copy bookmarks to clipboard functionality
async function copyBookmarksStringToClipboard() {
const bookmarkData = bookmarkDataInput.value;
try {
await navigator.clipboard.writeText(bookmarkData);
} catch (error) {
throw new Error(`Failed to copy bookmarks: ${error.message}`);
}
}
// Add event listener to the copy bookmarks button
const copyBookmarksBtn = document.getElementById('copyBookmarksBtn');
copyBookmarksBtn.addEventListener('click', copyBookmarksStringToClipboard);
// Listen for theme changes to update badge colors
const observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {

View File

@ -51,6 +51,12 @@
<p>
<a class="btn btn-outline-primary" data-bs-toggle="collapse" href="#info" role="button"
aria-expanded="false" aria-controls="info" th:text="#{info}"></a>
<button type="button"
id="copyBookmarksBtn"
class="btn btn-outline-primary"
th:text="#{editTableOfContents.copyBookmarks}"
th:title="#{editTableOfContents.copyBookmarksHint}">
</button>
</p>
<div class="collapse" id="info">
<p th:text="#{editTableOfContents.desc.1}"></p>