rapier-markdown-kit 1.2.48 → 1.2.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -210,6 +210,24 @@ const REFUSALS = {
210
210
  export_too_large: 'The file is larger than the limit. Split the document.',
211
211
  };
212
212
 
213
+ function sliceTallDrawings(main, pageHeight) {
214
+ const document = main.ownerDocument;
215
+ for (const svg of main.querySelectorAll('svg.rapier-native-flowchart, svg.rapier-diagram')) {
216
+ const box = svg.getBoundingClientRect(), view = (svg.getAttribute('viewBox') || '').trim().split(/[\s,]+/).map(Number);
217
+ if (!(box.height > pageHeight) || view.length !== 4 || !view.every(Number.isFinite) || !(view[2] > 0) || !(view[3] > 0)) continue;
218
+ const unit = view[3] / box.height, windows = [];
219
+ for (let offset = 0; offset < box.height; offset += pageHeight) {
220
+ const shown = Math.min(pageHeight, box.height - offset), part = svg.cloneNode(true);
221
+ part.setAttribute('viewBox', [view[0], view[1] + offset * unit, view[2], shown * unit].join(' '));
222
+ part.setAttribute('preserveAspectRatio', 'xMidYMin meet');
223
+ part.style.setProperty('width', box.width + 'px', 'important'); part.style.setProperty('height', shown + 'px', 'important');
224
+ part.style.setProperty('break-before', 'column', 'important'); part.style.setProperty('break-inside', 'avoid', 'important');
225
+ windows.push(part);
226
+ }
227
+ svg.replaceWith(...windows);
228
+ }
229
+ }
230
+
213
231
  async function _rapierWritePrintPdf({root, css, fontCss = '', canonical, bom = false, filename, title, settings, templatePage = null}, {capture, signal, current, maxBytes = 8 * 1024 * 1024, film, ink} = {}) {
214
232
  const refuse = code => { throw Object.assign(new Error(code), {code}); };
215
233
  const spoken = error => {
@@ -295,6 +313,7 @@ async function _rapierWritePrintPdf({root, css, fontCss = '', canonical, bom = f
295
313
  if (holder && !holder.textContent.trim() && !holder.querySelector('img,svg,math,table,pre')) holder.remove();
296
314
  }
297
315
  }
316
+ sliceTallDrawings(main, bodyHeight);
298
317
  wrapMasks(main);
299
318
  check();
300
319
  for (const node of [main, ...main.querySelectorAll('*')]) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rapier-markdown-kit",
3
- "version": "1.2.48",
3
+ "version": "1.2.49",
4
4
  "description": "Read, render and write Self-contained Markdown: one .md file that carries its pictures, drawings and layout, and that any Markdown app can read. HTML renderer, stylesheet, text layout, Will/1 agent permissions, and an edit history with authorship and offline merge. MIT, no dependencies.",
5
5
  "keywords": [
6
6
  "markdown",
package/style.css CHANGED
@@ -264,9 +264,12 @@
264
264
  @media (prefers-reduced-motion:reduce){
265
265
  :where(.md-render) svg.rapier-diagram[aria-roledescription^="flowchart"] :is(path,line,polyline):is(.edge-animation-fast,.edge-animation-slow){animation:none!important;stroke-dashoffset:0!important}
266
266
  }
267
- /* Printed diagrams fit the page. */
267
+ /* Printed diagrams fit the page's width, at their own size; a drawing taller than a page continues onto the next (the
268
+ export slices it, the browser's print fragments it) and the figure's screen height is not held. */
268
269
  @media print{
269
- :where(.md-render) .diagram-block{overflow:visible!important}
270
+ :where(.md-render) .diagram-block{overflow:visible!important;min-height:0!important}
271
+ /* The frame's rules are a background, not ink, and the figure's box and its cache hold no words: the drawing alone is the block. */
272
+ :where(.md-render) .diagram-block:is([data-diagram-state="ready"],[data-diagram-state="idle"]),:where(.md-render) .diagram-block .diagram-cache{display:contents!important}
270
273
  :where(.md-render) svg.rapier-diagram,:where(.md-render) svg.rapier-native-flowchart{width:auto!important;max-width:100%!important}
271
274
  }
272
275
  :where(.md-render) .diagram-reason {