Written by Anonymous

  1. /**
  2. * Cocoon Blocks
  3. * @author: yhira
  4. * @link: https://wp-cocoon.com/
  5. * @license: http://www.gnu.org/licenses/gpl-2.0.html GPL v2 or later
  6. */
  7.  
  8. const { __ } = wp.i18n;
  9. const { registerBlockType } = wp.blocks;
  10. const { InnerBlocks/*, RichText, InspectorControls*/ } = wp.editor;
  11. // const { PanelBody, SelectControl, BaseControl } = wp.components;
  12. const { Fragment } = wp.element;
  13. const THEME_NAME = 'cocoon';
  14. //const DEFAULT_MSG = __( 'キーワード', THEME_NAME );
  15. const BLOCK_CLASS = ' layout-box';
  16.  
  17. registerBlockType( 'cocoon-blocks/column-2-1-1', {
  18.  
  19. title: __( '2カラム(1:1)', THEME_NAME ),
  20. icon: 'grid-view',
  21. category: THEME_NAME + '-layout',
  22.  
  23. attributes: {
  24. content: {
  25. type: 'string',
  26. //default: DEFAULT_MSG,
  27. },
  28. },
  29.  
  30. edit( { attributes, setAttributes } ) {
  31. return (
  32. <Fragment>
  33. <div className={"column-wrap column-2" + BLOCK_CLASS}>
  34. <div className="column-left">
  35. <InnerBlocks />
  36. </div>
  37. <div className="column-right">
  38. <InnerBlocks />
  39. </div>
  40. </div>
  41. </Fragment>
  42. );
  43. },
  44.  
  45. save( { attributes } ) {
  46. return (
  47. <div className={"column-wrap column-2" + BLOCK_CLASS}>
  48. <div className="column-left">
  49. <InnerBlocks.Content />
  50. </div>
  51. <div className="column-right">
  52. <InnerBlocks.Content />
  53. </div>
  54. </div>
  55. );
  56. }
  57. } );
Notepad
Select All