diff --git a/src/main/capacitor/components/app.css b/src/main/capacitor/components/app.css index b2b0a71583..fcecfd297b 100644 --- a/src/main/capacitor/components/app.css +++ b/src/main/capacitor/components/app.css @@ -241,3 +241,9 @@ html[data-color=logseq] { .graph-switcher .action-sheet-button { font-size: 1.125em; } + +div.block-content[contenteditable][data-readonly] { + user-select: text; /* allow text selection */ + caret-color: transparent; /* hide caret */ + outline: none; /* remove focus outline */ +} diff --git a/src/main/frontend/components/block.cljs b/src/main/frontend/components/block.cljs index 2523db7efe..b643c2c3b9 100644 --- a/src/main/frontend/components/block.cljs +++ b/src/main/frontend/components/block.cljs @@ -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 diff --git a/src/main/frontend/state.cljs b/src/main/frontend/state.cljs index 9911646ec6..75509381d9 100644 --- a/src/main/frontend/state.cljs +++ b/src/main/frontend/state.cljs @@ -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 []