|
@@ -3223,9 +3223,10 @@
|
|
|
[{:block a :level 1}
|
|
|
{:block b :level 2}
|
|
|
{:block e :level 2}]"
|
|
|
- [{:keys [collapse? expanded? incremental? root-block]
|
|
|
+ [{:keys [collapse? expanded? incremental? root-block page]
|
|
|
:or {collapse? false expanded? false incremental? true root-block nil}}]
|
|
|
- (when-let [page (or (state/get-current-page)
|
|
|
+ (when-let [page (or page
|
|
|
+ (state/get-current-page)
|
|
|
(date/today))]
|
|
|
(let [block-id (or root-block (parse-uuid page))
|
|
|
blocks (if block-id
|
|
@@ -3411,15 +3412,53 @@
|
|
|
(expand-all! block-id))))
|
|
|
|
|
|
(defn select-all-blocks!
|
|
|
- []
|
|
|
+ [{:keys [page]}]
|
|
|
(if-let [current-input-id (state/get-edit-input-id)]
|
|
|
(let [input (gdom/getElement current-input-id)
|
|
|
blocks-container (util/rec-get-blocks-container input)
|
|
|
blocks (dom/by-class blocks-container "ls-block")]
|
|
|
(state/exit-editing-and-set-selected-blocks! blocks))
|
|
|
- (->> (all-blocks-with-level {:collapse? true})
|
|
|
+ (->> (all-blocks-with-level {:page page
|
|
|
+ :collapse? true})
|
|
|
(map (comp gdom/getElementByClass str :block/uuid))
|
|
|
- state/exit-editing-and-set-selected-blocks!)))
|
|
|
+ state/exit-editing-and-set-selected-blocks!))
|
|
|
+ (state/set-state! :selection/selected-all? true))
|
|
|
+
|
|
|
+(defn select-parent [e]
|
|
|
+ (let [edit-input (some-> (state/get-edit-input-id) gdom/getElement)
|
|
|
+ edit-block (state/get-edit-block)]
|
|
|
+ (cond
|
|
|
+ ;; editing block fully selected
|
|
|
+ (and edit-block edit-input
|
|
|
+ (= (util/get-selected-text) (.-value edit-input)))
|
|
|
+ (do
|
|
|
+ (util/stop e)
|
|
|
+ (state/exit-editing-and-set-selected-blocks!
|
|
|
+ [(gdom/getElementByClass (str (:block/uuid edit-block)))]))
|
|
|
+
|
|
|
+ edit-block
|
|
|
+ nil
|
|
|
+
|
|
|
+ :else
|
|
|
+ (do
|
|
|
+ (util/stop e)
|
|
|
+ (when-not (:selection/selected-all? @state/state)
|
|
|
+ (if-let [block-id (some-> (first (state/get-selection-blocks))
|
|
|
+ (dom/attr "blockid")
|
|
|
+ uuid)]
|
|
|
+ (when-let [block (db/entity [:block/uuid block-id])]
|
|
|
+ (let [parent (:block/parent block)]
|
|
|
+ (cond
|
|
|
+ (= (state/get-current-page) (str (:block/uuid block)))
|
|
|
+ nil
|
|
|
+
|
|
|
+ (and parent (:block/parent parent))
|
|
|
+ (state/exit-editing-and-set-selected-blocks! [(gdom/getElementByClass (:block/uuid parent))])
|
|
|
+
|
|
|
+ (:block/name parent)
|
|
|
+ ;; page block
|
|
|
+ (select-all-blocks! {:page (:block/name parent)}))))
|
|
|
+ (select-all-blocks! {})))))))
|
|
|
|
|
|
(defn escape-editing
|
|
|
([]
|