|
|
@@ -7,6 +7,7 @@
|
|
|
[frontend.handler.page :as page-handler]
|
|
|
[frontend.state :as state]
|
|
|
[frontend.ui :as ui]
|
|
|
+ [frontend.util :as util]
|
|
|
[logseq.db.frontend.entity-util :as entity-util]
|
|
|
[logseq.shui.hooks :as hooks]
|
|
|
[logseq.shui.silkhq :as silkhq]
|
|
|
@@ -32,91 +33,97 @@
|
|
|
[block])
|
|
|
|
|
|
(hooks/use-effect!
|
|
|
- (fn []
|
|
|
- (when open?
|
|
|
- (state/clear-edit!)
|
|
|
- (init/keyboard-hide)))
|
|
|
- [open?])
|
|
|
+ (fn []
|
|
|
+ (when open?
|
|
|
+ (state/clear-edit!)
|
|
|
+ (init/keyboard-hide))
|
|
|
+ (let [light-theme? (= "light" (:ui/theme @state/state))]
|
|
|
+ (if open?
|
|
|
+ (when light-theme?
|
|
|
+ (util/set-theme-dark))
|
|
|
+ (when light-theme?
|
|
|
+ (util/set-theme-light)))))
|
|
|
+ [open?])
|
|
|
|
|
|
(silkhq/depth-sheet
|
|
|
- {:presented (boolean open?)
|
|
|
- :onPresentedChange (fn [v?]
|
|
|
- (when (false? v?)
|
|
|
- (mobile-state/set-singleton-modal! nil)
|
|
|
- (state/clear-edit!)
|
|
|
- (state/pub-event! [:mobile/keyboard-will-hide])))}
|
|
|
- (silkhq/depth-sheet-portal
|
|
|
- (silkhq/depth-sheet-view
|
|
|
- {:class "block-modal-page"
|
|
|
- :inertOutside false}
|
|
|
- (silkhq/depth-sheet-backdrop)
|
|
|
- (silkhq/depth-sheet-content
|
|
|
- {:class "app-silk-depth-sheet-content"}
|
|
|
- (silkhq/scroll
|
|
|
- {:as-child true}
|
|
|
- (silkhq/scroll-view
|
|
|
- {:class "app-silk-scroll-view"
|
|
|
- :scrollGestureTrap {:yEnd true}}
|
|
|
- (silkhq/scroll-content
|
|
|
- {:class "app-silk-scroll-content"}
|
|
|
+ {:presented (boolean open?)
|
|
|
+ :onPresentedChange (fn [v?]
|
|
|
+ (when (false? v?)
|
|
|
+ (mobile-state/set-singleton-modal! nil)
|
|
|
+ (state/clear-edit!)
|
|
|
+ (state/pub-event! [:mobile/keyboard-will-hide])))}
|
|
|
+ (silkhq/depth-sheet-portal
|
|
|
+ (silkhq/depth-sheet-view
|
|
|
+ {:class "block-modal-page"
|
|
|
+ :inertOutside false}
|
|
|
+ (silkhq/depth-sheet-backdrop)
|
|
|
+ (silkhq/depth-sheet-content
|
|
|
+ {:class "app-silk-depth-sheet-content"}
|
|
|
+ (silkhq/scroll
|
|
|
+ {:as-child true}
|
|
|
+ (silkhq/scroll-view
|
|
|
+ {:class "app-silk-scroll-view"
|
|
|
+ :scrollGestureTrap {:yEnd true}}
|
|
|
+ (silkhq/scroll-content
|
|
|
+ {:class "app-silk-scroll-content"}
|
|
|
|
|
|
- [:div.app-silk-scroll-content-inner
|
|
|
- [:div.flex.justify-between.items-center.block-modal-page-header
|
|
|
- (shui/button
|
|
|
- {:variant :text
|
|
|
- :size :sm
|
|
|
- :on-click close!
|
|
|
- :class "-ml-2"}
|
|
|
- (shui/tabler-icon "chevron-down" {:size 24}))
|
|
|
+ [:div.app-silk-scroll-content-inner
|
|
|
+ [:div.flex.justify-between.items-center.block-modal-page-header
|
|
|
+ (shui/button
|
|
|
+ {:variant :text
|
|
|
+ :size :sm
|
|
|
+ :on-click close!
|
|
|
+ :class "-ml-2"}
|
|
|
+ (shui/tabler-icon "chevron-down" {:size 24}))
|
|
|
|
|
|
- [:span.flex.items-center.-mr-2
|
|
|
- (when-let [block-id-str (str (:block/uuid block))]
|
|
|
- (shui/button
|
|
|
- {:variant :text
|
|
|
- :size :sm
|
|
|
- :class (when favorited? "!text-yellow-800")
|
|
|
- :on-click #(-> (if favorited?
|
|
|
- (page-handler/<unfavorite-page! block-id-str)
|
|
|
- (page-handler/<favorite-page! block-id-str))
|
|
|
- (p/then (fn [] (set-favorited! (not favorited?)))))}
|
|
|
- (shui/tabler-icon (if favorited? "star-filled" "star") {:size 20})))
|
|
|
- (shui/button
|
|
|
- {:variant :text
|
|
|
- :size :sm
|
|
|
- :on-click (fn []
|
|
|
- (mobile-ui/open-popup!
|
|
|
- (fn []
|
|
|
- [:div.-mx-2
|
|
|
- (ui/menu-link
|
|
|
- {:on-click #(mobile-ui/close-popup!)}
|
|
|
- [:span.text-lg.flex.gap-2.items-center
|
|
|
- (shui/tabler-icon "copy" {:class "opacity-80" :size 22})
|
|
|
- "Copy"])
|
|
|
+ [:span.flex.items-center.-mr-2
|
|
|
+ (when-let [block-id-str (str (:block/uuid block))]
|
|
|
+ (shui/button
|
|
|
+ {:variant :text
|
|
|
+ :size :sm
|
|
|
+ :class (when favorited? "!text-yellow-800")
|
|
|
+ :on-click #(-> (if favorited?
|
|
|
+ (page-handler/<unfavorite-page! block-id-str)
|
|
|
+ (page-handler/<favorite-page! block-id-str))
|
|
|
+ (p/then (fn [] (set-favorited! (not favorited?)))))}
|
|
|
+ (shui/tabler-icon (if favorited? "star-filled" "star") {:size 20})))
|
|
|
+ (shui/button
|
|
|
+ {:variant :text
|
|
|
+ :size :sm
|
|
|
+ :on-click (fn []
|
|
|
+ (mobile-ui/open-popup!
|
|
|
+ (fn []
|
|
|
+ [:div.-mx-2
|
|
|
+ (ui/menu-link
|
|
|
+ {:on-click #(mobile-ui/close-popup!)}
|
|
|
+ [:span.text-lg.flex.gap-2.items-center
|
|
|
+ (shui/tabler-icon "copy" {:class "opacity-80" :size 22})
|
|
|
+ "Copy"])
|
|
|
|
|
|
- (ui/menu-link
|
|
|
- {:on-click #(-> (shui/dialog-confirm!
|
|
|
- (str "⚠️ Are you sure you want to delete this "
|
|
|
- (if (entity-util/page? block) "page" "block")
|
|
|
- "?"))
|
|
|
- (p/then
|
|
|
- (fn []
|
|
|
- (mobile-ui/close-popup!)
|
|
|
- (some->
|
|
|
- (:block/uuid block)
|
|
|
- (page-handler/<delete!
|
|
|
- (fn [] (close!))
|
|
|
- {:error-handler
|
|
|
- (fn [{:keys [msg]}]
|
|
|
- (notification/show! msg :warning))})))))}
|
|
|
- [:span.text-lg.flex.gap-2.items-center.text-red-700
|
|
|
- (shui/tabler-icon "trash" {:class "opacity-80" :size 22})
|
|
|
- "Delete"])])
|
|
|
- {:title "Actions"
|
|
|
- :default-height false
|
|
|
- :type :action-sheet}))}
|
|
|
- (shui/tabler-icon "dots-vertical" {:size 20}))]]
|
|
|
+ (ui/menu-link
|
|
|
+ {:on-click #(-> (shui/dialog-confirm!
|
|
|
+ (str "⚠️ Are you sure you want to delete this "
|
|
|
+ (if (entity-util/page? block) "page" "block")
|
|
|
+ "?"))
|
|
|
+ (p/then
|
|
|
+ (fn []
|
|
|
+ (mobile-ui/close-popup!)
|
|
|
+ (some->
|
|
|
+ (:block/uuid block)
|
|
|
+ (page-handler/<delete!
|
|
|
+ (fn [] (close!))
|
|
|
+ {:error-handler
|
|
|
+ (fn [{:keys [msg]}]
|
|
|
+ (notification/show! msg :warning))})))))}
|
|
|
+ [:span.text-lg.flex.gap-2.items-center.text-red-700
|
|
|
+ (shui/tabler-icon "trash" {:class "opacity-80" :size 22})
|
|
|
+ "Delete"])])
|
|
|
+ {:title "Actions"
|
|
|
+ :default-height false
|
|
|
+ :type :action-sheet}))}
|
|
|
+ (shui/tabler-icon "dots-vertical" {:size 20}))]]
|
|
|
|
|
|
- ;; block page content
|
|
|
- [:div.block-modal-page-content
|
|
|
- (mobile-ui/classic-app-container-wrap
|
|
|
- (page/page-cp (db/entity [:block/uuid (:block/uuid block)])))]])))))))))
|
|
|
+ ;; block page content
|
|
|
+ [:div.block-modal-page-content
|
|
|
+ (mobile-ui/classic-app-container-wrap
|
|
|
+ (page/page-cp (db/entity [:block/uuid (:block/uuid block)])))]])))))))))
|