diff options
author | Cheng-Han, Wu | 2016-03-15 11:01:01 +0800 |
---|---|---|
committer | Cheng-Han, Wu | 2016-03-15 11:01:01 +0800 |
commit | 88e6e8522fd577a7818482c33c4a84ebedc1b4ba (patch) | |
tree | 0da402be00b1254797492654c04ab0e7264dc395 /public | |
parent | e729166c322a06530addd6c63400e08326a682ed (diff) |
Updated to support containers syntax textcomplete
Diffstat (limited to 'public')
-rw-r--r-- | public/js/index.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/public/js/index.js b/public/js/index.js index 1656e680..ed70bfc4 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -55,6 +55,7 @@ var updateViewDebounce = 200; var cursorMenuThrottle = 100; var cursorActivityDebounce = 50; var cursorAnimatePeriod = 100; +var supportContainers = ['success', 'info', 'warning', 'danger']; 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', 'flow', 'graphviz', 'mermaid']; var supportHeaders = [ @@ -2617,6 +2618,42 @@ $(editor.getInputField()) return isInCode; } }, + { // Container strategy + containers: supportContainers, + match: /(^|\n):::(\s*)(\w*)$/, + search: function (term, callback) { + var line = editor.getLine(editor.getCursor().line); + term = line.match(this.match)[3]; + var list = []; + term = term.trim(); + $.map(this.containers, function (container) { + if (container.indexOf(term) === 0 && container !== term) + list.push(container); + }); + callback(list); + }, + replace: function (lang) { + var ending = ''; + if (!checkBelow(matchInContainer)) { + ending = '\n\n:::'; + } + if (this.containers.indexOf(lang) !== -1) + return '$1:::$2' + lang + ending; + }, + done: function () { + var cursor = editor.getCursor(); + var text = []; + text.push(editor.getLine(cursor.line - 1)); + text.push(editor.getLine(cursor.line)); + text = text.join('\n'); + //console.log(text); + if (text == '\n:::') + editor.doc.cm.execCommand("goLineUp"); + }, + context: function (text) { + return !isInCode && isInContainer; + } + }, { //header match: /(?:^|\n)(\s{0,3})(#{1,6}\w*)$/, search: function (term, callback) { |