| 1 |
import { __ } from "@wordpress/i18n"; |
| 2 |
import { useBlockProps } from "@wordpress/block-editor"; |
| 3 |
import DynamicShortcodeInput from "./dynamicShortcode"; |
| 4 |
import { ShortCodeBlockIcon } from "./blockIcon"; |
| 5 |
import "./editor.scss"; |
| 6 |
|
| 7 |
const Edit = ({ attributes, setAttributes }) => { |
| 8 |
const shortCodeList = smartPostShowGbScript.shortCodeList; |
| 9 |
|
| 10 |
const blockProps = useBlockProps(); |
| 11 |
|
| 12 |
|
| 13 |
const updateShortcode = (e) => { |
| 14 |
setAttributes({ shortcode: e.target.value }); |
| 15 |
}; |
| 16 |
|
| 17 |
const shortcodeUpdate = (e) => { |
| 18 |
updateShortcode(e); |
| 19 |
}; |
| 20 |
|
| 21 |
|
| 22 |
if (shortCodeList.length === 0) { |
| 23 |
return ( |
| 24 |
<div {...blockProps}> |
| 25 |
<div className="spsp_block_shortcode components-placeholder"> |
| 26 |
<div className="components-placeholder__label"> |
| 27 |
<ShortCodeBlockIcon /> |
| 28 |
{__("Smart Post", "post-carousel")} |
| 29 |
</div> |
| 30 |
<p className="spsp_block_shortcode_text"> |
| 31 |
{__("No shortcode found.", "post-carousel")} |
| 32 |
<a href={smartPostShowGbScript.link}>{__("Create a shortcode now!", "post-carousel")}</a> |
| 33 |
</p> |
| 34 |
</div> |
| 35 |
</div> |
| 36 |
); |
| 37 |
} |
| 38 |
|
| 39 |
return ( |
| 40 |
<div {...blockProps}> |
| 41 |
<div className="components-placeholder is-large"> |
| 42 |
<div className="components-placeholder__label"> |
| 43 |
<ShortCodeBlockIcon /> |
| 44 |
{__("Smart Post", "post-carousel")} |
| 45 |
</div> |
| 46 |
<div className="components-placeholder__instructions"> |
| 47 |
{__("Select a Show", "post-carousel")} |
| 48 |
</div> |
| 49 |
<DynamicShortcodeInput |
| 50 |
attributes={attributes} |
| 51 |
shortCodeList={shortCodeList} |
| 52 |
shortcodeUpdate={shortcodeUpdate} |
| 53 |
/> |
| 54 |
</div> |
| 55 |
</div> |
| 56 |
); |
| 57 |
}; |
| 58 |
|
| 59 |
export default Edit; |
| 60 |
|