hotfix pagebreak
This commit is contained in:
Generated
+1
-1
@@ -2581,7 +2581,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustpad"
|
||||
version = "0.2.73"
|
||||
version = "0.2.74"
|
||||
dependencies = [
|
||||
"argon2",
|
||||
"aws-config",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "rustpad"
|
||||
version = "0.2.73"
|
||||
version = "0.2.74"
|
||||
edition = "2024"
|
||||
rust-version = "1.94"
|
||||
description = "Collaborative Markdown notepad built with Axum, WebSockets and SQLite, PostgreSQL and MySQL"
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<link rel="stylesheet" href="/static/css/styles.css">
|
||||
<link rel="stylesheet" href="/static/libs/rustpad-player/player.css">
|
||||
<script>window.__RUSTPAD_CONFIG__={assetVersion:"test"};</script>
|
||||
<script type="importmap">
|
||||
{"imports":{
|
||||
"@rustpad/i18n":"/static/js/i18n.js",
|
||||
"@rustpad/toast":"/static/js/toast.js",
|
||||
"@rustpad/vendor-libs":"/static/js/vendor-libs.js",
|
||||
"@rustpad/markdown":"/static/js/markdown.js",
|
||||
"@rustpad/emoji-data":"/static/js/emoji-data.js",
|
||||
"@rustpad/image-alias":"/static/js/image-alias.js"
|
||||
}}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="toast"></div>
|
||||
<button id="pdf">PDF</button>
|
||||
<dialog id="dlg">
|
||||
<form id="form" method="dialog">
|
||||
<select id="pdf-page-format"><option value="screen-16-9" selected>screen</option></select>
|
||||
<select id="pdf-page-margin"><option value="12" selected>12</option></select>
|
||||
<input id="pdf-include-title" type="checkbox">
|
||||
<input id="pdf-preserve-colors" type="checkbox">
|
||||
<button data-pdf-cancel type="button">cancel</button>
|
||||
<button type="submit">go</button>
|
||||
</form>
|
||||
</dialog>
|
||||
<div id="preview" class="preview markdown-body"></div>
|
||||
<script type="module">
|
||||
import { renderMarkdown } from "@rustpad/markdown";
|
||||
import { bindPdfExport } from "/static/js/pdf-export.js";
|
||||
|
||||
const source = await (await fetch('/TEST_NOTE_FEATURES.txt')).text();
|
||||
const preview = document.querySelector('#preview');
|
||||
preview.innerHTML = renderMarkdown(source);
|
||||
|
||||
// Replace raw Mermaid source blocks with representative SVGs so pagination
|
||||
// exercises the same tall/wide atomic visuals as the real rendered preview.
|
||||
[...preview.querySelectorAll('.mermaid')].forEach((node, index) => {
|
||||
const tall = index === 2 || index === 3 || index === 4;
|
||||
const height = tall ? 1500 : 520;
|
||||
node.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 ${height}" width="900" height="${height}"><rect width="900" height="${height}" fill="#efeae2"/><rect x="90" y="60" width="720" height="180" rx="16" fill="#202323"/><text x="450" y="160" text-anchor="middle" font-size="56" fill="white">Mermaid ${index + 1}</text><line x1="450" y1="240" x2="450" y2="${height - 100}" stroke="#777" stroke-width="6"/></svg>`;
|
||||
});
|
||||
|
||||
let popupFrame = null;
|
||||
window.open = () => {
|
||||
popupFrame = document.createElement('iframe');
|
||||
popupFrame.id = 'print-frame';
|
||||
popupFrame.style.cssText = 'position:absolute;left:-10000px;top:0;width:1400px;height:900px;border:0';
|
||||
document.body.appendChild(popupFrame);
|
||||
const win = popupFrame.contentWindow;
|
||||
win.focus = () => {};
|
||||
win.print = async () => {
|
||||
const html = win.document.documentElement.outerHTML;
|
||||
await fetch('/capture', { method: 'POST', headers: {'Content-Type':'text/html'}, body: html });
|
||||
document.documentElement.dataset.captureDone = '1';
|
||||
};
|
||||
return win;
|
||||
};
|
||||
|
||||
const dialog = document.querySelector('#dlg');
|
||||
bindPdfExport({
|
||||
button: document.querySelector('#pdf'),
|
||||
dialog,
|
||||
form: document.querySelector('#form'),
|
||||
preview,
|
||||
title: () => 'TEST_NOTE_FEATURES',
|
||||
});
|
||||
|
||||
dialog.showModal();
|
||||
document.querySelector('#form').dispatchEvent(new Event('submit', { bubbles: true, cancelable: true }));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
File diff suppressed because one or more lines are too long
+14
-2
@@ -427,15 +427,27 @@ function printStyles(cssSize, pageWidthMm, pageHeightMm, marginMm, preserveColor
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.pdf-content .preview-source-line::before { display: none !important; content: none !important; }
|
||||
.pdf-content .preview-source-line { min-height: 0; }
|
||||
.pdf-content .preview-source-line { min-height: 0; position: static !important; }
|
||||
.pdf-content .preview-editable:hover,
|
||||
.pdf-content .preview-editable:focus { background: transparent !important; box-shadow: none !important; }
|
||||
.pdf-content a { color: inherit !important; text-decoration: underline; }
|
||||
|
||||
/* Book-like pagination: keep small semantic units together, not whole sections. */
|
||||
/*
|
||||
* Do not rely on break-after: avoid for the main Markdown headings.
|
||||
* Chromium can first paint the heading at the end of the old page and
|
||||
* then move it to the next page, leaving a clipped strip of glyphs behind.
|
||||
* A small invisible reserve inside the heading keeps one following line
|
||||
* with it without triggering that fragmentation bug.
|
||||
*/
|
||||
.pdf-content h1,
|
||||
.pdf-content h2,
|
||||
.pdf-content h3,
|
||||
.pdf-content h3 {
|
||||
break-after: auto;
|
||||
page-break-after: auto;
|
||||
padding-bottom: 1.15em;
|
||||
margin-bottom: calc(.18em - 1.15em);
|
||||
}
|
||||
.pdf-content h4,
|
||||
.pdf-content h5,
|
||||
.pdf-content h6,
|
||||
|
||||
Reference in New Issue
Block a user