PluginProbe
Gutenberg / trunk
Gutenberg vtrunk
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 +23 -8 23.8.0 → trunk View file →
@@ -2581,13 +2581,19 @@
2581 2581
2582 2582 // packages/icons/build-module/icon/index.mjs
2583 2583 var import_element = __toESM(require_element(), 1);
2584 2584 var icon_default = (0, import_element.forwardRef)(
2585 - ({ 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;
2586 2588 return (0, import_element.cloneElement)(icon, {
2587 2589 width: size,
2588 2590 height: size,
2589 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 } : {},
2590 2596 ref
2591 2597 });
2592 2598 }
2593 2599 );
@@ -2594,14 +2600,14 @@
2594 2600
2595 2601 // packages/icons/build-module/library/arrow-right.mjs
2596 2602 var import_primitives = __toESM(require_primitives(), 1);
2597 2603 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
2598 - 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" }) });
2599 2605
2600 2606 // packages/icons/build-module/library/search.mjs
2601 2607 var import_primitives2 = __toESM(require_primitives(), 1);
2602 2608 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
2603 - 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" }) });
2604 2610
2605 2611 // packages/commands/build-module/store/index.mjs
2606 2612 var import_data3 = __toESM(require_data(), 1);
2607 2613
@@ -2917,9 +2923,9 @@
2917 2923 // packages/commands/build-module/components/command-menu.mjs
2918 2924 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
2919 2925 var ITEM_ID_PREFIX = "command-palette-item-";
2920 2926 var inputLabel = (0, import_i18n.__)("Search commands and settings");
2921 - var CATEGORY_ICONS = {
2927 + var CATEGORY_FALLBACK_ICONS = {
2922 2928 view: arrow_right_default
2923 2929 };
2924 2930 var CATEGORY_LABELS = {
2925 2931 command: (0, import_i18n.__)("Command"),
@@ -2933,8 +2939,9 @@
2933 2939 }
2934 2940 function CommandItem({ command, search, category, valuePrefix }) {
2935 2941 const { close: close2 } = (0, import_data5.useDispatch)(store);
2936 2942 const commandCategory = category ?? command.category;
2943 + const icon = command.icon ?? CATEGORY_FALLBACK_ICONS[commandCategory];
2937 2944 const label = command.searchLabel ?? command.label;
2938 2945 const value = valuePrefix ? `${valuePrefix}${command.name}` : label;
2939 2946 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2940 2947 _e.Item,
@@ -2950,12 +2957,12 @@
2950 2957 import_components.__experimentalHStack,
2951 2958 {
2952 2959 alignment: "left",
2953 2960 className: clsx_default("commands-command-menu__item", {
2954 - "has-icon": CATEGORY_ICONS[commandCategory] || command.icon
2961 + "has-icon": !!icon
2955 2962 }),
2956 2963 children: [
2957 - 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 }),
2958 2965 /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "commands-command-menu__item-label", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2959 2966 import_components.TextHighlight,
2960 2967 {
2961 2968 text: command.label,
@@ -3314,15 +3321,23 @@
3314 3321 var import_element6 = __toESM(require_element(), 1);
3315 3322 var import_data8 = __toESM(require_data(), 1);
3316 3323 function useCommandLoader(loader) {
3317 3324 const { registerCommandLoader: registerCommandLoader2, unregisterCommandLoader: unregisterCommandLoader2 } = (0, import_data8.useDispatch)(store);
3325 + const currentHookRef = (0, import_element6.useRef)(loader.hook);
3318 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)(() => {
3319 3334 if (loader.disabled) {
3320 3335 return;
3321 3336 }
3322 3337 registerCommandLoader2({
3323 3338 name: loader.name,
3324 - hook: loader.hook,
3339 + hook,
3325 3340 context: loader.context,
3326 3341 category: loader.category
3327 3342 });
3328 3343 return () => {
@@ -3329,9 +3344,9 @@
3329 3344 unregisterCommandLoader2(loader.name);
3330 3345 };
3331 3346 }, [
3332 3347 loader.name,
3333 - loader.hook,
3348 + hook,
3334 3349 loader.context,
3335 3350 loader.category,
3336 3351 loader.disabled,
3337 3352 registerCommandLoader2,