Skip to content

A platform for community discussion. Free, open, simple.

UX: Copy selected text to the link building modal

Vinoth Kannan86e142b39f06
diff --git a/app/assets/javascripts/discourse/components/d-editor.js.es6 b/app/assets/javascripts/discourse/components/d-editor.js.es6
index 819beb5fa53..109254c2d97 100644
--- a/app/assets/javascripts/discourse/components/d-editor.js.es6
+++ b/app/assets/javascripts/discourse/components/d-editor.js.es6
@@ -735,6 +735,11 @@ export default Ember.Component.extend({
showLinkModal() {
this._lastSel = this._getSelected();
+
+ if (this._lastSel) {
+ this.set("linkText", this._lastSel.value);
+ }
+
this.set('insertLinkHidden', false);
},
diff --git a/test/javascripts/components/d-editor-test.js.es6 b/test/javascripts/components/d-editor-test.js.es6
index cf3dfdfcd17..faf4f30b3b8 100644
--- a/test/javascripts/components/d-editor-test.js.es6
+++ b/test/javascripts/components/d-editor-test.js.es6
@@ -248,6 +248,9 @@ testCase('link modal (simple link) with selected text', function(assert, textare
textarea.selectionEnd = 12;
click('button.link');
+ andThen(() => {
+ assert.equal(this.$('input.link-text')[0].value, 'hello world.');
+ });
fillIn('.insert-link input.link-url', 'http://eviltrout.com');
click('.insert-link button.btn-primary');
andThen(() => {