mirror of https://github.com/logseq/logseq
fix: tests
parent
e6bc77e8b5
commit
fbb8f96191
|
@ -308,13 +308,11 @@
|
||||||
|
|
||||||
(defn create-new-block!
|
(defn create-new-block!
|
||||||
[block property value]
|
[block property value]
|
||||||
(let [repo (state/get-current-repo)
|
(let [last-block-id (db-property-handler/create-property-text-block! block property value
|
||||||
{:keys [page blocks]} (db-property-handler/property-create-new-block block property value editor-handler/wrap-parse-block)
|
editor-handler/wrap-parse-block
|
||||||
last-block-id (:block/uuid (last blocks))]
|
|
||||||
(db/transact! repo (if page (cons page blocks) blocks) {:outliner-op :insert-blocks})
|
{})]
|
||||||
(add-property! block (:block/original-name property) (:block/uuid (first blocks)))
|
(editor-handler/edit-block! (db/entity [:block/uuid last-block-id]) :max last-block-id)))
|
||||||
(editor-handler/edit-block! (db/entity [:block/uuid last-block-id]) :max last-block-id)
|
|
||||||
last-block-id))
|
|
||||||
|
|
||||||
(defn create-new-block-from-template!
|
(defn create-new-block-from-template!
|
||||||
"`template`: tag block"
|
"`template`: tag block"
|
||||||
|
|
|
@ -592,6 +592,21 @@
|
||||||
{:page page-tx
|
{:page page-tx
|
||||||
:blocks [parent child-1]}))
|
:blocks [parent child-1]}))
|
||||||
|
|
||||||
|
(defn create-property-text-block!
|
||||||
|
[block property value parse-block {:keys [class-schema?]}]
|
||||||
|
(let [repo (state/get-current-repo)
|
||||||
|
{:keys [page blocks]} (property-create-new-block block property value parse-block)
|
||||||
|
first-block (first blocks)
|
||||||
|
last-block-id (:block/uuid (last blocks))
|
||||||
|
class? (contains? (:block/type block) "class")
|
||||||
|
property-key (:block/original-name property)]
|
||||||
|
(db/transact! repo (if page (cons page blocks) blocks) {:outliner-op :insert-blocks})
|
||||||
|
(when property-key
|
||||||
|
(if (and class? class-schema?)
|
||||||
|
(class-add-property! repo (:block/uuid block) property-key)
|
||||||
|
(set-block-property! repo (:block/uuid block) property-key (:block/uuid first-block) {})))
|
||||||
|
last-block-id))
|
||||||
|
|
||||||
(defn property-create-new-block-from-template
|
(defn property-create-new-block-from-template
|
||||||
[block property template]
|
[block property template]
|
||||||
(let [current-page-id (:block/uuid (or (:block/page block) block))
|
(let [current-page-id (:block/uuid (or (:block/page block) block))
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
[frontend.handler.property.util :as pu]
|
[frontend.handler.property.util :as pu]
|
||||||
[frontend.state :as state]
|
[frontend.state :as state]
|
||||||
[frontend.handler.page :as page-handler]
|
[frontend.handler.page :as page-handler]
|
||||||
[frontend.handler.editor :as editor-handler]
|
[frontend.handler.editor :as editor-handler]))
|
||||||
[frontend.components.property.value :as component-pv]))
|
|
||||||
|
|
||||||
(def repo test-helper/test-db-name-db-version)
|
(def repo test-helper/test-db-name-db-version)
|
||||||
|
|
||||||
|
@ -291,7 +290,7 @@
|
||||||
;; add property
|
;; add property
|
||||||
(db-property-handler/upsert-property! repo k {:type :default} {})
|
(db-property-handler/upsert-property! repo k {:type :default} {})
|
||||||
(let [property (db/entity [:block/name k])
|
(let [property (db/entity [:block/name k])
|
||||||
last-block-id (component-pv/create-new-block! fb property "Block content")
|
last-block-id (db-property-handler/create-property-text-block! fb property "Block content" editor-handler/wrap-parse-block {})
|
||||||
{:keys [from-block-id from-property-id]} (db-property-handler/get-property-block-created-block [:block/uuid last-block-id])]
|
{:keys [from-block-id from-property-id]} (db-property-handler/get-property-block-created-block [:block/uuid last-block-id])]
|
||||||
(is (= from-block-id (:db/id fb)))
|
(is (= from-block-id (:db/id fb)))
|
||||||
(is (= from-property-id (:db/id property)))))))
|
(is (= from-property-id (:db/id property)))))))
|
||||||
|
|
Loading…
Reference in New Issue