# Idea: Paste links in the editor

**URL:** https://meta.discourse.org/t/idea-paste-links-in-the-editor/47125
**Category:** UX
**Tags:** pr-welcome
**Created:** [11 juli 2016 om 20:57 UTC](https://meta.discourse.org/t/idea-paste-links-in-the-editor/47125 "2016-07-11T20:57:37Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![iamntz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/iamntz/32/114670_2.png) [@iamntz](https://meta.discourse.org/u/iamntz)
#### Post date: [11 juli 2016 om 20:57 UTC](https://meta.discourse.org/t/idea-paste-links-in-the-editor/47125/1 "2016-07-11T20:57:38Z")

</div>

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? 🙂

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

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [11 juli 2016 om 21:00 UTC](https://meta.discourse.org/t/idea-paste-links-in-the-editor/47125/2 "2016-07-11T21:00:17Z")

</div>

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

---

<div class="post-metadata">

### Author: ![iamntz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/iamntz/32/114670_2.png) [@iamntz](https://meta.discourse.org/u/iamntz)
#### Post date: [11 juli 2016 om 21:17 UTC](https://meta.discourse.org/t/idea-paste-links-in-the-editor/47125/3 "2016-07-11T21:17:40Z")

</div>

Alright, so I’ve made a short video:

> **[Ionuț Staicu](https://ionutstaicu.com/)**

Obviously enough, this should insert markdown instead.

---

<div class="post-metadata">

### Author: ![yaxu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yaxu/32/178942_2.png) [@yaxu](https://meta.discourse.org/u/yaxu)
#### Post date: [20 januari 2021 om 19:35 UTC](https://meta.discourse.org/t/idea-paste-links-in-the-editor/47125/4 "2021-01-20T19:35:12Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [21 januari 2021 om 06:27 UTC](https://meta.discourse.org/t/idea-paste-links-in-the-editor/47125/5 "2021-01-21T06:27:49Z")

</div>

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

---

<div class="post-metadata">

### Author: ![iamntz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/iamntz/32/114670_2.png) [@iamntz](https://meta.discourse.org/u/iamntz)
#### Post date: [21 januari 2021 om 07:09 UTC](https://meta.discourse.org/t/idea-paste-links-in-the-editor/47125/6 "2021-01-21T07:09:25Z")

</div>

> [@codinghorror](#):
>
> And we already have an insert hyperlink toolbar button.

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).

---

<div class="post-metadata">

### Author: ![JimPas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jimpas/32/148179_2.png) [@JimPas](https://meta.discourse.org/u/JimPas)
#### Post date: [21 januari 2021 om 07:42 UTC](https://meta.discourse.org/t/idea-paste-links-in-the-editor/47125/7 "2021-01-21T07:42:40Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![iamntz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/iamntz/32/114670_2.png) [@iamntz](https://meta.discourse.org/u/iamntz)
#### Post date: [21 januari 2021 om 08:48 UTC](https://meta.discourse.org/t/idea-paste-links-in-the-editor/47125/8 "2021-01-21T08:48:26Z")

</div>

> [@JimPas](#):
>
> 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?

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](https://meta.discourse.org/t/undo-ctrl-cmd-z-doesnt-work-for-markdown/51026), [cough](https://meta.discourse.org/t/editor-markup-issues-when-toggling-text-attributes/49957)), I’m pretty sure it wouldn’t be such a big problem for users 🙂

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [21 januari 2021 om 17:31 UTC](https://meta.discourse.org/t/idea-paste-links-in-the-editor/47125/9 "2021-01-21T17:31:59Z")

</div>

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

---

<div class="post-metadata">

### Author: ![iamntz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/iamntz/32/114670_2.png) [@iamntz](https://meta.discourse.org/u/iamntz)
#### Post date: [22 januari 2021 om 05:23 UTC](https://meta.discourse.org/t/idea-paste-links-in-the-editor/47125/10 "2021-01-22T05:23:11Z")

</div>

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)_

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [29 januari 2021 om 01:35 UTC](https://meta.discourse.org/t/idea-paste-links-in-the-editor/47125/11 "2021-01-29T01:35:38Z")

</div>

> [@iamntz](#):
>
> I can’t start discourse docker dev env on windows

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.

---

<div class="post-metadata">

### Author: ![iamntz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/iamntz/32/114670_2.png) [@iamntz](https://meta.discourse.org/u/iamntz)
#### Post date: [29 januari 2021 om 07:19 UTC](https://meta.discourse.org/t/idea-paste-links-in-the-editor/47125/12 "2021-01-29T07:19:12Z")

</div>

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 🙂

---

<div class="post-metadata">

### Author: ![Jonathan5](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jonathan5/32/197134_2.png) [@Jonathan5](https://meta.discourse.org/u/Jonathan5)
#### Post date: [29 januari 2021 om 10:34 UTC](https://meta.discourse.org/t/idea-paste-links-in-the-editor/47125/13 "2021-01-29T10:34:11Z")

</div>

> [@eviltrout](#):
>
> I’m not against it but I also haven’t heard of anyone else asking for it. It seems fairly niche.

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).

---

<div class="post-metadata">

### Author: ![yaxu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yaxu/32/178942_2.png) [@yaxu](https://meta.discourse.org/u/yaxu)
#### Post date: [23 mei 2021 om 15:08 UTC](https://meta.discourse.org/t/idea-paste-links-in-the-editor/47125/14 "2021-05-23T15:08:26Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![yaxu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yaxu/32/178942_2.png) [@yaxu](https://meta.discourse.org/u/yaxu)
#### Post date: [12 juni 2021 om 08:04 UTC](https://meta.discourse.org/t/idea-paste-links-in-the-editor/47125/15 "2021-06-12T08:04:11Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![gwwar](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gwwar/32/116586_2.png) [@gwwar](https://meta.discourse.org/u/gwwar)
#### Post date: [18 november 2021 om 19:59 UTC](https://meta.discourse.org/t/idea-paste-links-in-the-editor/47125/16 "2021-11-18T19:59:33Z")

</div>

I’ve added a PR for this in [UX: pasting links on a selection will apply a link format by gwwar · Pull Request #15010 · discourse/discourse · GitHub](https://github.com/discourse/discourse/pull/15010)

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [26 november 2021 om 20:25 UTC](https://meta.discourse.org/t/idea-paste-links-in-the-editor/47125/17 "2021-11-26T20:25:49Z")

</div>

Oh wow! Welcome back and thank you! It’s been a while!

---

<div class="post-metadata">

### Author: ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)
#### Post date: [27 november 2021 om 10:48 UTC](https://meta.discourse.org/t/idea-paste-links-in-the-editor/47125/18 "2021-11-27T10:48:01Z")

</div>

I’m using this in WordPress all the time. I first write the whole sentence, or even a paragraph, then make another pass and convert words/phrases into links.

---

<div class="post-metadata">

### Author: ![Jagster](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagster/32/192154_2.png) [@Jagster](https://meta.discourse.org/u/Jagster)
#### Post date: [27 november 2021 om 12:58 UTC](https://meta.discourse.org/t/idea-paste-links-in-the-editor/47125/19 "2021-11-27T12:58:37Z")

</div>

Same here. Much more easier to create content.

I know CMSes, as WordPress, is a bit different than foruma, but those borders are disappearing, like computers vs. tablets vs. phones.

For me the question is quite easy: it is matter of UX and easiness, but if devs see things differently is possible.

I don’t try to start any flaming, but every now and then devs are forgetting end users and doing things as they are used to 😉

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [29 november 2021 om 05:57 UTC](https://meta.discourse.org/t/idea-paste-links-in-the-editor/47125/20 "2021-11-29T05:57:53Z")

</div>

This is now merged!

- Cut a URL
- Select a word in Discourse composer
- Paste URL
- Word becomes a link… Magic 🧙‍♀️🧙

Big thank you [gwwar](https://meta.discourse.org/t/idea-paste-links-in-the-editor/47125/16) ← That was easily created using the paste trick @gwwar!

I find this quite cool, very hard to learn about it existing, but now that I know it exists I will certainly use the trick on occasion

[Volgende pagina](https://meta.discourse.org/t/idea-paste-links-in-the-editor/47125.md?page=2)
