@@ -767,16 +767,18 @@ function TableFloatingToolbar({
767767 [ ]
768768 ) ;
769769 const selected = useSelected ( ) ;
770- const collapsedInside = useEditorSelector (
771- ( editor ) => selected && editor . api . isCollapsed ( ) ,
772- [ selected ]
773- ) ;
774770 const isFocusedLast = useFocusedLast ( ) ;
775771 const [ isExpandedSelectionToolbarReady , setIsExpandedSelectionToolbarReady ] =
776772 React . useState ( false ) ;
777- const isCollapsedToolbarOpen = isFocusedLast && collapsedInside ;
778- const isExpandedSelectionPending =
779- isFocusedLast && ! collapsedInside && selectedCellCount > 1 ;
773+ // `getSelectedCellIds` only reports cells once a range spans more than one
774+ // cell, so a count of zero means the selection (a caret or an expanded
775+ // range) is confined to a single cell. Gating on it instead of
776+ // `editor.api.isCollapsed()` keeps the row/column controls available while a
777+ // cell's content is fully selected (e.g. select-all inside a cell), not just
778+ // while the caret is collapsed in it.
779+ const isSingleCellToolbarOpen =
780+ isFocusedLast && selected && selectedCellCount === 0 ;
781+ const isExpandedSelectionPending = isFocusedLast && selectedCellCount > 1 ;
780782
781783 React . useEffect ( ( ) => {
782784 if ( ! isExpandedSelectionPending ) {
@@ -798,13 +800,13 @@ function TableFloatingToolbar({
798800 const shouldRenderExpandedSelectionToolbar =
799801 isExpandedSelectionToolbarReady && isExpandedSelectionPending ;
800802 const isToolbarOpen =
801- isCollapsedToolbarOpen || shouldRenderExpandedSelectionToolbar ;
803+ isSingleCellToolbarOpen || shouldRenderExpandedSelectionToolbar ;
802804
803805 return (
804806 < Popover open = { isToolbarOpen } modal = { false } >
805807 < PopoverAnchor asChild > { children } </ PopoverAnchor >
806- { isCollapsedToolbarOpen && (
807- < CollapsedTableFloatingToolbarContent { ...props } />
808+ { isSingleCellToolbarOpen && (
809+ < SingleCellTableFloatingToolbarContent { ...props } />
808810 ) }
809811 { shouldRenderExpandedSelectionToolbar && (
810812 < ExpandedSelectionTableFloatingToolbarContent { ...props } />
@@ -832,7 +834,7 @@ function ExpandedSelectionTableFloatingToolbarContent(
832834 ) ;
833835}
834836
835- function CollapsedTableFloatingToolbarContent (
837+ function SingleCellTableFloatingToolbarContent (
836838 props : React . ComponentProps < typeof PopoverContent >
837839) {
838840 const { tf } = useEditorPlugin ( TablePlugin ) ;
@@ -844,7 +846,7 @@ function CollapsedTableFloatingToolbarContent(
844846 < TableFloatingToolbarContent
845847 buttonProps = { buttonProps }
846848 canSplit = { canSplit }
847- collapsedInside
849+ singleCellMode
848850 onDeleteColumn = { ( ) => {
849851 tf . remove . tableColumn ( ) ;
850852 } }
@@ -873,7 +875,7 @@ function TableFloatingToolbarContent({
873875 buttonProps,
874876 canMerge = false ,
875877 canSplit = false ,
876- collapsedInside = false ,
878+ singleCellMode = false ,
877879 onDeleteColumn,
878880 onDeleteRow,
879881 onInsertColumnAfter,
@@ -887,7 +889,7 @@ function TableFloatingToolbarContent({
887889 buttonProps ?: React . ComponentProps < typeof ToolbarButton > ;
888890 canMerge ?: boolean ;
889891 canSplit ?: boolean ;
890- collapsedInside ?: boolean ;
892+ singleCellMode ?: boolean ;
891893 onDeleteColumn ?: ( ) => void ;
892894 onDeleteRow ?: ( ) => void ;
893895 onInsertColumnAfter ?: ( ) => void ;
@@ -943,7 +945,7 @@ function TableFloatingToolbarContent({
943945 </ DropdownMenuPortal >
944946 </ DropdownMenu >
945947
946- { collapsedInside && (
948+ { singleCellMode && (
947949 < ToolbarGroup >
948950 < ToolbarButton tooltip = "Delete table" { ...buttonProps } >
949951 < Trash2Icon />
@@ -952,7 +954,7 @@ function TableFloatingToolbarContent({
952954 ) }
953955 </ ToolbarGroup >
954956
955- { collapsedInside && (
957+ { singleCellMode && (
956958 < ToolbarGroup >
957959 < ToolbarButton
958960 onClick = { onInsertRowBefore }
@@ -978,7 +980,7 @@ function TableFloatingToolbarContent({
978980 </ ToolbarGroup >
979981 ) }
980982
981- { collapsedInside && (
983+ { singleCellMode && (
982984 < ToolbarGroup >
983985 < ToolbarButton
984986 onClick = { onInsertColumnBefore }
0 commit comments