Aucune description

editor.js 921B

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