Bläddra i källkod

Merge branch 'master' into dev/malli-schema&kondo-config

Andelf 2 år sedan
förälder
incheckning
c19787f099

+ 2 - 2
android/app/build.gradle

@@ -6,8 +6,8 @@ android {
         applicationId "com.logseq.app"
         minSdkVersion rootProject.ext.minSdkVersion
         targetSdkVersion rootProject.ext.targetSdkVersion
-        versionCode 49
-        versionName "0.8.15"
+        versionCode 50
+        versionName "0.8.16"
         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
         aaptOptions {
              // Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.

+ 4 - 4
ios/App/App.xcodeproj/project.pbxproj

@@ -515,7 +515,7 @@
 				INFOPLIST_FILE = App/Info.plist;
 				IPHONEOS_DEPLOYMENT_TARGET = 13.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
-				MARKETING_VERSION = 0.8.15;
+				MARKETING_VERSION = 0.8.16;
 				OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\"";
 				PRODUCT_BUNDLE_IDENTIFIER = com.logseq.logseq;
 				PRODUCT_NAME = "$(TARGET_NAME)";
@@ -542,7 +542,7 @@
 				INFOPLIST_FILE = App/Info.plist;
 				IPHONEOS_DEPLOYMENT_TARGET = 13.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
-				MARKETING_VERSION = 0.8.15;
+				MARKETING_VERSION = 0.8.16;
 				PRODUCT_BUNDLE_IDENTIFIER = com.logseq.logseq;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				SWIFT_ACTIVE_COMPILATION_CONDITIONS = "";
@@ -567,7 +567,7 @@
 				INFOPLIST_KEY_NSHumanReadableCopyright = "";
 				IPHONEOS_DEPLOYMENT_TARGET = 13.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
-				MARKETING_VERSION = 0.8.15;
+				MARKETING_VERSION = 0.8.16;
 				MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
 				MTL_FAST_MATH = YES;
 				PRODUCT_BUNDLE_IDENTIFIER = com.logseq.logseq.ShareViewController;
@@ -594,7 +594,7 @@
 				INFOPLIST_KEY_NSHumanReadableCopyright = "";
 				IPHONEOS_DEPLOYMENT_TARGET = 13.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
-				MARKETING_VERSION = 0.8.15;
+				MARKETING_VERSION = 0.8.16;
 				MTL_FAST_MATH = YES;
 				PRODUCT_BUNDLE_IDENTIFIER = com.logseq.logseq.ShareViewController;
 				PRODUCT_NAME = "$(TARGET_NAME)";

+ 1 - 1
resources/package.json

@@ -1,7 +1,7 @@
 {
   "name": "Logseq",
   "productName": "Logseq",
-  "version": "0.8.15",
+  "version": "0.8.16",
   "main": "electron.js",
   "author": "Logseq",
   "license": "AGPL-3.0",

+ 118 - 0
src/main/frontend/components/bug_report.cljs

@@ -0,0 +1,118 @@
+(ns frontend.components.bug-report
+  (:require [rum.core :as rum]
+            [frontend.ui :as ui]
+            [frontend.components.header :as header]
+            [frontend.util :as util]
+            [reitit.frontend.easy :as rfe]
+            [clojure.string :as string]
+            [frontend.handler.notification :as notification]))
+
+(defn parse-clipboard-data-transfer
+  "parse dataTransfer
+
+   input: dataTransfer
+
+   output: {:types {:type :data} :items {:kind :type} :files {:name :size :type}}"
+  [data]
+  (let [items (.-items data)
+        types (.-types data)
+        files (.-files data)]
+    (conj
+     {:items (->> items
+                  (map (fn [item] {:kind (.-kind item) :type (.-type item)}))
+                  (conj))}
+     {:types (->> types
+                  (map (fn [type] {:type type :data (.getData data type)}))
+                  (conj))}
+     {:files (->> files
+                  (map (fn [file] {:name (.-name file) :type (.-type file) :size (.-size file)}))
+                  (conj))})))
+
+(rum/defc clipboard-data-inspector
+  "bug report tool for clipboard"
+  []
+  (let [[result set-result!] (rum/use-state {})
+        [step set-step!] (rum/use-state 0)
+        paste-handler! (fn [e]
+                         (let [clipboard-data (.-clipboardData e)
+                               result (parse-clipboard-data-transfer clipboard-data)
+                               result (into {} result)]
+                           (set-result! result)
+                           (set-step! 1)))
+
+        copy-result-to-clipboard! (fn [result]
+                                    (util/copy-to-clipboard! result)
+                                    (notification/show! "Copied to clipboard!"))
+
+        reset-step! (fn []
+                      (set-step! 0)
+                      (set-result! {}))]
+
+    (rum/use-effect!
+     (fn []
+       (cond (= step 0) (js/addEventListener "paste" paste-handler!))
+       (fn [] (cond (= step 0) (js/removeEventListener "paste" paste-handler!))))
+     [step]) ;; when step === 0
+
+    [:div.flex.flex-col
+     (when (= step 0)
+       (list [:div.mx-auto "Press Ctrl+V / ⌘+V to inspect your clipboard data"]
+             [:div.mx-auto "or click here to paste if you are using the mobile version"]
+             ;; for mobile
+             [:input.form-input.is-large.transition.duration-150.ease-in-out {:type "text" :placeholder "Long press here to paste if you are on mobile"}]
+             [:div.flex.justify-between.items-center.mt-2
+              [:div "Something wrong? No problem, click to go back to the previous step."]
+              (ui/button "Go back" :on-click #(util/open-url (rfe/href :bug-report)))]))
+
+     (when (= step 1)
+       (list
+        [:div "Here is the data read from clipboard."]
+        [:div.flex.justify-between.items-center.mt-2
+         [:div "If this is okay to share, click the copy button."]
+         (ui/button "Copy the result" :on-click #(copy-result-to-clipboard! (js/JSON.stringify (clj->js result) nil 2)))]
+        [:div.flex.justify-between.items-center.mt-2
+         [:div "Now you can report the result pasted to your clipboard. Please paste the result in the 'Additional Context' section and state where you copied the original content from. Thanks!"]
+         (ui/button "Create an issue" :href header/bug-report-url)]
+        [:div.flex.justify-between.items-center.mt-2
+         [:div "Something wrong? No problem, click to go back to the previous step."]
+         (ui/button "Go back" :on-click reset-step!)]
+
+        [:pre.whitespace-pre-wrap [:code (js/JSON.stringify (clj->js result) nil 2)]]))]))
+
+(rum/defc bug-report-tool-route
+  [route-match]
+  (let [name (get-in route-match [:parameters :path :tool])]
+    [:div.flex.flex-col ;; container
+     [:h1.text-2xl.mx-auto.mb-4 (ui/icon "clipboard") " " (-> name (string/replace #"-" " ") (string/capitalize))]
+     (cond ;; TODO any fallback?
+       (= name "clipboard-data-inspector")
+       (clipboard-data-inspector))]))
+
+(rum/defc report-item-button
+  [title description icon-name {:keys [on-click]}]
+   [:a.cp__bug-report-item-button.flex.items-center.px-4.py-2.my-2.rounded-lg {:on-click on-click}
+    [(ui/icon icon-name)
+     [:div.flex.flex-col.ml-2
+      [:div title]
+      [:div.opacity-60 description]]]])
+
+(rum/defc bug-report
+  []
+  [:div.flex.flex-col
+   [:div.flex.flex-col.items-center
+    [:div.flex.items-center.mb-2
+     (ui/icon "bug")
+     [:h1.text-3xl.ml-2 "Bug report"]]
+    [:div.opacity-60 "Can you help us out by submitting a bug report? We'll get it sorted out as soon as we can."]]
+   [:div.cp__bug-report-reporter.rounded-lg.p-8.mt-8
+    [:h1.text-2xl "Is the bug you encountered related to these features?"]
+    [:div.opacity-60 "You can use these handy tools to give us additional information."]
+    (report-item-button "Clipboard helper"
+                 "Inspect and collect clipboard data"
+                 "clipboard"
+                 {:on-click #(util/open-url (rfe/href :bug-report-tools {:tool "clipboard-data-inspector"}))})
+    [:div.py-2] ;; divider
+    [:div.flex.flex-col
+     [:h1.text-2xl "Or..."]
+     [:div.opacity-60 "If there are no tools available for you to gather additional information, please report the bug directly."]
+     (report-item-button "Submit a bug report" "Help Make Logseq Better!" "message-report" {:on-click #(util/open-url header/bug-report-url)})]]])

+ 7 - 0
src/main/frontend/components/bug_report.css

@@ -0,0 +1,7 @@
+.cp__bug-report-reporter {
+  background-color: var(--ls-tertiary-background-color);
+}
+
+.cp__bug-report-item-button {
+  background-color: var(--ls-quaternary-background-color);
+}

+ 2 - 3
src/main/frontend/components/header.cljs

@@ -70,6 +70,7 @@
     (str "https://github.com/logseq/logseq/issues/new?"
          "title=&"
          "template=bug_report.yaml&"
+         "labels=from:in-app&"
          "platform="
          (js/encodeURIComponent platform))))
 
@@ -120,9 +121,7 @@
 
        {:title [:div.flex-row.flex.justify-between.items-center
                 [:span (t :help/bug)]]
-        :options {:href bug-report-url
-                  :title "Fire a bug report on Github"
-                  :target "_blank"}
+        :options {:href (rfe/href :bug-report)}
         :icon (ui/icon "bug")}
 
        (when (and (state/sub :auth/id-token) (user-handler/logged-in?))

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

@@ -170,7 +170,9 @@
                               [:string (when-let [updated-at (:block/updated-at item)]
                                          (date/int->local-time-2 updated-at))]
 
-                              [:string (get-in item [:block/properties-text-values column])])]
+                              [:string (or (get-in item [:block/properties-text-values column])
+                                           ;; Fallback to property relationships for page blocks
+                                           (get-in item [:block/properties column]))])]
                   [:td.whitespace-nowrap {:on-mouse-down (fn [] (reset! select? false))
                                           :on-mouse-move (fn [] (reset! select? true))
                                           :on-mouse-up (fn []

+ 13 - 14
src/main/frontend/extensions/pdf/assets.cljs

@@ -29,21 +29,20 @@
 
 (defn inflate-asset
   [original-path]
-  (let [filename (util/node-path.basename original-path)
+  (let [filename  (util/node-path.basename original-path)
         web-link? (string/starts-with? original-path "http")
-        ext-name (util/get-file-ext filename)
-        url (assets-handler/normalize-asset-resource-url original-path)]
-    (when-let [key
-               (if web-link?
-                 (str (hash url))
-                 (and
-                   (= ext-name "pdf")
-                   (subs filename 0 (- (count filename) 4))))]
-      {:key      key
-       :identity (subs key (- (count key) 15))
-       :filename filename
-       :url      url
-       :hls-file (str "assets/" key ".edn")
+        ext-name  (util/get-file-ext filename)
+        url       (assets-handler/normalize-asset-resource-url original-path)
+        filekey   (util/safe-sanitize-file-name (subs filename 0 (- (count filename) (inc (count ext-name)))))]
+    (when-let [key (and (not (string/blank? filekey))
+                        (if web-link?
+                          (str filekey "__" (hash url)) filekey))]
+
+      {:key           key
+       :identity      (subs key (- (count key) 15))
+       :filename      filename
+       :url           url
+       :hls-file      (str "assets/" key ".edn")
        :original-path original-path})))
 
 (defn resolve-area-image-file

+ 1 - 0
src/main/frontend/extensions/pdf/utils.cljs

@@ -183,6 +183,7 @@
         (-> filename
             (subs 0 (if local-asset? (- len 15) len))
             (string/replace #"^hls__" "")
+            (string/replace #"__[-\d]+$" "")
             (string/replace "_" " ")
             (string/trimr))
         filename))))

+ 1 - 1
src/main/frontend/handler/user.cljs

@@ -146,7 +146,7 @@
         ;; refresh remote graph list by pub login event
         (when (user-uuid) (state/pub-event! [:user/fetch-info-and-graphs]))))))
 
-(defn login-callback [code]
+(defn ^:export login-callback [code]
   (state/set-state! [:ui/loading? :login] true)
   (go
     (let [resp (<! (http/get (str "https://" config/API-DOMAIN "/auth_callback?code=" code)

+ 11 - 2
src/main/frontend/routes.cljs

@@ -10,8 +10,9 @@
             [frontend.components.search :as search]
             [frontend.components.settings :as settings]
             [frontend.components.shortcut :as shortcut]
-            [frontend.components.whiteboard :as whiteboard]
-            [frontend.extensions.zotero :as zotero]))
+            [frontend.components.whiteboard :as whiteboard] 
+            [frontend.extensions.zotero :as zotero]
+            [frontend.components.bug-report :as bug-report]))
 
 ;; http://localhost:3000/#?anchor=fn.1
 (def routes
@@ -78,6 +79,14 @@
    ["/import"
     {:name :import
      :view setups/importer}]
+   
+   ["/bug-report"
+    {:name :bug-report
+     :view bug-report/bug-report}]
+   
+    ["/bug-report-tool/:tool"
+     {:name :bug-report-tools
+      :view bug-report/bug-report-tool-route}]
 
    ["/all-journals"
     {:name :all-journals

+ 1 - 1
src/main/frontend/version.cljs

@@ -1,3 +1,3 @@
 (ns ^:no-doc frontend.version)
 
-(defonce version "0.8.15")
+(defonce version "0.8.16")

+ 2 - 1
src/test/frontend/extensions/pdf/assets_test.cljs

@@ -7,7 +7,8 @@
     (are [x y] (= y (pdf-utils/fix-local-asset-pagename x))
       "2015_Book_Intertwingled_1659920114630_0" "2015 Book Intertwingled"
       "hls__2015_Book_Intertwingled_1659920114630_0" "2015 Book Intertwingled"
-      "hls/2015_Book_Intertwingled_1659920114630_0" "hls/2015 Book Intertwingled"))
+      "hls/2015_Book_Intertwingled_1659920114630_0" "hls/2015 Book Intertwingled"
+      "hls__sicp__-1234567" "sicp"))
   (testing "non matched filenames"
     (are [x y] (= y (pdf-utils/fix-local-asset-pagename x))
       "foo" "foo"