mirror of https://github.com/logseq/logseq
cleanup: frontend.components.block.cljs
parent
43cc8c2723
commit
be28193e32
|
@ -61,8 +61,7 @@
|
|||
[reitit.frontend.easy :as rfe]
|
||||
[rum.core :as rum]
|
||||
[shadow.loader :as loader]
|
||||
[frontend.components.query-table :as query-table]
|
||||
[frontend.mixins :as mixins]))
|
||||
[frontend.components.query-table :as query-table]))
|
||||
|
||||
;; TODO: remove rum/with-context because it'll make reactive queries not working
|
||||
|
||||
|
@ -219,7 +218,7 @@
|
|||
{:title (t :asset/confirm-delete (.toLocaleLowerCase (t :text/image)))
|
||||
:sub-title (if local? :asset/physical-delete "")
|
||||
:sub-checkbox? local?
|
||||
:on-confirm (fn [e {:keys [close-fn sub-selected]}]
|
||||
:on-confirm (fn [_e {:keys [close-fn sub-selected]}]
|
||||
(close-fn)
|
||||
(editor-handler/delete-asset-of-block!
|
||||
{:block-id block-id
|
||||
|
@ -238,7 +237,7 @@
|
|||
:on-click (fn [^js e] (let [images (js/document.querySelectorAll ".asset-container img")
|
||||
images (to-array images)
|
||||
images (if-not (= (count images) 1)
|
||||
(let [^js image (.closest (.-target e) ".asset-container")
|
||||
(let [^js _image (.closest (.-target e) ".asset-container")
|
||||
image (js/image.querySelector "img")]
|
||||
(cons image (remove #(= image %) images)))
|
||||
images)
|
||||
|
@ -246,14 +245,14 @@
|
|||
:w (.-naturalWidth it)
|
||||
:h (.-naturalHeight it)})]
|
||||
|
||||
(if (seq images)
|
||||
(when (seq images)
|
||||
(lightbox/preview-images! images))))}
|
||||
|
||||
(svg/maximize)]]])))))
|
||||
|
||||
(rum/defcs asset-link < rum/reactive
|
||||
(rum/local nil ::src)
|
||||
[state config title href label metadata full_text]
|
||||
[state config title href metadata full_text]
|
||||
(let [src (::src state)
|
||||
granted? (state/sub [:nfs/user-granted? (state/get-current-repo)])
|
||||
href (config/get-local-asset-absolute-path href)]
|
||||
|
@ -274,7 +273,7 @@
|
|||
[:span.warning full_text]
|
||||
(if (and (config/local-asset? href)
|
||||
(config/local-db? (state/get-current-repo)))
|
||||
(asset-link config title href label metadata full_text)
|
||||
(asset-link config title href metadata full_text)
|
||||
(let [protocol (and (= "Complex" (first url))
|
||||
(:protocol (second url)))
|
||||
href (cond
|
||||
|
@ -300,7 +299,7 @@
|
|||
(str kind n (string/lower-case (str (first duration))))))
|
||||
|
||||
(defn timestamp-to-string
|
||||
[{:keys [active date time repetition wday active]}]
|
||||
[{:keys [_active date time repetition wday active]}]
|
||||
(let [{:keys [year month day]} date
|
||||
{:keys [hour min]} time
|
||||
[open close] (if active ["<" ">"] ["[" "]"])
|
||||
|
@ -326,7 +325,7 @@
|
|||
repetition
|
||||
close)))
|
||||
|
||||
(defn timestamp [{:keys [active date time repetition wday] :as t} kind]
|
||||
(defn timestamp [{:keys [active _date _time _repetition _wday] :as t} kind]
|
||||
(let [prefix (case kind
|
||||
"Scheduled"
|
||||
[:i {:class "fa fa-calendar"
|
||||
|
@ -345,14 +344,14 @@
|
|||
"From: "
|
||||
"Stop"
|
||||
"To: "
|
||||
nil)]
|
||||
(let [class (when (= kind "Closed")
|
||||
"line-through")]
|
||||
[:span.timestamp (cond-> {:active (str active)}
|
||||
class
|
||||
(assoc :class class))
|
||||
prefix
|
||||
(timestamp-to-string t)])))
|
||||
nil)
|
||||
class (when (= kind "Closed")
|
||||
"line-through")]
|
||||
[:span.timestamp (cond-> {:active (str active)}
|
||||
class
|
||||
(assoc :class class))
|
||||
prefix
|
||||
(timestamp-to-string t)]))
|
||||
|
||||
(defn range [{:keys [start stop]} stopped?]
|
||||
[:div {:class "timestamp-range"
|
||||
|
@ -367,7 +366,7 @@
|
|||
(declare page-reference)
|
||||
|
||||
(rum/defc page-inner
|
||||
[config page-name-in-block page-name href redirect-page-name page-entity contents-page? children html-export? label]
|
||||
[config page-name-in-block page-name redirect-page-name page-entity contents-page? children html-export? label]
|
||||
(let [tag? (:tag? config)]
|
||||
[:a
|
||||
{:class (if tag? "tag" "page-ref")
|
||||
|
@ -461,19 +460,16 @@
|
|||
children)))
|
||||
|
||||
(rum/defc page-cp
|
||||
[{:keys [html-export? label children contents-page? sidebar? preview?] :as config} page]
|
||||
[{:keys [html-export? label children contents-page? preview?] :as config} page]
|
||||
(when-let [page-name-in-block (:block/name page)]
|
||||
(let [page-name-in-block (util/remove-boundary-slashes page-name-in-block)
|
||||
page-name (string/lower-case page-name-in-block)
|
||||
page-entity (db/entity [:block/name page-name])
|
||||
redirect-page-name (model/get-redirect-page-name page-name (:block/alias? config))
|
||||
href (if html-export?
|
||||
(util/encode-str page-name)
|
||||
(rfe/href :page {:name redirect-page-name}))
|
||||
inner (page-inner config
|
||||
page-name-in-block
|
||||
page-name
|
||||
href redirect-page-name page-entity contents-page? children html-export? label)]
|
||||
redirect-page-name page-entity contents-page? children html-export? label)]
|
||||
(if (and (not (util/mobile?)) (not preview?))
|
||||
(page-preview-trigger (assoc config :children inner) page-name)
|
||||
inner))))
|
||||
|
@ -530,8 +526,7 @@
|
|||
[html-export? s config label]
|
||||
(let [show-brackets? (state/show-brackets?)
|
||||
nested-link? (:nested-link? config)
|
||||
contents-page? (= "contents" (string/lower-case (str (:id config))))
|
||||
draw? (string/ends-with? s ".excalidraw")]
|
||||
contents-page? (= "contents" (string/lower-case (str (:id config))))]
|
||||
(if (string/ends-with? s ".excalidraw")
|
||||
[:div.draw {:on-click (fn [e]
|
||||
(.stopPropagation e))}
|
||||
|
@ -688,8 +683,7 @@
|
|||
{:style {:width 735
|
||||
:text-align "left"
|
||||
:max-height 600}}
|
||||
[(block-parents config repo block-id (:block/format config)
|
||||
{:indent? true})
|
||||
[(block-parents config repo block-id {:indent? true})
|
||||
(blocks-container
|
||||
(db/get-block-and-children repo block-id)
|
||||
(assoc config :id (str id) :preview? true))]])
|
||||
|
@ -811,7 +805,7 @@
|
|||
(->elem :sup (map-inline config l))
|
||||
["Subscript" l]
|
||||
(->elem :sub (map-inline config l))
|
||||
["Tag" s]
|
||||
["Tag" _s]
|
||||
(when-let [s (block/get-tag item)]
|
||||
(let [s (text/page-ref-un-brackets! s)]
|
||||
(page-cp (assoc config :tag? true) {:block/name s})))
|
||||
|
@ -994,7 +988,7 @@
|
|||
(show-link? config metadata href full_text))
|
||||
[:a.asset-ref.is-pdf
|
||||
{:href "javascript:void(0);"
|
||||
:on-mouse-down (fn [e]
|
||||
:on-mouse-down (fn [_event]
|
||||
(when-let [current (pdf-assets/inflate-asset href)]
|
||||
(state/set-state! :pdf/current current)))}
|
||||
(get-label-text label)]
|
||||
|
@ -1041,9 +1035,9 @@
|
|||
["Hard_Break_Line"]
|
||||
[:br]
|
||||
|
||||
["Timestamp" ["Scheduled" t]]
|
||||
["Timestamp" ["Scheduled" _timestamp]]
|
||||
nil
|
||||
["Timestamp" ["Deadline" t]]
|
||||
["Timestamp" ["Deadline" _timestamp]]
|
||||
nil
|
||||
|
||||
["Timestamp" ["Date" t]]
|
||||
|
@ -1066,7 +1060,7 @@
|
|||
(util/format "[%d/%d]" current total)]
|
||||
|
||||
["Footnote_Reference" options]
|
||||
(let [{:keys [id name]} options
|
||||
(let [{:keys [name]} options
|
||||
encode-name (util/url-encode name)]
|
||||
[:sup.fn
|
||||
[:a {:id (str "fnr." encode-name)
|
||||
|
@ -1257,7 +1251,7 @@
|
|||
|
||||
2
|
||||
(cond
|
||||
(and (util/safe-parse-int (nth arguments 1)))
|
||||
(util/safe-parse-int (nth arguments 1))
|
||||
(util/format "[:img {:src \"%s\" :style {:width %s}}]"
|
||||
(first arguments)
|
||||
(util/safe-parse-int (nth arguments 1)))
|
||||
|
@ -1315,7 +1309,7 @@
|
|||
(reset! *dragging-block block))
|
||||
|
||||
(defn- bullet-on-click
|
||||
[e block config uuid]
|
||||
[e block uuid]
|
||||
(if (gobj/get e "shiftKey")
|
||||
(do
|
||||
(state/sidebar-add-block!
|
||||
|
@ -1362,7 +1356,7 @@
|
|||
(every? #(= % ["Horizontal_Rule"]) body)))
|
||||
|
||||
(rum/defcs block-control < rum/reactive
|
||||
[state config block uuid block-id body children collapsed? *ref-collapsed? *control-show? edit-input-id edit? doc-mode?]
|
||||
[state config block uuid block-id body children collapsed? *ref-collapsed? *control-show? edit?]
|
||||
(let [doc-mode? (state/sub :document/mode?)
|
||||
has-children-blocks? (and (coll? children) (seq children))
|
||||
has-child? (and
|
||||
|
@ -1375,7 +1369,6 @@
|
|||
has-children-blocks?)
|
||||
(util/react *control-show?))
|
||||
ref-collapsed? (util/react *ref-collapsed?)
|
||||
dark? (= "dark" (state/sub :ui/theme))
|
||||
ref? (:ref? config)
|
||||
collapsed? (if ref? ref-collapsed? collapsed?)
|
||||
empty-content? (block-content-empty? block)]
|
||||
|
@ -1386,8 +1379,8 @@
|
|||
|
||||
[:a.block-control
|
||||
{:id (str "control-" uuid)
|
||||
:on-click (fn [e]
|
||||
(util/stop e)
|
||||
:on-click (fn [event]
|
||||
(util/stop event)
|
||||
(when-not (and (not collapsed?) (not has-child?))
|
||||
(if ref?
|
||||
(swap! *ref-collapsed? not)
|
||||
|
@ -1396,8 +1389,8 @@
|
|||
(editor-handler/collapse-block! uuid)))))}
|
||||
[:span {:class (if control-show? "control-show" "control-hide")}
|
||||
(ui/rotating-arrow collapsed?)]]
|
||||
(let [bullet [:a {:on-click (fn [e]
|
||||
(bullet-on-click e block config uuid))}
|
||||
(let [bullet [:a {:on-click (fn [event]
|
||||
(bullet-on-click event block uuid))}
|
||||
[:span.bullet-container.cursor
|
||||
{:id (str "dot-" uuid)
|
||||
:draggable true
|
||||
|
@ -1430,7 +1423,7 @@
|
|||
bullet))]))
|
||||
|
||||
(rum/defc dnd-separator
|
||||
[block move-to block-content?]
|
||||
[move-to block-content?]
|
||||
[:div.relative
|
||||
[:div.dnd-separator.absolute
|
||||
{:style {:left (cond-> (if (= move-to :nested) 40 20)
|
||||
|
@ -1485,7 +1478,7 @@
|
|||
marker])))
|
||||
|
||||
(defn marker-cp
|
||||
[{:block/keys [pre-block? marker] :as block}]
|
||||
[{:block/keys [pre-block? marker] :as _block}]
|
||||
(when-not pre-block?
|
||||
(when (contains? #{"IN-PROGRESS" "WAIT" "WAITING"} marker)
|
||||
[:span {:class (str "task-status block-marker " (string/lower-case marker))
|
||||
|
@ -1518,7 +1511,7 @@
|
|||
(priority-text priority))))
|
||||
|
||||
(defn block-tags-cp
|
||||
[{:block/keys [pre-block? tags] :as block}]
|
||||
[{:block/keys [pre-block? tags] :as _block}]
|
||||
(when (and (not pre-block?)
|
||||
(seq tags))
|
||||
(->elem
|
||||
|
@ -1536,7 +1529,7 @@
|
|||
(declare block-content)
|
||||
|
||||
(defn build-block-title
|
||||
[{:keys [slide?] :as config} {:block/keys [uuid title tags marker priority meta format content pre-block? page properties unordered level heading-level]
|
||||
[config {:block/keys [title marker pre-block? properties level heading-level]
|
||||
:as t}]
|
||||
(let [config (assoc config :block t)
|
||||
slide? (boolean (:slide? config))
|
||||
|
@ -1610,8 +1603,7 @@
|
|||
|
||||
(rum/defc property-cp
|
||||
[config block k v]
|
||||
(let [pre-block? (:block/pre-block? block)
|
||||
date (and (= k :date) (date/get-locale-string (str v)))]
|
||||
(let [date (and (= k :date) (date/get-locale-string (str v)))]
|
||||
[:div
|
||||
[:span.page-property-key.font-medium (name k)]
|
||||
[:span.mr-1 ":"]
|
||||
|
@ -1711,7 +1703,7 @@
|
|||
(datetime-comp/date-picker nil nil ts)]))]))
|
||||
|
||||
(defn- block-content-on-mouse-down
|
||||
[e block block-id properties content format edit-input-id]
|
||||
[e block block-id content edit-input-id]
|
||||
(.stopPropagation e)
|
||||
(let [target (gobj/get e "target")
|
||||
button (gobj/get e "buttons")]
|
||||
|
@ -1766,15 +1758,14 @@
|
|||
(and (not block-content?)
|
||||
(seq (:block/children block))
|
||||
(= move-to :nested)))
|
||||
(dnd-separator block move-to block-content?))))))
|
||||
(dnd-separator move-to block-content?))))))
|
||||
|
||||
(rum/defc block-content < rum/reactive
|
||||
[config {:block/keys [uuid title body meta content marker page format repo children pre-block? properties idx container block-refs-count scheduled deadline repeated?] :as block} edit-input-id block-id slide?]
|
||||
[config {:block/keys [uuid title body content children properties scheduled deadline] :as block} edit-input-id block-id slide?]
|
||||
(let [collapsed? (get properties :collapsed)
|
||||
block-ref? (:block-ref? config)
|
||||
block-ref-with-title? (and block-ref? (seq title))
|
||||
block-type (or (:ls-type properties) :default)
|
||||
dragging? (rum/react *dragging?)
|
||||
content (if (string? content) (string/trim content) "")
|
||||
mouse-down-key (if (util/ios?)
|
||||
:on-click
|
||||
|
@ -1786,7 +1777,7 @@
|
|||
:style {:width "100%"}}
|
||||
(not block-ref?)
|
||||
(assoc mouse-down-key (fn [e]
|
||||
(block-content-on-mouse-down e block block-id properties content format edit-input-id))))]
|
||||
(block-content-on-mouse-down e block block-id content edit-input-id))))]
|
||||
[:div.block-content.inline
|
||||
(cond-> {:id (str "block-content-" uuid)
|
||||
:on-mouse-up (fn [_e]
|
||||
|
@ -1853,7 +1844,7 @@
|
|||
block-refs-count]])))
|
||||
|
||||
(rum/defc block-content-or-editor < rum/reactive
|
||||
[config {:block/keys [uuid title body meta content page format repo children marker properties pre-block? idx] :as block} edit-input-id block-id slide? heading-level edit?]
|
||||
[config {:block/keys [uuid body format] :as block} edit-input-id block-id heading-level edit?]
|
||||
(let [editor-box (get config :editor-box)
|
||||
editor-id (str "editor-" edit-input-id)
|
||||
slide? (:slide? config)]
|
||||
|
@ -1864,7 +1855,7 @@
|
|||
:block-parent-id block-id
|
||||
:format format
|
||||
:heading-level heading-level
|
||||
:on-hide (fn [value event]
|
||||
:on-hide (fn [_value event]
|
||||
(when (= event :esc)
|
||||
(editor-handler/escape-editing)))}
|
||||
edit-input-id
|
||||
|
@ -1916,7 +1907,7 @@
|
|||
(not @*dragging?)))
|
||||
|
||||
(rum/defc breadcrumb-fragment
|
||||
[config block href label]
|
||||
[config block label]
|
||||
(if (= block :page) ; page
|
||||
(when label
|
||||
(let [page (db/entity [:block/name (string/lower-case label)])]
|
||||
|
@ -1938,7 +1929,7 @@
|
|||
(rum/defc breadcrumb-separator [] [:span.mx-2.opacity-50 "➤"])
|
||||
|
||||
(defn block-parents
|
||||
[config repo block-id format {:keys [show-page? indent?]
|
||||
[config repo block-id {:keys [show-page? indent?]
|
||||
:or {show-page? true}}]
|
||||
(let [parents (db/get-block-parents repo block-id 3)
|
||||
page (db/get-block-page repo block-id)
|
||||
|
@ -1959,7 +1950,7 @@
|
|||
breadcrumb (->> (into [] parents-props)
|
||||
(concat [page-name-props])
|
||||
(filterv identity)
|
||||
(map (fn [[block href label]] (breadcrumb-fragment config block href label)))
|
||||
(map (fn [[block label]] (breadcrumb-fragment config block label)))
|
||||
(interpose (breadcrumb-separator)))]
|
||||
[:div.block-parents.flex-row.flex-1
|
||||
{:class (when (seq breadcrumb)
|
||||
|
@ -2009,7 +2000,7 @@
|
|||
(editor-handler/unhighlight-blocks!))
|
||||
|
||||
(defn- block-mouse-over
|
||||
[e has-child? *control-show? block-id doc-mode?]
|
||||
[e *control-show? block-id doc-mode?]
|
||||
(util/stop e)
|
||||
(reset! *control-show? true)
|
||||
(when-let [parent (gdom/getElement block-id)]
|
||||
|
@ -2023,7 +2014,7 @@
|
|||
(editor-handler/highlight-selection-area! block-id)))
|
||||
|
||||
(defn- block-mouse-leave
|
||||
[e has-child? *control-show? block-id doc-mode?]
|
||||
[e *control-show? block-id doc-mode?]
|
||||
(util/stop e)
|
||||
(reset! *control-show? false)
|
||||
(when doc-mode?
|
||||
|
@ -2035,16 +2026,16 @@
|
|||
(state/into-selection-mode!)))
|
||||
|
||||
(defn- on-drag-and-mouse-attrs
|
||||
[block uuid top? block-id *move-to has-child? *control-show? doc-mode?]
|
||||
[block uuid top? block-id *move-to]
|
||||
{:on-drag-over (fn [event]
|
||||
(block-drag-over event uuid top? block-id *move-to))
|
||||
:on-drag-leave (fn [event]
|
||||
:on-drag-leave (fn [_event]
|
||||
(block-drag-leave *move-to))
|
||||
:on-drop (fn [event]
|
||||
(block-drop event uuid block *move-to))})
|
||||
|
||||
(defn- build-refs-data-value
|
||||
[block refs]
|
||||
[refs]
|
||||
(let [refs (model/get-page-names-by-ids
|
||||
(->> (map :db/id refs)
|
||||
(remove nil?)))]
|
||||
|
@ -2097,7 +2088,7 @@
|
|||
(select-keys (second (:rum/args new-state)) compare-keys))
|
||||
(not= (select-keys (first (:rum/args old-state)) config-compare-keys)
|
||||
(select-keys (first (:rum/args new-state)) config-compare-keys)))))}
|
||||
[state config {:block/keys [uuid title body meta content page format repo children pre-block? top? properties refs path-refs heading-level level type idx] :as block}]
|
||||
[state config {:block/keys [uuid body repo children pre-block? top? properties refs heading-level level type] :as block}]
|
||||
(let [blocks-container-id (:blocks-container-id config)
|
||||
config (update config :block merge block)
|
||||
;; Each block might have multiple queries, but we store only the first query's result
|
||||
|
@ -2111,7 +2102,6 @@
|
|||
(get properties :collapsed))
|
||||
ref? (boolean (:ref? config))
|
||||
breadcrumb-show? (:breadcrumb-show? config)
|
||||
sidebar? (boolean (:sidebar? config))
|
||||
slide? (boolean (:slide? config))
|
||||
custom-query? (boolean (:custom-query? config))
|
||||
doc-mode? (:document/mode? config)
|
||||
|
@ -2123,10 +2113,10 @@
|
|||
(not pre-block?)
|
||||
(or (and (coll? children) (seq children))
|
||||
(seq body))))
|
||||
attrs (on-drag-and-mouse-attrs block uuid top? block-id *move-to has-child? *control-show? doc-mode?)
|
||||
attrs (on-drag-and-mouse-attrs block uuid top? block-id *move-to)
|
||||
children-refs (get-children-refs children)
|
||||
data-refs (build-refs-data-value block children-refs)
|
||||
data-refs-self (build-refs-data-value block refs)
|
||||
data-refs (build-refs-data-value children-refs)
|
||||
data-refs-self (build-refs-data-value refs)
|
||||
edit-input-id (str "edit-block-" blocks-container-id "-" uuid)
|
||||
edit? (state/sub [:editor/editing? edit-input-id])]
|
||||
[:div.ls-block.flex.flex-col.rounded-sm
|
||||
|
@ -2155,8 +2145,8 @@
|
|||
(assoc :data-query true))
|
||||
|
||||
(when (and ref? breadcrumb-show?)
|
||||
(block-parents config repo uuid format {:show-page? false
|
||||
:indent? true}))
|
||||
(block-parents config repo uuid {:show-page? false
|
||||
:indent? true}))
|
||||
|
||||
;; only render this for the first block in each container
|
||||
(when top?
|
||||
|
@ -2165,13 +2155,13 @@
|
|||
[:div.flex.flex-row.pr-2
|
||||
{:class (if heading? "items-baseline" "")
|
||||
:on-mouse-over (fn [e]
|
||||
(block-mouse-over e has-child? *control-show? block-id doc-mode?))
|
||||
(block-mouse-over e *control-show? block-id doc-mode?))
|
||||
:on-mouse-leave (fn [e]
|
||||
(block-mouse-leave e has-child? *control-show? block-id doc-mode?))}
|
||||
(block-mouse-leave e *control-show? block-id doc-mode?))}
|
||||
(when (not slide?)
|
||||
(block-control config block uuid block-id body children collapsed? *ref-collapsed? *control-show? edit-input-id edit? doc-mode?))
|
||||
(block-control config block uuid block-id body children collapsed? *ref-collapsed? *control-show? edit?))
|
||||
|
||||
(block-content-or-editor config block edit-input-id block-id slide? heading-level edit?)]
|
||||
(block-content-or-editor config block edit-input-id block-id heading-level edit?)]
|
||||
|
||||
(block-children config children collapsed? *ref-collapsed?)
|
||||
|
||||
|
@ -2199,7 +2189,7 @@
|
|||
(defn list-element
|
||||
[l]
|
||||
(match l
|
||||
[l1 & tl]
|
||||
[l1 & _tl]
|
||||
(let [{:keys [ordered name]} l1]
|
||||
(cond
|
||||
(seq name)
|
||||
|
@ -2213,7 +2203,7 @@
|
|||
:ul))
|
||||
|
||||
(defn list-item
|
||||
[config {:keys [name content checkbox items number] :as l}]
|
||||
[config {:keys [name content checkbox items number] :as _list}]
|
||||
(let [content (when-not (empty? content)
|
||||
(match content
|
||||
[["Paragraph" i] & rest]
|
||||
|
@ -2277,7 +2267,7 @@
|
|||
:colgroup
|
||||
(repeat number col-elem))))
|
||||
col_groups)
|
||||
(catch js/Error e
|
||||
(catch js/Error _e
|
||||
[]))
|
||||
head (when header
|
||||
[:thead (tr :th header)])
|
||||
|
@ -2308,10 +2298,10 @@
|
|||
|
||||
(defn built-in-custom-query?
|
||||
[title]
|
||||
(let [repo (state/get-current-repo)]
|
||||
(let [queries (state/sub [:config repo :default-queries :journals])]
|
||||
(when (seq queries)
|
||||
(boolean (some #(= % title) (map :title queries)))))))
|
||||
(let [repo (state/get-current-repo)
|
||||
queries (state/sub [:config repo :default-queries :journals])]
|
||||
(when (seq queries)
|
||||
(boolean (some #(= % title) (map :title queries))))))
|
||||
|
||||
(defn- trigger-custom-query!
|
||||
[state]
|
||||
|
@ -2354,7 +2344,7 @@
|
|||
(state/remove-custom-query-component! query)
|
||||
(db/remove-custom-query! (state/get-current-repo) query))
|
||||
state)}
|
||||
[state config {:keys [title query inputs view collapsed? children? breadcrumb-show?] :as q}]
|
||||
[state config {:keys [title query view collapsed? children? breadcrumb-show?] :as q}]
|
||||
(ui/catch-error
|
||||
[:div.warning
|
||||
[:p "Query failed: "]
|
||||
|
@ -2468,7 +2458,7 @@
|
|||
{:default-collapsed? collapsed?}))]))))
|
||||
|
||||
(defn admonition
|
||||
[config type options result]
|
||||
[config type result]
|
||||
(when-let [icon (case (string/lower-case (name type))
|
||||
"note" svg/note
|
||||
"tip" svg/tip
|
||||
|
@ -2606,7 +2596,7 @@
|
|||
(when (not html-export?)
|
||||
[:div.raw_html {:dangerouslySetInnerHTML
|
||||
{:__html content}}])
|
||||
["Export" "html" options content]
|
||||
["Export" "html" _options content]
|
||||
(when (not html-export?)
|
||||
[:div.export_html {:dangerouslySetInnerHTML
|
||||
{:__html content}}])
|
||||
|
@ -2617,12 +2607,12 @@
|
|||
(-> (safe-read-string content)
|
||||
(security/remove-javascript-links-in-href)))
|
||||
|
||||
["Export" "latex" options content]
|
||||
["Export" "latex" _options content]
|
||||
(if html-export?
|
||||
(latex/html-export content true false)
|
||||
(latex/latex (str (dc/squuid)) content true false))
|
||||
|
||||
["Custom" "query" _options result content]
|
||||
["Custom" "query" _options _result content]
|
||||
(try
|
||||
(let [query (reader/read-string content)
|
||||
query (if (string? query)
|
||||
|
@ -2635,30 +2625,30 @@
|
|||
[:div.warning {:title "Invalid query"}
|
||||
content]))
|
||||
|
||||
["Custom" "note" options result content]
|
||||
(admonition config "note" options result)
|
||||
["Custom" "note" _options result _content]
|
||||
(admonition config "note" result)
|
||||
|
||||
["Custom" "tip" options result content]
|
||||
(admonition config "tip" options result)
|
||||
["Custom" "tip" _options result _content]
|
||||
(admonition config "tip" result)
|
||||
|
||||
["Custom" "important" options result content]
|
||||
(admonition config "important" options result)
|
||||
["Custom" "important" _options result _content]
|
||||
(admonition config "important" result)
|
||||
|
||||
["Custom" "caution" options result content]
|
||||
(admonition config "caution" options result)
|
||||
["Custom" "caution" _options result _content]
|
||||
(admonition config "caution" result)
|
||||
|
||||
["Custom" "warning" options result content]
|
||||
(admonition config "warning" options result)
|
||||
["Custom" "warning" _options result _content]
|
||||
(admonition config "warning" result)
|
||||
|
||||
["Custom" "pinned" options result content]
|
||||
(admonition config "pinned" options result)
|
||||
["Custom" "pinned" _options result _content]
|
||||
(admonition config "pinned" result)
|
||||
|
||||
["Custom" "center" options l content]
|
||||
["Custom" "center" _options l _content]
|
||||
(->elem
|
||||
:div.text-center
|
||||
(markup-elements-cp config l))
|
||||
|
||||
["Custom" name options l content]
|
||||
["Custom" name _options l _content]
|
||||
(->elem
|
||||
:div
|
||||
{:class name}
|
||||
|
@ -2821,12 +2811,11 @@
|
|||
[:div
|
||||
(page-cp config page)
|
||||
(when alias? [:span.text-sm.font-medium.opacity-50 " Alias"])]
|
||||
(for [[parent blocks] parent-blocks]
|
||||
(for [[_parent blocks] parent-blocks]
|
||||
(let [block (first blocks)]
|
||||
[:div
|
||||
(when (:breadcrumb-show? config)
|
||||
(block-parents config (state/get-current-repo) (:block/uuid block)
|
||||
(:block/format block)
|
||||
{:show-page? false}))
|
||||
(blocks-container blocks (assoc config :breadcrumb-show? false))]))
|
||||
{})])))]
|
||||
|
|
|
@ -340,7 +340,7 @@
|
|||
(let [config {:id "block-parent"
|
||||
:block? true}]
|
||||
[:div.mb-4
|
||||
(block/block-parents config repo block-id format {})]))
|
||||
(block/block-parents config repo block-id {})]))
|
||||
|
||||
;; blocks
|
||||
(let [page (if block?
|
||||
|
|
|
@ -78,8 +78,7 @@
|
|||
format (:block/format block)]
|
||||
[[:div.ml-2.mt-1
|
||||
(block/block-parents {:id "block-parent"
|
||||
:block? true} repo block-id format
|
||||
{})]
|
||||
:block? true} repo block-id {})]
|
||||
[:div.ml-2
|
||||
(block-cp repo idx block)]])])
|
||||
|
||||
|
@ -88,8 +87,7 @@
|
|||
(let [block-id (:block/uuid block-data)
|
||||
format (:block/format block-data)]
|
||||
[(block/block-parents {:id "block-parent"
|
||||
:block? true} repo block-id format
|
||||
{})
|
||||
:block? true} repo block-id {})
|
||||
[:div.ml-2
|
||||
(block-cp repo idx block-data)]]))
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@
|
|||
:block? true
|
||||
:search? true}
|
||||
repo
|
||||
(clojure.core/uuid uuid) format
|
||||
(clojure.core/uuid uuid)
|
||||
{:indent? false})])
|
||||
[:div {:class "font-medium" :key "content"} (highlight-exact-query content q)]]])
|
||||
|
||||
|
|
|
@ -445,9 +445,7 @@
|
|||
(util/hiccup->class ".flex.flex-col.resize.overflow-y-auto"))}
|
||||
(let [repo (state/get-current-repo)]
|
||||
[:div.my-2.opacity-70.hover:opacity-100
|
||||
(component-block/block-parents {} repo root-block-id
|
||||
(:block/format root-block)
|
||||
{})])
|
||||
(component-block/block-parents {} repo root-block-id {})])
|
||||
(component-block/blocks-container
|
||||
blocks
|
||||
(merge (show-cycle-config card @phase)
|
||||
|
|
Loading…
Reference in New Issue