소스 검색

Merge branch 'enhance/ux-of-file-sync' into feat/add-age-encrypt-to-sync

Andelf 3 년 전
부모
커밋
1a6107194a
100개의 변경된 파일3764개의 추가작업 그리고 1671개의 파일을 삭제
  1. 1 3
      .carve/config.edn
  2. 6 11
      .clj-kondo/config.edn
  3. 1 3
      .github/workflows/build.yml
  4. 113 0
      .github/workflows/graph-parser.yml
  5. 5 1
      CODEBASE_OVERVIEW.md
  6. 2 2
      android/app/build.gradle
  7. 19 3
      bb.edn
  8. 3 3
      deps.edn
  9. 9 0
      deps/graph-parser/.carve/config.edn
  10. 4 0
      deps/graph-parser/.carve/ignore
  11. 13 0
      deps/graph-parser/.clj-kondo/config.edn
  12. 3 0
      deps/graph-parser/.gitignore
  13. 63 0
      deps/graph-parser/README.md
  14. 23 0
      deps/graph-parser/deps.edn
  15. 11 0
      deps/graph-parser/package.json
  16. 70 0
      deps/graph-parser/src/logseq/graph_parser.cljs
  17. 9 3
      deps/graph-parser/src/logseq/graph_parser/block.cljc
  18. 68 0
      deps/graph-parser/src/logseq/graph_parser/cli.cljs
  19. 60 0
      deps/graph-parser/src/logseq/graph_parser/config.cljs
  20. 2 2
      deps/graph-parser/src/logseq/graph_parser/date_time_util.cljs
  21. 15 0
      deps/graph-parser/src/logseq/graph_parser/db.cljs
  22. 1 1
      deps/graph-parser/src/logseq/graph_parser/db/default.cljs
  23. 1 1
      deps/graph-parser/src/logseq/graph_parser/db/schema.cljs
  24. 60 53
      deps/graph-parser/src/logseq/graph_parser/extract.cljc
  25. 0 0
      deps/graph-parser/src/logseq/graph_parser/log.cljs
  26. 1 1
      deps/graph-parser/src/logseq/graph_parser/mldoc.cljc
  27. 2 1
      deps/graph-parser/src/logseq/graph_parser/property.cljs
  28. 160 0
      deps/graph-parser/src/logseq/graph_parser/test/docs_graph_helper.cljs
  29. 1 119
      deps/graph-parser/src/logseq/graph_parser/text.cljs
  30. 1 6
      deps/graph-parser/src/logseq/graph_parser/utf8.cljs
  31. 2 5
      deps/graph-parser/src/logseq/graph_parser/util.cljs
  32. 2 1
      deps/graph-parser/test/logseq/graph_parser/block_test.cljs
  33. 13 0
      deps/graph-parser/test/logseq/graph_parser/cli_test.cljs
  34. 17 32
      deps/graph-parser/test/logseq/graph_parser/extract_test.cljs
  35. 7 6
      deps/graph-parser/test/logseq/graph_parser/mldoc_test.cljs
  36. 4 8
      deps/graph-parser/test/logseq/graph_parser/nbb_test_runner.cljs
  37. 0 0
      deps/graph-parser/test/logseq/graph_parser/property_test.cljs
  38. 0 30
      deps/graph-parser/test/logseq/graph_parser/text_test.cljs
  39. 411 0
      deps/graph-parser/yarn.lock
  40. 7 1
      docs/dev-practices.md
  41. 1 1
      docs/mobile.md
  42. 3 3
      e2e-tests/sidebar.spec.ts
  43. 4 4
      ios/App/App.xcodeproj/project.pbxproj
  44. 2 2
      package.json
  45. 4 4
      resources/css/common.css
  46. 9 0
      resources/css/shepherd.css
  47. 117 0
      resources/js/shepherd.min.js
  48. 2 2
      resources/package.json
  49. 1 0
      scripts/bump-version.sh
  50. 1 1
      scripts/carve.clj
  51. 9 5
      scripts/large_vars.clj
  52. 1 1
      scripts/src/logseq/tasks/dev.clj
  53. 75 45
      scripts/src/logseq/tasks/file_sync.clj
  54. 164 0
      scripts/src/logseq/tasks/file_sync_actions.clj
  55. 25 8
      scripts/src/logseq/tasks/nbb.clj
  56. 48 2
      src/electron/electron/core.cljs
  57. 4 2
      src/electron/electron/file_sync_rsapi.cljs
  58. 3 0
      src/electron/electron/handler.cljs
  59. 86 16
      src/main/frontend/components/block.cljs
  60. 2 7
      src/main/frontend/components/editor.cljs
  61. 2 2
      src/main/frontend/components/editor.css
  62. 22 16
      src/main/frontend/components/encryption.cljs
  63. 2 1
      src/main/frontend/components/export.cljs
  64. 4 4
      src/main/frontend/components/file.cljs
  65. 1 1
      src/main/frontend/components/file_sync.cljs
  66. 5 0
      src/main/frontend/components/file_sync.css
  67. 17 7
      src/main/frontend/components/header.cljs
  68. 111 94
      src/main/frontend/components/header.css
  69. 2 2
      src/main/frontend/components/journal.cljs
  70. 557 334
      src/main/frontend/components/onboarding/index.css
  71. 158 0
      src/main/frontend/components/onboarding/quick_tour.cljs
  72. 154 150
      src/main/frontend/components/page.cljs
  73. 15 15
      src/main/frontend/components/page.css
  74. 4 4
      src/main/frontend/components/repo.cljs
  75. 3 3
      src/main/frontend/components/select.cljs
  76. 99 84
      src/main/frontend/components/sidebar.cljs
  77. 71 37
      src/main/frontend/components/sidebar.css
  78. 2 2
      src/main/frontend/components/svg.cljs
  79. 4 38
      src/main/frontend/config.cljs
  80. 19 22
      src/main/frontend/db.cljs
  81. 7 26
      src/main/frontend/db/conn.cljs
  82. 5 88
      src/main/frontend/db/model.cljs
  83. 13 11
      src/main/frontend/db/query_dsl.cljs
  84. 5 3
      src/main/frontend/db/query_react.cljs
  85. 0 15
      src/main/frontend/db/react.cljs
  86. 352 18
      src/main/frontend/dicts.cljc
  87. 2 2
      src/main/frontend/diff.cljs
  88. 4 0
      src/main/frontend/extensions/pdf/pdf.css
  89. 6 3
      src/main/frontend/extensions/sci.cljs
  90. 0 5
      src/main/frontend/format.cljs
  91. 2 1
      src/main/frontend/format/block.cljs
  92. 277 151
      src/main/frontend/fs/sync.cljs
  93. 2 2
      src/main/frontend/fs/watcher_handler.cljs
  94. 1 1
      src/main/frontend/handler.cljs
  95. 1 3
      src/main/frontend/handler/common.cljs
  96. 29 26
      src/main/frontend/handler/editor.cljs
  97. 14 10
      src/main/frontend/handler/events.cljs
  98. 34 55
      src/main/frontend/handler/file.cljs
  99. 6 35
      src/main/frontend/handler/file_sync.cljs
  100. 1 1
      src/main/frontend/handler/graph.cljs

+ 1 - 3
.carve/config.edn

@@ -5,7 +5,5 @@
                   ;; Ignore b/c too many false positives
                   frontend.db
                   ;; Used for debugging
-                  frontend.db.debug
-                  ;; carve doesn't detect nbb only usage
-                  logseq.graph-parser.log]
+                  frontend.db.debug]
  :report {:format :ignore}}

+ 6 - 11
.clj-kondo/config.edn

@@ -2,13 +2,7 @@
  {:unresolved-symbol {:exclude [goog.DEBUG
                                 goog.string.unescapeEntities
                                 ;; TODO:lint: Fix when fixing all type hints
-                                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]}
+                                object]}
   ;; TODO:lint: Remove node-path excludes once we have a cleaner api
   :unresolved-var {:exclude [frontend.util/node-path.basename
                              frontend.util/node-path.dirname
@@ -26,10 +20,12 @@
              frontend.db.query-react query-react
              frontend.util util
              frontend.util.property property
+             frontend.util.text text-util
              frontend.config config
              frontend.format.mldoc mldoc
              frontend.format.block block
              frontend.handler.extract extract
+             logseq.graph-parser graph-parser
              logseq.graph-parser.text text
              logseq.graph-parser.block gp-block
              logseq.graph-parser.mldoc gp-mldoc
@@ -39,12 +35,10 @@
              logseq.graph-parser.date-time-util date-time-util}}}
 
  :hooks {:analyze-call {rum.core/defc hooks.rum/defc
-                         rum.core/defcs hooks.rum/defcs}}
+                        rum.core/defcs hooks.rum/defcs}}
  :lint-as {promesa.core/let clojure.core/let
            promesa.core/loop clojure.core/loop
            promesa.core/recur clojure.core/recur
-           garden.def/defstyles clojure.core/def
-           garden.def/defkeyframes clojure.core/def
            rum.core/defcc rum.core/defc
            rum.core/defcontext clojure.core/def
            clojure.test.check.clojure-test/defspec clojure.core/def
@@ -55,4 +49,5 @@
            frontend.namespaces/import-vars potemkin/import-vars
            ;; src/test
            frontend.react/defc clojure.core/defn}
- :skip-comments true}
+ :skip-comments true
+ :output {:progress true}}

+ 1 - 3
.github/workflows/build.yml

@@ -79,11 +79,9 @@ jobs:
           yarn cljs:test
           node static/tests.js
 
-      - name: Run nbb tests for graph-parser
-        run: yarn nbb-logseq -cp src/main:src/test -m logseq.graph-parser.nbb-test-runner/run-tests
       # In this job because it depends on an npm package
       - name: Load nbb compatible namespaces
-        run: bb test:load-nbb-compatible-namespaces
+        run: bb test:load-namespaces-with-nbb
 
   lint:
     runs-on: ubuntu-latest

+ 113 - 0
.github/workflows/graph-parser.yml

@@ -0,0 +1,113 @@
+name: logseq graph-parser CI
+
+on:
+  # Path filters ensure jobs only kick off if a change is made to graph-parser
+  push:
+    branches: [master]
+    paths:
+      - 'deps/graph-parser/**'
+      - '!deps/graph-parser/**.md'
+  pull_request:
+    branches: [master]
+    paths:
+      - 'deps/graph-parser/**'
+      - '!deps/graph-parser/**.md'
+
+env:
+  CLOJURE_VERSION: '1.10.1.727'
+  # setup-java@v2 dropped support for legacy Java version syntax.
+  # This is the same as 1.8.
+  JAVA_VERSION: '8'
+  # This is the latest node version we can run.
+  NODE_VERSION: '16'
+  BABASHKA_VERSION: '0.8.2'
+
+jobs:
+  test:
+    runs-on: ubuntu-latest
+
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v2
+
+      - name: Set up Node
+        uses: actions/setup-node@v2
+        with:
+          node-version: ${{ env.NODE_VERSION }}
+          cache: 'yarn'
+          cache-dependency-path: deps/graph-parser/yarn.lock
+
+      - name: Set up Java
+        uses: actions/setup-java@v2
+        with:
+          distribution: 'zulu'
+          java-version: ${{ env.JAVA_VERSION }}
+
+      - name: Set up Clojure
+        uses: DeLaGuardo/setup-clojure@master
+        with:
+          cli: ${{ env.CLOJURE_VERSION }}
+
+      - name: Setup Babashka
+        uses: turtlequeue/[email protected]
+        with:
+          babashka-version: ${{ env.BABASHKA_VERSION }}
+
+      - name: Clojure cache
+        uses: actions/cache@v2
+        id: clojure-deps
+        with:
+          path: |
+            ~/.m2/repository
+            ~/.gitlibs
+          key: ${{ runner.os }}-clojure-deps-${{ hashFiles('deps.edn') }}
+          restore-keys: ${{ runner.os }}-clojure-deps-
+
+      - name: Fetch Clojure deps
+        if: steps.clojure-deps.outputs.cache-hit != 'true'
+        run: cd deps/graph-parser && clojure -A:test -P
+
+      - name: Fetch yarn deps
+        run: cd deps/graph-parser && yarn install --frozen-lockfile
+
+      - name: Run ClojureScript tests
+        run: cd deps/graph-parser && clojure -M:test
+
+      - name: Run nbb-logseq tests
+        run: cd deps/graph-parser && yarn nbb-logseq -cp src:test -m logseq.graph-parser.nbb-test-runner/run-tests
+
+      # In this job because it depends on an npm package
+      - name: Load namespaces into nbb-logseq
+        run: bb test:load-all-namespaces-with-nbb deps/graph-parser src
+
+  lint:
+    runs-on: ubuntu-latest
+
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v2
+
+      - name: Set up Java
+        uses: actions/setup-java@v2
+        with:
+          distribution: 'zulu'
+          java-version: ${{ env.JAVA_VERSION }}
+
+      - name: Set up Clojure
+        uses: DeLaGuardo/setup-clojure@master
+        with:
+          cli: ${{ env.CLOJURE_VERSION }}
+
+      - name: Setup Babashka
+        uses: turtlequeue/[email protected]
+        with:
+          babashka-version: ${{ env.BABASHKA_VERSION }}
+
+      - name: Run clj-kondo lint
+        run: cd deps/graph-parser && clojure -M:clj-kondo --parallel --lint src test
+
+      - name: Carve lint for unused vars
+        run: cd deps/graph-parser && ../../scripts/carve.clj
+
+      - name: Lint for vars that are too large
+        run: scripts/large_vars.clj deps/graph-parser/src '{:max-lines-count 75}'

+ 5 - 1
CODEBASE_OVERVIEW.md

@@ -46,7 +46,11 @@ After cloning the [Logseq repository](https://github.com/logseq/logseq), there a
 
   - `src/main/frontend/` contains code that powers the Logseq editor. Folders and files inside are organized by features or functions. For example, `components` contains all the UI components and `handler` contains all the event-handling code. You can explore on your own interest.
 
-  - `src/main/logseq/` contains the api used by plugins and the graph-parser.
+  - `src/main/logseq/` contains the api used by plugins.
+
+- `deps/` contains dependencies or libraries used by the frontend.
+
+  - `deps/graph-parser/` is a library that parses a Logseq graph and saves it to a database.
 
 ## Data Flow
 

+ 2 - 2
android/app/build.gradle

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

+ 19 - 3
bb.edn

@@ -2,9 +2,16 @@
  :deps
  {org.babashka/spec.alpha
   {:git/url "https://github.com/babashka/spec.alpha"
-   :sha "1a841c4cc1d4f6dab7505a98ed2d532dd9d56b78"}}
+   :sha "1a841c4cc1d4f6dab7505a98ed2d532dd9d56b78"}
+  logseq/bb-tasks
+  #_{:local/root "../bb-tasks"}
+  {:git/url "https://github.com/logseq/bb-tasks"
+   :git/sha "4b3e623fb475cacb992425aa9dac770d6dd63e38"}
+  logseq/graph-parser
+  {:local/root "deps/graph-parser"}}
  :pods
- {clj-kondo/clj-kondo {:version "2022.02.09"}}
+ {clj-kondo/clj-kondo {:version "2022.02.09"}
+  org.babashka/fswatcher {:version "0.0.3"}}
  :tasks
  {dev:watch
   logseq.tasks.dev/watch
@@ -26,9 +33,18 @@
   dev:lint
   logseq.tasks.dev/lint
 
-  test:load-nbb-compatible-namespaces
+  nbb:watch
+  logseq.bb-tasks.nbb.watch/watch
+
+  nbb:portal-watch
+  logseq.bb-tasks.nbb.watch/portal-watch
+
+  test:load-namespaces-with-nbb
   logseq.tasks.nbb/load-compatible-namespaces
 
+  test:load-all-namespaces-with-nbb
+  logseq.tasks.nbb/load-all-namespaces
+
   lang:list
   logseq.tasks.lang/list-langs
 

+ 3 - 3
deps.edn

@@ -29,8 +29,8 @@
   camel-snake-kebab/camel-snake-kebab   {:mvn/version "0.4.2"}
   instaparse/instaparse                 {:mvn/version "1.4.10"}
   nubank/workspaces                     {:mvn/version "1.1.1"}
-  frankiesardo/linked                   {:mvn/version "1.3.0"}
-  org.clojars.mmb90/cljs-cache          {:mvn/version "0.1.4"}}
+  org.clojars.mmb90/cljs-cache          {:mvn/version "0.1.4"}
+  logseq/graph-parser                   {:local/root "deps/graph-parser"}}
 
  :aliases {:cljs {:extra-paths ["src/dev-cljs/" "src/test/" "src/electron/"]
                   :extra-deps  {org.clojure/clojurescript        {:mvn/version "1.11.54"}
@@ -47,5 +47,5 @@
                   :main-opts   ["-m" "shadow.cljs.devtools.cli"]}
 
            ;; Use :replace-deps for tools. See https://github.com/clj-kondo/clj-kondo/issues/1536#issuecomment-1013006889
-           :clj-kondo {:replace-deps {clj-kondo/clj-kondo {:mvn/version "2022.01.13"}}
+           :clj-kondo {:replace-deps {clj-kondo/clj-kondo {:mvn/version "2022.05.28"}}
                        :main-opts  ["-m" "clj-kondo.main"]}}}

+ 9 - 0
deps/graph-parser/.carve/config.edn

@@ -0,0 +1,9 @@
+{:paths ["src"]
+ :api-namespaces [
+                  ;; carve doesn't detect nbb only usage
+                  logseq.graph-parser.log
+                  ;; Used by logseq but not worth splitting up
+                  logseq.graph-parser.db.schema
+                  ;; Used in tests
+                  logseq.graph-parser.test.docs-graph-helper]
+ :report {:format :ignore}}

+ 4 - 0
deps/graph-parser/.carve/ignore

@@ -0,0 +1,4 @@
+;; For CLI
+logseq.graph-parser.cli/parse-graph
+;; For CLI
+logseq.graph-parser.mldoc/ast-export-markdown

+ 13 - 0
deps/graph-parser/.clj-kondo/config.edn

@@ -0,0 +1,13 @@
+{:linters
+ {:consistent-alias
+  {:aliases {datascript.core d
+             logseq.graph-parser graph-parser
+             logseq.graph-parser.text text
+             logseq.graph-parser.block gp-block
+             logseq.graph-parser.mldoc gp-mldoc
+             logseq.graph-parser.util gp-util
+             logseq.graph-parser.property gp-property
+             logseq.graph-parser.config gp-config
+             logseq.graph-parser.date-time-util date-time-util}}}
+ :skip-comments true
+ :output {:progress true}}

+ 3 - 0
deps/graph-parser/.gitignore

@@ -0,0 +1,3 @@
+/.clj-kondo/.cache
+cljs-test-runner-out
+/test/docs

+ 63 - 0
deps/graph-parser/README.md

@@ -0,0 +1,63 @@
+## Description
+
+This library parses a logseq graph directory and returns it as a datascript
+database connection. This library powers the Logseq app and also runs from the
+commandline, _independent_ of the app. This is powerful as this can run anywhere
+that a Node.js script has access to a Logseq graph e.g. on CI processes like
+Github Actions. This library is compatible with ClojureScript and with
+[nbb-logseq](https://github.com/logseq/nbb-logseq) to respectively provide
+frontend and commandline functionality.
+
+## API
+
+This library is under the parent namespace `logseq.graph-parser`. This library
+provides two main namespaces for parsing, `logseq.graph-parser` and
+`logseq.graph-parser.cli`. `logseq.graph-parser/parse-file` is the main fn for
+the frontend. `logseq.graph-parser.cli/parse-graph` is the main fn for node.js
+CLIs.
+
+## Usage
+
+See `logseq.graph-parser.cli-test` for now. A real world example is coming soon.
+
+## Dev
+
+This follows the practices that [the Logseq frontend
+follows](/docs/dev-practices.md). Most of the same linters are used, with
+configurations that are specific to this library. See [this library's CI
+file](/.github/workflows/graph-parser.yml) for linting examples.
+
+### Setup
+
+To run linters and tests, you'll want to install yarn dependencies once:
+```
+yarn install
+```
+
+This step is not needed if you're just running the application.
+
+### Testing
+
+Since this file is compatible with cljs and nbb-logseq, tests are run against both languages.
+
+ClojureScript tests use https://github.com/Olical/cljs-test-runner. To run tests:
+```
+clojure -M:test
+```
+
+To see available options that can run specific tests or namespaces: `clojure -M:test --help`
+
+To run nbb-logseq tests:
+```
+yarn nbb-logseq -cp src:test -m logseq.graph-parser.nbb-test-runner/run-tests
+```
+
+### Managing dependencies
+
+The package.json dependencies are just for testing and should be updated if there is
+new behavior to test.
+
+The deps.edn dependecies are used by both ClojureScript and nbb-logseq. Their
+versions should be backwards compatible with each other with priority given to
+the frontend. _No new dependency_ should be introduced to this library without
+an understanding of the tradeoffs of adding this to nbb-logseq.

+ 23 - 0
deps/graph-parser/deps.edn

@@ -0,0 +1,23 @@
+{:paths ["src"]
+ :deps
+ ;; Deps should be kept in sync with https://github.com/logseq/nbb-logseq/blob/main/bb.edn
+ {datascript/datascript {:mvn/version "1.3.8"}
+  frankiesardo/linked {:mvn/version "1.3.0"}
+  com.andrewmcveigh/cljs-time {:git/url "https://github.com/logseq/cljs-time" ;; fork
+                               :sha     "5704fbf48d3478eedcf24d458c8964b3c2fd59a9"}
+  ;; stubbed in nbb
+  com.lambdaisland/glogi {:mvn/version "1.1.144"}
+  ;; built in to nbb
+  cljs-bean/cljs-bean {:mvn/version "1.5.0"}}
+
+ :aliases
+ ;; This runs tests with nodejs. Would be nice to run this with in a browser env
+ ;; since this is how its normally run in the app but this requires more setup
+ ;; with karma, shadow-cljs.edn and headless mode on CI
+ {:test {:extra-paths ["test"]
+         :extra-deps {olical/cljs-test-runner {:mvn/version "3.8.0"}
+                      org.clojure/clojurescript {:mvn/version "1.11.54"}}
+         :main-opts ["-m" "cljs-test-runner.main"]}
+
+  :clj-kondo {:replace-deps {clj-kondo/clj-kondo {:mvn/version "2022.05.28"}}
+              :main-opts  ["-m" "clj-kondo.main"]}}}

+ 11 - 0
deps/graph-parser/package.json

@@ -0,0 +1,11 @@
+{
+  "name": "@logseq/graph-parser",
+  "version": "1.0.0",
+  "private": true,
+  "devDependencies": {
+    "@logseq/nbb-logseq": "^0.5.103"
+  },
+  "dependencies": {
+    "mldoc": "^1.3.3"
+  }
+}

+ 70 - 0
deps/graph-parser/src/logseq/graph_parser.cljs

@@ -0,0 +1,70 @@
+(ns logseq.graph-parser
+  "Main ns used by logseq app to parse graph from source files"
+  (:require [datascript.core :as d]
+            [logseq.graph-parser.extract :as extract]
+            [logseq.graph-parser.util :as gp-util]
+            [logseq.graph-parser.date-time-util :as date-time-util]
+            [logseq.graph-parser.config :as gp-config]
+            [clojure.string :as string]
+            [clojure.set :as set]))
+
+(defn- db-set-file-content!
+  "Modified copy of frontend.db.model/db-set-file-content!"
+  [conn path content]
+  (let [tx-data {:file/path path
+                 :file/content content}]
+    (d/transact! conn [tx-data] {:skip-refresh? true})))
+
+(defn parse-file
+  "Parse file and save parsed data to the given db. Main parse fn used by logseq app"
+  [conn file content {:keys [new? delete-blocks-fn extract-options]
+                      :or {new? true
+                           delete-blocks-fn (constantly [])}
+                      :as options}]
+  (db-set-file-content! conn file content)
+  (let [format (gp-util/get-format file)
+        file-content [{:file/path file}]
+        tx (if (contains? gp-config/mldoc-support-formats format)
+             (let [extract-options' (merge {:block-pattern (gp-config/get-block-pattern format)
+                                            :date-formatter "MMM do, yyyy"
+                                            :supported-formats (gp-config/supported-formats)}
+                                           extract-options
+                                           {:db @conn})
+                   [pages blocks]
+                   (extract/extract-blocks-pages file content extract-options')
+                   delete-blocks (delete-blocks-fn (first pages) file)
+                   block-ids (map (fn [block] {:block/uuid (:block/uuid block)}) blocks)
+                   block-refs-ids (->> (mapcat :block/refs blocks)
+                                       (filter (fn [ref] (and (vector? ref)
+                                                              (= :block/uuid (first ref)))))
+                                       (map (fn [ref] {:block/uuid (second ref)}))
+                                       (seq))
+                   ;; To prevent "unique constraint" on datascript
+                   block-ids (set/union (set block-ids) (set block-refs-ids))
+                   pages (extract/with-ref-pages pages blocks)
+                   pages-index (map #(select-keys % [:block/name]) pages)]
+               ;; does order matter?
+               (concat file-content pages-index delete-blocks pages block-ids blocks))
+             file-content)
+        tx (concat tx [(cond-> {:file/path file}
+                               new?
+                               ;; TODO: use file system timestamp?
+                               (assoc :file/created-at (date-time-util/time-ms)))])]
+    (d/transact! conn (gp-util/remove-nils tx) (select-keys options [:new-graph? :from-disk?]))))
+
+(defn filter-files
+  "Filters files in preparation for parsing. Only includes files that are
+  supported by parser"
+  [files]
+  (let [support-files (filter
+                       (fn [file]
+                         (let [format (gp-util/get-format (:file/path file))]
+                           (contains? (set/union #{:edn :css} gp-config/mldoc-support-formats) format)))
+                       files)
+        support-files (sort-by :file/path support-files)
+        {journals true non-journals false} (group-by (fn [file] (string/includes? (:file/path file) "journals/")) support-files)
+        {built-in true others false} (group-by (fn [file]
+                                                 (or (string/includes? (:file/path file) "contents.")
+                                                     (string/includes? (:file/path file) ".edn")
+                                                     (string/includes? (:file/path file) "custom.css"))) non-journals)]
+    (concat (reverse journals) built-in others)))

+ 9 - 3
src/main/logseq/graph_parser/block.cljc → deps/graph-parser/src/logseq/graph_parser/block.cljc

@@ -1,4 +1,4 @@
-(ns ^:nbb-compatible logseq.graph-parser.block
+(ns logseq.graph-parser.block
   ;; Disable clj linters since we don't support clj
   #?(:clj {:clj-kondo/config {:linters {:unresolved-namespace {:level :off}
                                         :unresolved-symbol {:level :off}}}})
@@ -174,8 +174,13 @@
                                            k)
                                        v (if (coll? v)
                                            (remove string/blank? v)
-                                           (if (string/blank? v)
+                                           (cond
+                                             (string/blank? v)
                                              nil
+                                             (and (= (keyword k) :file-path)
+                                                  (string/starts-with? v "file:"))
+                                             v
+                                             :else
                                              (text/parse-property format k v user-config)))
                                        k (keyword k)
                                        v (if (and
@@ -426,7 +431,8 @@
   (or (when-let [custom-id (or (get-in properties [:properties :custom-id])
                                (get-in properties [:properties :custom_id])
                                (get-in properties [:properties :id]))]
-        (let [custom-id (and (string? custom-id) (string/trim custom-id))]
+        ;; guard against non-string custom-ids
+        (when-let [custom-id (and (string? custom-id) (string/trim custom-id))]
           (some-> custom-id parse-uuid)))
       (d/squuid)))
 

+ 68 - 0
deps/graph-parser/src/logseq/graph_parser/cli.cljs

@@ -0,0 +1,68 @@
+(ns logseq.graph-parser.cli
+  "Primary ns to parse graphs with node.js based CLIs"
+  (:require ["fs" :as fs]
+            ["child_process" :as child-process]
+            [clojure.edn :as edn]
+            [clojure.string :as string]
+            [logseq.graph-parser :as graph-parser]
+            [logseq.graph-parser.config :as gp-config]
+            [logseq.graph-parser.db :as gp-db]))
+
+(defn slurp
+  "Return file contents like clojure.core/slurp"
+  [file]
+  (str (fs/readFileSync file)))
+
+(defn sh
+  "Run shell cmd synchronously and print to inherited streams by default. Aims
+    to be similar to babashka.tasks/shell
+TODO: Fail fast when process exits 1"
+  [cmd opts]
+  (child-process/spawnSync (first cmd)
+                           (clj->js (rest cmd))
+                           (clj->js (merge {:stdio "inherit"} opts))))
+
+(defn build-graph-files
+  "Given a git graph directory, returns allowed file paths and their contents in
+  preparation for parsing"
+  [dir]
+  (let [files (->> (str (.-stdout (sh ["git" "ls-files"]
+                                      {:cwd dir :stdio nil})))
+                   string/split-lines
+                   (map #(hash-map :file/path (str dir "/" %)))
+                   graph-parser/filter-files)]
+    (mapv #(assoc % :file/content (slurp (:file/path %))) files)))
+
+(defn- read-config
+  "Commandline version of frontend.handler.common/read-config without graceful
+  handling of broken config. Config is assumed to be at $dir/logseq/config.edn "
+  [dir]
+  (let [config-file (str dir "/" gp-config/app-name "/config.edn")]
+    (if (fs/existsSync config-file)
+     (-> config-file fs/readFileSync str edn/read-string)
+     {})))
+
+(defn- parse-files
+  [conn files {:keys [config] :as options}]
+  (let [extract-options (merge {:date-formatter (gp-config/get-date-formatter config)}
+                               (select-keys options [:verbose]))]
+    (doseq [{:file/keys [path content]} files]
+      (graph-parser/parse-file conn path content {:extract-options extract-options}))))
+
+(defn parse-graph
+  "Parses a given graph directory and returns a datascript connection and all
+  files that were processed. The directory is parsed as if it were a new graph
+  as it can't assume that the metadata in logseq/ is up to date. Directory is
+  assumed to be using git. This fn takes the following options:
+* :verbose - When enabled prints more information during parsing. Defaults to true
+* :files - Specific files to parse instead of parsing the whole directory"
+  ([dir]
+   (parse-graph dir {}))
+  ([dir options]
+   (let [files (or (:files options) (build-graph-files dir))
+         conn (gp-db/start-conn)
+         config (read-config dir)]
+     (when-not (:files options) (println "Parsing" (count files) "files..."))
+     (parse-files conn files (merge options {:config config}))
+     {:conn conn
+      :files (map :file/path files)})))

+ 60 - 0
deps/graph-parser/src/logseq/graph_parser/config.cljs

@@ -0,0 +1,60 @@
+(ns logseq.graph-parser.config
+  "Config that is shared between graph-parser and rest of app"
+  (:require [logseq.graph-parser.util :as gp-util]
+            [clojure.set :as set]
+            [clojure.string :as string]))
+
+(def app-name
+  "Copy of frontend.config/app-name. Too small to couple to main app"
+  "logseq")
+
+(defonce local-assets-dir "assets")
+
+(defn local-asset?
+  [s]
+  (gp-util/safe-re-find (re-pattern (str "^[./]*" local-assets-dir)) s))
+
+(defonce default-draw-directory "draws")
+
+(defn draw?
+  [path]
+  (string/starts-with? path default-draw-directory))
+
+;; TODO: rename
+(defonce mldoc-support-formats
+  #{:org :markdown :md})
+
+(defn mldoc-support?
+  [format]
+  (contains? mldoc-support-formats (keyword format)))
+
+(defn text-formats
+  []
+  #{:json :org :md :yml :dat :asciidoc :rst :txt :markdown :adoc :html :js :ts :edn :clj :ml :rb :ex :erl :java :php :c :css
+    :excalidraw})
+
+(defn img-formats
+  []
+  #{:gif :svg :jpeg :ico :png :jpg :bmp :webp})
+
+(defn supported-formats
+  []
+  (set/union (text-formats)
+             (img-formats)))
+
+(defn get-date-formatter
+  [config]
+  (or
+   (:journal/page-title-format config)
+   ;; for compatibility
+   (:date-formatter config)
+   "MMM do, yyyy"))
+
+(defn get-block-pattern
+  [format]
+  (let [format' (keyword format)]
+    (case format'
+      :org
+      "*"
+
+      "-")))

+ 2 - 2
src/main/logseq/graph_parser/date_time_util.cljs → deps/graph-parser/src/logseq/graph_parser/date_time_util.cljs

@@ -1,4 +1,4 @@
-(ns ^:nbb-compatible logseq.graph-parser.date-time-util
+(ns logseq.graph-parser.date-time-util
   "cljs-time util fns for graph-parser"
   (:require [cljs-time.coerce :as tc]
             [cljs-time.core :as t]
@@ -25,7 +25,7 @@
                           (fn [formatter]
                             (try
                               (tf/parse (tf/formatter formatter) (gp-util/capitalize-all journal-title))
-                              (catch js/Error _e
+                              (catch :default _e
                                 nil)))
                           formatters)
                          (filter some?)

+ 15 - 0
deps/graph-parser/src/logseq/graph_parser/db.cljs

@@ -0,0 +1,15 @@
+(ns logseq.graph-parser.db
+  (:require [logseq.graph-parser.db.default :as default-db]
+            [logseq.graph-parser.db.schema :as db-schema]
+            [datascript.core :as d]))
+
+(defn start-conn
+  "Create datascript conn with schema and default data"
+  []
+  (let [db-conn (d/create-conn db-schema/schema)]
+    (d/transact! db-conn [{:schema/version db-schema/version}
+                          {:block/name "card"
+                           :block/original-name "card"
+                           :block/uuid (d/squuid)}])
+    (d/transact! db-conn default-db/built-in-pages)
+    db-conn))

+ 1 - 1
src/main/frontend/db/default.cljs → deps/graph-parser/src/logseq/graph_parser/db/default.cljs

@@ -1,4 +1,4 @@
-(ns ^:nbb-compatible frontend.db.default
+(ns logseq.graph-parser.db.default
   (:require [clojure.string :as string]))
 
 (defonce built-in-pages-names

+ 1 - 1
src/main/frontend/db_schema.cljs → deps/graph-parser/src/logseq/graph_parser/db/schema.cljs

@@ -1,4 +1,4 @@
-(ns ^:nbb-compatible frontend.db-schema)
+(ns logseq.graph-parser.db.schema)
 
 (defonce version 1)
 (defonce ast-version 1)

+ 60 - 53
src/main/logseq/graph_parser/extract.cljc → deps/graph-parser/src/logseq/graph_parser/extract.cljc

@@ -1,4 +1,4 @@
-(ns ^:nbb-compatible logseq.graph-parser.extract
+(ns logseq.graph-parser.extract
   ;; Disable clj linters since we don't support clj
   #?(:clj {:clj-kondo/config {:linters {:unresolved-namespace {:level :off}
                                         :unresolved-symbol {:level :off}}}})
@@ -39,12 +39,57 @@
               (or first-block-name file-name)
               (or file-name first-block-name)))))))
 
+(defn- build-page-entity
+  [properties file page-name page ref-tags {:keys [date-formatter db]}]
+  (let [alias (:alias properties)
+        alias (if (string? alias) [alias] alias)
+        aliases (and alias
+                     (seq (remove #(or (= page-name (gp-util/page-name-sanity-lc %))
+                                       (string/blank? %)) ;; disable blank alias
+                                  alias)))
+        aliases (->>
+                 (map
+                  (fn [alias]
+                    (let [page-name (gp-util/page-name-sanity-lc alias)
+                          aliases (distinct
+                                   (conj
+                                    (remove #{alias} aliases)
+                                    page))
+                          aliases (when (seq aliases)
+                                    (map
+                                     (fn [alias]
+                                       {:block/name (gp-util/page-name-sanity-lc alias)})
+                                     aliases))]
+                      (if (seq aliases)
+                        {:block/name page-name
+                         :block/alias aliases}
+                        {:block/name page-name})))
+                  aliases)
+                 (remove nil?))]
+    (cond->
+     (gp-util/remove-nils
+      (assoc
+       (gp-block/page-name->map page false db true date-formatter)
+       :block/file {:file/path (gp-util/path-normalize file)}))
+     (seq properties)
+     (assoc :block/properties properties)
+
+     (seq aliases)
+     (assoc :block/alias aliases)
+
+     (:tags properties)
+     (assoc :block/tags (let [tags (:tags properties)
+                              tags (if (string? tags) [tags] tags)
+                              tags (remove string/blank? tags)]
+                          (swap! ref-tags set/union (set tags))
+                          (map (fn [tag] {:block/name (gp-util/page-name-sanity-lc tag)
+                                          :block/original-name tag})
+                               tags))))))
 
 ;; TODO: performance improvement
 (defn- extract-pages-and-blocks
   [format ast properties file content {:keys [date-formatter page-name-order db] :as options}]
   (try
-    #_:clj-kondo/ignore ;;clj-kondo bug
     (let [page (get-page-name file ast page-name-order)
           [_original-page-name page-name _journal-day] (gp-block/convert-page-if-journal page date-formatter)
           blocks (->> (gp-block/extract-blocks ast content false format (dissoc options :page-name-order))
@@ -65,50 +110,7 @@
                                      :block/refs block-ref-pages
                                      :block/path-refs block-path-ref-pages))))
                       blocks)
-          page-entity (let [alias (:alias properties)
-                            alias (if (string? alias) [alias] alias)
-                            aliases (and alias
-                                         (seq (remove #(or (= page-name (gp-util/page-name-sanity-lc %))
-                                                           (string/blank? %)) ;; disable blank alias
-                                                      alias)))
-                            aliases (->>
-                                     (map
-                                      (fn [alias]
-                                        (let [page-name (gp-util/page-name-sanity-lc alias)
-                                              aliases (distinct
-                                                       (conj
-                                                        (remove #{alias} aliases)
-                                                        page))
-                                              aliases (when (seq aliases)
-                                                        (map
-                                                         (fn [alias]
-                                                           {:block/name (gp-util/page-name-sanity-lc alias)})
-                                                         aliases))]
-                                          (if (seq aliases)
-                                            {:block/name page-name
-                                             :block/alias aliases}
-                                            {:block/name page-name})))
-                                      aliases)
-                                     (remove nil?))]
-                        (cond->
-                         (gp-util/remove-nils
-                          (assoc
-                           (gp-block/page-name->map page false db true date-formatter)
-                           :block/file {:file/path (gp-util/path-normalize file)}))
-                         (seq properties)
-                         (assoc :block/properties properties)
-
-                         (seq aliases)
-                         (assoc :block/alias aliases)
-
-                         (:tags properties)
-                         (assoc :block/tags (let [tags (:tags properties)
-                                                  tags (if (string? tags) [tags] tags)
-                                                  tags (remove string/blank? tags)]
-                                              (swap! ref-tags set/union (set tags))
-                                              (map (fn [tag] {:block/name (gp-util/page-name-sanity-lc tag)
-                                                              :block/original-name tag})
-                                                   tags)))))
+          page-entity (build-page-entity properties file page-name page ref-tags options)
           namespace-pages (let [page (:block/original-name page-entity)]
                             (when (text/namespace-page? page)
                               (->> (gp-util/split-namespace-pages page)
@@ -137,21 +139,23 @@
       (log/error :exception e))))
 
 (defn extract-blocks-pages
-  [file content {:keys [user-config] :as options}]
+  [file content {:keys [user-config verbose] :or {verbose true} :as options}]
   (if (string/blank? content)
     []
     (let [format (gp-util/get-format file)
-          _ (println "Parsing start: " file)
+          _ (when verbose (println "Parsing start: " file))
           ast (gp-mldoc/->edn content (gp-mldoc/default-config format
                                                          ;; {:parse_outline_only? true}
                                                          )
                            user-config)]
-      (println "Parsing finished : " file)
+      (when verbose (println "Parsing finished: " file))
       (let [first-block (ffirst ast)
             properties (let [properties (and (gp-property/properties-ast? first-block)
                                              (->> (last first-block)
                                                   (map (fn [[x y]]
-                                                         [x (if (string? y)
+                                                         [x (if (and (string? y)
+                                                                     (not (and (= (keyword x) :file-path)
+                                                                               (string/starts-with? y "file:"))))
                                                               (text/parse-property format x y user-config)
                                                               y)]))
                                                   (into {})
@@ -184,6 +188,9 @@
          (map (partial apply merge))
          (with-block-uuid))))
 
-(defn extract-all-block-refs
-  [content]
-  (map second (re-seq #"\(\(([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12})\)\)" content)))
+#?(:org.babashka/nbb
+   (alter-var-root #'gp-mldoc/parse-property (constantly text/parse-property))
+   :default
+   ;; TODO: Properly fix this circular dependency:
+   ;; mldoc/->edn > text/parse-property > mldoc/link? ->mldoc/inline->edn + mldoc/default-config
+   (set! gp-mldoc/parse-property text/parse-property))

+ 0 - 0
src/main/logseq/graph_parser/log.cljs → deps/graph-parser/src/logseq/graph_parser/log.cljs


+ 1 - 1
src/main/logseq/graph_parser/mldoc.cljc → deps/graph-parser/src/logseq/graph_parser/mldoc.cljc

@@ -1,4 +1,4 @@
-(ns ^:nbb-compatible logseq.graph-parser.mldoc
+(ns logseq.graph-parser.mldoc
   ;; Disable clj linters since we don't support clj
   #?(:clj {:clj-kondo/config {:linters {:unresolved-namespace {:level :off}
                                         :unresolved-symbol {:level :off}}}})

+ 2 - 1
src/main/logseq/graph_parser/property.cljs → deps/graph-parser/src/logseq/graph_parser/property.cljs

@@ -2,7 +2,8 @@
   "Property fns needed by graph-parser"
   (:require [logseq.graph-parser.util :as gp-util]
             [clojure.string :as string]
-            [goog.string :as gstring]))
+            [goog.string :as gstring]
+            [goog.string.format]))
 
 (defn properties-ast?
   [block]

+ 160 - 0
deps/graph-parser/src/logseq/graph_parser/test/docs_graph_helper.cljs

@@ -0,0 +1,160 @@
+(ns logseq.graph-parser.test.docs-graph-helper
+  "Helper fns for setting up and running tests against docs graph"
+  (:require ["fs" :as fs]
+            ["child_process" :as child-process]
+            [cljs.test :refer [is testing]]
+            [clojure.string :as string]
+            [logseq.graph-parser.config :as gp-config]
+            [datascript.core :as d]))
+
+;; Helper fns for test setup
+;; =========================
+(defn- sh
+  "Run shell cmd synchronously and print to inherited streams by default. Aims
+    to be similar to babashka.tasks/shell"
+  [cmd opts]
+  (child-process/spawnSync (first cmd)
+                           (clj->js (rest cmd))
+                           (clj->js (merge {:stdio "inherit"} opts))))
+
+(defn clone-docs-repo-if-not-exists
+  [dir]
+  (when-not (.existsSync fs dir)
+    (sh ["git" "clone" "--depth" "1" "-b" "v0.6.7" "-c" "advice.detachedHead=false"
+         "https://github.com/logseq/docs" dir] {})))
+
+
+;; Fns for common test assertions
+;; ==============================
+(defn- get-top-block-properties
+  [db]
+  (->> (d/q '[:find (pull ?b [*])
+              :where
+              [?b :block/properties]
+              [(missing? $ ?b :block/name)]]
+            db)
+       (map first)
+       (map (fn [m] (zipmap (keys (:block/properties m)) (repeat 1))))
+       (apply merge-with +)
+       (filter #(>= (val %) 5))
+       (into {})))
+
+(defn- get-all-page-properties
+  [db]
+  (->> (d/q '[:find (pull ?b [*])
+              :where
+              [?b :block/properties]
+              [?b :block/name]]
+            db)
+       (map first)
+       (map (fn [m] (zipmap (keys (:block/properties m)) (repeat 1))))
+       (apply merge-with +)
+       (into {})))
+
+(defn- get-block-format-counts
+  [db]
+  (->> (d/q '[:find (pull ?b [*]) :where [?b :block/format]] db)
+       (map first)
+       (group-by :block/format)
+       (map (fn [[k v]] [k (count v)]))
+       (into {})))
+
+(defn- query-assertions
+  [db files]
+  (testing "Query based stats"
+    (is (= (->> files
+                ;; logseq files aren't saved under :block/file
+                (remove #(string/includes? % (str "/" gp-config/app-name "/")))
+                set)
+           (->> (d/q '[:find (pull ?b [* {:block/file [:file/path]}])
+                       :where [?b :block/name] [?b :block/file]]
+                     db)
+                (map (comp #(get-in % [:block/file :file/path]) first))
+                set))
+        "Files on disk should equal ones in db")
+
+    (is (= (count (filter #(re-find #"journals/" %) files))
+           (->> (d/q '[:find (count ?b)
+                       :where
+                       [?b :block/journal? true]
+                       [?b :block/name]
+                       [?b :block/file]]
+                     db)
+                ffirst))
+        "Journal page count on disk equals count in db")
+
+    (is (= {"CANCELED" 2 "DONE" 6 "LATER" 4 "NOW" 5}
+           (->> (d/q '[:find (pull ?b [*]) :where [?b :block/marker] ]
+                     db)
+                (map first)
+                (group-by :block/marker)
+                (map (fn [[k v]] [k (count v)]))
+                (into {})))
+        "Task marker counts")
+
+    (is (= {:markdown 3143 :org 460}
+           (get-block-format-counts db))
+        "Block format counts")
+
+    (is (= {:title 98 :id 98
+            :updated-at 47 :created-at 47
+            :card-last-score 6 :card-repeats 6 :card-next-schedule 6
+            :card-last-interval 6 :card-ease-factor 6 :card-last-reviewed 6
+            :alias 6}
+           (get-top-block-properties db))
+        "Counts for top block properties")
+
+    (is (= {:title 98
+            :alias 6
+            :tags 2 :permalink 2
+            :name 1 :type 1 :related 1 :sample 1 :click 1 :id 1 :example 1}
+           (get-all-page-properties db))
+        "Counts for all page properties")
+
+    (is (= {:block/scheduled 2
+            :block/priority 4
+            :block/deadline 1
+            :block/collapsed? 22
+            :block/heading-level 60
+            :block/repeated? 1}
+           (->> [:block/scheduled :block/priority :block/deadline :block/collapsed?
+                 :block/heading-level :block/repeated?]
+                (map (fn [attr]
+                       [attr
+                        (ffirst (d/q [:find (list 'count '?b) :where ['?b attr]]
+                                     db))]))
+                (into {})))
+        "Counts for blocks with common block attributes")
+
+    (is (= #{"term" "setting" "book" "Templates" "Query" "Query/table" "page"}
+           (->> (d/q '[:find (pull ?n [*]) :where [?b :block/namespace ?n]] db)
+                (map (comp :block/original-name first))
+                set))
+        "Has correct namespaces")))
+
+(defn docs-graph-assertions
+  "These are common assertions that should pass in both graph-parser and main
+  logseq app. It is important to run these in both contexts to ensure that the
+  functionality in frontend.handler.repo and logseq.graph-parser remain the
+  same"
+  [db files]
+  ;; Counts assertions help check for no major regressions. These counts should
+  ;; only increase over time as the docs graph rarely has deletions
+  (testing "Counts"
+    (is (= 211 (count files)) "Correct file count")
+    (is (= 40943 (count (d/datoms db :eavt))) "Correct datoms count")
+
+    (is (= 3600
+           (ffirst
+            (d/q '[:find (count ?b)
+                   :where [?b :block/path-refs ?bp] [?bp :block/name]] db)))
+        "Correct referenced blocks count")
+    (is (= 21
+           (ffirst
+            (d/q '[:find (count ?b)
+                   :where [?b :block/content ?content]
+                   [(clojure.string/includes? ?content "+BEGIN_QUERY")]]
+                 db)))
+        "Advanced query count"))
+
+  (query-assertions db files))

+ 1 - 119
src/main/logseq/graph_parser/text.cljs → deps/graph-parser/src/logseq/graph_parser/text.cljs

@@ -1,4 +1,4 @@
-(ns ^:nbb-compatible logseq.graph-parser.text
+(ns logseq.graph-parser.text
   (:require ["path" :as path]
             [goog.string :as gstring]
             [clojure.string :as string]
@@ -51,8 +51,6 @@
 
 (def page-ref-re-without-nested #"\[\[([^\[\]]+)\]\]")
 
-(defonce between-re #"\(between ([^\)]+)\)")
-
 (defn page-ref-un-brackets!
   [s]
   (or (get-page-name s) s))
@@ -122,18 +120,6 @@
   [s]
   (string/split s #"(\"[^\"]*\")"))
 
-(def bilibili-regex #"^((?:https?:)?//)?((?:www).)?((?:bilibili.com))(/(?:video/)?)([\w-]+)(\S+)?$")
-(def loom-regex #"^((?:https?:)?//)?((?:www).)?((?:loom.com))(/(?:share/|embed/))([\w-]+)(\S+)?$")
-(def vimeo-regex #"^((?:https?:)?//)?((?:www).)?((?:player.vimeo.com|vimeo.com))(/(?:video/)?)([\w-]+)(\S+)?$")
-(def youtube-regex #"^((?:https?:)?//)?((?:www|m).)?((?:youtube.com|youtu.be|y2u.be|youtube-nocookie.com))(/(?:[\w-]+\?v=|embed/|v/)?)([\w-]+)([\S^\?]+)?$")
-
-(defn get-matched-video
-  [url]
-  (or (re-find youtube-regex url)
-      (re-find loom-regex url)
-      (re-find vimeo-regex url)
-      (re-find bilibili-regex url)))
-
 (def markdown-link #"\[([^\[]+)\](\(.*\))")
 
 (defn split-page-refs-without-brackets
@@ -228,16 +214,6 @@
        :else
        (remove-level-space-aux! text block-pattern space? trim-left?)))))
 
-(defn build-data-value
-  [col]
-  (let [items (map (fn [item] (str "\"" item "\"")) col)]
-    (gstring/format "[%s]"
-                 (string/join ", " items))))
-
-(defn media-link?
-  [media-formats s]
-  (some (fn [fmt] (gp-util/safe-re-find (re-pattern (str "(?i)\\." fmt "(?:\\?([^#]*))?(?:#(.*))?$")) s)) media-formats))
-
 (defn namespace-page?
   [p]
   (and (string? p)
@@ -246,100 +222,6 @@
        (not (string/starts-with? p "./"))
        (not (gp-util/url? p))))
 
-(defn add-timestamp
-  [content key value]
-  (let [new-line (str (string/upper-case key) ": " value)
-        lines (string/split-lines content)
-        new-lines (map (fn [line]
-                         (string/trim
-                          (if (string/starts-with? (string/lower-case line) key)
-                            new-line
-                            line)))
-                    lines)
-        new-lines (if (not= (map string/trim lines) new-lines)
-                    new-lines
-                    (cons (first new-lines) ;; title
-                          (cons
-                           new-line
-                           (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)
-        result (reduce (fn [acc line]
-                         (let [new-pos (+ acc (count line))]
-                           (if (>= new-pos pos)
-                             (reduced line)
-                             (inc new-pos)))) 0 lines)]
-    (when (string? result)
-      result)))
-
-(defn get-string-all-indexes
-  "Get all indexes of `value` in the string `s`."
-  [s value]
-  (loop [acc []
-         i 0]
-    (if-let [i (string/index-of s value i)]
-      (recur (conj acc i) (+ i (count value)))
-      acc)))
-
-(defn surround-by?
-  "`pos` must be surrounded by `before` and `and` in string `value`, e.g. ((|))"
-  [value pos before end]
-  (let [start-pos (if (= :start before) 0 (- pos (count before)))
-        end-pos (if (= :end end) (count value) (+ pos (count end)))]
-    (when (>= (count value) end-pos)
-      (= (cond
-           (and (= :end end) (= :start before))
-           ""
-
-           (= :end end)
-           before
-
-           (= :start before)
-           end
-
-           :else
-           (str before end))
-         (subs value start-pos end-pos)))))
-
-(defn wrapped-by?
-  "`pos` must be wrapped by `before` and `and` in string `value`, e.g. ((a|b))"
-  [value pos before end]
-  (let [before-matches (->> (get-string-all-indexes value before)
-                            (map (fn [i] [i :before])))
-        end-matches (->> (get-string-all-indexes value end)
-                         (map (fn [i] [i :end])))
-        indexes (sort-by first (concat before-matches end-matches [[pos :between]]))
-        ks (map second indexes)
-        q [:before :between :end]]
-    (true?
-     (reduce (fn [acc k]
-               (if (= q (conj acc k))
-                 (reduced true)
-                 (vec (take-last 2 (conj acc k)))))
-             []
-             ks))))
-
-(defn get-graph-name-from-path
-  [path]
-  (when (string? path)
-    (let [parts (->> (string/split path #"/")
-                     (take-last 2))]
-      (-> (if (not= (first parts) "0")
-            (string/join "/" parts)
-            (last parts))
-          js/decodeURI))))
-
 (defonce non-parsing-properties
   (atom #{"background-color" "background_color"}))
 

+ 1 - 6
src/main/logseq/graph_parser/utf8.cljs → deps/graph-parser/src/logseq/graph_parser/utf8.cljs

@@ -1,5 +1,4 @@
-(ns ^:nbb-compatible logseq.graph-parser.utf8
-  (:require [goog.object :as gobj]))
+(ns logseq.graph-parser.utf8)
 
 (defonce encoder
   (js/TextEncoder. "utf-8"))
@@ -22,7 +21,3 @@
    (if end
      (decode (.subarray arr start end))
      (decode (.subarray arr start)))))
-
-(defn length
-  [arr]
-  (gobj/get arr "length"))

+ 2 - 5
src/main/logseq/graph_parser/util.cljs → deps/graph-parser/src/logseq/graph_parser/util.cljs

@@ -1,4 +1,4 @@
-(ns ^:nbb-compatible logseq.graph-parser.util
+(ns logseq.graph-parser.util
   "Util fns shared between graph-parser and rest of app. Util fns only rely on
   clojure standard libraries."
   (:require [clojure.walk :as walk]
@@ -7,9 +7,6 @@
 (defn safe-re-find
   "Copy of frontend.util/safe-re-find. Too basic to couple to main app"
   [pattern s]
-  (when-not (string? s)
-    ;; TODO: sentry
-    (js/console.trace))
   (when (string? s)
     (re-find pattern s)))
 
@@ -65,7 +62,7 @@
        (try
          (js/URL. s)
          true
-         (catch js/Error _e
+         (catch :default _e
            false))))
 
 (defn json->clj

+ 2 - 1
src/test/logseq/graph_parser/block_test.cljs → deps/graph-parser/test/logseq/graph_parser/block_test.cljs

@@ -21,7 +21,8 @@
     [["foo" "[[bar]], [[nested [[baz]]]]"]] {:foo #{"bar" "nested [[baz]]"}}
     [["foo" "[[bar]], [[nested [[baz]]]]"]] {:foo #{"bar" "nested [[baz]]"}}
     [["foo" "bar, [[baz, test]]"]] {:foo #{"bar" "baz, test"}}
-    [["foo" "bar, [[baz, test, [[nested]]]]"]] {:foo #{"bar" "baz, test, [[nested]]"}})
+    [["foo" "bar, [[baz, test, [[nested]]]]"]] {:foo #{"bar" "baz, test, [[nested]]"}}
+    [["file-path" "file:///home/x, y.pdf"]] {:file-path "file:///home/x, y.pdf"})
 
   (are [x y] (= (vec (:page-refs (gp-block/extract-properties :markdown x {}))) y)
     [["year" "1000"]] []

+ 13 - 0
deps/graph-parser/test/logseq/graph_parser/cli_test.cljs

@@ -0,0 +1,13 @@
+(ns logseq.graph-parser.cli-test
+  (:require [cljs.test :refer [deftest]]
+            [logseq.graph-parser.cli :as gp-cli]
+            [logseq.graph-parser.test.docs-graph-helper :as docs-graph-helper]))
+
+;; Integration test that test parsing a large graph like docs
+(deftest ^:integration parse-graph
+  (let [graph-dir "test/docs"
+        _ (docs-graph-helper/clone-docs-repo-if-not-exists graph-dir)
+        {:keys [conn files]} (gp-cli/parse-graph graph-dir)
+        db @conn]
+
+    (docs-graph-helper/docs-graph-assertions db files)))

+ 17 - 32
src/test/logseq/graph_parser/extract_test.cljs → deps/graph-parser/test/logseq/graph_parser/extract_test.cljs

@@ -1,12 +1,11 @@
 (ns logseq.graph-parser.extract-test
-  (:require [cljs.test :refer [async deftest is]]
+  (:require [cljs.test :refer [deftest is]]
             [logseq.graph-parser.extract :as extract]
-            [clojure.pprint :as pprint]
-            [promesa.core :as p]))
+            [clojure.pprint :as pprint]))
 
 (defn- extract
   [text]
-  (p/let [result (extract/extract-blocks-pages "a.md" text {:block-pattern "-"})
+  (let [result (extract/extract-blocks-pages "a.md" text {:block-pattern "-"})
           result (last result)
           lefts (map (juxt :block/parent :block/left) result)]
     (if (not= (count lefts) (count (distinct lefts)))
@@ -15,34 +14,24 @@
         (throw (js/Error. ":block/parent && :block/left conflicts")))
       (mapv :block/content result))))
 
-(defn- async-test
-  [x y]
-  (async done
-         (p/then
-          (extract x)
-          (fn [v]
-            (is (= y v))
-            (done)))))
-
 (deftest test-extract-blocks-pages
   []
-  (async-test
-   "- a
+  (is (= ["a" "b" "c"]
+         (extract
+          "- a
   - b
-    - c"
-   ["a" "b" "c"])
+    - c")))
 
-  (async-test
-   "## hello
+  (is (= ["## hello" "world" "nice" "nice" "bingo" "world"]
+         (extract "## hello
     - world
       - nice
         - nice
       - bingo
-      - world"
-   ["## hello" "world" "nice" "nice" "bingo" "world"])
+      - world")))
 
-  (async-test
-   "# a
+  (is (= ["# a" "## b" "### c" "#### d" "### e" "f" "g" "h" "i" "j"]
+       (extract "# a
 ## b
 ### c
 #### d
@@ -51,17 +40,13 @@
   - g
     - h
   - i
-- j"
-
-   ["# a" "## b" "### c" "#### d" "### e" "f" "g" "h" "i" "j"]))
+- j"))))
 
 (deftest test-regression-1902
   []
-  (async-test
-   "- line1
+  (is (= ["line1" "line2" "line3" "line4"]
+         (extract
+          "- line1
     - line2
       - line3
-     - line4"
-   ["line1" "line2" "line3" "line4"]))
-
-#_(cljs.test/run-tests)
+     - line4"))))

+ 7 - 6
src/test/logseq/graph_parser/mldoc_test.cljs → deps/graph-parser/test/logseq/graph_parser/mldoc_test.cljs

@@ -1,7 +1,8 @@
 (ns logseq.graph-parser.mldoc-test
   (:require [logseq.graph-parser.mldoc :as gp-mldoc]
             [clojure.string :as string]
-            [frontend.test.docs-graph-helper :as docs-graph-helper]
+            [logseq.graph-parser.test.docs-graph-helper :as docs-graph-helper]
+            [logseq.graph-parser.cli :as gp-cli]
             [cljs.test :refer [testing deftest are is]]))
 
 (deftest test-link
@@ -98,9 +99,9 @@
 : definition" md-config {})))))
 
 (deftest ^:integration test->edn
-  (let [graph-dir "src/test/docs"
+  (let [graph-dir "test/docs"
         _ (docs-graph-helper/clone-docs-repo-if-not-exists graph-dir)
-        files (docs-graph-helper/build-graph-files graph-dir)
+        files (gp-cli/build-graph-files graph-dir)
         asts-by-file (->> files
                           (map (fn [{:file/keys [path content]}]
                                  (let [format (if (string/ends-with? path ".org")
@@ -116,10 +117,10 @@
             "Drawer" 1,
             "Example" 20,
             "Footnote_Definition" 2,
-            "Heading" 3493,
+            "Heading" 3496,
             "Hiccup" 15,
-            "List" 36,
-            "Paragraph" 411,
+            "List" 37,
+            "Paragraph" 417,
             "Properties" 104,
             "Property_Drawer" 188,
             "Quote" 9,

+ 4 - 8
src/test/logseq/graph_parser/nbb_test_runner.cljs → deps/graph-parser/test/logseq/graph_parser/nbb_test_runner.cljs

@@ -1,13 +1,12 @@
 (ns logseq.graph-parser.nbb-test-runner
   "Nbb tests for graph-parser"
   (:require [cljs.test :as t]
-            [logseq.graph-parser.mldoc :as gp-mldoc]
-            [logseq.graph-parser.text :as text]
             [logseq.graph-parser.text-test]
             [logseq.graph-parser.mldoc-test]
             [logseq.graph-parser.block-test]
             [logseq.graph-parser.property-test]
-            [logseq.graph-parser.extract-test]))
+            [logseq.graph-parser.extract-test]
+            [logseq.graph-parser.cli-test]))
 
 (defmethod cljs.test/report [:cljs.test/default :end-run-tests] [m]
   (when-not (cljs.test/successful? m)
@@ -15,12 +14,9 @@
 
 ;; run this function with: nbb-logseq -m logseq.test.nbb-test-runner/run-tests
 (defn run-tests []
-  ;; This hack is the same as the one in frontend.format. This has to be in an nbb only
-  ;; ns since alter-var-root doesn't exist in cljs and nbb doesn't support set! yet
-  #_:clj-kondo/ignore
-  (alter-var-root #'gp-mldoc/parse-property (constantly text/parse-property))
   (t/run-tests 'logseq.graph-parser.mldoc-test
                'logseq.graph-parser.text-test
                'logseq.graph-parser.property-test
                'logseq.graph-parser.block-test
-               'logseq.graph-parser.extract-test))
+               'logseq.graph-parser.extract-test
+               'logseq.graph-parser.cli-test))

+ 0 - 0
src/test/logseq/graph_parser/property_test.cljs → deps/graph-parser/test/logseq/graph_parser/property_test.cljs


+ 0 - 30
src/test/logseq/graph_parser/text_test.cljs → deps/graph-parser/test/logseq/graph_parser/text_test.cljs

@@ -98,36 +98,6 @@
       "**foobar" "foobar"
       "*********************foobar" "foobar")))
 
-(deftest test-add-timestamp
-  []
-  (are [x y] (= x y)
-    (text/add-timestamp "LATER hello world\nhello"
-                        "scheduled"
-                        "<2021-08-25 Wed>")
-    "LATER hello world\nSCHEDULED: <2021-08-25 Wed>\nhello"
-
-    (text/add-timestamp "LATER hello world "
-                        "scheduled"
-                        "<2021-08-25 Wed>")
-    "LATER hello world\nSCHEDULED: <2021-08-25 Wed>"
-
-    (text/add-timestamp "LATER hello world\nfoo:: bar\ntest"
-                        "scheduled"
-                        "<2021-08-25 Wed>")
-    "LATER hello world\nSCHEDULED: <2021-08-25 Wed>\nfoo:: bar\ntest"))
-
-(deftest get-string-all-indexes
-  []
-  (are [x y] (= x y)
-    (text/get-string-all-indexes "[[hello]] [[world]]" "[[")
-    [0 10]
-
-    (text/get-string-all-indexes "abc abc ab" "ab")
-    [0 4 8]
-
-    (text/get-string-all-indexes "a.c a.c ab" "a.")
-    [0 4]))
-
 (deftest test-parse-property
   (testing "parse-property"
     (are [k v y] (= (text/parse-property k v {}) y)

+ 411 - 0
deps/graph-parser/yarn.lock

@@ -0,0 +1,411 @@
+# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
+# yarn lockfile v1
+
+
+"@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:
+    import-meta-resolve "^1.1.1"
+
+ansi-regex@^2.0.0:
+  version "2.1.1"
+  resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df"
+  integrity sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==
+
+ansi-regex@^3.0.0:
+  version "3.0.1"
+  resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.1.tgz#123d6479e92ad45ad897d4054e3c7ca7db4944e1"
+  integrity sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==
+
+builtins@^4.0.0:
+  version "4.1.0"
+  resolved "https://registry.yarnpkg.com/builtins/-/builtins-4.1.0.tgz#1edd016dd91ce771a1ed6fc3b2b71fb918953250"
+  integrity sha512-1bPRZQtmKaO6h7qV1YHXNtr6nCK28k0Zo95KM4dXfILcZZwoHJBN1m3lfLv9LPkcOZlrSr+J1bzMaZFO98Yq0w==
+  dependencies:
+    semver "^7.0.0"
+
+camelcase@^5.0.0:
+  version "5.3.1"
+  resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320"
+  integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==
+
+cliui@^4.0.0:
+  version "4.1.0"
+  resolved "https://registry.yarnpkg.com/cliui/-/cliui-4.1.0.tgz#348422dbe82d800b3022eef4f6ac10bf2e4d1b49"
+  integrity sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ==
+  dependencies:
+    string-width "^2.1.1"
+    strip-ansi "^4.0.0"
+    wrap-ansi "^2.0.0"
+
+code-point-at@^1.0.0:
+  version "1.1.0"
+  resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77"
+  integrity sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=
+
+cross-spawn@^6.0.0:
+  version "6.0.5"
+  resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4"
+  integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==
+  dependencies:
+    nice-try "^1.0.4"
+    path-key "^2.0.1"
+    semver "^5.5.0"
+    shebang-command "^1.2.0"
+    which "^1.2.9"
+
+decamelize@^1.2.0:
+  version "1.2.0"
+  resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"
+  integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=
+
+end-of-stream@^1.1.0:
+  version "1.4.4"
+  resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.4.tgz#5ae64a5f45057baf3626ec14da0ca5e4b2431eb0"
+  integrity sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==
+  dependencies:
+    once "^1.4.0"
+
+execa@^1.0.0:
+  version "1.0.0"
+  resolved "https://registry.yarnpkg.com/execa/-/execa-1.0.0.tgz#c6236a5bb4df6d6f15e88e7f017798216749ddd8"
+  integrity sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA==
+  dependencies:
+    cross-spawn "^6.0.0"
+    get-stream "^4.0.0"
+    is-stream "^1.1.0"
+    npm-run-path "^2.0.0"
+    p-finally "^1.0.0"
+    signal-exit "^3.0.0"
+    strip-eof "^1.0.0"
+
+find-up@^3.0.0:
+  version "3.0.0"
+  resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73"
+  integrity sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==
+  dependencies:
+    locate-path "^3.0.0"
+
+get-caller-file@^1.0.1:
+  version "1.0.3"
+  resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.3.tgz#f978fa4c90d1dfe7ff2d6beda2a515e713bdcf4a"
+  integrity sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==
+
+get-stream@^4.0.0:
+  version "4.1.0"
+  resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-4.1.0.tgz#c1b255575f3dc21d59bfc79cd3d2b46b1c3a54b5"
+  integrity sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==
+  dependencies:
+    pump "^3.0.0"
+
+import-meta-resolve@^1.1.1:
+  version "1.1.1"
+  resolved "https://registry.yarnpkg.com/import-meta-resolve/-/import-meta-resolve-1.1.1.tgz#244fd542fd1fae73550d4f8b3cde3bba1d7b2b18"
+  integrity sha512-JiTuIvVyPaUg11eTrNDx5bgQ/yMKMZffc7YSjvQeSMXy58DO2SQ8BtAf3xteZvmzvjYh14wnqNjL8XVeDy2o9A==
+  dependencies:
+    builtins "^4.0.0"
+
+invert-kv@^2.0.0:
+  version "2.0.0"
+  resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-2.0.0.tgz#7393f5afa59ec9ff5f67a27620d11c226e3eec02"
+  integrity sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA==
+
+is-fullwidth-code-point@^1.0.0:
+  version "1.0.0"
+  resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb"
+  integrity sha1-754xOG8DGn8NZDr4L95QxFfvAMs=
+  dependencies:
+    number-is-nan "^1.0.0"
+
+is-fullwidth-code-point@^2.0.0:
+  version "2.0.0"
+  resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f"
+  integrity sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=
+
+is-stream@^1.1.0:
+  version "1.1.0"
+  resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44"
+  integrity sha1-EtSj3U5o4Lec6428hBc66A2RykQ=
+
+isexe@^2.0.0:
+  version "2.0.0"
+  resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
+  integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=
+
+lcid@^2.0.0:
+  version "2.0.0"
+  resolved "https://registry.yarnpkg.com/lcid/-/lcid-2.0.0.tgz#6ef5d2df60e52f82eb228a4c373e8d1f397253cf"
+  integrity sha512-avPEb8P8EGnwXKClwsNUgryVjllcRqtMYa49NTsbQagYuT1DcXnl1915oxWjoyGrXR6zH/Y0Zc96xWsPcoDKeA==
+  dependencies:
+    invert-kv "^2.0.0"
+
+locate-path@^3.0.0:
+  version "3.0.0"
+  resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e"
+  integrity sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==
+  dependencies:
+    p-locate "^3.0.0"
+    path-exists "^3.0.0"
+
+lru-cache@^6.0.0:
+  version "6.0.0"
+  resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94"
+  integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==
+  dependencies:
+    yallist "^4.0.0"
+
+map-age-cleaner@^0.1.1:
+  version "0.1.3"
+  resolved "https://registry.yarnpkg.com/map-age-cleaner/-/map-age-cleaner-0.1.3.tgz#7d583a7306434c055fe474b0f45078e6e1b4b92a"
+  integrity sha512-bJzx6nMoP6PDLPBFmg7+xRKeFZvFboMrGlxmNj9ClvX53KrmvM5bXFXEWjbz4cz1AFn+jWJ9z/DJSz7hrs0w3w==
+  dependencies:
+    p-defer "^1.0.0"
+
+mem@^4.0.0:
+  version "4.3.0"
+  resolved "https://registry.yarnpkg.com/mem/-/mem-4.3.0.tgz#461af497bc4ae09608cdb2e60eefb69bff744178"
+  integrity sha512-qX2bG48pTqYRVmDB37rn/6PT7LcR8T7oAX3bf99u1Tt1nzxYfxkgqDwUwolPlXweM0XzBOBFzSx4kfp7KP1s/w==
+  dependencies:
+    map-age-cleaner "^0.1.1"
+    mimic-fn "^2.0.0"
+    p-is-promise "^2.0.0"
+
+mimic-fn@^2.0.0:
+  version "2.1.0"
+  resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b"
+  integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==
+
+mldoc@^1.3.3:
+  version "1.3.3"
+  resolved "https://registry.yarnpkg.com/mldoc/-/mldoc-1.3.3.tgz#b7f39b48eb0ef3558619d3e3522265977bd78fe3"
+  integrity sha512-TzW06GBltdKxwWAxOvflPmIVedu6bzl9T4YoYqnDUyZ3kELFMllEgiYCh65PPW3xsRMA/5OcRQqqGZGiKEJEug==
+  dependencies:
+    yargs "^12.0.2"
+
+nice-try@^1.0.4:
+  version "1.0.5"
+  resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366"
+  integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==
+
+npm-run-path@^2.0.0:
+  version "2.0.2"
+  resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f"
+  integrity sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=
+  dependencies:
+    path-key "^2.0.0"
+
+number-is-nan@^1.0.0:
+  version "1.0.1"
+  resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d"
+  integrity sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=
+
+once@^1.3.1, once@^1.4.0:
+  version "1.4.0"
+  resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
+  integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E=
+  dependencies:
+    wrappy "1"
+
+os-locale@^3.0.0:
+  version "3.1.0"
+  resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-3.1.0.tgz#a802a6ee17f24c10483ab9935719cef4ed16bf1a"
+  integrity sha512-Z8l3R4wYWM40/52Z+S265okfFj8Kt2cC2MKY+xNi3kFs+XGI7WXu/I309QQQYbRW4ijiZ+yxs9pqEhJh0DqW3Q==
+  dependencies:
+    execa "^1.0.0"
+    lcid "^2.0.0"
+    mem "^4.0.0"
+
+p-defer@^1.0.0:
+  version "1.0.0"
+  resolved "https://registry.yarnpkg.com/p-defer/-/p-defer-1.0.0.tgz#9f6eb182f6c9aa8cd743004a7d4f96b196b0fb0c"
+  integrity sha1-n26xgvbJqozXQwBKfU+WsZaw+ww=
+
+p-finally@^1.0.0:
+  version "1.0.0"
+  resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae"
+  integrity sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=
+
+p-is-promise@^2.0.0:
+  version "2.1.0"
+  resolved "https://registry.yarnpkg.com/p-is-promise/-/p-is-promise-2.1.0.tgz#918cebaea248a62cf7ffab8e3bca8c5f882fc42e"
+  integrity sha512-Y3W0wlRPK8ZMRbNq97l4M5otioeA5lm1z7bkNkxCka8HSPjR0xRWmpCmc9utiaLP9Jb1eD8BgeIxTW4AIF45Pg==
+
+p-limit@^2.0.0:
+  version "2.3.0"
+  resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1"
+  integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==
+  dependencies:
+    p-try "^2.0.0"
+
+p-locate@^3.0.0:
+  version "3.0.0"
+  resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-3.0.0.tgz#322d69a05c0264b25997d9f40cd8a891ab0064a4"
+  integrity sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==
+  dependencies:
+    p-limit "^2.0.0"
+
+p-try@^2.0.0:
+  version "2.2.0"
+  resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6"
+  integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==
+
+path-exists@^3.0.0:
+  version "3.0.0"
+  resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515"
+  integrity sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=
+
+path-key@^2.0.0, path-key@^2.0.1:
+  version "2.0.1"
+  resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40"
+  integrity sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=
+
+pump@^3.0.0:
+  version "3.0.0"
+  resolved "https://registry.yarnpkg.com/pump/-/pump-3.0.0.tgz#b4a2116815bde2f4e1ea602354e8c75565107a64"
+  integrity sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==
+  dependencies:
+    end-of-stream "^1.1.0"
+    once "^1.3.1"
+
+require-directory@^2.1.1:
+  version "2.1.1"
+  resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42"
+  integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I=
+
+require-main-filename@^1.0.1:
+  version "1.0.1"
+  resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1"
+  integrity sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=
+
+semver@^5.5.0:
+  version "5.7.1"
+  resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"
+  integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==
+
+semver@^7.0.0:
+  version "7.3.7"
+  resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.7.tgz#12c5b649afdbf9049707796e22a4028814ce523f"
+  integrity sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==
+  dependencies:
+    lru-cache "^6.0.0"
+
+set-blocking@^2.0.0:
+  version "2.0.0"
+  resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7"
+  integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc=
+
+shebang-command@^1.2.0:
+  version "1.2.0"
+  resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea"
+  integrity sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=
+  dependencies:
+    shebang-regex "^1.0.0"
+
+shebang-regex@^1.0.0:
+  version "1.0.0"
+  resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3"
+  integrity sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=
+
+signal-exit@^3.0.0:
+  version "3.0.7"
+  resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9"
+  integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==
+
+string-width@^1.0.1:
+  version "1.0.2"
+  resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3"
+  integrity sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=
+  dependencies:
+    code-point-at "^1.0.0"
+    is-fullwidth-code-point "^1.0.0"
+    strip-ansi "^3.0.0"
+
+string-width@^2.0.0, string-width@^2.1.1:
+  version "2.1.1"
+  resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e"
+  integrity sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==
+  dependencies:
+    is-fullwidth-code-point "^2.0.0"
+    strip-ansi "^4.0.0"
+
+strip-ansi@^3.0.0, strip-ansi@^3.0.1:
+  version "3.0.1"
+  resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf"
+  integrity sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=
+  dependencies:
+    ansi-regex "^2.0.0"
+
+strip-ansi@^4.0.0:
+  version "4.0.0"
+  resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f"
+  integrity sha1-qEeQIusaw2iocTibY1JixQXuNo8=
+  dependencies:
+    ansi-regex "^3.0.0"
+
+strip-eof@^1.0.0:
+  version "1.0.0"
+  resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf"
+  integrity sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=
+
+which-module@^2.0.0:
+  version "2.0.0"
+  resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a"
+  integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=
+
+which@^1.2.9:
+  version "1.3.1"
+  resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a"
+  integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==
+  dependencies:
+    isexe "^2.0.0"
+
+wrap-ansi@^2.0.0:
+  version "2.1.0"
+  resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85"
+  integrity sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=
+  dependencies:
+    string-width "^1.0.1"
+    strip-ansi "^3.0.1"
+
+wrappy@1:
+  version "1.0.2"
+  resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
+  integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=
+
+"y18n@^3.2.1 || ^4.0.0":
+  version "4.0.3"
+  resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.3.tgz#b5f259c82cd6e336921efd7bfd8bf560de9eeedf"
+  integrity sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==
+
+yallist@^4.0.0:
+  version "4.0.0"
+  resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"
+  integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==
+
+yargs-parser@^11.1.1:
+  version "11.1.1"
+  resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-11.1.1.tgz#879a0865973bca9f6bab5cbdf3b1c67ec7d3bcf4"
+  integrity sha512-C6kB/WJDiaxONLJQnF8ccx9SEeoTTLek8RVbaOIsrAUS8VrBEXfmeSnCZxygc+XC2sNMBIwOOnfcxiynjHsVSQ==
+  dependencies:
+    camelcase "^5.0.0"
+    decamelize "^1.2.0"
+
+yargs@^12.0.2:
+  version "12.0.5"
+  resolved "https://registry.yarnpkg.com/yargs/-/yargs-12.0.5.tgz#05f5997b609647b64f66b81e3b4b10a368e7ad13"
+  integrity sha512-Lhz8TLaYnxq/2ObqHDql8dX8CJi97oHxrjUcYtzKbbykPtVW9WB+poxI+NM2UIzsMgNCZTIf0AQwsjK5yMAqZw==
+  dependencies:
+    cliui "^4.0.0"
+    decamelize "^1.2.0"
+    find-up "^3.0.0"
+    get-caller-file "^1.0.1"
+    os-locale "^3.0.0"
+    require-directory "^2.1.1"
+    require-main-filename "^1.0.1"
+    set-blocking "^2.0.0"
+    string-width "^2.0.0"
+    which-module "^2.0.0"
+    y18n "^3.2.1 || ^4.0.0"
+    yargs-parser "^11.1.1"

+ 7 - 1
docs/dev-practices.md

@@ -62,7 +62,7 @@ scripts/lint_rules.clj
 
 Namespaces have the metadata flag `^:nbb-compatible` indicate they are compatible with https://github.com/logseq/nbb-logseq. This compatibility is necessary in order for namespaces to be reused by the frontend and CLIs. To confirm these compatibilities, run:
 ```
-bb test:load-nbb-compatible-namespaces
+bb test:load-namespaces-with-nbb
 ```
 
 ## Testing
@@ -135,3 +135,9 @@ Specs should go under `src/main/frontend/spec/` and be compatible with clojure
 and clojurescript. See `frontend.spec.storage` for an example. By following
 these conventions, specs should also be usable by babashka. This is helpful as it
 allows for third party tools to be written with logseq's data model.
+
+## Development Tools
+
+There are some babashka tasks under `nbb:` which are useful for inspecting
+database changes in realtime. See [these
+docs](https://github.com/logseq/bb-tasks#logseqbb-tasksnbbwatch) for more info.

+ 1 - 1
docs/mobile.md

@@ -2,7 +2,7 @@
 * Android studio
 * SDK 30
 * other sdk tools in Android studio preference setting https://capacitorjs.com/docs/getting-started/environment-setup
-* change the server url in capacitor.config.json with your local ip:3001 (run ifconfig to check)
+* change the server url in `capacitor.config.ts` with your local ip:3001 (run ifconfig to check)
 * run `yarn && yarn app-watch`
 * in another console, run `npx cap open android`
 * create Android virtual device in Android studio

+ 3 - 3
e2e-tests/sidebar.spec.ts

@@ -16,12 +16,12 @@ test('favorite item and recent item test', async ({ page }) => {
   await page.locator("text=Add to Favorites").click()
   // click from another page
   const another_page_name = await createRandomPage(page)
-  expect(await page.innerText(':nth-match(.favorite-item a, 1)')).toBe('◦' + fav_page_name)
+  expect(await page.innerText(':nth-match(.favorite-item a, 1)')).toBe(fav_page_name)
   await page.click(":nth-match(.favorite-item, 1)")
   expect(await page.innerText('.page-title .title')).toBe(fav_page_name)
 
-  expect(await page.innerText(':nth-match(.recent-item a, 1)')).toBe('◦' + fav_page_name)
-  expect(await page.innerText(':nth-match(.recent-item a, 2)')).toBe('◦' + another_page_name)
+  expect(await page.innerText(':nth-match(.recent-item a, 1)')).toBe(fav_page_name)
+  expect(await page.innerText(':nth-match(.recent-item a, 2)')).toBe(another_page_name)
 
   // remove fav
   await page.click('.ui__dropdown-trigger')

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

@@ -554,7 +554,7 @@
 				INFOPLIST_FILE = App/Info.plist;
 				IPHONEOS_DEPLOYMENT_TARGET = 13.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
-				MARKETING_VERSION = 0.7.0;
+				MARKETING_VERSION = 0.7.1;
 				OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\"";
 				PRODUCT_BUNDLE_IDENTIFIER = com.logseq.logseq;
 				PRODUCT_NAME = "$(TARGET_NAME)";
@@ -580,7 +580,7 @@
 				INFOPLIST_FILE = App/Info.plist;
 				IPHONEOS_DEPLOYMENT_TARGET = 13.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
-				MARKETING_VERSION = 0.7.0;
+				MARKETING_VERSION = 0.7.1;
 				PRODUCT_BUNDLE_IDENTIFIER = com.logseq.logseq;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				SWIFT_ACTIVE_COMPILATION_CONDITIONS = "";
@@ -605,7 +605,7 @@
 				INFOPLIST_KEY_NSHumanReadableCopyright = "";
 				IPHONEOS_DEPLOYMENT_TARGET = 13.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
-				MARKETING_VERSION = 0.7.0;
+				MARKETING_VERSION = 0.7.1;
 				MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
 				MTL_FAST_MATH = YES;
 				PRODUCT_BUNDLE_IDENTIFIER = com.logseq.logseq.ShareViewController;
@@ -632,7 +632,7 @@
 				INFOPLIST_KEY_NSHumanReadableCopyright = "";
 				IPHONEOS_DEPLOYMENT_TARGET = 13.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
-				MARKETING_VERSION = 0.7.0;
+				MARKETING_VERSION = 0.7.1;
 				MTL_FAST_MATH = YES;
 				PRODUCT_BUNDLE_IDENTIFIER = com.logseq.logseq.ShareViewController;
 				PRODUCT_NAME = "$(TARGET_NAME)";

+ 2 - 2
package.json

@@ -63,7 +63,7 @@
         "cljs:debug": "clojure -M:cljs release app --debug",
         "cljs:report": "clojure -M:cljs run shadow.cljs.build-report app report.html",
         "cljs:build-electron": "clojure -A:cljs compile app electron",
-        "cljs:lint": "clojure -M:clj-kondo --parallel --lint src"
+        "cljs:lint": "clojure -M:clj-kondo --parallel --lint src --cache false"
     },
     "dependencies": {
         "@capacitor/android": "3.2.2",
@@ -104,7 +104,7 @@
         "ignore": "5.1.8",
         "is-svg": "4.3.0",
         "jszip": "3.5.0",
-        "mldoc": "1.3.9",
+        "mldoc": "1.4.0",
         "path": "0.12.7",
         "pixi-graph-fork": "0.2.0",
         "pixi.js": "6.2.0",

+ 4 - 4
resources/css/common.css

@@ -11,8 +11,8 @@
   --ls-border-radius-medium: 8px;
   --ls-headbar-height: 3rem;
   --ls-headbar-inner-top-padding: 0px;
-  --ls-left-sidebar-width: 240px;
-  --ls-left-sidebar-sm-width: 80%;
+  --ls-left-sidebar-width: 246px;
+  --ls-left-sidebar-sm-width: 70%;
   --ls-left-sidebar-nav-btn-size: 38px;
 }
 
@@ -101,8 +101,8 @@ See: https://github.com/logseq/logseq/pull/4652. */
 html[data-theme='light'] {
   --ls-primary-background-color: #ffffff;
   --ls-secondary-background-color: #f7f7f7;
-  --ls-tertiary-background-color: #f1eee8;
-  --ls-quaternary-background-color: #e8e5de;
+  --ls-tertiary-background-color: #eaeaea;
+  --ls-quaternary-background-color: #dcdcdc;
   --ls-table-tr-even-background-color: #f7f7f7;
   --ls-active-primary-color: rgb(0, 105, 182);
   --ls-active-secondary-color: #00477c;

+ 9 - 0
resources/css/shepherd.css

@@ -0,0 +1,9 @@
+.shepherd-button{background:#3288e6;border:0;border-radius:3px;color:hsla(0,0%,100%,.75);cursor:pointer;margin-right:.5rem;padding:.5rem 1.5rem;transition:all .5s ease}.shepherd-button:not(:disabled):hover{background:#196fcc;color:hsla(0,0%,100%,.75)}.shepherd-button.shepherd-button-secondary{background:#f1f2f3;color:rgba(0,0,0,.75)}.shepherd-button.shepherd-button-secondary:not(:disabled):hover{background:#d6d9db;color:rgba(0,0,0,.75)}.shepherd-button:disabled{cursor:not-allowed}
+.shepherd-footer{border-bottom-left-radius:5px;border-bottom-right-radius:5px;display:flex;justify-content:flex-end;padding:0 .75rem .75rem}.shepherd-footer .shepherd-button:last-child{margin-right:0}
+.shepherd-cancel-icon{background:transparent;border:none;color:hsla(0,0%,50%,.75);cursor:pointer;font-size:2em;font-weight:400;margin:0;padding:0;transition:color .5s ease}.shepherd-cancel-icon:hover{color:rgba(0,0,0,.75)}.shepherd-has-title .shepherd-content .shepherd-cancel-icon{color:hsla(0,0%,50%,.75)}.shepherd-has-title .shepherd-content .shepherd-cancel-icon:hover{color:rgba(0,0,0,.75)}
+.shepherd-title{color:rgba(0,0,0,.75);display:flex;flex:1 0 auto;font-size:1rem;font-weight:400;margin:0;padding:0}
+.shepherd-header{align-items:center;border-top-left-radius:5px;border-top-right-radius:5px;display:flex;justify-content:flex-end;line-height:2em;padding:.75rem .75rem 0}.shepherd-has-title .shepherd-content .shepherd-header{background:#e6e6e6;padding:1em}
+.shepherd-text{color:rgba(0,0,0,.75);font-size:1rem;line-height:1.3em;padding:.75em}.shepherd-text p{margin-top:0}.shepherd-text p:last-child{margin-bottom:0}
+.shepherd-content{border-radius:5px;outline:none;padding:0}
+.shepherd-element{background:#fff;border-radius:5px;box-shadow:0 1px 4px rgba(0,0,0,.2);max-width:400px;opacity:0;outline:none;transition:opacity .3s,visibility .3s;visibility:hidden;width:100%;z-index:9999}.shepherd-enabled.shepherd-element{opacity:1;visibility:visible}.shepherd-element[data-popper-reference-hidden]:not(.shepherd-centered){opacity:0;pointer-events:none;visibility:hidden}.shepherd-element,.shepherd-element *,.shepherd-element :after,.shepherd-element :before{box-sizing:border-box}.shepherd-arrow,.shepherd-arrow:before{height:16px;position:absolute;width:16px;z-index:-1}.shepherd-arrow:before{background:#fff;content:"";transform:rotate(45deg)}.shepherd-element[data-popper-placement^=top]>.shepherd-arrow{bottom:-8px}.shepherd-element[data-popper-placement^=bottom]>.shepherd-arrow{top:-8px}.shepherd-element[data-popper-placement^=left]>.shepherd-arrow{right:-8px}.shepherd-element[data-popper-placement^=right]>.shepherd-arrow{left:-8px}.shepherd-element.shepherd-centered>.shepherd-arrow{opacity:0}.shepherd-element.shepherd-has-title[data-popper-placement^=bottom]>.shepherd-arrow:before{background-color:#e6e6e6}.shepherd-target-click-disabled.shepherd-enabled.shepherd-target,.shepherd-target-click-disabled.shepherd-enabled.shepherd-target *{pointer-events:none}
+.shepherd-modal-overlay-container{height:0;left:0;opacity:0;overflow:hidden;pointer-events:none;position:fixed;top:0;transition:all .3s ease-out,height 0ms .3s,opacity .3s 0ms;width:100vw;z-index:9997}.shepherd-modal-overlay-container.shepherd-modal-is-visible{height:100vh;opacity:.5;transition:all .3s ease-out,height 0s 0s,opacity .3s 0s}.shepherd-modal-overlay-container.shepherd-modal-is-visible path{pointer-events:all}

+ 117 - 0
resources/js/shepherd.min.js

@@ -0,0 +1,117 @@
+/*! shepherd.js 9.1.0 */
+
+'use strict';(function(O,pa){"object"===typeof exports&&"undefined"!==typeof module?module.exports=pa():"function"===typeof define&&define.amd?define(pa):(O="undefined"!==typeof globalThis?globalThis:O||self,O.Shepherd=pa())})(this,function(){function O(a,b){return!1!==b.clone&&b.isMergeableObject(a)?da(Array.isArray(a)?[]:{},a,b):a}function pa(a,b,c){return a.concat(b).map(function(d){return O(d,c)})}function Db(a){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(a).filter(function(b){return a.propertyIsEnumerable(b)}):
+[]}function Ta(a){return Object.keys(a).concat(Db(a))}function Ua(a,b){try{return b in a}catch(c){return!1}}function Eb(a,b,c){var d={};c.isMergeableObject(a)&&Ta(a).forEach(function(e){d[e]=O(a[e],c)});Ta(b).forEach(function(e){if(!Ua(a,e)||Object.hasOwnProperty.call(a,e)&&Object.propertyIsEnumerable.call(a,e))if(Ua(a,e)&&c.isMergeableObject(b[e])){if(c.customMerge){var f=c.customMerge(e);f="function"===typeof f?f:da}else f=da;d[e]=f(a[e],b[e],c)}else d[e]=O(b[e],c)});return d}function da(a,b,c){c=
+c||{};c.arrayMerge=c.arrayMerge||pa;c.isMergeableObject=c.isMergeableObject||Fb;c.cloneUnlessOtherwiseSpecified=O;var d=Array.isArray(b),e=Array.isArray(a);return d!==e?O(b,c):d?c.arrayMerge(a,b,c):Eb(a,b,c)}function ea(a){return"function"===typeof a}function qa(a){return"string"===typeof a}function Va(a){let b=Object.getOwnPropertyNames(a.constructor.prototype);for(let c=0;c<b.length;c++){let d=b[c],e=a[d];"constructor"!==d&&"function"===typeof e&&(a[d]=e.bind(a))}return a}function Gb(a,b){return c=>
+{if(b.isOpen()){let d=b.el&&c.currentTarget===b.el;(void 0!==a&&c.currentTarget.matches(a)||d)&&b.tour.next()}}}function Hb(a){let {event:b,selector:c}=a.options.advanceOn||{};if(b){let d=Gb(c,a),e;try{e=document.querySelector(c)}catch(f){}if(void 0===c||e)e?(e.addEventListener(b,d),a.on("destroy",()=>e.removeEventListener(b,d))):(document.body.addEventListener(b,d,!0),a.on("destroy",()=>document.body.removeEventListener(b,d,!0)));else return console.error(`No element was found for the selector supplied to advanceOn: ${c}`)}else return console.error("advanceOn was defined, but no event name was passed.")}
+function M(a){return a?(a.nodeName||"").toLowerCase():null}function K(a){return null==a?window:"[object Window]"!==a.toString()?(a=a.ownerDocument)?a.defaultView||window:window:a}function fa(a){var b=K(a).Element;return a instanceof b||a instanceof Element}function F(a){var b=K(a).HTMLElement;return a instanceof b||a instanceof HTMLElement}function Ea(a){if("undefined"===typeof ShadowRoot)return!1;var b=K(a).ShadowRoot;return a instanceof b||a instanceof ShadowRoot}function N(a){return a.split("-")[0]}
+function ha(a,b){void 0===b&&(b=!1);var c=a.getBoundingClientRect(),d=1,e=1;F(a)&&b&&(b=a.offsetHeight,a=a.offsetWidth,0<a&&(d=ia(c.width)/a||1),0<b&&(e=ia(c.height)/b||1));return{width:c.width/d,height:c.height/e,top:c.top/e,right:c.right/d,bottom:c.bottom/e,left:c.left/d,x:c.left/d,y:c.top/e}}function Fa(a){var b=ha(a),c=a.offsetWidth,d=a.offsetHeight;1>=Math.abs(b.width-c)&&(c=b.width);1>=Math.abs(b.height-d)&&(d=b.height);return{x:a.offsetLeft,y:a.offsetTop,width:c,height:d}}function Wa(a,b){var c=
+b.getRootNode&&b.getRootNode();if(a.contains(b))return!0;if(c&&Ea(c)){do{if(b&&a.isSameNode(b))return!0;b=b.parentNode||b.host}while(b)}return!1}function P(a){return K(a).getComputedStyle(a)}function U(a){return((fa(a)?a.ownerDocument:a.document)||window.document).documentElement}function wa(a){return"html"===M(a)?a:a.assignedSlot||a.parentNode||(Ea(a)?a.host:null)||U(a)}function Xa(a){return F(a)&&"fixed"!==P(a).position?a.offsetParent:null}function ra(a){for(var b=K(a),c=Xa(a);c&&0<=["table","td",
+"th"].indexOf(M(c))&&"static"===P(c).position;)c=Xa(c);if(c&&("html"===M(c)||"body"===M(c)&&"static"===P(c).position))return b;if(!c)a:{c=-1!==navigator.userAgent.toLowerCase().indexOf("firefox");if(-1===navigator.userAgent.indexOf("Trident")||!F(a)||"fixed"!==P(a).position)for(a=wa(a),Ea(a)&&(a=a.host);F(a)&&0>["html","body"].indexOf(M(a));){var d=P(a);if("none"!==d.transform||"none"!==d.perspective||"paint"===d.contain||-1!==["transform","perspective"].indexOf(d.willChange)||c&&"filter"===d.willChange||
+c&&d.filter&&"none"!==d.filter){c=a;break a}else a=a.parentNode}c=null}return c||b}function Ga(a){return 0<=["top","bottom"].indexOf(a)?"x":"y"}function Ya(a){return Object.assign({},{top:0,right:0,bottom:0,left:0},a)}function Za(a,b){return b.reduce(function(c,d){c[d]=a;return c},{})}function ja(a){return a.split("-")[1]}function $a(a){var b,c=a.popper,d=a.popperRect,e=a.placement,f=a.variation,g=a.offsets,l=a.position,m=a.gpuAcceleration,k=a.adaptive,p=a.roundOffsets,q=a.isFixed;a=g.x;a=void 0===
+a?0:a;var n=g.y,r=void 0===n?0:n;n="function"===typeof p?p({x:a,y:r}):{x:a,y:r};a=n.x;r=n.y;n=g.hasOwnProperty("x");g=g.hasOwnProperty("y");var x="left",h="top",t=window;if(k){var v=ra(c),A="clientHeight",u="clientWidth";v===K(c)&&(v=U(c),"static"!==P(v).position&&"absolute"===l&&(A="scrollHeight",u="scrollWidth"));if("top"===e||("left"===e||"right"===e)&&"end"===f)h="bottom",r-=(q&&v===t&&t.visualViewport?t.visualViewport.height:v[A])-d.height,r*=m?1:-1;if("left"===e||("top"===e||"bottom"===e)&&
+"end"===f)x="right",a-=(q&&v===t&&t.visualViewport?t.visualViewport.width:v[u])-d.width,a*=m?1:-1}c=Object.assign({position:l},k&&Ib);!0===p?(p=r,d=window.devicePixelRatio||1,a={x:ia(a*d)/d||0,y:ia(p*d)/d||0}):a={x:a,y:r};p=a;a=p.x;r=p.y;if(m){var w;return Object.assign({},c,(w={},w[h]=g?"0":"",w[x]=n?"0":"",w.transform=1>=(t.devicePixelRatio||1)?"translate("+a+"px, "+r+"px)":"translate3d("+a+"px, "+r+"px, 0)",w))}return Object.assign({},c,(b={},b[h]=g?r+"px":"",b[x]=n?a+"px":"",b.transform="",b))}
+function xa(a){return a.replace(/left|right|bottom|top/g,function(b){return Jb[b]})}function ab(a){return a.replace(/start|end/g,function(b){return Kb[b]})}function Ha(a){a=K(a);return{scrollLeft:a.pageXOffset,scrollTop:a.pageYOffset}}function Ia(a){return ha(U(a)).left+Ha(a).scrollLeft}function Ja(a){a=P(a);return/auto|scroll|overlay|hidden/.test(a.overflow+a.overflowY+a.overflowX)}function bb(a){return 0<=["html","body","#document"].indexOf(M(a))?a.ownerDocument.body:F(a)&&Ja(a)?a:bb(wa(a))}function sa(a,
+b){var c;void 0===b&&(b=[]);var d=bb(a);a=d===(null==(c=a.ownerDocument)?void 0:c.body);c=K(d);d=a?[c].concat(c.visualViewport||[],Ja(d)?d:[]):d;b=b.concat(d);return a?b:b.concat(sa(wa(d)))}function Ka(a){return Object.assign({},a,{left:a.x,top:a.y,right:a.x+a.width,bottom:a.y+a.height})}function cb(a,b){if("viewport"===b){b=K(a);var c=U(a);b=b.visualViewport;var d=c.clientWidth;c=c.clientHeight;var e=0,f=0;b&&(d=b.width,c=b.height,/^((?!chrome|android).)*safari/i.test(navigator.userAgent)||(e=b.offsetLeft,
+f=b.offsetTop));a={width:d,height:c,x:e+Ia(a),y:f};a=Ka(a)}else fa(b)?(a=ha(b),a.top+=b.clientTop,a.left+=b.clientLeft,a.bottom=a.top+b.clientHeight,a.right=a.left+b.clientWidth,a.width=b.clientWidth,a.height=b.clientHeight,a.x=a.left,a.y=a.top):(f=U(a),a=U(f),d=Ha(f),b=null==(c=f.ownerDocument)?void 0:c.body,c=L(a.scrollWidth,a.clientWidth,b?b.scrollWidth:0,b?b.clientWidth:0),e=L(a.scrollHeight,a.clientHeight,b?b.scrollHeight:0,b?b.clientHeight:0),f=-d.scrollLeft+Ia(f),d=-d.scrollTop,"rtl"===P(b||
+a).direction&&(f+=L(a.clientWidth,b?b.clientWidth:0)-c),a=Ka({width:c,height:e,x:f,y:d}));return a}function Lb(a){var b=sa(wa(a)),c=0<=["absolute","fixed"].indexOf(P(a).position)&&F(a)?ra(a):a;return fa(c)?b.filter(function(d){return fa(d)&&Wa(d,c)&&"body"!==M(d)}):[]}function Mb(a,b,c){b="clippingParents"===b?Lb(a):[].concat(b);c=[].concat(b,[c]);c=c.reduce(function(d,e){e=cb(a,e);d.top=L(e.top,d.top);d.right=V(e.right,d.right);d.bottom=V(e.bottom,d.bottom);d.left=L(e.left,d.left);return d},cb(a,
+c[0]));c.width=c.right-c.left;c.height=c.bottom-c.top;c.x=c.left;c.y=c.top;return c}function db(a){var b=a.reference,c=a.element,d=(a=a.placement)?N(a):null;a=a?ja(a):null;var e=b.x+b.width/2-c.width/2,f=b.y+b.height/2-c.height/2;switch(d){case "top":e={x:e,y:b.y-c.height};break;case "bottom":e={x:e,y:b.y+b.height};break;case "right":e={x:b.x+b.width,y:f};break;case "left":e={x:b.x-c.width,y:f};break;default:e={x:b.x,y:b.y}}d=d?Ga(d):null;if(null!=d)switch(f="y"===d?"height":"width",a){case "start":e[d]-=
+b[f]/2-c[f]/2;break;case "end":e[d]+=b[f]/2-c[f]/2}return e}function ta(a,b){void 0===b&&(b={});var c=b;b=c.placement;b=void 0===b?a.placement:b;var d=c.boundary,e=void 0===d?"clippingParents":d;d=c.rootBoundary;var f=void 0===d?"viewport":d;d=c.elementContext;d=void 0===d?"popper":d;var g=c.altBoundary,l=void 0===g?!1:g;c=c.padding;c=void 0===c?0:c;c=Ya("number"!==typeof c?c:Za(c,ua));g=a.rects.popper;l=a.elements[l?"popper"===d?"reference":"popper":d];e=Mb(fa(l)?l:l.contextElement||U(a.elements.popper),
+e,f);f=ha(a.elements.reference);l=db({reference:f,element:g,strategy:"absolute",placement:b});g=Ka(Object.assign({},g,l));f="popper"===d?g:f;var m={top:e.top-f.top+c.top,bottom:f.bottom-e.bottom+c.bottom,left:e.left-f.left+c.left,right:f.right-e.right+c.right};a=a.modifiersData.offset;if("popper"===d&&a){var k=a[b];Object.keys(m).forEach(function(p){var q=0<=["right","bottom"].indexOf(p)?1:-1,n=0<=["top","bottom"].indexOf(p)?"y":"x";m[p]+=k[n]*q})}return m}function Nb(a,b){void 0===b&&(b={});var c=
+b.boundary,d=b.rootBoundary,e=b.padding,f=b.flipVariations,g=b.allowedAutoPlacements,l=void 0===g?eb:g,m=ja(b.placement);b=m?f?fb:fb.filter(function(p){return ja(p)===m}):ua;f=b.filter(function(p){return 0<=l.indexOf(p)});0===f.length&&(f=b);var k=f.reduce(function(p,q){p[q]=ta(a,{placement:q,boundary:c,rootBoundary:d,padding:e})[N(q)];return p},{});return Object.keys(k).sort(function(p,q){return k[p]-k[q]})}function Ob(a){if("auto"===N(a))return[];var b=xa(a);return[ab(a),b,ab(b)]}function gb(a,
+b,c){void 0===c&&(c={x:0,y:0});return{top:a.top-b.height-c.y,right:a.right-b.width+c.x,bottom:a.bottom-b.height+c.y,left:a.left-b.width-c.x}}function hb(a){return["top","right","bottom","left"].some(function(b){return 0<=a[b]})}function Pb(a,b,c){void 0===c&&(c=!1);var d=F(b),e;if(e=F(b)){var f=b.getBoundingClientRect();e=ia(f.width)/b.offsetWidth||1;f=ia(f.height)/b.offsetHeight||1;e=1!==e||1!==f}f=e;e=U(b);a=ha(a,f);f={scrollLeft:0,scrollTop:0};var g={x:0,y:0};if(d||!d&&!c){if("body"!==M(b)||Ja(e))f=
+b!==K(b)&&F(b)?{scrollLeft:b.scrollLeft,scrollTop:b.scrollTop}:Ha(b);F(b)?(g=ha(b,!0),g.x+=b.clientLeft,g.y+=b.clientTop):e&&(g.x=Ia(e))}return{x:a.left+f.scrollLeft-g.x,y:a.top+f.scrollTop-g.y,width:a.width,height:a.height}}function Qb(a){function b(f){d.add(f.name);[].concat(f.requires||[],f.requiresIfExists||[]).forEach(function(g){d.has(g)||(g=c.get(g))&&b(g)});e.push(f)}var c=new Map,d=new Set,e=[];a.forEach(function(f){c.set(f.name,f)});a.forEach(function(f){d.has(f.name)||b(f)});return e}function Rb(a){var b=
+Qb(a);return Sb.reduce(function(c,d){return c.concat(b.filter(function(e){return e.phase===d}))},[])}function Tb(a){var b;return function(){b||(b=new Promise(function(c){Promise.resolve().then(function(){b=void 0;c(a())})}));return b}}function Ub(a){var b=a.reduce(function(c,d){var e=c[d.name];c[d.name]=e?Object.assign({},e,d,{options:Object.assign({},e.options,d.options),data:Object.assign({},e.data,d.data)}):d;return c},{});return Object.keys(b).map(function(c){return b[c]})}function ib(){for(var a=
+arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];return!b.some(function(d){return!(d&&"function"===typeof d.getBoundingClientRect)})}function La(){La=Object.assign||function(a){for(var b=1;b<arguments.length;b++){var c=arguments[b],d;for(d in c)Object.prototype.hasOwnProperty.call(c,d)&&(a[d]=c[d])}return a};return La.apply(this,arguments)}function Vb(){return[{name:"applyStyles",fn(a){let {state:b}=a;Object.keys(b.elements).forEach(c=>{if("popper"===c){var d=b.attributes[c]||{},e=b.elements[c];
+Object.assign(e.style,{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%, -50%)"});Object.keys(d).forEach(f=>{let g=d[f];!1===g?e.removeAttribute(f):e.setAttribute(f,!0===g?"":g)})}})}},{name:"computeStyles",options:{adaptive:!1}}]}function Wb(a){let b=Vb(),c={placement:"top",strategy:"fixed",modifiers:[{name:"focusAfterRender",enabled:!0,phase:"afterWrite",fn(){setTimeout(()=>{a.el&&a.el.focus()},300)}}]};return c=La({},c,{modifiers:Array.from(new Set([...c.modifiers,...b]))})}function jb(a){return qa(a)&&
+""!==a?"-"!==a.charAt(a.length-1)?`${a}-`:a:""}function Ma(a){a=a.options.attachTo||{};let b=Object.assign({},a);if(qa(a.element)){try{b.element=document.querySelector(a.element)}catch(c){}b.element||console.error(`The element for this Shepherd step was not found ${a.element}`)}return b}function Na(){let a=Date.now();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,b=>{let c=(a+16*Math.random())%16|0;a=Math.floor(a/16);return("x"==b?c:c&3|8).toString(16)})}function Xb(a,b){let c={modifiers:[{name:"preventOverflow",
+options:{altAxis:!0,tether:!1}},{name:"focusAfterRender",enabled:!0,phase:"afterWrite",fn(){setTimeout(()=>{b.el&&b.el.focus()},300)}}],strategy:"absolute"};b.isCentered()?c=Wb(b):c.placement=a.on;(a=b.tour&&b.tour.options&&b.tour.options.defaultStepOptions)&&(c=kb(a,c));return c=kb(b.options,c)}function kb(a,b){if(a.popperOptions){let c=Object.assign({},b,a.popperOptions);if(a.popperOptions.modifiers&&0<a.popperOptions.modifiers.length){let d=a.popperOptions.modifiers.map(e=>e.name);b=b.modifiers.filter(e=>
+!d.includes(e.name));c.modifiers=Array.from(new Set([...b,...a.popperOptions.modifiers]))}return c}return b}function G(){}function Yb(a,b){for(let c in b)a[c]=b[c];return a}function ka(a){return a()}function lb(a){return"function"===typeof a}function Q(a,b){return a!=a?b==b:a!==b||a&&"object"===typeof a||"function"===typeof a}function H(a){a.parentNode.removeChild(a)}function mb(a){return document.createElementNS("http://www.w3.org/2000/svg",a)}function ya(a,b,c,d){a.addEventListener(b,c,d);return()=>
+a.removeEventListener(b,c,d)}function B(a,b,c){null==c?a.removeAttribute(b):a.getAttribute(b)!==c&&a.setAttribute(b,c)}function nb(a,b){let c=Object.getOwnPropertyDescriptors(a.__proto__);for(let d in b)null==b[d]?a.removeAttribute(d):"style"===d?a.style.cssText=b[d]:"__value"===d?a.value=a[d]=b[d]:c[d]&&c[d].set?a[d]=b[d]:B(a,d,b[d])}function la(a,b,c){a.classList[c?"add":"remove"](b)}function za(){if(!R)throw Error("Function called outside component initialization");return R}function Oa(a){Aa.push(a)}
+function ob(){let a=R;do{for(;Ba<va.length;){var b=va[Ba];Ba++;R=b;b=b.$$;if(null!==b.fragment){b.update();b.before_update.forEach(ka);var c=b.dirty;b.dirty=[-1];b.fragment&&b.fragment.p(b.ctx,c);b.after_update.forEach(Oa)}}R=null;for(Ba=va.length=0;ma.length;)ma.pop()();for(b=0;b<Aa.length;b+=1)c=Aa[b],Pa.has(c)||(Pa.add(c),c());Aa.length=0}while(va.length);for(;pb.length;)pb.pop()();Qa=!1;Pa.clear();R=a}function Z(){aa={r:0,c:[],p:aa}}function ba(){aa.r||aa.c.forEach(ka);aa=aa.p}function z(a,b){a&&
+a.i&&(Ca.delete(a),a.i(b))}function C(a,b,c,d){a&&a.o&&!Ca.has(a)&&(Ca.add(a),aa.c.push(()=>{Ca.delete(a);d&&(c&&a.d(1),d())}),a.o(b))}function ca(a){a&&a.c()}function W(a,b,c,d){let {fragment:e,on_mount:f,on_destroy:g,after_update:l}=a.$$;e&&e.m(b,c);d||Oa(()=>{let m=f.map(ka).filter(lb);g?g.push(...m):m.forEach(ka);a.$$.on_mount=[]});l.forEach(Oa)}function X(a,b){a=a.$$;null!==a.fragment&&(a.on_destroy.forEach(ka),a.fragment&&a.fragment.d(b),a.on_destroy=a.fragment=null,a.ctx=[])}function S(a,b,
+c,d,e,f,g,l){void 0===l&&(l=[-1]);let m=R;R=a;let k=a.$$={fragment:null,ctx:null,props:f,update:G,not_equal:e,bound:Object.create(null),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(b.context||(m?m.$$.context:[])),callbacks:Object.create(null),dirty:l,skip_bound:!1,root:b.target||m.$$.root};g&&g(k.root);let p=!1;k.ctx=c?c(a,b.props||{},function(q,n){let r=(2>=arguments.length?0:arguments.length-2)?2>=arguments.length?void 0:arguments[2]:n;if(k.ctx&&e(k.ctx[q],
+k.ctx[q]=r)){if(!k.skip_bound&&k.bound[q])k.bound[q](r);p&&(-1===a.$$.dirty[0]&&(va.push(a),Qa||(Qa=!0,Zb.then(ob)),a.$$.dirty.fill(0)),a.$$.dirty[q/31|0]|=1<<q%31)}return n}):[];k.update();p=!0;k.before_update.forEach(ka);k.fragment=d?d(k.ctx):!1;b.target&&(b.hydrate?(c=Array.from(b.target.childNodes),k.fragment&&k.fragment.l(c),c.forEach(H)):k.fragment&&k.fragment.c(),b.intro&&z(a.$$.fragment),W(a,b.target,b.anchor,b.customElement),ob());R=m}function $b(a){let b,c,d,e,f;return{c(){b=document.createElement("button");
+B(b,"aria-label",c=a[3]?a[3]:null);B(b,"class",d=`${a[1]||""} shepherd-button ${a[4]?"shepherd-button-secondary":""}`);b.disabled=a[2];B(b,"tabindex","0")},m(g,l){g.insertBefore(b,l||null);b.innerHTML=a[5];e||(f=ya(b,"click",function(){lb(a[0])&&a[0].apply(this,arguments)}),e=!0)},p(g,l){[l]=l;a=g;l&32&&(b.innerHTML=a[5]);l&8&&c!==(c=a[3]?a[3]:null)&&B(b,"aria-label",c);l&18&&d!==(d=`${a[1]||""} shepherd-button ${a[4]?"shepherd-button-secondary":""}`)&&B(b,"class",d);l&4&&(b.disabled=a[2])},i:G,o:G,
+d(g){g&&H(b);e=!1;f()}}}function ac(a,b,c){function d(n){return ea(n)?n.call(f):n}let {config:e,step:f}=b,g,l,m,k,p,q;a.$$set=n=>{"config"in n&&c(6,e=n.config);"step"in n&&c(7,f=n.step)};a.$$.update=()=>{a.$$.dirty&192&&(c(0,g=e.action?e.action.bind(f.tour):null),c(1,l=e.classes),c(2,m=e.disabled?d(e.disabled):!1),c(3,k=e.label?d(e.label):null),c(4,p=e.secondary),c(5,q=e.text?d(e.text):null))};return[g,l,m,k,p,q,e,f]}function qb(a,b,c){a=a.slice();a[2]=b[c];return a}function rb(a){let b,c,d=a[1],
+e=[];for(let g=0;g<d.length;g+=1)e[g]=sb(qb(a,d,g));let f=g=>C(e[g],1,1,()=>{e[g]=null});return{c(){for(let g=0;g<e.length;g+=1)e[g].c();b=document.createTextNode("")},m(g,l){for(let m=0;m<e.length;m+=1)e[m].m(g,l);g.insertBefore(b,l||null);c=!0},p(g,l){if(l&3){d=g[1];let m;for(m=0;m<d.length;m+=1){let k=qb(g,d,m);e[m]?(e[m].p(k,l),z(e[m],1)):(e[m]=sb(k),e[m].c(),z(e[m],1),e[m].m(b.parentNode,b))}Z();for(m=d.length;m<e.length;m+=1)f(m);ba()}},i(g){if(!c){for(g=0;g<d.length;g+=1)z(e[g]);c=!0}},o(g){e=
+e.filter(Boolean);for(g=0;g<e.length;g+=1)C(e[g]);c=!1},d(g){var l=e;for(let m=0;m<l.length;m+=1)l[m]&&l[m].d(g);g&&H(b)}}}function sb(a){let b,c;b=new bc({props:{config:a[2],step:a[0]}});return{c(){ca(b.$$.fragment)},m(d,e){W(b,d,e);c=!0},p(d,e){let f={};e&2&&(f.config=d[2]);e&1&&(f.step=d[0]);b.$set(f)},i(d){c||(z(b.$$.fragment,d),c=!0)},o(d){C(b.$$.fragment,d);c=!1},d(d){X(b,d)}}}function cc(a){let b,c,d=a[1]&&rb(a);return{c(){b=document.createElement("footer");d&&d.c();B(b,"class","shepherd-footer")},
+m(e,f){e.insertBefore(b,f||null);d&&d.m(b,null);c=!0},p(e,f){[f]=f;e[1]?d?(d.p(e,f),f&2&&z(d,1)):(d=rb(e),d.c(),z(d,1),d.m(b,null)):d&&(Z(),C(d,1,1,()=>{d=null}),ba())},i(e){c||(z(d),c=!0)},o(e){C(d);c=!1},d(e){e&&H(b);d&&d.d()}}}function dc(a,b,c){let d,{step:e}=b;a.$$set=f=>{"step"in f&&c(0,e=f.step)};a.$$.update=()=>{a.$$.dirty&1&&c(1,d=e.options.buttons)};return[e,d]}function ec(a){let b,c,d,e,f;return{c(){b=document.createElement("button");c=document.createElement("span");c.textContent="\u00d7";
+B(c,"aria-hidden","true");B(b,"aria-label",d=a[0].label?a[0].label:"Close Tour");B(b,"class","shepherd-cancel-icon");B(b,"type","button")},m(g,l){g.insertBefore(b,l||null);b.appendChild(c);e||(f=ya(b,"click",a[1]),e=!0)},p(g,l){[l]=l;l&1&&d!==(d=g[0].label?g[0].label:"Close Tour")&&B(b,"aria-label",d)},i:G,o:G,d(g){g&&H(b);e=!1;f()}}}function fc(a,b,c){let {cancelIcon:d,step:e}=b;a.$$set=f=>{"cancelIcon"in f&&c(0,d=f.cancelIcon);"step"in f&&c(2,e=f.step)};return[d,f=>{f.preventDefault();e.cancel()},
+e]}function gc(a){let b;return{c(){b=document.createElement("h3");B(b,"id",a[1]);B(b,"class","shepherd-title")},m(c,d){c.insertBefore(b,d||null);a[3](b)},p(c,d){[d]=d;d&2&&B(b,"id",c[1])},i:G,o:G,d(c){c&&H(b);a[3](null)}}}function hc(a,b,c){let {labelId:d,element:e,title:f}=b;za().$$.after_update.push(()=>{ea(f)&&c(2,f=f());c(0,e.innerHTML=f,e)});a.$$set=g=>{"labelId"in g&&c(1,d=g.labelId);"element"in g&&c(0,e=g.element);"title"in g&&c(2,f=g.title)};return[e,d,f,function(g){ma[g?"unshift":"push"](()=>
+{e=g;c(0,e)})}]}function tb(a){let b,c;b=new ic({props:{labelId:a[0],title:a[2]}});return{c(){ca(b.$$.fragment)},m(d,e){W(b,d,e);c=!0},p(d,e){let f={};e&1&&(f.labelId=d[0]);e&4&&(f.title=d[2]);b.$set(f)},i(d){c||(z(b.$$.fragment,d),c=!0)},o(d){C(b.$$.fragment,d);c=!1},d(d){X(b,d)}}}function ub(a){let b,c;b=new jc({props:{cancelIcon:a[3],step:a[1]}});return{c(){ca(b.$$.fragment)},m(d,e){W(b,d,e);c=!0},p(d,e){let f={};e&8&&(f.cancelIcon=d[3]);e&2&&(f.step=d[1]);b.$set(f)},i(d){c||(z(b.$$.fragment,d),
+c=!0)},o(d){C(b.$$.fragment,d);c=!1},d(d){X(b,d)}}}function kc(a){let b,c,d,e=a[2]&&tb(a),f=a[3]&&a[3].enabled&&ub(a);return{c(){b=document.createElement("header");e&&e.c();c=document.createTextNode(" ");f&&f.c();B(b,"class","shepherd-header")},m(g,l){g.insertBefore(b,l||null);e&&e.m(b,null);b.appendChild(c);f&&f.m(b,null);d=!0},p(g,l){[l]=l;g[2]?e?(e.p(g,l),l&4&&z(e,1)):(e=tb(g),e.c(),z(e,1),e.m(b,c)):e&&(Z(),C(e,1,1,()=>{e=null}),ba());g[3]&&g[3].enabled?f?(f.p(g,l),l&8&&z(f,1)):(f=ub(g),f.c(),
+z(f,1),f.m(b,null)):f&&(Z(),C(f,1,1,()=>{f=null}),ba())},i(g){d||(z(e),z(f),d=!0)},o(g){C(e);C(f);d=!1},d(g){g&&H(b);e&&e.d();f&&f.d()}}}function lc(a,b,c){let {labelId:d,step:e}=b,f,g;a.$$set=l=>{"labelId"in l&&c(0,d=l.labelId);"step"in l&&c(1,e=l.step)};a.$$.update=()=>{a.$$.dirty&2&&(c(2,f=e.options.title),c(3,g=e.options.cancelIcon))};return[d,e,f,g]}function mc(a){let b;return{c(){b=document.createElement("div");B(b,"class","shepherd-text");B(b,"id",a[1])},m(c,d){c.insertBefore(b,d||null);a[3](b)},
+p(c,d){[d]=d;d&2&&B(b,"id",c[1])},i:G,o:G,d(c){c&&H(b);a[3](null)}}}function nc(a,b,c){let {descriptionId:d,element:e,step:f}=b;za().$$.after_update.push(()=>{let {text:g}=f.options;ea(g)&&(g=g.call(f));g instanceof HTMLElement?e.appendChild(g):c(0,e.innerHTML=g,e)});a.$$set=g=>{"descriptionId"in g&&c(1,d=g.descriptionId);"element"in g&&c(0,e=g.element);"step"in g&&c(2,f=g.step)};return[e,d,f,function(g){ma[g?"unshift":"push"](()=>{e=g;c(0,e)})}]}function vb(a){let b,c;b=new oc({props:{labelId:a[1],
+step:a[2]}});return{c(){ca(b.$$.fragment)},m(d,e){W(b,d,e);c=!0},p(d,e){let f={};e&2&&(f.labelId=d[1]);e&4&&(f.step=d[2]);b.$set(f)},i(d){c||(z(b.$$.fragment,d),c=!0)},o(d){C(b.$$.fragment,d);c=!1},d(d){X(b,d)}}}function wb(a){let b,c;b=new pc({props:{descriptionId:a[0],step:a[2]}});return{c(){ca(b.$$.fragment)},m(d,e){W(b,d,e);c=!0},p(d,e){let f={};e&1&&(f.descriptionId=d[0]);e&4&&(f.step=d[2]);b.$set(f)},i(d){c||(z(b.$$.fragment,d),c=!0)},o(d){C(b.$$.fragment,d);c=!1},d(d){X(b,d)}}}function xb(a){let b,
+c;b=new qc({props:{step:a[2]}});return{c(){ca(b.$$.fragment)},m(d,e){W(b,d,e);c=!0},p(d,e){let f={};e&4&&(f.step=d[2]);b.$set(f)},i(d){c||(z(b.$$.fragment,d),c=!0)},o(d){C(b.$$.fragment,d);c=!1},d(d){X(b,d)}}}function rc(a){let b,c=void 0!==a[2].options.title||a[2].options.cancelIcon&&a[2].options.cancelIcon.enabled,d,e=void 0!==a[2].options.text,f,g=Array.isArray(a[2].options.buttons)&&a[2].options.buttons.length,l,m=c&&vb(a),k=e&&wb(a),p=g&&xb(a);return{c(){b=document.createElement("div");m&&m.c();
+d=document.createTextNode(" ");k&&k.c();f=document.createTextNode(" ");p&&p.c();B(b,"class","shepherd-content")},m(q,n){q.insertBefore(b,n||null);m&&m.m(b,null);b.appendChild(d);k&&k.m(b,null);b.appendChild(f);p&&p.m(b,null);l=!0},p(q,n){[n]=n;n&4&&(c=void 0!==q[2].options.title||q[2].options.cancelIcon&&q[2].options.cancelIcon.enabled);c?m?(m.p(q,n),n&4&&z(m,1)):(m=vb(q),m.c(),z(m,1),m.m(b,d)):m&&(Z(),C(m,1,1,()=>{m=null}),ba());n&4&&(e=void 0!==q[2].options.text);e?k?(k.p(q,n),n&4&&z(k,1)):(k=wb(q),
+k.c(),z(k,1),k.m(b,f)):k&&(Z(),C(k,1,1,()=>{k=null}),ba());n&4&&(g=Array.isArray(q[2].options.buttons)&&q[2].options.buttons.length);g?p?(p.p(q,n),n&4&&z(p,1)):(p=xb(q),p.c(),z(p,1),p.m(b,null)):p&&(Z(),C(p,1,1,()=>{p=null}),ba())},i(q){l||(z(m),z(k),z(p),l=!0)},o(q){C(m);C(k);C(p);l=!1},d(q){q&&H(b);m&&m.d();k&&k.d();p&&p.d()}}}function sc(a,b,c){let {descriptionId:d,labelId:e,step:f}=b;a.$$set=g=>{"descriptionId"in g&&c(0,d=g.descriptionId);"labelId"in g&&c(1,e=g.labelId);"step"in g&&c(2,f=g.step)};
+return[d,e,f]}function yb(a){let b;return{c(){b=document.createElement("div");B(b,"class","shepherd-arrow");B(b,"data-popper-arrow","")},m(c,d){c.insertBefore(b,d||null)},d(c){c&&H(b)}}}function tc(a){let b,c,d,e,f,g,l,m,k=a[4].options.arrow&&a[4].options.attachTo&&a[4].options.attachTo.element&&a[4].options.attachTo.on&&yb();d=new uc({props:{descriptionId:a[2],labelId:a[3],step:a[4]}});let p=[{"aria-describedby":e=void 0!==a[4].options.text?a[2]:null},{"aria-labelledby":f=a[4].options.title?a[3]:
+null},a[1],{role:"dialog"},{tabindex:"0"}],q={};for(let n=0;n<p.length;n+=1)q=Yb(q,p[n]);return{c(){b=document.createElement("div");k&&k.c();c=document.createTextNode(" ");ca(d.$$.fragment);nb(b,q);la(b,"shepherd-has-cancel-icon",a[5]);la(b,"shepherd-has-title",a[6]);la(b,"shepherd-element",!0)},m(n,r){n.insertBefore(b,r||null);k&&k.m(b,null);b.appendChild(c);W(d,b,null);a[13](b);g=!0;l||(m=ya(b,"keydown",a[7]),l=!0)},p(n,r){var [x]=r;n[4].options.arrow&&n[4].options.attachTo&&n[4].options.attachTo.element&&
+n[4].options.attachTo.on?k||(k=yb(),k.c(),k.m(b,c)):k&&(k.d(1),k=null);r={};x&4&&(r.descriptionId=n[2]);x&8&&(r.labelId=n[3]);x&16&&(r.step=n[4]);d.$set(r);r=b;x=[(!g||x&20&&e!==(e=void 0!==n[4].options.text?n[2]:null))&&{"aria-describedby":e},(!g||x&24&&f!==(f=n[4].options.title?n[3]:null))&&{"aria-labelledby":f},x&2&&n[1],{role:"dialog"},{tabindex:"0"}];let h={},t={},v={$$scope:1},A=p.length;for(;A--;){let u=p[A],w=x[A];if(w){for(let y in u)y in w||(t[y]=1);for(let y in w)v[y]||(h[y]=w[y],v[y]=
+1);p[A]=w}else for(let y in u)v[y]=1}for(let u in t)u in h||(h[u]=void 0);nb(r,q=h);la(b,"shepherd-has-cancel-icon",n[5]);la(b,"shepherd-has-title",n[6]);la(b,"shepherd-element",!0)},i(n){g||(z(d.$$.fragment,n),g=!0)},o(n){C(d.$$.fragment,n);g=!1},d(n){n&&H(b);k&&k.d();X(d);a[13](null);l=!1;m()}}}function zb(a){return a.split(" ").filter(b=>!!b.length)}function vc(a,b,c){let {classPrefix:d,element:e,descriptionId:f,firstFocusableElement:g,focusableElements:l,labelId:m,lastFocusableElement:k,step:p,
+dataStepId:q}=b,n,r,x;za().$$.on_mount.push(()=>{c(1,q={[`data-${d}shepherd-step-id`]:p.id});c(9,l=e.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]'));c(8,g=l[0]);c(10,k=l[l.length-1])});za().$$.after_update.push(()=>{if(x!==p.options.classes){var h=x;qa(h)&&(h=zb(h),h.length&&e.classList.remove(...h));h=x=p.options.classes;qa(h)&&(h=zb(h),h.length&&e.classList.add(...h))}});a.$$set=h=>{"classPrefix"in
+h&&c(11,d=h.classPrefix);"element"in h&&c(0,e=h.element);"descriptionId"in h&&c(2,f=h.descriptionId);"firstFocusableElement"in h&&c(8,g=h.firstFocusableElement);"focusableElements"in h&&c(9,l=h.focusableElements);"labelId"in h&&c(3,m=h.labelId);"lastFocusableElement"in h&&c(10,k=h.lastFocusableElement);"step"in h&&c(4,p=h.step);"dataStepId"in h&&c(1,q=h.dataStepId)};a.$$.update=()=>{a.$$.dirty&16&&(c(5,n=p.options&&p.options.cancelIcon&&p.options.cancelIcon.enabled),c(6,r=p.options&&p.options.title))};
+return[e,q,f,m,p,n,r,h=>{const {tour:t}=p;switch(h.keyCode){case 9:if(0===l.length){h.preventDefault();break}if(h.shiftKey){if(document.activeElement===g||document.activeElement.classList.contains("shepherd-element"))h.preventDefault(),k.focus()}else document.activeElement===k&&(h.preventDefault(),g.focus());break;case 27:t.options.exitOnEsc&&p.cancel();break;case 37:t.options.keyboardNavigation&&t.back();break;case 39:t.options.keyboardNavigation&&t.next()}},g,l,k,d,()=>e,function(h){ma[h?"unshift":
+"push"](()=>{e=h;c(0,e)})}]}function wc(a){a&&({steps:a}=a,a.forEach(b=>{b.options&&!1===b.options.canClickTarget&&b.options.attachTo&&b.target instanceof HTMLElement&&b.target.classList.remove("shepherd-target-click-disabled")}))}function xc(a){let b,c,d,e,f;return{c(){b=mb("svg");c=mb("path");B(c,"d",a[2]);B(b,"class",d=`${a[1]?"shepherd-modal-is-visible":""} shepherd-modal-overlay-container`)},m(g,l){g.insertBefore(b,l||null);b.appendChild(c);a[11](b);e||(f=ya(b,"touchmove",a[3]),e=!0)},p(g,l){[l]=
+l;l&4&&B(c,"d",g[2]);l&2&&d!==(d=`${g[1]?"shepherd-modal-is-visible":""} shepherd-modal-overlay-container`)&&B(b,"class",d)},i:G,o:G,d(g){g&&H(b);a[11](null);e=!1;f()}}}function Ab(a){if(!a)return null;let b=a instanceof HTMLElement&&window.getComputedStyle(a).overflowY;return"hidden"!==b&&"visible"!==b&&a.scrollHeight>=a.clientHeight?a:Ab(a.parentElement)}function yc(a,b,c){function d(){c(4,p={width:0,height:0,x:0,y:0,r:0})}function e(){c(1,q=!1);l()}function f(h,t,v,A){void 0===h&&(h=0);void 0===
+t&&(t=0);if(A){var u=A.getBoundingClientRect();let y=u.y||u.top;u=u.bottom||y+u.height;if(v){var w=v.getBoundingClientRect();v=w.y||w.top;w=w.bottom||v+w.height;y=Math.max(y,v);u=Math.min(u,w)}let {y:Y,height:E}={y,height:Math.max(u-y,0)},{x:I,width:D,left:na}=A.getBoundingClientRect();c(4,p={width:D+2*h,height:E+2*h,x:(I||na)-h,y:Y-h,r:t})}else d()}function g(){c(1,q=!0)}function l(){n&&(cancelAnimationFrame(n),n=void 0);window.removeEventListener("touchmove",x,{passive:!1})}function m(h){let {modalOverlayOpeningPadding:t,
+modalOverlayOpeningRadius:v}=h.options,A=Ab(h.target),u=()=>{n=void 0;f(t,v,A,h.target);n=requestAnimationFrame(u)};u();window.addEventListener("touchmove",x,{passive:!1})}let {element:k,openingProperties:p}=b;Na();let q=!1,n=void 0,r;d();let x=h=>{h.preventDefault()};a.$$set=h=>{"element"in h&&c(0,k=h.element);"openingProperties"in h&&c(4,p=h.openingProperties)};a.$$.update=()=>{if(a.$$.dirty&16){let {width:h,height:t,x:v=0,y:A=0,r:u=0}=p,{innerWidth:w,innerHeight:y}=window;c(2,r=`M${w},${y}\
+H0\
+V0\
+H${w}\
+V${y}\
+Z\
+M${v+u},${A}\
+a${u},${u},0,0,0-${u},${u}\
+V${t+A-u}\
+a${u},${u},0,0,0,${u},${u}\
+H${h+v-u}\
+a${u},${u},0,0,0,${u}-${u}\
+V${A+u}\
+a${u},${u},0,0,0-${u}-${u}\
+Z`)}};return[k,q,r,h=>{h.stopPropagation()},p,()=>k,d,e,f,function(h){l();h.tour.options.useModalOverlay?(m(h),g()):e()},g,function(h){ma[h?"unshift":"push"](()=>{k=h;c(0,k)})}]}var Fb=function(a){var b;if(b=!!a&&"object"===typeof a)b=Object.prototype.toString.call(a),b=!("[object RegExp]"===b||"[object Date]"===b||a.$$typeof===zc);return b},zc="function"===typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;da.all=function(a,b){if(!Array.isArray(a))throw Error("first argument should be an array");
+return a.reduce(function(c,d){return da(c,d,b)},{})};var Ac=da;class Ra{on(a,b,c,d){void 0===d&&(d=!1);void 0===this.bindings&&(this.bindings={});void 0===this.bindings[a]&&(this.bindings[a]=[]);this.bindings[a].push({handler:b,ctx:c,once:d});return this}once(a,b,c){return this.on(a,b,c,!0)}off(a,b){if(void 0===this.bindings||void 0===this.bindings[a])return this;void 0===b?delete this.bindings[a]:this.bindings[a].forEach((c,d)=>{c.handler===b&&this.bindings[a].splice(d,1)});return this}trigger(a){for(var b=
+arguments.length,c=Array(1<b?b-1:0),d=1;d<b;d++)c[d-1]=arguments[d];void 0!==this.bindings&&this.bindings[a]&&this.bindings[a].forEach((e,f)=>{let {ctx:g,handler:l,once:m}=e;l.apply(g||this,c);m&&this.bindings[a].splice(f,1)});return this}}var ua=["top","bottom","right","left"],fb=ua.reduce(function(a,b){return a.concat([b+"-start",b+"-end"])},[]),eb=[].concat(ua,["auto"]).reduce(function(a,b){return a.concat([b,b+"-start",b+"-end"])},[]),Sb="beforeRead read afterRead beforeMain main afterMain beforeWrite write afterWrite".split(" "),
+L=Math.max,V=Math.min,ia=Math.round,Ib={top:"auto",right:"auto",bottom:"auto",left:"auto"},Da={passive:!0},Jb={left:"right",right:"left",bottom:"top",top:"bottom"},Kb={start:"end",end:"start"},Bb={placement:"bottom",modifiers:[],strategy:"absolute"},Bc=function(a){void 0===a&&(a={});var b=a.defaultModifiers,c=void 0===b?[]:b;a=a.defaultOptions;var d=void 0===a?Bb:a;return function(e,f,g){function l(){k.orderedModifiers.forEach(function(r){var x=r.name,h=r.options;h=void 0===h?{}:h;r=r.effect;"function"===
+typeof r&&(x=r({state:k,name:x,instance:n,options:h}),p.push(x||function(){}))})}function m(){p.forEach(function(r){return r()});p=[]}void 0===g&&(g=d);var k={placement:"bottom",orderedModifiers:[],options:Object.assign({},Bb,d),modifiersData:{},elements:{reference:e,popper:f},attributes:{},styles:{}},p=[],q=!1,n={state:k,setOptions:function(r){r="function"===typeof r?r(k.options):r;m();k.options=Object.assign({},d,k.options,r);k.scrollParents={reference:fa(e)?sa(e):e.contextElement?sa(e.contextElement):
+[],popper:sa(f)};r=Rb(Ub([].concat(c,k.options.modifiers)));k.orderedModifiers=r.filter(function(x){return x.enabled});l();return n.update()},forceUpdate:function(){if(!q){var r=k.elements,x=r.reference;r=r.popper;if(ib(x,r))for(k.rects={reference:Pb(x,ra(r),"fixed"===k.options.strategy),popper:Fa(r)},k.reset=!1,k.placement=k.options.placement,k.orderedModifiers.forEach(function(v){return k.modifiersData[v.name]=Object.assign({},v.data)}),x=0;x<k.orderedModifiers.length;x++)if(!0===k.reset)k.reset=
+!1,x=-1;else{var h=k.orderedModifiers[x];r=h.fn;var t=h.options;t=void 0===t?{}:t;h=h.name;"function"===typeof r&&(k=r({state:k,options:t,name:h,instance:n})||k)}}},update:Tb(function(){return new Promise(function(r){n.forceUpdate();r(k)})}),destroy:function(){m();q=!0}};if(!ib(e,f))return n;n.setOptions(g).then(function(r){if(!q&&g.onFirstUpdate)g.onFirstUpdate(r)});return n}}({defaultModifiers:[{name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:function(a){var b=a.state,c=a.instance;
+a=a.options;var d=a.scroll,e=void 0===d?!0:d;a=a.resize;var f=void 0===a?!0:a,g=K(b.elements.popper),l=[].concat(b.scrollParents.reference,b.scrollParents.popper);e&&l.forEach(function(m){m.addEventListener("scroll",c.update,Da)});f&&g.addEventListener("resize",c.update,Da);return function(){e&&l.forEach(function(m){m.removeEventListener("scroll",c.update,Da)});f&&g.removeEventListener("resize",c.update,Da)}},data:{}},{name:"popperOffsets",enabled:!0,phase:"read",fn:function(a){var b=a.state;b.modifiersData[a.name]=
+db({reference:b.rects.reference,element:b.rects.popper,strategy:"absolute",placement:b.placement})},data:{}},{name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:function(a){var b=a.state,c=a.options;a=c.gpuAcceleration;a=void 0===a?!0:a;var d=c.adaptive;d=void 0===d?!0:d;c=c.roundOffsets;c=void 0===c?!0:c;a={placement:N(b.placement),variation:ja(b.placement),popper:b.elements.popper,popperRect:b.rects.popper,gpuAcceleration:a,isFixed:"fixed"===b.options.strategy};null!=b.modifiersData.popperOffsets&&
+(b.styles.popper=Object.assign({},b.styles.popper,$a(Object.assign({},a,{offsets:b.modifiersData.popperOffsets,position:b.options.strategy,adaptive:d,roundOffsets:c}))));null!=b.modifiersData.arrow&&(b.styles.arrow=Object.assign({},b.styles.arrow,$a(Object.assign({},a,{offsets:b.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:c}))));b.attributes.popper=Object.assign({},b.attributes.popper,{"data-popper-placement":b.placement})},data:{}},{name:"applyStyles",enabled:!0,phase:"write",
+fn:function(a){var b=a.state;Object.keys(b.elements).forEach(function(c){var d=b.styles[c]||{},e=b.attributes[c]||{},f=b.elements[c];F(f)&&M(f)&&(Object.assign(f.style,d),Object.keys(e).forEach(function(g){var l=e[g];!1===l?f.removeAttribute(g):f.setAttribute(g,!0===l?"":l)}))})},effect:function(a){var b=a.state,c={popper:{position:b.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(b.elements.popper.style,c.popper);b.styles=c;b.elements.arrow&&
+Object.assign(b.elements.arrow.style,c.arrow);return function(){Object.keys(b.elements).forEach(function(d){var e=b.elements[d],f=b.attributes[d]||{};d=Object.keys(b.styles.hasOwnProperty(d)?b.styles[d]:c[d]).reduce(function(g,l){g[l]="";return g},{});F(e)&&M(e)&&(Object.assign(e.style,d),Object.keys(f).forEach(function(g){e.removeAttribute(g)}))})}},requires:["computeStyles"]},{name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:function(a){var b=a.state,c=a.name;a=a.options.offset;
+var d=void 0===a?[0,0]:a;a=eb.reduce(function(g,l){var m=b.rects;var k=N(l);var p=0<=["left","top"].indexOf(k)?-1:1,q="function"===typeof d?d(Object.assign({},m,{placement:l})):d;m=q[0];q=q[1];m=m||0;q=(q||0)*p;k=0<=["left","right"].indexOf(k)?{x:q,y:m}:{x:m,y:q};g[l]=k;return g},{});var e=a[b.placement],f=e.x;e=e.y;null!=b.modifiersData.popperOffsets&&(b.modifiersData.popperOffsets.x+=f,b.modifiersData.popperOffsets.y+=e);b.modifiersData[c]=a}},{name:"flip",enabled:!0,phase:"main",fn:function(a){var b=
+a.state,c=a.options;a=a.name;if(!b.modifiersData[a]._skip){var d=c.mainAxis;d=void 0===d?!0:d;var e=c.altAxis;e=void 0===e?!0:e;var f=c.fallbackPlacements,g=c.padding,l=c.boundary,m=c.rootBoundary,k=c.altBoundary,p=c.flipVariations,q=void 0===p?!0:p,n=c.allowedAutoPlacements;c=b.options.placement;p=N(c);f=f||(p!==c&&q?Ob(c):[xa(c)]);var r=[c].concat(f).reduce(function(E,I){return E.concat("auto"===N(I)?Nb(b,{placement:I,boundary:l,rootBoundary:m,padding:g,flipVariations:q,allowedAutoPlacements:n}):
+I)},[]);c=b.rects.reference;f=b.rects.popper;var x=new Map;p=!0;for(var h=r[0],t=0;t<r.length;t++){var v=r[t],A=N(v),u="start"===ja(v),w=0<=["top","bottom"].indexOf(A),y=w?"width":"height",Y=ta(b,{placement:v,boundary:l,rootBoundary:m,altBoundary:k,padding:g});u=w?u?"right":"left":u?"bottom":"top";c[y]>f[y]&&(u=xa(u));y=xa(u);w=[];d&&w.push(0>=Y[A]);e&&w.push(0>=Y[u],0>=Y[y]);if(w.every(function(E){return E})){h=v;p=!1;break}x.set(v,w)}if(p)for(d=function(E){var I=r.find(function(D){if(D=x.get(D))return D.slice(0,
+E).every(function(na){return na})});if(I)return h=I,"break"},e=q?3:1;0<e&&"break"!==d(e);e--);b.placement!==h&&(b.modifiersData[a]._skip=!0,b.placement=h,b.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}},{name:"preventOverflow",enabled:!0,phase:"main",fn:function(a){var b=a.state,c=a.options;a=a.name;var d=c.mainAxis,e=void 0===d?!0:d;d=c.altAxis;var f=void 0===d?!1:d;d=c.tether;var g=void 0===d?!0:d;d=c.tetherOffset;var l=void 0===d?0:d,m=ta(b,{boundary:c.boundary,rootBoundary:c.rootBoundary,
+padding:c.padding,altBoundary:c.altBoundary}),k=N(b.placement),p=ja(b.placement),q=!p,n=Ga(k);c="x"===n?"y":"x";d=b.modifiersData.popperOffsets;var r=b.rects.reference,x=b.rects.popper;l="function"===typeof l?l(Object.assign({},b.rects,{placement:b.placement})):l;var h="number"===typeof l?{mainAxis:l,altAxis:l}:Object.assign({mainAxis:0,altAxis:0},l),t=b.modifiersData.offset?b.modifiersData.offset[b.placement]:null;l={x:0,y:0};if(d){if(e){var v,A="y"===n?"top":"left",u="y"===n?"bottom":"right",w=
+"y"===n?"height":"width";e=d[n];var y=e+m[A],Y=e-m[u],E=g?-x[w]/2:0,I="start"===p?r[w]:x[w];p="start"===p?-x[w]:-r[w];var D=b.elements.arrow;D=g&&D?Fa(D):{width:0,height:0};var na=b.modifiersData["arrow#persistent"]?b.modifiersData["arrow#persistent"].padding:{top:0,right:0,bottom:0,left:0};A=na[A];u=na[u];D=L(0,V(r[w],D[w]));I=q?r[w]/2-E-D-A-h.mainAxis:I-D-A-h.mainAxis;q=q?-r[w]/2+E+D+u+h.mainAxis:p+D+u+h.mainAxis;w=(w=b.elements.arrow&&ra(b.elements.arrow))?"y"===n?w.clientTop||0:w.clientLeft||
+0:0;E=null!=(v=null==t?void 0:t[n])?v:0;v=e+q-E;y=g?V(y,e+I-E-w):y;v=g?L(Y,v):Y;v=L(y,V(e,v));d[n]=v;l[n]=v-e}if(f){var J;f=d[c];e="y"===c?"height":"width";v=f+m["x"===n?"top":"left"];m=f-m["x"===n?"bottom":"right"];k=-1!==["top","left"].indexOf(k);n=null!=(J=null==t?void 0:t[c])?J:0;J=k?v:f-r[e]-x[e]-n+h.altAxis;r=k?f+r[e]+x[e]-n-h.altAxis:m;g&&k?(J=L(J,V(f,r)),J=J>r?r:J):J=L(g?J:v,V(f,g?r:m));d[c]=J;l[c]=J-f}b.modifiersData[a]=l}},requiresIfExists:["offset"]},{name:"arrow",enabled:!0,phase:"main",
+fn:function(a){var b,c=a.state,d=a.name,e=a.options,f=c.elements.arrow,g=c.modifiersData.popperOffsets,l=N(c.placement);a=Ga(l);l=0<=["left","right"].indexOf(l)?"height":"width";if(f&&g){e=e.padding;e="function"===typeof e?e(Object.assign({},c.rects,{placement:c.placement})):e;e=Ya("number"!==typeof e?e:Za(e,ua));var m=Fa(f),k="y"===a?"top":"left",p="y"===a?"bottom":"right",q=c.rects.reference[l]+c.rects.reference[a]-g[a]-c.rects.popper[l];g=g[a]-c.rects.reference[a];f=(f=ra(f))?"y"===a?f.clientHeight||
+0:f.clientWidth||0:0;g=f/2-m[l]/2+(q/2-g/2);l=L(e[k],V(g,f-m[l]-e[p]));c.modifiersData[d]=(b={},b[a]=l,b.centerOffset=l-g,b)}},effect:function(a){var b=a.state;a=a.options.element;a=void 0===a?"[data-popper-arrow]":a;if(null!=a){if("string"===typeof a&&(a=b.elements.popper.querySelector(a),!a))return;Wa(b.elements.popper,a)&&(b.elements.arrow=a)}},requires:["popperOffsets"],requiresIfExists:["preventOverflow"]},{name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:function(a){var b=
+a.state;a=a.name;var c=b.rects.reference,d=b.rects.popper,e=b.modifiersData.preventOverflow,f=ta(b,{elementContext:"reference"}),g=ta(b,{altBoundary:!0});c=gb(f,c);d=gb(g,d,e);e=hb(c);g=hb(d);b.modifiersData[a]={referenceClippingOffsets:c,popperEscapeOffsets:d,isReferenceHidden:e,hasPopperEscaped:g};b.attributes.popper=Object.assign({},b.attributes.popper,{"data-popper-reference-hidden":e,"data-popper-escaped":g})}}]});let R,va=[],ma=[],Aa=[],pb=[],Zb=Promise.resolve(),Qa=!1,Pa=new Set,Ba=0,Ca=new Set,
+aa;class T{$destroy(){X(this,1);this.$destroy=G}$on(a,b){let c=this.$$.callbacks[a]||(this.$$.callbacks[a]=[]);c.push(b);return()=>{let d=c.indexOf(b);-1!==d&&c.splice(d,1)}}$set(a){this.$$set&&0!==Object.keys(a).length&&(this.$$.skip_bound=!0,this.$$set(a),this.$$.skip_bound=!1)}}class bc extends T{constructor(a){super();S(this,a,ac,$b,Q,{config:6,step:7})}}class qc extends T{constructor(a){super();S(this,a,dc,cc,Q,{step:0})}}class jc extends T{constructor(a){super();S(this,a,fc,ec,Q,{cancelIcon:0,
+step:2})}}class ic extends T{constructor(a){super();S(this,a,hc,gc,Q,{labelId:1,element:0,title:2})}}class oc extends T{constructor(a){super();S(this,a,lc,kc,Q,{labelId:0,step:1})}}class pc extends T{constructor(a){super();S(this,a,nc,mc,Q,{descriptionId:1,element:0,step:2})}}class uc extends T{constructor(a){super();S(this,a,sc,rc,Q,{descriptionId:0,labelId:1,step:2})}}class Cc extends T{constructor(a){super();S(this,a,vc,tc,Q,{classPrefix:11,element:0,descriptionId:2,firstFocusableElement:8,focusableElements:9,
+labelId:3,lastFocusableElement:10,step:4,dataStepId:1,getElement:12})}get getElement(){return this.$$.ctx[12]}}var Cb=function(a,b){return b={exports:{}},a(b,b.exports),b.exports}(function(a,b){(function(){a.exports={polyfill:function(){function c(h,t){this.scrollLeft=h;this.scrollTop=t}function d(h){if(null===h||"object"!==typeof h||void 0===h.behavior||"auto"===h.behavior||"instant"===h.behavior)return!0;if("object"===typeof h&&"smooth"===h.behavior)return!1;throw new TypeError("behavior member of ScrollOptions "+
+h.behavior+" is not a valid value for enumeration ScrollBehavior.");}function e(h,t){if("Y"===t)return h.clientHeight+x<h.scrollHeight;if("X"===t)return h.clientWidth+x<h.scrollWidth}function f(h,t){h=k.getComputedStyle(h,null)["overflow"+t];return"auto"===h||"scroll"===h}function g(h){var t=e(h,"Y")&&f(h,"Y");h=e(h,"X")&&f(h,"X");return t||h}function l(h){var t=(r()-h.startTime)/468;var v=.5*(1-Math.cos(Math.PI*(1<t?1:t)));t=h.startX+(h.x-h.startX)*v;v=h.startY+(h.y-h.startY)*v;h.method.call(h.scrollable,
+t,v);t===h.x&&v===h.y||k.requestAnimationFrame(l.bind(k,h))}function m(h,t,v){var A=r();if(h===p.body){var u=k;var w=k.scrollX||k.pageXOffset;h=k.scrollY||k.pageYOffset;var y=n.scroll}else u=h,w=h.scrollLeft,h=h.scrollTop,y=c;l({scrollable:u,method:y,startTime:A,startX:w,startY:h,x:t,y:v})}var k=window,p=document;if(!("scrollBehavior"in p.documentElement.style&&!0!==k.__forceSmoothScrollPolyfill__)){var q=k.HTMLElement||k.Element,n={scroll:k.scroll||k.scrollTo,scrollBy:k.scrollBy,elementScroll:q.prototype.scroll||
+c,scrollIntoView:q.prototype.scrollIntoView},r=k.performance&&k.performance.now?k.performance.now.bind(k.performance):Date.now,x=/MSIE |Trident\/|Edge\//.test(k.navigator.userAgent)?1:0;k.scroll=k.scrollTo=function(h,t){void 0!==h&&(!0===d(h)?n.scroll.call(k,void 0!==h.left?h.left:"object"!==typeof h?h:k.scrollX||k.pageXOffset,void 0!==h.top?h.top:void 0!==t?t:k.scrollY||k.pageYOffset):m.call(k,p.body,void 0!==h.left?~~h.left:k.scrollX||k.pageXOffset,void 0!==h.top?~~h.top:k.scrollY||k.pageYOffset))};
+k.scrollBy=function(h,t){void 0!==h&&(d(h)?n.scrollBy.call(k,void 0!==h.left?h.left:"object"!==typeof h?h:0,void 0!==h.top?h.top:void 0!==t?t:0):m.call(k,p.body,~~h.left+(k.scrollX||k.pageXOffset),~~h.top+(k.scrollY||k.pageYOffset)))};q.prototype.scroll=q.prototype.scrollTo=function(h,t){if(void 0!==h)if(!0===d(h)){if("number"===typeof h&&void 0===t)throw new SyntaxError("Value could not be converted");n.elementScroll.call(this,void 0!==h.left?~~h.left:"object"!==typeof h?~~h:this.scrollLeft,void 0!==
+h.top?~~h.top:void 0!==t?~~t:this.scrollTop)}else t=h.left,h=h.top,m.call(this,this,"undefined"===typeof t?this.scrollLeft:~~t,"undefined"===typeof h?this.scrollTop:~~h)};q.prototype.scrollBy=function(h,t){void 0!==h&&(!0===d(h)?n.elementScroll.call(this,void 0!==h.left?~~h.left+this.scrollLeft:~~h+this.scrollLeft,void 0!==h.top?~~h.top+this.scrollTop:~~t+this.scrollTop):this.scroll({left:~~h.left+this.scrollLeft,top:~~h.top+this.scrollTop,behavior:h.behavior}))};q.prototype.scrollIntoView=function(h){if(!0===
+d(h))n.scrollIntoView.call(this,void 0===h?!0:h);else{for(h=this;h!==p.body&&!1===g(h);)h=h.parentNode||h.host;var t=h.getBoundingClientRect(),v=this.getBoundingClientRect();h!==p.body?(m.call(this,h,h.scrollLeft+v.left-t.left,h.scrollTop+v.top-t.top),"fixed"!==k.getComputedStyle(h).position&&k.scrollBy({left:t.left,top:t.top,behavior:"smooth"})):k.scrollBy({left:v.left,top:v.top,behavior:"smooth"})}}}}}})()});Cb.polyfill;Cb.polyfill();class Sa extends Ra{constructor(a,b){void 0===b&&(b={});super(a,
+b);this.tour=a;this.classPrefix=this.tour.options?jb(this.tour.options.classPrefix):"";this.styles=a.styles;Va(this);this._setOptions(b);return this}cancel(){this.tour.cancel();this.trigger("cancel")}complete(){this.tour.complete();this.trigger("complete")}destroy(){this.tooltip&&(this.tooltip.destroy(),this.tooltip=null);this.el instanceof HTMLElement&&this.el.parentNode&&(this.el.parentNode.removeChild(this.el),this.el=null);this._updateStepTargetOnHide();this.trigger("destroy")}getTour(){return this.tour}hide(){this.tour.modal.hide();
+this.trigger("before-hide");this.el&&(this.el.hidden=!0);this._updateStepTargetOnHide();this.trigger("hide")}isCentered(){let a=Ma(this);return!a.element||!a.on}isOpen(){return!(!this.el||this.el.hidden)}show(){if(ea(this.options.beforeShowPromise)){let a=this.options.beforeShowPromise();if(void 0!==a)return a.then(()=>this._show())}this._show()}updateStepOptions(a){Object.assign(this.options,a);this.shepherdElementComponent&&this.shepherdElementComponent.$set({step:this})}getElement(){return this.el}getTarget(){return this.target}_createTooltipContent(){this.shepherdElementComponent=
+new Cc({target:this.tour.options.stepsContainer||document.body,props:{classPrefix:this.classPrefix,descriptionId:`${this.id}-description`,labelId:`${this.id}-label`,step:this,styles:this.styles}});return this.shepherdElementComponent.getElement()}_scrollTo(a){let {element:b}=Ma(this);ea(this.options.scrollToHandler)?this.options.scrollToHandler(b):b instanceof Element&&"function"===typeof b.scrollIntoView&&b.scrollIntoView(a)}_getClassOptions(a){var b=this.tour&&this.tour.options&&this.tour.options.defaultStepOptions;
+b=b&&b.classes?b.classes:"";a=[...(a.classes?a.classes:"").split(" "),...b.split(" ")];a=new Set(a);return Array.from(a).join(" ").trim()}_setOptions(a){void 0===a&&(a={});let b=this.tour&&this.tour.options&&this.tour.options.defaultStepOptions;b=Ac({},b||{});this.options=Object.assign({arrow:!0},b,a);let {when:c}=this.options;this.options.classes=this._getClassOptions(a);this.destroy();this.id=this.options.id||`step-${Na()}`;c&&Object.keys(c).forEach(d=>{this.on(d,c[d],this)})}_setupElements(){void 0!==
+this.el&&this.destroy();this.el=this._createTooltipContent();this.options.advanceOn&&Hb(this);this.tooltip&&this.tooltip.destroy();let a=Ma(this),b=a.element,c=Xb(a,this);this.isCentered()&&(b=document.body,this.shepherdElementComponent.getElement().classList.add("shepherd-centered"));this.tooltip=Bc(b,this.el,c);this.target=a.element}_show(){this.trigger("before-show");this._setupElements();this.tour.modal||this.tour._setupModal();this.tour.modal.setupForStep(this);this._styleTargetElementForStep(this);
+this.el.hidden=!1;this.options.scrollTo&&setTimeout(()=>{this._scrollTo(this.options.scrollTo)});this.el.hidden=!1;let a=this.shepherdElementComponent.getElement(),b=this.target||document.body;b.classList.add(`${this.classPrefix}shepherd-enabled`);b.classList.add(`${this.classPrefix}shepherd-target`);a.classList.add("shepherd-enabled");this.trigger("show")}_styleTargetElementForStep(a){let b=a.target;b&&(a.options.highlightClass&&b.classList.add(a.options.highlightClass),b.classList.remove("shepherd-target-click-disabled"),
+!1===a.options.canClickTarget&&b.classList.add("shepherd-target-click-disabled"))}_updateStepTargetOnHide(){let a=this.target||document.body;this.options.highlightClass&&a.classList.remove(this.options.highlightClass);a.classList.remove("shepherd-target-click-disabled",`${this.classPrefix}shepherd-enabled`,`${this.classPrefix}shepherd-target`)}}class Dc extends T{constructor(a){super();S(this,a,yc,xc,Q,{element:0,openingProperties:4,getElement:5,closeModalOpening:6,hide:7,positionModal:8,setupForStep:9,
+show:10})}get getElement(){return this.$$.ctx[5]}get closeModalOpening(){return this.$$.ctx[6]}get hide(){return this.$$.ctx[7]}get positionModal(){return this.$$.ctx[8]}get setupForStep(){return this.$$.ctx[9]}get show(){return this.$$.ctx[10]}}let oa=new Ra;class Ec extends Ra{constructor(a){void 0===a&&(a={});super(a);Va(this);this.options=Object.assign({},{exitOnEsc:!0,keyboardNavigation:!0},a);this.classPrefix=jb(this.options.classPrefix);this.steps=[];this.addSteps(this.options.steps);"active cancel complete inactive show start".split(" ").map(b=>
+{(c=>{this.on(c,d=>{d=d||{};d.tour=this;oa.trigger(c,d)})})(b)});this._setTourID();return this}addStep(a,b){a instanceof Sa?a.tour=this:a=new Sa(this,a);void 0!==b?this.steps.splice(b,0,a):this.steps.push(a);return a}addSteps(a){Array.isArray(a)&&a.forEach(b=>{this.addStep(b)});return this}back(){let a=this.steps.indexOf(this.currentStep);this.show(a-1,!1)}cancel(){this.options.confirmCancel?window.confirm(this.options.confirmCancelMessage||"Are you sure you want to stop the tour?")&&this._done("cancel"):
+this._done("cancel")}complete(){this._done("complete")}getById(a){return this.steps.find(b=>b.id===a)}getCurrentStep(){return this.currentStep}hide(){let a=this.getCurrentStep();if(a)return a.hide()}isActive(){return oa.activeTour===this}next(){let a=this.steps.indexOf(this.currentStep);a===this.steps.length-1?this.complete():this.show(a+1,!0)}removeStep(a){let b=this.getCurrentStep();this.steps.some((c,d)=>{if(c.id===a)return c.isOpen()&&c.hide(),c.destroy(),this.steps.splice(d,1),!0});b&&b.id===
+a&&(this.currentStep=void 0,this.steps.length?this.show(0):this.cancel())}show(a,b){void 0===a&&(a=0);void 0===b&&(b=!0);if(a=qa(a)?this.getById(a):this.steps[a])this._updateStateBeforeShow(),ea(a.options.showOn)&&!a.options.showOn()?this._skipStep(a,b):(this.trigger("show",{step:a,previous:this.currentStep}),this.currentStep=a,a.show())}start(){this.trigger("start");this.focusedElBeforeOpen=document.activeElement;this.currentStep=null;this._setupModal();this._setupActiveTour();this.next()}_done(a){let b=
+this.steps.indexOf(this.currentStep);Array.isArray(this.steps)&&this.steps.forEach(c=>c.destroy());wc(this);this.trigger(a,{index:b});oa.activeTour=null;this.trigger("inactive",{tour:this});this.modal&&this.modal.hide();"cancel"!==a&&"complete"!==a||!this.modal||(a=document.querySelector(".shepherd-modal-overlay-container"))&&a.remove();this.focusedElBeforeOpen instanceof HTMLElement&&this.focusedElBeforeOpen.focus()}_setupActiveTour(){this.trigger("active",{tour:this});oa.activeTour=this}_setupModal(){this.modal=
+new Dc({target:this.options.modalContainer||document.body,props:{classPrefix:this.classPrefix,styles:this.styles}})}_skipStep(a,b){a=this.steps.indexOf(a);a=b?a+1:a-1;a===this.steps.length-1?this.complete():this.show(a,b)}_updateStateBeforeShow(){this.currentStep&&this.currentStep.hide();this.isActive()||this._setupActiveTour()}_setTourID(){this.id=`${this.options.tourName||"tour"}--${Na()}`}}Object.assign(oa,{Tour:Ec,Step:Sa});return oa})

+ 2 - 2
resources/package.json

@@ -1,6 +1,6 @@
 {
   "name": "Logseq",
-  "version": "0.7.0",
+  "version": "0.7.1",
   "main": "electron.js",
   "author": "Logseq",
   "license": "AGPL-3.0",
@@ -36,7 +36,7 @@
     "https-proxy-agent": "5.0.0",
     "@sentry/electron": "2.5.1",
     "posthog-js": "1.10.2",
-    "@logseq/rsapi": "0.0.17",
+    "@logseq/rsapi": "0.0.20",
     "electron-deeplink": "1.0.10"
   },
   "devDependencies": {

+ 1 - 0
scripts/bump-version.sh

@@ -58,6 +58,7 @@ $SED -i 's/defonce version ".*"/defonce version "'${NEW_VERSION}'"/g' src/main/f
 $SED -i 's/"version": ".*"/"version": "'${NEW_VERSION}'"/g' resources/package.json
 $SED -i 's/versionName ".*"/versionName "'${NEW_VERSION}'"/g' android/app/build.gradle
 $SED -i 's/versionCode .*/versionCode '${NEW_VERSION_CODE}'/g' android/app/build.gradle
+$SED -i 's/MARKETING_VERSION = .*;/MARKETING_VERSION = '${NEW_VERSION}';/g' ios/App/App.xcodeproj/project.pbxproj
 
 git --no-pager diff -U0
 

+ 1 - 1
scripts/carve.clj

@@ -7,7 +7,7 @@
 
 (require '[babashka.pods :as pods])
 
-(pods/load-pod 'clj-kondo/clj-kondo "2021.12.19")
+(pods/load-pod 'clj-kondo/clj-kondo "2022.02.09")
 (require '[pod.borkdude.clj-kondo :as clj-kondo])
 ;; define clj-kondo.core ns which is used by carve
 (intern (create-ns 'clj-kondo.core) 'run! clj-kondo/run!)

+ 9 - 5
scripts/large_vars.clj

@@ -5,12 +5,13 @@
   the team to maintain and understand them."
   (:require [babashka.pods :as pods]
             [clojure.pprint :as pprint]
+            [clojure.edn :as edn]
             [clojure.set :as set]))
 
-(pods/load-pod 'clj-kondo/clj-kondo "2021.12.19")
+(pods/load-pod 'clj-kondo/clj-kondo "2022.02.09")
 (require '[pod.borkdude.clj-kondo :as clj-kondo])
 
-(def config
+(def default-config
   ;; TODO: Discuss with team and agree on lower number
   {:max-lines-count 100
    ;; Vars with these metadata flags are allowed. Name should indicate the reason
@@ -23,11 +24,14 @@
 
 (defn -main
   [args]
-  (let [paths (or args ["src"])
+  (let [paths [(or (first args) "src")]
+        config (or (some->> (second args) edn/read-string (merge default-config))
+                   default-config)
         {{:keys [var-definitions]} :analysis}
         (clj-kondo/run!
          {:lint paths
-          :config {:output {:analysis {:var-definitions {:meta true}}}}})
+          :config {:output {:analysis {:var-definitions {:meta true
+                                                         :lang :cljs}}}}})
         vars (->> var-definitions
                   (keep (fn [m]
                           (let [lines-count (inc (- (:end-row m) (:row m)))]
@@ -40,7 +44,7 @@
                   (sort-by :lines-count (fn [x y] (compare y x))))]
     (if (seq vars)
       (do
-        (println (format "The following vars exceed the line count max of %s:"
+        (println (format "\nThe following vars exceed the line count max of %s:"
                          (:max-lines-count config)))
         (pprint/print-table vars)
         (System/exit 1))

+ 1 - 1
scripts/src/logseq/tasks/dev.clj

@@ -34,7 +34,7 @@
   - lint invalid translation entries
   - Lint datalog rules"
   []
-  (doseq [cmd ["clojure -M:clj-kondo --parallel --lint src"
+  (doseq [cmd ["clojure -M:clj-kondo --parallel --lint src --cache false"
                "scripts/carve.clj"
                "scripts/large_vars.clj"
                "bb lang:invalid-translations"

+ 75 - 45
scripts/src/logseq/tasks/file_sync.clj

@@ -3,23 +3,23 @@
 
 * Login to electron app and toggle file-sync on
 * Set up file-sync-auth.json file per #'read-config
-* Run `bb file-sync:integration-tests GRAPH_DIRECTORY`
+* Run `bb file-sync:integration-tests`
 * Wait for test results. Each action takes 10-20s and prints results as it goes"
   (:require [clojure.string :as str]
             [cheshire.core :as json]
+            [clojure.pprint :as pp]
             [babashka.fs :as fs]
             [babashka.curl :as curl]
             [clojure.data :as data]
-            [clojure.test :as t :refer [deftest is]])
+            [clojure.test :as t :refer [deftest is]]
+            [logseq.tasks.file-sync-actions :as file-sync-actions])
   (:import (java.net URLDecoder)))
 
-(def root-dir
-  "Root directory for graph that is being tested"
-  (atom nil))
+;; Root directory for graph that is being tested
+(defonce root-dir (atom nil))
 
-(def root-graph-id
-  "Graph id for given graph"
-  (atom nil))
+;; Graph id for given graph
+(defonce root-graph-id (atom nil))
 
 (defn- read-config*
   []
@@ -42,8 +42,8 @@
 
 (defn- build-headers
   []
-  (let [{:strs [access_token]} (read-config)]
-    {"authorization" (str "Bearer " access_token)}))
+  (let [{:strs [id_token]} (read-config)]
+    {"authorization" (str "Bearer " id_token)}))
 
 (defn- api-get-all-files
   [graph-id subdir]
@@ -85,8 +85,19 @@
   (fs/move (fs/file dir file)
            (fs/file dir new-file)))
 
+(defmethod run-action* :update-file
+  [{{:keys [file blocks dir]} :args}]
+  (let [origin-content (slurp (fs/file dir file))
+        new-content (str (str/trim-newline origin-content) "\n"
+                         (->> blocks
+                              (map #(str "- " %))
+                              (str/join "\n")))]
+    (spit (fs/file dir file) new-content)))
+
 (defn run-action [action-map]
-  (println "\n===\nRUN" (pr-str action-map) "\n===")
+  (println "==\nRUN")
+  (pp/pprint ((juxt :action #(get-in % [:args :file])) action-map))
+  (println "===")
   (run-action* action-map))
 
 (defn- ensure-dir-is-synced!
@@ -119,45 +130,64 @@
 
 (defn- files-are-in-sync?
   [dir graph-id subdir]
+  (try (ensure-dir-is-synced! dir graph-id subdir)
+       true
+       (catch Throwable e
+         (println (.getMessage e))
+         false)))
+
+(defn- wait&files-are-in-sync?
+  [dir graph-id subdir & [msg]]
   ;; Approximate polling time before file changes are picked up by client
-  (println "Wait 10s for logseq to pick up changes...")
+  (if msg
+    (println msg)
+    (println "Wait 10s for logseq to pick up changes..."))
   (Thread/sleep 10000)
-  (try-fn-n-times (fn []
-                    (try (ensure-dir-is-synced! dir graph-id subdir)
-                      true
-                      (catch Throwable e
-                        (println (.getMessage e))
-                        false)))
-                  10))
-
-(deftest file-changes
+  (try-fn-n-times #(files-are-in-sync? dir graph-id subdir) 10))
+
+(defn- clear-dir-pages
+  [subdir]
+  (fs/delete-tree (str @root-dir "/" subdir))
+  (fs/create-dir (str @root-dir "/" subdir)))
+
+(deftest rand-file-changes
   (let [subdir "pages"
-        ;; Directory must be in sync in order for assertions to pass
-        _ (ensure-dir-is-synced! @root-dir @root-graph-id subdir)
-        ;; These actions are data driven which allows us to spec to generate them
-        ;; when the API is able to handle more randomness
+        actions (:generated-action (file-sync-actions/generate-rand-actions 30))
         actions (mapv
                  #(assoc-in % [:args :dir] @root-dir)
-                 [{:action :create-file
-                   :args {:file (str subdir "/test.create-page.md")
-                          :blocks ["hello world"]}}
-                  {:action :move-file
-                   :args {:file (str subdir "/test.create-page.md")
-                          :new-file (str subdir "/test.create-page-new.md")}}
-                  {:action :delete-file
-                   :args {:file (str subdir "/test.create-page-new.md")}}])]
-
-    (doseq [action-map actions]
-      (run-action action-map)
-      (is (files-are-in-sync? @root-dir @root-graph-id subdir)
-          (str "Test " (select-keys action-map [:action]))))))
-
-(defn integration-tests
-  "Run file-sync integration tests on graph directory"
-  [dir & _args]
-  (let [graph-names-to-ids (api-post-get-graphs)
+                 actions)
+        partitioned-actions (partition-all 3 actions)]
+    (clear-dir-pages subdir)
+    (wait&files-are-in-sync? @root-dir @root-graph-id subdir
+                             (format "clear dir [%s], and ensure it's in sync" subdir))
+    (doseq [actions partitioned-actions]
+      (doseq [action actions]
+        (run-action action)
+        (Thread/sleep 500))
+      (is (wait&files-are-in-sync? @root-dir @root-graph-id subdir)
+          (str "Test " (mapv (juxt :action #(get-in % [:args :file])) actions))))))
+
+(defn setup-vars
+  []
+  (let [{:strs [dir]} (read-config)
+        graph-names-to-ids (api-post-get-graphs)
         graph-id (get graph-names-to-ids (fs/file-name dir))]
     (assert dir "No graph id for given dir")
     (reset! root-dir dir)
-    (reset! root-graph-id graph-id)
-    (t/run-tests 'logseq.tasks.file-sync)))
+    (reset! root-graph-id graph-id)))
+
+(defn integration-tests
+  "Run file-sync integration tests on graph directory
+  requirements:
+
+  * file-sync-auth.json, and it looks like:
+  ```
+  {\"id_token\":\"<id-token>\",
+    \"dir\": \"/Users/me/Documents/untitled folder 31\"}
+  ```
+
+  * you alse need to open logseq-app(or yarn electron-watch),
+    and open <dir> and start file-sync"
+  [& _args]
+  (setup-vars)
+  (t/run-tests 'logseq.tasks.file-sync))

+ 164 - 0
scripts/src/logseq/tasks/file_sync_actions.clj

@@ -0,0 +1,164 @@
+(ns logseq.tasks.file-sync-actions
+  (:require [clojure.test.check.generators :as gen]))
+
+
+(defmulti gen-action* (fn [& args] (first args)))
+
+(defmethod gen-action* :create-file
+  [_ page-index & _args]
+  (gen/let [blocks (gen/vector gen/string-alphanumeric 1 10)]
+    {:action :create-file
+     :args {:file (format "pages/test.page-%d.md" page-index)
+            :blocks blocks}}))
+
+(defmethod gen-action* :move-file
+  [_ origin-page-index & [moved?]]
+  (let [page-name (if moved?
+                      (format "pages/test.page-move-%d.md" origin-page-index)
+                      (format "pages/test.page-%d.md" origin-page-index))]
+    (gen/return
+     {:action :move-file
+      :args {:file page-name
+             :new-file (format "pages/test.page-move-%d.md" origin-page-index)}})))
+
+(defmethod gen-action* :update-file
+  [_ page-index & [moved?]]
+  (gen/let [append-blocks (gen/vector gen/string-alphanumeric 1 10)]
+    (let [page-name (if moved?
+                      (format "pages/test.page-move-%d.md" page-index)
+                      (format "pages/test.page-%d.md" page-index))]
+      {:action :update-file
+       :args {:file page-name
+              :blocks append-blocks}})))
+
+(defmethod gen-action* :delete-file
+  [_ page-index & [moved?]]
+  (let [page-name (if moved?
+                    (format "pages/test.page-move-%d.md" page-index)
+                    (format "pages/test.page-%d.md" page-index))]
+    (gen/return
+     {:action :delete-file
+      :args {:file page-name}})))
+
+
+(defmacro gen-actions-plan
+  "state monad
+  state: {:page-index [{:index 1 :moved? false}, ...]
+          :generated-action [...]}
+
+  (gen-actions-plan
+     [id+moved? get-rand-available-index-op
+      _ (when-op id+moved? (apply action-op action id+moved?))]
+     nil)"
+  [binds val-expr]
+  (let [binds (partition 2 binds)
+        psym (gensym "state_")
+        forms (reduce (fn [acc [id expr]]
+                        (concat acc `[[~id ~psym] (~expr ~psym)]))
+                      []
+                      binds)]
+    `(fn [~psym]
+       (let [~@forms]
+         [~val-expr ~psym]))))
+
+(defn- all-indexes
+  [state]
+  (let [r (map :index (:page-index state))]
+    (if (empty? r) '(0) r)))
+
+(defn- add-index
+  [state index moved?]
+  (update state :page-index conj {:index index :moved? moved?}))
+
+(defn- assign-page-index-op
+  [state]
+  (let [max-index (apply max (all-indexes state))
+          next-index (inc max-index)]
+      [next-index (add-index state next-index false)]))
+
+(defn- get-rand-available-index-op
+  [state]
+  (let [indexes (:page-index state)]
+    (if (empty? indexes)
+      [nil state]
+      (let [rand-index (rand-nth (vec indexes))]
+        [((juxt :index :moved?) rand-index) state]))))
+
+(defn- action-op
+  [action id & args]
+  (fn [state]
+    (let [generated-action (gen/generate (apply gen-action* action id args))
+          [moved?] args
+          state* (update state :generated-action conj generated-action)
+          state* (case action
+                   :move-file
+                   (update state* :page-index
+                           #(-> %
+                                (disj {:index id :moved? (boolean moved?)})
+                                (conj {:index id :moved? true})))
+                   :delete-file
+                   (update state* :page-index
+                           #(disj % {:index id :moved? (boolean moved?)}))
+                   state*)]
+      [nil state*])))
+
+(defmacro when-op
+  [x f]
+  `(fn [state#]
+     (if ~x
+       (~f state#)
+       [nil state#])))
+
+(defn- print-op
+  [x]
+  (fn [state]
+    (println x)
+    [nil state]))
+
+
+(defn rand-action-op
+  []
+  (let [action (gen/generate
+                (gen/frequency [[5 (gen/return :update-file)]
+                                [2 (gen/return :create-file)]
+                                [2 (gen/return :move-file)]
+                                [1 (gen/return :delete-file)]]))]
+    (case action
+      :create-file
+      (gen-actions-plan
+       [id assign-page-index-op
+        _ (action-op action id)]
+       nil)
+      :update-file
+      (gen-actions-plan
+       [id+moved? get-rand-available-index-op
+        _ (when-op id+moved? (apply action-op action id+moved?))]
+       nil)
+      :move-file
+      (gen-actions-plan
+       [id+moved? get-rand-available-index-op
+        _ (when-op id+moved? (apply action-op action id+moved?))]
+       nil)
+      :delete-file
+      (gen-actions-plan
+       [id+moved? get-rand-available-index-op
+        _ (when-op id+moved? (apply action-op action id+moved? ))]
+       nil))))
+
+(def empty-actions-plan {:page-index #{}
+                         :generated-action []})
+
+
+(defmacro generate-rand-actions
+  [max-n & {:keys [pre-create-files-n] :or {pre-create-files-n 2}}]
+  (let [pre-create-files-binds
+        (for [id (map (fn [_] (gensym)) (range pre-create-files-n))]
+          `[~id assign-page-index-op
+            ~'_ (action-op :create-file ~id)])
+        binds (apply concat
+                     (concat pre-create-files-binds (repeat max-n `[~'_ (rand-action-op)])))]
+    `(second
+      ((gen-actions-plan
+        ~binds
+        nil)
+       empty-actions-plan))))

+ 25 - 8
scripts/src/logseq/tasks/nbb.clj

@@ -1,15 +1,16 @@
 (ns logseq.tasks.nbb
   (:require [pod.borkdude.clj-kondo :as clj-kondo]
+            [clojure.string :as str]
             [babashka.tasks :refer [shell]]))
 
 (defn- fetch-meta-namespaces
   "Return namespaces with metadata"
   [paths]
-  (let [paths (or (seq paths) ["src"])
-        {{:keys [namespace-definitions]} :analysis}
+  (let [{{:keys [namespace-definitions]} :analysis}
         (clj-kondo/run!
          {:lint paths
-          :config {:output {:analysis {:namespace-definitions {:meta true}}}}})
+          :config {:output {:analysis {:namespace-definitions {:meta true
+                                                               :lang :cljs}}}}})
         matches (keep (fn [m]
                         (when (:meta m)
                           {:ns   (:name m)
@@ -17,14 +18,30 @@
                       namespace-definitions)]
     matches))
 
+(defn- validate-namespaces
+  [namespaces classpath dir]
+  (assert (seq namespaces) "There must be some namespaces to check")
+  ;; distinct b/c sometimes namespaces are duplicated with .cljc analysis
+  (doseq [n (distinct namespaces)]
+    (println "Requiring" n "...")
+    (shell {:dir dir} "yarn nbb-logseq -cp" classpath "-e" (format "(require '[%s])" n)))
+  (println "Success!"))
+
 (defn load-compatible-namespaces
   "Check nbb-compatible namespaces can be required by nbb-logseq"
   []
   (let [namespaces (map :ns
                         (filter #(get-in % [:meta :nbb-compatible])
                                 (fetch-meta-namespaces ["src/main"])))]
-    (assert (seq namespaces) "There must be some nbb namespaces to check")
-    (doseq [n namespaces]
-      (println "Requiring" n "...")
-      (shell "yarn nbb-logseq -cp src/main -e" (format "(require '[%s])" n)))
-    (println "Success!")))
+    (validate-namespaces namespaces "src/main" ".")))
+
+(defn load-all-namespaces
+  "Check all namespaces in source path(s) can be required by nbb-logseq"
+  [dir & paths]
+  (let [{{:keys [namespace-definitions]} :analysis}
+        (clj-kondo/run!
+         {:lint (map #(str dir "/" %) paths)
+          :config {:output {:analysis {:namespace-definitions {:lang :cljs}}}}})]
+    (validate-namespaces (map :name namespace-definitions)
+                         (str/join ":" paths)
+                         dir)))

+ 48 - 2
src/electron/electron/core.cljs

@@ -1,7 +1,7 @@
 (ns electron.core
   (:require [electron.handler :as handler]
             [electron.search :as search]
-            [electron.updater :refer [init-updater]]
+            [electron.updater :refer [init-updater] :as updater]
             [electron.utils :refer [*win mac? linux? dev? logger get-win-from-sender restore-user-fetch-agent]]
             [electron.url :refer [logseq-url-handler]]
             [clojure.string :as string]
@@ -11,7 +11,7 @@
             ["fs-extra" :as fs]
             ["path" :as path]
             ["os" :as os]
-            ["electron" :refer [BrowserWindow app protocol ipcMain dialog] :as electron]
+            ["electron" :refer [BrowserWindow Menu app protocol ipcMain dialog shell] :as electron]
             ["electron-deeplink" :refer [Deeplink]]
             [clojure.core.async :as async]
             [electron.state :as state]
@@ -180,6 +180,51 @@
          (.removeHandler ipcMain call-app-channel)
          (.removeHandler ipcMain call-win-channel))))
 
+(defn- set-app-menu! []
+  (let [about-fn (fn []
+                   (.showMessageBox dialog (clj->js {:title "Logseq"
+                                                     :icon (path/join js/__dirname "icons/logseq.png")
+                                                     :message (str "Version " updater/electron-version)})))
+        template (if mac?
+                   [{:label (.-name app)
+                     :submenu [{:role "about"}
+                               {:type "separator"}
+                               {:role "services"}
+                               {:type "separator"}
+                               {:role "hide"}
+                               {:role "hideOthers"}
+                               {:role "unhide"}
+                               {:type "separator"}
+                               {:role "quit"}]}]
+                   [])
+        template (conj template
+                       {:role "fileMenu"
+                        :submenu [{:label "New Window"
+                                   :click (fn []
+                                            (handler/open-new-window!))
+                                   :accelerator "CommandOrControl+N"
+                                   :acceleratorWorksWhenHidden false}
+                                  (if mac?
+                                    {:role "close"}
+                                    {:role "quit"})]}
+                       {:role "editMenu"}
+                       {:role "viewMenu"}
+                       {:role "windowMenu"})
+        ;; Windows has no about role
+        template (conj template
+                       (if mac?
+                         {:role "help"
+                          :submenu [{:label "Official Documentation"
+                                     :click #(.openExternal shell "https://docs.logseq.com/")}]}
+                         {:role "help"
+                          :submenu [{:label "Official Documentation"
+                                     :click #(.openExternal shell "https://docs.logseq.com/")}
+                                    {:role "about"
+                                     :label "About Logseq"
+                                     :click about-fn}]}))
+        menu (.buildFromTemplate Menu (clj->js template))]
+    (.setApplicationMenu Menu menu)))
+
 (defn- setup-deeplink! []
   ;; Works for Deeplink v1.0.9
   ;; :mainWindow is only used for handeling window restoring on second-instance,
@@ -210,6 +255,7 @@
                              {:scheme     FILE_LSP_SCHEME
                               :privileges privileges}]))
 
+      (set-app-menu!)
       (setup-deeplink!)
 
       (.on app "second-instance"

+ 4 - 2
src/electron/electron/file_sync_rsapi.cljs

@@ -1,8 +1,10 @@
 (ns electron.file-sync-rsapi
   (:require ["@logseq/rsapi" :as rsapi]))
 
-(defn set-env [env secret-key public-key]
-  (rsapi/setEnv env secret-key public-key))
+(defn key-gen [] (rsapi/keygen))
+
+(defn set-env [env private-key public-key]
+  (rsapi/setEnv env private-key public-key))
 
 (defn get-local-files-meta [graph-uuid base-path file-paths]
   (rsapi/getLocalFilesMeta graph-uuid base-path (clj->js file-paths)))

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

@@ -450,6 +450,9 @@
 ;; file-sync-rs-apis ;;
 ;;;;;;;;;;;;;;;;;;;;;;;
 
+(defmethod handle :key-gen [_]
+  (rsapi/key-gen))
+
 (defmethod handle :set-env [_ args]
   (apply rsapi/set-env (rest args)))
 

+ 86 - 16
src/main/frontend/components/block.cljs

@@ -53,6 +53,7 @@
             [frontend.util :as util]
             [frontend.util.clock :as clock]
             [frontend.util.drawer :as drawer]
+            [frontend.util.text :as text-util]
             [frontend.util.property :as property]
             [logseq.graph-parser.config :as gp-config]
             [logseq.graph-parser.util :as gp-util]
@@ -65,6 +66,8 @@
             [promesa.core :as p]
             [reitit.frontend.easy :as rfe]
             [rum.core :as rum]
+            [frontend.fs :as fs]
+            [frontend.handler.file-sync :as file-sync]
             [shadow.loader :as loader]))
 
 (defn safe-read-string
@@ -173,6 +176,60 @@
                 parts (remove #(string/blank? %) parts)]
             (string/join "/" (reverse parts))))))))
 
+(rum/defcs asset-loader
+  < rum/reactive
+    (rum/local nil ::exist?)
+    (rum/local false ::loading?)
+    {:will-mount  (fn [state]
+                    (let [src (first (:rum/args state))]
+                      (if (and (gp-config/local-asset? src)
+                               (file-sync/current-graph-sync-on?))
+                        (let [*exist? (::exist? state)
+                              asset-path (string/replace src (str gp-config/local-assets-dir "://") "")]
+                          (if (string/blank? asset-path)
+                            (reset! *exist? false)
+                            (-> (fs/file-exists? "" asset-path)
+                                (p/then
+                                  (fn [exist?]
+                                    (reset! *exist? (boolean exist?))))))
+                          (assoc state ::asset-path asset-path ::asset-file? true))
+                        state)))
+     :will-update (fn [state]
+                    (let [src (first (:rum/args state))
+                          asset-file? (boolean (::asset-file? state))
+                          sync-on? (file-sync/current-graph-sync-on?)
+                          *loading? (::loading? state)
+                          *exist? (::exist? state)]
+                      (when (and sync-on? asset-file? (false? @*exist?))
+                        (let [sync-state (state/sub [:file-sync/sync-state (state/get-current-repo)])
+                              _downloading-files (:current-remote->local-files sync-state)
+                              contain-url? (and (seq _downloading-files)
+                                                (some #(string/ends-with? src %) _downloading-files))]
+                          (cond
+                            (and (not @*loading?) contain-url?)
+                            (reset! *loading? true)
+
+                            (and @*loading? (not contain-url?))
+                            (do
+                              (reset! *exist? true)
+                              (reset! *loading? false))))))
+                    state)}
+  [state _src content-fn]
+  (let [_ (state/sub [:file-sync/sync-state (state/get-current-repo)])
+        exist? @(::exist? state)
+        loading? @(::loading? state)
+        asset-file? (::asset-file? state)
+        sync-enabled? (boolean (file-sync/current-graph-sync-on?))]
+
+    (if (not sync-enabled?)
+      (content-fn)
+      (if (and asset-file? (or loading? (nil? exist?)))
+        [:p.text-sm.opacity-50 (ui/loading "Loading image ...")]
+        (if (or (not asset-file?)
+                (and exist? (not loading?)))
+          (content-fn)
+          [:p.text-red-500.text-xs [:small.opacity-80 "Image not found!"]])))))
+
 (defonce *resizing-image? (atom false))
 (rum/defcs resizable-image <
   (rum/local nil ::size)
@@ -280,8 +337,9 @@
           (contains? config/audio-formats ext)
           (audio-cp @src)
 
-          (contains? (config/img-formats) ext)
-          (resizable-image config title @src metadata full_text true)
+          (contains? (gp-config/img-formats) ext)
+          (asset-loader @src
+            #(resizable-image config title @src metadata full_text true))
 
           (= ext :pdf)
           [:a.asset-ref.is-pdf {:href @src
@@ -825,7 +883,7 @@
         (nil? metadata-show)
         (or
          (gp-config/local-asset? s)
-         (text/media-link? media-formats s)))
+         (text-util/media-link? media-formats s)))
        (true? (boolean metadata-show))))
 
      ;; markdown
@@ -834,7 +892,7 @@
      ;; image http link
      (and (or (string/starts-with? full-text "http://")
               (string/starts-with? full-text "https://"))
-          (text/media-link? media-formats s)))))
+          (text-util/media-link? media-formats s)))))
 
 (defn- relative-assets-path->absolute-path
   [path]
@@ -1114,7 +1172,7 @@
 (defn- macro-vimeo-cp
   [_config arguments]
   (when-let [url (first arguments)]
-    (when-let [vimeo-id (nth (util/safe-re-find text/vimeo-regex url) 5)]
+    (when-let [vimeo-id (nth (util/safe-re-find text-util/vimeo-regex url) 5)]
       (when-not (string/blank? vimeo-id)
         (let [width (min (- (util/get-width) 96)
                          560)
@@ -1134,7 +1192,7 @@
     (when-let [id (cond
                     (<= (count url) 15) url
                     :else
-                    (nth (util/safe-re-find text/bilibili-regex url) 5))]
+                    (nth (util/safe-re-find text-util/bilibili-regex url) 5))]
       (when-not (string/blank? id)
         (let [width (min (- (util/get-width) 96)
                          560)
@@ -1155,7 +1213,7 @@
     (let [width (min (- (util/get-width) 96)
                      560)
           height (int (* width (/ 315 560)))
-          results (text/get-matched-video url)
+          results (text-util/get-matched-video url)
           src (match results
                      [_ _ _ (:or "youtube.com" "youtu.be" "y2u.be") _ id _]
                      (if (= (count id) 11) ["youtube-player" id] url)
@@ -1303,7 +1361,7 @@
         (when-let [youtube-id (cond
                                 (== 11 (count url)) url
                                 :else
-                                (nth (util/safe-re-find text/youtube-regex url) 5))]
+                                (nth (util/safe-re-find text-util/youtube-regex url) 5))]
           (when-not (string/blank? youtube-id)
             (youtube/youtube-video youtube-id))))
 
@@ -1794,6 +1852,9 @@
        (int? v)
        v
 
+       (= k :file-path)
+       v
+
        date
        date
 
@@ -2023,7 +2084,7 @@
                                (util/clear-selection!)))}
        (not slide?)
        (merge attrs))
-     
+
      [:<>
       [:div.flex.flex-row.justify-between
        [:div.flex-1
@@ -2345,7 +2406,7 @@
   (let [refs (model/get-page-names-by-ids
               (->> (map :db/id refs)
                    (remove nil?)))]
-    (text/build-data-value refs)))
+    (text-util/build-data-value refs)))
 
 (defn- get-children-refs
   [children]
@@ -2466,14 +2527,14 @@
                         (block-handler/on-touch-move event block uuid *show-left-menu? *show-right-menu?))
        :on-touch-end (fn [event]
                        (block-handler/on-touch-end event block uuid *show-left-menu? *show-right-menu?))
-       :on-touch-cancel block-handler/on-touch-cancel 
+       :on-touch-cancel block-handler/on-touch-cancel
        :on-mouse-over (fn [e]
                         (block-mouse-over uuid e *control-show? block-id doc-mode?))
        :on-mouse-leave (fn [e]
                          (block-mouse-leave e *control-show? block-id doc-mode?))}
       (when (not slide?)
         (block-control config block uuid block-id collapsed? *control-show? edit?))
-      
+
       (when @*show-left-menu?
         (block-left-menu config block))
       (block-content-or-editor config block edit-input-id block-id heading-level edit?)
@@ -2485,7 +2546,7 @@
      (dnd-separator-wrapper block block-id slide? false false)]))
 
 (rum/defcs block-container < rum/reactive
-  (rum/local false ::show-block-left-menu?) 
+  (rum/local false ::show-block-left-menu?)
   (rum/local false ::show-block-right-menu?)
   {:init (fn [state]
            (let [[config block] (:rum/args state)
@@ -2734,6 +2795,8 @@
   [state config {:keys [title query view collapsed? children? breadcrumb-show? table-view?] :as q}]
   (let [dsl-query? (:dsl-query? config)
         query-atom (:query-atom state)
+        repo (state/get-current-repo)
+        view-fn (if (keyword? view) (state/sub [:config repo :query/views view]) view)
         current-block-uuid (or (:block/uuid (:block config))
                                (:block/uuid config))
         current-block (db/entity [:block/uuid current-block-uuid])
@@ -2754,7 +2817,7 @@
         _ (when-let [query-result (:query-result config)]
             (let [result (remove (fn [b] (some? (get-in b [:block/properties :template]))) result)]
               (reset! query-result result)))
-        view-f (and view (sci/eval-string (pr-str view)))
+        view-f (and view-fn (sci/eval-string (pr-str view-fn)))
         only-blocks? (:block/uuid (first result))
         blocks-grouped-by-page? (and (seq result)
                                      (not not-grouped-by-page?)
@@ -2773,8 +2836,8 @@
       (when-not (and built-in? (empty? result))
         [:div.custom-query.mt-4 (get config :attr {})
          (ui/foldable
-          [:div.custom-query-title
-           [:span.title-text (cond
+          [:div.custom-query-title.flex.justify-between.w-full
+           [:div [:span.title-text (cond
                                (vector? title) title
                                (string? title) (inline-text config
                                                             (get-in config [:block :block/format] :markdown)
@@ -2782,6 +2845,13 @@
                                :else title)]
            [:span.opacity-60.text-sm.ml-2.results-count
             (str (count transformed-query-result) " results")]]
+           ;;insert an "edit" button in the query view
+           [:a.opacity-70.hover:opacity-100.svg-small.inline 
+            {:on-mouse-down (fn [e]
+                              (util/stop e)
+                              (editor-handler/edit-block! current-block :max (:block/uuid current-block)))}
+            svg/edit]]
+          
           (fn []
             [:div
              (when (and current-block (not view-f) (nil? table-view?))

+ 2 - 7
src/main/frontend/components/editor.cljs

@@ -23,8 +23,8 @@
             [logseq.graph-parser.util :as gp-util]
             [goog.dom :as gdom]
             [promesa.core :as p]
-            [rum.core :as rum]
-            [frontend.mobile.footer :as footer]))
+            [react-draggable]
+            [rum.core :as rum]))
 
 (rum/defc commands < rum/reactive
   [id format]
@@ -523,11 +523,6 @@
         heading-class (get-editor-style-class content format)]
     [:div.editor-inner {:class (if block "block-editor" "non-block-editor")}
 
-     (when (= (state/sub :editor/record-status) "RECORDING")
-       [:div#audio-record-toolbar
-        {:style {:bottom (+ @util/keyboard-height 45)}}
-        (footer/audio-record-cp)])
-
      (ui/ls-textarea
       {:id                id
        :cacheMeasurements (editor-row-height-unchanged?) ;; check when content updated (as the content variable is binded)

+ 2 - 2
src/main/frontend/components/editor.css

@@ -1,12 +1,12 @@
 #audio-record-toolbar {
     position: fixed;
     background-color: var(--ls-secondary-background-color);
-    width: 88px;
+    width: 90px;
     justify-content: left;
     left: 5px;
     transition: none;
     z-index: 9999;
-    padding: 5px 5px 0px 5px;
+    padding: 5px 5px 5px 8px;
     border-radius: 5px;
 }
 

+ 22 - 16
src/main/frontend/components/encryption.cljs

@@ -50,25 +50,25 @@
   (fn [close-fn]
     (encryption-dialog-inner repo-url close-fn)))
 
-(rum/defcs input-password-inner <
+(rum/defcs input-password-inner < rum/reactive
   (rum/local "" ::password)
   (rum/local "" ::password-confirm)
-  [state repo-url close-fn {:keys [type GraphName GraphUUID repo]}]
+  [state repo-url close-fn {:keys [type GraphName GraphUUID]}]
   (let [password (get state ::password)
         password-confirm (get state ::password-confirm)
         local-pw?  (= type :local)
-        verify-pw? (= type :input-pwd-remote)]
+        verify-pw? (= type :input-pwd-remote)
+        loading? (state/sub [:ui/loading? :set-graph-password])]
     [:div.sm:max-w-2xl
      [:div.sm:flex.sm:items-start
       [:div.mt-3.text-center.sm:mt-0.sm:text-left
        [:h3#modal-headline.text-lg.leading-6.font-medium.font-bold
-        (if verify-pw? "What's the password of your remote graph?" "Enter a password")]]]
+        (if verify-pw? "What's the password for this graph?" "Enter a password")]]]
 
-     (when-not verify-pw?
-       (ui/admonition
-         :warning
-         [:div.opacity-70
-          "Choose a strong and hard to guess password.\nIf you lose your password, all the data can't be decrypted!! Please make sure you remember the password you have set, or you can keep a secure backup of the password."]))
+     (ui/admonition
+      :warning
+      [:div.opacity-70
+       "Choose a strong and hard to guess password.\nIf you lose your password, all the data can't be decrypted!! Please make sure you remember the password you have set, or you can keep a secure backup of the password."])
 
      (when-not local-pw?
        [:p.px-2.pb-2
@@ -112,13 +112,19 @@
                                   (close-fn true))
 
                            (:create-pwd-remote :input-pwd-remote)
-                           (a/go
-                             (let [persist-r (a/<! (sync/encrypt+persist-pwd! @password GraphUUID repo))]
-                               (if (instance? ExceptionInfo persist-r)
-                                 (js/console.error persist-r)
-                                 (notification/show! (str "Successfully set the password for graph: " GraphName) :success)))
-                             (close-fn true))))))}
-        "Submit"]]]]))
+                           (do
+                             (state/set-state! [:ui/loading? :set-graph-password] true)
+                             (a/go
+                              (let [persist-r (a/<! (sync/encrypt+persist-pwd! @password GraphUUID))]
+                                (if (instance? ExceptionInfo persist-r)
+                                  (js/console.error persist-r)
+                                  (notification/show! (str "Successfully set the password") :success)))
+                              (state/set-state! [:ui/loading? :set-graph-password] false)
+                              (close-fn true)))))))}
+        [:span.inline-flex
+         [:span "Submit"]
+         (when loading?
+           [:span.ml-2 (ui/loading "")])]]]]]))
 
 (defn input-password
   ([repo-url close-fn] (input-password repo-url close-fn {:type :local}))

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

@@ -126,5 +126,6 @@
      [:div.mt-4
       (ui/button (if @copied? "Copied to clipboard!" "Copy to clipboard")
         :on-click (fn []
-                    (util/copy-to-clipboard! content (= type :html))
+                    (util/copy-to-clipboard! content (when (= type :html)
+                                                       content))
                     (reset! copied? true)))]]))

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

@@ -5,7 +5,6 @@
             [datascript.core :as d]
             [frontend.components.lazy-editor :as lazy-editor]
             [frontend.components.svg :as svg]
-            [frontend.config :as config]
             [frontend.context.i18n :refer [t]]
             [frontend.date :as date]
             [frontend.db :as db]
@@ -74,7 +73,8 @@
         format (gp-util/get-format path)
         original-name (db/get-file-page path)
         random-id (str (d/squuid))]
-    [:div.file {:id (str "file-edit-wrapper-" random-id)}
+    [:div.file {:id (str "file-edit-wrapper-" random-id)
+                :key path}
      [:h1.title
       [:bdi (js/decodeURI path)]]
      (when original-name
@@ -99,10 +99,10 @@
 
      (cond
        ;; image type
-       (and format (contains? (config/img-formats) format))
+       (and format (contains? (gp-config/img-formats) format))
        [:img {:src path}]
 
-       (and format (contains? (config/text-formats) format))
+       (and format (contains? (gp-config/text-formats) format))
        (when-let [file-content (db/get-file path)]
          (let [content (string/trim file-content)
                mode (util/get-file-ext path)]

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

@@ -40,7 +40,7 @@
                    (state/set-state! :file-sync/toggling? true)
                    (if-not graph-txid-exists?
                      (as/go
-                       (notifications/show! "Not a remote graph, ready to init remote graph!" :warn)
+                       (notifications/show! "Going to init a remote graph!" :warn)
                        (let [repo (state/get-current-repo)
                              GraphName (util/node-path.basename repo)]
                          (when-let [GraphUUID (get (as/<! (file-sync-handler/create-graph GraphName)) 2)]

+ 5 - 0
src/main/frontend/components/file_sync.css

@@ -99,6 +99,11 @@
       > .py-1 {
         padding: 0;
       }
+
+      .menu-link {
+        white-space: normal;
+        word-break: break-all;
+      }
     }
   }
 }

+ 17 - 7
src/main/frontend/components/header.cljs

@@ -33,19 +33,26 @@
 
 (rum/defc login < rum/reactive
   []
-  (let [_ (state/sub :auth/id-token)]
+  (let [_ (state/sub :auth/id-token)
+        loading? (state/sub [:ui/loading? :login])]
     (when-not (or config/publishing?
                   (user-handler/logged-in?))
-      [:a.button.text-sm.font-medium.block {:on-click #(js/window.open config/LOGIN-URL)}
-         [:span (t :login)]])))
+      [:a.button.text-sm.font-medium.block {:on-click
+                                            #(do
+                                               (state/set-state! [:ui/loading? :login] true)
+                                               (js/window.open config/LOGIN-URL))}
+       [:span (t :login)]
+       (when loading?
+         [:span.ml-2 (ui/loading "")])])))
 
 (rum/defc left-menu-button < rum/reactive
   [{:keys [on-click]}]
   (ui/with-shortcut :ui/toggle-left-sidebar "bottom"
     [:a#left-menu.cp__header-left-menu.button
      {:on-click on-click
-      :style {:margin-left 12}}
-     (ui/icon "menu-2" {:style {:fontSize ui/icon-size}})]))
+      :style    {:margin-left 12}}
+     [:span.inner
+      (ui/icon "menu-2" {:style {:fontSize ui/icon-size}})]]))
 
 (rum/defc dropdown-menu < rum/reactive
   [{:keys [current-repo t]}]
@@ -148,7 +155,9 @@
         left-menu (left-menu-button {:on-click (fn []
                                        (open-fn)
                                        (state/set-left-sidebar-open!
-                                        (not (:ui/left-sidebar-open? @state/state))))})]
+                                        (not (:ui/left-sidebar-open? @state/state))))})
+        graph-file-sync-init-downloading? (:downloading?
+                                           (state/sub [:file-sync/download-init-progress (state/get-current-repo)]))]
     [:div.cp__header#head
      {:class           (util/classnames [{:electron-mac   electron-mac?
                                           :native-ios     (mobile-util/native-ios?)
@@ -179,7 +188,8 @@
              (ui/icon "chevron-left" {:style {:fontSize 25}})])))]
 
      [:div.r.flex
-      (when-not file-sync-handler/hiding-login&file-sync
+      (when-not (or file-sync-handler/hiding-login&file-sync
+                    graph-file-sync-init-downloading?)
         (fs-sync/indicator))
       (when-not file-sync-handler/hiding-login&file-sync
         (login))

+ 111 - 94
src/main/frontend/components/header.css

@@ -1,5 +1,5 @@
 .cp__header {
-  @apply z-10;  
+  @apply z-10;
   -webkit-app-region: drag;
 
   padding-top: var(--ls-headbar-inner-top-padding);
@@ -31,9 +31,10 @@
   }
 
   /* To prevent header glitch on Safari */
+
   > .l, > .r {
-      -webkit-transform: translate3d(0, 0, 0);
-      transform: translate3d(0, 0, 0);
+    -webkit-transform: translate3d(0, 0, 0);
+    transform: translate3d(0, 0, 0);
   }
 
   .it svg {
@@ -104,7 +105,6 @@
 
   .dropdown-wrapper {
     .ti {
-      margin-right: 5px;
       opacity: .9;
     }
   }
@@ -119,6 +119,18 @@
       top: 1px;
     }
   }
+
+  &-left-menu {
+    &.button {
+      margin: 0;
+      padding: 0;
+    }
+
+    > .inner {
+      line-height: 0;
+      padding: 3px;
+    }
+  }
 }
 
 .is-electron.is-mac .cp__header {
@@ -189,6 +201,10 @@ a.button {
   &:hover, &.active {
     opacity: 1;
     background: none;
+
+    @screen md {
+      background: var(--ls-tertiary-background-color);
+    }
   }
 
   &:active {
@@ -201,6 +217,7 @@ a.button {
 }
 
 html.is-ios.is-safari {
+
   .cp__header {
     background-color: var(--ls-primary-background-color);
   }
@@ -214,130 +231,130 @@ html.is-native-iphone,
 html.is-native-iphone-without-notch,
 html.is-native-ipad {
 
-     #main-container {
-         padding-top: 0px;
-         display: flex;
-         flex-direction: column;
-    }
+  #main-container {
+    padding-top: 0px;
+    display: flex;
+    flex-direction: column;
+  }
 
-     #main-content-container {
-         padding-left: 22px;
-         padding-right: 14px;
-         padding-top: 0px;
-         height: calc(100vh - var(--ls-headbar-inner-top-padding) - var(--ls-headbar-height));
+  #main-content-container {
+    padding-left: 22px;
+    padding-right: 14px;
+    padding-top: 0px;
+    height: calc(100vh - var(--ls-headbar-inner-top-padding) - var(--ls-headbar-height));
 
-         @screen sm {
-             padding-left: 2rem;
-         }
+    @screen sm {
+      padding-left: 2rem;
+    }
 
-         .page {
-             margin-top: 24px;
-         }
+    .page {
+      margin-top: 24px;
     }
+  }
 
-     .cp__header {
-         > .r {
-             display: flex;
-         }
+  .cp__header {
+    > .r {
+      display: flex;
+    }
 
-         a.button {
-             opacity: 1;
-         }
+    a.button {
+      opacity: 1;
     }
+  }
 }
 
 html.is-native-ipad {
-    --ls-headbar-inner-top-padding: 0px;
-    --ls-headbar-height: 4rem;
+  --ls-headbar-inner-top-padding: 0px;
+  --ls-headbar-height: 4rem;
 
-    .cp__header {
-      background-color: transparent !important;
-      display: flex;
+  .cp__header {
+    background-color: transparent !important;
+    display: flex;
 
-      > .l {
-        /* background-color: var(--ls-primary-background-color); */
-        padding-top: 20px;
-      }
+    > .l {
+      /* background-color: var(--ls-primary-background-color); */
+      padding-top: 20px;
+    }
 
-      > .r {
-        flex: 1;
-        background-color: var(--ls-primary-background-color);
-        height: 100%;
-        padding-top: 20px;
-        justify-content: flex-end;
-        align-items: center;
-      }
+    > .r {
+      flex: 1;
+      background-color: var(--ls-primary-background-color);
+      height: 100%;
+      padding-top: 20px;
+      justify-content: flex-end;
+      align-items: center;
     }
+  }
 
-    .left-sidebar-inner  {
-        > .wrap {
-            padding-top: 20px;
-      }
+  .left-sidebar-inner  {
+    > .wrap {
+      padding-top: 20px;
     }
+  }
 
-    .cp__right-sidebar {
-        &-settings {
-            margin-top: -4px;
-        }
-
-        &-topbar {
-            padding-top: 37px;
-        }
-
-        &-inner {
-            .resizer {
-                top: 30vh;
-                width: 12px;
-                height: 40vh;
-            }
-
-            .resizer:hover {
-                background-color: var(--ls-guideline-color, #ddd);
-            }
-        }
+  .cp__right-sidebar {
+    &-settings {
+      margin-top: -4px;
     }
-}
 
-html.is-native-iphone {
-    --ls-headbar-inner-top-padding: 36px;
+    &-topbar {
+      padding-top: 37px;
+    }
 
-    .left-sidebar-inner {
-        > .wrap {
-            padding-top: 12px;
-        }
+    &-inner {
+      .resizer {
+        top: 30vh;
+        width: 12px;
+        height: 40vh;
+      }
 
-        .new-page {
-            padding-bottom: 12px;
-        }
+      .resizer:hover {
+        background-color: var(--ls-guideline-color, #ddd);
+      }
     }
+  }
+}
 
-    .ui__notifications {
-        top: calc(var(--ls-headbar-height) + var(--ls-headbar-inner-top-padding) - 0.3rem);
+html.is-native-iphone {
+  --ls-headbar-inner-top-padding: 36px;
+
+  .left-sidebar-inner {
+    > .wrap {
+      padding-top: 12px;
     }
 
-    @media (orientation: landscape) {
-        --ls-headbar-inner-top-padding: 8px;
-        --ls-headbar-height: 2.5rem;
+    .new-page {
+      padding-bottom: 12px;
     }
+  }
+
+  .ui__notifications {
+    top: calc(var(--ls-headbar-height) + var(--ls-headbar-inner-top-padding) - 0.3rem);
+  }
+
+  @media (orientation: landscape) {
+    --ls-headbar-inner-top-padding: 8px;
+    --ls-headbar-height: 2.5rem;
+  }
 }
 
 html.is-native-iphone-without-notch {
 
-    --ls-headbar-inner-top-padding: 15px;
-    --ls-headbar-height: 2.5rem;
+  --ls-headbar-inner-top-padding: 15px;
+  --ls-headbar-height: 2.5rem;
 
-    @media (orientation: landscape) {
+  @media (orientation: landscape) {
 
-        --ls-headbar-inner-top-padding: 0px;
-        --ls-headbar-height: 2.5rem;
-    }
+    --ls-headbar-inner-top-padding: 0px;
+    --ls-headbar-height: 2.5rem;
+  }
 }
 
 html.is-zoomed-native-ios {
-    --ls-headbar-inner-top-padding: 30px;
+  --ls-headbar-inner-top-padding: 30px;
 
-     @media (orientation: landscape) {
-        --ls-headbar-inner-top-padding: 8px;
-        --ls-headbar-height: 2.5rem;
-    }
+  @media (orientation: landscape) {
+    --ls-headbar-inner-top-padding: 8px;
+    --ls-headbar-height: 2.5rem;
+  }
 }

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

@@ -8,10 +8,10 @@
             [frontend.db.model :as model]
             [frontend.handler.page :as page-handler]
             [frontend.state :as state]
-            [logseq.graph-parser.text :as text]
             [logseq.graph-parser.util :as gp-util]
             [frontend.ui :as ui]
             [frontend.util :as util]
+            [frontend.util.text :as text-util]
             [goog.object :as gobj]
             [reitit.frontend.easy :as rfe]
             [rum.core :as rum]))
@@ -32,7 +32,7 @@
         page-entity (db/pull [:block/name (util/page-name-sanity-lc title)])
         data-page-tags (when (seq (:block/tags page-entity))
                          (let [page-names (model/get-page-names-by-ids (map :db/id (:block/tags page)))]
-                           (text/build-data-value page-names)))]
+                           (text-util/build-data-value page-names)))]
     [:div.flex-1.journal.page (cond-> {}
                                 data-page-tags
                                 (assoc :data-page-tags data-page-tags))

+ 557 - 334
src/main/frontend/components/onboarding/index.css

@@ -1,393 +1,616 @@
 body[data-page=repo-add],
 body[data-page=import] {
-    .cp__header .add-graph-btn {
-        display: none;
-    }
+  .cp__header .add-graph-btn {
+    display: none;
+  }
 }
 
 .cp__onboarding {
-    &-setups {
-        background-color: var(--ls-primary-background-color);
-        z-index: 1;
+  &-setups {
+    background-color: var(--ls-primary-background-color);
+    z-index: 1;
+
+    .as-flex-center {
+      display: flex;
+      align-items: center;
+      justify-content: center;
+    }
+
+    .inner-card {
+      background-color: var(--ls-secondary-background-color);
+      padding-top: 55px;
 
-        .as-flex-center {
+      > h1 {
+        font-size: 30px;
+
+        strong {
+          color: var(--ls-active-primary-color);
+          display: inline-block;
+          padding-right: 4px;
+          font-weight: normal;
+
+          &:first-child {
+            display: block;
+            text-align: center;
+            padding-bottom: 15px;
+          }
+        }
+      }
+
+      > h2 {
+        font-size: 14px;
+        margin-top: 20px;
+        margin-bottom: 40px;
+        padding: 0 30px;
+        text-align: center;
+      }
+
+      > article {
+        background-color: var(--ls-secondary-background-color);
+        border-radius: 20px;
+        flex: 1;
+
+        > section {
+          flex: 1;
+
+          &.a {
+            background-color: var(--ls-tertiary-background-color);
             display: flex;
+            flex-direction: column;
             align-items: center;
-            justify-content: center;
-        }
+            padding-top: 75px;
+            padding-bottom: 100px;
+            border-radius: 20px 20px 0 0;
+            min-width: 50%;
+
+            > strong {
+              font-size: 28px;
+              padding-bottom: 15px;
+              font-weight: 600;
+            }
 
-        .inner-card {
-            background-color: var(--ls-secondary-background-color);
-            padding-top: 55px;
+            > small {
+              font-size: 18px;
+              line-height: 30px;
+              padding: 0 40px;
+              text-align: center;
+            }
 
-            > h1 {
-                font-size: 30px;
+            > .choose {
+              padding-top: 48px;
+              width: 100%;
+              cursor: pointer;
 
-                strong {
-                    color: var(--ls-active-primary-color);
-                    display: inline-block;
-                    padding-right: 4px;
-                    font-weight: normal;
-
-                    &:first-child {
-                        display: block;
-                        text-align: center;
-                        padding-bottom: 15px;
-                    }
-                }
-            }
+              &:active {
+                opacity: .8;
+              }
 
-            > h2 {
-                font-size: 14px;
-                margin-top: 20px;
-                margin-bottom: 40px;
-                padding: 0 30px;
-                text-align: center;
+              i {
+                width: 180px;
+                height: 120px;
+                background-image: url("../img/folder-logo.png");
+                background-size: contain;
+              }
+
+              .control {
+                padding: 20px 20px 0 20px;
+                width: 100%;
+              }
             }
+          }
 
-            > article {
-                background-color: var(--ls-secondary-background-color);
-                border-radius: 20px;
-                flex: 1;
+          &.b {
+            display: none;
+            padding: 50px 40px;
 
-                > section {
-                    flex: 1;
-
-                    &.a {
-                        background-color: var(--ls-tertiary-background-color);
-                        display: flex;
-                        flex-direction: column;
-                        align-items: center;
-                        padding-top: 75px;
-                        padding-bottom: 100px;
-                        border-radius: 20px 20px 0 0;
-                        min-width: 50%;
-
-                        > strong {
-                            font-size: 28px;
-                            padding-bottom: 15px;
-                            font-weight: 600;
-                        }
-
-                        > small {
-                            font-size: 18px;
-                            line-height: 30px;
-                            padding: 0 40px;
-                            text-align: center;
-                        }
-
-                        > .choose {
-                            padding-top: 48px;
-                            width: 100%;
-                            cursor: pointer;
-
-                            &:active {
-                                opacity: .8;
-                            }
-
-                            i {
-                                width: 180px;
-                                height: 120px;
-                                background-image: url("../img/folder-logo.png");
-                                background-size: contain;
-                            }
-
-                            .control {
-                                padding: 20px 20px 0 20px;
-                                width: 100%;
-                            }
-                        }
-                    }
+            > p {
+              width: 100%;
 
-                    &.b {
-                        display: none;
-                        padding: 50px 40px;
-
-                        > p {
-                            width: 100%;
-
-                            &:first-child {
-                                i {
-                                    width: 42px;
-                                }
-
-                                strong {
-                                    font-size: 19px;
-                                    line-height: 1.5em;
-                                }
-                            }
-                        }
-
-                        ul {
-                            margin: 0;
-                            padding-top: 20px;
-                            width: 100%;
-
-                            > li {
-                                list-style: none;
-                                margin-bottom: 8px;
-                                height: 40px;
-                                display: flex;
-
-                                &.hr {
-                                    height: 1px;
-                                    border-bottom: 1px solid var(--ls-border-color);
-                                    margin: 20px 0px;
-                                    opacity: 0.6;
-                                }
-
-                                > i {
-                                    width: 48px;
-                                    background-image: url(../img/folder.png);
-                                    background-size: contain;
-                                    background-repeat: no-repeat;
-                                    background-position-y: 2px;
-                                    position: relative;
-                                    right: -2px;
-
-                                    &.is-file {
-                                        background-image: url("../img/file-edn.png");
-                                        background-size: 50%;
-                                        background-position-x: center;
-                                    }
-
-                                    > .ti {
-                                        opacity: .25;
-                                        color: black;
-                                    }
-                                }
-
-                                > span {
-                                    flex: 1;
-                                    padding-left: 15px;
-                                    display: flex;
-                                    flex-direction: column;
-
-                                    strong {
-                                        font-size: 11px;
-                                    }
-                                }
-                            }
-                        }
-                    }
+              &:first-child {
+                i {
+                  width: 42px;
                 }
 
-                &.importer {
-                    background-color: var(--ls-tertiary-background-color);
-                    position: relative;
-
-                    > section {
-                        flex: unset;
-                        padding: 0 30px;
-
-                        h1 {
-                            font-size: 26px;
-                            font-weight: 500;
-                        }
-
-                        h2 {
-                            font-size: 14px;
-                            padding-top: 15px;
-                            padding-bottom: 15px;
-                        }
-
-                        &.d {
-                            width: 100%;
-                            padding: 20px 0;
-
-                            > label {
-                                width: unset;
-                                height: 80px;
-                                flex: 1;
-                                margin-bottom: 10px;
-
-                                > span {
-                                    &:first-child {
-                                        padding: 16px;
-
-                                        i {
-                                            height: 30px;
-                                            width: 30px;
-                                            display: flex;
-                                            align-items: center;
-                                            justify-content: center;
-                                        }
-                                    }
-                                }
-
-                                strong {
-                                    font-size: 18px;
-                                }
-
-                                small {
-                                    font-size: 11px;
-                                }
-                            }
-                        }
-                    }
+                strong {
+                  font-size: 19px;
+                  line-height: 1.5em;
                 }
+              }
             }
 
+            ul {
+              margin: 0;
+              padding-top: 20px;
+              width: 100%;
+
+              > li {
+                list-style: none;
+                margin-bottom: 8px;
+                height: 40px;
+                display: flex;
+
+                &.hr {
+                  height: 1px;
+                  border-bottom: 1px solid var(--ls-border-color);
+                  margin: 20px 0px;
+                  opacity: 0.6;
+                }
 
-            @screen lg {
-                background-color: unset;
+                > i {
+                  width: 48px;
+                  background-image: url(../img/folder.png);
+                  background-size: contain;
+                  background-repeat: no-repeat;
+                  background-position-y: 2px;
+                  position: relative;
+                  right: -2px;
+
+                  &.is-file {
+                    background-image: url("../img/file-edn.png");
+                    background-size: 50%;
+                    background-position-x: center;
+                  }
+
+                  > .ti {
+                    opacity: .25;
+                    color: black;
+                  }
+                }
 
-                > h1 {
-                    font-size: 36px;
+                > span {
+                  flex: 1;
+                  padding-left: 15px;
+                  display: flex;
+                  flex-direction: column;
 
-                    strong {
-                        &:first-child {
-                            display: inline-block;
-                        }
-                    }
+                  strong {
+                    font-size: 11px;
+                  }
                 }
+              }
+            }
+          }
+        }
 
-                > h2 {
-                    font-size: 20px;
-                    padding: 0;
-                }
+        &.importer {
+          background-color: var(--ls-tertiary-background-color);
+          position: relative;
 
-                > article {
-                    max-width: 100vw;
-                    flex: unset;
+          > section {
+            flex: unset;
+            padding: 0 30px;
 
-                    > section {
-                        &.a {
-                            border-radius: 20px 0 0 20px;
+            h1 {
+              font-size: 26px;
+              font-weight: 500;
+            }
 
-                            > small {
-                                padding: 0 95px;
-                            }
+            h2 {
+              font-size: 14px;
+              padding-top: 15px;
+              padding-bottom: 15px;
+            }
 
-                            > .choose {
-                                .control {
-                                    padding: 30px 70px 0 70px;
-                                }
-                            }
-                        }
+            &.d {
+              width: 100%;
+              padding: 20px 0;
 
-                        &.b {
-                            display: flex;
-                        }
+              > label {
+                width: unset;
+                height: 80px;
+                flex: 1;
+                margin-bottom: 10px;
+
+                > span {
+                  &:first-child {
+                    padding: 16px;
+
+                    i {
+                      height: 30px;
+                      width: 30px;
+                      display: flex;
+                      align-items: center;
+                      justify-content: center;
                     }
+                  }
+                }
 
-                    &.importer {
-                        > section {
-                            padding: 0;
-
-                            h1 {
-                                font-size: 28px;
-                            }
-
-                            h2 {
-                                font-size: 19px;
-                                line-height: 3em;
-                                padding: unset;
-                            }
-
-                            &.e {
-                                position: absolute;
-                                bottom: -50px;
-                                right: 15px;
-
-                                a.button {
-                                    padding: 4px 10px;
-                                }
-                            }
-                        }
-                    }
+                strong {
+                  font-size: 18px;
+                }
+
+                small {
+                  font-size: 11px;
                 }
+              }
             }
+          }
         }
+      }
 
-        label.action-input {
-            transition: none;
-            color: var(--ls-active-primary-color);
-            background-color: var(--ls-quaternary-background-color);
-            height: 68px;
-            width: 100%;
-            opacity: .8;
-            user-select: none;
-            border-radius: 12px;
-            overflow: hidden;
-            cursor: pointer;
-
-            small {
-                font-size: 11px;
-                text-align: center;
+
+      @screen lg {
+        background-color: unset;
+
+        > h1 {
+          font-size: 36px;
+
+          strong {
+            &:first-child {
+              display: inline-block;
             }
+          }
+        }
 
-            &:hover {
-                opacity: 1;
+        > h2 {
+          font-size: 20px;
+          padding: 0;
+        }
+
+        > article {
+          max-width: 100vw;
+          flex: unset;
+
+          > section {
+            &.a {
+              border-radius: 20px 0 0 20px;
+
+              > small {
+                padding: 0 95px;
+              }
+
+              > .choose {
+                .control {
+                  padding: 30px 70px 0 70px;
+                }
+              }
             }
 
-            &:active {
-                opacity: .5;
+            &.b {
+              display: flex;
             }
+          }
+
+          &.importer {
+            > section {
+              padding: 0;
 
-            &[disabled] {
-                pointer-events: none;
+              h1 {
+                font-size: 28px;
+              }
+
+              h2 {
+                font-size: 19px;
+                line-height: 3em;
+                padding: unset;
+              }
+
+              &.e {
+                position: absolute;
+                bottom: -50px;
+                right: 15px;
+
+                a.button {
+                  padding: 4px 10px;
+                }
+              }
             }
+          }
         }
+      }
+    }
 
-        @screen lg {
-            justify-content: center;
-            align-items: center;
+    label.action-input {
+      transition: none;
+      color: var(--ls-active-primary-color);
+      background-color: var(--ls-quaternary-background-color);
+      height: 68px;
+      width: 100%;
+      opacity: .8;
+      user-select: none;
+      border-radius: 12px;
+      overflow: hidden;
+      cursor: pointer;
+
+      small {
+        font-size: 11px;
+        text-align: center;
+      }
+
+      &:hover {
+        opacity: 1;
+      }
+
+      &:active {
+        opacity: .5;
+      }
+
+      &[disabled] {
+        pointer-events: none;
+      }
+    }
+
+    @screen lg {
+      justify-content: center;
+      align-items: center;
+    }
+  }
+
+  &-quick-tour {
+    &.shepherd-element, .shepherd-arrow:before {
+      background-color: var(--ls-quaternary-background-color);
+      font-size: 14px;
+    }
+
+    &.shepherd-element {
+      max-width: 320px;
+      border-radius: 8px;
+      box-shadow: none;
+
+      &[data-shepherd-step-id=nav-journal-page] {
+        .shepherd-arrow {
+          left: 30px !important;
         }
+      }
     }
+
+    .shepherd-content {
+      display: flex;
+      flex-direction: column;
+      -webkit-font-smoothing: antialiased;
+    }
+
+    .shepherd-text {
+      font-size: 14px;
+      color: var(--ls-secondary-text-color);
+      flex: 1;
+      padding: 8px 10px;
+      position: relative;
+
+      h2 {
+        font-size: 18px;
+        line-height: 28px;
+        font-weight: 700;
+        padding-top: 5px;
+        padding-bottom: 5px;
+      }
+
+      p {
+        color: var(--ls-secondary-text-color);
+      }
+
+      .steps {
+        position: absolute;
+        bottom: -28px;
+        left: 10px;
+        font-size: 12px;
+
+        strong {
+          opacity: .5;
+          font-size: 11px;
+        }
+
+        ul {
+          display: flex;
+          list-style: none;
+          align-items: center;
+          margin: 0;
+          padding-left: 1px;
+          padding-top: 2px;
+
+          li {
+            padding: 0;
+            width: 5px;
+            height: 5px;
+            margin: 0 5px 0 0;
+            background-color: rgba(0, 0, 0, .2);
+            border-radius: 100%;
+            font-size: 0;
+
+            &.active {
+              background-color: var(--ls-primary-text-color);
+            }
+          }
+        }
+      }
+    }
+
+    .shepherd-footer {
+      button {
+        @apply bg-indigo-600 hover:bg-indigo-700;
+
+        padding: 4px 8px;
+        border-radius: 6px;
+        overflow: hidden;
+        color: white;
+        font-size: 13px;
+        font-weight: 500;
+
+        &.back {
+          background-color: rgba(0, 0, 0, .3);
+        }
+      }
+    }
+  }
+
+  &-skip-quick-tour {
+    -webkit-font-smoothing: antialiased;
+    position: fixed;
+    bottom: 20px;
+    left: 50%;
+    transform: translateX(-60px);
+    z-index: 10001;
+    background-color: #4B5563;
+    padding: 12px 20px;
+    border-radius: 8px;
+    color: white;
+    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
+    font-weight: 700;
+
+    .ti {
+      padding-right: 6px;
+      font-size: 18px;
+      position: relative;
+      top: 2px;
+      font-weight: normal;
+    }
+
+    &:hover {
+      opacity: .8;
+    }
+
+    &:active {
+      opacity: 1;
+    }
+  }
+}
+
+.shepherd-modal-overlay-container.shepherd-modal-is-visible {
+  transition: none;
+  opacity: .4;
+}
+
+.shepherd-target {
+  &.nav-content-item {
+    background-color: rgba(0, 0, 0, .4);
+    padding-left: 15px;
+    padding-right: 15px;
+  }
+
+  .nav-content-item-inner {
+    background-color: var(--ls-secondary-background-color);
+    overflow: hidden;
+
+    .header {
+      padding: 4px 10px !important;
+    }
+
+    .bd {
+      ul a {
+        padding: 2px 4px !important;
+      }
+    }
+  }
+
+  &.page-title {
+    background-color: rgba(0, 0, 0, .4);
+
+    > h1 {
+      background-color: var(--ls-primary-background-color);
+      border-radius: 12px;
+    }
+  }
+
+  &.cp__sidebar-help-btn {
+    background-color: rgba(0, 0, 0, .4);
+
+    > .inner {
+      opacity: 1;
+    }
+  }
+
+  &.cp__header-left-menu {
+    background-color: rgba(0, 0, 0, .4);
+    border-radius: 0;
+    opacity: 1 !important;
+    transition: none;
+
+    &:hover {
+      background-color: rgba(0, 0, 0, .4);
+    }
+
+    > .inner {
+      border-radius: 100%;
+      background-color: var(--ls-primary-background-color);
+    }
+  }
+}
+
+.shepherd-element {
+  &[data-popper-placement^=right] > .shepherd-arrow {
+    left: -4px;
+  }
+
+  &[data-popper-placement^=top] > .shepherd-arrow {
+    bottom: -4px !important;
+  }
+
+  &[data-popper-placement^=left] > .shepherd-arrow {
+    right: -4px !important;
+  }
+
+  &[data-popper-placement^=bottom] > .shepherd-arrow {
+    top: -4px !important;
+  }
+}
+
+.shepherd-arrow, .shepherd-arrow:before {
+  width: 8px;
+  height: 8px;
+}
+
+html[data-theme=light] {
+  .cp__onboarding {
+    &-quick-tour {
+      &.shepherd-element, .shepherd-arrow:before {
+        background-color: #E8E5DE;
+      }
+    }
+  }
 }
 
 html.is-native-android,
 html.is-native-ipad,
 html.is-native-iphone,
 html.is-native-iphone-without-notch {
-    .cp__onboarding {
-        &-setups {
-            position: absolute;
-            width: 100%;
-            top: 0;
-            left: 0;
-            height: 100vh;
-            overflow-y: auto;
-
-            .inner-card {
-                padding-top: 30px;
-                min-height: 100vh;
-                width: 100%;
-
-                > h2 {
-                    margin-bottom: 25px;
-                }
-
-                > article {
-                    > section {
-                        &.a {
-                            padding-top: 25px;
-
-                            small {
-                                text-align: left;
-                                padding: 0 40px;
-                            }
-                            .mobile-intro {
-                                margin-top: 10px;
-                                line-height: 1.5rem;
-                                font-size: 1rem;
-                            }
-
-                            > .choose {
-                                padding-top: 25px;
-                            }
-                        }
-                    }
-                }
+  .cp__onboarding {
+    &-setups {
+      position: absolute;
+      width: 100%;
+      top: 0;
+      left: 0;
+      height: 100vh;
+      overflow-y: auto;
+
+      .inner-card {
+        padding-top: 30px;
+        min-height: 100vh;
+        width: 100%;
+
+        > h2 {
+          margin-bottom: 25px;
+        }
 
-                @screen lg {
-                    > article {
-                        width: 1040px;
-                        height: 510px;
-                    }
-                }
+        > article {
+          > section {
+            &.a {
+              padding-top: 25px;
+
+              small {
+                text-align: left;
+                padding: 0 40px;
+              }
+
+              .mobile-intro {
+                margin-top: 10px;
+                line-height: 1.5rem;
+                font-size: 1rem;
+              }
+
+              > .choose {
+                padding-top: 25px;
+              }
             }
+          }
+        }
+
+        @screen lg {
+          > article {
+            width: 1040px;
+            height: 510px;
+          }
         }
+      }
     }
+  }
 }

+ 158 - 0
src/main/frontend/components/onboarding/quick_tour.cljs

@@ -0,0 +1,158 @@
+(ns frontend.components.onboarding.quick-tour
+  (:require [promesa.core :as p]
+            [cljs-bean.core :as bean]
+            [frontend.loader :refer [load]]
+            [frontend.state :as state]
+            [frontend.date :as date]
+            [frontend.util :as util]
+            [frontend.handler.route :as router-handler]
+            [frontend.handler.command-palette :as command-palette]
+            [hiccups.runtime :as h]
+            [dommy.core :as d]))
+
+(defn js-load$
+  [url]
+  (p/create
+    (fn [resolve]
+      (load url resolve))))
+
+(def JS_ROOT
+  (if (= js/location.protocol "file:")
+    "./js"
+    "./static/js"))
+
+(defn- load-base-assets$
+  []
+  (js-load$ (str JS_ROOT "/shepherd.min.js")))
+
+(defn- make-skip-fns
+  [^js jsTour]
+  (let [^js el (js/document.createElement "button")]
+    (.add (.-classList el) "cp__onboarding-skip-quick-tour")
+    (set! (.-innerHTML el) (h/render-html [:span [:i.ti.ti-player-skip-forward] "Skip Quick Tour"]))
+    (.addEventListener el "click" #(.cancel jsTour))
+    [#(.appendChild js/document.body el)
+     #(.removeChild js/document.body el)]))
+
+(defn- wait-target
+  [fn-or-selector time]
+  (p/let [action (if (string? fn-or-selector)
+                   #(d/sel1 fn-or-selector)
+                   fn-or-selector)
+          _      (action)
+          _      (p/delay time)]))
+
+(defn- inject-steps-indicator
+  [current total]
+
+  (h/render-html
+    [:div.steps
+     [:strong (str "STEP " current)]
+     [:ul (for [i (range total)] [:li {:class (when (= current (inc i)) "active")} i])]]))
+
+(defn- create-steps! [^js jsTour]
+  [
+   ;; step 1
+   {:id                "nav-help"
+    :text              (h/render-html [:section [:h2 "❓ Help"]
+                                       [:p "You can always click here for help and other information about Logseq."]])
+    :attachTo          {:element ".cp__sidebar-help-btn" :on "top"}
+    :beforeShowPromise #(if (state/sub :ui/sidebar-open?)
+                          (wait-target state/hide-right-sidebar! 700)
+                          (p/resolved true))
+    :canClickTarget    true
+    :buttons           [{:text "Next" :action (.-next jsTour)}]
+    :popperOptions     {:modifiers [{:name    "preventOverflow"
+                                     :options {:padding 20}}
+                                    {:name    "offset"
+                                     :options {:offset [0, 10]}}]}}
+
+   ;; step 2
+   {:id                "nav-journal-page"
+    :text              (h/render-html [:section [:h2 "📆 Daily Journal Page"]
+                                       [:p
+                                        [:span "This is today’s daily journal page. Here yo can dump your thoughts, learnings and ideas. Don’t worry about organizing. Just write and"]
+                                        [:a "[[link]]"]
+                                        [:span "your thoughts."]]])
+
+    :attachTo          {:element ".page.is-journals .page-title" :on "top-end"}
+    :beforeShowPromise #(if-not (= (util/safe-lower-case (state/get-current-page))
+                                  (util/safe-lower-case (date/today)))
+                          (wait-target (fn []
+                                         (router-handler/redirect-to-page! (date/today))
+                                         (util/scroll-to-top)) 200)
+                          (p/resolved true))
+    :buttons           [{:text "Back" :classes "back" :action (.-back jsTour)}
+                        {:text "Next" :action (.-next jsTour)}]
+    :popperOptions     {:modifiers [{:name    "preventOverflow"
+                                     :options {:padding 63}}
+                                    {:name    "offset"
+                                     :options {:offset [10, 10]}}]}}
+
+   ;; step 3
+   {:id                "nav-left-sidebar"
+    :text              (h/render-html [:section [:h2 "👀 Left Sidebar"]
+                                       [:p [:span "Open the left sidebar to explore important menu items in Logseq."]]])
+
+    :attachTo          {:element "#left-menu" :on "top"}
+    :beforeShowPromise #(p/resolved true)
+    :buttons           [{:text "Back" :classes "back" :action (.-back jsTour)}
+                        {:text "Next" :action (.-next jsTour)}]
+    :popperOptions     {:modifiers [{:name    "preventOverflow"
+                                     :options {:padding 20}}
+                                    {:name    "offset"
+                                     :options {:offset [10, 10]}}]}}
+
+   ;; step 4
+   {:id                "nav-favorites"
+    :text              (h/render-html [:section [:h2 "⭐️ Favorites"]
+                                       [:p "Pin your favorite pages via the `... `menu on any page."]
+                                       [:p "We’ve also added some template pages here to help you get started. You can remove these once you start writing your own notes."]])
+    :beforeShowPromise #(if-not (state/sub :ui/left-sidebar-open?)
+                          (wait-target state/toggle-left-sidebar! 500)
+                          (p/resolved true))
+    :attachTo          {:element ".nav-content-item.favorites" :on "right"}
+    :buttons           [{:text "Back" :classes "back" :action (.-back jsTour)}
+                        {:text "Finish" :action (.-complete jsTour)}]}
+   ])
+
+(defn start
+  []
+  (let [^js jsTour (js/Shepherd.Tour.
+                     (bean/->js
+                       {:useModalOverlay    true
+                        :defaultStepOptions {:classes  "cp__onboarding-quick-tour"
+                                             :scrollTo false}}))
+        steps      (create-steps! jsTour)
+        steps      (map-indexed #(assoc %2 :text (str (:text %2) (inject-steps-indicator (inc %1) (count steps)))) steps)
+        [show-skip! hide-skip!] (make-skip-fns jsTour)]
+
+    ;; events
+    (doto jsTour
+      (.on "show" show-skip!)
+      (.on "hide" hide-skip!)
+      (.on "complete" hide-skip!)
+      (.on "cancel" hide-skip!))
+
+    (doseq [step steps]
+      (.addStep jsTour (bean/->js step)))
+
+    (.start jsTour)))
+
+(defn- ready
+  [callback]
+  (p/then
+    (if (nil? js/window.Shepherd)
+      (load-base-assets$) (p/resolved true))
+    callback))
+
+(def should-guide? false)
+
+(defn init []
+  (command-palette/register {:id     :document/quick-tour
+                             :desc   "Quick tour for onboarding"
+                             :action #(ready start)})
+
+  ;; TODO: fix logic
+  (when should-guide?
+    (ready start)))

+ 154 - 150
src/main/frontend/components/page.cljs

@@ -25,10 +25,10 @@
             [frontend.handler.route :as route-handler]
             [frontend.mixins :as mixins]
             [frontend.state :as state]
-            [logseq.graph-parser.text :as text]
             [frontend.search :as search]
             [frontend.ui :as ui]
             [frontend.util :as util]
+            [frontend.util.text :as text-util]
             [goog.object :as gobj]
             [reitit.frontend.easy :as rfe]
             [medley.core :as medley]
@@ -346,7 +346,7 @@
       [:div.flex-1.page.relative
        (merge (if (seq (:block/tags page))
                 (let [page-names (model/get-page-names-by-ids (map :db/id (:block/tags page)))]
-                  {:data-page-tags (text/build-data-value page-names)})
+                  {:data-page-tags (text-util/build-data-value page-names)})
                 {})
 
               {:key path-page-name
@@ -673,7 +673,7 @@
   [title key by-item desc?]
   [:th
    {:class [(name key)]}
-   [:a {:on-click (fn []
+   [:a.fade-link {:on-click (fn []
                     (reset! by-item key)
                     (swap! desc? not))}
     [:span.flex.items-center
@@ -743,10 +743,6 @@
   (rum/local false ::journals)
   (rum/local nil ::filter-fn)
   (rum/local 1 ::current-page)
-  ;; {:did-mount (fn [state]
-  ;;               (let [current-repo (state/sub :git/current-repo)]
-  ;;                 (js/setTimeout #(db/remove-orphaned-pages! current-repo) 0))
-  ;;               state)}
   [state]
   (let [current-repo (state/sub :git/current-repo)
         per-page-num 40
@@ -794,6 +790,8 @@
     [:div.flex-1.cp__all_pages
      [:h1.title (t :all-pages)]
 
+     [:div.text-sm.ml-1.opacity-70.mb-4 (t :paginates/pages (count @*results-all))]
+
      (when current-repo
 
        ;; all pages
@@ -829,147 +827,153 @@
                                       [idx (boolean (get @*checks idx))])))
            (reset! *results pages)))
 
-       [[:div.actions
-         {:class (util/classnames [{:has-selected (or (nil? @*indeterminate)
-                                                      (not= 0 @*indeterminate))}])}
-         [:div.l.flex.items-center
-          [:div.actions-wrap
-           (ui/button
-             [(ui/icon "trash") (t :delete)]
-             :on-click (fn []
-                         (let [selected (filter (fn [[_ v]] v) @*checks)
-                               selected (and (seq selected)
-                                             (into #{} (for [[k _] selected] k)))]
-                           (when-let [pages (and selected (filter #(contains? selected (:block/idx %)) @*results))]
-                             (state/set-modal! (batch-delete-dialog pages false #(do
-                                                                                   (reset! *checks nil)
-                                                                                   (refresh-pages)))))))
-             :small? true)]
-
-          [:div.search-wrap.flex.items-center.pl-2
-           (let [search-fn (fn []
+       (let [has-prev? (> @*current-page 1)
+             has-next? (not= @*current-page total-pages)]
+         [:div
+         [:div.actions
+          {:class (util/classnames [{:has-selected (or (nil? @*indeterminate)
+                                                       (not= 0 @*indeterminate))}])}
+          [:div.l.flex.items-center
+           [:div.actions-wrap
+            (ui/button
+              [(ui/icon "trash" {:style {:font-size 15}}) (t :delete)]
+              :on-click (fn []
+                          (let [selected (filter (fn [[_ v]] v) @*checks)
+                                selected (and (seq selected)
+                                              (into #{} (for [[k _] selected] k)))]
+                            (when-let [pages (and selected (filter #(contains? selected (:block/idx %)) @*results))]
+                              (state/set-modal! (batch-delete-dialog pages false #(do
+                                                                                    (reset! *checks nil)
+                                                                                    (refresh-pages)))))))
+              :class "fade-link"
+              :small? true)]
+
+           [:div.search-wrap.flex.items-center.pl-2
+            (let [search-fn (fn []
+                              (let [^js input (rum/deref *search-input)]
+                                (search-key (.-value input))
+                                (reset! *current-page 1)))
+                  reset-fn (fn []
                              (let [^js input (rum/deref *search-input)]
-                               (search-key (.-value input))
-                               (reset! *current-page 1)))
-                 reset-fn (fn []
-                            (let [^js input (rum/deref *search-input)]
-                              (set! (.-value input) "")
-                              (reset! *search-key nil)))]
-
-             [(ui/button (ui/icon "search")
-                :on-click search-fn
-                :small? true)
-              [:input.form-input {:placeholder   (t :search/page-names)
-                                  :on-key-up     (fn [^js e]
-                                                   (let [^js target (.-target e)]
-                                                     (if (string/blank? (.-value target))
-                                                       (reset! *search-key nil)
-                                                       (cond
-                                                         (= 13 (.-keyCode e)) (search-fn)
-                                                         (= 27 (.-keyCode e)) (reset-fn)))))
-                                  :ref           *search-input
-                                  :default-value ""}]
-
-              (when (not (string/blank? @*search-key))
-                [:a.cancel {:on-click reset-fn}
-                 (ui/icon "x")])])]]
-
-         [:div.r.flex.items-center.justify-between
-          (let [orphaned-pages (model/get-orphaned-pages {})
-                orphaned-pages? (seq orphaned-pages)]
-            [:a.ml-1.pr-2.opacity-70.hover:opacity-100
-             {:on-click (fn []
-                          (if orphaned-pages?
-                            (state/set-modal!
-                             (batch-delete-dialog
-                              orphaned-pages  true
-                              #(do
-                                 (reset! *checks nil)
-                                 (refresh-pages))))
-                            (notification/show! "Congratulations, no orphaned pages in your graph!" :success)))}
-             [:span
-              (ui/icon "file-x")
-              [:span.ml-1 (t :remove-orphaned-pages)]]])
-
-          [:a.ml-1.pr-2.opacity-70.hover:opacity-100 {:href (rfe/href :all-files)}
-           [:span
-            (ui/icon "files")
-            [:span.ml-1 (t :all-files)]]]
-
-          [:div
-           (ui/tippy
-            {:html  [:small (str (t :page/show-journals) " ?")]
-             :arrow true}
-            [:a.button.journal
-             {:class    (util/classnames [{:active (boolean @*journal?)}])
-              :on-click #(reset! *journal? (not @*journal?))}
-             (ui/icon "calendar")])]
-
-          [:div.paginates
-           [:span.flex.items-center.opacity-60.text-sm
-            [:span.pr-1 (t :paginates/pages (count @*results-all))]]
-           [:span.flex.items-center
-            {:class (util/classnames [{:is-first (= 1 @*current-page)
-                                       :is-last  (= @*current-page total-pages)}])}
-            [:a.py-4.pr-2 {:on-click #(to-page (dec @*current-page))} (ui/icon "caret-left") (str " " (t :paginates/prev))]
-            [:span.opacity-30 (str @*current-page "/" total-pages)]
-            [:a.py-4.pl-2 {:on-click #(to-page (inc @*current-page))} (str (t :paginates/next) " ") (ui/icon "caret-right")]]]]]
-
-        [:table.table-auto.cp__all_pages_table
-         [:thead
-          [:tr
-           [:th.selector
-            (checkbox-opt "all-pages-select-all"
-                          (= 1 @*indeterminate)
-                          {:on-change     (fn []
-                                            (let [indeterminate? (= -1 @*indeterminate)
-                                                  all? (= 1 @*indeterminate)]
-                                              (doseq [{:block/keys [idx]} @*results]
-                                                (swap! *checks assoc idx (or indeterminate? (not all?))))))
-                           :indeterminate (= -1 @*indeterminate)})]
-
-           (sortable-title (t :block/name) :block/name *sort-by-item *desc?)
-           (when-not mobile?
-             [(sortable-title (t :page/backlinks) :block/backlinks *sort-by-item *desc?)
-              (sortable-title (t :page/created-at) :block/created-at *sort-by-item *desc?)
-              (sortable-title (t :page/updated-at) :block/updated-at *sort-by-item *desc?)])]]
-
-         [:tbody
-          (for [{:block/keys [idx name created-at updated-at backlinks] :as page} @*results]
-            (when-not (string/blank? name)
-              [:tr {:key name}
-               [:td.selector
-                (checkbox-opt (str "label-" idx)
-                              (get @*checks idx)
-                              {:on-change (fn []
-                                            (swap! *checks update idx not))})]
-
-               [:td.name [:a {:on-click (fn [e]
-                                          (let [repo (state/get-current-repo)]
-                                            (when (gobj/get e "shiftKey")
-                                              (state/sidebar-add-block!
-                                               repo
-                                               (:db/id page)
-                                               :page))))
-                              :href     (rfe/href :page {:name (:block/name page)})}
-                          (component-block/page-cp {} page)]]
-
-               (when-not mobile?
-                 [:td.backlinks [:span backlinks]])
-
-               (when-not mobile?
-                 [:td.created-at [:span (if created-at
-                                          (date/int->local-time-2 created-at)
-                                          "Unknown")]])
-               (when-not mobile?
-                 [:td.updated-at [:span (if updated-at
-                                          (date/int->local-time-2 updated-at)
-                                          "Unknown")]])]))]]
-
-        [:div.paginates
-         [:span]
-         [:span.flex.items-center
-          {:class (util/classnames [{:is-first (= 1 @*current-page)
-                                     :is-last  (= @*current-page total-pages)}])}
-          [:a.py-4.text-sm {:on-click #(to-page (dec @*current-page))} (ui/icon "caret-left") (str " " (t :paginates/prev))]
-          [:a.py-4.pl-2.text-sm {:on-click #(to-page (inc @*current-page))} (str (t :paginates/next) " ") (ui/icon "caret-right")]]]])]))
+                               (set! (.-value input) "")
+                               (reset! *search-key nil)))]
+
+              [(ui/button (ui/icon "search")
+                 :on-click search-fn
+                 :small? true)
+               [:input.form-input {:placeholder   (t :search/page-names)
+                                   :on-key-up     (fn [^js e]
+                                                    (let [^js target (.-target e)]
+                                                      (if (string/blank? (.-value target))
+                                                        (reset! *search-key nil)
+                                                        (cond
+                                                          (= 13 (.-keyCode e)) (search-fn)
+                                                          (= 27 (.-keyCode e)) (reset-fn)))))
+                                   :ref           *search-input
+                                   :default-value ""}]
+
+               (when (not (string/blank? @*search-key))
+                 [:a.cancel {:on-click reset-fn}
+                  (ui/icon "x")])])]]
+
+          [:div.r.flex.items-center.justify-between
+           [:div
+            (ui/tippy
+             {:html  [:small (str (t :page/show-journals) " ?")]
+              :arrow true}
+             [:a.button.journal
+              {:class    (util/classnames [{:active (boolean @*journal?)}])
+               :on-click #(reset! *journal? (not @*journal?))}
+              (ui/icon "calendar")])]
+
+           [:div.paginates
+            [:span.flex.items-center
+             {:class (util/classnames [{:is-first (= 1 @*current-page)
+                                        :is-last  (= @*current-page total-pages)}])}
+             (when has-prev?
+               [:a.py-4.pr-2.fade-link {:on-click #(to-page (dec @*current-page))} (ui/icon "caret-left") (str " " (t :paginates/prev))])
+             [:span.opacity-60 (str @*current-page "/" total-pages)]
+             (when has-next?
+               [:a.py-4.pl-2.fade-link {:on-click #(to-page (inc @*current-page))} (str (t :paginates/next) " ") (ui/icon "caret-right")])]]
+
+           (ui/dropdown-with-links
+            (fn [{:keys [toggle-fn]}]
+              [:a.button.fade-link
+               {:on-click toggle-fn}
+               (ui/icon "dots" {:style {:fontSize ui/icon-size}})])
+            [{:title (t :remove-orphaned-pages)
+              :options {:on-click (fn []
+                                    (let [orphaned-pages (model/get-orphaned-pages {})
+                                          orphaned-pages? (seq orphaned-pages)]
+                                      (if orphaned-pages?
+                                        (state/set-modal!
+                                         (batch-delete-dialog
+                                          orphaned-pages  true
+                                          #(do
+                                             (reset! *checks nil)
+                                             (refresh-pages))))
+                                        (notification/show! "Congratulations, no orphaned pages in your graph!" :success))))}
+              :icon (ui/icon "file-x")}
+             {:title (t :all-files)
+              :options {:href (rfe/href :all-files)}
+              :icon (ui/icon "files")}]
+            {})]]
+
+         [:table.table-auto.cp__all_pages_table
+          [:thead
+           [:tr
+            [:th.selector
+             (checkbox-opt "all-pages-select-all"
+                           (= 1 @*indeterminate)
+                           {:on-change     (fn []
+                                             (let [indeterminate? (= -1 @*indeterminate)
+                                                   all? (= 1 @*indeterminate)]
+                                               (doseq [{:block/keys [idx]} @*results]
+                                                 (swap! *checks assoc idx (or indeterminate? (not all?))))))
+                            :indeterminate (= -1 @*indeterminate)})]
+
+            (sortable-title (t :block/name) :block/name *sort-by-item *desc?)
+            (when-not mobile?
+              [(sortable-title (t :page/backlinks) :block/backlinks *sort-by-item *desc?)
+               (sortable-title (t :page/created-at) :block/created-at *sort-by-item *desc?)
+               (sortable-title (t :page/updated-at) :block/updated-at *sort-by-item *desc?)])]]
+
+          [:tbody
+           (for [{:block/keys [idx name created-at updated-at backlinks] :as page} @*results]
+             (when-not (string/blank? name)
+               [:tr {:key name}
+                [:td.selector
+                 (checkbox-opt (str "label-" idx)
+                               (get @*checks idx)
+                               {:on-change (fn []
+                                             (swap! *checks update idx not))})]
+
+                [:td.name [:a {:on-click (fn [e]
+                                           (let [repo (state/get-current-repo)]
+                                             (when (gobj/get e "shiftKey")
+                                               (state/sidebar-add-block!
+                                                repo
+                                                (:db/id page)
+                                                :page))))
+                               :href     (rfe/href :page {:name (:block/name page)})}
+                           (component-block/page-cp {} page)]]
+
+                (when-not mobile?
+                  [:td.backlinks [:span backlinks]])
+
+                (when-not mobile?
+                  [:td.created-at [:span (if created-at
+                                           (date/int->local-time-2 created-at)
+                                           "Unknown")]])
+                (when-not mobile?
+                  [:td.updated-at [:span (if updated-at
+                                           (date/int->local-time-2 updated-at)
+                                           "Unknown")]])]))]]
+
+         [:div.paginates
+          [:span]
+          [:span.flex.items-center
+           (when has-prev?
+             [:a.py-4.text-sm.fade-link {:on-click #(to-page (dec @*current-page))} (ui/icon "caret-left") (str " " (t :paginates/prev))])
+           (when has-next?
+             [:a.py-4.pl-2.text-sm.fade-link {:on-click #(to-page (inc @*current-page))} (str (t :paginates/next) " ") (ui/icon "caret-right")])]]]))]))

+ 15 - 15
src/main/frontend/components/page.css

@@ -101,7 +101,7 @@
     position: sticky;
     background-color: var(--ls-primary-background-color);
     white-space: nowrap;
-    top: -1px;
+    top: -18px;
     padding-bottom: 10px;
     z-index: 1;
 
@@ -119,7 +119,6 @@
       font-size: 16px;
       display: inline-block;
       position: relative;
-      bottom: -1px;
     }
 
     .l {
@@ -136,7 +135,7 @@
 
       a.journal {
         color: var(--ls-primary-text-color);
-        opacity: .3;
+        margin-top: 1px;
 
         &.active {
           opacity: 1;
@@ -148,7 +147,7 @@
         display: flex;
         align-items: center;
         justify-content: center;
-        margin-right: 5px;
+        margin-right: 3px;
       }
     }
 
@@ -195,7 +194,7 @@
     display: flex;
     align-items: center;
     justify-content: space-between;
-    padding: 0 5px;
+    padding: 0 5px 0 0;
 
     > span {
       color: var(--ls-primary-text-color);
@@ -209,12 +208,6 @@
           }
         }
       }
-
-      &.is-first > a:first-child,
-      &.is-last > a:last-child {
-        pointer-events: none;
-        opacity: .3;
-      }
     }
   }
 }
@@ -257,10 +250,10 @@
 
 .ls-page-title {
   @apply rounded-sm;
-  
+
   padding: 5px 8px;
   margin: 0 -6px;
-  
+
   &.title {
     margin-bottom: 12px;
   }
@@ -274,11 +267,18 @@
   }
 }
 
+a.page-title {
+  padding: 0 8px;
+  margin-left: -8px;
+  transition: none;
+  display: block;
+}
+
 html.is-native-android,
 html.is-native-ipad,
 html.is-native-iphone,
 html.is-native-iphone-without-notch {
-    
+
     .ls-page-title {
         margin: 0px 0px 24px -15px;
         padding: 0px;
@@ -383,4 +383,4 @@ html.is-native-ios {
   display: inline-block;
   line-height: normal;
   background-color: var(--ls-quaternary-background-color);
- }
+ }

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

@@ -14,7 +14,7 @@
             [reitit.frontend.easy :as rfe]
             [rum.core :as rum]
             [frontend.mobile.util :as mobile-util]
-            [logseq.graph-parser.text :as text]
+            [frontend.util.text :as text-util]
             [promesa.core :as p]
             [electron.ipc :as ipc]
             [goog.object :as gobj]
@@ -39,7 +39,7 @@
       [:span.flex.items-center
        (if local?
          (let [local-dir (config/get-local-dir url)
-               graph-name (text/get-graph-name-from-path local-dir)]
+               graph-name (text-util/get-graph-name-from-path local-dir)]
            [:a {:title    local-dir
                 :on-click #(on-click graph)}
             [:span graph-name (and GraphName [:strong.px-1 "(" GraphName ")"])]
@@ -123,7 +123,7 @@
                     (fn [{:keys [url remote? GraphName GraphUUID] :as graph}]
                       (let [local? (config/local-db? url)
                             repo-path (if local? (db/get-repo-name url) GraphName )
-                            short-repo-name (if local? (text/get-graph-name-from-path repo-path) GraphName)]
+                            short-repo-name (if local? (text-util/get-graph-name-from-path repo-path) GraphName)]
                         {:title        [:span.flex.items-center short-repo-name
                                         (when remote? [:span.pl-1
                                                        {:title (str "<" GraphName "> #" GraphUUID)}
@@ -201,7 +201,7 @@
                                              (check-multiple-windows? state)
                                              (toggle-fn))
                                  :title    repo-path}       ;; show full path on hover
-                                (ui/icon "database mr-3" {:style {:font-size 20} :id "database-icon"})
+                                (ui/icon "database mr-2" {:style {:font-size 16} :id "database-icon"})
                                 [:div.graphs
                                  [:span#repo-switch.block.pr-2.whitespace-nowrap
                                   [:span [:span#repo-name.font-medium

+ 3 - 3
src/main/frontend/components/select.cljs

@@ -9,8 +9,8 @@
             [frontend.state :as state]
             [frontend.ui :as ui]
             [frontend.util :as util]
+            [frontend.util.text :as text-util]
             [frontend.db :as db]
-            [logseq.graph-parser.text :as text]
             [rum.core :as rum]
             [frontend.config :as config]
             [frontend.handler.repo :as repo-handler]
@@ -76,7 +76,7 @@
                            (or (config/demo-graph? url)
                                (= url (state/get-current-repo)))))
                  (map (fn [{:keys [url]}]
-                        {:value (text/get-graph-name-from-path
+                        {:value (text-util/get-graph-name-from-path
                                  ;; TODO: Use helper when a common one is refactored
                                  ;; from components.repo
                                  (if (config/local-db? url)
@@ -99,7 +99,7 @@
                      (remove (fn [{:keys [url]}]
                                (config/demo-graph? url)))
                      (map (fn [{:keys [url] :as original-graph}]
-                            {:value (text/get-graph-name-from-path
+                            {:value (text-util/get-graph-name-from-path
                                      ;; TODO: Use helper when a common one is refactored
                                      ;; from components.repo
                                      (if (config/local-db? url)

+ 99 - 84
src/main/frontend/components/sidebar.cljs

@@ -19,41 +19,44 @@
             [frontend.db.model :as db-model]
             [frontend.extensions.pdf.assets :as pdf-assets]
             [frontend.extensions.srs :as srs]
+            [frontend.handler.common :as common-handler]
             [frontend.handler.editor :as editor-handler]
             [frontend.handler.mobile.swipe :as swipe]
             [frontend.handler.page :as page-handler]
             [frontend.handler.route :as route-handler]
             [frontend.handler.user :as user-handler]
-            [frontend.handler.common :as common-handler]
             [frontend.mixins :as mixins]
             [frontend.mobile.action-bar :as action-bar]
             [frontend.mobile.footer :as footer]
-            [frontend.mobile.util :as mobile-util]
             [frontend.mobile.mobile-bar :refer [mobile-bar]]
+            [frontend.mobile.util :as mobile-util]
             [frontend.modules.shortcut.data-helper :as shortcut-dh]
             [frontend.state :as state]
             [frontend.ui :as ui]
             [frontend.util :as util]
+            [frontend.util.cursor :as cursor]
             [goog.dom :as gdom]
             [goog.object :as gobj]
-            [rum.core :as rum]
-            [reitit.frontend.easy :as rfe]))
+            [react-draggable]
+            [reitit.frontend.easy :as rfe]
+            [rum.core :as rum]))
 
 (rum/defc nav-content-item
   [name {:keys [class]} child]
 
   [:div.nav-content-item.is-expand
    {:class class}
-   [:div.header.items-center.mb-1
-    {:on-click (fn [^js/MouseEvent e]
-                 (let [^js target (.-target e)
-                       ^js parent (.closest target ".nav-content-item")]
-                   (.toggle (.-classList parent) "is-expand")))}
-
-    [:div.font-medium.fade-link name]
-    [:span
-     [:a.more svg/arrow-down-v2]]]
-   [:div.bd child]])
+   [:div.nav-content-item-inner
+    [:div.header.items-center.mb-1
+     {:on-click (fn [^js/MouseEvent e]
+                  (let [^js target (.-target e)
+                        ^js parent (.closest target ".nav-content-item")]
+                    (.toggle (.-classList parent) "is-expand")))}
+
+     [:div.font-medium.fade-link name]
+     [:span
+      [:a.more svg/arrow-down-v2]]]
+    [:div.bd child]]])
 
 (defn- delta-y
   [e]
@@ -82,7 +85,7 @@
      (pdf-assets/fix-local-asset-filename original-name)]))
 
 (defn get-page-icon [page-entity]
-  (let [default-icon "◦"
+  (let [default-icon (ui/icon "file-text")
         from-properties (get-in (into {} page-entity) [:block/properties :icon])]
     (or
      (when (not= from-properties "") from-properties)
@@ -97,6 +100,7 @@
         target (state/sub :favorites/dragging)]
     [:li.favorite-item
      {:key name
+      :title name
       :data-ref name
       :class (if (and target @dragging-over (not= target @dragging-over))
                "dragging-target"
@@ -121,10 +125,9 @@
 (rum/defc favorites < rum/reactive
   [t]
   (nav-content-item
-   [:a.flex.items-center.text-sm.font-medium.rounded-md
-    (ui/icon "star mr-1" {:style {:font-size 18}})
-    [:span.flex-1.ml-1 {:style {:padding-top 2}}
-     (t :left-side-bar/nav-favorites)]]
+   [:a.flex.items-center.text-sm.font-medium.rounded-md.wrap-th
+    (ui/icon "star mr-1" {:style {:font-size 16}})
+    [:span.flex-1.ml-1 (string/upper-case (t :left-side-bar/nav-favorites))]]
 
    {:class "favorites"
     :edit-fn
@@ -146,10 +149,10 @@
 (rum/defc recent-pages < rum/reactive db-mixins/query
   [t]
   (nav-content-item
-   [:a.flex.items-center.text-sm.font-medium.rounded-md
-    (ui/icon "history mr-2" {:style {:font-size 18}})
-    [:span.flex-1 {:style {:padding-top 2}}
-     (t :left-side-bar/nav-recent-pages)]]
+   [:a.flex.items-center.text-sm.font-medium.rounded-md.wrap-th
+    (ui/icon "history mr-2" {:style {:font-size 16}})
+    [:span.flex-1
+     (string/upper-case (t :left-side-bar/nav-recent-pages))]]
 
    {:class "recent"}
 
@@ -165,6 +168,7 @@
         (when-let [entity (db/entity [:block/name (util/safe-page-name-sanity-lc name)])]
           [:li.recent-item.select-none
            {:key name
+            :title name
             :data-ref name}
            (page-name name (get-page-icon entity))]))])))
 
@@ -172,10 +176,12 @@
   {:did-mount (fn [state]
                 (srs/update-cards-due-count!)
                 state)}
-  [state]
+  [_state srs-open?]
   (let [num (state/sub :srs/cards-due-count)]
-    [:a.item.group.flex.items-center.px-2.py-2.text-sm.font-medium.rounded-md {:on-click #(state/pub-event! [:modal/show-cards])}
-     (ui/icon "infinity mr-3" {:style {:font-size 20}})
+    [:a.item.group.flex.items-center.px-2.py-2.text-sm.font-medium.rounded-md
+     {:class (util/classnames [{:active srs-open?}])
+      :on-click #(state/pub-event! [:modal/show-cards])}
+     (ui/icon "infinity")
      [:span.flex-1 (t :right-side-bar/flashcards)]
      (when (and num (not (zero? num)))
        [:span.ml-3.inline-block.py-0.5.px-3.text-xs.font-medium.rounded-full.fade-in num])]))
@@ -196,18 +202,21 @@
     class :class
     title :title
     icon :icon
+    active :active
     href :href}]
   [:div
    {:class class}
    [:a.item.group.flex.items-center.px-2.py-2.text-sm.font-medium.rounded-md
     {:on-click on-click-handler
+     :class (when active "active")
      :href href}
-    (ui/icon (str icon " mr-3") {:style {:font-size 20}})
+    (ui/icon (str icon))
     [:span.flex-1 title]]])
 
 (rum/defc sidebar-nav
-  [_route-match close-modal-fn left-sidebar-open?]
-  (let [default-home (get-default-home-if-valid)]
+  [route-match close-modal-fn left-sidebar-open? srs-open?]
+  (let [default-home (get-default-home-if-valid)
+        route-name (get-in route-match [:data :name])]
 
     [:div.left-sidebar-inner.flex-1.flex.flex-col.min-h-0
      {:on-click #(when-let [^js target (and (util/sm-breakpoint?) (.-target %))]
@@ -215,36 +224,43 @@
                                [".favorites .bd" ".recent .bd" ".dropdown-wrapper" ".nav-header"])
                      (close-modal-fn)))}
      [:div.flex.flex-col.pb-4.wrap
-      [:nav.px-2.space-y-1 {:aria-label "Sidebar"}
+      [:nav.px-4.pt-1.space-y-1 {:aria-label "Sidebar"}
        (repo/repos-dropdown)
 
        [:div.nav-header
-        (if (:page default-home)
+        (if-let [page (:page default-home)]
           (sidebar-item
-           {:class            "home-nav"
-            :title            (:page default-home)
-            :on-click-handler route-handler/redirect-to-home!
-            :icon             "home"})
+            {:class            "home-nav"
+             :title            page
+             :on-click-handler route-handler/redirect-to-home!
+             :active           (and (not srs-open?)
+                                    (= route-name :page)
+                                    (= page (get-in route-match [:path-params :name])))
+             :icon             "home"})
           (sidebar-item
-           {:class            "journals-nav"
-            :title            (t :left-side-bar/journals)
-            :on-click-handler route-handler/go-to-journals!
-            :icon             "calendar"}))
+            {:class            "journals-nav"
+             :active           (and (not srs-open?)
+                                 (or (= route-name :all-journals) (= route-name :home)))
+             :title            (t :left-side-bar/journals)
+             :on-click-handler route-handler/go-to-journals!
+             :icon             "calendar"}))
 
         [:div.flashcards-nav
-         (flashcards)]
+         (flashcards srs-open?)]
 
         (sidebar-item
-         {:class "graph-view-nav"
-          :title (t :right-side-bar/graph-view)
-          :href  (rfe/href :graph)
-          :icon  "hierarchy"})
+          {:class  "graph-view-nav"
+           :title  (t :right-side-bar/graph-view)
+           :href   (rfe/href :graph)
+           :active (and (not srs-open?) (= route-name :graph))
+           :icon   "hierarchy"})
 
         (sidebar-item
-         {:class "all-pages-nav"
-          :title (t :right-side-bar/all-pages)
-          :href  (rfe/href :all-pages)
-          :icon  "files"})]]
+          {:class  "all-pages-nav"
+           :title  (t :right-side-bar/all-pages)
+           :href   (rfe/href :all-pages)
+           :active (and (not srs-open?) (= route-name :all-pages))
+           :icon   "files"})]]
 
       (favorites t)
 
@@ -254,7 +270,7 @@
        [:nav.px-2 {:aria-label "Sidebar"
                    :class      "new-page"}
         (when-not config/publishing?
-          [:a.item.group.flex.items-center.px-2.py-2.text-sm.font-medium.rounded-md
+          [:a.item.group.flex.items-center.px-2.py-2.text-sm.font-medium.rounded-md.new-page-link
            {:on-click (fn []
                         (and (util/sm-breakpoint?)
                              (state/toggle-left-sidebar!))
@@ -264,14 +280,31 @@
 
 (rum/defc left-sidebar < rum/reactive
   [{:keys [left-sidebar-open? route-match]}]
-  (let [close-fn #(state/set-left-sidebar-open! false)]
+  (let [close-fn #(state/set-left-sidebar-open! false)
+        srs-open? (= :srs (state/sub :modal/id))]
     [:div#left-sidebar.cp__sidebar-left-layout
      {:class (util/classnames [{:is-open left-sidebar-open?}])}
 
      ;; sidebar contents
-     (sidebar-nav route-match close-fn left-sidebar-open?)
+     (sidebar-nav route-match close-fn left-sidebar-open? srs-open?)
      [:span.shade-mask {:on-click close-fn}]]))
 
+(rum/defc recording-bar
+  []
+  [:> react-draggable
+   {:onStart (fn [_event]
+               (when-let [pos (some-> (state/get-input) cursor/pos)]
+                 (state/set-editor-last-pos! pos)))
+    :onStop (fn [_event]
+              (when-let [block (get-in @state/state [:editor/block :block/uuid])]
+                (editor-handler/edit-block! block :max (:block/uuid block))
+                (when-let [input (state/get-input)]
+                  (when-let [saved-cursor (state/get-editor-last-pos)]
+                    (cursor/move-cursor-to input saved-cursor)))))}
+   [:div#audio-record-toolbar
+    {:style {:bottom (+ @util/keyboard-height 45)}}
+    (footer/audio-record-cp)]])
+
 (rum/defc main <
   {:did-mount (fn [state]
                 (when-let [element (gdom/getElement "main-content-container")]
@@ -284,7 +317,7 @@
                                 (editor-handler/upload-asset id files format editor-handler/*asset-uploading? true))))})
                   (common-handler/listen-to-scroll! element))
                 state)}
-  [{:keys [route-match global-graph-pages? route-name indexeddb-support? db-restoring? main-content show-action-bar?]}]
+  [{:keys [route-match global-graph-pages? route-name indexeddb-support? db-restoring? main-content show-action-bar? show-recording-bar?]}]
   (let [left-sidebar-open? (state/sub :ui/left-sidebar-open?)
         onboarding-and-home? (and (or (nil? (state/get-current-repo)) (config/demo-graph?))
                                   (not config/publishing?)
@@ -306,9 +339,12 @@
         :data-is-full-width         (or global-graph-pages?
                                         (contains? #{:all-files :all-pages :my-publishing} route-name))}
 
+       (when show-recording-bar?
+         (recording-bar))
+
        (mobile-bar)
        (footer/footer)
-
+       
        (when (and (not (mobile-util/native-platform?))
                   (contains? #{:page :home} route-name))
          (widgets/demo-graph-alert))
@@ -352,22 +388,6 @@
                        (:current-parsing-file state))]]]]
     (ui/progress-bar-with-label width left-label (str finished "/" total))))
 
-(rum/defc file-sync-download-progress < rum/static
-  [state]
-  (let [finished (or (:finished state) 0)
-        total (:total state)]
-    (if (= total :unknown)
-      (ui/loading "Loading...")
-      (let [width (js/Math.round (* (.toFixed (/ finished total) 2) 100))
-           left-label [:div.flex.flex-row.font-bold
-                       "Downloading"
-                       [:div.hidden.md:flex.flex-row
-                        [:span.mr-1 ": "]
-                        [:ul
-                         (for [file (:downloading-files state)]
-                           [:li file])]]]]
-       (ui/progress-bar-with-label width left-label (str finished "/" total))))))
-
 (rum/defc main-content < rum/reactive db-mixins/query
   {:init (fn [state]
            (when-not @sidebar-inited?
@@ -393,16 +413,8 @@
         loading-files? (when current-repo (state/sub [:repo/loading-files? current-repo]))
         journals-length (state/sub :journals-length)
         latest-journals (db/get-latest-journals (state/get-current-repo) journals-length)
-        graph-parsing-state (state/sub [:graph/parsing-state current-repo])
-        graph-file-sync-download-init-state (state/sub [:file-sync/download-init-progress current-repo])]
+        graph-parsing-state (state/sub [:graph/parsing-state current-repo])]
     (cond
-      (or
-       (:downloading? graph-file-sync-download-init-state)
-       (not= (:total graph-file-sync-download-init-state) (:finished graph-file-sync-download-init-state)))
-      [:div.flex.items-center.justify-center.full-height-without-header
-       [:div.flex-1
-        (file-sync-download-progress graph-file-sync-download-init-state)]]
-
       (or
        (:graph-loading? graph-parsing-state)
        (not= (:total graph-parsing-state) (:finished graph-parsing-state)))
@@ -465,10 +477,11 @@
   []
   (when-not (state/sub :ui/sidebar-open?)
     [:div.cp__sidebar-help-btn
-     {:title (t :help-shortcut-title)
-      :on-click (fn []
-                  (state/sidebar-add-block! (state/get-current-repo) "help" :help))}
-     "?"]))
+     [:div.inner
+      {:title    (t :help-shortcut-title)
+       :on-click (fn []
+                   (state/sidebar-add-block! (state/get-current-repo) "help" :help))}
+      "?"]]))
 
 (defn- hide-context-menu-and-clear-selection
   [e]
@@ -518,7 +531,8 @@
         edit? (:editor/editing? @state/state)
         default-home (get-default-home-if-valid)
         logged? (user-handler/logged-in?)
-        show-action-bar? (state/sub :mobile/show-action-bar?)]
+        show-action-bar? (state/sub :mobile/show-action-bar?)
+        show-recording-bar? (state/sub :mobile/show-recording-bar?)]
     (theme/container
      {:t             t
       :theme         theme
@@ -561,7 +575,8 @@
                :light?              light?
                :db-restoring?       db-restoring?
                :main-content        main-content
-               :show-action-bar?    show-action-bar?})]
+               :show-action-bar?    show-action-bar?
+               :show-recording-bar? show-recording-bar?})]
 
        (right-sidebar/sidebar)
 

+ 71 - 37
src/main/frontend/components/sidebar.css

@@ -37,13 +37,13 @@
     height: 100%;
     transition: padding-left .3s;
 
-    &.is-left-sidebar-open {
-        padding-left: 0;
+  &.is-left-sidebar-open {
+    padding-left: 0;
 
-        @screen sm {
-            padding-left: var(--ls-left-sidebar-width);
-        }
+    @screen sm {
+      padding-left: var(--ls-left-sidebar-width);
     }
+  }
 }
 
 #main-content {
@@ -68,6 +68,8 @@
   transform: translateX(-100%);
   z-index: 3;
 
+  -webkit-font-smoothing: antialiased;
+
   > .wrap {
     height: calc(100vh - var(--ls-headbar-inner-top-padding) - 50px);
     margin-top: 40px;
@@ -80,36 +82,53 @@
   }
 
   .page-icon {
-    margin-right: 8px;
-    width: 1.1em;
     text-align: center;
     display: inline-block;
+    line-height: 1em;
     color: #aaa;
+    padding: 0 4px 0 8px;
   }
 
   a.item {
     user-select: none;
-    transition: none;
+    transition: background-color .3s;
+    margin-bottom: 2px;
+
+    > .ti {
+      font-size: 16px;
+      margin-right: 8px;
+      opacity: .6;
+      position: relative;
+      top: -1px;
+    }
 
-    > span {
-      margin-top: 3px;
+    &.active, &:active {
+      background-color: var(--ls-quaternary-background-color);
     }
 
     &:hover {
-      background-color: var(--ls-quaternary-background-color);
+      opacity: .8;
+
+      .ti {
+        opacity: .8;
+      }
     }
   }
 
   .nav-content-item {
-    padding: 18px 0 0 0;
+    margin-top: 14px;
+
+    &-inner {
+      border-radius: 8px;
+    }
 
-    > .header {
+    .header {
       display: flex;
       justify-content: space-between;
       align-items: center;
       user-select: none;
       cursor: pointer;
-      padding: 4px 18px;
+      padding: 4px 25px;
 
       > span {
         > a {
@@ -152,9 +171,17 @@
       &:active {
         opacity: .8;
       }
+
+      .wrap-th {
+        > span {
+          font-size: 11px;
+          font-weight: 600;
+          padding-top: 2px;
+        }
+      }
     }
 
-    > .bd {
+    .bd {
       display: none;
 
       ul {
@@ -164,12 +191,13 @@
 
         a {
           width: 100%;
-          padding: 2px 20px;
+          padding: 2px 18px;
           display: block;
           text-overflow: ellipsis;
           overflow: hidden;
           white-space: nowrap;
           color: var(--ls-primary-text-color);
+          transition: background-color .3s;
 
           &:hover {
             background-color: var(--ls-quaternary-background-color);
@@ -183,13 +211,13 @@
     }
 
     &.is-expand {
-      > .header > span > a {
+      .header > span > a {
         &:last-child {
           transform: translateY(2px) translateX(-3px);
         }
       }
 
-      > .bd {
+      .bd {
         display: block;
       }
     }
@@ -197,25 +225,30 @@
 
   .new-page {
     position: absolute;
-    background-color: var(--ls-primary-background-color);
     bottom: 0;
     left: 0;
     width: 100%;
-    padding-bottom: 8px;
-    padding-top: 8px;
+    padding: 14px;
+
+    &-link {
+      background-color: var(--ls-primary-background-color);
+      box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
+    }
   }
 
   @screen sm {
-    background-color: var(--ls-secondary-background-color);
-    width: var(--ls-left-sidebar-width);
     padding-top: 0;
+    width: var(--ls-left-sidebar-width);
+    background-color: var(--ls-secondary-background-color);
 
     > .wrap {
       margin-top: 50px;
     }
 
     .new-page {
-      background-color: var(--ls-secondary-background-color);
+      &-link {
+        background-color: var(--ls-primary-background-color);
+      }
     }
   }
 }
@@ -302,9 +335,9 @@
 }
 
 .ls-wide-mode {
- .cp__sidebar-main-content {
-   max-width: var(--ls-main-content-max-width-wide);
- }
+  .cp__sidebar-main-content {
+    max-width: var(--ls-main-content-max-width-wide);
+  }
 }
 
 html[data-theme='dark'] {
@@ -347,14 +380,15 @@ html[data-theme='dark'] {
   }
 
   &-btn {
-    @apply font-bold fixed bottom-4
-    rounded-full h-8 w-8 flex items-center justify-center font-bold
-    opacity-70 hover:opacity-100;
+    @apply fixed bottom-4 right-8;
 
-    user-select: none;
-    cursor: help;
-    right: 24px;
-    background-color: var(--ls-secondary-background-color);
+    > .inner {
+      @apply font-bold
+      rounded-full h-8 w-8 flex items-center justify-center font-bold
+      opacity-70 hover:opacity-100 select-none cursor-help;
+
+      background-color: var(--ls-secondary-background-color);
+    }
   }
 }
 
@@ -368,8 +402,8 @@ html[data-theme='dark'] {
   }
 
   &.open {
-      width: var(--ls-right-sidebar-width);
-      max-width: 60vw;
+    width: var(--ls-right-sidebar-width);
+    max-width: 60vw;
   }
 
   &-scollable {
@@ -479,5 +513,5 @@ html[data-theme='dark'] {
 }
 
 .full-height-without-header {
-    height: calc(100vh - var(--ls-headbar-height) - 4rem);
+  height: calc(100vh - var(--ls-headbar-height) - 4rem);
 }

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

@@ -380,8 +380,8 @@
 
 (def circle-stop
   [:svg
-   {:width "1.3rem"
-    :height "1.3rem"
+   {:width "20px"
+    :height "20px"
     :viewBox "0 0 512 512"
     :fill     "currentColor"}
    [:path

+ 4 - 38
src/main/frontend/config.cljs

@@ -5,6 +5,7 @@
             [frontend.util :as util]
             [shadow.resource :as rc]
             [logseq.graph-parser.util :as gp-util]
+            [logseq.graph-parser.config :as gp-config]
             [frontend.mobile.util :as mobile-util]))
 
 (goog-define DEV-RELEASE false)
@@ -63,49 +64,20 @@
     (if dev? path
         (str asset-domain path))))
 
-(defn text-formats
-  []
-  (let [config-formats (some->> (get-in @state/state [:config :text-formats])
-                                (map :keyword)
-                                (set))]
-    (set/union
-     config-formats
-     #{:json :org :md :yml :dat :asciidoc :rst :txt :markdown :adoc :html :js :ts :edn :clj :ml :rb :ex :erl :java :php :c :css
-       :excalidraw})))
-
 (def markup-formats
   #{:org :md :markdown :asciidoc :adoc :rst})
 
-(defn img-formats
-  []
-  (let [config-formats (some->> (get-in @state/state [:config :image-formats])
-                                (map :keyword)
-                                (set))]
-    (set/union
-     config-formats
-     #{:gif :svg :jpeg :ico :png :jpg :bmp :webp})))
-
 (defn doc-formats
   []
-  (let [config-formats (some->> (get-in @state/state [:config :document-formats])
-                                (map :keyword)
-                                (set))]
-    (set/union
-     config-formats
-     #{:doc :docx :xls :xlsx :ppt :pptx :one :pdf :epub})))
+  #{:doc :docx :xls :xlsx :ppt :pptx :one :pdf :epub})
 
 (def audio-formats #{:mp3 :ogg :mpeg :wav :m4a :flac :wma :aac})
 
-(def media-formats (set/union (img-formats) audio-formats))
+(def media-formats (set/union (gp-config/img-formats) audio-formats))
 
 (def html-render-formats
   #{:adoc :asciidoc})
 
-(defn supported-formats
-  []
-  (set/union (text-formats)
-             (img-formats)))
-
 (def mobile?
   (when-not util/node-test?
     (util/safe-re-find #"Mobi" js/navigator.userAgent)))
@@ -114,13 +86,7 @@
 
 (defn get-block-pattern
   [format]
-  (let [format (or format (state/get-preferred-format))
-        format (keyword format)]
-    (case format
-      :org
-      "*"
-
-      "-")))
+  (gp-config/get-block-pattern (or format (state/get-preferred-format))))
 
 (defn get-hr
   [format]

+ 19 - 22
src/main/frontend/db.cljs

@@ -1,9 +1,9 @@
 (ns frontend.db
   (:require [clojure.core.async :as async]
             [datascript.core :as d]
-            [frontend.db-schema :as db-schema]
+            [logseq.graph-parser.db.schema :as db-schema]
             [frontend.db.conn :as conn]
-            [frontend.db.default :as default-db]
+            [logseq.graph-parser.db.default :as default-db]
             [frontend.db.model]
             [frontend.db.query-custom]
             [frontend.db.query-react]
@@ -27,7 +27,6 @@
   get-short-repo-name
   datascript-db
   get-db
-  me-tx
   remove-conn!]
 
  [frontend.db.utils
@@ -39,28 +38,27 @@
 
  [frontend.db.model
   blocks-count blocks-count-cache clean-export! delete-blocks get-pre-block
-  delete-file! delete-file-blocks! delete-page-blocks delete-file-pages! delete-file-tx delete-files delete-pages-by-files
+  delete-file-blocks! delete-page-blocks delete-files delete-pages-by-files
   filter-only-public-pages-and-blocks get-all-block-contents get-all-tagged-pages
   get-all-templates get-block-and-children get-block-by-uuid get-block-children sort-by-left
   get-block-parent get-block-parents parents-collapsed? get-block-referenced-blocks
   get-block-children-ids get-block-immediate-children get-block-page
-  get-blocks-contents get-custom-css
-  get-date-scheduled-or-deadlines get-db-type
-  get-file-blocks get-file-contents get-file-last-modified-at get-file get-file-page get-file-page-id file-exists?
-  get-file-pages get-files get-files-blocks get-files-full get-journals-length
-  get-latest-journals get-matched-blocks get-page get-page-alias get-page-alias-names get-paginated-blocks get-page-linked-refs-refed-pages
+  get-custom-css get-date-scheduled-or-deadlines
+  get-file-blocks get-file-last-modified-at get-file get-file-page get-file-page-id file-exists?
+  get-files get-files-blocks get-files-full get-journals-length
+  get-latest-journals get-page get-page-alias get-page-alias-names get-paginated-blocks get-page-linked-refs-refed-pages
   get-page-blocks-count get-page-blocks-no-cache get-page-file get-page-format get-page-properties
   get-page-referenced-blocks get-page-referenced-pages get-page-unlinked-references get-page-referenced-blocks-no-cache
   get-all-pages get-pages get-pages-relation get-pages-that-mentioned-page get-public-pages get-tag-pages
   journal-page? page-alias-set pull-block
-  set-file-last-modified-at! transact-files-db! page-empty? page-exists? page-empty-or-dummy? get-alias-source-page
+  set-file-last-modified-at! page-empty? page-exists? page-empty-or-dummy? get-alias-source-page
   set-file-content! has-children? get-namespace-pages get-all-namespace-relation get-pages-by-name-partition]
 
  [frontend.db.react
   get-current-page set-key-value
   remove-key! remove-q! remove-query-component! add-q! add-query-component! clear-query-state!
   clear-query-state-without-refs-and-embeds! kv q
-  query-state query-components query-entity-in-component remove-custom-query! set-new-result! sub-key-value refresh!]
+  query-state query-components remove-custom-query! set-new-result! sub-key-value refresh!]
 
  [frontend.db.query-custom
   custom-query]
@@ -68,7 +66,7 @@
  [frontend.db.query-react
   react-query custom-query-result-transform]
 
- [frontend.db.default built-in-pages-names built-in-pages])
+ [logseq.graph-parser.db.default built-in-pages-names built-in-pages])
 
 (defn get-schema-version [db]
   (d/q
@@ -147,16 +145,16 @@
     (repo-listen-to-tx! repo conn)))
 
 (defn start-db-conn!
-  ([me repo]
-   (start-db-conn! me repo {}))
-  ([me repo option]
-   (conn/start! me repo
+  ([repo]
+   (start-db-conn! repo {}))
+  ([repo option]
+   (conn/start! repo
                 (assoc option
                        :listen-handler listen-and-persist!))))
 
 (defn restore-graph!
   "Restore db from serialized db cache, and swap into the current db status"
-  [repo me]
+  [repo]
   (p/let [db-name (datascript-db repo)
           db-conn (d/create-conn db-schema/schema)
           _ (swap! conns assoc db-name db-conn)
@@ -166,9 +164,8 @@
                                    (catch js/Error _e
                                      (js/console.warn "Invalid graph cache")
                                      (d/empty-db db-schema/schema)))
-                    attached-db (d/db-with stored-db (concat
-                                                      [(me-tx stored-db me)]
-                                                      default-db/built-in-pages)) ;; TODO bug overriding uuids?
+                    attached-db (d/db-with stored-db
+                                           default-db/built-in-pages) ;; TODO bug overriding uuids?
                     db (if (old-schema? attached-db)
                          (db-migrate/migrate attached-db)
                          attached-db)]
@@ -176,10 +173,10 @@
     (d/transact! db-conn [{:schema/version db-schema/version}])))
 
 (defn restore!
-  [{:keys [repos] :as me} _old-db-schema restore-config-handler]
+  [{:keys [repos]} _old-db-schema restore-config-handler]
   (let [repo (or (state/get-current-repo) (:url (first repos)))]
     (when repo
-      (p/let [_ (restore-graph! repo me)]
+      (p/let [_ (restore-graph! repo)]
         (restore-config-handler repo)
         (listen-and-persist! repo)))))
 

+ 7 - 26
src/main/frontend/db/conn.cljs

@@ -1,15 +1,13 @@
 (ns frontend.db.conn
   "Contains db connections."
   (:require [clojure.string :as string]
-            [frontend.db-schema :as db-schema]
-            [frontend.db.default :as default-db]
             [frontend.util :as util]
             [frontend.mobile.util :as mobile-util]
             [frontend.state :as state]
             [frontend.config :as config]
+            [frontend.util.text :as text-util]
             [logseq.graph-parser.text :as text]
-            [logseq.graph-parser.util :as gp-util]
-            [datascript.core :as d]))
+            [logseq.graph-parser.db :as gp-db]))
 
 (defonce conns (atom {}))
 
@@ -25,7 +23,7 @@
   [repo]
   (cond
     (mobile-util/native-platform?)
-    (text/get-graph-name-from-path repo)
+    (text-util/get-graph-name-from-path repo)
 
     (config/local-db? repo)
     (config/get-local-dir repo)
@@ -69,30 +67,13 @@
   [repo]
   (swap! conns dissoc (datascript-db repo)))
 
-(defn me-tx
-  [_db {:keys [name email avatar]}]
-  (gp-util/remove-nils {:me/name name
-                     :me/email email
-                     :me/avatar avatar}))
-
 (defn start!
-  ([me repo]
-   (start! me repo {}))
-  ([me repo {:keys [db-type listen-handler]}]
+  ([repo]
+   (start! repo {}))
+  ([repo {:keys [listen-handler]}]
    (let [db-name (datascript-db repo)
-         db-conn (d/create-conn db-schema/schema)]
+         db-conn (gp-db/start-conn)]
      (swap! conns assoc db-name db-conn)
-     (d/transact! db-conn [(cond-> {:schema/version db-schema/version}
-                             db-type
-                             (assoc :db/type db-type))
-                           {:block/name "card"
-                            :block/original-name "card"
-                            :block/uuid (d/squuid)}])
-     (when me
-       (d/transact! db-conn [(me-tx (d/db db-conn) me)]))
-
-     (d/transact! db-conn default-db/built-in-pages)
-
      (when listen-handler
        (listen-handler repo)))))
 

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

@@ -8,7 +8,7 @@
             [datascript.core :as d]
             [frontend.config :as config]
             [frontend.date :as date]
-            [frontend.db-schema :as db-schema]
+            [logseq.graph-parser.db.schema :as db-schema]
             [frontend.db.conn :as conn]
             [frontend.db.react :as react]
             [frontend.db.utils :as db-utils]
@@ -16,7 +16,7 @@
             [frontend.util :as util :refer [react]]
             [logseq.graph-parser.util :as gp-util]
             [frontend.db.rules :refer [rules]]
-            [frontend.db.default :as default-db]
+            [logseq.graph-parser.db.default :as default-db]
             [frontend.util.drawer :as drawer]))
 
 ;; lazy loading
@@ -56,18 +56,6 @@
     {:block/page [:db/id :block/name :block/original-name :block/journal-day]}
     {:block/_parent ...}])
 
-(defn transact-files-db!
-  ([tx-data]
-   (db-utils/transact! (state/get-current-repo) tx-data))
-  ([repo-url tx-data]
-   (when-not config/publishing?
-     (let [tx-data (->> (gp-util/remove-nils tx-data)
-                        (remove nil?)
-                        (map #(dissoc % :file/handle :file/type)))]
-       (when (seq tx-data)
-         (when-let [conn (conn/get-db repo-url false)]
-           (d/transact! conn (vec tx-data))))))))
-
 (defn pull-block
   [id]
   (let [repo (state/get-current-repo)]
@@ -208,16 +196,6 @@
            (conn/get-db repo-url) path)
       db-utils/seq-flatten))
 
-(defn get-file-pages
-  [repo-url path]
-  (-> (d/q '[:find ?page
-             :in $ ?path
-             :where
-             [?file :file/path ?path]
-             [?page :block/file ?file]]
-           (conn/get-db repo-url) path)
-      db-utils/seq-flatten))
-
 (defn set-file-last-modified-at!
   [repo path last-modified-at]
   (when (and repo path last-modified-at)
@@ -240,19 +218,6 @@
     (when-let [db (conn/get-db repo)]
       (d/entity db [:file/path path]))))
 
-(defn get-file-contents
-  [repo]
-  (when-let [db (conn/get-db repo)]
-    (->>
-     (d/q
-      '[:find ?path ?content
-        :where
-        [?file :file/path ?path]
-        [?file :file/content ?content]]
-       db)
-     (into {}))))
-
-
 (defn get-files-full
   [repo]
   (when-let [db (conn/get-db repo)]
@@ -666,7 +631,9 @@
         cached-ids-set (set (conj cached-ids page-id))
         first-changed-id (cond
                            (= (:real-outliner-op tx-meta) :indent-outdent)
-                           (last (:move-blocks tx-meta))
+                           (if (state/logical-outdenting?)
+                             (first (:move-blocks tx-meta))
+                             (last (:move-blocks tx-meta)))
 
                            (= outliner-op :move-blocks)
                            (let [{:keys [move-blocks target from-page to-page]} tx-meta]
@@ -1303,43 +1270,11 @@
     (get-block-referenced-blocks-ids id)
     (get-page-referenced-blocks-ids page-name-or-block-uuid)))
 
-(defn get-matched-blocks
-  [match-fn limit]
-  (when-let [repo (state/get-current-repo)]
-    (let [pred (fn [_db content]
-                 (match-fn content))]
-      (->> (d/q
-            '[:find ?block
-              :in $ ?pred
-              :where
-              [?block :block/content ?content]
-              [(?pred $ ?content)]]
-            (conn/get-db)
-            pred)
-           (take limit)
-           db-utils/seq-flatten
-           (db-utils/pull-many '[:block/uuid
-                                 :block/content
-                                 :block/properties
-                                 :block/format
-                                 {:block/page [:block/name]}])))))
-
-;; TODO: Does the result preserves the order of the arguments?
-(defn get-blocks-contents
-  [repo block-uuids]
-  (let [db (conn/get-db repo)]
-    (db-utils/pull-many repo '[:block/content]
-                        (mapv (fn [id] [:block/uuid id]) block-uuids))))
-
 (defn journal-page?
   "sanitized page-name only"
   [page-name]
   (:block/journal? (db-utils/entity [:block/name page-name])))
 
-(defn get-db-type
-  [repo]
-  (db-utils/get-key-value repo :db/type))
-
 (defn get-public-pages
   [db]
   (-> (d/q
@@ -1514,24 +1449,6 @@
                 block-eids (mapv :e datoms)]
             (mapv (fn [eid] [:db.fn/retractEntity eid]) block-eids)))))))
 
-(defn delete-file-pages!
-  [repo-url path]
-  (let [pages (get-file-pages repo-url path)]
-    (mapv (fn [eid] [:db.fn/retractEntity eid]) pages)))
-
-(defn delete-file-tx
-  [repo-url file-path]
-  (->>
-   (concat
-    (delete-file-blocks! repo-url file-path)
-    (delete-file-pages! repo-url file-path)
-    [[:db.fn/retractEntity [:file/path file-path]]])
-   (remove nil?)))
-
-(defn delete-file!
-  [repo-url file-path]
-  (db-utils/transact! repo-url (delete-file-tx repo-url file-path)))
-
 (defn delete-pages-by-files
   [files]
   (let [pages (->> (mapv get-file-page files)

+ 13 - 11
src/main/frontend/db/query_dsl.cljs

@@ -14,6 +14,7 @@
             [frontend.db.rules :as rules]
             [frontend.template :as template]
             [logseq.graph-parser.text :as text]
+            [frontend.util.text :as text-util]
             [frontend.util :as util]))
 
 
@@ -443,17 +444,18 @@ Some bindings in this fn:
   [s]
   (some-> s
           (string/replace text/page-ref-re "\"[[$1]]\"")
-          (string/replace text/between-re (fn [[_ x]]
-                                            (->> (string/split x #" ")
-                                                 (remove string/blank?)
-                                                 (map (fn [x]
-                                                        (if (or (contains? #{"+" "-"} (first x))
-                                                                (and (util/safe-re-find #"\d" (first x))
-                                                                     (some #(string/ends-with? x %) ["y" "m" "d" "h" "min"])))
-                                                          (keyword (name x))
-                                                          x)))
-                                                 (string/join " ")
-                                                 (util/format "(between %s)"))))))
+          (string/replace text-util/between-re
+                          (fn [[_ x]]
+                            (->> (string/split x #" ")
+                                 (remove string/blank?)
+                                 (map (fn [x]
+                                        (if (or (contains? #{"+" "-"} (first x))
+                                                (and (util/safe-re-find #"\d" (first x))
+                                                     (some #(string/ends-with? x %) ["y" "m" "d" "h" "min"])))
+                                          (keyword (name x))
+                                          x)))
+                                 (string/join " ")
+                                 (util/format "(between %s)"))))))
 
 (defn- add-bindings!
   [form q]

+ 5 - 3
src/main/frontend/db/query_react.cljs

@@ -76,8 +76,10 @@
                               remove-nested-children-blocks
                               (model/sort-by-left-recursive)
                               (model/with-pages)))
-                   result)]
-      (if-let [result-transform (:result-transform q)]
+                   result)
+          result-transform-fn (:result-transform q)
+          repo (state/get-current-repo)]
+      (if-let [result-transform (if (keyword? result-transform-fn) (state/sub [:config repo :query/result-transforms result-transform-fn]) result-transform-fn)]
         (if-let [f (sci/eval-string (pr-str result-transform))]
           (try
             (sci/call-fn f result)
@@ -130,4 +132,4 @@
           k [:custom query']]
       (pprint "inputs (post-resolution):" resolved-inputs)
       (pprint "query-opts:" query-opts)
-      (apply react/q repo k query-opts query inputs))))
+      (apply react/q repo k query-opts query inputs))))

+ 0 - 15
src/main/frontend/db/react.cljs

@@ -137,21 +137,6 @@
 
 ;; Reactive query
 
-
-(defn query-entity-in-component
-  ([id-or-lookup-ref]
-   (db-utils/entity (state/get-current-repo) id-or-lookup-ref))
-  ([repo id-or-lookup-ref]
-   (let [k [:entity id-or-lookup-ref]
-         result-atom (:result (get @query-state k))]
-     (when-let [component *query-component*]
-       (add-query-component! k component))
-     (when-let [db (conn/get-db repo)]
-       (let [result (d/entity db id-or-lookup-ref)
-             result-atom (or result-atom (atom nil))]
-         (set! (.-state result-atom) result)
-         (add-q! k nil nil result-atom identity identity identity))))))
-
 (defn get-query-cached-result
   [k]
   (:result (get @query-state k)))

+ 352 - 18
src/main/frontend/dicts.cljc

@@ -1563,14 +1563,18 @@
         :file-sync/other-user-graph "El gráfico local actual está unido al gráfico remoto de otro usuario. Así que no se puede empezar a sincronizar"
         :file-sync/graph-deleted "El gráfico remoto actual se ha eliminado"}
 
-   :nb-NO {:on-boarding/demo-graph "This is a demo graph, changes will not be saved until you open a local folder."
-           :on-boarding/add-graph "Add a graph"
-           :on-boarding/open-local-dir "Open a local directory"
-           :on-boarding/new-graph-desc-1 "Logseq supports both Markdown and Org-mode. You can open an existing directory or create a new one on your device, a directory is also known simply as a folder. Your data will be stored only on this device."
-           :on-boarding/new-graph-desc-2 "After you have opened your directory, it will create three folders in that directory:"
-           :on-boarding/new-graph-desc-3 "/journals - store your journal pages"
-           :on-boarding/new-graph-desc-4 "/pages - store the other pages"
-           :on-boarding/new-graph-desc-5 "/logseq - store configuration, custom.css, and some metadata."
+   :nb-NO {:tutorial/text #?(:cljs (rc/inline "tutorial-no.md")
+                                :default "tutorial-no.md")
+           :tutorial/dummy-notes #?(:cljs (rc/inline "dummy-notes-no.md")
+                                       :default "dummy-notes-no.md")
+           :on-boarding/demo-graph "Dette er en demo graf, endringer vil ikke bli lagret før du åpner en lokal mappe."
+           :on-boarding/add-graph "Legg til en graf"
+           :on-boarding/open-local-dir "Åpne en lokal mappe"
+           :on-boarding/new-graph-desc-1 "Logseq støtter både Markdown og Org-mode. Du kan åpne en eksisterende mappe eller lage en ny på din enhet. Dine data vil bare bli lagret på denne enheten."
+           :on-boarding/new-graph-desc-2 "Etter at du har åpnet en mappe vil det blir opprettet tre undermapper i denne:"
+           :on-boarding/new-graph-desc-3 "/journals - lagrer dine dagboknotater"
+           :on-boarding/new-graph-desc-4 "/pages - lagrer andre sider"
+           :on-boarding/new-graph-desc-5 "/logseq - lagrer konfigurasjon, custom.css og noe metadata."
            :help/start "Kom i gang"
            :help/about "Om Logseq"
            :help/roadmap "Veikart"
@@ -1592,7 +1596,7 @@
            :help/block-reference "Blokkreferanse"
            :help/key-commands "Nøkkelkommandoer"
            :help/working-with-lists " (arbeide med lister)"
-           :help/select-nfs-browser " Vennligst bruk en annen nettleser (f.eks. siste chrome) som støtter NFS for å åpne en lokal mappe."
+           :help/select-nfs-browser " Vennligst bruk en annen nettleser (f.eks. siste Chrome) som støtter NFS for å åpne en lokal mappe."
            :undo "Angre"
            :redo "Gjør om"
            :general "Generell"
@@ -1673,7 +1677,7 @@
            :draw/invalid-file "Kunne ikke laste inn den ugyldige excalidraw-filen"
            :draw/specify-title "Vennligst spesifiser en tittel først!"
            :draw/rename-success "Filen ble omdøpt!"
-           :draw/rename-failure "Omdøpring av fil feilet, årsak: "
+           :draw/rename-failure "Omdøping av fil feilet, årsak: "
            :draw/title-placeholder "Uten navn"
            :draw/save "Lagre"
            :draw/save-changes "Lagre endringer"
@@ -1694,10 +1698,10 @@
            :content/open-in-sidebar "Åpne i sidefeltet"
            :content/copy-as-json "Kopier som JSON"
            :content/click-to-edit "Klikk for å redigere"
-           :settings-page/git-desc "is used for pages version control, you can click the vertical three dots menu to check the page's history."
-           :settings-page/git-confirm "You need to restart the app after updating the Git settings."
-           :settings-page/git-switcher-label "Enable Git auto commit"
-           :settings-page/git-commit-delay "Git auto commit seconds"
+           :settings-page/git-desc "brukes for versjonskontroll av sider. Du kan klikke på ...-menyen for å sjekke sidens historikk."
+           :settings-page/git-confirm "Du må starte appen på nytt etter å ha oppdatert Git innstillingene."
+           :settings-page/git-switcher-label "Skru på Git auto commit"
+           :settings-page/git-commit-delay "Git auto commit sekunder"
            :settings-page/edit-config-edn "Rediger config.edn for nåværende repo"
            :settings-page/edit-custom-css "Rediger custom.css"
            :settings-page/custom-configuration "Tilpasset konfigurasjon"
@@ -1828,7 +1832,7 @@
            :plugin/title "Tittel"
            :plugin/all "Alle"
            :plugin/unpacked "Utpakket"
-           :plugin/delete-alert "Vil du avinstallere plugin [{1}]?"
+           :plugin/delete-alert "Vil du avinstallere utvidelse [{1}]?"
            :plugin/open-settings "Åpne innstillinger"
            :plugin/open-package "Åpne pakke"
            :plugin/load-unpacked "Last inn utpakket utvidelse"
@@ -3545,8 +3549,10 @@
         :settings-page/git-commit-delay "Git otomatik commit saniyesi"
         :settings-page/edit-config-edn "config.edn dosyasını düzenle"
         :settings-page/edit-custom-css "custom.css dosyasını düzenle"
+        :settings-page/edit-export-css "export.css dosyasını düzenle"
         :settings-page/custom-configuration "Özel yapılandırma"
         :settings-page/custom-theme "Özel tema"
+        :settings-page/export-theme "Temayı dışarı aktar"
         :settings-page/show-brackets "Köşeli ayraçları göster"
         :settings-page/spell-checker "Yazım denetleyici"
         :settings-page/auto-updater "Otomatik güncelleme"
@@ -3724,8 +3730,335 @@
 
         :file-sync/other-user-graph "Geçerli yerel grafik, diğer kullanıcının uzak grafiğine bağlıdır. Bu yüzden senkronizasyon başlatılamıyor."
         :file-sync/graph-deleted "Geçerli uzak grafik silindi"}
-
-   :tongue/fallback :en})
+   
+   :ko {:tutorial/text #?(:cljs (rc/inline "tutorial-ko.md")
+                          :default "tutorial-ko.md")
+        :tutorial/dummy-notes #?(:cljs (rc/inline "dummy-notes-ko.md")
+                                 :default "dummy-notes-ko.md")
+        :on-boarding/demo-graph "이 그래프는 데모 그래프입니다. 로컬 폴더를 열기 전까지 변경 사항은 저장되지 않습니다."
+        :on-boarding/add-graph "그래프 추가"
+        :on-boarding/open-local-dir "로컬 폴더 열기"
+        :on-boarding/new-graph-desc-1 "Logseq은 Markdown과 Org-Mode를 모두 지원합니다. 기기에서 존재하는 디렉토리(폴더)를 열거나 새 디렉토리를 만들 수 있습니다. 사용자의 데이터는 오직 이 기기에만 저장됩니다."
+        :on-boarding/new-graph-desc-2 "디렉토리를 열면 Logseq은 3가지 폴더를 만들 것입니다:"
+        :on-boarding/new-graph-desc-3 "/journals - 일지 페이지들을 저장합니다."
+        :on-boarding/new-graph-desc-4 "/pages - 기타 페이지들을 저장합니다."
+        :on-boarding/new-graph-desc-5 "/logseq - 사용자 설정과 custom.css, 그리고 몇 가지 메타데이터를 저장합니다."
+        :help/start "시작"
+        :help/about "Logseq에 대하여"
+        :help/roadmap "로드맵"
+        :help/bug "오류 제보"
+        :help/feature "기능 제안"
+        :help/changelog "변경 사항"
+        :help/blog "Logseq 블로그"
+        :help/docs "안내 문서"
+        :help/privacy "개인정보 보호정책"
+        :help/terms "약관"
+        :help/community "디스코드 커뮤니티"
+        :help/awesome-logseq "Awesome Logseq"
+        :help/shortcuts "키보드 단축키"
+        :help/shortcuts-triggers "트리거"
+        :help/shortcut "단축키"
+        :help/slash-autocomplete "Slash 자동 완성"
+        :help/block-content-autocomplete "블록 콘텐츠 자동 완성"
+        :help/reference-autocomplete "페이지 레퍼런스 자동 완성"
+        :help/block-reference "블록 레퍼런스"
+        :help/key-commands "키 커맨드"
+        :help/working-with-lists " (목록을 사용하는 법)"
+        :help/select-nfs-browser "최신 Chrome과 같이, NFS 기능을 지원하여 로컬 디렉토리를 열 수 있는 기타 브라우저에서 사용할 수 있습니다."
+        :undo "실행 취소"
+        :redo "다시 실행"
+        :general "일반"
+        :more "더 보기"
+        :search/result-for "검색 결과: "
+        :search/items "항목"
+        :search/page-names "페이지 이름 검색"
+        :help/context-menu "블록 컨텍스트 메뉴"
+        :help/fold-unfold "블록 접기/열기 (편집 모드가 아닐 때)"
+        :help/markdown-syntax "Markdown 문법"
+        :help/org-mode-syntax "Org mode 문법"
+        :bold "볼드체"
+        :italics "이탤릭체"
+        :html-link "HTML 링크"
+        :highlight "하이라이트"
+        :strikethrough "취소선"
+        :code "코드"
+        :right-side-bar/help "도움말"
+        :right-side-bar/switch-theme "테마 모드"
+        :right-side-bar/theme "{1} 테마"
+        :right-side-bar/page "페이지 그래프"
+        :right-side-bar/recent "최근 페이지"
+        :right-side-bar/contents "콘텐츠"
+        :right-side-bar/favorites "즐겨찾기"
+        :right-side-bar/page-graph "페이지 그래프"
+        :right-side-bar/block-ref "블록 레퍼런스"
+        :right-side-bar/graph-view "그래프 뷰"
+        :right-side-bar/all-pages "모든 페이지"
+        :right-side-bar/flashcards "플래시 카드"
+        :right-side-bar/new-page "새 페이지"
+        :left-side-bar/journals "일지"
+        :left-side-bar/new-page "새 페이지"
+        :left-side-bar/nav-favorites "즐겨찾기"
+        :left-side-bar/nav-shortcuts "단축키"
+        :left-side-bar/nav-recent-pages "최근 페이지"
+        :format/preferred-mode "어떤 모드를 사용하시겠습니까?"
+        :format/markdown "Markdown"
+        :format/org-mode "Org mode"
+        :reference/linked "링크된 레퍼런스"
+        :reference/unlinked-ref "링크되지 않은 레퍼런스"
+        :page/presentation-mode "프레젠테이션 모드"
+        :page/edit-properties-placeholder "속성"
+        :page/delete-success "{1} 페이지가 성공적으로 삭제되었습니다."
+        :page/delete-confirmation "이 페이지와 페이지의 파일들을 삭제하시겠습니까?"
+        :page/rename-to "\"{1}\" 페이지의 이름을 무엇으로 바꾸시겠습니까?"
+        :page/priority "중요도 \"{1}\""
+        :page/copy-to-json "전체 페이지를 JSON으로 복사"
+        :page/rename "페이지 이름 바꾸기"
+        :page/open-in-finder "디렉토리에서 열기"
+        :page/open-with-default-app "기본 앱으로 열기"
+        :page/action-publish "출판"
+        :page/make-public "출판 전 공개 상태로 만들기"
+        :page/version-history "페이지 편집 기록 확인"
+        :page/open-backup-directory "페이지 백업 디렉토리 열기"
+        :page/file-sync-versions "페이지 버전"
+        :page/make-private "비공개 상태로 만들기"
+        :page/delete "페이지 삭제"
+        :page/add-to-favorites "즐겨찾기에 추가"
+        :page/unfavorite "즐겨찾기에서 삭제"
+        :page/show-journals "일지 보기"
+        :page/show-name "페이지 이름 보기"
+        :page/hide-name "페이지 이름 숨기기"
+        :block/name "페이지 일므"
+        :page/last-modified "마지막 편집 시간:"
+        :page/new-title "새 문서의 제목이 무엇입니까?"
+        :page/earlier "이전"
+        :page/no-more-journals "일지 더 없음"
+        :page/copy-page-url "페이지 URL 복사"
+        :journal/multiple-files-with-different-formats "같은 달에 여러 포맷의 일지 파일이 확인되었습니다. 각 달마다 하나의 일지 파일만 사용하시기 바랍니다."
+        :journal/go-to "파일로 가기"
+        :file/name "파일 이름"
+        :file/file "파일: "
+        :file/last-modified-at "마지막 편집 시간:"
+        :file/no-data "데이터 없음"
+        :file/format-not-supported "확장자 .{1} 형태의 파일은 지원되지 않습니다."
+        :page/created-at "생성 시간:"
+        :page/updated-at "수정 시간:"
+        :page/backlinks "역링크"
+        :editor/block-search "블록 검색"
+        :editor/image-uploading "업로드 중"
+        :draw/invalid-file "유효하지 않은 excalidraw 파일을 불러올 수 없습니다."
+        :draw/specify-title "제목을 먼저 입력하십시오."
+        :draw/rename-success "파일 이름이 성공적으로 변경되었습니다."
+        :draw/rename-failure "파일 이름 변경이 다음 이유로 실패하였습니다: "
+        :draw/title-placeholder "무제"
+        :draw/save "저장"
+        :draw/save-changes "변경사항 저장"
+        :draw/new-file "새 파일"
+        :draw/list-files "파일 목록"
+        :draw/delete "삭제"
+        :draw/more-options "더 보기"
+        :draw/back-to-logseq "Logseq으로 돌아가기"
+        :text/image "이미지"
+        :asset/confirm-delete "정말 {1} 을/를 삭제하겠습니까?"
+        :asset/physical-delete "파일 또한 삭제 (복구 불가능)"
+        :content/copy "복사"
+        :content/cut "잘라내기"
+        :content/make-todos "{1} 만들기"
+        :content/copy-block-ref "블록 주소 복사"
+        :content/copy-block-emebed "블록 임베드 복사"
+        :content/focus-on-block "블록 포커스"
+        :content/open-in-sidebar "사이드바에서 열기"
+        :content/copy-as-json "JSON으로 복사"
+        :content/click-to-edit "클릭하여 수정"
+        :settings-page/git-desc "페이지 버전 컨트롤을 위해 사용되며, 점 세개 메뉴를 클릭하여 페이지의 변경 기록을 확인할 수 있습니다."
+        :settings-page/git-confirm "Git 설정을 변경한 뒤 앱을 재시작해야 합니다."
+        :settings-page/git-switcher-label "Git 자동 커밋 설정"
+        :settings-page/git-commit-delay "Git 자동 커밋 간격 (초)"
+        :settings-page/edit-config-edn "config.edn 수정"
+        :settings-page/edit-custom-css "custom.css 수정"
+        :settings-page/edit-export-css "export.css 수정"
+        :settings-page/custom-configuration "사용자 설정"
+        :settings-page/custom-theme "사용자 테마"
+        :settings-page/export-theme "테마 내보내기"
+        :settings-page/show-brackets "대괄호 표시"
+        :settings-page/spell-checker "문법 검사"
+        :settings-page/auto-updater "자동 업데이트"
+        :settings-page/disable-sentry "사용 통계와 분석을 Logseq에 전송"
+        :settings-page/preferred-outdenting "논리적 아웃덴팅"
+        :settings-page/custom-date-format "선호하는 날짜 형식"
+        :settings-page/preferred-file-format "선호하는 파일 형식"
+        :settings-page/preferred-workflow "선호하는 워크플로우"
+        :settings-page/enable-shortcut-tooltip "단축키 툴팁 활성화"
+        :settings-page/enable-timetracking "시간 추적 활성화"
+        :settings-page/enable-tooltip "툴팁 활성화"
+        :settings-page/enable-journals "일지 활성화"
+        :settings-page/enable-all-pages-public "출판할 때 모든 페이지 공개로 설정"
+        :settings-page/enable-encryption "암호화"
+        :settings-page/customize-shortcuts "키보드 단축키"
+        :settings-page/shortcut-settings "단축키 설정"
+        :settings-page/home-default-page "기본 홈 페이지 설정"
+        :settings-page/enable-block-time "블록 타임스탬프"
+        :settings-page/clear-cache "캐시 지우기"
+        :settings-page/clear "지우기"
+        :settings-page/developer-mode "개발자 모드"
+        :settings-page/enable-developer-mode "개발자 모드 활성화"
+        :settings-page/disable-developer-mode "개발자 모드 비활성화"
+        :settings-page/developer-mode-desc "개발자 모드는 컨트리뷰터와 확장 프로그램 개발자들이 Logseq과의 연동을 더 쉽고 효율적으로 테스트할 수 있게 도와줍니다."
+        :settings-page/current-version "현재 버전"
+        :settings-page/current-graph "현재 그래프"
+        :settings-page/tab-general "일반"
+        :settings-page/tab-editor "에디터"
+        :settings-page/tab-shortcuts "단축키"
+        :settings-page/tab-version-control "버전 컨트롤"
+        :settings-page/tab-advanced "고급"
+        :settings-page/plugin-system "플러그인 시스템"
+        :settings-page/network-proxy "네트워크 프록시"
+        :logseq "Logseq"
+        :on "ON"
+        :more-options "더 많은 옵션"
+        :to "to"
+        :yes "예"
+        :no "아니오"
+        :submit "제출"
+        :cancel "취소"
+        :close "닫기"
+        :delete "삭제"
+        :save "저장"
+        :type "타입"
+        :host "호스트"
+        :port "포트"
+        :re-index "인덱스 재생성"
+        :re-index-detail "그래프 다시 빌드"
+        :re-index-multiple-windows-warning "그래프를 다시 인덱싱 전 다른 윈도우를 모두 닫아야 합니다."
+        :re-index-discard-unsaved-changes-warning "인덱싱을 다시 하게 되면 현재 나타나 있는 그래프가 사라지며, 하드 디스크에 저장된 파일대로 그래프를 재구성하게 됩니다. 저장되지 않은 변경사항들이 삭제되며 약간의 시간이 걸릴 수 있습니다. 계속하시겠습니까?"
+        :open-new-window "새 창"
+        :sync-from-local-files "새로고침"
+        :sync-from-local-files-detail "로컬 파일로부터 변경 사항 불러오기"
+        :sync-from-local-changes-detected "그래프를 새로 고치면 로컬 디스크에서 Logseq과는 다르게 변경된 파일들을 감지하고 처리합니다. 계속하시겠습니까?"
+
+        :unlink "링크 해제"
+        :search/publishing "검색"
+        :search "페이지를 검색하거나 생성"
+        :page-search "현재 페이지에서 검색"
+        :graph-search "그래프 검색"
+        :new-page "새 페이지"
+        :new-file "새 파일"
+        :new-graph "새 그래프"
+        :graph "그래프"
+        :graph-view "그래프 보기"
+        :graph/persist "Logseq가 내부 상태를 동기화 중입니다. 잠시만 기다려주십시오."
+        :graph/persist-error "내부 상태 동기화에 실패했습니다."
+        :graph/save "저장 중..."
+        :graph/save-success "저장 완료"
+        :graph/save-error "저장 실패"
+        :cards-view "카드 보기"
+        :publishing "출판"
+        :export "내보내기"
+        :export-graph "그래프 내보내기"
+        :export-page "페이지 내보내기"
+        :export-markdown "표준 Markdown으로 내보내기 (블록 속성 미포함)"
+        :export-opml "OPML으로 내보내기"
+        :export-public-pages "공개 페이지 내보내기"
+        :export-json "JSON으로 내보내기"
+        :export-roam-json "Roam JSON으로 내보내기"
+        :export-edn "EDN으로 내보내기"
+        :export-datascript-edn "Datascript EDN으로 내보내기"
+        :convert-markdown "Markdown 헤딩을 Unordered List들로 내보내기 (# -> -)"
+        :all-graphs "모든 그래프"
+        :all-pages "모든 페이지"
+        :all-files "모든 파일"
+        :remove-orphaned-pages "고립된 페이지 삭제"
+        :all-journals "모든 일지"
+        :my-publishing "나의 출판"
+        :settings "설정"
+        :settings-of-plugins "플러그인 설정"
+        :plugins "플러그인"
+        :themes "테마"
+        :developer-mode-alert "플러그인 시스템을 활성화하려면 앱을 재시작해야 합니다. 지금 재시작하시겠습니까?"
+        :relaunch-confirm-to-work "완료하려면 앱을 재시작해야 합니다. 지금 재시작하시겠습니까?"
+        :import "불러오기"
+        :join-community "커뮤니티에 참여"
+        :sponsor-us "후원"
+        :discord-title "디스코드"
+        :help-shortcut-title "다른 단축키와 도움말 확인하기"
+        :loading "로딩 중"
+        :cloning "복제 중"
+        :parsing-files "파일 파싱 중"
+        :loading-files "파일 로딩 중"
+        :login "로그인"
+        :logout "로그아웃"
+        :go-to "다음으로 이동: "
+        :or "또는"
+        :download "다운로드"
+        :repo/download-zip "ZIP 다운로드"
+        :language "언어"
+        :white "라이트 모드"
+        :dark "다크 모드"
+        :remove-background "배경 제거"
+        :open "열기"
+        :open-a-directory "로컬 디렉토리 열기"
+        :user/delete-account "계정 삭제"
+        :user/delete-your-account "사용자의 계정 삭제"
+        :user/delete-account-notice "logseq.com에 출판된 모든 문서가 삭제됩니다."
+
+        :help/shortcut-page-title "키보드 단축키"
+
+        :plugin/installed "설치됨"
+        :plugin/not-installed "설치되지 않음"
+        :plugin/installing "설치 중"
+        :plugin/install "설치"
+        :plugin/reload "다시 불러오기"
+        :plugin/update "업데이트"
+        :plugin/check-update "업데이트 확인"
+        :plugin/check-all-updates "모든 업데이트 확인"
+        :plugin/refresh-lists "리스트 새로고침"
+        :plugin/enabled "활성화됨"
+        :plugin/disabled "비활성화됨"
+        :plugin/update-available "업데이트 가능"
+        :plugin/updating "업데이트 중"
+        :plugin/uninstall "설지 제거"
+        :plugin/marketplace "마켓플레이스"
+        :plugin/downloads "다운로드"
+        :plugin/stars "스타"
+        :plugin/title "제목"
+        :plugin/all "전체"
+        :plugin/unpacked "압축 해제됨"
+        :plugin/delete-alert "다음 [{1}] 플러그인을 삭제하시겠습니까?"
+        :plugin/open-settings "설정 열기"
+        :plugin/open-package "패키지 열기"
+        :plugin/load-unpacked "압축 해제된 플러그인 불러오기"
+        :plugin/open-preferences "플러그인 설정 열기"
+        :plugin/restart "앱 다시 시작"
+        :plugin/unpacked-tips "플러그인 디렉토리 열기"
+        :plugin/contribute "✨ 새 플러그인을 만들고 기여하기"
+        :plugin/marketplace-tips "플러그인을 처음 설치하고 정상적으로 동작하지 않으면 Logseq를 다시 시작해 보십시오."
+        :plugin/up-to-date "최신 상태입니다."
+        :plugin/custom-js-alert "custom.js 파일을 감지했습니다. 실행을 허용하겠습니까? (파일의 내용을 이해하지 못한다면 보안과 안전 상의 이유로 실행하지 않는 것이 권장됩니다."
+
+        :pdf/copy-ref "레퍼런스 복사하기"
+        :pdf/copy-text "텍스트 복사하기"
+        :pdf/linked-ref "링크된 레퍼런스"
+        :pdf/toggle-dashed "영역 하이라이트를 위해 Dashed style 사용"
+
+        :updater/new-version-install "새 버전이 다운로드되었습니다."
+        :updater/quit-and-install "다시 시작하여 설치하십시오."
+
+        :paginates/pages "총 {1} 페이지"
+        :paginates/prev "이전"
+        :paginates/next "다음"
+
+        :tips/all-done "모두 완료"
+
+        :command-palette/prompt "커맨드를 입력하십시오"
+        :select/default-prompt "하나를 선택하십시오"
+        :select.graph/prompt "그래프를 선택하십시오."
+        :select.graph/empty-placeholder-description "일치하는 그래프가 없습니다. 새로 추가하시겠습니까?"
+        :select.graph/add-graph "네, 새 그래프를 추가합니다"
+
+        :file-sync/other-user-graph "현재 로컬 그래프가 다른 유저의 리모트 그래프와 충돌합니다. 동기화를 시작할 수 없습니다."
+        :file-sync/graph-deleted "현재 리모트 그래프를 삭제했습니다."
+        }
+     
+     :tongue/fallback :en})
 
 (def languages [{:label "English" :value :en}
                 {:label "Français" :value :fr}
@@ -3740,4 +4073,5 @@
                 {:label "Русский" :value :ru}
                 {:label "日本語" :value :ja}
                 {:label "Italiano" :value :it}
-                {:label "Türkçe" :value :tr}])
+                {:label "Türkçe" :value :tr}
+                {:label "한국어" :value :ko}])

+ 2 - 2
src/main/frontend/diff.cljs

@@ -6,7 +6,7 @@
             [cljs-bean.core :as bean]
             [frontend.util :as util]
             [logseq.graph-parser.util :as gp-util]
-            [logseq.graph-parser.text :as text]))
+            [frontend.util.text :as text-util]))
 
 (defn diff
   [s1 s2]
@@ -47,7 +47,7 @@
 
                       :else
                       (recur r1 t2 (inc i1) i2))))
-            current-line (text/get-current-line-by-pos markup pos)]
+            current-line (text-util/get-current-line-by-pos markup pos)]
         (cond
           (= (util/nth-safe markup pos)
              (util/nth-safe markup (inc pos))

+ 4 - 0
src/main/frontend/extensions/pdf/pdf.css

@@ -684,6 +684,10 @@ body.is-pdf-active {
   #main-container.is-left-sidebar-open {
     padding-left: unset;
   }
+
+  #left-menu {
+    display: none;
+  }
 }
 
 /* overrides for pdf_viewer.css from PDF.JS web viewer */

+ 6 - 3
src/main/frontend/extensions/sci.cljs

@@ -1,5 +1,6 @@
 (ns frontend.extensions.sci
-  (:require [sci.core :as sci]))
+  (:require [sci.core :as sci]
+            [frontend.util :as util]))
 
 ;; Some helpers
 (def sum (partial apply +))
@@ -13,7 +14,9 @@
     (sci/eval-string s {:bindings {'sum sum
                                    'average average
                                    'parseFloat js/parseFloat
-                                   'isNaN js/isNaN}})
+                                   'isNaN js/isNaN
+                                   'log js/console.log
+                                   'pprint util/pp-str}})
     (catch js/Error e
       (println "Query: sci eval failed:")
       (js/console.error e))))
@@ -29,4 +32,4 @@
    [:div.results.mt-1
     [:pre.code
      (let [result (eval-string code)]
-       (str result))]]])
+       (str result))]]])

+ 0 - 5
src/main/frontend/format.cljs

@@ -3,14 +3,9 @@
             [frontend.format.adoc :refer [->AdocMode]]
             [frontend.format.protocol :as protocol]
             [logseq.graph-parser.mldoc :as gp-mldoc]
-            [logseq.graph-parser.text :as text]
             [logseq.graph-parser.util :as gp-util]
             [clojure.string :as string]))
 
-;; TODO: Properly fix this circular dependency:
-;; mldoc/->edn > text/parse-property > mldoc/link? ->mldoc/inline->edn + mldoc/default-config
-(set! gp-mldoc/parse-property text/parse-property)
-
 (defonce mldoc-record (->MldocMode))
 (defonce adoc-record (->AdocMode))
 

+ 2 - 1
src/main/frontend/format/block.cljs

@@ -6,6 +6,7 @@
             [frontend.db :as db]
             [frontend.format :as format]
             [frontend.state :as state]
+            [logseq.graph-parser.config :as gp-config]
             [logseq.graph-parser.property :as gp-property]
             [logseq.graph-parser.mldoc :as gp-mldoc]))
 
@@ -15,7 +16,7 @@
   (gp-block/extract-blocks blocks content with-id? format
                            {:user-config (state/get-config)
                             :block-pattern (config/get-block-pattern format)
-                            :supported-formats (config/supported-formats)
+                            :supported-formats (gp-config/supported-formats)
                             :db (db/get-db (state/get-current-repo))
                             :date-formatter (state/get-date-formatter)}))
 

+ 277 - 151
src/main/frontend/fs/sync.cljs

@@ -1,6 +1,8 @@
 (ns frontend.fs.sync
   (:require [cljs-http.client :as http]
             [cljs-time.core :as t]
+            [cljs-time.format :as tf]
+            [cljs-time.coerce :as tc]
             [cljs.core.async :as async :refer [go timeout go-loop offer! poll! chan <! >!]]
             [cljs.core.async.impl.channels]
             [cljs.core.async.interop :refer [p->c]]
@@ -115,12 +117,14 @@
 
 (def graphs-txid (persist-var/persist-var nil "graphs-txid"))
 
+(declare assert-local-txid<=remote-txid)
 (defn update-graphs-txid!
   [latest-txid graph-uuid user-uuid repo]
   {:pre [(int? latest-txid) (>= latest-txid 0)]}
   (persist-var/-reset-value! graphs-txid [user-uuid graph-uuid latest-txid] repo)
   (some-> (persist-var/persist-save graphs-txid)
-          p->c))
+          p->c)
+  (when (state/developer-mode?) (assert-local-txid<=remote-txid)))
 
 (defn clear-graphs-txid! [repo]
   (persist-var/-reset-value! graphs-txid nil repo)
@@ -192,20 +196,37 @@
        :api-name api-name
        :body body})))
 
-(defn- request
-  ([api-name body token refresh-token-fn] (request api-name body token refresh-token-fn 0))
-  ([api-name body token refresh-token-fn retry-count]
+(def *on-flying-request
+  "requests not finished"
+  (atom #{}))
+
+(defn- request*
+  "max retry count is 5.
+  *stop: volatile var, stop retry-request when it's true,
+          and return :stop"
+  ([api-name body token refresh-token-fn *stop] (request* api-name body token refresh-token-fn 0 *stop))
+  ([api-name body token refresh-token-fn retry-count *stop]
    (go
-     (let [resp (<! (request-once api-name body token))]
-       (if (and
-            (= 401 (get-in resp [:resp :status]))
-            (= "Unauthorized" (:message (get-json-body (get-in resp [:resp :body])))))
-         (do
-           (println "will retry after" (min 60000 (* 1000 retry-count)) "ms")
-           (<! (timeout (min 60000 (* 1000 retry-count))))
-           (let [token (<! (refresh-token-fn))]
-             (<! (request api-name body token refresh-token-fn (inc retry-count)))))
-         (:resp resp))))))
+     (if (and *stop @*stop)
+       :stop
+       (let [resp (<! (request-once api-name body token))]
+         (if (and
+              (= 401 (get-in resp [:resp :status]))
+              (= "Unauthorized" (:message (get-json-body (get-in resp [:resp :body])))))
+           (if (> retry-count 5)
+             (throw (js/Error. :file-sync-request))
+             (do (println "will retry after" (min 60000 (* 1000 retry-count)) "ms")
+                 (<! (timeout (min 60000 (* 1000 retry-count))))
+                 (let [token (<! (refresh-token-fn))]
+                   (<! (request* api-name body token refresh-token-fn (inc retry-count) *stop)))))
+           (:resp resp)))))))
+
+(defn request [api-name & args]
+  (let [name (str api-name (.now js/Date))]
+    (go (swap! *on-flying-request conj name)
+        (let [r (<! (apply request* api-name args))]
+          (swap! *on-flying-request disj name)
+          r))))
 
 (defn- remove-dir-prefix [dir path]
   (let [is-mobile-url? (string/starts-with? dir "file://")
@@ -381,14 +402,17 @@
   IRelativePath
   (-relative-path [_] path)
 
+
+  ;; ignore size, cause size value from remote is count of encrypted-data
   IEquiv
   (-equiv [o ^FileMetadata other]
-    (and (= size (.-size other))
+    (and ;; (= size (.-size other))
          (= (.get-normalized-path o) (.get-normalized-path other))
          (= etag (.-etag other))))
 
   IHash
-  (-hash [_] (hash {:size size :etag etag :path path}))
+  (-hash [_] (hash {;; :size size
+                    :etag etag :path path}))
 
   IPrintWithWriter
   (-pr-writer [_ w _opts]
@@ -403,13 +427,48 @@
     (remove-user-graph-uuid-prefix o)
 
     :else
-    (throw (js/Error. (str "unsupport type " (type o))))))
+    (throw (js/Error. (str "unsupport type " (str o))))))
+
+(defn- sort-file-metatdata-fn
+  ":recent-days-range > :favorite-pages > small-size pages > ...
+  :recent-days-range : [<min-inst-ms> <max-inst-ms>]
+"
+  [& {:keys [recent-days-range favorite-pages]}]
+  {:pre [(or (nil? recent-days-range)
+             (every? number? recent-days-range))]}
+  (let [favorite-pages* (set favorite-pages)]
+    (fn [^FileMetadata item]
+      (let [path (relative-path item)
+            journal? (string/starts-with? path "journals/")
+            journal-day
+            (when journal?
+              (try
+                (tc/to-long
+                 (tf/parse (tf/formatter "yyyy_MM_dd")
+                           (-> path
+                               (string/replace-first "journals/" "")
+                               (string/replace-first ".md" ""))))
+                (catch :default _)))]
+        (cond
+          (and recent-days-range
+               journal-day
+               (<= (first recent-days-range)
+                   ^number journal-day
+                   (second recent-days-range)))
+          journal-day
+
+          (contains? favorite-pages* path)
+          (count path)
+
+          :else
+          (- (.-size item)))))))
 
 ;;; ### APIs
 ;; `RSAPI` call apis through rsapi package, supports operations on files
 
 (defprotocol IRSAPI
-  (set-env [this prod? secret-key public-key] "set environment and passphrase")
+  (key-gen [this] "generate public+private keys")
+  (set-env [this prod? private-key public-key] "set environment")
   (get-local-files-meta [this graph-uuid base-path filepaths] "get local files' metadata")
   (get-local-all-files-meta [this graph-uuid base-path] "get all local files' metadata")
   (rename-local-file [this graph-uuid base-path from to])
@@ -431,7 +490,7 @@
   (get-graph-salt [this graph-uuid] "return httpcode 410 when salt expired")
   (create-graph-salt [this graph-uuid] "return httpcode 409 when salt already exists and not expired yet")
   (get-graph-encrypt-keys [this graph-uuid])
-  (create-graph-encrypt-keys [this graph-uuid public-key encrypted-private-key]))
+  (upload-graph-encrypt-keys [this graph-uuid public-key encrypted-private-key]))
 
 (defprotocol IToken
   (get-token [this])
@@ -459,11 +518,14 @@
     (go
       (<! (user/refresh-id-token&access-token))
       (state/get-auth-id-token)))
+
   IRSAPI
-  (set-env [_ prod? secret-key public-key]
-    (when (not-empty secret-key)
+  (key-gen [_] (go (js->clj (<! (p->c (ipc/ipc "key-gen")))
+                            :keywordize-keys true)))
+  (set-env [_ prod? private-key public-key]
+    (when (not-empty private-key)
       (print "[sync] setting sync age-encryption passphrase..."))
-    (go (<! (p->c (ipc/ipc "set-env" (if prod? "prod" "dev") secret-key public-key)))))
+    (go (<! (p->c (ipc/ipc "set-env" (if prod? "prod" "dev") private-key public-key)))))
   (get-local-all-files-meta [_ graph-uuid base-path]
     (go
       (let [r (<! (retry-rsapi #(p->c (ipc/ipc "get-local-all-files-meta" graph-uuid base-path))))]
@@ -529,6 +591,8 @@
       (state/get-auth-id-token)))
 
   IRSAPI
+  (key-gen [_] ;; TODO
+    )
   (set-env [_ prod? secret-key public-key]
     (go (<! (p->c (.setEnv mobile-util/file-sync (clj->js {:env (if prod? "prod" "dev")
                                                            :secretKey secret-key
@@ -620,16 +684,19 @@
              :else
              nil))
 
-(deftype RemoteAPI []
+(deftype RemoteAPI [*stopped?]
   Object
 
   (request [this api-name body]
     (go
-      (let [resp (<! (request api-name body (<! (get-token this)) #(refresh-token this)))]
+      (let [resp (<! (request api-name body (<! (get-token this)) #(refresh-token this) *stopped?))]
         (if (http/unexceptional-status? (:status resp))
           (get-resp-json-body resp)
           (ex-info "request failed"
-                   {:err resp :body (get-resp-json-body resp)})))))
+                   {:err resp
+                    :body (get-resp-json-body resp)
+                    :api-name api-name
+                    :request-body body})))))
 
   ;; for test
   (update-files [this graph-uuid txid files]
@@ -665,7 +732,7 @@
               (apply conj! file-meta-list
                      (map
                       #(->FileMetadata (:Size %)
-                                       (:ETag %)
+                                       (:checksum %)
                                        (remove-user-graph-uuid-prefix (js/decodeURIComponent (:Key %)))
                                        (:LastModified %)
                                        true nil)
@@ -731,19 +798,17 @@
   (get-graph-encrypt-keys [this graph-uuid]
     (.request this "get_graph_encrypt_keys" {:GraphUUID graph-uuid}))
 
-  (create-graph-encrypt-keys [this graph-uuid public-key encrypted-private-key]
-    (.request this "create_graph_encrypt_keys" {:GraphUUID graph-uuid
+  (upload-graph-encrypt-keys [this graph-uuid public-key encrypted-private-key]
+    (.request this "upload_graph_encrypt_keys" {:GraphUUID graph-uuid
                                                 :public-key public-key
                                                 :encrypted-private-key encrypted-private-key})))
 
 
-(def remoteapi (->RemoteAPI))
+(def remoteapi (->RemoteAPI nil))
 
 (defn- add-new-version-file
   [repo path content]
-  (go
-    (println "add-new-version-file: "
-             (<! (p->c (ipc/ipc "addVersionFile" (config/get-local-dir repo) path content))))))
+  (p->c (ipc/ipc "addVersionFile" (config/get-local-dir repo) path content)))
 
 (defn- is-journals-or-pages?
   [filetxn]
@@ -806,6 +871,12 @@
                    (string/index-of (str (ex-cause r)) "No such file or directory"))
             true
             r))))))
+(defn- assert-local-txid<=remote-txid
+  []
+  (when-let [local-txid (last @graphs-txid)]
+    (go (let [remote-txid (:TXId (<! (get-remote-graph remoteapi nil (second @graphs-txid))))]
+          (assert (<= local-txid remote-txid)
+                  [@graphs-txid local-txid remote-txid])))))
 
 (declare sync-state--add-current-local->remote-files
          sync-state--add-current-remote->local-files
@@ -813,6 +884,7 @@
          sync-state--remove-current-remote->local-files
          sync-state--stopped?)
 
+
 (defn apply-filetxns-partitions
   "won't call update-graph-txid! when *txid is nil"
   [*sync-state user-uuid graph-uuid base-path filetxns-partitions repo *txid *stopped before-f after-f]
@@ -860,14 +932,19 @@
         cause (ex-cause resp)]
     (or
      (and (= (:error data) :promise-error)
-          (string/index-of (str cause) "txid_to_validate")) ;FIXME: better rsapi err info
+          (when-let [r (re-find #"(\d+), txid_to_validate = (\d+)" (str cause))]
+            (> (nth r 1) (nth r 2)))) ;; TODO: better rsapi err info
      (= 409 (get-in data [:err :status])))))
 
 (defmethod need-sync-remote? :chan [c]
   (go (need-sync-remote? (<! c))))
 (defmethod need-sync-remote? :default [_] false)
 
-
+(defn- need-reset-local-txid?
+  [r]
+  (when-let [cause (ex-cause r)]
+    (when-let [r (re-find #"(\d+), txid_to_validate = (\d+)" (str cause))]
+      (< (nth r 1) (nth r 2)))))
 
 
 ;; type = "change" | "add" | "unlink"
@@ -914,35 +991,40 @@
 
 ;;; ### encryption
 (def pwd-map
-  "graph-uuid->pwd"
+  "graph-uuid->{:pwd xxx :public-key xxx :private-key xxx}"
   (atom {}))
+
 (def pwd-map-changed-chan
   (chan (async/sliding-buffer 1)))
 
 (add-watch pwd-map :pwd-map-changed #(offer! pwd-map-changed-chan true))
 
-(defn- encrypt-pwd
-  [pwd key*]
-  (p->c (encrypt/encrypt-with-passphrase key* pwd)))
+(defn- encrypt-content
+  [content key*]
+  (p->c (encrypt/encrypt-with-passphrase key* content)))
 
-(defn- decrypt-pwd
-  [encrypted-pwd key*]
+(defn- decrypt-content
+  [encrypted-content key*]
   (go
-    (let [r (<! (p->c (encrypt/decrypt-with-passphrase key* encrypted-pwd)))]
+    (let [r (<! (p->c (encrypt/decrypt-with-passphrase key* encrypted-content)))]
       (when-not (instance? ExceptionInfo r) r))))
 
+(defn- local-storage-pwd-path
+  [graph-uuid]
+  (str "encrypted-pwd/" graph-uuid))
+
 (defn- persist-pwd!
-  [pwd repo]
-  (go
-    (let [path (config/get-file-path repo (str config/app-name "/encrypted-password.txt"))
-          repo-dir (config/get-repo-dir repo)]
-      (<! (p->c (fs/mkdir-if-not-exists (str repo-dir "/" config/app-name))))
-      (<! (p->c (fs/write-file! repo repo-dir path pwd {:skip-compare? true}))))))
+  [pwd graph-uuid]
+  (js/localStorage.setItem (local-storage-pwd-path graph-uuid) pwd))
+
+(defn- remove-pwd!
+  [graph-uuid]
+  (js/localStorage.removeItem (local-storage-pwd-path graph-uuid)))
 
 (defn encrypt+persist-pwd!
   "- store pwd in `pwd-map`
-  - persist encrypted pwd at 'logseq/encrypted-password.txt'"
-  [pwd graph-uuid repo]
+  - persist encrypted pwd at local-storage"
+  [pwd graph-uuid]
   (go
     (let [[value expired-at gone?]
           ((juxt :value :expired-at #(-> % ex-data :err :status (= 410)))
@@ -951,44 +1033,96 @@
           (if gone?
             ((juxt :value :expired-at) (<! (create-graph-salt remoteapi graph-uuid)))
             [value expired-at])
-          encrypted-pwd (<! (encrypt-pwd pwd salt-value))]
-      (<! (persist-pwd! encrypted-pwd repo)))))
+          encrypted-pwd (<! (encrypt-content pwd salt-value))]
+      (persist-pwd! encrypted-pwd graph-uuid))))
 
 (defn restore-pwd!
   "restore pwd from persisted encrypted-pwd, update `pwd-map`"
-  [repo graph-uuid]
+  [graph-uuid]
   (go
-    (let [encrypted-pwd (<! (p->c (fs/read-file "" (config/get-file-path repo "logseq/encrypted-password.txt"))))]
-      (if (or (nil? encrypted-pwd) (instance? ExceptionInfo encrypted-pwd))
+    (let [encrypted-pwd (js/localStorage.getItem (local-storage-pwd-path graph-uuid))]
+      (if (nil? encrypted-pwd)
         {:restore-pwd-failed true}
         (let [[salt-value _expired-at gone?]
               ((juxt :value :expired-at #(-> % ex-data :err :status (= 410)))
                (<! (get-graph-salt remoteapi graph-uuid)))]
           (if (or gone? (empty? salt-value))
             {:restore-pwd-failed "expired salt"}
-            (let [pwd (<! (decrypt-pwd encrypted-pwd salt-value))]
+            (let [pwd (<! (decrypt-content encrypted-pwd salt-value))]
               (if (nil? pwd)
                 {:restore-pwd-failed (str "decrypt-pwd failed, salt: " salt-value)}
-                (swap! pwd-map assoc graph-uuid pwd)))))))))
+                (swap! pwd-map assoc-in [graph-uuid :pwd] pwd)))))))))
 
 (defn ensure-pwd-exists!
   [repo graph-uuid]
   (go
-    (let [pwd (get @pwd-map graph-uuid)]
+    (let [pwd (get-in @pwd-map [graph-uuid :pwd])]
       (when (nil? pwd)
         (let [{restore-pwd-failed :restore-pwd-failed}
-              (<! (restore-pwd! repo graph-uuid))]
+              (<! (restore-pwd! graph-uuid))]
           (when restore-pwd-failed
             (state/pub-event! [:modal/remote-encryption-input-pw-dialog repo {:GraphUUID graph-uuid} :input-pwd-remote
-                               #(restore-pwd! repo graph-uuid)])))
+                               #(restore-pwd! graph-uuid)])))
         (loop []
           (<! pwd-map-changed-chan)
-          (let [pwd (get @pwd-map graph-uuid)]
+          (let [pwd (get-in @pwd-map [graph-uuid :pwd])]
             (when (nil? pwd) (recur)))))
-      (get @pwd-map graph-uuid))))
+      (get-in @pwd-map [graph-uuid :pwd]))))
+
+(defn clear-pwd!
+  "- clear pwd in `pwd-map`
+  - remove encrypted-pwd in local-storage"
+  [graph-uuid]
+  (swap! pwd-map dissoc graph-uuid)
+  (remove-pwd! graph-uuid))
+
+(defn ensure-pwd+keys-exists!
+  "ensure password persisted,
+  and ensure public&private keys exists at server"
+  [graph-uuid repo]
+  (go
+    (<! (ensure-pwd-exists! repo graph-uuid))
+    (let [pwd (get-in @pwd-map [graph-uuid :pwd])
+          {:keys [public-key encrypted-private-key] :as r}
+          (<! (get-graph-encrypt-keys remoteapi graph-uuid))]
+      (if (and (nil? public-key)
+               (nil? encrypted-private-key)
+               (-> r ex-data :err :status (= 404)))
+        ;; when public+private keys not stored at server
+        ;; generate a new key pair and upload them
+        (let [{public-key :publicKey private-key :secretKey}
+              (<! (key-gen rsapi))
+              encrypted-private-key (<! (encrypt-content private-key pwd))
+              upload-r (<! (upload-graph-encrypt-keys remoteapi graph-uuid public-key encrypted-private-key))]
+          (if (instance? ExceptionInfo upload-r)
+            (do (js/console.log "upload-graph-encrypt-keys err" upload-r)
+                ::stop)
+            (do (swap! pwd-map assoc-in [graph-uuid :public-key] public-key)
+                (swap! pwd-map assoc-in [graph-uuid :private-key] private-key)
+                (<! (set-env rsapi config/FILE-SYNC-PROD? private-key public-key))
+                ::idle)))
+
+        (let [private-key (<! (decrypt-content encrypted-private-key pwd))]
+          (if (and private-key
+                   (string/starts-with?
+                    private-key "AGE-SECRET-KEY"))
+            (do (swap! pwd-map assoc-in [graph-uuid :public-key] public-key)
+                (swap! pwd-map assoc-in [graph-uuid :private-key] private-key)
+                (<! (set-env rsapi config/FILE-SYNC-PROD? private-key public-key))
+                ::idle)
+
+            ;; bad pwd
+            (do (notification/show! "wrong password" :error false)
+                (clear-pwd! graph-uuid)
+                ::need-password)))))))
 
 ;;; ### sync state
 
+(def full-sync-chan (chan 1))
+(def stop-sync-chan (chan 1))
+(def remote->local-sync-chan (chan 1))
+(def remote->local-full-sync-chan (chan 1))
+
 (defn sync-state
   "create a new sync-state"
   []
@@ -1078,7 +1212,7 @@
   (sync-local->remote-all-files! [this] "compare all local files to remote ones, sync when not equal.
   if local-txid != remote-txid, return {:need-sync-remote true}"))
 
-(defrecord Remote->LocalSyncer [user-uuid graph-uuid base-path repo *txid *sync-state
+(defrecord Remote->LocalSyncer [user-uuid graph-uuid base-path repo *txid *sync-state remoteapi
                                 ^:mutable local->remote-syncer *stopped]
   Object
   (set-local->remote-syncer! [_ s] (set! local->remote-syncer s))
@@ -1115,8 +1249,7 @@
               (if (instance? ExceptionInfo diff-r)
                 diff-r
                 (let [[diff-txns latest-txid min-txid] diff-r]
-                  (if (or (nil? min-txid)             ;; if min-txid is nil(not found any diff txn)
-                          (> (dec min-txid) @*txid))  ;; or min-txid-1 > @*txid, need to remote->local-full-sync
+                  (if (> (dec min-txid) @*txid) ;; min-txid-1 > @*txid, need to remote->local-full-sync
                     (do (println "min-txid" min-txid "request-txid" @*txid)
                         {:need-remote->local-full-sync true})
 
@@ -1155,11 +1288,13 @@
             remote-all-files-meta (<! remote-all-files-meta-c)
             local-all-files-meta (<! local-all-files-meta-c)
             diff-remote-files (set/difference remote-all-files-meta local-all-files-meta)
+            recent-10-days-range ((juxt #(tc/to-long (t/minus % (t/days 10))) #(tc/to-long %)) (t/today))
+            sorted-diff-remote-files (sort-by (sort-file-metatdata-fn :recent-days-range recent-10-days-range) > diff-remote-files)
             latest-txid (:TXId (<! (get-remote-graph remoteapi nil graph-uuid)))]
         (println "[full-sync(remote->local)]"
-                 (count diff-remote-files) "files need to sync")
+                 (count sorted-diff-remote-files) "files need to sync")
         (<! (.sync-files-remote->local!
-             this (map relative-path diff-remote-files)
+             this (map relative-path sorted-diff-remote-files)
              latest-txid))))))
 
 (defn- file-changed?
@@ -1199,8 +1334,8 @@
              (<! (file-changed? graph-uuid r-path basepath)))))))
 
 (defrecord ^:large-vars/cleanup-todo
-    Local->RemoteSyncer [user-uuid graph-uuid base-path repo *sync-state
-                         ^:mutable rate *txid ^:mutable remote->local-syncer stop-chan ^:mutable stopped]
+    Local->RemoteSyncer [user-uuid graph-uuid base-path repo *sync-state remoteapi
+                         ^:mutable rate *txid ^:mutable remote->local-syncer stop-chan *stopped]
     Object
     (filter-file-change-events-fn [this]
       (fn [^FileChangeEvent e] (and (instance? FileChangeEvent e)
@@ -1219,48 +1354,30 @@
     (get-ignore-files [_] #{#"logseq/graphs-txid.edn$"
                             #"logseq/bak/.*"
                             #"logseq/version-files/.*"
-                            #"logseq/encrypted-password.txt$"
                             #"logseq/\.recycle/.*"
                             #"\.DS_Store$"})
     (get-monitored-dirs [_] #{#"^assets/" #"^journals/" #"^logseq/" #"^pages/"})
     (stop-local->remote! [_]
       (async/close! stop-chan)
-      (set! stopped true))
+      (vreset! *stopped true))
 
     (ratelimit [this from-chan]
-      (let [c (.filtered-chan this 10000)
-            filter-e-fn (.filter-file-change-events-fn this)]
-        (go-loop [timeout-c (timeout rate)
-                  coll []]
-          (let [{:keys [timeout ^FileChangeEvent e stop]}
-                (async/alt! timeout-c {:timeout true}
-                            from-chan ([e] {:e e})
-                            stop-chan {:stop true})]
-            (cond
-              stop
-              (async/close! c)
-
-              timeout
-              (do (async/onto-chan! c coll false)
-                  (swap! *sync-state sync-state-reset-queued-local->remote-files)
-                  (recur (async/timeout rate) []))
-
-              (some? e)
-              (if (filter-e-fn e)
+      (let [filter-e-fn (.filter-file-change-events-fn this)]
+        (util/ratelimit
+         from-chan rate
+         :filter-fn
+         (fn [e]
+           (and (filter-e-fn e)
                 (let [e-path [(relative-path e)]]
                   (swap! *sync-state sync-state--add-queued-local->remote-files e-path)
-                  (if (<! (filter-local-changes-pred e base-path graph-uuid))
-                    (let [coll* (distinct (conj coll e))]
-                      (recur timeout-c coll*))
-                    (do (swap! *sync-state sync-state--remove-queued-local->remote-files e-path)
-                        (recur timeout-c coll))))
-                (recur timeout-c coll))
-
-              (nil? e)
-              (do (println "close ratelimit chan")
-                  (async/close! c)))))
-        c))
-
+                  (go
+                    (let [v (<! (filter-local-changes-pred e base-path graph-uuid))]
+                      (when-not v
+                        (swap! *sync-state sync-state--remove-queued-local->remote-files e-path))
+                      v)))))
+         :flush-fn #(swap! *sync-state sync-state-reset-queued-local->remote-files)
+         :stop-ch stop-chan
+         :distinct-coll? true)))
 
     (sync-local->remote! [this es]
       (if (empty? es)
@@ -1287,7 +1404,15 @@
                     _ (swap! *sync-state sync-state--remove-current-local->remote-files paths)]
                 (cond
                   (need-sync-remote? r*)
-                  {:need-sync-remote true}
+                  (do (println :need-sync-remote r*)
+                      {:need-sync-remote true})
+
+                  (need-reset-local-txid? r*) ;; TODO: this cond shouldn't be true,
+                                              ;; but some potential bugs cause local-txid > remote-txid
+                  (let [remote-txid (:TXId (<! (get-remote-graph remoteapi nil graph-uuid)))]
+                    (update-graphs-txid! remote-txid graph-uuid user-uuid repo)
+                    (reset! *txid remote-txid)
+                    {:succ true})
 
                   (number? r*)          ; succ
                   (do
@@ -1325,7 +1450,7 @@
                diff-local-files)]
           (println "[full-sync(local->remote)]" (count (flatten change-events-partitions)) "files need to sync")
           (loop [es-partitions change-events-partitions]
-            (if stopped
+            (if @*stopped
               {:stop true}
               (if (empty? es-partitions)
                 {:succ true}
@@ -1343,18 +1468,11 @@
 
 ;;; ### put all stuff together
 
-(defn- drain-chan
-  "drop all stuffs in CH"
-  [ch]
-  (->> (repeatedly #(poll! ch))
-       (take-while identity)))
-
 (defrecord ^:large-vars/cleanup-todo
     SyncManager [graph-uuid base-path *sync-state
-                 ^Local->RemoteSyncer local->remote-syncer ^Remote->LocalSyncer remote->local-syncer
-                 full-sync-chan stop-sync-chan remote->local-sync-chan local->remote-sync-chan
-                 local-changes-chan ^:mutable ratelimit-local-changes-chan
-                 *txid ^:mutable state ^:mutable _remote-change-chan ^:mutable _*ws ^:mutable stopped
+                 ^Local->RemoteSyncer local->remote-syncer ^Remote->LocalSyncer remote->local-syncer remoteapi
+                 ^:mutable ratelimit-local-changes-chan
+                 *txid ^:mutable state ^:mutable _remote-change-chan ^:mutable _*ws *stopped?
                  ^:mutable ops-chan]
     Object
     (schedule [this next-state args]
@@ -1385,9 +1503,10 @@
       (set! _remote-change-chan (ws-listen! graph-uuid _*ws))
       (set! ratelimit-local-changes-chan (ratelimit local->remote-syncer local-changes-chan))
       (go-loop []
-        (let [{:keys [stop remote->local local->remote-full-sync local->remote]}
+        (let [{:keys [stop remote->local remote->local-full-sync local->remote-full-sync local->remote]}
               (async/alt!
                 stop-sync-chan {:stop true}
+                remote->local-full-sync-chan {:remote->local-full-sync true}
                 remote->local-sync-chan {:remote->local true}
                 full-sync-chan {:local->remote-full-sync true}
                 _remote-change-chan ([v] (println "remote change:" v) {:remote->local v})
@@ -1396,8 +1515,12 @@
                 :priority true)]
           (cond
             stop
-            (do (drain-chan ops-chan)
+            (do (util/drain-chan ops-chan)
                 (>! ops-chan {:stop true}))
+            remote->local-full-sync
+            (do (util/drain-chan ops-chan)
+                (>! ops-chan {:remote->local-full-sync true})
+                (recur))
             remote->local
             (let [txid
                   (if (true? remote->local)
@@ -1410,20 +1533,16 @@
             (do (>! ops-chan {:local->remote local->remote})
                 (recur))
             local->remote-full-sync
-            (do (drain-chan ops-chan)
+            (do (util/drain-chan ops-chan)
                 (>! ops-chan {:local->remote-full-sync true})
                 (recur)))))
       (.schedule this ::need-password nil))
 
-    (need-password [this]
+    (need-password
+      [this]
       (go
-        (<! (ensure-pwd-exists! (state/get-current-repo) graph-uuid))
-        (<! (set-env rsapi config/FILE-SYNC-PROD?
-                     "AGE-SECRET-KEY-1RRP2D43M00FTPARY5MJNN0Z4D6K8NDWC9ME5P60ZE59EDKMXP9PQK0P6YA"
-                     "age1sk2zx4lxcy47tjcgmfdz65sxcpw92k8fjpdencmcgyncxtexfupsz38tcg"
-                     ;; (get @pwd-map graph-uuid)
-                     ))
-        (.schedule this ::idle nil)))
+        (let [next-state (<! (ensure-pwd+keys-exists! graph-uuid (state/get-current-repo)))]
+          (.schedule this next-state nil))))
 
     (idle [this]
       (go
@@ -1452,7 +1571,7 @@
             succ
             (.schedule this ::idle nil)
             need-sync-remote
-            (do (drain-chan ops-chan)
+            (do (util/drain-chan ops-chan)
                 (>! ops-chan {:remote->local true})
                 (>! ops-chan {:local->remote-full-sync true})
                 (.schedule this ::idle nil))
@@ -1486,7 +1605,7 @@
             (s/assert ::sync-remote->local!-result r)
             (cond
               need-remote->local-full-sync
-              (do (drain-chan ops-chan)
+              (do (util/drain-chan ops-chan)
                   (>! ops-chan {:remote->local-full-sync true})
                   (>! ops-chan {:local->remote-full-sync true})
                   (.schedule this ::idle nil))
@@ -1509,9 +1628,9 @@
             (.schedule this ::idle nil)
 
             need-sync-remote
-            (do (drain-chan ops-chan)
+            (do (util/drain-chan ops-chan)
                 (>! ops-chan {:remote->local true})
-                (>! ops-chan {:local->remote {:local local-change}})
+                (>! ops-chan {:local->remote local-change})
                 (.schedule this ::idle nil))
 
             unknown
@@ -1520,8 +1639,8 @@
               (.schedule this ::idle nil))))))
     IStoppable
     (-stop! [_]
-      (when-not stopped
-        (set! stopped true)
+      (when-not @*stopped?
+        (vreset! *stopped? true)
         (ws-stop! _*ws)
         (offer! stop-sync-chan true)
         (when ops-chan (async/close! ops-chan))
@@ -1530,27 +1649,23 @@
         (debug/pprint ["stop sync-manager, graph-uuid" graph-uuid "base-path" base-path])
         (swap! *sync-state sync-state--update-state ::stop))))
 
-(defn sync-manager [user-uuid graph-uuid base-path repo txid *sync-state full-sync-chan stop-sync-chan
-                    remote->local-sync-chan local->remote-sync-chan local-changes-chan]
+(defn sync-manager [user-uuid graph-uuid base-path repo txid *sync-state]
   (let [*txid (atom txid)
+        *stopped? (volatile! false)
+        remoteapi-with-stop (->RemoteAPI *stopped?)
         local->remote-syncer (->Local->RemoteSyncer user-uuid graph-uuid
                                                     base-path
-                                                    repo *sync-state
+                                                    repo *sync-state remoteapi-with-stop
                                                     20000
-                                                    *txid nil (chan) false)
-        remote->local-syncer (->Remote->LocalSyncer user-uuid graph-uuid
-                                                    base-path
-                                                    repo *txid *sync-state nil (volatile! false))]
+                                                    *txid nil (chan) *stopped?)
+        remote->local-syncer (->Remote->LocalSyncer user-uuid graph-uuid base-path
+                                                    repo *txid *sync-state remoteapi-with-stop
+                                                    nil *stopped?)]
     (.set-remote->local-syncer! local->remote-syncer remote->local-syncer)
     (.set-local->remote-syncer! remote->local-syncer local->remote-syncer)
-    (->SyncManager graph-uuid base-path *sync-state local->remote-syncer remote->local-syncer
-                   full-sync-chan stop-sync-chan
-                   remote->local-sync-chan local->remote-sync-chan local-changes-chan nil *txid nil nil nil false nil)))
+    (->SyncManager graph-uuid base-path *sync-state local->remote-syncer remote->local-syncer remoteapi-with-stop
+                   nil *txid nil nil nil *stopped? nil)))
 
-(def full-sync-chan (chan 1))
-(def stop-sync-chan (chan 1))
-(def remote->local-sync-chan (chan 1))
-(def local->remote-sync-chan (chan))
 
 (defn sync-stop []
   (when-let [sm (state/get-file-sync-manager)]
@@ -1590,8 +1705,7 @@
         repo (state/get-current-repo)
         sm (sync-manager current-user-uuid graph-uuid
                          (config/get-repo-dir repo) repo
-                         txid *sync-state full-sync-chan stop-sync-chan remote->local-sync-chan local->remote-sync-chan
-                         local-changes-chan)]
+                         txid *sync-state)]
     (when-not (config/demo-graph? repo)
       (go
        ;; 1. if remote graph has been deleted, clear graphs-txid.edn
@@ -1604,11 +1718,10 @@
              (clear-graphs-txid! repo)
              (do
                ;; set-env
-               (<! (set-env rsapi config/FILE-SYNC-PROD?
-                            "AGE-SECRET-KEY-1RRP2D43M00FTPARY5MJNN0Z4D6K8NDWC9ME5P60ZE59EDKMXP9PQK0P6YA"
-                            "age1sk2zx4lxcy47tjcgmfdz65sxcpw92k8fjpdencmcgyncxtexfupsz38tcg"))
+               (<! (set-env rsapi config/FILE-SYNC-PROD? nil nil))
                (state/set-file-sync-state repo @*sync-state)
                (state/set-file-sync-manager sm)
+               (<! (ensure-pwd+keys-exists! graph-uuid repo))
                ;; wait seconds to receive all file change events,
                ;; and then drop all of them.
                ;; WHY: when opening a graph(or switching to another graph),
@@ -1616,9 +1729,10 @@
                ;;      actually, each file corresponds to a file-change-event,
                ;;      we need to ignore all of them.
                (<! (timeout 5000))
-               (drain-chan local-changes-chan)
+               (util/drain-chan local-changes-chan)
                (poll! stop-sync-chan)
                (poll! remote->local-sync-chan)
+               (poll! remote->local-full-sync-chan)
 
                ;; update global state when *sync-state changes
                (add-watch *sync-state ::update-global-state
@@ -1627,7 +1741,10 @@
                (.start sm)
 
 
-               (offer! remote->local-sync-chan true)
+               ;; (if (zero? txid)
+               ;;   (offer! remote->local-full-sync-chan true)
+               ;;   (offer! remote->local-sync-chan true))
+               (offer! remote->local-full-sync-chan true)
                (offer! full-sync-chan true)
 
                ;; watch :network/online?
@@ -1640,3 +1757,12 @@
                           (fn [_k _r _o n]
                             (when (nil? n)
                               (sync-stop))))))))))))
+
+
+
+;;; debug funcs
+(comment
+  (get-remote-all-files-meta remoteapi graph-uuid)
+  (get-local-all-files-meta rsapi graph-uuid
+                            (config/get-repo-dir (state/get-current-repo)))
+  )

+ 2 - 2
src/main/frontend/fs/watcher_handler.cljs

@@ -4,12 +4,12 @@
             [frontend.db :as db]
             [frontend.db.model :as model]
             [frontend.handler.editor :as editor]
-            [logseq.graph-parser.extract :as extract]
             [frontend.handler.file :as file-handler]
             [frontend.handler.page :as page-handler]
             [frontend.handler.repo :as repo-handler]
             [frontend.handler.ui :as ui-handler]
             [logseq.graph-parser.util :as gp-util]
+            [frontend.util.text :as text-util]
             [lambdaisland.glogi :as log]
             [electron.ipc :as ipc]
             [promesa.core :as p]
@@ -21,7 +21,7 @@
 (defn- set-missing-block-ids!
   [content]
   (when (string? content)
-    (doseq [block-id (extract/extract-all-block-refs content)]
+    (doseq [block-id (text-util/extract-all-block-refs content)]
       (when-let [block (try
                          (model/get-block-by-uuid block-id)
                          (catch js/Error _e

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

@@ -6,7 +6,7 @@
             [frontend.config :as config]
             [frontend.context.i18n :as i18n]
             [frontend.db :as db]
-            [frontend.db-schema :as db-schema]
+            [logseq.graph-parser.db.schema :as db-schema]
             [frontend.db.conn :as conn]
             [frontend.db.react :as react]
             [frontend.error :as error]

+ 1 - 3
src/main/frontend/handler/common.cljs

@@ -16,9 +16,7 @@
 
 (defn copy-to-clipboard-without-id-property!
   [format raw-text html]
-  (util/copy-to-clipboard! (property/remove-id-property format raw-text))
-  (when html
-    (util/copy-to-clipboard! html true)))
+  (util/copy-to-clipboard! (property/remove-id-property format raw-text) html))
 
 (defn config-with-document-mode
   [config]

+ 29 - 26
src/main/frontend/handler/editor.cljs

@@ -13,7 +13,7 @@
             [frontend.config :as config]
             [frontend.date :as date]
             [frontend.db :as db]
-            [frontend.db-schema :as db-schema]
+            [logseq.graph-parser.db.schema :as db-schema]
             [frontend.db.model :as db-model]
             [frontend.db.utils :as db-utils]
             [frontend.diff :as diff]
@@ -48,6 +48,7 @@
             [frontend.util.priority :as priority]
             [frontend.util.property :as property]
             [frontend.util.thingatpt :as thingatpt]
+            [frontend.util.text :as text-util]
             [goog.dom :as gdom]
             [goog.dom.classes :as gdom-classes]
             [goog.object :as gobj]
@@ -815,7 +816,7 @@
               tail-len (count value)
               pos (max
                    (if original-content
-                     (utf8/length (utf8/encode original-content))
+                     (gobj/get (utf8/encode original-content) "length")
                      0)
                    0)]
           (edit-block! block pos id
@@ -935,8 +936,8 @@
     (when-let [block (db/pull [:block/uuid block-id])]
       (let [{:block/keys [content]} block
             content (or content (state/get-edit-content))
-            new-content (-> (text/remove-timestamp content key)
-                            (text/add-timestamp key value))]
+            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
@@ -1567,7 +1568,7 @@
   (when input
     (let [value (gobj/get input "value")
           pos (cursor/pos input)]
-      (text/surround-by? value pos before end))))
+      (text-util/surround-by? value pos before end))))
 
 (defn wrapped-by?
   [input before end]
@@ -1575,7 +1576,7 @@
     (let [value (gobj/get input "value")
           pos (dec (cursor/pos input))]
       (when (>= pos 0)
-        (text/wrapped-by? value pos before end)))))
+        (text-util/wrapped-by? value pos before end)))))
 
 (defn get-matched-pages
   "Return matched page names"
@@ -2043,18 +2044,21 @@
                         (db/entity [:block/name (util/page-name-sanity-lc id)]))]
       (= (:block/uuid entity) (tree/-get-parent-id current-node)))))
 
-(defn- insert
-  [insertion]
-  (when-not (auto-complete?)
-    (let [^js input (state/get-input)
-          selected-start (util/get-selection-start input)
-          selected-end (util/get-selection-end input)
-          value (.-value input)
-          s1 (subs value 0 selected-start)
-          s2 (subs value selected-end)]
-      (state/set-edit-content! (state/get-edit-input-id)
-                               (str s1 insertion s2))
-      (cursor/move-cursor-to input (+ selected-start (count insertion))))))
+(defn insert
+  ([insertion]
+   (insert insertion false))
+  ([insertion auto-complete-enabled?]
+   (when (or auto-complete-enabled?
+             (not (auto-complete?)))
+     (let [^js input (state/get-input)
+           selected-start (util/get-selection-start input)
+           selected-end (util/get-selection-end input)
+           value (.-value input)
+           s1 (subs value 0 selected-start)
+           s2 (subs value selected-end)]
+       (state/set-edit-content! (state/get-edit-input-id)
+                                (str s1 insertion s2))
+       (cursor/move-cursor-to input (+ selected-start (count insertion)))))))
 
 (defn- keydown-new-line
   []
@@ -2874,7 +2878,7 @@
 (defn wrap-macro-url
   [url]
   (cond
-    (boolean (text/get-matched-video url))
+    (boolean (text-util/get-matched-video url))
     (util/format "{{video %s}}" url)
 
     (string/includes? url "twitter.com")
@@ -2884,7 +2888,7 @@
     (notification/show! (util/format "No macro is available for %s" url) :warning)))
 
 (defn- paste-copied-blocks-or-text
-  [text e]
+  [initial-text text e]
   (let [copied-blocks (state/get-copied-blocks)
         copied-block-ids (:copy/block-ids copied-blocks)
         copied-graph (:copy/graph copied-blocks)
@@ -2896,9 +2900,9 @@
        (= copied-graph (state/get-current-repo))
        (or (seq copied-block-ids)
            (seq (:copy/full-blocks copied-blocks)))
-       text
+       initial-text
        ;; not copied from the external clipboard
-       (= (string/replace (string/trim text) "\r" "")
+       (= (string/replace (string/trim initial-text) "\r" "")
           (string/replace (string/trim (or (:copy/content copied-blocks) "")) "\r" "")))
       (let [blocks (or
                     (:copy/full-blocks copied-blocks)
@@ -2917,8 +2921,7 @@
 
       :else
       ;; from external
-      (let [format (or (db/get-page-format (state/get-current-page)) :markdown)
-            text (string/trim text)]
+      (let [format (or (db/get-page-format (state/get-current-page)) :markdown)]
         (match [format
                 (nil? (util/safe-re-find #"(?m)^\s*(?:[-+*]|#+)\s+" text))
                 (nil? (util/safe-re-find #"(?m)^\s*\*+\s+" text))
@@ -2949,7 +2952,7 @@
        (let [data (if (gp-util/url? clipboard-data)
                         (wrap-macro-url clipboard-data)
                         clipboard-data)]
-             (state/append-current-edit-content! data))))
+         (insert data true))))
    (fn [error]
      (js/console.error error))))
 
@@ -2972,7 +2975,7 @@
           (when-not (mobile-util/native-ios?)
             (util/stop e)
             (paste-text-in-one-block-at-point))
-          (paste-copied-blocks-or-text text e))
+          (paste-copied-blocks-or-text initial-text text e))
         (let [_handled
               (let [clipboard-data (gobj/get e "clipboardData")
                     files (.-files clipboard-data)]

+ 14 - 10
src/main/frontend/handler/events.cljs

@@ -12,7 +12,7 @@
             [frontend.config :as config]
             [frontend.context.i18n :refer [t]]
             [frontend.db :as db]
-            [frontend.db-schema :as db-schema]
+            [logseq.graph-parser.db.schema :as db-schema]
             [frontend.encrypt :as encrypt]
             [frontend.extensions.srs :as srs]
             [frontend.fs :as fs]
@@ -55,7 +55,12 @@
          (sync/sync-stop)
          (sync/sync-start)))
 
+(defn- file-sync-stop! []
+  (p/do! (persist-var/load-vars)
+         (sync/sync-stop)))
+
 (defmethod handle :user/login [[_]]
+  (state/set-state! [:ui/loading? :login] false)
   (async/go
     (async/<! (file-sync-handler/load-session-graphs))
     (p/let [repos (repo-handler/refresh-repos!)]
@@ -77,7 +82,8 @@
     (if empty-graph?
       (route-handler/redirect! {:to :import :query-params {:from "picker"}})
       (route-handler/redirect-to-home!)))
-  (repo-handler/refresh-repos!))
+  (repo-handler/refresh-repos!)
+  (file-sync-stop!))
 
 (defn- graph-switch [graph]
   (state/set-current-repo! graph)
@@ -116,7 +122,7 @@
      (graph-switch graph))))
 
 (defmethod handle :graph/switch [[_ graph opts]]
-  (if (outliner-file/writes-finished?)
+  (if @outliner-file/*writes-finished?
     (graph-switch-on-persisted graph opts)
     (notification/show!
      "Please wait seconds until all changes are saved for the current graph."
@@ -314,6 +320,8 @@
     (state/set-state! :mobile/show-tabbar? false)
     (state/set-state! :mobile/show-toolbar? true)
     (state/set-state! :mobile/show-action-bar? false)
+    (when (= (state/sub :editor/record-status) "RECORDING")
+      (state/set-state! :mobile/show-recording-bar? true))
     (when (mobile-util/native-ios?)
       (reset! util/keyboard-height keyboard-height)
       (set! (.. main-node -style -marginBottom) (str keyboard-height "px"))
@@ -323,9 +331,6 @@
         (set! (.. right-sidebar-node -style -paddingBottom) (str (+ 150 keyboard-height) "px")))
       (when-let [card-preview-el (js/document.querySelector ".cards-review")]
         (set! (.. card-preview-el -style -marginBottom) (str keyboard-height "px")))
-      (when (= (state/sub :editor/record-status) "RECORDING")
-        (when-let [record-node (gdom/getElement "audio-record-toolbar")]
-          (set! (.. record-node -style -bottom) (str (+ 45 keyboard-height) "px"))))
       (js/setTimeout (fn []
                        (let [toolbar (.querySelector main-node "#mobile-editor-toolbar")]
                          (set! (.. toolbar -style -bottom) (str keyboard-height "px"))))
@@ -335,6 +340,8 @@
   (let [main-node (util/app-scroll-container-node)]
     (state/set-state! :mobile/show-toolbar? false)
     (state/set-state! :mobile/show-tabbar? true)
+    (when (= (state/sub :editor/record-status) "RECORDING")
+      (state/set-state! :mobile/show-recording-bar? false))
     (when (mobile-util/native-ios?)
       (when-let [card-preview-el (js/document.querySelector ".cards-review")]
         (set! (.. card-preview-el -style -marginBottom) "0px"))
@@ -342,10 +349,7 @@
       (when-let [left-sidebar-node (gdom/getElement "left-sidebar")]
         (set! (.. left-sidebar-node -style -bottom) "0px"))
       (when-let [right-sidebar-node (gdom/getElementByClass "sidebar-item-list")]
-        (set! (.. right-sidebar-node -style -paddingBottom) "150px"))
-      (when (= (state/sub :editor/record-status) "RECORDING")
-        (when-let [record-node (gdom/getElement "audio-record-toolbar")]
-          (set! (.. record-node -style -bottom) "45px"))))))
+        (set! (.. right-sidebar-node -style -paddingBottom) "150px")))))
 
 (defmethod handle :plugin/consume-updates [[_ id pending? updated?]]
   (let [downloading? (:plugin/updates-downloading? @state/state)]

+ 34 - 55
src/main/frontend/handler/file.cljs

@@ -2,8 +2,6 @@
   (:refer-clojure :exclude [load-file])
   (:require ["/frontend/utils" :as utils]
             [borkdude.rewrite-edn :as rewrite]
-            [cljs-time.coerce :as tc]
-            [cljs-time.core :as t]
             [cljs.core.async.interop :refer [<p!]]
             [clojure.core.async :as async]
             [frontend.config :as config]
@@ -11,16 +9,16 @@
             [frontend.fs :as fs]
             [frontend.fs.nfs :as nfs]
             [frontend.handler.common :as common-handler]
-            [logseq.graph-parser.extract :as extract]
             [frontend.handler.ui :as ui-handler]
             [frontend.state :as state]
             [frontend.util :as util]
             [logseq.graph-parser.util :as gp-util]
-            [logseq.graph-parser.config :as gp-config]
             [lambdaisland.glogi :as log]
             [promesa.core :as p]
             [frontend.mobile.util :as mobile]
-            [clojure.set :as set]))
+            [frontend.modules.outliner.file :as outliner-file]
+            [logseq.graph-parser.config :as gp-config]
+            [logseq.graph-parser :as graph-parser]))
 
 ;; TODO: extract all git ops using a channel
 
@@ -49,11 +47,11 @@
 
 (defn- only-text-formats
   [files]
-  (keep-formats files (config/text-formats)))
+  (keep-formats files (gp-config/text-formats)))
 
 (defn- only-image-formats
   [files]
-  (keep-formats files (config/img-formats)))
+  (keep-formats files (gp-config/img-formats)))
 
 (defn restore-config!
   ([repo-url project-changed-check?]
@@ -91,10 +89,25 @@
       (when (not= file current-file)
        current-file))))
 
+(defn- get-delete-blocks [repo-url first-page file]
+  (let [delete-blocks (->
+                       (concat
+                        (db/delete-file-blocks! repo-url file)
+                        (when first-page (db/delete-page-blocks repo-url (:block/name first-page))))
+                       (distinct))]
+    (when-let [current-file (page-exists-in-another-file repo-url first-page file)]
+      (when (not= file current-file)
+        (let [error (str "Page already exists with another file: " current-file ", current file: " file)]
+          (state/pub-event! [:notification/show
+                             {:content error
+                              :status :error
+                              :clear? false}]))))
+    delete-blocks))
+
 (defn reset-file!
   ([repo-url file content]
    (reset-file! repo-url file content {}))
-  ([repo-url file content {:keys [new-graph? from-disk?]}]
+  ([repo-url file content options]
    (let [electron-local-repo? (and (util/electron?)
                                    (config/local-db? repo-url))
          file (cond
@@ -118,53 +131,18 @@
                 file)
          file (gp-util/path-normalize file)
          new? (nil? (db/entity [:file/path file]))]
-     (db/set-file-content! repo-url file content)
-     (let [format (gp-util/get-format file)
-           file-content [{:file/path file}]
-           tx (if (contains? gp-config/mldoc-support-formats format)
-                (let [[pages blocks]
-                      (extract/extract-blocks-pages
-                       file
-                       content
-                       {:user-config (state/get-config)
-                        :date-formatter (state/get-date-formatter)
-                        :page-name-order (state/page-name-order)
-                        :block-pattern (config/get-block-pattern format)
-                        :supported-formats (config/supported-formats)
-                        :db (db/get-db (state/get-current-repo))})
-                      first-page (first pages)
-                      delete-blocks (->
-                                     (concat
-                                      (db/delete-file-blocks! repo-url file)
-                                      (when first-page (db/delete-page-blocks repo-url (:block/name first-page))))
-                                     (distinct))
-                      _ (when-let [current-file (page-exists-in-another-file repo-url first-page file)]
-                          (when (not= file current-file)
-                            (let [error (str "Page already exists with another file: " current-file ", current file: " file)]
-                              (state/pub-event! [:notification/show
-                                                 {:content error
-                                                  :status :error
-                                                  :clear? false}]))))
-                      block-ids (map (fn [block] {:block/uuid (:block/uuid block)}) blocks)
-                      block-refs-ids (->> (mapcat :block/refs blocks)
-                                          (filter (fn [ref] (and (vector? ref)
-                                                                 (= :block/uuid (first ref)))))
-                                          (map (fn [ref] {:block/uuid (second ref)}))
-                                          (seq))
-                      ;; To prevent "unique constraint" on datascript
-                      block-ids (set/union (set block-ids) (set block-refs-ids))
-                      pages (extract/with-ref-pages pages blocks)
-                      pages-index (map #(select-keys % [:block/name]) pages)]
-                  ;; does order matter?
-                  (concat file-content pages-index delete-blocks pages block-ids blocks))
-                file-content)
-           tx (concat tx [(let [t (tc/to-long (t/now))] ;; TODO: use file system timestamp?
-                            (cond->
-                              {:file/path file}
-                              new?
-                              (assoc :file/created-at t)))])]
-       (db/transact! repo-url tx {:new-graph? new-graph?
-                                  :from-disk? from-disk?})))))
+     (graph-parser/parse-file
+      (db/get-db repo-url false)
+      file
+      content
+      (merge options
+             {:new? new?
+              :delete-blocks-fn (partial get-delete-blocks repo-url)
+              :extract-options {:user-config (state/get-config)
+                                :date-formatter (state/get-date-formatter)
+                                :page-name-order (state/page-name-order)
+                                :block-pattern (config/get-block-pattern (gp-util/get-format file))
+                                :supported-formats (gp-config/supported-formats)}})))))
 
 ;; TODO: Remove this function in favor of `alter-files`
 (defn alter-file
@@ -275,6 +253,7 @@
           (catch js/Error e
             (log/error :file/write-failed e))))
       (recur))
+    (outliner-file/ratelimit-file-writes!)
     chan))
 
 (defn watch-for-current-graph-dir!

+ 6 - 35
src/main/frontend/handler/file_sync.cljs

@@ -5,7 +5,6 @@
             [cljs.core.async :as async :refer [go <!]]
             [cljs.core.async.interop :refer [p->c]]
             [clojure.string :as string]
-            [clojure.set :as set]
             [frontend.config :as config]
             [frontend.db :as db]
             [frontend.fs.sync :as sync]
@@ -23,6 +22,10 @@
   (let [[_user-uuid graph-uuid _txid] @sync/graphs-txid]
     (some? graph-uuid)))
 
+(defn current-graph-sync-on?
+  []
+  (when-let [sync-state (state/sub [:file-sync/sync-state (state/get-current-repo)])]
+    (not (sync/sync-state--stopped? sync-state))))
 
 (defn create-graph
   [name]
@@ -55,34 +58,6 @@
   []
   (go (:Graphs (<! (sync/list-remote-graphs sync/remoteapi)))))
 
-(defn download-all-files
-  [repo graph-uuid user-uuid base-path]
-  (go
-    (<! (sync/ensure-pwd-exists! repo graph-uuid))
-    (state/reset-file-sync-download-init-state!)
-    (state/set-file-sync-download-init-state! {:total :unknown :finished 0 :downloading? true})
-    (let [remote-all-files-meta (<! (sync/get-remote-all-files-meta sync/remoteapi graph-uuid))
-          local-all-files-meta (<! (sync/get-local-all-files-meta sync/rsapi graph-uuid base-path))
-          diff-remote-files (set/difference remote-all-files-meta local-all-files-meta)
-          latest-txid (:TXId (<! (sync/get-remote-graph sync/remoteapi nil graph-uuid)))
-          partitioned-filetxns
-          (sequence (sync/filepaths->partitioned-filetxns 10 graph-uuid user-uuid)
-                    (map sync/relative-path diff-remote-files))]
-      (state/set-file-sync-download-init-state! {:total (count diff-remote-files) :finished 0})
-      (let [r (<! (sync/apply-filetxns-partitions
-                   nil user-uuid graph-uuid base-path partitioned-filetxns repo nil (atom false)
-                   (fn [filetxns]
-                     (state/set-file-sync-download-init-state!
-                      {:downloading-files (mapv sync/relative-path filetxns)}))
-                   (fn [filetxns]
-                     (state/set-file-sync-download-init-state!
-                      {:finished (+ (count filetxns)
-                                    (or (:finished (state/get-file-sync-download-init-state)) 0))}))))]
-        (if (instance? ExceptionInfo r)
-          ;; TODO: add re-download button
-          (notification/show! (str "Download graph failed: " (ex-cause r)) :warning)
-          (do (state/reset-file-sync-download-init-state!)
-              (<! (sync/update-graphs-txid! latest-txid graph-uuid user-uuid repo))))))))
 
 (defn load-session-graphs
   []
@@ -97,18 +72,14 @@
 
 (defn init-graph [graph-uuid]
   (let [repo (state/get-current-repo)
-        base-path (config/get-repo-dir repo)
         user-uuid (user/user-uuid)]
     ;; FIXME: when switching graph, sync-start is not called. set-env is not called as well.
     (sync/set-env sync/rsapi config/FILE-SYNC-PROD?
                   "AGE-SECRET-KEY-1RRP2D43M00FTPARY5MJNN0Z4D6K8NDWC9ME5P60ZE59EDKMXP9PQK0P6YA"
                   "age1sk2zx4lxcy47tjcgmfdz65sxcpw92k8fjpdencmcgyncxtexfupsz38tcg")
     (sync/update-graphs-txid! 0 graph-uuid user-uuid repo)
-    (go (sync/sync-stop)
-        (<! (download-all-files repo graph-uuid user-uuid base-path))
-        (println :debug sync/graphs-txid)
-        (swap! refresh-file-sync-component not)
-        (state/pub-event! [:graph/switch repo {:persist? false}]))))
+    (swap! refresh-file-sync-component not)
+    (state/pub-event! [:graph/switch repo {:persist? false}])))
 
 (defn- download-version-file [graph-uuid file-uuid version-uuid]
   (go

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

@@ -2,7 +2,7 @@
   (:require [clojure.set :as set]
             [clojure.string :as string]
             [frontend.db :as db]
-            [frontend.db.default :as default-db]
+            [logseq.graph-parser.db.default :as default-db]
             [frontend.state :as state]
             [frontend.util :as util]))
 

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.