@bendyline/squisq 2.0.0 → 2.0.1
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/{chunk-QTSJOY54.js → chunk-2PWOO4ZE.js} +2 -2
- package/dist/{chunk-T3TI7GSZ.js → chunk-CY2R2VPR.js} +2 -2
- package/dist/{chunk-LYNJEOAC.js → chunk-MMPBOUK7.js} +2 -2
- package/dist/{chunk-QVANWDPH.js → chunk-TFJVXUHH.js} +3 -3
- package/dist/{chunk-6PJRB2CF.js → chunk-W4O2TX5I.js} +2 -2
- package/dist/{chunk-6PJRB2CF.js.map → chunk-W4O2TX5I.js.map} +1 -1
- package/dist/{chunk-GF3BVNLU.js → chunk-X6DUONGT.js} +74 -19
- package/dist/chunk-X6DUONGT.js.map +1 -0
- package/dist/doc/index.js +3 -3
- package/dist/index.js +6 -6
- package/dist/jsonForm/index.js +3 -3
- package/dist/narration/index.js +3 -3
- package/dist/schemas/index.js +2 -2
- package/package.json +1 -1
- package/src/__tests__/customThemesFrontmatter.test.ts +1 -0
- package/src/__tests__/markdown.test.ts +13 -4
- package/src/__tests__/markdownSanitize.test.ts +7 -5
- package/src/doc/markdownToDoc.ts +3 -1
- package/src/doc/templates/__tests__/listBlock.test.ts +64 -0
- package/src/doc/templates/listBlock.ts +88 -30
- package/src/schemas/themes/gezellig.json +1 -1
- package/dist/chunk-GF3BVNLU.js.map +0 -1
- /package/dist/{chunk-QTSJOY54.js.map → chunk-2PWOO4ZE.js.map} +0 -0
- /package/dist/{chunk-T3TI7GSZ.js.map → chunk-CY2R2VPR.js.map} +0 -0
- /package/dist/{chunk-LYNJEOAC.js.map → chunk-MMPBOUK7.js.map} +0 -0
- /package/dist/{chunk-QVANWDPH.js.map → chunk-TFJVXUHH.js.map} +0 -0
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
resolveFontFamily,
|
|
31
31
|
validateTheme,
|
|
32
32
|
withAlpha
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-W4O2TX5I.js";
|
|
34
34
|
import {
|
|
35
35
|
VIEWPORT_PRESETS,
|
|
36
36
|
cloneData,
|
|
@@ -51,6 +51,7 @@ import {
|
|
|
51
51
|
} from "./chunk-R2YZTCLO.js";
|
|
52
52
|
import {
|
|
53
53
|
extractPlainText,
|
|
54
|
+
readFrontmatterThemeId,
|
|
54
55
|
walkMarkdownTree
|
|
55
56
|
} from "./chunk-AMIR72JP.js";
|
|
56
57
|
import {
|
|
@@ -1919,6 +1920,30 @@ function fullBleedQuote(input, context) {
|
|
|
1919
1920
|
}
|
|
1920
1921
|
|
|
1921
1922
|
// src/doc/templates/listBlock.ts
|
|
1923
|
+
var LIST_ITEM_LINE_HEIGHT = 1.2;
|
|
1924
|
+
var LIST_ITEM_GAP_PX = 18;
|
|
1925
|
+
function estimateWrappedLineCount(text, fontSize, maxWidth) {
|
|
1926
|
+
if (!text.trim()) return 1;
|
|
1927
|
+
const charsPerLine = Math.floor(maxWidth / (fontSize * 0.5));
|
|
1928
|
+
if (charsPerLine <= 0) return 1;
|
|
1929
|
+
let lineCount = 0;
|
|
1930
|
+
let currentLineLength = 0;
|
|
1931
|
+
for (const word of text.split(/\s+/)) {
|
|
1932
|
+
const testLineLength = currentLineLength ? currentLineLength + 1 + word.length : word.length;
|
|
1933
|
+
if (testLineLength <= charsPerLine) {
|
|
1934
|
+
currentLineLength = testLineLength;
|
|
1935
|
+
continue;
|
|
1936
|
+
}
|
|
1937
|
+
if (currentLineLength) lineCount += 1;
|
|
1938
|
+
let remainingLength = word.length;
|
|
1939
|
+
while (remainingLength > charsPerLine) {
|
|
1940
|
+
lineCount += 1;
|
|
1941
|
+
remainingLength -= charsPerLine;
|
|
1942
|
+
}
|
|
1943
|
+
currentLineLength = remainingLength;
|
|
1944
|
+
}
|
|
1945
|
+
return Math.max(1, lineCount + (currentLineLength ? 1 : 0));
|
|
1946
|
+
}
|
|
1922
1947
|
function listBlock(input, context) {
|
|
1923
1948
|
const { title, accentImage } = input;
|
|
1924
1949
|
const items = Array.isArray(input.items) ? input.items : [];
|
|
@@ -1949,7 +1974,8 @@ function listBlock(input, context) {
|
|
|
1949
1974
|
}
|
|
1950
1975
|
const centerX = parseFloat(accentLayout.textCenterX);
|
|
1951
1976
|
const widthPct = parseFloat(accentLayout.textWidth);
|
|
1952
|
-
const
|
|
1977
|
+
const leftPct = Number.isFinite(centerX) && Number.isFinite(widthPct) ? centerX - widthPct / 2 : 8;
|
|
1978
|
+
const leftX = `${leftPct}%`;
|
|
1953
1979
|
const startY = title ? 34 : 26;
|
|
1954
1980
|
if (title) {
|
|
1955
1981
|
layers.push({
|
|
@@ -1974,14 +2000,43 @@ function listBlock(input, context) {
|
|
|
1974
2000
|
animation: themedEntrance(context, "text", { type: "fadeIn", duration: 1 })
|
|
1975
2001
|
});
|
|
1976
2002
|
}
|
|
1977
|
-
const
|
|
1978
|
-
const
|
|
1979
|
-
const
|
|
1980
|
-
const
|
|
1981
|
-
const
|
|
2003
|
+
const textWidthPx = (Number.isFinite(widthPct) ? widthPct / 100 : 0.85) * context.viewport.width;
|
|
2004
|
+
const markerText = `${items.length}.`;
|
|
2005
|
+
const markerWidthPx = Math.max(itemFontSize, markerText.length * itemFontSize * 0.5);
|
|
2006
|
+
const markerGapPx = itemFontSize * 0.35;
|
|
2007
|
+
const bodyIndentPx = markerWidthPx + markerGapPx;
|
|
2008
|
+
const bodyLeftX = `${leftPct + bodyIndentPx / context.viewport.width * 100}%`;
|
|
2009
|
+
const bodyWidthPx = Math.max(itemFontSize, textWidthPx - bodyIndentPx);
|
|
2010
|
+
let itemY = startY;
|
|
1982
2011
|
for (let i = 0; i < items.length; i++) {
|
|
1983
|
-
const
|
|
1984
|
-
const
|
|
2012
|
+
const itemText = items[i];
|
|
2013
|
+
const lineCount = estimateWrappedLineCount(itemText, itemFontSize, bodyWidthPx);
|
|
2014
|
+
const animation = themedEntrance(context, "text", {
|
|
2015
|
+
type: "fadeIn",
|
|
2016
|
+
duration: 0.8,
|
|
2017
|
+
delay: 0.3 + 0.3 * i
|
|
2018
|
+
});
|
|
2019
|
+
layers.push({
|
|
2020
|
+
type: "text",
|
|
2021
|
+
id: `item-${i}-marker`,
|
|
2022
|
+
content: {
|
|
2023
|
+
text: `${i + 1}.`,
|
|
2024
|
+
style: {
|
|
2025
|
+
fontSize: itemFontSize,
|
|
2026
|
+
fontFamily: getThemeFont(context, "body"),
|
|
2027
|
+
color: theme.colors.text,
|
|
2028
|
+
textAlign: "right",
|
|
2029
|
+
lineHeight: LIST_ITEM_LINE_HEIGHT,
|
|
2030
|
+
shadow: shouldUseShadow(context)
|
|
2031
|
+
}
|
|
2032
|
+
},
|
|
2033
|
+
position: {
|
|
2034
|
+
x: leftX,
|
|
2035
|
+
y: adjustY(`${itemY}%`, accentLayout),
|
|
2036
|
+
width: markerWidthPx
|
|
2037
|
+
},
|
|
2038
|
+
animation
|
|
2039
|
+
});
|
|
1985
2040
|
layers.push({
|
|
1986
2041
|
type: "text",
|
|
1987
2042
|
id: `item-${i}`,
|
|
@@ -1992,21 +2047,19 @@ function listBlock(input, context) {
|
|
|
1992
2047
|
fontFamily: getThemeFont(context, "body"),
|
|
1993
2048
|
color: theme.colors.text,
|
|
1994
2049
|
textAlign: "left",
|
|
1995
|
-
lineHeight:
|
|
2050
|
+
lineHeight: LIST_ITEM_LINE_HEIGHT,
|
|
1996
2051
|
shadow: shouldUseShadow(context)
|
|
1997
2052
|
}
|
|
1998
2053
|
},
|
|
1999
2054
|
position: {
|
|
2000
|
-
x:
|
|
2001
|
-
y: adjustY(`${
|
|
2002
|
-
width:
|
|
2055
|
+
x: bodyLeftX,
|
|
2056
|
+
y: adjustY(`${itemY}%`, accentLayout),
|
|
2057
|
+
width: bodyWidthPx
|
|
2003
2058
|
},
|
|
2004
|
-
animation
|
|
2005
|
-
type: "fadeIn",
|
|
2006
|
-
duration: 0.8,
|
|
2007
|
-
delay: 0.3 + 0.3 * i
|
|
2008
|
-
})
|
|
2059
|
+
animation
|
|
2009
2060
|
});
|
|
2061
|
+
const itemHeightPx = lineCount * itemFontSize * LIST_ITEM_LINE_HEIGHT;
|
|
2062
|
+
itemY += (itemHeightPx + LIST_ITEM_GAP_PX) / context.viewport.height * 100;
|
|
2010
2063
|
}
|
|
2011
2064
|
return layers;
|
|
2012
2065
|
}
|
|
@@ -7132,6 +7185,7 @@ function markdownToDoc(markdownDoc, options) {
|
|
|
7132
7185
|
} : void 0;
|
|
7133
7186
|
const customTemplates = readCustomTemplatesFromFrontmatter(markdownDoc.frontmatter);
|
|
7134
7187
|
const customThemes = readCustomThemesFromFrontmatter(markdownDoc.frontmatter);
|
|
7188
|
+
const themeId = readFrontmatterThemeId(markdownDoc.frontmatter);
|
|
7135
7189
|
const doc = {
|
|
7136
7190
|
articleId,
|
|
7137
7191
|
duration: currentTime,
|
|
@@ -7141,6 +7195,7 @@ function markdownToDoc(markdownDoc, options) {
|
|
|
7141
7195
|
},
|
|
7142
7196
|
...captions ? { captions } : {},
|
|
7143
7197
|
...markdownDoc.frontmatter ? { frontmatter: markdownDoc.frontmatter } : {},
|
|
7198
|
+
...themeId ? { themeId } : {},
|
|
7144
7199
|
...customTemplates ? { customTemplates } : {},
|
|
7145
7200
|
...customThemes ? { customThemes } : {},
|
|
7146
7201
|
...diagnostics.length > 0 ? { diagnostics } : {},
|
|
@@ -7842,4 +7897,4 @@ export {
|
|
|
7842
7897
|
buildNarrationTimingJson,
|
|
7843
7898
|
parseNarrationTimingJson
|
|
7844
7899
|
};
|
|
7845
|
-
//# sourceMappingURL=chunk-
|
|
7900
|
+
//# sourceMappingURL=chunk-X6DUONGT.js.map
|