Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update fetchLinkSuggestions to sort results by relevancy #62397

Merged
merged 8 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/block-library/src/paragraph/test/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jest.mock( '@wordpress/compose/src/utils/debounce', () => ( {
// Mock link suggestions that are fetched by the link picker
// when typing a search query.
jest.mock( '@wordpress/core-data/src/fetch', () => ( {
__experimentalFetchLinkSuggestions: jest.fn().mockResolvedValue( [ {} ] ),
fetchLinkSuggestions: jest.fn().mockResolvedValue( [ {} ] ),
} ) );

setupCoreBlocks();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jest.mock( '@wordpress/compose/src/utils/debounce', () => ( {
// Mock link suggestions that are fetched by the link picker
// when typing a search query.
jest.mock( '@wordpress/core-data/src/fetch', () => ( {
__experimentalFetchLinkSuggestions: jest.fn().mockResolvedValue( [ {} ] ),
fetchLinkSuggestions: jest.fn().mockResolvedValue( [ {} ] ),
} ) );

/**
Expand Down
44 changes: 44 additions & 0 deletions packages/core-data/src/deprecated.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* WordPress dependencies
*/
import deprecated from '@wordpress/deprecated';

/**
* Internal dependencies
*/
import { fetchLinkSuggestions } from './fetch';

/**
* Fetches link suggestions from the API.
*
* @async
* @param {string} search
* @param {import("./fetch/fetch-link-suggestions").SearchOptions} [searchOptions]
* @param {import("./fetch/fetch-link-suggestions").EditorSettings} [settings]
*
* @example
* ```js
* import { __experimentalFetchLinkSuggestions as fetchLinkSuggestions } from '@wordpress/core-data';
*
* //...
*
* export function initialize( id, settings ) {
*
* settings.__experimentalFetchLinkSuggestions = (
* search,
* searchOptions
* ) => fetchLinkSuggestions( search, searchOptions, settings );
* ```
* @return {Promise< import("./fetch/fetch-link-suggestions").SearchResult[] >} List of search suggestions
*/
export function __experimentalFetchLinkSuggestions(
search,
searchOptions,
settings
) {
deprecated( 'wp.coreData.__experimentalFetchLinkSuggestions', {
alternative: 'wp.coreData.fetchLinkSuggestions',
since: '6.7',
} );
return fetchLinkSuggestions( search, searchOptions, settings );
}

This file was deleted.

Loading
Loading