Tienson Qin 20 ساعت پیش
والد
کامیت
ec7a325bcb
45فایلهای تغییر یافته به همراه121 افزوده شده و 1166 حذف شده
  1. 1 15
      .carve/ignore
  2. 0 3
      package.json
  3. 0 5
      scripts/src/logseq/tasks/dev/db_and_file_graphs.clj
  4. 0 28
      src/electron/electron/handler.cljs
  5. 19 57
      src/main/frontend/components/container.cljs
  6. 24 3
      src/main/frontend/components/repo.cljs
  7. 1 2
      src/main/frontend/components/settings.cljs
  8. 0 5
      src/main/frontend/components/svg.cljs
  9. 1 6
      src/main/frontend/components/theme.cljs
  10. 0 43
      src/main/frontend/date.cljs
  11. 0 16
      src/main/frontend/db/async.cljs
  12. 5 29
      src/main/frontend/db/model.cljs
  13. 3 11
      src/main/frontend/diff.cljs
  14. 4 0
      src/main/frontend/extensions/fsrs.cljs
  15. 0 18
      src/main/frontend/external.cljs
  16. 0 9
      src/main/frontend/external/protocol.cljc
  17. 0 145
      src/main/frontend/external/roam.cljs
  18. 0 86
      src/main/frontend/external/roam_export.cljs
  19. 0 32
      src/main/frontend/format/mldoc.cljs
  20. 0 26
      src/main/frontend/handler/assets.cljs
  21. 0 30
      src/main/frontend/handler/block.cljs
  22. 0 1
      src/main/frontend/handler/db_based/export.cljs
  23. 2 2
      src/main/frontend/handler/db_based/rtc.cljs
  24. 0 74
      src/main/frontend/handler/editor.cljs
  25. 5 4
      src/main/frontend/handler/export/common.cljs
  26. 0 5
      src/main/frontend/handler/global_config.cljs
  27. 0 35
      src/main/frontend/handler/import.cljs
  28. 0 1
      src/main/frontend/handler/page.cljs
  29. 2 15
      src/main/frontend/handler/query/builder.cljs
  30. 10 35
      src/main/frontend/handler/repo.cljs
  31. 0 4
      src/main/frontend/handler/route.cljs
  32. 0 25
      src/main/frontend/handler/user.cljs
  33. 0 8
      src/main/frontend/mobile/util.cljs
  34. 0 22
      src/main/frontend/rum.cljs
  35. 0 19
      src/main/frontend/search.cljs
  36. 1 2
      src/main/frontend/spec/storage.cljc
  37. 6 128
      src/main/frontend/state.cljs
  38. 0 19
      src/main/frontend/ui.cljs
  39. 25 89
      src/main/frontend/util.cljc
  40. 11 27
      src/main/frontend/util/cursor.cljs
  41. 1 22
      src/main/frontend/util/fs.cljs
  42. 0 6
      src/main/frontend/util/page.cljs
  43. 0 8
      src/main/frontend/util/text.cljs
  44. 0 11
      src/main/frontend/worker/state.cljs
  45. 0 35
      src/test/frontend/external/roam_test.cljs

+ 1 - 15
.carve/ignore

@@ -11,29 +11,15 @@ frontend.debug/defn
 frontend.debug/print
 ;; Lazily loaded
 frontend.extensions.code/editor
-;; Lazily loaded
-frontend.extensions.age-encryption/keygen
-frontend.extensions.age-encryption/encrypt-with-x25519
-frontend.extensions.age-encryption/decrypt-with-x25519
-frontend.extensions.age-encryption/encrypt-with-user-passphrase
-frontend.extensions.age-encryption/decrypt-with-user-passphrase
-;; Lazily loaded
-frontend.extensions.excalidraw/draw
-;; Lazily loaded
-frontend.extensions.tldraw/tldraw-app
-frontend.extensions.tldraw/generate-preview
 ;; Referenced in commented TODO
 frontend.extensions.pdf.utils/get-page-bounding
 ;; For repl
-frontend.extensions.zotero.api/item
-;; For repl
-frontend.external.roam/reset-state!
-;; For repl
 logseq.graph-parser.mldoc/ast-export-markdown
 ;; Protocol fn wrapper that could be used
 frontend.fs/readdir
 ;; Referenced in TODO
 frontend.handler.metadata/update-properties!
+frontend.handler.user/<ensure-id&access-token
 ;; Referenced in comment
 frontend.image/get-orientation
 ;; For debugging

+ 0 - 3
package.json

@@ -147,13 +147,11 @@
         "@tabler/icons-webfont": "^2.47.0",
         "@tippyjs/react": "4.2.5",
         "bignumber.js": "^9.0.2",
-        "check-password-strength": "2.0.7",
         "chokidar": "3.5.1",
         "chrono-node": "2.2.4",
         "codemirror": "5.65.18",
         "comlink": "^4.4.1",
         "d3-force": "3.0.0",
-        "diff": "5.0.0",
         "dompurify": "2.4.0",
         "emoji-mart": "^5.5.2",
         "fs": "0.0.1-security",
@@ -186,7 +184,6 @@
         "react-transition-group": "4.3.0",
         "react-virtuoso": "4.12.5",
         "remove-accents": "0.4.2",
-        "sanitize-filename": "1.6.3",
         "send-intent": "^7.0.0",
         "shepherd.js": "^9.1.0",
         "tailwind-capitalize-first-letter": "^1.0.4",

+ 0 - 5
scripts/src/logseq/tasks/dev/db_and_file_graphs.clj

@@ -80,12 +80,7 @@
    "deps/graph-parser/src/logseq/graph_parser/extract.cljc"
    "deps/graph-parser/src/logseq/graph_parser/property.cljs"
    "deps/graph-parser/src/logseq/graph_parser.cljs"
-   "src/main/frontend/handler/file_based" "src/main/frontend/handler/file_sync.cljs" "src/main/frontend/db/file_based"
-   "src/main/frontend/util/file_based" "src/main/frontend/worker/handler/page/file_based" "src/main/frontend/worker/file.cljs"
-   "src/main/frontend/common/file_based"
    "src/main/frontend/fs"
-   "src/main/frontend/components/file_sync.cljs"
-   "src/main/frontend/components/file_based"
    "src/main/frontend/util/fs.cljs"])
 
 (defn- grep-many

+ 0 - 28
src/electron/electron/handler.cljs

@@ -12,7 +12,6 @@
             ["os" :as os]
             ["path" :as node-path]
             [cljs-bean.core :as bean]
-            [cljs.reader :as reader]
             [clojure.string :as string]
             [electron.backup-file :as backup-file]
             [electron.configs :as cfgs]
@@ -29,7 +28,6 @@
             [electron.window :as win]
             [logseq.cli.common.graph :as cli-common-graph]
             [logseq.common.graph :as common-graph]
-            [logseq.db :as ldb]
             [logseq.db.common.sqlite :as common-sqlite]
             [logseq.db.sqlite.util :as sqlite-util]
             [promesa.core :as p]))
@@ -233,32 +231,6 @@
 (defmethod handle :getGraphs [_window [_]]
   (get-graphs))
 
-(defn- read-txid-info!
-  [root]
-  (try
-    (let [txid-path (.join node-path root "logseq/graphs-txid.edn")]
-      (when (fs/existsSync txid-path)
-        (when-let [sync-meta (and (not (string/blank? root))
-                                  (.toString (.readFileSync fs txid-path)))]
-          (reader/read-string sync-meta))))
-    (catch :default e
-      (logger/error "[read txid meta] #" root (.-message e)))))
-
-(defmethod handle :inflateGraphsInfo [_win [_ graphs]]
-  (let [graphs (ldb/read-transit-str graphs)]
-    (-> (if (seq graphs)
-          (for [{:keys [root] :as graph} graphs]
-            (if-let [sync-meta (read-txid-info! root)]
-              (assoc graph
-                     :sync-meta sync-meta
-                     :GraphUUID (second sync-meta))
-              graph))
-          [])
-        ldb/write-transit-str)))
-
-(defmethod handle :readGraphTxIdInfo [_win [_ root]]
-  (read-txid-info! root))
-
 (defmethod handle :deleteGraph [_window [_ graph graph-name _db-based?]]
   (when graph-name
     (db/unlink-graph! graph)

+ 19 - 57
src/main/frontend/components/container.cljs

@@ -31,7 +31,6 @@
             [frontend.version :refer [version]]
             [goog.dom :as gdom]
             [goog.object :as gobj]
-            [logseq.common.path :as path]
             [logseq.shui.dialog.core :as shui-dialog]
             [logseq.shui.hooks :as hooks]
             [logseq.shui.popup.core :as shui-popup]
@@ -106,30 +105,9 @@
                                     margin-less-pages? 0
                                     onboarding-and-home? 0
                                     :else 120)}}
-          main-content])
-
-       (comment
-         (when onboarding-and-home?
-           (onboarding/intro onboarding-and-home?)))]]]))
+          main-content])]]]))
 
 (defonce sidebar-inited? (atom false))
-;; TODO: simplify logic
-
-(rum/defc parsing-progress < rum/static
-  [state]
-  (let [finished (or (:finished state) 0)
-        total (:total state)
-        width (js/Math.round (* (.toFixed (/ finished total) 2) 100))
-        display-filename (some-> (:current-parsing-file state)
-                                 not-empty
-                                 path/filename)
-        left-label [:div.flex.flex-row.font-bold
-                    (t :parsing-files)
-                    [:div.hidden.md:flex.flex-row
-                     [:span.mr-1 ": "]
-                     [:div.text-ellipsis-wrapper {:style {:max-width 300}}
-                      display-filename]]]]
-    (ui/progress-bar-with-label width left-label (str finished "/" total))))
 
 (rum/defc main-content < rum/reactive db-mixins/query
   {:init (fn [state]
@@ -150,38 +128,24 @@
            state)}
   []
   (let [default-home (app-left-sidebar/get-default-home-if-valid)
-        current-repo (state/sub :git/current-repo)
-        loading-files? (when current-repo (state/sub [:repo/loading-files? current-repo]))
-        graph-parsing-state (state/sub [:graph/parsing-state current-repo])]
-    (cond
-      (or
-       (:graph-loading? graph-parsing-state)
-       (not= (:total graph-parsing-state) (:finished graph-parsing-state)))
-      [:div.flex.items-center.justify-center.full-height-without-header
-       [:div.flex-1
-        (parsing-progress graph-parsing-state)]]
-
-      :else
-      [:div
-       (cond
-         (and default-home
-              (= :home (state/get-current-route))
-              (not (state/route-has-p?))
-              (:page default-home))
-         (route-handler/redirect-to-page! (:page default-home))
-
-         (or (not (state/enable-journals? current-repo))
-             (let [latest-journals (db/get-latest-journals (state/get-current-repo) 1)]
-               (and config/publishing?
-                    (not default-home)
-                    (empty? latest-journals))))
-         (route-handler/redirect! {:to :all-pages})
-
-         loading-files?
-         (ui/loading (t :loading-files))
-
-         :else
-         (journal/all-journals))])))
+        current-repo (state/sub :git/current-repo)]
+    [:div
+     (cond
+       (and default-home
+            (= :home (state/get-current-route))
+            (not (state/route-has-p?))
+            (:page default-home))
+       (route-handler/redirect-to-page! (:page default-home))
+
+       (or (not (state/enable-journals? current-repo))
+           (let [latest-journals (db/get-latest-journals (state/get-current-repo) 1)]
+             (and config/publishing?
+                  (not default-home)
+                  (empty? latest-journals))))
+       (route-handler/redirect! {:to :all-pages})
+
+       :else
+       (journal/all-journals))]))
 
 (defn- hide-context-menu-and-clear-selection
   [e & {:keys [esc?]}]
@@ -413,7 +377,6 @@
         left-sidebar-open? (state/sub :ui/left-sidebar-open?)
         wide-mode? (state/sub :ui/wide-mode?)
         ls-block-hl-colored? (state/sub :pdf/block-highlight-colored?)
-        onboarding-state (state/sub :file-sync/onboarding-state)
         right-sidebar-blocks (state/sub-right-sidebar-blocks)
         route-name (get-in route-match [:data :name])
         margin-less-pages? (boolean (#{:graph} route-name))
@@ -442,7 +405,6 @@
       :settings-open? settings-open?
       :sidebar-blocks-len (count right-sidebar-blocks)
       :system-theme? system-theme?
-      :onboarding-state onboarding-state
       :preferred-language preferred-language
       :on-click (fn [e]
                   (editor-handler/unhighlight-blocks!)

+ 24 - 3
src/main/frontend/components/repo.cljs

@@ -137,7 +137,28 @@
                                   (p/do!
                                    (rtc-flows/trigger-rtc-start repo)
                                    (rtc-handler/<get-remote-graphs)))))))}
-              "Use Logseq sync (Alpha testing)"))
+              "Use Logseq sync (Beta testing)"))
+
+           (when (and remote? manager?)
+             (shui/dropdown-menu-item
+              {:key "delete-remotely"
+               :class "delete-remote-graph-menu-item"
+               :on-click (fn []
+                           (let [prompt-str (str "Are you sure you want to permanently delete the graph \"" graph-name "\" from our server?")]
+                             (-> (shui/dialog-confirm!
+                                  [:p.font-medium.-my-4 prompt-str
+                                   [:span.my-2.flex.font-normal.opacity-75
+                                    [:small "⚠️ Notice that we can't recover this graph after being deleted. Make sure you have backups before deleting it."]]])
+                                 (p/then
+                                  (fn []
+                                    (let [<delete-graph rtc-handler/<rtc-delete-graph!]
+                                      (state/set-state! :rtc/loading-graphs? true)
+                                      (when (= (state/get-current-repo) repo)
+                                        (state/<invoke-db-worker :thread-api/rtc-stop))
+                                      (p/do! (<delete-graph GraphUUID GraphSchemaVersion)
+                                             (state/set-state! :rtc/loading-graphs? false)
+                                             (rtc-handler/<get-remote-graphs))))))))}
+              "Delete from server"))
 
            (when (and remote? (not manager?))
              (shui/dropdown-menu-item
@@ -168,7 +189,7 @@
         repos (state/sub [:me :repos])
         repos (util/distinct-by :url repos)
         remotes (state/sub :rtc/graphs)
-        remotes-loading? (state/sub [:file-sync/remote-graphs :loading])
+        remotes-loading? (state/sub :rtc/loading-graphs?)
         repos (if (and login? (seq remotes))
                 (repo-handler/combine-local-&-remote-graphs repos remotes) repos)
         repos (cond->>
@@ -295,7 +316,7 @@
         repos (state/sub [:me :repos])
         rtc-graphs (state/sub :rtc/graphs)
         downloading-graph-id (state/sub :rtc/downloading-graph-uuid)
-        remotes-loading? (state/sub [:file-sync/remote-graphs :loading])
+        remotes-loading? (state/sub :rtc/loading-graphs?)
         repos (sort-repos-with-metadata-local repos)
         repos (distinct
                (if (and (seq rtc-graphs) login?)

+ 1 - 2
src/main/frontend/components/settings.cljs

@@ -19,7 +19,6 @@
             [frontend.handler.notification :as notification]
             [frontend.handler.plugin :as plugin-handler]
             [frontend.handler.property :as property-handler]
-            [frontend.handler.route :as route-handler]
             [frontend.handler.ui :as ui-handler]
             [frontend.handler.user :as user-handler]
             [frontend.mobile.util :as mobile-util]
@@ -722,7 +721,7 @@
 
 (rum/defc ^:large-vars/cleanup-todo settings-account < rum/reactive
   []
-  (let [graph-usage (state/get-remote-graph-usage)
+  (let [graph-usage []
         logged-in? (user-handler/logged-in?)
         user-info (state/get-user-info)
         paid-user? (#{"active" "on_trial" "cancelled"} (:LemonStatus user-info))

+ 0 - 5
src/main/frontend/components/svg.cljs

@@ -157,11 +157,6 @@
       :ry "6.13006"
       :rx "7.78547"}]]))
 
-(def page
-  [:svg.h-5.w-4 {:viewBox "0 0 24 24", :fill "none", :xmlns "http://www.w3.org/2000/svg"}
-   [:path {:d "M2 0.5H6.78272L13.5 7.69708V18C13.5 18.8284 12.8284 19.5 12 19.5H2C1.17157 19.5 0.5 18.8284 0.5 18V2C0.5 1.17157 1.17157 0.5 2 0.5Z", :fill "var(--ls-active-primary-color)"}]
-   [:path {:d "M7 5.5V0L14 7.5H9C7.89543 7.5 7 6.60457 7 5.5Z", :fill "var(--ls-active-secondary-color)"}]])
-
 (def clock
   [:svg.h-5.w-5
    {:fill "currentColor", :viewBox "0 0 20 20"}

+ 1 - 6
src/main/frontend/components/theme.cljs

@@ -11,7 +11,6 @@
             [frontend.handler.ui :as ui-handler]
             [frontend.rum :refer [use-mounted]]
             [frontend.state :as state]
-            [frontend.storage :as storage]
             [frontend.ui :as ui]
             [frontend.util :as util]
             [logseq.shui.hooks :as hooks]
@@ -38,7 +37,7 @@
 
 (rum/defc ^:large-vars/cleanup-todo container < rum/static
   [{:keys [route theme accent-color editor-font on-click current-repo db-restoring?
-           settings-open? sidebar-open? system-theme? sidebar-blocks-len onboarding-state preferred-language]} child]
+           settings-open? sidebar-open? system-theme? sidebar-blocks-len preferred-language]} child]
   (let [mounted-fn (use-mounted)
         [restored-sidebar? set-restored-sidebar?] (rum/use-state false)]
 
@@ -145,10 +144,6 @@
          (shui/dialog-close! :app-settings)))
      [settings-open?])
 
-    (hooks/use-effect!
-     #(storage/set :file-sync/onboarding-state onboarding-state)
-     [onboarding-state])
-
     [:div#root-container.theme-container
      {:on-click on-click
       :tab-index -1}

+ 0 - 43
src/main/frontend/date.cljs

@@ -20,7 +20,6 @@
 (def custom-formatter (tf/formatter "yyyy-MM-dd'T'HH:mm:ssZZ"))
 
 (def ^:private mmm-do-yyyy-formatter (tf/formatter "MMM do, yyyy"))
-(def ^:private yyyy-MM-dd-formatter (tf/formatter "yyyy-MM-dd"))
 (def ^:private yyyy-MM-dd-HH-mm-formatter (tf/formatter "yyyy-MM-dd HH:mm"))
 
 (defn journal-title-formatters
@@ -50,14 +49,6 @@
 (defn get-date-time-string-2 []
   (tf/unparse custom-formatter-2 (tl/local-now)))
 
-(def custom-formatter-3 (tf/formatter "yyyy-MM-dd E HH:mm"))
-(defn get-date-time-string-3 []
-  (tf/unparse custom-formatter-3 (tl/local-now)))
-
-(def custom-formatter-4 (tf/formatter "yyyy-MM-dd E HH:mm:ss"))
-(defn get-date-time-string-4 []
-  (tf/unparse custom-formatter-4 (tl/local-now)))
-
 (defn journal-name
   ([]
    (journal-name (tl/local-now)))
@@ -71,14 +62,6 @@
                                          :format formatter})
          (throw e))))))
 
-(defn journal-name-s [s]
-  (try
-    (journal-name (tf/parse yyyy-MM-dd-formatter s))
-    (catch :default _e
-      (log/error :parse-journal-date {:message  "Unable to parse date to journal name, skipping."
-                                      :date-str s})
-      nil)))
-
 (defn start-of-day [date]
   (t/date-time (t/year date) (t/month date) (t/day date)))
 
@@ -94,20 +77,6 @@
   []
   (journal-name (t/minus (start-of-day (tl/local-now)) (t/days 1))))
 
-(defn get-local-date
-  []
-  (let [date (js/Date.)
-        year (.getFullYear date)
-        month (inc (.getMonth date))
-        day (.getDate date)
-        hour (.getHours date)
-        minute (.getMinutes date)]
-    {:year year
-     :month month
-     :day day
-     :hour hour
-     :minute minute}))
-
 (defn get-current-time
   []
   (let [d (js/Date.)]
@@ -150,18 +119,6 @@
 
 (def default-journal-filename-formatter common-date/default-journal-filename-formatter)
 
-(defn journal-title->default
-  "Journal title to filename format"
-  [journal-title]
-  (let [formatter (if-let [format (state/get-journal-file-name-format)]
-                    (tf/formatter format)
-                    (tf/formatter default-journal-filename-formatter))]
-    (journal-title-> journal-title #(tf/unparse formatter %))))
-
-(defn journal-title->custom-format
-  [journal-title]
-  (journal-title-> journal-title #(date-time-util/format % (state/get-date-formatter))))
-
 (defn int->local-time-2
   [n]
   (tf/unparse

+ 0 - 16
src/main/frontend/db/async.cljs

@@ -158,12 +158,6 @@
         [?refed-b   :block/uuid ?refed-uuid]
         [?referee-b :block/refs ?refed-b]]))
 
-(defn <get-file
-  [graph path]
-  (when (and graph path)
-    (p/let [result (<pull graph [:file/path path])]
-      (:file/content result))))
-
 (defn <get-date-scheduled-or-deadlines
   [journal-title]
   (when-let [date (date/journal-title->int journal-title)]
@@ -229,16 +223,6 @@
             :db/id
             db/entity)))
 
-(defn <get-pdf-annotations
-  [graph pdf-id]
-  (p/let [result (<q graph {:transact-db? true}
-                     '[:find [(pull ?b [*]) ...]
-                       :in $ ?pdf-id
-                       :where
-                       [?b :logseq.property/asset ?pdf-id]]
-                     pdf-id)]
-    result))
-
 (defn <get-block-properties-history
   [graph block-id]
   (p/let [result (<q graph {:transact-db? true}

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

@@ -5,7 +5,6 @@
             [datascript.core :as d]
             [frontend.common.graph-view :as graph-view]
             [frontend.config :as config]
-            [frontend.date :as date]
             [frontend.db.conn :as conn]
             [frontend.db.react :as react]
             [frontend.db.utils :as db-utils]
@@ -185,10 +184,11 @@ independent of format as format specific heading characters are stripped"
   ([db block-id]
    (ldb/has-children? db block-id)))
 
-(defn top-block?
-  [block]
-  (= (:db/id (:block/parent block))
-     (:db/id (:block/page block))))
+(comment
+  (defn top-block?
+    [block]
+    (= (:db/id (:block/parent block))
+       (:db/id (:block/page block)))))
 
 (defn get-block-parent
   ([block-id]
@@ -319,30 +319,6 @@ independent of format as format specific heading characters are stripped"
   (when page-name-or-uuid
     (ldb/get-case-page (conn/get-db) page-name-or-uuid)))
 
-(defn get-redirect-page-name
-  "Given any readable page-name, return the exact page-name in db. If page
-   doesn't exists yet, will return the passed `page-name`. Accepts both
-   sanitized or unsanitized names.
-   alias?: if true, alias is allowed to be returned; otherwise, it would be deref."
-  ([page-name] (get-redirect-page-name page-name false))
-  ([page-name alias?]
-   (when page-name
-     (let [page-entity (ldb/get-page (conn/get-db) page-name)]
-       (cond
-         alias?
-         (or (:block/name page-entity) page-name)
-
-         (nil? page-entity)
-         (if-let [journal-name (date/journal-title->custom-format page-name)]
-           (util/page-name-sanity-lc journal-name)
-           page-name)
-
-         :else
-         (let [source-page (get-alias-source-page (state/get-current-repo) (:db/id page-entity))]
-           (or (:block/name source-page)
-               (:block/name page-entity)
-               page-name)))))))
-
 (defn get-latest-journals
   ([n]
    (get-latest-journals (state/get-current-repo) n))

+ 3 - 11
src/main/frontend/diff.cljs

@@ -1,17 +1,9 @@
 (ns ^:no-doc frontend.diff
   (:require [clojure.string :as string]
-            ["diff" :as jsdiff]
-            [goog.object :as gobj]
-            [lambdaisland.glogi :as log]
-            [cljs-bean.core :as bean]
             [frontend.util :as util]
-            [logseq.common.util :as common-util]
-            [frontend.util.text :as text-util]))
-
-(defn diff
-  [s1 s2]
-  (-> ((gobj/get jsdiff "diffLines") s1 s2 (clj->js {"newlineIsToken" true}))
-      bean/->clj))
+            [frontend.util.text :as text-util]
+            [lambdaisland.glogi :as log]
+            [logseq.common.util :as common-util]))
 
 (def inline-special-chars
   #{\* \_ \/ \` \+ \^ \~ \$})

+ 4 - 0
src/main/frontend/extensions/fsrs.cljs

@@ -1,6 +1,7 @@
 (ns frontend.extensions.fsrs
   "Flashcards functions based on FSRS, only works in db-based graphs"
   (:require [clojure.string :as string]
+            [frontend.commands :as commands]
             [frontend.common.missionary :as c.m]
             [frontend.components.block :as component-block]
             [frontend.components.macro :as component-macro]
@@ -25,6 +26,9 @@
             [rum.core :as rum]
             [tick.core :as tick]))
 
+(commands/register-slash-command ["Cloze"
+                                  [[:editor/input "{{cloze }}" {:backward-pos 2}]]])
+
 (def ^:private instant->inst-ms (comp inst-ms tick/inst))
 (defn- inst-ms->instant [ms] (tick/instant (js/Date. ms)))
 

+ 0 - 18
src/main/frontend/external.cljs

@@ -1,18 +0,0 @@
-(ns frontend.external
-  "Handles importing from external services"
-  (:require [frontend.external.roam :refer [->Roam]]
-            [frontend.external.protocol :as protocol]))
-
-(defonce roam-record (->Roam))
-
-(defn get-record
-  [type]
-  (case type
-    :roam
-    roam-record
-    nil))
-
-(defn to-markdown-files
-  [type content config]
-  (when-let [record (get-record (keyword type))]
-    (protocol/toMarkdownFiles record content config)))

+ 0 - 9
src/main/frontend/external/protocol.cljc

@@ -1,9 +0,0 @@
-(ns ^:no-doc frontend.external.protocol)
-
-(defprotocol External
-  (toMarkdownFiles [this content config]
-    "Should return a map of markdown's file name to contents."))
-
-  ;; Long-term goal:
-  ;; (toMldocAst [this content])
-  ;; (fromMldocAst [this ast])

+ 0 - 145
src/main/frontend/external/roam.cljs

@@ -1,145 +0,0 @@
-(ns frontend.external.roam
-  "Provides roam import by implementing the external protocol"
-  (:require [cljs-bean.core :as bean]
-            [frontend.external.protocol :as protocol]
-            [frontend.date :as date]
-            [clojure.walk :as walk]
-            [clojure.string :as string]
-            [goog.string :as gstring]
-            [logseq.common.util.block-ref :as block-ref]
-            [logseq.common.util :as common-util]
-            [logseq.graph-parser.text :as text]))
-
-(defonce all-refed-uids (atom #{}))
-(defonce uid->uuid (atom {}))
-
-(defn reset-state!
-  []
-  (reset! all-refed-uids #{})
-  (reset! uid->uuid {}))
-
-;; DONE: 1. uid converted to a uuid
-;; DONE: 2. merge pages with same names (case-sensitive)
-;; DONE: 3. mldoc add support to roam research macros, or we can transform here.
-;; DONE: 4. mldoc add support to nested links
-;; DONE: 5. Roam attributes -> properties
-;; TODO: 6. hiccup
-
-(defonce uid-pattern #"\(\(([a-zA-Z0-9_\\-]{6,24})\)\)")
-(defonce macro-pattern #"\{\{([^{}]+)\}\}")
-
-(defn uid-transform
-  [text]
-  (string/replace text uid-pattern (fn [[_ uid]]
-                                     (let [id (get @uid->uuid uid uid)]
-                                       (block-ref/->block-ref id)))))
-
-(defn macro-transform
-  [text]
-  (string/replace text macro-pattern (fn [[original text]]
-                                       (let [[name arg] (common-util/split-first ":" text)]
-                                         (if name
-                                           (let [name (text/page-ref-un-brackets! name)]
-                                             (gstring/format "{{%s %s}}" name arg))
-                                           original)))))
-
-(defn- fenced-code-transform
-  [text]
-  (string/replace text #"```" "\n```"))
-
-(defn load-all-refed-uids!
-  [data]
-  (let [full-text (atom "")]
-    (walk/postwalk
-     (fn [f]
-       (when (and (map? f) (:string f))
-         (swap! full-text (fn [v] (str v (:string f)))))
-       f)
-     data)
-    (let [uids (->> (re-seq uid-pattern @full-text)
-                    (map last)
-                    (distinct)
-                    (set))]
-      (reset! all-refed-uids uids)
-      (doseq [uid uids]
-        (swap! uid->uuid assoc uid (random-uuid))))))
-
-(defn transform
-  [text]
-  (-> text
-      (string/replace "{{[[TODO]]}}" "TODO")
-      (string/replace "{{[[DONE]]}}" "DONE")
-      (uid-transform)
-      (macro-transform)
-      (fenced-code-transform)))
-
-(declare children->text)
-(defn child->text
-  [{:keys [uid string children]} level]
-  (when-not (and (get @uid->uuid uid) uid)
-    (swap! uid->uuid assoc uid (random-uuid)))
-  (let [children-text (children->text children (inc level))
-        level-pattern (str (apply str (repeat level "\t"))
-                           (if (zero? level)
-                             "-"
-                             " -"))
-        properties (when (contains? @all-refed-uids uid)
-                     (str
-                      (gstring/format "id:: %s"
-                                   (str (get @uid->uuid uid)))
-                      "\n"))]
-    (if string
-      (str level-pattern " " (string/triml string) "\n" properties children-text)
-      children-text)))
-
-(defn children->text
-  [children level]
-  (->> (map #(child->text % level) children)
-       (interpose "\n")
-       (apply str)))
-
-(defn json->edn
-  [raw-string]
-  (-> raw-string js/JSON.parse bean/->clj))
-
-(defn ->file
-  [page-data]
-  (let [{:keys [create-time title children edit-time]} page-data
-        initial-level 1
-        text (when (seq children)
-               (when-let [text (children->text children (dec initial-level))]
-                 (let [journal? (date/valid-journal-title? title)
-                       front-matter (if journal?
-                                      ""
-                                      (gstring/format "---\ntitle: %s\n---\n\n" title))]
-                   (str front-matter (transform text)))))]
-    (when (and (not (string/blank? title))
-               text)
-      {:title title
-       :created-at create-time
-       :last-modified-at edit-time
-       :text text})))
-
-(defn ->files
-  [edn-data]
-  (load-all-refed-uids! edn-data)
-  (let [files (map ->file edn-data)
-        files (remove #(nil? (:title %)) files)
-        files (group-by (fn [f] (string/lower-case (:title f)))
-                        files)]
-    (map
-     (fn [[_ [fst & others]]]
-       (assoc fst :text
-              (->> (map :text (cons fst others))
-                   (interpose "\n")
-                   (apply str))))
-     files)))
-
-(defrecord Roam []
-  protocol/External
-  (toMarkdownFiles [_this content _config]
-                   (-> content json->edn ->files)))
-
-(comment
-  (defonce test-roam-json (frontend.db/get-file "same.json"))
-  (defonce edn-data (bean/->clj (js/JSON.parse test-roam-json))))

+ 0 - 86
src/main/frontend/external/roam_export.cljs

@@ -1,86 +0,0 @@
-(ns ^:no-doc frontend.external.roam-export
-  (:require [clojure.set :as s]
-            [clojure.string :as string]
-            [clojure.walk :as walk]
-            [frontend.db.async :as db-async]
-            [frontend.state :as state]
-            [promesa.core :as p]))
-
-(def todo-marker-regex
-  #"^(NOW|LATER|TODO|DOING|WAITING|WAIT|CANCELED|CANCELLED|STARTED|IN-PROGRESS)")
-
-(def done-marker-regex #"^DONE")
-
-(def nano-char-range "_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
-
-(defn- nano-id-char []
-  (rand-nth nano-char-range))
-
-(defn nano-id []
-  (->> (repeatedly 9 nano-id-char)
-       (string/join)))
-
-(defn <uuid->uid-map []
-  (let [repo (state/get-current-repo)]
-    (p/let [result (db-async/<q repo {:transact-db? false}
-                                '[:find (pull ?r [:block/uuid])
-                                  :in $
-                                  :where
-                                  [?b :block/refs ?r]])]
-      (->> result
-           (map (comp :block/uuid first))
-           (distinct)
-           (map (fn [uuid] [uuid (nano-id)]))
-           (into {})))))
-
-(defn update-content [content uuid->uid-map]
-  (when content                         ; page block doesn't have content
-    (let [uuids (keys uuid->uid-map)]
-      (reduce
-       (fn [acc uuid]
-         (if (string/includes? acc (str uuid))
-           (string/replace acc (str uuid) (get uuid->uid-map uuid))
-           acc))
-       content
-       uuids))))
-
-(defn update-uid [{:block/keys [uuid title] :as b}
-                  uuid->uid-map]
-  (cond-> b
-    (contains? uuid->uid-map uuid)
-    (assoc :block/uid (get uuid->uid-map uuid))
-
-    (some (fn [id] (string/includes? (str title) (str id))) (keys uuid->uid-map))
-    (update :block/title #(update-content % uuid->uid-map))))
-
-(defn update-todo [{:block/keys [title] :as block}]
-  (if title
-    (update block :block/title
-            (fn [c]
-              (-> c
-                  (string/replace todo-marker-regex "{{[[TODO]]}}")
-                  (string/replace done-marker-regex "{{[[DONE]]}}")
-                  (string/replace "{{embed " "{{embed: ")
-                  (string/trim))))
-    block))
-
-(defn traverse
-  [keyseq vec-tree]
-  (p/let [uuid->uid-map (<uuid->uid-map)]
-    (walk/postwalk
-     (fn [x]
-       (cond
-         (and (map? x) (contains? x :block/uuid))
-         (-> x
-
-             (update-uid uuid->uid-map)
-
-             (update-todo)
-
-             (s/rename-keys {:block/title :page/title})
-
-             (select-keys keyseq))
-
-         :else
-         x))
-     vec-tree)))

+ 0 - 32
src/main/frontend/format/mldoc.cljs

@@ -7,20 +7,13 @@
             [frontend.format.protocol :as protocol]
             [frontend.state :as state]
             [goog.object :as gobj]
-            [lambdaisland.glogi :as log]
-            [logseq.common.util :as common-util]
             [logseq.graph-parser.mldoc :as gp-mldoc]))
 
 (defonce anchorLink (gobj/get Mldoc "anchorLink"))
-(defonce parseOPML (gobj/get Mldoc "parseOPML"))
 (defonce parseAndExportMarkdown (gobj/get Mldoc "parseAndExportMarkdown"))
 (defonce parseAndExportOPML (gobj/get Mldoc "parseAndExportOPML"))
 (defonce export (gobj/get Mldoc "export"))
 
-(defn parse-opml
-  [content]
-  (parseOPML content))
-
 (defn parse-export-markdown
   [content config references]
   (parseAndExportMarkdown content
@@ -36,17 +29,6 @@
 
 (def block-with-title? gp-mldoc/block-with-title?)
 
-(defn opml->edn
-  [config content]
-  (try
-    (if (string/blank? content)
-      {}
-      (let [[headers blocks] (-> content (parse-opml) (common-util/json->clj))]
-        [headers (gp-mldoc/collect-page-properties blocks config)]))
-    (catch :default e
-      (log/error :edn/convert-failed e)
-      [])))
-
 (defn get-default-config
   [format]
   (gp-mldoc/get-default-config (state/get-current-repo) format))
@@ -70,13 +52,6 @@
   [plains]
   (string/join (map last plains)))
 
-(def properties? gp-mldoc/properties?)
-
-(defn typ-drawer?
-  [ast typ]
-  (and (contains? #{"Drawer"} (ffirst ast))
-       (= typ (second (first ast)))))
-
 (defn extract-first-query-from-ast [ast]
   (let [*result (atom nil)]
     (walk/postwalk
@@ -88,10 +63,3 @@
          f))
      ast)
     @*result))
-
-(defn get-title&body
-  "parses content and returns [title body]
-   returns nil if no title"
-  [content format]
-  (when-let [repo (state/get-current-repo)]
-    (gp-mldoc/get-title&body repo content format)))

+ 0 - 26
src/main/frontend/handler/assets.cljs

@@ -94,32 +94,6 @@
       (some-> (resolve-asset-real-path-url (state/get-current-repo) path)
               (common-util/safe-decode-uri-component)))))
 
-(defn get-matched-alias-by-ext
-  [ext]
-  (when-let [ext (and (alias-enabled?)
-                      (string? ext)
-                      (not (string/blank? ext))
-                      (util/safe-lower-case ext))]
-
-    (let [alias (medley/find-first
-                 (fn [{:keys [exts]}]
-                   (some #(string/ends-with? ext %) exts))
-                 (get-alias-dirs))]
-      alias)))
-
-(defn get-asset-file-link
-  "Link text for inserting to markdown/org"
-  [format url file-name image?]
-  (let [pdf?   (and url (string/ends-with? (string/lower-case url) ".pdf"))
-        media? (and url (or (config/ext-of-audio? url)
-                            (config/ext-of-video? url)))]
-    (case (keyword format)
-      :markdown (util/format (str (when (or image? media? pdf?) "!") "[%s](%s)") file-name url)
-      :org (if image?
-             (util/format "[[%s]]" url)
-             (util/format "[[%s][%s]]" url file-name))
-      nil)))
-
 (defn <make-data-url
   [path]
   (let [repo-dir (config/get-repo-dir (state/get-current-repo))]

+ 0 - 30
src/main/frontend/handler/block.cljs

@@ -1,6 +1,5 @@
 (ns ^:no-doc frontend.handler.block
   (:require [clojure.string :as string]
-            [clojure.walk :as walk]
             [datascript.impl.entity :as de]
             [dommy.core :as dom]
             [frontend.config :as config]
@@ -15,41 +14,12 @@
             [frontend.util :as util]
             [goog.object :as gobj]
             [logseq.db :as ldb]
-            [logseq.graph-parser.block :as gp-block]
             [logseq.outliner.core :as outliner-core]
             [logseq.outliner.op]
             [promesa.core :as p]))
 
 ;;  Fns
 
-;; TODO: reduced version
-(defn- walk-block
-  [block check? transform]
-  (let [result (atom nil)]
-    (walk/postwalk
-     (fn [x]
-       (if (check? x)
-         (reset! result (transform x))
-         x))
-     (:block.temp/ast-body block))
-    @result))
-
-(defn get-timestamp
-  [block typ]
-  (walk-block block
-              (fn [x]
-                (and (gp-block/timestamp-block? x)
-                     (= typ (first (second x)))))
-              #(second (second %))))
-
-(defn get-scheduled-ast
-  [block]
-  (get-timestamp block "Scheduled"))
-
-(defn get-deadline-ast
-  [block]
-  (get-timestamp block "Deadline"))
-
 (defn select-block!
   [block-uuid]
   (let [blocks (util/get-blocks-by-id block-uuid)]

+ 0 - 1
src/main/frontend/handler/db_based/export.cljs

@@ -2,7 +2,6 @@
   "Handles DB graph exports and imports across graphs"
   (:require [cljs.pprint :as pprint]
             [clojure.string :as string]
-            [frontend.config :as config]
             [frontend.handler.notification :as notification]
             [frontend.state :as state]
             [frontend.util :as util]

+ 2 - 2
src/main/frontend/handler/db_based/rtc.cljs

@@ -145,7 +145,7 @@
 (defn <get-remote-graphs
   []
   (->
-   (p/let [_ (state/set-state! [:file-sync/remote-graphs :loading] true)
+   (p/let [_ (state/set-state! :rtc/loading-graphs? true)
            _ (js/Promise. user-handler/task--ensure-id&access-token)
            token (state/get-auth-id-token)
            graphs (state/<invoke-db-worker :thread-api/rtc-get-graphs token)
@@ -164,7 +164,7 @@
      (repo-handler/refresh-repos!))
    (p/finally
      (fn []
-       (state/set-state! [:file-sync/remote-graphs :loading] false)))))
+       (state/set-state! :rtc/loading-graphs? false)))))
 
 (defn <rtc-invite-email
   [graph-uuid email]

+ 0 - 74
src/main/frontend/handler/editor.cljs

@@ -58,7 +58,6 @@
             [logseq.db.frontend.property :as db-property]
             [logseq.graph-parser.block :as gp-block]
             [logseq.graph-parser.mldoc :as gp-mldoc]
-            [logseq.graph-parser.property :as gp-property]
             [logseq.graph-parser.utf8 :as utf8]
             [logseq.outliner.core :as outliner-core]
             [logseq.outliner.property :as outliner-property]
@@ -848,37 +847,6 @@
               (doseq [journal journals]
                 (outliner-op/delete-page! (:block/uuid journal)))))))))))
 
-(defn set-block-timestamp!
-  [block-id key value]
-  (let [key (string/lower-case (str key))
-        block-id (if (string? block-id) (uuid block-id) block-id)
-        value (str value)]
-    (when-let [block (db/entity [:block/uuid block-id])]
-      (let [{:block/keys [title]} block
-            content (or title (state/get-edit-content))
-            new-content (-> (text-util/remove-timestamp content key)
-                            (text-util/add-timestamp key value))]
-        (when (not= content new-content)
-          (let [input-id (state/get-edit-input-id)]
-            (if (and input-id
-                     (string/ends-with? input-id (str block-id)))
-              (state/set-edit-content! input-id new-content)
-              (save-block-if-changed! block new-content))))))))
-
-(defn set-editing-block-timestamp!
-  "Almost the same as set-block-timestamp! except for:
-   - it doesn't save the block
-   - it extracts current content from current input"
-  [key value]
-  (let [key (string/lower-case (str key))
-        value (str value)
-        content (state/get-edit-content)
-        new-content (-> (text-util/remove-timestamp content key)
-                        (text-util/add-timestamp key value))]
-    (when (not= content new-content)
-      (let [input-id (state/get-edit-input-id)]
-        (state/set-edit-content! input-id new-content)))))
-
 (defn copy-block-ref!
   ([block-id]
    (copy-block-ref! block-id #(str %)))
@@ -1582,10 +1550,6 @@
   [q]
   (search/template-search q))
 
-(defn <get-matched-properties
-  [q]
-  (search/property-search q))
-
 (defn get-last-command
   [input]
   (try
@@ -2039,44 +2003,6 @@
       (insert-template! element-id db-id
                         {:replace-empty-target? true}))))
 
-(defn get-searching-property
-  [input]
-  (let [value (.-value input)
-        pos (util/get-selection-start input)
-        postfix (subs value pos)
-        end-index (when-let [idx (string/index-of postfix gp-property/colons)]
-                    (+ (max 0 (count (subs value 0 pos))) idx))
-        start-index (or (when-let [p (string/last-index-of (subs value 0 pos) "\n")]
-                          (inc p))
-                        0)]
-    {:end-index end-index
-     :searching-property (when (and start-index end-index (>= end-index start-index))
-                           (subs value start-index end-index))}))
-
-(defn property-on-chosen-handler
-  [element-id q]
-  (fn [property]
-    (when-let [input (gdom/getElement element-id)]
-      (let [{:keys [end-index searching-property]} (get-searching-property input)]
-        (cursor/move-cursor-to input (+ end-index 2))
-        (commands/insert! element-id (str (or property q) gp-property/colons " ")
-                          {:last-pattern (str searching-property gp-property/colons)})
-        (state/clear-editor-action!)
-        (js/setTimeout (fn []
-                         (let [pos (let [input (gdom/getElement element-id)]
-                                     (cursor/get-caret-pos input))]
-                           (state/set-editor-action-data! {:property (or property q)
-                                                           :pos pos})
-                           (state/set-editor-action! :property-value-search)))
-                       50)))))
-
-(defn property-value-on-chosen-handler
-  [element-id q]
-  (fn [property-value]
-    (commands/insert! element-id (str gp-property/colons " " (or property-value q))
-                      {:last-pattern (str gp-property/colons " " q)})
-    (state/clear-editor-action!)))
-
 (declare indent-outdent)
 
 (defn- last-top-level-child?

+ 5 - 4
src/main/frontend/handler/export/common.cljs

@@ -31,9 +31,10 @@
     (cli-export-common/get-page-content page-uuid)))
 
 ;; Utils
-(defn <get-all-pages
-  [repo]
-  (state/<invoke-db-worker :thread-api/export-get-all-pages repo))
+(comment
+  (defn <get-all-pages
+    [repo]
+    (state/<invoke-db-worker :thread-api/export-get-all-pages repo)))
 
 (defn <get-debug-datoms
   [repo]
@@ -69,4 +70,4 @@
 (def remove-page-ref-brackets cli-export-common/remove-page-ref-brackets)
 (def remove-tags cli-export-common/remove-tags)
 (def remove-prefix-spaces-in-Plain cli-export-common/remove-prefix-spaces-in-Plain)
-(def walk-block-ast cli-export-common/walk-block-ast)
+(def walk-block-ast cli-export-common/walk-block-ast)

+ 0 - 5
src/main/frontend/handler/global_config.cljs

@@ -31,11 +31,6 @@
   []
   (path/path-join @root-dir "config" "config.edn"))
 
-(defn safe-global-config-path
-  "Fetch config path in a general context, not just for global config"
-  []
-  (when @root-dir (global-config-path)))
-
 (defn set-global-config-state!
   [content]
   (let [config (edn/read-string content)]

+ 0 - 35
src/main/frontend/handler/import.cljs

@@ -7,50 +7,15 @@
             [clojure.walk :as walk]
             [frontend.db :as db]
             [frontend.db.async :as db-async]
-            [frontend.format.block :as block]
-            [frontend.format.mldoc :as mldoc]
             [frontend.handler.editor :as editor]
             [frontend.handler.notification :as notification]
             [frontend.handler.page :as page-handler]
             [frontend.state :as state]
             [frontend.util :as util]
-            [logseq.graph-parser.mldoc :as gp-mldoc]
             [logseq.graph-parser.whiteboard :as gp-whiteboard]
             [medley.core :as medley]
             [promesa.core :as p]))
 
-;;; import OPML files
-(defn import-from-opml!
-  [data finished-ok-handler]
-  #_:clj-kondo/ignore
-  (when-let [repo (state/get-current-repo)]
-    (let [config (gp-mldoc/default-config :markdown)
-          [headers parsed-blocks] (mldoc/opml->edn config data)
-          ;; add empty pos metadata
-          parsed-blocks (map (fn [b] [b {}]) parsed-blocks)
-          page-name (:title headers)
-          parsed-blocks (->>
-                         (block/extract-blocks parsed-blocks "" :markdown {:page-name page-name})
-                         (mapv editor/wrap-parse-block))]
-      (p/do!
-       (when (not (db/page-exists? page-name))
-         (page-handler/<create! page-name {:redirect? false}))
-       (let [page-block (db/get-page page-name)
-             children (:block/_parent page-block)
-             blocks (db/sort-by-order children)
-             last-block (last blocks)
-             snd-last-block (last (butlast blocks))
-             [target-block sibling?] (if (and last-block (seq (:block/title last-block)))
-                                       [last-block true]
-                                       (if snd-last-block
-                                         [snd-last-block true]
-                                         [page-block false]))]
-         (editor/paste-blocks
-          parsed-blocks
-          {:target-block target-block
-           :sibling? sibling?})
-         (finished-ok-handler [page-name]))))))
-
 (defn create-page-with-exported-tree!
   "Create page from the per page object generated in `export-repo-as-edn-v2!`
    Return page-name (title)

+ 0 - 1
src/main/frontend/handler/page.cljs

@@ -276,7 +276,6 @@
                ;; We should implement an app-wide check rather than list them all here
                (not (:graph/loading? @state/state))
                (not (:graph/importing @state/state))
-               (not (state/loading-files? repo))
                (not config/publishing?))
       (when-let [title (date/today)]
         (state/set-today! title)

+ 2 - 15
src/main/frontend/handler/query/builder.cljs

@@ -1,28 +1,15 @@
 (ns frontend.handler.query.builder
   "DSL query builder handler"
   (:require [clojure.walk :as walk]
-            [logseq.common.util.page-ref :as page-ref]
+            [frontend.db.query-dsl :as query-dsl]
             [lambdaisland.glogi :as log]
-            [frontend.db.query-dsl :as query-dsl]))
+            [logseq.common.util.page-ref :as page-ref]))
 
 ;; TODO: make it extensible for Datalog/SPARQL etc.
 
 (def operators [:and :or :not])
 (def operators-set (set operators))
 
-(def page-filters ["all page tags"
-                   "namespace"
-                   "tags"
-                   "property"
-                   "sample"])
-(def block-filters ["page reference"
-                    "property"
-                    "task"
-                    "priority"
-                    "page"
-                    "full text search"
-                    "between"
-                    "sample"])
 (def db-based-block-filters
   ["tags"
    "page reference"

+ 10 - 35
src/main/frontend/handler/repo.cljs

@@ -1,8 +1,7 @@
 (ns frontend.handler.repo
   "System-component-like ns that manages user's repos/graphs"
   (:refer-clojure :exclude [clone])
-  (:require [cljs-bean.core :as bean]
-            [clojure.string :as string]
+  (:require [clojure.string :as string]
             [electron.ipc :as ipc]
             [frontend.config :as config]
             [frontend.date :as date]
@@ -22,7 +21,6 @@
             [frontend.util :as util]
             [frontend.util.text :as text-util]
             [logseq.common.config :as common-config]
-            [logseq.db :as ldb]
             [logseq.db.frontend.schema :as db-schema]
             [promesa.core :as p]))
 
@@ -78,26 +76,14 @@
 
 (defn get-repos
   []
-  (p/let [nfs-dbs (db-persist/get-all-graphs)
-          nfs-dbs (map (fn [db]
-                         (let [graph-name (:name db)]
-                           {:url graph-name
-                            :metadata (:metadata db)
-                            :root (config/get-local-dir graph-name)
-                            :nfs? true}))
-                       nfs-dbs)
-          nfs-dbs (and (seq nfs-dbs)
-                       (cond (util/electron?)
-                             (p/chain
-                              (ipc/ipc :inflateGraphsInfo (ldb/write-transit-str nfs-dbs))
-                              ldb/read-transit-str)
-
-                                        ;(mobile-util/native-platform?)
-                                        ;(util-fs/inflate-graphs-info nfs-dbs)
-
-                             :else
-                             nfs-dbs))]
-    (seq (bean/->clj nfs-dbs))))
+  (p/let [dbs (db-persist/get-all-graphs)]
+    (map (fn [db]
+           (let [graph-name (:name db)]
+             {:url graph-name
+              :metadata (:metadata db)
+              :root (config/get-local-dir graph-name)
+              :nfs? true}))
+         dbs)))
 
 (defn combine-local-&-remote-graphs
   [local-repos remote-repos]
@@ -126,23 +112,12 @@
                                       (last (string/split (:root repo) #"/")))]
                    [(:remote? repo) (string/lower-case graph-name)])) repos''))))
 
-(defn get-detail-graph-info
-  [url]
-  (when-let [graphs (seq (and url (combine-local-&-remote-graphs
-                                   (state/get-repos)
-                                   (state/get-remote-file-graphs))))]
-    (first (filter #(when-let [url' (:url %)]
-                      (= url url')) graphs))))
-
 (defn refresh-repos!
   []
   (p/let [repos (get-repos)
           repos' (combine-local-&-remote-graphs
                   repos
-                  (concat
-                   (state/get-rtc-graphs)
-                   (when-not (or (util/mobile?) util/web-platform?)
-                     (state/get-remote-file-graphs))))]
+                  (state/get-rtc-graphs))]
     (state/set-repos! repos')
     repos'))
 

+ 0 - 4
src/main/frontend/handler/route.cljs

@@ -50,10 +50,6 @@
   []
   (redirect! {:to :graphs}))
 
-(defn redirect-to-whiteboard-dashboard!
-  []
-  (redirect! {:to :whiteboards}))
-
 ;; Named block links only works on web (and publishing)
 (if util/web-platform?
   (defn- default-page-route [page-name-or-block-uuid]

+ 0 - 25
src/main/frontend/handler/user.cljs

@@ -11,7 +11,6 @@
             [frontend.config :as config]
             [frontend.debug :as debug]
             [frontend.flows :as flows]
-            [frontend.handler.config :as config-handler]
             [frontend.handler.notification :as notification]
             [frontend.state :as state]
             [goog.crypt :as crypt]
@@ -19,18 +18,6 @@
             [goog.crypt.Sha256]
             [missionary.core :as m]))
 
-(defn set-preferred-format!
-  [format]
-  (when format
-    (config-handler/set-config! :preferred-format format)
-    (state/set-preferred-format! format)))
-
-(defn set-preferred-workflow!
-  [workflow]
-  (when workflow
-    (config-handler/set-config! :preferred-workflow workflow)
-    (state/set-preferred-workflow! workflow)))
-
 ;;; userinfo, token, login/logout, ...
 
 (defn- decode-username
@@ -210,11 +197,6 @@
         ;; refresh remote graph list by pub login event
         (when (user-uuid) (state/pub-event! [:user/fetch-info-and-graphs]))))))
 
-(defn has-refresh-token?
-  "Has refresh-token"
-  []
-  (boolean (js/localStorage.getItem "refresh-token")))
-
 (defn login-callback
   [session]
   (set-tokens!
@@ -289,13 +271,6 @@
                   (-> (state/get-auth-id-token) parse-jwt expired?))
           (throw (ex-info "empty or expired token and refresh failed" {:type :expired-token})))))))
 
-(defn <user-uuid
-  []
-  (go
-    (if-some [exp (<! (<ensure-id&access-token))]
-      exp
-      (user-uuid))))
-
 ;;; user groups
 
 (defn rtc-group?

+ 0 - 8
src/main/frontend/mobile/util.cljs

@@ -19,9 +19,6 @@
   (and (native-platform?)
        (= (platform) "android")))
 
-(defn convert-file-src [path-str]
-  (.convertFileSrc Capacitor path-str))
-
 (defn plugin-available?
   "Check if a native plugin is available from Capacitor.Plugins."
   [name]
@@ -152,11 +149,6 @@
       (let [^js cl (.-classList js/document.documentElement)]
         (.add cl "is-zoomed-native-ios")))))
 
-(defn in-iCloud-container-path?
-  "Check whether `path' is logseq's iCloud container path on iOS"
-  [path]
-  (string/includes? path "/iCloud~com~logseq~logseq/"))
-
 (defn alert
   "Show a native drop alert on iOS.
    Options: :title or :message (required), :subtitle, :type (info/success/warning/error),

+ 0 - 22
src/main/frontend/rum.cljs

@@ -99,25 +99,3 @@
         #())
       [ref tick])
      [set-ref rect])))
-
-(defn ->breakpoint
-  "Converts a number to a breakpoint string
-   Values come from https://tailwindcss.com/docs/responsive-design"
-  [size]
-  (cond
-    (nil? size) :md
-    (<= size 640) :sm
-    (<= size 768) :md
-    (<= size 1024) :lg
-    (<= size 1280) :xl
-    (<= size 1536) :xl
-    :else :2xl))
-
-(defn use-breakpoint
-  "Returns the current breakpoint
-   You can manually change the tick value, if you want to force refresh the value, you can manually change the tick value"
-  ([] (use-breakpoint nil))
-  ([tick]
-   (let [[ref rect] (use-bounding-client-rect tick)
-         bp (->breakpoint (when (some? rect) (.-width rect)))]
-     [ref bp])))

+ 0 - 19
src/main/frontend/search.cljs

@@ -54,20 +54,6 @@
              (fuzzy/fuzzy-search templates q {:limit limit
                                               :extract-fn extract-fn}))))))))
 
-(defn property-search
-  ([q]
-   (property-search q 100))
-  ([q limit]
-   (when q
-     (p/let [q (fuzzy/clean-str q)
-             properties* (db-async/<get-all-properties)
-             properties (map :block/title properties*)]
-       (when (seq properties)
-         (if (string/blank? q)
-           properties
-           (let [result (fuzzy/fuzzy-search properties q :limit limit)]
-             (vec result))))))))
-
 (defn rebuild-indices!
   ([]
    (rebuild-indices! (state/get-current-repo)))
@@ -78,11 +64,6 @@
         (protocol/rebuild-pages-indice! engine)
         (protocol/rebuild-blocks-indice! engine))))))
 
-(defn reset-indice!
-  [repo]
-  (when-let [engine (get-engine repo)]
-    (protocol/truncate-blocks! engine)))
-
 (defn remove-db!
   [repo]
   (when-let [engine (get-engine repo)]

+ 1 - 2
src/main/frontend/spec/storage.cljc

@@ -64,5 +64,4 @@
             :ui/shortcut-tooltip?
             :copy/export-block-text-indent-style
             :copy/export-block-text-remove-options
-            :copy/export-block-text-other-options
-            :file-sync/onboarding-state]))
+            :copy/export-block-text-other-options]))

+ 6 - 128
src/main/frontend/state.cljs

@@ -73,12 +73,9 @@
       :route-match                           nil
       :today                                 nil
       :system/events                         (async/chan 1000)
-      :file/unlinked-dirs                    #{}
       :reactive/custom-queries               (async/chan 1000)
       :notification/show?                    false
       :notification/content                  nil
-      :repo/loading-files?                   {}
-      :nfs/refreshing?                       nil
       :instrument/disabled?                  (storage/get "instrument-disabled")
       ;; TODO: how to detect the network reliably?
       ;; NOTE: prefer to use flows/network-online-event-flow
@@ -257,9 +254,6 @@
 
       ;; all notification contents as k-v pairs
       :notification/contents                 {}
-      :graph/syncing?                        false
-      ;; graph -> state
-      :graph/parsing-state                   {}
 
       :copy/export-block-text-indent-style   (or (storage/get :copy/export-block-text-indent-style)
                                                  "dashes")
@@ -288,24 +282,9 @@
       :auth/access-token                     nil
       :auth/id-token                         nil
 
-      ;; file-sync
-      :file-sync/jstour-inst                   nil
-      :file-sync/onboarding-state            (or (storage/get :file-sync/onboarding-state)
-                                                 {:welcome false})
-      :file-sync/remote-graphs               {:loading false :graphs nil}
-      :file-sync/set-remote-graph-password-result {}
-
-      ;; graph-uuid -> {:graphs-txid {}
-      ;;                :file-sync/sync-manager {}
-      ;;                :file-sync/sync-state {}
-      ;;                ;; {file-path -> payload}
-      ;;                :file-sync/progress {}
-      ;;                :file-sync/start-time {}
-      ;;                :file-sync/last-synced-at {}}
-      :file-sync/graph-state                 {:current-graph-uuid nil}
       ;; graph-uuid -> ...
-
       :rtc/state                             (atom {})
+      :rtc/loading-graphs?                   nil
       ;; only latest rtc-log stored here, when a log stream is needed,
       ;; use missionary to create a rtc-log-flow, use (missionary.core/watch <atom>)
       :rtc/log                               (atom nil)
@@ -323,9 +302,7 @@
       :ui/container-id                       (atom 0)
       :ui/cached-key->container-id           (atom {})
       :feature/enable-sync?                  (storage/get :logseq-sync-enabled)
-      :feature/enable-sync-diff-merge?       ((fnil identity true) (storage/get :logseq-sync-diff-merge-enabled))
 
-      :file/rename-event-chan                (async/chan 100)
       :ui/find-in-page                       nil
       :graph/importing                       nil
       :graph/importing-state                 {}
@@ -470,12 +447,6 @@ should be done through this fn in order to get global config and config defaults
   []
   (:custom-js-url (get-config)))
 
-(defn get-default-journal-template
-  []
-  (when-let [template (get-in (get-config) [:default-templates :journals])]
-    (when-not (string/blank? template)
-      (string/trim template))))
-
 (defn all-pages-public?
   []
   (let [value (:publishing/all-pages-public? (get-config))
@@ -686,10 +657,6 @@ Similar to re-frame subscriptions"
   ([repo]
    (not (false? (:feature/enable-flashcards? (sub-config repo))))))
 
-(defn enable-git-auto-push?
-  [repo]
-  (not (false? (:git-auto-push (sub-config repo)))))
-
 (defn graph-settings
   []
   (:graph/settings (sub-config)))
@@ -848,22 +815,14 @@ Similar to re-frame subscriptions"
   []
   (:git/current-repo @state))
 
-(defn get-remote-file-graphs
-  []
-  (get-in @state [:file-sync/remote-graphs :graphs]))
-
 (defn get-rtc-graphs
   []
   (:rtc/graphs @state))
 
-(defn get-remote-graph-info-by-uuid
-  [uuid]
-  (when-let [graphs (seq (get-in @state [:file-sync/remote-graphs :graphs]))]
-    (some #(when (= (:GraphUUID %) (str uuid)) %) graphs)))
-
-(defn get-remote-graph-usage
-  []
-  (when-let [graphs (seq (get-in @state [:file-sync/remote-graphs :graphs]))]
+;; TODO: rtc version
+(comment
+  (defn get-remote-graph-usage
+    [graphs]
     (->> graphs
          (map #(hash-map :uuid (:GraphUUID %)
                          :name (:GraphName %)
@@ -873,24 +832,6 @@ Similar to re-frame subscriptions"
          (map #(assoc % :free-gbs (- (:limit-gbs %) (:used-gbs %))))
          (vec))))
 
-(defn delete-remote-graph!
-  [repo]
-  (let [remove-repo! (fn [repos]
-                       (remove #(and
-                                 (:GraphUUID repo)
-                                 (:GraphUUID %)
-                                 (= (:GraphUUID repo) (:GraphUUID %))) repos))]
-    (if (:rtc-graph? repo)
-      (swap! state update :rtc/graphs remove-repo!)
-      (swap! state update-in [:file-sync/remote-graphs :graphs] remove-repo!))))
-
-(defn add-remote-graph!
-  [repo]
-  (swap! state update-in [:file-sync/remote-graphs :graphs]
-         (fn [repos]
-           (->> (conj repos repo)
-                (distinct)))))
-
 (defn get-repos
   []
   (get-in @state [:me :repos]))
@@ -916,14 +857,6 @@ Similar to re-frame subscriptions"
     (storage/remove :git/current-repo))
   (ipc/ipc "setCurrentGraph" repo))
 
-(defn set-preferred-format!
-  [format]
-  (swap! state assoc-in [:me :preferred_format] (name format)))
-
-(defn set-preferred-workflow!
-  [workflow]
-  (swap! state assoc-in [:me :preferred_workflow] (name workflow)))
-
 (defn set-preferred-language!
   [language]
   (set-state! :preferred-language (name language))
@@ -1342,11 +1275,6 @@ Similar to re-frame subscriptions"
   (set-state! :editor/action-data nil)
   (set-state! :view/selected-blocks nil))
 
-(defn into-code-editor-mode!
-  []
-  (set-state! :editor/cursor-range nil)
-  (swap! state assoc :editor/code-mode? true))
-
 (defn set-editor-last-pos!
   [new-pos]
   (update-state! :editor/last-saved-cursor
@@ -1698,15 +1626,6 @@ Similar to re-frame subscriptions"
   []
   (:editor/in-composition? @state))
 
-(defn set-loading-files!
-  [repo value]
-  (when repo
-    (set-state! [:repo/loading-files? repo] value)))
-
-(defn loading-files?
-  [repo]
-  (get-in @state [:repo/loading-files? repo]))
-
 (defn set-editor-last-input-time!
   [repo time]
   (set-state! :editor/last-input-time time :path-in-sub-atom repo))
@@ -1725,14 +1644,6 @@ Similar to re-frame subscriptions"
        ;; not in editing mode
        (not (get-edit-input-id))))))
 
-(defn set-nfs-refreshing!
-  [value]
-  (set-state! :nfs/refreshing? value))
-
-(defn nfs-refreshing?
-  []
-  (:nfs/refreshing? @state))
-
 (defn set-search-result!
   [value]
   (set-state! :search/result value))
@@ -1924,14 +1835,6 @@ Similar to re-frame subscriptions"
             (when (mobile-util/native-platform?)
               (set-state! :mobile/show-action-bar? false))))))))
 
-(defn get-git-auto-commit-enabled?
-  []
-  (false? (sub [:electron/user-cfgs :git/disable-auto-commit?])))
-
-(defn get-git-commit-on-close-enabled?
-  []
-  (sub [:electron/user-cfgs :git/commit-on-close?]))
-
 (defn set-last-key-code!
   [key-code]
   (set-state! :editor/last-key-code key-code))
@@ -2077,11 +1980,8 @@ Similar to re-frame subscriptions"
 (defn get-auth-refresh-token []
   (:auth/refresh-token @state))
 
-(defn reset-parsing-state!
-  []
-  (set-state! [:graph/parsing-state (get-current-repo)] {}))
-
 (defn set-parsing-state!
+  "Leave for tests"
   [m]
   (update-state! [:graph/parsing-state (get-current-repo)]
                  (if (fn? m) m
@@ -2093,28 +1993,6 @@ Similar to re-frame subscriptions"
                 (every? not-empty (vals agent-opts)))
       (str protocol "://" host ":" port))))
 
-(defn get-sync-graph-by-id
-  [graph-uuid]
-  (when graph-uuid
-    (let [graph (first (filter #(= graph-uuid (:GraphUUID %))
-                               (get-repos)))]
-      (when (:url graph)
-        graph))))
-
-(defn unlinked-dir?
-  [dir]
-  (contains? (:file/unlinked-dirs @state) dir))
-
-(defn get-file-rename-event-chan
-  []
-  (:file/rename-event-chan @state))
-
-(defn offer-file-rename-event-chan!
-  [v]
-  {:pre [(map? v)
-         (= #{:repo :old-path :new-path} (set (keys v)))]}
-  (async/offer! (get-file-rename-event-chan) v))
-
 (defn get-current-pdf
   []
   (:pdf/current @state))

+ 0 - 19
src/main/frontend/ui.cljs

@@ -367,25 +367,6 @@
            items (if clear-all (cons clear-all notifications) notifications)]
        (doall items)))))
 
-(rum/defc humanity-time-ago
-  [input opts]
-  (let [time-fn (fn []
-                  (try
-                    (util/human-time input)
-                    (catch :default e
-                      (js/console.error e)
-                      input)))
-        [time set-time] (rum/use-state (time-fn))]
-
-    (hooks/use-effect!
-     (fn []
-       (let [timer (js/setInterval
-                    #(set-time (time-fn)) (* 1000 30))]
-         #(js/clearInterval timer)))
-     [])
-
-    [:span.ui__humanity-time (merge {} opts) time]))
-
 (defn checkbox
   [option]
   (let [on-change' (:on-change option)

+ 25 - 89
src/main/frontend/util.cljc

@@ -2,34 +2,30 @@
   "Main ns for utility fns. This ns should be split up into more focused namespaces"
   #?(:clj (:refer-clojure :exclude [format]))
   #?(:cljs (:require-macros [frontend.util]))
-  #?(:cljs (:require
-            ["/frontend/selection" :as selection]
-            ["/frontend/utils" :as utils]
-            ["@capacitor/status-bar" :refer [^js StatusBar Style]]
-            ["@capacitor/core" :refer [Capacitor]]
-            ["@capacitor/clipboard" :as CapacitorClipboard]
-            ["grapheme-splitter" :as GraphemeSplitter]
-            ["sanitize-filename" :as sanitizeFilename]
-            ["check-password-strength" :refer [passwordStrength]]
-            ["path-complete-extname" :as pathCompleteExtname]
-            ["semver" :as semver]
-            [frontend.loader :refer [load]]
-            [cljs-bean.core :as bean]
-            [cljs-time.core :as t]
-            [clojure.pprint]
-            [dommy.core :as d]
-            [frontend.mobile.util :as mobile-util]
-            [logseq.common.util :as common-util]
-            [goog.dom :as gdom]
-            [goog.object :as gobj]
-            [goog.string :as gstring]
-            [goog.functions :as gfun]
-            [goog.userAgent]
-            [promesa.core :as p]
-            [rum.core :as rum]
-            [clojure.core.async :as async]
-            [datascript.impl.entity :as de]
-            [logseq.common.config :as common-config]))
+  #?(:cljs (:require ["/frontend/selection" :as selection]
+                     ["/frontend/utils" :as utils]
+                     ["@capacitor/clipboard" :as CapacitorClipboard]
+                     ["@capacitor/core" :refer [Capacitor]]
+                     ["@capacitor/status-bar" :refer [^js StatusBar Style]]
+                     ["grapheme-splitter" :as GraphemeSplitter]
+                     ["path-complete-extname" :as pathCompleteExtname]
+                     ["semver" :as semver]
+                     [cljs-bean.core :as bean]
+                     [cljs-time.core :as t]
+                     [clojure.pprint]
+                     [datascript.impl.entity :as de]
+                     [dommy.core :as d]
+                     [frontend.loader :refer [load]]
+                     [frontend.mobile.util :as mobile-util]
+                     [goog.dom :as gdom]
+                     [goog.functions :as gfun]
+                     [goog.object :as gobj]
+                     [goog.string :as gstring]
+                     [goog.userAgent]
+                     [logseq.common.config :as common-config]
+                     [logseq.common.util :as common-util]
+                     [promesa.core :as p]
+                     [rum.core :as rum]))
   #?(:cljs (:import [goog.async Debouncer]))
   (:require
    [clojure.pprint]
@@ -114,24 +110,7 @@
 #?(:cljs (def string-join-path common-util/string-join-path))
 
 #?(:cljs
-   (do
-     (def uuid-string? common-util/uuid-string?)
-     (defn check-password-strength
-       {:malli/schema [:=> [:cat :string] [:maybe
-                                           [:map
-                                            [:contains [:sequential :string]]
-                                            [:length :int]
-                                            [:id :int]
-                                            [:value :string]]]]}
-       [input]
-       (when-let [^js ret (and (string? input)
-                               (not (string/blank? input))
-                               (passwordStrength input))]
-         (bean/->clj ret)))
-     (defn safe-sanitize-file-name
-       {:malli/schema [:=> [:cat :string] :string]}
-       [s]
-       (sanitizeFilename (str s)))))
+   (def uuid-string? common-util/uuid-string?))
 
 #?(:cljs
    (do
@@ -555,10 +534,6 @@
 #?(:cljs
    (def distinct-by-last-wins common-util/distinct-by-last-wins))
 
-(defn get-git-owner-and-repo
-  [repo-url]
-  (take-last 2 (string/split repo-url #"/")))
-
 (defn safe-lower-case
   [s]
   (if (string? s)
@@ -997,13 +972,6 @@
                      (d/set-attr! :media "all"))]
            (d/append! parent-node link))))))
 
-(defn remove-common-preceding
-  [col1 col2]
-  (if (and (= (first col1) (first col2))
-           (seq col1))
-    (recur (rest col1) (rest col2))
-    [col1 col2]))
-
 ;; fs
 #?(:cljs
    (defn get-file-ext
@@ -1022,22 +990,6 @@
                     string-join-path)]
        [dir basename])))
 
-#?(:cljs
-   (defn get-relative-path
-     [current-file-path another-file-path]
-     (let [directories-f #(butlast (string/split % "/"))
-           parts-1 (directories-f current-file-path)
-           parts-2 (directories-f another-file-path)
-           [parts-1 parts-2] (remove-common-preceding parts-1 parts-2)
-           another-file-name (last (string/split another-file-path "/"))]
-       (->> (concat
-             (if (seq parts-1)
-               (repeat (count parts-1) "..")
-               ["."])
-             parts-2
-             [another-file-name])
-            string-join-path))))
-
 #?(:clj
    (defmacro profile
      [k & body]
@@ -1073,22 +1025,6 @@
 
 (defn keyname [key] (str (namespace key) "/" (name key)))
 
-;; FIXME: drain-chan was copied from frontend.worker-common.util due to shadow-cljs compile bug
-#?(:cljs
-   (defn drain-chan
-     "drop all stuffs in CH, and return all of them"
-     [ch]
-     (->> (repeatedly #(async/poll! ch))
-          (take-while identity))))
-
-#?(:cljs
-   (defn trace!
-     []
-     (js/console.trace)))
-
-#?(:cljs
-   (def remove-first common-util/remove-first))
-
 #?(:cljs
    (defn backward-kill-word
      [input]

+ 11 - 27
src/main/frontend/util/cursor.cljs

@@ -99,20 +99,6 @@
   [(gobj/get input "value")
    (pos input)])
 
-(defn line-beginning-pos
-  [input]
-  (let [[content pos'] (get-input-content&pos input)]
-    (if (zero? pos') 0
-        (let [last-newline-pos (string/last-index-of content \newline (dec pos'))]
-          (if (= nil last-newline-pos) 0 ;; no newline found (first line)
-              (inc last-newline-pos))))))
-
-(defn line-end-pos
-  [input]
-  (let [[content pos'] (get-input-content&pos input)]
-    (or (string/index-of content \newline pos')
-        (count content))))
-
 (defn beginning-of-line?
   [input]
   (let [[content pos'] (get-input-content&pos input)]
@@ -121,14 +107,20 @@
           (when-let [pre-char (subs content (dec pos') pos')]
             (= pre-char \newline))))))
 
-(defn move-cursor-to-line-end
-  [input]
-  (move-cursor-to input (line-end-pos input)))
-
 (comment
+  (defn line-end-pos
+    [input]
+    (let [[content pos'] (get-input-content&pos input)]
+      (or (string/index-of content \newline pos')
+          (count content))))
+
   (defn move-cursor-to-line-beginning
     [input]
-    (move-cursor-to input (line-beginning-pos input))))
+    (move-cursor-to input (line-beginning-pos input)))
+
+  (defn move-cursor-to-line-end
+    [input]
+    (move-cursor-to input (line-end-pos input))))
 
 (defn move-cursor-to-start
   [input]
@@ -139,14 +131,6 @@
   (let [pos' (count (gobj/get input "value"))]
     (move-cursor-to input pos')))
 
-(defn move-cursor-to-thing
-  ([input thing]
-   (move-cursor-to-thing input thing (pos input)))
-  ([input thing from]
-   (let [[content _pos] (get-input-content&pos input)
-         pos' (string/index-of content thing from)]
-     (move-cursor-to input pos'))))
-
 (defn move-cursor-forward-by-word
   [input]
   (let [val   (.-value input)

+ 1 - 22
src/main/frontend/util/fs.cljs

@@ -3,12 +3,8 @@
 (ns frontend.util.fs
   "Misc util fns built on top of frontend.fs"
   (:require ["path" :as node-path]
-            [cljs.reader :as reader]
             [clojure.string :as string]
-            [frontend.common.file.util :as wfu]
-            [frontend.config :as config]
-            [frontend.fs :as fs]
-            [promesa.core :as p]))
+            [frontend.common.file.util :as wfu]))
 
 ;; NOTE: This is not the same ignored-path? as src/electron/electron/utils.cljs.
 ;;       The assets directory is ignored.
@@ -41,23 +37,6 @@
            (some #(string/ends-with? path %)
                  [".md" ".markdown" ".org" ".js" ".edn" ".css"]))))))))
 
-(defn read-graphs-txid-info
-  [root]
-  (when (string? root)
-    (p/let [exists? (fs/file-exists? root "logseq/graphs-txid.edn")]
-      (when exists?
-        (-> (p/let [txid-str (fs/read-file root "logseq/graphs-txid.edn")
-                    txid-meta (and txid-str (reader/read-string txid-str))]
-              txid-meta)
-            (p/catch
-             (fn [^js e]
-               (js/console.error "[fs read txid data error]" e))))))))
-
-(defn read-repo-file
-  [repo-url file-rpath]
-  (when-let [repo-dir (config/get-repo-dir repo-url)]
-    (fs/read-file repo-dir file-rpath)))
-
 (def include-reserved-chars? wfu/include-reserved-chars?)
 (def windows-reserved-filebodies wfu/windows-reserved-filebodies)
 (defn file-name-sanity

+ 0 - 6
src/main/frontend/util/page.cljs

@@ -4,12 +4,6 @@
             [frontend.state :as state]
             [frontend.util :as util]))
 
-(defn get-current-page-name
-  "Fetch the current page's original name with same approach as get-current-page-id"
-  []
-  (or (:block/title (db/get-page (state/get-current-page)))
-      (get-in (first (state/get-editor-args)) [:block :block/page :block/title])))
-
 (defn get-current-page-uuid
   "Fetch the current page's uuid with same approach as get-current-page-id"
   []

+ 0 - 8
src/main/frontend/util/text.cljs

@@ -50,14 +50,6 @@
                            (rest new-lines))))]
     (string/join "\n" new-lines)))
 
-(defn remove-timestamp
-  [content key]
-  (let [lines (string/split-lines content)
-        new-lines (filter (fn [line]
-                            (not (string/starts-with? (string/lower-case line) key)))
-                          lines)]
-    (string/join "\n" new-lines)))
-
 (defn get-current-line-by-pos
   [s pos]
   (let [lines (string/split-lines s)

+ 0 - 11
src/main/frontend/worker/state.cljs

@@ -76,17 +76,6 @@
   [repo]
   (get @*opfs-pools repo))
 
-(defn tx-idle?
-  [repo & {:keys [diff]
-           :or {diff 1000}}]
-  (when repo
-    (let [last-input-time (get-in @*state [:db/latest-transact-time repo])]
-      (or
-       (nil? last-input-time)
-
-       (let [now (common-util/time-ms)]
-         (>= (- now last-input-time) diff))))))
-
 (defn set-db-latest-tx-time!
   [repo]
   (swap! *state assoc-in [:db/latest-transact-time repo] (common-util/time-ms)))

+ 0 - 35
src/test/frontend/external/roam_test.cljs

@@ -1,35 +0,0 @@
-(ns frontend.external.roam-test
-  (:require [cljs.test :refer [is deftest]]
-            [frontend.external.roam :as roam]
-            [frontend.external :refer [to-markdown-files]]))
-
-(def minimal-json "
-[
- {
-  \"create-email\": \"[email protected]\",
-  \"create-time\": 1610708403162,
-  \"title\": \"Export JSON\",
-  \"children\": [
-                  {
-                    \"string\": \"Hello, world!\",
-                    \"create-email\": \"[email protected]\",
-                    \"create-time\": 1610708405787,
-                    \"uid\": \"7c5um7hSz\",
-                    \"edit-time\": 1610708415484,
-                    \"edit-email\": \"[email protected]\"}
-                ],
-  \"edit-time\": 1610708403169,
-  \"edit-email\": \"[email protected]\"}]
-")
-
-(deftest json->edn-test
-  (is (= [1 {:foo 42, :bar "baz"} 3] (roam/json->edn "[1, {\"foo\": 42, \"bar\": \"baz\"}, 3]"))))
-
-(deftest roam-import-test
-  (let [got (to-markdown-files :roam minimal-json {})
-        md (first got)]
-    (is (= 1 (count got)))
-    (is (= "Export JSON" (:title md)))
-    (is (:created-at md))
-    (is (:last-modified-at md))
-    (is (= "---\ntitle: Export JSON\n---\n\n- Hello, world!\n" (:text md)))))