MCPcopy Create free account
hub / github.com/wavetermdev/waveterm / MarkdownSource

Function MarkdownSource

frontend/app/element/markdown.tsx:184–212  ·  view source on GitHub ↗
({
    props,
    resolveOpts,
}: {
    props: React.HTMLAttributes<HTMLSourceElement> & {
        srcSet?: string;
        media?: string;
    };
    resolveOpts: MarkdownResolveOpts;
})

Source from the content-addressed store, hash-verified

182};
183
184const MarkdownSource = ({
185 props,
186 resolveOpts,
187}: {
188 props: React.HTMLAttributes<HTMLSourceElement> & {
189 srcSet?: string;
190 media?: string;
191 };
192 resolveOpts: MarkdownResolveOpts;
193}) => {
194 const [resolvedSrcSet, setResolvedSrcSet] = useState<string>(props.srcSet);
195 const [resolving, setResolving] = useState<boolean>(true);
196
197 useEffect(() => {
198 const resolvePath = async () => {
199 const resolved = await resolveSrcSet(props.srcSet, resolveOpts);
200 setResolvedSrcSet(resolved);
201 setResolving(false);
202 };
203
204 resolvePath();
205 }, [props.srcSet]);
206
207 if (resolving) {
208 return null;
209 }
210
211 return <source srcSet={resolvedSrcSet} media={props.media} />;
212};
213
214interface WaveBlockProps {
215 blockkey: string;

Callers

nothing calls this directly

Calls 1

resolvePathFunction · 0.85

Tested by

no test coverage detected