enhance(query table): click to edit and human-readable time

This commit is contained in:
Tienson Qin
2021-07-17 00:54:19 +08:00
parent 54573675f2
commit 962cd9fd7a
5 changed files with 100 additions and 62 deletions

View File

@@ -819,24 +819,25 @@
(let [block (db/entity [:block/uuid block-id])]
(seq (:block/_parent block)))))]
(when-not (and has-children? left-has-children?)
(let [block-parent (gdom/getElement block-parent-id)
sibling-block (util/get-prev-block-non-collapsed block-parent)]
(delete-block-aux! block delete-children?)
(when (and repo sibling-block)
(when-let [sibling-block-id (dom/attr sibling-block "blockid")]
(when-let [block (db/pull repo '[*] [:block/uuid (uuid sibling-block-id)])]
(let [original-content (util/trim-safe (:block/content block))
new-value (str original-content " " (string/triml value))
tail-len (count (string/triml value))
pos (max
(if original-content
(utf8/length (utf8/encode original-content))
0)
0)]
(edit-block! block pos format id
{:custom-content new-value
:tail-len tail-len
:move-cursor? false}))))))))))))
(when block-parent-id
(let [block-parent (gdom/getElement block-parent-id)
sibling-block (util/get-prev-block-non-collapsed block-parent)]
(delete-block-aux! block delete-children?)
(when (and repo sibling-block)
(when-let [sibling-block-id (dom/attr sibling-block "blockid")]
(when-let [block (db/pull repo '[*] [:block/uuid (uuid sibling-block-id)])]
(let [original-content (util/trim-safe (:block/content block))
new-value (str original-content " " (string/triml value))
tail-len (count (string/triml value))
pos (max
(if original-content
(utf8/length (utf8/encode original-content))
0)
0)]
(edit-block! block pos format id
{:custom-content new-value
:tail-len tail-len
:move-cursor? false})))))))))))))
(state/set-editor-op! nil)))
(defn- get-end-block-parent