react-client icon indicating copy to clipboard operation
react-client copied to clipboard

After adding a link, set the selection to the destination anchor instead of the text

Open AnomalRoil opened this issue 4 years ago • 3 comments

Which part of the project should be enhanced? The "add a link" feature from the editor.

Is your enhancement request related to a problem? Please describe. Whenever I'm writing a document and adding links to it, what I'm doing is usually switching from my tab to another tab, copying the URL of that tab, coming back to my HedgeDoc editor, selecting the text I want to linkify, clicking the link button and then it will add [](https://) around my selected text and I need to manually go and select the https:// and replace it with my copied data.

Describe the solution you'd like Instead of keeping the initial text selected it would be nice if https:// could be selected after adding a link. This is how the interface in Github is doing for example and is quite intuitive.

Describe alternatives you've considered Maybe have a popup asking for a link? I don't like popup too much.

Additional context This shouldn't be too difficult to tweak in there: https://github.com/hedgedoc/hedgedoc/blob/e8e9c9c1115527d9dc51a9b606f45122ac867fdb/public/js/lib/editor/utils.js#L58

AnomalRoil avatar Jul 13 '21 12:07 AnomalRoil

For version 2.0 we already implemented the link button like GitHub does it. Feel free to try it out for yourself on our UI-test page (no backend): https://ui-test.hedgedoc.org/n/features

For version 1.x we won't backport this.

ErikMichelson avatar Jul 14 '21 17:07 ErikMichelson

I just tried clicking on the URL link button on the UI-test page and it seems to be selecting both parenthesis, not the https:// anchor?

image

Trying to paste a link directly after clicking the button also didn't work, it seems the focus after clicking the link button isn't on the text edit box anymore.

AnomalRoil avatar Jul 14 '21 17:07 AnomalRoil

It seems there was a misunderstanding in our conversation:

If you select a URL and then press the anchor button, the selected URL will be used for the link target. If you select some text and then press the anchor button, the selected text will be used for the link description and the link target remains at https://.

Selecting the link target or link description after the button action seems like a good idea. 👍

ErikMichelson avatar Jul 18 '21 19:07 ErikMichelson