-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
[Feature] Keyboard Shortcut for Hyperlink #1729
[Feature] Keyboard Shortcut for Hyperlink #1729
Conversation
Will allow code changes in a subsequent commit to access the function and utilize the same core logic
Use the conventional Ctrl+K keyboard shortcut for adding a hyperlink
const setLink = useCallback(() => { | ||
const previousUrl = editor.getAttributes("link").href; | ||
const url = window.prompt("URL", previousUrl); | ||
const setLinkGlobal = (editor: Editor) => { |
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.
I'm open to changing the naming of this function if desired, I just decided to leave Toolbar.setLink
as-is to keep the diff
of this PR low for now.
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.
I actually don't mind if the code is refactored to be inside Toolbar, and within a useCallback. Would be neater that way. I can take it from here and make the necessary changes.
Thank you for this quick helpful fix.
return { | ||
"Mod-k": () => { | ||
setLinkGlobal(this.editor as Editor); | ||
return true; |
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.
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 219e699. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 4 targetsSent with 💌 from NxCloud. |
#1728
The Rich Text Editor already has common keyboard shortcuts such as:
Mod-B
: BoldMod-I
: ItalicsMod-U
: Underline(Where
Mod
is the term used to refer tocmd
forMac
devices, andCtrl
for all others in the Tiptap documentation)This PR adds
Mod-K
for adding a hyperlink when using the Rich Text Editor