@reblu/site-blocks 0.16.0 → 0.17.0

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.
package/dist/index.d.cts CHANGED
@@ -3,6 +3,7 @@ export { DATA_REQUEST_TYPES } from '@reblu/site-contracts';
3
3
  import { FaqItem } from './seo.cjs';
4
4
  export { FaqPageJsonLd, MarkdownToPlainTextOptions, buildFaqPageJsonLd, collectFaqItems, markdownToPlainText } from './seo.cjs';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
+ import * as React$1 from 'react';
6
7
  import { ReactNode, ComponentType, FormEvent } from 'react';
7
8
 
8
9
  declare function readingTime(content: string | null | undefined): number | null;
@@ -226,8 +227,27 @@ interface MarkdownRendererProps {
226
227
  * the page keeps a single h1.
227
228
  */
228
229
  headingOffset?: number;
230
+ /**
231
+ * Restrict and render images (REB-1075). Absent: every image the sanitiser keeps is
232
+ * rendered as a lazy `<img>` inside its paragraph (the historical behaviour).
233
+ */
234
+ images?: MarkdownImageOptions;
235
+ }
236
+ /** The `images` option of {@link MarkdownRenderer}. */
237
+ interface MarkdownImageOptions {
238
+ /**
239
+ * Absolute URL prefixes an image may load from (e.g. a storage bucket's public URL,
240
+ * ending in `/`). Any other image is dropped. Compared on the parsed, normalised URL
241
+ * (`..` resolved), with the scheme included, so `http:` never matches an `https:` prefix.
242
+ */
243
+ allowedUrlPrefixes: readonly string[];
244
+ /** Render an allowed image yourself (e.g. `next/image`). Default: a lazy `<img>`. */
245
+ render?: (image: {
246
+ src: string;
247
+ alt: string;
248
+ }) => React$1.ReactNode;
229
249
  }
230
- declare function MarkdownRenderer({ content, className, headingOffset }: MarkdownRendererProps): react_jsx_runtime.JSX.Element | null;
250
+ declare function MarkdownRenderer({ content, className, headingOffset, images, }: MarkdownRendererProps): react_jsx_runtime.JSX.Element | null;
231
251
  /**
232
252
  * Render an **already-sanitised** HTML string through the same token-driven
233
253
  * component map as {@link MarkdownRenderer}. Consumers pass HTML that has been run
@@ -1229,4 +1249,4 @@ interface OrderInvoiceLinkProps {
1229
1249
  }
1230
1250
  declare function OrderInvoiceLink({ invoice, labels, className }: OrderInvoiceLinkProps): react_jsx_runtime.JSX.Element | null;
1231
1251
 
1232
- export { ALLOWED_YOUTUBE_HOSTS, AddedToCartToast, type AddedToCartToastLabels, type AddedToCartToastProps, type AddedToCartToastStatus, type BlockRendererProps, type CanonicalBlockType, type CartAdjustmentLine, CartAdjustmentsNotice, type CartAdjustmentsNoticeLabels, type CartAdjustmentsNoticeProps, type CartLineItemView, CartLineList, type CartLineListLabels, type CartLineListProps, CartSummary, type CartSummaryLabels, type CartSummaryProps, type CheckoutAppliedDiscount, type CheckoutContactErrors, type CheckoutContactValues, CheckoutForm, type CheckoutFormLabels, type CheckoutFormProps, CheckoutLoginPrompt, type CheckoutLoginPromptLabels, type CheckoutLoginPromptProps, CourseDescription, type CourseDescriptionProps, DEFAULT_INVOICE_COUNTRIES, DEFAULT_SHOP_ERROR_FALLBACK_MESSAGE, DEFAULT_SHOP_ERROR_MESSAGES, DEFAULT_SHOP_PRICE_BANDS, DEFAULT_TRUST_BADGE_HEADINGS, DEFAULT_TRUST_BADGE_TYPE_ORDER, DEFAULT_TRUST_ICONS, EMPTY_FULL_INVOICE_VALUE, FaqAccordion, type FaqAccordionProps, FaqItem, type FullInvoiceErrors, FullInvoiceFields, type FullInvoiceFieldsLabels, type FullInvoiceFieldsProps, type FullInvoiceIdType, type FullInvoiceValue, type HeadingLevel, MarkdownRenderer, type MarkdownRendererProps, OrderConfirmation, type OrderConfirmationLabels, type OrderConfirmationOrder, type OrderConfirmationProps, type OrderConfirmationStatus, OrderInvoiceLink, type OrderInvoiceLinkLabels, type OrderInvoiceLinkProps, PageBlocks, type PageBlocksComponents, type PageBlocksProps, PageCardGrid, type PageCardGridProps, ParentPage, type ParentPageProps, ProductCard, type ProductCardProps, ProductTrustItems, type ProductTrustItemsProps, ProfileCard, type ProfileCardProps, type RenderableBlock, SafeHtml, type SafeHtmlProps, type ShareUrls, type ShopFilterPriceBand, ShopFilters, type ShopFiltersActive, type ShopFiltersHrefs, type ShopFiltersLabels, type ShopFiltersProps, Specialty, type SpecialtyProps, Treatment, type TreatmentProps, TrustBadges, type TrustBadgesProps, type TrustIconComponent, type TrustIconProps, buildShareUrls, formatPrice, getShopErrorMessage, isAllowedYouTubeHost, isOverSimplifiedInvoiceCap, markdownToSafeHtml, readingTime, sanitizeHtml, shopIssuesInvoices, shouldRenderShopFilters, toCheckoutInvoiceFields };
1252
+ export { ALLOWED_YOUTUBE_HOSTS, AddedToCartToast, type AddedToCartToastLabels, type AddedToCartToastProps, type AddedToCartToastStatus, type BlockRendererProps, type CanonicalBlockType, type CartAdjustmentLine, CartAdjustmentsNotice, type CartAdjustmentsNoticeLabels, type CartAdjustmentsNoticeProps, type CartLineItemView, CartLineList, type CartLineListLabels, type CartLineListProps, CartSummary, type CartSummaryLabels, type CartSummaryProps, type CheckoutAppliedDiscount, type CheckoutContactErrors, type CheckoutContactValues, CheckoutForm, type CheckoutFormLabels, type CheckoutFormProps, CheckoutLoginPrompt, type CheckoutLoginPromptLabels, type CheckoutLoginPromptProps, CourseDescription, type CourseDescriptionProps, DEFAULT_INVOICE_COUNTRIES, DEFAULT_SHOP_ERROR_FALLBACK_MESSAGE, DEFAULT_SHOP_ERROR_MESSAGES, DEFAULT_SHOP_PRICE_BANDS, DEFAULT_TRUST_BADGE_HEADINGS, DEFAULT_TRUST_BADGE_TYPE_ORDER, DEFAULT_TRUST_ICONS, EMPTY_FULL_INVOICE_VALUE, FaqAccordion, type FaqAccordionProps, FaqItem, type FullInvoiceErrors, FullInvoiceFields, type FullInvoiceFieldsLabels, type FullInvoiceFieldsProps, type FullInvoiceIdType, type FullInvoiceValue, type HeadingLevel, type MarkdownImageOptions, MarkdownRenderer, type MarkdownRendererProps, OrderConfirmation, type OrderConfirmationLabels, type OrderConfirmationOrder, type OrderConfirmationProps, type OrderConfirmationStatus, OrderInvoiceLink, type OrderInvoiceLinkLabels, type OrderInvoiceLinkProps, PageBlocks, type PageBlocksComponents, type PageBlocksProps, PageCardGrid, type PageCardGridProps, ParentPage, type ParentPageProps, ProductCard, type ProductCardProps, ProductTrustItems, type ProductTrustItemsProps, ProfileCard, type ProfileCardProps, type RenderableBlock, SafeHtml, type SafeHtmlProps, type ShareUrls, type ShopFilterPriceBand, ShopFilters, type ShopFiltersActive, type ShopFiltersHrefs, type ShopFiltersLabels, type ShopFiltersProps, Specialty, type SpecialtyProps, Treatment, type TreatmentProps, TrustBadges, type TrustBadgesProps, type TrustIconComponent, type TrustIconProps, buildShareUrls, formatPrice, getShopErrorMessage, isAllowedYouTubeHost, isOverSimplifiedInvoiceCap, markdownToSafeHtml, readingTime, sanitizeHtml, shopIssuesInvoices, shouldRenderShopFilters, toCheckoutInvoiceFields };
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export { DATA_REQUEST_TYPES } from '@reblu/site-contracts';
3
3
  import { FaqItem } from './seo.js';
4
4
  export { FaqPageJsonLd, MarkdownToPlainTextOptions, buildFaqPageJsonLd, collectFaqItems, markdownToPlainText } from './seo.js';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
+ import * as React$1 from 'react';
6
7
  import { ReactNode, ComponentType, FormEvent } from 'react';
7
8
 
8
9
  declare function readingTime(content: string | null | undefined): number | null;
@@ -226,8 +227,27 @@ interface MarkdownRendererProps {
226
227
  * the page keeps a single h1.
227
228
  */
228
229
  headingOffset?: number;
230
+ /**
231
+ * Restrict and render images (REB-1075). Absent: every image the sanitiser keeps is
232
+ * rendered as a lazy `<img>` inside its paragraph (the historical behaviour).
233
+ */
234
+ images?: MarkdownImageOptions;
235
+ }
236
+ /** The `images` option of {@link MarkdownRenderer}. */
237
+ interface MarkdownImageOptions {
238
+ /**
239
+ * Absolute URL prefixes an image may load from (e.g. a storage bucket's public URL,
240
+ * ending in `/`). Any other image is dropped. Compared on the parsed, normalised URL
241
+ * (`..` resolved), with the scheme included, so `http:` never matches an `https:` prefix.
242
+ */
243
+ allowedUrlPrefixes: readonly string[];
244
+ /** Render an allowed image yourself (e.g. `next/image`). Default: a lazy `<img>`. */
245
+ render?: (image: {
246
+ src: string;
247
+ alt: string;
248
+ }) => React$1.ReactNode;
229
249
  }
230
- declare function MarkdownRenderer({ content, className, headingOffset }: MarkdownRendererProps): react_jsx_runtime.JSX.Element | null;
250
+ declare function MarkdownRenderer({ content, className, headingOffset, images, }: MarkdownRendererProps): react_jsx_runtime.JSX.Element | null;
231
251
  /**
232
252
  * Render an **already-sanitised** HTML string through the same token-driven
233
253
  * component map as {@link MarkdownRenderer}. Consumers pass HTML that has been run
@@ -1229,4 +1249,4 @@ interface OrderInvoiceLinkProps {
1229
1249
  }
1230
1250
  declare function OrderInvoiceLink({ invoice, labels, className }: OrderInvoiceLinkProps): react_jsx_runtime.JSX.Element | null;
1231
1251
 
1232
- export { ALLOWED_YOUTUBE_HOSTS, AddedToCartToast, type AddedToCartToastLabels, type AddedToCartToastProps, type AddedToCartToastStatus, type BlockRendererProps, type CanonicalBlockType, type CartAdjustmentLine, CartAdjustmentsNotice, type CartAdjustmentsNoticeLabels, type CartAdjustmentsNoticeProps, type CartLineItemView, CartLineList, type CartLineListLabels, type CartLineListProps, CartSummary, type CartSummaryLabels, type CartSummaryProps, type CheckoutAppliedDiscount, type CheckoutContactErrors, type CheckoutContactValues, CheckoutForm, type CheckoutFormLabels, type CheckoutFormProps, CheckoutLoginPrompt, type CheckoutLoginPromptLabels, type CheckoutLoginPromptProps, CourseDescription, type CourseDescriptionProps, DEFAULT_INVOICE_COUNTRIES, DEFAULT_SHOP_ERROR_FALLBACK_MESSAGE, DEFAULT_SHOP_ERROR_MESSAGES, DEFAULT_SHOP_PRICE_BANDS, DEFAULT_TRUST_BADGE_HEADINGS, DEFAULT_TRUST_BADGE_TYPE_ORDER, DEFAULT_TRUST_ICONS, EMPTY_FULL_INVOICE_VALUE, FaqAccordion, type FaqAccordionProps, FaqItem, type FullInvoiceErrors, FullInvoiceFields, type FullInvoiceFieldsLabels, type FullInvoiceFieldsProps, type FullInvoiceIdType, type FullInvoiceValue, type HeadingLevel, MarkdownRenderer, type MarkdownRendererProps, OrderConfirmation, type OrderConfirmationLabels, type OrderConfirmationOrder, type OrderConfirmationProps, type OrderConfirmationStatus, OrderInvoiceLink, type OrderInvoiceLinkLabels, type OrderInvoiceLinkProps, PageBlocks, type PageBlocksComponents, type PageBlocksProps, PageCardGrid, type PageCardGridProps, ParentPage, type ParentPageProps, ProductCard, type ProductCardProps, ProductTrustItems, type ProductTrustItemsProps, ProfileCard, type ProfileCardProps, type RenderableBlock, SafeHtml, type SafeHtmlProps, type ShareUrls, type ShopFilterPriceBand, ShopFilters, type ShopFiltersActive, type ShopFiltersHrefs, type ShopFiltersLabels, type ShopFiltersProps, Specialty, type SpecialtyProps, Treatment, type TreatmentProps, TrustBadges, type TrustBadgesProps, type TrustIconComponent, type TrustIconProps, buildShareUrls, formatPrice, getShopErrorMessage, isAllowedYouTubeHost, isOverSimplifiedInvoiceCap, markdownToSafeHtml, readingTime, sanitizeHtml, shopIssuesInvoices, shouldRenderShopFilters, toCheckoutInvoiceFields };
1252
+ export { ALLOWED_YOUTUBE_HOSTS, AddedToCartToast, type AddedToCartToastLabels, type AddedToCartToastProps, type AddedToCartToastStatus, type BlockRendererProps, type CanonicalBlockType, type CartAdjustmentLine, CartAdjustmentsNotice, type CartAdjustmentsNoticeLabels, type CartAdjustmentsNoticeProps, type CartLineItemView, CartLineList, type CartLineListLabels, type CartLineListProps, CartSummary, type CartSummaryLabels, type CartSummaryProps, type CheckoutAppliedDiscount, type CheckoutContactErrors, type CheckoutContactValues, CheckoutForm, type CheckoutFormLabels, type CheckoutFormProps, CheckoutLoginPrompt, type CheckoutLoginPromptLabels, type CheckoutLoginPromptProps, CourseDescription, type CourseDescriptionProps, DEFAULT_INVOICE_COUNTRIES, DEFAULT_SHOP_ERROR_FALLBACK_MESSAGE, DEFAULT_SHOP_ERROR_MESSAGES, DEFAULT_SHOP_PRICE_BANDS, DEFAULT_TRUST_BADGE_HEADINGS, DEFAULT_TRUST_BADGE_TYPE_ORDER, DEFAULT_TRUST_ICONS, EMPTY_FULL_INVOICE_VALUE, FaqAccordion, type FaqAccordionProps, FaqItem, type FullInvoiceErrors, FullInvoiceFields, type FullInvoiceFieldsLabels, type FullInvoiceFieldsProps, type FullInvoiceIdType, type FullInvoiceValue, type HeadingLevel, type MarkdownImageOptions, MarkdownRenderer, type MarkdownRendererProps, OrderConfirmation, type OrderConfirmationLabels, type OrderConfirmationOrder, type OrderConfirmationProps, type OrderConfirmationStatus, OrderInvoiceLink, type OrderInvoiceLinkLabels, type OrderInvoiceLinkProps, PageBlocks, type PageBlocksComponents, type PageBlocksProps, PageCardGrid, type PageCardGridProps, ParentPage, type ParentPageProps, ProductCard, type ProductCardProps, ProductTrustItems, type ProductTrustItemsProps, ProfileCard, type ProfileCardProps, type RenderableBlock, SafeHtml, type SafeHtmlProps, type ShareUrls, type ShopFilterPriceBand, ShopFilters, type ShopFiltersActive, type ShopFiltersHrefs, type ShopFiltersLabels, type ShopFiltersProps, Specialty, type SpecialtyProps, Treatment, type TreatmentProps, TrustBadges, type TrustBadgesProps, type TrustIconComponent, type TrustIconProps, buildShareUrls, formatPrice, getShopErrorMessage, isAllowedYouTubeHost, isOverSimplifiedInvoiceCap, markdownToSafeHtml, readingTime, sanitizeHtml, shopIssuesInvoices, shouldRenderShopFilters, toCheckoutInvoiceFields };