@@ -6,6 +6,11 @@ attachDocumentEditor = function (editorElement, commitDialogElement)
6
6
require ( "./prosemirror/dist/markdown" )
7
7
var _menu = require ( "./prosemirror/dist/menu/menu" )
8
8
9
+ var link = window . location . href ;
10
+ var extIdx = link . lastIndexOf ( '.' ) ;
11
+ var ext = extIdx > 0 && ( extIdx > link . length - 8 ) ? link . substring ( extIdx + 1 ) : "" ;
12
+ //FIXME It work, but is not a good idea.
13
+ var isMd = ( ext == 'md' || ext == 'mkd' || ext == 'markdown' || ext == 'MD' || ext == 'MKD' ) ;
9
14
10
15
var content = document . querySelector ( '#editor' ) ;
11
16
content . style . display = "none" ;
@@ -15,15 +20,17 @@ attachDocumentEditor = function (editorElement, commitDialogElement)
15
20
var textCommands = new _menu . MenuCommandGroup ( "textCommands" ) ;
16
21
var insertCommands = new _menu . MenuCommandGroup ( "insertCommands" ) ;
17
22
18
- var menuItems = [ gitblitCommands , viewCommands , textCommands , _menu . inlineGroup , _menu . blockGroup , _menu . historyGroup , insertCommands ] ;
23
+ var menuItems = isMd ?
24
+ [ gitblitCommands , viewCommands , textCommands , _menu . inlineGroup , _menu . blockGroup , _menu . historyGroup , insertCommands ]
25
+ : [ gitblitCommands , viewCommands , _menu . historyGroup ] ;
19
26
20
27
const updateCmd = Object . create ( null ) ;
21
28
22
29
updateCmd [ "GitblitCommit" ] = {
23
30
label : "GitblitCommit" ,
24
31
run : function ( ) {
25
32
commitDialogElement . modal ( { show :true } ) ;
26
- editorElement . value = pm . getContent ( 'markdown' ) ;
33
+ editorElement . value = isMd ? pm . getContent ( 'markdown' ) : pm . getContent ( 'text ') ;
27
34
} ,
28
35
menu : {
29
36
group : "gitblitCommands" , rank : 10 ,
@@ -214,7 +221,7 @@ attachDocumentEditor = function (editorElement, commitDialogElement)
214
221
doc : content . value ,
215
222
menuBar : { float :true , content : menuItems } ,
216
223
commands : edit . CommandSet . default . update ( updateCmd ) ,
217
- docFormat : "markdown"
224
+ docFormat : isMd ? "markdown" : "text "
218
225
} ) ;
219
226
220
227
0 commit comments