浏览代码

Merge branch 'master' into disable-webview-resize

llcc 3 年之前
父节点
当前提交
b13f0e336e
共有 35 个文件被更改,包括 132 次插入205 次删除
  1. 7 1
      .clj-kondo/config.edn
  2. 1 2
      bb.edn
  3. 5 5
      deps.edn
  4. 1 1
      package.json
  5. 4 10
      src/main/frontend/components/block.cljs
  6. 2 2
      src/main/frontend/components/content.cljs
  7. 4 4
      src/main/frontend/components/page.cljs
  8. 1 1
      src/main/frontend/components/plugins.cljs
  9. 3 5
      src/main/frontend/components/reference.cljs
  10. 2 3
      src/main/frontend/db/debug.cljs
  11. 4 5
      src/main/frontend/db/model.cljs
  12. 2 2
      src/main/frontend/db/query_dsl.cljs
  13. 2 2
      src/main/frontend/db/query_react.cljs
  14. 1 2
      src/main/frontend/db/utils.cljs
  15. 3 4
      src/main/frontend/extensions/slide.cljs
  16. 2 2
      src/main/frontend/extensions/video/youtube.cljs
  17. 2 3
      src/main/frontend/external/roam.cljs
  18. 13 24
      src/main/frontend/handler/editor.cljs
  19. 1 2
      src/main/frontend/handler/route.cljs
  20. 5 5
      src/main/frontend/modules/outliner/datascript.cljc
  21. 2 3
      src/main/frontend/modules/outliner/tree.cljs
  22. 4 3
      src/main/frontend/modules/shortcut/config.cljs
  23. 2 3
      src/main/frontend/modules/shortcut/core.cljs
  24. 14 11
      src/main/frontend/modules/shortcut/dicts.cljc
  25. 1 1
      src/main/frontend/state.cljs
  26. 6 4
      src/main/frontend/ui.cljs
  27. 8 26
      src/main/frontend/util.cljc
  28. 2 3
      src/main/frontend/util/list.cljs
  29. 1 2
      src/main/frontend/util/property.cljs
  30. 11 13
      src/main/logseq/api.cljs
  31. 10 14
      src/main/logseq/graph_parser/block.cljc
  32. 1 1
      src/main/logseq/graph_parser/date_time_util.cljs
  33. 1 1
      src/main/logseq/graph_parser/text.cljs
  34. 0 31
      src/main/logseq/graph_parser/util.cljs
  35. 4 4
      yarn.lock

+ 7 - 1
.clj-kondo/config.edn

@@ -2,7 +2,13 @@
  {:unresolved-symbol {:exclude [goog.DEBUG
  {:unresolved-symbol {:exclude [goog.DEBUG
                                 goog.string.unescapeEntities
                                 goog.string.unescapeEntities
                                 ;; TODO:lint: Fix when fixing all type hints
                                 ;; TODO:lint: Fix when fixing all type hints
-                                object]}
+                                object
+                                ;; TODO: Remove parse-* and update-* when https://github.com/clj-kondo/clj-kondo/issues/1694 is done
+                                parse-long
+                                parse-double
+                                parse-uuid
+                                update-keys
+                                update-vals]}
   ;; TODO:lint: Remove node-path excludes once we have a cleaner api
   ;; TODO:lint: Remove node-path excludes once we have a cleaner api
   :unresolved-var {:exclude [frontend.util/node-path.basename
   :unresolved-var {:exclude [frontend.util/node-path.basename
                              frontend.util/node-path.dirname
                              frontend.util/node-path.dirname

+ 1 - 2
bb.edn

@@ -2,8 +2,7 @@
  :deps
  :deps
  {org.babashka/spec.alpha
  {org.babashka/spec.alpha
   {:git/url "https://github.com/babashka/spec.alpha"
   {:git/url "https://github.com/babashka/spec.alpha"
-   :sha "1a841c4cc1d4f6dab7505a98ed2d532dd9d56b78"}
-  medley/medley {:mvn/version "1.3.0"}}
+   :sha "1a841c4cc1d4f6dab7505a98ed2d532dd9d56b78"}}
  :pods
  :pods
  {clj-kondo/clj-kondo {:version "2022.02.09"}}
  {clj-kondo/clj-kondo {:version "2022.02.09"}}
  :tasks
  :tasks

+ 5 - 5
deps.edn

@@ -7,7 +7,7 @@
   borkdude/rewrite-edn                  {:git/url "https://github.com/borkdude/rewrite-edn"
   borkdude/rewrite-edn                  {:git/url "https://github.com/borkdude/rewrite-edn"
                                          :sha     "edd87dc7f045f28d7afcbfc44bc0f0a2683dde62"}
                                          :sha     "edd87dc7f045f28d7afcbfc44bc0f0a2683dde62"}
   funcool/promesa                       {:mvn/version "4.0.2"}
   funcool/promesa                       {:mvn/version "4.0.2"}
-  medley/medley                         {:mvn/version "1.2.0"}
+  medley/medley                         {:mvn/version "1.4.0"}
   metosin/reitit-frontend               {:mvn/version "0.3.10"}
   metosin/reitit-frontend               {:mvn/version "0.3.10"}
   cljs-bean/cljs-bean                   {:mvn/version "1.5.0"}
   cljs-bean/cljs-bean                   {:mvn/version "1.5.0"}
   prismatic/dommy                       {:mvn/version "1.1.0"}
   prismatic/dommy                       {:mvn/version "1.1.0"}
@@ -20,9 +20,9 @@
   hickory/hickory                       {:git/url "https://github.com/logseq/hickory"
   hickory/hickory                       {:git/url "https://github.com/logseq/hickory"
                                          :sha     "9c2c2f1fc2c45efaad906e0faabc3201278deeaa"}
                                          :sha     "9c2c2f1fc2c45efaad906e0faabc3201278deeaa"}
   hiccups/hiccups                       {:mvn/version "0.3.0"}
   hiccups/hiccups                       {:mvn/version "0.3.0"}
-  tongue/tongue                         {:mvn/version "0.2.9"}
+  tongue/tongue                         {:mvn/version "0.4.4"}
   org.clojure/core.async                {:mvn/version "1.3.610"}
   org.clojure/core.async                {:mvn/version "1.3.610"}
-  thheller/shadow-cljs                  {:mvn/version "2.17.5"}
+  thheller/shadow-cljs                  {:mvn/version "2.19.0"}
   expound/expound                       {:mvn/version "0.8.6"}
   expound/expound                       {:mvn/version "0.8.6"}
   com.lambdaisland/glogi                {:mvn/version "1.1.144"}
   com.lambdaisland/glogi                {:mvn/version "1.1.144"}
   binaryage/devtools                    {:mvn/version "1.0.5"}
   binaryage/devtools                    {:mvn/version "1.0.5"}
@@ -33,14 +33,14 @@
   org.clojars.mmb90/cljs-cache          {:mvn/version "0.1.4"}}
   org.clojars.mmb90/cljs-cache          {:mvn/version "0.1.4"}}
 
 
  :aliases {:cljs {:extra-paths ["src/dev-cljs/" "src/test/" "src/electron/"]
  :aliases {:cljs {:extra-paths ["src/dev-cljs/" "src/test/" "src/electron/"]
-                  :extra-deps  {org.clojure/clojurescript        {:mvn/version "1.10.891"}
+                  :extra-deps  {org.clojure/clojurescript        {:mvn/version "1.11.54"}
                                 org.clojure/tools.namespace      {:mvn/version "0.2.11"}
                                 org.clojure/tools.namespace      {:mvn/version "0.2.11"}
                                 cider/cider-nrepl                {:mvn/version "0.26.0"}
                                 cider/cider-nrepl                {:mvn/version "0.26.0"}
                                 org.clojars.knubie/cljs-run-test {:mvn/version "1.0.1"}}
                                 org.clojars.knubie/cljs-run-test {:mvn/version "1.0.1"}}
                   :main-opts   ["-m" "shadow.cljs.devtools.cli"]}
                   :main-opts   ["-m" "shadow.cljs.devtools.cli"]}
 
 
            :test {:extra-paths ["src/test/"]
            :test {:extra-paths ["src/test/"]
-                  :extra-deps  {org.clojure/clojurescript        {:mvn/version "1.10.891"}
+                  :extra-deps  {org.clojure/clojurescript        {:mvn/version "1.11.54"}
                                 org.clojure/test.check           {:mvn/version "1.1.1"}
                                 org.clojure/test.check           {:mvn/version "1.1.1"}
                                 pjstadig/humane-test-output      {:mvn/version "0.11.0"}
                                 pjstadig/humane-test-output      {:mvn/version "0.11.0"}
                                 org.clojars.knubie/cljs-run-test {:mvn/version "1.0.1"}}
                                 org.clojars.knubie/cljs-run-test {:mvn/version "1.0.1"}}

+ 1 - 1
package.json

@@ -5,7 +5,7 @@
     "main": "static/electron.js",
     "main": "static/electron.js",
     "devDependencies": {
     "devDependencies": {
         "@capacitor/cli": "3.2.2",
         "@capacitor/cli": "3.2.2",
-        "@logseq/nbb-logseq": "^0.3.99",
+        "@logseq/nbb-logseq": "^0.5.103",
         "@playwright/test": "^1.19.2",
         "@playwright/test": "^1.19.2",
         "@tailwindcss/ui": "0.7.2",
         "@tailwindcss/ui": "0.7.2",
         "@types/gulp": "^4.0.7",
         "@types/gulp": "^4.0.7",

+ 4 - 10
src/main/frontend/components/block.cljs

@@ -707,11 +707,8 @@
 (rum/defc block-reference < rum/reactive
 (rum/defc block-reference < rum/reactive
   db-mixins/query
   db-mixins/query
   [config id label]
   [config id label]
-  (when (and
-         (not (string/blank? id))
-         (util/uuid-string? id))
-    (let [block-id (uuid id)
-          block (db/pull-block block-id)
+  (when-let [block-id (parse-uuid id)]
+    (let [block (db/pull-block block-id)
           block-type (keyword (get-in block [:block/properties :ls-type]))
           block-type (keyword (get-in block [:block/properties :ls-type]))
           hl-type (get-in block [:block/properties :hl-type])
           hl-type (get-in block [:block/properties :hl-type])
           repo (state/get-current-repo)]
           repo (state/get-current-repo)]
@@ -1104,10 +1101,7 @@
       (when-let [s (-> (string/replace a "((" "")
       (when-let [s (-> (string/replace a "((" "")
                        (string/replace "))" "")
                        (string/replace "))" "")
                        string/trim)]
                        string/trim)]
-        (when-let [id (and s
-                           (let [s (string/trim s)]
-                             (and (util/uuid-string? s)
-                                  (uuid s))))]
+        (when-let [id (some-> s string/trim parse-uuid)]
           (block-embed (assoc config :link-depth (inc link-depth)) id)))
           (block-embed (assoc config :link-depth (inc link-depth)) id)))
 
 
       :else                         ;TODO: maybe collections?
       :else                         ;TODO: maybe collections?
@@ -2817,7 +2811,7 @@
         :else
         :else
         (let [language (if (contains? #{"edn" "clj" "cljc" "cljs"} language) "clojure" language)]
         (let [language (if (contains? #{"edn" "clj" "cljc" "cljs"} language) "clojure" language)]
           (if (:slide? config)
           (if (:slide? config)
-            (highlight/highlight (str (medley/random-uuid))
+            (highlight/highlight (str (random-uuid))
                                  {:class (str "language-" language)
                                  {:class (str "language-" language)
                                   :data-lang language}
                                   :data-lang language}
                                  code)
                                  code)

+ 2 - 2
src/main/frontend/components/content.cljs

@@ -363,13 +363,13 @@
                            e
                            e
                            (custom-context-menu-content))
                            (custom-context-menu-content))
 
 
-                          (and block-id (util/uuid-string? block-id))
+                          (and block-id (parse-uuid block-id))
                           (let [block (.closest target ".ls-block")]
                           (let [block (.closest target ".ls-block")]
                             (when block
                             (when block
                               (util/select-highlight! [block]))
                               (util/select-highlight! [block]))
                             (common-handler/show-custom-context-menu!
                             (common-handler/show-custom-context-menu!
                             e
                             e
-                            (block-context-menu-content target (cljs.core/uuid block-id))))
+                            (block-context-menu-content target (uuid block-id))))
 
 
                           :else
                           :else
                           nil))))))
                           nil))))))

+ 4 - 4
src/main/frontend/components/page.cljs

@@ -122,8 +122,8 @@
   (when page-e
   (when page-e
     (let [page-name (or (:block/name page-e)
     (let [page-name (or (:block/name page-e)
                         (str (:block/uuid page-e)))
                         (str (:block/uuid page-e)))
-          block? (util/uuid-string? page-name)
-          block-id (and block? (uuid page-name))
+          block-id (parse-uuid page-name)
+          block? (boolean block-id)
           page-blocks (get-blocks repo page-name block-id)]
           page-blocks (get-blocks repo page-name block-id)]
       (if (empty? page-blocks)
       (if (empty? page-blocks)
         (dummy-block page-name)
         (dummy-block page-name)
@@ -315,8 +315,8 @@
     (let [current-repo (state/sub :git/current-repo)
     (let [current-repo (state/sub :git/current-repo)
           repo (or repo current-repo)
           repo (or repo current-repo)
           page-name (util/page-name-sanity-lc path-page-name)
           page-name (util/page-name-sanity-lc path-page-name)
-          block? (util/uuid-string? page-name)
-          block-id (and block? (uuid page-name))
+          block-id (parse-uuid page-name)
+          block? (boolean block-id)
           format (let [page (if block-id
           format (let [page (if block-id
                               (:block/name (:block/page (db/entity [:block/uuid block-id])))
                               (:block/name (:block/page (db/entity [:block/uuid block-id])))
                               page-name)]
                               page-name)]

+ 1 - 1
src/main/frontend/components/plugins.cljs

@@ -733,7 +733,7 @@
         updates (state/all-available-coming-updates)]
         updates (state/all-available-coming-updates)]
 
 
     [:div.cp__plugins-waiting-updates
     [:div.cp__plugins-waiting-updates
-     [:h1.mb-4.text-2xl.p-1 (util/format "Found %s updates" (util/safe-parse-int (count updates)))]
+     [:h1.mb-4.text-2xl.p-1 (util/format "Found %s updates" (count updates))]
 
 
      (if (seq updates)
      (if (seq updates)
        ;; lists
        ;; lists

+ 3 - 5
src/main/frontend/components/reference.cljs

@@ -12,7 +12,6 @@
             [frontend.state :as state]
             [frontend.state :as state]
             [frontend.ui :as ui]
             [frontend.ui :as ui]
             [frontend.util :as util]
             [frontend.util :as util]
-            [medley.core :as medley]
             [rum.core :as rum]))
             [rum.core :as rum]))
 
 
 (rum/defc filter-dialog-inner < rum/reactive
 (rum/defc filter-dialog-inner < rum/reactive
@@ -82,8 +81,7 @@
           default-collapsed? (>= (count refed-blocks-ids) threshold)
           default-collapsed? (>= (count refed-blocks-ids) threshold)
           filters-atom (get state ::filters)
           filters-atom (get state ::filters)
           filter-state (rum/react filters-atom)
           filter-state (rum/react filters-atom)
-          block? (util/uuid-string? page-name)
-          block-id (and block? (uuid page-name))
+          block-id (parse-uuid page-name)
           page-name (string/lower-case page-name)
           page-name (string/lower-case page-name)
           journal? (date/valid-journal-title? (string/capitalize page-name))
           journal? (date/valid-journal-title? (string/capitalize page-name))
           scheduled-or-deadlines (when (and journal?
           scheduled-or-deadlines (when (and journal?
@@ -142,8 +140,8 @@
                                   (db/get-block-referenced-blocks block-id)
                                   (db/get-block-referenced-blocks block-id)
                                   (db/get-page-referenced-blocks page-name))
                                   (db/get-page-referenced-blocks page-name))
                      filters (when (seq filter-state)
                      filters (when (seq filter-state)
-                               (->> (group-by second filter-state)
-                                    (medley/map-vals #(map first %))))
+                               (-> (group-by second filter-state)
+                                   (update-vals #(map first %))))
                      filtered-ref-blocks (block-handler/filter-blocks repo ref-blocks filters true)
                      filtered-ref-blocks (block-handler/filter-blocks repo ref-blocks filters true)
                      n-ref (apply +
                      n-ref (apply +
                              (for [[_ rfs] filtered-ref-blocks]
                              (for [[_ rfs] filtered-ref-blocks]

+ 2 - 3
src/main/frontend/db/debug.cljs

@@ -1,6 +1,5 @@
 (ns frontend.db.debug
 (ns frontend.db.debug
-  (:require [medley.core :as medley]
-            [frontend.db.utils :as db-utils]
+  (:require [frontend.db.utils :as db-utils]
             [frontend.db :as db]
             [frontend.db :as db]
             [datascript.core :as d]
             [datascript.core :as d]
             [frontend.util :as util]))
             [frontend.util :as util]))
@@ -8,7 +7,7 @@
 ;; shortcut for query a block with string ref
 ;; shortcut for query a block with string ref
 (defn qb
 (defn qb
   [string-id]
   [string-id]
-  (db-utils/pull [:block/uuid (medley/uuid string-id)]))
+  (db-utils/pull [:block/uuid (uuid string-id)]))
 
 
 (defn check-left-id-conflicts
 (defn check-left-id-conflicts
   []
   []

+ 4 - 5
src/main/frontend/db/model.cljs

@@ -916,8 +916,8 @@
 
 
 (defn get-page
 (defn get-page
   [page-name]
   [page-name]
-  (if (util/uuid-string? page-name)
-    (db-utils/entity [:block/uuid (uuid page-name)])
+  (if-let [id (parse-uuid page-name)]
+    (db-utils/entity [:block/uuid id])
     (db-utils/entity [:block/name (util/page-name-sanity-lc page-name)])))
     (db-utils/entity [:block/name (util/page-name-sanity-lc page-name)])))
 
 
 (defn get-redirect-page-name
 (defn get-redirect-page-name
@@ -1225,9 +1225,8 @@
 
 
 (defn get-referenced-blocks-ids
 (defn get-referenced-blocks-ids
   [page-name-or-block-uuid]
   [page-name-or-block-uuid]
-  (if (util/uuid-string? (str page-name-or-block-uuid))
-    (let [id (uuid page-name-or-block-uuid)]
-      (get-block-referenced-blocks-ids id))
+  (if-let [id (parse-uuid (str page-name-or-block-uuid))]
+    (get-block-referenced-blocks-ids id)
     (get-page-referenced-blocks-ids page-name-or-block-uuid)))
     (get-page-referenced-blocks-ids page-name-or-block-uuid)))
 
 
 (defn get-matched-blocks
 (defn get-matched-blocks

+ 2 - 2
src/main/frontend/db/query_dsl.cljs

@@ -67,7 +67,7 @@
           (date/journal-title->int input)))
           (date/journal-title->int input)))
 
 
       :else
       :else
-      (let [duration (util/parse-int (subs input 0 (dec (count input))))
+      (let [duration (parse-long (subs input 0 (dec (count input))))
             kind (last input)
             kind (last input)
             tf (case kind
             tf (case kind
                  "y" t/years
                  "y" t/years
@@ -99,7 +99,7 @@
           (date/journal-title->long input)))
           (date/journal-title->long input)))
 
 
       :else
       :else
-      (let [duration (util/parse-int (subs input 0 (dec (count input))))
+      (let [duration (parse-long (subs input 0 (dec (count input))))
             kind (last input)
             kind (last input)
             tf (case kind
             tf (case kind
                  "y" t/years
                  "y" t/years

+ 2 - 2
src/main/frontend/db/query_react.cljs

@@ -33,12 +33,12 @@
     (and (keyword? input)
     (and (keyword? input)
          (util/safe-re-find #"^\d+d(-before)?$" (name input)))
          (util/safe-re-find #"^\d+d(-before)?$" (name input)))
     (let [input (name input)
     (let [input (name input)
-          days (util/parse-int (subs input 0 (dec (count input))))]
+          days (parse-long (subs input 0 (dec (count input))))]
       (date->int (t/minus (t/today) (t/days days))))
       (date->int (t/minus (t/today) (t/days days))))
     (and (keyword? input)
     (and (keyword? input)
          (util/safe-re-find #"^\d+d(-after)?$" (name input)))
          (util/safe-re-find #"^\d+d(-after)?$" (name input)))
     (let [input (name input)
     (let [input (name input)
-          days (util/parse-int (subs input 0 (dec (count input))))]
+          days (parse-long (subs input 0 (dec (count input))))]
       (date->int (t/plus (t/today) (t/days days))))
       (date->int (t/plus (t/today) (t/days days))))
 
 
     (and (string? input) (text/page-ref? input))
     (and (string? input) (text/page-ref? input))

+ 1 - 2
src/main/frontend/db/utils.cljs

@@ -4,7 +4,6 @@
             [frontend.state :as state]
             [frontend.state :as state]
             [clojure.string :as string]
             [clojure.string :as string]
             [datascript.transit :as dt]
             [datascript.transit :as dt]
-            [frontend.util :as util]
             [frontend.date :as date]
             [frontend.date :as date]
             [frontend.db.conn :as conn]
             [frontend.db.conn :as conn]
             [frontend.config :as config]
             [frontend.config :as config]
@@ -46,7 +45,7 @@
 
 
 (defn date->int
 (defn date->int
   [date]
   [date]
-  (util/parse-int
+  (parse-long
    (string/replace (date/ymd date) "/" "")))
    (string/replace (date/ymd date) "/" "")))
 
 
 (defn entity
 (defn entity

+ 3 - 4
src/main/frontend/extensions/slide.cljs

@@ -1,6 +1,5 @@
 (ns frontend.extensions.slide
 (ns frontend.extensions.slide
   (:require [rum.core :as rum]
   (:require [rum.core :as rum]
-            [medley.core :as medley]
             [cljs-bean.core :as bean]
             [cljs-bean.core :as bean]
             [frontend.loader :as loader]
             [frontend.loader :as loader]
             [frontend.ui :as ui]
             [frontend.ui :as ui]
@@ -20,11 +19,11 @@
   (let [properties (:block/properties block)]
   (let [properties (:block/properties block)]
     (if (seq properties)
     (if (seq properties)
       (merge m
       (merge m
-             (medley/map-keys
+             (update-keys
+              properties
               (fn [k]
               (fn [k]
                 (-> (str "data-" (name k))
                 (-> (str "data-" (name k))
-                    (string/replace "data-data-" "data-")))
-              properties))
+                    (string/replace "data-data-" "data-")))))
       m)))
       m)))
 
 
 (defonce *loading? (atom false))
 (defonce *loading? (atom false))

+ 2 - 2
src/main/frontend/extensions/video/youtube.cljs

@@ -123,9 +123,9 @@ Remember: You can paste a raw YouTube url as embedded video on mobile."
         reg-number #"^\d+$"
         reg-number #"^\d+$"
         timestamp (str timestamp)
         timestamp (str timestamp)
         total-seconds (-> (re-matches reg-number timestamp)
         total-seconds (-> (re-matches reg-number timestamp)
-                          util/safe-parse-int)
+                          parse-long)
         [_ hours minutes seconds] (re-matches reg timestamp)
         [_ hours minutes seconds] (re-matches reg timestamp)
-        [hours minutes seconds] (map util/safe-parse-int [hours minutes seconds])]
+        [hours minutes seconds] (map parse-long [hours minutes seconds])]
     (cond
     (cond
       total-seconds
       total-seconds
       total-seconds
       total-seconds

+ 2 - 3
src/main/frontend/external/roam.cljs

@@ -2,7 +2,6 @@
   (:require [cljs-bean.core :as bean]
   (:require [cljs-bean.core :as bean]
             [frontend.external.protocol :as protocol]
             [frontend.external.protocol :as protocol]
             [frontend.date :as date]
             [frontend.date :as date]
-            [medley.core :as medley]
             [clojure.walk :as walk]
             [clojure.walk :as walk]
             [clojure.string :as string]
             [clojure.string :as string]
             [frontend.util :as util]
             [frontend.util :as util]
@@ -61,7 +60,7 @@
                     (set))]
                     (set))]
       (reset! all-refed-uids uids)
       (reset! all-refed-uids uids)
       (doseq [uid uids]
       (doseq [uid uids]
-        (swap! uid->uuid assoc uid (medley/random-uuid))))))
+        (swap! uid->uuid assoc uid (random-uuid))))))
 
 
 (defn transform
 (defn transform
   [text]
   [text]
@@ -76,7 +75,7 @@
 (defn child->text
 (defn child->text
   [{:keys [uid string children]} level]
   [{:keys [uid string children]} level]
   (when-not (and (get @uid->uuid uid) uid)
   (when-not (and (get @uid->uuid uid) uid)
-    (swap! uid->uuid assoc uid (medley/random-uuid)))
+    (swap! uid->uuid assoc uid (random-uuid)))
   (let [children-text (children->text children (inc level))
   (let [children-text (children->text children (inc level))
         level-pattern (str (apply str (repeat level "\t"))
         level-pattern (str (apply str (repeat level "\t"))
                            (if (zero? level)
                            (if (zero? level)

+ 13 - 24
src/main/frontend/handler/editor.cljs

@@ -52,7 +52,6 @@
             [goog.dom.classes :as gdom-classes]
             [goog.dom.classes :as gdom-classes]
             [goog.object :as gobj]
             [goog.object :as gobj]
             [lambdaisland.glogi :as log]
             [lambdaisland.glogi :as log]
-            [medley.core :as medley]
             [promesa.core :as p]
             [promesa.core :as p]
             [logseq.graph-parser.util :as gp-util]
             [logseq.graph-parser.util :as gp-util]
             [logseq.graph-parser.mldoc :as gp-mldoc]
             [logseq.graph-parser.mldoc :as gp-mldoc]
@@ -257,10 +256,9 @@
 
 
 (defn- another-block-with-same-id-exists?
 (defn- another-block-with-same-id-exists?
   [current-id block-id]
   [current-id block-id]
-  (and (string? block-id)
-       (util/uuid-string? block-id)
-       (not= current-id (cljs.core/uuid block-id))
-       (db/entity [:block/uuid (cljs.core/uuid block-id)])))
+  (when-let [id (and (string? block-id) (parse-uuid block-id))]
+    (and (not= current-id id)
+         (db/entity [:block/uuid id]))))
 
 
 (defn- attach-page-properties-if-exists!
 (defn- attach-page-properties-if-exists!
   [block]
   [block]
@@ -482,14 +480,9 @@
 (defn- block-self-alone-when-insert?
 (defn- block-self-alone-when-insert?
   [config uuid]
   [config uuid]
   (let [current-page (state/get-current-page)
   (let [current-page (state/get-current-page)
-        block-id (or
-                  (and (:id config)
-                       (util/uuid-string? (:id config))
-                       (:id config))
-                  (and current-page
-                       (util/uuid-string? current-page)
-                       current-page))]
-    (= uuid (and block-id (medley/uuid block-id)))))
+        block-id (or (some-> (:id config) parse-uuid)
+                     (some-> current-page parse-uuid))]
+    (= uuid block-id)))
 
 
 (defn insert-new-block-before-block-aux!
 (defn insert-new-block-before-block-aux!
   [config block _value {:keys [ok-handler]}]
   [config block _value {:keys [ok-handler]}]
@@ -1176,10 +1169,7 @@
   []
   []
   (if (state/editing?)
   (if (state/editing?)
     (let [page (state/get-current-page)
     (let [page (state/get-current-page)
-          block-id (and
-                    (string? page)
-                    (util/uuid-string? page)
-                    (medley/uuid page))]
+          block-id (and (string? page) (parse-uuid page))]
       (when block-id
       (when block-id
         (let [block-parent (db/get-block-parent block-id)]
         (let [block-parent (db/get-block-parent block-id)]
           (if-let [id (and
           (if-let [id (and
@@ -2044,8 +2034,8 @@
 (defn- last-top-level-child?
 (defn- last-top-level-child?
   [{:keys [id]} current-node]
   [{:keys [id]} current-node]
   (when id
   (when id
-    (when-let [entity (if (util/uuid-string? (str id))
-                        (db/entity [:block/uuid (uuid id)])
+    (when-let [entity (if-let [id' (parse-uuid (str id))]
+                        (db/entity [:block/uuid id'])
                         (db/entity [:block/name (util/page-name-sanity-lc id)]))]
                         (db/entity [:block/name (util/page-name-sanity-lc id)]))]
       (= (:block/uuid entity) (tree/-get-parent-id current-node)))))
       (= (:block/uuid entity) (tree/-get-parent-id current-node)))))
 
 
@@ -3099,7 +3089,7 @@
   (when-let [block-id (some-> (state/get-selection-blocks)
   (when-let [block-id (some-> (state/get-selection-blocks)
                               first
                               first
                               (dom/attr "blockid")
                               (dom/attr "blockid")
-                              medley/uuid)]
+                              uuid)]
     (util/stop e)
     (util/stop e)
     (let [block    {:block/uuid block-id}
     (let [block    {:block/uuid block-id}
           block-id (-> (state/get-selection-blocks)
           block-id (-> (state/get-selection-blocks)
@@ -3211,8 +3201,7 @@
     :or {collapse? false expanded? false incremental? true root-block nil}}]
     :or {collapse? false expanded? false incremental? true root-block nil}}]
   (when-let [page (or (state/get-current-page)
   (when-let [page (or (state/get-current-page)
                       (date/today))]
                       (date/today))]
-    (let [block? (util/uuid-string? page)
-          block-id (or root-block (and block? (uuid page)))
+    (let [block-id (or root-block (parse-uuid page))
           blocks (if block-id
           blocks (if block-id
                    (db/get-block-and-children (state/get-current-repo) block-id)
                    (db/get-block-and-children (state/get-current-repo) block-id)
                    (db/get-page-blocks-no-cache page))
                    (db/get-page-blocks-no-cache page))
@@ -3309,7 +3298,7 @@
        (->> (get-selected-blocks)
        (->> (get-selected-blocks)
             (map (fn [dom]
             (map (fn [dom]
                    (-> (dom/attr dom "blockid")
                    (-> (dom/attr dom "blockid")
-                       medley/uuid
+                       uuid
                        expand-block!)))
                        expand-block!)))
             doall)
             doall)
        (and clear-selection? (clear-selection!)))
        (and clear-selection? (clear-selection!)))
@@ -3342,7 +3331,7 @@
        (->> (get-selected-blocks)
        (->> (get-selected-blocks)
             (map (fn [dom]
             (map (fn [dom]
                    (-> (dom/attr dom "blockid")
                    (-> (dom/attr dom "blockid")
-                       medley/uuid
+                       uuid
                        collapse-block!)))
                        collapse-block!)))
             doall)
             doall)
        (and clear-selection? (clear-selection!)))
        (and clear-selection? (clear-selection!)))

+ 1 - 2
src/main/frontend/handler/route.cljs

@@ -9,7 +9,6 @@
             [frontend.state :as state]
             [frontend.state :as state]
             [logseq.graph-parser.text :as text]
             [logseq.graph-parser.text :as text]
             [frontend.util :as util]
             [frontend.util :as util]
-            [medley.core :as medley]
             [reitit.frontend.easy :as rfe]))
             [reitit.frontend.easy :as rfe]))
 
 
 (defn redirect!
 (defn redirect!
@@ -80,7 +79,7 @@
     (let [name (:name path-params)
     (let [name (:name path-params)
           block? (util/uuid-string? name)]
           block? (util/uuid-string? name)]
       (if block?
       (if block?
-        (if-let [block (db/entity [:block/uuid (medley/uuid name)])]
+        (if-let [block (db/entity [:block/uuid (uuid name)])]
           (let [content (text/remove-level-spaces (:block/content block)
           (let [content (text/remove-level-spaces (:block/content block)
                                                   (:block/format block) (config/get-block-pattern (:block/format block)))]
                                                   (:block/format block) (config/get-block-pattern (:block/format block)))]
             (if (> (count content) 48)
             (if (> (count content) 48)

+ 5 - 5
src/main/frontend/modules/outliner/datascript.cljc

@@ -8,8 +8,7 @@
                      [frontend.state :as state]
                      [frontend.state :as state]
                      [frontend.config :as config]
                      [frontend.config :as config]
                      [logseq.graph-parser.util :as gp-util]
                      [logseq.graph-parser.util :as gp-util]
-                     [lambdaisland.glogi :as log]
-                     [medley.core :as medley])))
+                     [lambdaisland.glogi :as log])))
 
 
 #?(:cljs
 #?(:cljs
    (defn new-outliner-txs-state [] (atom [])))
    (defn new-outliner-txs-state [] (atom [])))
@@ -33,9 +32,10 @@
      (some->> (gp-util/remove-nils txs)
      (some->> (gp-util/remove-nils txs)
               (map (fn [x]
               (map (fn [x]
                      (if (map? x)
                      (if (map? x)
-                       (medley/map-vals (fn [v] (if (vector? v)
-                                                  (remove nil? v)
-                                                  v)) x)
+                       (update-vals x (fn [v]
+                                        (if (vector? v)
+                                          (remove nil? v)
+                                          v)))
                        x))))))
                        x))))))
 
 
 #?(:cljs
 #?(:cljs

+ 2 - 3
src/main/frontend/modules/outliner/tree.cljs

@@ -1,6 +1,5 @@
 (ns frontend.modules.outliner.tree
 (ns frontend.modules.outliner.tree
   (:require [frontend.db :as db]
   (:require [frontend.db :as db]
-            [frontend.util :as util]
             [clojure.string :as string]
             [clojure.string :as string]
             [frontend.state :as state]))
             [frontend.state :as state]))
 
 
@@ -45,8 +44,8 @@
 (defn- get-root-and-page
 (defn- get-root-and-page
   [repo root-id]
   [repo root-id]
   (if (string? root-id)
   (if (string? root-id)
-    (if (util/uuid-string? root-id)
-      [false (db/entity repo [:block/uuid (uuid root-id)])]
+    (if-let [id (parse-uuid root-id)]
+      [false (db/entity repo [:block/uuid id])]
       [true (db/entity repo [:block/name (string/lower-case root-id)])])
       [true (db/entity repo [:block/name (string/lower-case root-id)])])
     [false root-id]))
     [false root-id]))
 
 

+ 4 - 3
src/main/frontend/modules/shortcut/config.cljs

@@ -659,9 +659,10 @@
 
 
 (def category
 (def category
   "Active list of categories for docs purpose"
   "Active list of categories for docs purpose"
-  (medley/map-vals (fn [v]
-                     (vec (remove #(:inactive (get all-default-keyboard-shortcuts %)) v)))
-                   category*))
+  (update-vals
+   category*
+   (fn [v]
+     (vec (remove #(:inactive (get all-default-keyboard-shortcuts %)) v)))))
 
 
 (defn add-shortcut!
 (defn add-shortcut!
   [handler-id id shortcut-map]
   [handler-id id shortcut-map]

+ 2 - 3
src/main/frontend/modules/shortcut/core.cljs

@@ -8,8 +8,7 @@
             [frontend.util :as util]
             [frontend.util :as util]
             [goog.events :as events]
             [goog.events :as events]
             [goog.ui.KeyboardShortcutHandler.EventType :as EventType]
             [goog.ui.KeyboardShortcutHandler.EventType :as EventType]
-            [lambdaisland.glogi :as log]
-            [medley.core :as medley])
+            [lambdaisland.glogi :as log])
   (:import [goog.events KeyCodes KeyHandler KeyNames]
   (:import [goog.events KeyCodes KeyHandler KeyNames]
            [goog.ui KeyboardShortcutHandler]))
            [goog.ui KeyboardShortcutHandler]))
 
 
@@ -117,7 +116,7 @@
                     dispatch-fn (get shortcut-map (keyword (.-identifier e)))]
                     dispatch-fn (get shortcut-map (keyword (.-identifier e)))]
                 ;; trigger fn
                 ;; trigger fn
                 (when dispatch-fn (dispatch-fn e))))
                 (when dispatch-fn (dispatch-fn e))))
-          install-id (medley/random-uuid)
+          install-id (random-uuid)
           data       {install-id
           data       {install-id
                       {:group      handler-id
                       {:group      handler-id
                        :dispatch-fn f
                        :dispatch-fn f

+ 14 - 11
src/main/frontend/modules/shortcut/dicts.cljc

@@ -1,10 +1,11 @@
 (ns ^:bb-compatible frontend.modules.shortcut.dicts
 (ns ^:bb-compatible frontend.modules.shortcut.dicts
-  "Provides dictionary entries for shortcuts"
-  (:require [medley.core :as medley]))
+  "Provides dictionary entries for shortcuts")
+
 (defn- decorate-namespace [k]
 (defn- decorate-namespace [k]
   (let [n (name k)
   (let [n (name k)
         ns (namespace k)]
         ns (namespace k)]
     (keyword (str "command." ns) n)))
     (keyword (str "command." ns) n)))
+
 (def ^:large-vars/data-var all-default-keyboard-shortcuts
 (def ^:large-vars/data-var all-default-keyboard-shortcuts
   {:date-picker/complete         "Date picker: Choose selected day"
   {:date-picker/complete         "Date picker: Choose selected day"
    :date-picker/prev-day         "Date picker: Select previous day"
    :date-picker/prev-day         "Date picker: Select previous day"
@@ -113,6 +114,7 @@
    :editor/toggle-open-blocks       "Toggle open blocks (collapse or expand all blocks)"
    :editor/toggle-open-blocks       "Toggle open blocks (collapse or expand all blocks)"
    :ui/toggle-cards                 "Toggle cards"
    :ui/toggle-cards                 "Toggle cards"
    :git/commit                      "Git commit message"})
    :git/commit                      "Git commit message"})
+
 (def category
 (def category
   {:shortcut.category/basics "Basics"
   {:shortcut.category/basics "Basics"
    :shortcut.category/formatting "Formatting"
    :shortcut.category/formatting "Formatting"
@@ -122,12 +124,13 @@
    :shortcut.category/block-selection "Block selection (press Esc to quit selection)"
    :shortcut.category/block-selection "Block selection (press Esc to quit selection)"
    :shortcut.category/toggle "Toggle"
    :shortcut.category/toggle "Toggle"
    :shortcut.category/others "Others"})
    :shortcut.category/others "Others"})
+
 (def ^:large-vars/data-var dicts
 (def ^:large-vars/data-var dicts
   {:en (merge
   {:en (merge
         ;; Dynamically add this ns since command descriptions have to
         ;; Dynamically add this ns since command descriptions have to
         ;; stay in sync with shortcut.config command ids which do not
         ;; stay in sync with shortcut.config command ids which do not
         ;; have a namespce
         ;; have a namespce
-        (medley/map-keys decorate-namespace all-default-keyboard-shortcuts)
+        (update-keys all-default-keyboard-shortcuts decorate-namespace)
         category)
         category)
 
 
    :zh-CN   {:shortcut.category/formatting            "格式化"
    :zh-CN   {:shortcut.category/formatting            "格式化"
@@ -217,7 +220,7 @@
              :command.ui/toggle-theme                "“在暗色/亮色主題之間切換”"
              :command.ui/toggle-theme                "“在暗色/亮色主題之間切換”"
              :command.ui/toggle-right-sidebar        "啟用/關閉右側欄"
              :command.ui/toggle-right-sidebar        "啟用/關閉右側欄"
              :command.go/journals                    "跳轉到日記"}
              :command.go/journals                    "跳轉到日記"}
-   
+
    :de      {:shortcut.category/formatting           "Formatierung"
    :de      {:shortcut.category/formatting           "Formatierung"
              :command.editor/indent                  "Block einrücken"
              :command.editor/indent                  "Block einrücken"
              :command.editor/outdent                 "Block ausrücken"
              :command.editor/outdent                 "Block ausrücken"
@@ -264,7 +267,7 @@
              :command.ui/toggle-theme                "Intervertir le thème foncé/clair"
              :command.ui/toggle-theme                "Intervertir le thème foncé/clair"
              :command.ui/toggle-right-sidebar        "Afficher/cacher la barre latérale"
              :command.ui/toggle-right-sidebar        "Afficher/cacher la barre latérale"
              :command.go/journals                    "Aller au Journal"}
              :command.go/journals                    "Aller au Journal"}
-   
+
    :af      {:shortcut.category/formatting           "Formatering"
    :af      {:shortcut.category/formatting           "Formatering"
              :command.editor/indent                  "Ingekeepte blok oortjie"
              :command.editor/indent                  "Ingekeepte blok oortjie"
              :command.editor/outdent                 "Oningekeepte blok"
              :command.editor/outdent                 "Oningekeepte blok"
@@ -288,7 +291,7 @@
              :command.go/journals                    "Spring na joernale"
              :command.go/journals                    "Spring na joernale"
              :command.ui/toggle-theme                "Wissel tussen donker/lig temas"
              :command.ui/toggle-theme                "Wissel tussen donker/lig temas"
              :command.ui/toggle-right-sidebar        "Wissel regter sybalk"}
              :command.ui/toggle-right-sidebar        "Wissel regter sybalk"}
-   
+
    :es      {:shortcut.category/formatting            "Formato"
    :es      {:shortcut.category/formatting            "Formato"
              :shortcut.category/basics                "Básico"
              :shortcut.category/basics                "Básico"
              :shortcut.category/navigating            "Navegación"
              :shortcut.category/navigating            "Navegación"
@@ -352,7 +355,7 @@
              :command.editor/open-edit                "Editar bloque seleccionado"
              :command.editor/open-edit                "Editar bloque seleccionado"
              :command.editor/delete-selection         "Eliminar bloques seleccionados"
              :command.editor/delete-selection         "Eliminar bloques seleccionados"
              :command.editor/toggle-open-blocks       "Alternar bloques abieros, (colapsar o expandir todos)"}
              :command.editor/toggle-open-blocks       "Alternar bloques abieros, (colapsar o expandir todos)"}
-   
+
    :ru      {:shortcut.category/formatting            "Форматирование"
    :ru      {:shortcut.category/formatting            "Форматирование"
              :shortcut.category/basics                "Базовые"
              :shortcut.category/basics                "Базовые"
              :shortcut.category/navigating            "Навигация"
              :shortcut.category/navigating            "Навигация"
@@ -416,7 +419,7 @@
              :command.editor/open-edit                "Редактировать выбранный блок"
              :command.editor/open-edit                "Редактировать выбранный блок"
              :command.editor/delete-selection         "Удалить выбранные блоки"
              :command.editor/delete-selection         "Удалить выбранные блоки"
              :command.editor/toggle-open-blocks       "Переключить открытые блоки (свернуть или развернуть все)"}
              :command.editor/toggle-open-blocks       "Переключить открытые блоки (свернуть или развернуть все)"}
-   
+
    :nb-NO   {:shortcut.category/formatting            "Formatering"
    :nb-NO   {:shortcut.category/formatting            "Formatering"
              :shortcut.category/basics                "Basis"
              :shortcut.category/basics                "Basis"
              :shortcut.category/navigating            "Navigasjon"
              :shortcut.category/navigating            "Navigasjon"
@@ -481,7 +484,7 @@
              :command.editor/open-edit                "Rediger valgt blokk"
              :command.editor/open-edit                "Rediger valgt blokk"
              :command.editor/delete-selection         "Slett valgte blokker"
              :command.editor/delete-selection         "Slett valgte blokker"
              :command.editor/toggle-open-blocks       "Veksle åpne blokker (slå sammen eller utvid alle blokker)"}
              :command.editor/toggle-open-blocks       "Veksle åpne blokker (slå sammen eller utvid alle blokker)"}
-   
+
    :pt-PT   {:shortcut.category/formatting            "Formatação"
    :pt-PT   {:shortcut.category/formatting            "Formatação"
              :shortcut.category/basics                "Básico"
              :shortcut.category/basics                "Básico"
              :shortcut.category/navigating            "Navegação"
              :shortcut.category/navigating            "Navegação"
@@ -545,7 +548,7 @@
              :command.editor/open-edit                "Editar bloco selecionado"
              :command.editor/open-edit                "Editar bloco selecionado"
              :command.editor/delete-selection         "Eliminar blocos selecionados"
              :command.editor/delete-selection         "Eliminar blocos selecionados"
              :command.editor/toggle-open-blocks       "Alternar blocos abertos (colapsar ou expandir todos)"}
              :command.editor/toggle-open-blocks       "Alternar blocos abertos (colapsar ou expandir todos)"}
-   
+
    :pt-BR   {:shortcut.category/formatting            "Formatação"
    :pt-BR   {:shortcut.category/formatting            "Formatação"
              :shortcut.category/basics                "Básico"
              :shortcut.category/basics                "Básico"
              :shortcut.category/navigating            "Navegação"
              :shortcut.category/navigating            "Navegação"
@@ -659,7 +662,7 @@
              :command.misc/copy                       "Copiar (copiar seleção ou referência do bloco)"
              :command.misc/copy                       "Copiar (copiar seleção ou referência do bloco)"
              :command.ui/goto-plugins                 "Ir para o painel de plugins"
              :command.ui/goto-plugins                 "Ir para o painel de plugins"
              :command.ui/open-new-window              "Abra uma nova janela"}
              :command.ui/open-new-window              "Abra uma nova janela"}
-   
+
    :ja      {:shortcut.category/formatting                "フォーマット"
    :ja      {:shortcut.category/formatting                "フォーマット"
              :shortcut.category/basics                "基本操作"
              :shortcut.category/basics                "基本操作"
              :shortcut.category/navigating            "ナビゲーション"
              :shortcut.category/navigating            "ナビゲーション"

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

@@ -1269,7 +1269,7 @@
   [pid hook-or-all]
   [pid hook-or-all]
   (when-let [pid (keyword pid)]
   (when-let [pid (keyword pid)]
     (if (nil? hook-or-all)
     (if (nil? hook-or-all)
-      (swap! state update :plugin/installed-hooks #(medley/map-vals (fn [ids] (disj ids pid)) %))
+      (swap! state update :plugin/installed-hooks #(update-vals % (fn [ids] (disj ids pid))))
       (when-let [coll (get-in @state [:plugin/installed-hooks hook-or-all])]
       (when-let [coll (get-in @state [:plugin/installed-hooks hook-or-all])]
         (set-state! [:plugin/installed-hooks hook-or-all] (disj coll pid))))
         (set-state! [:plugin/installed-hooks hook-or-all] (disj coll pid))))
     true))
     true))

+ 6 - 4
src/main/frontend/ui.cljs

@@ -291,10 +291,12 @@
       style)))
       style)))
 
 
 (defn apply-custom-theme-effect! [theme]
 (defn apply-custom-theme-effect! [theme]
-  (when-let [custom-theme (state/sub [:ui/custom-theme (keyword theme)])]
-    (js/LSPluginCore.selectTheme (bean/->js custom-theme)
-                                 (bean/->js {:effect false :emit false}))
-    (state/set-state! :plugin/selected-theme (:url custom-theme))))
+  (when plugin-handler/lsp-enabled?
+    (when-let [custom-theme (state/sub [:ui/custom-theme (keyword theme)])]
+      (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))))))
 
 
 (defn setup-system-theme-effect!
 (defn setup-system-theme-effect!
   []
   []

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

@@ -217,39 +217,21 @@
     (str "0" n)
     (str "0" n)
     (str n)))
     (str n)))
 
 
-(defn parse-int
-  [x]
-  #?(:cljs (if (string? x)
-             (js/parseInt x)
-             x)
-     :clj (if (string? x)
-            (Integer/parseInt x)
-            x)))
-
-(defn safe-parse-int
-  [x]
-  #?(:cljs (let [result (parse-int x)]
-             (if (js/isNaN result)
-               nil
-               result))
-     :clj ((try
-             (parse-int x)
-             (catch Exception _
-               nil)))))
-#?(:cljs
-   (defn parse-float
+#?(:cljs
+   (defn safe-parse-int
+     "Use if arg could be an int or string. If arg is only a string, use `parse-long`."
      [x]
      [x]
      (if (string? x)
      (if (string? x)
-       (js/parseFloat x)
+       (parse-long x)
        x)))
        x)))
 
 
 #?(:cljs
 #?(:cljs
    (defn safe-parse-float
    (defn safe-parse-float
+     "Use if arg could be a float or string. If arg is only a string, use `parse-double`"
      [x]
      [x]
-     (let [result (parse-float x)]
-       (if (js/isNaN result)
-         nil
-         result))))
+     (if (string? x)
+       (parse-double x)
+       x)))
 
 
 #?(:cljs
 #?(:cljs
    (defn debounce
    (defn debounce

+ 2 - 3
src/main/frontend/util/list.cljs

@@ -1,8 +1,7 @@
 (ns frontend.util.list
 (ns frontend.util.list
   (:require [frontend.util.thingatpt :as thingatpt]
   (:require [frontend.util.thingatpt :as thingatpt]
             [frontend.util.cursor :as cursor]
             [frontend.util.cursor :as cursor]
-            [clojure.string :as string]
-            [frontend.util :as util]))
+            [clojure.string :as string]))
 
 
 (defn get-prev-item [& [input]]
 (defn get-prev-item [& [input]]
   (when-not (cursor/textarea-cursor-first-row? input)
   (when-not (cursor/textarea-cursor-first-row? input)
@@ -56,7 +55,7 @@
              (map (fn [line] (if (newline? line) "" line)))
              (map (fn [line] (if (newline? line) "" line)))
              (string/join "\n"))
              (string/join "\n"))
         (let [[_ num-str] (re-find #"^(\d+){1}\." line)
         (let [[_ num-str] (re-find #"^(\d+){1}\." line)
-              num (if num-str (util/safe-parse-int num-str) nil)
+              num (if num-str (parse-long num-str) nil)
               double-newlines?' (or double-newlines?
               double-newlines?' (or double-newlines?
                                      (and (newline? line) (seq others) (newline? (first others))))
                                      (and (newline? line) (seq others) (newline? (first others))))
               [idx' result'] (if (and (not double-newlines?') num)
               [idx' result'] (if (and (not double-newlines?') num)

+ 1 - 2
src/main/frontend/util/property.cljs

@@ -4,7 +4,6 @@
             [frontend.util :as util]
             [frontend.util :as util]
             [clojure.set :as set]
             [clojure.set :as set]
             [frontend.config :as config]
             [frontend.config :as config]
-            [medley.core :as medley]
             [logseq.graph-parser.util :as gp-util]
             [logseq.graph-parser.util :as gp-util]
             [logseq.graph-parser.mldoc :as gp-mldoc]
             [logseq.graph-parser.mldoc :as gp-mldoc]
             [logseq.graph-parser.property :as gp-property :refer [properties-start properties-end]]
             [logseq.graph-parser.property :as gp-property :refer [properties-start properties-end]]
@@ -364,7 +363,7 @@
 
 
 (defn add-page-properties
 (defn add-page-properties
   [page-format properties-content properties]
   [page-format properties-content properties]
-  (let [properties (medley/map-keys name properties)
+  (let [properties (update-keys properties name)
         lines (string/split-lines properties-content)
         lines (string/split-lines properties-content)
         front-matter-format? (contains? #{:markdown} page-format)
         front-matter-format? (contains? #{:markdown} page-format)
         lines (if front-matter-format?
         lines (if front-matter-format?

+ 11 - 13
src/main/logseq/api.cljs

@@ -32,11 +32,9 @@
             [frontend.loader :as loader]
             [frontend.loader :as loader]
             [goog.dom :as gdom]
             [goog.dom :as gdom]
             [lambdaisland.glogi :as log]
             [lambdaisland.glogi :as log]
-            [medley.core :as medley]
             [promesa.core :as p]
             [promesa.core :as p]
             [reitit.frontend.easy :as rfe]
             [reitit.frontend.easy :as rfe]
             [sci.core :as sci]
             [sci.core :as sci]
-            [logseq.graph-parser.util :as gp-util]
             [frontend.version :as fv]
             [frontend.version :as fv]
             [frontend.handler.shell :as shell]
             [frontend.handler.shell :as shell]
             [frontend.modules.layout.core]))
             [frontend.modules.layout.core]))
@@ -442,11 +440,11 @@
 
 
 (defn ^:export open_in_right_sidebar
 (defn ^:export open_in_right_sidebar
   [block-uuid]
   [block-uuid]
-  (editor-handler/open-block-in-sidebar! (medley/uuid block-uuid)))
+  (editor-handler/open-block-in-sidebar! (uuid block-uuid)))
 
 
 (def ^:export edit_block
 (def ^:export edit_block
   (fn [block-uuid ^js opts]
   (fn [block-uuid ^js opts]
-    (when-let [block-uuid (and block-uuid (medley/uuid block-uuid))]
+    (when-let [block-uuid (and block-uuid (uuid block-uuid))]
       (when-let [block (db-model/query-block-by-uuid block-uuid)]
       (when-let [block (db-model/query-block-by-uuid block-uuid)]
         (let [{:keys [pos] :or {pos :max}} (bean/->clj opts)]
         (let [{:keys [pos] :or {pos :max}} (bean/->clj opts)]
           (editor-handler/edit-block! block pos block-uuid))))))
           (editor-handler/edit-block! block pos block-uuid))))))
@@ -455,7 +453,7 @@
   (fn [block-uuid-or-page-name content ^js opts]
   (fn [block-uuid-or-page-name content ^js opts]
     (let [{:keys [before sibling isPageBlock properties]} (bean/->clj opts)
     (let [{:keys [before sibling isPageBlock properties]} (bean/->clj opts)
           page-name (and isPageBlock block-uuid-or-page-name)
           page-name (and isPageBlock block-uuid-or-page-name)
-          block-uuid (if isPageBlock nil (medley/uuid block-uuid-or-page-name))
+          block-uuid (if isPageBlock nil (uuid block-uuid-or-page-name))
           new-block (editor-handler/api-insert-new-block!
           new-block (editor-handler/api-insert-new-block!
                       content
                       content
                       {:block-uuid block-uuid
                       {:block-uuid block-uuid
@@ -480,7 +478,7 @@
     (let [includeChildren true
     (let [includeChildren true
           repo (state/get-current-repo)]
           repo (state/get-current-repo)]
       (editor-handler/delete-block-aux!
       (editor-handler/delete-block-aux!
-        {:block/uuid (medley/uuid block-uuid) :repo repo} includeChildren)
+        {:block/uuid (uuid block-uuid) :repo repo} includeChildren)
       nil)))
       nil)))
 
 
 (def ^:export update_block
 (def ^:export update_block
@@ -490,7 +488,7 @@
           editing? (and edit-input (string/ends-with? edit-input block-uuid))]
           editing? (and edit-input (string/ends-with? edit-input block-uuid))]
       (if editing?
       (if editing?
         (state/set-edit-content! edit-input content)
         (state/set-edit-content! edit-input content)
-        (editor-handler/save-block! repo (medley/uuid block-uuid) content))
+        (editor-handler/save-block! repo (uuid block-uuid) content))
       nil)))
       nil)))
 
 
 (def ^:export move_block
 (def ^:export move_block
@@ -505,8 +503,8 @@
 
 
                     :else
                     :else
                     nil)
                     nil)
-          src-block (db-model/query-block-by-uuid (medley/uuid src-block-uuid))
-          target-block (db-model/query-block-by-uuid (medley/uuid target-block-uuid))]
+          src-block (db-model/query-block-by-uuid (uuid src-block-uuid))
+          target-block (db-model/query-block-by-uuid (uuid target-block-uuid))]
       (editor-dnd-handler/move-blocks nil [src-block] target-block move-to) nil)))
       (editor-dnd-handler/move-blocks nil [src-block] target-block move-to) nil)))
 
 
 (def ^:export get_block
 (def ^:export get_block
@@ -565,11 +563,11 @@
 
 
 (def ^:export upsert_block_property
 (def ^:export upsert_block_property
   (fn [block-uuid key value]
   (fn [block-uuid key value]
-    (editor-handler/set-block-property! (medley/uuid block-uuid) key value)))
+    (editor-handler/set-block-property! (uuid block-uuid) key value)))
 
 
 (def ^:export remove_block_property
 (def ^:export remove_block_property
   (fn [block-uuid key]
   (fn [block-uuid key]
-    (editor-handler/remove-block-property! (medley/uuid block-uuid) key)))
+    (editor-handler/remove-block-property! (uuid block-uuid) key)))
 
 
 (def ^:export get_block_property
 (def ^:export get_block_property
   (fn [block-uuid key]
   (fn [block-uuid key]
@@ -637,7 +635,7 @@
 
 
 (defn ^:export prepend_block_in_page
 (defn ^:export prepend_block_in_page
   [uuid-or-page-name content ^js opts]
   [uuid-or-page-name content ^js opts]
-  (let [page? (not (gp-util/uuid-string? uuid-or-page-name))
+  (let [page? (not (util/uuid-string? uuid-or-page-name))
         page-not-exist? (and page? (nil? (db-model/get-page uuid-or-page-name)))
         page-not-exist? (and page? (nil? (db-model/get-page uuid-or-page-name)))
         _ (and page-not-exist? (page-handler/create! uuid-or-page-name
         _ (and page-not-exist? (page-handler/create! uuid-or-page-name
                                  {:redirect? false
                                  {:redirect? false
@@ -653,7 +651,7 @@
 
 
 (defn ^:export append_block_in_page
 (defn ^:export append_block_in_page
   [uuid-or-page-name content ^js opts]
   [uuid-or-page-name content ^js opts]
-  (let [page? (not (gp-util/uuid-string? uuid-or-page-name))
+  (let [page? (not (util/uuid-string? uuid-or-page-name))
         page-not-exist? (and page? (nil? (db-model/get-page uuid-or-page-name)))
         page-not-exist? (and page? (nil? (db-model/get-page uuid-or-page-name)))
         _ (and page-not-exist? (page-handler/create! uuid-or-page-name
         _ (and page-not-exist? (page-handler/create! uuid-or-page-name
                                  {:redirect? false
                                  {:redirect? false

+ 10 - 14
src/main/logseq/graph_parser/block.cljc

@@ -129,8 +129,7 @@
 
 
                         :else
                         :else
                         nil)]
                         nil)]
-    (when (and block-id
-               (gp-util/uuid-string? block-id))
+    (when (some-> block-id parse-uuid)
       block-id)))
       block-id)))
 
 
 (defn- paragraph-block?
 (defn- paragraph-block?
@@ -208,7 +207,7 @@
 ;; {"Deadline" {:date {:year 2020, :month 10, :day 20}, :wday "Tue", :time {:hour 8, :min 0}, :repetition [["DoublePlus"] ["Day"] 1], :active true}}
 ;; {"Deadline" {:date {:year 2020, :month 10, :day 20}, :wday "Tue", :time {:hour 8, :min 0}, :repetition [["DoublePlus"] ["Day"] 1], :active true}}
 (defn timestamps->scheduled-and-deadline
 (defn timestamps->scheduled-and-deadline
   [timestamps]
   [timestamps]
-  (let [timestamps (gp-util/map-keys (comp keyword string/lower-case) timestamps)
+  (let [timestamps (update-keys timestamps (comp keyword string/lower-case))
         m (some->> (select-keys timestamps [:scheduled :deadline])
         m (some->> (select-keys timestamps [:scheduled :deadline])
                    (map (fn [[k v]]
                    (map (fn [[k v]]
                           (let [{:keys [date repetition]} v
                           (let [{:keys [date repetition]} v
@@ -325,23 +324,21 @@
          (swap! ref-blocks conj block))
          (swap! ref-blocks conj block))
        form)
        form)
      (concat title body))
      (concat title body))
-    (let [ref-blocks (->> @ref-blocks
-                          (filter gp-util/uuid-string?))
-          ref-blocks (map
-                       (fn [id]
-                         [:block/uuid (uuid id)])
-                       ref-blocks)
+    (let [ref-blocks (keep (fn [block]
+                             (when-let [id (parse-uuid block)]
+                               [:block/uuid id]))
+                           @ref-blocks)
           refs (distinct (concat (:refs block) ref-blocks))]
           refs (distinct (concat (:refs block) ref-blocks))]
       (assoc block :refs refs))))
       (assoc block :refs refs))))
 
 
 (defn- block-keywordize
 (defn- block-keywordize
   [block]
   [block]
-  (gp-util/map-keys
+  (update-keys
+   block
    (fn [k]
    (fn [k]
      (if (namespace k)
      (if (namespace k)
        k
        k
-       (keyword "block" k)))
-   block))
+       (keyword "block" k)))))
 
 
 (defn- sanity-blocks-data
 (defn- sanity-blocks-data
   [blocks]
   [blocks]
@@ -430,8 +427,7 @@
                                (get-in properties [:properties :custom_id])
                                (get-in properties [:properties :custom_id])
                                (get-in properties [:properties :id]))]
                                (get-in properties [:properties :id]))]
         (let [custom-id (and (string? custom-id) (string/trim custom-id))]
         (let [custom-id (and (string? custom-id) (string/trim custom-id))]
-          (when (and custom-id (gp-util/uuid-string? custom-id))
-            (uuid custom-id))))
+          (some-> custom-id parse-uuid)))
       (d/squuid)))
       (d/squuid)))
 
 
 (defn get-page-refs-from-properties
 (defn get-page-refs-from-properties

+ 1 - 1
src/main/logseq/graph_parser/date_time_util.cljs

@@ -37,7 +37,7 @@
   (when journal-title
   (when journal-title
     (let [journal-title (gp-util/capitalize-all journal-title)]
     (let [journal-title (gp-util/capitalize-all journal-title)]
       (journal-title-> journal-title
       (journal-title-> journal-title
-                       #(gp-util/parse-int (tf/unparse (tf/formatter "yyyyMMdd") %))
+                       #(parse-long (tf/unparse (tf/formatter "yyyyMMdd") %))
                        formatters))))
                        formatters))))
 
 
 (defn format
 (defn format

+ 1 - 1
src/main/logseq/graph_parser/text.cljs

@@ -350,7 +350,7 @@
        false
        false
 
 
        (and (not= k "alias") (gp-util/safe-re-find #"^\d+$" v))
        (and (not= k "alias") (gp-util/safe-re-find #"^\d+$" v))
-       (gp-util/safe-parse-int v)
+       (parse-long v)
 
 
        (gp-util/wrapped-by-quotes? v) ; wrapped in ""
        (gp-util/wrapped-by-quotes? v) ; wrapped in ""
        v
        v

+ 0 - 31
src/main/logseq/graph_parser/util.cljs

@@ -4,9 +4,6 @@
   (:require [clojure.walk :as walk]
   (:require [clojure.walk :as walk]
             [clojure.string :as string]))
             [clojure.string :as string]))
 
 
-(def uuid-pattern "[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}")
-(defonce exactly-uuid-pattern (re-pattern (str "(?i)^" uuid-pattern "$")))
-
 (defn safe-re-find
 (defn safe-re-find
   "Copy of frontend.util/safe-re-find. Too basic to couple to main app"
   "Copy of frontend.util/safe-re-find. Too basic to couple to main app"
   [pattern s]
   [pattern s]
@@ -16,11 +13,6 @@
   (when (string? s)
   (when (string? s)
     (re-find pattern s)))
     (re-find pattern s)))
 
 
-(defn uuid-string?
-  "Copy of frontend.util/uuid-string?. Too basic to couple to main app"
-  [s]
-  (safe-re-find exactly-uuid-pattern s))
-
 (defn path-normalize
 (defn path-normalize
   "Normalize file path (for reading paths from FS, not required by writting)"
   "Normalize file path (for reading paths from FS, not required by writting)"
   [s]
   [s]
@@ -67,21 +59,6 @@
   [v]
   [v]
   (and (string? v) (>= (count v) 2) (= "\"" (first v) (last v))))
   (and (string? v) (>= (count v) 2) (= "\"" (first v) (last v))))
 
 
-(defn parse-int
-  "Copy of frontend.util/parse-int. Too basic to couple to main app"
-  [x]
-  (if (string? x)
-    (js/parseInt x)
-    x))
-
-(defn safe-parse-int
-  "Copy of frontend.util/safe-parse-int. Too basic to couple to main app"
-  [x]
-  (let [result (parse-int x)]
-    (if (js/isNaN result)
-      nil
-      result)))
-
 (defn url?
 (defn url?
   [s]
   [s]
   (and (string? s)
   (and (string? s)
@@ -97,14 +74,6 @@
       (js/JSON.parse)
       (js/JSON.parse)
       (js->clj :keywordize-keys true)))
       (js->clj :keywordize-keys true)))
 
 
-;; TODO: Use update-keys once its available in cljs and nbb
-(defn map-keys
-  "Maps function `f` over the keys of map `m` to produce a new map."
-  [f m]
-  (reduce-kv
-   (fn [m_ k v]
-     (assoc m_ (f k) v)) {} m))
-
 (defn zero-pad
 (defn zero-pad
   "Copy of frontend.util/zero-pad. Too basic to couple to main app"
   "Copy of frontend.util/zero-pad. Too basic to couple to main app"
   [n]
   [n]

+ 4 - 4
yarn.lock

@@ -721,10 +721,10 @@
   resolved "https://registry.yarnpkg.com/@kanru/rage-wasm/-/rage-wasm-0.2.1.tgz#dd8fdd3133992c42bf68c0086d8cad40a13bc329"
   resolved "https://registry.yarnpkg.com/@kanru/rage-wasm/-/rage-wasm-0.2.1.tgz#dd8fdd3133992c42bf68c0086d8cad40a13bc329"
   integrity sha512-sYi4F2mL6Mpcz7zbS4myasw11xLBEbgZkDMRVg9jNxTKt6Ct/LT7/vCHDmEzAFcPcPqixD5De6Ql3bJijAX0/w==
   integrity sha512-sYi4F2mL6Mpcz7zbS4myasw11xLBEbgZkDMRVg9jNxTKt6Ct/LT7/vCHDmEzAFcPcPqixD5De6Ql3bJijAX0/w==
 
 
-"@logseq/nbb-logseq@^0.3.99":
-  version "0.3.99"
-  resolved "https://registry.yarnpkg.com/@logseq/nbb-logseq/-/nbb-logseq-0.3.99.tgz#cf6c05c559963e4e0fb92f214a63228972ef87d3"
-  integrity sha512-Msa6Ck6wqt7sYGExQZgUT/uUG/z5jGaPlytVdgGkCrVogZb2yaChbWeMOCfCsCTi6kbHo15hC3aOeDAXcfnFzw==
+"@logseq/nbb-logseq@^0.5.103":
+  version "0.5.103"
+  resolved "https://registry.yarnpkg.com/@logseq/nbb-logseq/-/nbb-logseq-0.5.103.tgz#1084380cd54c92ca8cc94a8934cc777206e45cc0"
+  integrity sha512-V9UW0XrCaaadHUc6/Hp9wfGpQqkzqzoqnDGeSVZkWR6l3QwyqGi9mkhnhVcfTwAvxIfOgrfz93GcaeepV4pYNA==
   dependencies:
   dependencies:
     import-meta-resolve "^1.1.1"
     import-meta-resolve "^1.1.1"