# Selected text is overwritten when using the link toolbar action

**URL:** https://meta.discourse.org/t/selected-text-is-overwritten-when-using-the-link-toolbar-action/75515
**Category:** Bug
**Created:** [December 6, 2017, 11:45am UTC](https://meta.discourse.org/t/selected-text-is-overwritten-when-using-the-link-toolbar-action/75515 "2017-12-06T11:45:14Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![terraboss](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/terraboss/32/381157_2.png) [@terraboss](https://meta.discourse.org/u/terraboss)
#### Post date: [December 6, 2017, 11:45am UTC](https://meta.discourse.org/t/selected-text-is-overwritten-when-using-the-link-toolbar-action/75515/1 "2017-12-06T11:45:14Z")

</div>

Hello,

Since the latest github commits, it seems, there is something broken. Workaround:

By selecting a few words and trying to insert a hyperlink with the symbol bar icon, I’ve got a problem: The link I’ve copied before will overwrite the selected text, insted of filling the text field of the hyperlink prompt.

Result:  
If I wrote more than just a few words and overwrite them, they will be lost for ever! I can’t undo this to restore my text. :sadpanda:

---

<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: [December 6, 2017, 11:49am UTC](https://meta.discourse.org/t/selected-text-is-overwritten-when-using-the-link-toolbar-action/75515/2 "2017-12-06T11:49:34Z")

</div>

> [@terraboss](#):
>
> By selecting a few words and trying to insert a hyperlink with the symbol bar icon, I’ve got a problem: The link I’ve copied before will overwrite the selected text, insted of filling the text field of the hyperlink prompt.

Aha that does seem like a regression, but the temporary workaround is to not do that for now. How is this “urgent”?

---

<div class="post-metadata">

### Author: ![terraboss](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/terraboss/32/381157_2.png) [@terraboss](https://meta.discourse.org/u/terraboss)
#### Post date: [December 6, 2017, 11:52am UTC](https://meta.discourse.org/t/selected-text-is-overwritten-when-using-the-link-toolbar-action/75515/4 "2017-12-06T11:52:11Z")

</div>

> [@codinghorror](#):
>
> How is this “urgent”?

I would say, the link prompt is one of the most important functions at our Discourse instance. Especially for mobile / tablet users.

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [December 6, 2017, 11:54am UTC](https://meta.discourse.org/t/selected-text-is-overwritten-when-using-the-link-toolbar-action/75515/5 "2017-12-06T11:54:03Z")

</div>

Hello Markus,

I am able to understand the issue now. I am checking it. Thanks for reporting it.

---

<div class="post-metadata">

### Author: ![terraboss](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/terraboss/32/381157_2.png) [@terraboss](https://meta.discourse.org/u/terraboss)
#### Post date: [December 6, 2017, 11:54am UTC](https://meta.discourse.org/t/selected-text-is-overwritten-when-using-the-link-toolbar-action/75515/6 "2017-12-06T11:54:49Z")

</div>

Thank you very much!!! 🙂

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [December 6, 2017, 12:01pm UTC](https://meta.discourse.org/t/selected-text-is-overwritten-when-using-the-link-toolbar-action/75515/7 "2017-12-06T12:01:49Z")

</div>

Also as a workaround you can use “Paste as plain text” from context menu or Ctrl + Shift + V to skip HTML pasting.

---

<div class="post-metadata">

### Author: ![terraboss](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/terraboss/32/381157_2.png) [@terraboss](https://meta.discourse.org/u/terraboss)
#### Post date: [December 6, 2017, 12:08pm UTC](https://meta.discourse.org/t/selected-text-is-overwritten-when-using-the-link-toolbar-action/75515/8 "2017-12-06T12:08:45Z")

</div>

> [@vinothkannans](#):
>
> Also as a workaround you can use “Paste as plain text” from context menu

Thanks for the hint. 🙂

> [@vinothkannans](#):
>
> or Ctrl + Shift + V to skip HTML pasting.

Is it possible to generally disable HTML pasting? It seems to take much longer then before and won’t be kind of necessary / useful for us.

Maybe some kind of an integrated undo option inside the composer would be useful?

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [December 6, 2017, 2:59pm UTC](https://meta.discourse.org/t/selected-text-is-overwritten-when-using-the-link-toolbar-action/75515/10 "2017-12-06T14:59:52Z")

</div>

It is fixed now 👍.

> [@terraboss](#):
>
> Is it possible to generally disable HTML pasting?

Currently there is no option to disable it. But you can always use the two workarounds above for plain text pasting.

---

<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: [December 6, 2017, 9:46pm UTC](https://meta.discourse.org/t/selected-text-is-overwritten-when-using-the-link-toolbar-action/75515/11 "2017-12-06T21:46:41Z")

</div>

> [@terraboss](#):
>
> Is it possible to generally disable HTML pasting? It seems to take much longer then before and won’t be kind of necessary / useful for us.

Can this be sped up @vinothkannans? Can there be a quick reject check where the code running sees that none of the special characters / data necessary for a fancy paste are present, and then it exits that code path to the traditional fast paste?

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [December 7, 2017, 4:20pm UTC](https://meta.discourse.org/t/selected-text-is-overwritten-when-using-the-link-toolbar-action/75515/12 "2017-12-07T16:20:02Z")

</div>

It’s done. Now HTML to Markdown conversion happening silently in background. So no more waiting.

---

<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: [December 7, 2017, 8:41pm UTC](https://meta.discourse.org/t/selected-text-is-overwritten-when-using-the-link-toolbar-action/75515/13 "2017-12-07T20:41:50Z")

</div>

I do like this a lot, I wonder though if long term we want to do this stuff in JavaScript both on server and client side. It just adds a tiny bit more polish to a wonderful feature.

Nothing urgent, something to think about longer term.

---

<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: [January 22, 2018, 10:26am UTC](https://meta.discourse.org/t/selected-text-is-overwritten-when-using-the-link-toolbar-action/75515/14 "2018-01-22T10:26:26Z")

</div>

Is this fixed now, or should still be open?

---

<div class="post-metadata">

### Author: ![terraboss](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/terraboss/32/381157_2.png) [@terraboss](https://meta.discourse.org/u/terraboss)
#### Post date: [January 22, 2018, 11:28am UTC](https://meta.discourse.org/t/selected-text-is-overwritten-when-using-the-link-toolbar-action/75515/15 "2018-01-22T11:28:44Z")

</div>

Solved. Thanks guys! ❤

---

<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: [January 22, 2018, 11:35am UTC](https://meta.discourse.org/t/selected-text-is-overwritten-when-using-the-link-toolbar-action/75515/16 "2018-01-22T11:35:24Z")

</div>


