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

Stabilize LinkControl Component #56384

Merged
merged 9 commits into from
Dec 10, 2024
8 changes: 8 additions & 0 deletions packages/block-editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,14 @@ _Related_

- <https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/line-height-control/README.md>

### LinkControl

Renders a link control. A link control is a controlled input which maintains a value associated with a link (HTML anchor element) and relevant settings for how that link is expected to behave.

_Parameters_

- _props_ `WPLinkControlProps`: Component props.
fabiankaegy marked this conversation as resolved.
Show resolved Hide resolved

### MediaPlaceholder

_Related_
Expand Down
11 changes: 7 additions & 4 deletions packages/block-editor/src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,13 @@ export {
JustifyToolbar,
JustifyContentControl,
} from './justify-content-control';
export { default as __experimentalLinkControl } from './link-control';
export { default as __experimentalLinkControlSearchInput } from './link-control/search-input';
export { default as __experimentalLinkControlSearchResults } from './link-control/search-results';
export { default as __experimentalLinkControlSearchItem } from './link-control/search-item';
export {
default as LinkControl,
DeprecatedExperimentalLinkControl as __experimentalLinkControl,
} from './link-control';
export { __experimentalLinkControlSearchInput } from './link-control/search-input';
export { __experimentalLinkControlSearchResults } from './link-control/search-results';
export { __experimentalLinkControlSearchItem } from './link-control/search-item';
export { default as LineHeightControl } from './line-height-control';
export { default as __experimentalListView } from './list-view';
export { default as MediaReplaceFlow } from './media-replace-flow';
Expand Down
10 changes: 10 additions & 0 deletions packages/block-editor/src/components/link-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import useCreatePage from './use-create-page';
import useInternalValue from './use-internal-value';
import { ViewerFill } from './viewer-slot';
import { DEFAULT_LINK_SETTINGS } from './constants';
import deprecated from '@wordpress/deprecated';

/**
* Default properties associated with a link control value.
Expand Down Expand Up @@ -500,4 +501,13 @@ function LinkControl( {
LinkControl.ViewerFill = ViewerFill;
LinkControl.DEFAULT_LINK_SETTINGS = DEFAULT_LINK_SETTINGS;

export const DeprecatedExperimentalLinkControl = ( props ) => {
deprecated( 'wp.blockEditor.__experimentalLinkControl', {
since: '6.8',
alternative: 'wp.blockEditor.LinkControl',
} );

return <LinkControl { ...props } />;
};

export default LinkControl;
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { URLInput } from '../';
import LinkControlSearchResults from './search-results';
import { CREATE_TYPE } from './constants';
import useSearchHandler from './use-search-handler';
import deprecated from '@wordpress/deprecated';

// Must be a function as otherwise URLInput will default
// to the fetchLinkSuggestions passed in block editor settings
Expand Down Expand Up @@ -156,3 +157,11 @@ const LinkControlSearchInput = forwardRef(
);

export default LinkControlSearchInput;

export const __experimentalLinkControlSearchInput = ( props ) => {
deprecated( 'wp.blockEditor.__experimentalLinkControlSearchInput', {
since: '6.8',
} );

return <LinkControlSearchInput { ...props } />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
import { safeDecodeURI, filterURLForDisplay, getPath } from '@wordpress/url';
import { pipe } from '@wordpress/compose';
import deprecated from '@wordpress/deprecated';

const ICONS_MAP = {
post: postList,
Expand Down Expand Up @@ -160,3 +161,11 @@ function getVisualTypeName( suggestion ) {
}

export default LinkControlSearchItem;

export const __experimentalLinkControlSearchItem = ( props ) => {
deprecated( 'wp.blockEditor.__experimentalLinkControlSearchItem', {
since: '6.8',
} );

return <LinkControlSearchItem { ...props } />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import clsx from 'clsx';
import LinkControlSearchCreate from './search-create-button';
import LinkControlSearchItem from './search-item';
import { CREATE_TYPE, LINK_ENTRY_TYPES } from './constants';
import deprecated from '@wordpress/deprecated';

export default function LinkControlSearchResults( {
function LinkControlSearchResults( {
withCreateSuggestion,
currentInputValue,
handleSuggestionClick,
Expand Down Expand Up @@ -121,3 +122,13 @@ export default function LinkControlSearchResults( {
</div>
);
}

export default LinkControlSearchResults;

export const __experimentalLinkControlSearchResults = ( props ) => {
deprecated( 'wp.blockEditor.__experimentalLinkControlSearchResults', {
since: '6.8',
} );

return <LinkControlSearchResults { ...props } />;
};
2 changes: 1 addition & 1 deletion packages/block-library/src/button/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ import {
InspectorControls,
RichText,
useBlockProps,
LinkControl,
__experimentalUseBorderProps as useBorderProps,
__experimentalUseColorProps as useColorProps,
__experimentalGetSpacingClassesAndStyles as useSpacingProps,
__experimentalGetShadowClassesAndStyles as useShadowProps,
__experimentalLinkControl as LinkControl,
__experimentalGetElementClassName,
store as blockEditorStore,
useBlockEditingMode,
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/navigation-link/link-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from '@wordpress/components';
import { __, sprintf, isRTL } from '@wordpress/i18n';
import {
__experimentalLinkControl as LinkControl,
LinkControl,
store as blockEditorStore,
privateApis as blockEditorPrivateApis,
} from '@wordpress/block-editor';
Expand Down
2 changes: 1 addition & 1 deletion packages/format-library/src/link/inline.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
useAnchor,
} from '@wordpress/rich-text';
import {
__experimentalLinkControl as LinkControl,
LinkControl,
store as blockEditorStore,
} from '@wordpress/block-editor';
import { useDispatch, useSelect } from '@wordpress/data';
Expand Down
Loading