瀏覽代碼

Merge branch 'feat/db' into enhance/plugin-web

charlie 10 月之前
父節點
當前提交
6773542473

+ 12 - 10
deps/shui/src/logseq/shui/shortcut/v1.cljs

@@ -62,26 +62,28 @@
                                      "bg-transparent cursor-default active:bg-gray-03 hover:text-gray-11 opacity-80"))
                        :size size}
                       (for [[index tile] (map-indexed vector tiles)]
-                        [:<>
-                         (when (< 0 index)
-                           [:span.ui__button__tile-separator])
-                         [:span.ui__button__tile tile]]))))
+                        [:span {:key index}
+                         [:<>
+                          (when (< 0 index)
+                            [:span.ui__button__tile-separator])
+                          [:span.ui__button__tile tile]]]))))
 
 (rum/defc root
   [shortcut & {:keys [size theme interactive?]
-               :or   {size  :xs
-                      interactive? true
-                      theme :gray}}]
+               :or {size :xs
+                    interactive? true
+                    theme :gray}}]
   (when (seq shortcut)
     (let [shortcuts (if (coll? shortcut)
                       [shortcut]
                       (parse-shortcuts shortcut))
           opts {:interactive? interactive?}]
       (for [[index binding] (map-indexed vector shortcuts)]
-        [:<>
+        [:span
+         {:key (str index)}
          (when (< 0 index)
-           [:div.text-gray-11.text-sm {:key "sep"} "|"])
-         (if (coll? (first binding))   ; + included
+           [:span.text-gray-11.text-sm {:key "sep"} "|"])
+         (if (coll? (first binding))                        ; + included
            (for [[idx ks] (map-indexed vector binding)]
              (rum/with-key
                (part ks size opts)

+ 10 - 3
deps/shui/src/logseq/shui/util.cljs

@@ -59,12 +59,19 @@
   (let [[opts children] (if (map? (first args))
                           [(first args) (rest args)]
                           [{} args])
+        children (some->> children (remove nil?))
         type# (first children)
+        children# (daiquiri.interpreter/interpret children)
+        children# (if (= 1 (count children#)) (first children#) children#)
         ;; we have to make sure to check if the children is sequential
         ;; as a list can be returned, eg: from a (for)
-        new-children (if (sequential? type#)
-                       [(daiquiri.interpreter/interpret children)]
-                       (daiquiri.interpreter/interpret children))
+        new-children (if (and (not (nil? children#))
+                           (not (empty? children))
+                           (or (not (array? children#))
+                             ;; maybe list children
+                             (not (vector? type#))))
+                       [children#] children#)
+
         ;; convert any options key value to a React element, if
         ;; a valid html element tag is used, using sablono (rum.daiquiri)
         vector->react-elems (fn [[key val]]

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

@@ -2630,7 +2630,7 @@
            (db-property-handler/delete-property-value! (:db/id block) :block/tags (:db/id tag)))}
         (ui/icon "x" {:size 14
                       :style {:margin-top 1}})]
-       [:a.hash-symbol {:style {:margin-left 5}}
+       [:a.hash-symbol.select-none {:style {:margin-left 5}}
         "#"])
      (page-cp (assoc config
                      :disable-preview? true
@@ -4130,7 +4130,7 @@
     (when (seq blocks)
       [:div.blocks-container.flex-1
        {:class (when doc-mode? "document-mode")
-        :container-id (:container-id state)}
+        :containerid (:container-id state)}
        (block-list (assoc config :container-id (:container-id state))
                    blocks)])))
 

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

@@ -372,7 +372,7 @@
           :title (block-handler/block-unique-title page)
           :draggable true
           :on-drag-start (fn [event] (editor-handler/block->data-transfer! (:block/name page) event true))
-          :data-ref name}
+          :data-ref (str name)}
          (page-name page (icon/get-node-icon-cp page {:size 16}) true)])])))
 
 (defn get-default-home-if-valid
@@ -380,7 +380,7 @@
   (when-let [default-home (state/get-default-home)]
     (let [page (:page default-home)
           page (when (and (string? page)
-                          (not (string/blank? page)))
+                       (not (string/blank? page)))
                  (db/get-page page))]
       (if page
         default-home

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

@@ -94,7 +94,7 @@
                        :else
                        (rum/with-key (sortable-item prop (:content item)) id))))
         children' (if parent-node
-                    [parent-node children]
+                    [parent-node {:key "parent-node"} children]
                     children)]
     (dnd-context
      dnd-opts

+ 19 - 9
src/main/frontend/worker/db/migrate.cljs

@@ -597,24 +597,34 @@
                               (= (:db/ident data) :logseq.kv/schema-version)
                               nil
 
-                              (:db/ident data)
-                              data
-
-                              (:block/name data)
-                              (if-let [page (ldb/get-page @conn (:block/name data))]
+                              (:block/uuid data)
+                              (if-let [block (d/entity @conn [:block/uuid (:block/uuid data)])]
                                 (do
-                                  (swap! *uuids assoc (:block/uuid data) (:block/uuid page))
-                                  (assoc data :block/uuid (:block/uuid page)))
+                                  (swap! *uuids assoc (:block/uuid data) (:block/uuid block))
+                                  (let [existing-data (assoc (into {} block) :db/id (:db/id block))]
+                                    (reduce
+                                     (fn [data [k existing-value]]
+                                       (update data k
+                                               (fn [v]
+                                                 (if (and (coll? v) (not (map? v)))
+                                                   (concat v (if (coll? existing-value) existing-value [existing-value]))
+                                                   (if (some? existing-value) existing-value v)))))
+                                     data
+                                     existing-data)))
                                 data)
 
                               :else
                               data)
                             data))))
         ;; using existing page's uuid
-        data' (walk/postwalk
+        data' (walk/prewalk
                (fn [f]
-                 (if (and (vector? f) (= :block/uuid (first f)) (@*uuids (second f)))
+                 (cond
+                   (and (de/entity? f) (:block/uuid f))
+                   (or (:db/ident f) [:block/uuid (:block/uuid f)])
+                   (and (vector? f) (= :block/uuid (first f)) (@*uuids (second f)))
                    [:block/uuid (@*uuids (second f))]
+                   :else
                    f))
                data)]
     (d/transact! conn data' {:fix-db? true