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
20 changes: 20 additions & 0 deletions packages/block-editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,26 @@ _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

### LinkControlSearchInput

Undocumented declaration.

### LinkControlSearchItem

Undocumented declaration.

### LinkControlSearchResults

Undocumented declaration.

### MediaPlaceholder

_Related_
Expand Down
20 changes: 16 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,22 @@ 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 {
default as LinkControlSearchInput,
DeprecatedExperimentalLinkControlSearchInput as __experimentalLinkControlSearchInput,
} from './link-control/search-input';
export {
default as LinkControlSearchResults,
DeprecatedExperimentalLinkControlSearchResults as __experimentalLinkControlSearchResults,
} from './link-control/search-results';
export {
default as LinkControlSearchItem,
DeprecatedExperimentalLinkControlSearchItem as __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 @@ -33,6 +33,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 @@ -499,4 +500,13 @@ function LinkControl( {
LinkControl.ViewerFill = ViewerFill;
LinkControl.DEFAULT_LINK_SETTINGS = DEFAULT_LINK_SETTINGS;

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

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

export default LinkControl;
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,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 @@ -163,4 +164,14 @@ const LinkControlSearchInput = forwardRef(
}
);

export const DeprecatedExperimentalLinkControlSearchInput = forwardRef(
( props, ref ) => {
deprecated( 'wp.blockEditor.__experimentalLinkControlSearchInput', {
since: '6.5',
alternative: 'wp.blockEditor.LinkControlSearchInput',
} );
return <LinkControlSearchInput { ...props } ref={ ref } />;
}
);

export default LinkControlSearchInput;
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 @@ -153,4 +154,13 @@ function getVisualTypeName( suggestion ) {
return suggestion.type === 'post_tag' ? 'tag' : suggestion.type;
}

export const DeprecatedExperimentalLinkControlSearchItem = ( props ) => {
deprecated( 'wp.blockEditor.__experimentalLinkControlSearchItem', {
since: '6.5',
alternative: 'wp.blockEditor.LinkControlSearchItem',
} );

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

export default LinkControlSearchItem;
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import classnames from 'classnames';
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( {
instanceId,
Expand Down Expand Up @@ -132,3 +133,11 @@ export default function LinkControlSearchResults( {
</div>
);
}

export const DeprecatedExperimentalLinkControlSearchResults = ( props ) => {
deprecated( 'wp.blockEditor.__experimentalLinkControlSearchResults', {
since: '6.5',
alternative: 'wp.blockEditor.LinkControlSearchResults',
} );
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 @@ -31,7 +31,7 @@ import {
__experimentalUseBorderProps as useBorderProps,
__experimentalUseColorProps as useColorProps,
__experimentalGetSpacingClassesAndStyles as useSpacingProps,
__experimentalLinkControl as LinkControl,
LinkControl,
__experimentalGetElementClassName,
store as blockEditorStore,
} from '@wordpress/block-editor';
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 @@ -5,7 +5,7 @@ import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
import { Popover, Button } from '@wordpress/components';
import { __, sprintf } from '@wordpress/i18n';
import {
__experimentalLinkControl as LinkControl,
LinkControl,
BlockIcon,
store as blockEditorStore,
} 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 {
concat,
} from '@wordpress/rich-text';
import {
__experimentalLinkControl as LinkControl,
LinkControl,
store as blockEditorStore,
} from '@wordpress/block-editor';
import { useSelect } from '@wordpress/data';
Expand Down
Loading