mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-08-29 13:48:46 +02:00
add import/export functionality for bookmarks in the editor
This commit is contained in:
parent
198928cb4b
commit
b595a9b8c3
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -156,7 +156,7 @@
|
||||
.bookmark-actions {
|
||||
margin-top: 20px;
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
/* Collapse/expand icons */
|
||||
|
@ -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) {
|
||||
|
@ -42,6 +42,24 @@
|
||||
|
||||
<div class="bookmark-actions">
|
||||
<button type="button" id="addBookmarkBtn" class="btn btn-outline-primary" th:text="#{editTableOfContents.addBookmark}"></button>
|
||||
<div class="d-flex flex-wrap justify-content-end gap-2">
|
||||
<button type="button"
|
||||
id="importBookmarksBtn"
|
||||
class="btn btn-outline-primary"
|
||||
th:text="#{editTableOfContents.importBookmarks}"
|
||||
th:data-bs-original-title="#{editTableOfContents.importBookmarksHint}"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-placement="top">
|
||||
</button>
|
||||
<button type="button"
|
||||
id="exportBookmarksBtn"
|
||||
class="btn btn-outline-primary"
|
||||
th:text="#{editTableOfContents.exportBookmarks}"
|
||||
th:data-bs-original-title="#{editTableOfContents.exportBookmarksHint}"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-placement="top">
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Hidden field to store JSON data -->
|
||||
@ -51,12 +69,6 @@
|
||||
<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>
|
||||
|
Loading…
Reference in New Issue
Block a user