Преглед изворни кода

fix: namespace whiteboard pages import

Tienson Qin пре 2 година
родитељ
комит
70406332dc

+ 4 - 3
deps/graph-parser/src/logseq/graph_parser/block.cljs

@@ -294,9 +294,10 @@
        {:block/name page-name
         :block/original-name original-page-name}
        (when with-id?
-         (let [new-uuid (cond page-entity      (:block/uuid page-entity)
-                              (uuid? with-id?) with-id?
-                              :else            (d/squuid))]
+         (let [new-uuid (or
+                         (cond page-entity      (:block/uuid page-entity)
+                               (uuid? with-id?) with-id?)
+                         (d/squuid))]
            {:block/uuid new-uuid}))
        (when namespace?
          (let [namespace (first (gp-util/split-last "/" original-page-name))]

+ 9 - 7
deps/graph-parser/src/logseq/graph_parser/util.cljs

@@ -116,13 +116,15 @@
 (defn split-namespace-pages
   [title]
   (let [parts (string/split title "/")]
-    (loop [others (rest parts)
-           result [(first parts)]]
-      (if (seq others)
-        (let [prev (last result)]
-          (recur (rest others)
-                 (conj result (str prev "/" (first others)))))
-        result))))
+    (->>
+     (loop [others (rest parts)
+            result [(first parts)]]
+       (if (seq others)
+         (let [prev (last result)]
+           (recur (rest others)
+                  (conj result (str prev "/" (first others)))))
+         result))
+     (map string/trim))))
 
 (defn decode-namespace-underlines
   "Decode namespace underlines to slashed;

+ 2 - 1
src/main/frontend/handler/import.cljs

@@ -122,7 +122,8 @@
    :properties - map
    "
   [{:keys [type uuid title children properties] :as tree}]
-  (let [has-children? (seq children)
+  (let [title (string/trim title)
+        has-children? (seq children)
         page-format (or (some-> tree (:children) (first) (:format)) :markdown)
         whiteboard? (= type "whiteboard")]
     (try (page-handler/create! title {:redirect?           false

+ 1 - 1
src/main/frontend/handler/page.cljs

@@ -158,7 +158,7 @@
                              ;; only apply uuid to the deepest hierarchy of page to create if provided.
                              (-> (block/page-name->map page (if (= page title) with-uuid? true))
                                  (assoc :block/format format)))
-                           pages)
+                        pages)
              txs      (->> pages
                            ;; for namespace pages, only last page need properties
                            drop-last