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.editorTitle=Lesezeichen-Editor
|
||||||
editTableOfContents.editorDesc=Fügen unten Lesezeichen hinzu und ordne sie an. Klicke auf +, um das untergeordnete Lesezeichen hinzuzufügen.
|
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.addBookmark=Neues Lesezeichen hinzufügen
|
||||||
editTableOfContents.copyBookmarks=Kopieren
|
editTableOfContents.importBookmarks=Import
|
||||||
editTableOfContents.copyBookmarksHint=Kopiere Lesezeichendaten als Text
|
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.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.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.
|
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.editorTitle=Bookmark Editor
|
||||||
editTableOfContents.editorDesc=Add and arrange bookmarks below. Click + to add child bookmarks.
|
editTableOfContents.editorDesc=Add and arrange bookmarks below. Click + to add child bookmarks.
|
||||||
editTableOfContents.addBookmark=Add New Bookmark
|
editTableOfContents.addBookmark=Add New Bookmark
|
||||||
editTableOfContents.copyBookmarks=Copy
|
editTableOfContents.importBookmarks=Import
|
||||||
editTableOfContents.copyBookmarksHint=Copy bookmark data as string
|
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.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.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.
|
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.editorTitle=Bookmark Editor
|
||||||
editTableOfContents.editorDesc=Add and arrange bookmarks below. Click + to add child bookmarks.
|
editTableOfContents.editorDesc=Add and arrange bookmarks below. Click + to add child bookmarks.
|
||||||
editTableOfContents.addBookmark=Add New Bookmark
|
editTableOfContents.addBookmark=Add New Bookmark
|
||||||
editTableOfContents.copyBookmarks=Copy
|
editTableOfContents.importBookmarks=Import
|
||||||
editTableOfContents.copyBookmarksHint=Copy bookmark data as string
|
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.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.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.
|
editTableOfContents.desc.3=Each bookmark requires a title and target page number.
|
||||||
|
@ -156,7 +156,7 @@
|
|||||||
.bookmark-actions {
|
.bookmark-actions {
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-start;
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Collapse/expand icons */
|
/* Collapse/expand icons */
|
||||||
|
@ -597,19 +597,36 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
updateEmptyStateButton();
|
updateEmptyStateButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add copy bookmarks to clipboard functionality
|
// Add import/export bookmarks to clipboard functionality
|
||||||
async function copyBookmarksStringToClipboard() {
|
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;
|
const bookmarkData = bookmarkDataInput.value;
|
||||||
try {
|
try {
|
||||||
await navigator.clipboard.writeText(bookmarkData);
|
await navigator.clipboard.writeText(bookmarkData);
|
||||||
} catch (error) {
|
} 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
|
// Add event listeners for import/export buttons
|
||||||
const copyBookmarksBtn = document.getElementById('copyBookmarksBtn');
|
document.getElementById('importBookmarksBtn').addEventListener('click', importBookmarkStringFromClipboard);
|
||||||
copyBookmarksBtn.addEventListener('click', copyBookmarksStringToClipboard);
|
document.getElementById('exportBookmarksBtn').addEventListener('click', exportBookmarkStringToClipboard);
|
||||||
|
|
||||||
// Listen for theme changes to update badge colors
|
// Listen for theme changes to update badge colors
|
||||||
const observer = new MutationObserver(function(mutations) {
|
const observer = new MutationObserver(function(mutations) {
|
||||||
|
@ -42,6 +42,24 @@
|
|||||||
|
|
||||||
<div class="bookmark-actions">
|
<div class="bookmark-actions">
|
||||||
<button type="button" id="addBookmarkBtn" class="btn btn-outline-primary" th:text="#{editTableOfContents.addBookmark}"></button>
|
<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>
|
</div>
|
||||||
|
|
||||||
<!-- Hidden field to store JSON data -->
|
<!-- Hidden field to store JSON data -->
|
||||||
@ -51,12 +69,6 @@
|
|||||||
<p>
|
<p>
|
||||||
<a class="btn btn-outline-primary" data-bs-toggle="collapse" href="#info" role="button"
|
<a class="btn btn-outline-primary" data-bs-toggle="collapse" href="#info" role="button"
|
||||||
aria-expanded="false" aria-controls="info" th:text="#{info}"></a>
|
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>
|
</p>
|
||||||
<div class="collapse" id="info">
|
<div class="collapse" id="info">
|
||||||
<p th:text="#{editTableOfContents.desc.1}"></p>
|
<p th:text="#{editTableOfContents.desc.1}"></p>
|
||||||
|
Loading…
Reference in New Issue
Block a user