feat(client/print): add a toast when printing is in progress

This commit is contained in:
Elian Doran
2025-10-19 17:12:41 +03:00
parent c160ab4721
commit 61bdcf2a53
2 changed files with 9 additions and 1 deletions

View File

@@ -1722,7 +1722,8 @@
"window-on-top": "Keep Window on Top"
},
"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": {
"placeholder": "type note's title here..."

View File

@@ -33,6 +33,7 @@ import type { NoteType } from "../entities/fnote.js";
import type TypeWidget from "./type_widgets/type_widget.js";
import { MermaidTypeWidget } from "./type_widgets/mermaid.js";
import AiChatTypeWidget from "./type_widgets/ai_chat.js";
import toast from "../services/toast.js";
const TPL = /*html*/`
<div class="note-detail">
@@ -297,6 +298,11 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
return;
}
toast.showPersistent({
icon: "bx bx-loader-circle bx-spin",
message: t("note_detail.printing"),
id: "printing"
});
const iframe = document.createElement('iframe');
iframe.src = `?print#${this.notePath}`;
iframe.className = "print-iframe";
@@ -304,6 +310,7 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
iframe.onload = () => {
if (!iframe.contentWindow) return;
iframe.contentWindow.addEventListener("note-ready", () => {
toast.closePersistent("printing");
iframe.contentWindow?.print();
document.body.removeChild(iframe);
});