mirror of
https://github.com/logseq/logseq.git
synced 2026-04-26 23:25:05 +00:00
shui/table introduction
This commit is contained in:
committed by
Gabriel Horner
parent
42dd084544
commit
928742e66b
@@ -23,8 +23,8 @@
|
||||
[frontend.context.i18n :refer [t]]
|
||||
[frontend.date :as date]
|
||||
[frontend.db :as db]
|
||||
[frontend.db-mixins :as db-mixins]
|
||||
[frontend.db.model :as model]
|
||||
[frontend.db-mixins :as db-mixins]
|
||||
[frontend.extensions.highlight :as highlight]
|
||||
[frontend.extensions.latex :as latex]
|
||||
[frontend.extensions.lightbox :as lightbox]
|
||||
@@ -52,6 +52,7 @@
|
||||
[frontend.mobile.util :as mobile-util]
|
||||
[frontend.modules.outliner.tree :as tree]
|
||||
[frontend.security :as security]
|
||||
[frontend.shui :refer [get-shui-component-version make-shui-context]]
|
||||
[frontend.state :as state]
|
||||
[frontend.template :as template]
|
||||
[frontend.ui :as ui]
|
||||
@@ -73,6 +74,7 @@
|
||||
[logseq.graph-parser.util.block-ref :as block-ref]
|
||||
[logseq.graph-parser.util.page-ref :as page-ref]
|
||||
[logseq.graph-parser.whiteboard :as gp-whiteboard]
|
||||
[logseq.shui.core :as shui]
|
||||
[medley.core :as medley]
|
||||
[promesa.core :as p]
|
||||
[reitit.frontend.easy :as rfe]
|
||||
@@ -292,8 +294,8 @@
|
||||
(js/setTimeout #(reset! *resizing-image? false) 200)))
|
||||
:onClick (fn [e]
|
||||
(when @*resizing-image? (util/stop e)))}
|
||||
(and (:width metadata) (not (util/mobile?)))
|
||||
(assoc :style {:width (:width metadata)}))
|
||||
(and (:width metadata) (not (util/mobile?)))
|
||||
(assoc :style {:width (:width metadata)}))
|
||||
{})
|
||||
[:div.asset-container {:key "resize-asset-container"}
|
||||
[:img.rounded-sm.relative
|
||||
@@ -926,8 +928,8 @@
|
||||
inner)])
|
||||
[:span.warning.mr-1 {:title "Block ref invalid"}
|
||||
(block-ref/->block-ref id)]))
|
||||
[:span.warning.mr-1 {:title "Block ref invalid"}
|
||||
(block-ref/->block-ref id)]))
|
||||
[:span.warning.mr-1 {:title "Block ref invalid"}
|
||||
(block-ref/->block-ref id)]))
|
||||
|
||||
(defn inline-text
|
||||
([format v]
|
||||
@@ -1106,8 +1108,8 @@
|
||||
{:href (path/path-join "file://" path)
|
||||
:data-href path
|
||||
:target "_blank"}
|
||||
title
|
||||
(assoc :title title))
|
||||
title
|
||||
(assoc :title title))
|
||||
(map-inline config label)))
|
||||
|
||||
:else
|
||||
@@ -1200,8 +1202,8 @@
|
||||
(cond->
|
||||
{:href (ar-url->http-url href)
|
||||
:target "_blank"}
|
||||
title
|
||||
(assoc :title title))
|
||||
title
|
||||
(assoc :title title))
|
||||
(map-inline config label))
|
||||
|
||||
:else
|
||||
@@ -1210,11 +1212,11 @@
|
||||
(cond->
|
||||
{:href href
|
||||
:target "_blank"}
|
||||
title
|
||||
(assoc :title title))
|
||||
title
|
||||
(assoc :title title))
|
||||
(map-inline config label)))))))
|
||||
|
||||
(declare ->hiccup)
|
||||
(declare ->hiccup inline)
|
||||
|
||||
(defn wrap-query-components
|
||||
[config]
|
||||
@@ -1223,7 +1225,8 @@
|
||||
:->elem ->elem
|
||||
:page-cp page-cp
|
||||
:inline-text inline-text
|
||||
:map-inline map-inline}))
|
||||
:map-inline map-inline
|
||||
:inline inline}))
|
||||
|
||||
;;;; Macro component render functions
|
||||
(defn- macro-query-cp
|
||||
@@ -2247,7 +2250,7 @@
|
||||
(and (not block-content?)
|
||||
(seq (:block/children block))
|
||||
(= move-to :nested)))
|
||||
(dnd-separator move-to block-content?))))))
|
||||
(dnd-separator move-to block-content?))))))
|
||||
|
||||
(defn clock-summary-cp
|
||||
[block body]
|
||||
@@ -2312,19 +2315,19 @@
|
||||
content (if (string? content) (string/trim content) "")
|
||||
mouse-down-key (if (util/ios?)
|
||||
:on-click
|
||||
:on-mouse-down ; TODO: it seems that Safari doesn't work well with on-mouse-down
|
||||
)
|
||||
:on-mouse-down) ; TODO: it seems that Safari doesn't work well with on-mouse-down
|
||||
|
||||
attrs (cond->
|
||||
{:blockid (str uuid)
|
||||
:data-type (name block-type)
|
||||
:style {:width "100%" :pointer-events (when stop-events? "none")}}
|
||||
|
||||
(not (string/blank? (:hl-color properties)))
|
||||
(assoc :data-hl-color (:hl-color properties))
|
||||
(not (string/blank? (:hl-color properties)))
|
||||
(assoc :data-hl-color (:hl-color properties))
|
||||
|
||||
(not block-ref?)
|
||||
(assoc mouse-down-key (fn [e]
|
||||
(block-content-on-mouse-down e block block-id content edit-input-id))))]
|
||||
(not block-ref?)
|
||||
(assoc mouse-down-key (fn [e]
|
||||
(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]
|
||||
@@ -3002,8 +3005,8 @@
|
||||
:li
|
||||
(cond->
|
||||
{:checked checked?}
|
||||
number
|
||||
(assoc :value number))
|
||||
number
|
||||
(assoc :value number))
|
||||
(vec-cat
|
||||
[(->elem
|
||||
:p
|
||||
@@ -3021,52 +3024,55 @@
|
||||
|
||||
(defn table
|
||||
[config {:keys [header groups col_groups]}]
|
||||
(let [tr (fn [elm cols]
|
||||
(->elem
|
||||
:tr
|
||||
(mapv (fn [col]
|
||||
(->elem
|
||||
elm
|
||||
{:scope "col"
|
||||
:class "org-left"}
|
||||
(map-inline config col)))
|
||||
cols)))
|
||||
tb-col-groups (try
|
||||
(mapv (fn [number]
|
||||
(let [col-elem [:col {:class "org-left"}]]
|
||||
(->elem
|
||||
:colgroup
|
||||
(repeat number col-elem))))
|
||||
col_groups)
|
||||
(catch :default _e
|
||||
[]))
|
||||
head (when header
|
||||
[:thead (tr :th header)])
|
||||
groups (mapv (fn [group]
|
||||
(->elem
|
||||
:tbody
|
||||
(mapv #(tr :td %) group)))
|
||||
groups)]
|
||||
[:div.table-wrapper
|
||||
(->elem
|
||||
:table
|
||||
{:class "table-auto"
|
||||
:border 2
|
||||
:cell-spacing 0
|
||||
:cell-padding 6
|
||||
:rules "groups"
|
||||
:frame "hsides"}
|
||||
(vec-cat
|
||||
tb-col-groups
|
||||
(cons head groups)))]))
|
||||
(case (get-shui-component-version :table config)
|
||||
2 (shui/table-v2 {:data (concat [[header]] groups)}
|
||||
(make-shui-context config inline))
|
||||
1 (let [tr (fn [elm cols]
|
||||
(->elem
|
||||
:tr
|
||||
(mapv (fn [col]
|
||||
(->elem
|
||||
elm
|
||||
{:scope "col"
|
||||
:class "org-left"}
|
||||
(map-inline config col)))
|
||||
cols)))
|
||||
tb-col-groups (try
|
||||
(mapv (fn [number]
|
||||
(let [col-elem [:col {:class "org-left"}]]
|
||||
(->elem
|
||||
:colgroup
|
||||
(repeat number col-elem))))
|
||||
col_groups)
|
||||
(catch :default _e
|
||||
[]))
|
||||
head (when header
|
||||
[:thead (tr :th header)])
|
||||
groups (mapv (fn [group]
|
||||
(->elem
|
||||
:tbody
|
||||
(mapv #(tr :td %) group)))
|
||||
groups)]
|
||||
[:div.table-wrapper
|
||||
(->elem
|
||||
:table
|
||||
{:class "table-auto"
|
||||
:border 2
|
||||
:cell-spacing 0
|
||||
:cell-padding 6
|
||||
:rules "groups"
|
||||
:frame "hsides"}
|
||||
(vec-cat
|
||||
tb-col-groups
|
||||
(cons head groups)))])))
|
||||
|
||||
(defn logbook-cp
|
||||
[log]
|
||||
(let [clocks (filter #(string/starts-with? % "CLOCK:") log)
|
||||
clocks (reverse (sort-by str clocks))
|
||||
clocks (reverse (sort-by str clocks))]
|
||||
;; TODO: display states change log
|
||||
; states (filter #(not (string/starts-with? % "CLOCK:")) log)
|
||||
]
|
||||
|
||||
(when (seq clocks)
|
||||
(let [tr (fn [elm cols] (->elem :tr
|
||||
(mapv (fn [col] (->elem elm col)) cols)))
|
||||
@@ -3091,6 +3097,8 @@
|
||||
[config col]
|
||||
(map #(inline config %) col))
|
||||
|
||||
(declare ->hiccup)
|
||||
|
||||
(rum/defc src-cp < rum/static
|
||||
[config options html-export?]
|
||||
(when options
|
||||
|
||||
Reference in New Issue
Block a user