commit
91c80aaff1
@ -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) # 展示下级目录
|
||||
|
||||
@ -151,8 +151,8 @@
|
||||
<div class="layui-form" style="display: {% if is_share and doc_share.is_enable %}block;{% else %}none;{% endif %}" id="share-link">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">{% trans "链接" %}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="share_link" class="layui-input" id="share_link" disabled>
|
||||
<div class="layui-input-block" id='copy_link'>
|
||||
<input type="text" name="share_link" class="layui-input" id="share_link" readonly>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -243,7 +243,7 @@
|
||||
if(r.status){
|
||||
layer.msg("{% trans '设置成功' %}",{offset: 't'})
|
||||
console.log(r.data)
|
||||
$("input[name=share_link]").val(document.domain + '/share_doc/?token=' + r.data.doc)
|
||||
$("input[name=share_link]").val(document.location.protocol + '//' + document.location.host + '/share_doc/?token=' + r.data.doc)
|
||||
}else{
|
||||
layer.msg("{% trans '设置出错' %}")
|
||||
}
|
||||
@ -263,13 +263,27 @@
|
||||
})
|
||||
})
|
||||
{% if is_share %}
|
||||
$("input[name=share_link]").val(window.location.protocol + '//' + document.domain + '/share_doc/?token={{doc_share.token}}')
|
||||
$("input[name=share_link]").val(window.location.protocol + '//' + document.location.host + '/share_doc/?token={{doc_share.token}}')
|
||||
{% endif %}
|
||||
|
||||
var share_data = {
|
||||
'id':'{{doc.id}}',
|
||||
}
|
||||
|
||||
//监听链接栏被单击
|
||||
$('#copy_link').click(function(){
|
||||
var target = document.getElementById("share_link");
|
||||
// 选择内容
|
||||
target.focus();
|
||||
target.setSelectionRange(0, target.value.length);
|
||||
document.execCommand("copy");
|
||||
layer.msg('链接地址已复制', {
|
||||
time: 2000, //2s后自动关闭
|
||||
btn: '好的',
|
||||
btnAlign: 'c'
|
||||
});
|
||||
})
|
||||
|
||||
//监听分享框分享类型的单选事件
|
||||
form.on('radio(share_type)', function(data){
|
||||
// console.log(data.value); //被点击的radio的value值
|
||||
|
||||
@ -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