文档新建、修改页面新增编辑器选择框
This commit is contained in:
parent
47ebdc982c
commit
dad6b1338a
@ -890,6 +890,14 @@ def create_doc(request):
|
||||
except ObjectDoesNotExist:
|
||||
editor_mode = 1
|
||||
if request.method == 'GET':
|
||||
try:
|
||||
# 获取url中自定义编辑器模式
|
||||
eid = request.GET.get('eid',0)
|
||||
if eid in [1,2,3,'1','2','3']:
|
||||
editor_mode = int(eid)
|
||||
except Exception as e:
|
||||
# 异常直接跳过使用设置中的mode
|
||||
pass
|
||||
try:
|
||||
editor_type = "新建文档"
|
||||
pid = request.GET.get('pid',-999)
|
||||
@ -909,6 +917,7 @@ def create_doc(request):
|
||||
doc_content = request.POST.get('content','') # 文档内容
|
||||
pre_content = request.POST.get('pre_content','') # 文档Markdown内容
|
||||
sort = request.POST.get('sort','') # 文档排序
|
||||
editor_mode = request.POST.get('editor_mode','') #获取文档编辑器
|
||||
status = request.POST.get('status',1) # 文档状态
|
||||
open_children = request.POST.get('open_children', False) # 展示下级目录
|
||||
show_children = request.POST.get('show_children', False) # 展示下级目录
|
||||
@ -973,14 +982,18 @@ def create_doc(request):
|
||||
def modify_doc(request,doc_id):
|
||||
editor_type = "修改文档"
|
||||
# 获取用户的编辑器模式
|
||||
try:
|
||||
user_opt = UserOptions.objects.get(user=request.user)
|
||||
editor_mode = user_opt.editor_mode
|
||||
except ObjectDoesNotExist:
|
||||
editor_mode = 1
|
||||
# try:
|
||||
# user_opt = UserOptions.objects.get(user=request.user)
|
||||
# editor_mode = user_opt.editor_mode
|
||||
# except ObjectDoesNotExist:
|
||||
# editor_mode = 1
|
||||
if request.method == 'GET':
|
||||
try:
|
||||
doc = Doc.objects.get(id=doc_id) # 查询文档信息
|
||||
editor_mode = doc.editor_mode
|
||||
eid = request.GET.get('eid',0)
|
||||
if eid in [1,2,3,'1','2','3']:
|
||||
editor_mode = int(eid)
|
||||
doc_tags = ','.join([i.tag.name for i in DocTag.objects.filter(doc=doc)]) # 查询文档标签信息
|
||||
project = Project.objects.get(id=doc.top_doc) # 查询文档所属的文集信息
|
||||
pro_colla = ProjectCollaborator.objects.filter(project=project,user=request.user) # 查询用户的协作文集信息
|
||||
@ -1016,6 +1029,7 @@ def modify_doc(request,doc_id):
|
||||
doc_content = request.POST.get('content', '') # 文档内容
|
||||
pre_content = request.POST.get('pre_content', '') # 文档Markdown格式内容
|
||||
sort = request.POST.get('sort', '') # 文档排序
|
||||
editor_mode = request.POST.get('editor_mode','') #获取文档编辑器
|
||||
status = request.POST.get('status',1) # 文档状态
|
||||
open_children = request.POST.get('open_children',False) # 展示下级目录
|
||||
show_children = request.POST.get('show_children', False) # 展示下级目录
|
||||
|
||||
@ -17,8 +17,8 @@
|
||||
|
||||
|
||||
{% block left_opera %}
|
||||
<div class="layui-form" style="padding: 0 10px 10px 10px;">
|
||||
<div class="layui-row">
|
||||
<div class="layui-form" style="padding: 0 10px 10px 10px;" lay-filter="left_form">
|
||||
<div class="layui-row">
|
||||
<div class="layui-btn-container" style="margin-bottom: 0px;">
|
||||
<button class="layui-btn layui-btn-primary layui-btn-sm mrdoc-btn-default" id="sel-doctemp" title="导入模板内容">
|
||||
导入模板
|
||||
@ -30,7 +30,17 @@
|
||||
<button class="layui-btn layui-btn-primary layui-btn-sm mrdoc-btn-default" id="doc-cache-btn" title="查看浏览器缓存">
|
||||
本地缓存
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label" style="padding-left: 0px;">编辑器选择</label>
|
||||
<div class="layui-input-block">
|
||||
<select name="select_editor_mode" lay-verify="required" lay-filter="select_editor_mode">
|
||||
<option value="1">EditorMD(Markdown)</option>
|
||||
<option value="2">Vditor(Markdown)</option>
|
||||
<option value="3">iceEditor(富文本)</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 选择文集 -->
|
||||
<div class="layui-col-md12" style="margin-bottom: 10px;">
|
||||
<div class="layui-input-inblock">
|
||||
@ -182,7 +192,29 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block custom_script %}
|
||||
<script>
|
||||
<script>
|
||||
form.val("left_form",{
|
||||
"select_editor_mode":{{editor_mode}}
|
||||
})
|
||||
form.on('select(select_editor_mode)',function(data){
|
||||
//console.log(data.value)
|
||||
layer.open({
|
||||
type:0,
|
||||
title:'更换编辑器',
|
||||
area:'300px;',
|
||||
id:'change_editor',//配置ID
|
||||
content: "为保证更换后格式兼容,更换编辑器将导致内容丢失!",
|
||||
btn:['确定更换','取消返回'], //添加按钮
|
||||
btnAlign:'c', //按钮居中
|
||||
yes:function (index,layero) {
|
||||
eurl = "{% url 'create_doc' %}?pid={{pid}}&eid=" + data.value.toString();
|
||||
$(location).attr('href', eurl);
|
||||
},
|
||||
btn2: function(index, layero){
|
||||
//暂时不需要返回
|
||||
}
|
||||
});
|
||||
})
|
||||
var tree = layui.tree;
|
||||
//选择文集
|
||||
form.on('select(project)', function(data){
|
||||
@ -287,6 +319,7 @@
|
||||
'content':content,
|
||||
'pre_content':pre_content,
|
||||
'sort':$("#sort").val(),
|
||||
'editor_mode':'{{editor_mode}}',
|
||||
'status':status,
|
||||
'open_children':$('input:radio[name="open-children"]:checked').val(),
|
||||
'show_children':$('input:radio[name="show-children"]:checked').val(),
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block left_opera %}
|
||||
<div class="layui-form" style="padding:0 10px 10px 10px;">
|
||||
<div class="layui-form" style="padding:0 10px 10px 10px;" lay-filter="left_form">
|
||||
<div class="layui-row">
|
||||
<div class="doc-form-label" style="margin-bottom: 10px;">
|
||||
{% if doc.status == 0 %}
|
||||
@ -51,6 +51,16 @@
|
||||
<i class="fa fa-history"></i> 缓存
|
||||
</button>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label" style="padding-left: 0px;">编辑器选择</label>
|
||||
<div class="layui-input-block">
|
||||
<select name="select_editor_mode" lay-verify="required" lay-filter="select_editor_mode">
|
||||
<option value="1">EditorMD(Markdown)</option>
|
||||
<option value="2">Vditor(Markdown)</option>
|
||||
<option value="3">iceEditor(富文本)</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-col-md12" style="margin-bottom: 10px;">
|
||||
<label class="doc-form-label" style="margin-right:0px;">
|
||||
@ -206,6 +216,31 @@
|
||||
|
||||
{% block custom_script %}
|
||||
<script>
|
||||
form.val("left_form",{
|
||||
"select_editor_mode":{{editor_mode}}
|
||||
})
|
||||
form.on('select(select_editor_mode)',function(data){
|
||||
//console.log(data.value)
|
||||
layer.open({
|
||||
type:0,
|
||||
title:'更换编辑器',
|
||||
area:'300px;',
|
||||
id:'change_editor',//配置ID
|
||||
content: "页面将重载,未提交的修改将丢失!",
|
||||
btn:['确定更换','取消返回'], //添加按钮
|
||||
btnAlign:'c', //按钮居中
|
||||
yes:function (index,layero) {
|
||||
eurl = "{% url 'modify_doc' doc_id=doc.id %}"+"?eid=" + data.value.toString();
|
||||
$(location).attr('href', eurl);
|
||||
},
|
||||
btn2: function(index, layero){
|
||||
//暂时不需要返回
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
|
||||
//获取文档数和上级文档信息
|
||||
$(function(){
|
||||
layer.load(1);
|
||||
@ -281,6 +316,7 @@
|
||||
'content':content,
|
||||
'pre_content':pre_content,
|
||||
'sort':$("#sort").val(),
|
||||
'editor_mode':'{{editor_mode}}',
|
||||
'status':status,
|
||||
'open_children':$('input:radio[name="open-children"]:checked').val(),
|
||||
'show_children':$('input:radio[name="show-children"]:checked').val(),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user