Browse Source

fix: disable context menu on whiteboards

Konstantinos Kaloutas 3 years ago
parent
commit
214c7c311a
1 changed files with 30 additions and 28 deletions
  1. 30 28
      src/main/frontend/components/content.cljs

+ 30 - 28
src/main/frontend/components/content.cljs

@@ -380,36 +380,38 @@
                             block-id (d/attr target "blockid")
                             block-id (d/attr target "blockid")
                             {:keys [block block-ref]} (state/sub :block-ref/context)
                             {:keys [block block-ref]} (state/sub :block-ref/context)
                             {:keys [page]} (state/sub :page-title/context)]
                             {:keys [page]} (state/sub :page-title/context)]
-                        (cond
-                          page
-                          (do
+                        ;; TODO: Find a better way to handle this on whiteboards
+                        (when-not (.closest target ".logseq-tldraw")
+                          (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")))
                             (common-handler/show-custom-context-menu!
                             (common-handler/show-custom-context-menu!
                              e
                              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")))
-                          (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))))))
+                             (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]}]
   [id {:keys [hiccup]}]
   [:div {:id id}
   [:div {:id id}
    (if hiccup
    (if hiccup