@tekkare/romulus 0.1.179 → 0.1.181

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.
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.16.0"
6
6
  },
7
- "version": "0.1.178",
7
+ "version": "0.1.180",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "2.0.0"
@@ -159,7 +159,12 @@ function resetDraft() {
159
159
  draft.value = new Set(selected.value)
160
160
  // Les branches qui portent la selection s'ouvrent : arriver sur un arbre
161
161
  // replie alors qu'il est filtre ne dit pas sur quoi.
162
- const open = new Set<string>()
162
+ //
163
+ // Elles s'AJOUTENT a ce qui est deja deplie, jamais a la place. En `inline`
164
+ // chaque clic ecrit le modele, donc ce reglage repassait ici a chaque case
165
+ // cochee : repartir d'un ensemble vide refermait tout l'arbre sous les
166
+ // doigts, y compris la branche qu'on etait en train de parcourir.
167
+ const open = new Set(expanded.value)
163
168
  selected.value.forEach((value) => {
164
169
  let parent = index.value.get(value)?.parent ?? null
165
170
  while (parent) {
@@ -122,11 +122,30 @@ async function capture(el) {
122
122
  useCORS: true
123
123
  });
124
124
  if (!canvas.width || !canvas.height) return null;
125
- return { data: canvas.toDataURL("image/png"), width: canvas.width, height: canvas.height };
125
+ return canvas;
126
126
  } catch {
127
127
  return null;
128
128
  }
129
129
  }
130
+ function slice(canvas, top, height) {
131
+ const part = document.createElement("canvas");
132
+ part.width = canvas.width;
133
+ part.height = Math.max(1, Math.round(height));
134
+ const context = part.getContext("2d");
135
+ if (!context) return canvas.toDataURL("image/png");
136
+ context.drawImage(
137
+ canvas,
138
+ 0,
139
+ Math.round(top),
140
+ canvas.width,
141
+ part.height,
142
+ 0,
143
+ 0,
144
+ canvas.width,
145
+ part.height
146
+ );
147
+ return part.toDataURL("image/png");
148
+ }
130
149
  async function raster(markup, width, height, scale = 2) {
131
150
  const image = new Image();
132
151
  image.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(markup)}`;
@@ -585,28 +604,39 @@ export function useRmExport() {
585
604
  if (faithful) {
586
605
  sectionTitle(lang === "en" ? "Page" : "La page");
587
606
  for (const shot of shots) {
588
- let drawWidth = inner;
589
- let drawHeight = shot.height / shot.width * drawWidth;
590
- const maxHeight = bottom - margin;
591
- if (drawHeight > maxHeight) {
592
- drawHeight = maxHeight;
593
- drawWidth = shot.width / shot.height * drawHeight;
607
+ const drawWidth = inner;
608
+ const height = shot.height / shot.width * drawWidth;
609
+ const room = () => bottom - y;
610
+ if (height <= bottom - margin) {
611
+ if (height > room()) {
612
+ doc.addPage();
613
+ y = margin;
614
+ }
615
+ doc.addImage(shot.toDataURL("image/png"), "PNG", margin, y, drawWidth, height, void 0, "FAST");
616
+ y += height + 6;
617
+ continue;
594
618
  }
595
- if (y + drawHeight > bottom) {
596
- doc.addPage();
597
- y = margin;
619
+ let drawn = 0;
620
+ while (drawn < height - 0.5) {
621
+ if (room() < 20) {
622
+ doc.addPage();
623
+ y = margin;
624
+ }
625
+ const band = Math.min(room(), height - drawn);
626
+ doc.addImage(
627
+ slice(shot, drawn / height * shot.height, band / height * shot.height),
628
+ "PNG",
629
+ margin,
630
+ y,
631
+ drawWidth,
632
+ band,
633
+ void 0,
634
+ "FAST"
635
+ );
636
+ drawn += band;
637
+ y += band;
598
638
  }
599
- doc.addImage(
600
- shot.data,
601
- "PNG",
602
- margin + (inner - drawWidth) / 2,
603
- y,
604
- drawWidth,
605
- drawHeight,
606
- void 0,
607
- "FAST"
608
- );
609
- y += drawHeight + 6;
639
+ y += 6;
610
640
  }
611
641
  }
612
642
  let rowCount = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tekkare/romulus",
3
- "version": "0.1.179",
3
+ "version": "0.1.181",
4
4
  "description": "Romulus Design System - Nuxt module by Tekkare",
5
5
  "license": "MIT",
6
6
  "type": "module",