Skip to content

Commit 5c65a62

Browse files
make utils private
1 parent 073510e commit 5c65a62

File tree

6 files changed

+18
-23
lines changed

6 files changed

+18
-23
lines changed

packages/edit-post/src/hooks/use-navigate-to-entity-record.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33
*/
44
import { useCallback, useReducer } from '@wordpress/element';
55
import { useSelect, useDispatch } from '@wordpress/data';
6-
import { store as editorStore, useGenerateBlockPath } from '@wordpress/editor';
6+
import { store as editorStore, privateApis } from '@wordpress/editor';
7+
8+
/**
9+
* Internal dependencies
10+
*/
11+
import { unlock } from '../lock-unlock';
12+
13+
const { useGenerateBlockPath } = unlock( privateApis );
714

815
/**
916
* A hook that records the 'entity' history in the post editor as a user

packages/edit-site/src/components/block-editor/use-navigate-to-entity-record.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
import { privateApis as routerPrivateApis } from '@wordpress/router';
55
import { useCallback } from '@wordpress/element';
66
import { addQueryArgs } from '@wordpress/url';
7-
import { useGenerateBlockPath } from '@wordpress/editor';
7+
import { privateApis as editorPrivateApis } from '@wordpress/editor';
88

99
/**
1010
* Internal dependencies
1111
*/
1212
import { unlock } from '../../lock-unlock';
1313

1414
const { useHistory, useLocation } = unlock( routerPrivateApis );
15+
const { useGenerateBlockPath } = unlock( editorPrivateApis );
1516

1617
/**
1718
* Hook to handle navigation to entity records and retrieve initial block selection.

packages/editor/README.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,14 +1729,6 @@ _Returns_
17291729

17301730
- `Object`: An object containing the following properties: - dirtyEntityRecords: An array of dirty entity records. - isDirty: A boolean indicating if there are any dirty entity records. - setUnselectedEntities: A function to set the unselected entities. - unselectedEntities: An array of unselected entities.
17311731

1732-
### useGenerateBlockPath
1733-
1734-
Hook that returns a function to generate a block path for a given block clientId. The path is an array of steps from root to the target block, where each step contains the block name and index within its parent.
1735-
1736-
_Returns_
1737-
1738-
- `Function`: Function that takes a clientId and returns the block path or null.
1739-
17401732
### usePostScheduleLabel
17411733

17421734
Custom hook to get the label for post schedule.
@@ -1774,14 +1766,6 @@ _Type_
17741766

17751767
- `Object`
17761768

1777-
### useRestoreBlockFromPath
1778-
1779-
Hook that returns a function to restore a block selection using a previously generated block path. Walks the path from root to target, matching block name and index at each level.
1780-
1781-
_Returns_
1782-
1783-
- `Function`: Function that takes a path and returns the clientId or null.
1784-
17851769
### VisualEditorGlobalKeyboardShortcuts
17861770

17871771
Handles the keyboard shortcuts for the editor.

packages/editor/src/components/editor/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { store as blockEditorStore } from '@wordpress/block-editor';
1313
*/
1414
import { store as editorStore } from '../../store';
1515
import { TEMPLATE_POST_TYPE } from '../../store/constants';
16-
import { useRestoreBlockFromPath } from '../../utils';
16+
import { useRestoreBlockFromPath } from '../../utils/block-selection-path';
1717
import EditorInterface from '../editor-interface';
1818
import { ExperimentalEditorProvider } from '../provider';
1919
import Sidebar from '../sidebar';

packages/editor/src/private-apis.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ import GlobalStylesUIWrapper from './components/global-styles';
2929
import { StyleBookPreview } from './components/style-book';
3030
import { useGlobalStyles, useStyle } from './components/global-styles/hooks';
3131
import { GlobalStylesActionMenu } from './components/global-styles/menu';
32+
import {
33+
useGenerateBlockPath,
34+
useRestoreBlockFromPath,
35+
} from './utils/block-selection-path';
3236

3337
const { store: interfaceStore, ...remainingInterfaceApis } = interfaceApis;
3438

@@ -56,6 +60,9 @@ lock( privateApis, {
5660
StyleBookPreview,
5761
useGlobalStyles,
5862
useStyle,
63+
// Block selection
64+
useGenerateBlockPath,
65+
useRestoreBlockFromPath,
5966
// This is a temporary private API while we're updating the site editor to use EditorProvider.
6067
interfaceStore,
6168
...remainingInterfaceApis,

packages/editor/src/utils/index.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,3 @@ import mediaUpload from './media-upload';
66
export { mediaUpload };
77
export { cleanForSlug } from './url.js';
88
export { getTemplatePartIcon } from './get-template-part-icon';
9-
export {
10-
useGenerateBlockPath,
11-
useRestoreBlockFromPath,
12-
} from './block-selection-path';

0 commit comments

Comments
 (0)