PluginProbe
CodePen Embed Block / trunk
CodePen Embed Block vtrunk
codepen-embed-block / src / save.js

save.js in CodePen Embed Block trunk, at src/save.js

37 lines 934 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * WordPress dependencies
3 */
4 import { useBlockProps } from "@wordpress/block-editor";
5 import { __ } from "@wordpress/i18n";
6
7 /**
8 * Internal dependencies
9 */
10 import getPenHTML from "./utils/getPenHTML";
11
12 /**
13 * The save function defines the way in which the different attributes should
14 * be combined into the final markup, which is then serialized by the block
15 * editor into `post_content`.
16 *
17 * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-edit-save/#save
18 *
19 * @return {WPElement} Element to render.
20 */
21 export default function save({ attributes }) {
22 const { penID, penURL } = attributes;
23
24 if (!penID || penID === "" || penID === null) {
25 return (
26 <p
27 className="wp-block-cp-codepen-gutenberg-embed-block codepen error"
28 style={{ textAlign: "center" }}
29 >
30 {__("The pen URL is invalid.")}
31 </p>
32 );
33 }
34
35 return getPenHTML(attributes);
36 }
37