WordPress/wp-includes/js/dist/keyboard-shortcuts.min.js

2 lines
2.9 KiB
JavaScript
Raw Permalink Normal View History

Block Editor: Update WordPress Packages. The following package versions were changed: @wordpress/a11y: 2.5.1 -> 2.6.0 @wordpress/annotations: 1.9.0 -> 1.10.0 @wordpress/api-fetch: 3.8.0 -> 3.9.0 @wordpress/blob: 2.5.1 -> 2.6.0 @wordpress/block-directory: 1.2.0 -> 1.3.0 @wordpress/block-editor: 3.4.0 -> 3.5.0 @wordpress/block-library: 2.11.0 -> 2.12.0 @wordpress/blocks: 6.9.0 -> 6.10.0 @wordpress/components: 8.5.0 -> 9.0.0 @wordpress/compose: 3.9.0 -> 3.10.0 @wordpress/core-data: 2.9.0 -> 2.10.0 @wordpress/data: 4.11.0 -> 4.12.0 @wordpress/data-controls: 1.5.0 -> 1.6.0 @wordpress/dom: 2.6.0 -> 2.7.0 @wordpress/dom-ready: 2.5.1 -> 2.6.0 @wordpress/e2e-test-utils: 4.0.0 -> 4.1.0 @wordpress/edit-post: 3.10.0 -> 3.11.0 @wordpress/editor: 9.9.0 -> 9.10.0 @wordpress/format-library: 1.11.0 -> 1.12.0 @wordpress/i18n: 3.7.0 -> 3.8.0 @wordpress/is-shallow-equal: 1.6.1 -> 1.7.0 @wordpress/keycodes: 2.7.0 -> 2.8.0 @wordpress/list-reusable-blocks: 1.10.0 -> 1.11.0 @wordpress/media-utils: 1.4.0 -> 1.5.0 @wordpress/notices: 1.10.0 -> 1.11.0 @wordpress/nux: 3.9.0 -> 3.10.0 @wordpress/plugins: 2.9.0 -> 2.10.0 @wordpress/priority-queue: 1.3.1 -> 1.4.0 @wordpress/rich-text: 3.9.0 -> 3.10.0 @wordpress/scripts: 6.1.1 -> 6.2.0 @wordpress/server-side-render: 1.5.0 -> 1.6.0 @wordpress/viewport: 2.10.0 -> 2.11.0 The following package was added: @wordpress/keyboard-shortcuts Props gziolo. Fixes #49204. Built from https://develop.svn.wordpress.org/trunk@47106 git-svn-id: http://core.svn.wordpress.org/trunk@46906 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-01-22 17:06:21 -05:00
/*! This file is auto-generated */
(()=>{"use strict";var e={d:(t,o)=>{for(var n in o)e.o(o,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:o[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{ShortcutProvider:()=>K,__unstableUseShortcutEventMatch:()=>R,store:()=>h,useShortcut:()=>T});var o={};e.r(o),e.d(o,{registerShortcut:()=>c,unregisterShortcut:()=>a});var n={};e.r(n),e.d(n,{getAllShortcutKeyCombinations:()=>m,getAllShortcutRawKeyCombinations:()=>p,getCategoryShortcuts:()=>b,getShortcutAliases:()=>w,getShortcutDescription:()=>f,getShortcutKeyCombination:()=>y,getShortcutRepresentation:()=>S});const r=window.wp.data;const i=function(e={},t){switch(t.type){case"REGISTER_SHORTCUT":return{...e,[t.name]:{category:t.category,keyCombination:t.keyCombination,aliases:t.aliases,description:t.description}};case"UNREGISTER_SHORTCUT":const{[t.name]:o,...n}=e;return n}return e};function c({name:e,category:t,description:o,keyCombination:n,aliases:r}){return{type:"REGISTER_SHORTCUT",name:e,category:t,keyCombination:n,aliases:r,description:o}}function a(e){return{type:"UNREGISTER_SHORTCUT",name:e}}const s=window.wp.keycodes,u=[],d={display:s.displayShortcut,raw:s.rawShortcut,ariaLabel:s.shortcutAriaLabel};function l(e,t){return e?e.modifier?d[t][e.modifier](e.character):e.character:null}function y(e,t){return e[t]?e[t].keyCombination:null}function S(e,t,o="display"){return l(y(e,t),o)}function f(e,t){return e[t]?e[t].description:null}function w(e,t){return e[t]&&e[t].aliases?e[t].aliases:u}const m=(0,r.createSelector)(((e,t)=>[y(e,t),...w(e,t)].filter(Boolean)),((e,t)=>[e[t]])),p=(0,r.createSelector)(((e,t)=>m(e,t).map((e=>l(e,"raw")))),((e,t)=>[e[t]])),b=(0,r.createSelector)(((e,t)=>Object.entries(e).filter((([,e])=>e.category===t)).map((([e])=>e))),(e=>[e])),h=(0,r.createReduxStore)("core/keyboard-shortcuts",{reducer:i,actions:o,selectors:n});(0,r.register)(h);const g=window.wp.element;function R(){const{getAllShortcutKeyCombinations:e}=(0,r.useSelect)(h);return function(t,o){return e(t).some((({modifier:e,character:t})=>s.isKeyboardEvent[e](o,t)))}}const C=new Set,v=e=>{for(const t of C)t(e)},E=(0,g.createContext)({add:e=>{0===C.size&&document.addEventListener("keydown",v),C.add(e)},delete:e=>{C.delete(e),0===C.size&&document.removeEventListener("keydown",v)}});function T(e,t,{isDisabled:o=!1}={}){const n=(0,g.useContext)(E),r=R(),i=(0,g.useRef)();(0,g.useEffect)((()=>{i.current=t}),[t]),(0,g.useEffect)((()=>{if(!o)return n.add(t),()=>{n.delete(t)};function t(t){r(e,t)&&i.current(t)}}),[e,o,n])}const k=window.ReactJSXRuntime,{Provider:O}=E;function K(e){const[t]=(0,g.useState)((()=>new Set));return(0,k.jsx)(O,{value:t,children:(0,k.jsx)("div",{...e,onKeyDown:function(o){e.onKeyDown&&e.onKeyDown(o);for(const e of t)e(o)}})})}(window.wp=window.wp||{}).keyboardShortcuts=t})();