|
|
@@ -976,8 +976,9 @@
|
|
|
|
|
|
(rum/defc page-cp
|
|
|
[config page]
|
|
|
- (rum/with-key (page-cp-inner config page)
|
|
|
- (or (str (:db/id page)) (str (:block/uuid page)) (:block/name page))))
|
|
|
+ (let [id (or (:db/id page) (:block/uuid page) (:block/name page))]
|
|
|
+ (rum/with-key (page-cp-inner config page)
|
|
|
+ (str id))))
|
|
|
|
|
|
(rum/defc asset-reference
|
|
|
[config title path]
|
|
|
@@ -1067,51 +1068,59 @@
|
|
|
(declare block-positioned-properties)
|
|
|
(rum/defc page-reference < rum/reactive db-mixins/query
|
|
|
"Component for page reference"
|
|
|
- [{:keys [html-export? nested-link? show-brackets? id] :as config} uuid-or-title* label]
|
|
|
+ [{:keys [html-export? nested-link? show-brackets? id] :as config*} uuid-or-title* label]
|
|
|
(when uuid-or-title*
|
|
|
(let [uuid-or-title (if (string? uuid-or-title*)
|
|
|
(string/trim uuid-or-title*)
|
|
|
uuid-or-title*)
|
|
|
- show-brackets? (if (some? show-brackets?) show-brackets? (state/show-brackets?))
|
|
|
- contents-page? (= "contents" (string/lower-case (str id)))
|
|
|
- block* (db/get-page uuid-or-title)
|
|
|
- block (or (some-> (:db/id block*) db/sub-block) block*)
|
|
|
- config' (assoc config
|
|
|
- :label (mldoc/plain->text label)
|
|
|
- :contents-page? contents-page?
|
|
|
- :show-icon? true?)
|
|
|
- asset? (some? (:logseq.property.asset/type block))
|
|
|
- brackets? (and (or show-brackets? nested-link?)
|
|
|
- (not html-export?)
|
|
|
- (not contents-page?))]
|
|
|
- (when-not (= (:db/id block) (:db/id (:block config)))
|
|
|
- (cond
|
|
|
- (and asset? (img-audio-video? block))
|
|
|
- (asset-cp config block)
|
|
|
-
|
|
|
- (and (string? uuid-or-title) (string/ends-with? uuid-or-title ".excalidraw"))
|
|
|
- [:div.draw {:on-click (fn [e]
|
|
|
- (.stopPropagation e))}
|
|
|
- (excalidraw uuid-or-title (:block/uuid config))]
|
|
|
-
|
|
|
- :else
|
|
|
- [:span.page-reference
|
|
|
- {:data-ref (str uuid-or-title)}
|
|
|
- (when brackets?
|
|
|
- [:span.text-gray-500.bracket page-ref/left-brackets])
|
|
|
- (when (and (config/db-based-graph?) (ldb/class-instance? (db/entity :logseq.class/Task) block))
|
|
|
- [:div.inline-block
|
|
|
- {:style {:margin-right 1
|
|
|
- :margin-top -2
|
|
|
- :vertical-align "middle"}
|
|
|
- :on-pointer-down (fn [e]
|
|
|
- (util/stop e))}
|
|
|
- (block-positioned-properties config block :block-left)])
|
|
|
- (page-cp config' (if (uuid? uuid-or-title)
|
|
|
- {:block/uuid uuid-or-title}
|
|
|
- {:block/name uuid-or-title}))
|
|
|
- (when brackets?
|
|
|
- [:span.text-gray-500.bracket page-ref/right-brackets])])))))
|
|
|
+ self-reference? (when (set? (:ref-set config*))
|
|
|
+ (contains? (:ref-set config*) uuid-or-title))]
|
|
|
+ (when-not self-reference?
|
|
|
+ (let [config (update config* :ref-set (fn [s]
|
|
|
+ (let [bid (:block/uuid (:block config*))]
|
|
|
+ (if (nil? s)
|
|
|
+ #{uuid-or-title*}
|
|
|
+ (conj s bid uuid-or-title*)))))
|
|
|
+ show-brackets? (if (some? show-brackets?) show-brackets? (state/show-brackets?))
|
|
|
+ contents-page? (= "contents" (string/lower-case (str id)))
|
|
|
+ block* (db/get-page uuid-or-title)
|
|
|
+ block (or (some-> (:db/id block*) db/sub-block) block*)
|
|
|
+ config' (assoc config
|
|
|
+ :label (mldoc/plain->text label)
|
|
|
+ :contents-page? contents-page?
|
|
|
+ :show-icon? true?)
|
|
|
+ asset? (some? (:logseq.property.asset/type block))
|
|
|
+ brackets? (and (or show-brackets? nested-link?)
|
|
|
+ (not html-export?)
|
|
|
+ (not contents-page?))]
|
|
|
+ (when-not (= (:db/id block) (:db/id (:block config)))
|
|
|
+ (cond
|
|
|
+ (and asset? (img-audio-video? block))
|
|
|
+ (asset-cp config block)
|
|
|
+
|
|
|
+ (and (string? uuid-or-title) (string/ends-with? uuid-or-title ".excalidraw"))
|
|
|
+ [:div.draw {:on-click (fn [e]
|
|
|
+ (.stopPropagation e))}
|
|
|
+ (excalidraw uuid-or-title (:block/uuid config))]
|
|
|
+
|
|
|
+ :else
|
|
|
+ [:span.page-reference
|
|
|
+ {:data-ref (str uuid-or-title)}
|
|
|
+ (when brackets?
|
|
|
+ [:span.text-gray-500.bracket page-ref/left-brackets])
|
|
|
+ (when (and (config/db-based-graph?) (ldb/class-instance? (db/entity :logseq.class/Task) block))
|
|
|
+ [:div.inline-block
|
|
|
+ {:style {:margin-right 1
|
|
|
+ :margin-top -2
|
|
|
+ :vertical-align "middle"}
|
|
|
+ :on-pointer-down (fn [e]
|
|
|
+ (util/stop e))}
|
|
|
+ (block-positioned-properties config block :block-left)])
|
|
|
+ (page-cp config' (if (uuid? uuid-or-title)
|
|
|
+ {:block/uuid uuid-or-title}
|
|
|
+ {:block/name uuid-or-title}))
|
|
|
+ (when brackets?
|
|
|
+ [:span.text-gray-500.bracket page-ref/right-brackets])])))))))
|
|
|
|
|
|
(defn- latex-environment-content
|
|
|
[name option content]
|
|
|
@@ -1319,29 +1328,32 @@
|
|
|
|
|
|
(rum/defc block-reference
|
|
|
[config id label]
|
|
|
- (if (config/db-based-graph?)
|
|
|
- (page-reference config id label)
|
|
|
- (let [block-id (and id (if (uuid? id) id (parse-uuid id)))
|
|
|
- [block set-block!] (hooks/use-state (db/entity [:block/uuid block-id]))
|
|
|
- self-reference? (when (set? (:ref-set config))
|
|
|
- (contains? (:ref-set config) block-id))]
|
|
|
- (hooks/use-effect!
|
|
|
- (fn []
|
|
|
- (p/let [block (db-async/<get-block (state/get-current-repo)
|
|
|
- block-id
|
|
|
- {:children? false
|
|
|
- :skip-refresh? true})]
|
|
|
- (set-block! block)))
|
|
|
- [])
|
|
|
- (when-not self-reference?
|
|
|
- (if block
|
|
|
- (let [config' (update config :ref-set (fn [s]
|
|
|
- (let [bid (:block/uuid (:block config))]
|
|
|
- (if (nil? s)
|
|
|
- #{bid}
|
|
|
- (conj s bid block-id)))))]
|
|
|
- (block-reference-aux config' block label))
|
|
|
- (invalid-node-ref block-id))))))
|
|
|
+ (let [block-id (and id (if (uuid? id) id (parse-uuid id)))
|
|
|
+ [block set-block!] (hooks/use-state (db/entity [:block/uuid block-id]))
|
|
|
+ self-reference? (when (set? (:ref-set config))
|
|
|
+ (contains? (:ref-set config) block-id))]
|
|
|
+ (hooks/use-effect!
|
|
|
+ (fn []
|
|
|
+ (p/let [block (db-async/<get-block (state/get-current-repo)
|
|
|
+ block-id
|
|
|
+ {:children? false
|
|
|
+ :skip-refresh? true})]
|
|
|
+ (set-block! block)))
|
|
|
+ [])
|
|
|
+ (when-not self-reference?
|
|
|
+ (cond
|
|
|
+ (config/db-based-graph?)
|
|
|
+ (page-reference config block-id label)
|
|
|
+
|
|
|
+ block
|
|
|
+ (let [config' (update config :ref-set (fn [s]
|
|
|
+ (let [bid (:block/uuid (:block config))]
|
|
|
+ (if (nil? s)
|
|
|
+ #{bid}
|
|
|
+ (conj s bid block-id)))))]
|
|
|
+ (block-reference-aux config' block label))
|
|
|
+ :else
|
|
|
+ (invalid-node-ref block-id)))))
|
|
|
|
|
|
(defn- render-macro
|
|
|
[config name arguments macro-content format]
|