mirror of
https://github.com/logseq/logseq.git
synced 2026-04-24 22:25:01 +00:00
wip: add selection bar
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
[frontend.handler.page :as page-handler]
|
||||
[frontend.handler.repo :as repo-handler]
|
||||
[frontend.handler.user :as user-handler]
|
||||
[frontend.mobile.action-bar :as action-bar]
|
||||
[frontend.mobile.mobile-bar :as mobile-bar]
|
||||
[frontend.mobile.util :as mobile-util]
|
||||
[frontend.rum :as frum]
|
||||
@@ -86,11 +87,15 @@
|
||||
[:input.absolute.top-4.left-0.w-1.h-1.opacity-0
|
||||
{:id "app-keep-keyboard-open-input"}])
|
||||
|
||||
(rum/defc journals []
|
||||
(ion/content
|
||||
(ui/classic-app-container-wrap
|
||||
[:div.pt-3
|
||||
(journal/all-journals)])))
|
||||
(rum/defc journals < rum/reactive
|
||||
[]
|
||||
(let [show-action-bar? (fstate/sub :mobile/show-action-bar?)]
|
||||
(ion/content
|
||||
(ui/classic-app-container-wrap
|
||||
[:div.pt-3
|
||||
(journal/all-journals)])
|
||||
(when show-action-bar?
|
||||
(action-bar/action-bar)))))
|
||||
|
||||
(rum/defc home < rum/reactive
|
||||
[]
|
||||
@@ -147,7 +152,7 @@
|
||||
;; (rtc-indicator/uploading-detail))
|
||||
])]))))
|
||||
|
||||
;; main content
|
||||
;; main content
|
||||
(if db-restoring?
|
||||
(ion/content
|
||||
[:strong.flex.justify-center.items-center.py-24
|
||||
|
||||
@@ -365,14 +365,11 @@
|
||||
(do
|
||||
(state/clear-edit!)
|
||||
(state/conj-selection-block! block-container nil)))
|
||||
(haptics/haptics))
|
||||
|
||||
;; (haptics/with-haptics-impact
|
||||
;; (do (state/set-state! :mobile/show-action-bar? true)
|
||||
;; (state/set-state! :mobile/actioned-block block)
|
||||
;; (select-block! uuid))
|
||||
;; :light)
|
||||
)
|
||||
(when (seq (state/get-selection-blocks))
|
||||
(state/set-state! :mobile/show-action-bar? true)
|
||||
;; (state/set-state! :mobile/actioned-block )
|
||||
)
|
||||
(haptics/haptics)))
|
||||
(reset! *swiped? false)
|
||||
(catch :default e
|
||||
(js/console.error e))
|
||||
|
||||
@@ -1,19 +1,11 @@
|
||||
(ns frontend.mobile.action-bar
|
||||
"Block Action bar, activated when swipe on a block"
|
||||
(:require [frontend.config :as config]
|
||||
[frontend.db :as db]
|
||||
[frontend.extensions.fsrs :as fsrs]
|
||||
[frontend.extensions.srs :as srs]
|
||||
(:require [frontend.db :as db]
|
||||
[frontend.handler.editor :as editor-handler]
|
||||
[frontend.mixins :as mixins]
|
||||
[frontend.mobile.util :as mobile-util]
|
||||
[frontend.util.ref :as ref]
|
||||
[frontend.state :as state]
|
||||
[frontend.ui :as ui]
|
||||
[frontend.util :as util]
|
||||
[frontend.util.url :as url-util]
|
||||
[goog.dom :as gdom]
|
||||
[goog.object :as gobj]
|
||||
[rum.core :as rum]))
|
||||
|
||||
(defn- action-command
|
||||
@@ -38,40 +30,19 @@
|
||||
(editor-handler/clear-selection!)
|
||||
(state/set-state! :mobile/show-action-bar? false)))))
|
||||
[state]
|
||||
(when-let [block (state/sub :mobile/actioned-block)]
|
||||
(let [{:block/keys [uuid children]} block
|
||||
last-child-block-id (when-not (empty? children)
|
||||
(->> (db/get-block-children (state/get-current-repo) uuid)
|
||||
(filter #(not (db/parents-collapsed? (state/get-current-repo) (:block/uuid %1)))) ;; DOM nodes of blocks the have collapsed parents have no bounding client rect
|
||||
last
|
||||
:block/uuid))]
|
||||
|
||||
;; scroll to the most bottom element of the selected block
|
||||
(let [tag-id (or last-child-block-id uuid)
|
||||
bottom-el (gdom/getElement (str "block-content-" tag-id))
|
||||
bottom (gobj/get (.getBoundingClientRect bottom-el) "bottom")
|
||||
vw-height (or (.-height js/window.visualViewport)
|
||||
(.-clientHeight js/document.documentElement))
|
||||
delta (- vw-height bottom 170)]
|
||||
(when (< delta 0)
|
||||
(.scrollBy (util/app-scroll-container-node) #js {:top (- 10 delta)})))
|
||||
[:div.action-bar
|
||||
[:div.action-bar-commands
|
||||
(action-command "infinity" "Card" #(if (config/db-based-graph? (state/get-current-repo))
|
||||
(fsrs/batch-make-cards! [(:block/uuid block)])
|
||||
(srs/batch-make-cards! [(:block/uuid block)])))
|
||||
(action-command "copy" "Copy" #(editor-handler/copy-selection-blocks false))
|
||||
(action-command "cut" "Cut" #(editor-handler/cut-selection-blocks true))
|
||||
(action-command "trash" "Delete" #(editor-handler/delete-block-aux! block))
|
||||
(action-command "registered" "Copy ref"
|
||||
(fn [_event] (editor-handler/copy-block-ref! uuid ref/->block-ref)))
|
||||
(action-command "link" "Copy url"
|
||||
(fn [_event] (let [current-repo (state/get-current-repo)
|
||||
tap-f (fn [block-id]
|
||||
(url-util/get-logseq-graph-uuid-url nil current-repo block-id))]
|
||||
(editor-handler/copy-block-ref! uuid tap-f))))
|
||||
(when (mobile-util/native-ipad?)
|
||||
(action-command "text-direction-ltr" "Right sidebar"
|
||||
(fn [_event]
|
||||
(let [current-repo (state/get-current-repo)]
|
||||
(state/sidebar-add-block! current-repo uuid :block-ref)))))]])))
|
||||
(let [blocks (->> (state/get-selection-block-ids)
|
||||
(keep (fn [id]
|
||||
(db/entity [:block/uuid id]))))
|
||||
block-ids (map :block/uuid blocks)]
|
||||
[:div.action-bar
|
||||
[:div.action-bar-commands
|
||||
(action-command "copy" "Copy" #(editor-handler/copy-selection-blocks false))
|
||||
(action-command "cut" "Cut" #(editor-handler/cut-selection-blocks true))
|
||||
(action-command "trash" "Delete" #(editor-handler/cut-selection-blocks false))
|
||||
(action-command "registered" "Copy ref"
|
||||
(fn [_event] (editor-handler/copy-block-refs)))
|
||||
(action-command "link" "Copy url"
|
||||
(fn [_event] (let [current-repo (state/get-current-repo)
|
||||
tap-f (fn [block-id]
|
||||
(url-util/get-logseq-graph-uuid-url nil current-repo block-id))]
|
||||
(editor-handler/copy-block-ref! (first block-ids) tap-f))))]]))
|
||||
|
||||
@@ -214,7 +214,6 @@
|
||||
;; mobile
|
||||
:mobile/container-urls nil
|
||||
:mobile/show-action-bar? false
|
||||
:mobile/actioned-block nil
|
||||
:mobile/show-toolbar? false
|
||||
:mobile/show-recording-bar? false
|
||||
:mobile/show-tabbar? false
|
||||
|
||||
Reference in New Issue
Block a user