@bendyline/squisq-react 2.11.17 → 2.11.19

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.
@@ -23,7 +23,8 @@ function InlineVideoPlayer({
23
23
  poster,
24
24
  controls = true,
25
25
  preload = "metadata",
26
- className
26
+ className,
27
+ label
27
28
  }) {
28
29
  const resolvedSrc = useMediaUrl(src, basePath);
29
30
  const resolvedPoster = useMediaUrl(poster ?? "", basePath);
@@ -38,7 +39,9 @@ function InlineVideoPlayer({
38
39
  preload,
39
40
  width,
40
41
  height,
41
- playsInline: true
42
+ playsInline: true,
43
+ "aria-label": label,
44
+ title: label
42
45
  }
43
46
  ) });
44
47
  }
@@ -50,16 +53,79 @@ function InlineAudioPlayer({
50
53
  basePath = "",
51
54
  controls = true,
52
55
  preload = "metadata",
53
- className
56
+ className,
57
+ label
54
58
  }) {
55
59
  const resolvedSrc = useMediaUrl(src, basePath);
56
60
  if (!resolvedSrc) return null;
57
- return /* @__PURE__ */ jsx2("span", { className: `squisq-inline-audio-player ${className ?? ""}`.trim(), children: /* @__PURE__ */ jsx2("audio", { src: resolvedSrc, controls, preload }) });
61
+ return /* @__PURE__ */ jsx2("span", { className: `squisq-inline-audio-player ${className ?? ""}`.trim(), children: /* @__PURE__ */ jsx2(
62
+ "audio",
63
+ {
64
+ src: resolvedSrc,
65
+ controls,
66
+ preload,
67
+ "aria-label": label,
68
+ title: label
69
+ }
70
+ ) });
71
+ }
72
+
73
+ // src/VideoEmbedFrame.tsx
74
+ import { videoEmbedIframeAttributes } from "@bendyline/squisq/markdown";
75
+ import { jsx as jsx3, jsxs } from "react/jsx-runtime";
76
+ var IFRAME_STYLE = {
77
+ position: "absolute",
78
+ inset: 0,
79
+ width: "100%",
80
+ height: "100%",
81
+ border: 0
82
+ };
83
+ function VideoEmbedFrame({
84
+ embed,
85
+ title,
86
+ showCaption = true,
87
+ inline = false,
88
+ className
89
+ }) {
90
+ const attrs = videoEmbedIframeAttributes(embed, title);
91
+ const portrait = embed.aspectRatio < 1;
92
+ const caption = showCaption && !inline ? title?.trim() : "";
93
+ const Root = inline ? "span" : "figure";
94
+ return /* @__PURE__ */ jsxs(
95
+ Root,
96
+ {
97
+ className: `squisq-video-embed ${className ?? ""}`.trim(),
98
+ "data-provider": embed.provider,
99
+ "data-orientation": portrait ? "portrait" : "landscape",
100
+ children: [
101
+ /* @__PURE__ */ jsx3(
102
+ "span",
103
+ {
104
+ className: "squisq-video-embed-frame",
105
+ style: { position: "relative", display: "block", aspectRatio: String(embed.aspectRatio) },
106
+ children: /* @__PURE__ */ jsx3(
107
+ "iframe",
108
+ {
109
+ src: attrs.src,
110
+ title: attrs.title,
111
+ allow: attrs.allow,
112
+ allowFullScreen: true,
113
+ referrerPolicy: "strict-origin-when-cross-origin",
114
+ loading: "lazy",
115
+ style: IFRAME_STYLE
116
+ }
117
+ )
118
+ }
119
+ ),
120
+ caption ? /* @__PURE__ */ jsx3("figcaption", { className: "squisq-video-embed-caption", children: /* @__PURE__ */ jsx3("a", { href: embed.watchUrl, target: "_blank", rel: "noopener noreferrer", children: caption }) }) : null
121
+ ]
122
+ }
123
+ );
58
124
  }
59
125
 
60
126
  // src/animatedImage/AnimatedImageControls.tsx
61
127
  import { useLayoutEffect, useRef } from "react";
62
- import { Fragment, jsx as jsx3, jsxs } from "react/jsx-runtime";
128
+ import { Fragment, jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
63
129
  var FORMAT_LABELS = { gif: "GIF", webp: "WEBP", png: "APNG" };
64
130
  function AnimatedImageControls({ playback, imageRef }) {
65
131
  const canvasRef = useRef(null);
@@ -86,8 +152,8 @@ function AnimatedImageControls({ playback, imageRef }) {
86
152
  }, [paused, animated, displaySrc, imageRef]);
87
153
  if (!info || !animated) return null;
88
154
  const label = status === "playing" ? "Pause animation" : status === "ended" ? "Replay animation" : "Play animation";
89
- return /* @__PURE__ */ jsxs(Fragment, { children: [
90
- paused && /* @__PURE__ */ jsx3(
155
+ return /* @__PURE__ */ jsxs2(Fragment, { children: [
156
+ paused && /* @__PURE__ */ jsx4(
91
157
  "canvas",
92
158
  {
93
159
  ref: canvasRef,
@@ -102,7 +168,7 @@ function AnimatedImageControls({ playback, imageRef }) {
102
168
  }
103
169
  }
104
170
  ),
105
- /* @__PURE__ */ jsxs(
171
+ /* @__PURE__ */ jsxs2(
106
172
  "button",
107
173
  {
108
174
  type: "button",
@@ -119,8 +185,8 @@ function AnimatedImageControls({ playback, imageRef }) {
119
185
  else playback.play();
120
186
  },
121
187
  children: [
122
- /* @__PURE__ */ jsx3(StatusGlyph, { status }),
123
- /* @__PURE__ */ jsx3("span", { className: "squisq-animated-image-format", children: FORMAT_LABELS[info.format] })
188
+ /* @__PURE__ */ jsx4(StatusGlyph, { status }),
189
+ /* @__PURE__ */ jsx4("span", { className: "squisq-animated-image-format", children: FORMAT_LABELS[info.format] })
124
190
  ]
125
191
  }
126
192
  )
@@ -128,7 +194,7 @@ function AnimatedImageControls({ playback, imageRef }) {
128
194
  }
129
195
  function StatusGlyph({ status }) {
130
196
  const path = status === "playing" ? "M2.5 1.5h2.75v9H2.5zM6.75 1.5H9.5v9H6.75z" : status === "ended" ? "M6 1.5V0L3.5 2.25 6 4.5V3a3 3 0 1 1-3 3H1.5A4.5 4.5 0 1 0 6 1.5z" : "M3 1.5v9l7.5-4.5z";
131
- return /* @__PURE__ */ jsx3("svg", { viewBox: "0 0 12 12", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ jsx3("path", { d: path }) });
197
+ return /* @__PURE__ */ jsx4("svg", { viewBox: "0 0 12 12", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ jsx4("path", { d: path }) });
132
198
  }
133
199
 
134
200
  // src/animatedImage/useAnimatedImage.ts
@@ -245,11 +311,17 @@ function useAnimatedImage(src, resolvedUrl) {
245
311
  import { Component, Fragment as Fragment2, useEffect as useEffect2, useRef as useRef3, useState as useState2 } from "react";
246
312
  import { mayBeAnimatedImage as mayBeAnimatedImage2 } from "@bendyline/squisq/imageEdit";
247
313
  import {
314
+ findBlockVideoEmbed,
248
315
  sanitizeHtmlNodes,
249
- sanitizeUrl
316
+ mediaKindForUrl,
317
+ sanitizeUrl,
318
+ videoEmbedFromIframe
250
319
  } from "@bendyline/squisq/markdown";
251
- import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
320
+ import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
252
321
  var DEFAULT_CTX = { htmlPolicy: "sanitize" };
322
+ function nestedCtx(ctx) {
323
+ return ctx.nested ? ctx : { ...ctx, nested: true };
324
+ }
253
325
  var CODE_COPY_LABELS = {
254
326
  idle: "Copy",
255
327
  copying: "Copying\u2026",
@@ -279,7 +351,7 @@ function CodeBlock({
279
351
  },
280
352
  []
281
353
  );
282
- const pre = /* @__PURE__ */ jsx4("pre", { className: "squisq-md-code-block", children: /* @__PURE__ */ jsx4("code", { className: language ? `language-${language}` : void 0, children: value }) });
354
+ const pre = /* @__PURE__ */ jsx5("pre", { className: "squisq-md-code-block", children: /* @__PURE__ */ jsx5("code", { className: language ? `language-${language}` : void 0, children: value }) });
283
355
  if (!ctx.showCodeCopyButton) return pre;
284
356
  const handleCopy = async () => {
285
357
  if (status === "copying") return;
@@ -293,9 +365,9 @@ function CodeBlock({
293
365
  if (resetTimer.current !== void 0) clearTimeout(resetTimer.current);
294
366
  resetTimer.current = setTimeout(() => setStatus("idle"), 1600);
295
367
  };
296
- return /* @__PURE__ */ jsxs2("div", { className: "squisq-md-code-frame", children: [
368
+ return /* @__PURE__ */ jsxs3("div", { className: "squisq-md-code-frame", children: [
297
369
  pre,
298
- /* @__PURE__ */ jsx4(
370
+ /* @__PURE__ */ jsx5(
299
371
  "button",
300
372
  {
301
373
  type: "button",
@@ -328,7 +400,7 @@ function HostFence({
328
400
  }) {
329
401
  const renderer = ctx.fenceRenderers?.[lang];
330
402
  if (!renderer) return null;
331
- return /* @__PURE__ */ jsx4("div", { className: `squisq-md-fence-widget squisq-md-fence-widget-${lang}`, "data-fence-lang": lang, children: renderer({
403
+ return /* @__PURE__ */ jsx5("div", { className: `squisq-md-fence-widget squisq-md-fence-widget-${lang}`, "data-fence-lang": lang, children: renderer({
332
404
  lang,
333
405
  ...node.meta != null ? { meta: node.meta } : {},
334
406
  value: node.value,
@@ -342,37 +414,37 @@ function renderInline(nodes, keyPrefix = "", ctx = DEFAULT_CTX) {
342
414
  switch (node.type) {
343
415
  case "text": {
344
416
  if (!node.value.includes("\n")) {
345
- return /* @__PURE__ */ jsx4(Fragment2, { children: node.value }, key);
417
+ return /* @__PURE__ */ jsx5(Fragment2, { children: node.value }, key);
346
418
  }
347
419
  const parts = node.value.split("\n");
348
- return /* @__PURE__ */ jsx4(Fragment2, { children: parts.map((part, j) => /* @__PURE__ */ jsxs2(Fragment2, { children: [
349
- j > 0 && /* @__PURE__ */ jsx4("br", {}),
420
+ return /* @__PURE__ */ jsx5(Fragment2, { children: parts.map((part, j) => /* @__PURE__ */ jsxs3(Fragment2, { children: [
421
+ j > 0 && /* @__PURE__ */ jsx5("br", {}),
350
422
  part
351
423
  ] }, j)) }, key);
352
424
  }
353
425
  case "emphasis":
354
- return /* @__PURE__ */ jsx4("em", { className: "squisq-md-em", children: renderInline(node.children, key, ctx) }, key);
426
+ return /* @__PURE__ */ jsx5("em", { className: "squisq-md-em", children: renderInline(node.children, key, ctx) }, key);
355
427
  case "strong":
356
- return /* @__PURE__ */ jsx4("strong", { className: "squisq-md-strong", children: renderInline(node.children, key, ctx) }, key);
428
+ return /* @__PURE__ */ jsx5("strong", { className: "squisq-md-strong", children: renderInline(node.children, key, ctx) }, key);
357
429
  case "delete":
358
- return /* @__PURE__ */ jsx4("del", { className: "squisq-md-del", children: renderInline(node.children, key, ctx) }, key);
430
+ return /* @__PURE__ */ jsx5("del", { className: "squisq-md-del", children: renderInline(node.children, key, ctx) }, key);
359
431
  case "superscript":
360
- return /* @__PURE__ */ jsx4("sup", { className: "squisq-md-sup", children: renderInline(node.children, key, ctx) }, key);
432
+ return /* @__PURE__ */ jsx5("sup", { className: "squisq-md-sup", children: renderInline(node.children, key, ctx) }, key);
361
433
  case "subscript":
362
- return /* @__PURE__ */ jsx4("sub", { className: "squisq-md-sub", children: renderInline(node.children, key, ctx) }, key);
434
+ return /* @__PURE__ */ jsx5("sub", { className: "squisq-md-sub", children: renderInline(node.children, key, ctx) }, key);
363
435
  case "inlineCode":
364
- return /* @__PURE__ */ jsx4("code", { className: "squisq-md-inline-code", children: node.value }, key);
436
+ return /* @__PURE__ */ jsx5("code", { className: "squisq-md-inline-code", children: node.value }, key);
365
437
  case "link": {
366
438
  if (ctx.accessoryPaths?.has(node.url)) {
367
- return /* @__PURE__ */ jsxs2(
439
+ return /* @__PURE__ */ jsxs3(
368
440
  "span",
369
441
  {
370
442
  className: "squisq-md-attachment",
371
443
  "data-attachment-path": node.url,
372
444
  title: node.title ?? `Attachment: ${node.url}`,
373
445
  children: [
374
- /* @__PURE__ */ jsx4("i", { className: "fa-solid fa-paperclip", "aria-hidden": "true" }),
375
- /* @__PURE__ */ jsx4("span", { className: "squisq-md-attachment-label", children: renderInline(node.children, key, ctx) })
446
+ /* @__PURE__ */ jsx5("i", { className: "fa-solid fa-paperclip", "aria-hidden": "true" }),
447
+ /* @__PURE__ */ jsx5("span", { className: "squisq-md-attachment-label", children: renderInline(node.children, key, ctx) })
376
448
  ]
377
449
  },
378
450
  key
@@ -380,9 +452,9 @@ function renderInline(nodes, keyPrefix = "", ctx = DEFAULT_CTX) {
380
452
  }
381
453
  const href = sanitizeUrl(node.url, "link", { extraLinkSchemes: ctx.linkSchemes });
382
454
  if (!href) {
383
- return /* @__PURE__ */ jsx4("span", { className: "squisq-md-link squisq-md-link--blocked", children: renderInline(node.children, key, ctx) }, key);
455
+ return /* @__PURE__ */ jsx5("span", { className: "squisq-md-link squisq-md-link--blocked", children: renderInline(node.children, key, ctx) }, key);
384
456
  }
385
- return /* @__PURE__ */ jsx4(
457
+ return /* @__PURE__ */ jsx5(
386
458
  "a",
387
459
  {
388
460
  className: "squisq-md-link",
@@ -395,14 +467,22 @@ function renderInline(nodes, keyPrefix = "", ctx = DEFAULT_CTX) {
395
467
  key
396
468
  );
397
469
  }
398
- case "image":
399
- return /* @__PURE__ */ jsx4(MdImage, { src: node.url, alt: node.alt ?? "", title: node.title ?? void 0 }, key);
470
+ case "image": {
471
+ const kind = mediaKindForUrl(node.url);
472
+ if (kind) {
473
+ const src = sanitizeUrl(node.url, "media");
474
+ if (!src) return null;
475
+ const label = node.alt || node.title || void 0;
476
+ return kind === "video" ? /* @__PURE__ */ jsx5(InlineVideoPlayer, { src, basePath: ".", label }, key) : /* @__PURE__ */ jsx5(InlineAudioPlayer, { src, basePath: ".", label }, key);
477
+ }
478
+ return /* @__PURE__ */ jsx5(MdImage, { src: node.url, alt: node.alt ?? "", title: node.title ?? void 0 }, key);
479
+ }
400
480
  case "break":
401
- return /* @__PURE__ */ jsx4("br", {}, key);
481
+ return /* @__PURE__ */ jsx5("br", {}, key);
402
482
  case "inlineMath":
403
- return /* @__PURE__ */ jsx4("code", { className: "squisq-md-inline-math", children: node.value }, key);
483
+ return /* @__PURE__ */ jsx5("code", { className: "squisq-md-inline-math", children: node.value }, key);
404
484
  case "inlineIcon":
405
- return /* @__PURE__ */ jsx4(
485
+ return /* @__PURE__ */ jsx5(
406
486
  "i",
407
487
  {
408
488
  className: `fa-${node.family} fa-${node.name}`,
@@ -413,25 +493,25 @@ function renderInline(nodes, keyPrefix = "", ctx = DEFAULT_CTX) {
413
493
  );
414
494
  case "htmlInline":
415
495
  if (ctx.htmlPolicy === "strip") return null;
416
- return /* @__PURE__ */ jsx4("span", { className: "squisq-md-html-inline", children: renderHtmlNodes(resolveHtmlNodes(node.htmlChildren, ctx.htmlPolicy), `${key}h`, ctx) }, key);
496
+ return /* @__PURE__ */ jsx5("span", { className: "squisq-md-html-inline", children: renderHtmlNodes(resolveHtmlNodes(node.htmlChildren, ctx.htmlPolicy), `${key}h`, ctx) }, key);
417
497
  case "footnoteReference":
418
- return /* @__PURE__ */ jsx4("sup", { className: "squisq-md-footnote-ref", children: /* @__PURE__ */ jsxs2("a", { href: `#fn-${node.identifier}`, children: [
498
+ return /* @__PURE__ */ jsx5("sup", { className: "squisq-md-footnote-ref", children: /* @__PURE__ */ jsxs3("a", { href: `#fn-${node.identifier}`, children: [
419
499
  "[",
420
500
  node.label ?? node.identifier,
421
501
  "]"
422
502
  ] }) }, key);
423
503
  case "linkReference":
424
- return /* @__PURE__ */ jsx4("span", { className: "squisq-md-link-ref", children: renderInline(node.children, key, ctx) }, key);
504
+ return /* @__PURE__ */ jsx5("span", { className: "squisq-md-link-ref", children: renderInline(node.children, key, ctx) }, key);
425
505
  case "imageReference":
426
- return /* @__PURE__ */ jsxs2("span", { className: "squisq-md-image-ref", children: [
506
+ return /* @__PURE__ */ jsxs3("span", { className: "squisq-md-image-ref", children: [
427
507
  "[",
428
508
  node.alt ?? node.identifier,
429
509
  "]"
430
510
  ] }, key);
431
511
  case "textDirective":
432
- return /* @__PURE__ */ jsx4("span", { className: "squisq-md-text-directive", "data-directive": node.name, children: renderInline(node.children, key, ctx) }, key);
512
+ return /* @__PURE__ */ jsx5("span", { className: "squisq-md-text-directive", "data-directive": node.name, children: renderInline(node.children, key, ctx) }, key);
433
513
  case "mention":
434
- return /* @__PURE__ */ jsxs2(
514
+ return /* @__PURE__ */ jsxs3(
435
515
  "span",
436
516
  {
437
517
  className: "squisq-md-mention mention",
@@ -453,33 +533,36 @@ function renderInline(nodes, keyPrefix = "", ctx = DEFAULT_CTX) {
453
533
  }
454
534
  function renderBlock(node, key, ctx = DEFAULT_CTX) {
455
535
  switch (node.type) {
456
- case "paragraph":
457
- return /* @__PURE__ */ jsx4("p", { className: "squisq-md-p", children: renderInline(node.children, key, ctx) }, key);
536
+ case "paragraph": {
537
+ const video = ctx.nested ? null : findBlockVideoEmbed(node);
538
+ if (video) return /* @__PURE__ */ jsx5(VideoEmbedFrame, { embed: video.embed, title: video.title }, key);
539
+ return /* @__PURE__ */ jsx5("p", { className: "squisq-md-p", children: renderInline(node.children, key, ctx) }, key);
540
+ }
458
541
  case "heading": {
459
542
  const Tag = `h${node.depth}`;
460
- return /* @__PURE__ */ jsx4(Tag, { className: `squisq-md-heading squisq-md-h${node.depth}`, children: renderInline(node.children, key, ctx) }, key);
543
+ return /* @__PURE__ */ jsx5(Tag, { className: `squisq-md-heading squisq-md-h${node.depth}`, children: renderInline(node.children, key, ctx) }, key);
461
544
  }
462
545
  case "blockquote":
463
- return /* @__PURE__ */ jsx4("blockquote", { className: "squisq-md-blockquote", children: renderBlocks(node.children, key, ctx) }, key);
546
+ return /* @__PURE__ */ jsx5("blockquote", { className: "squisq-md-blockquote", children: renderBlocks(node.children, key, nestedCtx(ctx)) }, key);
464
547
  case "list":
465
548
  if (node.ordered) {
466
- return /* @__PURE__ */ jsx4("ol", { className: "squisq-md-list squisq-md-ol", start: node.start ?? void 0, children: node.children.map((item, i) => renderListItem(item, `${key}li${i}`, ctx)) }, key);
549
+ return /* @__PURE__ */ jsx5("ol", { className: "squisq-md-list squisq-md-ol", start: node.start ?? void 0, children: node.children.map((item, i) => renderListItem(item, `${key}li${i}`, ctx)) }, key);
467
550
  }
468
- return /* @__PURE__ */ jsx4("ul", { className: "squisq-md-list squisq-md-ul", children: node.children.map((item, i) => renderListItem(item, `${key}li${i}`, ctx)) }, key);
551
+ return /* @__PURE__ */ jsx5("ul", { className: "squisq-md-list squisq-md-ul", children: node.children.map((item, i) => renderListItem(item, `${key}li${i}`, ctx)) }, key);
469
552
  case "code": {
470
553
  const fenceLang = node.lang?.trim().toLowerCase();
471
554
  if (fenceLang && ctx.fenceRenderers?.[fenceLang]) {
472
- return /* @__PURE__ */ jsx4(
555
+ return /* @__PURE__ */ jsx5(
473
556
  FenceWidgetBoundary,
474
557
  {
475
- fallback: /* @__PURE__ */ jsx4(CodeBlock, { value: node.value, language: node.lang, ctx }),
476
- children: /* @__PURE__ */ jsx4(HostFence, { node, lang: fenceLang, ctx })
558
+ fallback: /* @__PURE__ */ jsx5(CodeBlock, { value: node.value, language: node.lang, ctx }),
559
+ children: /* @__PURE__ */ jsx5(HostFence, { node, lang: fenceLang, ctx })
477
560
  },
478
561
  key
479
562
  );
480
563
  }
481
564
  if (fenceLang === "mermaid") {
482
- return /* @__PURE__ */ jsx4(
565
+ return /* @__PURE__ */ jsx5(
483
566
  MermaidDiagram,
484
567
  {
485
568
  source: node.value,
@@ -490,39 +573,42 @@ function renderBlock(node, key, ctx = DEFAULT_CTX) {
490
573
  key
491
574
  );
492
575
  }
493
- return /* @__PURE__ */ jsx4(CodeBlock, { value: node.value, language: node.lang, ctx }, key);
576
+ return /* @__PURE__ */ jsx5(CodeBlock, { value: node.value, language: node.lang, ctx }, key);
494
577
  }
495
578
  case "thematicBreak":
496
- return /* @__PURE__ */ jsx4("hr", { className: "squisq-md-hr" }, key);
579
+ return /* @__PURE__ */ jsx5("hr", { className: "squisq-md-hr" }, key);
497
580
  case "table":
498
581
  return renderTable(node.children, node.align, key, ctx);
499
- case "htmlBlock":
582
+ case "htmlBlock": {
500
583
  if (ctx.htmlPolicy === "strip") return null;
501
- return /* @__PURE__ */ jsx4("div", { className: "squisq-md-html-block", children: renderHtmlNodes(resolveHtmlNodes(node.htmlChildren, ctx.htmlPolicy), `${key}h`, ctx) }, key);
584
+ const video = findBlockVideoEmbed(node);
585
+ if (video) return /* @__PURE__ */ jsx5(VideoEmbedFrame, { embed: video.embed, title: video.title }, key);
586
+ return /* @__PURE__ */ jsx5("div", { className: "squisq-md-html-block", children: renderHtmlNodes(resolveHtmlNodes(node.htmlChildren, ctx.htmlPolicy), `${key}h`, ctx) }, key);
587
+ }
502
588
  case "math":
503
- return /* @__PURE__ */ jsx4("pre", { className: "squisq-md-math-block", children: /* @__PURE__ */ jsx4("code", { children: node.value }) }, key);
589
+ return /* @__PURE__ */ jsx5("pre", { className: "squisq-md-math-block", children: /* @__PURE__ */ jsx5("code", { children: node.value }) }, key);
504
590
  case "definition":
505
591
  return null;
506
592
  case "footnoteDefinition":
507
- return /* @__PURE__ */ jsxs2("div", { className: "squisq-md-footnote-def", id: `fn-${node.identifier}`, children: [
508
- /* @__PURE__ */ jsx4("sup", { children: node.label ?? node.identifier }),
509
- renderBlocks(node.children, key, ctx)
593
+ return /* @__PURE__ */ jsxs3("div", { className: "squisq-md-footnote-def", id: `fn-${node.identifier}`, children: [
594
+ /* @__PURE__ */ jsx5("sup", { children: node.label ?? node.identifier }),
595
+ renderBlocks(node.children, key, nestedCtx(ctx))
510
596
  ] }, key);
511
597
  case "containerDirective":
512
- return /* @__PURE__ */ jsxs2(
598
+ return /* @__PURE__ */ jsxs3(
513
599
  "div",
514
600
  {
515
601
  className: `squisq-md-directive squisq-md-directive-${node.name}`,
516
602
  "data-directive": node.name,
517
603
  children: [
518
- node.label && /* @__PURE__ */ jsx4("div", { className: "squisq-md-directive-label", children: node.label }),
519
- renderBlocks(node.children, key, ctx)
604
+ node.label && /* @__PURE__ */ jsx5("div", { className: "squisq-md-directive-label", children: node.label }),
605
+ renderBlocks(node.children, key, nestedCtx(ctx))
520
606
  ]
521
607
  },
522
608
  key
523
609
  );
524
610
  case "leafDirective":
525
- return /* @__PURE__ */ jsx4(
611
+ return /* @__PURE__ */ jsx5(
526
612
  "div",
527
613
  {
528
614
  className: `squisq-md-directive squisq-md-directive-${node.name}`,
@@ -532,11 +618,11 @@ function renderBlock(node, key, ctx = DEFAULT_CTX) {
532
618
  key
533
619
  );
534
620
  case "definitionList":
535
- return /* @__PURE__ */ jsx4("dl", { className: "squisq-md-dl", children: node.children.map((child, i) => {
621
+ return /* @__PURE__ */ jsx5("dl", { className: "squisq-md-dl", children: node.children.map((child, i) => {
536
622
  if (child.type === "definitionTerm") {
537
- return /* @__PURE__ */ jsx4("dt", { className: "squisq-md-dt", children: renderInline(child.children, `${key}dt${i}`, ctx) }, `${key}dt${i}`);
623
+ return /* @__PURE__ */ jsx5("dt", { className: "squisq-md-dt", children: renderInline(child.children, `${key}dt${i}`, ctx) }, `${key}dt${i}`);
538
624
  }
539
- return /* @__PURE__ */ jsx4("dd", { className: "squisq-md-dd", children: renderBlocks(child.children, `${key}dd${i}`, ctx) }, `${key}dd${i}`);
625
+ return /* @__PURE__ */ jsx5("dd", { className: "squisq-md-dd", children: renderBlocks(child.children, `${key}dd${i}`, nestedCtx(ctx)) }, `${key}dd${i}`);
540
626
  }) }, key);
541
627
  default:
542
628
  return null;
@@ -544,15 +630,15 @@ function renderBlock(node, key, ctx = DEFAULT_CTX) {
544
630
  }
545
631
  function renderListItem(item, key, ctx = DEFAULT_CTX) {
546
632
  const isTask = item.checked !== null && item.checked !== void 0;
547
- return /* @__PURE__ */ jsxs2("li", { className: `squisq-md-li${isTask ? " squisq-md-task" : ""}`, children: [
548
- isTask && /* @__PURE__ */ jsx4("input", { type: "checkbox", checked: !!item.checked, readOnly: true, className: "squisq-md-checkbox" }),
549
- renderBlocks(item.children, key, ctx)
633
+ return /* @__PURE__ */ jsxs3("li", { className: `squisq-md-li${isTask ? " squisq-md-task" : ""}`, children: [
634
+ isTask && /* @__PURE__ */ jsx5("input", { type: "checkbox", checked: !!item.checked, readOnly: true, className: "squisq-md-checkbox" }),
635
+ renderBlocks(item.children, key, nestedCtx(ctx))
550
636
  ] }, key);
551
637
  }
552
638
  function renderTable(rows, align, key, ctx = DEFAULT_CTX) {
553
639
  const [headerRow, ...bodyRows] = rows;
554
- return /* @__PURE__ */ jsxs2("table", { className: "squisq-md-table", children: [
555
- headerRow && /* @__PURE__ */ jsx4("thead", { children: /* @__PURE__ */ jsx4("tr", { children: headerRow.children.map((cell, ci) => /* @__PURE__ */ jsx4(
640
+ return /* @__PURE__ */ jsxs3("table", { className: "squisq-md-table", children: [
641
+ headerRow && /* @__PURE__ */ jsx5("thead", { children: /* @__PURE__ */ jsx5("tr", { children: headerRow.children.map((cell, ci) => /* @__PURE__ */ jsx5(
556
642
  "th",
557
643
  {
558
644
  className: "squisq-md-th",
@@ -561,7 +647,7 @@ function renderTable(rows, align, key, ctx = DEFAULT_CTX) {
561
647
  },
562
648
  `${key}th${ci}`
563
649
  )) }) }),
564
- bodyRows.length > 0 && /* @__PURE__ */ jsx4("tbody", { children: bodyRows.map((row, ri) => /* @__PURE__ */ jsx4("tr", { children: row.children.map((cell, ci) => /* @__PURE__ */ jsx4(
650
+ bodyRows.length > 0 && /* @__PURE__ */ jsx5("tbody", { children: bodyRows.map((row, ri) => /* @__PURE__ */ jsx5("tr", { children: row.children.map((cell, ci) => /* @__PURE__ */ jsx5(
565
651
  "td",
566
652
  {
567
653
  className: "squisq-md-td",
@@ -582,16 +668,16 @@ function MdImage({ src, alt, title }) {
582
668
  const playback = useAnimatedImage(safeSrc ?? "", resolved);
583
669
  if (!safeSrc) return null;
584
670
  if (!mayBeAnimatedImage2(safeSrc)) {
585
- return /* @__PURE__ */ jsx4("img", { className: "squisq-md-image", src: resolved, alt, title });
671
+ return /* @__PURE__ */ jsx5("img", { className: "squisq-md-image", src: resolved, alt, title });
586
672
  }
587
- return /* @__PURE__ */ jsxs2(
673
+ return /* @__PURE__ */ jsxs3(
588
674
  "span",
589
675
  {
590
676
  className: "squisq-animated-image",
591
677
  "data-animated": playback.animated ? "true" : void 0,
592
678
  style: { position: "relative", display: "inline-block", maxWidth: "100%" },
593
679
  children: [
594
- /* @__PURE__ */ jsx4(
680
+ /* @__PURE__ */ jsx5(
595
681
  "img",
596
682
  {
597
683
  ref: imageRef,
@@ -602,7 +688,7 @@ function MdImage({ src, alt, title }) {
602
688
  style: { display: "block", maxWidth: "100%" }
603
689
  }
604
690
  ),
605
- /* @__PURE__ */ jsx4(AnimatedImageControls, { playback, imageRef })
691
+ /* @__PURE__ */ jsx5(AnimatedImageControls, { playback, imageRef })
606
692
  ]
607
693
  }
608
694
  );
@@ -673,11 +759,15 @@ function reactPropsFromAttrs(attrs, ctx) {
673
759
  }
674
760
  function renderHtmlElement(el, key, ctx) {
675
761
  const tagName = el.tagName.toLowerCase();
762
+ if (tagName === "iframe") {
763
+ const video = videoEmbedFromIframe(el);
764
+ return video ? /* @__PURE__ */ jsx5(VideoEmbedFrame, { embed: video.embed, title: video.title, inline: true }, key) : null;
765
+ }
676
766
  if (DANGEROUS_HTML_TAGS.has(tagName)) return null;
677
767
  if (tagName === "video") {
678
768
  const src = sanitizeUrl(el.attributes.src ?? "", "media") ?? "";
679
769
  const poster = sanitizeUrl(el.attributes.poster ?? "", "media") ?? void 0;
680
- return /* @__PURE__ */ jsx4(
770
+ return /* @__PURE__ */ jsx5(
681
771
  InlineVideoPlayer,
682
772
  {
683
773
  src,
@@ -692,7 +782,7 @@ function renderHtmlElement(el, key, ctx) {
692
782
  }
693
783
  if (tagName === "audio") {
694
784
  const src = sanitizeUrl(el.attributes.src ?? "", "media") ?? "";
695
- return /* @__PURE__ */ jsx4(
785
+ return /* @__PURE__ */ jsx5(
696
786
  InlineAudioPlayer,
697
787
  {
698
788
  src,
@@ -705,9 +795,9 @@ function renderHtmlElement(el, key, ctx) {
705
795
  const Tag = tagName;
706
796
  const props = reactPropsFromAttrs(el.attributes, ctx);
707
797
  if (el.selfClosing) {
708
- return /* @__PURE__ */ jsx4(Tag, { ...props }, key);
798
+ return /* @__PURE__ */ jsx5(Tag, { ...props }, key);
709
799
  }
710
- return /* @__PURE__ */ jsx4(Tag, { ...props, children: renderHtmlNodes(el.children, `${key}c`, ctx) }, key);
800
+ return /* @__PURE__ */ jsx5(Tag, { ...props, children: renderHtmlNodes(el.children, `${key}c`, ctx) }, key);
711
801
  }
712
802
  function renderHtmlNodes(nodes, keyPrefix, ctx = DEFAULT_CTX) {
713
803
  return nodes.map((node, i) => {
@@ -716,7 +806,7 @@ function renderHtmlNodes(nodes, keyPrefix, ctx = DEFAULT_CTX) {
716
806
  case "htmlElement":
717
807
  return renderHtmlElement(node, key, ctx);
718
808
  case "htmlText":
719
- return /* @__PURE__ */ jsx4(Fragment2, { children: node.value }, key);
809
+ return /* @__PURE__ */ jsx5(Fragment2, { children: node.value }, key);
720
810
  case "htmlComment":
721
811
  return null;
722
812
  default:
@@ -758,7 +848,7 @@ function MarkdownRenderer({
758
848
  };
759
849
  }, [mediaProvider]);
760
850
  if (!nodes || nodes.length === 0) return null;
761
- return /* @__PURE__ */ jsx4("div", { className: `squisq-md ${className || ""}`, children: renderBlocks(nodes, "", {
851
+ return /* @__PURE__ */ jsx5("div", { className: `squisq-md ${className || ""}`, children: renderBlocks(nodes, "", {
762
852
  htmlPolicy,
763
853
  linkSchemes,
764
854
  theme,
@@ -774,6 +864,7 @@ export {
774
864
  useFenceRenderers,
775
865
  InlineVideoPlayer,
776
866
  InlineAudioPlayer,
867
+ VideoEmbedFrame,
777
868
  AnimatedImageControls,
778
869
  useAnimatedImage,
779
870
  MarkdownRenderer
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  LinearDocView
3
- } from "./chunk-2VSD55NT.js";
3
+ } from "./chunk-BMQ3EGOP.js";
4
4
 
5
5
  // src/PaginatedDocView.tsx
6
6
  import {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  BlockRenderer
3
- } from "../chunk-5FJZDX7H.js";
4
- import "../chunk-PZCWGBRQ.js";
3
+ } from "../chunk-KJZF2U3I.js";
4
+ import "../chunk-WG7ALU5G.js";
5
5
  import "../chunk-QXZXQPL3.js";
6
6
  import {
7
7
  renderMermaidSvgForExport
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { S as SquisqRenderAPI, V as VideoPresentation$1, P as PipSize, a as PipShape, b as PipPosition } from './player-BCPc3Tv3.js';
2
- export { B as BlockMarker, c as BlockRenderer, C as CaptionMode, d as CaptionOverlay, e as CaptionPosition, f as CaptionStyle, g as ControlsLayout, D as DisplayMode, h as DocControlsBottom, i as DocControlsOverlay, j as DocControlsSidebar, k as DocControlsSlideshow, l as DocPlayer, m as DocPlayerProps, n as DocPlayerWithSidebar, o as DocProgressBar, F as FlashcardFaceView, p as FlashcardFaceViewProps, q as FlashcardView, r as FlashcardViewProps, I as InlineAudioPlayer, s as InlineAudioPlayerProps, t as InlineVideoPlayer, u as InlineVideoPlayerProps, M as MediaClipLayer, v as MediaClipLayerProps, w as PlaybackActions, x as PlaybackState, R as RenderAudioSegmentInfo, y as RenderBlockInfo, z as RenderCaptionInfo, A as RenderChapterInfo, E as RenderVideoFrameSelector, G as SlideNavActions, H as SocialCaptionOverlay, J as formatTime } from './player-BCPc3Tv3.js';
1
+ import { S as SquisqRenderAPI, V as VideoPresentation$1, P as PipSize, a as PipShape, b as PipPosition } from './player-xxe4LWQI.js';
2
+ export { B as BlockMarker, c as BlockRenderer, C as CaptionMode, d as CaptionOverlay, e as CaptionPosition, f as CaptionStyle, g as ControlsLayout, D as DisplayMode, h as DocControlsBottom, i as DocControlsOverlay, j as DocControlsSidebar, k as DocControlsSlideshow, l as DocPlayer, m as DocPlayerProps, n as DocPlayerWithSidebar, o as DocProgressBar, F as FlashcardFaceView, p as FlashcardFaceViewProps, q as FlashcardView, r as FlashcardViewProps, I as InlineAudioPlayer, s as InlineAudioPlayerProps, t as InlineVideoPlayer, u as InlineVideoPlayerProps, M as MediaClipLayer, v as MediaClipLayerProps, w as PlaybackActions, x as PlaybackState, R as RenderAudioSegmentInfo, y as RenderBlockInfo, z as RenderCaptionInfo, A as RenderChapterInfo, E as RenderVideoFrameSelector, G as SlideNavActions, H as SocialCaptionOverlay, J as formatTime } from './player-xxe4LWQI.js';
3
3
  import { Theme, VideoPresentation, VideoPipSize, VideoPipShape, VideoPipPosition, MotionSpec, Doc, ScheduledClip, MediaProvider } from '@bendyline/squisq/schemas';
4
4
  import { DashboardStyleId, ViewportConfig, CoverSlideTemplate, CoverSlidePlayback } from '@bendyline/squisq/doc';
5
5
  export { getAnimationStyle, getTransitionClass } from '@bendyline/squisq/doc';
6
6
  import { C as CodeBlockCopyHandler } from './MarkdownRenderer-CC9dOc6b.js';
7
7
  export { a as CodeBlockCopyContext, M as MarkdownRenderer, b as MarkdownRendererProps } from './MarkdownRenderer-CC9dOc6b.js';
8
- export { FenceRendererContext, MermaidDiagram, MermaidDiagramProps, useFenceRenderers } from './markdown/index.js';
8
+ export { FenceRendererContext, MermaidDiagram, MermaidDiagramProps, VideoEmbedFrame, VideoEmbedFrameProps, useFenceRenderers } from './markdown/index.js';
9
9
  export { CanvasSection, CanvasSectionProps, ImageDisplayMode, LinearDocView, LinearDocViewProps, PageSectionView, PageSectionViewProps, PageViewContext, PageViewContextValue, PaginatedDocPage, PaginatedDocView, PaginatedDocViewProps, usePageView } from './page/index.js';
10
10
  import * as react_jsx_runtime from 'react/jsx-runtime';
11
11
  import { RefObject } from 'react';
package/dist/index.js CHANGED
@@ -15,17 +15,17 @@ import {
15
15
  formatTime,
16
16
  resolveDocPlayerAppearance,
17
17
  useMediaClipDurations
18
- } from "./chunk-622IA3KB.js";
18
+ } from "./chunk-LXOQCAU6.js";
19
19
  import {
20
20
  PaginatedDocView
21
- } from "./chunk-PSAO2CTF.js";
21
+ } from "./chunk-ZNW3DJAD.js";
22
22
  import {
23
23
  CanvasSection,
24
24
  LinearDocView,
25
25
  PageSectionView,
26
26
  PageViewContext,
27
27
  usePageView
28
- } from "./chunk-2VSD55NT.js";
28
+ } from "./chunk-BMQ3EGOP.js";
29
29
  import {
30
30
  useModalDialog
31
31
  } from "./chunk-65POMKHR.js";
@@ -38,7 +38,7 @@ import {
38
38
  import {
39
39
  JsonView,
40
40
  createJsonFormFenceRenderer
41
- } from "./chunk-L4LIIOU2.js";
41
+ } from "./chunk-J4BHV6UO.js";
42
42
  import {
43
43
  useAutoSurface
44
44
  } from "./chunk-TT6ENR6T.js";
@@ -48,12 +48,13 @@ import {
48
48
  InlineAudioPlayer,
49
49
  InlineVideoPlayer,
50
50
  MarkdownRenderer,
51
+ VideoEmbedFrame,
51
52
  useAnimatedImage,
52
53
  useFenceRenderers
53
- } from "./chunk-2FZUFQO3.js";
54
+ } from "./chunk-YLFAOGJF.js";
54
55
  import {
55
56
  BlockRenderer
56
- } from "./chunk-5FJZDX7H.js";
57
+ } from "./chunk-KJZF2U3I.js";
57
58
  import {
58
59
  ImageLayer,
59
60
  MapLayer,
@@ -66,7 +67,7 @@ import {
66
67
  VideoLayer,
67
68
  getAnimationStyle,
68
69
  getTransitionClass
69
- } from "./chunk-PZCWGBRQ.js";
70
+ } from "./chunk-WG7ALU5G.js";
70
71
  import {
71
72
  MermaidDiagram
72
73
  } from "./chunk-QXZXQPL3.js";
@@ -114,6 +115,7 @@ export {
114
115
  TableLayer,
115
116
  TextLayer,
116
117
  TreeLayer,
118
+ VideoEmbedFrame,
117
119
  VideoLayer,
118
120
  createJsonFormFenceRenderer,
119
121
  formatTime,