2020-11-29 14:03:39 +08:00
|
|
|
{% extends 'app_doc/editor/create_base_2.html' %}
|
2020-10-18 08:05:41 +08:00
|
|
|
{% load static %}
|
2020-12-02 21:25:59 +08:00
|
|
|
{% load i18n %}
|
2019-07-24 10:45:45 +08:00
|
|
|
{% block title %}新建文档模板{% endblock %}
|
2020-04-06 17:36:04 +08:00
|
|
|
|
|
|
|
{% block head_toolbar %}
|
|
|
|
<a class="btn pull-left" aria-label="" href="{% url 'create_doc' %}?pid={{project.id}}" target="_blank">
|
|
|
|
<i class="fa fa-plus-square"></i> <span class="layui-hide-xs">新建模板</span>
|
|
|
|
</a>
|
|
|
|
<a class="btn pull-left" aria-label="" href="{% url 'manage_doctemp' %}?pid={{project.id}}" target="_blank">
|
|
|
|
<i class="fa fa-cubes"></i> <span class="layui-hide-xs">管理模板</span>
|
|
|
|
</a>
|
|
|
|
<a class="btn pull-left" aria-label="" href="{% url 'manage_project' %}" target="_blank">
|
|
|
|
<i class="fa fa-cubes"></i> <span class="layui-hide-xs">管理文集</span>
|
|
|
|
</a>
|
|
|
|
{% endblock %}
|
|
|
|
|
|
|
|
{% block left_opera %}
|
2020-12-07 20:58:59 +08:00
|
|
|
{% include 'app_doc/editor/tpl_left_create_doctemp_custom.html' %}
|
2020-04-06 17:36:04 +08:00
|
|
|
{% endblock %}
|
|
|
|
|
2019-07-24 10:45:45 +08:00
|
|
|
|
|
|
|
{% block content %}
|
2019-07-21 23:00:55 +08:00
|
|
|
<div class="create-doc-form">
|
2020-04-06 17:36:04 +08:00
|
|
|
<div class="layui-form" style="padding-bottom:10px;">
|
|
|
|
<div class="layui-input-block" style="margin-left:0px;">
|
|
|
|
<input type="text" name="doc-name" id="doctemp-name" required lay-verify="required" placeholder="请输入模板标题" autocomplete="off" class="layui-input">
|
2019-07-21 23:00:55 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div id="editor-md">
|
|
|
|
<textarea style="display:none;"></textarea>
|
|
|
|
<textarea class="editormd-html-textarea" name="$id-html-code"></textarea>
|
|
|
|
</div>
|
2019-07-24 10:45:45 +08:00
|
|
|
{% endblock %}
|
2019-07-21 22:08:04 +08:00
|
|
|
|
2019-07-21 23:00:55 +08:00
|
|
|
{% block custom_script %}
|
|
|
|
<script>
|
|
|
|
//保存文档模板
|
|
|
|
createDocTemp = function(){
|
2020-05-10 09:31:31 +08:00
|
|
|
$('button.layui-btn').attr("disabled",true);
|
|
|
|
$('button.layui-btn').addClass('layui-btn-disabled');
|
2020-04-11 22:14:27 +08:00
|
|
|
layer.load();
|
2019-07-21 23:00:55 +08:00
|
|
|
var data = {
|
|
|
|
'name':$("#doctemp-name").val(),
|
|
|
|
'content':editor.getMarkdown(),
|
|
|
|
}
|
|
|
|
$.post("{% url 'create_doctemp' %}",data,function(r){
|
|
|
|
if(r.status){
|
|
|
|
//创建成功
|
2020-04-11 22:14:27 +08:00
|
|
|
layer.closeAll("loading");
|
2020-12-02 22:01:47 +08:00
|
|
|
window.localStorage.removeItem('mrdoc_doc_cache') // 清空文档缓存
|
2019-07-21 23:00:55 +08:00
|
|
|
layer.msg('保存成功',function(){
|
2020-04-06 17:36:04 +08:00
|
|
|
md_changed = false;
|
|
|
|
window.location.href = "{% url 'manage_doctemp' %}";
|
2019-07-21 23:00:55 +08:00
|
|
|
});
|
|
|
|
}else{
|
|
|
|
//创建失败
|
2020-04-11 22:14:27 +08:00
|
|
|
layer.closeAll("loading");
|
2019-07-21 23:00:55 +08:00
|
|
|
layer.msg('保存失败');
|
2020-05-10 09:31:31 +08:00
|
|
|
$('button.layui-btn').attr("disabled",false);
|
|
|
|
$('button.layui-btn').removeClass('layui-btn-disabled');
|
2019-07-21 23:00:55 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
2020-12-02 22:01:47 +08:00
|
|
|
// 查看本地文档缓存
|
|
|
|
$("#doc-cache-btn").click(function(){
|
|
|
|
var editor_cache = window.localStorage.getItem('mrdoc_doc_cache') // 获取文档缓存内容
|
|
|
|
if(editor_cache === null){
|
|
|
|
var editor_cache_cnt = 0
|
|
|
|
}else{
|
|
|
|
var editor_cache_cnt = editor_cache.replace(/\s+|[\r\n]/g,"").length
|
|
|
|
}
|
|
|
|
if(editor_cache_cnt > 5){ // 文档缓存去除空格换行后长度大于5
|
|
|
|
console.log("存在文档缓存")
|
|
|
|
$("#doc-cache-content").val(editor_cache)
|
|
|
|
layer.open({
|
|
|
|
title:"浏览器文档缓存",
|
|
|
|
type:1,
|
|
|
|
id:'doc-cache',
|
|
|
|
area:['500px','500px'],
|
|
|
|
content:$('#doc-cache-div'),
|
|
|
|
btn:['使用缓存',"删除缓存"],
|
|
|
|
success : function(index, layero) { // 成功弹出后回调
|
|
|
|
form.render();
|
|
|
|
},
|
|
|
|
yes:function(index, layero){
|
|
|
|
editor.setValue(editor_cache)
|
|
|
|
window.localStorage.removeItem('mrdoc_doc_cache')
|
|
|
|
layer.closeAll()
|
|
|
|
autoCacheDoc();
|
|
|
|
},
|
|
|
|
btn2:function(index,layero){
|
|
|
|
window.localStorage.removeItem('mrdoc_doc_cache')
|
|
|
|
layer.closeAll()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}else{
|
|
|
|
layer.msg("暂无本地缓存")
|
|
|
|
}
|
|
|
|
})
|
2019-07-21 23:00:55 +08:00
|
|
|
</script>
|
2019-07-24 10:45:45 +08:00
|
|
|
{% endblock %}
|