import React, { useEffect, useRef } from 'react' import styled from '../../styled-components' export const Block = styled.div` position: relative; white-space: normal; /* styles for image link */ img.img-responsive { margin: 0 auto; max-width: 100%; height: auto; display: block; } ` export const Caption = styled.div` font-size: 14px; line-height: 1.43; letter-spacing: 0.4px; color: #808080; padding: 15px 15px 0 15px; ` type EmbeddedCodeBlockProps = { className?: string data: { caption?: string embeddedCode: string } } export const EmbeddedCodeBlock = ({ className, data, }: EmbeddedCodeBlockProps) => { const { caption, embeddedCode } = data const embedded = useRef(null) useEffect(() => { if (!embedded.current) return const node: HTMLElement = embedded.current const fragment = document.createDocumentFragment() // `embeddedCode` is a string, which may includes // multiple '