|
|
@@ -942,6 +942,13 @@
|
|
|
nil
|
|
|
nil)))
|
|
|
|
|
|
+(defn- img-audio-video?
|
|
|
+ [block]
|
|
|
+ (let [asset-type (some-> (:logseq.property.asset/type block) keyword)]
|
|
|
+ (or (contains? (common-config/img-formats) asset-type)
|
|
|
+ (contains? config/audio-formats asset-type)
|
|
|
+ (contains? config/video-formats asset-type))))
|
|
|
+
|
|
|
(rum/defc page-reference < rum/reactive
|
|
|
"Component for page reference"
|
|
|
[html-export? s {:keys [nested-link? show-brackets? id] :as config} label]
|
|
|
@@ -957,8 +964,12 @@
|
|
|
config' (assoc config
|
|
|
:label (mldoc/plain->text label)
|
|
|
:contents-page? contents-page?
|
|
|
- :show-icon? true?)]
|
|
|
+ :show-icon? true?)
|
|
|
+ asset? (some? (:logseq.property.asset/type block))]
|
|
|
(cond
|
|
|
+ (and asset? (img-audio-video? block))
|
|
|
+ (asset-cp config block)
|
|
|
+
|
|
|
(string/ends-with? s ".excalidraw")
|
|
|
[:div.draw {:on-click (fn [e]
|
|
|
(.stopPropagation e))}
|
|
|
@@ -1118,61 +1129,64 @@
|
|
|
repo (state/get-current-repo)
|
|
|
stop-inner-events? (= block-type :whiteboard-shape)]
|
|
|
(if (and block (:block/title block))
|
|
|
- (let [title [:span.block-ref
|
|
|
- (block-content (assoc config :block-ref? true :stop-events? stop-inner-events?)
|
|
|
- block nil (:block/uuid block)
|
|
|
- (:slide? config))]
|
|
|
- inner (cond
|
|
|
- label
|
|
|
- (->elem
|
|
|
- :span.block-ref
|
|
|
- (map-inline config label))
|
|
|
- :else
|
|
|
- title)]
|
|
|
- [:div.block-ref-wrap.inline
|
|
|
- {:data-type (name (or block-type :default))
|
|
|
- :data-hl-type hl-type
|
|
|
- :on-pointer-down
|
|
|
- (fn [^js/MouseEvent e]
|
|
|
- (if (util/right-click? e)
|
|
|
- (state/set-state! :block-ref/context {:block (:block config)
|
|
|
- :block-ref block-id})
|
|
|
- (when (and
|
|
|
- (or (gobj/get e "shiftKey")
|
|
|
- (not (.. e -target (closest ".blank"))))
|
|
|
- (not (util/right-click? e)))
|
|
|
- (util/stop e)
|
|
|
-
|
|
|
- (cond
|
|
|
- (gobj/get e "shiftKey")
|
|
|
- (state/sidebar-add-block!
|
|
|
- (state/get-current-repo)
|
|
|
- (:db/id block)
|
|
|
- :block-ref)
|
|
|
-
|
|
|
- (and (util/meta-key? e) (whiteboard-handler/inside-portal? (.-target e)))
|
|
|
- (whiteboard-handler/add-new-block-portal-shape!
|
|
|
- (:block/uuid block)
|
|
|
- (whiteboard-handler/closest-shape (.-target e)))
|
|
|
-
|
|
|
- :else
|
|
|
- (match [block-type (util/electron?)]
|
|
|
+ (let [content-cp (block-content (assoc config :block-ref? true :stop-events? stop-inner-events?)
|
|
|
+ block nil (:block/uuid block)
|
|
|
+ (:slide? config))
|
|
|
+ display-type (:logseq.property.node/display-type block)]
|
|
|
+ (if (and display-type (not (contains? #{:quote :math} display-type)))
|
|
|
+ content-cp
|
|
|
+ (let [title [:span.block-ref content-cp]
|
|
|
+ inner (cond
|
|
|
+ label
|
|
|
+ (->elem
|
|
|
+ :span.block-ref
|
|
|
+ (map-inline config label))
|
|
|
+ :else
|
|
|
+ title)]
|
|
|
+ [:div.block-ref-wrap.inline
|
|
|
+ {:data-type (name (or block-type :default))
|
|
|
+ :data-hl-type hl-type
|
|
|
+ :on-pointer-down
|
|
|
+ (fn [^js/MouseEvent e]
|
|
|
+ (if (util/right-click? e)
|
|
|
+ (state/set-state! :block-ref/context {:block (:block config)
|
|
|
+ :block-ref block-id})
|
|
|
+ (when (and
|
|
|
+ (or (gobj/get e "shiftKey")
|
|
|
+ (not (.. e -target (closest ".blank"))))
|
|
|
+ (not (util/right-click? e)))
|
|
|
+ (util/stop e)
|
|
|
+
|
|
|
+ (cond
|
|
|
+ (gobj/get e "shiftKey")
|
|
|
+ (state/sidebar-add-block!
|
|
|
+ (state/get-current-repo)
|
|
|
+ (:db/id block)
|
|
|
+ :block-ref)
|
|
|
+
|
|
|
+ (and (util/meta-key? e) (whiteboard-handler/inside-portal? (.-target e)))
|
|
|
+ (whiteboard-handler/add-new-block-portal-shape!
|
|
|
+ (:block/uuid block)
|
|
|
+ (whiteboard-handler/closest-shape (.-target e)))
|
|
|
+
|
|
|
+ :else
|
|
|
+ (match [block-type (util/electron?)]
|
|
|
;; pdf annotation
|
|
|
- [:annotation true] (pdf-assets/open-block-ref! block)
|
|
|
+ [:annotation true] (pdf-assets/open-block-ref! block)
|
|
|
|
|
|
- [:whiteboard-shape true] (route-handler/redirect-to-page!
|
|
|
- (get-in block [:block/page :block/uuid]) {:block-id block-id})
|
|
|
+ [:whiteboard-shape true] (route-handler/redirect-to-page!
|
|
|
+ (get-in block [:block/page :block/uuid]) {:block-id block-id})
|
|
|
|
|
|
;; default open block page
|
|
|
- :else (route-handler/redirect-to-page! id))))))}
|
|
|
-
|
|
|
- (if (and (not (util/mobile?))
|
|
|
- (not (:preview? config))
|
|
|
- (not (:modal/show? @state/state))
|
|
|
- (nil? block-type))
|
|
|
- (block-reference-preview inner
|
|
|
- {:repo repo :config config :id block-id})
|
|
|
- inner)])
|
|
|
+ :else (route-handler/redirect-to-page! id))))))}
|
|
|
+
|
|
|
+ (if (and (not (util/mobile?))
|
|
|
+ (not (:preview? config))
|
|
|
+ (not (:modal/show? @state/state))
|
|
|
+ (nil? block-type))
|
|
|
+ (block-reference-preview inner
|
|
|
+ {:repo repo :config config :id block-id})
|
|
|
+ inner)])))
|
|
|
(invalid-node-ref id))))
|
|
|
(invalid-node-ref id))))
|
|
|
|
|
|
@@ -1798,7 +1812,7 @@
|
|
|
["Latex_Fragment" [display s]] ;display can be "Displayed" or "Inline"
|
|
|
(if html-export?
|
|
|
(latex/html-export s false true)
|
|
|
- (latex/latex (str (d/squuid)) s false (not= display "Inline")))
|
|
|
+ (latex/latex s false (not= display "Inline")))
|
|
|
|
|
|
[(:or "Target" "Radio_Target") s]
|
|
|
[:a {:id s} s]
|
|
|
@@ -2195,15 +2209,19 @@
|
|
|
(text-block-title (dissoc config :raw-title?) block)
|
|
|
|
|
|
(= "asset" (:block/type block))
|
|
|
- (asset-cp config block)
|
|
|
+ [:div.grid.grid-cols-1.justify-items-center
|
|
|
+ (asset-cp config block)
|
|
|
+ (when (img-audio-video? block)
|
|
|
+ [:div.text-xs.opacity-60.mt-1
|
|
|
+ (text-block-title (dissoc config :raw-title?) block)])]
|
|
|
|
|
|
(= :code node-display-type)
|
|
|
[:div.flex.flex-1.w-full
|
|
|
- (src-cp (assoc config :block block) {:language (:logseq.property.code/lang block)})]
|
|
|
+ (src-cp (assoc config :code-block block) {:language (:logseq.property.code/lang block)})]
|
|
|
|
|
|
;; TODO: switched to https://cortexjs.io/mathlive/ for editing
|
|
|
(= :math node-display-type)
|
|
|
- (latex/latex (str (:container-id config) "-" (:db/id block)) (:block/title block) true false)
|
|
|
+ (latex/latex (:block/title block) true false)
|
|
|
|
|
|
(and query?
|
|
|
collapsed?
|
|
|
@@ -3159,7 +3177,7 @@
|
|
|
(cond
|
|
|
(and advanced-query? (not collapsed?))
|
|
|
[:div.flex.flex-1.my-1 {:style {:margin-left 42}}
|
|
|
- (src-cp (assoc config :block query)
|
|
|
+ (src-cp (assoc config :code-block query)
|
|
|
{:language "clojure"})]
|
|
|
|
|
|
(and (not advanced-query?) (not collapsed?))
|
|
|
@@ -3613,7 +3631,7 @@
|
|
|
|
|
|
(rum/defc src-cp < rum/static
|
|
|
[config options]
|
|
|
- (let [block (:block config)
|
|
|
+ (let [block (or (:code-block config) (:block config))
|
|
|
container-id (:container-id config)
|
|
|
*mode-ref (rum/use-ref nil)
|
|
|
*actions-ref (rum/use-ref nil)]
|
|
|
@@ -3753,7 +3771,7 @@
|
|
|
["Math" s]
|
|
|
(if html-export?
|
|
|
(latex/html-export s true true)
|
|
|
- (latex/latex (str (d/squuid)) s true true))
|
|
|
+ (latex/latex s true true))
|
|
|
["Example" l]
|
|
|
[:pre.pre-wrap-white-space
|
|
|
(join-lines l)]
|
|
|
@@ -3783,7 +3801,7 @@
|
|
|
(latex/html-export content true false)
|
|
|
(if (config/db-based-graph? (state/get-current-repo))
|
|
|
[:div.warning "'#+BEGIN_EXPORT latex' is deprecated. Use '/Math block' command instead."]
|
|
|
- (latex/latex (str (d/squuid)) content true false)))
|
|
|
+ (latex/latex content true false)))
|
|
|
|
|
|
["Custom" "query" _options _result content]
|
|
|
(if (config/db-based-graph? (state/get-current-repo))
|
|
|
@@ -3832,12 +3850,12 @@
|
|
|
(let [content (latex-environment-content name option content)]
|
|
|
(if html-export?
|
|
|
(latex/html-export content true true)
|
|
|
- (latex/latex (str (d/squuid)) content true true)))
|
|
|
+ (latex/latex content true true)))
|
|
|
|
|
|
["Displayed_Math" content]
|
|
|
(if html-export?
|
|
|
(latex/html-export content true true)
|
|
|
- (latex/latex (str (d/squuid)) content true true))
|
|
|
+ (latex/latex content true true))
|
|
|
|
|
|
["Footnote_Definition" name definition]
|
|
|
(let [id (util/url-encode name)]
|