Skip to content

Commit fc84ab9

Browse files
authored
Update editor.dev.js
1 parent a13f078 commit fc84ab9

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/main/js/editor.dev.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ attachDocumentEditor = function (editorElement, commitDialogElement)
66
require("./prosemirror/dist/markdown")
77
var _menu = require("./prosemirror/dist/menu/menu")
88

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');
914

1015
var content = document.querySelector('#editor');
1116
content.style.display = "none";
@@ -15,15 +20,17 @@ attachDocumentEditor = function (editorElement, commitDialogElement)
1520
var textCommands = new _menu.MenuCommandGroup("textCommands");
1621
var insertCommands = new _menu.MenuCommandGroup("insertCommands");
1722

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];
1926

2027
const updateCmd = Object.create(null);
2128

2229
updateCmd["GitblitCommit"] = {
2330
label: "GitblitCommit",
2431
run: function() {
2532
commitDialogElement.modal({show:true});
26-
editorElement.value = pm.getContent('markdown');
33+
editorElement.value = isMd ? pm.getContent('markdown') : pm.getContent('text');
2734
},
2835
menu: {
2936
group: "gitblitCommands", rank: 10,
@@ -214,7 +221,7 @@ attachDocumentEditor = function (editorElement, commitDialogElement)
214221
doc: content.value,
215222
menuBar: { float:true, content: menuItems},
216223
commands: edit.CommandSet.default.update(updateCmd),
217-
docFormat: "markdown"
224+
docFormat: isMd ? "markdown" : "text"
218225
});
219226

220227

0 commit comments

Comments
 (0)