Move __experimentalFetchLinkSuggestions
to core/data
store.
#32087
Labels
[Feature] Link Editing
Link components (LinkControl, URLInput) and integrations (RichText link formatting)
[Package] Core data
/packages/core-data
[Type] Experimental
Experimental feature or API.
Following the discussion in #31416 (comment)_ let's discuss the possibility of moving
__experimentalFetchLinkSuggestions
to thecore-data
package store.Update: I gave this a go over here #32096.
Rationale
All of the implementations currently in use today in the various
edit*
packages defer theirfetchLinkSuggestions
functionality to the centralfetchLinkSuggestions
fromcore-data
.Post Editor
gutenberg/packages/editor/src/components/provider/use-block-editor-settings.js
Lines 11 to 15 in 79cb3eb
Widgets Editor
gutenberg/packages/edit-widgets/src/index.js
Line 14 in 79cb3eb
Site Editor
gutenberg/packages/edit-site/src/index.js
Line 9 in 79cb3eb
Navigation Editor
gutenberg/packages/edit-navigation/src/index.js
Line 9 in 79cb3eb
As this function fetches data from Core WP and is WordPress specific I'd like to understand why
core-data
would not be a good fit for this?Indeed the README says:
Possible Problems
The only issue I see is how this function is currently wired up to the
<LinkControl>
component which resides in@packages/block-editor
.To avoid coupling the block-editor to WordPress specific functionality it currently uses
getSettings()
to retrieve the__experimentalFetchLinkSuggestions
function.gutenberg/packages/block-editor/src/components/link-control/use-search-handler.js
Lines 112 to 118 in 79cb3eb
Whilst this function is not actually available in
core/block-editor
it is made available in other packages (as shown above) by overloading the editor settings.Typically what happens is something akin to the following:
If we make
__experimentalFetchLinkSuggestions
a first class API incore/data
then how can we still ensure@wordpress/block-editor
's<LinkControl>
is not coupled to WordPress?Similar examples
In #31464 I'm adding the ability to fetch rich meta data about an entry. I want to use this in
<LinkControl>
but I don't want to couple that component to a WordPress specific implementation.Again, we need a way to make calls to REST API endpoints but still allow them to be overloaded on a per editor basis.
cc @gwwar @adamziel @youknowriad @gziolo
The text was updated successfully, but these errors were encountered: