@bendyline/squisq-react 2.12.27 → 2.12.29

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.
@@ -12,7 +12,7 @@ import {
12
12
  getAnchorOffset,
13
13
  getTransitionClass,
14
14
  resolveValue
15
- } from "./chunk-E7TEWUNF.js";
15
+ } from "./chunk-DRPMS5JK.js";
16
16
 
17
17
  // src/BlockRenderer.tsx
18
18
  import { useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
@@ -1,11 +1,14 @@
1
1
  import {
2
- MermaidDiagram
3
- } from "./chunk-A65WPCGZ.js";
2
+ MermaidDiagram,
3
+ mediaCropStyle,
4
+ useCutTimeMap,
5
+ useSkipCuts
6
+ } from "./chunk-FXAKS6KU.js";
4
7
  import {
5
8
  svgDataImageSrc,
6
9
  useMediaProvider,
7
10
  useMediaUrl
8
- } from "./chunk-OTYJ4MRH.js";
11
+ } from "./chunk-ZKMBIWAA.js";
9
12
 
10
13
  // src/hooks/FenceRendererContext.tsx
11
14
  import { createContext, useContext } from "react";
@@ -15,6 +18,7 @@ function useFenceRenderers() {
15
18
  }
16
19
 
17
20
  // src/InlineVideoPlayer.tsx
21
+ import { useRef } from "react";
18
22
  import { jsx } from "react/jsx-runtime";
19
23
  function InlineVideoPlayer({
20
24
  src,
@@ -25,15 +29,20 @@ function InlineVideoPlayer({
25
29
  controls = true,
26
30
  preload = "metadata",
27
31
  className,
28
- label
32
+ label,
33
+ edits
29
34
  }) {
30
35
  const resolvedSrc = useMediaUrl(src, basePath);
36
+ const videoRef = useRef(null);
37
+ useSkipCuts(videoRef, useCutTimeMap(edits?.cuts), resolvedSrc);
31
38
  const resolvedPoster = useMediaUrl(poster ?? "", basePath);
32
39
  const posterUrl = poster ? resolvedPoster : void 0;
33
40
  if (!resolvedSrc) return null;
34
41
  return /* @__PURE__ */ jsx("span", { className: `squisq-inline-video-player ${className ?? ""}`.trim(), children: /* @__PURE__ */ jsx(
35
42
  "video",
36
43
  {
44
+ ref: videoRef,
45
+ style: mediaCropStyle(edits?.crop),
37
46
  src: resolvedSrc,
38
47
  poster: posterUrl,
39
48
  controls,
@@ -48,6 +57,7 @@ function InlineVideoPlayer({
48
57
  }
49
58
 
50
59
  // src/InlineAudioPlayer.tsx
60
+ import { useRef as useRef2 } from "react";
51
61
  import { jsx as jsx2 } from "react/jsx-runtime";
52
62
  function InlineAudioPlayer({
53
63
  src,
@@ -55,13 +65,17 @@ function InlineAudioPlayer({
55
65
  controls = true,
56
66
  preload = "metadata",
57
67
  className,
58
- label
68
+ label,
69
+ edits
59
70
  }) {
60
71
  const resolvedSrc = useMediaUrl(src, basePath);
72
+ const audioRef = useRef2(null);
73
+ useSkipCuts(audioRef, useCutTimeMap(edits?.cuts), resolvedSrc);
61
74
  if (!resolvedSrc) return null;
62
75
  return /* @__PURE__ */ jsx2("span", { className: `squisq-inline-audio-player ${className ?? ""}`.trim(), children: /* @__PURE__ */ jsx2(
63
76
  "audio",
64
77
  {
78
+ ref: audioRef,
65
79
  src: resolvedSrc,
66
80
  controls,
67
81
  preload,
@@ -125,11 +139,11 @@ function VideoEmbedFrame({
125
139
  }
126
140
 
127
141
  // src/animatedImage/AnimatedImageControls.tsx
128
- import { useLayoutEffect, useRef } from "react";
142
+ import { useLayoutEffect, useRef as useRef3 } from "react";
129
143
  import { Fragment, jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
130
144
  var FORMAT_LABELS = { gif: "GIF", webp: "WEBP", png: "APNG" };
131
145
  function AnimatedImageControls({ playback, imageRef }) {
132
- const canvasRef = useRef(null);
146
+ const canvasRef = useRef3(null);
133
147
  const { info, status, displaySrc } = playback;
134
148
  const paused = status === "paused";
135
149
  const animated = info?.animated ?? false;
@@ -199,7 +213,7 @@ function StatusGlyph({ status }) {
199
213
  }
200
214
 
201
215
  // src/animatedImage/useAnimatedImage.ts
202
- import { useCallback, useEffect, useRef as useRef2, useState } from "react";
216
+ import { useCallback, useEffect, useRef as useRef4, useState } from "react";
203
217
  import {
204
218
  inspectAnimatedImage,
205
219
  mayBeAnimatedImage
@@ -242,8 +256,8 @@ function useAnimatedImage(src, resolvedUrl) {
242
256
  const [status, setStatus] = useState(initialStatus);
243
257
  const [replayUrl, setReplayUrl] = useState(null);
244
258
  const [run, setRun] = useState(0);
245
- const generationRef = useRef2(0);
246
- const replayUrlRef = useRef2(null);
259
+ const generationRef = useRef4(0);
260
+ const replayUrlRef = useRef4(null);
247
261
  const swapReplayUrl = useCallback((next) => {
248
262
  if (replayUrlRef.current) URL.revokeObjectURL(replayUrlRef.current);
249
263
  replayUrlRef.current = next;
@@ -309,7 +323,7 @@ function useAnimatedImage(src, resolvedUrl) {
309
323
  }
310
324
 
311
325
  // src/svgIsland/SvgIslandImage.tsx
312
- import { useLayoutEffect as useLayoutEffect2, useMemo, useRef as useRef3, useState as useState2 } from "react";
326
+ import { useLayoutEffect as useLayoutEffect2, useMemo, useRef as useRef5, useState as useState2 } from "react";
313
327
  import { parseSvgIsland, svgIslandDataUrl } from "@bendyline/squisq/markdown";
314
328
  import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
315
329
  function prefersReducedMotion2() {
@@ -322,7 +336,7 @@ function SvgIslandImage({
322
336
  color,
323
337
  className
324
338
  }) {
325
- const figureRef = useRef3(null);
339
+ const figureRef = useRef5(null);
326
340
  const [surroundingColor, setSurroundingColor] = useState2(void 0);
327
341
  const [reducedMotion] = useState2(prefersReducedMotion2);
328
342
  const still = isStatic ?? reducedMotion;
@@ -369,7 +383,7 @@ function SvgIslandImage({
369
383
  }
370
384
 
371
385
  // src/MarkdownRenderer.tsx
372
- import { Component, Fragment as Fragment2, useEffect as useEffect2, useRef as useRef4, useState as useState3 } from "react";
386
+ import { Component, Fragment as Fragment2, useEffect as useEffect2, useRef as useRef6, useState as useState3 } from "react";
373
387
  import { mayBeAnimatedImage as mayBeAnimatedImage2 } from "@bendyline/squisq/imageEdit";
374
388
  import {
375
389
  findBlockVideoEmbed,
@@ -378,6 +392,7 @@ import {
378
392
  sanitizeUrl,
379
393
  videoEmbedFromIframe
380
394
  } from "@bendyline/squisq/markdown";
395
+ import { mediaEditValuesFromAttributes, parseMediaEdits } from "@bendyline/squisq/mediaEdit";
381
396
  import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
382
397
  var DEFAULT_CTX = { htmlPolicy: "sanitize" };
383
398
  function nestedCtx(ctx) {
@@ -405,7 +420,7 @@ function CodeBlock({
405
420
  ctx
406
421
  }) {
407
422
  const [status, setStatus] = useState3("idle");
408
- const resetTimer = useRef4();
423
+ const resetTimer = useRef6();
409
424
  useEffect2(
410
425
  () => () => {
411
426
  if (resetTimer.current !== void 0) clearTimeout(resetTimer.current);
@@ -751,7 +766,7 @@ function MdImage({
751
766
  }) {
752
767
  const safeSrc = sanitizeUrl(src, "media") ?? svgDataImageSrc(src);
753
768
  const resolved = useMediaUrl(safeSrc ?? "", ".");
754
- const imageRef = useRef4(null);
769
+ const imageRef = useRef6(null);
755
770
  const playback = useAnimatedImage(safeSrc ?? "", resolved);
756
771
  if (!safeSrc) return null;
757
772
  if (!mayBeAnimatedImage2(safeSrc)) {
@@ -870,6 +885,7 @@ function renderHtmlElement(el, key, ctx) {
870
885
  InlineVideoPlayer,
871
886
  {
872
887
  src,
888
+ edits: parseMediaEdits(mediaEditValuesFromAttributes("video", el.attributes)),
873
889
  width: el.attributes.width,
874
890
  height: el.attributes.height,
875
891
  poster,
@@ -885,6 +901,7 @@ function renderHtmlElement(el, key, ctx) {
885
901
  InlineAudioPlayer,
886
902
  {
887
903
  src,
904
+ edits: parseMediaEdits(mediaEditValuesFromAttributes("audio", el.attributes)),
888
905
  controls: "controls" in el.attributes,
889
906
  preload: el.attributes.preload === "none" || el.attributes.preload === "metadata" || el.attributes.preload === "auto" ? el.attributes.preload : void 0
890
907
  },