mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Better blockquote button in Markdown editor when non-traditional markdown linebreaks
are enabled.
This commit is contained in:
parent
098673ecc0
commit
26a8156f08
@ -10,5 +10,29 @@ window.PagedownCustom = {
|
|||||||
return Discourse.__container__.lookup('controller:composer').send('importQuote');
|
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; }
|
||||||
|
}
|
||||||
|
result.push(newLine)
|
||||||
|
})
|
||||||
|
chunk.selection = result.join("\n");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
22
vendor/assets/javascripts/Markdown.Editor.js
vendored
22
vendor/assets/javascripts/Markdown.Editor.js
vendored
@ -18,6 +18,17 @@
|
|||||||
// ]
|
// ]
|
||||||
// };
|
// };
|
||||||
//
|
//
|
||||||
|
// To extend actions:
|
||||||
|
//
|
||||||
|
// window.PagedownCustom = {
|
||||||
|
// customActions: {
|
||||||
|
// "doBlockquote": function(chunk, postProcessing, oldDoBlockquote) {
|
||||||
|
// console.log('custom blockquote called!');
|
||||||
|
// return oldDoBlockquote.call(this, chunk, postProcessing);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
|
|
||||||
@ -1470,6 +1481,17 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function bindCommand(method) {
|
function bindCommand(method) {
|
||||||
|
if (typeof PagedownCustom != "undefined" && PagedownCustom.customActions) {
|
||||||
|
var custom = PagedownCustom.customActions[method];
|
||||||
|
if (custom) {
|
||||||
|
return function() {
|
||||||
|
var args = Array.prototype.slice.call(arguments);
|
||||||
|
args.push(commandManager[method]);
|
||||||
|
return custom.apply(commandManager, args);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof method === "string")
|
if (typeof method === "string")
|
||||||
method = commandManager[method];
|
method = commandManager[method];
|
||||||
return function () { method.apply(commandManager, arguments); }
|
return function () { method.apply(commandManager, arguments); }
|
||||||
|
Loading…
Reference in New Issue
Block a user