From 788cebad98d11379afa524ee3c2e59b061463b9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20K=C3=A4gy?= Date: Tue, 10 Dec 2024 14:48:00 +0100 Subject: [PATCH] Stabilize `LinkControl` Component (#56384) Co-authored-by: fabiankaegy Co-authored-by: youknowriad Co-authored-by: getdave Co-authored-by: Mamaduka Co-authored-by: ndiego --- packages/block-editor/README.md | 8 ++++++++ packages/block-editor/src/components/index.js | 11 +++++++---- .../src/components/link-control/index.js | 10 ++++++++++ .../src/components/link-control/search-input.js | 9 +++++++++ .../src/components/link-control/search-item.js | 9 +++++++++ .../src/components/link-control/search-results.js | 13 ++++++++++++- packages/block-library/src/button/edit.js | 2 +- .../block-library/src/navigation-link/link-ui.js | 2 +- packages/format-library/src/link/inline.js | 2 +- 9 files changed, 58 insertions(+), 8 deletions(-) diff --git a/packages/block-editor/README.md b/packages/block-editor/README.md index a0f75683914408..13dffce114f59a 100644 --- a/packages/block-editor/README.md +++ b/packages/block-editor/README.md @@ -659,6 +659,14 @@ _Related_ - +### 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. + ### MediaPlaceholder _Related_ diff --git a/packages/block-editor/src/components/index.js b/packages/block-editor/src/components/index.js index 29bb71b682e970..cf9167e4781576 100644 --- a/packages/block-editor/src/components/index.js +++ b/packages/block-editor/src/components/index.js @@ -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'; diff --git a/packages/block-editor/src/components/link-control/index.js b/packages/block-editor/src/components/link-control/index.js index 0f2ae4a0e05d26..74ee2dbfd9a7f0 100644 --- a/packages/block-editor/src/components/link-control/index.js +++ b/packages/block-editor/src/components/link-control/index.js @@ -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. @@ -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 ; +}; + export default LinkControl; diff --git a/packages/block-editor/src/components/link-control/search-input.js b/packages/block-editor/src/components/link-control/search-input.js index 3f109b8a371552..2debdec296d948 100644 --- a/packages/block-editor/src/components/link-control/search-input.js +++ b/packages/block-editor/src/components/link-control/search-input.js @@ -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 @@ -156,3 +157,11 @@ const LinkControlSearchInput = forwardRef( ); export default LinkControlSearchInput; + +export const __experimentalLinkControlSearchInput = ( props ) => { + deprecated( 'wp.blockEditor.__experimentalLinkControlSearchInput', { + since: '6.8', + } ); + + return ; +}; diff --git a/packages/block-editor/src/components/link-control/search-item.js b/packages/block-editor/src/components/link-control/search-item.js index fa8d1540b3daed..27084e5e77b96a 100644 --- a/packages/block-editor/src/components/link-control/search-item.js +++ b/packages/block-editor/src/components/link-control/search-item.js @@ -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, @@ -160,3 +161,11 @@ function getVisualTypeName( suggestion ) { } export default LinkControlSearchItem; + +export const __experimentalLinkControlSearchItem = ( props ) => { + deprecated( 'wp.blockEditor.__experimentalLinkControlSearchItem', { + since: '6.8', + } ); + + return ; +}; diff --git a/packages/block-editor/src/components/link-control/search-results.js b/packages/block-editor/src/components/link-control/search-results.js index 29558f69291c57..6b405b0df1770c 100644 --- a/packages/block-editor/src/components/link-control/search-results.js +++ b/packages/block-editor/src/components/link-control/search-results.js @@ -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, @@ -121,3 +122,13 @@ export default function LinkControlSearchResults( { ); } + +export default LinkControlSearchResults; + +export const __experimentalLinkControlSearchResults = ( props ) => { + deprecated( 'wp.blockEditor.__experimentalLinkControlSearchResults', { + since: '6.8', + } ); + + return ; +}; diff --git a/packages/block-library/src/button/edit.js b/packages/block-library/src/button/edit.js index 3539fd54f4eece..2106c2031491fe 100644 --- a/packages/block-library/src/button/edit.js +++ b/packages/block-library/src/button/edit.js @@ -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, diff --git a/packages/block-library/src/navigation-link/link-ui.js b/packages/block-library/src/navigation-link/link-ui.js index ee238c71ed28e0..52db034c6f980c 100644 --- a/packages/block-library/src/navigation-link/link-ui.js +++ b/packages/block-library/src/navigation-link/link-ui.js @@ -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'; diff --git a/packages/format-library/src/link/inline.js b/packages/format-library/src/link/inline.js index 3d2ee57567dc13..964e9a4271dda9 100644 --- a/packages/format-library/src/link/inline.js +++ b/packages/format-library/src/link/inline.js @@ -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';