index.js 1000 B

12345678910111213141516171819202122232425262728
  1. import { registerBlockType } from '@wordpress/blocks';
  2. import metadata from './block.json';
  3. import { useBlockProps, RichText } from '@wordpress/block-editor';
  4. import ServerSideRender from '@wordpress/server-side-render';
  5. registerBlockType(metadata.name, {
  6. edit: () => {
  7. return (
  8. <div { ...useBlockProps() }>
  9. <ServerSideRender
  10. block="tsu-plugins/newsletter"
  11. // attributes={ attributes }
  12. urlQueryArgs={ {
  13. // Let the render callback knows that this is an editor preview.
  14. preview: 1,
  15. // In the preview mode, get_the_ID() does not work (it returns a
  16. // `false`), hence let's send the post ID.
  17. // post_id: context.postId,
  18. } }
  19. />
  20. </div>
  21. );
  22. },
  23. save: () => {
  24. return ("Tutaj renderujemy blok newsletter.");
  25. }
  26. });