From b6998a32d1e2b12f2b86c4a3d7f5ae6eef5a6e5e Mon Sep 17 00:00:00 2001 From: Fons van der Plas Date: Wed, 6 Dec 2023 15:56:34 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=96=A8=EF=B8=8F=20Some=20PDF=20layout=20i?= =?UTF-8?q?mprovements=20(#2738)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/components/Editor.js | 6 ++++- frontend/components/ExportBanner.js | 7 ++--- frontend/editor.css | 3 +-- frontend/hide-ui.css | 41 +++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 6 deletions(-) diff --git a/frontend/components/Editor.js b/frontend/components/Editor.js index 77275ed7e8..628ee51089 100644 --- a/frontend/components/Editor.js +++ b/frontend/components/Editor.js @@ -1464,7 +1464,11 @@ patch: ${JSON.stringify(
<${ExportBanner} notebook_id=${this.state.notebook.notebook_id} - notebook_shortpath=${this.state.notebook.shortpath} + print_title=${ + this.state.notebook.metadata?.frontmatter?.title ?? + new URLSearchParams(window.location.search).get("name") ?? + this.state.notebook.shortpath + } notebookfile_url=${this.export_url("notebookfile")} notebookexport_url=${this.export_url("notebookexport")} open=${export_menu_open} diff --git a/frontend/components/ExportBanner.js b/frontend/components/ExportBanner.js index 34ee367202..043b9afeef 100644 --- a/frontend/components/ExportBanner.js +++ b/frontend/components/ExportBanner.js @@ -44,7 +44,7 @@ export const WarnForVisisblePasswords = () => { } } -export const ExportBanner = ({ notebook_id, notebook_shortpath, open, onClose, notebookfile_url, notebookexport_url, start_recording }) => { +export const ExportBanner = ({ notebook_id, print_title, open, onClose, notebookfile_url, notebookexport_url, start_recording }) => { // @ts-ignore const isDesktop = !!window.plutoDesktop @@ -55,12 +55,13 @@ export const ExportBanner = ({ notebook_id, notebook_shortpath, open, onClose, n } } + // let print_old_title_ref = useRef("") useEffect(() => { let a = () => { console.log("beforeprint") print_old_title_ref.current = document.title - document.title = notebook_shortpath.replace(/\.jl$/, "").replace(/\.plutojl$/, "") + document.title = print_title.replace(/\.jl$/, "").replace(/\.plutojl$/, "") } let b = () => { document.title = print_old_title_ref.current @@ -71,7 +72,7 @@ export const ExportBanner = ({ notebook_id, notebook_shortpath, open, onClose, n window.removeEventListener("beforeprint", a) window.removeEventListener("afterprint", b) } - }, [notebook_shortpath]) + }, [print_title]) return html`