Browse Source

Merge branch 'master' into gesture-support-on-block

llcc 3 years ago
parent
commit
f52786a1c8

+ 6 - 0
resources/css/animation.css

@@ -44,6 +44,12 @@
   animation-duration: 1s;
 }
 
+.faster-fade-in {
+  -webkit-animation-duration: 0.3s;
+  -moz-animation-duration: 0.3s;
+  animation-duration: 0.3s;
+}
+
 /* page transition */
 .fade-enter {
   opacity: 0;

+ 7 - 5
src/main/frontend/components/block.cljs

@@ -509,6 +509,7 @@
 
     (if (or (not manual?) open?)
       (ui/tippy {:ref             *tippy-ref
+                 :in-editor?      true
                  :html            html-template
                  :interactive     true
                  :delay           [1000, 100]
@@ -761,6 +762,7 @@
                                           (db/get-block-and-children repo block-id)
                                           (assoc config :id (str id) :preview? true))]])
                         :interactive true
+                        :in-editor?  true
                         :delay       [1000, 100]} inner)
              inner)])
         [:span.warning.mr-1 {:title "Block ref invalid"}
@@ -1056,7 +1058,8 @@
      (when-not (string/blank? query)
        (custom-query (assoc config :dsl-query? true)
                      {:title (ui/tippy {:html commands/query-doc
-                                        :interactive true}
+                                        :interactive true
+                                        :in-editor?  true}
                                        [:span.font-medium.px-2.py-1.query-title.text-sm.rounded-md.shadow-xs
                                         (str "Query: " query)])
                       :query query})))])
@@ -1615,8 +1618,6 @@
                            [(str class " checked") true])]
     (when class
       (ui/checkbox {:class class
-                    :style {:margin-top -2
-                            :margin-right 5}
                     :checked checked?
                     :on-mouse-down (fn [e]
                                      (util/stop-propagation e))
@@ -1717,7 +1718,7 @@
         html-export? (:html-export? config)
         checkbox (when (and (not pre-block?)
                             (not html-export?))
-                   (block-checkbox t (str "mr-1 cursor")))
+                   (block-checkbox t "mr-1 cursor"))
         marker-switch (when (and (not pre-block?)
                                  (not html-export?))
                         (marker-switch t))
@@ -1734,7 +1735,7 @@
         elem (if heading-level
                (keyword (str "h" heading-level
                              (when block-ref? ".inline")))
-               :span.inline)]
+               :span.inline-flex.items-center)]
     (->elem
      elem
      (merge
@@ -1981,6 +1982,7 @@
                                          (for [clock (take 10 (reverse clocks))]
                                            [:li clock])]])))
                     :interactive true
+                    :in-editor?  true
                     :delay       [1000, 100]}
                    [:div.text-sm.time-spent.ml-1 {:style {:padding-top 3}}
                     [:a.fade-link

+ 0 - 1
src/main/frontend/components/header.css

@@ -9,7 +9,6 @@
   justify-content: space-between;
   flex: 0 0 auto;
   position: sticky;
-  position: -webkit-sticky;
   top: 0;
   left: 0;
   right: 0;

+ 3 - 1
src/main/frontend/components/sidebar.cljs

@@ -24,6 +24,7 @@
             [frontend.handler.page :as page-handler]
             [frontend.handler.route :as route-handler]
             [frontend.handler.user :as user-handler]
+            [frontend.handler.common :as common-handler]
             [frontend.mixins :as mixins]
             [frontend.mobile.action-bar :as action-bar]
             [frontend.mobile.footer :as footer]
@@ -279,7 +280,8 @@
                    {:drop (fn [_e files]
                             (when-let [id (state/get-edit-input-id)]
                               (let [format (:block/format (state/get-edit-block))]
-                                (editor-handler/upload-asset id files format editor-handler/*asset-uploading? true))))}))
+                                (editor-handler/upload-asset id files format editor-handler/*asset-uploading? true))))})
+                  (common-handler/listen-to-scroll! element))
                 state)}
   [{:keys [route-match global-graph-pages? route-name indexeddb-support? db-restoring? main-content show-action-bar?]}]
   (let [left-sidebar-open? (state/sub :ui/left-sidebar-open?)

+ 3 - 0
src/main/frontend/components/sidebar.css

@@ -30,6 +30,9 @@
 }
 
 #main-container {
+    /* Hack: (overflow-y) to fix sticky header not working */
+    /* To reproduce: quick creating blocks */
+    overflow-y: hidden;
     position: relative;
     height: 100%;
     transition: padding-left .3s;

+ 0 - 1
src/main/frontend/components/theme.css

@@ -48,7 +48,6 @@ html {
   border-color: var(--ls-page-checkbox-border-color, #6093a0);
   border: none;
   position: relative;
-  top: -1px;
 }
 
 .form-checkbox:hover {

+ 7 - 4
src/main/frontend/db/query_react.cljs

@@ -12,6 +12,7 @@
             [frontend.state :as state]
             [logseq.graph-parser.text :as text]
             [frontend.util :as util]
+            [frontend.date :as date]
             [lambdaisland.glogi :as log]))
 
 (defn resolve-input
@@ -28,17 +29,19 @@
     (= :tomorrow input)
     (date->int (t/plus (t/today) (t/days 1)))
     (= :current-page input)
-    ;; This sometimes runs when there isn't a current page e.g. :home route
-    (some-> (state/get-current-page) string/lower-case)
+    (some-> (or (state/get-current-page)
+                (:page (state/get-default-home))
+                (date/today)) string/lower-case)
+
     (and (keyword? input)
          (util/safe-re-find #"^\d+d(-before)?$" (name input)))
     (let [input (name input)
-          days (parse-long (subs input 0 (dec (count input))))]
+          days (parse-long (re-find #"^\d+" input))]
       (date->int (t/minus (t/today) (t/days days))))
     (and (keyword? input)
          (util/safe-re-find #"^\d+d(-after)?$" (name input)))
     (let [input (name input)
-          days (parse-long (subs input 0 (dec (count input))))]
+          days (parse-long (re-find #"^\d+" input))]
       (date->int (t/plus (t/today) (t/days days))))
 
     (and (string? input) (text/page-ref? input))

+ 1 - 0
src/main/frontend/extensions/code.cljs

@@ -168,6 +168,7 @@
               new-content (if (string/blank? value)
                             (str prefix surfix)
                             (str prefix value "\n" surfix))]
+          (state/set-edit-content! (state/get-edit-input-id) new-content)
           (editor-handler/save-block-if-changed! block new-content))
 
         (:file-path config)

+ 12 - 0
src/main/frontend/handler/common.cljs

@@ -139,3 +139,15 @@
       (log/error :parse/config-failed e)
       (state/pub-event! [:backup/broken-config (state/get-current-repo) content])
       (rewrite/parse-string config/config-default-content))))
+
+(defn listen-to-scroll!
+  [element]
+  (let [*scroll-timer (atom nil)]
+    (.addEventListener element "scroll"
+                       (fn []
+                         (when @*scroll-timer
+                           (js/clearTimeout @*scroll-timer))
+                         (state/set-state! :ui/scrolling? true)
+                         (reset! *scroll-timer (js/setTimeout
+                                                (fn [] (state/set-state! :ui/scrolling? false)) 500)))
+                       false)))

+ 1 - 0
src/main/frontend/state.cljs

@@ -89,6 +89,7 @@
      :ui/shortcut-tooltip?                  (if (false? (storage/get :ui/shortcut-tooltip?))
                                               false
                                               true)
+     :ui/scrolling?                         false
      :document/mode?                        document-mode?
 
      :config                                {}

+ 35 - 22
src/main/frontend/ui.cljs

@@ -296,7 +296,7 @@
       (when-let [url (:url custom-theme)]
         (js/LSPluginCore.selectTheme (bean/->js custom-theme)
                                      (bean/->js {:effect false :emit false}))
-        (state/set-state! :plugin/selected-theme (:url url))))))
+        (state/set-state! :plugin/selected-theme url)))))
 
 (defn setup-system-theme-effect!
   []
@@ -787,20 +787,31 @@
           :checked selected}]
         label])]))
 
-(rum/defcs tippy < rum/static
+(rum/defcs tippy < rum/reactive
   (rum/local false ::mounted?)
-  [state {:keys [fixed-position? open?] :as opts} child]
+  [state {:keys [fixed-position? open? in-editor?] :as opts} child]
   (let [*mounted? (::mounted? state)
-        mounted? @*mounted?
-        manual (not= open? nil)]
+        manual (not= open? nil)
+        edit-id (ffirst (state/sub :editor/editing?))
+        editing-node (when edit-id (gdom/getElement edit-id))
+        editing? (some? editing-node)
+        scrolling? (state/sub :ui/scrolling?)
+        open? (if manual open? @*mounted?)
+        disabled? (boolean
+                   (or
+                    (and in-editor?
+                         ;; editing in non-preview containers or scrolling
+                         (not (util/rec-get-tippy-container editing-node))
+                         (or editing? scrolling?))
+                    (not (state/enable-tooltip?))))]
     (Tippy (->
             (merge {:arrow true
                     :sticky true
                     :delay 600
                     :theme "customized"
-                    :disabled (not (state/enable-tooltip?))
+                    :disabled disabled?
                     :unmountHTMLWhenHide true
-                    :open (if manual open? @*mounted?)
+                    :open (if disabled? false open?)
                     :trigger (if manual "manual" "mouseenter focus")
                     ;; See https://github.com/tvkhoa/react-tippy/issues/13
                     :popperOptions {:modifiers {:flip {:enabled (not fixed-position?)}
@@ -809,18 +820,19 @@
                     :onShow #(reset! *mounted? true)
                     :onHide #(reset! *mounted? false)}
                    opts)
-            (assoc :html (if (or open? mounted?)
-                           (try
-                             (when-let [html (:html opts)]
-                               (if (fn? html)
-                                 (html)
-                                 [:div.px-2.py-1
-                                  html]))
-                             (catch js/Error e
-                               (log/error :exception e)
-                               [:div]))
-                           [:div {:key "tippy"} ""])))
-            (rum/fragment {:key "tippy-children"} child))))
+            (assoc :html (or
+                          (when open?
+                            (try
+                              (when-let [html (:html opts)]
+                                (if (fn? html)
+                                  (html)
+                                  [:div.px-2.py-1
+                                   html]))
+                              (catch js/Error e
+                                (log/error :exception e)
+                                [:div])))
+                          [:div {:key "tippy"} ""])))
+           (rum/fragment {:key "tippy-children"} child))))
 
 (defn slider
   [default-value {:keys [min max on-change]}]
@@ -868,7 +880,7 @@
 (rum/defc progress-bar
   [width]
   {:pre (integer? width)}
-  [:div.w-full.bg-indigo-200.rounded-full.h-2.5
+  [:div.w-full.bg-indigo-200.rounded-full.h-2.5.animate-pulse
    [:div.bg-indigo-600.h-2.5.rounded-full {:style {:width (str width "%")}
                                            :transition "width 1s"}]])
 
@@ -892,8 +904,9 @@
    {:ref #(reset! (::ref state) %)
     :style {:min-height 24}}
    (if visible?
-     (when (fn? content-fn) (content-fn))
-     [:div.shadow.rounded-md.p-4.w-full.mx-auto.mb-5 {:style {:height 88}}
+     (when (fn? content-fn)
+       [:div.fade-in.faster-fade-in (content-fn)])
+     [:div.shadow.rounded-md.p-4.w-full.mx-auto.mb-5.fade-in {:style {:height 88}}
       [:div.animate-pulse.flex.space-x-4
        [:div.flex-1.space-y-3.py-1
         [:div.h-2.bg-base-4.rounded]

+ 8 - 0
src/main/frontend/util.cljc

@@ -669,6 +669,14 @@
            :up
            :down)))))
 
+#?(:cljs
+   (defn rec-get-tippy-container
+     [node]
+     (if (and node (d/has-class? node "tippy-tooltip-content"))
+       node
+       (and node
+            (rec-get-tippy-container (gobj/get node "parentNode"))))))
+
 #?(:cljs
    (defn rec-get-blocks-container
      [node]

+ 14 - 0
templates/dummy-notes-it.md

@@ -0,0 +1,14 @@
+---
+title: Come prendere appunti fittizi?
+---
+
+- Ciao, io sono un blocco!
+:PROPERTIES:
+:id: 5f713e91-8a3c-4b04-a33a-c39482428e2d
+:END:
+    - Io sono un blocco figlio!
+    - Io sono un altro blocco figlio!
+- Hey, io sono un altro blocco!
+:PROPERTIES:
+:id: 5f713ea8-8cba-403d-ac00-9964b1ec7190
+:END:

+ 27 - 0
templates/tutorial-it.md

@@ -0,0 +1,27 @@
+## Ciao, benvenuto su Logseq
+- Logseq è una piattaforma con la _privacy come priorità_, [open-source](https://github.com/logseq/logseq) per la gestione della _conoscenza_ e la collaborazione.
+- Questo è un tutorial di 3 minuti su come utilizzare Logseq. Iniziamo!
+- Ecco alcuni suggerimenti che potrebbero essere utili.
+#+BEGIN_TIP
+Fare clic per modificare qualsiasi blocco.
+Digita "Invio" per creare un nuovo blocco.
+Digita `Maiusc+Invio` per creare una nuova riga.
+Digita `/` per mostrare tutti i comandi.
+#+END_TIP
+- 1. Creiamo una pagina chiamata [[Come prendere appunti fittizi?]]. Puoi fare clic su di esso per andare a quella pagina, oppure puoi "Maiusc + clic" per aprirlo nella barra laterale destra! Ora dovresti vedere sia _Riferimenti collegati_ che _Riferimenti non collegati_.
+- 2. Facciamo riferimento ad alcuni blocchi su [[Come prendere appunti fittizi?]], puoi fare `Maiusc+Clic` su qualsiasi riferimento di blocco per aprirlo nella barra laterale destra. Prova a fare
+alcune modifiche sulla barra laterale destra, verranno modificati anche quei blocchi di riferimento!
+    - ((5f713e91-8a3c-4b04-a33a-c39482428e2d)) : This is a block reference.
+    - ((5f713ea8-8cba-403d-ac00-9964b1ec7190)) : This is another block reference.
+- 3. Supportate i tag?
+    - Naturalmente, questo è un tag #falso.
+- 4. Supportate le azioni come todo/doing/done e le priorità?
+    - Si, digita `/` e scegli la tua parola chiave todo o la tua priorità preferita (A/B/C).
+    - NOW [#A] Un tutorial fittizio su "Come prendere appunti fittizi?"
+    - LATER [#A] Guarda questo fantastico video di [:a {:href "https://twitter.com/shuomi3" :target "_blank"} "@shuomi3"] su come usare Logseq per prendere appunti e organizzare la tua vita!
+    {{youtube <https://www.youtube.com/watch?v=BhHfF0P9A80&ab_channel=ShuOmi>}}
+
+    - DONE Crea una pagina
+    - CANCELED [#C] Scrivi una pagina con più di 1000 blocchi
+- Questo è tutto! Puoi creare più blocchi o aprire una directory locale per importare alcune note adesso!
+- Puoi anche scaricare la nostra app desktop su <https://github.com/logseq/logseq/releases>