[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/js/dist/ -> keyboard-shortcuts.js (source)

   1  /******/ (function() { // webpackBootstrap
   2  /******/     "use strict";
   3  /******/     // The require scope
   4  /******/     var __webpack_require__ = {};
   5  /******/     
   6  /************************************************************************/
   7  /******/     /* webpack/runtime/define property getters */
   8  /******/     !function() {
   9  /******/         // define getter functions for harmony exports
  10  /******/         __webpack_require__.d = function(exports, definition) {
  11  /******/             for(var key in definition) {
  12  /******/                 if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  13  /******/                     Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  14  /******/                 }
  15  /******/             }
  16  /******/         };
  17  /******/     }();
  18  /******/     
  19  /******/     /* webpack/runtime/hasOwnProperty shorthand */
  20  /******/     !function() {
  21  /******/         __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
  22  /******/     }();
  23  /******/     
  24  /******/     /* webpack/runtime/make namespace object */
  25  /******/     !function() {
  26  /******/         // define __esModule on exports
  27  /******/         __webpack_require__.r = function(exports) {
  28  /******/             if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  29  /******/                 Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  30  /******/             }
  31  /******/             Object.defineProperty(exports, '__esModule', { value: true });
  32  /******/         };
  33  /******/     }();
  34  /******/     
  35  /************************************************************************/
  36  var __webpack_exports__ = {};
  37  // ESM COMPAT FLAG
  38  __webpack_require__.r(__webpack_exports__);
  39  
  40  // EXPORTS
  41  __webpack_require__.d(__webpack_exports__, {
  42    "ShortcutProvider": function() { return /* reexport */ ShortcutProvider; },
  43    "__unstableUseShortcutEventMatch": function() { return /* reexport */ useShortcutEventMatch; },
  44    "store": function() { return /* reexport */ store; },
  45    "useShortcut": function() { return /* reexport */ useShortcut; }
  46  });
  47  
  48  // NAMESPACE OBJECT: ./node_modules/@wordpress/keyboard-shortcuts/build-module/store/actions.js
  49  var actions_namespaceObject = {};
  50  __webpack_require__.r(actions_namespaceObject);
  51  __webpack_require__.d(actions_namespaceObject, {
  52    "registerShortcut": function() { return registerShortcut; },
  53    "unregisterShortcut": function() { return unregisterShortcut; }
  54  });
  55  
  56  // NAMESPACE OBJECT: ./node_modules/@wordpress/keyboard-shortcuts/build-module/store/selectors.js
  57  var selectors_namespaceObject = {};
  58  __webpack_require__.r(selectors_namespaceObject);
  59  __webpack_require__.d(selectors_namespaceObject, {
  60    "getAllShortcutKeyCombinations": function() { return getAllShortcutKeyCombinations; },
  61    "getAllShortcutRawKeyCombinations": function() { return getAllShortcutRawKeyCombinations; },
  62    "getCategoryShortcuts": function() { return getCategoryShortcuts; },
  63    "getShortcutAliases": function() { return getShortcutAliases; },
  64    "getShortcutDescription": function() { return getShortcutDescription; },
  65    "getShortcutKeyCombination": function() { return getShortcutKeyCombination; },
  66    "getShortcutRepresentation": function() { return getShortcutRepresentation; }
  67  });
  68  
  69  ;// CONCATENATED MODULE: external ["wp","data"]
  70  var external_wp_data_namespaceObject = window["wp"]["data"];
  71  ;// CONCATENATED MODULE: external "lodash"
  72  var external_lodash_namespaceObject = window["lodash"];
  73  ;// CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/store/reducer.js
  74  /**
  75   * External dependencies
  76   */
  77  
  78  /**
  79   * Reducer returning the registered shortcuts
  80   *
  81   * @param {Object} state  Current state.
  82   * @param {Object} action Dispatched action.
  83   *
  84   * @return {Object} Updated state.
  85   */
  86  
  87  function reducer() {
  88    let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  89    let action = arguments.length > 1 ? arguments[1] : undefined;
  90  
  91    switch (action.type) {
  92      case 'REGISTER_SHORTCUT':
  93        return { ...state,
  94          [action.name]: {
  95            category: action.category,
  96            keyCombination: action.keyCombination,
  97            aliases: action.aliases,
  98            description: action.description
  99          }
 100        };
 101  
 102      case 'UNREGISTER_SHORTCUT':
 103        return (0,external_lodash_namespaceObject.omit)(state, action.name);
 104    }
 105  
 106    return state;
 107  }
 108  
 109  /* harmony default export */ var store_reducer = (reducer);
 110  
 111  ;// CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/store/actions.js
 112  /** @typedef {import('@wordpress/keycodes').WPKeycodeModifier} WPKeycodeModifier */
 113  
 114  /**
 115   * Keyboard key combination.
 116   *
 117   * @typedef {Object} WPShortcutKeyCombination
 118   *
 119   * @property {string}                      character Character.
 120   * @property {WPKeycodeModifier|undefined} modifier  Modifier.
 121   */
 122  
 123  /**
 124   * Configuration of a registered keyboard shortcut.
 125   *
 126   * @typedef {Object} WPShortcutConfig
 127   *
 128   * @property {string}                     name           Shortcut name.
 129   * @property {string}                     category       Shortcut category.
 130   * @property {string}                     description    Shortcut description.
 131   * @property {WPShortcutKeyCombination}   keyCombination Shortcut key combination.
 132   * @property {WPShortcutKeyCombination[]} [aliases]      Shortcut aliases.
 133   */
 134  
 135  /**
 136   * Returns an action object used to register a new keyboard shortcut.
 137   *
 138   * @param {WPShortcutConfig} config Shortcut config.
 139   *
 140   * @return {Object} action.
 141   */
 142  function registerShortcut(_ref) {
 143    let {
 144      name,
 145      category,
 146      description,
 147      keyCombination,
 148      aliases
 149    } = _ref;
 150    return {
 151      type: 'REGISTER_SHORTCUT',
 152      name,
 153      category,
 154      keyCombination,
 155      aliases,
 156      description
 157    };
 158  }
 159  /**
 160   * Returns an action object used to unregister a keyboard shortcut.
 161   *
 162   * @param {string} name Shortcut name.
 163   *
 164   * @return {Object} action.
 165   */
 166  
 167  function unregisterShortcut(name) {
 168    return {
 169      type: 'UNREGISTER_SHORTCUT',
 170      name
 171    };
 172  }
 173  
 174  ;// CONCATENATED MODULE: ./node_modules/rememo/es/rememo.js
 175  
 176  
 177  var LEAF_KEY, hasWeakMap;
 178  
 179  /**
 180   * Arbitrary value used as key for referencing cache object in WeakMap tree.
 181   *
 182   * @type {Object}
 183   */
 184  LEAF_KEY = {};
 185  
 186  /**
 187   * Whether environment supports WeakMap.
 188   *
 189   * @type {boolean}
 190   */
 191  hasWeakMap = typeof WeakMap !== 'undefined';
 192  
 193  /**
 194   * Returns the first argument as the sole entry in an array.
 195   *
 196   * @param {*} value Value to return.
 197   *
 198   * @return {Array} Value returned as entry in array.
 199   */
 200  function arrayOf( value ) {
 201      return [ value ];
 202  }
 203  
 204  /**
 205   * Returns true if the value passed is object-like, or false otherwise. A value
 206   * is object-like if it can support property assignment, e.g. object or array.
 207   *
 208   * @param {*} value Value to test.
 209   *
 210   * @return {boolean} Whether value is object-like.
 211   */
 212  function isObjectLike( value ) {
 213      return !! value && 'object' === typeof value;
 214  }
 215  
 216  /**
 217   * Creates and returns a new cache object.
 218   *
 219   * @return {Object} Cache object.
 220   */
 221  function createCache() {
 222      var cache = {
 223          clear: function() {
 224              cache.head = null;
 225          },
 226      };
 227  
 228      return cache;
 229  }
 230  
 231  /**
 232   * Returns true if entries within the two arrays are strictly equal by
 233   * reference from a starting index.
 234   *
 235   * @param {Array}  a         First array.
 236   * @param {Array}  b         Second array.
 237   * @param {number} fromIndex Index from which to start comparison.
 238   *
 239   * @return {boolean} Whether arrays are shallowly equal.
 240   */
 241  function isShallowEqual( a, b, fromIndex ) {
 242      var i;
 243  
 244      if ( a.length !== b.length ) {
 245          return false;
 246      }
 247  
 248      for ( i = fromIndex; i < a.length; i++ ) {
 249          if ( a[ i ] !== b[ i ] ) {
 250              return false;
 251          }
 252      }
 253  
 254      return true;
 255  }
 256  
 257  /**
 258   * Returns a memoized selector function. The getDependants function argument is
 259   * called before the memoized selector and is expected to return an immutable
 260   * reference or array of references on which the selector depends for computing
 261   * its own return value. The memoize cache is preserved only as long as those
 262   * dependant references remain the same. If getDependants returns a different
 263   * reference(s), the cache is cleared and the selector value regenerated.
 264   *
 265   * @param {Function} selector      Selector function.
 266   * @param {Function} getDependants Dependant getter returning an immutable
 267   *                                 reference or array of reference used in
 268   *                                 cache bust consideration.
 269   *
 270   * @return {Function} Memoized selector.
 271   */
 272  /* harmony default export */ function rememo(selector, getDependants ) {
 273      var rootCache, getCache;
 274  
 275      // Use object source as dependant if getter not provided
 276      if ( ! getDependants ) {
 277          getDependants = arrayOf;
 278      }
 279  
 280      /**
 281       * Returns the root cache. If WeakMap is supported, this is assigned to the
 282       * root WeakMap cache set, otherwise it is a shared instance of the default
 283       * cache object.
 284       *
 285       * @return {(WeakMap|Object)} Root cache object.
 286       */
 287  	function getRootCache() {
 288          return rootCache;
 289      }
 290  
 291      /**
 292       * Returns the cache for a given dependants array. When possible, a WeakMap
 293       * will be used to create a unique cache for each set of dependants. This
 294       * is feasible due to the nature of WeakMap in allowing garbage collection
 295       * to occur on entries where the key object is no longer referenced. Since
 296       * WeakMap requires the key to be an object, this is only possible when the
 297       * dependant is object-like. The root cache is created as a hierarchy where
 298       * each top-level key is the first entry in a dependants set, the value a
 299       * WeakMap where each key is the next dependant, and so on. This continues
 300       * so long as the dependants are object-like. If no dependants are object-
 301       * like, then the cache is shared across all invocations.
 302       *
 303       * @see isObjectLike
 304       *
 305       * @param {Array} dependants Selector dependants.
 306       *
 307       * @return {Object} Cache object.
 308       */
 309  	function getWeakMapCache( dependants ) {
 310          var caches = rootCache,
 311              isUniqueByDependants = true,
 312              i, dependant, map, cache;
 313  
 314          for ( i = 0; i < dependants.length; i++ ) {
 315              dependant = dependants[ i ];
 316  
 317              // Can only compose WeakMap from object-like key.
 318              if ( ! isObjectLike( dependant ) ) {
 319                  isUniqueByDependants = false;
 320                  break;
 321              }
 322  
 323              // Does current segment of cache already have a WeakMap?
 324              if ( caches.has( dependant ) ) {
 325                  // Traverse into nested WeakMap.
 326                  caches = caches.get( dependant );
 327              } else {
 328                  // Create, set, and traverse into a new one.
 329                  map = new WeakMap();
 330                  caches.set( dependant, map );
 331                  caches = map;
 332              }
 333          }
 334  
 335          // We use an arbitrary (but consistent) object as key for the last item
 336          // in the WeakMap to serve as our running cache.
 337          if ( ! caches.has( LEAF_KEY ) ) {
 338              cache = createCache();
 339              cache.isUniqueByDependants = isUniqueByDependants;
 340              caches.set( LEAF_KEY, cache );
 341          }
 342  
 343          return caches.get( LEAF_KEY );
 344      }
 345  
 346      // Assign cache handler by availability of WeakMap
 347      getCache = hasWeakMap ? getWeakMapCache : getRootCache;
 348  
 349      /**
 350       * Resets root memoization cache.
 351       */
 352  	function clear() {
 353          rootCache = hasWeakMap ? new WeakMap() : createCache();
 354      }
 355  
 356      // eslint-disable-next-line jsdoc/check-param-names
 357      /**
 358       * The augmented selector call, considering first whether dependants have
 359       * changed before passing it to underlying memoize function.
 360       *
 361       * @param {Object} source    Source object for derivation.
 362       * @param {...*}   extraArgs Additional arguments to pass to selector.
 363       *
 364       * @return {*} Selector result.
 365       */
 366  	function callSelector( /* source, ...extraArgs */ ) {
 367          var len = arguments.length,
 368              cache, node, i, args, dependants;
 369  
 370          // Create copy of arguments (avoid leaking deoptimization).
 371          args = new Array( len );
 372          for ( i = 0; i < len; i++ ) {
 373              args[ i ] = arguments[ i ];
 374          }
 375  
 376          dependants = getDependants.apply( null, args );
 377          cache = getCache( dependants );
 378  
 379          // If not guaranteed uniqueness by dependants (primitive type or lack
 380          // of WeakMap support), shallow compare against last dependants and, if
 381          // references have changed, destroy cache to recalculate result.
 382          if ( ! cache.isUniqueByDependants ) {
 383              if ( cache.lastDependants && ! isShallowEqual( dependants, cache.lastDependants, 0 ) ) {
 384                  cache.clear();
 385              }
 386  
 387              cache.lastDependants = dependants;
 388          }
 389  
 390          node = cache.head;
 391          while ( node ) {
 392              // Check whether node arguments match arguments
 393              if ( ! isShallowEqual( node.args, args, 1 ) ) {
 394                  node = node.next;
 395                  continue;
 396              }
 397  
 398              // At this point we can assume we've found a match
 399  
 400              // Surface matched node to head if not already
 401              if ( node !== cache.head ) {
 402                  // Adjust siblings to point to each other.
 403                  node.prev.next = node.next;
 404                  if ( node.next ) {
 405                      node.next.prev = node.prev;
 406                  }
 407  
 408                  node.next = cache.head;
 409                  node.prev = null;
 410                  cache.head.prev = node;
 411                  cache.head = node;
 412              }
 413  
 414              // Return immediately
 415              return node.val;
 416          }
 417  
 418          // No cached value found. Continue to insertion phase:
 419  
 420          node = {
 421              // Generate the result from original function
 422              val: selector.apply( null, args ),
 423          };
 424  
 425          // Avoid including the source object in the cache.
 426          args[ 0 ] = null;
 427          node.args = args;
 428  
 429          // Don't need to check whether node is already head, since it would
 430          // have been returned above already if it was
 431  
 432          // Shift existing head down list
 433          if ( cache.head ) {
 434              cache.head.prev = node;
 435              node.next = cache.head;
 436          }
 437  
 438          cache.head = node;
 439  
 440          return node.val;
 441      }
 442  
 443      callSelector.getDependants = getDependants;
 444      callSelector.clear = clear;
 445      clear();
 446  
 447      return callSelector;
 448  }
 449  
 450  ;// CONCATENATED MODULE: external ["wp","keycodes"]
 451  var external_wp_keycodes_namespaceObject = window["wp"]["keycodes"];
 452  ;// CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/store/selectors.js
 453  /**
 454   * External dependencies
 455   */
 456  
 457  
 458  /**
 459   * WordPress dependencies
 460   */
 461  
 462  
 463  /** @typedef {import('./actions').WPShortcutKeyCombination} WPShortcutKeyCombination */
 464  
 465  /** @typedef {import('@wordpress/keycodes').WPKeycodeHandlerByModifier} WPKeycodeHandlerByModifier */
 466  
 467  /**
 468   * Shared reference to an empty array for cases where it is important to avoid
 469   * returning a new array reference on every invocation.
 470   *
 471   * @type {Array<any>}
 472   */
 473  
 474  const EMPTY_ARRAY = [];
 475  /**
 476   * Shortcut formatting methods.
 477   *
 478   * @property {WPKeycodeHandlerByModifier} display     Display formatting.
 479   * @property {WPKeycodeHandlerByModifier} rawShortcut Raw shortcut formatting.
 480   * @property {WPKeycodeHandlerByModifier} ariaLabel   ARIA label formatting.
 481   */
 482  
 483  const FORMATTING_METHODS = {
 484    display: external_wp_keycodes_namespaceObject.displayShortcut,
 485    raw: external_wp_keycodes_namespaceObject.rawShortcut,
 486    ariaLabel: external_wp_keycodes_namespaceObject.shortcutAriaLabel
 487  };
 488  /**
 489   * Returns a string representing the key combination.
 490   *
 491   * @param {?WPShortcutKeyCombination} shortcut       Key combination.
 492   * @param {keyof FORMATTING_METHODS}  representation Type of representation
 493   *                                                   (display, raw, ariaLabel).
 494   *
 495   * @return {string?} Shortcut representation.
 496   */
 497  
 498  function getKeyCombinationRepresentation(shortcut, representation) {
 499    if (!shortcut) {
 500      return null;
 501    }
 502  
 503    return shortcut.modifier ? FORMATTING_METHODS[representation][shortcut.modifier](shortcut.character) : shortcut.character;
 504  }
 505  /**
 506   * Returns the main key combination for a given shortcut name.
 507   *
 508   * @param {Object} state Global state.
 509   * @param {string} name  Shortcut name.
 510   *
 511   * @return {WPShortcutKeyCombination?} Key combination.
 512   */
 513  
 514  
 515  function getShortcutKeyCombination(state, name) {
 516    return state[name] ? state[name].keyCombination : null;
 517  }
 518  /**
 519   * Returns a string representing the main key combination for a given shortcut name.
 520   *
 521   * @param {Object}                   state          Global state.
 522   * @param {string}                   name           Shortcut name.
 523   * @param {keyof FORMATTING_METHODS} representation Type of representation
 524   *                                                  (display, raw, ariaLabel).
 525   *
 526   * @return {string?} Shortcut representation.
 527   */
 528  
 529  function getShortcutRepresentation(state, name) {
 530    let representation = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'display';
 531    const shortcut = getShortcutKeyCombination(state, name);
 532    return getKeyCombinationRepresentation(shortcut, representation);
 533  }
 534  /**
 535   * Returns the shortcut description given its name.
 536   *
 537   * @param {Object} state Global state.
 538   * @param {string} name  Shortcut name.
 539   *
 540   * @return {string?} Shortcut description.
 541   */
 542  
 543  function getShortcutDescription(state, name) {
 544    return state[name] ? state[name].description : null;
 545  }
 546  /**
 547   * Returns the aliases for a given shortcut name.
 548   *
 549   * @param {Object} state Global state.
 550   * @param {string} name  Shortcut name.
 551   *
 552   * @return {WPShortcutKeyCombination[]} Key combinations.
 553   */
 554  
 555  function getShortcutAliases(state, name) {
 556    return state[name] && state[name].aliases ? state[name].aliases : EMPTY_ARRAY;
 557  }
 558  const getAllShortcutKeyCombinations = rememo((state, name) => {
 559    return (0,external_lodash_namespaceObject.compact)([getShortcutKeyCombination(state, name), ...getShortcutAliases(state, name)]);
 560  }, (state, name) => [state[name]]);
 561  /**
 562   * Returns the raw representation of all the keyboard combinations of a given shortcut name.
 563   *
 564   * @param {Object} state Global state.
 565   * @param {string} name  Shortcut name.
 566   *
 567   * @return {string[]} Shortcuts.
 568   */
 569  
 570  const getAllShortcutRawKeyCombinations = rememo((state, name) => {
 571    return getAllShortcutKeyCombinations(state, name).map(combination => getKeyCombinationRepresentation(combination, 'raw'));
 572  }, (state, name) => [state[name]]);
 573  /**
 574   * Returns the shortcut names list for a given category name.
 575   *
 576   * @param {Object} state Global state.
 577   * @param {string} name  Category name.
 578   *
 579   * @return {string[]} Shortcut names.
 580   */
 581  
 582  const getCategoryShortcuts = rememo((state, categoryName) => {
 583    return Object.entries(state).filter(_ref => {
 584      let [, shortcut] = _ref;
 585      return shortcut.category === categoryName;
 586    }).map(_ref2 => {
 587      let [name] = _ref2;
 588      return name;
 589    });
 590  }, state => [state]);
 591  
 592  ;// CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/store/index.js
 593  /**
 594   * WordPress dependencies
 595   */
 596  
 597  /**
 598   * Internal dependencies
 599   */
 600  
 601  
 602  
 603  
 604  const STORE_NAME = 'core/keyboard-shortcuts';
 605  /**
 606   * Store definition for the keyboard shortcuts namespace.
 607   *
 608   * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
 609   *
 610   * @type {Object}
 611   */
 612  
 613  const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, {
 614    reducer: store_reducer,
 615    actions: actions_namespaceObject,
 616    selectors: selectors_namespaceObject
 617  });
 618  (0,external_wp_data_namespaceObject.register)(store);
 619  
 620  ;// CONCATENATED MODULE: external ["wp","element"]
 621  var external_wp_element_namespaceObject = window["wp"]["element"];
 622  ;// CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/hooks/use-shortcut-event-match.js
 623  /**
 624   * WordPress dependencies
 625   */
 626  
 627  
 628  /**
 629   * Internal dependencies
 630   */
 631  
 632  
 633  /**
 634   * Returns a function to check if a keyboard event matches a shortcut name.
 635   *
 636   * @return {Function} A function to to check if a keyboard event matches a
 637   *                    predefined shortcut combination.
 638   */
 639  
 640  function useShortcutEventMatch() {
 641    const {
 642      getAllShortcutKeyCombinations
 643    } = (0,external_wp_data_namespaceObject.useSelect)(store);
 644    /**
 645     * A function to check if a keyboard event matches a predefined shortcut
 646     * combination.
 647     *
 648     * @param {string}        name  Shortcut name.
 649     * @param {KeyboardEvent} event Event to check.
 650     *
 651     * @return {boolean} True if the event matches any shortcuts, false if not.
 652     */
 653  
 654    function isMatch(name, event) {
 655      return getAllShortcutKeyCombinations(name).some(_ref => {
 656        let {
 657          modifier,
 658          character
 659        } = _ref;
 660        return external_wp_keycodes_namespaceObject.isKeyboardEvent[modifier](event, character);
 661      });
 662    }
 663  
 664    return isMatch;
 665  }
 666  
 667  ;// CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/context.js
 668  /**
 669   * WordPress dependencies
 670   */
 671  
 672  const context = (0,external_wp_element_namespaceObject.createContext)();
 673  
 674  ;// CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/hooks/use-shortcut.js
 675  /**
 676   * WordPress dependencies
 677   */
 678  
 679  /**
 680   * Internal dependencies
 681   */
 682  
 683  
 684  
 685  /**
 686   * Attach a keyboard shortcut handler.
 687   *
 688   * @param {string}   name               Shortcut name.
 689   * @param {Function} callback           Shortcut callback.
 690   * @param {Object}   options            Shortcut options.
 691   * @param {boolean}  options.isDisabled Whether to disable to shortut.
 692   */
 693  
 694  function useShortcut(name, callback) {
 695    let {
 696      isDisabled
 697    } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
 698    const shortcuts = (0,external_wp_element_namespaceObject.useContext)(context);
 699    const isMatch = useShortcutEventMatch();
 700    const callbackRef = (0,external_wp_element_namespaceObject.useRef)();
 701    callbackRef.current = callback;
 702    (0,external_wp_element_namespaceObject.useEffect)(() => {
 703      if (isDisabled) {
 704        return;
 705      }
 706  
 707      function _callback(event) {
 708        if (isMatch(name, event)) {
 709          callbackRef.current(event);
 710        }
 711      }
 712  
 713      shortcuts.current.add(_callback);
 714      return () => {
 715        shortcuts.current.delete(_callback);
 716      };
 717    }, [name, isDisabled]);
 718  }
 719  
 720  ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
 721  function _extends() {
 722    _extends = Object.assign || function (target) {
 723      for (var i = 1; i < arguments.length; i++) {
 724        var source = arguments[i];
 725  
 726        for (var key in source) {
 727          if (Object.prototype.hasOwnProperty.call(source, key)) {
 728            target[key] = source[key];
 729          }
 730        }
 731      }
 732  
 733      return target;
 734    };
 735  
 736    return _extends.apply(this, arguments);
 737  }
 738  ;// CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/components/shortcut-provider.js
 739  
 740  
 741  
 742  /**
 743   * WordPress dependencies
 744   */
 745  
 746  /**
 747   * Internal dependencies
 748   */
 749  
 750  
 751  const {
 752    Provider
 753  } = context;
 754  /**
 755   * Handles callbacks added to context by `useShortcut`.
 756   *
 757   * @param {Object} props Props to pass to `div`.
 758   *
 759   * @return {import('@wordpress/element').WPElement} Component.
 760   */
 761  
 762  function ShortcutProvider(props) {
 763    const keyboardShortcuts = (0,external_wp_element_namespaceObject.useRef)(new Set());
 764  
 765    function onKeyDown(event) {
 766      if (props.onKeyDown) props.onKeyDown(event);
 767  
 768      for (const keyboardShortcut of keyboardShortcuts.current) {
 769        keyboardShortcut(event);
 770      }
 771    }
 772    /* eslint-disable jsx-a11y/no-static-element-interactions */
 773  
 774  
 775    return (0,external_wp_element_namespaceObject.createElement)(Provider, {
 776      value: keyboardShortcuts
 777    }, (0,external_wp_element_namespaceObject.createElement)("div", _extends({}, props, {
 778      onKeyDown: onKeyDown
 779    })));
 780    /* eslint-enable jsx-a11y/no-static-element-interactions */
 781  }
 782  
 783  ;// CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/index.js
 784  
 785  
 786  
 787  
 788  
 789  (window.wp = window.wp || {}).keyboardShortcuts = __webpack_exports__;
 790  /******/ })()
 791  ;


Generated: Thu Nov 21 01:00:03 2024 Cross-referenced by PHPXref 0.7.1