Tienson Qin 2 лет назад
Родитель
Сommit
2913af2d96

+ 4 - 16
src/main/frontend/components/block.cljs

@@ -2741,7 +2741,7 @@
     (nil? (:query-result config))
     (assoc :query-result (atom nil))
 
-    (:ref? config)
+    true
     (block-handler/attach-order-list-state block)))
 
 (defn- build-block [config block* {:keys [navigating-block navigated?]}]
@@ -2878,12 +2878,6 @@
 
      (dnd-separator-wrapper block block-id slide? false false)]))
 
-(defn- attach-order-list-state!
-  [cp-state]
-  (let [args (:rum/args cp-state)]
-    (assoc cp-state
-      :rum/args (assoc (vec args) 0 (block-handler/attach-order-list-state (first args) (second args))))))
-
 (defn- block-changed?
   [old-block new-block]
   (let [ks [:block/uuid :block/content :block/collapsed?
@@ -2916,15 +2910,9 @@
 
                :else
                nil)
-             (-> (assoc state
-                   ::control-show? (atom false)
-                   ::navigating-block (atom (:block/uuid block)))
-                 (attach-order-list-state!))))
-
-   :will-remount (fn [_old-state new-state]
-                   (-> new-state
-                       (attach-order-list-state!)))
-
+             (assoc state
+                    ::control-show? (atom false)
+                    ::navigating-block (atom (:block/uuid block)))))
    :should-update (fn [old-state new-state]
                     (let [config-compare-keys [:show-cloze? :hide-children? :own-order-list-type :own-order-list-index]
                           b1                  (second (:rum/args old-state))

+ 3 - 0
src/main/frontend/db/utils.cljs

@@ -129,6 +129,9 @@
    (when-not config/publishing?
      (let [tx-data (gp-util/fast-remove-nils tx-data)]
        (when (seq tx-data)
+         ;; (prn :debug "DB transact:")
+         ;; (frontend.util/pprint {:tx-data tx-data
+         ;;                        :tx-meta tx-meta})
          (when-let [conn (conn/get-db repo-url false)]
            (if tx-meta
              (d/transact! conn (vec tx-data) tx-meta)

+ 5 - 1
src/main/frontend/handler/editor.cljs

@@ -86,7 +86,8 @@
 
 (defn own-order-number-list?
   [block]
-  (= (get-block-own-order-list-type block) "number"))
+  (when-let [block (db/entity (:db/id block))]
+    (= (get-block-own-order-list-type block) "number")))
 
 (defn make-block-as-own-order-list!
   [block]
@@ -717,6 +718,7 @@
    (delete-block! repo true))
   ([repo delete-children?]
    (state/set-editor-op! :delete)
+   (prn :debug 0)
    (let [{:keys [id block-id block-parent-id value format config]} (get-state)]
      (when block-id
        (let [page-id (:db/id (:block/page (db/entity [:block/uuid block-id])))
@@ -730,8 +732,10 @@
                                          (when-let [block-id (:block/uuid (:data left))]
                                            (let [block (db/entity [:block/uuid block-id])]
                                              (seq (:block/_parent block)))))]
+             (prn :debug 1)
              (when-not (and has-children? left-has-children?)
                (when block-parent-id
+                 (prn :debug 2)
                  (let [block-parent (gdom/getElement block-parent-id)
                        sibling-block (if (:embed? config)
                                        (util/get-prev-block-non-collapsed

+ 3 - 2
src/main/frontend/handler/property/util.cljs

@@ -20,5 +20,6 @@
 (defn get-property
   "Get the value of block's property `key`"
   [block key]
-  (when-let [properties (:block/properties block)]
-    (lookup properties key)))
+  (let [block (db/entity (:db/id block))]
+    (when-let [properties (:block/properties block)]
+     (lookup properties key))))

+ 12 - 8
src/main/frontend/modules/outliner/core.cljs

@@ -254,19 +254,23 @@
                 gp-util/remove-nils
                 block-with-timestamps
                 fix-tag-ids)
-          m (if (config/db-based-graph? (state/get-current-repo))
-              (dissoc m* :block/properties :block/properties-order :block/properties-text-values)
+          repo (state/get-current-repo)
+          db-based? (config/db-based-graph? repo)
+          m (if db-based?
+              (dissoc m* :block/properties :block/properties-order)
               m*)
           id (:db/id (:data this))
           block-entity (db/entity id)]
       (when id
         ;; Retract attributes to prepare for tx which rewrites block attributes
-        (swap! txs-state (fn [txs]
-                           (vec
-                            (concat txs
-                                    (map (fn [attribute]
-                                           [:db/retract id attribute])
-                                         db-schema/retract-attributes)))))
+        (let [retract-attributes (if db-based?
+                                   (remove #{:block/properties :block/properties-order} db-schema/retract-attributes))]
+          (swap! txs-state (fn [txs]
+                            (vec
+                             (concat txs
+                                     (map (fn [attribute]
+                                            [:db/retract id attribute])
+                                       retract-attributes))))))
 
         ;; Update block's page attributes
         (update-page-when-save-block txs-state block-entity m)

+ 2 - 2
src/main/frontend/modules/outliner/datascript.cljs

@@ -166,8 +166,8 @@
                    (not (contains? (:file/unlinked-dirs @state/state)
                                    (config/get-repo-dir repo)))))
 
-      ;; (prn :debug "Outliner transact:")
-      ;; (frontend.util/pprint {:txs txs :opts opts})
+      (prn :debug "Outliner transact:")
+      (frontend.util/pprint {:txs txs :opts opts})
 
       (try
         (let [repo (get opts :repo (state/get-current-repo))