| 1 |
/** |
| 2 |
* JavaScript code for the TablePress table block in the block editor. |
| 3 |
* |
| 4 |
* @package TablePress |
| 5 |
* @subpackage Blocks |
| 6 |
* @author Tobias Bäthge |
| 7 |
* @since 2.0.0 |
| 8 |
*/ |
| 9 |
|
| 10 |
/** |
| 11 |
* WordPress dependencies |
| 12 |
*/ |
| 13 |
import { RawHTML } from '@wordpress/element'; |
| 14 |
|
| 15 |
/** |
| 16 |
* The save function defines the way in which the different attributes should |
| 17 |
* be combined into the final markup, which is then serialized by the block |
| 18 |
* editor into `post_content`. |
| 19 |
* |
| 20 |
* @param {Object} params Function parameters. |
| 21 |
* @param {Object} params.attributes Block attributes. |
| 22 |
* @param {string} params.attributes.id Table ID. |
| 23 |
* @param {string} params.attributes.parameters Table render attributes. |
| 24 |
* @return {Element} Element to render. |
| 25 |
*/ |
| 26 |
const save = ( { attributes: { id = '', parameters = '' } } ) => { |
| 27 |
if ( '' === id ) { |
| 28 |
return ''; |
| 29 |
} |
| 30 |
|
| 31 |
parameters = parameters.trim(); |
| 32 |
if ( '' !== parameters ) { |
| 33 |
parameters += ' '; |
| 34 |
} |
| 35 |
return <RawHTML>{ `[${ tp.table.shortcode } id=${ id } ${ parameters }/]` }</RawHTML>; |
| 36 |
}; |
| 37 |
|
| 38 |
export default save; |
| 39 |
|