|
|
@@ -62,6 +62,7 @@
|
|
|
[frontend.util.drawer :as drawer]
|
|
|
[frontend.util.property :as property]
|
|
|
[frontend.util.text :as text-util]
|
|
|
+ [frontend.handler.notification :as notification]
|
|
|
[goog.dom :as gdom]
|
|
|
[goog.object :as gobj]
|
|
|
[lambdaisland.glogi :as log]
|
|
|
@@ -265,14 +266,6 @@
|
|
|
(when (seq images)
|
|
|
(lightbox/preview-images! images))))
|
|
|
|
|
|
-(defn copy-image-to-clipboard
|
|
|
- [src]
|
|
|
- (-> (js/fetch src)
|
|
|
- (.then (fn [data]
|
|
|
- (-> (.blob data)
|
|
|
- (.then (fn [blob]
|
|
|
- (js/navigator.clipboard.write (clj->js [(js/ClipboardItem. (clj->js {(.-type blob) blob}))])))))))))
|
|
|
-
|
|
|
(defonce *resizing-image? (atom false))
|
|
|
(rum/defcs resizable-image <
|
|
|
(rum/local nil ::size)
|
|
|
@@ -354,12 +347,13 @@
|
|
|
(ui/icon "trash")]
|
|
|
|
|
|
[:button.asset-action-btn
|
|
|
- {:title (t :asset/copy)
|
|
|
- :tabIndex "-1"
|
|
|
+ {:title (t :asset/copy)
|
|
|
+ :tabIndex "-1"
|
|
|
:on-mouse-down util/stop
|
|
|
- :on-click (fn [e]
|
|
|
- (util/stop e)
|
|
|
- (copy-image-to-clipboard image-src))}
|
|
|
+ :on-click (fn [e]
|
|
|
+ (util/stop e)
|
|
|
+ (-> (util/copy-image-to-clipboard image-src)
|
|
|
+ (p/then #(notification/show! "Copied!" :success))))}
|
|
|
(ui/icon "copy")]
|
|
|
|
|
|
[:button.asset-action-btn
|
|
|
@@ -392,8 +386,12 @@
|
|
|
share-fn (fn [event]
|
|
|
(util/stop event)
|
|
|
(when (mobile-util/native-platform?)
|
|
|
- (.share Share #js {:url path
|
|
|
- :title "Open file with your favorite app"})))]
|
|
|
+ ;; File URL must be legal, so filename muse be URI-encoded
|
|
|
+ (let [[rel-dir basename] (util/get-dir-and-basename href)
|
|
|
+ basename (js/encodeURIComponent basename)
|
|
|
+ asset-url (str repo-dir rel-dir "/" basename)]
|
|
|
+ (.share Share (clj->js {:url asset-url
|
|
|
+ :title "Open file with your favorite app"})))))]
|
|
|
|
|
|
(cond
|
|
|
(contains? config/audio-formats ext)
|
|
|
@@ -408,7 +406,7 @@
|
|
|
[:a.asset-ref.is-plaintext {:href (rfe/href :file {:path path})
|
|
|
:on-click (fn [_event]
|
|
|
(p/let [result (fs/read-file repo-dir path)]
|
|
|
- (db/set-file-content! repo path result )))}
|
|
|
+ (db/set-file-content! repo path result)))}
|
|
|
title]
|
|
|
|
|
|
(= ext :pdf)
|
|
|
@@ -567,13 +565,15 @@
|
|
|
All page-names are sanitized except page-name-in-block"
|
|
|
[config page-name-in-block page-name redirect-page-name page-entity contents-page? children html-export? label whiteboard-page?]
|
|
|
(let [tag? (:tag? config)
|
|
|
- config (assoc config :whiteboard-page? whiteboard-page?)]
|
|
|
+ config (assoc config :whiteboard-page? whiteboard-page?)
|
|
|
+ untitled? (model/untitled-page? page-name)]
|
|
|
[:a
|
|
|
{:tabIndex "0"
|
|
|
:class (cond-> (if tag? "tag" "page-ref")
|
|
|
(or (:property? config)
|
|
|
(= (:block/type page-entity) "property"))
|
|
|
- (str " property-key"))
|
|
|
+ (str " property-key")
|
|
|
+ untitled? (str " opacity-50"))
|
|
|
:data-ref page-name
|
|
|
:on-mouse-down (fn [e] (open-page-ref e page-name redirect-page-name page-name-in-block contents-page? whiteboard-page?))
|
|
|
:on-key-up (fn [e] (when (and e (= (.-key e) "Enter"))
|
|
|
@@ -597,9 +597,14 @@
|
|
|
|
|
|
:else
|
|
|
(let [original-name (util/get-page-original-name page-entity)
|
|
|
- s (if (not= (util/safe-page-name-sanity-lc original-name) page-name-in-block)
|
|
|
- page-name-in-block ;; page-name-in-block might be overrided (legacy)
|
|
|
- (pdf-assets/human-page-name original-name))
|
|
|
+ s (cond untitled?
|
|
|
+ (t :untitled)
|
|
|
+
|
|
|
+ (not= (util/safe-page-name-sanity-lc original-name) page-name-in-block)
|
|
|
+ page-name-in-block ;; page-name-in-block might be overrided (legacy))
|
|
|
+
|
|
|
+ :else
|
|
|
+ (pdf-assets/human-page-name original-name))
|
|
|
_ (when-not page-entity (js/console.warn "page-inner's page-entity is nil, given page-name: " page-name
|
|
|
" page-name-in-block: " page-name-in-block))]
|
|
|
(if tag? (str "#" s) s))))]))
|
|
|
@@ -619,10 +624,7 @@
|
|
|
inner (page-inner config
|
|
|
page-name-in-block
|
|
|
page-name
|
|
|
- redirect-page-name page-entity contents-page? children html-export? label whiteboard-page?)
|
|
|
- inner (if whiteboard-page?
|
|
|
- [:<> [:span.text-gray-500 (ui/icon "whiteboard" {:extension? true}) " "] inner]
|
|
|
- inner)]
|
|
|
+ redirect-page-name page-entity contents-page? children html-export? label whiteboard-page?)]
|
|
|
(cond
|
|
|
(:breadcrumb? config)
|
|
|
(or (:block/original-name page)
|
|
|
@@ -984,7 +986,7 @@
|
|
|
[:a.asset-ref.is-pdf
|
|
|
{:on-mouse-down (fn [_event]
|
|
|
(when-let [current (pdf-assets/inflate-asset s)]
|
|
|
- (state/set-state! :pdf/current current)))}
|
|
|
+ (state/set-current-pdf! current)))}
|
|
|
(or label-text
|
|
|
(->elem :span (map-inline config label)))]
|
|
|
|
|
|
@@ -1584,9 +1586,7 @@
|
|
|
(defn- bullet-drag-start
|
|
|
[event block uuid block-id]
|
|
|
(editor-handler/highlight-block! uuid)
|
|
|
- (.setData (gobj/get event "dataTransfer")
|
|
|
- "block-uuid"
|
|
|
- uuid)
|
|
|
+ (editor-handler/block->data-transfer! uuid event)
|
|
|
(.setData (gobj/get event "dataTransfer")
|
|
|
"block-dom-id"
|
|
|
block-id)
|
|
|
@@ -1625,23 +1625,22 @@
|
|
|
(when (and (coll? children)
|
|
|
(seq children)
|
|
|
(not collapsed?))
|
|
|
- (let [doc-mode? (state/sub :document/mode?)]
|
|
|
- [:div.block-children-container.flex {:style {:margin-left (if doc-mode? 18 29)}}
|
|
|
- [:div.block-children-left-border
|
|
|
- {:on-click (fn [_]
|
|
|
- (editor-handler/toggle-open-block-children! (:block/uuid block)))}]
|
|
|
- [:div.block-children.w-full {:style {:display (if collapsed? "none" "")}}
|
|
|
- (for [child children]
|
|
|
- (when (map? child)
|
|
|
- (let [child (dissoc child :block/meta)
|
|
|
- config (cond->
|
|
|
- (-> config
|
|
|
- (assoc :block/uuid (:block/uuid child))
|
|
|
- (dissoc :breadcrumb-show? :embed-parent))
|
|
|
- (or ref? query?)
|
|
|
- (assoc :ref-query-child? true))]
|
|
|
- (rum/with-key (block-container config child)
|
|
|
- (:block/uuid child)))))]]))))
|
|
|
+ [:div.block-children-container.flex
|
|
|
+ [:div.block-children-left-border
|
|
|
+ {:on-click (fn [_]
|
|
|
+ (editor-handler/toggle-open-block-children! (:block/uuid block)))}]
|
|
|
+ [:div.block-children.w-full {:style {:display (if collapsed? "none" "")}}
|
|
|
+ (for [child children]
|
|
|
+ (when (map? child)
|
|
|
+ (let [child (dissoc child :block/meta)
|
|
|
+ config (cond->
|
|
|
+ (-> config
|
|
|
+ (assoc :block/uuid (:block/uuid child))
|
|
|
+ (dissoc :breadcrumb-show? :embed-parent))
|
|
|
+ (or ref? query?)
|
|
|
+ (assoc :ref-query-child? true))]
|
|
|
+ (rum/with-key (block-container config child)
|
|
|
+ (:block/uuid child)))))]])))
|
|
|
|
|
|
(defn- block-content-empty?
|
|
|
[{:block/keys [properties title body]}]
|
|
|
@@ -1656,30 +1655,29 @@
|
|
|
(every? #(= % ["Horizontal_Rule"]) body)))
|
|
|
|
|
|
(rum/defcs block-control < rum/reactive
|
|
|
- [state config block uuid block-id collapsed? *control-show? edit?]
|
|
|
+ [state config block uuid block-id collapsed? *control-show? edit? has-child?]
|
|
|
(let [doc-mode? (state/sub :document/mode?)
|
|
|
control-show? (util/react *control-show?)
|
|
|
ref? (:ref? config)
|
|
|
- empty-content? (block-content-empty? block)]
|
|
|
- [:div.mr-1.flex.flex-row.items-center.sm:mr-2
|
|
|
- {:style {:height 24
|
|
|
- :margin-top 0
|
|
|
- :float "left"}}
|
|
|
-
|
|
|
- [:a.block-control
|
|
|
- {:id (str "control-" uuid)
|
|
|
- :on-click (fn [event]
|
|
|
- (util/stop event)
|
|
|
- (state/clear-edit!)
|
|
|
- (if ref?
|
|
|
- (state/toggle-collapsed-block! uuid)
|
|
|
- (if collapsed?
|
|
|
- (editor-handler/expand-block! uuid)
|
|
|
- (editor-handler/collapse-block! uuid))))}
|
|
|
- [:span {:class (if (and control-show?
|
|
|
- (or collapsed?
|
|
|
- (editor-handler/collapsable? uuid {:semantic? true}))) "control-show cursor-pointer" "control-hide")}
|
|
|
- (ui/rotating-arrow collapsed?)]]
|
|
|
+ empty-content? (block-content-empty? block)
|
|
|
+ fold-button-right? (state/enable-fold-button-right?)]
|
|
|
+ [:div.block-control-wrap.mr-1.flex.flex-row.items-center.sm:mr-2
|
|
|
+ (when (or (not fold-button-right?) has-child?)
|
|
|
+ [:a.block-control
|
|
|
+ {:id (str "control-" uuid)
|
|
|
+ :on-click (fn [event]
|
|
|
+ (util/stop event)
|
|
|
+ (state/clear-edit!)
|
|
|
+ (if ref?
|
|
|
+ (state/toggle-collapsed-block! uuid)
|
|
|
+ (if collapsed?
|
|
|
+ (editor-handler/expand-block! uuid)
|
|
|
+ (editor-handler/collapse-block! uuid))))}
|
|
|
+ [:span {:class (if (and control-show?
|
|
|
+ (or collapsed?
|
|
|
+ (editor-handler/collapsable? uuid {:semantic? true}))) "control-show cursor-pointer" "control-hide")}
|
|
|
+ (ui/rotating-arrow collapsed?)]])
|
|
|
+
|
|
|
(let [bullet [:a {:on-click (fn [event]
|
|
|
(bullet-on-click event block uuid))}
|
|
|
[:span.bullet-container.cursor
|
|
|
@@ -1853,7 +1851,8 @@
|
|
|
(when bg-color
|
|
|
{:style {:background-color (if (some #{bg-color} ui/block-background-colors)
|
|
|
(str "var(--ls-highlight-color-" bg-color ")")
|
|
|
- bg-color)}
|
|
|
+ bg-color)
|
|
|
+ :color (when-not (some #{bg-color} ui/block-background-colors) "white")}
|
|
|
:class "px-1 with-bg-color"}))
|
|
|
(remove-nils
|
|
|
(concat
|
|
|
@@ -2285,10 +2284,17 @@
|
|
|
[:div.more (ui/icon "dots-circle-horizontal" {:size 18})])]])
|
|
|
|
|
|
(rum/defcs block-content-or-editor < rum/reactive
|
|
|
- (rum/local true ::hide-block-refs?)
|
|
|
+ {:init (fn [state]
|
|
|
+ (let [block (second (:rum/args state))
|
|
|
+ config (first (:rum/args state))
|
|
|
+ current-block-page? (= (str (:block/uuid block)) (state/get-current-page))
|
|
|
+ embed-self? (and (:embed? config)
|
|
|
+ (= (:block/uuid block) (:block/uuid (:block config))))
|
|
|
+ default-hide? (if (and current-block-page? (not embed-self?)) false true)]
|
|
|
+ (assoc state ::hide-block-refs? (atom default-hide?))))}
|
|
|
[state config {:block/keys [uuid format] :as block} edit-input-id block-id edit? hide-block-refs-count?]
|
|
|
(let [*hide-block-refs? (get state ::hide-block-refs?)
|
|
|
- hide-block-refs? @*hide-block-refs?
|
|
|
+ hide-block-refs? (rum/react *hide-block-refs?)
|
|
|
editor-box (get config :editor-box)
|
|
|
editor-id (str "editor-" edit-input-id)
|
|
|
slide? (:slide? config)
|
|
|
@@ -2426,54 +2432,57 @@
|
|
|
(rum/defc breadcrumb-separator [] [:span.mx-2.opacity-50 "➤"])
|
|
|
|
|
|
(defn breadcrumb
|
|
|
+ "block-id - uuid of the target block of breadcrumb. page uuid is also acceptable"
|
|
|
[config repo block-id {:keys [show-page? indent? end-separator? level-limit _navigating-block]
|
|
|
:or {show-page? true
|
|
|
level-limit 3}
|
|
|
:as opts}]
|
|
|
- (let [parents (db/get-block-parents repo block-id (inc level-limit))
|
|
|
- page (db/get-block-page repo block-id)
|
|
|
- page-name (:block/name page)
|
|
|
- page-original-name (:block/original-name page)
|
|
|
- show? (or (seq parents) show-page? page-name)
|
|
|
- parents (if (= page-name (:block/name (first parents)))
|
|
|
- (rest parents)
|
|
|
- parents)
|
|
|
- more? (> (count parents) level-limit)
|
|
|
- parents (if more? (take-last level-limit parents) parents)
|
|
|
- config (assoc config :breadcrumb? true)]
|
|
|
- (when show?
|
|
|
- (let [page-name-props (when show-page?
|
|
|
- [page
|
|
|
- (page-cp (dissoc config :breadcrumb? true) page)
|
|
|
- {:block/name (or page-original-name page-name)}])
|
|
|
- parents-props (doall
|
|
|
- (for [{:block/keys [uuid name content] :as block} parents]
|
|
|
- (when-not name ; not page
|
|
|
- (let [{:block/keys [title body]} (block/parse-title-and-body
|
|
|
- uuid
|
|
|
- (:block/format block)
|
|
|
- (:block/pre-block? block)
|
|
|
- content)
|
|
|
- config (assoc config :block/uuid uuid)]
|
|
|
- [block
|
|
|
- (if (seq title)
|
|
|
- (->elem :span (map-inline config title))
|
|
|
- (->elem :div (markup-elements-cp config body)))]))))
|
|
|
- breadcrumb (->> (into [] parents-props)
|
|
|
- (concat [page-name-props] (when more? [:more]))
|
|
|
- (filterv identity)
|
|
|
- (map (fn [x] (if (vector? x)
|
|
|
- (let [[block label] x]
|
|
|
- (breadcrumb-fragment config block label opts))
|
|
|
- [:span.opacity-70 "⋯"])))
|
|
|
- (interpose (breadcrumb-separator)))]
|
|
|
- [:div.breadcrumb.block-parents.flex-row.flex-1
|
|
|
- {:class (when (seq breadcrumb)
|
|
|
- (str (when-not (:search? config)
|
|
|
- " my-2")
|
|
|
- (when indent?
|
|
|
- " ml-4")))}
|
|
|
- breadcrumb (when end-separator? (breadcrumb-separator))]))))
|
|
|
+ (when block-id
|
|
|
+ (let [parents (db/get-block-parents repo block-id (inc level-limit))
|
|
|
+ page (or (db/get-block-page repo block-id) ;; only return for block uuid
|
|
|
+ (model/query-block-by-uuid block-id)) ;; return page entity when received page uuid
|
|
|
+ page-name (:block/name page)
|
|
|
+ page-original-name (:block/original-name page)
|
|
|
+ show? (or (seq parents) show-page? page-name)
|
|
|
+ parents (if (= page-name (:block/name (first parents)))
|
|
|
+ (rest parents)
|
|
|
+ parents)
|
|
|
+ more? (> (count parents) level-limit)
|
|
|
+ parents (if more? (take-last level-limit parents) parents)
|
|
|
+ config (assoc config :breadcrumb? true)]
|
|
|
+ (when show?
|
|
|
+ (let [page-name-props (when show-page?
|
|
|
+ [page
|
|
|
+ (page-cp (dissoc config :breadcrumb? true) page)
|
|
|
+ {:block/name (or page-original-name page-name)}])
|
|
|
+ parents-props (doall
|
|
|
+ (for [{:block/keys [uuid name content] :as block} parents]
|
|
|
+ (when-not name ; not page
|
|
|
+ (let [{:block/keys [title body]} (block/parse-title-and-body
|
|
|
+ uuid
|
|
|
+ (:block/format block)
|
|
|
+ (:block/pre-block? block)
|
|
|
+ content)
|
|
|
+ config (assoc config :block/uuid uuid)]
|
|
|
+ [block
|
|
|
+ (if (seq title)
|
|
|
+ (->elem :span (map-inline config title))
|
|
|
+ (->elem :div (markup-elements-cp config body)))]))))
|
|
|
+ breadcrumb (->> (into [] parents-props)
|
|
|
+ (concat [page-name-props] (when more? [:more]))
|
|
|
+ (filterv identity)
|
|
|
+ (map (fn [x] (if (vector? x)
|
|
|
+ (let [[block label] x]
|
|
|
+ (rum/with-key (breadcrumb-fragment config block label opts) (:block/uuid block)))
|
|
|
+ [:span.opacity-70 "⋯"])))
|
|
|
+ (interpose (breadcrumb-separator)))]
|
|
|
+ [:div.breadcrumb.block-parents.flex-row.flex-1
|
|
|
+ {:class (when (seq breadcrumb)
|
|
|
+ (str (when-not (:search? config)
|
|
|
+ " my-2")
|
|
|
+ (when indent?
|
|
|
+ " ml-4")))}
|
|
|
+ breadcrumb (when end-separator? (breadcrumb-separator))])))))
|
|
|
|
|
|
(defn- block-drag-over
|
|
|
[event uuid top? block-id *move-to]
|
|
|
@@ -2687,20 +2696,24 @@
|
|
|
(block-handler/on-touch-move event block uuid edit? *show-left-menu? *show-right-menu?))
|
|
|
:on-touch-end (fn [event]
|
|
|
(block-handler/on-touch-end event block uuid *show-left-menu? *show-right-menu?))
|
|
|
- :on-touch-cancel block-handler/on-touch-cancel
|
|
|
+ :on-touch-cancel (fn [_e]
|
|
|
+ (block-handler/on-touch-cancel *show-left-menu? *show-right-menu?))
|
|
|
:on-mouse-over (fn [e]
|
|
|
(block-mouse-over e *control-show? block-id doc-mode?))
|
|
|
:on-mouse-leave (fn [e]
|
|
|
(block-mouse-leave e *control-show? block-id doc-mode?))}
|
|
|
(when (not slide?)
|
|
|
- (block-control config block uuid block-id collapsed? *control-show? edit?))
|
|
|
+ (block-control config block uuid block-id collapsed? *control-show? edit? has-child?))
|
|
|
|
|
|
(when @*show-left-menu?
|
|
|
(block-left-menu config block))
|
|
|
|
|
|
(if whiteboard-block?
|
|
|
(block-reference {} (str uuid) nil)
|
|
|
- (block-content-or-editor config block edit-input-id block-id edit? false))
|
|
|
+ ;; Not embed self
|
|
|
+ (let [hide-block-refs-count? (and (:embed? config)
|
|
|
+ (= (:block/uuid block) (:embed-id config)))]
|
|
|
+ (block-content-or-editor config block edit-input-id block-id edit? hide-block-refs-count?)))
|
|
|
|
|
|
(when @*show-right-menu?
|
|
|
(block-right-menu config block edit?))]
|
|
|
@@ -3183,9 +3196,9 @@
|
|
|
:else
|
|
|
[:<>
|
|
|
(lazy-editor/editor config (str (d/squuid)) attr code options)
|
|
|
- (let [options (:options options)]
|
|
|
+ (let [options (:options options) block (:block config)]
|
|
|
(when (and (= language "clojure") (contains? (set options) ":results"))
|
|
|
- (sci/eval-result code)))])])))))
|
|
|
+ (sci/eval-result code block)))])])))))
|
|
|
|
|
|
(defn ^:large-vars/cleanup-todo markup-element-cp
|
|
|
[{:keys [html-export?] :as config} item]
|
|
|
@@ -3387,22 +3400,29 @@
|
|
|
(let [last-block-id (:db/id (last flat-blocks))]
|
|
|
(block-handler/load-more! db-id last-block-id))))
|
|
|
|
|
|
+(defn- loading-more-data!
|
|
|
+ [config *loading? flat-blocks initial?]
|
|
|
+ ;; To prevent scrolling after inserting new blocks
|
|
|
+ (when (or initial?
|
|
|
+ (and (not initial?) (> (- (util/time-ms) (:start-time config)) 100)))
|
|
|
+ (reset! *loading? true)
|
|
|
+ (load-more-blocks! config flat-blocks)
|
|
|
+ (reset! *loading? false)))
|
|
|
+
|
|
|
(rum/defcs lazy-blocks < rum/reactive
|
|
|
(rum/local nil ::loading?)
|
|
|
{:init (fn [state]
|
|
|
- (assoc state ::id (str (random-uuid))))}
|
|
|
+ (assoc state ::id (str (random-uuid))))
|
|
|
+ :did-mount (fn [state]
|
|
|
+ (let [[config _ flat-blocks] (:rum/args state)]
|
|
|
+ (loading-more-data! config (::loading? state) flat-blocks true))
|
|
|
+ state)}
|
|
|
[state config blocks flat-blocks]
|
|
|
(let [db-id (:db/id config)
|
|
|
*loading? (::loading? state)]
|
|
|
(if-not db-id
|
|
|
(block-list config blocks)
|
|
|
- (let [loading-more-data! (fn []
|
|
|
- ;; To prevent scrolling after inserting new blocks
|
|
|
- (when (> (- (util/time-ms) (:start-time config)) 100)
|
|
|
- (reset! *loading? true)
|
|
|
- (load-more-blocks! config flat-blocks)
|
|
|
- (reset! *loading? false)))
|
|
|
- has-more? (and
|
|
|
+ (let [has-more? (and
|
|
|
(>= (count flat-blocks) model/initial-blocks-length)
|
|
|
(some? (model/get-next-open-block (db/get-db) (last flat-blocks) db-id)))
|
|
|
dom-id (str "lazy-blocks-" (::id state))]
|
|
|
@@ -3410,7 +3430,7 @@
|
|
|
(ui/infinite-list
|
|
|
"main-content-container"
|
|
|
(block-list config blocks)
|
|
|
- {:on-load loading-more-data!
|
|
|
+ {:on-load #(loading-more-data! config *loading? flat-blocks false)
|
|
|
:bottom-reached (fn []
|
|
|
(when-let [node (gdom/getElement dom-id)]
|
|
|
(ui/bottom-reached? node 300)))
|
|
|
@@ -3455,7 +3475,7 @@
|
|
|
(assoc state
|
|
|
::initial-block first-block
|
|
|
::navigating-block (atom (:block/uuid first-block)))))}
|
|
|
- [state block config]
|
|
|
+ [state blocks config]
|
|
|
(let [repo (state/get-current-repo)
|
|
|
*navigating-block (::navigating-block state)
|
|
|
navigating-block (rum/react *navigating-block)
|
|
|
@@ -3468,10 +3488,10 @@
|
|
|
(let [block navigating-block-entity]
|
|
|
(db/get-paginated-blocks repo (:db/id block)
|
|
|
{:scoped-block-id (:db/id block)}))
|
|
|
- [block])]
|
|
|
+ blocks)]
|
|
|
[:div
|
|
|
(when (:breadcrumb-show? config)
|
|
|
- (breadcrumb config (state/get-current-repo) (or navigating-block (:block/uuid block))
|
|
|
+ (breadcrumb config (state/get-current-repo) (or navigating-block (:block/uuid (first blocks)))
|
|
|
{:show-page? false
|
|
|
:navigating-block *navigating-block}))
|
|
|
(blocks-container blocks (assoc config
|
|
|
@@ -3494,7 +3514,8 @@
|
|
|
(fn []
|
|
|
(let [alias? (:block/alias? page)
|
|
|
page (db/entity (:db/id page))
|
|
|
- blocks' (tree/non-consecutive-blocks->vec-tree blocks)]
|
|
|
+ blocks (tree/non-consecutive-blocks->vec-tree blocks)
|
|
|
+ parent-blocks (group-by :block/parent blocks)]
|
|
|
[:div.my-2 (cond-> {:key (str "page-" (:db/id page))}
|
|
|
(:ref? config)
|
|
|
(assoc :class "color-level px-2 sm:px-7 py-2 rounded"))
|
|
|
@@ -3502,34 +3523,37 @@
|
|
|
[:div
|
|
|
(page-cp config page)
|
|
|
(when alias? [:span.text-sm.font-medium.opacity-50 " Alias"])]
|
|
|
- (for [block blocks']
|
|
|
+ (for [[parent blocks] parent-blocks]
|
|
|
(rum/with-key
|
|
|
- (breadcrumb-with-container block config)
|
|
|
- (:db/id block)))
|
|
|
+ (breadcrumb-with-container blocks config)
|
|
|
+ (:db/id parent)))
|
|
|
{:debug-id page
|
|
|
:trigger-once? false})])))))]
|
|
|
|
|
|
(and (:ref? config) (:group-by-page? config))
|
|
|
[:div.flex.flex-col
|
|
|
(let [blocks (sort-by (comp :block/journal-day first) > blocks)]
|
|
|
- (for [[page parent-blocks] blocks]
|
|
|
- (ui/lazy-visible
|
|
|
- (fn []
|
|
|
- (let [alias? (:block/alias? page)
|
|
|
- page (db/entity (:db/id page))]
|
|
|
- [:div.my-2 (cond-> {:key (str "page-" (:db/id page))}
|
|
|
- (:ref? config)
|
|
|
- (assoc :class "color-level px-2 sm:px-7 py-2 rounded"))
|
|
|
- (ui/foldable
|
|
|
- [:div
|
|
|
- (page-cp config page)
|
|
|
- (when alias? [:span.text-sm.font-medium.opacity-50 " Alias"])]
|
|
|
- (for [block parent-blocks]
|
|
|
- (let [block' (update block :block/children tree/non-consecutive-blocks->vec-tree)]
|
|
|
- (rum/with-key
|
|
|
- (breadcrumb-with-container block' config)
|
|
|
- (:db/id block'))))
|
|
|
- {:debug-id page})])))))]
|
|
|
+ (for [[page page-blocks] blocks]
|
|
|
+ (ui/lazy-visible
|
|
|
+ (fn []
|
|
|
+ (let [alias? (:block/alias? page)
|
|
|
+ page (db/entity (:db/id page))
|
|
|
+ page-blocks' (tree/non-consecutive-blocks->vec-tree page-blocks)
|
|
|
+ parent-blocks (group-by :block/parent page-blocks')]
|
|
|
+ [:div.my-2 (cond-> {:key (str "page-" (:db/id page))}
|
|
|
+ (:ref? config)
|
|
|
+ (assoc :class "color-level px-2 sm:px-7 py-2 rounded"))
|
|
|
+ (ui/foldable
|
|
|
+ [:div
|
|
|
+ (page-cp config page)
|
|
|
+ (when alias? [:span.text-sm.font-medium.opacity-50 " Alias"])]
|
|
|
+ (for [[parent blocks] parent-blocks]
|
|
|
+ (let [blocks' (map #(update % :block/children (fn [col]
|
|
|
+ (tree/non-consecutive-blocks->vec-tree col 2))) blocks)]
|
|
|
+ (rum/with-key
|
|
|
+ (breadcrumb-with-container blocks' config)
|
|
|
+ (:db/id parent))))
|
|
|
+ {:debug-id page})])))))]
|
|
|
|
|
|
(and (:group-by-page? config)
|
|
|
(vector? (first blocks)))
|
|
|
@@ -3540,7 +3564,7 @@
|
|
|
(when (seq blocks)
|
|
|
(let [alias? (:block/alias? page)
|
|
|
page (db/entity (:db/id page))
|
|
|
- whiteboard? (= "whiteboard" (:block/type page))]
|
|
|
+ whiteboard? (model/whiteboard-page? page)]
|
|
|
[:div.my-2 (cond-> {:key (str "page-" (:db/id page))}
|
|
|
(:ref? config)
|
|
|
(assoc :class "color-level px-2 sm:px-7 py-2 rounded"))
|