PluginProbe
Extendify / 3.2.1
Extendify v3.2.1
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
extendify / src / QuickEdit / lib / link-suggestions.js

link-suggestions.js in Extendify 3.2.1, at src/QuickEdit/lib/link-suggestions.js

23 lines 790 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 // BlockEditorProvider's sub-registry doesn't inherit core's default
2 // __experimentalFetchLinkSuggestions; pass this in via settings or the
3 // LinkControl falls back to treating the search term as a literal URL.
4 import apiFetch from '@wordpress/api-fetch';
5
6 export function fetchLinkSuggestions(search, opts = {}) {
7 const params = new URLSearchParams();
8 params.set('search', search || '');
9 params.set('per_page', String(opts.perPage || 10));
10 if (opts.type) params.set('type', opts.type);
11 if (opts.subtype) params.set('subtype', opts.subtype);
12 return apiFetch({ path: `/wp/v2/search?${params.toString()}` }).then(
13 (results) =>
14 (results || []).map((r) => ({
15 id: r.id,
16 url: r.url,
17 title: r.title || r.url,
18 type: r.subtype || r.type,
19 kind: r.type,
20 })),
21 );
22 }
23