Improvements to automatic topic title based on pasted link
This commit is contained in:
parent
67a0a36362
commit
1f0793ac50
|
@ -82,15 +82,17 @@ export default Ember.Component.extend({
|
|||
this.set('composer.featuredLink', this.get('composer.title'));
|
||||
|
||||
const $h = $(html),
|
||||
header = $h.find('h4').length > 0 ? $h.find('h4') : $h.find('h3');
|
||||
heading = $h.find('h3').length > 0 ? $h.find('h3') : $h.find('h4');
|
||||
|
||||
this.set('composer.reply', this.get('composer.title'));
|
||||
|
||||
if (header.length > 0 && header.text().length > 0) {
|
||||
this.changeTitle(header.text());
|
||||
if (heading.length > 0 && heading.text().length > 0) {
|
||||
this.changeTitle(heading.text());
|
||||
} else {
|
||||
const filename = (this.get('composer.featuredLink')||"").split("/").pop();
|
||||
this.changeTitle(filename);
|
||||
const firstTitle = $h.attr('title') || $h.find("[title]").attr("title");
|
||||
if (firstTitle && firstTitle.length > 0) {
|
||||
this.changeTitle(firstTitle);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -26,7 +26,7 @@ test("onebox result doesn't include a title", () => {
|
|||
andThen(() => {
|
||||
ok(find('.d-editor-preview').html().trim().indexOf('onebox') > 0, "it pastes the link into the body and previews it");
|
||||
ok(exists('.d-editor-textarea-wrapper .popup-tip.good'), 'the body is now good');
|
||||
equal(find('.title-input input').val(), "no-title.html", "title is from the end of the url");
|
||||
equal(find('.title-input input').val(), "http://www.example.com/no-title.html", "title is unchanged");
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue