mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 20:54:31 +08:00
38 lines
1.0 KiB
JavaScript
38 lines
1.0 KiB
JavaScript
window.PagedownCustom = {
|
|
insertButtons: [
|
|
{
|
|
id: 'wmd-quote-post',
|
|
description: I18n.t("composer.quote_post_title"),
|
|
execute: function() {
|
|
return Discourse.__container__.lookup('controller:composer').send('importQuote');
|
|
}
|
|
}
|
|
],
|
|
|
|
appendButtons: [],
|
|
|
|
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; }
|
|
}
|
|
result.push(newLine);
|
|
});
|
|
chunk.selection = result.join("\n");
|
|
|
|
}
|
|
}
|
|
};
|