fix: allow custom context menu

This commit is contained in:
Konstantinos Kaloutas
2022-12-23 11:39:41 +02:00
committed by Tienson Qin
parent bdd1dbb937
commit 4282f21a62

View File

@@ -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