@@ -55,6 +55,7 @@ var updateViewDebounce = 200;
5555var cursorMenuThrottle = 100 ;
5656var cursorActivityDebounce = 50 ;
5757var cursorAnimatePeriod = 100 ;
58+ var supportContainers = [ 'success' , 'info' , 'warning' , 'danger' ] ;
5859var supportCodeModes = [ 'javascript' , 'htmlmixed' , 'htmlembedded' , 'css' , 'xml' , 'clike' , 'clojure' , 'ruby' , 'python' , 'shell' , 'php' , 'sql' , 'coffeescript' , 'yaml' , 'jade' , 'lua' , 'cmake' , 'nginx' , 'perl' , 'sass' , 'r' , 'dockerfile' ] ;
5960var supportCharts = [ 'sequence' , 'flow' , 'graphviz' , 'mermaid' ] ;
6061var 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