MCPcopy Create free account
hub / github.com/block/buzz / isBlockMedia

Function isBlockMedia

desktop/src/shared/ui/markdownUtils.ts:10–25  ·  view source on GitHub ↗

* Returns true when a React element is a block-level media wrapper (image or * video). The `img` component in `createMarkdownComponents` marks its output * with a `data-block-media` prop so we can reliably distinguish media from * other custom components (links, mentions, etc.) that also have non

(child: React.ReactNode)

Source from the content-addressed store, hash-verified

8 * types in react-markdown v10.
9 */
10function isBlockMedia(child: React.ReactNode): boolean {
11 if (!React.isValidElement(child)) return false;
12
13 const props = child.props as {
14 children?: React.ReactNode;
15 node?: { tagName?: unknown };
16 [key: string]: unknown;
17 };
18 const node = props?.node as { tagName?: unknown } | undefined;
19
20 if (props?.["data-block-media"] != null || node?.tagName === "img") {
21 return true;
22 }
23
24 return React.Children.toArray(props.children).some(isBlockMedia);
25}
26
27/**
28 * Classifies an array of React children into media vs non-media buckets.

Callers 1

classifyChildrenFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected