FIX: reply as new topic wasn't working in FF when the post was only composed of an image

This commit is contained in:
Régis Hanol 2015-10-01 21:43:43 +02:00
parent 2c9058ab00
commit 2c384aec83
3 changed files with 15 additions and 15 deletions

View File

@ -410,12 +410,12 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
action: Discourse.Composer.CREATE_TOPIC,
draftKey: Discourse.Composer.REPLY_AS_NEW_TOPIC_KEY,
categoryId: this.get('category.id')
}).then(function() {
}).then(() => {
return Em.isEmpty(quotedText) ? Discourse.Post.loadQuote(post.get('id')) : quotedText;
}).then(function(q) {
const postUrl = "" + location.protocol + "//" + location.host + post.get('url'),
postLink = "[" + Handlebars.escapeExpression(self.get('model.title')) + "](" + postUrl + ")";
composerController.appendText(I18n.t("post.continue_discussion", { postLink: postLink }) + "\n\n" + q);
}).then(q => {
const postUrl = `${location.protocol}//${location.host}${post.get('url')}`,
postLink = `[${Handlebars.escapeExpression(self.get('model.title'))}](${postUrl})`;
composerController.appendText(`${I18n.t("post.continue_discussion", { postLink })}\n\n${q}`);
});
},

View File

@ -3,15 +3,17 @@ export default {
REGEXP: /\[quote=([^\]]*)\]((?:[\s\S](?!\[quote=[^\]]*\]))*?)\[\/quote\]/im,
// Build the BBCode quote around the selected text
build: function(post, contents, opts) {
build(post, contents, opts) {
var contents_hashed, result, sansQuotes, stripped, stripped_hashed, tmp;
var full = opts && opts["full"];
var raw = opts && opts["raw"];
if (!post) { return ""; }
if (!contents) contents = "";
sansQuotes = contents.replace(this.REGEXP, '').trim();
if (sansQuotes.length === 0) return "";
if (sansQuotes.length === 0) { return ""; }
// Escape the content of the quote
sansQuotes = sansQuotes.replace(/</g, "&lt;")
@ -22,7 +24,7 @@ export default {
/* Strip the HTML from cooked */
tmp = document.createElement('div');
tmp.innerHTML = post.get('cooked');
stripped = tmp.textContent || tmp.innerText;
stripped = tmp.textContent || tmp.innerText || "";
/*
Let's remove any non alphanumeric characters as a kind of hash. Yes it's

View File

@ -405,9 +405,8 @@ Post.reopenClass({
},
loadRevision(postId, version) {
return Discourse.ajax("/posts/" + postId + "/revisions/" + version + ".json").then(function (result) {
return Ember.Object.create(result);
});
return Discourse.ajax("/posts/" + postId + "/revisions/" + version + ".json")
.then(result => Ember.Object.create(result));
},
hideRevision(postId, version) {
@ -419,16 +418,15 @@ Post.reopenClass({
},
loadQuote(postId) {
return Discourse.ajax("/posts/" + postId + ".json").then(function (result) {
return Discourse.ajax("/posts/" + postId + ".json").then(result => {
const post = Discourse.Post.create(result);
return Quote.build(post, post.get('raw'), {raw: true, full: true});
});
},
loadRawEmail(postId) {
return Discourse.ajax("/posts/" + postId + "/raw-email").then(function (result) {
return result.raw_email;
});
return Discourse.ajax("/posts/" + postId + "/raw-email")
.then(result => result.raw_email);
}
});