[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-content/themes/twentytwentyone/assets/js/ -> editor.js (source)

   1  /* global setTimeout */
   2  wp.domReady( function() {
   3      // Unregister "Wide" Separator Style.
   4      wp.blocks.unregisterBlockStyle( 'core/separator', 'wide' );
   5  
   6      // Add to ".block-editor__typewriter" the "is-dark-theme" class if needed.
   7  	function twentytwentyoneCopyDarkThemeClass() {
   8          var editor,
   9              attemptDelay = 25,
  10              attempt = 0,
  11              maxAttempts = 10;
  12  
  13          if ( ! document.body.classList.contains( 'is-dark-theme' ) ) {
  14              return;
  15          }
  16  
  17          editor = document.querySelector( '.block-editor__typewriter' );
  18          if ( null === editor ) {
  19              // Try again.
  20              if ( attempt < maxAttempts ) {
  21                  setTimeout( function() {
  22                      twentytwentyoneCopyDarkThemeClass();
  23                  }, attemptDelay );
  24  
  25                  // Increment the attempts counter.
  26                  attempt++;
  27  
  28                  // Double the delay, give the server some time to breathe.
  29                  attemptDelay *= 2;
  30              }
  31              return;
  32          }
  33  
  34          editor.classList.add( 'is-dark-theme' );
  35      }
  36  
  37      twentytwentyoneCopyDarkThemeClass();
  38  } );


Generated : Sun Nov 24 08:20:01 2024 Cross-referenced by PHPXref