mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-28 17:20:55 -05:00
Added support of code block languages autocomplete for charts
This commit is contained in:
parent
0dbde6d3d0
commit
75548df29e
1 changed files with 16 additions and 4 deletions
|
@ -26,6 +26,7 @@ var updateViewDebounce = 200;
|
|||
var cursorActivityDebounce = 50;
|
||||
var cursorAnimatePeriod = 100;
|
||||
var supportCodeModes = ['javascript', 'htmlmixed', 'htmlembedded', 'css', 'xml', 'clike', 'clojure', 'ruby', 'python', 'shell', 'php', 'sql', 'coffeescript', 'yaml', 'jade', 'lua', 'cmake', 'nginx', 'perl', 'sass', 'r', 'dockerfile'];
|
||||
var supportCharts = ['sequence-diagram', 'flow-chart', 'graphviz'];
|
||||
var supportHeaders = [
|
||||
{
|
||||
text: '# h1',
|
||||
|
@ -2230,15 +2231,26 @@ $(editor.getInputField())
|
|||
},
|
||||
{ // Code block language strategy
|
||||
langs: supportCodeModes,
|
||||
charts: supportCharts,
|
||||
match: /(^|\n)```(\w+)$/,
|
||||
search: function (term, callback) {
|
||||
callback($.map(this.langs, function (lang) {
|
||||
return lang.indexOf(term) === 0 ? lang : null;
|
||||
}));
|
||||
var list = [];
|
||||
$.map(this.langs, function (lang) {
|
||||
if (lang.indexOf(term) === 0)
|
||||
list.push(lang);
|
||||
});
|
||||
$.map(this.charts, function (chart) {
|
||||
if (chart.indexOf(term) === 0)
|
||||
list.push(chart);
|
||||
});
|
||||
checkCursorMenu();
|
||||
callback(list);
|
||||
},
|
||||
replace: function (lang) {
|
||||
if (this.langs.indexOf(lang) !== -1)
|
||||
return '$1```' + lang + '=\n\n```';
|
||||
else if (this.charts.indexOf(lang) !== -1)
|
||||
return '$1```' + lang + '\n\n```';
|
||||
},
|
||||
done: function () {
|
||||
editor.doc.cm.execCommand("goLineUp");
|
||||
|
|
Loading…
Reference in a new issue