2013-03-05 14:33:27 -05:00
|
|
|
/*global Markdown:true*/
|
2013-02-20 13:15:50 -05:00
|
|
|
|
2013-03-05 14:33:27 -05:00
|
|
|
window.PagedownCustom = {
|
|
|
|
insertButtons: [
|
|
|
|
{
|
|
|
|
id: 'wmd-quote-post',
|
2013-07-08 19:32:16 -04:00
|
|
|
description: I18n.t("composer.quote_post_title"),
|
2013-03-05 14:33:27 -05:00
|
|
|
execute: function() {
|
|
|
|
// AWFUL but I can't figure out how to call a controller method from outside our app
|
2013-09-16 14:08:55 -04:00
|
|
|
return Discourse.__container__.lookup('controller:composer').send('importQuote');
|
2013-02-20 13:15:50 -05:00
|
|
|
}
|
2013-03-05 14:33:27 -05:00
|
|
|
}
|
2013-10-28 12:44:10 -04:00
|
|
|
],
|
|
|
|
|
|
|
|
customActions: {
|
|
|
|
"doBlockquote": function(chunk, postProcessing, oldDoBlockquote) {
|
|
|
|
|
|
|
|
// When traditional linebreaks are set, use the default Pagedown implementation
|
|
|
|
if (Discourse.SiteSettings.traditional_markdown_linebreaks) {
|
|
|
|
return oldDoBlockquote.call(this, chunk, postProcessing);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Our custom blockquote for non-traditional markdown linebreaks
|
|
|
|
var result = [];
|
|
|
|
chunk.selection.split(/\n/).forEach(function (line) {
|
|
|
|
var newLine = "";
|
|
|
|
if (line.indexOf("> ") === 0) {
|
|
|
|
newLine += line.substr(2);
|
|
|
|
} else {
|
|
|
|
if (/\S/.test(line)) { newLine += "> " + line; }
|
|
|
|
}
|
2013-10-28 13:00:34 -04:00
|
|
|
result.push(newLine);
|
|
|
|
});
|
2013-10-28 12:44:10 -04:00
|
|
|
chunk.selection = result.join("\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2013-03-05 14:33:27 -05:00
|
|
|
};
|