|
@@ -37,7 +37,9 @@
|
|
|
[logseq.graph-parser.util :as gp-util]
|
|
|
[medley.core :as medley]
|
|
|
[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
|
|
|
[state]
|
|
@@ -292,8 +294,8 @@
|
|
|
(rum/local false ::edit?)
|
|
|
(rum/local "" ::input-value)
|
|
|
{:init (fn [state]
|
|
|
- (assoc state ::title-value (atom (nth (:rum/args state) 2))))}
|
|
|
- [state page-name icon title _format fmt-journal?]
|
|
|
+ (assoc state ::title-value (atom (nth (:rum/args state) 3))))}
|
|
|
+ [state page page-name icon title _format fmt-journal?]
|
|
|
(when title
|
|
|
(let [*title-value (get state ::title-value)
|
|
|
*edit? (get state ::edit?)
|
|
@@ -304,7 +306,9 @@
|
|
|
untitled? (and whiteboard-page? (parse-uuid page-name)) ;; normal page cannot be untitled right?
|
|
|
title (if hls-page?
|
|
|
[: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)]
|
|
|
[:h1.page-title.flex.cursor-pointer.gap-1.w-full
|
|
|
{:class (when-not whiteboard-page? "title")
|
|
@@ -312,16 +316,16 @@
|
|
|
(when (util/right-click? e)
|
|
|
(state/set-state! :page-title/context {:page page-name})))
|
|
|
:on-click (fn [e]
|
|
|
- (.preventDefault e)
|
|
|
- (if (gobj/get e "shiftKey")
|
|
|
- (when-let [page (db/pull repo '[*] [:block/name page-name])]
|
|
|
- (state/sidebar-add-block!
|
|
|
- repo
|
|
|
- (:db/id page)
|
|
|
- :page))
|
|
|
- (when (and (not hls-page?) (not fmt-journal?) (not config/publishing?))
|
|
|
- (reset! *input-value (if untitled? "" old-name))
|
|
|
- (reset! *edit? true))))}
|
|
|
+ (.preventDefault e)
|
|
|
+ (if (gobj/get e "shiftKey")
|
|
|
+ (when-let [page (db/pull repo '[*] [:block/name page-name])]
|
|
|
+ (state/sidebar-add-block!
|
|
|
+ repo
|
|
|
+ (:db/id page)
|
|
|
+ :page))
|
|
|
+ (when (and (not hls-page?) (not fmt-journal?) (not config/publishing?))
|
|
|
+ (reset! *input-value (if untitled? "" old-name))
|
|
|
+ (reset! *edit? true))))}
|
|
|
(when (not= icon "") [:span.page-icon icon])
|
|
|
[:div.page-title-sizer-wrapper.relative
|
|
|
(when @*edit?
|
|
@@ -337,9 +341,13 @@
|
|
|
{:data-value @*input-value
|
|
|
:data-ref page-name
|
|
|
:style {:opacity (when @*edit? 0)}}
|
|
|
- (cond @*edit? [:span {:style {:white-space "pre"}} (rum/react *input-value)]
|
|
|
- untitled? [:span.opacity-50 (t :untitled)]
|
|
|
- :else title)]]])))
|
|
|
+ (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)]
|
|
|
+ untitled? [:span.opacity-50 (t :untitled)]
|
|
|
+ nested? (component-block/map-inline {} (gp-mldoc/inline->edn title (gp-mldoc/default-config
|
|
|
+ (:block/format page))))
|
|
|
+ :else title))]]])))
|
|
|
|
|
|
(defn- page-mouse-over
|
|
|
[e *control-show? *all-collapsed?]
|
|
@@ -440,7 +448,7 @@
|
|
|
(page-blocks-collapse-control title *control-show? *all-collapsed?)])
|
|
|
(when-not whiteboard?
|
|
|
[: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 config/lsp-enabled?
|
|
|
[:div.flex.flex-row
|