fix: disable contenteditable in selection mode

This commit is contained in:
Tienson Qin
2025-06-23 16:27:18 +08:00
parent 2682bd4522
commit bfbb5422d6
3 changed files with 21 additions and 5 deletions

View File

@@ -58,6 +58,7 @@
[frontend.handler.ui :as ui-handler]
[frontend.handler.whiteboard :as whiteboard-handler]
[frontend.mixins :as mixins]
[frontend.mobile.core :as mobile]
[frontend.mobile.haptics :as haptics]
[frontend.mobile.intent :as mobile-intent]
[frontend.mobile.util :as mobile-util]
@@ -3012,14 +3013,19 @@
(block-content-on-pointer-down e block block-id edit-input-id content config))))))))]
[:div.block-content.inline
(cond-> {:id (str "block-content-" uuid)
:key (str "block-content-" uuid)
:content-editable (and (mobile-util/native-ios?) (not page-title?))}
:key (str "block-content-" uuid)}
(and (mobile-util/native-ios?) (not page-title?))
(assoc :content-editable true
:data-readonly true
:on-key-down util/stop
:on-before-input util/stop
:on-input util/stop)
true
(merge attrs))
[:<>
(when (and (> (count content) (state/block-content-max-length (state/get-current-repo)))
(not (contains? #{:code} (:logseq.property.node/display-type block))))
(not (contains? #{:code} (:logseq.property.node/display-type block))))
[:div.warning.text-sm
"Large block will not be editable or searchable to not slow down the app, please use another editor to edit this block."])
[:div.flex.flex-row.justify-between.block-content-inner

View File

@@ -1218,7 +1218,9 @@ Similar to re-frame subscriptions"
(doseq [node (dom/sel (util/format "[blockid='%s']" id))]
(dom/remove-class! node "selected")
(when (dom/has-class? node "ls-table-row")
(.blur node))))))
(.blur node))))
(doseq [node (dom/sel ".block-content[contenteditable=true]")]
(dom/set-attr! node "contenteditable" "false"))))
(defn set-selection-blocks!
([blocks]
@@ -1242,7 +1244,9 @@ Similar to re-frame subscriptions"
(defn clear-selection!
[]
(dom-clear-selection!)
(state-clear-selection!))
(state-clear-selection!)
(doseq [node (dom/sel ".block-content[contenteditable=false]")]
(dom/set-attr! node "contenteditable" "true")))
(defn get-selection-start-block-or-first
[]