@@ -10,7 +10,13 @@ import type { Properties } from 'csstype';
1010import { __ } from '@wordpress/i18n' ;
1111import { useEffect , useState } from '@wordpress/element' ;
1212import { useSelect , useDispatch } from '@wordpress/data' ;
13- import { InspectorControls , BlockControls , useBlockProps } from '@wordpress/block-editor' ;
13+ import {
14+ InspectorControls ,
15+ BlockControls ,
16+ useBlockProps ,
17+ // @ts -ignore: has no exported member
18+ useBlockEditingMode ,
19+ } from '@wordpress/block-editor' ;
1420import {
1521 // @ts -ignore: has no exported member
1622 ToolbarDropdownMenu ,
@@ -79,6 +85,8 @@ function TableEdit( props: BlockEditProps< BlockAttributes > ) {
7985 [ ]
8086 ) ;
8187 const { createWarningNotice } = useDispatch ( noticesStore ) ;
88+ const blockEditingMode = useBlockEditingMode ( ) ;
89+ const isContentOnlyMode = blockEditingMode === 'contentOnly' ;
8290
8391 // Release cell selection.
8492 useEffect ( ( ) => {
@@ -256,6 +264,7 @@ function TableEdit( props: BlockEditProps< BlockAttributes > ) {
256264 [ `is-content-justification-${ contentJustification } ` ] : contentJustification ,
257265 'show-dot-on-th' : options . show_dot_on_th ,
258266 'show-control-button' : options . show_control_button ,
267+ 'is-content-only' : isContentOnlyMode ,
259268 } ) ,
260269 } ) ;
261270
@@ -270,6 +279,7 @@ function TableEdit( props: BlockEditProps< BlockAttributes > ) {
270279 setSelectedCells,
271280 selectedLine,
272281 setSelectedLine,
282+ isContentOnlyMode,
273283 } ;
274284
275285 const tableSettingsProps = {
@@ -316,28 +326,33 @@ function TableEdit( props: BlockEditProps< BlockAttributes > ) {
316326 ) }
317327 { ! isEmpty && (
318328 < figure { ...tableFigureProps } >
319- < BlockControls
320- // @ts -ignore: `group` prop is not exist at @types
321- group = "block"
322- >
323- < ToolbarDropdownMenu
324- label = { __ ( 'Change table justification' , 'flexible-table-block' ) }
325- icon = {
326- ( contentJustification &&
327- TableJustifyControls . find ( ( control ) => control . value === contentJustification )
328- ?. icon ) ||
329- justifyLeft
330- }
331- controls = { TableJustifyControls }
332- hasArrowIndicator
333- />
334- < ToolbarDropdownMenu
335- label = { __ ( 'Edit table' , 'flexible-table-block' ) }
336- icon = { blockTable }
337- controls = { TableEditControls }
338- hasArrowIndicator
339- />
340- </ BlockControls >
329+ { ! isContentOnlyMode && (
330+ < >
331+ < BlockControls
332+ // @ts -ignore: `group` prop is not exist at @types
333+ group = "block"
334+ >
335+ < ToolbarDropdownMenu
336+ label = { __ ( 'Change table justification' , 'flexible-table-block' ) }
337+ icon = {
338+ ( contentJustification &&
339+ TableJustifyControls . find (
340+ ( control ) => control . value === contentJustification
341+ ) ?. icon ) ||
342+ justifyLeft
343+ }
344+ controls = { TableJustifyControls }
345+ hasArrowIndicator
346+ />
347+ < ToolbarDropdownMenu
348+ label = { __ ( 'Edit table' , 'flexible-table-block' ) }
349+ icon = { blockTable }
350+ controls = { TableEditControls }
351+ hasArrowIndicator
352+ />
353+ </ BlockControls >
354+ </ >
355+ ) }
341356 < InspectorControls >
342357 < PanelBody
343358 title = { __ ( 'Table settings' , 'flexible-table-block' ) }
0 commit comments