mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-29 19:12:27 +08:00
feat(print): add option to print as PDF (not yet implemented)
This commit is contained in:
parent
e3dbe21c5a
commit
dbf004d673
@ -59,8 +59,12 @@ const TPL = `
|
|||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li data-trigger-command="printActiveNote" class="dropdown-item print-active-note-button">
|
<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>
|
<div class="dropdown-divider"></div>
|
||||||
|
|
||||||
@ -111,6 +115,7 @@ export default class NoteActionsWidget extends NoteContextAwareWidget {
|
|||||||
private $convertNoteIntoAttachmentButton!: JQuery<HTMLElement>;
|
private $convertNoteIntoAttachmentButton!: JQuery<HTMLElement>;
|
||||||
private $findInTextButton!: JQuery<HTMLElement>;
|
private $findInTextButton!: JQuery<HTMLElement>;
|
||||||
private $printActiveNoteButton!: JQuery<HTMLElement>;
|
private $printActiveNoteButton!: JQuery<HTMLElement>;
|
||||||
|
private $exportAsPdfButton!: JQuery<HTMLElement>;
|
||||||
private $showSourceButton!: JQuery<HTMLElement>;
|
private $showSourceButton!: JQuery<HTMLElement>;
|
||||||
private $showAttachmentsButton!: JQuery<HTMLElement>;
|
private $showAttachmentsButton!: JQuery<HTMLElement>;
|
||||||
private $renderNoteButton!: 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.$convertNoteIntoAttachmentButton = this.$widget.find("[data-trigger-command='convertNoteIntoAttachment']");
|
||||||
this.$findInTextButton = this.$widget.find(".find-in-text-button");
|
this.$findInTextButton = this.$widget.find(".find-in-text-button");
|
||||||
this.$printActiveNoteButton = this.$widget.find(".print-active-note-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.$showSourceButton = this.$widget.find(".show-source-button");
|
||||||
this.$showAttachmentsButton = this.$widget.find(".show-attachments-button");
|
this.$showAttachmentsButton = this.$widget.find(".show-attachments-button");
|
||||||
this.$renderNoteButton = this.$widget.find(".render-note-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.$showAttachmentsButton, !isInOptions);
|
||||||
this.toggleDisabled(this.$showSourceButton, ["text", "code", "relationMap", "mermaid", "canvas", "mindMap", "geoMap"].includes(note.type));
|
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");
|
this.$renderNoteButton.toggle(note.type === "render");
|
||||||
|
|
||||||
|
@ -291,6 +291,14 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async exportAsPdfEvent() {
|
||||||
|
if (!this.noteContext.isActive()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
alert("Hi");
|
||||||
|
}
|
||||||
|
|
||||||
hoistedNoteChangedEvent({ ntxId }) {
|
hoistedNoteChangedEvent({ ntxId }) {
|
||||||
if (this.isNoteContext(ntxId)) {
|
if (this.isNoteContext(ntxId)) {
|
||||||
this.refresh();
|
this.refresh();
|
||||||
|
@ -672,7 +672,8 @@
|
|||||||
"save_revision": "Save revision",
|
"save_revision": "Save revision",
|
||||||
"convert_into_attachment_failed": "Converting note '{{title}}' failed.",
|
"convert_into_attachment_failed": "Converting note '{{title}}' failed.",
|
||||||
"convert_into_attachment_successful": "Note '{{title}}' has been converted to attachment.",
|
"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": {
|
"onclick_button": {
|
||||||
"no_click_handler": "Button widget '{{componentId}}' has no defined click handler"
|
"no_click_handler": "Button widget '{{componentId}}' has no defined click handler"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user