Skip to content

Commit

Permalink
Make useShouldContextualToolbarShow private
Browse files Browse the repository at this point in the history
  • Loading branch information
jeryj committed Apr 19, 2023
1 parent 47c6561 commit 3eef424
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 15 deletions.
12 changes: 0 additions & 12 deletions packages/block-editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -858,18 +858,6 @@ _Returns_

- `any`: Returns the value defined for the setting.

### useShouldContextualToolbarShow

Returns true if the contextual block toolbar should show, or false if it should be hidden.

_Parameters_

- _clientId_ `string`: The client ID of the block.

_Returns_

- `boolean`: Whether the block toolbar is hidden.

### Warning

_Related_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import BlockPopover from '../block-popover';
import useBlockToolbarPopoverProps from './use-block-toolbar-popover-props';
import Inserter from '../inserter';
import { unlock } from '../../lock-unlock';
import { useShouldContextualToolbarShow } from '../../utils/use-should-contextual-toolbar-show';
import { privateApis } from '../../private-apis';

function selector( select ) {
const {
Expand Down Expand Up @@ -53,6 +53,8 @@ function SelectedBlockPopover( {
selector,
[]
);

const { useShouldContextualToolbarShow } = unlock( privateApis );
const isInsertionPointVisible = useSelect(
( select ) => {
const {
Expand Down
2 changes: 2 additions & 0 deletions packages/block-editor/src/private-apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import ResizableBoxPopover from './components/resizable-box-popover';
import { ComposedPrivateInserter as PrivateInserter } from './components/inserter';
import { PrivateListView } from './components/list-view';
import BlockInfo from './components/block-info-slot-fill';
import { useShouldContextualToolbarShow } from './utils/use-should-contextual-toolbar-show';

/**
* Private @wordpress/block-editor APIs.
Expand All @@ -24,4 +25,5 @@ lock( privateApis, {
PrivateListView,
ResizableBoxPopover,
BlockInfo,
useShouldContextualToolbarShow,
} );
1 change: 0 additions & 1 deletion packages/block-editor/src/utils/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export { default as transformStyles } from './transform-styles';
export * from './block-variation-transforms';
export { default as getPxFromCssUnit } from './parse-css-unit-to-px';
export { useShouldContextualToolbarShow } from './use-should-contextual-toolbar-show';
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
NavigableToolbar,
ToolSelector,
store as blockEditorStore,
useShouldContextualToolbarShow,
privateApis as blockEditorPrivateApis,
} from '@wordpress/block-editor';
import {
EditorHistoryRedo,
Expand All @@ -24,6 +24,7 @@ import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
* Internal dependencies
*/
import { store as editPostStore } from '../../../store';
import { unlock } from '../../../private-apis';

const preventDefault = ( event ) => {
event.preventDefault();
Expand Down Expand Up @@ -78,6 +79,8 @@ function HeaderToolbar() {
};
}, [] );

const { useShouldContextualToolbarShow } = unlock( blockEditorPrivateApis );

const isLargeViewport = useViewportMatch( 'medium' );
const isWideViewport = useViewportMatch( 'wide' );
const { shouldShowContextualToolbar, canFocusHiddenToolbar } =
Expand Down

0 comments on commit 3eef424

Please sign in to comment.