diff --git a/app/assets/javascripts/discourse/components/d-editor.js.es6 b/app/assets/javascripts/discourse/components/d-editor.js.es6 index 5173f41d89e..e668828ccbf 100644 --- a/app/assets/javascripts/discourse/components/d-editor.js.es6 +++ b/app/assets/javascripts/discourse/components/d-editor.js.es6 @@ -99,6 +99,7 @@ class Toolbar { id: "link", group: "insertions", shortcut: "K", + trimLeading: true, sendAction: event => this.context.send("showLinkModal", event) }); } @@ -956,15 +957,14 @@ export default Component.extend({ } let linkText = ""; - this._lastSel = this._getSelected(); + this._lastSel = toolbarEvent.selected; if (this._lastSel) { - linkText = this._lastSel.value.trim(); + linkText = this._lastSel.value; } showModal("insert-hyperlink").setProperties({ - linkText: linkText, - _lastSel: this._lastSel, + linkText, toolbarEvent }); }, diff --git a/app/assets/javascripts/discourse/controllers/insert-hyperlink.js.es6 b/app/assets/javascripts/discourse/controllers/insert-hyperlink.js.es6 index b04499456ba..21ea0603f82 100644 --- a/app/assets/javascripts/discourse/controllers/insert-hyperlink.js.es6 +++ b/app/assets/javascripts/discourse/controllers/insert-hyperlink.js.es6 @@ -147,7 +147,7 @@ export default Controller.extend(ModalFunctionality, { const origLink = this.linkUrl; const linkUrl = origLink.indexOf("://") === -1 ? `http://${origLink}` : origLink; - const sel = this._lastSel; + const sel = this.toolbarEvent.selected; if (isEmpty(linkUrl)) { return;