Skip to content

Commit 88e6e85

Browse files
committed
Updated to support containers syntax textcomplete
1 parent e729166 commit 88e6e85

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

public/js/index.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ var updateViewDebounce = 200;
5555
var cursorMenuThrottle = 100;
5656
var cursorActivityDebounce = 50;
5757
var cursorAnimatePeriod = 100;
58+
var supportContainers = ['success', 'info', 'warning', 'danger'];
5859
var supportCodeModes = ['javascript', 'htmlmixed', 'htmlembedded', 'css', 'xml', 'clike', 'clojure', 'ruby', 'python', 'shell', 'php', 'sql', 'coffeescript', 'yaml', 'jade', 'lua', 'cmake', 'nginx', 'perl', 'sass', 'r', 'dockerfile'];
5960
var supportCharts = ['sequence', 'flow', 'graphviz', 'mermaid'];
6061
var supportHeaders = [
@@ -2616,6 +2617,42 @@ $(editor.getInputField())
26162617
checkCursorMenu();
26172618
return isInCode;
26182619
}
2620+
},
2621+
{ // Container strategy
2622+
containers: supportContainers,
2623+
match: /(^|\n):::(\s*)(\w*)$/,
2624+
search: function (term, callback) {
2625+
var line = editor.getLine(editor.getCursor().line);
2626+
term = line.match(this.match)[3];
2627+
var list = [];
2628+
term = term.trim();
2629+
$.map(this.containers, function (container) {
2630+
if (container.indexOf(term) === 0 && container !== term)
2631+
list.push(container);
2632+
});
2633+
callback(list);
2634+
},
2635+
replace: function (lang) {
2636+
var ending = '';
2637+
if (!checkBelow(matchInContainer)) {
2638+
ending = '\n\n:::';
2639+
}
2640+
if (this.containers.indexOf(lang) !== -1)
2641+
return '$1:::$2' + lang + ending;
2642+
},
2643+
done: function () {
2644+
var cursor = editor.getCursor();
2645+
var text = [];
2646+
text.push(editor.getLine(cursor.line - 1));
2647+
text.push(editor.getLine(cursor.line));
2648+
text = text.join('\n');
2649+
//console.log(text);
2650+
if (text == '\n:::')
2651+
editor.doc.cm.execCommand("goLineUp");
2652+
},
2653+
context: function (text) {
2654+
return !isInCode && isInContainer;
2655+
}
26192656
},
26202657
{ //header
26212658
match: /(?:^|\n)(\s{0,3})(#{1,6}\w*)$/,

0 commit comments

Comments
 (0)