Skip to content

Commit

Permalink
Fix hasRichTextBlockContent for blocks with no content blocks (#3282)
Browse files Browse the repository at this point in the history
Co-authored-by: Johannes Obermair <[email protected]>
  • Loading branch information
SebiVPS and johnnyomair authored Feb 3, 2025
1 parent 0233d48 commit 6ff1d70
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .changeset/clever-cougars-glow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@comet/cms-site": patch
---

Fix `hasRichTextBlockContent` for blocks with no content blocks
12 changes: 0 additions & 12 deletions packages/site/cms-site/src/blocks/RichTextBlock.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { RawDraftContentState } from "draft-js";

import { RichTextBlockData } from "../../blocks.generated";

export const hasRichTextBlockContent = (data: RichTextBlockData) => {
const draftContent = data.draftContent as RawDraftContentState;
return !(draftContent.blocks.length === 0 || (draftContent.blocks.length === 1 && draftContent.blocks[0].text === ""));
};
2 changes: 1 addition & 1 deletion packages/site/cms-site/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ export { OneOfBlock } from "./blocks/factories/OneOfBlock";
export { OptionalBlock } from "./blocks/factories/OptionalBlock";
export { SeoBlock } from "./blocks/factories/SeoBlock";
export type { SupportedBlocks } from "./blocks/factories/types";
export { hasRichTextBlockContent } from "./blocks/helpers/RichTextBlockHelper";
export type { VideoPreviewImageProps } from "./blocks/helpers/VideoPreviewImage";
export { InternalLinkBlock } from "./blocks/InternalLinkBlock";
export { PhoneLinkBlock } from "./blocks/PhoneLinkBlock";
export { PixelImageBlock } from "./blocks/PixelImageBlock";
export type { PropsWithData } from "./blocks/PropsWithData";
export { hasRichTextBlockContent } from "./blocks/RichTextBlock";
export { SvgImageBlock } from "./blocks/SvgImageBlock";
export { VimeoVideoBlock } from "./blocks/VimeoVideoBlock";
export { YouTubeVideoBlock } from "./blocks/YouTubeVideoBlock";
Expand Down

0 comments on commit 6ff1d70

Please sign in to comment.