Idea: Paste links in the editor

Hey guys. If any of you uses WordPress, will know what I’m talking about. For others… I’ll explain.

So, in the WordPress editor, if you select a text and you press CTRL+V, it will do one of the following:

  • if the clipboard content is a valid url, it will insert the link with the selected text as anchor;
  • if the clipboard content is not a valid url, it will just overwrite the selected text.

I think it would be nice to just skip few steps (CTRL+K + CTRL+V + enter).

Any chance that this would be implemented on Discourse? :slight_smile:

(also, what’s up with the undo? it’s simply broken if you use any toolbar/shortcut)

「いいね!」 4

Er… what? That sounds confusing. I’m confused! What would that do?

Alright, so I’ve made a short video:

Obviously enough, this should insert markdown instead.

「いいね!」 5

This is something I really enjoy in wordpress too, and miss in discourse on a daily basis. It allows you to write a whole bunch of text, then go through adding hyperlinks extremely quickly and naturally.

「いいね!」 2

I’m not sure, what do you think @eviltrout — this could be unexpected. And we already have an insert hyperlink toolbar button.

「いいね!」 1

The flow with the link button is this:

  1. Select the text
  2. Click the button (or press ctrl+k)
  3. Paste the link
  4. Click OK (or press enter

With the functionality I proposed, you kind of half the whole process, as you only select then paste. If no text is selected, the paste will work as usual (i.e. just insert the clipboard text).

「いいね!」 3

In every editor I know of, if you jselect some text and paste from a clipboard, that text is overwritten by what’s in the clipboard. What you are suggesting would do away with the existing function of replace text with what’s in the clipboard.

  • Not selecting any text and pasting from clipboard is a simple PASTE action.
  • Selecting text and pasting from a clipboard is a REPLACE TEXT action with what is in the clipboard.

Inserting hyperlink - using the already supplied button - is the easiest way to insert a link in whatever text you select by selecting the text first.
Inserting a hyperlink without text is clicking on the button, paste the link, click okay or hit enter or by just typing or pasting a link to a blank space.

I don’t see why you would want to take the universal Select & Replace Text function and convert that into what the existing button already does without losing that function common to all text editors. What would happen if you wanted to replace text with other text if you lose the Select & Replace function?

In Wordpress, what determines whether the text is replaced with what’s in the clipboard or inserts a hyperlink without overwriting the existing text using a simple select & paste as you suggest? Surely a simple highlighting of text and clicking paste cannot perform both functions or do one function without losing the other.

Or am I missing something?

As is already in Discourse, typing in or pasting a URL does turn it into a clickable link without having to use the Insert Link feature. Then you have the Onebox feature. And you have the Insert Link button already.

Paste inserts text.
Select and paste replaces the text.
Select and delete/back space deletes the text.

These are common functions of all text editors.

「いいね!」 2

A combination of clipboard content and editor state:

  • If cliboard content is not a valid URL: the paste will act just as you said (replace any selected text or append it at the cursor otherwise)
  • If the clipboard is an URL and:
    • no text selected: the URL will be inserted at the cursor position
    • text selected: use that text as an anchor text.

Considering that there are a few other things that doesn’t quite work as other editors (cough, cough), I’m pretty sure it wouldn’t be such a big problem for users :slight_smile:

「いいね!」 1

I’m not against it but I also haven’t heard of anyone else asking for it. It seems fairly niche.

「いいね!」 4

I think it’s one of those things you don’t know you need until you actually got it.

(I would try to do it myself as a plugin or something, but for some reasons I can’t start discourse docker dev env on windows)

「いいね!」 4

I strongly recommend WSL-2 here, and our official docker setup, easiest way to get started on Windows.

Also … you don’t even need a full dev environment, you could experiment on theme creator, this can be built as a theme component.

「いいね!」 2

Meanwhile I’ve figured out what I was doing wrong (and updated the post to prevent others persist in my mistake), now I can run it, but I have no spare time. Maybe in the near future :slight_smile:

「いいね!」 1

I didn’t even know Wordpress or anything else did this, so wouldn’t have thought of asking, but it would be handy, and likely wouldn’t cause huge surprises (I’ve never tried to overwrite any text with a URL, and if I were to then I’d understand what was happening).

「いいね!」 3

Honestly it’s just such a lovely feature in wordpress. Hypertext is a great thing, and foundational concept for the web, of course… but going back adding 10 links to a post is really irritating unless you can simply copy and paste them. So I don’t bother, unless I’m using wordpress. There should really be no surprise that pasting a link creates a link.

「いいね!」 1

I just tried this in the zettlr editor, it doesn’t have the wordpress paste-to-create-link but does have similar behaviour for ctrl-k… With an URL in the clipboard, you …

  • select text
  • press ctrl-k

… and that’s it, the text becomes a link. Alternatively you can right-click to add a link. In discourse you have to:

  • select text
  • press ctrl-k
  • press ctrl-v
  • press enter

This really breaks the flow of marking up some text.

I’m not sure if browser security would let you paste with ctrl-k, but really I think the wordpress behaviour is perfect.

edit I’ve noticed that slack has the same link-on-paste behaviour as wordpress, so that’s another well-used UI to embrace this feature.

「いいね!」 3

UX: pasting links on a selection will apply a link format by gwwar · Pull Request #15010 · discourse/discourse · GitHub に PR を追加しました

「いいね!」 23

おかえりなさい、ありがとうございます!久しぶりですね!

「いいね!」 6

WordPressでいつもこうしています。まず文全体、あるいは段落全体を書き、その後もう一度見直して単語やフレーズをリンクに変換します。

「いいね!」 2

私も同じです。コンテンツ作成がずっと簡単になります。

WordPressのようなCMSはフォーラムとは少し違うことは承知していますが、コンピューター対タブレット対電話のように、それらの境界線は消えつつあります。

私にとって、この質問は非常に簡単です。UXと使いやすさの問題ですが、開発者が異なる見方をするのであれば、それは可能です。

炎上を狙っているわけではありませんが、開発者は時々エンドユーザーを忘れ、使い慣れた方法で物事を行ってしまうことがあります :wink:

「いいね!」 1

これはマージされました!

  • URLをカットする
  • Discourseコンポーザーで単語を選択する
  • URLを貼り付ける
  • 単語がリンクになる…魔法 :woman_mage: :mage:

gwwarさんに感謝します ← @gwwarさんのペーストトリックで簡単に作成できました

これはかなりクールだと思います。存在を知るのは非常に難しいですが、存在を知った今、時々このトリックを使うでしょう。

「いいね!」 21