@bendyline/squisq-react 2.12.2 → 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.
@@ -1,10 +1,11 @@
1
1
  import {
2
2
  MermaidDiagram
3
- } from "./chunk-Z7OW6RGR.js";
3
+ } from "./chunk-EY3DUCK7.js";
4
4
  import {
5
+ svgDataImageSrc,
5
6
  useMediaProvider,
6
7
  useMediaUrl
7
- } from "./chunk-HCKL2AFN.js";
8
+ } from "./chunk-JP2VHB5H.js";
8
9
 
9
10
  // src/hooks/FenceRendererContext.tsx
10
11
  import { createContext, useContext } from "react";
@@ -307,8 +308,68 @@ function useAnimatedImage(src, resolvedUrl) {
307
308
  };
308
309
  }
309
310
 
311
+ // src/svgIsland/SvgIslandImage.tsx
312
+ import { useLayoutEffect as useLayoutEffect2, useMemo, useRef as useRef3, useState as useState2 } from "react";
313
+ import { parseSvgIsland, svgIslandDataUrl } from "@bendyline/squisq/markdown";
314
+ import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
315
+ function prefersReducedMotion2() {
316
+ return typeof window !== "undefined" && !!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
317
+ }
318
+ function SvgIslandImage({
319
+ source,
320
+ fallback,
321
+ isStatic,
322
+ color,
323
+ className
324
+ }) {
325
+ const figureRef = useRef3(null);
326
+ const [surroundingColor, setSurroundingColor] = useState2(void 0);
327
+ const [reducedMotion] = useState2(prefersReducedMotion2);
328
+ const still = isStatic ?? reducedMotion;
329
+ const result = useMemo(() => parseSvgIsland(source, { static: still }), [source, still]);
330
+ useLayoutEffect2(() => {
331
+ if (color !== void 0 || !figureRef.current) return;
332
+ const computed = getComputedStyle(figureRef.current).color;
333
+ if (computed) setSurroundingColor(computed);
334
+ }, [color, result]);
335
+ const effectiveColor = color ?? surroundingColor;
336
+ const src = useMemo(
337
+ () => result.ok ? svgIslandDataUrl(result.island, { color: effectiveColor }) : null,
338
+ [result, effectiveColor]
339
+ );
340
+ if (!result.ok || !src) {
341
+ return /* @__PURE__ */ jsxs3("div", { className: ["squisq-md-svg-error", className].filter(Boolean).join(" "), children: [
342
+ /* @__PURE__ */ jsxs3("p", { className: "squisq-md-svg-error-note", role: "note", children: [
343
+ "Couldn\u2019t render this SVG: ",
344
+ result.ok ? "unknown error" : result.message
345
+ ] }),
346
+ fallback
347
+ ] });
348
+ }
349
+ const { island } = result;
350
+ return /* @__PURE__ */ jsx5(
351
+ "figure",
352
+ {
353
+ ref: figureRef,
354
+ className: ["squisq-md-svg", className].filter(Boolean).join(" "),
355
+ "data-svg-island": "",
356
+ children: /* @__PURE__ */ jsx5(
357
+ "img",
358
+ {
359
+ src,
360
+ alt: island.title ?? "Illustration",
361
+ width: island.width,
362
+ height: island.height,
363
+ decoding: "sync",
364
+ draggable: false
365
+ }
366
+ )
367
+ }
368
+ );
369
+ }
370
+
310
371
  // src/MarkdownRenderer.tsx
311
- import { Component, Fragment as Fragment2, useEffect as useEffect2, useRef as useRef3, useState as useState2 } from "react";
372
+ import { Component, Fragment as Fragment2, useEffect as useEffect2, useRef as useRef4, useState as useState3 } from "react";
312
373
  import { mayBeAnimatedImage as mayBeAnimatedImage2 } from "@bendyline/squisq/imageEdit";
313
374
  import {
314
375
  findBlockVideoEmbed,
@@ -317,7 +378,7 @@ import {
317
378
  sanitizeUrl,
318
379
  videoEmbedFromIframe
319
380
  } from "@bendyline/squisq/markdown";
320
- import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
381
+ import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
321
382
  var DEFAULT_CTX = { htmlPolicy: "sanitize" };
322
383
  function nestedCtx(ctx) {
323
384
  return ctx.nested ? ctx : { ...ctx, nested: true };
@@ -343,15 +404,15 @@ function CodeBlock({
343
404
  language,
344
405
  ctx
345
406
  }) {
346
- const [status, setStatus] = useState2("idle");
347
- const resetTimer = useRef3();
407
+ const [status, setStatus] = useState3("idle");
408
+ const resetTimer = useRef4();
348
409
  useEffect2(
349
410
  () => () => {
350
411
  if (resetTimer.current !== void 0) clearTimeout(resetTimer.current);
351
412
  },
352
413
  []
353
414
  );
354
- const pre = /* @__PURE__ */ jsx5("pre", { className: "squisq-md-code-block", children: /* @__PURE__ */ jsx5("code", { className: language ? `language-${language}` : void 0, children: value }) });
415
+ const pre = /* @__PURE__ */ jsx6("pre", { className: "squisq-md-code-block", children: /* @__PURE__ */ jsx6("code", { className: language ? `language-${language}` : void 0, children: value }) });
355
416
  if (!ctx.showCodeCopyButton) return pre;
356
417
  const handleCopy = async () => {
357
418
  if (status === "copying") return;
@@ -365,9 +426,9 @@ function CodeBlock({
365
426
  if (resetTimer.current !== void 0) clearTimeout(resetTimer.current);
366
427
  resetTimer.current = setTimeout(() => setStatus("idle"), 1600);
367
428
  };
368
- return /* @__PURE__ */ jsxs3("div", { className: "squisq-md-code-frame", children: [
429
+ return /* @__PURE__ */ jsxs4("div", { className: "squisq-md-code-frame", children: [
369
430
  pre,
370
- /* @__PURE__ */ jsx5(
431
+ /* @__PURE__ */ jsx6(
371
432
  "button",
372
433
  {
373
434
  type: "button",
@@ -400,7 +461,7 @@ function HostFence({
400
461
  }) {
401
462
  const renderer = ctx.fenceRenderers?.[lang];
402
463
  if (!renderer) return null;
403
- return /* @__PURE__ */ jsx5("div", { className: `squisq-md-fence-widget squisq-md-fence-widget-${lang}`, "data-fence-lang": lang, children: renderer({
464
+ return /* @__PURE__ */ jsx6("div", { className: `squisq-md-fence-widget squisq-md-fence-widget-${lang}`, "data-fence-lang": lang, children: renderer({
404
465
  lang,
405
466
  ...node.meta != null ? { meta: node.meta } : {},
406
467
  value: node.value,
@@ -414,37 +475,37 @@ function renderInline(nodes, keyPrefix = "", ctx = DEFAULT_CTX) {
414
475
  switch (node.type) {
415
476
  case "text": {
416
477
  if (!node.value.includes("\n")) {
417
- return /* @__PURE__ */ jsx5(Fragment2, { children: node.value }, key);
478
+ return /* @__PURE__ */ jsx6(Fragment2, { children: node.value }, key);
418
479
  }
419
480
  const parts = node.value.split("\n");
420
- return /* @__PURE__ */ jsx5(Fragment2, { children: parts.map((part, j) => /* @__PURE__ */ jsxs3(Fragment2, { children: [
421
- j > 0 && /* @__PURE__ */ jsx5("br", {}),
481
+ return /* @__PURE__ */ jsx6(Fragment2, { children: parts.map((part, j) => /* @__PURE__ */ jsxs4(Fragment2, { children: [
482
+ j > 0 && /* @__PURE__ */ jsx6("br", {}),
422
483
  part
423
484
  ] }, j)) }, key);
424
485
  }
425
486
  case "emphasis":
426
- return /* @__PURE__ */ jsx5("em", { className: "squisq-md-em", children: renderInline(node.children, key, ctx) }, key);
487
+ return /* @__PURE__ */ jsx6("em", { className: "squisq-md-em", children: renderInline(node.children, key, ctx) }, key);
427
488
  case "strong":
428
- return /* @__PURE__ */ jsx5("strong", { className: "squisq-md-strong", children: renderInline(node.children, key, ctx) }, key);
489
+ return /* @__PURE__ */ jsx6("strong", { className: "squisq-md-strong", children: renderInline(node.children, key, ctx) }, key);
429
490
  case "delete":
430
- return /* @__PURE__ */ jsx5("del", { className: "squisq-md-del", children: renderInline(node.children, key, ctx) }, key);
491
+ return /* @__PURE__ */ jsx6("del", { className: "squisq-md-del", children: renderInline(node.children, key, ctx) }, key);
431
492
  case "superscript":
432
- return /* @__PURE__ */ jsx5("sup", { className: "squisq-md-sup", children: renderInline(node.children, key, ctx) }, key);
493
+ return /* @__PURE__ */ jsx6("sup", { className: "squisq-md-sup", children: renderInline(node.children, key, ctx) }, key);
433
494
  case "subscript":
434
- return /* @__PURE__ */ jsx5("sub", { className: "squisq-md-sub", children: renderInline(node.children, key, ctx) }, key);
495
+ return /* @__PURE__ */ jsx6("sub", { className: "squisq-md-sub", children: renderInline(node.children, key, ctx) }, key);
435
496
  case "inlineCode":
436
- return /* @__PURE__ */ jsx5("code", { className: "squisq-md-inline-code", children: node.value }, key);
497
+ return /* @__PURE__ */ jsx6("code", { className: "squisq-md-inline-code", children: node.value }, key);
437
498
  case "link": {
438
499
  if (ctx.accessoryPaths?.has(node.url)) {
439
- return /* @__PURE__ */ jsxs3(
500
+ return /* @__PURE__ */ jsxs4(
440
501
  "span",
441
502
  {
442
503
  className: "squisq-md-attachment",
443
504
  "data-attachment-path": node.url,
444
505
  title: node.title ?? `Attachment: ${node.url}`,
445
506
  children: [
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) })
507
+ /* @__PURE__ */ jsx6("i", { className: "fa-solid fa-paperclip", "aria-hidden": "true" }),
508
+ /* @__PURE__ */ jsx6("span", { className: "squisq-md-attachment-label", children: renderInline(node.children, key, ctx) })
448
509
  ]
449
510
  },
450
511
  key
@@ -452,9 +513,9 @@ function renderInline(nodes, keyPrefix = "", ctx = DEFAULT_CTX) {
452
513
  }
453
514
  const href = sanitizeUrl(node.url, "link", { extraLinkSchemes: ctx.linkSchemes });
454
515
  if (!href) {
455
- return /* @__PURE__ */ jsx5("span", { className: "squisq-md-link squisq-md-link--blocked", children: renderInline(node.children, key, ctx) }, key);
516
+ return /* @__PURE__ */ jsx6("span", { className: "squisq-md-link squisq-md-link--blocked", children: renderInline(node.children, key, ctx) }, key);
456
517
  }
457
- return /* @__PURE__ */ jsx5(
518
+ return /* @__PURE__ */ jsx6(
458
519
  "a",
459
520
  {
460
521
  className: "squisq-md-link",
@@ -473,16 +534,16 @@ function renderInline(nodes, keyPrefix = "", ctx = DEFAULT_CTX) {
473
534
  const src = sanitizeUrl(node.url, "media");
474
535
  if (!src) return null;
475
536
  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);
537
+ return kind === "video" ? /* @__PURE__ */ jsx6(InlineVideoPlayer, { src, basePath: ".", label }, key) : /* @__PURE__ */ jsx6(InlineAudioPlayer, { src, basePath: ".", label }, key);
477
538
  }
478
- return /* @__PURE__ */ jsx5(MdImage, { src: node.url, alt: node.alt ?? "", title: node.title ?? void 0 }, key);
539
+ return /* @__PURE__ */ jsx6(MdImage, { src: node.url, alt: node.alt ?? "", title: node.title ?? void 0 }, key);
479
540
  }
480
541
  case "break":
481
- return /* @__PURE__ */ jsx5("br", {}, key);
542
+ return /* @__PURE__ */ jsx6("br", {}, key);
482
543
  case "inlineMath":
483
- return /* @__PURE__ */ jsx5("code", { className: "squisq-md-inline-math", children: node.value }, key);
544
+ return /* @__PURE__ */ jsx6("code", { className: "squisq-md-inline-math", children: node.value }, key);
484
545
  case "inlineIcon":
485
- return /* @__PURE__ */ jsx5(
546
+ return /* @__PURE__ */ jsx6(
486
547
  "i",
487
548
  {
488
549
  className: `fa-${node.family} fa-${node.name}`,
@@ -493,25 +554,25 @@ function renderInline(nodes, keyPrefix = "", ctx = DEFAULT_CTX) {
493
554
  );
494
555
  case "htmlInline":
495
556
  if (ctx.htmlPolicy === "strip") return null;
496
- return /* @__PURE__ */ jsx5("span", { className: "squisq-md-html-inline", children: renderHtmlNodes(resolveHtmlNodes(node.htmlChildren, ctx.htmlPolicy), `${key}h`, ctx) }, key);
557
+ return /* @__PURE__ */ jsx6("span", { className: "squisq-md-html-inline", children: renderHtmlNodes(resolveHtmlNodes(node.htmlChildren, ctx.htmlPolicy), `${key}h`, ctx) }, key);
497
558
  case "footnoteReference":
498
- return /* @__PURE__ */ jsx5("sup", { className: "squisq-md-footnote-ref", children: /* @__PURE__ */ jsxs3("a", { href: `#fn-${node.identifier}`, children: [
559
+ return /* @__PURE__ */ jsx6("sup", { className: "squisq-md-footnote-ref", children: /* @__PURE__ */ jsxs4("a", { href: `#fn-${node.identifier}`, children: [
499
560
  "[",
500
561
  node.label ?? node.identifier,
501
562
  "]"
502
563
  ] }) }, key);
503
564
  case "linkReference":
504
- return /* @__PURE__ */ jsx5("span", { className: "squisq-md-link-ref", children: renderInline(node.children, key, ctx) }, key);
565
+ return /* @__PURE__ */ jsx6("span", { className: "squisq-md-link-ref", children: renderInline(node.children, key, ctx) }, key);
505
566
  case "imageReference":
506
- return /* @__PURE__ */ jsxs3("span", { className: "squisq-md-image-ref", children: [
567
+ return /* @__PURE__ */ jsxs4("span", { className: "squisq-md-image-ref", children: [
507
568
  "[",
508
569
  node.alt ?? node.identifier,
509
570
  "]"
510
571
  ] }, key);
511
572
  case "textDirective":
512
- return /* @__PURE__ */ jsx5("span", { className: "squisq-md-text-directive", "data-directive": node.name, children: renderInline(node.children, key, ctx) }, key);
573
+ return /* @__PURE__ */ jsx6("span", { className: "squisq-md-text-directive", "data-directive": node.name, children: renderInline(node.children, key, ctx) }, key);
513
574
  case "mention":
514
- return /* @__PURE__ */ jsxs3(
575
+ return /* @__PURE__ */ jsxs4(
515
576
  "span",
516
577
  {
517
578
  className: "squisq-md-mention mention",
@@ -535,34 +596,34 @@ function renderBlock(node, key, ctx = DEFAULT_CTX) {
535
596
  switch (node.type) {
536
597
  case "paragraph": {
537
598
  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);
599
+ if (video) return /* @__PURE__ */ jsx6(VideoEmbedFrame, { embed: video.embed, title: video.title }, key);
600
+ return /* @__PURE__ */ jsx6("p", { className: "squisq-md-p", children: renderInline(node.children, key, ctx) }, key);
540
601
  }
541
602
  case "heading": {
542
603
  const Tag = `h${node.depth}`;
543
- return /* @__PURE__ */ jsx5(Tag, { className: `squisq-md-heading squisq-md-h${node.depth}`, children: renderInline(node.children, key, ctx) }, key);
604
+ return /* @__PURE__ */ jsx6(Tag, { className: `squisq-md-heading squisq-md-h${node.depth}`, children: renderInline(node.children, key, ctx) }, key);
544
605
  }
545
606
  case "blockquote":
546
- return /* @__PURE__ */ jsx5("blockquote", { className: "squisq-md-blockquote", children: renderBlocks(node.children, key, nestedCtx(ctx)) }, key);
607
+ return /* @__PURE__ */ jsx6("blockquote", { className: "squisq-md-blockquote", children: renderBlocks(node.children, key, nestedCtx(ctx)) }, key);
547
608
  case "list":
548
609
  if (node.ordered) {
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);
610
+ return /* @__PURE__ */ jsx6("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);
550
611
  }
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);
612
+ return /* @__PURE__ */ jsx6("ul", { className: "squisq-md-list squisq-md-ul", children: node.children.map((item, i) => renderListItem(item, `${key}li${i}`, ctx)) }, key);
552
613
  case "code": {
553
614
  const fenceLang = node.lang?.trim().toLowerCase();
554
615
  if (fenceLang && ctx.fenceRenderers?.[fenceLang]) {
555
- return /* @__PURE__ */ jsx5(
616
+ return /* @__PURE__ */ jsx6(
556
617
  FenceWidgetBoundary,
557
618
  {
558
- fallback: /* @__PURE__ */ jsx5(CodeBlock, { value: node.value, language: node.lang, ctx }),
559
- children: /* @__PURE__ */ jsx5(HostFence, { node, lang: fenceLang, ctx })
619
+ fallback: /* @__PURE__ */ jsx6(CodeBlock, { value: node.value, language: node.lang, ctx }),
620
+ children: /* @__PURE__ */ jsx6(HostFence, { node, lang: fenceLang, ctx })
560
621
  },
561
622
  key
562
623
  );
563
624
  }
564
625
  if (fenceLang === "mermaid") {
565
- return /* @__PURE__ */ jsx5(
626
+ return /* @__PURE__ */ jsx6(
566
627
  MermaidDiagram,
567
628
  {
568
629
  source: node.value,
@@ -573,42 +634,52 @@ function renderBlock(node, key, ctx = DEFAULT_CTX) {
573
634
  key
574
635
  );
575
636
  }
576
- return /* @__PURE__ */ jsx5(CodeBlock, { value: node.value, language: node.lang, ctx }, key);
637
+ if (fenceLang === "svg") {
638
+ return /* @__PURE__ */ jsx6(
639
+ SvgIslandImage,
640
+ {
641
+ source: node.value,
642
+ fallback: /* @__PURE__ */ jsx6(CodeBlock, { value: node.value, language: node.lang, ctx })
643
+ },
644
+ key
645
+ );
646
+ }
647
+ return /* @__PURE__ */ jsx6(CodeBlock, { value: node.value, language: node.lang, ctx }, key);
577
648
  }
578
649
  case "thematicBreak":
579
- return /* @__PURE__ */ jsx5("hr", { className: "squisq-md-hr" }, key);
650
+ return /* @__PURE__ */ jsx6("hr", { className: "squisq-md-hr" }, key);
580
651
  case "table":
581
652
  return renderTable(node.children, node.align, key, ctx);
582
653
  case "htmlBlock": {
583
654
  if (ctx.htmlPolicy === "strip") return null;
584
655
  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);
656
+ if (video) return /* @__PURE__ */ jsx6(VideoEmbedFrame, { embed: video.embed, title: video.title }, key);
657
+ return /* @__PURE__ */ jsx6("div", { className: "squisq-md-html-block", children: renderHtmlNodes(resolveHtmlNodes(node.htmlChildren, ctx.htmlPolicy), `${key}h`, ctx) }, key);
587
658
  }
588
659
  case "math":
589
- return /* @__PURE__ */ jsx5("pre", { className: "squisq-md-math-block", children: /* @__PURE__ */ jsx5("code", { children: node.value }) }, key);
660
+ return /* @__PURE__ */ jsx6("pre", { className: "squisq-md-math-block", children: /* @__PURE__ */ jsx6("code", { children: node.value }) }, key);
590
661
  case "definition":
591
662
  return null;
592
663
  case "footnoteDefinition":
593
- return /* @__PURE__ */ jsxs3("div", { className: "squisq-md-footnote-def", id: `fn-${node.identifier}`, children: [
594
- /* @__PURE__ */ jsx5("sup", { children: node.label ?? node.identifier }),
664
+ return /* @__PURE__ */ jsxs4("div", { className: "squisq-md-footnote-def", id: `fn-${node.identifier}`, children: [
665
+ /* @__PURE__ */ jsx6("sup", { children: node.label ?? node.identifier }),
595
666
  renderBlocks(node.children, key, nestedCtx(ctx))
596
667
  ] }, key);
597
668
  case "containerDirective":
598
- return /* @__PURE__ */ jsxs3(
669
+ return /* @__PURE__ */ jsxs4(
599
670
  "div",
600
671
  {
601
672
  className: `squisq-md-directive squisq-md-directive-${node.name}`,
602
673
  "data-directive": node.name,
603
674
  children: [
604
- node.label && /* @__PURE__ */ jsx5("div", { className: "squisq-md-directive-label", children: node.label }),
675
+ node.label && /* @__PURE__ */ jsx6("div", { className: "squisq-md-directive-label", children: node.label }),
605
676
  renderBlocks(node.children, key, nestedCtx(ctx))
606
677
  ]
607
678
  },
608
679
  key
609
680
  );
610
681
  case "leafDirective":
611
- return /* @__PURE__ */ jsx5(
682
+ return /* @__PURE__ */ jsx6(
612
683
  "div",
613
684
  {
614
685
  className: `squisq-md-directive squisq-md-directive-${node.name}`,
@@ -618,11 +689,11 @@ function renderBlock(node, key, ctx = DEFAULT_CTX) {
618
689
  key
619
690
  );
620
691
  case "definitionList":
621
- return /* @__PURE__ */ jsx5("dl", { className: "squisq-md-dl", children: node.children.map((child, i) => {
692
+ return /* @__PURE__ */ jsx6("dl", { className: "squisq-md-dl", children: node.children.map((child, i) => {
622
693
  if (child.type === "definitionTerm") {
623
- return /* @__PURE__ */ jsx5("dt", { className: "squisq-md-dt", children: renderInline(child.children, `${key}dt${i}`, ctx) }, `${key}dt${i}`);
694
+ return /* @__PURE__ */ jsx6("dt", { className: "squisq-md-dt", children: renderInline(child.children, `${key}dt${i}`, ctx) }, `${key}dt${i}`);
624
695
  }
625
- return /* @__PURE__ */ jsx5("dd", { className: "squisq-md-dd", children: renderBlocks(child.children, `${key}dd${i}`, nestedCtx(ctx)) }, `${key}dd${i}`);
696
+ return /* @__PURE__ */ jsx6("dd", { className: "squisq-md-dd", children: renderBlocks(child.children, `${key}dd${i}`, nestedCtx(ctx)) }, `${key}dd${i}`);
626
697
  }) }, key);
627
698
  default:
628
699
  return null;
@@ -630,15 +701,15 @@ function renderBlock(node, key, ctx = DEFAULT_CTX) {
630
701
  }
631
702
  function renderListItem(item, key, ctx = DEFAULT_CTX) {
632
703
  const isTask = item.checked !== null && item.checked !== void 0;
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" }),
704
+ return /* @__PURE__ */ jsxs4("li", { className: `squisq-md-li${isTask ? " squisq-md-task" : ""}`, children: [
705
+ isTask && /* @__PURE__ */ jsx6("input", { type: "checkbox", checked: !!item.checked, readOnly: true, className: "squisq-md-checkbox" }),
635
706
  renderBlocks(item.children, key, nestedCtx(ctx))
636
707
  ] }, key);
637
708
  }
638
709
  function renderTable(rows, align, key, ctx = DEFAULT_CTX) {
639
710
  const [headerRow, ...bodyRows] = rows;
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(
711
+ return /* @__PURE__ */ jsxs4("table", { className: "squisq-md-table", children: [
712
+ headerRow && /* @__PURE__ */ jsx6("thead", { children: /* @__PURE__ */ jsx6("tr", { children: headerRow.children.map((cell, ci) => /* @__PURE__ */ jsx6(
642
713
  "th",
643
714
  {
644
715
  className: "squisq-md-th",
@@ -647,7 +718,7 @@ function renderTable(rows, align, key, ctx = DEFAULT_CTX) {
647
718
  },
648
719
  `${key}th${ci}`
649
720
  )) }) }),
650
- bodyRows.length > 0 && /* @__PURE__ */ jsx5("tbody", { children: bodyRows.map((row, ri) => /* @__PURE__ */ jsx5("tr", { children: row.children.map((cell, ci) => /* @__PURE__ */ jsx5(
721
+ bodyRows.length > 0 && /* @__PURE__ */ jsx6("tbody", { children: bodyRows.map((row, ri) => /* @__PURE__ */ jsx6("tr", { children: row.children.map((cell, ci) => /* @__PURE__ */ jsx6(
651
722
  "td",
652
723
  {
653
724
  className: "squisq-md-td",
@@ -662,22 +733,22 @@ function renderBlocks(nodes, keyPrefix = "", ctx = DEFAULT_CTX) {
662
733
  return nodes.map((node, i) => renderBlock(node, `${keyPrefix}b${i}`, ctx));
663
734
  }
664
735
  function MdImage({ src, alt, title }) {
665
- const safeSrc = sanitizeUrl(src, "media");
736
+ const safeSrc = sanitizeUrl(src, "media") ?? svgDataImageSrc(src);
666
737
  const resolved = useMediaUrl(safeSrc ?? "", ".");
667
- const imageRef = useRef3(null);
738
+ const imageRef = useRef4(null);
668
739
  const playback = useAnimatedImage(safeSrc ?? "", resolved);
669
740
  if (!safeSrc) return null;
670
741
  if (!mayBeAnimatedImage2(safeSrc)) {
671
- return /* @__PURE__ */ jsx5("img", { className: "squisq-md-image", src: resolved, alt, title });
742
+ return /* @__PURE__ */ jsx6("img", { className: "squisq-md-image", src: resolved, alt, title });
672
743
  }
673
- return /* @__PURE__ */ jsxs3(
744
+ return /* @__PURE__ */ jsxs4(
674
745
  "span",
675
746
  {
676
747
  className: "squisq-animated-image",
677
748
  "data-animated": playback.animated ? "true" : void 0,
678
749
  style: { position: "relative", display: "inline-block", maxWidth: "100%" },
679
750
  children: [
680
- /* @__PURE__ */ jsx5(
751
+ /* @__PURE__ */ jsx6(
681
752
  "img",
682
753
  {
683
754
  ref: imageRef,
@@ -688,7 +759,7 @@ function MdImage({ src, alt, title }) {
688
759
  style: { display: "block", maxWidth: "100%" }
689
760
  }
690
761
  ),
691
- /* @__PURE__ */ jsx5(AnimatedImageControls, { playback, imageRef })
762
+ /* @__PURE__ */ jsx6(AnimatedImageControls, { playback, imageRef })
692
763
  ]
693
764
  }
694
765
  );
@@ -761,13 +832,13 @@ function renderHtmlElement(el, key, ctx) {
761
832
  const tagName = el.tagName.toLowerCase();
762
833
  if (tagName === "iframe") {
763
834
  const video = videoEmbedFromIframe(el);
764
- return video ? /* @__PURE__ */ jsx5(VideoEmbedFrame, { embed: video.embed, title: video.title, inline: true }, key) : null;
835
+ return video ? /* @__PURE__ */ jsx6(VideoEmbedFrame, { embed: video.embed, title: video.title, inline: true }, key) : null;
765
836
  }
766
837
  if (DANGEROUS_HTML_TAGS.has(tagName)) return null;
767
838
  if (tagName === "video") {
768
839
  const src = sanitizeUrl(el.attributes.src ?? "", "media") ?? "";
769
840
  const poster = sanitizeUrl(el.attributes.poster ?? "", "media") ?? void 0;
770
- return /* @__PURE__ */ jsx5(
841
+ return /* @__PURE__ */ jsx6(
771
842
  InlineVideoPlayer,
772
843
  {
773
844
  src,
@@ -782,7 +853,7 @@ function renderHtmlElement(el, key, ctx) {
782
853
  }
783
854
  if (tagName === "audio") {
784
855
  const src = sanitizeUrl(el.attributes.src ?? "", "media") ?? "";
785
- return /* @__PURE__ */ jsx5(
856
+ return /* @__PURE__ */ jsx6(
786
857
  InlineAudioPlayer,
787
858
  {
788
859
  src,
@@ -795,9 +866,9 @@ function renderHtmlElement(el, key, ctx) {
795
866
  const Tag = tagName;
796
867
  const props = reactPropsFromAttrs(el.attributes, ctx);
797
868
  if (el.selfClosing) {
798
- return /* @__PURE__ */ jsx5(Tag, { ...props }, key);
869
+ return /* @__PURE__ */ jsx6(Tag, { ...props }, key);
799
870
  }
800
- return /* @__PURE__ */ jsx5(Tag, { ...props, children: renderHtmlNodes(el.children, `${key}c`, ctx) }, key);
871
+ return /* @__PURE__ */ jsx6(Tag, { ...props, children: renderHtmlNodes(el.children, `${key}c`, ctx) }, key);
801
872
  }
802
873
  function renderHtmlNodes(nodes, keyPrefix, ctx = DEFAULT_CTX) {
803
874
  return nodes.map((node, i) => {
@@ -806,7 +877,7 @@ function renderHtmlNodes(nodes, keyPrefix, ctx = DEFAULT_CTX) {
806
877
  case "htmlElement":
807
878
  return renderHtmlElement(node, key, ctx);
808
879
  case "htmlText":
809
- return /* @__PURE__ */ jsx5(Fragment2, { children: node.value }, key);
880
+ return /* @__PURE__ */ jsx6(Fragment2, { children: node.value }, key);
810
881
  case "htmlComment":
811
882
  return null;
812
883
  default:
@@ -828,7 +899,7 @@ function MarkdownRenderer({
828
899
  }) {
829
900
  const ambientFenceRenderers = useFenceRenderers();
830
901
  const mediaProvider = useMediaProvider();
831
- const [accessoryPaths, setAccessoryPaths] = useState2(NO_ACCESSORY_PATHS);
902
+ const [accessoryPaths, setAccessoryPaths] = useState3(NO_ACCESSORY_PATHS);
832
903
  useEffect2(() => {
833
904
  if (!mediaProvider) {
834
905
  setAccessoryPaths(clearAccessoryPaths);
@@ -848,7 +919,7 @@ function MarkdownRenderer({
848
919
  };
849
920
  }, [mediaProvider]);
850
921
  if (!nodes || nodes.length === 0) return null;
851
- return /* @__PURE__ */ jsx5("div", { className: `squisq-md ${className || ""}`, children: renderBlocks(nodes, "", {
922
+ return /* @__PURE__ */ jsx6("div", { className: `squisq-md ${className || ""}`, children: renderBlocks(nodes, "", {
852
923
  htmlPolicy,
853
924
  linkSchemes,
854
925
  theme,
@@ -867,5 +938,6 @@ export {
867
938
  VideoEmbedFrame,
868
939
  AnimatedImageControls,
869
940
  useAnimatedImage,
941
+ SvgIslandImage,
870
942
  MarkdownRenderer
871
943
  };
@@ -33,7 +33,7 @@ interface DiagramPictureOptions {
33
33
  }
34
34
  /** The diagram description `@bendyline/squisq-formats/diagrams` passes. */
35
35
  interface DiagramToPicture {
36
- kind: 'mermaid' | 'diagram' | 'timeline' | 'tree' | 'container';
36
+ kind: 'mermaid' | 'diagram' | 'timeline' | 'tree' | 'container' | 'svg';
37
37
  markdown: string;
38
38
  source: string;
39
39
  }
@@ -43,6 +43,12 @@ declare const EXPORT_FONT_STACK = "-apple-system, BlinkMacSystemFont, 'Segoe UI'
43
43
  declare function svgToPng(svg: SVGSVGElement, width: number, height: number, options?: DiagramPictureOptions): Promise<DiagramPicturePng>;
44
44
  /** A Mermaid diagram as a PNG at its natural size (capped at `maxWidth`). */
45
45
  declare function renderMermaidPicture(source: string, options?: DiagramPictureOptions): Promise<DiagramPicturePng>;
46
+ /**
47
+ * An SVG island as a PNG: core's sanitized markup (drawn as a still, in the
48
+ * theme's text color) at its intrinsic size, capped at `maxWidth`. Null when
49
+ * the fence is not an island.
50
+ */
51
+ declare function renderSvgIslandPicture(source: string, options?: DiagramPictureOptions): Promise<DiagramPicturePng | null>;
46
52
  /** A file-tree fence as monospace text lines, exactly as written. */
47
53
  declare function renderTreePicture(source: string, options?: DiagramPictureOptions): Promise<DiagramPicturePng | null>;
48
54
  /**
@@ -58,4 +64,4 @@ declare function renderSquisqDiagramPicture(markdown: string, options?: DiagramP
58
64
  */
59
65
  declare function createDiagramPictureRenderer(options?: DiagramPictureOptions): (diagram: DiagramToPicture) => Promise<DiagramPicturePng | null>;
60
66
 
61
- export { type DiagramPictureOptions, type DiagramPicturePng, type DiagramToPicture, EXPORT_FONT_STACK, createDiagramPictureRenderer, renderMermaidPicture, renderSquisqDiagramPicture, renderTreePicture, svgToPng };
67
+ export { type DiagramPictureOptions, type DiagramPicturePng, type DiagramToPicture, EXPORT_FONT_STACK, createDiagramPictureRenderer, renderMermaidPicture, renderSquisqDiagramPicture, renderSvgIslandPicture, renderTreePicture, svgToPng };