mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: pasting link into composer with a topic template will onebox the link after the template
This commit is contained in:
parent
8395569b05
commit
d34dd4ed4f
@ -45,7 +45,7 @@ export default Ember.Component.extend({
|
|||||||
|
|
||||||
@observes('composer.replyLength')
|
@observes('composer.replyLength')
|
||||||
_clearFeaturedLink() {
|
_clearFeaturedLink() {
|
||||||
if (this.get('watchForLink') && this.get('composer.replyLength') === 0) {
|
if (this.get('watchForLink') && this.bodyIsDefault()) {
|
||||||
this.set('composer.featuredLink', null);
|
this.set('composer.featuredLink', null);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -53,7 +53,7 @@ export default Ember.Component.extend({
|
|||||||
_checkForUrl() {
|
_checkForUrl() {
|
||||||
if (!this.element || this.isDestroying || this.isDestroyed) { return; }
|
if (!this.element || this.isDestroying || this.isDestroyed) { return; }
|
||||||
|
|
||||||
if (this.get('isAbsoluteUrl') && (this.get('composer.reply')||"").length === 0) {
|
if (this.get('isAbsoluteUrl') && this.bodyIsDefault()) {
|
||||||
|
|
||||||
// only feature links to external sites
|
// only feature links to external sites
|
||||||
if (this.get('composer.title').match(new RegExp("^https?:\\/\\/" + window.location.hostname, "i"))) { return; }
|
if (this.get('composer.title').match(new RegExp("^https?:\\/\\/" + window.location.hostname, "i"))) { return; }
|
||||||
@ -88,9 +88,10 @@ export default Ember.Component.extend({
|
|||||||
this.set('composer.featuredLink', this.get('composer.title'));
|
this.set('composer.featuredLink', this.get('composer.title'));
|
||||||
|
|
||||||
const $h = $(html),
|
const $h = $(html),
|
||||||
heading = $h.find('h3').length > 0 ? $h.find('h3') : $h.find('h4');
|
heading = $h.find('h3').length > 0 ? $h.find('h3') : $h.find('h4'),
|
||||||
|
composer = this.get('composer');
|
||||||
|
|
||||||
this.set('composer.reply', this.get('composer.title'));
|
composer.appendText(this.get('composer.title'), null, {block: true});
|
||||||
|
|
||||||
if (heading.length > 0 && heading.text().length > 0) {
|
if (heading.length > 0 && heading.text().length > 0) {
|
||||||
this.changeTitle(heading.text());
|
this.changeTitle(heading.text());
|
||||||
@ -112,5 +113,10 @@ export default Ember.Component.extend({
|
|||||||
@computed('composer.title')
|
@computed('composer.title')
|
||||||
isAbsoluteUrl() {
|
isAbsoluteUrl() {
|
||||||
return this.get('composer.titleLength') > 0 && /^(https?:)?\/\/[\w\.\-]+/i.test(this.get('composer.title'));
|
return this.get('composer.titleLength') > 0 && /^(https?:)?\/\/[\w\.\-]+/i.test(this.get('composer.title'));
|
||||||
|
},
|
||||||
|
|
||||||
|
bodyIsDefault() {
|
||||||
|
const reply = this.get('composer.reply')||"";
|
||||||
|
return (reply.length === 0 || (reply === (this.get("composer.category.topic_template")||"")));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -73,6 +73,11 @@ const Composer = RestModel.extend({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@computed('categoryId')
|
||||||
|
category(categoryId) {
|
||||||
|
return categoryId ? this.site.categories.findBy('id', categoryId) : null;
|
||||||
|
},
|
||||||
|
|
||||||
creatingTopic: Em.computed.equal('action', CREATE_TOPIC),
|
creatingTopic: Em.computed.equal('action', CREATE_TOPIC),
|
||||||
creatingPrivateMessage: Em.computed.equal('action', PRIVATE_MESSAGE),
|
creatingPrivateMessage: Em.computed.equal('action', PRIVATE_MESSAGE),
|
||||||
notCreatingPrivateMessage: Em.computed.not('creatingPrivateMessage'),
|
notCreatingPrivateMessage: Em.computed.not('creatingPrivateMessage'),
|
||||||
|
Loading…
Reference in New Issue
Block a user