fix: nested page title can't be clicked

pull/9142/head^2
Tienson Qin 2023-05-08 19:26:14 +08:00
parent 8b8bd04ced
commit 6b94181116
2 changed files with 27 additions and 19 deletions

View File

@ -37,7 +37,9 @@
[logseq.graph-parser.util :as gp-util] [logseq.graph-parser.util :as gp-util]
[medley.core :as medley] [medley.core :as medley]
[reitit.frontend.easy :as rfe] [reitit.frontend.easy :as rfe]
[rum.core :as rum])) [rum.core :as rum]
[logseq.graph-parser.util.page-ref :as page-ref]
[logseq.graph-parser.mldoc :as gp-mldoc]))
(defn- get-page-name (defn- get-page-name
[state] [state]
@ -292,8 +294,8 @@
(rum/local false ::edit?) (rum/local false ::edit?)
(rum/local "" ::input-value) (rum/local "" ::input-value)
{:init (fn [state] {:init (fn [state]
(assoc state ::title-value (atom (nth (:rum/args state) 2))))} (assoc state ::title-value (atom (nth (:rum/args state) 3))))}
[state page-name icon title _format fmt-journal?] [state page page-name icon title _format fmt-journal?]
(when title (when title
(let [*title-value (get state ::title-value) (let [*title-value (get state ::title-value)
*edit? (get state ::edit?) *edit? (get state ::edit?)
@ -304,7 +306,9 @@
untitled? (and whiteboard-page? (parse-uuid page-name)) ;; normal page cannot be untitled right? untitled? (and whiteboard-page? (parse-uuid page-name)) ;; normal page cannot be untitled right?
title (if hls-page? title (if hls-page?
[:a.asset-ref (pdf-utils/fix-local-asset-pagename title)] [:a.asset-ref (pdf-utils/fix-local-asset-pagename title)]
(if fmt-journal? (date/journal-title->custom-format title) title)) (if fmt-journal?
(date/journal-title->custom-format title)
title))
old-name (or title page-name)] old-name (or title page-name)]
[:h1.page-title.flex.cursor-pointer.gap-1.w-full [:h1.page-title.flex.cursor-pointer.gap-1.w-full
{:class (when-not whiteboard-page? "title") {:class (when-not whiteboard-page? "title")
@ -337,9 +341,13 @@
{:data-value @*input-value {:data-value @*input-value
:data-ref page-name :data-ref page-name
:style {:opacity (when @*edit? 0)}} :style {:opacity (when @*edit? 0)}}
(let [nested? (and (string/includes? title page-ref/left-brackets)
(string/includes? title page-ref/right-brackets))]
(cond @*edit? [:span {:style {:white-space "pre"}} (rum/react *input-value)] (cond @*edit? [:span {:style {:white-space "pre"}} (rum/react *input-value)]
untitled? [:span.opacity-50 (t :untitled)] untitled? [:span.opacity-50 (t :untitled)]
:else title)]]]))) nested? (component-block/map-inline {} (gp-mldoc/inline->edn title (gp-mldoc/default-config
(:block/format page))))
:else title))]]])))
(defn- page-mouse-over (defn- page-mouse-over
[e *control-show? *all-collapsed?] [e *control-show? *all-collapsed?]
@ -440,7 +448,7 @@
(page-blocks-collapse-control title *control-show? *all-collapsed?)]) (page-blocks-collapse-control title *control-show? *all-collapsed?)])
(when-not whiteboard? (when-not whiteboard?
[:div.ls-page-title.flex-1.flex-row.w-full [:div.ls-page-title.flex-1.flex-row.w-full
(page-title page-name icon title format fmt-journal?)]) (page-title page page-name icon title format fmt-journal?)])
(when (not config/publishing?) (when (not config/publishing?)
(when config/lsp-enabled? (when config/lsp-enabled?
[:div.flex.flex-row [:div.flex.flex-row

View File

@ -276,7 +276,7 @@ a.page-title {
} }
> .title { > .title {
@apply w-full pointer-events-none overflow-hidden overflow-ellipsis; @apply w-full overflow-hidden overflow-ellipsis;
} }
.edit-input { .edit-input {