@@ -21,6 +21,8 @@ import { useMemo, useCallback, memo } from 'react';
2121import { ChevronDown , ChevronRight } from 'lucide-react' ;
2222import { useCommandTranslation } from '../../hooks/useCommandTranslation' ;
2323import { useTranslation } from 'react-i18next' ;
24+ import { groupCommandsByCategory } from '../../utils/commandCategories' ;
25+ import { CategoryMenuRenderer } from '../common/CategoryMenuRenderer' ;
2426
2527/**
2628 * CommandList コンポーネント - パフォーマンス最適化済み
@@ -447,6 +449,7 @@ const CommandItem = memo(({
447449 */
448450
449451// コンテキストメニューをメモ化コンポーネントとして分離
452+
450453const CommandContextMenu = memo ( ( {
451454 command,
452455 index,
@@ -470,6 +473,9 @@ const CommandContextMenu = memo(({
470473} ) => {
471474 const isGroupStart = command . type === 'group_start' ;
472475
476+ // Group commands by category
477+ const commandCategories = groupCommandsByCategory ( commandDefinitions ) ;
478+
473479 return (
474480 < ContextMenuContent >
475481 < ContextMenuItem
@@ -501,28 +507,34 @@ const CommandContextMenu = memo(({
501507 < ContextMenuSub >
502508 < ContextMenuSubTrigger > 上にコマンドを追加</ ContextMenuSubTrigger >
503509 < ContextMenuSubContent >
504- { commandDefinitions . map ( ( cmdDef : CommandDefinition ) => (
505- < ContextMenuItem
506- key = { cmdDef . id }
507- onClick = { ( ) => handleAddCommand ( cmdDef . id , index , 'above' ) }
508- >
509- { cmdDef . label }
510- </ ContextMenuItem >
511- ) ) }
510+ < CategoryMenuRenderer
511+ categoryNode = { commandCategories }
512+ onSelectCommand = { ( commandType ) => handleAddCommand ( commandType , index , 'above' ) }
513+ components = { {
514+ MenuItem : ContextMenuItem ,
515+ MenuSub : ContextMenuSub ,
516+ MenuSubTrigger : ContextMenuSubTrigger ,
517+ MenuSubContent : ContextMenuSubContent ,
518+ MenuSeparator : ContextMenuSeparator
519+ } }
520+ />
512521 </ ContextMenuSubContent >
513522 </ ContextMenuSub >
514523
515524 < ContextMenuSub >
516525 < ContextMenuSubTrigger > 下にコマンドを追加</ ContextMenuSubTrigger >
517526 < ContextMenuSubContent >
518- { commandDefinitions . map ( ( cmdDef : CommandDefinition ) => (
519- < ContextMenuItem
520- key = { cmdDef . id }
521- onClick = { ( ) => handleAddCommand ( cmdDef . id , index , 'below' ) }
522- >
523- { cmdDef . label }
524- </ ContextMenuItem >
525- ) ) }
527+ < CategoryMenuRenderer
528+ categoryNode = { commandCategories }
529+ onSelectCommand = { ( commandType ) => handleAddCommand ( commandType , index , 'below' ) }
530+ components = { {
531+ MenuItem : ContextMenuItem ,
532+ MenuSub : ContextMenuSub ,
533+ MenuSubTrigger : ContextMenuSubTrigger ,
534+ MenuSubContent : ContextMenuSubContent ,
535+ MenuSeparator : ContextMenuSeparator
536+ } }
537+ />
526538 </ ContextMenuSubContent >
527539 </ ContextMenuSub >
528540 </ ContextMenuContent >
0 commit comments