From dad6b1338a9b706ea9ff2f6e412ba0b2c1bc5a30 Mon Sep 17 00:00:00 2001 From: HuYang Date: Wed, 16 Dec 2020 11:36:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E6=A1=A3=E6=96=B0=E5=BB=BA=E3=80=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A1=B5=E9=9D=A2=E6=96=B0=E5=A2=9E=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E5=99=A8=E9=80=89=E6=8B=A9=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app_doc/views.py | 24 ++++++++++++--- template/app_doc/editor/create_doc.html | 41 ++++++++++++++++++++++--- template/app_doc/editor/modify_doc.html | 38 ++++++++++++++++++++++- 3 files changed, 93 insertions(+), 10 deletions(-) diff --git a/app_doc/views.py b/app_doc/views.py index e298bd6..6db17dd 100644 --- a/app_doc/views.py +++ b/app_doc/views.py @@ -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) # 展示下级目录 diff --git a/template/app_doc/editor/create_doc.html b/template/app_doc/editor/create_doc.html index 93125b5..9f7bf6f 100644 --- a/template/app_doc/editor/create_doc.html +++ b/template/app_doc/editor/create_doc.html @@ -17,8 +17,8 @@ {% block left_opera %} -
-
+
+
-
+
+
+ +
+ +
+
@@ -182,7 +192,29 @@ {% endblock %} {% block custom_script %} -