Skip to content

Commit 8e9b6e2

Browse files
authored
🤖 Merge PR DefinitelyTyped#74040 [@wordpress/block-editor] Add basic link control definitions by @Toberumono
1 parent 4cbffe5 commit 8e9b6e2

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

‎types/wordpress__block-editor/components/index.d.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export * from "./font-sizes";
1919
export { default as InnerBlocks, useInnerBlocksProps } from "./inner-blocks";
2020
export { default as InspectorAdvancedControls } from "./inspector-advanced-controls";
2121
export { default as InspectorControls } from "./inspector-controls";
22+
export { default as LinkControl } from "./link-control";
2223
export { default as MediaPlaceholder } from "./media-placeholder";
2324
export { default as MediaUpload } from "./media-upload";
2425
export { default as MediaUploadCheck } from "./media-upload/check";
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { ComponentType, ReactNode } from "react";
2+
3+
interface WPLinkControlDefaultValue {
4+
url?: string;
5+
title?: string;
6+
opensInNewTab?: boolean;
7+
}
8+
9+
interface WPLinkControlSettingsValue {
10+
[setting: string]: any;
11+
}
12+
13+
declare namespace LinkControl {
14+
interface Props {
15+
settings?: Setting[];
16+
forceIsEditingLink?: boolean;
17+
value?: Value;
18+
onChange?: (nextValue?: Value) => void;
19+
onRemove?: () => void;
20+
onCancel?: () => void;
21+
22+
noDirectEntry?: boolean;
23+
showSuggestions?: boolean;
24+
showInitialSuggestions?: boolean;
25+
withCreateSuggestion?: boolean;
26+
suggestionsQuery?: any;
27+
noURLSuggestion?: boolean;
28+
hasTextControl?: boolean;
29+
createSuggestion?: ((title: string) => Suggestion) | undefined;
30+
createSuggestionButtonText?: string | ((searchTerm: string | undefined) => ReactNode);
31+
renderControlBottom?: () => ReactNode;
32+
handleEntities?: boolean;
33+
hasRichPreviews?: boolean;
34+
}
35+
36+
interface Setting {
37+
id: string;
38+
title: string;
39+
}
40+
41+
interface Suggestion {
42+
id: string;
43+
type: string;
44+
title: string;
45+
url: string;
46+
}
47+
48+
interface Value extends WPLinkControlDefaultValue, WPLinkControlSettingsValue {}
49+
}
50+
declare const LinkControl: ComponentType<LinkControl.Props> & { DEFAULT_LINK_SETTINGS: LinkControl.Setting[] };
51+
52+
export default LinkControl;

‎types/wordpress__block-editor/wordpress__block-editor-tests.tsx‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,15 @@ be.withFontSizes("fontSize")(() => <h1>Hello World</h1>);
246246
<be.InspectorControls group={"styles"}>Hello World</be.InspectorControls>;
247247
<be.InspectorControls.Slot />;
248248

249+
//
250+
// link-control
251+
//
252+
<be.LinkControl
253+
onChange={item => console.log(item)}
254+
onRemove={() => console.log("removed")}
255+
settings={be.LinkControl.DEFAULT_LINK_SETTINGS}
256+
/>;
257+
249258
//
250259
// media-placeholder
251260
//

0 commit comments

Comments
 (0)