feat(ui): WIP number list block (own-property)

This commit is contained in:
charlie
2023-04-14 18:37:31 +08:00
parent 8d6e9b7cfd
commit 1043eff9cd
2 changed files with 34 additions and 2 deletions

View File

@@ -62,6 +62,31 @@
(defonce *asset-uploading? (atom false))
(defonce *asset-uploading-process (atom 0))
(declare set-block-property!)
(declare remove-block-property!)
(defn get-block-own-order-list-type
[block]
(some-> block :block/properties :logseq.order-list-type))
(defn set-block-own-order-list-type!
[block type]
(when-let [uuid (:block/uuid block)]
(set-block-property! uuid :logseq.order-list-type (name type))))
(defn remove-block-own-order-list-type!
[block]
(when-let [uuid (:block/uuid block)]
(remove-block-property! uuid :logseq.order-list-type)))
(defn own-order-list?
[block]
(not (string/blank? (get-block-own-order-list-type block))))
(defn own-order-number-list?
[block]
(= (get-block-own-order-list-type block) "number"))
(defn get-selection-and-format
[]
(when-let [block (state/get-edit-block)]
@@ -558,7 +583,9 @@
{:ok-handler
(fn [last-block]
(clear-when-saved!)
(edit-block! last-block 0 id))}))))
(edit-block! last-block 0 id)
(when-let [order-list-type (and (own-order-list? block) (get-block-own-order-list-type block))]
(set-block-own-order-list-type! last-block order-list-type)))}))))
(state/set-editor-op! nil)))
(defn api-insert-new-block!
@@ -2466,6 +2493,7 @@
(let [{:keys [block config]} (get-state)]
(when block
(let [input (state/get-input)
config (assoc config :keydown-new-block true)
content (gobj/get input "value")
pos (cursor/pos input)
current-node (outliner-core/block block)
@@ -2508,6 +2536,10 @@
"list-item" (dwim-in-list)
"properties-drawer" (dwim-in-properties state))
(and (string/blank? content)
(own-order-number-list? block))
(remove-block-own-order-list-type! block)
(and
(string/blank? content)
(not has-right?)