@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.
@@ -30,7 +30,7 @@ import {
30
30
  resolveFontFamily,
31
31
  validateTheme,
32
32
  withAlpha
33
- } from "./chunk-6PJRB2CF.js";
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 leftX = Number.isFinite(centerX) && Number.isFinite(widthPct) ? `${centerX - widthPct / 2}%` : "8%";
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 LIST_ITEM_BASE_PX = 34;
1978
- const LIST_ITEM_LINE_HEIGHT = 1.2;
1979
- const LIST_ITEM_GAP_PX = 18;
1980
- const DESIGN_HEIGHT_PX = 1080;
1981
- const spacing = (LIST_ITEM_BASE_PX * LIST_ITEM_LINE_HEIGHT + LIST_ITEM_GAP_PX) / DESIGN_HEIGHT_PX * 100;
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 y = startY + spacing * i;
1984
- const itemText = `${i + 1}. ${items[i]}`;
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: 1.2,
2050
+ lineHeight: LIST_ITEM_LINE_HEIGHT,
1996
2051
  shadow: shouldUseShadow(context)
1997
2052
  }
1998
2053
  },
1999
2054
  position: {
2000
- x: leftX,
2001
- y: adjustY(`${y}%`, accentLayout),
2002
- width: accentLayout.textWidth
2055
+ x: bodyLeftX,
2056
+ y: adjustY(`${itemY}%`, accentLayout),
2057
+ width: bodyWidthPx
2003
2058
  },
2004
- animation: themedEntrance(context, "text", {
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-GF3BVNLU.js.map
7900
+ //# sourceMappingURL=chunk-X6DUONGT.js.map