mirror of https://github.com/mindoc-org/mindoc.git
1、格式化了 markdown.js 的代码;2、文档阅读页面中增加了分隔条功能。
parent
87f7fd29ed
commit
d0a1c77c43
|
@ -1,32 +1,32 @@
|
||||||
$(function () {
|
$(function () {
|
||||||
window.addDocumentModalFormHtml = $(this).find("form").html();
|
window.addDocumentModalFormHtml = $(this).find("form").html();
|
||||||
window.editor = editormd("docEditor", {
|
window.editor = editormd("docEditor", {
|
||||||
width : "100%",
|
width: "100%",
|
||||||
height : "100%",
|
height: "100%",
|
||||||
path : "/static/editor.md/lib/",
|
path: "/static/editor.md/lib/",
|
||||||
toolbar : true,
|
toolbar: true,
|
||||||
placeholder : "本编辑器支持 Markdown 编辑,左边编写,右边预览。",
|
placeholder: "本编辑器支持 Markdown 编辑,左边编写,右边预览。",
|
||||||
imageUpload : true,
|
imageUpload: true,
|
||||||
imageFormats : ["jpg", "jpeg", "gif", "png", "JPG", "JPEG", "GIF", "PNG"],
|
imageFormats: ["jpg", "jpeg", "gif", "png", "JPG", "JPEG", "GIF", "PNG"],
|
||||||
imageUploadURL : window.imageUploadURL,
|
imageUploadURL: window.imageUploadURL,
|
||||||
toolbarModes : "full",
|
toolbarModes: "full",
|
||||||
fileUpload : true,
|
fileUpload: true,
|
||||||
fileUploadURL : window.fileUploadURL,
|
fileUploadURL: window.fileUploadURL,
|
||||||
taskList : true,
|
taskList: true,
|
||||||
flowChart : true,
|
flowChart: true,
|
||||||
htmlDecode : "style,script,iframe,title,onmouseover,onmouseout,style",
|
htmlDecode: "style,script,iframe,title,onmouseover,onmouseout,style",
|
||||||
lineNumbers : false,
|
lineNumbers: false,
|
||||||
tocStartLevel : 1,
|
tocStartLevel: 1,
|
||||||
tocm : true,
|
tocm: true,
|
||||||
saveHTMLToTextarea : true,
|
saveHTMLToTextarea: true,
|
||||||
|
|
||||||
onload : function() {
|
onload: function() {
|
||||||
this.hideToolbar();
|
this.hideToolbar();
|
||||||
var keyMap = {
|
var keyMap = {
|
||||||
"Ctrl-S" : function(cm) {
|
"Ctrl-S": function(cm) {
|
||||||
saveDocument(false);
|
saveDocument(false);
|
||||||
},
|
},
|
||||||
"Cmd-S" : function(cm){
|
"Cmd-S": function(cm){
|
||||||
saveDocument(false);
|
saveDocument(false);
|
||||||
},
|
},
|
||||||
"Ctrl-A": function(cm) {
|
"Ctrl-A": function(cm) {
|
||||||
|
@ -50,7 +50,7 @@ $(function () {
|
||||||
uploadImage("docEditor", function ($state, $res) {
|
uploadImage("docEditor", function ($state, $res) {
|
||||||
if ($state === "before") {
|
if ($state === "before") {
|
||||||
return layer.load(1, {
|
return layer.load(1, {
|
||||||
shade: [0.1,'#fff'] // 0.1 透明度的白色背景
|
shade: [0.1, '#fff'] // 0.1 透明度的白色背景
|
||||||
});
|
});
|
||||||
} else if ($state === "success") {
|
} else if ($state === "success") {
|
||||||
if ($res.errcode === 0) {
|
if ($res.errcode === 0) {
|
||||||
|
@ -60,7 +60,7 @@ $(function () {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onchange : function () {
|
onchange: function () {
|
||||||
resetEditorChanged(true);
|
resetEditorChanged(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -135,7 +135,7 @@ $(function () {
|
||||||
*/
|
*/
|
||||||
window.loadDocument = function($node) {
|
window.loadDocument = function($node) {
|
||||||
var index = layer.load(1, {
|
var index = layer.load(1, {
|
||||||
shade: [0.1,'#fff'] // 0.1 透明度的白色背景
|
shade: [0.1, '#fff'] // 0.1 透明度的白色背景
|
||||||
});
|
});
|
||||||
|
|
||||||
$.get(window.editURL + $node.node.id ).done(function (res) {
|
$.get(window.editURL + $node.node.id ).done(function (res) {
|
||||||
|
@ -147,7 +147,7 @@ $(function () {
|
||||||
window.editor.clear();
|
window.editor.clear();
|
||||||
window.editor.insertValue(res.data.markdown);
|
window.editor.insertValue(res.data.markdown);
|
||||||
window.editor.setCursor({ line : 0, ch : 0 });
|
window.editor.setCursor({ line : 0, ch : 0 });
|
||||||
var node = { "id" : res.data.doc_id, 'parent' : res.data.parent_id === 0 ? '#' : res.data.parent_id, "text" : res.data.doc_name, "identify" : res.data.identify, "version" : res.data.version };
|
var node = { "id": res.data.doc_id, 'parent': res.data.parent_id === 0 ? '#' : res.data.parent_id, "text": res.data.doc_name, "identify": res.data.identify, "version": res.data.version };
|
||||||
pushDocumentCategory(node);
|
pushDocumentCategory(node);
|
||||||
window.selectNode = node;
|
window.selectNode = node;
|
||||||
pushVueLists(res.data.attach);
|
pushVueLists(res.data.attach);
|
||||||
|
@ -187,14 +187,14 @@ $(function () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$.ajax({
|
$.ajax({
|
||||||
beforeSend : function () {
|
beforeSend: function () {
|
||||||
index = layer.load(1, { shade : [0.1,'#fff'] });
|
index = layer.load(1, { shade: [0.1, '#fff'] });
|
||||||
},
|
},
|
||||||
url : window.editURL,
|
url: window.editURL,
|
||||||
data : { "identify" : window.book.identify, "doc_id" : doc_id, "markdown" : content, "html" : html, "cover" : $is_cover ? "yes" : "no", "version" : version },
|
data: { "identify": window.book.identify, "doc_id": doc_id, "markdown": content, "html": html, "cover": $is_cover ? "yes" : "no", "version": version },
|
||||||
type : "post",
|
type: "post",
|
||||||
dataType : "json",
|
dataType: "json",
|
||||||
success : function (res) {
|
success: function (res) {
|
||||||
layer.close(index);
|
layer.close(index);
|
||||||
if (res.errcode === 0) {
|
if (res.errcode === 0) {
|
||||||
resetEditorChanged(false);
|
resetEditorChanged(false);
|
||||||
|
@ -211,7 +211,7 @@ $(function () {
|
||||||
}
|
}
|
||||||
} else if(res.errcode === 6005) {
|
} else if(res.errcode === 6005) {
|
||||||
var confirmIndex = layer.confirm('文档已被其他人修改确定覆盖已存在的文档吗?', {
|
var confirmIndex = layer.confirm('文档已被其他人修改确定覆盖已存在的文档吗?', {
|
||||||
btn: ['确定','取消'] // 按钮
|
btn: ['确定', '取消'] // 按钮
|
||||||
}, function() {
|
}, function() {
|
||||||
layer.close(confirmIndex);
|
layer.close(confirmIndex);
|
||||||
saveDocument(true, callback);
|
saveDocument(true, callback);
|
||||||
|
@ -225,11 +225,11 @@ $(function () {
|
||||||
|
|
||||||
function releaseBook() {
|
function releaseBook() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url : window.releaseURL,
|
url: window.releaseURL,
|
||||||
data : { "identify" : window.book.identify },
|
data: { "identify": window.book.identify },
|
||||||
type : "post",
|
type: "post",
|
||||||
dataType : "json",
|
dataType: "json",
|
||||||
success : function (res) {
|
success: function (res) {
|
||||||
if (res.errcode === 0) {
|
if (res.errcode === 0) {
|
||||||
layer.msg("发布任务已推送到任务队列,稍后将在后台执行。");
|
layer.msg("发布任务已推送到任务队列,稍后将在后台执行。");
|
||||||
} else {
|
} else {
|
||||||
|
@ -259,7 +259,7 @@ $(function () {
|
||||||
* 添加顶级文档
|
* 添加顶级文档
|
||||||
*/
|
*/
|
||||||
$("#addDocumentForm").ajaxForm({
|
$("#addDocumentForm").ajaxForm({
|
||||||
beforeSubmit : function () {
|
beforeSubmit: function () {
|
||||||
var doc_name = $.trim($("#documentName").val());
|
var doc_name = $.trim($("#documentName").val());
|
||||||
if (doc_name === "") {
|
if (doc_name === "") {
|
||||||
return showError("目录名称不能为空", "#add-error-message")
|
return showError("目录名称不能为空", "#add-error-message")
|
||||||
|
@ -267,13 +267,13 @@ $(function () {
|
||||||
$("#btnSaveDocument").button("loading");
|
$("#btnSaveDocument").button("loading");
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
success : function (res) {
|
success: function (res) {
|
||||||
if (res.errcode === 0) {
|
if (res.errcode === 0) {
|
||||||
var data = { "id" : res.data.doc_id, 'parent' : res.data.parent_id === 0 ? '#' : res.data.parent_id , "text" : res.data.doc_name, "identify" : res.data.identify, "version" : res.data.version };
|
var data = { "id": res.data.doc_id, 'parent': res.data.parent_id === 0 ? '#' : res.data.parent_id , "text": res.data.doc_name, "identify": res.data.identify, "version": res.data.version };
|
||||||
|
|
||||||
var node = window.treeCatalog.get_node(data.id);
|
var node = window.treeCatalog.get_node(data.id);
|
||||||
if (node) {
|
if (node) {
|
||||||
window.treeCatalog.rename_node({ "id" : data.id }, data.text);
|
window.treeCatalog.rename_node({ "id": data.id }, data.text);
|
||||||
} else {
|
} else {
|
||||||
window.treeCatalog.create_node(data.parent, data);
|
window.treeCatalog.create_node(data.parent, data);
|
||||||
window.treeCatalog.deselect_all();
|
window.treeCatalog.deselect_all();
|
||||||
|
@ -293,54 +293,54 @@ $(function () {
|
||||||
* 文档目录树
|
* 文档目录树
|
||||||
*/
|
*/
|
||||||
$("#sidebar").jstree({
|
$("#sidebar").jstree({
|
||||||
'plugins' : ["wholerow", "types", 'dnd', 'contextmenu'],
|
'plugins': ["wholerow", "types", 'dnd', 'contextmenu'],
|
||||||
"types" : {
|
"types": {
|
||||||
"default" : {
|
"default": {
|
||||||
"icon" : false // 删除默认图标
|
"icon": false // 删除默认图标
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'core' : {
|
'core': {
|
||||||
'check_callback' : true,
|
'check_callback': true,
|
||||||
"multiple" : false,
|
"multiple": false,
|
||||||
'animation' : 0,
|
'animation': 0,
|
||||||
"data" : window.documentCategory
|
"data": window.documentCategory
|
||||||
},
|
},
|
||||||
"contextmenu" : {
|
"contextmenu": {
|
||||||
show_at_node : false,
|
show_at_node: false,
|
||||||
select_node : false,
|
select_node: false,
|
||||||
"items" : {
|
"items": {
|
||||||
"添加文档" : {
|
"添加文档": {
|
||||||
"separator_before" : false,
|
"separator_before": false,
|
||||||
"separator_after" : true,
|
"separator_after": true,
|
||||||
"_disabled" : false,
|
"_disabled": false,
|
||||||
"label" : "添加文档",
|
"label": "添加文档",
|
||||||
"icon" : "fa fa-plus",
|
"icon": "fa fa-plus",
|
||||||
"action" : function (data) {
|
"action": function (data) {
|
||||||
var inst = $.jstree.reference(data.reference),
|
var inst = $.jstree.reference(data.reference),
|
||||||
node = inst.get_node(data.reference);
|
node = inst.get_node(data.reference);
|
||||||
|
|
||||||
openCreateCatalogDialog(node);
|
openCreateCatalogDialog(node);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"编辑" : {
|
"编辑": {
|
||||||
"separator_before" : false,
|
"separator_before": false,
|
||||||
"separator_after" : true,
|
"separator_after": true,
|
||||||
"_disabled" : false,
|
"_disabled": false,
|
||||||
"label" : "编辑",
|
"label": "编辑",
|
||||||
"icon" : "fa fa-edit",
|
"icon": "fa fa-edit",
|
||||||
"action" : function (data) {
|
"action": function (data) {
|
||||||
var inst = $.jstree.reference(data.reference);
|
var inst = $.jstree.reference(data.reference);
|
||||||
var node = inst.get_node(data.reference);
|
var node = inst.get_node(data.reference);
|
||||||
openEditCatalogDialog(node);
|
openEditCatalogDialog(node);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"删除" : {
|
"删除": {
|
||||||
"separator_before" : false,
|
"separator_before": false,
|
||||||
"separator_after" : true,
|
"separator_after": true,
|
||||||
"_disabled" : false,
|
"_disabled": false,
|
||||||
"label" : "删除",
|
"label": "删除",
|
||||||
"icon" : "fa fa-trash-o",
|
"icon": "fa fa-trash-o",
|
||||||
"action" : function (data) {
|
"action": function (data) {
|
||||||
var inst = $.jstree.reference(data.reference);
|
var inst = $.jstree.reference(data.reference);
|
||||||
var node = inst.get_node(data.reference);
|
var node = inst.get_node(data.reference);
|
||||||
openDeleteDocumentDialog(node);
|
openDeleteDocumentDialog(node);
|
||||||
|
@ -370,7 +370,7 @@ $(function () {
|
||||||
window.isLoad = true;
|
window.isLoad = true;
|
||||||
window.editor.clear();
|
window.editor.clear();
|
||||||
window.editor.insertValue(body);
|
window.editor.insertValue(body);
|
||||||
window.editor.setCursor({ line : 0, ch : 0 });
|
window.editor.setCursor({ line: 0, ch: 0 });
|
||||||
resetEditorChanged(true);
|
resetEditorChanged(true);
|
||||||
}
|
}
|
||||||
$("#documentTemplateModal").modal('hide');
|
$("#documentTemplateModal").modal('hide');
|
||||||
|
|
|
@ -0,0 +1,176 @@
|
||||||
|
$(function () {
|
||||||
|
var splitBar = {
|
||||||
|
// 设置当前屏幕为 840px 时将分割条隐藏
|
||||||
|
maxWidth: 840,
|
||||||
|
|
||||||
|
// 父元素选择器
|
||||||
|
parentSelector: '.manual-body',
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化分割条
|
||||||
|
*/
|
||||||
|
init: function () {
|
||||||
|
var self = this;
|
||||||
|
$(self.parentSelector)
|
||||||
|
.append(
|
||||||
|
$('\
|
||||||
|
<div id="manual-vsplitbar" unselectable="on"\
|
||||||
|
style="\
|
||||||
|
z-index:301;\
|
||||||
|
position: absolute;\
|
||||||
|
user-select: none;\
|
||||||
|
cursor: col-resize;\
|
||||||
|
left: 275px;\
|
||||||
|
height: 100%;\
|
||||||
|
display: block;\
|
||||||
|
width: 3px;\
|
||||||
|
border-right: 1px solid #8f949a;">\
|
||||||
|
<a href="javascript:void(0)" accesskey="" tabindex="0" title="vsplitbar"></a>\
|
||||||
|
</div>\
|
||||||
|
')
|
||||||
|
.hover(
|
||||||
|
function (event) {
|
||||||
|
event.target.style.background = '#8f949ad8';
|
||||||
|
},
|
||||||
|
function (event) {
|
||||||
|
event.target.style.background = '';
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
self.loadingHtml();
|
||||||
|
|
||||||
|
// 设置媒体查询
|
||||||
|
mediaMatcher.set();
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加载页面时设置分割条是否显示
|
||||||
|
*/
|
||||||
|
loadingHtml: function () {
|
||||||
|
var self = this;
|
||||||
|
var htmlWidth = document.body.clientWidth;
|
||||||
|
if (htmlWidth <= self.maxWidth) $('#manual-vsplitbar').css('display', 'none');
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在打开关闭菜单事初始化左右窗口和分割条
|
||||||
|
*/
|
||||||
|
reset: function () {
|
||||||
|
if (isFullScreen) {
|
||||||
|
// 关闭菜单时,初始化左右窗口
|
||||||
|
$('#manual-vsplitbar').css('display', 'none');
|
||||||
|
splitBar.inMaxWidthReset();
|
||||||
|
$('.manual-left').css('width', '0px');
|
||||||
|
} else {
|
||||||
|
// 打开菜单时,初始化左右窗口
|
||||||
|
$('#manual-vsplitbar').css('display', 'block');
|
||||||
|
splitBar.outMaxWidthReset();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 屏幕小于等于 840px,重置左右窗口
|
||||||
|
*/
|
||||||
|
inMaxWidthReset: function () {
|
||||||
|
$('#manual-vsplitbar').css('display', 'none');
|
||||||
|
$('.m-manual.manual-reader .manual-right').css('left', '0');
|
||||||
|
$('.manual-left').css('width', '280px');
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 屏幕大于 840px,重置左右窗口
|
||||||
|
*/
|
||||||
|
outMaxWidthReset: function () {
|
||||||
|
$('.manual-right').css('left', '279px');
|
||||||
|
$('.manual-left').css('width', '279px');
|
||||||
|
$('#manual-vsplitbar').css('left', '275px').css('display', 'block');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置媒体查询
|
||||||
|
* 分割条隐藏
|
||||||
|
*/
|
||||||
|
var mediaMatcher = {
|
||||||
|
mql: window.matchMedia('(max-width:' + splitBar.maxWidth + 'px)'),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加媒体查询监听事件
|
||||||
|
*/
|
||||||
|
set: function () {
|
||||||
|
var self = this;
|
||||||
|
self.mql.addListener(self.mqCallback);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除媒体查询监听事件
|
||||||
|
*/
|
||||||
|
remove: function () {
|
||||||
|
var self = this;
|
||||||
|
self.mql.removeListener(self.mqCallback);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 媒体查询回调函数
|
||||||
|
*/
|
||||||
|
mqCallback: function (event) {
|
||||||
|
if (event.target.matches) { // 宽度小于等于 840 像素
|
||||||
|
$(".m-manual").removeClass('manual-fullscreen-active');
|
||||||
|
splitBar.inMaxWidthReset();
|
||||||
|
} else { // 宽度大于 840 像素
|
||||||
|
splitBar.outMaxWidthReset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化分割条
|
||||||
|
splitBar.init();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 控制菜单宽度
|
||||||
|
* 最小为 140px
|
||||||
|
*/
|
||||||
|
$('#manual-vsplitbar').on('mousedown', function (e) {
|
||||||
|
var bodyEle = $('.manual-body')[0];
|
||||||
|
|
||||||
|
var leftPane = $('.manual-left')[0];
|
||||||
|
var splitBar = $('#manual-vsplitbar')[0];
|
||||||
|
var rightPane = $('.manual-right')[0];
|
||||||
|
|
||||||
|
var disX = (e || event).clientX;
|
||||||
|
|
||||||
|
splitBar.left = splitBar.offsetLeft;
|
||||||
|
|
||||||
|
var docMouseMove = document.onmousemove;
|
||||||
|
var docMouseUp = document.onmouseup;
|
||||||
|
|
||||||
|
document.onmousemove = function (e) {
|
||||||
|
var curPos = splitBar.left + ((e || event).clientX - disX);
|
||||||
|
var maxPos = bodyEle.clientWidth - splitBar.offsetWidth;
|
||||||
|
|
||||||
|
curPos > maxPos && (curPos = maxPos);
|
||||||
|
curPos < 140 && (curPos = 140);
|
||||||
|
|
||||||
|
leftPane.style.width = curPos + "px";
|
||||||
|
splitBar.style.left = curPos - 3 + "px";
|
||||||
|
rightPane.style.left = curPos + 3 + "px";
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
document.onmouseup = function () {
|
||||||
|
document.onmousemove = docMouseMove;
|
||||||
|
document.onmouseup = docMouseUp;
|
||||||
|
splitBar.releaseCapture && splitBar.releaseCapture();
|
||||||
|
};
|
||||||
|
|
||||||
|
splitBar.setCapture && splitBar.setCapture();
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关闭侧边栏时,同步分割条;
|
||||||
|
*/
|
||||||
|
$(".manual-fullscreen-switch").on("click", splitBar.reset);
|
||||||
|
});
|
|
@ -230,11 +230,12 @@
|
||||||
<script src="{{cdnjs "/static/bootstrap/js/bootstrap.min.js"}}"></script>
|
<script src="{{cdnjs "/static/bootstrap/js/bootstrap.min.js"}}"></script>
|
||||||
<script src="{{cdnjs "/static/js/jquery.form.js"}}" type="text/javascript"></script>
|
<script src="{{cdnjs "/static/js/jquery.form.js"}}" type="text/javascript"></script>
|
||||||
<script src="{{cdnjs "/static/jstree/3.3.4/jstree.min.js"}}" type="text/javascript"></script>
|
<script src="{{cdnjs "/static/jstree/3.3.4/jstree.min.js"}}" type="text/javascript"></script>
|
||||||
<script type="text/javascript" src="{{cdnjs "/static/nprogress/nprogress.js"}}"></script>
|
<script src="{{cdnjs "/static/nprogress/nprogress.js"}}" type="text/javascript"></script>
|
||||||
<script type="text/javascript" src="{{cdnjs "/static/highlight/highlight.js"}}"></script>
|
<script src="{{cdnjs "/static/highlight/highlight.js"}}" type="text/javascript"></script>
|
||||||
<script type="text/javascript" src="{{cdnjs "/static/highlight/highlightjs-line-numbers.min.js"}}"></script>
|
<script src="{{cdnjs "/static/highlight/highlightjs-line-numbers.min.js"}}" type="text/javascript"></script>
|
||||||
<script type="text/javascript" src="/static/js/jquery.highlight.js"></script>
|
<script src="/static/js/jquery.highlight.js" type="text/javascript"></script>
|
||||||
<script type="text/javascript" src="/static/js/kancloud.js"></script>
|
<script src="/static/js/kancloud.js" type="text/javascript"></script>
|
||||||
|
<script src="/static/js/splitbar.js" type="text/javascript"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
active_book_id = {{.Model.Identify}};
|
active_book_id = {{.Model.Identify}};
|
||||||
active_doc_id = {{.DocumentId}};
|
active_doc_id = {{.DocumentId}};
|
||||||
|
|
Loading…
Reference in New Issue