@@ -45,7 +45,7 @@ | |||
<!-- blob nav links --> | |||
<div class="page_nav2"> | |||
<a wicket:id="blameLink"><wicket:message key="gb.blame"></wicket:message></a> | <a wicket:id="historyLink"><wicket:message key="gb.history"></wicket:message></a> | <a wicket:id="rawLink"><wicket:message key="gb.raw"></wicket:message></a> | |||
<a wicket:id="editLink"><wicket:message key="gb.edit"></wicket:message></a> | <a wicket:id="blameLink"><wicket:message key="gb.blame"></wicket:message></a> | <a wicket:id="historyLink"><wicket:message key="gb.history"></wicket:message></a> | <a wicket:id="rawLink"><wicket:message key="gb.raw"></wicket:message></a> | |||
</div> | |||
<!-- commit header --> | |||
@@ -62,4 +62,4 @@ | |||
</wicket:extend> | |||
</body> | |||
</html> | |||
</html> |
@@ -57,6 +57,12 @@ public class BlobPage extends RepositoryPage { | |||
throw new RedirectException(TreePage.class, WicketUtils.newRepositoryParameter(repositoryName)); | |||
} | |||
//add blob edit link | |||
BookmarkablePageLink<EditFilePage> editDocLink = new BookmarkablePageLink<>("editDocLink", EditFilePage.class, | |||
WicketUtils.newPathParameter(repositoryName, objectId, blobPath)); | |||
editDocLink.setEnabled(false); | |||
add(editDocLink); | |||
if (StringUtils.isEmpty(blobPath)) { | |||
// blob by objectid | |||
@@ -142,6 +148,8 @@ public class BlobPage extends RepositoryPage { | |||
add(new Label("blobText", table).setEscapeModelStrings(false)); | |||
add(new Image("blobImage").setVisible(false)); | |||
fileExtension = extension; | |||
//set blob edit link enable | |||
editDocLink.setEnabled(true); | |||
} | |||
} else { | |||
// plain text | |||
@@ -155,6 +163,8 @@ public class BlobPage extends RepositoryPage { | |||
} | |||
add(new Label("blobText", table).setEscapeModelStrings(false)); | |||
add(new Image("blobImage").setVisible(false)); | |||
//set blob edit link enable | |||
editDocLink.setEnabled(true); | |||
} | |||
} | |||
} |
@@ -6,6 +6,11 @@ attachDocumentEditor = function (editorElement, commitDialogElement) | |||
require("./prosemirror/dist/markdown") | |||
var _menu = require("./prosemirror/dist/menu/menu") | |||
var link = window.location.href; | |||
var extIdx = link.lastIndexOf('.'); | |||
var ext = extIdx > 0 && (extIdx > link.length - 8) ? link.substring(extIdx+1) : ""; | |||
//FIXME It work, but is not a good idea. | |||
var isMd=(ext=='md'||ext=='mkd'||ext=='markdown'||ext=='MD'||ext=='MKD'); | |||
var content = document.querySelector('#editor'); | |||
content.style.display = "none"; | |||
@@ -15,7 +20,9 @@ attachDocumentEditor = function (editorElement, commitDialogElement) | |||
var textCommands = new _menu.MenuCommandGroup("textCommands"); | |||
var insertCommands = new _menu.MenuCommandGroup("insertCommands"); | |||
var menuItems = [gitblitCommands, viewCommands, textCommands, _menu.inlineGroup, _menu.blockGroup, _menu.historyGroup, insertCommands]; | |||
var menuItems = isMd ? | |||
[gitblitCommands, viewCommands, textCommands, _menu.inlineGroup, _menu.blockGroup, _menu.historyGroup, insertCommands] | |||
: [gitblitCommands, viewCommands, _menu.historyGroup]; | |||
const updateCmd = Object.create(null); | |||
@@ -23,7 +30,7 @@ attachDocumentEditor = function (editorElement, commitDialogElement) | |||
label: "GitblitCommit", | |||
run: function() { | |||
commitDialogElement.modal({show:true}); | |||
editorElement.value = pm.getContent('markdown'); | |||
editorElement.value = isMd ? pm.getContent('markdown') : pm.getContent('text'); | |||
}, | |||
menu: { | |||
group: "gitblitCommands", rank: 10, | |||
@@ -214,7 +221,7 @@ attachDocumentEditor = function (editorElement, commitDialogElement) | |||
doc: content.value, | |||
menuBar: { float:true, content: menuItems}, | |||
commands: edit.CommandSet.default.update(updateCmd), | |||
docFormat: "markdown" | |||
docFormat: isMd ? "markdown" : "text" | |||
}); | |||