mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 11:20:57 -06:00
Merge pull request #3891 from cpradio/fix-selected-link-text
FIX: Use selected text in the link if text is already selected, otherwise, put the URL
This commit is contained in:
commit
a7d87d1530
@ -404,7 +404,8 @@ export default Ember.Component.extend({
|
|||||||
const remaining = link.replace(m[0], '');
|
const remaining = link.replace(m[0], '');
|
||||||
this._addText(this._lastSel, `[${description}](${remaining})`);
|
this._addText(this._lastSel, `[${description}](${remaining})`);
|
||||||
} else {
|
} else {
|
||||||
this._addText(this._lastSel, `[${link}](${link})`);
|
const selectedValue = this._lastSel.value || link;
|
||||||
|
this._addText(this._lastSel, `[${selectedValue}](${link})`);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.set('link', '');
|
this.set('link', '');
|
||||||
|
@ -193,6 +193,19 @@ testCase('link modal (simple link)', function(assert) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testCase('link modal (simple link) with selected text', function(assert, textarea) {
|
||||||
|
textarea.selectionStart = 0;
|
||||||
|
textarea.selectionEnd = 12;
|
||||||
|
|
||||||
|
click('button.link');
|
||||||
|
fillIn('.insert-link input', 'http://eviltrout.com');
|
||||||
|
click('.insert-link button.btn-primary');
|
||||||
|
andThen(() => {
|
||||||
|
assert.equal(this.$('.insert-link.hidden').length, 1);
|
||||||
|
assert.equal(this.get('value'), '[hello world.](http://eviltrout.com)');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
testCase('link modal (link with description)', function(assert) {
|
testCase('link modal (link with description)', function(assert) {
|
||||||
click('button.link');
|
click('button.link');
|
||||||
fillIn('.insert-link input', 'http://eviltrout.com "evil trout"');
|
fillIn('.insert-link input', 'http://eviltrout.com "evil trout"');
|
||||||
|
Loading…
Reference in New Issue
Block a user