Question: How can I change highlighted text into link tags with modifier keys?
See original GitHub issueSo I want to be able to add a link to a highlighted text, similar to the example on Link on the website, and that one is pretty straightforward. However I also want to add Cmd+K
as a keyboard hotkey to bring up the same prompt menu.
I tried to extend the current Link and then adding my own keys
, which made the hotkey work, however I couldn’t figure out how to actually turn the highlighted node into a link node (the example on the website uses the commands
from Editor, which I don’t get access to inside keys
). Any help here?
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
SwiftUI: is there exist modifier to highlight substring of Text ...
It's noteworthy here that NSAttributedString is just "an string annotated by attributes over ranges." It's not "a styled string." We can make up ......
Read more >CSS Basics: Styling Links Like a Boss
Here is the same link we have been looking at. First, try hovering your mouse on top of it without clicking and notice...
Read more >Chapter 4: Reading text - Microsoft Support
Learn about how to read text using Narrator in Windows, including how to get info ... Tip: The Narrator key is a modifier...
Read more >Video: Create accessible links in Word - Microsoft Support
Right-click to open the context menu, then find and select Edit Hyperlink. In the dialog box, look for a text box labeled Text...
Read more >Find and Replace text in InDesign - Adobe Support
Click the Special Characters For Search icon to the right of the Find What option and choose options from the Locations, Repeat, Match, ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@philippkuehn that’s amazing! Couldn’t figure out how to use the selections to setNodeMarkup referred to the doc here but wasn’t sure how to actually use it, but using
editor
directly worked perfectly! It’s basically doing the exact same thing as what the menubar is doing.Here’s my piece of code that worked if anyone else is struggling:
Thanks for the help 😃
state, dispatch, view
are all given as arguments to keys. Using state.selection, you should be able to the position of the highlighted node, and then usetr.setNodeMarkup
to apply the link mark to the node.