@bendyline/squisq-react 2.12.3 → 2.12.5

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";
@@ -5,10 +5,10 @@ import {
5
5
  InlineVideoPlayer,
6
6
  MarkdownRenderer,
7
7
  VideoEmbedFrame
8
- } from "./chunk-YVQ7KEYI.js";
8
+ } from "./chunk-IERUAQFK.js";
9
9
  import {
10
10
  BlockRenderer
11
- } from "./chunk-M7DM4NOX.js";
11
+ } from "./chunk-PFKYO6C2.js";
12
12
  import {
13
13
  svgDataImageSrc,
14
14
  useMediaUrl
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  LinearDocView
3
- } from "./chunk-PVRZGR5J.js";
3
+ } from "./chunk-5KK6I55U.js";
4
4
 
5
5
  // src/PaginatedDocView.tsx
6
6
  import {
@@ -536,7 +536,17 @@ function renderInline(nodes, keyPrefix = "", ctx = DEFAULT_CTX) {
536
536
  const label = node.alt || node.title || void 0;
537
537
  return kind === "video" ? /* @__PURE__ */ jsx6(InlineVideoPlayer, { src, basePath: ".", label }, key) : /* @__PURE__ */ jsx6(InlineAudioPlayer, { src, basePath: ".", label }, key);
538
538
  }
539
- return /* @__PURE__ */ jsx6(MdImage, { src: node.url, alt: node.alt ?? "", title: node.title ?? void 0 }, key);
539
+ return /* @__PURE__ */ jsx6(
540
+ MdImage,
541
+ {
542
+ src: node.url,
543
+ alt: node.alt ?? "",
544
+ title: node.title ?? void 0,
545
+ width: node.width,
546
+ height: node.height
547
+ },
548
+ key
549
+ );
540
550
  }
541
551
  case "break":
542
552
  return /* @__PURE__ */ jsx6("br", {}, key);
@@ -732,14 +742,30 @@ function renderTable(rows, align, key, ctx = DEFAULT_CTX) {
732
742
  function renderBlocks(nodes, keyPrefix = "", ctx = DEFAULT_CTX) {
733
743
  return nodes.map((node, i) => renderBlock(node, `${keyPrefix}b${i}`, ctx));
734
744
  }
735
- function MdImage({ src, alt, title }) {
745
+ function MdImage({
746
+ src,
747
+ alt,
748
+ title,
749
+ width,
750
+ height
751
+ }) {
736
752
  const safeSrc = sanitizeUrl(src, "media") ?? svgDataImageSrc(src);
737
753
  const resolved = useMediaUrl(safeSrc ?? "", ".");
738
754
  const imageRef = useRef4(null);
739
755
  const playback = useAnimatedImage(safeSrc ?? "", resolved);
740
756
  if (!safeSrc) return null;
741
757
  if (!mayBeAnimatedImage2(safeSrc)) {
742
- return /* @__PURE__ */ jsx6("img", { className: "squisq-md-image", src: resolved, alt, title });
758
+ return /* @__PURE__ */ jsx6(
759
+ "img",
760
+ {
761
+ className: "squisq-md-image",
762
+ src: resolved,
763
+ alt,
764
+ title,
765
+ width,
766
+ height
767
+ }
768
+ );
743
769
  }
744
770
  return /* @__PURE__ */ jsxs4(
745
771
  "span",
@@ -756,6 +782,8 @@ function MdImage({ src, alt, title }) {
756
782
  src: playback.displaySrc,
757
783
  alt,
758
784
  title,
785
+ width,
786
+ height,
759
787
  style: { display: "block", maxWidth: "100%" }
760
788
  }
761
789
  ),
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-TT6ENR6T.js";
4
4
  import {
5
5
  MarkdownRenderer
6
- } from "./chunk-YVQ7KEYI.js";
6
+ } from "./chunk-IERUAQFK.js";
7
7
 
8
8
  // src/jsonView/useJsonViewTokens.ts
9
9
  import { useMemo } from "react";
@@ -12,7 +12,7 @@ import {
12
12
  getAnchorOffset,
13
13
  getTransitionClass,
14
14
  resolveValue
15
- } from "./chunk-LWB4AM3W.js";
15
+ } from "./chunk-4ILJDBJ7.js";
16
16
 
17
17
  // src/BlockRenderer.tsx
18
18
  import { useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";