diff --git a/app/core/src/main/resources/messages_de_DE.properties b/app/core/src/main/resources/messages_de_DE.properties index a0e8d7d4e..2b4ece097 100644 --- a/app/core/src/main/resources/messages_de_DE.properties +++ b/app/core/src/main/resources/messages_de_DE.properties @@ -1859,8 +1859,10 @@ editTableOfContents.replaceExisting=Vorhandene Lesezeichen ersetzen (deaktiviere editTableOfContents.editorTitle=Lesezeichen-Editor editTableOfContents.editorDesc=Fügen unten Lesezeichen hinzu und ordne sie an. Klicke auf +, um das untergeordnete Lesezeichen hinzuzufügen. editTableOfContents.addBookmark=Neues Lesezeichen hinzufügen -editTableOfContents.copyBookmarks=Kopieren -editTableOfContents.copyBookmarksHint=Kopiere Lesezeichendaten als Text +editTableOfContents.importBookmarks=Import +editTableOfContents.exportBookmarks=Export +editTableOfContents.importBookmarksHint=Lade Lesezeichendaten aus der Zwischenablage +editTableOfContents.exportBookmarksHint=Exportiere Lesezeichendaten als Text in die Zwischenablage editTableOfContents.desc.1=Mit diesem Werkzeug können Sie das Inhaltsverzeichnis (Lesezeichen) eines PDF-Dokuments hinzufügen oder bearbeiten. editTableOfContents.desc.2=Sie können eine hierarchische Struktur erstellen, indem Sie untergeordnete Lesezeichen zu übergeordneten hinzufügen. editTableOfContents.desc.3=Jedes Lesezeichen benötigt einen Titel und eine Seitenzahl. diff --git a/app/core/src/main/resources/messages_en_GB.properties b/app/core/src/main/resources/messages_en_GB.properties index 5d8549f9d..51adf45b1 100644 --- a/app/core/src/main/resources/messages_en_GB.properties +++ b/app/core/src/main/resources/messages_en_GB.properties @@ -1859,8 +1859,10 @@ 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.importBookmarks=Import +editTableOfContents.exportBookmarks=Export +editTableOfContents.importBookmarksHint=Load bookmark data from clipboard +editTableOfContents.exportBookmarksHint=Export bookmark data as string to clipboard 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. diff --git a/app/core/src/main/resources/messages_en_US.properties b/app/core/src/main/resources/messages_en_US.properties index 1a8961098..384db46e2 100644 --- a/app/core/src/main/resources/messages_en_US.properties +++ b/app/core/src/main/resources/messages_en_US.properties @@ -1859,8 +1859,10 @@ 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.importBookmarks=Import +editTableOfContents.exportBookmarks=Export +editTableOfContents.importBookmarksHint=Load bookmark data from clipboard +editTableOfContents.exportBookmarksHint=Export bookmark data as string to clipboard 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. diff --git a/app/core/src/main/resources/static/css/edit-table-of-contents.css b/app/core/src/main/resources/static/css/edit-table-of-contents.css index d85813a73..b82b6c4df 100644 --- a/app/core/src/main/resources/static/css/edit-table-of-contents.css +++ b/app/core/src/main/resources/static/css/edit-table-of-contents.css @@ -156,7 +156,7 @@ .bookmark-actions { margin-top: 20px; display: flex; - justify-content: flex-start; + justify-content: space-between; } /* Collapse/expand icons */ diff --git a/app/core/src/main/resources/static/js/pages/edit-table-of-contents.js b/app/core/src/main/resources/static/js/pages/edit-table-of-contents.js index 52955dc4b..3b561b8b8 100644 --- a/app/core/src/main/resources/static/js/pages/edit-table-of-contents.js +++ b/app/core/src/main/resources/static/js/pages/edit-table-of-contents.js @@ -597,19 +597,36 @@ document.addEventListener('DOMContentLoaded', function() { updateEmptyStateButton(); } - // Add copy bookmarks to clipboard functionality - async function copyBookmarksStringToClipboard() { + // Add import/export bookmarks to clipboard functionality + async function importBookmarkStringFromClipboard() { + try { + const newBookmarkDataString = await navigator.clipboard.readText(); + const newBookmarkData = JSON.parse(newBookmarkDataString); + + if (!newBookmarkData || newBookmarkData.length === 0) { + // don't change bookmarks for empty import data + return; + } + + bookmarks = newBookmarkData.map(convertExtractedBookmark); + updateBookmarksUI(); + } catch (error) { + throw new Error(`Failed to import bookmarks: ${error.message}`); + } + } + + async function exportBookmarkStringToClipboard() { const bookmarkData = bookmarkDataInput.value; try { await navigator.clipboard.writeText(bookmarkData); } catch (error) { - throw new Error(`Failed to copy bookmarks: ${error.message}`); + throw new Error(`Failed to export bookmarks: ${error.message}`); } } - // Add event listener to the copy bookmarks button - const copyBookmarksBtn = document.getElementById('copyBookmarksBtn'); - copyBookmarksBtn.addEventListener('click', copyBookmarksStringToClipboard); + // Add event listeners for import/export buttons + document.getElementById('importBookmarksBtn').addEventListener('click', importBookmarkStringFromClipboard); + document.getElementById('exportBookmarksBtn').addEventListener('click', exportBookmarkStringToClipboard); // Listen for theme changes to update badge colors const observer = new MutationObserver(function(mutations) { diff --git a/app/core/src/main/resources/templates/edit-table-of-contents.html b/app/core/src/main/resources/templates/edit-table-of-contents.html index 8935ae67e..c9f00e411 100644 --- a/app/core/src/main/resources/templates/edit-table-of-contents.html +++ b/app/core/src/main/resources/templates/edit-table-of-contents.html @@ -42,6 +42,24 @@
+
+ + +
@@ -51,12 +69,6 @@

-