| 1 |
import { __ } from "@wordpress/i18n"; |
| 2 |
|
| 3 |
const DynamicShortcodeInput = ({ attributes: { shortcode }, shortCodeList, shortcodeUpdate }) => { |
| 4 |
return ( |
| 5 |
<div className="spsp-gutenberg-shortcode editor-styles-wrapper"> |
| 6 |
<select className="spsp-shortcode-selector" onChange={(e) => shortcodeUpdate(e)} value={shortcode}> |
| 7 |
<option value="0">{__("-- Select a Show --", "post-carousel")}</option> |
| 8 |
{shortCodeList.map((shortcodeItem) => { |
| 9 |
const title = |
| 10 |
shortcodeItem.title.length > 35 |
| 11 |
? `${shortcodeItem.title.substring(0, 30)}.... #(${shortcodeItem.id})` |
| 12 |
: `${shortcodeItem.title} #(${shortcodeItem.id})`; |
| 13 |
|
| 14 |
return ( |
| 15 |
<option key={shortcodeItem.id.toString()} value={shortcodeItem.id.toString()}> |
| 16 |
{title} |
| 17 |
</option> |
| 18 |
); |
| 19 |
})} |
| 20 |
</select> |
| 21 |
</div> |
| 22 |
); |
| 23 |
}; |
| 24 |
|
| 25 |
export default DynamicShortcodeInput; |
| 26 |
|