-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Block Editor: Add settings to enable/disable auto anchor generation #38780
Conversation
Size Change: +61 B (0%) Total Size: 1.15 MB
ℹ️ View Unchanged
|
Do we want to enable this feature in tests, or should I re-generate the fixtures? |
I'm still unsure about whether this should be opt-in or opt-out 🤔 |
Considering feedback, we might want to make this opt-in in 5.9.x and then opt-out when UX is more polished. @youknowriad, @jasmussen, @priethor What do you think? |
Without a UI, it seems safest to start conservative, opt-in by default, and then we can make it opt-out if/when a UI surfaces for it. I want to note that's not at all a strong opinion and I'll defer to someone who has one. |
I think that ideally, it would be opt-out for latin languages (with some basic transliteration to remove accents etc), and opt-in for non-latin languages like Mandarin, Greek, Arabic etc where we've seen most issues. |
I think this is the most viable option to be backported into a minor release. We can work on UI and smart default for 6.0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following the discussion in the comments above, I'll go ahead and pre-approve this (pending re-generation of the fixtures to fix failing tests)
66ad596
to
4d36fc2
Compare
Thanks for the feedback, folks. Let's try to polish UI/UX for this feature before 6.0. I'm going to merge this PR and backport it to a minor release. |
…38780) * Block Editor: Add settings to enable/disable auto anchor generation * Fix deps * Update snapshots
Ok so you have gone to opt-out by default. But where do I go to opt in? A feature I liked has been disabled, and I have looked in all the seemingly obvious places to re-enable it. |
Hi, @shuttermuse Currently, there's no UI to enable the feature back, but we'll try to ship this in a future version of WordPress. Meanwhile, to enable it, you'll need to place the following snippet in add_filter(
'block_editor_settings_all',
static function( $settings ) {
$settings['__experimentalGenerateAnchors'] = true;
return $settings;
}
); |
@Mamaduka Thanks for the code snippet! I was tearing my hair out trying to find the UI option. |
For future reference: it also seems like it should be turned on automatically in the context of a post that uses the table of contents block. |
For anyone googling how to turn this back on - add_filter( 'block_editor_settings_all', function( $editor_settings, $editor_context ) {
$editor_settings['generateAnchors'] = true;
return $editor_settings;
}, 10, 2 ); |
In WordPress 5.9, auto-generation of anchors for headings was switched on. However, in 5.9.1 this was changed to an option you need to explicitly opt into: WordPress/gutenberg#38780 We need anchors for the heading blocks to always be generated, so that we can use those anchors for in-page nav. The suggestion is that this will become opt-out once a UI is available for these kind of options, probably in WordPress 6.0. So there doesn't seem to be any significant risk of this functionality being removed in future, despite it currently being labelled experimental.
In WordPress 5.9, auto-generation of anchors for headings was switched on. However, in 5.9.1 this was changed to an option you need to explicitly opt into: WordPress/gutenberg#38780 We need anchors for the heading blocks to always be generated, so that we can use those anchors for in-page nav. The suggestion is that this will become opt-out once a UI is available for these kind of options, probably in WordPress 6.0. So there doesn't seem to be any significant risk of this functionality being removed in future, despite it currently being labelled experimental.
Thx! |
Description
Resolves #38171.
This PR introduces new block editor settings -
__experimentalGenerateAnchors
and makes automatic anchor generation opt-in.Why use block editor settings instead of Preferences?
Most of the Preferences are saved in the
edit-post
packages store. As we don't want to make theblock-library
package dependent onedit-post
this was the most viable option.Testing Instructions
Types of changes
Enhancement
Checklist:
*.native.js
files for terms that need renaming or removal).