Просмотр исходного кода

Fixes #1062 - Upgraded to Prosemirror 0.6.1

tags/v1.8.0
Paul Martin 8 лет назад
Родитель
Сommit
811cf09382

+ 2
- 3
src/main/java/com/gitblit/wicket/pages/EditFilePage.java Просмотреть файл



Fragment fragment; Fragment fragment;
String displayedCommitId = commit.getId().getName(); 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())) { 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> commitMessage = new Model<String>("Document update");
final Model<String> commitIdAtLoad = new Model<String>(displayedCommitId); final Model<String> commitIdAtLoad = new Model<String>(displayedCommitId);
} else { } else {
MarkupDocument markupDoc = processor.parse(repositoryName, displayedCommitId, documentPath, markupText);
final Model<String> documentContent = new Model<String>(markupDoc.html); final Model<String> documentContent = new Model<String>(markupDoc.html);
fragment = new Fragment("doc", "plainContent", this); fragment = new Fragment("doc", "plainContent", this);

+ 24
- 16
src/main/js/editor.dev.js Просмотреть файл

var selection = pm.selection; var selection = pm.selection;
var from = selection.from; var from = selection.from;
var to = selection.to; 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)) { 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 { } else {
return pm.tr.setBlockType(from, to, pm.schema.nodes.heading, attr).apply(pm.apply.scroll); return pm.tr.setBlockType(from, to, pm.schema.nodes.heading, attr).apply(pm.apply.scroll);
} }
}, },
active: function active(pm) { 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 true;
} }
return false; return false;
var selection = pm.selection; var selection = pm.selection;
var from = selection.from; var from = selection.from;
var to = selection.to; 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)) { 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 { } else {
return pm.tr.setBlockType(from, to, pm.schema.nodes.heading, attr).apply(pm.apply.scroll); return pm.tr.setBlockType(from, to, pm.schema.nodes.heading, attr).apply(pm.apply.scroll);
} }
}, },
active: function active(pm) { 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 true;
} }
return false; return false;
var selection = pm.selection; var selection = pm.selection;
var from = selection.from; var from = selection.from;
var to = selection.to; 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)) { 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 { } else {
return pm.tr.setBlockType(from, to, pm.schema.nodes.heading, attr).apply(pm.apply.scroll); return pm.tr.setBlockType(from, to, pm.schema.nodes.heading, attr).apply(pm.apply.scroll);
} }
}, },
active: function active(pm) { 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 true;
} }
return false; return false;
} }
}; };
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({ var pm = window.pm = new edit.ProseMirror({
place: document.querySelector('#visualEditor'), place: document.querySelector('#visualEditor'),
autoInput: true, autoInput: true,
var icon = document.createElement("i"); var icon = document.createElement("i");
icon.setAttribute("class", "fa fa-fw " + classNames); icon.setAttribute("class", "fa fa-fw " + classNames);
//TODO: try modify parent to simplify css border etc
var active = cmd.active(pm); var active = cmd.active(pm);
if (active || cmd.spec.invert) node.classList.add("ProseMirror-menu-active"); if (active || cmd.spec.invert) node.classList.add("ProseMirror-menu-active");

+ 1
- 1
src/main/js/prosemirror

Subproject commit 501e6fd6d5067c942b73d140a41e21afc8bb5f9b
Subproject commit b53cacec194d8f6fc5309383aed633c37c2c7114

+ 10
- 10
src/main/resources/gitblit-editor.min.js
Разница между файлами не показана из-за своего большого размера
Просмотреть файл


Загрузка…
Отмена
Сохранить