Browse Source

Fixes #1062 - Upgraded to Prosemirror 0.6.1

tags/v1.8.0
Paul Martin 8 years ago
parent
commit
811cf09382

+ 2
- 3
src/main/java/com/gitblit/wicket/pages/EditFilePage.java View File

@@ -96,12 +96,10 @@ public class EditFilePage extends RepositoryPage {

Fragment fragment;
String displayedCommitId = commit.getId().getName();
MarkupDocument markupDoc = processor.parse(repositoryName, displayedCommitId, documentPath, markupText);
logger.trace("Loading Edit File page: " + displayedCommitId);

if (currentUser.canEdit(getRepositoryModel()) && JGitUtils.isTip(getRepository(), objectId.toString())) {
final Model<String> documentContent = new Model<String>(markupDoc.markup);
final Model<String> documentContent = new Model<String>(markupText);
final Model<String> commitMessage = new Model<String>("Document update");
final Model<String> commitIdAtLoad = new Model<String>(displayedCommitId);
@@ -181,6 +179,7 @@ public class EditFilePage extends RepositoryPage {
} else {
MarkupDocument markupDoc = processor.parse(repositoryName, displayedCommitId, documentPath, markupText);
final Model<String> documentContent = new Model<String>(markupDoc.html);
fragment = new Fragment("doc", "plainContent", this);

+ 24
- 16
src/main/js/editor.dev.js View File

@@ -70,19 +70,19 @@ attachDocumentEditor = function (editorElement, commitDialogElement)
var selection = pm.selection;
var from = selection.from;
var to = selection.to;
var attr = {name:"make", level:1};
var attr = {name:"make", level:"1"};
var node = pm.doc.path(from.path);
var node = pm.doc.resolve(from).parent;
if (node && node.hasMarkup(pm.schema.nodes.heading, attr)) {
return pm.tr.setBlockType(from, to, pm.schema.nodes.paragraph, {}).apply(pm.apply.scroll);
return pm.tr.setBlockType(from, to, pm.schema.defaultTextblockType(), {}).apply(pm.apply.scroll);
} else {
return pm.tr.setBlockType(from, to, pm.schema.nodes.heading, attr).apply(pm.apply.scroll);
}
},
active: function active(pm) {
var node = pm.doc.path(pm.selection.from.path);
if (node && node.hasMarkup(pm.schema.nodes.heading, {name:"make", level:1})) {
var node = pm.doc.resolve(pm.selection.from).parent;
if (node && node.hasMarkup(pm.schema.nodes.heading, {name:"make", level:"1"})) {
return true;
}
return false;
@@ -102,19 +102,19 @@ attachDocumentEditor = function (editorElement, commitDialogElement)
var selection = pm.selection;
var from = selection.from;
var to = selection.to;
var attr = {name:"make", level:2};
var attr = {name:"make", level:"2"};
var node = pm.doc.path(from.path);
var node = pm.doc.resolve(from).parent;
if (node && node.hasMarkup(pm.schema.nodes.heading, attr)) {
return pm.tr.setBlockType(from, to, pm.schema.nodes.paragraph, {}).apply(pm.apply.scroll);
return pm.tr.setBlockType(from, to, pm.schema.defaultTextblockType(), {}).apply(pm.apply.scroll);
} else {
return pm.tr.setBlockType(from, to, pm.schema.nodes.heading, attr).apply(pm.apply.scroll);
}
},
active: function active(pm) {
var node = pm.doc.path(pm.selection.from.path);
if (node && node.hasMarkup(pm.schema.nodes.heading, {name:"make", level:2})) {
var node = pm.doc.resolve(pm.selection.from).parent;
if (node && node.hasMarkup(pm.schema.nodes.heading, {name:"make", level:"2"})) {
return true;
}
return false;
@@ -134,19 +134,19 @@ attachDocumentEditor = function (editorElement, commitDialogElement)
var selection = pm.selection;
var from = selection.from;
var to = selection.to;
var attr = {name:"make", level:3};
var attr = {name:"make", level:"3"};
var node = pm.doc.path(from.path);
var node = pm.doc.resolve(from).parent;
if (node && node.hasMarkup(pm.schema.nodes.heading, attr)) {
return pm.tr.setBlockType(from, to, pm.schema.nodes.paragraph, {}).apply(pm.apply.scroll);
return pm.tr.setBlockType(from, to, pm.schema.defaultTextblockType(), {}).apply(pm.apply.scroll);
} else {
return pm.tr.setBlockType(from, to, pm.schema.nodes.heading, attr).apply(pm.apply.scroll);
}
},
active: function active(pm) {
var node = pm.doc.path(pm.selection.from.path);
if (node && node.hasMarkup(pm.schema.nodes.heading, {name:"make", level:3})) {
var node = pm.doc.resolve(pm.selection.from).parent;
if (node && node.hasMarkup(pm.schema.nodes.heading, {name:"make", level:"3"})) {
return true;
}
return false;
@@ -199,6 +199,15 @@ attachDocumentEditor = function (editorElement, commitDialogElement)
}
};
updateCmd["selectParentNode"] = {
menu: {
group: "insertCommands", rank: 10,
display: {
render: function(cmd, pm) { return renderFontAwesomeIcon(cmd, pm, "fa-arrow-circle-o-left"); }
}
}
};
var pm = window.pm = new edit.ProseMirror({
place: document.querySelector('#visualEditor'),
autoInput: true,
@@ -235,7 +244,6 @@ function renderFontAwesomeIcon(cmd, pm, classNames) {
var icon = document.createElement("i");
icon.setAttribute("class", "fa fa-fw " + classNames);
//TODO: try modify parent to simplify css border etc
var active = cmd.active(pm);
if (active || cmd.spec.invert) node.classList.add("ProseMirror-menu-active");

+ 1
- 1
src/main/js/prosemirror

@@ -1 +1 @@
Subproject commit 501e6fd6d5067c942b73d140a41e21afc8bb5f9b
Subproject commit b53cacec194d8f6fc5309383aed633c37c2c7114

+ 10
- 10
src/main/resources/gitblit-editor.min.js
File diff suppressed because it is too large
View File


Loading…
Cancel
Save