@k-l-lambda/lilylet-markdown 0.1.19 → 0.1.21
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/lib/index.js +11 -2
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -67,11 +67,20 @@ async function renderLilylet(code, options) {
|
|
|
67
67
|
if (!verovioToolkit) {
|
|
68
68
|
return `<div class="${containerClass}" data-lilylet${sourceAttr}${meiAttr}></div>`;
|
|
69
69
|
}
|
|
70
|
-
// Calculate pageHeight based on measure count
|
|
70
|
+
// Calculate pageHeight based on measure count and staff count
|
|
71
71
|
const measureCount = doc.measures?.length || 1;
|
|
72
|
+
// Calculate total staff count
|
|
73
|
+
let staffCount = 1;
|
|
74
|
+
if (doc.measures && doc.measures.length > 0) {
|
|
75
|
+
const firstMeasure = doc.measures[0];
|
|
76
|
+
staffCount = firstMeasure.parts.reduce((total, part) => {
|
|
77
|
+
const maxStaff = part.voices.reduce((max, voice) => Math.max(max, voice.staff || 1), 1);
|
|
78
|
+
return total + maxStaff;
|
|
79
|
+
}, 0) || 1;
|
|
80
|
+
}
|
|
72
81
|
const basePageHeight = 2000;
|
|
73
82
|
const measuresPerPage = 20;
|
|
74
|
-
const pageHeight = Math.max(basePageHeight, Math.ceil(measureCount / measuresPerPage) * basePageHeight);
|
|
83
|
+
const pageHeight = Math.max(basePageHeight, Math.ceil(measureCount / measuresPerPage) * basePageHeight) * 2 * staffCount;
|
|
75
84
|
// Set Verovio options with dynamic pageHeight
|
|
76
85
|
if (verovioToolkit.setOptions) {
|
|
77
86
|
verovioToolkit.setOptions({
|