fix: slide bugs

close #4799
pull/7142/head
Tienson Qin 2022-10-29 07:24:47 +08:00
parent 223b62de28
commit ef7e3d2fa4
4 changed files with 27 additions and 12 deletions

View File

@ -2716,7 +2716,7 @@
edit? (state/sub [:editor/editing? edit-input-id])
card? (string/includes? data-refs-self "\"card\"")
review-cards? (:review-cards? config)
selected? (state/sub-block-selected? uuid)]
selected? (when-not slide? (state/sub-block-selected? uuid))]
[:div.ls-block
(cond->
{:id block-id
@ -2728,7 +2728,7 @@
(when (and card? (not review-cards?)) " shadow-md")
(when selected? " selected noselect"))
:blockid (str uuid)
:haschild (str has-child?)}
:haschild (str (boolean has-child?))}
level
(assoc :level level)

View File

@ -3,6 +3,7 @@
[cljs-bean.core :as bean]
[frontend.loader :as loader]
[frontend.ui :as ui]
[frontend.util :as util]
[frontend.config :as config]
[frontend.components.block :as block]
[clojure.string :as string]
@ -37,17 +38,17 @@
:controls true
:history false
:center true
:transition "slide"}))]
:transition "slide"
:keyboardCondition "focused"}))]
(.initialize deck)))
;; reveal.js doesn't support multiple nested sections yet.
;; https://github.com/hakimel/reveal.js/issues/1440
(rum/defc block-container
[config block level]
(let [deep-level? (>= level 2)
children (:block/children block)
(let [children (:block/children block)
has-children? (seq children)
children (when (and has-children? (not deep-level?))
children (when has-children?
(map (fn [block]
(block-container config block (inc level))) children))
block-el (block/block-container config (dissoc block :block/children))
@ -55,9 +56,7 @@
(if has-children?
[:section dom-attrs
[:section.relative
block-el
(when deep-level?
[:span.opacity-30.text-xl "Hidden children"])]
block-el]
children]
[:section dom-attrs block-el])))
@ -93,11 +92,21 @@
page (db/entity [:block/name page-name])
journal? (:journal? page)
repo (state/get-current-repo)
blocks (-> (db/get-paginated-blocks repo (:db/id page))
blocks (-> (db/get-paginated-blocks repo (:db/id page)
{:limit 1000})
(outliner-tree/blocks->vec-tree page-name))
blocks (if journal?
(rest blocks)
blocks)
blocks (map (fn [block]
(update block :block/children
(fn [children]
(->>
(mapcat
(fn [x]
(tree-seq map? :block/children x))
children)
(map #(dissoc % :block/children)))))) blocks)
config {:id "slide-reveal-js"
:slide? true
:sidebar? true

View File

@ -3089,9 +3089,15 @@
(when (state/editing?)
(keydown-backspace-handler false e)))
(defn- slide-focused?
[]
(some-> (first (dom/by-class "reveal"))
(dom/has-class? "focused")))
(defn shortcut-up-down [direction]
(fn [e]
(when-not (auto-complete?)
(when (and (not (auto-complete?))
(not (slide-focused?)))
(util/stop e)
(cond
(state/editing?)

View File

@ -723,7 +723,7 @@
#?(:cljs
(defn get-blocks-noncollapse []
(->> (d/by-class "ls-block")
(->> (d/sel "div:not(.reveal) .ls-block")
(filter (fn [b] (some? (gobj/get b "offsetParent")))))))
#?(:cljs