Browse Source

Introduce node (a page or a block)

Tienson Qin 1 year ago
parent
commit
cef3a9f456

+ 6 - 3
src/main/frontend/commands.cljs

@@ -280,10 +280,10 @@
     (->>
      (concat
         ;; basic
-      [[(if db? "Block reference" "Page reference")
+      [[(if db? "Node reference" "Page reference")
         [[:editor/input page-ref/left-and-right-brackets {:backward-pos 2}]
          [:editor/search-page]]
-        (if db? "Create a backlink to a page"
+        (if db? "Create a backlink to a node (a page or a block)"
             "Create a backlink to a BLOCK")
         :icon/pageRef
         "BASIC"]
@@ -292,7 +292,10 @@
          ["Block reference" [[:editor/input block-ref/left-and-right-parens {:backward-pos 2}]
                              [:editor/search-block :reference]]
           "Create a backlink to a block" :icon/blockRef])
-       ["Block embed" (embed-block) "Embed a block here" :icon/blockEmbed]]
+       [(if db? "Node embed" "Block embed")
+        (embed-block)
+        (if db? "Embed a node here" "Embed a block here")
+        :icon/blockEmbed]]
 
         ;; format
       [["Link" (link-steps) "Create a HTTP link" :icon/link "FORMAT"]

+ 10 - 10
src/main/frontend/components/cmdk/core.cljs

@@ -48,7 +48,7 @@
 
 (def search-actions
   [{:filter {:group :current-page} :text "Search only current page" :info "Add filter to search" :icon-theme :gray :icon "page"}
-   {:filter {:group :blocks} :text "Search only blocks" :info "Add filter to search" :icon-theme :gray :icon "block"}
+   {:filter {:group :nodes} :text "Search only nodes" :info "Add filter to search" :icon-theme :gray :icon "block"}
    {:filter {:group :commands} :text "Search only commands" :info "Add filter to search" :icon-theme :gray :icon "command"}
    {:filter {:group :files} :text "Search only files" :info "Add filter to search" :icon-theme :gray :icon "file"}
    {:filter {:group :themes} :text "Search only themes" :info "Add filter to search" :icon-theme :gray :icon "palette"}])
@@ -60,7 +60,7 @@
   {:commands       {:status :success :show :less :items nil}
    :favorites      {:status :success :show :less :items nil}
    :current-page   {:status :success :show :less :items nil}
-   :blocks         {:status :success :show :less :items nil}
+   :nodes         {:status :success :show :less :items nil}
    :files          {:status :success :show :less :items nil}
    :themes         {:status :success :show :less :items nil}
    :filters        {:status :success :show :less :items nil}})
@@ -99,7 +99,7 @@
 
                             :else
                             (take 5 items))))
-        node-exists? (let [blocks-result (keep :source-block (get-in results [:blocks :items]))]
+        node-exists? (let [blocks-result (keep :source-block (get-in results [:nodes :items]))]
                        (when-not (string/blank? input)
                          (or (db/get-page (string/trim input))
                              (some (fn [block]
@@ -117,12 +117,12 @@
                     ["Create"         :create         (create-items input)])
 
                   ["Current page"   :current-page   (visible-items :current-page)]
-                  ["Blocks"         :blocks         (visible-items :blocks)]
+                  ["Nodes"         :nodes         (visible-items :nodes)]
                   ["Files"          :files          (visible-items :files)]
                   ["Filters" :filters (visible-items :filters)]]
 
                  filter-group
-                 [(when (= filter-group :blocks)
+                 [(when (= filter-group :nodes)
                     ["Current page"   :current-page   (visible-items :current-page)])
                   [(if (= filter-group :current-page) "Current page" (name filter-group))
                    filter-group
@@ -135,7 +135,7 @@
                   [(when-not node-exists?
                      ["Create"         :create       (create-items input)])
                    ["Current page"   :current-page   (visible-items :current-page)]
-                   ["Blocks"         :blocks         (visible-items :blocks)]
+                   ["Nodes"         :nodes         (visible-items :nodes)]
                    ["Commands"       :commands       (visible-items :commands)]
                    ["Files"          :files          (visible-items :files)]
                    ["Filters"        :filters        (visible-items :filters)]]
@@ -241,7 +241,7 @@
      :source-block block}))
 
 ;; The blocks search action uses an existing handler
-(defmethod load-results :blocks [group state]
+(defmethod load-results :nodes [group state]
   (let [!input (::input state)
         !results (::results state)
         repo (state/get-current-repo)
@@ -355,7 +355,7 @@
         (load-results filter-group state)
         (do
           (load-results :commands state)
-          (load-results :blocks state)
+          (load-results :nodes state)
           (load-results :filters state)
           (load-results :files state)
           ;; (load-results :recents state)
@@ -622,7 +622,7 @@
                                                        (not (:mouse-enter-triggered-highlight @(::highlighted-item state))))
                                               (scroll-into-view-when-invisible state (.-current ref)))))
                      nil)]
-           (if (= group :blocks)
+           (if (= group :nodes)
              (ui/lazy-visible (fn [] item) {:trigger-once? true})
              item)))]]]))
 
@@ -977,7 +977,7 @@
                       (and (not= 0 group-count)
                         (if-not group-filter true
                                              (or (= group-filter group-key)
-                                               (and (= group-filter :blocks)
+                                               (and (= group-filter :nodes)
                                                  (= group-key :current-page))
                                                (and (contains? #{:create} group-filter)
                                                  (= group-key :create))))))

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

@@ -189,7 +189,7 @@
                           (search-handler/highlight-exact-query title q))])
         :empty-placeholder [:div.text-gray-500.text-sm.px-4.py-2 (if db-tag?
                                                                    "Search for a class"
-                                                                   "Search for a block")]
+                                                                   "Search for a node")]
         :class       "black"}))))
 
 (rum/defc page-search < rum/reactive