From 4282f21a62c540b876c8a288ef38ac8ca644658b Mon Sep 17 00:00:00 2001 From: Konstantinos Kaloutas Date: Fri, 23 Dec 2022 11:39:41 +0200 Subject: [PATCH] fix: allow custom context menu --- src/main/frontend/components/content.cljs | 54 +++++++++++------------ 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/src/main/frontend/components/content.cljs b/src/main/frontend/components/content.cljs index 83e3868f8a..4cd245f75f 100644 --- a/src/main/frontend/components/content.cljs +++ b/src/main/frontend/components/content.cljs @@ -354,38 +354,36 @@ block-id (d/attr target "blockid") {:keys [block block-ref]} (state/sub :block-ref/context) {:keys [page]} (state/sub :page-title/context)] - ;; TODO: Find a better way to handle this on whiteboards - (when-not (whiteboard-handler/inside-portal? target) - (cond - page - (do - (common-handler/show-custom-context-menu! - e - (page-title-custom-context-menu-content page)) - (state/set-state! :page-title/context nil)) - - block-ref - (do - (common-handler/show-custom-context-menu! - e - (block-ref-custom-context-menu-content block block-ref)) - (state/set-state! :block-ref/context nil)) - - (and (state/selection?) (not (d/has-class? target "bullet"))) + (cond + page + (do (common-handler/show-custom-context-menu! e - (custom-context-menu-content)) + (page-title-custom-context-menu-content page)) + (state/set-state! :page-title/context nil)) - (and block-id (parse-uuid block-id)) - (let [block (.closest target ".ls-block")] - (when block - (util/select-highlight! [block])) - (common-handler/show-custom-context-menu! - e - (block-context-menu-content target (uuid block-id)))) + block-ref + (do + (common-handler/show-custom-context-menu! + e + (block-ref-custom-context-menu-content block block-ref)) + (state/set-state! :block-ref/context nil)) - :else - nil))))))) + (and (state/selection?) (not (d/has-class? target "bullet"))) + (common-handler/show-custom-context-menu! + e + (custom-context-menu-content)) + + (and block-id (parse-uuid block-id)) + (let [block (.closest target ".ls-block")] + (when block + (util/select-highlight! [block])) + (common-handler/show-custom-context-menu! + e + (block-context-menu-content target (uuid block-id)))) + + :else + nil)))))) [id {:keys [hiccup]}] [:div {:id id} (if hiccup