PluginProbe
Gutenberg / 24.1.0
Gutenberg v24.1.0
24.1.0 24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 All 404 releases
← All changes | build/scripts/commands/index.js +35 -10 23.7.2 → 24.1.0 View file →
@@ -1,4 +1,5 @@
1 +(function() {
1 2 var wp;
2 3 (wp ||= {}).commands = (() => {
3 4 var __create = Object.create;
4 5 var __defProp = Object.defineProperty;
@@ -86,8 +87,15 @@
86 87 module.exports = window.wp.keyboardShortcuts;
87 88 }
88 89 });
89 90
91 + // package-external:@wordpress/keycodes
92 + var require_keycodes = __commonJS({
93 + "package-external:@wordpress/keycodes"(exports, module) {
94 + module.exports = window.wp.keycodes;
95 + }
96 + });
97 +
90 98 // package-external:@wordpress/primitives
91 99 var require_primitives = __commonJS({
92 100 "package-external:@wordpress/primitives"(exports, module) {
93 101 module.exports = window.wp.primitives;
@@ -2568,17 +2576,24 @@
2568 2576 var import_element3 = __toESM(require_element(), 1);
2569 2577 var import_i18n = __toESM(require_i18n(), 1);
2570 2578 var import_components = __toESM(require_components(), 1);
2571 2579 var import_keyboard_shortcuts = __toESM(require_keyboard_shortcuts(), 1);
2580 + var import_keycodes = __toESM(require_keycodes(), 1);
2572 2581
2573 2582 // packages/icons/build-module/icon/index.mjs
2574 2583 var import_element = __toESM(require_element(), 1);
2575 2584 var icon_default = (0, import_element.forwardRef)(
2576 - ({ icon, size = 24, ...props }, ref) => {
2585 + ({ icon, size = 24, style, ...props }, ref) => {
2586 + const intrinsicStyle = icon.props.style;
2587 + const mergedStyle = intrinsicStyle || style ? { ...intrinsicStyle, ...style } : void 0;
2577 2588 return (0, import_element.cloneElement)(icon, {
2578 2589 width: size,
2579 2590 height: size,
2580 2591 ...props,
2592 + // Merge styles so the icon's intrinsic style (e.g. `fill: none` on
2593 + // stroke-based icons) is preserved unless the consumer overrides
2594 + // the same property explicitly.
2595 + ...mergedStyle ? { style: mergedStyle } : {},
2581 2596 ref
2582 2597 });
2583 2598 }
2584 2599 );
@@ -2585,14 +2600,14 @@
2585 2600
2586 2601 // packages/icons/build-module/library/arrow-right.mjs
2587 2602 var import_primitives = __toESM(require_primitives(), 1);
2588 2603 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
2589 - var arrow_right_default = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives.Path, { d: "m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z" }) });
2604 + var arrow_right_default = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives.Path, { d: "M4 12L19 12M14 17L19 12L14 7", vectorEffect: "non-scaling-stroke" }) });
2590 2605
2591 2606 // packages/icons/build-module/library/search.mjs
2592 2607 var import_primitives2 = __toESM(require_primitives(), 1);
2593 2608 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
2594 - var search_default = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives2.Path, { d: "M13 5c-3.3 0-6 2.7-6 6 0 1.4.5 2.7 1.3 3.7l-3.8 3.8 1.1 1.1 3.8-3.8c1 .8 2.3 1.3 3.7 1.3 3.3 0 6-2.7 6-6S16.3 5 13 5zm0 10.5c-2.5 0-4.5-2-4.5-4.5s2-4.5 4.5-4.5 4.5 2 4.5 4.5-2 4.5-4.5 4.5z" }) });
2609 + var search_default = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: { fill: "none" }, stroke: "currentColor", strokeWidth: "1.5", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives2.Path, { d: "M5 19L9.28769 14.7123M18.25 11C18.25 13.8995 15.8995 16.25 13 16.25C10.1005 16.25 7.75 13.8995 7.75 11C7.75 8.10051 10.1005 5.75 13 5.75C15.8995 5.75 18.25 8.10051 18.25 11Z", vectorEffect: "non-scaling-stroke" }) });
2595 2610
2596 2611 // packages/commands/build-module/store/index.mjs
2597 2612 var import_data3 = __toESM(require_data(), 1);
2598 2613
@@ -2906,12 +2921,11 @@
2906 2921 }
2907 2922
2908 2923 // packages/commands/build-module/components/command-menu.mjs
2909 2924 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
2910 - var { withIgnoreIMEEvents } = unlock(import_components.privateApis);
2911 2925 var ITEM_ID_PREFIX = "command-palette-item-";
2912 2926 var inputLabel = (0, import_i18n.__)("Search commands and settings");
2913 - var CATEGORY_ICONS = {
2927 + var CATEGORY_FALLBACK_ICONS = {
2914 2928 view: arrow_right_default
2915 2929 };
2916 2930 var CATEGORY_LABELS = {
2917 2931 command: (0, import_i18n.__)("Command"),
@@ -2925,8 +2939,9 @@
2925 2939 }
2926 2940 function CommandItem({ command, search, category, valuePrefix }) {
2927 2941 const { close: close2 } = (0, import_data5.useDispatch)(store);
2928 2942 const commandCategory = category ?? command.category;
2943 + const icon = command.icon ?? CATEGORY_FALLBACK_ICONS[commandCategory];
2929 2944 const label = command.searchLabel ?? command.label;
2930 2945 const value = valuePrefix ? `${valuePrefix}${command.name}` : label;
2931 2946 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2932 2947 _e.Item,
@@ -2942,12 +2957,12 @@
2942 2957 import_components.__experimentalHStack,
2943 2958 {
2944 2959 alignment: "left",
2945 2960 className: clsx_default("commands-command-menu__item", {
2946 - "has-icon": CATEGORY_ICONS[commandCategory] || command.icon
2961 + "has-icon": !!icon
2947 2962 }),
2948 2963 children: [
2949 - CATEGORY_ICONS[commandCategory] ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(icon_default, { icon: CATEGORY_ICONS[commandCategory] }) : isValidIcon(command.icon) && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(icon_default, { icon: command.icon }),
2964 + isValidIcon(icon) && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(icon_default, { icon }),
2950 2965 /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "commands-command-menu__item-label", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2951 2966 import_components.TextHighlight,
2952 2967 {
2953 2968 text: command.label,
@@ -3136,9 +3151,9 @@
3136 3151 }, [registerShortcut]);
3137 3152 (0, import_keyboard_shortcuts.useShortcut)(
3138 3153 "core/commands",
3139 3154 /** @type {React.KeyboardEventHandler} */
3140 - withIgnoreIMEEvents((event) => {
3155 + (0, import_keycodes.withIgnoreIMEEvents)((event) => {
3141 3156 if (event.defaultPrevented) {
3142 3157 return;
3143 3158 }
3144 3159 event.preventDefault();
@@ -3306,15 +3321,23 @@
3306 3321 var import_element6 = __toESM(require_element(), 1);
3307 3322 var import_data8 = __toESM(require_data(), 1);
3308 3323 function useCommandLoader(loader) {
3309 3324 const { registerCommandLoader: registerCommandLoader2, unregisterCommandLoader: unregisterCommandLoader2 } = (0, import_data8.useDispatch)(store);
3325 + const currentHookRef = (0, import_element6.useRef)(loader.hook);
3310 3326 (0, import_element6.useEffect)(() => {
3327 + currentHookRef.current = loader.hook;
3328 + }, [loader.hook]);
3329 + const hook = (0, import_element6.useCallback)(
3330 + (...args) => currentHookRef.current(...args),
3331 + []
3332 + );
3333 + (0, import_element6.useEffect)(() => {
3311 3334 if (loader.disabled) {
3312 3335 return;
3313 3336 }
3314 3337 registerCommandLoader2({
3315 3338 name: loader.name,
3316 - hook: loader.hook,
3339 + hook,
3317 3340 context: loader.context,
3318 3341 category: loader.category
3319 3342 });
3320 3343 return () => {
@@ -3321,9 +3344,9 @@
3321 3344 unregisterCommandLoader2(loader.name);
3322 3345 };
3323 3346 }, [
3324 3347 loader.name,
3325 - loader.hook,
3348 + hook,
3326 3349 loader.context,
3327 3350 loader.category,
3328 3351 loader.disabled,
3329 3352 registerCommandLoader2,
@@ -3330,6 +3353,8 @@
3330 3353 unregisterCommandLoader2
3331 3354 ]);
3332 3355 }
3333 3356 return __toCommonJS(index_exports);
3357 +})();
3358 +(window.wp ||= {}).commands = wp.commands;
3334 3359 })();
3335 3360 //# sourceMappingURL=index.js.map