Advertisement
Guest User

Gutenberg modal

a guest
Dec 3rd, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ( function( wp ) {
  2.     var el = wp.element.createElement;
  3.     var withState = wp.compose.withState;
  4.  
  5.     const MyModal = withState( {
  6.         isOpen: false
  7.     } )( ( {
  8.     isOpen,
  9.         setState
  10.     } ) => el( "div", null, el( wp.components.Button, {
  11.             isDefault: true,
  12.             onClick: () => setState( {
  13.                     isOpen: true
  14.                 } )
  15.         }, "Open Modal" ), isOpen ? el( wp.components.Modal, {
  16.             title: "Go https://otshelnik-fm.ru/",
  17.  
  18.             onRequestClose: () => setState( {
  19.                     isOpen: false
  20.                 } )
  21.         },
  22.             el( wp.components.Button, {
  23.                 isDefault: true,
  24.                 onClick: () => setState( {
  25.                         isOpen: false
  26.                     } )
  27.             }, "My custom close button" ) ) : null ) );
  28.     wp.richText.registerFormatType(
  29.         'my-custom-format/sample-output', {
  30.             title: 'Sample output',
  31.             tagName: 'samp',
  32.             className: null,
  33.             edit: MyModal
  34.         }
  35.     );
  36. } )( window.wp );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement