|
|
@@ -214,6 +214,17 @@
|
|
|
(container config' row)
|
|
|
[:div])]))
|
|
|
|
|
|
+(defn- save-block-and-focus
|
|
|
+ [*ref set-focus-timeout! hide-popup?]
|
|
|
+ (let [node (rum/deref *ref)
|
|
|
+ cell (util/rec-get-node node "ls-table-cell")]
|
|
|
+ (p/do!
|
|
|
+ (editor-handler/save-current-block!)
|
|
|
+ (when hide-popup?
|
|
|
+ (shui/popup-hide!))
|
|
|
+ (state/exit-editing-and-set-selected-blocks! [cell])
|
|
|
+ (set-focus-timeout! (js/setTimeout #(.focus cell) 100)))))
|
|
|
+
|
|
|
(rum/defc block-title
|
|
|
"Used on table view"
|
|
|
[block* {:keys [create-new-block width row property]}]
|
|
|
@@ -256,9 +267,16 @@
|
|
|
[:div.ls-table-block.flex.flex-row.items-start
|
|
|
{:style {:width width :max-width width :margin-right "6px"}
|
|
|
:on-click util/stop-propagation}
|
|
|
- (block-container {:popup? true
|
|
|
- :view? true
|
|
|
- :table-block-title? true} block)])))]
|
|
|
+ (block-container
|
|
|
+ {:popup? true
|
|
|
+ :view? true
|
|
|
+ :table-block-title? true
|
|
|
+ :on-key-down
|
|
|
+ (fn [e]
|
|
|
+ (when (= (util/ekey e) "Enter")
|
|
|
+ (util/stop e)
|
|
|
+ (save-block-and-focus *ref set-focus-timeout! true)))}
|
|
|
+ block)])))]
|
|
|
(p/do!
|
|
|
(shui/popup-show!
|
|
|
(.closest (.-target e) ".ls-table-cell")
|
|
|
@@ -266,12 +284,7 @@
|
|
|
{:id :ls-table-block-editor
|
|
|
:as-mask? true
|
|
|
:on-after-hide (fn []
|
|
|
- (let [node (rum/deref *ref)
|
|
|
- cell (util/rec-get-node node "ls-table-cell")]
|
|
|
- (p/do!
|
|
|
- (editor-handler/save-current-block!)
|
|
|
- (state/exit-editing-and-set-selected-blocks! [cell])
|
|
|
- (set-focus-timeout! (js/setTimeout #(.focus cell) 100)))))})
|
|
|
+ (save-block-and-focus *ref set-focus-timeout! false))})
|
|
|
(editor-handler/edit-block! block :max {:container-id :unknown-container})))))))}
|
|
|
(if block
|
|
|
[:div.flex.flex-row
|