Skip to content

Commit 75548df

Browse files
committed
Added support of code block languages autocomplete for charts
1 parent 0dbde6d commit 75548df

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

public/js/index.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var updateViewDebounce = 200;
2626
var cursorActivityDebounce = 50;
2727
var cursorAnimatePeriod = 100;
2828
var supportCodeModes = ['javascript', 'htmlmixed', 'htmlembedded', 'css', 'xml', 'clike', 'clojure', 'ruby', 'python', 'shell', 'php', 'sql', 'coffeescript', 'yaml', 'jade', 'lua', 'cmake', 'nginx', 'perl', 'sass', 'r', 'dockerfile'];
29+
var supportCharts = ['sequence-diagram', 'flow-chart', 'graphviz'];
2930
var supportHeaders = [
3031
{
3132
text: '# h1',
@@ -2230,15 +2231,26 @@ $(editor.getInputField())
22302231
},
22312232
{ // Code block language strategy
22322233
langs: supportCodeModes,
2234+
charts: supportCharts,
22332235
match: /(^|\n)```(\w+)$/,
22342236
search: function (term, callback) {
2235-
callback($.map(this.langs, function (lang) {
2236-
return lang.indexOf(term) === 0 ? lang : null;
2237-
}));
2237+
var list = [];
2238+
$.map(this.langs, function (lang) {
2239+
if (lang.indexOf(term) === 0)
2240+
list.push(lang);
2241+
});
2242+
$.map(this.charts, function (chart) {
2243+
if (chart.indexOf(term) === 0)
2244+
list.push(chart);
2245+
});
22382246
checkCursorMenu();
2247+
callback(list);
22392248
},
22402249
replace: function (lang) {
2241-
return '$1```' + lang + '=\n\n```';
2250+
if (this.langs.indexOf(lang) !== -1)
2251+
return '$1```' + lang + '=\n\n```';
2252+
else if (this.charts.indexOf(lang) !== -1)
2253+
return '$1```' + lang + '\n\n```';
22422254
},
22432255
done: function () {
22442256
editor.doc.cm.execCommand("goLineUp");

0 commit comments

Comments
 (0)