mirror of
https://github.com/zadam/trilium.git
synced 2025-11-14 01:05:49 +01:00
feat(client/print): add a toast when printing is in progress
This commit is contained in:
@@ -1722,7 +1722,8 @@
|
|||||||
"window-on-top": "Keep Window on Top"
|
"window-on-top": "Keep Window on Top"
|
||||||
},
|
},
|
||||||
"note_detail": {
|
"note_detail": {
|
||||||
"could_not_find_typewidget": "Could not find typeWidget for type '{{type}}'"
|
"could_not_find_typewidget": "Could not find typeWidget for type '{{type}}'",
|
||||||
|
"printing": "Printing in progress..."
|
||||||
},
|
},
|
||||||
"note_title": {
|
"note_title": {
|
||||||
"placeholder": "type note's title here..."
|
"placeholder": "type note's title here..."
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import type { NoteType } from "../entities/fnote.js";
|
|||||||
import type TypeWidget from "./type_widgets/type_widget.js";
|
import type TypeWidget from "./type_widgets/type_widget.js";
|
||||||
import { MermaidTypeWidget } from "./type_widgets/mermaid.js";
|
import { MermaidTypeWidget } from "./type_widgets/mermaid.js";
|
||||||
import AiChatTypeWidget from "./type_widgets/ai_chat.js";
|
import AiChatTypeWidget from "./type_widgets/ai_chat.js";
|
||||||
|
import toast from "../services/toast.js";
|
||||||
|
|
||||||
const TPL = /*html*/`
|
const TPL = /*html*/`
|
||||||
<div class="note-detail">
|
<div class="note-detail">
|
||||||
@@ -297,6 +298,11 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toast.showPersistent({
|
||||||
|
icon: "bx bx-loader-circle bx-spin",
|
||||||
|
message: t("note_detail.printing"),
|
||||||
|
id: "printing"
|
||||||
|
});
|
||||||
const iframe = document.createElement('iframe');
|
const iframe = document.createElement('iframe');
|
||||||
iframe.src = `?print#${this.notePath}`;
|
iframe.src = `?print#${this.notePath}`;
|
||||||
iframe.className = "print-iframe";
|
iframe.className = "print-iframe";
|
||||||
@@ -304,6 +310,7 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
|
|||||||
iframe.onload = () => {
|
iframe.onload = () => {
|
||||||
if (!iframe.contentWindow) return;
|
if (!iframe.contentWindow) return;
|
||||||
iframe.contentWindow.addEventListener("note-ready", () => {
|
iframe.contentWindow.addEventListener("note-ready", () => {
|
||||||
|
toast.closePersistent("printing");
|
||||||
iframe.contentWindow?.print();
|
iframe.contentWindow?.print();
|
||||||
document.body.removeChild(iframe);
|
document.body.removeChild(iframe);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user