UNPKG

@wordpress/block-library

Version:
112 lines • 3.96 kB
interface SearchOptions { type: string; subtype?: string; } export interface SuggestionsQuery { preferTypes: (SearchOptions | string)[]; initialSuggestionsSearchOptions: SearchOptions & { perPage: number; }; } /** * Given the Link block's type attribute, return the query params to give to * /wp/v2/search. * * @param type Link block's type attribute. * @param kind Link block's entity of kind (post-type|taxonomy) * @return Search query params. */ export declare function getSuggestionsQuery(type?: string, kind?: string): SuggestionsQuery; /** * Check if a URL points to the site homepage. * Handles protocol (http/https) and trailing slash variations. * Does not match subdomains unless they are the site URL. * * @param url The URL to check * @param homeUrl The WordPress site URL * @return True if url is the homepage */ export declare function isHomepage(url?: string | null, homeUrl?: string): boolean; /** * Compute display URL - strips site URL if internal, shows full URL if external. * * @param options Parameters object * @param options.linkUrl The URL to process * @param options.homeUrl The WordPress site URL (required for internal/external detection) * @return Object with displayUrl and isExternal flag */ export declare function computeDisplayUrl({ linkUrl, homeUrl, }?: { linkUrl?: string | null; homeUrl?: string; }): { displayUrl: string; isExternal: boolean; }; export interface Badge { label: string; /** A `@wordpress/ui` `Badge` intent. */ intent: 'none' | 'high' | 'low' | 'stable' | 'informational'; } /** * Compute badges for the link preview. * * @param options Options object * @param options.url Link URL * @param options.homeUrl WordPress site URL (for homepage detection) * @param options.type Entity type (page, post, etc.) * @param options.isExternal Whether link is external * @param options.entityStatus Entity status (publish, draft, etc.) * @param options.hasBinding Whether link has entity binding * @param options.isEntityAvailable Whether bound entity exists * @return Array of badge objects with label and `@wordpress/ui` `Badge` intent */ export declare function computeBadges({ url, homeUrl, type, isExternal, entityStatus, hasBinding, isEntityAvailable, }: { url?: string | null; homeUrl?: string; type?: string | null; isExternal?: boolean; entityStatus?: string; hasBinding?: boolean; isEntityAvailable?: boolean; }): Badge[]; /** * The parts of an entity record the link preview reads. Posts and pages * expose `title` as a `{ raw, rendered }` object; terms use a plain `name`. */ export interface LinkPreviewEntityRecord { title?: string | { raw?: string; rendered?: string; }; name?: string; status?: string; featured_media?: number; } /** * Hook to compute link preview data for display. * * This hook takes raw link data and entity information and computes * presentation-ready preview data including formatted title, URL, and badges. * * @param options Options object * @param options.url Link URL * @param options.type Entity type (page, post, etc.) * @param options.entityRecord Entity record * @param options.hasBinding Whether link has entity binding * @param options.isEntityAvailable Whether bound entity exists * @return Preview data object with title, url, image, and badges */ export declare function useLinkPreview({ url, entityRecord, type, hasBinding, isEntityAvailable, }: { url?: string | null; entityRecord?: LinkPreviewEntityRecord | null; type?: string | null; hasBinding?: boolean; isEntityAvailable?: boolean; }): { title: any; url: string; image: string | null; badges: Badge[]; }; export {}; //# sourceMappingURL=link-picker.d.ts.map