mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-04 00:28:33 +00:00
fix: visibility issue of document in print mode (#14367)
fix #14330 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved print-to-PDF rendering by enforcing a consistent light theme, ensuring better readability and visual consistency in exported PDF documents. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -35,9 +35,28 @@ export async function printToPdf(
|
|||||||
overflow: initial !important;
|
overflow: initial !important;
|
||||||
print-color-adjust: exact;
|
print-color-adjust: exact;
|
||||||
-webkit-print-color-adjust: exact;
|
-webkit-print-color-adjust: exact;
|
||||||
|
color: #000 !important;
|
||||||
|
background: #fff !important;
|
||||||
|
color-scheme: light !important;
|
||||||
}
|
}
|
||||||
::-webkit-scrollbar {
|
::-webkit-scrollbar {
|
||||||
display: none;
|
display: none;
|
||||||
|
}
|
||||||
|
:root, body {
|
||||||
|
--affine-text-primary: #000 !important;
|
||||||
|
--affine-text-secondary: #111 !important;
|
||||||
|
--affine-text-tertiary: #333 !important;
|
||||||
|
--affine-background-primary: #fff !important;
|
||||||
|
--affine-background-secondary: #fff !important;
|
||||||
|
--affine-background-tertiary: #fff !important;
|
||||||
|
}
|
||||||
|
body, [data-theme='dark'] {
|
||||||
|
color: #000 !important;
|
||||||
|
background: #fff !important;
|
||||||
|
}
|
||||||
|
body * {
|
||||||
|
color: #000 !important;
|
||||||
|
-webkit-text-fill-color: #000 !important;
|
||||||
}
|
}
|
||||||
:root {
|
:root {
|
||||||
--affine-note-shadow-box: none !important;
|
--affine-note-shadow-box: none !important;
|
||||||
@@ -95,6 +114,14 @@ export async function printToPdf(
|
|||||||
true
|
true
|
||||||
) as HTMLDivElement;
|
) as HTMLDivElement;
|
||||||
|
|
||||||
|
// force light theme in print iframe
|
||||||
|
iframe.contentWindow.document.documentElement.setAttribute(
|
||||||
|
'data-theme',
|
||||||
|
'light'
|
||||||
|
);
|
||||||
|
iframe.contentWindow.document.body.setAttribute('data-theme', 'light');
|
||||||
|
importedRoot.setAttribute('data-theme', 'light');
|
||||||
|
|
||||||
// draw saved canvas image to canvas
|
// draw saved canvas image to canvas
|
||||||
const allImportedCanvas = importedRoot.getElementsByTagName('canvas');
|
const allImportedCanvas = importedRoot.getElementsByTagName('canvas');
|
||||||
for (const importedCanvas of allImportedCanvas) {
|
for (const importedCanvas of allImportedCanvas) {
|
||||||
|
|||||||
Reference in New Issue
Block a user