瀏覽代碼

Add shortcut for seeing whiteboards and minor fixes

See #6812 for the catch and we should be using our util fns
for ref chars
Gabriel Horner 3 年之前
父節點
當前提交
639001971d

+ 4 - 2
deps/graph-parser/src/logseq/graph_parser/extract.cljc

@@ -10,6 +10,8 @@
             [datascript.core :as d]
             [logseq.graph-parser.text :as text]
             [logseq.graph-parser.util :as gp-util]
+            [logseq.graph-parser.util.page-ref :as page-ref]
+            [logseq.graph-parser.util.block-ref :as block-ref]
             [logseq.graph-parser.mldoc :as gp-mldoc]
             [logseq.graph-parser.block :as gp-block]
             [logseq.graph-parser.property :as gp-property]
@@ -216,8 +218,8 @@
   {:block/content (case (:type shape)
                     "text" (:text shape)
                     "logseq-portal" (if (= (:blockType shape) "P")
-                                      (str "[[" (:pageId shape) "]]")
-                                      (str "((" (:pageId shape) "))"))
+                                      (page-ref/->page-ref (:pageId shape))
+                                      (block-ref/->block-ref (:pageId shape)))
                     "line" (str "whiteboard arrow" (when-let [label (:label shape)] (str ": " label)))
                     (str "whiteboard " (:type shape)))})
 

+ 3 - 3
src/main/frontend/handler/paste.cljs

@@ -62,7 +62,7 @@
 (defn- try-parse-as-json
   [text]
   (try (js/JSON.parse text)
-       (catch js/Object _ #js{})))
+       (catch :default _ #js{})))
 
 (defn- paste-copied-blocks-or-text
   [text e html]
@@ -71,8 +71,8 @@
         input (state/get-input)
         text (string/replace text "\r\n" "\n") ;; Fix for Windows platform
         whiteboard-shape? (= "logseq/whiteboard-shapes" (gobj/get (try-parse-as-json text) "type"))
-        text (if whiteboard-shape? 
-               (str "((" (gobj/getValueByKeys (try-parse-as-json text) "shapes" 0 "id") "))")
+        text (if whiteboard-shape?
+               (block-ref/->block-ref (gobj/getValueByKeys (try-parse-as-json text) "shapes" 0 "id"))
                text)
         internal-paste? (and
                          (seq (:copy/blocks copied-blocks))

+ 5 - 0
src/main/frontend/modules/shortcut/config.cljs

@@ -333,6 +333,9 @@
    :go/all-graphs                  {:binding "g shift+g"
                                     :fn      route-handler/redirect-to-all-graphs}
 
+   :go/whiteboards                  {:binding "g w"
+                                     :fn      route-handler/redirect-to-whiteboard-dashboard!}
+
    :go/keyboard-shortcuts          {:binding "g s"
                                     :fn      #(route-handler/redirect! {:to :shortcut-setting})}
 
@@ -542,6 +545,7 @@
                           :go/flashcards
                           :go/graph-view
                           :go/all-graphs
+                          :go/whiteboards
                           :go/keyboard-shortcuts
                           :go/tomorrow
                           :go/next-journal
@@ -609,6 +613,7 @@
     :go/all-pages
     :go/graph-view
     :go/all-graphs
+    :go/whiteboards
     :go/flashcards
     :go/tomorrow
     :go/next-journal

+ 1 - 0
src/main/frontend/modules/shortcut/dicts.cljc

@@ -98,6 +98,7 @@
    :command/run                    "Run git command"
    :go/home                        "Go to home"
    :go/all-graphs                  "Go to all graphs"
+   :go/whiteboards                 "Go to whiteboards"
    :go/all-pages                   "Go to all pages"
    :go/graph-view                  "Go to graph view"
    :go/keyboard-shortcuts          "Go to keyboard shortcuts"