Просмотр исходного кода

fix: search nodes shows title with parents

This commit also removes parents from page reference display because
1. there're bugs when clicking to edit
2. this may not be users' expected behavior
Tienson Qin 1 год назад
Родитель
Сommit
cb0539ebec

+ 26 - 18
deps/db/src/logseq/db.cljs

@@ -17,7 +17,8 @@
             [logseq.db.sqlite.common-db :as sqlite-common-db]
             [logseq.db.sqlite.util :as sqlite-util]
             [logseq.db.frontend.content :as db-content]
-            [logseq.db.frontend.property :as db-property])
+            [logseq.db.frontend.property :as db-property]
+            [logseq.common.util.namespace :as ns-util])
   (:refer-clojure :exclude [object?]))
 
 ;; Use it as an input argument for datalog queries
@@ -606,25 +607,32 @@
        (map (fn [d]
               (d/entity db (:e d))))))
 
-(defn get-class-parents
-  [class]
-  (let [*classes (atom #{})]
-    (when-let [parent (:logseq.property/parent class)]
-      (loop [current-parent parent]
-        (when (and
-               current-parent
-               (class? current-parent)
-               (not (contains? @*classes (:db/id current-parent))))
-          (swap! *classes conj (:db/id current-parent))
-          (recur (:logseq.property/parent current-parent)))))
-    @*classes))
+(defn get-page-parents
+  [node & {:keys [node-class?]}]
+  (when-let [parent (:logseq.property/parent node)]
+    (loop [current-parent parent
+           parents []]
+      (if (and
+           current-parent
+           (if node-class? (class? current-parent) true)
+           (not (contains? parents current-parent)))
+        (recur (:logseq.property/parent current-parent)
+               (conj parents current-parent))
+        (vec (reverse parents))))))
+
+(defn get-title-with-parents
+  [entity]
+  (if (contains? #{"page" "class"} (:block/type entity))
+    (let [parents (get-page-parents entity)]
+      (string/join
+       ns-util/parent-char
+       (map :block/title (conj parents entity))))
+    (:block/title entity)))
 
 (defn get-classes-parents
-  [db tags]
+  [tags]
   (let [tags' (filter class? tags)
-        result (map
-                (fn [id] (d/entity db id))
-                (mapcat get-class-parents tags'))]
+        result (mapcat get-page-parents tags' {:node-class? true})]
     (set result)))
 
 (defn class-instance?
@@ -634,7 +642,7 @@
         tags-ids (set (map :db/id tags))]
     (or
      (contains? tags-ids (:db/id class))
-     (let [class-parents (get-classes-parents (.-db object) tags)]
+     (let [class-parents (get-classes-parents tags)]
        (contains? (set/union class-parents tags-ids) (:db/id class))))))
 
 (defn get-all-pages-views

+ 5 - 33
deps/db/src/logseq/db/frontend/entity_plus.cljc

@@ -12,7 +12,6 @@
             [logseq.db.frontend.property :as db-property]
             [logseq.db.frontend.entity-util :as entity-util]
             [logseq.common.util.date-time :as date-time-util]
-            [logseq.common.util.namespace :as ns-util]
             [datascript.core :as d]))
 
 (def db-based-graph? entity-util/db-based-graph?)
@@ -33,35 +32,11 @@
       (or
        (get (.-kv e) k)
        (let [result (lookup-entity e k default-value)
-             parent-title? (:block.temp/parent-title? e)]
-         (or
-          (let [result' (if (string? result)
-                          (db-content/special-id-ref->page-ref result
-                                                               (:block/refs e))
-                          result)
-                parent (when (= (:block/type e) "page")
-                         (:logseq.property/parent e))]
-            (if (and db-based? parent parent-title?)
-              (str (:block/title parent) ns-util/parent-char result')
-              result'))
-          default-value))))))
-
-(defn- get-block-title-parent-refs
-  "Add parent to block ref titles"
-  [^Entity e k default-value]
-  (let [db (.-db e)
-        db-based? (db-based-graph? db)]
-    (if (and db-based? (= "journal" (:block/type e)))
-      (get-journal-title db e)
-      (or
-       (get (.-kv e) k)
-       (let [result (lookup-entity e :block/title default-value)]
-         (or
-          (if (string? result)
-            (db-content/special-id-ref->page-ref result
-                                                 (map (fn [e] (assoc e :block.temp/parent-title? true)) (:block/refs e)))
-            result)
-          default-value))))))
+             result' (if (string? result)
+                       (db-content/special-id-ref->page-ref result
+                                                            (:block/refs e))
+                       result)]
+         (or result' default-value))))))
 
 (defn lookup-kv-then-entity
   ([e k] (lookup-kv-then-entity e k nil))
@@ -87,9 +62,6 @@
          :block/title
          (get-block-title e k default-value)
 
-         :block/title-with-refs-parent
-         (get-block-title-parent-refs e k default-value)
-
          :block/_parent
          (->> (lookup-entity e k default-value)
               (remove (fn [e] (or (:logseq.property/created-from-property e)

+ 3 - 5
deps/outliner/src/logseq/outliner/core.cljs

@@ -259,8 +259,8 @@
       [?b :block/name ?child-name]
       [?p :block/name ?parent-name]]
     db
-     (common-util/page-name-sanity-lc parent-title)
-     (common-util/page-name-sanity-lc child-title))
+    (common-util/page-name-sanity-lc parent-title)
+    (common-util/page-name-sanity-lc child-title))
    first
    (d/entity db)))
 
@@ -357,7 +357,7 @@
                   db-based?
                   (dissoc :block/properties))
           m* (-> data'
-                 (dissoc :block/children :block/meta :block.temp/top? :block.temp/bottom? :block/unordered :block.temp/parent-title?
+                 (dissoc :block/children :block/meta :block.temp/top? :block.temp/bottom? :block/unordered
                          :block.temp/ast-title :block.temp/ast-body :block/level :block.temp/fully-loaded?)
                  common-util/remove-nils
                  block-with-updated-at
@@ -501,7 +501,6 @@
                           [(assoc block :db/id (dec (- idx)))]))) blocks)
        (apply concat)))
 
-
 (defn- get-id
   [x]
   (cond
@@ -701,7 +700,6 @@
           block (if (de/entity? block) block (d/entity db (:db/id block)))]
       [block sibling?])))
 
-
 (defn ^:api blocks-with-level
   "Calculate `:block/level` for all the `blocks`. Blocks should be sorted already."
   [blocks]

+ 5 - 5
deps/outliner/src/logseq/outliner/property.cljs

@@ -354,12 +354,12 @@
                            {:outliner-op :save-block})))))))
 
 (defn ^:api get-classes-parents
-  [db tags]
-  (ldb/get-classes-parents db tags))
+  [tags]
+  (ldb/get-classes-parents tags))
 
 (defn ^:api get-class-properties
-  [db class]
-  (let [class-parents (get-classes-parents db [class])]
+  [class]
+  (let [class-parents (get-classes-parents [class])]
     (->> (mapcat (fn [class]
                    (:logseq.property.class/properties class)) (concat [class] class-parents))
          (common-util/distinct-by :db/id)
@@ -371,7 +371,7 @@
         classes (->> (:block/tags block)
                      (sort-by :block/name)
                      (filter ldb/class?))
-        class-parents (get-classes-parents db classes)
+        class-parents (get-classes-parents classes)
         all-classes (->> (concat classes class-parents)
                          (filter (fn [class]
                                    (seq (:logseq.property.class/properties class)))))

+ 34 - 42
src/main/frontend/components/block.cljs

@@ -2,7 +2,6 @@
   (:refer-clojure :exclude [range])
   (:require-macros [hiccups.core])
   (:require ["/frontend/utils" :as utils]
-            [goog.functions :refer [debounce]]
             [cljs-bean.core :as bean]
             [cljs.core.match :refer [match]]
             [cljs.reader :as reader]
@@ -10,30 +9,33 @@
             [datascript.core :as d]
             [datascript.impl.entity :as e]
             [dommy.core :as dom]
+            [electron.ipc :as ipc]
             [frontend.commands :as commands]
             [frontend.components.block.macros :as block-macros]
-            [frontend.components.file-based.block :as file-block]
             [frontend.components.datetime :as datetime-comp]
+            [frontend.components.file-based.block :as file-block]
+            [frontend.components.icon :as icon-component]
             [frontend.components.lazy-editor :as lazy-editor]
             [frontend.components.macro :as macro]
             [frontend.components.plugins :as plugins]
-            [frontend.components.query.builder :as query-builder-component]
-            [frontend.components.svg :as svg]
-            [frontend.components.query :as query]
             [frontend.components.property :as property-component]
             [frontend.components.property.value :as pv]
-            [frontend.components.icon :as icon-component]
+            [frontend.components.query :as query]
+            [frontend.components.query.builder :as query-builder-component]
+            [frontend.components.svg :as svg]
+            [frontend.components.title :as title]
             [frontend.config :as config]
             [frontend.context.i18n :refer [t]]
             [frontend.date :as date]
             [frontend.db :as db]
-            [frontend.db.model :as model]
-            [frontend.mixins :as mixins]
             [frontend.db-mixins :as db-mixins]
+            [frontend.db.async :as db-async]
+            [frontend.db.model :as model]
             [frontend.extensions.highlight :as highlight]
             [frontend.extensions.latex :as latex]
             [frontend.extensions.lightbox :as lightbox]
             [frontend.extensions.pdf.assets :as pdf-assets]
+            [frontend.extensions.pdf.utils :as pdf-utils]
             [frontend.extensions.sci :as sci]
             [frontend.extensions.video.youtube :as youtube]
             [frontend.extensions.zotero :as zotero]
@@ -42,58 +44,55 @@
             [frontend.fs :as fs]
             [frontend.handler.assets :as assets-handler]
             [frontend.handler.block :as block-handler]
+            [frontend.handler.db-based.property :as db-property-handler]
             [frontend.handler.dnd :as dnd]
             [frontend.handler.editor :as editor-handler]
+            [frontend.handler.export.common :as export-common-handler]
+            [frontend.handler.file-based.property.util :as property-util]
             [frontend.handler.file-sync :as file-sync]
             [frontend.handler.notification :as notification]
             [frontend.handler.plugin :as plugin-handler]
+            [frontend.handler.property.file :as property-file]
+            [frontend.handler.property.util :as pu]
             [frontend.handler.repeated :as repeated]
             [frontend.handler.route :as route-handler]
             [frontend.handler.ui :as ui-handler]
             [frontend.handler.whiteboard :as whiteboard-handler]
-            [frontend.handler.export.common :as export-common-handler]
-            [frontend.handler.property.util :as pu]
-            [frontend.handler.db-based.property :as db-property-handler]
-            [logseq.outliner.property :as outliner-property]
-            [frontend.mobile.util :as mobile-util]
+            [frontend.mixins :as mixins]
             [frontend.mobile.intent :as mobile-intent]
+            [frontend.mobile.util :as mobile-util]
             [frontend.modules.outliner.tree :as tree]
+            [frontend.modules.shortcut.utils :as shortcut-utils]
             [frontend.security :as security]
             [frontend.state :as state]
             [frontend.template :as template]
             [frontend.ui :as ui]
-            [logseq.shui.ui :as shui]
-            [logseq.shui.dialog.core :as shui-dialog]
             [frontend.util :as util]
-            [frontend.extensions.pdf.utils :as pdf-utils]
             [frontend.util.file-based.drawer :as drawer]
-            [frontend.handler.property.file :as property-file]
-            [frontend.handler.file-based.property.util :as property-util]
             [frontend.util.text :as text-util]
             [goog.dom :as gdom]
+            [goog.functions :refer [debounce]]
             [goog.object :as gobj]
             [lambdaisland.glogi :as log]
-            [logseq.graph-parser.block :as gp-block]
             [logseq.common.config :as common-config]
-            [logseq.graph-parser.mldoc :as gp-mldoc]
-            [logseq.graph-parser.text :as text]
+            [logseq.common.path :as path]
             [logseq.common.util :as common-util]
             [logseq.common.util.block-ref :as block-ref]
-            [logseq.common.util.page-ref :as page-ref]
             [logseq.common.util.macro :as macro-util]
+            [logseq.common.util.page-ref :as page-ref]
+            [logseq.db :as ldb]
+            [logseq.db.frontend.content :as db-content]
+            [logseq.graph-parser.block :as gp-block]
+            [logseq.graph-parser.mldoc :as gp-mldoc]
+            [logseq.graph-parser.text :as text]
+            [logseq.outliner.property :as outliner-property]
+            [logseq.shui.dialog.core :as shui-dialog]
+            [logseq.shui.ui :as shui]
             [medley.core :as medley]
             [promesa.core :as p]
             [reitit.frontend.easy :as rfe]
             [rum.core :as rum]
-            [shadow.loader :as loader]
-            [logseq.common.path :as path]
-            [electron.ipc :as ipc]
-            [frontend.db.async :as db-async]
-            [logseq.db.frontend.content :as db-content]
-            [logseq.db :as ldb]
-            [frontend.components.title :as title]
-            [frontend.modules.shortcut.utils :as shortcut-utils]
-            [logseq.common.util.namespace :as ns-util]))
+            [shadow.loader :as loader]))
 
 ;; local state
 (defonce *dragging?
@@ -552,10 +551,8 @@
 
    All page-names are sanitized except page-name-in-block"
   [state
-   {:keys [contents-page? whiteboard-page? html-export? meta-click? show-unique-title? stop-click-event?
-           display-parent?]
-    :or {stop-click-event? true
-         display-parent? true}
+   {:keys [contents-page? whiteboard-page? html-export? meta-click? show-unique-title? stop-click-event?]
+    :or {stop-click-event? true}
     :as config}
    page-entity children label]
   (let [*hover? (::hover? state)
@@ -660,12 +657,7 @@
                                    (let [inline-list (gp-mldoc/inline->edn (first (string/split-lines s))
                                                                            (mldoc/get-default-config (get page-entity :block/format :markdown)))]
                                      (->elem :span (map-inline config inline-list))))))]
-          (let [parent (:logseq.property/parent page-entity)]
-            (if (and display-parent? parent (not (ldb/class? page-entity)))
-              [:span
-               (str (:block/title parent) ns-util/parent-char)
-               page-component]
-              page-component))))]]))
+          page-component))]]))
 
 (rum/defc popup-preview-impl
   [children {:keys [*timer *timer1 visible? set-visible! render *el-popup]}]
@@ -2350,7 +2342,7 @@
                                                   util/caret-range)
                              {:block/keys [title format]} block
                              content (if (config/db-based-graph? (state/get-current-repo))
-                                       (:block/title-with-refs-parent block)
+                                       (:block/title block)
                                        (->> title
                                             (property-file/remove-built-in-properties-when-file-based
                                              (state/get-current-repo) format)

+ 1 - 2
src/main/frontend/components/class.cljs

@@ -13,8 +13,7 @@
     (when (seq children)
       [:ul
        (for [child (sort-by :block/title children)]
-         (let [title [:li.ml-2 (block/page-reference false (:block/title child) {:show-brackets? false
-                                                                                 :display-parent? false} nil)]]
+         (let [title [:li.ml-2 (block/page-reference false (:block/title child) {:show-brackets? false} nil)]]
            (if (seq (:logseq.property/_parent child))
              (ui/foldable
               title

+ 99 - 99
src/main/frontend/components/editor.cljs

@@ -1,13 +1,16 @@
 (ns frontend.components.editor
   (:require [clojure.string :as string]
+            [datascript.impl.entity :as de]
+            [dommy.core :as dom]
             [frontend.commands :as commands :refer [*matched-commands]]
             [frontend.components.datetime :as datetime-comp]
-            [frontend.components.svg :as svg]
             [frontend.components.search :as search]
+            [frontend.components.svg :as svg]
             [frontend.components.title :as title]
+            [frontend.config :as config]
             [frontend.context.i18n :refer [t]]
+            [frontend.date :as date]
             [frontend.db :as db]
-            [logseq.db :as ldb]
             [frontend.db.model :as db-model]
             [frontend.extensions.zotero :as zotero]
             [frontend.handler.editor :as editor-handler :refer [get-state]]
@@ -16,25 +19,23 @@
             [frontend.handler.paste :as paste-handler]
             [frontend.handler.property.util :as pu]
             [frontend.handler.search :as search-handler]
-            [frontend.search :refer [fuzzy-search]]
             [frontend.mixins :as mixins]
+            [frontend.search :refer [fuzzy-search]]
             [frontend.state :as state]
             [frontend.ui :as ui]
-            [logseq.shui.ui :as shui]
-            [logseq.shui.popup.core :as shui-popup]
             [frontend.util :as util]
             [frontend.util.cursor :as cursor]
             [frontend.util.keycode :as keycode]
             [goog.dom :as gdom]
             [goog.string :as gstring]
-            [dommy.core :as dom]
-            [logseq.graph-parser.property :as gp-property]
             [logseq.common.util :as common-util]
+            [logseq.db :as ldb]
+            [logseq.graph-parser.property :as gp-property]
+            [logseq.shui.popup.core :as shui-popup]
+            [logseq.shui.ui :as shui]
             [promesa.core :as p]
             [react-draggable]
-            [rum.core :as rum]
-            [frontend.config :as config]
-            [frontend.date :as date]))
+            [rum.core :as rum]))
 
 (defn filter-commands
   [page? commands]
@@ -118,7 +119,7 @@
     (fn [chosen-item _e]
       (let [value (.-value input)
             value' (str (common-util/safe-subs value 0 q)
-                     (common-util/safe-subs value (+ (count q) 4 pos)))]
+                        (common-util/safe-subs value (+ (count q) 4 pos)))]
         (state/set-edit-content! (.-id input) value')
         (state/clear-editor-action!)
         (p/let [page (db/get-page chosen-item)
@@ -149,9 +150,9 @@
                           (if db-tag?
                             (db-model/get-all-classes (state/get-current-repo) {:except-root-class? true})
                             (->> (map (fn [title] {:block/title title
-                                                  :nlp-date? true})
-                                     date/nlp-pages)
-                                (take 10)))
+                                                   :nlp-date? true})
+                                      date/nlp-pages)
+                                 (take 10)))
                           ;; reorder, shortest and starts-with first.
                           (let [matched-pages-with-new-page
                                 (fn [partial-matched-pages]
@@ -175,7 +176,7 @@
          :on-enter    (fn []
                         (page-handler/page-not-exists-handler input id q current-pos))
          :item-render (fn [block _chosen?]
-                        (let [block (if (:block/uuid block)
+                        (let [block (if (and (:block/uuid block) (not (de/entity? block)))
                                       (db/entity [:block/uuid (:block/uuid block)])
                                       block)]
                           [:div.flex.flex-col
@@ -227,10 +228,10 @@
           [:span " to display this tag inline instead of at the end of this node."]])])))
 
 (rum/defc page-search < rum/reactive
-                        {:will-unmount (fn [state]
-                                         (reset! commands/*current-command nil)
-                                         state)}
-                        "Page or tag searching popup"
+  {:will-unmount (fn [state]
+                   (reset! commands/*current-command nil)
+                   state)}
+  "Page or tag searching popup"
   [id format]
   (let [action (state/sub :editor/action)
         db? (config/db-based-graph? (state/get-current-repo))
@@ -243,12 +244,12 @@
         (let [current-pos (cursor/pos input)
               edit-content (state/sub-edit-content)
               q (or
-                  (editor-handler/get-selected-text)
-                  (when (= action :page-search-hashtag)
-                    (common-util/safe-subs edit-content pos current-pos))
-                  (when (> (count edit-content) current-pos)
-                    (common-util/safe-subs edit-content pos current-pos))
-                  "")]
+                 (editor-handler/get-selected-text)
+                 (when (= action :page-search-hashtag)
+                   (common-util/safe-subs edit-content pos current-pos))
+                 (when (> (count edit-content) current-pos)
+                   (common-util/safe-subs edit-content pos current-pos))
+                 "")]
           (page-search-aux id format embed? db-tag? q current-pos input pos))))))
 
 (defn- search-blocks!
@@ -325,9 +326,9 @@
         edit-block (state/get-edit-block)
         selected-text (editor-handler/get-selected-text)
         q (or
-            selected-text
-            (when (>= (count edit-content) current-pos)
-              (subs edit-content pos current-pos)))]
+           selected-text
+           (when (>= (count edit-content) current-pos)
+             (subs edit-content pos current-pos)))]
     (when input
       (block-search-auto-complete edit-block input id q format selected-text))))
 
@@ -393,14 +394,14 @@
          (set-values! result)))
      [property q])
     (ui/auto-complete
-         values
-         {:on-chosen (editor-handler/property-value-on-chosen-handler id q)
-          :on-enter (fn [_state]
-                      ((editor-handler/property-value-on-chosen-handler id q) nil))
-          :empty-placeholder [:div.px-4.py-2.text-sm (str "Create a new property value: " q)]
-          :header [:div.px-4.py-2.text-sm.font-medium "Matched property values: "]
-          :item-render (fn [property-value] property-value)
-          :class       "black"})))
+     values
+     {:on-chosen (editor-handler/property-value-on-chosen-handler id q)
+      :on-enter (fn [_state]
+                  ((editor-handler/property-value-on-chosen-handler id q) nil))
+      :empty-placeholder [:div.px-4.py-2.text-sm (str "Create a new property value: " q)]
+      :header [:div.px-4.py-2.text-sm.font-medium "Matched property values: "]
+      :item-render (fn [property-value] property-value)
+      :class       "black"})))
 
 (rum/defc property-value-search < rum/reactive
   [id]
@@ -422,10 +423,10 @@
 (rum/defc code-block-mode-keyup-listener
   [_q _edit-content last-pos current-pos]
   (rum/use-effect!
-    (fn []
-      (when (< current-pos last-pos)
-        (state/clear-editor-action!)))
-    [last-pos current-pos])
+   (fn []
+     (when (< current-pos last-pos)
+       (state/clear-editor-action!)))
+   [last-pos current-pos])
   [:<>])
 
 (rum/defc code-block-mode-picker < rum/reactive
@@ -450,11 +451,10 @@
                                              (editor-handler/insert-command! id
                                                                              prefix format {:last-pattern last-pattern})
                                              (-> (editor-handler/save-block!
-                                                   (state/get-current-repo)
-                                                   (:block/uuid (state/get-edit-block))
-                                                   (.-value input))
-                                               (p/then #(commands/handle-step [:codemirror/focus])))
-                                             ))
+                                                  (state/get-current-repo)
+                                                  (:block/uuid (state/get-edit-block))
+                                                  (.-value input))
+                                                 (p/then #(commands/handle-step [:codemirror/focus])))))
                             :on-enter (fn []
                                         (state/clear-editor-action!)
                                         (commands/handle-step [:codemirror/focus]))
@@ -615,7 +615,7 @@
 (defn- exist-editor-commands-popup?
   []
   (some->> (shui-popup/get-popups)
-    (some #(some-> % (:id) (str) (string/starts-with? ":editor.commands")))))
+           (some #(some-> % (:id) (str) (string/starts-with? ":editor.commands")))))
 
 (defn- open-editor-popup!
   [id content opts]
@@ -643,61 +643,61 @@
 (rum/defc shui-editor-popups
   [id format action _data]
   (rum/use-effect!
-    (fn []
-      (let [pid (case action
-                  :commands
-                  (open-editor-popup! :commands
-                    (commands id format)
-                    {:content-props {:withoutAnimation false}})
-
-                  (:block-search :page-search :page-search-hashtag)
-                  (open-editor-popup! action
-                    (if (= :block-search action)
-                      (block-search id format)
-                      (page-search id format))
-                    {:root-props {:onOpenChange
-                                  #(when-not %
-                                     (when (contains?
-                                             #{:block-search :page-search :page-search-hashtag}
-                                             (state/get-editor-action))
-                                       (state/clear-editor-action!)))}})
-
-                  :datepicker
-                  (open-editor-popup! :datepicker
-                    (datetime-comp/date-picker id format nil) {})
-
-                  :input
-                  (open-editor-popup! :input
-                    (editor-input id
-                      (fn [command m]
-                        (editor-handler/handle-command-input command id format m))
-                      (fn []
-                        (editor-handler/handle-command-input-close id)))
-                    {:content-props {:onOpenAutoFocus #()}})
-
-                  :select-code-block-mode
-                  (open-editor-popup! :code-block-mode-picker
-                    (code-block-mode-picker id format) {})
-
-                  :template-search
-                  (open-editor-popup! :template-search
-                    (template-search id format) {})
-
-                  (:property-search :property-value-search)
-                  (open-editor-popup! action
-                    (if (= :property-search action)
-                      (property-search id) (property-value-search id))
-                    {})
-
-                  :zotero
-                  (open-editor-popup! :zotero
-                    (zotero/zotero-search id) {})
+   (fn []
+     (let [pid (case action
+                 :commands
+                 (open-editor-popup! :commands
+                                     (commands id format)
+                                     {:content-props {:withoutAnimation false}})
+
+                 (:block-search :page-search :page-search-hashtag)
+                 (open-editor-popup! action
+                                     (if (= :block-search action)
+                                       (block-search id format)
+                                       (page-search id format))
+                                     {:root-props {:onOpenChange
+                                                   #(when-not %
+                                                      (when (contains?
+                                                             #{:block-search :page-search :page-search-hashtag}
+                                                             (state/get-editor-action))
+                                                        (state/clear-editor-action!)))}})
+
+                 :datepicker
+                 (open-editor-popup! :datepicker
+                                     (datetime-comp/date-picker id format nil) {})
+
+                 :input
+                 (open-editor-popup! :input
+                                     (editor-input id
+                                                   (fn [command m]
+                                                     (editor-handler/handle-command-input command id format m))
+                                                   (fn []
+                                                     (editor-handler/handle-command-input-close id)))
+                                     {:content-props {:onOpenAutoFocus #()}})
+
+                 :select-code-block-mode
+                 (open-editor-popup! :code-block-mode-picker
+                                     (code-block-mode-picker id format) {})
+
+                 :template-search
+                 (open-editor-popup! :template-search
+                                     (template-search id format) {})
+
+                 (:property-search :property-value-search)
+                 (open-editor-popup! action
+                                     (if (= :property-search action)
+                                       (property-search id) (property-value-search id))
+                                     {})
+
+                 :zotero
+                 (open-editor-popup! :zotero
+                                     (zotero/zotero-search id) {})
 
                   ;; TODO: try remove local model state
-                  false)]
-        #(when pid
-           (shui/popup-hide! pid))))
-    [action])
+                 false)]
+       #(when pid
+          (shui/popup-hide! pid))))
+   [action])
   [:<>])
 
 (rum/defc command-popups <

+ 2 - 2
src/main/frontend/components/objects.cljs

@@ -137,7 +137,7 @@
        (views/view view-entity {:data data
                                 :set-data! set-data!
                                 :views-title (class-views class views view-entity {:set-view-entity! set-view-entity!
-                                                                       :set-views! set-views!})
+                                                                                   :set-views! set-views!})
                                 :columns columns
                                 :add-new-object! #(add-new-class-object! class set-data!)
                                 :show-add-property? true
@@ -165,7 +165,7 @@
   (when class
     (let [class (db/sub-block (:db/id class))
           config {:container-id (:container-id state)}
-          properties (cond->> (outliner-property/get-class-properties (db/get-db) class)
+          properties (cond->> (outliner-property/get-class-properties class)
                        (= :logseq.class/Root (:db/ident class))
                        (concat [(db/entity :block/tags)]))
           repo (state/get-current-repo)

+ 1 - 2
src/main/frontend/components/property.cljs

@@ -528,8 +528,7 @@
 (defn- async-load-classes!
   [block]
   (let [repo (state/get-current-repo)
-        db (db/get-db repo)
-        classes (concat (:block/tags block) (outliner-property/get-classes-parents db (:block/tags block)))]
+        classes (concat (:block/tags block) (outliner-property/get-classes-parents (:block/tags block)))]
     (doseq [class classes]
       (db-async/<get-block repo (:db/id class) :children? false))
     (when (ldb/class? block)

+ 1 - 3
src/main/frontend/components/property/value.cljs

@@ -773,7 +773,6 @@
   [property type value {:keys [page-cp inline-text other-position? _icon?] :as opts}]
   (let [closed-values? (seq (:property/closed-values property))
         tag? (or (:tag? opts) (= (:db/ident property) :block/tags))
-        parent? (= (:db/ident property) :logseq.property/parent)
         inline-text-cp (fn [content]
                          [:div.flex.flex-row.items-center
                           (inline-text {} :markdown (macro-util/expand-value-if-macro content (state/get-macros)))
@@ -796,8 +795,7 @@
          (rum/with-key
            (page-cp {:disable-preview? true
                      :tag? tag?
-                     :meta-click? other-position?
-                     :display-parent? (not parent?)} value)
+                     :meta-click? other-position?} value)
            (:db/id value)))
 
        (contains? #{:node :class :property :page} type)

+ 46 - 46
src/main/frontend/extensions/fsrs.cljs

@@ -316,57 +316,57 @@
         :block/tags
         (:db/id (db/entity :logseq.class/Card)))))))
 
-(defn- cards-in-time-range
-  [cards start-instant end-instant]
-  (assert (and (tick/instant? start-instant)
-               (tick/instant? end-instant))
-          [start-instant end-instant])
-  (->> cards
-       (filter (fn [card] (tick/<= start-instant (:last-repeat card) end-instant)))))
+(comment
+  (defn- cards-in-time-range
+    [cards start-instant end-instant]
+    (assert (and (tick/instant? start-instant)
+                 (tick/instant? end-instant))
+            [start-instant end-instant])
+    (->> cards
+         (filter (fn [card] (tick/<= start-instant (:last-repeat card) end-instant)))))
 
-(defn- cards-today
-  [cards]
-  (let [date-today (tick/new-date)
-        start-instant (tick/instant (tick/at date-today (tick/new-time 0 0)))
-        end-instant (tick/instant)]
-    (cards-in-time-range cards start-instant end-instant)))
+  (defn- cards-today
+    [cards]
+    (let [date-today (tick/new-date)
+          start-instant (tick/instant (tick/at date-today (tick/new-time 0 0)))
+          end-instant (tick/instant)]
+      (cards-in-time-range cards start-instant end-instant)))
 
-(defn- cards-recent-7-days
-  [cards]
-  (let [now-instant (tick/instant)
-        date-7-days-ago (tick/date (tick/<< now-instant (tick/new-duration 7 :days)))
-        start-instant (tick/instant (tick/at date-7-days-ago (tick/new-time 0 0)))
-        end-instant now-instant]
-    (cards-in-time-range cards start-instant end-instant)))
+  (defn- cards-recent-7-days
+    [cards]
+    (let [now-instant (tick/instant)
+          date-7-days-ago (tick/date (tick/<< now-instant (tick/new-duration 7 :days)))
+          start-instant (tick/instant (tick/at date-7-days-ago (tick/new-time 0 0)))
+          end-instant now-instant]
+      (cards-in-time-range cards start-instant end-instant)))
 
-(defn- cards-recent-30-days
-  [cards]
-  (let [now-instant (tick/instant)
-        date-30-days-ago (tick/date (tick/<< now-instant (tick/new-duration 30 :days)))
-        start-instant (tick/instant (tick/at date-30-days-ago (tick/new-time 0 0)))
-        end-instant now-instant]
-    (cards-in-time-range cards start-instant end-instant)))
+  (defn- cards-recent-30-days
+    [cards]
+    (let [now-instant (tick/instant)
+          date-30-days-ago (tick/date (tick/<< now-instant (tick/new-duration 30 :days)))
+          start-instant (tick/instant (tick/at date-30-days-ago (tick/new-time 0 0)))
+          end-instant now-instant]
+      (cards-in-time-range cards start-instant end-instant)))
 
-(defn- cards-stat
-  [cards]
-  (let [state-grouped-cards (group-by :state cards)
-        state-cards-count (update-vals state-grouped-cards count)
-        {new-count :new
-         learning-count :learning
-         review-count :review
-         relearning-count :relearning} state-cards-count
-        passed-repeat-count (count (filter #(contains? #{:good :easy} (:logseq/last-rating %)) cards))
-        lapsed-repeat-count (count (filter #(contains? #{:again :hard} (:logseq/last-rating %)) cards))
-        true-retention-percent (when (seq cards) (/ review-count (count cards)))]
-    {:true-retention true-retention-percent
-     :passed-repeats passed-repeat-count
-     :lapsed-repeats lapsed-repeat-count
-     :new-state-cards (or new-count 0)
-     :learning-state-cards (or learning-count 0)
-     :review-state-cards (or review-count 0)
-     :relearning-state-cards (or relearning-count 0)}))
+  (defn- cards-stat
+    [cards]
+    (let [state-grouped-cards (group-by :state cards)
+          state-cards-count (update-vals state-grouped-cards count)
+          {new-count :new
+           learning-count :learning
+           review-count :review
+           relearning-count :relearning} state-cards-count
+          passed-repeat-count (count (filter #(contains? #{:good :easy} (:logseq/last-rating %)) cards))
+          lapsed-repeat-count (count (filter #(contains? #{:again :hard} (:logseq/last-rating %)) cards))
+          true-retention-percent (when (seq cards) (/ review-count (count cards)))]
+      {:true-retention true-retention-percent
+       :passed-repeats passed-repeat-count
+       :lapsed-repeats lapsed-repeat-count
+       :new-state-cards (or new-count 0)
+       :learning-state-cards (or learning-count 0)
+       :review-state-cards (or review-count 0)
+       :relearning-state-cards (or relearning-count 0)}))
 
-(comment
   (defn <cards-stat
     "Some explanations on return value:
   :true-retention, cards in review-state / all-cards-count

+ 3 - 7
src/main/frontend/handler/block.cljs

@@ -150,8 +150,8 @@
         own-order-list-type  (some-> type str string/lower-case)
         own-order-list-index (some->> own-order-list-type (get-idx-of-order-list-block block))]
     (assoc config :own-order-list-type own-order-list-type
-                  :own-order-list-index own-order-list-index
-                  :own-order-number-list? (= own-order-list-type "number"))))
+           :own-order-list-index own-order-list-index
+           :own-order-number-list? (= own-order-list-type "number"))))
 
 (defn- text-range-by-lst-fst-line [content [direction pos]]
   (case direction
@@ -197,11 +197,8 @@
        (state/clear-edit! {:clear-editing-block? false}))
      (when-let [block-id (:block/uuid block)]
        (let [repo (state/get-current-repo)
-             db-graph? (config/db-based-graph? repo)
              block (or (db/entity [:block/uuid block-id]) block)
-             content (if (and db-graph? (:block/name block))
-                       (:block/title-with-refs-parent block)
-                       (or custom-content (:block/title-with-refs-parent block) ""))
+             content (or custom-content (:block/title block) "")
              content-length (count content)
              text-range (cond
                           (vector? pos)
@@ -403,7 +400,6 @@
                       :else
                       nil)))))))))))
 
-
 (defn on-touch-end
   [_event block uuid *show-left-menu? *show-right-menu?]
   (when @*swipe

+ 3 - 2
src/main/frontend/handler/editor.cljs

@@ -290,7 +290,7 @@
          block-id (when (and (not (config/db-based-graph? repo)) (map? properties))
                     (get properties :id))
          content (if (config/db-based-graph? repo)
-                   (:block/title-with-refs-parent (db/entity (:db/id block)))
+                   (:block/title (db/entity (:db/id block)))
                    (-> (property-file/remove-built-in-properties-when-file-based repo format title)
                        (drawer/remove-logbook)))]
      (cond
@@ -1658,7 +1658,8 @@
           matched (keep (fn [b]
                           (when-let [id (:block/uuid b)]
                             (when-not (= id (:block/uuid block)) ; avoid block self-reference
-                              (db/entity [:block/uuid id]))))
+                              (assoc (db/entity [:block/uuid id])
+                                     :block/title (:block/title b)))))
                         nodes)]
     (-> (concat matched
                 (when nlp-pages?

+ 18 - 23
src/main/frontend/handler/page.cljs

@@ -2,24 +2,34 @@
   "Provides util handler fns for pages"
   (:require [cljs.reader :as reader]
             [clojure.string :as string]
+            [datascript.core :as d]
+            [datascript.impl.entity :as de]
+            [electron.ipc :as ipc]
             [frontend.commands :as commands]
             [frontend.config :as config]
+            [frontend.context.i18n :refer [t]]
             [frontend.date :as date]
             [frontend.db :as db]
             [frontend.db.async :as db-async]
+            [frontend.db.conn :as conn]
             [frontend.db.model :as model]
             [frontend.fs :as fs]
             [frontend.handler.common :as common-handler]
             [frontend.handler.common.page :as page-common-handler]
+            [frontend.handler.db-based.page :as db-page-handler]
+            [frontend.handler.db-based.property :as db-property-handler]
             [frontend.handler.editor :as editor-handler]
-            [frontend.handler.plugin :as plugin-handler]
+            [frontend.handler.file-based.nfs :as nfs-handler]
+            [frontend.handler.graph :as graph-handler]
             [frontend.handler.notification :as notification]
+            [frontend.handler.plugin :as plugin-handler]
             [frontend.handler.property :as property-handler]
-            [frontend.handler.db-based.property :as db-property-handler]
+            [frontend.handler.property.util :as pu]
             [frontend.handler.ui :as ui-handler]
-            [frontend.handler.file-based.nfs :as nfs-handler]
-            [frontend.handler.graph :as graph-handler]
             [frontend.mobile.util :as mobile-util]
+            [frontend.modules.outliner.op :as outliner-op]
+            [frontend.modules.outliner.ui :as ui-outliner-tx]
+            [frontend.persist-db.browser :as db-browser]
             [frontend.state :as state]
             [frontend.util :as util]
             [frontend.util.cursor :as cursor]
@@ -29,24 +39,13 @@
             [goog.object :as gobj]
             [lambdaisland.glogi :as log]
             [logseq.common.config :as common-config]
+            [logseq.common.path :as path]
             [logseq.common.util :as common-util]
-            [logseq.common.util.page-ref :as page-ref]
             [logseq.common.util.block-ref :as block-ref]
-            [promesa.core :as p]
-            [logseq.common.path :as path]
-            [electron.ipc :as ipc]
-            [frontend.context.i18n :refer [t]]
-            [frontend.persist-db.browser :as db-browser]
-            [datascript.core :as d]
-            [frontend.db.conn :as conn]
+            [logseq.common.util.page-ref :as page-ref]
             [logseq.db :as ldb]
             [logseq.graph-parser.db :as gp-db]
-            [frontend.modules.outliner.ui :as ui-outliner-tx]
-            [frontend.modules.outliner.op :as outliner-op]
-            [frontend.handler.property.util :as pu]
-            [datascript.impl.entity :as de]
-            [frontend.handler.db-based.page :as db-page-handler]
-            [logseq.common.util.namespace :as ns-util]))
+            [promesa.core :as p]))
 
 (def <create! page-common-handler/<create!)
 (def <delete! page-common-handler/<delete!)
@@ -80,7 +79,6 @@
          (page-common-handler/db-favorited? page-block-uuid)))
       (page-common-handler/file-favorited? page-name))))
 
-
 (defn get-favorites
   "return page-block entities"
   []
@@ -99,7 +97,6 @@
                               (distinct))]
           (keep (fn [page-name] (db/get-page page-name)) page-names))))))
 
-
 ;; FIXME: add whiteboard
 (defn- get-directory
   [journal?]
@@ -375,9 +372,7 @@
                                   :create-first-block? false
                                   :split-namespace? true})))
             ref-text' (if result
-                        (let [title (if-let [parent (:logseq.property/parent result)]
-                                      (str (:block/title parent) ns-util/parent-char (:block/title result))
-                                      (:block/title result))]
+                        (let [title (:block/title result)]
                           (page-ref/->page-ref title))
                         ref-text)]
       (p/do!

+ 5 - 6
src/main/frontend/worker/search.cljs

@@ -105,7 +105,7 @@ DROP TRIGGER IF EXISTS blocks_au;
                            (js/console.error "Upsert blocks wrong data: ")
                            (js/console.dir item)
                            (throw (ex-info "Search upsert-blocks wrong data: "
-                                          (bean/->clj item)))))))))
+                                           (bean/->clj item)))))))))
 
 (defn delete-blocks!
   [db ids]
@@ -220,10 +220,7 @@ DROP TRIGGER IF EXISTS blocks_au;
       ;; (let [content (if (and db-based? (seq (:block/properties block)))
       ;;                 (str content (when (not= content "") "\n") (get-db-properties-str db properties))
       ;;                 content)])
-    (let [parent (:logseq.property/parent block)
-          title (if (and parent (= "page" (:block/type block)))
-                  (str (:block/title parent) ns-util/parent-char title)
-                  title)]
+    (let [title (ldb/get-title-with-parents block)]
       (when uuid
         {:id (str uuid)
          :page (str (or (:block/uuid page) uuid))
@@ -307,7 +304,9 @@ DROP TRIGGER IF EXISTS blocks_au;
                                                   (ldb/class? block))))
                                       {:db/id (:db/id block)
                                        :block/uuid block-id
-                                       :block/title (or snippet title)
+                                       :block/title (if (ldb/page? block)
+                                                      (ldb/get-title-with-parents block)
+                                                      (or snippet title))
                                        :block/page (if (common-util/uuid-string? page)
                                                      (uuid page)
                                                      nil)