Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: disable content selection when blocks have been selected #9713

Merged
merged 2 commits into from Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 14 additions & 12 deletions src/main/frontend/components/block.cljs
Expand Up @@ -867,7 +867,8 @@
(let [title [:span.block-ref
(block-content (assoc config :block-ref? true :stop-events? stop-inner-events?)
block nil (:block/uuid block)
(:slide? config))]
(:slide? config)
false)]
inner (if label
(->elem
:span.block-ref
Expand Down Expand Up @@ -2258,7 +2259,7 @@
(str uuid "-" idx)))))]))))

(rum/defc block-content < rum/reactive
[config {:block/keys [uuid content children properties scheduled deadline format pre-block?] :as block} edit-input-id block-id slide?]
[config {:block/keys [uuid content children properties scheduled deadline format pre-block?] :as block} edit-input-id block-id slide? selected?]
(let [content (property/remove-built-in-properties format content)
{:block/keys [title body] :as block} (if (:block/title block) block
(merge block (block/parse-title-and-body uuid format pre-block? content)))
Expand All @@ -2278,14 +2279,15 @@
:data-type (name block-type)
:style {:width "100%" :pointer-events (when stop-events? "none")}}

(not (string/blank? (:hl-color properties)))
(assoc :data-hl-color (:hl-color properties))
(not (string/blank? (:hl-color properties)))
(assoc :data-hl-color (:hl-color properties))

(not block-ref?)
(assoc mouse-down-key (fn [e]
(block-content-on-mouse-down e block block-id content edit-input-id))))]
(not block-ref?)
(assoc mouse-down-key (fn [e]
(block-content-on-mouse-down e block block-id content edit-input-id))))]
[:div.block-content.inline
(cond-> {:id (str "block-content-" uuid)
:class (when selected? "select-none")
:on-mouse-up (fn [e]
(when (and
(state/in-selection-mode?)
Expand Down Expand Up @@ -2385,7 +2387,7 @@
(= (:block/uuid block) (:block/uuid (:block config))))
default-hide? (if (and current-block-page? (not embed-self?) (state/auto-expand-block-refs?)) false true)]
(assoc state ::hide-block-refs? (atom default-hide?))))}
[state config {:block/keys [uuid format] :as block} edit-input-id block-id edit? hide-block-refs-count?]
[state config {:block/keys [uuid format] :as block} edit-input-id block-id edit? hide-block-refs-count? selected?]
(let [*hide-block-refs? (get state ::hide-block-refs?)
hide-block-refs? (rum/react *hide-block-refs?)
editor-box (get config :editor-box)
Expand Down Expand Up @@ -2423,7 +2425,7 @@
(editor-handler/clear-selection!)
(editor-handler/unhighlight-blocks!)
(state/set-editing! edit-input-id (:block/content block) block ""))}})
(block-content config block edit-input-id block-id slide?))]
(block-content config block edit-input-id block-id slide? selected?))]

(when-not hide-block-refs-count?
[:div.flex.flex-row.items-center
Expand Down Expand Up @@ -2479,7 +2481,7 @@
[:div.single-block.ls-block
{:class (str block-uuid)
:id (str "ls-block-" blocks-container-id "-" block-uuid)}
(block-content-or-editor config block edit-input-id block-el-id edit? true)])))
(block-content-or-editor config block edit-input-id block-el-id edit? true false)])))

(rum/defc single-block-cp
[block-uuid]
Expand Down Expand Up @@ -2794,7 +2796,7 @@
:class (str uuid
(when pre-block? " pre-block")
(when (and card? (not review-cards?)) " shadow-md")
(when selected? " selected noselect")
(when selected? " selected")
(when order-list? " is-order-list")
(when (string/blank? content) " is-blank"))
:blockid (str uuid)
Expand Down Expand Up @@ -2848,7 +2850,7 @@
;; Not embed self
(let [hide-block-refs-count? (and (:embed? config)
(= (:block/uuid block) (:embed-id config)))]
(block-content-or-editor config block edit-input-id block-id edit? hide-block-refs-count?)))
(block-content-or-editor config block edit-input-id block-id edit? hide-block-refs-count? selected?)))

(when @*show-right-menu?
(block-right-menu config block edit?))]
Expand Down
2 changes: 1 addition & 1 deletion src/main/frontend/components/page.cljs
Expand Up @@ -872,7 +872,7 @@
has-next? (< current total-pages)
prev-page (if (= 1 current) 1 (dec current))
next-page (if (= total-pages current) total-pages (inc current))]
[:div.flex.items-center.noselect
[:div.flex.items-center.select-none
(when has-prev?
[[:a.fade-link.flex
{:on-click #(on-change 1)}
Expand Down