Browse Source

refactor: remove :block/format for db graphs (#11667)

Tienson Qin 10 months ago
parent
commit
8a0a05183e
76 changed files with 909 additions and 976 deletions
  1. 9 9
      deps/db/script/validate_client_db.cljs
  2. 1 2
      deps/db/src/logseq/db.cljs
  3. 3 3
      deps/db/src/logseq/db/frontend/class.cljs
  4. 1 1
      deps/db/src/logseq/db/frontend/entity_plus.cljc
  5. 0 1
      deps/db/src/logseq/db/frontend/malli_schema.cljs
  6. 0 1
      deps/db/src/logseq/db/frontend/property.cljs
  7. 4 5
      deps/db/src/logseq/db/frontend/property/build.cljs
  8. 2 2
      deps/db/src/logseq/db/frontend/schema.cljs
  9. 3 3
      deps/db/src/logseq/db/frontend/validate.cljs
  10. 14 16
      deps/db/src/logseq/db/sqlite/build.cljs
  11. 4 7
      deps/db/src/logseq/db/sqlite/create_graph.cljs
  12. 1 4
      deps/db/src/logseq/db/sqlite/util.cljs
  13. 14 11
      deps/graph-parser/src/logseq/graph_parser/block.cljs
  14. 24 26
      deps/graph-parser/src/logseq/graph_parser/exporter.cljs
  15. 45 36
      deps/graph-parser/src/logseq/graph_parser/extract.cljc
  16. 16 16
      deps/graph-parser/test/logseq/graph_parser/exporter_test.cljs
  17. 1 39
      deps/outliner/src/logseq/outliner/core.cljs
  18. 4 5
      src/electron/electron/handler.cljs
  19. 2 2
      src/main/frontend/background_tasks.cljs
  20. 10 10
      src/main/frontend/commands.cljs
  21. 15 12
      src/main/frontend/components/block.cljs
  22. 2 2
      src/main/frontend/components/container.cljs
  23. 6 5
      src/main/frontend/components/content.cljs
  24. 3 3
      src/main/frontend/components/editor.cljs
  25. 9 9
      src/main/frontend/components/file_based/query_table.cljs
  26. 7 7
      src/main/frontend/components/imports.cljs
  27. 27 27
      src/main/frontend/components/objects.cljs
  28. 5 5
      src/main/frontend/components/page.cljs
  29. 1 1
      src/main/frontend/components/page_menu.cljs
  30. 88 88
      src/main/frontend/components/plugins.cljs
  31. 13 14
      src/main/frontend/components/plugins_settings.cljs
  32. 5 5
      src/main/frontend/components/query/view.cljs
  33. 8 8
      src/main/frontend/components/right_sidebar.cljs
  34. 2 2
      src/main/frontend/components/settings.cljs
  35. 15 18
      src/main/frontend/components/svg.cljs
  36. 10 10
      src/main/frontend/components/theme.cljs
  37. 7 7
      src/main/frontend/config.cljs
  38. 5 5
      src/main/frontend/db.cljs
  39. 6 6
      src/main/frontend/db/model.cljs
  40. 2 2
      src/main/frontend/extensions/srs.cljs
  41. 11 9
      src/main/frontend/format/block.cljs
  42. 9 9
      src/main/frontend/handler.cljs
  43. 13 13
      src/main/frontend/handler/block.cljs
  44. 3 3
      src/main/frontend/handler/command_palette.cljs
  45. 3 2
      src/main/frontend/handler/common/developer.cljs
  46. 32 32
      src/main/frontend/handler/common/plugin.cljs
  47. 8 8
      src/main/frontend/handler/config.cljs
  48. 2 1
      src/main/frontend/handler/db_based/editor.cljs
  49. 8 8
      src/main/frontend/handler/dnd.cljs
  50. 30 24
      src/main/frontend/handler/editor.cljs
  51. 3 4
      src/main/frontend/handler/export/html.cljs
  52. 4 7
      src/main/frontend/handler/export/opml.cljs
  53. 7 9
      src/main/frontend/handler/export/text.cljs
  54. 16 16
      src/main/frontend/handler/file_based/editor.cljs
  55. 1 1
      src/main/frontend/handler/file_based/property.cljs
  56. 18 16
      src/main/frontend/handler/paste.cljs
  57. 188 190
      src/main/frontend/handler/plugin.cljs
  58. 27 27
      src/main/frontend/handler/plugin_config.cljs
  59. 11 10
      src/main/frontend/handler/route.cljs
  60. 1 1
      src/main/frontend/handler/ui.cljs
  61. 0 1
      src/main/frontend/idb.cljs
  62. 1 1
      src/main/frontend/mobile/camera.cljs
  63. 1 2
      src/main/frontend/mobile/record.cljs
  64. 15 1
      src/main/frontend/worker/db/migrate.cljs
  65. 5 5
      src/main/frontend/worker/export.cljs
  66. 10 11
      src/main/frontend/worker/handler/page.cljs
  67. 13 17
      src/main/frontend/worker/handler/page/db_based/page.cljs
  68. 4 10
      src/main/frontend/worker/rtc/full_upload_download_graph.cljs
  69. 1 2
      src/main/frontend/worker/rtc/remote_update.cljs
  70. 46 46
      src/main/logseq/api.cljs
  71. 4 22
      src/rtc_e2e_test/const.cljs
  72. 2 4
      src/rtc_e2e_test/helper.cljs
  73. 1 5
      src/test/frontend/test/generators.cljs
  74. 2 4
      src/test/frontend/test/helper.cljs
  75. 3 5
      src/test/frontend/worker/rtc/client_test.cljs
  76. 12 15
      src/test/frontend/worker/rtc/db_listener_test.cljs

+ 9 - 9
deps/db/script/validate_client_db.cljs

@@ -1,18 +1,18 @@
 (ns validate-client-db
   "Script that validates the datascript db of a DB graph
    NOTE: This script is also used in CI to confirm our db's schema is up to date"
-  (:require [logseq.db.sqlite.cli :as sqlite-cli]
+  (:require ["os" :as os]
+            ["path" :as node-path]
+            [babashka.cli :as cli]
+            [cljs.pprint :as pprint]
+            [clojure.string :as string]
+            [datascript.core :as d]
             [logseq.db.frontend.malli-schema :as db-malli-schema]
             [logseq.db.frontend.validate :as db-validate]
-            [datascript.core :as d]
-            [clojure.string :as string]
-            [nbb.core :as nbb]
+            [logseq.db.sqlite.cli :as sqlite-cli]
             [malli.core :as m]
-            [babashka.cli :as cli]
-            ["path" :as node-path]
-            ["os" :as os]
-            [cljs.pprint :as pprint]
-            [malli.error :as me]))
+            [malli.error :as me]
+            [nbb.core :as nbb]))
 
 (defn validate-client-db
   "Validate datascript db as a vec of entity maps"

+ 1 - 2
deps/db/src/logseq/db.cljs

@@ -510,8 +510,7 @@
   "Builds tx for a favorite block in favorite page"
   [favorite-uuid]
   {:block/link [:block/uuid favorite-uuid]
-   :block/title ""
-   :block/format :markdown})
+   :block/title ""})
 
 (defn get-key-value
   [db key-ident]

+ 3 - 3
deps/db/src/logseq/db/frontend/class.cljs

@@ -1,9 +1,9 @@
 (ns logseq.db.frontend.class
   "Class related fns for DB graphs and frontend/datascript usage"
-  (:require [logseq.db.sqlite.util :as sqlite-util]
+  (:require [clojure.set :as set]
+            [flatland.ordered.map :refer [ordered-map]]
             [logseq.db.frontend.db-ident :as db-ident]
-            [clojure.set :as set]
-            [flatland.ordered.map :refer [ordered-map]]))
+            [logseq.db.sqlite.util :as sqlite-util]))
 
 ;; Main class vars
 ;; ===============

+ 1 - 1
deps/db/src/logseq/db/frontend/entity_plus.cljc

@@ -17,7 +17,7 @@
 (def nil-db-ident-entities
   "No such entities with these :db/ident, but `(d/entity <db> <ident>)` has been called somewhere."
   #{:block/tx-id :block/warning :block/pre-block? :block/uuid :block/scheduled
-    :block/deadline :block/journal-day :block/format :block/level :block/heading-level
+    :block/deadline :block/journal-day :block/level :block/heading-level
     :block/type :block/name :block/marker :block/_refs
 
     :block.temp/ast-title :block.temp/top? :block.temp/bottom? :block.temp/search?

+ 0 - 1
deps/db/src/logseq/db/frontend/malli_schema.cljs

@@ -249,7 +249,6 @@
   [[:block/uuid :uuid]
    [:block/created-at :int]
    [:block/updated-at :int]
-   [:block/format [:enum :markdown]]
    ;; Injected by update-properties-in-ents
    [:block/properties {:optional true} block-properties]
    [:block/tags {:optional true} block-tags]

+ 0 - 1
deps/db/src/logseq/db/frontend/property.cljs

@@ -17,7 +17,6 @@
   (let [block-id (or (:db/id block) (:db/ident block))]
     (-> (merge
          {:block/uuid (d/squuid)
-          :block/format :markdown
           :block/page (if (:block/page block)
                         (:db/id (:block/page block))
                         ;; page block

+ 4 - 5
deps/db/src/logseq/db/frontend/property/build.cljs

@@ -1,15 +1,14 @@
 (ns logseq.db.frontend.property.build
   "Builds core property concepts"
-  (:require [logseq.db.sqlite.util :as sqlite-util]
-            [logseq.db.frontend.order :as db-order]
+  (:require [logseq.db.frontend.order :as db-order]
+            [logseq.db.frontend.property :as db-property]
             [logseq.db.frontend.property.type :as db-property-type]
-            [logseq.db.frontend.property :as db-property]))
+            [logseq.db.sqlite.util :as sqlite-util]))
 
 (defn- closed-value-new-block
   [block-id block-type value property]
   (let [property-id (:db/ident property)]
-    (merge {:block/format :markdown
-            :block/uuid block-id
+    (merge {:block/uuid block-id
             :block/page property-id
             :block/closed-value-property property-id
             :logseq.property/created-from-property (if (= property-id :logseq.property/default-value)

+ 2 - 2
deps/db/src/logseq/db/frontend/schema.cljs

@@ -2,7 +2,7 @@
   "Main datascript schemas for the Logseq app"
   (:require [clojure.set :as set]))
 
-(def version 56)
+(def version 57)
 
 ;; A page is a special block, a page can corresponds to multiple files with the same ":block/name".
 (def ^:large-vars/data-var schema
@@ -112,7 +112,7 @@
            :block/namespace :block/properties-text-values :block/pre-block? :recent/pages :block/file
            :block/properties :block/properties-order :block/repeated? :block/deadline :block/scheduled :block/priority
            :block/marker :block/macros
-           :block/type)
+           :block/type :block/format)
    {:block/name {:db/index true}        ; remove db/unique for :block/name
     ;; closed value
     :block/closed-value-property {:db/valueType :db.type/ref

+ 3 - 3
deps/db/src/logseq/db/frontend/validate.cljs

@@ -1,12 +1,12 @@
 (ns logseq.db.frontend.validate
   "Validate frontend db for DB graphs"
-  (:require [datascript.core :as d]
+  (:require [clojure.pprint :as pprint]
+            [datascript.core :as d]
             [logseq.db.frontend.malli-schema :as db-malli-schema]
             [logseq.db.frontend.property :as db-property]
             [malli.core :as m]
             [malli.error :as me]
-            [malli.util :as mu]
-            [clojure.pprint :as pprint]))
+            [malli.util :as mu]))
 
 (def ^:private db-schema-validator (m/validator db-malli-schema/DB))
 (def ^:private db-schema-explainer (m/explainer db-malli-schema/DB))

+ 14 - 16
deps/db/src/logseq/db/sqlite/build.cljs

@@ -5,24 +5,24 @@
   temporary db ids. The generated tx-data is used to create DB graphs that
   persist to sqlite or for testing with in-memory databases. See `Options` for
   the EDN format and `build-blocks-tx` which is the main fn to build tx data"
-  (:require [logseq.db.sqlite.util :as sqlite-util]
-            [logseq.db.frontend.property.build :as db-property-build]
-            [logseq.common.util :as common-util]
-            [logseq.common.util.date-time :as date-time-util]
-            [clojure.string :as string]
+  (:require [cljs.pprint :as pprint]
             [clojure.set :as set]
+            [clojure.string :as string]
             [datascript.core :as d]
-            [logseq.db.frontend.property :as db-property]
-            [logseq.db.frontend.order :as db-order]
-            [logseq.db.frontend.property.type :as db-property-type]
-            [logseq.db.frontend.class :as db-class]
-            [logseq.db.frontend.db-ident :as db-ident]
+            [logseq.common.util :as common-util]
+            [logseq.common.util.date-time :as date-time-util]
             [logseq.common.util.page-ref :as page-ref]
+            [logseq.common.uuid :as common-uuid]
+            [logseq.db.frontend.class :as db-class]
             [logseq.db.frontend.content :as db-content]
+            [logseq.db.frontend.db-ident :as db-ident]
+            [logseq.db.frontend.order :as db-order]
+            [logseq.db.frontend.property :as db-property]
+            [logseq.db.frontend.property.build :as db-property-build]
+            [logseq.db.frontend.property.type :as db-property-type]
+            [logseq.db.sqlite.util :as sqlite-util]
             [malli.core :as m]
-            [malli.error :as me]
-            [cljs.pprint :as pprint]
-            [logseq.common.uuid :as common-uuid]))
+            [malli.error :as me]))
 
 ;; should match definition in translate-property-value
 (defn page-prop-value?
@@ -113,7 +113,6 @@
 
 (defn- ->block-tx [{:keys [build/properties] :as m} properties-config page-uuids all-idents page-id]
   (let [new-block {:db/id (new-db-id)
-                   :block/format :markdown
                    :block/page {:db/id page-id}
                    :block/order (db-order/gen-key nil)
                    :block/parent (or (:block/parent m) {:db/id page-id})}
@@ -357,8 +356,7 @@
                       {:db/id (or (:db/id page) (new-db-id))
                        :block/title (or (:block/title page) (string/capitalize (:block/name page)))
                        :block/name (or (:block/name page) (common-util/page-name-sanity-lc (:block/title page)))
-                       :block/tags #{:logseq.class/Page}
-                       :block/format :markdown}
+                       :block/tags #{:logseq.class/Page}}
                       (dissoc page :build/properties :db/id :block/name :block/title :build/tags))
             pvalue-tx-m (->property-value-tx-m new-page (:build/properties page) properties all-idents)]
         (into

+ 4 - 7
deps/db/src/logseq/db/sqlite/create_graph.cljs

@@ -2,16 +2,16 @@
   "Helper fns for creating a DB graph"
   (:require [clojure.string :as string]
             [datascript.core :as d]
+            [logseq.common.config :as common-config]
             [logseq.common.util :as common-util]
             [logseq.common.uuid :as common-uuid]
             [logseq.db.frontend.class :as db-class]
+            [logseq.db.frontend.entity-util :as entity-util]
+            [logseq.db.frontend.order :as db-order]
             [logseq.db.frontend.property :as db-property]
             [logseq.db.frontend.property.build :as db-property-build]
             [logseq.db.frontend.schema :as db-schema]
-            [logseq.db.sqlite.util :as sqlite-util]
-            [logseq.common.config :as common-config]
-            [logseq.db.frontend.order :as db-order]
-            [logseq.db.frontend.entity-util :as entity-util]))
+            [logseq.db.sqlite.util :as sqlite-util]))
 
 (defn- mark-block-as-built-in [block]
   (assoc block :logseq.property/built-in? true))
@@ -121,12 +121,10 @@
        :block/title common-config/views-page-name
        :block/tags [:logseq.class/Page]
        :block/schema {:public? false}
-       :block/format :markdown
        :logseq.property/built-in? true})
      (sqlite-util/block-with-timestamps
       {:block/uuid (common-uuid/gen-uuid)
        :block/title "All Pages Default View"
-       :block/format :markdown
        :block/parent [:block/uuid page-id]
        :block/order (db-order/gen-key nil)
        :block/page [:block/uuid page-id]
@@ -141,7 +139,6 @@
      :block/title common-config/favorites-page-name
      :block/tags [:logseq.class/Page]
      :block/schema {:public? false}
-     :block/format :markdown
      :logseq.property/built-in? true})])
 
 (defn build-db-initial-data

+ 1 - 4
deps/db/src/logseq/db/sqlite/util.cljs

@@ -84,7 +84,6 @@
       (cond->
        {:db/ident db-ident'
         :block/tags #{:logseq.class/Property}
-        :block/format :markdown
         :block/schema (merge {:type :default} (dissoc prop-schema :classes :cardinality))
         :block/name (common-util/page-name-sanity-lc (name prop-name))
         :block/uuid (or block-uuid (common-uuid/gen-uuid :db-ident-block-uuid db-ident'))
@@ -107,8 +106,7 @@
   {:pre [(qualified-keyword? (:db/ident block))]}
   (block-with-timestamps
    (cond-> (merge block
-                  {:block/format :markdown
-                   :block/tags (set (conj (:block/tags block) :logseq.class/Tag))})
+                  {:block/tags (set (conj (:block/tags block) :logseq.class/Tag))})
      (and (not= (:db/ident block) :logseq.class/Root)
           (nil? (:logseq.property/parent block)))
      (assoc :logseq.property/parent :logseq.class/Root))))
@@ -120,7 +118,6 @@
    {:block/name (common-util/page-name-sanity-lc page-name)
     :block/title page-name
     :block/uuid (d/squuid)
-    :block/format :markdown
     :block/tags #{:logseq.class/Page}}))
 
 (defn kv

+ 14 - 11
deps/graph-parser/src/logseq/graph_parser/block.cljs

@@ -6,19 +6,19 @@
             [datascript.core :as d]
             [datascript.impl.entity :as de]
             [logseq.common.config :as common-config]
+            [logseq.common.date :as common-date]
             [logseq.common.util :as common-util]
             [logseq.common.util.block-ref :as block-ref]
             [logseq.common.util.date-time :as date-time-util]
             [logseq.common.util.page-ref :as page-ref]
             [logseq.common.uuid :as common-uuid]
             [logseq.db :as ldb]
+            [logseq.db.frontend.class :as db-class]
             [logseq.db.frontend.order :as db-order]
             [logseq.graph-parser.mldoc :as gp-mldoc]
             [logseq.graph-parser.property :as gp-property]
             [logseq.graph-parser.text :as text]
-            [logseq.graph-parser.utf8 :as utf8]
-            [logseq.db.frontend.class :as db-class]
-            [logseq.common.date :as common-date]))
+            [logseq.graph-parser.utf8 :as utf8]))
 
 (defn heading-block?
   [block]
@@ -453,7 +453,7 @@
        (when-not (and (vector? form)
                       (= (first form) "Custom")
                       (= (second form) "query"))
-         (when-let [page (get-page-reference form (:format block))]
+         (when-let [page (get-page-reference form (get block :format :markdown))]
            (when-let [page' (when-not (db-namespace-page? db-based? page)
                               page)]
              (swap! *refs conj page')))
@@ -522,7 +522,7 @@
         content (when content
                   (let [content (text/remove-level-spaces content format block-pattern)]
                     (if (or (:pre-block? block)
-                            (= (:format block) :org))
+                            (= (get block :format :markdown) :org))
                       content
                       (gp-mldoc/remove-indentation-spaces content (inc (:level block)) false))))]
     (if (= format :org)
@@ -619,7 +619,7 @@
     properties))
 
 (defn- construct-block
-  [block properties timestamps body encoded-content format pos-meta {:keys [block-pattern db date-formatter parse-block remove-properties?]}]
+  [block properties timestamps body encoded-content format pos-meta {:keys [block-pattern db date-formatter parse-block remove-properties? db-graph-mode? export-to-db-graph?]}]
   (let [id (get-custom-id-or-new-id properties)
         ref-pages-in-properties (->> (:page-refs properties)
                                      (remove string/blank?))
@@ -652,16 +652,19 @@
                 block)
         title (cond->> (get-block-content encoded-content block format pos-meta block-pattern)
                 remove-properties?
-                (gp-property/remove-properties (:format block)))
+                (gp-property/remove-properties (get block :format :markdown)))
         block (assoc block :block/title title)
         block (if (seq timestamps)
                 (merge block (timestamps->scheduled-and-deadline timestamps))
                 block)
+        db-based? (or db-graph-mode? export-to-db-graph?)
         block (-> block
                   (assoc :body body)
-                  (with-page-block-refs db date-formatter {:parse-block parse-block})
-                  (update :tags (fn [tags] (map #(assoc % :block/format format) tags)))
-                  (update :refs (fn [refs] (map #(if (map? %) (assoc % :block/format format) %) refs))))
+                  (with-page-block-refs db date-formatter {:parse-block parse-block}))
+        block (if db-based? block
+                  (-> block
+                      (update :tags (fn [tags] (map #(assoc % :block/format format) tags)))
+                      (update :refs (fn [refs] (map #(if (map? %) (assoc % :block/format format) %) refs)))))
         block (update block :refs concat (:block-refs properties))
         {:keys [created-at updated-at]} (:properties properties)
         block (cond-> block
@@ -684,7 +687,7 @@
                              (let [replace-str (re-pattern
                                                 (str
                                                  "\n*\\s*"
-                                                 (if (= :markdown (:block/format block))
+                                                 (if (= :markdown (get block :block/format :markdown))
                                                    (str "id" gp-property/colons " " (:block/uuid block))
                                                    (str (gp-property/colons-org "id") " " (:block/uuid block)))))]
                                (string/replace-first c replace-str ""))))))

+ 24 - 26
deps/graph-parser/src/logseq/graph_parser/exporter.cljs

@@ -1,35 +1,35 @@
 (ns logseq.graph-parser.exporter
   "Exports a file graph to DB graph. Used by the File to DB graph importer and
   by nbb-logseq CLIs"
-  (:require [clojure.set :as set]
-            [clojure.string :as string]
+  (:require [cljs-time.coerce :as tc]
+            [cljs.pprint]
             [clojure.edn :as edn]
+            [clojure.set :as set]
+            [clojure.string :as string]
             [datascript.core :as d]
-            [logseq.graph-parser.extract :as extract]
-            [logseq.common.uuid :as common-uuid]
+            [logseq.common.config :as common-config]
             [logseq.common.path :as path]
             [logseq.common.util :as common-util]
-            [logseq.common.config :as common-config]
-            [logseq.db.frontend.content :as db-content]
-            [logseq.db.frontend.property :as db-property]
-            [logseq.db.frontend.property.type :as db-property-type]
-            [logseq.common.util.macro :as macro-util]
             [logseq.common.util.date-time :as date-time-util]
-            [logseq.db.sqlite.util :as sqlite-util]
+            [logseq.common.util.macro :as macro-util]
+            [logseq.common.util.namespace :as ns-util]
+            [logseq.common.util.page-ref :as page-ref]
+            [logseq.common.uuid :as common-uuid]
             [logseq.db :as ldb]
-            [logseq.db.frontend.rules :as rules]
             [logseq.db.frontend.class :as db-class]
-            [logseq.common.util.page-ref :as page-ref]
-            [promesa.core :as p]
-            [cljs.pprint]
-            [logseq.db.frontend.order :as db-order]
+            [logseq.db.frontend.content :as db-content]
             [logseq.db.frontend.db-ident :as db-ident]
-            [logseq.db.frontend.property.build :as db-property-build]
             [logseq.db.frontend.malli-schema :as db-malli-schema]
-            [logseq.graph-parser.property :as gp-property]
+            [logseq.db.frontend.order :as db-order]
+            [logseq.db.frontend.property :as db-property]
+            [logseq.db.frontend.property.build :as db-property-build]
+            [logseq.db.frontend.property.type :as db-property-type]
+            [logseq.db.frontend.rules :as rules]
+            [logseq.db.sqlite.util :as sqlite-util]
             [logseq.graph-parser.block :as gp-block]
-            [logseq.common.util.namespace :as ns-util]
-            [cljs-time.coerce :as tc]))
+            [logseq.graph-parser.extract :as extract]
+            [logseq.graph-parser.property :as gp-property]
+            [promesa.core :as p]))
 
 (defn- add-missing-timestamps
   "Add updated-at or created-at timestamps if they doesn't exist"
@@ -885,10 +885,9 @@
                    (update-block-priority options)
                    add-missing-timestamps
                    ;; old whiteboards may have this
-                   (dissoc :block/left)
+                   (dissoc :block/left :block/format)
                    ;; ((fn [x] (prn :block-out x) x))
-                   ;; TODO: org-mode content needs to be handled
-                   (assoc :block/format :markdown))]
+                   )]
     ;; Order matters as properties are referenced in block
     (concat properties-tx deadline-properties-tx [block'])))
 
@@ -909,8 +908,6 @@
         (journal-created-ats (:block/name m))
         (assoc :block/created-at (journal-created-ats (:block/name m))))
       add-missing-timestamps
-      ;; TODO: org-mode content needs to be handled
-      (assoc :block/format :markdown)
       (dissoc :block/whiteboard?)
       (update-page-tags db user-options per-file-state all-idents)))
 
@@ -980,6 +977,8 @@
                  (not (:block/tags page)))
             (assoc :block/tags [:logseq.class/Page])))]
     (cond-> page'
+      true
+      (dissoc :block/format)
       (:block/namespace page)
       ((fn [block']
          (merge (build-new-namespace-page block')
@@ -1313,8 +1312,7 @@
                               (filter ldb/whiteboard?)
                               (map (fn [page-block]
                                      (-> page-block
-                                         (assoc :block/format :markdown
-                                                :logseq.property/ls-type :whiteboard-page)))))
+                                         (assoc :logseq.property/ls-type :whiteboard-page)))))
         pre-blocks (->> blocks (keep #(when (:block/pre-block? %) (:block/uuid %))) set)
         blocks-tx (->> blocks
                        (remove :block/pre-block?)

+ 45 - 36
deps/graph-parser/src/logseq/graph_parser/extract.cljc

@@ -4,20 +4,20 @@
   ;; Disable clj linters since we don't support clj
   #?(:clj {:clj-kondo/config {:linters {:unresolved-namespace {:level :off}
                                         :unresolved-symbol {:level :off}}}})
-  (:require [clojure.set :as set]
+  (:require #?(:org.babashka/nbb [logseq.common.log :as log]
+               :default [lambdaisland.glogi :as log])
+            [clojure.set :as set]
             [clojure.string :as string]
             [clojure.walk :as walk]
             [datascript.core :as d]
-            [logseq.graph-parser.text :as text]
+            [logseq.common.config :as common-config]
             [logseq.common.util :as common-util]
-            [logseq.graph-parser.mldoc :as gp-mldoc]
+            [logseq.db :as ldb]
             [logseq.graph-parser.block :as gp-block]
+            [logseq.graph-parser.mldoc :as gp-mldoc]
             [logseq.graph-parser.property :as gp-property]
-            [logseq.common.config :as common-config]
-            #?(:org.babashka/nbb [logseq.common.log :as log]
-               :default [lambdaisland.glogi :as log])
-            [logseq.graph-parser.whiteboard :as gp-whiteboard]
-            [logseq.db :as ldb]))
+            [logseq.graph-parser.text :as text]
+            [logseq.graph-parser.whiteboard :as gp-whiteboard]))
 
 (defn- filepath->page-name
   [filepath]
@@ -190,6 +190,33 @@
           (log/error :gp-extract/attach-block-ids-not-match "attach-block-ids-if-match: block-ids provided, but doesn't match the number of blocks, ignoring")))
       blocks))
 
+(defn- build-pages-aux
+  [db db-based? options page-map ref-pages date-formatter format]
+  (let [namespace-pages (when (or (not db-based?) (:export-to-db-graph? options))
+                          (let [page (:block/title page-map)]
+                            (when (text/namespace-page? page)
+                              (->> (common-util/split-namespace-pages page)
+                                   (map (fn [page]
+                                          (cond-> (gp-block/page-name->map page db true date-formatter)
+                                            (not db-based?)
+                                            (assoc :block/format format))))))))
+        pages (->> (concat
+                    [page-map]
+                    @ref-pages
+                    namespace-pages)
+                     ;; remove block references
+                   (remove vector?)
+                   (remove nil?)
+                   (filter :block/name))
+        pages (common-util/distinct-by :block/name pages)
+        pages (remove nil? pages)]
+    (map (fn [page]
+           (let [page-id (or (when db
+                               (:block/uuid (ldb/get-page db (:block/name page))))
+                             (d/squuid))]
+             (assoc page :block/uuid page-id)))
+         pages)))
+
 ;; TODO: performance improvement
 (defn- extract-pages-and-blocks
   "uri-encoded? - if is true, apply URL decode on the file path
@@ -225,11 +252,15 @@
                           (let [block-ref-pages (seq (:block/refs block))]
                             (when block-ref-pages
                               (swap! ref-pages set/union (set block-ref-pages)))
-                            (-> block
-                                (dissoc :ref-pages)
-                                (assoc :block/format format
-                                       :block/page [:block/name page-name]
-                                       :block/refs block-ref-pages)))))
+                            (cond->
+                             (-> block
+                                 (dissoc :ref-pages)
+                                 (assoc :block/page [:block/name page-name]
+                                        :block/refs block-ref-pages))
+                              (not db-based?)
+                              (assoc :block/format format)
+                              db-based?
+                              (dissoc :block/format)))))
                       blocks)
           [properties invalid-properties properties-text-values]
           (if (:block/pre-block? (first blocks))
@@ -238,29 +269,7 @@
              (:block/properties-text-values (first blocks))]
             [properties [] {}])
           page-map (build-page-map properties invalid-properties properties-text-values file page page-name (assoc options' :from-page page))
-          namespace-pages (when (or (not db-based?) (:export-to-db-graph? options))
-                            (let [page (:block/title page-map)]
-                              (when (text/namespace-page? page)
-                                (->> (common-util/split-namespace-pages page)
-                                     (map (fn [page]
-                                            (-> (gp-block/page-name->map page db true date-formatter)
-                                                (assoc :block/format format))))))))
-          pages (->> (concat
-                      [page-map]
-                      @ref-pages
-                      namespace-pages)
-                     ;; remove block references
-                     (remove vector?)
-                     (remove nil?)
-                     (filter :block/name))
-          pages (common-util/distinct-by :block/name pages)
-          pages (remove nil? pages)
-          pages (map (fn [page]
-                       (let [page-id (or (when db
-                                           (:block/uuid (ldb/get-page db (:block/name page))))
-                                         (d/squuid))]
-                         (assoc page :block/uuid page-id)))
-                     pages)
+          pages (build-pages-aux db db-based? options page-map ref-pages date-formatter format)
           blocks (->> (remove nil? blocks)
                       (map (fn [b] (dissoc b :block.temp/ast-title :block.temp/ast-body :block/level :block/children :block/meta))))]
       [pages blocks])

+ 16 - 16
deps/graph-parser/test/logseq/graph_parser/exporter_test.cljs

@@ -1,27 +1,27 @@
 (ns ^:node-only logseq.graph-parser.exporter-test
-  (:require [cljs.test :refer [testing is]]
-            [logseq.graph-parser.test.helper :as test-helper :include-macros true :refer [deftest-async]]
-            [logseq.graph-parser.test.docs-graph-helper :as docs-graph-helper]
-            [datascript.core :as d]
-            [clojure.string :as string]
-            [clojure.set :as set]
+  (:require ["fs" :as fs]
             ["path" :as node-path]
-            ["fs" :as fs]
+            [cljs.test :refer [testing is]]
+            [clojure.set :as set]
+            [clojure.string :as string]
+            [datascript.core :as d]
+            [logseq.common.config :as common-config]
             [logseq.common.graph :as common-graph]
-            [promesa.core :as p]
-            [logseq.db.frontend.validate :as db-validate]
-            [logseq.graph-parser.exporter :as gp-exporter]
+            [logseq.common.util.date-time :as date-time-util]
+            [logseq.db :as ldb]
+            [logseq.db.frontend.content :as db-content]
             [logseq.db.frontend.malli-schema :as db-malli-schema]
             [logseq.db.frontend.property :as db-property]
             [logseq.db.frontend.property.type :as db-property-type]
-            [logseq.common.config :as common-config]
-            [logseq.db :as ldb]
-            [logseq.outliner.db-pipeline :as db-pipeline]
-            [logseq.db.test.helper :as db-test]
             [logseq.db.frontend.rules :as rules]
-            [logseq.common.util.date-time :as date-time-util]
+            [logseq.db.frontend.validate :as db-validate]
+            [logseq.db.test.helper :as db-test]
             [logseq.graph-parser.block :as gp-block]
-            [logseq.db.frontend.content :as db-content]))
+            [logseq.graph-parser.exporter :as gp-exporter]
+            [logseq.graph-parser.test.docs-graph-helper :as docs-graph-helper]
+            [logseq.graph-parser.test.helper :as test-helper :include-macros true :refer [deftest-async]]
+            [logseq.outliner.db-pipeline :as db-pipeline]
+            [promesa.core :as p]))
 
 ;; Helpers
 ;; =======

+ 1 - 39
deps/outliner/src/logseq/outliner/core.cljs

@@ -133,44 +133,6 @@
 
 (declare move-blocks)
 
-(comment
-  (defn- create-linked-page-when-save
-    [repo conn db date-formatter txs-state block-entity m tags-has-class?]
-    (if tags-has-class?
-      (let [content (state/get-edit-content)
-            linked-page (some-> content #(gp-block/extract-plain repo %))
-            sanity-linked-page (some-> linked-page util/page-name-sanity-lc)
-            linking-page? (and (not (string/blank? sanity-linked-page))
-                               @(:editor/create-page? @state/state))]
-        (when linking-page?
-          (let [existing-ref-id (some (fn [r]
-                                        (when (= sanity-linked-page (:block/name r))
-                                          (:block/uuid r)))
-                                      (:block/refs m))
-                page-m (gp-block/page-name->map linked-page (or existing-ref-id true)
-                                                db true date-formatter)
-                _ (when-not (d/entity db [:block/uuid (:block/uuid page-m)])
-                    (ldb/transact! conn [page-m]))
-                merge-tx (let [children (:block/_parent block-entity)
-                               page (d/entity db [:block/uuid (:block/uuid page-m)])
-                               [target sibling?] (get-last-child-or-self db page)]
-                           (when (seq children)
-                             (:tx-data
-                              (move-blocks repo conn children target
-                                           {:sibling? sibling?
-                                            :outliner-op :move-blocks}))))]
-            (swap! txs-state (fn [txs]
-                               (concat txs
-                                       [(assoc page-m
-                                               :block/tags (:block/tags m)
-                                               :block/format :markdown)
-                                        {:db/id (:db/id block-entity)
-                                         :block/title ""
-                                         :block/refs []
-                                         :block/link [:block/uuid (:block/uuid page-m)]}]
-                                       merge-tx))))))
-      (reset! (:editor/create-page? @state/state) false))))
-
 (defn- file-rebuild-block-refs
   [repo db date-formatter {:block/keys [properties] :as block}]
   (let [property-key-refs (keys properties)
@@ -301,7 +263,7 @@
               (outliner-validate/validate-block-title db (:block/title m*) block-entity))
           m (cond-> m*
               db-based?
-              (dissoc :block/pre-block? :block/priority :block/marker :block/properties-order))]
+              (dissoc :block/format :block/pre-block? :block/priority :block/marker :block/properties-order))]
       ;; Ensure block UUID never changes
       (let [e (d/entity db db-id)]
         (when (and e block-uuid)

+ 4 - 5
src/electron/electron/handler.cljs

@@ -16,23 +16,23 @@
             [clojure.string :as string]
             [electron.backup-file :as backup-file]
             [electron.configs :as cfgs]
+            [electron.db :as db]
             [electron.file-sync-rsapi :as rsapi]
             [electron.find-in-page :as find]
             [electron.fs-watcher :as watcher]
             [electron.git :as git]
+            [electron.handler-interface :refer [handle]]
             [electron.logger :as logger]
             [electron.plugin :as plugin]
-            [electron.db :as db]
             [electron.server :as server]
             [electron.shell :as shell]
             [electron.state :as state]
             [electron.utils :as utils]
             [electron.window :as win]
-            [electron.handler-interface :refer [handle]]
-            [logseq.db.sqlite.util :as sqlite-util]
-            [logseq.db.sqlite.common-db :as sqlite-common-db]
             [goog.functions :refer [debounce]]
             [logseq.common.graph :as common-graph]
+            [logseq.db.sqlite.common-db :as sqlite-common-db]
+            [logseq.db.sqlite.util :as sqlite-util]
             [promesa.core :as p]))
 
 (defmethod handle :mkdir [_window [_ dir]]
@@ -466,7 +466,6 @@
   (debounced-configure-auto-commit!)
   nil)
 
-
 (defmethod handle :installMarketPlugin [_ [_ manifest]]
   (plugin/install-or-update! manifest))
 

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

@@ -1,7 +1,7 @@
 (ns frontend.background-tasks
   "Some background tasks"
-  (:require [frontend.flows :as flows]
-            [frontend.common.missionary :as c.m]
+  (:require [frontend.common.missionary :as c.m]
+            [frontend.flows :as flows]
             [logseq.db.frontend.entity-plus :as entity-plus]
             [missionary.core :as m]))
 

+ 10 - 10
src/main/frontend/commands.cljs

@@ -5,28 +5,28 @@
             [frontend.date :as date]
             [frontend.db :as db]
             [frontend.extensions.video.youtube :as youtube]
+            [frontend.handler.db-based.property :as db-property-handler]
+            [frontend.handler.db-based.property.util :as db-pu]
             [frontend.handler.draw :as draw]
+            [frontend.handler.file-based.property :as file-property-handler]
+            [frontend.handler.file-based.status :as file-based-status]
             [frontend.handler.notification :as notification]
             [frontend.handler.plugin :as plugin-handler]
+            [frontend.handler.property.file :as property-file]
             [frontend.search :as search]
             [frontend.state :as state]
             [frontend.util :as util]
             [frontend.util.cursor :as cursor]
             [frontend.util.file-based.priority :as priority]
-            [frontend.handler.file-based.property :as file-property-handler]
-            [frontend.handler.db-based.property.util :as db-pu]
-            [frontend.handler.property.file :as property-file]
             [goog.dom :as gdom]
             [goog.object :as gobj]
             [logseq.common.config :as common-config]
-            [logseq.graph-parser.property :as gp-property]
             [logseq.common.util :as common-util]
             [logseq.common.util.block-ref :as block-ref]
+            [logseq.common.util.macro :as macro-util]
             [logseq.common.util.page-ref :as page-ref]
-            [promesa.core :as p]
-            [frontend.handler.file-based.status :as file-based-status]
-            [frontend.handler.db-based.property :as db-property-handler]
-            [logseq.common.util.macro :as macro-util]))
+            [logseq.graph-parser.property :as gp-property]
+            [promesa.core :as p]))
 
 ;; TODO: move to frontend.handler.editor.commands
 
@@ -830,7 +830,7 @@
   (when-let [input-id (state/get-edit-input-id)]
     (when-let [current-input (gdom/getElement input-id)]
       (let [current-block (state/get-edit-block)
-            format (:block/format current-block)]
+            format (get current-block :block/format :markdown)]
         (if (config/db-based-graph?)
           (state/pub-event! [:editor/set-heading current-block heading])
           (if (= format :markdown)
@@ -930,6 +930,6 @@
 
 (defn exec-plugin-simple-command!
   [pid {:keys [block-id] :as cmd} action]
-  (let [format (and block-id (:block/format (db/entity [:block/uuid block-id])))
+  (let [format (and block-id (get (db/entity [:block/uuid block-id]) :block/format :markdown))
         inputs (vector (conj action (assoc cmd :pid pid)))]
     (handle-steps inputs format)))

+ 15 - 12
src/main/frontend/components/block.cljs

@@ -4,6 +4,7 @@
   (:require ["/frontend/utils" :as utils]
             [cljs-bean.core :as bean]
             [cljs.core.match :refer [match]]
+            [clojure.set :as set]
             [clojure.string :as string]
             [datascript.core :as d]
             [datascript.impl.entity :as e]
@@ -90,8 +91,7 @@
             [promesa.core :as p]
             [reitit.frontend.easy :as rfe]
             [rum.core :as rum]
-            [shadow.loader :as loader]
-            [clojure.set :as set]))
+            [shadow.loader :as loader]))
 
 ;; local state
 (defonce *dragging?
@@ -1337,7 +1337,7 @@
   [config metadata s full-text]
   (let [media-formats (set (map name config/media-formats))
         metadata-show (:show (common-util/safe-read-map-string metadata))
-        format (get-in config [:block :block/format])]
+        format (get-in config [:block :block/format] :markdown)]
     (or
      (and
       (= :org format)
@@ -1475,7 +1475,7 @@
                            id label*)))
 
       ["Page_ref" page]
-      (let [format (get-in config [:block :block/format])]
+      (let [format (get-in config [:block :block/format] :markdown)]
         (if (and (= format :org)
                  (show-link? config nil page page)
                  (not (contains? #{"pdf" "mp4" "ogg" "webm"} (util/get-file-ext page))))
@@ -1496,7 +1496,7 @@
             [protocol path] (or (and (= "Complex" (first url)) url)
                                 (and (= "File" (first url)) ["file" (second url)]))]
         (cond
-          (and (= (get-in config [:block :block/format]) :org)
+          (and (= (get-in config [:block :block/format] :markdown) :org)
                (= "Complex" protocol)
                (= (string/lower-case (:protocol path)) "id")
                (string? (:link path))
@@ -2196,7 +2196,8 @@
 
 (rum/defc ^:large-vars/cleanup-todo text-block-title
   [config {:block/keys [format marker pre-block? properties] :as block}]
-  (let [block (if-not (:block.temp/ast-title block)
+  (let [format (or format :markdown)
+        block (if-not (:block.temp/ast-title block)
                 (merge block (block/parse-title-and-body uuid format pre-block?
                                                          (:block/title block)))
                 block)
@@ -2406,7 +2407,7 @@
             (rum/with-key elem (str (random-uuid)))))
 
         :else
-        (inline-text config (:block/format block) (str v)))]]))
+        (inline-text config (get block :block/format :markdown) (str v)))]]))
 
 (rum/defc properties-cp
   [config {:block/keys [pre-block?] :as block}]
@@ -2765,7 +2766,8 @@
 
 (rum/defc ^:large-vars/cleanup-todo block-content < rum/reactive
   [config {:block/keys [uuid properties scheduled deadline format pre-block?] :as block} edit-input-id block-id slide?]
-  (let [collapsed? (:collapsed? config)
+  (let [format (or format :markdown)
+        collapsed? (:collapsed? config)
         repo (state/get-current-repo)
         db-based? (config/db-based-graph? (state/get-current-repo))
         content (if db-based?
@@ -2923,7 +2925,8 @@
                     ::hide-block-refs? (atom default-hide?)
                     ::refs-count *refs-count)))}
   [state config {:block/keys [uuid format] :as block} {:keys [edit-input-id block-id edit? hide-block-refs-count?]}]
-  (let [*hide-block-refs? (get state ::hide-block-refs?)
+  (let [format (or format :markdown)
+        *hide-block-refs? (get state ::hide-block-refs?)
         *refs-count (get state ::refs-count)
         hide-block-refs? (rum/react *hide-block-refs?)
         editor-box (state/get-component :editor/box)
@@ -3114,7 +3117,7 @@
                                  [block (page-cp {} block)]
                                  (let [result (block/parse-title-and-body
                                                uuid
-                                               (:block/format block)
+                                               (get block :block/format :markdown)
                                                (:block/pre-block? block)
                                                title)
                                        ast-body (:block.temp/ast-body result)
@@ -3212,7 +3215,7 @@
 
             (contains? transfer-types "Files")
             (let [files (.-files data-transfer)
-                  format (:block/format target-block)]
+                  format (get target-block :block/format :markdown)]
               ;; When editing, this event will be handled by editor-handler/upload-asset(editor-on-paste)
               (when (and (config/local-file-based-graph? repo) (not (state/editing?)))
                 ;; Basically the same logic as editor-handler/upload-asset,
@@ -3525,7 +3528,7 @@
             (block-reference {} (str uuid) nil)
           ;; Not embed self
             [:div.flex.flex-col.w-full
-             (let [block (merge block (block/parse-title-and-body uuid (:block/format block) pre-block? title))
+             (let [block (merge block (block/parse-title-and-body uuid (get block :block/format :markdown) pre-block? title))
                    hide-block-refs-count? (or (and (:embed? config)
                                                    (= (:block/uuid block) (:embed-id config)))
                                               table?)]

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

@@ -380,7 +380,7 @@
   (when-let [default-home (state/get-default-home)]
     (let [page (:page default-home)
           page (when (and (string? page)
-                       (not (string/blank? page)))
+                          (not (string/blank? page)))
                  (db/get-page page))]
       (if page
         default-home
@@ -598,7 +598,7 @@
                    :upload-files
                    {:drop (fn [_e files]
                             (when-let [id (state/get-edit-input-id)]
-                              (let [format (:block/format (state/get-edit-block))]
+                              (let [format (get (state/get-edit-block) :block/format :markdown)]
                                 (editor-handler/upload-asset! id files format editor-handler/*asset-uploading? true))))})
                   (common-handler/listen-to-scroll! element)
                   (when (:margin-less-pages? (first (:rum/args state))) ;; makes sure full screen pages displaying without scrollbar

+ 6 - 5
src/main/frontend/components/content.cljs

@@ -10,6 +10,7 @@
             [frontend.config :as config]
             [frontend.context.i18n :refer [t]]
             [frontend.db :as db]
+            [frontend.extensions.fsrs :as fsrs]
             [frontend.extensions.srs :as srs]
             [frontend.handler.common.developer :as dev-common-handler]
             [frontend.handler.editor :as editor-handler]
@@ -21,7 +22,6 @@
             [frontend.persist-db.browser :as db-browser]
             [frontend.state :as state]
             [frontend.ui :as ui]
-            [logseq.shui.ui :as shui]
             [frontend.util :as util]
             [frontend.util.url :as url-util]
             [goog.dom :as gdom]
@@ -29,10 +29,10 @@
             [logseq.common.util :as common-util]
             [logseq.common.util.block-ref :as block-ref]
             [logseq.common.util.page-ref :as page-ref]
-            [promesa.core :as p]
-            [rum.core :as rum]
             [logseq.db :as ldb]
-            [frontend.extensions.fsrs :as fsrs]))
+            [logseq.shui.ui :as shui]
+            [promesa.core :as p]
+            [rum.core :as rum]))
 
 ;; TODO i18n support
 
@@ -348,7 +348,8 @@
                {:key "(Dev) Show block AST"
                 :on-click (fn []
                             (let [block (db/entity [:block/uuid block-id])]
-                              (dev-common-handler/show-content-ast (:block/title block) (:block/format block))))}
+                              (dev-common-handler/show-content-ast (:block/title block)
+                                                                   (get block :block/format :markdown))))}
                (t :dev/show-block-ast))
               (shui/dropdown-menu-item
                {:key "(Dev) Show block content history"

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

@@ -12,13 +12,13 @@
             [frontend.db :as db]
             [frontend.db.model :as db-model]
             [frontend.extensions.zotero :as zotero]
+            [frontend.handler.block :as block-handler]
             [frontend.handler.editor :as editor-handler :refer [get-state]]
             [frontend.handler.editor.lifecycle :as lifecycle]
             [frontend.handler.page :as page-handler]
             [frontend.handler.paste :as paste-handler]
             [frontend.handler.property.util :as pu]
             [frontend.handler.search :as search-handler]
-            [frontend.handler.block :as block-handler]
             [frontend.mixins :as mixins]
             [frontend.search :refer [fuzzy-search]]
             [frontend.state :as state]
@@ -30,13 +30,13 @@
             [goog.string :as gstring]
             [logseq.common.util :as common-util]
             [logseq.db :as ldb]
+            [logseq.db.frontend.class :as db-class]
             [logseq.graph-parser.property :as gp-property]
             [logseq.shui.popup.core :as shui-popup]
             [logseq.shui.ui :as shui]
             [promesa.core :as p]
             [react-draggable]
-            [rum.core :as rum]
-            [logseq.db.frontend.class :as db-class]))
+            [rum.core :as rum]))
 
 (defn filter-commands
   [page? commands]

+ 9 - 9
src/main/frontend/components/file_based/query_table.cljs

@@ -5,15 +5,15 @@
             [frontend.db.query-dsl :as query-dsl]
             [frontend.format.block :as block]
             [frontend.handler.common :as common-handler]
+            [frontend.handler.file-based.property :as file-property-handler]
             [frontend.handler.property :as property-handler]
             [frontend.state :as state]
             [frontend.util :as util]
             [frontend.util.file-based.clock :as clock]
-            [frontend.handler.file-based.property :as file-property-handler]
+            [logseq.graph-parser.text :as text]
             [medley.core :as medley]
-            [rum.core :as rum]
             [promesa.core :as p]
-            [logseq.graph-parser.text :as text]))
+            [rum.core :as rum]))
 
 ;; Util fns
 ;; ========
@@ -136,7 +136,7 @@
           uuid (:block/uuid row)
           {:block/keys [title]} (block/parse-title-and-body
                                  (:block/uuid row)
-                                 (:block/format row)
+                                 (get row :block/format :markdown)
                                  (:block/pre-block? row)
                                  content)]
       (if (seq title)
@@ -201,7 +201,7 @@
             (sortable-title title column sort-state (:block/uuid current-block))))]]
       [:tbody
        (for [row sort-result']
-         (let [format (:block/format row)]
+         (let [format (get row :block/format :markdown)]
            [:tr.cursor
             (for [column columns]
               (let [[cell-format value] (build-column-value row
@@ -220,9 +220,9 @@
                   :on-pointer-up (fn []
                                    (when (and @*mouse-down? (not @select?))
                                      (state/sidebar-add-block!
-                                       (state/get-current-repo)
-                                       (:db/id row)
-                                       :block-ref)
+                                      (state/get-current-repo)
+                                      (:db/id row)
+                                      :block-ref)
                                      (reset! *mouse-down? false)))}
                  (when (some? value)
                    (render-column-value {:row-block row
@@ -241,4 +241,4 @@
           ;; as user needs to know if there result is sorted
           sort-state (get-sort-state current-block)
           sort-result' (sort-result result' (assoc sort-state :page? page?))]
-      (result-table-v1 config current-block sort-result' sort-state columns options map-inline page-cp ->elem inline-text))))
+      (result-table-v1 config current-block sort-result' sort-state columns options map-inline page-cp ->elem inline-text))))

+ 7 - 7
src/main/frontend/components/imports.cljs

@@ -1,8 +1,8 @@
 (ns frontend.components.imports
   "Import data into Logseq."
-  (:require [clojure.string :as string]
-            [cljs-time.core :as t]
+  (:require [cljs-time.core :as t]
             [cljs.pprint :as pprint]
+            [clojure.string :as string]
             [frontend.components.onboarding.setups :as setups]
             [frontend.components.repo :as repo]
             [frontend.components.svg :as svg]
@@ -23,15 +23,15 @@
             [frontend.util.fs :as fs-util]
             [goog.functions :refer [debounce]]
             [goog.object :as gobj]
+            [lambdaisland.glogi :as log]
             [logseq.common.path :as path]
+            [logseq.db.frontend.validate :as db-validate]
             [logseq.graph-parser.exporter :as gp-exporter]
-            [promesa.core :as p]
-            [rum.core :as rum]
-            [logseq.shui.ui :as shui]
             [logseq.shui.dialog.core :as shui-dialog]
             [logseq.shui.form.core :as form-core]
-            [lambdaisland.glogi :as log]
-            [logseq.db.frontend.validate :as db-validate]))
+            [logseq.shui.ui :as shui]
+            [promesa.core :as p]
+            [rum.core :as rum]))
 
 ;; Can't name this component as `frontend.components.import` since shadow-cljs
 ;; will complain about it.

+ 27 - 27
src/main/frontend/components/objects.cljs

@@ -1,26 +1,26 @@
 (ns frontend.components.objects
   "Provides table views for class objects and property related objects"
-  (:require [frontend.components.views :as views]
+  (:require [clojure.string :as string]
+            [frontend.components.filepicker :as filepicker]
+            [frontend.components.views :as views]
             [frontend.db :as db]
-            [logseq.db :as ldb]
             [frontend.db-mixins :as db-mixins]
             [frontend.db.async :as db-async]
             [frontend.db.model :as db-model]
+            [frontend.db.react :as react]
             [frontend.handler.editor :as editor-handler]
             [frontend.mixins :as mixins]
-            [frontend.state :as state]
-            [logseq.outliner.property :as outliner-property]
-            [promesa.core :as p]
-            [rum.core :as rum]
-            [frontend.modules.outliner.ui :as ui-outliner-tx]
             [frontend.modules.outliner.op :as outliner-op]
-            [frontend.db.react :as react]
-            [logseq.shui.ui :as shui]
-            [frontend.util :as util]
+            [frontend.modules.outliner.ui :as ui-outliner-tx]
+            [frontend.state :as state]
             [frontend.ui :as ui]
+            [frontend.util :as util]
             [logseq.common.config :as common-config]
-            [frontend.components.filepicker :as filepicker]
-            [clojure.string :as string]))
+            [logseq.db :as ldb]
+            [logseq.outliner.property :as outliner-property]
+            [logseq.shui.ui :as shui]
+            [promesa.core :as p]
+            [rum.core :as rum]))
 
 (defn- get-class-objects
   [class]
@@ -256,21 +256,21 @@
                    :show-add-property? false
                    ;; Relationships with built-in properties must not be deleted e.g. built-in? or parent
                    :on-delete-rows (when-not (:logseq.property/built-in? property)
-                                             (fn [table selected-rows]
-                                               (let [pages (->> selected-rows (filter ldb/page?) (remove :logseq.property/built-in?))
-                                                     blocks (->> selected-rows (remove ldb/page?) (remove :logseq.property/built-in?))]
-                                                 (p/do!
-                                                  (set-data! (get-property-related-objects (state/get-current-repo) property))
-                                                  (when-let [f (get-in table [:data-fns :set-row-selection!])]
-                                                    (f {}))
-                                                  (ui-outliner-tx/transact!
-                                                   {:outliner-op :delete-blocks}
-                                                   (when (seq blocks)
-                                                     (outliner-op/delete-blocks! blocks nil))
-                                                   (let [page-ids (map :db/id pages)
-                                                         tx-data (map (fn [pid] [:db/retract pid (:db/ident property)]) page-ids)]
-                                                     (when (seq tx-data)
-                                                       (outliner-op/transact! tx-data {:outliner-op :save-block}))))))))}))))
+                                     (fn [table selected-rows]
+                                       (let [pages (->> selected-rows (filter ldb/page?) (remove :logseq.property/built-in?))
+                                             blocks (->> selected-rows (remove ldb/page?) (remove :logseq.property/built-in?))]
+                                         (p/do!
+                                          (set-data! (get-property-related-objects (state/get-current-repo) property))
+                                          (when-let [f (get-in table [:data-fns :set-row-selection!])]
+                                            (f {}))
+                                          (ui-outliner-tx/transact!
+                                           {:outliner-op :delete-blocks}
+                                           (when (seq blocks)
+                                             (outliner-op/delete-blocks! blocks nil))
+                                           (let [page-ids (map :db/id pages)
+                                                 tx-data (map (fn [pid] [:db/retract pid (:db/ident property)]) page-ids)]
+                                             (when (seq tx-data)
+                                               (outliner-op/transact! tx-data {:outliner-op :save-block}))))))))}))))
 
 ;; Show all nodes containing the given property
 (rum/defcs property-related-objects < rum/reactive db-mixins/query mixins/container-id

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

@@ -1,9 +1,11 @@
 (ns frontend.components.page
   (:require ["/frontend/utils" :as utils]
             [clojure.string :as string]
+            [dommy.core :as dom]
             [frontend.components.block :as component-block]
             [frontend.components.class :as class-component]
             [frontend.components.content :as content]
+            [frontend.components.db-based.page :as db-page]
             [frontend.components.editor :as editor]
             [frontend.components.file-based.hierarchy :as hierarchy]
             [frontend.components.objects :as objects]
@@ -11,7 +13,6 @@
             [frontend.components.query :as query]
             [frontend.components.reference :as reference]
             [frontend.components.scheduled-deadlines :as scheduled]
-            [frontend.components.db-based.page :as db-page]
             [frontend.components.svg :as svg]
             [frontend.config :as config]
             [frontend.context.i18n :refer [t]]
@@ -34,6 +35,7 @@
             [frontend.handler.route :as route-handler]
             [frontend.mixins :as mixins]
             [frontend.mobile.util :as mobile-util]
+            [frontend.rum :as frontend-rum]
             [frontend.state :as state]
             [frontend.ui :as ui]
             [frontend.util :as util]
@@ -46,9 +48,7 @@
             [logseq.shui.ui :as shui]
             [promesa.core :as p]
             [reitit.frontend.easy :as rfe]
-            [rum.core :as rum]
-            [frontend.rum :as frontend-rum]
-            [dommy.core :as dom]))
+            [rum.core :as rum]))
 
 (defn- get-page-name
   [state]
@@ -421,7 +421,7 @@
                                   (string/includes? title page-ref/right-brackets))]
                  (cond untitled? [:span.opacity-50 (t :untitled)]
                        nested? (component-block/map-inline {} (gp-mldoc/inline->edn title (mldoc/get-default-config
-                                                                                           (:block/format page))))
+                                                                                           (get page :block/format :markdown))))
                        :else title))])]])))))
 
 (rum/defc db-page-title-actions

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

@@ -173,6 +173,6 @@
                                    (let [page (db/pull '[:block/format {:block/file [:file/content]}] (:db/id page))]
                                      (dev-common-handler/show-content-ast
                                       (get-in page [:block/file :file/content])
-                                      (:block/format page))))}})]
+                                      (get page :block/format :markdown))))}})]
          (flatten)
          (remove nil?))))))

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

@@ -1,27 +1,27 @@
 (ns frontend.components.plugins
-  (:require [rum.core :as rum]
-            [frontend.state :as state]
-            [cljs-bean.core :as bean]
+  (:require [cljs-bean.core :as bean]
+            [clojure.string :as string]
+            [electron.ipc :as ipc]
+            [frontend.components.plugins-settings :as plugins-settings]
+            [frontend.components.svg :as svg]
+            [frontend.config :as config]
             [frontend.context.i18n :refer [t]]
-            [frontend.ui :as ui]
-            [logseq.shui.ui :as shui]
-            [frontend.handler.ui :as ui-handler]
+            [frontend.handler.common.plugin :as plugin-common-handler]
             [frontend.handler.editor :as editor-handler]
+            [frontend.handler.notification :as notification]
+            [frontend.handler.plugin :as plugin-handler]
             [frontend.handler.plugin-config :as plugin-config-handler]
-            [frontend.handler.common.plugin :as plugin-common-handler]
+            [frontend.handler.ui :as ui-handler]
+            [frontend.mixins :as mixins]
+            [frontend.rum :as rum-utils]
             [frontend.search :as search]
+            [frontend.state :as state]
+            [frontend.storage :as storage]
+            [frontend.ui :as ui]
             [frontend.util :as util]
-            [frontend.mixins :as mixins]
-            [frontend.config :as config]
-            [electron.ipc :as ipc]
+            [logseq.shui.ui :as shui]
             [promesa.core :as p]
-            [frontend.components.svg :as svg]
-            [frontend.components.plugins-settings :as plugins-settings]
-            [frontend.handler.notification :as notification]
-            [frontend.handler.plugin :as plugin-handler]
-            [frontend.storage :as storage]
-            [frontend.rum :as rum-utils]
-            [clojure.string :as string]))
+            [rum.core :as rum]))
 
 (declare open-waiting-updates-modal!)
 (defonce PER-PAGE-SIZE 15)
@@ -256,20 +256,20 @@
             #(-> (shui/dialog-confirm!
                   [:b (t :plugin/delete-alert name)])
                  (p/then (fn []
-                          (plugin-common-handler/unregister-plugin id)
+                           (plugin-common-handler/unregister-plugin id)
 
-                          (when (util/electron?)
-                           (plugin-config-handler/remove-plugin id)))))}
+                           (when (util/electron?)
+                             (plugin-config-handler/remove-plugin id)))))}
        (t :plugin/uninstall)]]]
 
     (when (seq sponsors)
-     [:div.de.sponsors
-      [:strong (ui/icon "coffee")]
-      [:ul.menu-list
-       (for [link sponsors]
-        [:li {:key link}
-         [:a {:href link :target "_blank"}
-          [:span.flex.items-center link (ui/icon "external-link")]]])]])]
+      [:div.de.sponsors
+       [:strong (ui/icon "coffee")]
+       [:ul.menu-list
+        (for [link sponsors]
+          [:li {:key link}
+           [:a {:href link :target "_blank"}
+            [:span.flex.items-center link (ui/icon "external-link")]]])]])]
 
    [:div.r.flex.items-center
     (when (and unpacked? (not disabled?))
@@ -305,70 +305,70 @@
     url item (if (or repo webPkg) remote-readme-display local-markdown-display)))
 
 (rum/defc plugin-item-card < rum/static
- [t {:keys [id name title version url description author icon iir repo sponsors webPkg] :as item}
-  disabled? market? *search-key has-other-pending?
-  installing-or-updating? installed? stat coming-update]
-
- (let [name (or title name "Untitled")
-       web? (not (nil? webPkg))
-       unpacked? (and (not web?) (not iir))
-       new-version (state/coming-update-new-version? coming-update)]
-  [:div.cp__plugins-item-card
-   {:key   (str "lsp-card-" id)
-    :class (util/classnames
-            [{:market          market?
-              :installed       installed?
-              :updating        installing-or-updating?
-              :has-new-version new-version}])}
-
-   [:div.l.link-block.cursor-pointer
-    {:on-click (get-open-plugin-readme-handler url item repo)}
-    (if (and icon (not (string/blank? icon)))
-     [:img.icon {:src (if market? (plugin-handler/pkg-asset id icon) icon)}]
-     svg/folder)
-
-    (when (and (not market?) unpacked?)
-     [:span.flex.justify-center.text-xs.text-error.pt-2 (t :plugin/unpacked)])]
-
-   [:div.r
-    [:h3.head.text-xl.font-bold.pt-1.5
-
-     [:span.l.link-block.cursor-pointer
+  [t {:keys [id name title version url description author icon iir repo sponsors webPkg] :as item}
+   disabled? market? *search-key has-other-pending?
+   installing-or-updating? installed? stat coming-update]
+
+  (let [name (or title name "Untitled")
+        web? (not (nil? webPkg))
+        unpacked? (and (not web?) (not iir))
+        new-version (state/coming-update-new-version? coming-update)]
+    [:div.cp__plugins-item-card
+     {:key   (str "lsp-card-" id)
+      :class (util/classnames
+              [{:market          market?
+                :installed       installed?
+                :updating        installing-or-updating?
+                :has-new-version new-version}])}
+
+     [:div.l.link-block.cursor-pointer
       {:on-click (get-open-plugin-readme-handler url item repo)}
-      name]
-     (when (not market?) [:sup.inline-block.px-1.text-xs.opacity-50 version])]
+      (if (and icon (not (string/blank? icon)))
+        [:img.icon {:src (if market? (plugin-handler/pkg-asset id icon) icon)}]
+        svg/folder)
 
-    [:div.desc.text-xs.opacity-70
-     [:p description]
+      (when (and (not market?) unpacked?)
+        [:span.flex.justify-center.text-xs.text-error.pt-2 (t :plugin/unpacked)])]
+
+     [:div.r
+      [:h3.head.text-xl.font-bold.pt-1.5
+
+       [:span.l.link-block.cursor-pointer
+        {:on-click (get-open-plugin-readme-handler url item repo)}
+        name]
+       (when (not market?) [:sup.inline-block.px-1.text-xs.opacity-50 version])]
+
+      [:div.desc.text-xs.opacity-70
+       [:p description]
      ;;[:small (js/JSON.stringify (bean/->js settings))]
-     ]
+       ]
 
     ;; Author & Identity
-    [:div.flag
-     [:p.text-xs.pr-2.flex.justify-between
-      [:small {:on-click #(when-let [^js el (js/document.querySelector ".cp__plugins-page .search-ctls input")]
-                           (reset! *search-key (str "@" author))
-                           (.select el))} author]
-      [:small {:on-click #(do
-                           (notification/show! "Copied!" :success)
-                           (util/copy-to-clipboard! id))}
-       (str "ID: " id)]]]
+      [:div.flag
+       [:p.text-xs.pr-2.flex.justify-between
+        [:small {:on-click #(when-let [^js el (js/document.querySelector ".cp__plugins-page .search-ctls input")]
+                              (reset! *search-key (str "@" author))
+                              (.select el))} author]
+        [:small {:on-click #(do
+                              (notification/show! "Copied!" :success)
+                              (util/copy-to-clipboard! id))}
+         (str "ID: " id)]]]
 
     ;; Github repo
-    [:div.flag.is-top.opacity-50
-     (when repo
-      [:a.flex {:target "_blank"
-                :href   (plugin-handler/gh-repo-url repo)}
-       (svg/github {:width 16 :height 16})])]
+      [:div.flag.is-top.opacity-50
+       (when repo
+         [:a.flex {:target "_blank"
+                   :href   (plugin-handler/gh-repo-url repo)}
+          (svg/github {:width 16 :height 16})])]
 
-    (if market?
+      (if market?
      ;; market ctls
-     (card-ctls-of-market item stat installed? installing-or-updating?)
+        (card-ctls-of-market item stat installed? installing-or-updating?)
 
      ;; installed ctls
-     (card-ctls-of-installed
-      id name url sponsors unpacked? disabled?
-      installing-or-updating? has-other-pending? new-version item))]]))
+        (card-ctls-of-installed
+         id name url sponsors unpacked? disabled?
+         installing-or-updating? has-other-pending? new-version item))]]))
 
 (rum/defc panel-tab-search < rum/static
   [search-key *search-key *search-ref]
@@ -606,17 +606,17 @@
                               :options {:on-click #(plugin-handler/user-check-enabled-for-updates! (not= :plugins category))}}])
 
                           (when (util/electron?)
-                           [{:title   [:span.flex.items-center.gap-1 (ui/icon "world") (t :settings-page/network-proxy)]
-                             :options {:on-click #(state/pub-event! [:go/proxy-settings agent-opts])}}
+                            [{:title   [:span.flex.items-center.gap-1 (ui/icon "world") (t :settings-page/network-proxy)]
+                              :options {:on-click #(state/pub-event! [:go/proxy-settings agent-opts])}}
 
-                            {:title   [:span.flex.items-center.gap-1 (ui/icon "arrow-down-circle") (t :plugin.install-from-file/menu-title)]
-                             :options {:on-click plugin-config-handler/open-replace-plugins-modal}}])
+                             {:title   [:span.flex.items-center.gap-1 (ui/icon "arrow-down-circle") (t :plugin.install-from-file/menu-title)]
+                              :options {:on-click plugin-config-handler/open-replace-plugins-modal}}])
 
                           [{:hr true}]
 
                           (when (and (state/developer-mode?)
                                      (util/electron?))
-                           [{:title [:span.flex.items-center.gap-1 (ui/icon "file-code") (t :plugin/open-preferences)]
+                            [{:title [:span.flex.items-center.gap-1 (ui/icon "file-code") (t :plugin/open-preferences)]
                               :options {:on-click
                                         #(p/let [root (plugin-handler/get-ls-dotdir-root)]
                                            (js/apis.openPath (str root "/preferences.json")))}}
@@ -1273,14 +1273,14 @@
                      :class (when (not market?) "active")
                      :size :sm
                      :variant :text}
-         (t :plugin/installed))
+                    (t :plugin/installed))
 
        (shui/button {:on-click #(set-active! :marketplace)
                      :class (when market? "active")
                      :size :sm
                      :variant :text}
-         (shui/tabler-icon "apps")
-         (t :plugin/marketplace))]]
+                    (shui/tabler-icon "apps")
+                    (t :plugin/marketplace))]]
 
      [:div.panels
       (if market?

+ 13 - 14
src/main/frontend/components/plugins_settings.cljs

@@ -1,13 +1,13 @@
 (ns frontend.components.plugins-settings
-  (:require [logseq.shui.ui :as shui]
-            [rum.core :as rum]
-            [frontend.util :as util]
-            [frontend.ui :as ui]
-            [frontend.handler.plugin :as plugin-handler]
+  (:require [cljs-bean.core :as bean]
             [frontend.components.lazy-editor :as lazy-editor]
             [frontend.handler.notification :as notification]
-            [cljs-bean.core :as bean]
-            [goog.functions :refer [debounce]]))
+            [frontend.handler.plugin :as plugin-handler]
+            [frontend.ui :as ui]
+            [frontend.util :as util]
+            [goog.functions :refer [debounce]]
+            [logseq.shui.ui :as shui]
+            [rum.core :as rum]))
 
 (defn- dom-purify
   [html opts]
@@ -85,8 +85,7 @@
          :radio (ui/radio-list options #(update-setting! key %) nil)
          :checkbox (ui/checkbox-list options #(update-setting! key %) nil)
          ;; select
-         (ui/select options (fn [_ value ] (update-setting! key value))))
-       ]]]))
+         (ui/select options (fn [_ value] (update-setting! key value))))]]]))
 
 (rum/defc render-item-object
   [_val {:keys [key title description _default]} pid]
@@ -144,16 +143,16 @@
           [:div.code-mode-wrap.pl-3.pr-1.py-1.mb-8.-ml-1
            (let [content' (js/JSON.stringify (bean/->js settings) nil 2)]
              (lazy-editor/editor {:file? false}
-               (str "code-edit-lsp-settings")
-               {:data-lang "json"}
-               content' {}))
+                                 (str "code-edit-lsp-settings")
+                                 {:data-lang "json"}
+                                 content' {}))
            [:div.flex.justify-end.pt-2.gap-2
             (shui/button {:size :sm :variant :ghost
                           :on-click (fn [^js e]
                                       (let [^js cm (util/get-cm-instance (-> (.-target e) (.closest ".code-mode-wrap")))
                                             content' (some-> (.toJSON plugin-settings) (js/JSON.stringify nil 2))]
                                         (.setValue cm content')))}
-              "Reset")
+                         "Reset")
             (shui/button {:size :sm
                           :on-click (fn [^js e]
                                       (try
@@ -164,7 +163,7 @@
                                           (set-edit-mode! nil))
                                         (catch js/Error e
                                           (notification/show! (.-message e) :error))))}
-              "Save")]]
+                         "Save")]]
 
           ;; render with gui items
           (for [desc schema

+ 5 - 5
src/main/frontend/components/query/view.cljs

@@ -2,13 +2,13 @@
   "DB query result view"
   (:require [frontend.components.views :as views]
             [frontend.db :as db]
-            [logseq.db :as ldb]
-            [rum.core :as rum]
             [frontend.mixins :as mixins]
-            [promesa.core :as p]
-            [frontend.modules.outliner.ui :as ui-outliner-tx]
             [frontend.modules.outliner.op :as outliner-op]
-            [frontend.state]))
+            [frontend.modules.outliner.ui :as ui-outliner-tx]
+            [frontend.state]
+            [logseq.db :as ldb]
+            [promesa.core :as p]
+            [rum.core :as rum]))
 
 (defn- columns
   [config result]

+ 8 - 8
src/main/frontend/components/right_sidebar.cljs

@@ -2,28 +2,28 @@
   (:require [cljs-bean.core :as bean]
             [clojure.string :as string]
             [frontend.components.block :as block]
+            [frontend.components.cmdk.core :as cmdk]
+            [frontend.components.icon :as icon]
             [frontend.components.onboarding :as onboarding]
             [frontend.components.page :as page]
+            [frontend.components.profiler :as profiler]
             [frontend.components.shortcut-help :as shortcut-help]
-            [frontend.components.cmdk.core :as cmdk]
             [frontend.context.i18n :refer [t]]
             [frontend.date :as date]
             [frontend.db :as db]
+            [frontend.db.rtc.debug-ui :as rtc-debug-ui]
             [frontend.extensions.slide :as slide]
             [frontend.handler.editor :as editor-handler]
+            [frontend.handler.route :as route-handler]
             [frontend.handler.ui :as ui-handler]
             [frontend.state :as state]
             [frontend.ui :as ui]
-            [logseq.shui.ui :as shui]
             [frontend.util :as util]
+            [logseq.db :as ldb]
+            [logseq.shui.ui :as shui]
             [medley.core :as medley]
             [reitit.frontend.easy :as rfe]
-            [rum.core :as rum]
-            [frontend.db.rtc.debug-ui :as rtc-debug-ui]
-            [frontend.handler.route :as route-handler]
-            [logseq.db :as ldb]
-            [frontend.components.icon :as icon]
-            [frontend.components.profiler :as profiler]))
+            [rum.core :as rum]))
 
 (rum/defc toggle
   []

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

@@ -644,8 +644,8 @@
      (when (util/electron?)
        (when (not= (boolean value) on?)
          (ui/button (t :plugin/restart)
-           :on-click #(js/logseq.api.relaunch)
-           :small? true :intent "logseq")))]))
+                    :on-click #(js/logseq.api.relaunch)
+                    :small? true :intent "logseq")))]))
 
 (rum/defc http-server-enabled-switcher
   [t]

+ 15 - 18
src/main/frontend/components/svg.cljs

@@ -2,15 +2,15 @@
   (:require [rum.core :as rum]))
 
 (defonce arrow-right-v2
-         [:svg.h-3.w-3
-          {:version  "1.1"
-           :view-box "0 0 128 128"
-           :fill     "currentColor"
-           :display  "inline-block"
-           :style    {:margin-top -3}}
-          [:path
-           {:d
-            "M99.069 64.173c0 2.027-.77 4.054-2.316 5.6l-55.98 55.98a7.92 7.92 0 01-11.196 0c-3.085-3.086-3.092-8.105 0-11.196l50.382-50.382-50.382-50.382a7.92 7.92 0 010-11.195c3.086-3.085 8.104-3.092 11.196 0l55.98 55.98a7.892 7.892 0 012.316 5.595z"}]])
+  [:svg.h-3.w-3
+   {:version  "1.1"
+    :view-box "0 0 128 128"
+    :fill     "currentColor"
+    :display  "inline-block"
+    :style    {:margin-top -3}}
+   [:path
+    {:d
+     "M99.069 64.173c0 2.027-.77 4.054-2.316 5.6l-55.98 55.98a7.92 7.92 0 01-11.196 0c-3.085-3.086-3.092-8.105 0-11.196l50.382-50.382-50.382-50.382a7.92 7.92 0 010-11.195c3.086-3.085 8.104-3.092 11.196 0l55.98 55.98a7.892 7.892 0 012.316 5.595z"}]])
 
 (defn loader-fn [opts]
   [:svg.animate-spin
@@ -46,8 +46,8 @@
    (hero-icon "M4 4V9H4.58152M19.9381 11C19.446 7.05369 16.0796 4 12 4C8.64262 4 5.76829 6.06817 4.58152 9M4.58152 9H9M20 20V15H19.4185M19.4185 15C18.2317 17.9318 15.3574 20 12 20C7.92038 20 4.55399 16.9463 4.06189 13M19.4185 15H15"
               (cond-> (merge {:fill "none"} opts)
 
-                      (number? size)
-                      (assoc :height size :width size)))))
+                (number? size)
+                (assoc :height size :width size)))))
 
 (def close (hero-icon "M6 18L18 6M6 6L18 18"))
 (def folder (hero-icon "M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"))
@@ -102,9 +102,9 @@
   ([opts]
    [:svg.h-8.w-8.warning
     (merge
-      {:view-box "0 0 576 512"
-       :fill     "var(--color-orange-600)"}
-      opts)
+     {:view-box "0 0 576 512"
+      :fill     "var(--color-orange-600)"}
+     opts)
     [:path
      {:d
       "M569.517 440.013C587.975 472.007 564.806 512 527.94 512H48.054c-36.937 0-59.999-40.055-41.577-71.987L246.423 23.985c18.467-32.009 64.72-31.951 83.154 0l239.94 416.028zM288 354c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z"}]]))
@@ -121,7 +121,6 @@
         C339.535,328.526,339.142,287.519,322.397,252.352z M201.513,216.553c0,0-16.568-16.568-21.323-21.035
         c37.027-10.806,61.375,4.323,61.375,4.323C218.946,192.781,201.513,216.553,201.513,216.553z"}]])
 
-
 (rum/defc caret-up
   []
   [:svg.h-4.w-4
@@ -132,7 +131,6 @@
     :display     "inline-block"}
    [:path {:d "M288.662 352H31.338c-17.818 0-26.741-21.543-14.142-34.142l128.662-128.662c7.81-7.81 20.474-7.81 28.284 0l128.662 128.662c12.6 12.599 3.676 34.142-14.142 34.142z"}]])
 
-
 (rum/defc caret-down
   []
   [:svg.h-4.w-4
@@ -198,12 +196,11 @@
    {:stroke "currentColor", :view-box "0 0 24 24", :fill "none"}
    [:path
     {:d
-                      "M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z",
+     "M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z",
      :stroke-width    "2",
      :stroke-linejoin "round",
      :stroke-linecap  "round"}]])
 
-
 (defn search2
   ([] (search2 nil))
   ([size]

+ 10 - 10
src/main/frontend/components/theme.cljs

@@ -1,20 +1,20 @@
 (ns frontend.components.theme
   (:require [electron.ipc :as ipc]
-            [frontend.extensions.pdf.core :as pdf]
+            [frontend.components.settings :as settings]
             [frontend.config :as config]
+            [frontend.context.i18n :refer [t]]
+            [frontend.extensions.pdf.core :as pdf]
             [frontend.handler.plugin :as plugin-handler]
             [frontend.handler.plugin-config :as plugin-config-handler]
             [frontend.handler.route :as route-handler]
             [frontend.handler.ui :as ui-handler]
-            [frontend.ui :as ui]
-            [logseq.shui.ui :as shui]
-            [frontend.util :as util]
-            [frontend.state :as state]
-            [frontend.components.settings :as settings]
             [frontend.rum :refer [use-mounted]]
+            [frontend.state :as state]
             [frontend.storage :as storage]
-            [rum.core :as rum]
-            [frontend.context.i18n :refer [t]]))
+            [frontend.ui :as ui]
+            [frontend.util :as util]
+            [logseq.shui.ui :as shui]
+            [rum.core :as rum]))
 
 (rum/defc scrollbar-measure
   []
@@ -87,8 +87,8 @@
      #(when config/lsp-enabled?
         (plugin-handler/load-plugin-preferences)
         (comp
-          (plugin-handler/setup-install-listener!)
-          (plugin-config-handler/setup-install-listener!)))
+         (plugin-handler/setup-install-listener!)
+         (plugin-config-handler/setup-install-listener!)))
      [])
 
     (rum/use-effect!

+ 7 - 7
src/main/frontend/config.cljs

@@ -5,13 +5,13 @@
             [frontend.mobile.util :as mobile-util]
             [frontend.state :as state]
             [frontend.util :as util]
-            [logseq.common.path :as path]
+            [goog.crypt :as crypt]
+            [goog.crypt.Md5]
             [logseq.common.config :as common-config]
+            [logseq.common.path :as path]
             [logseq.common.util :as common-util]
-            [shadow.resource :as rc]
-            [goog.crypt.Md5]
-            [goog.crypt :as crypt]
-            [logseq.db.sqlite.util :as sqlite-util]))
+            [logseq.db.sqlite.util :as sqlite-util]
+            [shadow.resource :as rc]))
 
 (goog-define DEV-RELEASE false)
 (defonce dev-release? DEV-RELEASE)
@@ -75,8 +75,8 @@
 ;; User level configuration for whether plugins are enabled
 (defonce lsp-enabled?
   (and util/plugin-platform?
-    (not (false? feature-plugin-system-on?))
-    (state/lsp-enabled?-or-theme)))
+       (not (false? feature-plugin-system-on?))
+       (state/lsp-enabled?-or-theme)))
 
 (defn plugin-config-enabled?
   []

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

@@ -1,15 +1,15 @@
 (ns frontend.db
   "Main entry ns for db related fns"
-  (:require [frontend.db.conn :as conn]
+  (:require [frontend.config :as config]
+            [frontend.db.conn :as conn]
             [frontend.db.model]
             [frontend.db.react :as react]
             [frontend.db.utils]
-            [frontend.namespaces :refer [import-vars]]
-            [logseq.db :as ldb]
-            [frontend.modules.outliner.ui :as ui-outliner-tx]
             [frontend.modules.outliner.op :as outliner-op]
+            [frontend.modules.outliner.ui :as ui-outliner-tx]
+            [frontend.namespaces :refer [import-vars]]
             [frontend.state :as state]
-            [frontend.config :as config]
+            [logseq.db :as ldb]
             [logseq.outliner.op]))
 
 (import-vars

+ 6 - 6
src/main/frontend/db/model.cljs

@@ -6,19 +6,19 @@
             [clojure.string :as string]
             [clojure.walk :as walk]
             [datascript.core :as d]
+            [frontend.config :as config]
             [frontend.date :as date]
             [frontend.db.conn :as conn]
             [frontend.db.react :as react]
             [frontend.db.utils :as db-utils]
             [frontend.state :as state]
             [frontend.util :as util :refer [react]]
-            [logseq.db.frontend.rules :as rules]
-            [logseq.db.frontend.content :as db-content]
-            [logseq.graph-parser.db :as gp-db]
             [logseq.common.util :as common-util]
             [logseq.common.util.date-time :as date-time-util]
-            [frontend.config :as config]
-            [logseq.db :as ldb]))
+            [logseq.db :as ldb]
+            [logseq.db.frontend.content :as db-content]
+            [logseq.db.frontend.rules :as rules]
+            [logseq.graph-parser.db :as gp-db]))
 
 ;; TODO: extract to specific models and move data transform logic to the
 ;; corresponding handlers.
@@ -204,7 +204,7 @@ independent of format as format specific heading characters are stripped"
      (or
       (let [page (some->> page-name (ldb/get-page (conn/get-db)))]
         (or
-         (:block/format page)
+         (get page :block/format :markdown)
          (when-let [file (:block/file page)]
            (when-let [path (:file/path (db-utils/entity (:db/id file)))]
              (common-util/get-format path)))))

+ 2 - 2
src/main/frontend/extensions/srs.cljs

@@ -771,9 +771,9 @@
    a seq of [original-block new-content-string]"
   [block]
   (when-let [content (:block/title block)]
-    (let [format (:block/format block)
+    (let [format (get block :block/format :markdown)
           content (-> (property-file/remove-built-in-properties-when-file-based
-                       (state/get-current-repo) (:block/format block) content)
+                       (state/get-current-repo) format content)
                       (drawer/remove-logbook))
           [title body] (mldoc/get-title&body content format)]
       [block (str title " #" card-hash-tag "\n" body)])))

+ 11 - 9
src/main/frontend/format/block.cljs

@@ -6,12 +6,12 @@
             [frontend.date :as date]
             [frontend.db :as db]
             [frontend.format :as format]
+            [frontend.format.mldoc :as mldoc]
             [frontend.handler.notification :as notification]
             [frontend.state :as state]
-            [logseq.graph-parser.block :as gp-block]
-            [logseq.graph-parser.property :as gp-property]
             [lambdaisland.glogi :as log]
-            [frontend.format.mldoc :as mldoc]))
+            [logseq.graph-parser.block :as gp-block]
+            [logseq.graph-parser.property :as gp-property]))
 
 (defn extract-blocks
   "Wrapper around logseq.graph-parser.block/extract-blocks that adds in system state
@@ -29,7 +29,7 @@ and handles unexpected failure."
                                              :db-graph-mode? (config/db-based-graph? repo)})]
         (if (config/db-based-graph? repo)
           (map (fn [block]
-                 (cond-> (dissoc block :block/properties :block/macros :block/properties-order)
+                 (cond-> (dissoc block :block/format :block/properties :block/macros :block/properties-order)
                    (:block/properties block)
                    (merge (update-keys (:block/properties block)
                                        (fn [k]
@@ -79,16 +79,18 @@ and handles unexpected failure."
           parse-config (mldoc/get-default-config format)
           ;; Disable extraction for display-type blocks as there isn't a reason to have
           ;; it enabled yet and can cause visible bugs when '#' is used
-          blocks (if (and (config/db-based-graph? (state/get-current-repo))
+          db-based? (config/db-based-graph? (state/get-current-repo))
+          blocks (if (and db-based?
                           (:logseq.property.node/display-type block))
                    [block]
                    (let [ast (format/to-edn title format parse-config)]
                      (extract-blocks ast title format {:parse-block block})))
           new-block (first blocks)
-          block (cond->
-                 (merge block new-block)
+          block (cond-> (merge block new-block)
                   (> (count blocks) 1)
-                  (assoc :block/warning :multiple-blocks))
+                  (assoc :block/warning :multiple-blocks)
+                  db-based?
+                  (dissoc :block/format))
           block (dissoc block :block.temp/ast-body :block/level)]
       (if uuid (assoc block :block/uuid uuid) block))))
 
@@ -97,7 +99,7 @@ and handles unexpected failure."
    (when (map? block)
      (merge block
             (parse-title-and-body (:block/uuid block)
-                                  (:block/format block)
+                                  (get block :block/format :markdown)
                                   (:block/pre-block? block)
                                   (:block/title block)))))
   ([block-uuid format pre-block? content]

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

@@ -1,7 +1,8 @@
 (ns frontend.handler
   "Main ns that handles application startup. Closest ns that we have to a
   system. Contains a couple of small system components"
-  (:require [electron.ipc :as ipc]
+  (:require [cljs-bean.core :as bean]
+            [electron.ipc :as ipc]
             [electron.listener :as el]
             [frontend.components.block :as block]
             [frontend.components.editor :as editor]
@@ -10,36 +11,35 @@
             [frontend.components.whiteboard :as whiteboard]
             [frontend.config :as config]
             [frontend.context.i18n :as i18n]
-            [frontend.db.restore :as db-restore]
             [frontend.db.react :as react]
+            [frontend.db.restore :as db-restore]
             [frontend.error :as error]
             [frontend.handler.command-palette :as command-palette]
             [frontend.handler.events :as events]
-            [frontend.handler.file-based.events]
             [frontend.handler.file :as file-handler]
+            [frontend.handler.file-based.events]
             [frontend.handler.global-config :as global-config-handler]
             [frontend.handler.notification :as notification]
             [frontend.handler.page :as page-handler]
             [frontend.handler.plugin-config :as plugin-config-handler]
             [frontend.handler.repo :as repo-handler]
             [frontend.handler.repo-config :as repo-config-handler]
+            [frontend.handler.test :as test]
             [frontend.handler.ui :as ui-handler]
             [frontend.handler.user :as user-handler]
             [frontend.idb :as idb]
+            [frontend.mobile.core :as mobile]
             [frontend.mobile.util :as mobile-util]
             [frontend.modules.instrumentation.core :as instrument]
             [frontend.modules.shortcut.core :as shortcut]
+            [frontend.persist-db :as persist-db]
+            [frontend.persist-db.browser :as db-browser]
             [frontend.state :as state]
             [frontend.util :as util]
             [frontend.util.persist-var :as persist-var]
             [goog.object :as gobj]
             [lambdaisland.glogi :as log]
-            [promesa.core :as p]
-            [frontend.mobile.core :as mobile]
-            [cljs-bean.core :as bean]
-            [frontend.handler.test :as test]
-            [frontend.persist-db.browser :as db-browser]
-            [frontend.persist-db :as persist-db]))
+            [promesa.core :as p]))
 
 (defn- set-global-error-notification!
   []

+ 13 - 13
src/main/frontend/handler/block.cljs

@@ -3,27 +3,27 @@
    [clojure.set :as set]
    [clojure.string :as string]
    [clojure.walk :as walk]
+   [datascript.impl.entity :as de]
+   [dommy.core :as dom]
+   [frontend.config :as config]
    [frontend.db :as db]
-   [logseq.db :as ldb]
    [frontend.db.model :as db-model]
+   [frontend.handler.file-based.property.util :as property-util]
+   [frontend.handler.property.util :as pu]
    [frontend.mobile.haptics :as haptics]
-   [logseq.outliner.core :as outliner-core]
-   [frontend.modules.outliner.ui :as ui-outliner-tx]
    [frontend.modules.outliner.op :as outliner-op]
-   [logseq.outliner.op]
+   [frontend.modules.outliner.ui :as ui-outliner-tx]
    [frontend.state :as state]
    [frontend.util :as util]
    [frontend.util.file-based.drawer :as drawer]
    [goog.dom :as gdom]
-   [logseq.graph-parser.block :as gp-block]
-   [logseq.db.sqlite.util :as sqlite-util]
-   [frontend.config :as config]
-   [frontend.handler.file-based.property.util :as property-util]
-   [frontend.handler.property.util :as pu]
-   [dommy.core :as dom]
    [goog.object :as gobj]
-   [promesa.core :as p]
-   [datascript.impl.entity :as de]))
+   [logseq.db :as ldb]
+   [logseq.db.sqlite.util :as sqlite-util]
+   [logseq.graph-parser.block :as gp-block]
+   [logseq.outliner.core :as outliner-core]
+   [logseq.outliner.op]
+   [promesa.core :as p]))
 
 ;;  Fns
 
@@ -242,7 +242,7 @@
 
                           :else
                           (subs content 0 pos))
-             content (sanity-block-content repo (:block/format block) content)]
+             content (sanity-block-content repo (get block :block/format :markdown) content)]
          (state/clear-selection!)
          (edit-block-aux repo block content text-range (assoc opts :pos pos)))))))
 

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

@@ -1,12 +1,12 @@
 (ns frontend.handler.command-palette
   "System-component-like ns for command palette's functionality"
   (:require [cljs.spec.alpha :as s]
-            [frontend.modules.shortcut.data-helper :as shortcut-helper]
             [frontend.handler.plugin :as plugin-handler]
+            [frontend.modules.shortcut.data-helper :as shortcut-helper]
             [frontend.spec :as spec]
             [frontend.state :as state]
-            [lambdaisland.glogi :as log]
-            [frontend.storage :as storage]))
+            [frontend.storage :as storage]
+            [lambdaisland.glogi :as log]))
 
 (s/def :command/id keyword?)
 (s/def :command/desc string?)

+ 3 - 2
src/main/frontend/handler/common/developer.cljs

@@ -71,7 +71,7 @@
 
 (defn ^:export show-block-ast []
   (if-let [{:block/keys [title format]} (:block (first (state/get-editor-args)))]
-    (show-content-ast title format)
+    (show-content-ast title (or format :markdown))
     (notification/show! "No block found" :warning)))
 
 (defn ^:export show-page-data []
@@ -85,7 +85,8 @@
     (let [page-data (db/pull '[:block/format {:block/file [:file/content]}]
                              (page-util/get-current-page-id))]
       (if (get-in page-data [:block/file :file/content])
-        (show-content-ast (get-in page-data [:block/file :file/content]) (:block/format page-data))
+        (show-content-ast (get-in page-data [:block/file :file/content])
+                          (get page-data :block/format :markdown))
         (notification/show! "No page found" :warning)))))
 
 (defn ^:export validate-db []

+ 32 - 32
src/main/frontend/handler/common/plugin.cljs

@@ -1,29 +1,29 @@
 (ns frontend.handler.common.plugin
   "Common plugin related fns for handlers and api"
-  (:require [frontend.state :as state]
+  (:require [cljs-bean.core :as bean]
+            [electron.ipc :as ipc]
+            [frontend.state :as state]
             [frontend.util :as util]
-            [promesa.core :as p]
-            [cljs-bean.core :as bean]
-            [electron.ipc :as ipc]))
+            [promesa.core :as p]))
 
 (defn get-web-plugin-checker-url!
   ([repo] (get-web-plugin-checker-url! repo ""))
   ([repo version]
    (util/node-path.join "https://plugins.logseq.io/r2"
-     repo (if (not (string? version)) "" version))))
+                        repo (if (not (string? version)) "" version))))
 
 (defn fetch-web-plugin-entry-info
   [repo version]
   (p/let [url (get-web-plugin-checker-url! repo version)
           ^js res (js/window.fetch url)]
     (if (and (.-ok res)
-          (= (.-status res) 200))
+             (= (.-status res) 200))
       (-> (.json res)
-        (p/then #(bean/->clj %)))
+          (p/then #(bean/->clj %)))
       (-> (.text res)
-        (p/then
-          (fn [error-text]
-            (throw (js/Error. (str "web-plugin-entry-error:" error-text)))))))))
+          (p/then
+           (fn [error-text]
+             (throw (js/Error. (str "web-plugin-entry-error:" error-text)))))))))
 
 (defn installed?
   "For the given plugin id, returns boolean indicating if it is installed"
@@ -39,28 +39,28 @@
   [{:keys [version repo only-check] :as manifest}]
   (js/console.log "[plugin]" (if only-check "Checking" "Installing") " #" repo)
   (-> (fetch-web-plugin-entry-info repo (if only-check "" version))
-    (p/then (fn [web-pkg]
-             (let [web-pkg (merge web-pkg (dissoc manifest :stat))
-                   latest-version (:version web-pkg)
-                   valid-latest-version (when only-check
-                                          (let [coerced-current-version (.coerce util/sem-ver version)
-                                                coerced-latest-version (.coerce util/sem-ver latest-version)]
-                                            (if (and coerced-current-version
-                                                  coerced-latest-version
-                                                  (util/sem-ver.lt coerced-current-version coerced-latest-version))
-                                              latest-version
-                                              (throw (js/Error. :no-new-version)))))]
-              (emit-lsp-updates!
-                {:status :completed
-                 :only-check only-check
-                 :payload (if only-check
-                            (assoc manifest :latest-version valid-latest-version  :latest-notes "TODO: update notes")
-                            (assoc manifest :dst repo :version latest-version :web-pkg web-pkg))}))))
-    (p/catch (fn [^js e]
-               (emit-lsp-updates!
-                 {:status :error
-                  :only-check only-check
-                  :payload (assoc manifest :error-code (.-message e))})))))
+      (p/then (fn [web-pkg]
+                (let [web-pkg (merge web-pkg (dissoc manifest :stat))
+                      latest-version (:version web-pkg)
+                      valid-latest-version (when only-check
+                                             (let [coerced-current-version (.coerce util/sem-ver version)
+                                                   coerced-latest-version (.coerce util/sem-ver latest-version)]
+                                               (if (and coerced-current-version
+                                                        coerced-latest-version
+                                                        (util/sem-ver.lt coerced-current-version coerced-latest-version))
+                                                 latest-version
+                                                 (throw (js/Error. :no-new-version)))))]
+                  (emit-lsp-updates!
+                   {:status :completed
+                    :only-check only-check
+                    :payload (if only-check
+                               (assoc manifest :latest-version valid-latest-version  :latest-notes "TODO: update notes")
+                               (assoc manifest :dst repo :version latest-version :web-pkg web-pkg))}))))
+      (p/catch (fn [^js e]
+                 (emit-lsp-updates!
+                  {:status :error
+                   :only-check only-check
+                   :payload (assoc manifest :error-code (.-message e))})))))
 
 (defn install-marketplace-plugin!
   "Installs plugin given plugin map with id"

+ 8 - 8
src/main/frontend/handler/config.cljs

@@ -1,13 +1,13 @@
 (ns frontend.handler.config
   "Fns for setting repo config"
-  (:require [clojure.string :as string]
-            [frontend.state :as state]
+  (:require [borkdude.rewrite-edn :as rewrite]
+            [clojure.string :as string]
+            [frontend.config :as config]
+            [frontend.db :as db]
+            [frontend.handler.db-based.editor :as db-editor-handler]
             [frontend.handler.file :as file-handler]
             [frontend.handler.repo-config :as repo-config-handler]
-            [frontend.handler.db-based.editor :as db-editor-handler]
-            [frontend.db :as db]
-            [borkdude.rewrite-edn :as rewrite]
-            [frontend.config :as config]))
+            [frontend.state :as state]))
 
 (defn parse-repo-config
   "Parse repo configuration file content"
@@ -22,8 +22,8 @@
       (let [result (parse-repo-config (if (string/blank? content) "{}" content))
             ks (if (vector? k) k [k])
             v (cond->> v
-                       (map? v)
-                       (reduce-kv (fn [a k v] (rewrite/assoc a k v)) (rewrite/parse-string "{}")))
+                (map? v)
+                (reduce-kv (fn [a k v] (rewrite/assoc a k v)) (rewrite/parse-string "{}")))
             new-result (rewrite/assoc-in result ks v)
             new-content (str new-result)]
         (if (config/db-based-graph? repo)

+ 2 - 1
src/main/frontend/handler/db_based/editor.cljs

@@ -57,7 +57,8 @@
                       block-with-title? (mldoc/block-with-title? first-elem-type)
                       content' (str (config/get-block-pattern :markdown) (if block-with-title? " " "\n") title)
                       parsed-block (block/parse-block (assoc block :block/title content'))
-                      block' (merge block parsed-block {:block/title title})]
+                      block' (-> (merge block parsed-block {:block/title title})
+                                 (dissoc :block/format))]
                   (update block' :block/refs
                           (fn [refs]
                             (-> refs

+ 8 - 8
src/main/frontend/handler/dnd.cljs

@@ -1,14 +1,14 @@
 (ns frontend.handler.dnd
   "Provides fns for drag and drop"
-  (:require [frontend.handler.editor :as editor-handler]
+  (:require [frontend.db :as db]
+            [frontend.handler.block :as block-handler]
+            [frontend.handler.editor :as editor-handler]
             [frontend.handler.property :as property-handler]
-            [logseq.db :as ldb]
-            [frontend.modules.outliner.ui :as ui-outliner-tx]
             [frontend.modules.outliner.op :as outliner-op]
-            [logseq.common.util.block-ref :as block-ref]
+            [frontend.modules.outliner.ui :as ui-outliner-tx]
             [frontend.state :as state]
-            [frontend.db :as db]
-            [frontend.handler.block :as block-handler]))
+            [logseq.common.util.block-ref :as block-ref]
+            [logseq.db :as ldb]))
 
 (defn move-blocks
   [^js event blocks target-block original-block move-to]
@@ -18,8 +18,8 @@
         top? (= move-to :top)
         nested? (= move-to :nested)
         alt-key? (and event (.-altKey event))
-        current-format (:block/format first-block)
-        target-format (:block/format target-block)
+        current-format (get first-block :block/format :markdown)
+        target-format (get target-block :block/format :markdown)
         target-block (if nested? target-block
                          (or original-block target-block))]
     (cond

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

@@ -134,7 +134,7 @@
              :selection-end selection-end
              :selection (some-> selection
                                 string/trim)
-             :format (:block/format block)
+             :format (get block :block/format :markdown)
              :value value
              :block block
              :edit-id edit-id
@@ -173,7 +173,7 @@
 
 (defn highlight-format! []
   (when-let [block (state/get-edit-block)]
-    (let [format (:block/format block)]
+    (let [format (get block :block/format :markdown)]
       (format-text! #(config/get-highlight format)))))
 
 (defn strike-through-format! []
@@ -283,6 +283,7 @@
     {:keys [force?]
      :as opts}]
    (let [{:block/keys [uuid format repo title properties]} block
+         format (or format :markdown)
          repo (or repo (state/get-current-repo))
          format (or format (state/get-preferred-format))
          block-id (when (and (not (config/db-based-graph? repo)) (map? properties))
@@ -526,7 +527,7 @@
                  edit-block? true}}]
   (when (or page block-uuid)
     (let [repo (state/get-current-repo)
-          db-base? (config/db-based-graph? repo)
+          db-based? (config/db-based-graph? repo)
           before? (if page false before?)
           sibling? (boolean sibling?)
           sibling? (if before? true (if page false sibling?))
@@ -541,15 +542,17 @@
                              (when last-block-id
                                (db/entity last-block-id))))
               format (or
-                      (:block/format block)
+                      (get block :block/format :markdown)
                       (db/get-page-format (:block/name block))
                       (state/get-preferred-format))
-              content (if (and (not db-base?) (seq properties))
+              content (if (and (not db-based?) (seq properties))
                         (property-file/insert-properties-when-file-based repo format content properties)
                         content)
-              new-block (-> (select-keys block [:block/page])
-                            (assoc :block/title content
-                                   :block/format format))
+              new-block (cond->
+                         (-> (select-keys block [:block/page])
+                             (assoc :block/title content))
+                          (not db-based?)
+                          (assoc :block/format format))
               new-block (assoc new-block :block/page
                                (if page
                                  (:db/id block)
@@ -586,7 +589,7 @@
                                                             :keep-uuid? true
                                                             :ordered-list? ordered-list?
                                                             :replace-empty-target? replace-empty-target?})
-              (when (and db-base? (seq properties))
+              (when (and db-based? (seq properties))
                 (property-handler/set-block-properties! repo (:block/uuid new-block) properties)))
              (when edit-block?
                (if (and replace-empty-target?
@@ -602,7 +605,7 @@
       (when-let [page (db/get-page page-title)]
         (let [class-or-property? (or (ldb/class? page) (ldb/property? page))]
           (when (or class-or-property? (db/page-empty? (state/get-current-repo) (:db/id page)))
-            (let [format (or (:block/format page) (state/get-preferred-format))
+            (let [format (get page :block/format :markdown)
                   new-block {:block/title ""
                              :block/format format}]
               (ui-outliner-tx/transact!
@@ -857,7 +860,7 @@
         (outliner-op/delete-blocks! blocks' nil))
        (when sibling-block
          (let [{:keys [edit-block-f]} (move-to-prev-block repo sibling-block
-                                                          (:block/format block)
+                                                          (get block :block/format :markdown)
                                                           "")]
            (when edit-block-f (edit-block-f))))))))
 
@@ -963,7 +966,7 @@
                                                       [k v'])) b)
                                              (into {}))
                                         (assoc :db/id (:db/id b)))))))]
-          (common-handler/copy-to-clipboard-without-id-property! repo (:block/format block) content (when html? html) copied-blocks))
+          (common-handler/copy-to-clipboard-without-id-property! repo (get block :block/format :markdown) content (when html? html) copied-blocks))
         (state/set-block-op-type! :copy)
         (notification/show! "Copied!" :success)))))
 
@@ -997,7 +1000,7 @@
                             (map (fn [{:keys [id level]}]
                                    (if (config/db-based-graph? (state/get-current-repo))
                                      (str (string/join (repeat (dec level) "\t")) "- " (page-ref/->page-ref id))
-                                     (condp = (:block/format block)
+                                     (condp = (get block :block/format :markdown)
                                        :org
                                        (str (string/join (repeat level "*")) " " (block-ref/->block-ref id))
                                        :markdown
@@ -1193,7 +1196,7 @@
           [_top-level-block-uuids md-content] (compose-copied-blocks-contents repo [block-id])
           html (export-html/export-blocks-as-html repo [block-id] nil)
           sorted-blocks (tree/get-sorted-block-and-children repo (:db/id block))]
-      (common-handler/copy-to-clipboard-without-id-property! repo (:block/format block) md-content html sorted-blocks)
+      (common-handler/copy-to-clipboard-without-id-property! repo (get block :block/format :markdown) md-content html sorted-blocks)
       (state/set-block-op-type! :cut)
       (delete-block-aux! block))))
 
@@ -1289,7 +1292,7 @@
      (save-block!
       {:block block :repo repo :opts (dissoc opts :properties)}
       (if (seq properties)
-        (property-file/insert-properties-when-file-based repo (:block/format block) content properties)
+        (property-file/insert-properties-when-file-based repo (get block :block/format :markdown) content properties)
         content))))
   ([{:keys [block repo opts] :as _state} value]
    (let [repo (or repo (state/get-current-repo))]
@@ -2057,14 +2060,14 @@
     (merge (apply dissoc block (conj (when-not keep-uuid? [:block/_refs]) :block/pre-block? :block/meta))
            (cond->
             {:block/page {:db/id (:db/id page)}
-             :block/format format
              :block/title new-content}
              (not db-based?)
              (assoc :block/properties (apply dissoc (:block/properties block)
                                              (concat
                                               (when-not keep-uuid? [:id])
                                               [:custom_id :custom-id]
-                                              exclude-properties)))
+                                              exclude-properties))
+                    :block/format format)
              (not db-based?)
              (assoc :block/properties-text-values (apply dissoc (:block/properties-text-values block)
                                                          (concat
@@ -2134,7 +2137,7 @@
                            {:outliner-op :insert-blocks
                             :additional-tx revert-cut-txs}
                            (when target-block'
-                             (let [format (or (:block/format target-block') (state/get-preferred-format))
+                             (let [format (get target-block' :block/format :markdown)
                                    repo (state/get-current-repo)
                                    blocks' (map (fn [block]
                                                   (paste-block-cleanup repo block page exclude-properties format content-update-fn keep-uuid?))
@@ -2218,7 +2221,7 @@
          (when (:db/id block)
            (let [journal? (ldb/journal? target)
                  target (or target (state/get-edit-block))
-                 format (:block/format block)
+                 format (get block :block/format :markdown)
                  block-uuid (:block/uuid block)
                  template-including-parent? (not (false? (:template-including-parent (:block/properties block))))
                  blocks (db/get-block-and-children repo block-uuid)
@@ -2363,7 +2366,7 @@
       (when block
         (let [input (state/get-input)
               content (gobj/get input "value")
-              format (:block/format (:block (get-state)))
+              format (get (:block (get-state)) :block/format :markdown)
               property-key (:raw-content (thingatpt/property-key-at-point input))
               org? (= format :org)
               move-to-pos (if org? 2 3)]
@@ -2643,7 +2646,8 @@
               :down util/get-next-block-non-collapsed)
           current-block (util/rec-get-node input "ls-block")
           sibling-block (f current-block {:up-down? true})
-          {:block/keys [uuid title format]} (state/get-edit-block)]
+          {:block/keys [uuid title format]} (state/get-edit-block)
+          format (or format :markdown)]
       (if sibling-block
         (when-let [sibling-block-id (dom/attr sibling-block "blockid")]
           (let [container-id (some-> (dom/attr sibling-block "containerid") js/parseInt)
@@ -2693,6 +2697,7 @@
   (let [up? (= :left direction)
         pos (if up? :max 0)
         {:block/keys [format uuid] :as block} (or block (state/get-edit-block))
+        format (or format :markdown)
         repo (state/get-current-repo)
         editing-block (gdom/getElement (state/get-editing-block-dom-id))
         f (if up? util/get-prev-block-non-collapsed util/get-next-block-non-collapsed)
@@ -3486,7 +3491,7 @@
                         (file-editor-handler/valid-custom-query-block? block)))
                (and
                 (:outliner/block-title-collapse-enabled? (state/get-config))
-                (block-with-title? (:block/format block)
+                (block-with-title? (get block :block/format :markdown)
                                    (:block/title block)
                                    semantic?))))
          false)))))
@@ -3844,7 +3849,7 @@
     (when-let [{:keys [start end link]} (thingatpt/block-ref-at-point)]
       (when-let [block (db/entity [:block/uuid link])]
         (let [block-content (:block/title block)
-              format (or (:block/format block) :markdown)
+              format (get block :block/format :markdown)
               block-content-without-prop (-> (property-file/remove-properties-when-file-based repo format block-content)
                                              (drawer/remove-logbook))]
           (when-let [input (state/get-input)]
@@ -3876,7 +3881,8 @@
           match (block-ref/->block-ref ref-id)
           ref-block (db/entity [:block/uuid ref-id])
           block-ref-content (->> (or (:block/title ref-block) "")
-                                 (property-file/remove-built-in-properties-when-file-based repo (:block/format ref-block))
+                                 (property-file/remove-built-in-properties-when-file-based repo
+                                                                                           (get ref-block :block/format :markdown))
                                  (drawer/remove-logbook))
           content (string/replace-first (:block/title block) match
                                         block-ref-content)]

+ 3 - 4
src/main/frontend/handler/export/html.cljs

@@ -5,13 +5,12 @@
             [clojure.string :as string]
             [clojure.zip :as z]
             [frontend.db :as db]
+            [frontend.format.mldoc :as mldoc]
             [frontend.handler.export.common :as common :refer [*state*]]
             [frontend.handler.export.zip-helper :refer [get-level goto-last
                                                         goto-level]]
-            [frontend.state :as state]
             [frontend.util :as util :refer [concatv mapcatv removev]]
             [hiccups.runtime :as h]
-            [frontend.format.mldoc :as mldoc]
             [malli.core :as m]))
 
 (def ^:private hiccup-malli-schema
@@ -425,8 +424,8 @@
           (common/get-page-content root-block-uuids-or-page-uuid)
           (common/root-block-uuids->content repo root-block-uuids-or-page-uuid))
         first-block (and (coll? root-block-uuids-or-page-uuid)
-                          (db/entity [:block/uuid (first root-block-uuids-or-page-uuid)]))
-        format (or (:block/format first-block) (state/get-preferred-format))]
+                         (db/entity [:block/uuid (first root-block-uuids-or-page-uuid)]))
+        format (get first-block :block/format :markdown)]
     (export-helper content format options)))
 
 ;;; export fns (ends)

+ 4 - 7
src/main/frontend/handler/export/opml.cljs

@@ -4,19 +4,18 @@
   (:require ["/frontend/utils" :as utils]
             [clojure.string :as string]
             [clojure.zip :as z]
+            [frontend.config :as config]
             [frontend.db :as db]
             [frontend.extensions.zip :as zip]
+            [frontend.format.mldoc :as mldoc]
             [frontend.handler.export.common :as common :refer
              [*state* raw-text simple-asts->string space]]
             [frontend.handler.export.zip-helper :refer [get-level goto-last
                                                         goto-level]]
-            [frontend.state :as state]
             [frontend.util :as util :refer [concatv mapcatv removev]]
             [goog.dom :as gdom]
             [hiccups.runtime :as h]
-            [frontend.format.mldoc :as mldoc]
-            [promesa.core :as p]
-            [frontend.config :as config]))
+            [promesa.core :as p]))
 
 ;;; *opml-state*
 (def ^:private ^:dynamic
@@ -151,7 +150,6 @@
            (mapcatv (fn [inline] (cons space (inline-ast->simple-ast inline))) inline-coll)
            [(raw-text "}")]))
 
-
 (defn- inline-superscript
   [inline-coll]
   (concatv [(raw-text "^{")]
@@ -215,7 +213,6 @@
   [{:keys [local_part domain]}]
   [(raw-text (str "<" local_part "@" domain ">"))])
 
-
 (defn- inline-ast->simple-ast
   [inline]
   (let [[ast-type ast-content] inline]
@@ -448,7 +445,7 @@
                  "untitled")
          first-block (and (coll? root-block-uuids-or-page-uuid)
                           (db/entity [:block/uuid (first root-block-uuids-or-page-uuid)]))
-         format (or (:block/format first-block) (state/get-preferred-format))]
+         format (get first-block :block/format :markdown)]
      (export-helper content format options :title title))))
 
 (defn- export-files-as-opml

+ 7 - 9
src/main/frontend/handler/export/text.cljs

@@ -2,19 +2,18 @@
   "export blocks/pages as text"
   (:refer-clojure :exclude [map filter mapcat concat remove newline])
   (:require [clojure.string :as string]
+            [frontend.config :as config]
             [frontend.db :as db]
             [frontend.extensions.zip :as zip]
+            [frontend.format.mldoc :as mldoc]
             [frontend.handler.export.common :as common :refer
              [*state* indent newline* raw-text simple-ast-malli-schema
               simple-asts->string space]]
-            [logseq.graph-parser.schema.mldoc :as mldoc-schema]
-            [frontend.state :as state]
             [frontend.util :as util :refer [concatv mapcatv removev]]
             [goog.dom :as gdom]
-            [frontend.format.mldoc :as mldoc]
+            [logseq.graph-parser.schema.mldoc :as mldoc-schema]
             [malli.core :as m]
-            [promesa.core :as p]
-            [frontend.config :as config]))
+            [promesa.core :as p]))
 
 ;;; block-ast, inline-ast -> simple-ast
 
@@ -67,7 +66,7 @@
                      ""))
         current-level (get *state* :current-level 1)
         indent' (when (> current-level 1)
-                 (indent (dec current-level) 0))
+                  (indent (dec current-level) 0))
         items* (block-list items :in-list? true)]
     (concatv [indent' number* checkbox* space]
              content*
@@ -503,7 +502,6 @@
             simple-asts (mapcatv block-ast->simple-ast ast***)]
         (simple-asts->string simple-asts)))))
 
-
 (defn export-blocks-as-markdown
   "options:
   :indent-style \"dashes\" | \"spaces\" | \"no-indent\"
@@ -521,8 +519,8 @@
              (common/get-page-content root-block-uuids-or-page-uuid)
              (common/root-block-uuids->content repo root-block-uuids-or-page-uuid))
            first-block (and (coll? root-block-uuids-or-page-uuid)
-                          (db/entity [:block/uuid (first root-block-uuids-or-page-uuid)]))
-           format (or (:block/format first-block) (state/get-preferred-format))]
+                            (db/entity [:block/uuid (first root-block-uuids-or-page-uuid)]))
+           format (get first-block :block/format :markdown)]
        (export-helper content format options))
      (catch :default e
        (js/console.error e)))))

+ 16 - 16
src/main/frontend/handler/file_based/editor.cljs

@@ -1,29 +1,29 @@
 (ns frontend.handler.file-based.editor
   "File-based graph implementation"
   (:require [clojure.string :as string]
-            [frontend.config :as config]
             [frontend.commands :as commands]
+            [frontend.config :as config]
             [frontend.date :as date]
-            [frontend.format.block :as block]
             [frontend.db :as db]
             [frontend.db.query-dsl :as query-dsl]
+            [frontend.format.block :as block]
             [frontend.format.mldoc :as mldoc]
-            [frontend.state :as state]
+            [frontend.handler.block :as block-handler]
+            [frontend.handler.file-based.property :as file-property-handler]
+            [frontend.handler.file-based.property.util :as property-util]
+            [frontend.handler.file-based.repeated :as repeated]
+            [frontend.handler.file-based.status :as status]
+            [frontend.handler.property.file :as property-file]
             [frontend.modules.outliner.op :as outliner-op]
             [frontend.modules.outliner.ui :as ui-outliner-tx]
+            [frontend.state :as state]
             [frontend.util :as util]
             [frontend.util.file-based.clock :as clock]
             [frontend.util.file-based.drawer :as drawer]
-            [frontend.handler.file-based.repeated :as repeated]
-            [frontend.handler.block :as block-handler]
-            [frontend.handler.file-based.status :as status]
-            [frontend.handler.property.file :as property-file]
-            [frontend.handler.file-based.property :as file-property-handler]
-            [frontend.handler.file-based.property.util :as property-util]
-            [logseq.db.frontend.schema :as db-schema]
-            [logseq.common.util.block-ref :as block-ref]
             [logseq.common.util :as common-util]
-            [logseq.db :as ldb]))
+            [logseq.common.util.block-ref :as block-ref]
+            [logseq.db :as ldb]
+            [logseq.db.frontend.schema :as db-schema]))
 
 (defn- remove-non-existed-refs!
   [refs]
@@ -67,7 +67,7 @@
   [block value]
   (if (and (state/enable-timetracking?)
            (not= (:block/title block) value))
-    (let [format (:block/format block)
+    (let [format (get block :block/format :markdown)
           new-marker (last (util/safe-re-find (status/marker-pattern format) (or value "")))
           new-value (with-marker-time value block format
                       new-marker
@@ -140,7 +140,7 @@
   (when-let [block (cond (string? block-or-id) (db/entity [:block/uuid (uuid block-or-id)])
                          (uuid? block-or-id) (db/entity [:block/uuid block-or-id])
                          :else block-or-id)]
-    (let [format (:block/format block)
+    (let [format (get block :block/format :markdown)
           content (:block/title block)
           properties (:block/properties block)
           properties (if (nil? value)
@@ -158,7 +158,7 @@
 (defn- set-heading-aux!
   [block-id heading]
   (let [block (db/pull [:block/uuid block-id])
-        format (:block/format block)
+        format (get block :block/format :markdown)
         old-heading (get-in block [:block/properties :heading])]
     (if (= format :markdown)
       (cond
@@ -240,7 +240,7 @@
     (when content
       (when (and (string/includes? content "#+BEGIN_QUERY")
                  (string/includes? content "#+END_QUERY"))
-        (let [ast (mldoc/->edn (string/trim content) (or (:block/format entity) :markdown))
+        (let [ast (mldoc/->edn (string/trim content) (get entity :block/format :markdown))
               q (mldoc/extract-first-query-from-ast ast)]
           (some? (:query (common-util/safe-read-map-string q))))))))
 

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

@@ -32,7 +32,7 @@
               new-properties (zipmap (map second items)
                                      (map last items))]
           (when-let [block (db/entity [:block/uuid block-id])]
-            (let [format (:block/format block)
+            (let [format (get block :block/format :markdown)
                   content (:block/title block)
                   properties (:block/properties block)
                   properties-text-values (:block/properties-text-values block)

+ 18 - 16
src/main/frontend/handler/paste.cljs

@@ -1,25 +1,25 @@
 (ns ^:no-doc frontend.handler.paste
-  (:require [frontend.state :as state]
+  (:require ["/frontend/utils" :as utils]
+            [clojure.string :as string]
+            [frontend.commands :as commands]
+            [frontend.config :as config]
             [frontend.db :as db]
+            [frontend.extensions.html-parser :as html-parser]
             [frontend.format.block :as block]
-            [logseq.common.util :as common-util]
-            [logseq.graph-parser.block :as gp-block]
-            [logseq.common.util.block-ref :as block-ref]
-            [clojure.string :as string]
-            [frontend.util :as util]
+            [frontend.format.mldoc :as mldoc]
             [frontend.handler.editor :as editor-handler]
-            [frontend.extensions.html-parser :as html-parser]
-            [goog.object :as gobj]
             [frontend.mobile.util :as mobile-util]
-            [frontend.util.thingatpt :as thingatpt]
-            ["/frontend/utils" :as utils]
-            [frontend.commands :as commands]
+            [frontend.state :as state]
+            [frontend.util :as util]
             [frontend.util.text :as text-util]
-            [frontend.format.mldoc :as mldoc]
+            [frontend.util.thingatpt :as thingatpt]
+            [goog.object :as gobj]
             [lambdaisland.glogi :as log]
-            [promesa.core :as p]
-            [frontend.config :as config]
-            [logseq.db.frontend.content :as db-content]))
+            [logseq.common.util :as common-util]
+            [logseq.common.util.block-ref :as block-ref]
+            [logseq.db.frontend.content :as db-content]
+            [logseq.graph-parser.block :as gp-block]
+            [promesa.core :as p]))
 
 (defn- paste-text-parseable
   [format text]
@@ -235,7 +235,9 @@
       (loop [files files]
         (when-let [file (first files)]
           (when-let [block (state/get-edit-block)]
-            (editor-handler/upload-asset! id #js[file] (:block/format block) editor-handler/*asset-uploading? true))
+            (editor-handler/upload-asset! id #js[file]
+                                          (get block :block/format :markdown)
+                                          editor-handler/*asset-uploading? true))
           (recur (rest files))))
       (util/stop e))))
 

+ 188 - 190
src/main/frontend/handler/plugin.cljs

@@ -1,39 +1,39 @@
 (ns frontend.handler.plugin
   "System-component-like ns that provides all high level plugin functionality"
-  (:require [promesa.core :as p]
-            [rum.core :as rum]
-            [frontend.util :as util]
+  (:require [camel-snake-kebab.core :as csk]
+            [cljs-bean.core :as bean]
+            [clojure.string :as string]
             [clojure.walk :as walk]
-            [logseq.graph-parser.mldoc :as gp-mldoc]
-            [frontend.handler.notification :as notification]
+            [electron.ipc :as ipc]
+            [frontend.components.svg :as svg]
+            [frontend.config :as config]
+            [frontend.context.i18n :refer [t]]
+            [frontend.format :as format]
+            [frontend.fs :as fs]
             [frontend.handler.common.plugin :as plugin-common-handler]
+            [frontend.handler.notification :as notification]
+            [frontend.idb :as idb]
             [frontend.modules.shortcut.utils :as shortcut-utils]
-            [frontend.storage :as storage]
-            [camel-snake-kebab.core :as csk]
             [frontend.state :as state]
-            [medley.core :as medley]
-            [frontend.fs :as fs]
-            [frontend.idb :as idb]
-            [electron.ipc :as ipc]
-            [cljs-bean.core :as bean]
-            [clojure.string :as string]
+            [frontend.storage :as storage]
+            [frontend.util :as util]
             [lambdaisland.glogi :as log]
-            [frontend.components.svg :as svg]
+            [logseq.graph-parser.mldoc :as gp-mldoc]
             [logseq.shui.ui :as shui]
-            [frontend.context.i18n :refer [t]]
-            [frontend.config :as config]
-            [frontend.format :as format]))
+            [medley.core :as medley]
+            [promesa.core :as p]
+            [rum.core :as rum]))
 
 (defn- normalize-keyword-for-json
   [input]
   (when input
     (let [f (fn [[k v]] (if (keyword? k) [(csk/->camelCase (name k)) v] [k v]))]
       (walk/postwalk
-        (fn [x]
-          (cond
-            (map? x) (into {} (map f x))
-            (uuid? x) (str x)
-            :else x)) input))))
+       (fn [x]
+         (cond
+           (map? x) (into {} (map f x))
+           (uuid? x) (str x)
+           :else x)) input))))
 
 (defn invoke-exported-api
   [type & args]
@@ -58,7 +58,7 @@
 (defn setup-global-apis-for-web!
   []
   (when (and util/web-platform?
-          (nil? js/window.apis))
+             (nil? js/window.apis))
     (let [^js e (js/window.EventEmitter3.)]
       (set! (. js/window -apis) e))))
 
@@ -70,19 +70,19 @@
 (defn load-plugin-preferences
   []
   (-> (invoke-exported-api :load_user_preferences)
-    (p/then #(bean/->clj %))
-    (p/then #(state/set-state! :plugin/preferences %))
-    (p/catch
-     #(js/console.error %))))
+      (p/then #(bean/->clj %))
+      (p/then #(state/set-state! :plugin/preferences %))
+      (p/catch
+       #(js/console.error %))))
 
 (defn save-plugin-preferences!
   ([input] (save-plugin-preferences! input true))
   ([input reload-state?]
    (when-let [^js input (and (map? input) (bean/->js input))]
      (p/then
-       (js/LSPluginCore.saveUserPreferences input)
-       #(when reload-state?
-          (load-plugin-preferences))))))
+      (js/LSPluginCore.saveUserPreferences input)
+      #(when reload-state?
+         (load-plugin-preferences))))))
 
 (defn gh-repo-url [repo]
   (str "https://github.com/" repo))
@@ -96,66 +96,66 @@
   [refresh?]
   (if (or refresh? (nil? (:plugin/marketplace-pkgs @state/state)))
     (p/create
-      (fn [resolve reject]
-        (let [on-ok (fn [res]
-                      (if-let [res (and res (bean/->clj res))]
-                        (let [pkgs (:packages res)
-                              pkgs (if (util/electron?) pkgs
-                                     (some->> pkgs (filterv #(or (true? (:web %)) (not (true? (:effect %)))))))]
-                          (state/set-state! :plugin/marketplace-pkgs pkgs)
-                          (resolve pkgs))
-                        (reject nil)))]
-          (if (state/http-proxy-enabled-or-val?)
-            (-> (ipc/ipc :httpFetchJSON plugins-url)
-              (p/then on-ok)
-              (p/catch reject))
-            (util/fetch plugins-url on-ok reject)))))
+     (fn [resolve reject]
+       (let [on-ok (fn [res]
+                     (if-let [res (and res (bean/->clj res))]
+                       (let [pkgs (:packages res)
+                             pkgs (if (util/electron?) pkgs
+                                      (some->> pkgs (filterv #(or (true? (:web %)) (not (true? (:effect %)))))))]
+                         (state/set-state! :plugin/marketplace-pkgs pkgs)
+                         (resolve pkgs))
+                       (reject nil)))]
+         (if (state/http-proxy-enabled-or-val?)
+           (-> (ipc/ipc :httpFetchJSON plugins-url)
+               (p/then on-ok)
+               (p/catch reject))
+           (util/fetch plugins-url on-ok reject)))))
     (p/resolved (:plugin/marketplace-pkgs @state/state))))
 
 (defn load-marketplace-stats
   [refresh?]
   (if (or refresh? (nil? (:plugin/marketplace-stats @state/state)))
     (p/create
-      (fn [resolve reject]
-        (let [on-ok (fn [^js res]
-                      (if-let [res (and res (bean/->clj res))]
-                        (do
-                          (state/set-state!
-                            :plugin/marketplace-stats
-                            (into {} (map (fn [[k stat]]
-                                            [k (assoc stat
-                                                 :total_downloads
-                                                 (reduce (fn [a b] (+ a (get b 2))) 0 (:releases stat)))])
-                                       res)))
-                          (resolve nil))
-                        (reject nil)))]
-          (if (state/http-proxy-enabled-or-val?)
-            (-> (ipc/ipc :httpFetchJSON stats-url)
-              (p/then on-ok)
-              (p/catch reject))
-            (util/fetch stats-url on-ok reject)))))
+     (fn [resolve reject]
+       (let [on-ok (fn [^js res]
+                     (if-let [res (and res (bean/->clj res))]
+                       (do
+                         (state/set-state!
+                          :plugin/marketplace-stats
+                          (into {} (map (fn [[k stat]]
+                                          [k (assoc stat
+                                                    :total_downloads
+                                                    (reduce (fn [a b] (+ a (get b 2))) 0 (:releases stat)))])
+                                        res)))
+                         (resolve nil))
+                       (reject nil)))]
+         (if (state/http-proxy-enabled-or-val?)
+           (-> (ipc/ipc :httpFetchJSON stats-url)
+               (p/then on-ok)
+               (p/catch reject))
+           (util/fetch stats-url on-ok reject)))))
     (p/resolved nil)))
 
 (defn check-or-update-marketplace-plugin!
   [{:keys [id] :as pkg} error-handler]
   (when-not (and (:plugin/installing @state/state)
-              (not (plugin-common-handler/installed? id)))
+                 (not (plugin-common-handler/installed? id)))
     (state/set-state! :plugin/installing pkg)
 
     (-> (load-marketplace-plugins false)
-      (p/then (fn [manifests]
-                (let [mft (some #(when (= (:id %) id) %) manifests)
-                      opts (merge (dissoc pkg :logger) mft)]
+        (p/then (fn [manifests]
+                  (let [mft (some #(when (= (:id %) id) %) manifests)
+                        opts (merge (dissoc pkg :logger) mft)]
                   ;;TODO: (throw (js/Error. [:not-found-in-marketplace id]))
-                  (if (util/electron?)
-                    (ipc/ipc :updateMarketPlugin opts)
-                    (plugin-common-handler/async-install-or-update-for-web! opts)))
-                true))
-      (p/catch (fn [^js e]
-                 (state/reset-all-updates-state)
-                 (error-handler e)
-                 (state/set-state! :plugin/installing nil)
-                 (js/console.error e))))))
+                    (if (util/electron?)
+                      (ipc/ipc :updateMarketPlugin opts)
+                      (plugin-common-handler/async-install-or-update-for-web! opts)))
+                  true))
+        (p/catch (fn [^js e]
+                   (state/reset-all-updates-state)
+                   (error-handler e)
+                   (state/set-state! :plugin/installing nil)
+                   (js/console.error e))))))
 
 (defn get-plugin-inst
   [pid]
@@ -176,17 +176,17 @@
     (when-let [matched (medley/find-first #(= (:key (second %)) key) commands)]
       (let [[_ cmd action pid] matched]
         (state/pub-event!
-          [:exec-plugin-cmd {:type type :key key :pid pid :cmd (assoc cmd :args args) :action action}])))))
+         [:exec-plugin-cmd {:type type :key key :pid pid :cmd (assoc cmd :args args) :action action}])))))
 
 (defn open-updates-downloading
   []
   (when (and (not (:plugin/updates-downloading? @state/state))
-          (seq (state/all-available-coming-updates)))
+             (seq (state/all-available-coming-updates)))
     (->> (:plugin/updates-coming @state/state)
-      (map #(if (state/coming-update-new-version? (second %1))
-              (update % 1 dissoc :error-code) %1))
-      (into {})
-      (state/set-state! :plugin/updates-coming))
+         (map #(if (state/coming-update-new-version? (second %1))
+                 (update % 1 dissoc :error-code) %1))
+         (into {})
+         (state/set-state! :plugin/updates-coming))
     (state/set-state! :plugin/updates-downloading? true)))
 
 (defn close-updates-downloading
@@ -221,29 +221,29 @@
                                ;; update plugin
                                (when-let [^js pl (get-plugin-inst id)]
                                  (p/then
-                                   (.reload pl)
-                                   #(do
+                                  (.reload pl)
+                                  #(do
                                       ;;(if theme (select-a-plugin-theme id))
-                                      (when (not (util/electron?))
-                                        (set! (.-version (.-options pl)) (:version web-pkg))
-                                        (set! (.-webPkg (.-options pl)) (bean/->js web-pkg))
-                                        (invoke-exported-api :save_installed_web_plugin (.toJSON pl false)))
-                                      (notification/show!
-                                        (t :plugin/update-plugin name (.-version (.-options pl))) :success)
-                                      (state/consume-updates-from-coming-plugin! payload true))))
+                                     (when (not (util/electron?))
+                                       (set! (.-version (.-options pl)) (:version web-pkg))
+                                       (set! (.-webPkg (.-options pl)) (bean/->js web-pkg))
+                                       (invoke-exported-api :save_installed_web_plugin (.toJSON pl false)))
+                                     (notification/show!
+                                      (t :plugin/update-plugin name (.-version (.-options pl))) :success)
+                                     (state/consume-updates-from-coming-plugin! payload true))))
                                ;; register plugin
                                (-> (js/LSPluginCore.register (bean/->js {:key id :url dst :webPkg web-pkg}))
-                                 (p/then (fn []
-                                           (when-let [^js pl (get-plugin-inst id)]
-                                             (when theme (js/setTimeout #(select-a-plugin-theme id) 300))
-                                             (when (.-isWebPlugin pl)
-                                               (invoke-exported-api :save_installed_web_plugin (.toJSON pl false)))
-                                             (notification/show!
-                                               (t :plugin/installed-plugin name) :success))))
-                                 (p/catch (fn [^js e]
-                                            (notification/show!
-                                              (str "Install failed: " name "\n" (.-message e))
-                                              :error)))))))
+                                   (p/then (fn []
+                                             (when-let [^js pl (get-plugin-inst id)]
+                                               (when theme (js/setTimeout #(select-a-plugin-theme id) 300))
+                                               (when (.-isWebPlugin pl)
+                                                 (invoke-exported-api :save_installed_web_plugin (.toJSON pl false)))
+                                               (notification/show!
+                                                (t :plugin/installed-plugin name) :success))))
+                                   (p/catch (fn [^js e]
+                                              (notification/show!
+                                               (str "Install failed: " name "\n" (.-message e))
+                                               :error)))))))
 
                          :error
                          (let [error-code (keyword (string/replace (:error-code payload) #"^[\s\:\[]+" ""))
@@ -266,10 +266,10 @@
 
                                ;; notify human tips
                                (notification/show!
-                                 (str
-                                   (if (= :error type) "[Error]" "")
-                                   (str "<" (:id payload) "> ")
-                                   msg) type)))
+                                (str
+                                 (if (= :error type) "[Error]" "")
+                                 (str "<" (:id payload) "> ")
+                                 msg) type)))
 
                            (when-not fake-error?
                              (js/console.error "Update Error:" (:error-code payload))))
@@ -294,8 +294,8 @@
   [plugin-metadata]
   (when-let [pid (keyword (:id plugin-metadata))]
     (some->> plugin-metadata
-      (normalize-plugin-metadata)
-      (swap! state/state update-in [:plugin/installed-plugins] assoc pid))))
+             (normalize-plugin-metadata)
+             (swap! state/state update-in [:plugin/installed-plugins] assoc pid))))
 
 (defn host-mounted!
   []
@@ -306,7 +306,7 @@
   (when-let [pid (keyword pid)]
     (when (contains? (:plugin/installed-plugins @state/state) pid)
       (swap! state/state update-in [:plugin/installed-slash-commands pid]
-        (fnil merge {}) (hash-map cmd (mapv #(conj % {:pid pid}) actions)))
+             (fnil merge {}) (hash-map cmd (mapv #(conj % {:pid pid}) actions)))
       (state/pub-event! [:rebuild-slash-commands-list])
       true)))
 
@@ -332,7 +332,7 @@
                                    (get keybinding-mode-handler-map (keyword mode)))
                      :action (fn []
                                (state/pub-event!
-                                 [:exec-plugin-cmd {:type type :key key :pid pid :cmd cmd :action action}]))}]
+                                [:exec-plugin-cmd {:type type :key key :pid pid :cmd cmd :action action}]))}]
     palette-cmd))
 
 (defn simple-cmd-keybinding->shortcut-args
@@ -340,8 +340,8 @@
   (let [id (keyword (str "plugin." pid "/" key))
         binding (:binding keybinding)
         binding (some->> (if (string? binding) [binding] (vec binding))
-                  (remove string/blank?)
-                  (map shortcut-utils/undecorate-binding))
+                         (remove string/blank?)
+                         (map shortcut-utils/undecorate-binding))
         binding (if util/mac?
                   (or (:mac keybinding) binding) binding)
         mode (or (:mode keybinding) :global)
@@ -354,7 +354,7 @@
   (when-let [pid (keyword pid)]
     (when (contains? (:plugin/installed-plugins @state/state) pid)
       (swap! state/state update-in [:plugin/simple-commands pid]
-        (fnil conj []) [type cmd action pid])
+             (fnil conj []) [type cmd action pid])
       true)))
 
 (defn unregister-plugin-simple-command
@@ -368,7 +368,7 @@
       (let [items (or (get-in @state/state [:plugin/installed-ui-items pid]) [])
             items (filter #(not= key (:key (second %))) items)]
         (swap! state/state assoc-in [:plugin/installed-ui-items pid]
-          (conj items [type opts pid])))
+               (conj items [type opts pid])))
       true)))
 
 (defn unregister-plugin-ui-items
@@ -383,7 +383,7 @@
         ;; TODO: conditions
         ;; (when (contains? #{:error nil} (get-in @state/state (conj path key))))
         (swap! state/state update-in path
-          (fnil assoc {}) key (merge opts {:pid pid}))
+               (fnil assoc {}) key (merge opts {:pid pid}))
         true))))
 
 (defn unregister-plugin-resources
@@ -426,7 +426,7 @@
   (fn [pid key {subs' :subs :keys [render] :as opts}]
     (when-let [key (and key (keyword key))]
       (register-plugin-resources pid type
-        (merge opts {:key key :subs subs' :render render}))
+                                 (merge opts {:key key :subs subs' :render render}))
       (swap! *providers conj pid)
       #(swap! *providers disj pid))))
 
@@ -436,49 +436,49 @@
    (fn [key]
      (when-let [key (and (seq @*providers) key (keyword key))]
        (when-let [rs (->> @*providers
-                       (map (fn [pid] (state/get-plugin-resource pid type key)))
-                       (remove nil?)
-                       (flatten)
-                       (seq))]
+                          (map (fn [pid] (state/get-plugin-resource pid type key)))
+                          (remove nil?)
+                          (flatten)
+                          (seq))]
          (if many? rs (first rs)))))))
 
 (defonce *fenced-code-providers (atom #{}))
 (def register-fenced-code-renderer
   ;; [pid key payload]
   (create-local-renderer-register
-    :fenced-code-renderers *fenced-code-providers))
+   :fenced-code-renderers *fenced-code-providers))
 (def hook-fenced-code-by-lang
   ;; [key]
   (create-local-renderer-getter
-    :fenced-code-renderers *fenced-code-providers))
+   :fenced-code-renderers *fenced-code-providers))
 
 (def *extensions-enhancer-providers (atom #{}))
 (def register-extensions-enhancer
   ;; a plugin can only register one enhancer for a type
   (create-local-renderer-register
-    :extensions-enhancers *extensions-enhancer-providers))
+   :extensions-enhancers *extensions-enhancer-providers))
 (def hook-extensions-enhancers-by-key
   ;; multiple plug-ins can obtain more than one enhancer
   (create-local-renderer-getter
-    :extensions-enhancers *extensions-enhancer-providers true))
+   :extensions-enhancers *extensions-enhancer-providers true))
 
 (def *route-renderer-providers (atom #{}))
 (def register-route-renderer
   (create-local-renderer-register
-    :route-renderers *route-renderer-providers))
+   :route-renderers *route-renderer-providers))
 (def get-route-renderers
   (create-local-renderer-getter
-    :route-renderers *route-renderer-providers true))
+   :route-renderers *route-renderer-providers true))
 
 (defonce *daemon-renderer-providers (atom #{}))
 (def register-daemon-renderer
   ;; [pid key payload]
   (create-local-renderer-register
-    :daemon-renderers *daemon-renderer-providers))
+   :daemon-renderers *daemon-renderer-providers))
 (def get-daemon-renderers
   ;; [key]
   (create-local-renderer-getter
-    :daemon-renderers *daemon-renderer-providers true))
+   :daemon-renderers *daemon-renderer-providers true))
 
 (defn select-a-plugin-theme
   [pid]
@@ -492,7 +492,7 @@
     ;; TODO: force settings related ui reactive
     ;; Sometimes toggle to `disable` not working
     ;; But related-option data updated?
-    (assoc settings :disabled (boolean (:disabled settings)))))
+                    (assoc settings :disabled (boolean (:disabled settings)))))
 
 (defn open-settings-file-in-default-app!
   [id-or-plugin]
@@ -513,18 +513,17 @@
   ([] (open-report-modal! nil nil))
   ([pid name]
    (shui/dialog-open!
-     [:div.p-1
-      (when pid
-        [:h1.opacity-90.font-bold.pb-1.flex.item-center.gap-1
-         [:span.text-red-rx-10.flex.items-center (shui/tabler-icon "alert-triangle-filled" {:size 20})]
-         [:span name "  " [:code "#" (str pid)]]])
-      [:p
-       "If any plugin is unavailable or you think it contains malicious code,
+    [:div.p-1
+     (when pid
+       [:h1.opacity-90.font-bold.pb-1.flex.item-center.gap-1
+        [:span.text-red-rx-10.flex.items-center (shui/tabler-icon "alert-triangle-filled" {:size 20})]
+        [:span name "  " [:code "#" (str pid)]]])
+     [:p
+      "If any plugin is unavailable or you think it contains malicious code,
         please email " [:a.hover:underline {:href (str "mailto://[email protected]?subject=Report plugin from Logseq Marketplace"
-                                                           (when pid (str " (#" pid ")")))} "[email protected]"]
-       " . Mention the name of the plugin and the URL of its GitHub repository.
-       The Logseq team usually responds within a business day."]
-      ])))
+                                                       (when pid (str " (#" pid ")")))} "[email protected]"]
+      " . Mention the name of the plugin and the URL of its GitHub repository.
+       The Logseq team usually responds within a business day."]])))
 
 (defn parse-user-md-content
   [content {:keys [url]}]
@@ -532,11 +531,11 @@
     (when-not (string/blank? content)
       (let [content (if-not (string/blank? url)
                       (string/replace
-                        content #"!\[[^\]]*\]\((.*?)\s*(\"(?:.*[^\"])\")?\s*\)"
-                        (fn [[matched link]]
-                          (if (and link (not (string/starts-with? link "http")))
-                            (string/replace matched link (util/node-path.join url link))
-                            matched)))
+                       content #"!\[[^\]]*\]\((.*?)\s*(\"(?:.*[^\"])\")?\s*\)"
+                       (fn [[matched link]]
+                         (if (and link (not (string/starts-with? link "http")))
+                           (string/replace matched link (util/node-path.join url link))
+                           matched)))
                       content)]
         (format/to-html content :markdown (gp-mldoc/default-config :markdown))))
     (catch :default e
@@ -553,10 +552,10 @@
             (and (string/blank? (string/trim content)) (throw (js/Error. "blank readme content")))
             (state/set-state! :plugin/active-readme [content item])
             (shui/dialog-open! (fn [_] (display))
-              {:label "plugin-readme"
-               :content-props {:class "max-h-[86vh] overflow-auto"}}))
-        (p/catch #(do (js/console.warn %)
-                      (notification/show! "No README content." :warning))))
+                               {:label "plugin-readme"
+                                :content-props {:class "max-h-[86vh] overflow-auto"}}))
+          (p/catch #(do (js/console.warn %)
+                        (notification/show! "No README content." :warning))))
       ;; market
       (shui/dialog-open! (fn [_] (display item nil)) {:label "plugin-readme"}))))
 
@@ -576,12 +575,12 @@
   (when config/lsp-enabled?
     (try
       (js-invoke js/LSPluginCore
-        (str "hook" (string/capitalize (name tag)))
-        (name type)
-        (if (coll? payload)
-          (bean/->js (normalize-keyword-for-json payload))
-          payload)
-        (if (keyword? plugin-id) (name plugin-id) plugin-id))
+                 (str "hook" (string/capitalize (name tag)))
+                 (name type)
+                 (if (coll? payload)
+                   (bean/->js (normalize-keyword-for-json payload))
+                   payload)
+                 (if (keyword? plugin-id) (name plugin-id) plugin-id))
       (catch :default e
         (log/error :invoke-hook-exception e)))))
 
@@ -619,8 +618,7 @@
   (-> (if (util/electron?)
         (ipc/ipc "getLogseqDotDirRoot")
         "LSPUserDotRoot/")
-    (p/then #(do (reset! *ls-dotdir-root %) %))))
-
+      (p/then #(do (reset! *ls-dotdir-root %) %))))
 
 (defn make-fn-to-load-dotdir-json
   [dirname ^js default]
@@ -708,7 +706,7 @@
 (defn cancel-user-checking!
   []
   (when (and (get-user-checking?)
-          (not (get-auto-checking?)))
+             (not (get-auto-checking?)))
     (state/set-state! :plugin/updates-pending {})))
 
 (defn user-check-enabled-for-updates!
@@ -721,22 +719,22 @@
       ;; TODO: too many requests may be limited by Github api
       (when-let [plugins (seq (take 32 (state/get-enabled?-installed-plugins theme?)))]
         (->> plugins
-          (map (fn [v] [(keyword (:id v)) v]))
-          (into {})
-          (state/set-state! :plugin/updates-pending))
+             (map (fn [v] [(keyword (:id v)) v]))
+             (into {})
+             (state/set-state! :plugin/updates-pending))
         (state/pub-event! [:plugin/consume-updates])))))
 
 (defn auto-check-enabled-for-updates!
   []
   (when (and (not (get-updates-downloading?))
-          (not (get-auto-checking?))
-          (not (get-user-checking?)))
+             (not (get-auto-checking?))
+             (not (get-user-checking?)))
     ;; TODO: take some plugins used recently
     (when-let [plugins (seq (take 16 (shuffle (state/get-enabled?-installed-plugins nil))))]
       (->> plugins
-        (map (fn [v] [(keyword (:id v)) v]))
-        (into {})
-        (state/set-state! :plugin/updates-pending))
+           (map (fn [v] [(keyword (:id v)) v]))
+           (into {})
+           (state/set-state! :plugin/updates-pending))
       (state/pub-event! [:plugin/consume-updates])
       (set-auto-checking! true))))
 
@@ -791,7 +789,7 @@
   (let [el (js/document.createElement "div")]
     (.appendChild js/document.body el)
     (rum/mount
-      (lsp-indicator) el))
+     (lsp-indicator) el))
 
   (-> (p/let [root (init-ls-dotdir-root)
               _ (.setupPluginCore js/LSPlugin (bean/->js {:localUserConfigRoot root :dotConfigRoot root}))
@@ -809,7 +807,7 @@
                   (.on "registered"
                        (fn [^js pl]
                          (register-plugin
-                           (bean/->clj (.parse js/JSON (.stringify js/JSON pl))))))
+                          (bean/->clj (.parse js/JSON (.stringify js/JSON pl))))))
 
                   (.on "beforeload"
                        (fn [^js pl]
@@ -820,7 +818,7 @@
                   (.on "reloaded"
                        (fn [^js pl]
                          (register-plugin
-                           (bean/->clj (.parse js/JSON (.stringify js/JSON pl))))))
+                          (bean/->clj (.parse js/JSON (.stringify js/JSON pl))))))
 
                   (.on "unregistered" (fn [pid]
                                         (let [pid (keyword pid)]
@@ -879,43 +877,43 @@
                                  (when-let [plugins (and perf-table (.entries perf-table))]
                                    (->> plugins
                                         (keep
-                                          (fn [[_k ^js v]]
-                                            (when-let [end (and (some-> v (.-o) (.-disabled) (not))
-                                                                (.-e v))]
-                                              (when (and (number? end)
+                                         (fn [[_k ^js v]]
+                                           (when-let [end (and (some-> v (.-o) (.-disabled) (not))
+                                                               (.-e v))]
+                                             (when (and (number? end)
                                                          ;; valid end time
-                                                         (> end 0)
+                                                        (> end 0)
                                                          ;; greater than 6s
-                                                         (> (- end (.-s v)) 6000))
-                                                v))))
+                                                        (> (- end (.-s v)) 6000))
+                                               v))))
                                         ((fn [perfs]
                                            (doseq [perf perfs]
                                              (state/pub-event! [:plugin/loader-perf-tip (bean/->clj perf)])))))))))
 
               default-plugins (get-user-default-plugins)
               [plugins0, plugins-async] (if (and (seq default-plugins)
-                                         (not (util/electron?)))
-                                     ((juxt (fn [its] (filterv #(:theme %) its))
-                                        (fn [its] (filterv #(not (:theme %)) its)))
-                                      default-plugins)
-                                     [default-plugins])
+                                                 (not (util/electron?)))
+                                          ((juxt (fn [its] (filterv #(:theme %) its))
+                                                 (fn [its] (filterv #(not (:theme %)) its)))
+                                           default-plugins)
+                                          [default-plugins])
               _ (.register js/LSPluginCore (bean/->js (if (seq plugins0) plugins0 [])) true)]
         plugins-async)
 
-    (p/then
-      (fn [plugins-async]
-        (state/set-state! :plugin/indicator-text nil)
+      (p/then
+       (fn [plugins-async]
+         (state/set-state! :plugin/indicator-text nil)
         ;; wait for the plugin register async messages
-        (js/setTimeout
+         (js/setTimeout
           (fn [] (callback)
             (some-> (seq plugins-async)
-              (p/delay 16)
-              (p/then #(.register js/LSPluginCore (bean/->js plugins-async) true))))
+                    (p/delay 16)
+                    (p/then #(.register js/LSPluginCore (bean/->js plugins-async) true))))
           (if (util/electron?) 64 0))))
-    (p/catch
-     (fn [^js e]
-       (log/error :setup-plugin-system-error e)
-       (state/set-state! :plugin/indicator-text (str "Fatal: " e))))))
+      (p/catch
+       (fn [^js e]
+         (log/error :setup-plugin-system-error e)
+         (state/set-state! :plugin/indicator-text (str "Fatal: " e))))))
 
 (defn setup!
   "setup plugin core handler"

+ 27 - 27
src/main/frontend/handler/plugin_config.cljs

@@ -3,23 +3,23 @@
   global-config component. This component is only enabled? if both the
   global-config and plugin components are enabled. plugin.edn is automatically updated
 when a plugin is installed, updated or removed"
-  (:require [frontend.handler.global-config :as global-config-handler]
-            [logseq.common.path :as path]
-            [promesa.core :as p]
-            [borkdude.rewrite-edn :as rewrite]
+  (:require [borkdude.rewrite-edn :as rewrite]
+            [cljs-bean.core :as bean]
+            [clojure.edn :as edn]
+            [clojure.pprint :as pprint]
+            [clojure.set :as set]
             [frontend.fs :as fs]
-            [frontend.state :as state]
-            [frontend.handler.notification :as notification]
             [frontend.handler.common.plugin :as plugin-common-handler]
+            [frontend.handler.global-config :as global-config-handler]
+            [frontend.handler.notification :as notification]
+            [frontend.schema.handler.plugin-config :as plugin-config-schema]
+            [frontend.state :as state]
             [frontend.util :as util]
-            [clojure.edn :as edn]
-            [clojure.set :as set]
-            [clojure.pprint :as pprint]
+            [lambdaisland.glogi :as log]
+            [logseq.common.path :as path]
             [malli.core :as m]
             [malli.error :as me]
-            [frontend.schema.handler.plugin-config :as plugin-config-schema]
-            [cljs-bean.core :as bean]
-            [lambdaisland.glogi :as log]))
+            [promesa.core :as p]))
 
 (defn plugin-config-path
   "Full path to plugins.edn"
@@ -40,7 +40,7 @@ when a plugin is installed, updated or removed"
                               str)]
          ;; fs protocols require repo and dir when they aren't necessary. For this component,
          ;; neither is needed so these are blank and nil respectively
-         (fs/write-file! "" nil (plugin-config-path) updated-content {:skip-compare? true})))
+    (fs/write-file! "" nil (plugin-config-path) updated-content {:skip-compare? true})))
 
 (defn remove-plugin
   "Removes a plugin from plugin.edn"
@@ -80,16 +80,16 @@ returns map of plugins to install and uninstall"
   (p/catch
    (p/let [edn-plugins* (fs/read-file nil (plugin-config-path))
            edn-plugins (edn/read-string edn-plugins*)]
-          (if-let [errors (->> edn-plugins (m/explain plugin-config-schema/Plugins-edn) me/humanize)]
-            (do
-              (notification/show! "Invalid plugins.edn provided. See javascript console for specific errors"
-                                  :error)
-              (log/error :plugin-edn-errors errors)
-              (println "Invalid plugins.edn, errors: " errors))
-            (let [plugins-to-change (determine-plugins-to-change
-                                     (:plugin/installed-plugins @state/state)
-                                     edn-plugins)]
-              (state/pub-event! [:go/plugins-from-file plugins-to-change]))))
+     (if-let [errors (->> edn-plugins (m/explain plugin-config-schema/Plugins-edn) me/humanize)]
+       (do
+         (notification/show! "Invalid plugins.edn provided. See javascript console for specific errors"
+                             :error)
+         (log/error :plugin-edn-errors errors)
+         (println "Invalid plugins.edn, errors: " errors))
+       (let [plugins-to-change (determine-plugins-to-change
+                                (:plugin/installed-plugins @state/state)
+                                edn-plugins)]
+         (state/pub-event! [:go/plugins-from-file plugins-to-change]))))
    (fn [e]
      (if (= :reader-exception (:type (ex-data e)))
        (notification/show! "Malformed plugins.edn provided. Please check the file has correct edn syntax."
@@ -117,12 +117,12 @@ returns map of plugins to install and uninstall"
                      (when (and (= status "completed") (not only-check))
                        (let [{:keys [theme effect]} payload]
                          (add-or-update-plugin
-                           (assoc payload
-                             :version (:installed-version payload)
-                             :effect (boolean effect)
+                          (assoc payload
+                                 :version (:installed-version payload)
+                                 :effect (boolean effect)
                              ;; Manual installation doesn't have theme field but
                              ;; plugin.edn requires this field
-                             :theme (boolean theme)))))))]
+                                 :theme (boolean theme)))))))]
     (when (util/electron?)
       (js/window.apis.addListener channel listener))
     ;;teardown

+ 11 - 10
src/main/frontend/handler/route.cljs

@@ -1,23 +1,23 @@
 (ns frontend.handler.route
   "Provides fns used for routing throughout the app"
-  (:require [frontend.config :as config]
+  (:require [clojure.string :as string]
+            [frontend.config :as config]
+            [frontend.context.i18n :refer [t]]
             [frontend.date :as date]
             [frontend.db :as db]
             [frontend.db.model :as model]
+            [frontend.extensions.pdf.utils :as pdf-utils]
+            [frontend.handler.notification :as notification]
+            [frontend.handler.property.util :as pu]
             [frontend.handler.recent :as recent-handler]
             [frontend.handler.search :as search-handler]
             [frontend.handler.ui :as ui-handler]
-            [frontend.handler.property.util :as pu]
             [frontend.state :as state]
             [frontend.util :as util]
-            [frontend.extensions.pdf.utils :as pdf-utils]
-            [logseq.graph-parser.text :as text]
-            [reitit.frontend.easy :as rfe]
-            [frontend.context.i18n :refer [t]]
-            [clojure.string :as string]
             [logseq.common.util :as common-util]
-            [frontend.handler.notification :as notification]
-            [logseq.db :as ldb]))
+            [logseq.db :as ldb]
+            [logseq.graph-parser.text :as text]
+            [reitit.frontend.easy :as rfe]))
 
 (defn redirect!
   "If `push` is truthy, previous page will be left in history."
@@ -139,7 +139,8 @@
           block-title (when (and block? (not page))
                         (when-let [block (db/entity [:block/uuid (uuid name)])]
                           (let [content (text/remove-level-spaces (:block/title block)
-                                                                  (:block/format block) (config/get-block-pattern (:block/format block)))]
+                                                                  (get block :block/format :markdown)
+                                                                  (config/get-block-pattern (get block :block/format :markdown)))]
                             (if (> (count content) 48)
                               (str (subs content 0 48) "...")
                               content))))

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

@@ -12,10 +12,10 @@
             [frontend.state :as state]
             [frontend.storage :as storage]
             [frontend.util :as util]
-            [logseq.shui.dialog.core :as shui-dialog]
             [goog.dom :as gdom]
             [goog.object :as gobj]
             [logseq.common.path :as path]
+            [logseq.shui.dialog.core :as shui-dialog]
             [logseq.shui.ui :as shui]
             [promesa.core :as p]
             [rum.core :as rum]))

+ 0 - 1
src/main/frontend/idb.cljs

@@ -5,7 +5,6 @@
             [frontend.config :as config]
             [promesa.core :as p]))
 
-
 ;; offline db
 
 ;; To maintain backward compatibility

+ 1 - 1
src/main/frontend/mobile/camera.cljs

@@ -49,7 +49,7 @@
                        nil
 
                        :else " ")
-        format (:block/format block)]
+        format (get block :block/format :markdown)]
     (p/let [filename (take-or-choose-photo)]
       (when (not-empty filename)
         (commands/simple-insert!

+ 1 - 2
src/main/frontend/mobile/record.cljs

@@ -3,7 +3,6 @@
             ["capacitor-voice-recorder" :refer [VoiceRecorder]]
             [clojure.string :as string]
             [frontend.date :as date]
-            [frontend.db :as db]
             [frontend.handler.assets :as assets-handler]
             [frontend.handler.editor :as editor-handler]
             [frontend.state :as state]
@@ -47,7 +46,7 @@
   (p/let [page (or (state/get-current-page) (string/lower-case (date/journal-name)))
           filename (str (date/get-date-time-string-2) ".aac")
           edit-block (state/get-edit-block)
-          format (or (:block/format edit-block) (db/get-page-format page))
+          format (get edit-block :block/format :markdown)
           path (assets-handler/get-asset-path filename)
           _file (p/catch
                  (.writeFile Filesystem (clj->js {:data database64

+ 15 - 1
src/main/frontend/worker/db/migrate.cljs

@@ -474,6 +474,19 @@
               [:db/retract (:e d) :logseq.task/deadline]))
           datoms))))))
 
+(defn- remove-block-format-from-db
+  [conn _search-db]
+  (let [db @conn]
+    (when (ldb/db-based-graph? db)
+      (let [datoms (d/datoms db :avet :block/uuid)
+            tx-data (map
+                     (fn [d]
+                       [:db/retract (:e d) :block/format])
+                     datoms)]
+        (ldb/transact! conn tx-data {:db-migrate? true})
+        (d/reset-schema! conn (dissoc (:schema db) :block/format))
+        []))))
+
 (defn- deprecate-logseq-user-ns
   [conn _search-db]
   (let [db @conn]
@@ -582,7 +595,8 @@
    [55 {:fix update-deadline-to-datetime}]
    [56 {:properties [:logseq.property/enable-history?
                      :logseq.property.history/block :logseq.property.history/property
-                     :logseq.property.history/ref-value :logseq.property.history/scalar-value]}]])
+                     :logseq.property.history/ref-value :logseq.property.history/scalar-value]}]
+   [57 {:fix remove-block-format-from-db}]])
 
 (let [max-schema-version (apply max (map first schema-version->updates))]
   (assert (<= db-schema/version max-schema-version))

+ 5 - 5
src/main/frontend/worker/export.cljs

@@ -1,12 +1,12 @@
 (ns frontend.worker.export
   "Export data"
-  (:require [datascript.core :as d]
+  (:require [cljs-bean.core :as bean]
+            [datascript.core :as d]
             [frontend.common.file.core :as common-file]
             [logseq.db :as ldb]
+            [logseq.db.sqlite.util :as sqlite-util]
             [logseq.graph-parser.property :as gp-property]
-            [logseq.outliner.tree :as otree]
-            [cljs-bean.core :as bean]
-            [logseq.db.sqlite.util :as sqlite-util]))
+            [logseq.outliner.tree :as otree]))
 
 (defn- safe-keywordize
   [block]
@@ -35,7 +35,7 @@
                                      (let [b' (if (seq (:block/properties b))
                                                 (update b :block/title
                                                         (fn [content]
-                                                          (gp-property/remove-properties (:block/format b) content)))
+                                                          (gp-property/remove-properties (get b :block/format :markdown) content)))
                                                 b)]
                                        (safe-keywordize b'))) blocks))
                     children (if whiteboard?

+ 10 - 11
src/main/frontend/worker/handler/page.cljs

@@ -1,15 +1,15 @@
 (ns frontend.worker.handler.page
   "Page operations"
-  (:require [logseq.db :as ldb]
-            [logseq.graph-parser.db :as gp-db]
-            [logseq.graph-parser.block :as gp-block]
-            [logseq.db.sqlite.util :as sqlite-util]
-            [datascript.core :as d]
+  (:require [datascript.core :as d]
+            [frontend.worker.handler.page.db-based.page :as db-worker-page]
+            [frontend.worker.handler.page.file-based.page :as file-worker-page]
             [logseq.common.config :as common-config]
             [logseq.common.util :as common-util]
+            [logseq.db :as ldb]
             [logseq.db.frontend.content :as db-content]
-            [frontend.worker.handler.page.db-based.page :as db-worker-page]
-            [frontend.worker.handler.page.file-based.page :as file-worker-page]))
+            [logseq.db.sqlite.util :as sqlite-util]
+            [logseq.graph-parser.block :as gp-block]
+            [logseq.graph-parser.db :as gp-db]))
 
 (defn rtc-create-page!
   [conn config title {:keys [uuid]}]
@@ -17,10 +17,9 @@
   (let [date-formatter    (common-config/get-date-formatter config)
         title (db-worker-page/sanitize-title title)
         page-name (common-util/page-name-sanity-lc title)
-        page              (-> (gp-block/page-name->map title @conn true date-formatter
-                                                       {:page-uuid uuid
-                                                        :skip-existing-page-check? true})
-                              (assoc :block/format :markdown))
+        page              (gp-block/page-name->map title @conn true date-formatter
+                                                   {:page-uuid uuid
+                                                    :skip-existing-page-check? true})
         result            (ldb/transact! conn [page] {:persist-op? false
                                                       :outliner-op :create-page})]
     [result page-name (:block/uuid page)]))

+ 13 - 17
src/main/frontend/worker/handler/page/db_based/page.cljs

@@ -70,15 +70,14 @@
     title))
 
 (defn build-first-block-tx
-  [page-uuid format]
+  [page-uuid]
   (let [page-id [:block/uuid page-uuid]]
     [(sqlite-util/block-with-timestamps
       {:block/uuid (ldb/new-block-id)
        :block/page page-id
        :block/parent page-id
        :block/order (db-order/gen-key nil nil)
-       :block/title ""
-       :block/format format})]))
+       :block/title ""})]))
 
 (defn- get-page-by-parent-name
   [db parent-title child-title]
@@ -115,11 +114,10 @@
                                     (ldb/get-page db part)
                                     (get-page-by-parent-name db (nth parts (dec idx)) part))
                              result (or page
-                                        (-> (gp-block/page-name->map part db true date-formatter
-                                                                     {:page-uuid (when last-part? block-uuid)
-                                                                      :skip-existing-page-check? true
-                                                                      :class? class?})
-                                            (assoc :block/format :markdown)))]
+                                        (gp-block/page-name->map part db true date-formatter
+                                                                 {:page-uuid (when last-part? block-uuid)
+                                                                  :skip-existing-page-check? true
+                                                                  :class? class?}))]
                          result))
                      parts))]
          (cond
@@ -193,14 +191,12 @@
                          [:db/retract [:block/uuid (:block/uuid existing-page)] :block/tags :logseq.class/Page]]]
             {:tx-meta tx-meta
              :tx-data tx-data})))
-      (let [format    :markdown
-            page      (-> (gp-block/page-name->map title db true date-formatter
-                                                   {:class? class?
-                                                    :page-uuid (when (uuid? uuid) uuid)
-                                                    :skip-existing-page-check? (if (some? skip-existing-page-check?)
-                                                                                 skip-existing-page-check?
-                                                                                 true)})
-                          (assoc :block/format format))
+      (let [page      (gp-block/page-name->map title db true date-formatter
+                                               {:class? class?
+                                                :page-uuid (when (uuid? uuid) uuid)
+                                                :skip-existing-page-check? (if (some? skip-existing-page-check?)
+                                                                             skip-existing-page-check?
+                                                                             true)})
             [page parents] (if (and (text/namespace-page? title) split-namespace?)
                              (let [pages (split-namespace-pages db page date-formatter)]
                                [(last pages) (butlast pages)])
@@ -222,7 +218,7 @@
                                       create-first-block?
                                       (not (or whiteboard? class?))
                                       page-txs)
-                                 (build-first-block-tx (:block/uuid (first page-txs)) format))
+                                 (build-first-block-tx (:block/uuid (first page-txs))))
                 txs      (concat
                           ;; transact doesn't support entities
                           (remove de/entity? parents)

+ 4 - 10
src/main/frontend/worker/rtc/full_upload_download_graph.cljs

@@ -4,6 +4,7 @@
   (:require [cljs-http-missionary.client :as http]
             [clojure.set :as set]
             [datascript.core :as d]
+            [frontend.common.missionary :as c.m]
             [frontend.worker.crypt :as crypt]
             [frontend.worker.db-listener :as db-listener]
             [frontend.worker.rtc.client-op :as client-op]
@@ -12,7 +13,6 @@
             [frontend.worker.rtc.ws-util :as ws-util]
             [frontend.worker.state :as worker-state]
             [frontend.worker.util :as worker-util]
-            [frontend.common.missionary :as c.m]
             [logseq.db :as ldb]
             [logseq.db.frontend.malli-schema :as db-malli-schema]
             [logseq.db.frontend.schema :as db-schema]
@@ -161,11 +161,6 @@
            parent
            (page-of-block id->block-map parent)))))))
 
-(defn- convert-block-fields
-  [block]
-  (cond-> block
-    (:block/uuid block)        (assoc :block/format :markdown)))
-
 (defn- fill-block-fields
   [blocks]
   (let [groups (group-by #(boolean (:block/name %)) blocks)
@@ -173,10 +168,9 @@
         id->block (into {} (map (juxt :db/id identity) blocks))
         block-id->page-id (into {} (map (fn [b] [(:db/id b) (:db/id (page-of-block id->block b))]) other-blocks))]
     (mapv (fn [b]
-            (let [b (convert-block-fields b)]
-              (if-let [page-id (block-id->page-id (:db/id b))]
-                (assoc b :block/page page-id)
-                b)))
+            (if-let [page-id (block-id->page-id (:db/id b))]
+              (assoc b :block/page page-id)
+              b))
           blocks)))
 
 (defn- blocks->card-one-attrs

+ 1 - 2
src/main/frontend/worker/rtc/remote_update.cljs

@@ -189,8 +189,7 @@
               (transact-db! :move-blocks repo conn [b] local-parent false)
               (transact-db! :insert-blocks repo conn
                             [{:block/uuid block-uuid
-                              :block/title ""
-                              :block/format :markdown}]
+                              :block/title ""}]
                             local-parent {:sibling? false :keep-uuid? true}))
             (transact-db! :update-block-order-directly repo conn block-uuid first-remote-parent remote-block-order))
 

+ 46 - 46
src/main/logseq/api.cljs

@@ -1,61 +1,61 @@
 (ns ^:no-doc logseq.api
   (:require [cljs-bean.core :as bean]
             [cljs.reader]
-            [goog.object :as gobj]
-            [datascript.core :as d]
-            [frontend.db.conn :as conn]
-            [logseq.common.util :as common-util]
-            [logseq.sdk.core]
-            [logseq.sdk.git]
-            [logseq.sdk.experiments]
-            [logseq.sdk.utils :as sdk-utils]
-            [logseq.sdk.ui :as sdk-ui]
-            [logseq.sdk.assets :as sdk-assets]
             [clojure.string :as string]
+            [datascript.core :as d]
             [electron.ipc :as ipc]
             [frontend.commands :as commands]
             [frontend.config :as config]
-            [frontend.handler.config :as config-handler]
-            [frontend.handler.recent :as recent-handler]
-            [frontend.handler.route :as route-handler]
             [frontend.db :as db]
-            [frontend.idb :as idb]
             [frontend.db.async :as db-async]
+            [frontend.db.conn :as conn]
             [frontend.db.model :as db-model]
             [frontend.db.query-custom :as query-custom]
             [frontend.db.query-dsl :as query-dsl]
-            [frontend.db.utils :as db-utils]
             [frontend.db.query-react :as query-react]
+            [frontend.db.utils :as db-utils]
             [frontend.fs :as fs]
+            [frontend.handler.code :as code-handler]
+            [frontend.handler.command-palette :as palette-handler]
+            [frontend.handler.common.plugin :as plugin-common-handler]
+            [frontend.handler.config :as config-handler]
+            [frontend.handler.db-based.property :as db-property-handler]
             [frontend.handler.dnd :as editor-dnd-handler]
             [frontend.handler.editor :as editor-handler]
             [frontend.handler.export :as export-handler]
             [frontend.handler.page :as page-handler]
             [frontend.handler.plugin :as plugin-handler]
-            [frontend.handler.common.plugin :as plugin-common-handler]
             [frontend.handler.property :as property-handler]
-            [frontend.handler.db-based.property :as db-property-handler]
-            [logseq.outliner.core :as outliner-core]
+            [frontend.handler.recent :as recent-handler]
+            [frontend.handler.route :as route-handler]
+            [frontend.handler.search :as search-handler]
+            [frontend.handler.shell :as shell]
+            [frontend.idb :as idb]
+            [frontend.loader :as loader]
+            [frontend.modules.layout.core]
             [frontend.modules.outliner.tree :as outliner-tree]
-            [frontend.handler.command-palette :as palette-handler]
-            [frontend.modules.shortcut.core :as st]
             [frontend.modules.shortcut.config :as shortcut-config]
+            [frontend.modules.shortcut.core :as st]
             [frontend.state :as state]
             [frontend.util :as util]
             [frontend.util.cursor :as cursor]
-            [frontend.loader :as loader]
+            [frontend.version :as fv]
             [goog.dom :as gdom]
+            [goog.object :as gobj]
             [lambdaisland.glogi :as log]
-            [promesa.core :as p]
-            [reitit.frontend.easy :as rfe]
-            [frontend.version :as fv]
-            [frontend.handler.shell :as shell]
-            [frontend.modules.layout.core]
-            [frontend.handler.code :as code-handler]
-            [frontend.handler.search :as search-handler]
             [logseq.api.block :as api-block]
+            [logseq.common.util :as common-util]
             [logseq.db :as ldb]
-            [logseq.db.frontend.property.util :as db-property-util]))
+            [logseq.db.frontend.property.util :as db-property-util]
+            [logseq.outliner.core :as outliner-core]
+            [logseq.sdk.assets :as sdk-assets]
+            [logseq.sdk.core]
+            [logseq.sdk.experiments]
+            [logseq.sdk.git]
+            [logseq.sdk.ui :as sdk-ui]
+            [logseq.sdk.utils :as sdk-utils]
+            [promesa.core :as p]
+            [reitit.frontend.easy :as rfe]))
 
 ;; Alert: this namespace shouldn't invoke any reactive queries
 
@@ -209,7 +209,7 @@
     (if (util/electron?)
       (fs/read-file nil (util/node-path.join path "package.json"))
       (do (js/console.log "==>>> TODO: load plugin package.json from local???")
-        ""))))
+          ""))))
 
 (def ^:export load_plugin_readme
   (fn [path]
@@ -388,26 +388,26 @@
      key data)))
 
 (defn ^:export load_installed_web_plugins
- []
- (let [getter (plugin-handler/make-fn-to-load-dotdir-json "installed-plugins-for-web" #js {})]
-        (some-> (getter :all) (p/then second))))
+  []
+  (let [getter (plugin-handler/make-fn-to-load-dotdir-json "installed-plugins-for-web" #js {})]
+    (some-> (getter :all) (p/then second))))
 
 (defn ^:export save_installed_web_plugin
- ([^js plugin] (save_installed_web_plugin plugin false))
- ([^js plugin remove?]
-  (when-let [id (some-> plugin (.-key) (name))]
-   (let [setter (plugin-handler/make-fn-to-save-dotdir-json "installed-plugins-for-web")
-         plugin (js/JSON.parse (js/JSON.stringify plugin))]
-    (p/let [^js plugins (or (load_installed_web_plugins) #js {})]
-           (if (true? remove?)
-            (when (aget plugins id)
+  ([^js plugin] (save_installed_web_plugin plugin false))
+  ([^js plugin remove?]
+   (when-let [id (some-> plugin (.-key) (name))]
+     (let [setter (plugin-handler/make-fn-to-save-dotdir-json "installed-plugins-for-web")
+           plugin (js/JSON.parse (js/JSON.stringify plugin))]
+       (p/let [^js plugins (or (load_installed_web_plugins) #js {})]
+         (if (true? remove?)
+           (when (aget plugins id)
              (js-delete plugins id))
-            (gobj/set plugins id plugin))
-           (setter :all plugins))))))
+           (gobj/set plugins id plugin))
+         (setter :all plugins))))))
 
 (defn ^:export unlink_installed_web_plugin
- [key]
- (save_installed_web_plugin #js {:key key} true))
+  [key]
+  (save_installed_web_plugin #js {:key key} true))
 
 (def ^:export unlink_plugin_user_settings
   (plugin-handler/make-fn-to-unlink-dotdir-json "settings"))
@@ -779,7 +779,7 @@
                 block (if before
                         (db/pull (:db/id (ldb/get-left-sibling (db/entity (:db/id block))))) block)]
             (some-> (editor-handler/insert-block-tree-after-target
-                     (:db/id block) sibling bb (:block/format block) keep-uuid?)
+                     (:db/id block) sibling bb (get block :block/format :markdown) keep-uuid?)
                     (p/then (fn [results]
                               (some-> results (ldb/read-transit-str)
                                       :blocks (sdk-utils/normalize-keyword-for-json) (bean/->js)))))))))))

+ 4 - 22
src/rtc_e2e_test/const.cljs

@@ -48,12 +48,10 @@
      :block/uuid page1-uuid
      :block/created-at 1724836490809
      :block/updated-at 1724836490809
-     :block/type "page"
-     :block/format :markdown}
+     :block/type "page"}
     {:block/uuid block1-uuid
      :block/updated-at 1724836490810
      :block/created-at 1724836490810
-     :block/format :markdown
      :block/title "block1"
      :block/parent "page"
      :block/order "a0"
@@ -65,13 +63,11 @@
           :block/title "insert-500-blocks"
           :block/created-at 1725024677501
           :block/updated-at 1725024677501
-          :block/type "page"
-          :block/format :markdown}
+          :block/type "page"}
          (map (fn [i order]
                 {:block/uuid (random-uuid)
                  :block/created-at 1725024677501
                  :block/updated-at 1725024677501
-                 :block/format :markdown
                  :block/title (str "x" i)
                  :block/parent "page"
                  :block/order order
@@ -83,7 +79,6 @@
      :block/updated-at 1725455235108
      :block/created-at 1725455235108
      :block/journal-day 20240907
-     :block/format :markdown
      :block/title "Sep 7th, 2024"
      :block/name "sep 7th, 2024"
      :block/type "journal"}
@@ -105,12 +100,10 @@
      :block/title "move-blocks-concurrently"
      :block/created-at 1725024677501
      :block/updated-at 1725024677501
-     :block/type "page"
-     :block/format :markdown}
+     :block/type "page"}
     {:block/uuid block2-uuid
      :block/created-at 1725024677501
      :block/updated-at 1725024677501
-     :block/format :markdown
      :block/title "x1"
      :block/parent "page"
      :block/order "a0"
@@ -118,7 +111,6 @@
     {:block/uuid block3-uuid
      :block/created-at 1725024677501
      :block/updated-at 1725024677501
-     :block/format :markdown
      :block/title "x2"
      :block/parent "page"
      :block/order "a1"
@@ -126,7 +118,6 @@
     {:block/uuid block4-uuid
      :block/created-at 1725024677501
      :block/updated-at 1725024677501
-     :block/format :markdown
      :block/title "x3"
      :block/parent "page"
      :block/order "a2"
@@ -134,7 +125,6 @@
     {:block/uuid block5-uuid
      :block/created-at 1725024677501
      :block/updated-at 1725024677501
-     :block/format :markdown
      :block/title "x4"
      :block/parent "page"
      :block/order "a3"
@@ -142,7 +132,6 @@
     {:block/uuid block6-uuid
      :block/created-at 1725024677501
      :block/updated-at 1725024677501
-     :block/format :markdown
      :block/title "x5"
      :block/parent "page"
      :block/order "a4"
@@ -150,7 +139,6 @@
     {:block/uuid block7-uuid
      :block/created-at 1725024677501
      :block/updated-at 1725024677501
-     :block/format :markdown
      :block/title "x6"
      :block/parent "page"
      :block/order "a5"
@@ -192,13 +180,11 @@
      :block/title "step6-delete-blocks"
      :block/created-at 1725024677501
      :block/updated-at 1725024677501
-     :block/type "page"
-     :block/format :markdown}
+     :block/type "page"}
     {:db/id "b1"
      :block/uuid step6-block1-uuid
      :block/created-at 1725024677501
      :block/updated-at 1725024677501
-     :block/format :markdown
      :block/title "x1"
      :block/parent "page"
      :block/order "a0"
@@ -207,7 +193,6 @@
      :block/uuid step6-block2-uuid
      :block/created-at 1725024677501
      :block/updated-at 1725024677501
-     :block/format :markdown
      :block/title "x2"
      :block/parent "b1"
      :block/order "a0"
@@ -216,7 +201,6 @@
      :block/uuid step6-block3-uuid
      :block/created-at 1725024677501
      :block/updated-at 1725024677501
-     :block/format :markdown
      :block/title "x3"
      :block/parent "page"
      :block/order "a1"
@@ -225,7 +209,6 @@
      :block/uuid step6-block4-uuid
      :block/created-at 1725024677501
      :block/updated-at 1725024677501
-     :block/format :markdown
      :block/title "x4"
      :block/parent "b3"
      :block/order "a0"
@@ -234,7 +217,6 @@
      :block/uuid step6-block5-uuid
      :block/created-at 1725024677501
      :block/updated-at 1725024677501
-     :block/format :markdown
      :block/title "x5"
      :block/parent "b4"
      :block/order "a0"

+ 2 - 4
src/rtc_e2e_test/helper.cljs

@@ -3,11 +3,11 @@
             [const]
             [datascript.core :as d]
             [datascript.transit :as dt]
+            [frontend.common.missionary :as c.m]
             [frontend.worker.rtc.client-op :as client-op]
             [frontend.worker.rtc.core :as rtc.core]
             [frontend.worker.rtc.log-and-state :as rtc-log-and-state]
             [frontend.worker.state :as worker-state]
-            [frontend.common.missionary :as c.m]
             [logseq.db :as ldb]
             [logseq.db.frontend.order :as db-order]
             [logseq.outliner.batch-tx :as batch-tx]
@@ -124,14 +124,12 @@
                     :block/title "message-page"
                     :block/created-at 1725024677501
                     :block/updated-at 1725024677501
-                    :block/type "page"
-                    :block/format :markdown}
+                    :block/type "page"}
                    {:block/uuid (random-uuid)
                     :block/parent "page"
                     :block/order min-order
                     :block/title (dt/write-transit-str message)
                     :block/page "page"
-                    :block/format :markdown
                     :block/updated-at 1724836490810
                     :block/created-at 1724836490810}]]
       (batch-tx/with-batch-tx-mode conn {:e2e-test const/downloaded-test-repo :skip-store-conn true}

+ 1 - 5
src/test/frontend/test/generators.cljs

@@ -3,7 +3,6 @@
   (:require [clojure.test.check.generators :as gen]
             [datascript.core :as d]))
 
-
 (defn gen-available-block-uuid
   [db & {:keys [page-uuid]}]
   (let [query (cond-> '[:find ?block-uuid]
@@ -46,10 +45,8 @@
       (gen/elements coll)
       (gen/return nil))))
 
-
 ;;; generators for outliner operations
 
-
 (defn gen-insert-blocks-op
   [db & {:keys [opts] :as args}]
   (gen/let [target-block-uuid (gen-available-block-uuid db (select-keys args [:page-uuid]))
@@ -58,8 +55,7 @@
       (let [block-uuid (random-uuid)]
         [:insert-blocks
          [[{:block/uuid block-uuid
-            :block/title content
-            :block/format :markdown}]
+            :block/title content}]
           (:db/id (d/entity db [:block/uuid target-block-uuid]))
           opts]]))))
 

+ 2 - 4
src/test/frontend/test/helper.cljs

@@ -193,15 +193,13 @@ This can be called in synchronous contexts as no async fns should be invoked"
        :block/page page-id
        :block/parent page-id
        :block/order (db-order/gen-key nil)
-       :block/title "block 1"
-       :block/format :markdown}
+       :block/title "block 1"}
       ;; second block
       {:block/uuid second-block-uuid
        :block/page page-id
        :block/parent page-id
        :block/order (db-order/gen-key nil)
-       :block/title "block 2"
-       :block/format :markdown}]
+       :block/title "block 2"}]
      (map sqlite-util/block-with-timestamps))))
 
 (defn start-and-destroy-db

+ 3 - 5
src/test/frontend/worker/rtc/client_test.cljs

@@ -1,10 +1,10 @@
 (ns frontend.worker.rtc.client-test
   (:require
    [cljs.test :refer [deftest is testing]]
-   [frontend.worker.rtc.client :as subject]
-   [logseq.db.frontend.schema :as db-schema]
    [datascript.core :as d]
-   [logseq.db :as ldb]))
+   [frontend.worker.rtc.client :as subject]
+   [logseq.db :as ldb]
+   [logseq.db.frontend.schema :as db-schema]))
 
 (def empty-db (d/empty-db db-schema/schema-for-db-based-graph))
 
@@ -14,7 +14,6 @@
           db (d/db-with empty-db [{:block/uuid block-uuid,
                                    :block/updated-at 1720017595873,
                                    :block/created-at 1720017595872,
-                                   :block/format :markdown,
                                    :db/ident :user.class/yyy,
                                    :block/type "class",
                                    :block/name "yyy",
@@ -47,7 +46,6 @@
                                    :block/updated-at 1716880036491
                                    :block/created-at 1716880036491
                                    :block/schema {:type :number}
-                                   :block/format :markdown
                                    :db/cardinality :db.cardinality/one
                                    :db/ident :user.property/xxx,
                                    :block/type "property",

+ 12 - 15
src/test/frontend/worker/rtc/db_listener_test.cljs

@@ -9,9 +9,9 @@
             [frontend.worker.rtc.db-listener :as subject]
             [frontend.worker.rtc.fixture :as r.fixture]
             [frontend.worker.state :as worker-state]
+            [logseq.db.test.helper :as db-test]
             [logseq.outliner.batch-tx :as batch-tx]
-            [logseq.outliner.core :as outliner-core]
-            [logseq.db.test.helper :as db-test]))
+            [logseq.outliner.core :as outliner-core]))
 
 (t/use-fixtures :each
   test-helper/db-based-start-and-destroy-db-map-fixture
@@ -49,7 +49,6 @@
                    [:db/add 1000000 :block/updated-at 1716882111476]
                    [:db/add 1000000 :block/created-at 1716882111476]
                    [:db/add 1000000 :block/schema {:type :number}]
-                   [:db/add 1000000 :block/format :markdown]
                    [:db/add 1000000 :db/cardinality :db.cardinality/one]
                    [:db/add 1000000 :db/ident :user.property/qqq]
                    [:db/add 1000000 :block/tags :logseq.class/Property]
@@ -87,7 +86,6 @@
                    [:db/add 1000000 :block/updated-at 1720019497643 536870954]
                    [:db/add 1000000 :logseq.property/parent :logseq.class/Root 536870954]
                    [:db/add 1000000 :block/created-at 1720019497643 536870954]
-                   [:db/add 1000000 :block/format :markdown 536870954]
                    [:db/add 1000000 :db/ident :user.class/zzz 536870954]
                    [:db/add 1000000 :block/tags :logseq.class/Tag 536870954]
                    [:db/add 1000000 :block/name "zzz" 536870954]
@@ -100,17 +98,18 @@
            [[:update-page {:block-uuid #uuid "66856a29-6eb3-4122-af97-8580a853c6a6"}]
             [:update {:block-uuid #uuid "66856a29-6eb3-4122-af97-8580a853c6a6",
                       :av-coll
-                      [[:block/updated-at "[\"~#'\",1720019497643]"]
-                       [:block/created-at "[\"~#'\",1720019497643]"]
-                       [:block/tags #uuid "00000002-5389-0208-3000-000000000000"]
-                       [:block/title "[\"~#'\",\"zzz\"]"]
-                       [:logseq.property/parent #uuid "00000002-2737-8382-7000-000000000000"]
+                      (set
+                       [[:block/updated-at "[\"~#'\",1720019497643]"]
+                        [:block/created-at "[\"~#'\",1720019497643]"]
+                        [:block/tags #uuid "00000002-5389-0208-3000-000000000000"]
+                        [:block/title "[\"~#'\",\"zzz\"]"]
+                        [:logseq.property/parent #uuid "00000002-2737-8382-7000-000000000000"]
                        ;;1. shouldn't have :db/ident, :db/ident is special, will be handled later
-                       ]}]]
+                        ])}]]
            (map (fn [[op-type _t op-value]]
                   [op-type (cond-> op-value
                              (:av-coll op-value)
-                             (assoc :av-coll (map #(take 2 %) (:av-coll op-value))))])
+                             (assoc :av-coll (set (map #(take 2 %) (:av-coll op-value)))))])
                 ops))))))
 
 (deftest listen-db-changes-and-validate-generated-rtc-ops
@@ -135,11 +134,9 @@
           (batch-tx/with-batch-tx-mode conn
             {:persist-op? true}
             (outliner-core/insert-blocks! repo conn [{:block/uuid block-uuid1
-                                                      :block/title "block1"
-                                                      :block/format :markdown}
+                                                      :block/title "block1"}
                                                      {:block/uuid block-uuid2
-                                                      :block/title "block2"
-                                                      :block/format :markdown}]
+                                                      :block/title "block2"}]
                                           target-entity
                                           {:sibling? false :keep-uuid? true}))
           (is (=