Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(print): add option to print as PDF (not yet implemented)
Elian Dorandbf004d67388
diff --git a/src/public/app/widgets/buttons/note_actions.ts b/src/public/app/widgets/buttons/note_actions.tsindex 047a950bb8..c5a0dafcb3 100644--- a/src/public/app/widgets/buttons/note_actions.ts+++ b/src/public/app/widgets/buttons/note_actions.ts@@ -59,8 +59,12 @@ const TPL = `</li><li data-trigger-command="printActiveNote" class="dropdown-item print-active-note-button">- <span class="bx bx-printer"></span> ${t("note_actions.print_note")}<kbd data-command="printActiveNote"></kbd></li>+ <span class="bx bx-printer"></span> ${t("note_actions.print_note")}<kbd data-command="printActiveNote"></kbd>+ </li>+ <li data-trigger-command="exportAsPdf" class="dropdown-item export-as-pdf-button">+ <span class="bx bx-printer"></span> ${t("note_actions.print_pdf")}<kbd data-command="exportAsPdf"></kbd>+ </li><div class="dropdown-divider"></div>@@ -111,6 +115,7 @@ export default class NoteActionsWidget extends NoteContextAwareWidget {private $convertNoteIntoAttachmentButton!: JQuery<HTMLElement>;private $findInTextButton!: JQuery<HTMLElement>;private $printActiveNoteButton!: JQuery<HTMLElement>;+ private $exportAsPdfButton!: JQuery<HTMLElement>;private $showSourceButton!: JQuery<HTMLElement>;private $showAttachmentsButton!: JQuery<HTMLElement>;private $renderNoteButton!: JQuery<HTMLElement>;@@ -136,6 +141,7 @@ export default class NoteActionsWidget extends NoteContextAwareWidget {this.$convertNoteIntoAttachmentButton = this.$widget.find("[data-trigger-command='convertNoteIntoAttachment']");this.$findInTextButton = this.$widget.find(".find-in-text-button");this.$printActiveNoteButton = this.$widget.find(".print-active-note-button");+ this.$exportAsPdfButton = this.$widget.find("export-as-pdf-button");this.$showSourceButton = this.$widget.find(".show-source-button");this.$showAttachmentsButton = this.$widget.find(".show-attachments-button");this.$renderNoteButton = this.$widget.find(".render-note-button");@@ -185,7 +191,9 @@ export default class NoteActionsWidget extends NoteContextAwareWidget {this.toggleDisabled(this.$showAttachmentsButton, !isInOptions);this.toggleDisabled(this.$showSourceButton, ["text", "code", "relationMap", "mermaid", "canvas", "mindMap", "geoMap"].includes(note.type));- this.toggleDisabled(this.$printActiveNoteButton, ["text", "code"].includes(note.type));+ const canPrint = ["text", "code"].includes(note.type);+ this.toggleDisabled(this.$printActiveNoteButton, canPrint);+ this.toggleDisabled(this.$exportAsPdfButton, canPrint);this.$renderNoteButton.toggle(note.type === "render");diff --git a/src/public/app/widgets/note_detail.js b/src/public/app/widgets/note_detail.jsindex 3fad9f1388..ae38b1b939 100644--- a/src/public/app/widgets/note_detail.js+++ b/src/public/app/widgets/note_detail.js@@ -291,6 +291,14 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {});}+ async exportAsPdfEvent() {+ if (!this.noteContext.isActive()) {+ return;+ }++ alert("Hi");+ }+hoistedNoteChangedEvent({ ntxId }) {if (this.isNoteContext(ntxId)) {this.refresh();diff --git a/src/public/translations/en/translation.json b/src/public/translations/en/translation.jsonindex d58f0fd56a..c0d7d0eb1e 100644--- a/src/public/translations/en/translation.json+++ b/src/public/translations/en/translation.json@@ -672,7 +672,8 @@"save_revision": "Save revision","convert_into_attachment_failed": "Converting note '{{title}}' failed.","convert_into_attachment_successful": "Note '{{title}}' has been converted to attachment.",- "convert_into_attachment_prompt": "Are you sure you want to convert note '{{title}}' into an attachment of the parent note?"+ "convert_into_attachment_prompt": "Are you sure you want to convert note '{{title}}' into an attachment of the parent note?",+ "print_pdf": "Export as PDF..."},"onclick_button": {"no_click_handler": "Button widget '{{componentId}}' has no defined click handler"