@bendyline/squisq-react 2.12.3 → 2.12.4

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.
@@ -445,7 +445,12 @@ function IconTextLayer({ layer, viewport, blockTime, textScale = 1 }) {
445
445
  "div",
446
446
  {
447
447
  "data-squisq-text-content": "true",
448
- style: { width: "100%", whiteSpace: "pre-wrap", wordBreak: "break-word" },
448
+ style: {
449
+ width: "100%",
450
+ whiteSpace: "pre-wrap",
451
+ wordBreak: "break-word",
452
+ ...baselineShiftStyle(style.baselineShift)
453
+ },
449
454
  dangerouslySetInnerHTML: { __html: html }
450
455
  }
451
456
  )
@@ -491,6 +496,7 @@ function PlainTextLayer({ layer, viewport, blockTime, textScale = 1 }) {
491
496
  const shrinkToFit = style.shrinkToFit === true;
492
497
  const centerBlock = shrinkToFit && dominantBaseline === "middle";
493
498
  const firstLineDy = centerBlock ? -((lines.length - 1) / 2) * lineHeightPx : 0;
499
+ const baselineShiftPx = (style.baselineShift ?? 0) * style.fontSize;
494
500
  const textRef = useRef(null);
495
501
  const [fit, setFit] = useState(null);
496
502
  const linesKey = lines.join("\n");
@@ -607,7 +613,7 @@ function PlainTextLayer({ layer, viewport, blockTime, textScale = 1 }) {
607
613
  style: textStyles,
608
614
  filter: filterId ? `url(#${filterId})` : void 0,
609
615
  transform: fitTransform,
610
- children: lines.map((line, i) => /* @__PURE__ */ jsxs2("tspan", { x, dy: i === 0 ? firstLineDy : lineHeightPx, children: [
616
+ children: lines.map((line, i) => /* @__PURE__ */ jsxs2("tspan", { x, dy: i === 0 ? firstLineDy + baselineShiftPx : lineHeightPx, children: [
611
617
  renderLine(line),
612
618
  " "
613
619
  ] }, i))
@@ -704,7 +710,8 @@ function RichTextLayer({ layer, viewport, blockTime, textScale = 1 }) {
704
710
  width: "100%",
705
711
  color: style.color,
706
712
  whiteSpace: "pre-wrap",
707
- wordBreak: "break-word"
713
+ wordBreak: "break-word",
714
+ ...baselineShiftStyle(style.baselineShift)
708
715
  },
709
716
  dangerouslySetInnerHTML: { __html: safeHtml }
710
717
  }
@@ -758,6 +765,9 @@ function getTextAnchor(align, anchor) {
758
765
  if (anchor === "center") return "middle";
759
766
  return "start";
760
767
  }
768
+ function baselineShiftStyle(shift) {
769
+ return shift ? { position: "relative", top: `${shift}em` } : {};
770
+ }
761
771
  function getDominantBaseline(verticalAlign, anchor) {
762
772
  if (verticalAlign === "top") return "text-before-edge";
763
773
  if (verticalAlign === "middle") return "middle";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  LinearDocView
3
- } from "./chunk-PVRZGR5J.js";
3
+ } from "./chunk-MGFMKGZY.js";
4
4
 
5
5
  // src/PaginatedDocView.tsx
6
6
  import {