diff --git a/deps/db/src/logseq/db/frontend/property.cljs b/deps/db/src/logseq/db/frontend/property.cljs index 9a19628e4..c0ea666c1 100644 --- a/deps/db/src/logseq/db/frontend/property.cljs +++ b/deps/db/src/logseq/db/frontend/property.cljs @@ -54,8 +54,6 @@ :hide? true}} :logseq.property/built-in? {:schema {:type :checkbox :hide? true}} - :logseq.property/hide-properties? {:schema {:type :checkbox - :hide? true}} :logseq.property/query-table {:schema {:type :checkbox :hide? true}} ;; query-properties is a coll of property db-idents and keywords where keywords are special frontend keywords diff --git a/src/main/frontend/common.css b/src/main/frontend/common.css index 5f1c906e3..672d17cf2 100644 --- a/src/main/frontend/common.css +++ b/src/main/frontend/common.css @@ -319,7 +319,7 @@ i.ti { /** endregion **/ /* region FIXME: override elements (?) */ -h1.title, h1.title input { +h1.title, h1.title input, .ls-page-title-container { @apply font-medium; color: var(--lx-gray-12, var(--ls-title-text-color, hsl(var(--foreground)))); diff --git a/src/main/frontend/components/block.cljs b/src/main/frontend/components/block.cljs index 626441d66..9687d45e5 100644 --- a/src/main/frontend/components/block.cljs +++ b/src/main/frontend/components/block.cljs @@ -1912,7 +1912,7 @@ order-list-idx (:own-order-list-index config) collapsable? (editor-handler/collapsable? uuid {:semantic? true}) link? (boolean (:original-block config))] - [:div.block-control-wrap.flex.flex-row.items-center + [:div.block-control-wrap.flex.flex-row.items-center.h-6 {:class (util/classnames [{:is-order-list order-list? :bullet-closed collapsed? :bullet-hidden (:hide-bullet? config)}])} @@ -2381,12 +2381,12 @@ (rum/defc tags "Tags without inline tags" - [config block hover?] + [config block hover? edit?] (when (:block/raw-title block) (let [tags' (->> (:block/tags block) (remove (fn [t] (ldb/inline-tag? (:block/raw-title block) t)))) - block-tags (if (and (not hover?) (= [:logseq.class/Task] (map :db/ident tags'))) + block-tags (if (and (not hover?) (not edit?) (= [:logseq.class/Task] (map :db/ident tags'))) (remove (fn [t] (= (:db/ident t) :logseq.class/Task)) tags') tags')] (when (seq block-tags) @@ -2419,7 +2419,7 @@ (property-component/property-key-cp block property opts) [:div.select-none ":"]] (pv/property-value block property v opts)]))] - [:div.positioned-properties.right-align.flex.flex-row.items-center.gap-1.select-none.h-6 + [:div.positioned-properties.right-align.flex.flex-row.items-center.gap-1.select-none (for [pid properties] (when-let [property (db/entity pid)] (pv/property-value block property (get block pid) (assoc opts :show-tooltip? true))))])))) @@ -2585,11 +2585,12 @@ (rum/react *refs-count)) table? (:table? config)] [:div.block-content-or-editor-wrap - {:on-mouse-over #(reset! *hover? true) + {:class (when (:page-title? config) "ls-page-title-container") + :on-mouse-over #(reset! *hover? true) :on-mouse-leave #(reset! *hover? false)} (when (and db-based? (not table?)) (block-positioned-properties config block :block-left)) [:div.flex.flex-1.flex-col - [:div.flex.flex-1.flex-row.gap-1.items-start + [:div.flex.flex-1.flex-row.gap-1.items-center (if (and edit? editor-box) [:div.editor-wrapper.flex.flex-1 {:id editor-id} @@ -2635,16 +2636,16 @@ svg/edit])])]) (when-not (or (:block-ref? config) (:table? config)) - [:div.flex.flex-row.items-center.gap-1.h-6 - (when (and db-based? (seq (:block/tags block))) - (tags config block @*hover?))]) + (when (and db-based? (seq (:block/tags block))) + (tags (assoc config :block/uuid (:block/uuid block)) block @*hover? edit?))) - (when-not (:table? config) + (when-not (or (:table? config) (:page-title? config)) (block-refs-count block refs-count *hide-block-refs?))] (when (and (not (:table? config)) (not hide-block-refs?) - (> refs-count 0)) + (> refs-count 0) + (not (:page-title? config))) (when-let [refs-cp (state/get-component :block/linked-references)] (refs-cp uuid)))]])) @@ -3081,7 +3082,8 @@ (block-mouse-over e *control-show? block-id doc-mode?)) :on-mouse-leave (fn [e] (block-mouse-leave e *control-show? block-id doc-mode?))} - (when (and (not slide?) (not in-whiteboard?) (not table?)) + (when (and (not slide?) (not in-whiteboard?) (not table?) + (not (:page-title? config))) (let [edit? (or editing? (= uuid (:block/uuid (state/get-edit-block))))] (block-control config block @@ -3103,10 +3105,10 @@ (= (:block/uuid block) (:embed-id config))) table?)] (block-content-or-editor config block - {:edit-input-id edit-input-id - :block-id block-id - :edit? editing? - :hide-block-refs-count? hide-block-refs-count?}))]) + {:edit-input-id edit-input-id + :block-id block-id + :edit? editing? + :hide-block-refs-count? hide-block-refs-count?}))]) (when (and @*show-right-menu? (not in-whiteboard?) (not table?)) (block-right-menu config block editing?))] @@ -3115,7 +3117,7 @@ (block-positioned-properties config block :block-below)) (when (and db-based? (not collapsed?) (not table?)) - [:div {:style {:padding-left 45}} + [:div (when-not (:page-title? config) {:style {:padding-left 45}}) (db-properties-cp config block edit-input-id {:in-block-container? true})]) (when-not (or (:hide-children? config) in-whiteboard? table?) diff --git a/src/main/frontend/components/db_based/page.cljs b/src/main/frontend/components/db_based/page.cljs index 66a109c67..2fd7df25c 100644 --- a/src/main/frontend/components/db_based/page.cljs +++ b/src/main/frontend/components/db_based/page.cljs @@ -24,9 +24,8 @@ (let [edit-input-id-prefix (str "edit-block-" (:block/uuid page)) configure-opts {:selected? false :page-configure? configure?} - has-viewable-properties? (outliner-property/block-has-viewable-properties? page) - hide-properties? (:logseq.property/hide-properties? page)] - (when (or configure? (and (not hide-properties?) has-viewable-properties?)) + has-viewable-properties? (outliner-property/block-has-viewable-properties? page)] + (when (or configure? has-viewable-properties?) [:div.ls-page-properties {:class (util/classnames [{:no-properties (not has-viewable-properties?)}])} (if configure? diff --git a/src/main/frontend/components/editor.cljs b/src/main/frontend/components/editor.cljs index 894df581f..aa9929188 100644 --- a/src/main/frontend/components/editor.cljs +++ b/src/main/frontend/components/editor.cljs @@ -594,20 +594,27 @@ (defn- open-editor-popup! [id content opts] - (let [{:keys [left top rect]} (cursor/get-caret-pos (state/get-input)) - pos [(+ left (:left rect) -20) (+ top (:top rect) 20)] + (let [input (state/get-input) + line-height (or (when input + (some-> (.-lineHeight (js/window.getComputedStyle input)) + (js/parseFloat) + (- 4))) + 20) + {:keys [left top rect]} (cursor/get-caret-pos input) + pos [(+ left (:left rect) -20) (+ top (:top rect) line-height)] {:keys [root-props content-props]} opts] + (prn :debug :line-height) (shui/popup-show! - pos content - (merge - {:id (keyword :editor.commands id) - :align :start - :root-props (merge {:onOpenChange #(when-not % (state/clear-editor-action!))} root-props) - :content-props (merge {:onOpenAutoFocus #(.preventDefault %) - :onCloseAutoFocus #(.preventDefault %) - :data-editor-popup-ref (name id)} content-props) - :force-popover? true} - (dissoc opts :root-props :content-props))))) + pos content + (merge + {:id (keyword :editor.commands id) + :align :start + :root-props (merge {:onOpenChange #(when-not % (state/clear-editor-action!))} root-props) + :content-props (merge {:onOpenAutoFocus #(.preventDefault %) + :onCloseAutoFocus #(.preventDefault %) + :data-editor-popup-ref (name id)} content-props) + :force-popover? true} + (dissoc opts :root-props :content-props))))) (rum/defc shui-editor-popups [id format action _data] diff --git a/src/main/frontend/components/page.cljs b/src/main/frontend/components/page.cljs index 544853733..a30f64c9e 100644 --- a/src/main/frontend/components/page.cljs +++ b/src/main/frontend/components/page.cljs @@ -505,7 +505,7 @@ (plugins/hook-ui-items :pagebar)]))) ;; A page is just a logical block -(rum/defcs ^:large-vars/cleanup-todo page-inner < rum/reactive db-mixins/query +(rum/defcs ^:large-vars/cleanup-todo page-inner < rum/reactive db-mixins/query mixins/container-id (rum/local false ::all-collapsed?) (rum/local false ::control-show?) (rum/local nil ::current-page) @@ -559,7 +559,7 @@ [:div.relative.grid.gap-2.page-inner (when (and (not sidebar?) (not block?)) [:div.flex.flex-row.space-between - (when (or (mobile-util/native-platform?) (util/mobile?)) + (when (and (or (mobile-util/native-platform?) (util/mobile?)) (not db-based?)) [:div.flex.flex-row.pr-2 {:style {:margin-left -15} :on-mouse-over (fn [e] @@ -568,23 +568,31 @@ (page-mouse-leave e *control-show?))} (page-blocks-collapse-control title *control-show? *all-collapsed?)]) (when (and (not whiteboard?) (ldb/page? page)) - (page-title-cp page {:journal? journal? - :fmt-journal? fmt-journal? - :preview? preview? - :*hover? (::hover-title? state) - :*show-page-info? (::show-page-info? state)})) + (if db-based? + [:div.ls-page-title.w-full.content + {:class (when-not whiteboard-page? "title") + :on-pointer-down (fn [e] + (when (util/right-click? e) + (state/set-state! :page-title/context {:page (:block/title page) + :page-entity page}))) + :on-click (fn [e] + (when-not (= (.-nodeName (.-target e)) "INPUT") + (when (gobj/get e "shiftKey") + (.preventDefault e) + (state/sidebar-add-block! + repo + (:db/id page) + :page))))} + (component-block/block-container {:page-title? true + :hide-children? true + :container-id (:container-id state)} page)] + (page-title-cp page {:journal? journal? + :fmt-journal? fmt-journal? + :preview? preview? + :*hover? (::hover-title? state) + :*show-page-info? (::show-page-info? state)}))) (lsp-pagebar-slot)]) - (cond - (and db-based? (not block?)) - (db-page/page-info page - (if (and (ldb/class? page) sidebar?) - (atom true) - (::show-page-info? state))) - - (and (not db-based?) (not block?)) - [:<>]) - (when (and db-based? (ldb/class? page)) [:div.mt-8 (objects/class-objects page)]) diff --git a/src/main/frontend/components/page_menu.cljs b/src/main/frontend/components/page_menu.cljs index 2b39be92c..9dd4fee27 100644 --- a/src/main/frontend/components/page_menu.cljs +++ b/src/main/frontend/components/page_menu.cljs @@ -7,6 +7,7 @@ [frontend.handler.notification :as notification] [frontend.handler.page :as page-handler] [frontend.handler.common.developer :as dev-common-handler] + [frontend.handler.route :as route-handler] [frontend.state :as state] [logseq.shui.ui :as shui] [promesa.core :as p] @@ -67,7 +68,13 @@ (file-sync-handler/get-current-graph-uuid))] (when (not block?) (->> - [(when-not config/publishing? + [(when (not= (state/get-current-page) (str (:block/uuid page))) + {:title (t :page/go-to-page) + :options {:on-click + (fn [] + (route-handler/redirect-to-page! (:block/uuid page)))}}) + + (when-not config/publishing? {:title (if favorited? (t :page/unfavorite) (t :page/add-to-favorites)) @@ -126,7 +133,7 @@ {:title (t :page/open-with-default-app) :options {:on-click #(js/window.apis.openPath file-fpath)}}])) - (when (or (state/get-current-page) whiteboard?) + (when page {:title (t :export-page) :options {:on-click #(shui/dialog-open! (fn [] @@ -154,11 +161,6 @@ :options {:on-click #(commands/exec-plugin-simple-command! pid (assoc cmd :page page-name) action)}})) - (when (and db-based? (not whiteboard?)) - {:title (t :page/toggle-properties) - :options {:on-click (fn [] - (page-handler/toggle-properties! page))}}) - (when (and db-based? (= (:block/type page) "page")) {:title (t :page/convert-to-tag) :options {:on-click (fn [] diff --git a/src/main/frontend/components/property.cljs b/src/main/frontend/components/property.cljs index aee8a6526..15f9999d1 100644 --- a/src/main/frontend/components/property.cljs +++ b/src/main/frontend/components/property.cljs @@ -867,7 +867,7 @@ (remove (fn [property] (let [id (if (vector? property) (first property) property)] (or - (when-not page? (= id :block/tags)) + (= id :block/tags) (when-let [ent (db/entity id)] (or ;; built-in @@ -875,8 +875,7 @@ ;; TODO: Use ldb/built-in? when intermittent lazy loading issue fixed (get db-property/built-in-properties (:db/ident ent))) ;; other position - (when-not (or (and (:sidebar? opts) (= (:id opts) (str (:block/uuid block)))) - (ldb/page? block)) + (when-not (and (:sidebar? opts) (= (:id opts) (str (:block/uuid block)))) (outliner-property/property-with-other-position? ent))))))) properties)) {:keys [all-classes classes-properties]} (outliner-property/get-block-classes-properties (db/get-db) (:db/id block)) diff --git a/src/main/frontend/handler/page.cljs b/src/main/frontend/handler/page.cljs index 2cb188689..31275695d 100644 --- a/src/main/frontend/handler/page.cljs +++ b/src/main/frontend/handler/page.cljs @@ -503,14 +503,6 @@ (url-util/get-logseq-graph-page-url nil (state/get-current-repo) (str page-uuid))) (notification/show! "No page found to copy" :warning)))) -(defn toggle-properties! - [page-entity] - (let [e (db/entity (:db/id page-entity))] - (property-handler/set-block-property! (state/get-current-repo) - (:block/uuid page-entity) - :logseq.property/hide-properties? - (not (:logseq.property/hide-properties? e))))) - (defn convert-to-tag! [page-entity] (let [class (db-class/build-new-class (db/get-db) diff --git a/src/resources/dicts/en.edn b/src/resources/dicts/en.edn index d11464fda..e2920efaa 100644 --- a/src/resources/dicts/en.edn +++ b/src/resources/dicts/en.edn @@ -147,13 +147,13 @@ :page/make-private "Make it private" :page/delete "Delete page" :page/add-to-favorites "Add to Favorites" + :page/go-to-page "Go to this page" :page/unfavorite "Unfavorite page" :block/name "Page name" :page/copy-page-url "Copy page URL" :page/illegal-page-name "Illegal page name!" :page/page-already-exists "Page “{1}” already exists!" :page/whiteboard-to-journal-error "Whiteboard pages cannot be renamed to journal titles!" - :page/toggle-properties "Toggle properties" :page/convert-to-tag "Convert to Tag" :file/name "File name" :file/last-modified-at "Last modified at"