discourse/app/assets/javascripts/pagedown_custom.js

37 lines
1.1 KiB
JavaScript
Raw Normal View History

window.PagedownCustom = {
insertButtons: [
{
id: 'wmd-quote-post',
description: I18n.t("composer.quote_post_title"),
execute: function() {
// AWFUL but I can't figure out how to call a controller method from outside our app
2013-09-16 13:08:55 -05:00
return Discourse.__container__.lookup('controller:composer').send('importQuote');
}
}
],
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 12:00:34 -05:00
result.push(newLine);
});
chunk.selection = result.join("\n");
}
}
};