From 8fd7e0cbbe064acbe63791d99243e378d1587236 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Thu, 25 Feb 2021 20:09:33 +0800 Subject: [PATCH] enhance: add some docs for Contents --- resources/css/common.css | 4 +-- src/main/frontend/components/block.cljs | 15 ++-------- src/main/frontend/components/header.cljs | 2 +- src/main/frontend/components/page.cljs | 32 ++++++++++++++------- src/main/frontend/components/reference.cljs | 6 ++-- src/main/frontend/components/search.cljs | 7 +++-- src/main/frontend/dicts.cljs | 2 ++ src/main/frontend/handler/repo.cljs | 7 ++++- src/main/frontend/util.cljc | 2 ++ 9 files changed, 45 insertions(+), 32 deletions(-) diff --git a/resources/css/common.css b/resources/css/common.css index 5e7203575..cef2d1879 100644 --- a/resources/css/common.css +++ b/resources/css/common.css @@ -98,9 +98,9 @@ html[data-theme=light] { --ls-secondary-text-color: #161e2e; --ls-title-text-color: var(--ls-primary-text-color); --ls-link-text-color: #106BA3; - --ls-link-text-hover-color: #5d9cd6; + --ls-link-text-hover-color: #1a537c; --ls-link-ref-text-color: #106BA3; - --ls-link-ref-text-hover-color: #5d9cd6; + --ls-link-ref-text-hover-color: #1a537c; --ls-tag-text-color: var(--ls-link-ref-text-color); --ls-tag-text-hover-color: var(--ls-link-ref-text-hover-color); --ls-slide-background-color: #fff; diff --git a/src/main/frontend/components/block.cljs b/src/main/frontend/components/block.cljs index 3b431062b..6228885e7 100644 --- a/src/main/frontend/components/block.cljs +++ b/src/main/frontend/components/block.cljs @@ -1114,18 +1114,9 @@ (when-not slide? marker-switch) marker-cp priority] - (cond - dummy? - [[:span.opacity-50 "Click here to start writing"]] - - ;; empty item - (and contents? (or - (empty? title) - (= title [["Plain" "[[]]"]]))) - [[:span.opacity-50 "Click here to add a page, e.g. [[favorite-page]]"]] - - :else - (map-inline config title)) + (if title + (map-inline config title) + [[:span.opacity-50 "Click here to start writing"]]) [tags]))))))) (defn dnd-same-block? diff --git a/src/main/frontend/components/header.cljs b/src/main/frontend/components/header.cljs index 0e698f4e6..1e3f49205 100644 --- a/src/main/frontend/components/header.cljs +++ b/src/main/frontend/components/header.cljs @@ -82,7 +82,7 @@ :options {:on-click state/toggle-sidebar-open?!}}) (when current-repo - {:title (t :graph) + {:title (t :graph-view) :options {:href (rfe/href :graph)} :icon svg/graph-sm}) diff --git a/src/main/frontend/components/page.cljs b/src/main/frontend/components/page.cljs index 77ad1f56d..cd91f59b5 100644 --- a/src/main/frontend/components/page.cljs +++ b/src/main/frontend/components/page.cljs @@ -294,22 +294,26 @@ (not sidebar?) (not config/publishing?)) - (let [links (->> - [(when file - {:title (t :page/re-index) - :options {:on-click (fn [] - (file/re-index! file))}}) - {:title (t :page/add-to-contents) - :options {:on-click (fn [] (page-handler/handle-add-page-to-contents! page-original-name))}} - {:title (t :page/rename) - :options {:on-click #(state/set-modal! (rename-page-dialog page-name))}} + (let [contents? (= (string/lower-case (str page-name)) "contents") + links (->> + [(when-not contents? + {:title (t :page/add-to-contents) + :options {:on-click (fn [] (page-handler/handle-add-page-to-contents! page-original-name))}}) + + (when-not contents? + {:title (t :page/rename) + :options {:on-click #(state/set-modal! (rename-page-dialog page-name))}}) + (when (and file-path (util/electron?)) [{:title (t :page/open-in-finder) :options {:on-click #(js/window.apis.showItemInFolder file-path)}} {:title (t :page/open-with-default-app) :options {:on-click #(js/window.apis.openPath file-path)}}]) - {:title (t :page/delete) - :options {:on-click #(state/set-modal! (delete-page-dialog page-name))}} + + (when-not contents? + {:title (t :page/delete) + :options {:on-click #(state/set-modal! (delete-page-dialog page-name))}}) + {:title (t :page/action-publish) :options {:on-click (fn [] @@ -342,6 +346,12 @@ page-name (if public? false true)) (state/close-modal!))}}])])))}} + + (when file + {:title (t :page/re-index) + :options {:on-click (fn [] + (file/re-index! file))}}) + (when developer-mode? {:title "(Dev) Show page data" :options {:on-click (fn [] diff --git a/src/main/frontend/components/reference.cljs b/src/main/frontend/components/reference.cljs index fe5e6fe93..e67c8a5aa 100644 --- a/src/main/frontend/components/reference.cljs +++ b/src/main/frontend/components/reference.cljs @@ -54,7 +54,8 @@ (ui/foldable [:h2.font-bold.opacity-50 (let [] - (str n-ref " Linked References"))] + (str n-ref " Linked Reference" + (if (> n-ref 1) "s")))] [:div.references-blocks (let [ref-hiccup (block/->hiccup ref-blocks {:id page-name @@ -98,7 +99,8 @@ (ui/foldable [:h2.font-bold {:style {:opacity "0.3"}} (if @n-ref - (str @n-ref " Unlinked References") + (str @n-ref " Unlinked Reference" (if (> @n-ref 1) + "s")) "Unlinked References")] (fn [] (unlinked-references-aux page-name n-ref)) true)]])))) diff --git a/src/main/frontend/components/search.cljs b/src/main/frontend/components/search.cljs index 5705bb343..1803a5ebb 100644 --- a/src/main/frontend/components/search.cljs +++ b/src/main/frontend/components/search.cljs @@ -229,7 +229,8 @@ nil))})]))) -(rum/defc search < rum/reactive +(rum/defcs search < rum/reactive + (rum/local false ::inside-box?) (mixins/event-mixin (fn [state] (mixins/hide-when-esc-or-outside @@ -237,7 +238,7 @@ :on-hide (fn [] (search-handler/clear-search!) (leave-focus))))) - [] + [state] (let [search-result (state/sub :search/result) search-q (state/sub :search/q) show-result? (boolean (seq search-result))] @@ -271,7 +272,7 @@ (reset! search-timeout (js/setTimeout #(search-handler/search value) - 500))))))}] + 100))))))}] (when-not (string/blank? search-q) (ui/css-transition {:class-names "fade" diff --git a/src/main/frontend/dicts.cljs b/src/main/frontend/dicts.cljs index f9f2938ec..6c8a8dfa0 100644 --- a/src/main/frontend/dicts.cljs +++ b/src/main/frontend/dicts.cljs @@ -315,6 +315,7 @@ title: How to take dummy notes? :new-page "New page" :new-file "New file" :graph "Graph" + :graph-view "View Graph" :publishing "Publishing" :export "Export public pages" :all-graphs "All graphs" @@ -1035,6 +1036,7 @@ title: How to take dummy notes? :new-page "新页面" :new-file "新文件" :graph "图谱" + :graph-view "全局图谱" :publishing "发布" :export "导出公开页面" :all-graphs "所有库" diff --git a/src/main/frontend/handler/repo.cljs b/src/main/frontend/handler/repo.cljs index 97519e956..91b8a30fb 100644 --- a/src/main/frontend/handler/repo.cljs +++ b/src/main/frontend/handler/repo.cljs @@ -76,7 +76,12 @@ "/contents." (config/get-file-extension format)) file-path (str "/" path) - default-content (util/default-content-with-title format "contents")] + default-content (case (name format) + "org" + "** What's **Contents**?\n*** It's a normal page called [[Contents]], you can use it for:\n**** 1. table of content/index/MOC\n**** 2. pinning/bookmarking favorites pages/blocks (e.g. [[Logseq]])\n**** 3. You can also put many different things, depending on your personal workflow." + "markdown" + "## What's **Contents**?\n### It's a normal page called [[Contents]], you can use it for:\n#### 1. table of content/index/MOC\n#### 2. pinning/bookmarking favorites pages/blocks (e.g. [[Logseq]])\n#### 3. You can also put many different things, depending on your personal workflow." + "")] (p/let [_ (fs/mkdir-if-not-exists (str repo-dir "/" (state/get-pages-directory))) file-exists? (fs/create-if-not-exists repo-url repo-dir file-path default-content)] (when-not file-exists? diff --git a/src/main/frontend/util.cljc b/src/main/frontend/util.cljc index 7cf86ce1f..4b45fc73b 100644 --- a/src/main/frontend/util.cljc +++ b/src/main/frontend/util.cljc @@ -997,8 +997,10 @@ new-block (case (name text-format) "org" "** " + "markdown" "## " + "")] (if contents? new-block