mirror of
https://github.com/PR0M3TH3AN/Artstr-Studio.git
synced 2026-11-07 05:59:57 +00:00
Fix blank PDF print regression — split exporting / export-print classes
Recent commit 119b14e added body.classList.add('export-print') to
the regular print flow (printWithCurrentFilename) to strip selection
chrome from the output. That broke PDF print entirely because an
existing @media print rule —
body.export-print > *:not(#exportPrintContainer):not(#globalClipDefs) {
display: none !important;
}
— hides every direct body child when body.export-print is set. The
JPEG-PDF flow first reparents the sheet into #exportPrintContainer
(enterExportPrintMode), so that rule isolates the sheet correctly.
The regular print flow doesn't reparent anything, so the rule just
hid the entire .app and printed a blank page.
Fix: two classes with separate responsibilities.
- `body.exporting` — chrome stripping only (selection outlines,
resize handles, layer selection box, canvasVeil, color-adjust
hints). Safe to apply during any print/export, because nothing
hides the document.
- `body.export-print` — also reparents the sheet into
#exportPrintContainer. Only the JPEG-PDF flow does this setup.
Wiring:
- printWithCurrentFilename adds/removes body.exporting (no
export-print) — PDF print path now renders the live DOM with
only chrome stripped.
- enterExportPrintMode adds both classes; exitExportPrintMode
removes both.
- CSS chrome-stripping rules renamed from body.export-print →
body.exporting (the existing body.export-print container-isolation
rules at line 2588+ stay as they were).
Verified via CDP Page.printToPDF on customart mode: PDF is 1 page
at 960×540 pts (= 1280×720 px at 72 pt/in), text content "Print
Test" extracts, color block + crop marks render, and the
selected-layer outline is no longer visible (was visible before
my chrome-stripping rules existed; still working now).
Co-Authored-By: Claude Opus 4.7 <[email protected]>
This commit is contained in:
1 parent
29dcdeea61
commit
902befa189
1 file changed
+19
-12
+19
-12
@@ -2463,23 +2463,23 @@
|
||||
generating output via window.print(). It strips editor chrome from
|
||||
the snapshot so the PDF / JPEG-fallback doesn't include layer
|
||||
selection outlines, resize handles, the spine guide labels, etc. */
|
||||
body.export-print .spineText, body.export-print .discSpineStrip {
|
||||
body.exporting .spineText, body.exporting .discSpineStrip {
|
||||
display: none !important;
|
||||
}
|
||||
body.export-print .freeLayer.selected,
|
||||
body.export-print .freeLayer.multiSelected {
|
||||
body.exporting .freeLayer.selected,
|
||||
body.exporting .freeLayer.multiSelected {
|
||||
outline: none !important;
|
||||
box-shadow: none !important;
|
||||
}
|
||||
body.export-print .layerHandle,
|
||||
body.export-print .layerSelectionBox { display: none !important; }
|
||||
body.export-print .freeLayer {
|
||||
body.exporting .layerHandle,
|
||||
body.exporting .layerSelectionBox { display: none !important; }
|
||||
body.exporting .freeLayer {
|
||||
pointer-events: none !important;
|
||||
}
|
||||
body.export-print .sheet,
|
||||
body.export-print .sheet *,
|
||||
body.export-print .designerDiscWrap,
|
||||
body.export-print .designerDiscWrap * {
|
||||
body.exporting .sheet,
|
||||
body.exporting .sheet *,
|
||||
body.exporting .designerDiscWrap,
|
||||
body.exporting .designerDiscWrap * {
|
||||
-webkit-print-color-adjust: exact !important;
|
||||
print-color-adjust: exact !important;
|
||||
color-adjust: exact !important;
|
||||
@@ -14798,10 +14798,15 @@
|
||||
function printWithCurrentFilename() {
|
||||
const previousTitle = document.title;
|
||||
const nextTitle = currentPdfTitle();
|
||||
document.body.classList.add('export-print');
|
||||
// `exporting` (chrome-stripping only) is safe for the regular print
|
||||
// path which renders the live DOM as-is. The heavier `export-print`
|
||||
// class triggers a CSS rule that hides everything outside
|
||||
// #exportPrintContainer — only the JPEG-PDF flow sets that up, so
|
||||
// adding it here would print a blank page.
|
||||
document.body.classList.add('exporting');
|
||||
const restore = () => {
|
||||
document.title = previousTitle;
|
||||
document.body.classList.remove('export-print');
|
||||
document.body.classList.remove('exporting');
|
||||
window.removeEventListener('afterprint', restore);
|
||||
};
|
||||
window.addEventListener('afterprint', restore);
|
||||
@@ -21645,6 +21650,7 @@
|
||||
container.appendChild(sheet);
|
||||
sheet.style.cssText = `position:absolute!important;top:${fmt(offsetY)}in!important;left:${fmt(offsetX)}in!important;width:${fmt(sheetW())}in!important;height:${fmt(sheetH())}in!important;margin:0!important;padding:0!important;transform:none!important;box-shadow:none!important;${bg ? `background:${bg}!important;` : ''}`;
|
||||
document.body.classList.add('export-print');
|
||||
document.body.classList.add('exporting');
|
||||
$('dynamicPageStyle').textContent = `@page { size: ${fmt(pageWIn)}in ${fmt(pageHIn)}in; margin: 0; }`;
|
||||
return true;
|
||||
}
|
||||
@@ -21664,6 +21670,7 @@
|
||||
}
|
||||
container.remove();
|
||||
document.body.classList.remove('export-print');
|
||||
document.body.classList.remove('exporting');
|
||||
_exportSheetOrigParent = null;
|
||||
_exportSheetOrigNext = null;
|
||||
_exportSheetOrigStyle = null;
|
||||
|
||||
Reference in new issue
Block a user