/** * WordPress dependencies */ import { __ } from "@wordpress/i18n"; /** * Internal dependencies */ import getNewEditorCheck from "./getNewEditorCheck"; export default function getPenHTML(attributes) { const { penID, penTheme, penHeight, penURL, penType, clickToLoad, editable, isEditorURL, } = attributes; if (penID === null && penURL === "") { return null; } if (null === penID) { return (
{__("The pen URL is invalid.")}
); } let embedUrlPrefix = "//codepen.io/anon/embed"; if (isEditorURL || getNewEditorCheck(penURL)) { embedUrlPrefix = "//codepen.io/editor/anon/embed"; } if (clickToLoad) { embedUrlPrefix += "/preview"; } let src = `${embedUrlPrefix}/${penID}?height=${penHeight}&theme-id=${penTheme}&slug-hash=${penID}&default-tab=${penType}`; if (editable) { src += "&editable=true"; } return (