fix: remove non existed block refs when saving a block to avoid blank page

pull/1808/head
Tienson Qin 2021-05-11 17:54:31 +08:00
parent 83c481ab09
commit ac7f6e1967
1 changed files with 7 additions and 0 deletions

View File

@ -278,6 +278,12 @@
:db/other-tx page-tx))
block))
(defn- remove-non-existed-refs!
[refs]
(remove (fn [x] (and (vector? x)
(= :block/uuid (first x))
(nil? (db/entity x)))) refs))
(defn- wrap-parse-block
[{:block/keys [content format parent left page uuid pre-block?] :as block}]
(let [block (or (db/pull (:db/id block)) block)
@ -312,6 +318,7 @@
block (if (and first-block? (:block/pre-block? block))
block
(dissoc block :block/pre-block?))
block (update block :block/refs remove-non-existed-refs!)
block (attach-page-properties-if-exists! block)
new-properties (merge
(select-keys properties text/built-in-properties)