From 0c0bb269f56785cbdd7915995815fa47fd0f677e Mon Sep 17 00:00:00 2001 From: zhanzhenping <128675240+Zzhenping@users.noreply.github.com> Date: Fri, 5 Jul 2024 14:57:31 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96markdown=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/css/markdown.preview.css | 25 +++++++++++++++++++------ static/js/kancloud.js | 23 +++++++++++++++++++---- 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/static/css/markdown.preview.css b/static/css/markdown.preview.css index 0b35bfc9..bf23a4ff 100644 --- a/static/css/markdown.preview.css +++ b/static/css/markdown.preview.css @@ -51,30 +51,43 @@ width: 100%; } +.whole-article-wrap { + display: flex; + flex-direction: column; +} + .article-body .markdown-toc{ position: fixed; - right: 0; + right: 50px; width: 260px; font-size: 12px; - margin-top: -70px; overflow: auto; - margin-right: 50px; + border: 1px solid #e8e8e8; + border-radius: 6px; } .markdown-toc ul{ list-style:none; } + +.markdown-toc-list { + padding:20px 0 !important; + margin-bottom: 0 !important; +} + .markdown-toc .markdown-toc-list>li{ padding: 3px 10px 3px 16px; line-height: 18px; - border-left: 2px solid #e8e8e8; + /*border-left: 2px solid #e8e8e8;*/ color: #595959; + margin-left: -2px; } .markdown-toc .markdown-toc-list>li.active{ border-right: 2px solid #25b864; } .article-body .markdown-article{ - margin-right: 250px; + width: calc(100% - 260px); + /*margin-right: 250px;*/ } .article-body.content .markdown-toc{ position: relative; @@ -87,7 +100,7 @@ .markdown-toc-list .directory-item { padding: 3px 10px 3px 16px; line-height: 18px; - border-left: 2px solid #e8e8e8; + /*border-left: 2px solid #e8e8e8;*/ color: #595959; } .markdown-toc-list .directory-item-link { diff --git a/static/js/kancloud.js b/static/js/kancloud.js index 378f0797..eaae2174 100644 --- a/static/js/kancloud.js +++ b/static/js/kancloud.js @@ -143,9 +143,7 @@ function renderPage($data) { $("#doc_id").val($data.doc_id); if ($data.page) { loadComment($data.page, $data.doc_id); - - } - else { + } else { pageClicked(-1, $data.doc_id); } @@ -156,6 +154,7 @@ function renderPage($data) { $("#view_container").removeClass("theme__dark theme__green theme__light theme__red theme__default") $("#view_container").addClass($data.markdown_theme) } + checkMarkdownTocElement(); } /*** @@ -230,6 +229,7 @@ function initHighlighting() { } $(function () { + checkMarkdownTocElement(); $(".view-backtop").on("click", function () { $('.manual-right').animate({ scrollTop: '0px' }, 200); }); @@ -280,7 +280,7 @@ $(function () { $(window).resize(function (e) { - var h = $(".manual-catalog").innerHeight() - 20; + var h = $(".manual-catalog").innerHeight() - 50; $(".markdown-toc").height(h); }).resize(); @@ -417,4 +417,19 @@ function loadCopySnippets() { [].forEach.call(snippets, function (snippet) { Prism.highlightElement(snippet); }); +} + +function checkMarkdownTocElement() { + console.log(111) + let toc = $(".markdown-toc-list"); + let articleComment = $("#articleComment"); + if (toc.length) { + $(".wiki-bottom-left").css("width", "calc(100% - 260px)"); + articleComment.css("width", "calc(100% - 260px)"); + articleComment.css("margin", "30px 0 70px 0"); + } else { + $(".wiki-bottom-left").css("width", "100%"); + articleComment.css("width", "100%"); + articleComment.css("margin", "30px auto 70px auto;"); + } } \ No newline at end of file