@comet/site-react 9.0.0-beta.3 → 9.0.0-beta.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.
Files changed (74) hide show
  1. package/lib/blockLoader/blockLoader.js +1 -59
  2. package/lib/blocks/DamFileDownloadLinkBlock.js +1 -27
  3. package/lib/blocks/DamVideoBlock.d.ts.map +1 -1
  4. package/lib/blocks/DamVideoBlock.js +5 -99
  5. package/lib/blocks/DamVideoBlock.module.scss.js +1 -14
  6. package/lib/blocks/EmailLinkBlock.js +1 -21
  7. package/lib/blocks/ExternalLinkBlock.js +1 -47
  8. package/lib/blocks/PhoneLinkBlock.js +1 -21
  9. package/lib/blocks/SvgImageBlock.js +1 -30
  10. package/lib/blocks/VimeoVideoBlock.d.ts.map +1 -1
  11. package/lib/blocks/VimeoVideoBlock.js +4 -129
  12. package/lib/blocks/VimeoVideoBlock.module.scss.js +1 -14
  13. package/lib/blocks/YouTubeVideoBlock.d.ts.map +1 -1
  14. package/lib/blocks/YouTubeVideoBlock.js +4 -136
  15. package/lib/blocks/YouTubeVideoBlock.module.scss.js +1 -14
  16. package/lib/blocks/factories/BlocksBlock.js +1 -27
  17. package/lib/blocks/factories/ListBlock.js +1 -13
  18. package/lib/blocks/factories/OneOfBlock.js +1 -23
  19. package/lib/blocks/factories/OptionalBlock.js +1 -10
  20. package/lib/blocks/helpers/PlayPauseButton.js +1 -9
  21. package/lib/blocks/helpers/PlayPauseButton.module.scss.js +1 -14
  22. package/lib/blocks/helpers/RichTextBlockHelper.js +1 -7
  23. package/lib/blocks/helpers/TipTapRichTextRenderer.d.ts +35 -0
  24. package/lib/blocks/helpers/TipTapRichTextRenderer.d.ts.map +1 -0
  25. package/lib/blocks/helpers/TipTapRichTextRenderer.js +3 -0
  26. package/lib/blocks/helpers/VideoPreviewImage.js +2 -23
  27. package/lib/blocks/helpers/VideoPreviewImage.module.scss.js +1 -17
  28. package/lib/blocks/helpers/useIsElementInViewport.js +1 -21
  29. package/lib/cookies/CookieApiContext.js +2 -18
  30. package/lib/cookies/CookieSafe.js +2 -18
  31. package/lib/cookies/useCookieBotCookieApi.js +1 -33
  32. package/lib/cookies/useLocalStorageCookieApi.js +1 -40
  33. package/lib/cookies/useOneTrustCookieApi.js +1 -45
  34. package/lib/errorHandler/ErrorHandlerBoundary.js +2 -10
  35. package/lib/errorHandler/ErrorHandlerBoundaryInternal.js +1 -26
  36. package/lib/errorHandler/ErrorHandlerProvider.js +2 -20
  37. package/lib/graphQLFetch/fetchInMemoryCache.js +1 -37
  38. package/lib/graphQLFetch/graphQLFetch.js +1 -125
  39. package/lib/iframebridge/IFrameBridge.js +4 -253
  40. package/lib/iframebridge/IFrameBridge.module.scss.js +1 -8
  41. package/lib/iframebridge/IFrameMessage.js +1 -21
  42. package/lib/iframebridge/Preview.js +1 -56
  43. package/lib/iframebridge/Preview.module.scss.js +1 -8
  44. package/lib/iframebridge/PreviewOverlay.js +1 -28
  45. package/lib/iframebridge/PreviewOverlay.module.scss.js +1 -8
  46. package/lib/iframebridge/PreviewOverlayElement.js +2 -36
  47. package/lib/iframebridge/PreviewOverlayElement.module.scss.js +1 -20
  48. package/lib/iframebridge/useBlockPreviewFetch.js +1 -29
  49. package/lib/iframebridge/useIFrameBridge.js +1 -8
  50. package/lib/iframebridge/utils.js +1 -46
  51. package/lib/iframebridge/withPreview.js +1 -33
  52. package/lib/image/Image.js +2 -10
  53. package/lib/image/image.utils.js +1 -55
  54. package/lib/index.d.ts +2 -2
  55. package/lib/index.d.ts.map +1 -1
  56. package/lib/index.js +1 -96
  57. package/lib/jsonLd/JsonLd.d.ts +7 -0
  58. package/lib/jsonLd/JsonLd.d.ts.map +1 -0
  59. package/lib/jsonLd/JsonLd.js +1 -0
  60. package/lib/persistedQueries/createPersistedQueryGraphQLFetch.js +1 -70
  61. package/lib/persistedQueries/persistedQueryRoute.js +1 -100
  62. package/lib/persistedQueries/webpackPersistedQueriesLoader.js +1 -51
  63. package/lib/preview/BlockPreviewProvider.js +1 -32
  64. package/lib/preview/PreviewContext.js +1 -9
  65. package/lib/preview/usePreview.js +1 -41
  66. package/lib/previewskeleton/PreviewSkeleton.js +8 -64
  67. package/lib/previewskeleton/PreviewSkeleton.module.scss.js +1 -17
  68. package/lib/server.d.ts +2 -0
  69. package/lib/server.d.ts.map +1 -0
  70. package/lib/server.js +1 -0
  71. package/lib/sitePreview/iframebridge/SitePreviewIFrameMessage.js +1 -8
  72. package/lib/sitePreview/iframebridge/sendSitePreviewIFrameMessage.js +1 -6
  73. package/lib/style.css +1 -1
  74. package/package.json +15 -8
@@ -1,137 +1,5 @@
1
1
  "use client";
2
- import { jsx, Fragment, jsxs } from "react/jsx-runtime";
3
- import clsx from "clsx";
4
- import { useState, useRef, useCallback } from "react";
5
- import { withPreview } from "../iframebridge/withPreview.js";
6
- import { PreviewSkeleton } from "../previewskeleton/PreviewSkeleton.js";
7
- import { PlayPauseButton } from "./helpers/PlayPauseButton.js";
8
- import { useIsElementInViewport } from "./helpers/useIsElementInViewport.js";
9
- import styles from "./YouTubeVideoBlock.module.scss.js";
10
- const EXPECTED_YT_ID_LENGTH = 11;
11
- const parseYoutubeIdentifier = (value) => {
12
- const regExp = /(https?:\/\/)?(((m|www)\.)?(youtube(-nocookie)?|youtube.googleapis)\.com.*(v\/|v=|vi=|vi\/|e\/|embed\/|user\/.*\/u\/\d+\/)|youtu\.be\/)([_0-9a-zA-Z-]+)/;
13
- const match = value.match(regExp);
14
- const youtubeId = value.length === EXPECTED_YT_ID_LENGTH ? value : match && match[8].length === EXPECTED_YT_ID_LENGTH ? match[8] : null;
15
- return youtubeId ?? void 0;
16
- };
17
- const YouTubeVideoBlock = withPreview(
18
- ({
19
- data: { youtubeIdentifier, autoplay, loop, showControls, previewImage },
20
- aspectRatio = "16x9",
21
- previewImageSizes,
22
- renderPreviewImage,
23
- fill,
24
- previewImageIcon,
25
- playButtonAriaLabel,
26
- pauseButtonAriaLabel,
27
- playPauseButton: PlayPauseButtonComponent
28
- }) => {
29
- const [showPreviewImage, setShowPreviewImage] = useState(true);
30
- const [isPlaying, setIsPlaying] = useState(autoplay ?? false);
31
- const [isHandledManually, setIsHandledManually] = useState(false);
32
- const hasPreviewImage = !!(previewImage && previewImage.damFile);
33
- const [iframeElement, setIframeElement] = useState(null);
34
- const iframeRef = setIframeElement;
35
- const inViewRef = useRef(null);
36
- const pauseYouTubeVideo = useCallback(() => {
37
- var _a;
38
- (_a = iframeElement == null ? void 0 : iframeElement.contentWindow) == null ? void 0 : _a.postMessage(`{"event":"command","func":"pauseVideo","args":""}`, "https://www.youtube-nocookie.com");
39
- }, [iframeElement]);
40
- const playYouTubeVideo = useCallback(() => {
41
- var _a;
42
- (_a = iframeElement == null ? void 0 : iframeElement.contentWindow) == null ? void 0 : _a.postMessage(`{"event":"command","func":"playVideo","args":""}`, "https://www.youtube-nocookie.com");
43
- }, [iframeElement]);
44
- const handleInView = useCallback(
45
- (inView) => {
46
- if (!isHandledManually) {
47
- if (inView && autoplay) {
48
- playYouTubeVideo();
49
- setIsPlaying(true);
50
- } else {
51
- pauseYouTubeVideo();
52
- setIsPlaying(false);
53
- }
54
- }
55
- },
56
- [autoplay, isHandledManually, playYouTubeVideo, pauseYouTubeVideo]
57
- );
58
- useIsElementInViewport(inViewRef, handleInView);
59
- if (!youtubeIdentifier) {
60
- return /* @__PURE__ */ jsx(PreviewSkeleton, { type: "media", hasContent: false, aspectRatio });
61
- }
62
- const identifier = parseYoutubeIdentifier(youtubeIdentifier);
63
- const searchParams = new URLSearchParams();
64
- searchParams.append("modestbranding", "1");
65
- searchParams.append("rel", "0");
66
- searchParams.append("enablejsapi", "1");
67
- if (hasPreviewImage && !showPreviewImage) {
68
- searchParams.append("autoplay", "1");
69
- }
70
- if (autoplay) {
71
- searchParams.append("mute", "1");
72
- }
73
- if (showControls !== void 0) {
74
- searchParams.append("controls", Number(showControls).toString());
75
- }
76
- if (loop !== void 0) {
77
- searchParams.append("loop", Number(loop).toString());
78
- }
79
- if (loop && identifier) {
80
- searchParams.append("playlist", identifier);
81
- }
82
- const youtubeBaseUrl = "https://www.youtube-nocookie.com/embed/";
83
- const youtubeUrl = new URL(`${youtubeBaseUrl}${identifier ?? ""}`);
84
- youtubeUrl.search = searchParams.toString();
85
- const handlePlayPauseClick = () => {
86
- if (isPlaying) {
87
- setIsPlaying(false);
88
- setIsHandledManually(true);
89
- pauseYouTubeVideo();
90
- } else {
91
- setIsPlaying(true);
92
- playYouTubeVideo();
93
- }
94
- };
95
- return /* @__PURE__ */ jsx(Fragment, { children: hasPreviewImage && showPreviewImage ? renderPreviewImage({
96
- onPlay: () => setShowPreviewImage(false),
97
- image: previewImage,
98
- aspectRatio,
99
- sizes: previewImageSizes,
100
- fill,
101
- icon: previewImageIcon,
102
- playButtonAriaLabel
103
- }) : /* @__PURE__ */ jsxs(
104
- "div",
105
- {
106
- ref: inViewRef,
107
- className: clsx(styles.videoContainer, fill && styles.fill),
108
- style: !fill ? { "--aspect-ratio": aspectRatio.replace("x", "/") } : void 0,
109
- children: [
110
- !showControls && (PlayPauseButtonComponent ? /* @__PURE__ */ jsx(PlayPauseButtonComponent, { isPlaying, onClick: handlePlayPauseClick }) : /* @__PURE__ */ jsx(
111
- PlayPauseButton,
112
- {
113
- isPlaying,
114
- onClick: handlePlayPauseClick,
115
- ariaLabelPlay: playButtonAriaLabel,
116
- ariaLabelPause: pauseButtonAriaLabel
117
- }
118
- )),
119
- /* @__PURE__ */ jsx(
120
- "iframe",
121
- {
122
- ref: iframeRef,
123
- className: styles.youtubeContainer,
124
- allow: "autoplay",
125
- referrerPolicy: "strict-origin-when-cross-origin",
126
- src: youtubeUrl.toString()
127
- }
128
- )
129
- ]
130
- }
131
- ) });
132
- },
133
- { label: "Video" }
134
- );
135
- export {
136
- YouTubeVideoBlock
137
- };
2
+ import{jsx as e,Fragment as o,jsxs as t}from"react/jsx-runtime";import a from"clsx";import{useState as i,useRef as r,useCallback as n}from"react";import{withPreview as s}from"../iframebridge/withPreview.js";import{PreviewSkeleton as l}from"../previewskeleton/PreviewSkeleton.js";import{PlayPauseButton as p}from"./helpers/PlayPauseButton.js";import{useIsElementInViewport as m}from"./helpers/useIsElementInViewport.js";import u from"./YouTubeVideoBlock.module.scss.js";const c=s(({data:{youtubeIdentifier:s,autoplay:c,loop:d,showControls:w,previewImage:y},aspectRatio:g="16x9",previewImageSizes:b,renderPreviewImage:f,fill:v,previewImageIcon:h,playButtonAriaLabel:P,pauseButtonAriaLabel:k,playPauseButton:I})=>{const[j,L]=i(!0),[S,B]=i(c??!1),[C,x]=i(!1),R=!(!y||!y.damFile),[V,A]=i(null),N=A,z=r(null),M=n(()=>{V?.contentWindow?.postMessage('{"event":"command","func":"pauseVideo","args":""}',"https://www.youtube-nocookie.com")},[V]),U=n(()=>{V?.contentWindow?.postMessage('{"event":"command","func":"playVideo","args":""}',"https://www.youtube-nocookie.com")},[V]),W=n(e=>{C||(e&&c?(U(),B(!0)):(M(),B(!1)))},[c,C,U,M]);if(m(z,W),!s)/* @__PURE__ */
3
+ return e(l,{type:"media",hasContent:!1,aspectRatio:g});const E=(e=>{const o=e.match(/(https?:\/\/)?(((m|www)\.)?(youtube(-nocookie)?|youtube.googleapis)\.com.*(v\/|v=|vi=|vi\/|e\/|embed\/|user\/.*\/u\/\d+\/)|youtu\.be\/)([_0-9a-zA-Z-]+)/);return(11===e.length?e:o&&11===o[8].length?o[8]:null)??void 0})(s),F=new URLSearchParams;F.append("modestbranding","1"),F.append("rel","0"),F.append("enablejsapi","1"),R&&!j&&F.append("autoplay","1"),c&&F.append("mute","1"),void 0!==w&&F.append("controls",Number(w).toString()),void 0!==d&&F.append("loop",Number(d).toString()),d&&E&&F.append("playlist",E);const T=new URL(`https://www.youtube-nocookie.com/embed/${E??""}`);T.search=F.toString();const Y=()=>{S?(B(!1),x(!0),M()):(B(!0),U())};/* @__PURE__ */
4
+ return e(o,{children:R&&j?f({onPlay:()=>{L(!1),B(!0),x(!0)},image:y,aspectRatio:g,sizes:b,fill:v,icon:h,playButtonAriaLabel:P}):/* @__PURE__ */t("div",{ref:z,className:a(u.videoContainer,v&&u.fill),style:v?void 0:{"--aspect-ratio":g.replace("x","/")},children:[!w&&(I?/* @__PURE__ */e(I,{isPlaying:S,onClick:Y}):/* @__PURE__ */e(p,{isPlaying:S,onClick:Y,ariaLabelPlay:P,ariaLabelPause:k})),
5
+ /* @__PURE__ */e("iframe",{ref:N,className:u.youtubeContainer,allow:"autoplay",referrerPolicy:"strict-origin-when-cross-origin",src:T.toString()})]})})},{label:"Video"});export{c as YouTubeVideoBlock};
@@ -1,14 +1 @@
1
- const videoContainer = "_videoContainer_bhmhr_1";
2
- const fill = "_fill_bhmhr_7";
3
- const youtubeContainer = "_youtubeContainer_bhmhr_12";
4
- const styles = {
5
- videoContainer,
6
- fill,
7
- youtubeContainer
8
- };
9
- export {
10
- styles as default,
11
- fill,
12
- videoContainer,
13
- youtubeContainer
14
- };
1
+ const e="_videoContainer_bhmhr_1",o="_fill_bhmhr_7",n="_youtubeContainer_bhmhr_12",t={videoContainer:e,fill:o,youtubeContainer:n};export{t as default,o as fill,e as videoContainer,n as youtubeContainer};
@@ -1,27 +1 @@
1
- import { jsx, Fragment, jsxs } from "react/jsx-runtime";
2
- import { Fragment as Fragment$1 } from "react";
3
- import { ErrorHandlerBoundary } from "../../errorHandler/ErrorHandlerBoundary.js";
4
- import { PreviewSkeleton } from "../../previewskeleton/PreviewSkeleton.js";
5
- const BlocksBlock = ({ supportedBlocks, data: { blocks } }) => {
6
- if (blocks.length === 0) {
7
- return /* @__PURE__ */ jsx(PreviewSkeleton, { hasContent: false });
8
- }
9
- return /* @__PURE__ */ jsx(Fragment, { children: blocks.map((block) => {
10
- const blockFunction = supportedBlocks[block.type];
11
- if (!blockFunction) {
12
- if (process.env.NODE_ENV === "development") {
13
- return /* @__PURE__ */ jsxs("pre", { children: [
14
- "Unknown type (",
15
- block.type,
16
- "): ",
17
- JSON.stringify(block.props)
18
- ] }, block.key);
19
- }
20
- return null;
21
- }
22
- return /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(ErrorHandlerBoundary, { children: blockFunction(block.props) }) }, block.key);
23
- }) });
24
- };
25
- export {
26
- BlocksBlock
27
- };
1
+ import{jsx as r,Fragment as e,jsxs as o}from"react/jsx-runtime";import{Fragment as n}from"react";import{ErrorHandlerBoundary as t}from"../../errorHandler/ErrorHandlerBoundary.js";import{PreviewSkeleton as p}from"../../previewskeleton/PreviewSkeleton.js";const s=({supportedBlocks:s,data:{blocks:l}})=>0===l.length?/* @__PURE__ */r(p,{hasContent:!1}):/* @__PURE__ */r(e,{children:l.map(e=>{const p=s[e.type];return p?/* @__PURE__ */r(n,{children:/* @__PURE__ */r(t,{children:p(e.props)})},e.key):"development"===process.env.NODE_ENV?/* @__PURE__ */o("pre",{children:["Unknown type (",e.type,"): ",JSON.stringify(e.props)]},e.key):null})});export{s as BlocksBlock};
@@ -1,13 +1 @@
1
- import { jsx, Fragment } from "react/jsx-runtime";
2
- import { Fragment as Fragment$1 } from "react";
3
- import { ErrorHandlerBoundary } from "../../errorHandler/ErrorHandlerBoundary.js";
4
- import { PreviewSkeleton } from "../../previewskeleton/PreviewSkeleton.js";
5
- const ListBlock = ({ block: blockFunction, data: { blocks } }) => {
6
- if (blocks.length === 0) {
7
- return /* @__PURE__ */ jsx(PreviewSkeleton, { hasContent: false });
8
- }
9
- return /* @__PURE__ */ jsx(Fragment, { children: blocks.map((block) => /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(ErrorHandlerBoundary, { children: blockFunction(block.props) }) }, block.key)) });
10
- };
11
- export {
12
- ListBlock
13
- };
1
+ import{jsx as r,Fragment as e}from"react/jsx-runtime";import{Fragment as o}from"react";import{ErrorHandlerBoundary as t}from"../../errorHandler/ErrorHandlerBoundary.js";import{PreviewSkeleton as n}from"../../previewskeleton/PreviewSkeleton.js";const a=({block:a,data:{blocks:m}})=>0===m.length?/* @__PURE__ */r(n,{hasContent:!1}):/* @__PURE__ */r(e,{children:m.map(e=>/* @__PURE__ */r(o,{children:/* @__PURE__ */r(t,{children:a(e.props)})},e.key))});export{a as ListBlock};
@@ -1,23 +1 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { ErrorHandlerBoundary } from "../../errorHandler/ErrorHandlerBoundary.js";
3
- const OneOfBlock = ({ data: { block, ...additionalProps }, supportedBlocks, children, className }) => {
4
- if (!block) {
5
- return null;
6
- }
7
- const blockFunction = supportedBlocks[block.type];
8
- if (!blockFunction) {
9
- if (process.env.NODE_ENV === "development") {
10
- return /* @__PURE__ */ jsxs("pre", { children: [
11
- "Unknown type (",
12
- block.type,
13
- "): ",
14
- JSON.stringify(block.props)
15
- ] });
16
- }
17
- return null;
18
- }
19
- return /* @__PURE__ */ jsx(ErrorHandlerBoundary, { children: blockFunction({ ...block.props, ...additionalProps, children, className }) });
20
- };
21
- export {
22
- OneOfBlock
23
- };
1
+ import{jsxs as r,jsx as e}from"react/jsx-runtime";import{ErrorHandlerBoundary as n}from"../../errorHandler/ErrorHandlerBoundary.js";const o=({data:{block:o,...t},supportedBlocks:l,children:p,className:s})=>{if(!o)return null;const c=l[o.type];return c?/* @__PURE__ */e(n,{children:c({...o.props,...t,children:p,className:s})}):"development"===process.env.NODE_ENV?/* @__PURE__ */r("pre",{children:["Unknown type (",o.type,"): ",JSON.stringify(o.props)]}):null};export{o as OneOfBlock};
@@ -1,10 +1 @@
1
- import { jsx, Fragment } from "react/jsx-runtime";
2
- const OptionalBlock = ({ block: blockFunction, data: { visible, block }, children }) => {
3
- if (!visible || !block) {
4
- return null;
5
- }
6
- return /* @__PURE__ */ jsx(Fragment, { children: blockFunction({ ...block, children }) });
7
- };
8
- export {
9
- OptionalBlock
10
- };
1
+ import{jsx as l,Fragment as r}from"react/jsx-runtime";const c=({block:c,data:{visible:e,block:i},children:n})=>e&&i?/* @__PURE__ */l(r,{children:c({...i,children:n})}):null;export{c as OptionalBlock};
@@ -1,9 +1 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import clsx from "clsx";
3
- import styles from "./PlayPauseButton.module.scss.js";
4
- const PlayPauseButton = ({ isPlaying, onClick, ariaLabelPlay, ariaLabelPause }) => {
5
- return /* @__PURE__ */ jsx("button", { className: clsx(styles.button), onClick, "aria-label": isPlaying ? ariaLabelPause ?? "Pause" : ariaLabelPlay ?? "Play", children: /* @__PURE__ */ jsx("div", { className: clsx(styles.animatedPlayPause, isPlaying && styles.animatedPlayPausePaused) }) });
6
- };
7
- export {
8
- PlayPauseButton
9
- };
1
+ import{jsx as a}from"react/jsx-runtime";import e from"clsx";import s from"./PlayPauseButton.module.scss.js";const l=({isPlaying:l,onClick:i,ariaLabelPlay:t,ariaLabelPause:o})=>/* @__PURE__ */a("button",{className:e(s.button),onClick:i,"aria-label":l?o??"Pause":t??"Play",children:/* @__PURE__ */a("div",{className:e(s.animatedPlayPause,l&&s.animatedPlayPausePaused)})});export{l as PlayPauseButton};
@@ -1,14 +1 @@
1
- const button = "_button_4r8gs_1";
2
- const animatedPlayPause = "_animatedPlayPause_4r8gs_23";
3
- const animatedPlayPausePaused = "_animatedPlayPausePaused_4r8gs_32";
4
- const styles = {
5
- button,
6
- animatedPlayPause,
7
- animatedPlayPausePaused
8
- };
9
- export {
10
- animatedPlayPause,
11
- animatedPlayPausePaused,
12
- button,
13
- styles as default
14
- };
1
+ const a="_button_4r8gs_1",e="_animatedPlayPause_4r8gs_23",s="_animatedPlayPausePaused_4r8gs_32",t={button:a,animatedPlayPause:e,animatedPlayPausePaused:s};export{e as animatedPlayPause,s as animatedPlayPausePaused,a as button,t as default};
@@ -1,7 +1 @@
1
- const hasRichTextBlockContent = (data) => {
2
- const draftContent = data.draftContent;
3
- return !(draftContent.blocks.length === 0 || draftContent.blocks.length === 1 && draftContent.blocks[0].text === "");
4
- };
5
- export {
6
- hasRichTextBlockContent
7
- };
1
+ const t=t=>{const n=t.draftContent;return!(0===n.blocks.length||1===n.blocks.length&&""===n.blocks[0].text)};export{t as hasRichTextBlockContent};
@@ -0,0 +1,35 @@
1
+ import { ReactNode } from 'react';
2
+ export interface TipTapMark {
3
+ type: string;
4
+ attrs?: Record<string, unknown>;
5
+ }
6
+ export interface TipTapNode {
7
+ type: string;
8
+ attrs?: Record<string, unknown>;
9
+ content?: TipTapNode[];
10
+ marks?: TipTapMark[];
11
+ text?: string;
12
+ }
13
+ export interface TipTapNodeHandlerProps {
14
+ node: TipTapNode;
15
+ parent?: TipTapNode;
16
+ children: ReactNode;
17
+ }
18
+ export interface TipTapMarkHandlerProps {
19
+ mark: TipTapMark;
20
+ node: TipTapNode;
21
+ children: ReactNode;
22
+ }
23
+ export type TipTapNodeHandler = (props: TipTapNodeHandlerProps) => ReactNode;
24
+ export type TipTapMarkHandler = (props: TipTapMarkHandlerProps) => ReactNode;
25
+ export interface RenderTipTapRichTextOptions {
26
+ content: TipTapNode;
27
+ nodeMapping?: Record<string, TipTapNodeHandler>;
28
+ markMapping?: Record<string, TipTapMarkHandler>;
29
+ }
30
+ /**
31
+ * @experimental
32
+ */
33
+ export declare function renderTipTapRichText({ content, nodeMapping, markMapping }: RenderTipTapRichTextOptions): ReactNode;
34
+ export declare function hasTipTapRichTextContent(content: TipTapNode | null | undefined): boolean;
35
+ //# sourceMappingURL=TipTapRichTextRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TipTapRichTextRenderer.d.ts","sourceRoot":"","sources":["../../../src/blocks/helpers/TipTapRichTextRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAErE,MAAM,WAAW,UAAU;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,MAAM,WAAW,UAAU;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC;IACvB,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,sBAAsB;IACnC,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,QAAQ,EAAE,SAAS,CAAC;CACvB;AAED,MAAM,WAAW,sBAAsB;IACnC,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,SAAS,CAAC;CACvB;AAED,MAAM,MAAM,iBAAiB,GAAG,CAAC,KAAK,EAAE,sBAAsB,KAAK,SAAS,CAAC;AAC7E,MAAM,MAAM,iBAAiB,GAAG,CAAC,KAAK,EAAE,sBAAsB,KAAK,SAAS,CAAC;AAE7E,MAAM,WAAW,2BAA2B;IACxC,OAAO,EAAE,UAAU,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAChD,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;CACnD;AA4BD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,EAAE,2BAA2B,GAAG,SAAS,CAqClH;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAKxF"}
@@ -0,0 +1,3 @@
1
+ import{jsx as r,Fragment as n}from"react/jsx-runtime";import{isValidElement as e,cloneElement as t}from"react";const i=String.fromCodePoint(160),c=String.fromCodePoint(173),o={paragraph:({children:n})=>/* @__PURE__ */r("p",{children:n}),heading:({node:n,children:e})=>{const t=n.attrs?.level??1;/* @__PURE__ */
2
+ return r(`h${t}`,{children:e})},bulletList:({children:n})=>/* @__PURE__ */r("ul",{children:n}),orderedList:({children:n})=>/* @__PURE__ */r("ol",{children:n}),listItem:({children:n})=>/* @__PURE__ */r("li",{children:n}),hardBreak:()=>/* @__PURE__ */r("br",{}),nonBreakingSpace:()=>i,softHyphen:()=>c},d={bold:({children:n})=>/* @__PURE__ */r("strong",{children:n}),italic:({children:n})=>/* @__PURE__ */r("em",{children:n}),strike:({children:n})=>/* @__PURE__ */r("s",{children:n}),superscript:({children:n})=>/* @__PURE__ */r("sup",{children:n}),subscript:({children:n})=>/* @__PURE__ */r("sub",{children:n})};function l({content:i,nodeMapping:c,markMapping:l}){const h={...o,...c},s={...d,...l},a=(r,n)=>{if(!n.marks||0===n.marks.length)return r;let e=r;for(const t of n.marks){const r=s[t.type];r&&(e=r({mark:t,node:n,children:e}))}return e},p=(i,c)=>{if("text"===i.type)return a(i.text??"",i);const o=i.content?.map((r,n)=>{const c=p(r,i);return e(c)?t(c,{key:n}):c});if("doc"===i.type)/* @__PURE__ */
3
+ return r(n,{children:o});const d=h[i.type],l=d?d({node:i,parent:c,children:o}):/* @__PURE__ */r(n,{children:o});return a(l,i)};return p(i,void 0)}function h(r){return!(!r?.content||!Array.isArray(r.content))&&r.content.some(r=>"paragraph"!==r.type||Array.isArray(r.content)&&r.content.length>0)}export{h as hasTipTapRichTextContent,l as renderTipTapRichText};
@@ -1,23 +1,2 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import clsx from "clsx";
3
- import styles from "./VideoPreviewImage.module.scss.js";
4
- const VideoPreviewImage = ({
5
- onPlay,
6
- image,
7
- aspectRatio,
8
- sizes = "100vw",
9
- fill,
10
- playButtonAriaLabel = "Play video",
11
- icon = /* @__PURE__ */ jsx(PlayIcon, { playButtonAriaLabel }),
12
- className,
13
- renderImage
14
- }) => {
15
- return /* @__PURE__ */ jsxs("div", { className: clsx(styles.root, fill && styles.fill, className), children: [
16
- renderImage({ data: image, aspectRatio, sizes, fill }),
17
- /* @__PURE__ */ jsx("button", { className: styles.iconWrapper, onClick: onPlay, children: icon })
18
- ] });
19
- };
20
- const PlayIcon = ({ playButtonAriaLabel }) => /* @__PURE__ */ jsx("span", { className: styles.playIcon, "aria-label": playButtonAriaLabel });
21
- export {
22
- VideoPreviewImage
23
- };
1
+ import{jsxs as a,jsx as e}from"react/jsx-runtime";import l from"clsx";import i from"./VideoPreviewImage.module.scss.js";const o=({onPlay:o,image:r,aspectRatio:t,sizes:c="100vw",fill:m,playButtonAriaLabel:n="Play video",icon:p=/* @__PURE__ */e(s,{playButtonAriaLabel:n}),className:d,renderImage:f})=>/* @__PURE__ */a("div",{className:l(i.root,m&&i.fill,d),children:[f({data:r,aspectRatio:t,sizes:c,fill:m}),
2
+ /* @__PURE__ */e("button",{className:i.iconWrapper,onClick:o,children:p})]}),s=({playButtonAriaLabel:a})=>/* @__PURE__ */e("span",{className:i.playIcon,"aria-label":a});export{o as VideoPreviewImage};
@@ -1,17 +1 @@
1
- const root = "_root_1k5a5_1";
2
- const fill = "_fill_1k5a5_6";
3
- const iconWrapper = "_iconWrapper_1k5a5_10";
4
- const playIcon = "_playIcon_1k5a5_26";
5
- const styles = {
6
- root,
7
- fill,
8
- iconWrapper,
9
- playIcon
10
- };
11
- export {
12
- styles as default,
13
- fill,
14
- iconWrapper,
15
- playIcon,
16
- root
17
- };
1
+ const _="_root_1k5a5_1",a="_fill_1k5a5_6",o="_iconWrapper_1k5a5_10",l="_playIcon_1k5a5_26",p={root:_,fill:a,iconWrapper:o,playIcon:l};export{p as default,a as fill,o as iconWrapper,l as playIcon,_ as root};
@@ -1,22 +1,2 @@
1
1
  "use client";
2
- import { useEffect } from "react";
3
- const useIsElementInViewport = (ref, callback) => {
4
- useEffect(() => {
5
- if (!ref.current) {
6
- return;
7
- }
8
- const observer = new IntersectionObserver(
9
- ([entry]) => {
10
- callback(entry.isIntersecting);
11
- },
12
- { threshold: 0.5 }
13
- );
14
- observer.observe(ref.current);
15
- return () => {
16
- observer.disconnect();
17
- };
18
- }, [ref, callback]);
19
- };
20
- export {
21
- useIsElementInViewport
22
- };
2
+ import{useEffect as r}from"react";const e=(e,t)=>{r(()=>{if(!e.current)return;const r=new IntersectionObserver(([r])=>{t(r.isIntersecting)},{threshold:.5});return r.observe(e.current),()=>{r.disconnect()}},[e,t])};export{e as useIsElementInViewport};
@@ -1,19 +1,3 @@
1
1
  "use client";
2
- import { jsx } from "react/jsx-runtime";
3
- import { useContext, createContext } from "react";
4
- const CookieApiContext = createContext(void 0);
5
- const CookieApiProvider = ({ api: useCookieApi2, children }) => {
6
- const api = useCookieApi2();
7
- return /* @__PURE__ */ jsx(CookieApiContext.Provider, { value: api, children });
8
- };
9
- const useCookieApi = () => {
10
- const cookieApi = useContext(CookieApiContext);
11
- if (!cookieApi) {
12
- throw new Error("Can only be used inside CookieApiProvider.");
13
- }
14
- return cookieApi;
15
- };
16
- export {
17
- CookieApiProvider,
18
- useCookieApi
19
- };
2
+ import{jsx as r}from"react/jsx-runtime";import{useContext as e,createContext as o}from"react";const i=o(void 0),n=({api:e,children:o})=>{const n=e();/* @__PURE__ */
3
+ return r(i.Provider,{value:n,children:o})},t=()=>{const r=e(i);if(!r)throw new Error("Can only be used inside CookieApiProvider.");return r};export{n as CookieApiProvider,t as useCookieApi};
@@ -1,19 +1,3 @@
1
1
  "use client";
2
- import { jsx, Fragment } from "react/jsx-runtime";
3
- import { usePreview } from "../preview/usePreview.js";
4
- import { useCookieApi } from "./CookieApiContext.js";
5
- const CookieSafe = ({ consented, fallback, loading, children }) => {
6
- const { initialized } = useCookieApi();
7
- const { previewType } = usePreview();
8
- const isInPreview = previewType !== "NoPreview";
9
- if (initialized && consented || isInPreview) {
10
- return /* @__PURE__ */ jsx(Fragment, { children });
11
- }
12
- if (!initialized) {
13
- return /* @__PURE__ */ jsx(Fragment, { children: loading });
14
- }
15
- return /* @__PURE__ */ jsx(Fragment, { children: fallback });
16
- };
17
- export {
18
- CookieSafe
19
- };
2
+ import{jsx as e,Fragment as i}from"react/jsx-runtime";import{usePreview as r}from"../preview/usePreview.js";import{useCookieApi as o}from"./CookieApiContext.js";const n=({consented:n,fallback:t,loading:c,children:l})=>{const{initialized:p}=o(),{previewType:d}=r();/* @__PURE__ */
3
+ return e(i,p&&n||"NoPreview"!==d?{children:l}:p?{children:t}:{children:c})};export{n as CookieSafe};
@@ -1,34 +1,2 @@
1
1
  "use client";
2
- import { useState, useEffect } from "react";
3
- const isWindowWithCookiebot = (window2) => {
4
- return "Cookiebot" in window2;
5
- };
6
- const useCookieBotCookieApi = () => {
7
- const [consentedCookies, setConsentedCookies] = useState([]);
8
- const [initialized, setInitialized] = useState(false);
9
- useEffect(() => {
10
- const handleCookieUpdated = () => {
11
- if (isWindowWithCookiebot(window)) {
12
- setInitialized(true);
13
- const consentedList = window.Cookiebot.consent;
14
- setConsentedCookies(Object.keys(consentedList).filter((key) => consentedList[key]));
15
- }
16
- };
17
- window.addEventListener("CookiebotOnConsentReady", handleCookieUpdated);
18
- return () => {
19
- window.removeEventListener("CookiebotOnConsentReady", handleCookieUpdated);
20
- };
21
- }, []);
22
- return {
23
- initialized,
24
- consentedCookies,
25
- openCookieSettings: () => {
26
- if (isWindowWithCookiebot(window)) {
27
- window.Cookiebot.renew();
28
- }
29
- }
30
- };
31
- };
32
- export {
33
- useCookieBotCookieApi
34
- };
2
+ import{useState as o,useEffect as e}from"react";const n=o=>"Cookiebot"in o,t=()=>{const[t,i]=o([]),[r,s]=o(!1);return e(()=>{const o=()=>{if(n(window)){s(!0);const o=window.Cookiebot.consent;i(Object.keys(o).filter(e=>o[e]))}};return window.addEventListener("CookiebotOnConsentReady",o),()=>{window.removeEventListener("CookiebotOnConsentReady",o)}},[]),{initialized:r,consentedCookies:t,openCookieSettings:()=>{n(window)&&window.Cookiebot.renew()}}};export{t as useCookieBotCookieApi};
@@ -1,41 +1,2 @@
1
1
  "use client";
2
- import { useState, useCallback, useEffect } from "react";
3
- import { useLocalStorage } from "usehooks-ts";
4
- const localStorageCookieApiKey = "comet-dev-cookie-api-consented-cookies";
5
- const useLocalStorageCookieApi = () => {
6
- const [consentedCookies, setConsentedCookies] = useLocalStorage(localStorageCookieApiKey, []);
7
- const [initialized, setInitialized] = useState(false);
8
- const openCookieSettings = useCallback(() => {
9
- const cookies = prompt('Define consented cookies (separated by ","):', consentedCookies.join(",")) ?? "";
10
- const cookiesList = cookies.split(",").map((cookie) => cookie.trim());
11
- setConsentedCookies(cookiesList);
12
- logCookieUpdate(cookiesList);
13
- }, [consentedCookies, setConsentedCookies]);
14
- useEffect(() => {
15
- const storedCookies = window.localStorage.getItem(localStorageCookieApiKey);
16
- const cookiesList = JSON.parse(storedCookies ?? "[]");
17
- logCookieUpdate(cookiesList);
18
- const simulateLoadingTimeout = setTimeout(() => {
19
- setInitialized(true);
20
- window.cometLocalStorageCookieApi = {
21
- initialized: true,
22
- consentedCookies,
23
- openCookieSettings
24
- };
25
- }, 1e3);
26
- return () => {
27
- clearTimeout(simulateLoadingTimeout);
28
- };
29
- }, [consentedCookies, openCookieSettings]);
30
- return {
31
- initialized,
32
- consentedCookies,
33
- openCookieSettings
34
- };
35
- };
36
- const logCookieUpdate = (cookies) => {
37
- console.info("Consented cookies updated:", cookies);
38
- };
39
- export {
40
- useLocalStorageCookieApi
41
- };
2
+ import{useState as o,useCallback as e,useEffect as t}from"react";import{useLocalStorage as i}from"usehooks-ts";const n="comet-dev-cookie-api-consented-cookies",s=()=>{const[s,r]=i(n,[]),[a,p]=o(!1),d=e(()=>{const o=(prompt('Define consented cookies (separated by ","):',s.join(","))??"").split(",").map(o=>o.trim());r(o),c(o)},[s,r]);return t(()=>{const o=window.localStorage.getItem(n),e=JSON.parse(o??"[]");c(e);const t=setTimeout(()=>{p(!0),window.cometLocalStorageCookieApi={initialized:!0,consentedCookies:s,openCookieSettings:d}},1e3);return()=>{clearTimeout(t)}},[s,d]),{initialized:a,consentedCookies:s,openCookieSettings:d}},c=o=>{console.info("Consented cookies updated:",o)};export{s as useLocalStorageCookieApi};
@@ -1,46 +1,2 @@
1
1
  "use client";
2
- import { useState, useEffect } from "react";
3
- const isWindowWithOneTrust = (window2) => {
4
- return "OneTrust" in window2;
5
- };
6
- const useOneTrustCookieApi = () => {
7
- const [consentedCookies, setConsentedCookies] = useState([]);
8
- const [initialized, setInitialized] = useState(false);
9
- useEffect(() => {
10
- const startListeningForConsentChanges = (window2) => {
11
- const oneTrust = window2.OneTrust;
12
- const initialCookieConsent = [];
13
- if (window2.OnetrustActiveGroups) {
14
- initialCookieConsent.push(
15
- ...window2.OnetrustActiveGroups.split(",").map((groupId) => groupId.trim()).filter(Boolean)
16
- );
17
- }
18
- setConsentedCookies(initialCookieConsent);
19
- oneTrust.OnConsentChanged((event) => {
20
- setConsentedCookies(event.detail);
21
- });
22
- };
23
- const tryToAccessOneTrustInterval = setInterval(() => {
24
- if (isWindowWithOneTrust(window)) {
25
- setInitialized(true);
26
- clearInterval(tryToAccessOneTrustInterval);
27
- startListeningForConsentChanges(window);
28
- }
29
- }, 200);
30
- return () => {
31
- clearInterval(tryToAccessOneTrustInterval);
32
- };
33
- }, []);
34
- return {
35
- initialized,
36
- consentedCookies,
37
- openCookieSettings: () => {
38
- if (isWindowWithOneTrust(window)) {
39
- window.OneTrust.ToggleInfoDisplay();
40
- }
41
- }
42
- };
43
- };
44
- export {
45
- useOneTrustCookieApi
46
- };
2
+ import{useState as t,useEffect as e}from"react";const n=t=>"OneTrust"in t,o=()=>{const[o,r]=t([]),[i,s]=t(!1);return e(()=>{const t=setInterval(()=>{n(window)&&(s(!0),clearInterval(t),(t=>{const e=t.OneTrust,n=[];t.OnetrustActiveGroups&&n.push(...t.OnetrustActiveGroups.split(",").map(t=>t.trim()).filter(Boolean)),r(n),e.OnConsentChanged(t=>{r(t.detail)})})(window))},200);return()=>{clearInterval(t)}},[]),{initialized:i,consentedCookies:o,openCookieSettings:()=>{n(window)&&window.OneTrust.ToggleInfoDisplay()}}};export{o as useOneTrustCookieApi};
@@ -1,10 +1,2 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { ErrorHandlerBoundaryInternal } from "./ErrorHandlerBoundaryInternal.js";
3
- import { useErrorHandler } from "./ErrorHandlerProvider.js";
4
- function ErrorHandlerBoundary({ children }) {
5
- const { onError } = useErrorHandler();
6
- return /* @__PURE__ */ jsx(ErrorHandlerBoundaryInternal, { onError, children });
7
- }
8
- export {
9
- ErrorHandlerBoundary
10
- };
1
+ import{jsx as r}from"react/jsx-runtime";import{ErrorHandlerBoundaryInternal as o}from"./ErrorHandlerBoundaryInternal.js";import{useErrorHandler as n}from"./ErrorHandlerProvider.js";function e({children:e}){const{onError:t}=n();/* @__PURE__ */
2
+ return r(o,{onError:t,children:e})}export{e as ErrorHandlerBoundary};
@@ -1,27 +1,2 @@
1
1
  "use client";
2
- import { Component } from "react";
3
- class ErrorHandlerBoundaryInternal extends Component {
4
- constructor(props) {
5
- super(props);
6
- this.state = { hasError: false };
7
- }
8
- static getDerivedStateFromError() {
9
- return { hasError: true };
10
- }
11
- componentDidCatch(error, errorInfo) {
12
- console.error(error);
13
- if (this.props.onError) {
14
- this.props.onError(error, errorInfo);
15
- }
16
- }
17
- render() {
18
- var _a;
19
- if ((_a = this.state) == null ? void 0 : _a.hasError) {
20
- return null;
21
- }
22
- return this.props.children;
23
- }
24
- }
25
- export {
26
- ErrorHandlerBoundaryInternal
27
- };
2
+ import{Component as r}from"react";class t extends r{constructor(r){super(r),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(r,t){console.error(r),this.props.onError&&this.props.onError(r,t)}render(){return this.state?.hasError?null:this.props.children}}export{t as ErrorHandlerBoundaryInternal};