-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Only allow links to be created for selected text and fix CMD + K shortcut #58179
Only allow links to be created for selected text and fix CMD + K shortcut #58179
Conversation
@richtabor Shall we add an option to the command palette so that if you hit Cmd + K within a richtext then the first option in the command palette is create link? Possibly this should be a followup. |
Size Change: +26 B (0%) Total Size: 1.69 MB
ℹ️ View Unchanged
|
8ecc238
to
5775038
Compare
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core SVNCore Committers: Use this line as a base for the props when committing in SVN:
GitHub Merge commitsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
🚀 this fixes some bugs and it also makes the commend palette easier to get to. I think we should not do this tho. Inserting a link with no text selection is a feature which is useful to insert links to your content while in the flow of writing. In stand alone editors it exists too (Bear has it, Google docs has it) but it's less useful compared to when writing inside a CMS. In WP the fact that you can link directly to your content (or externally) while writing should not be considered a mere accident. WP also as a |
I think we should allow links to be created without having any selected text. |
I think there were some people that really wanted this to be possible, but I can't remember now. Also note that you can create almost any format without text selection, like bold etc., which is nice to be able to format as you type. Cmd+K is a standard shortcut for linking in every editor. |
I'm glad we had some more context here. So at least we know this was explored and rejected based on arguments above. |
What?
Currently it's possible to create a link in rich text when there is no text selection. This disables the ability to do that.
This has the nice (and intended) side effect of meaning the the Cmd + K shortcut will only be active if there is a text selection, thereby leaving it free to invoke the Command Palette.
Why?
Allowing links to be created from no text selection causes all manner of bugs and edge cases.
Moreover, it's annoying that the Link UI gets invoked when there is no text selection, when in most cases the user will have intended to invoke the Command Palette.
How?
Disables the ability to invoke the Link UI via UI or keyboard shortcut unless:
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast
Screen.Capture.on.2024-02-07.at.11-26-11.mp4