fix: multiple values

This commit is contained in:
Tienson Qin
2023-08-08 15:48:57 +08:00
parent 2e5a216e62
commit de6669fce0
3 changed files with 14 additions and 24 deletions

View File

@@ -320,25 +320,18 @@
(let [config {:editor-opts
{:on-key-down
(fn [e]
(let [enter? (= (util/ekey e) "Enter")]
(when (and (contains? #{"Enter" "Escape"} (util/ekey e))
(not (state/get-editor-action)))
(util/stop e)
(property-handler/set-block-property! repo (:block/uuid block)
(:block/original-name property)
(util/evalue e)
:old-value value)
(exit-edit-property)
(when (and enter? multiple-values?)
(let [values-count (-> (:block/properties (db/entity (:db/id block)))
(get (:block/uuid property))
(count))
editor-id (str "ls-property-" blocks-container-id "-" (:db/id block) "-" (:db/id property) "-" values-count)]
(set-editing! property editor-id nil ""))))))}}]
(editor-box editor-args editor-id (cond-> config
multiple-values?
(assoc :property-value value)))))]
(when (and (contains? #{"Enter" "Escape"} (util/ekey e))
(not (state/get-editor-action)))
(util/stop e)
(property-handler/set-block-property! repo (:block/uuid block)
(:block/original-name property)
(util/evalue e)
:old-value value)
(when editing-atom (reset! editing-atom false))
(exit-edit-property)))}}]
[:div.pl-1 (editor-box editor-args editor-id (cond-> config
multiple-values?
(assoc :property-value value)))]))]
(let [class (str (when-not row? "flex flex-1 ")
(when multiple-values? "property-value-content"))]
[:div {:id (or dom-id (random-uuid))
@@ -566,7 +559,7 @@
(cond
@*editing?
(property-scalar-value block property v
(property-scalar-value block property ""
(merge
opts
{:editor-args editor-args

View File

@@ -739,7 +739,6 @@
(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])))
@@ -753,10 +752,8 @@
(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
@@ -795,7 +792,6 @@
opts (cond-> {:outliner-op :delete-blocks}
(config/db-based-graph? repo)
(assoc :persist-op? true :repo repo))]
(prn {:blocks blocks})
(outliner-tx/transact!
opts
(outliner-core/delete-blocks! blocks {}))

View File

@@ -1186,6 +1186,7 @@ Similar to re-frame subscriptions"
(swap! state merge {:editor/editing? nil
:cursor-range nil
:editor/last-saved-cursor nil})
(set-state! :editor/content {})
(set-state! :editor/block nil))
(defn into-code-editor-mode!