mirror of https://github.com/logseq/logseq
fix: can't backspace to edit tagged page block
parent
b3eb7b6a43
commit
c6a46c43f2
|
@ -708,11 +708,13 @@
|
||||||
(outliner-core/delete-blocks! [block] {:children? children?})))))
|
(outliner-core/delete-blocks! [block] {:children? children?})))))
|
||||||
|
|
||||||
(defn- move-to-prev-block
|
(defn- move-to-prev-block
|
||||||
[repo sibling-block format id value move?]
|
[repo sibling-block format id value]
|
||||||
(when (and repo sibling-block)
|
(when (and repo sibling-block)
|
||||||
(when-let [sibling-block-id (dom/attr sibling-block "blockid")]
|
(when-let [sibling-block-id (dom/attr sibling-block "blockid")]
|
||||||
(when-let [block (db/entity [:block/uuid (uuid sibling-block-id)])]
|
(when-let [block (db/entity [:block/uuid (uuid sibling-block-id)])]
|
||||||
(let [original-content (util/trim-safe (:block/content block))
|
(let [original-block (dom/attr sibling-block "originalblockid")
|
||||||
|
id (if original-block (:block/uuid block) id)
|
||||||
|
original-content (util/trim-safe (:block/content block))
|
||||||
value' (-> (file-property/remove-built-in-properties-when-file-based repo format original-content)
|
value' (-> (file-property/remove-built-in-properties-when-file-based repo format original-content)
|
||||||
(drawer/remove-logbook))
|
(drawer/remove-logbook))
|
||||||
value (->> value
|
value (->> value
|
||||||
|
@ -724,17 +726,14 @@
|
||||||
(if original-content
|
(if original-content
|
||||||
(gobj/get (utf8/encode original-content) "length")
|
(gobj/get (utf8/encode original-content) "length")
|
||||||
0)
|
0)
|
||||||
0)
|
0)]
|
||||||
f (fn []
|
(edit-block! (db/pull (:db/id block))
|
||||||
(edit-block! (db/pull (:db/id block))
|
pos
|
||||||
pos
|
id
|
||||||
id
|
{:custom-content new-value
|
||||||
{:custom-content new-value
|
:tail-len tail-len})
|
||||||
:tail-len tail-len}))]
|
|
||||||
(when move? (f))
|
|
||||||
{:prev-block block
|
{:prev-block block
|
||||||
:new-content new-value
|
:new-content new-value})))))
|
||||||
:move-fn f})))))
|
|
||||||
|
|
||||||
(declare save-block!)
|
(declare save-block!)
|
||||||
|
|
||||||
|
@ -765,7 +764,7 @@
|
||||||
block-parent
|
block-parent
|
||||||
{:container (util/rec-get-blocks-container block-parent)})
|
{:container (util/rec-get-blocks-container block-parent)})
|
||||||
(util/get-prev-block-non-collapsed-non-embed block-parent))
|
(util/get-prev-block-non-collapsed-non-embed block-parent))
|
||||||
{:keys [prev-block new-content move-fn]} (move-to-prev-block repo sibling-block format id value false)
|
{:keys [prev-block new-content]} (move-to-prev-block repo sibling-block format id value)
|
||||||
concat-prev-block? (boolean (and prev-block new-content))
|
concat-prev-block? (boolean (and prev-block new-content))
|
||||||
transact-opts (cond->
|
transact-opts (cond->
|
||||||
{:outliner-op :delete-blocks}
|
{:outliner-op :delete-blocks}
|
||||||
|
@ -781,8 +780,7 @@
|
||||||
prev-block)]
|
prev-block)]
|
||||||
(delete-block-aux! block delete-children?)
|
(delete-block-aux! block delete-children?)
|
||||||
(save-block! repo prev-block' new-content {:editor/op :delete}))
|
(save-block! repo prev-block' new-content {:editor/op :delete}))
|
||||||
(delete-block-aux! block delete-children?)))
|
(delete-block-aux! block delete-children?)))))))))
|
||||||
(when (fn? move-fn) (move-fn))))))))
|
|
||||||
(state/set-editor-op! nil)))
|
(state/set-editor-op! nil)))
|
||||||
|
|
||||||
(defn delete-blocks!
|
(defn delete-blocks!
|
||||||
|
@ -799,8 +797,7 @@
|
||||||
(move-to-prev-block repo sibling-block
|
(move-to-prev-block repo sibling-block
|
||||||
(:block/format block)
|
(:block/format block)
|
||||||
(dom/attr sibling-block "id")
|
(dom/attr sibling-block "id")
|
||||||
""
|
"")))))
|
||||||
true)))))
|
|
||||||
|
|
||||||
(defn- set-block-property-aux!
|
(defn- set-block-property-aux!
|
||||||
[repo block-or-id key value]
|
[repo block-or-id key value]
|
||||||
|
|
|
@ -1018,7 +1018,8 @@
|
||||||
(when (> (count edit-content) current-pos)
|
(when (> (count edit-content) current-pos)
|
||||||
(gp-util/safe-subs edit-content pos current-pos)))]
|
(gp-util/safe-subs edit-content pos current-pos)))]
|
||||||
(if hashtag?
|
(if hashtag?
|
||||||
(fn [chosen _e]
|
(fn [chosen e]
|
||||||
|
(util/stop e)
|
||||||
(state/clear-editor-action!)
|
(state/clear-editor-action!)
|
||||||
(let [wrapped? (= page-ref/left-brackets (gp-util/safe-subs edit-content (- pos 2) pos))
|
(let [wrapped? (= page-ref/left-brackets (gp-util/safe-subs edit-content (- pos 2) pos))
|
||||||
chosen (if (and (util/safe-re-find #"\s+" chosen) (not wrapped?))
|
chosen (if (and (util/safe-re-find #"\s+" chosen) (not wrapped?))
|
||||||
|
@ -1038,7 +1039,8 @@
|
||||||
:end-pattern (when wrapped? page-ref/right-brackets)
|
:end-pattern (when wrapped? page-ref/right-brackets)
|
||||||
:command :page-ref})
|
:command :page-ref})
|
||||||
(when input (.focus input))))
|
(when input (.focus input))))
|
||||||
(fn [chosen _e]
|
(fn [chosen e]
|
||||||
|
(util/stop e)
|
||||||
(state/clear-editor-action!)
|
(state/clear-editor-action!)
|
||||||
(let [page-ref-text (get-page-ref-text chosen)]
|
(let [page-ref-text (get-page-ref-text chosen)]
|
||||||
(editor-handler/insert-command! id
|
(editor-handler/insert-command! id
|
||||||
|
|
Loading…
Reference in New Issue