diff options
author | Wu Cheng-Han | 2016-01-19 10:01:40 -0600 |
---|---|---|
committer | Wu Cheng-Han | 2016-01-19 10:01:40 -0600 |
commit | 75548df29eba7d90965c685bb9b66f4592e3beaa (patch) | |
tree | a89fe56d9a453b870a96678d7b9702c90485d680 | |
parent | 0dbde6d3d006700657a996ba8d9946461a26c558 (diff) |
Added support of code block languages autocomplete for charts
-rw-r--r-- | public/js/index.js | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/public/js/index.js b/public/js/index.js index 46e46f22..6eb04f6d 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -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) { - return '$1```' + lang + '=\n\n```'; + 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"); |