From d847023dc1310f944b91ccb0f137d95dc7760dc9 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Wed, 10 Jul 2024 22:33:44 +0800 Subject: [PATCH] Refactor: rename :block/content to :block/title --- deps/common/resources/templates/config.edn | 4 +- deps/db/script/create_graph.cljs | 2 +- deps/db/script/query.cljs | 4 +- deps/db/script/validate_client_db.cljs | 4 +- deps/db/src/logseq/db.cljs | 12 +- deps/db/src/logseq/db/frontend/content.cljs | 4 +- .../src/logseq/db/frontend/delete_blocks.cljs | 10 +- .../src/logseq/db/frontend/entity_plus.cljc | 10 +- .../src/logseq/db/frontend/malli_schema.cljs | 14 +-- deps/db/src/logseq/db/frontend/property.cljs | 4 +- .../logseq/db/frontend/property/build.cljs | 4 +- .../src/logseq/db/frontend/property/type.cljs | 6 +- deps/db/src/logseq/db/frontend/rules.cljc | 6 +- deps/db/src/logseq/db/frontend/schema.cljs | 2 - deps/db/src/logseq/db/sqlite/build.cljs | 12 +- .../test/logseq/db/frontend/inputs_test.cljs | 56 ++++----- deps/db/test/logseq/db/sqlite/build_test.cljs | 16 +-- .../test/logseq/db/sqlite/common_db_test.cljs | 2 +- .../logseq/db/sqlite/create_graph_test.cljs | 4 +- .../src/logseq/graph_parser/block.cljs | 10 +- .../src/logseq/graph_parser/exporter.cljs | 28 ++--- .../src/logseq/graph_parser/extract.cljc | 2 +- .../graph_parser/test/docs_graph_helper.cljs | 2 +- .../src/logseq/graph_parser/whiteboard.cljs | 4 +- .../test/logseq/graph_parser/block_test.cljs | 4 +- .../test/logseq/graph_parser/cli_test.cljs | 12 +- .../logseq/graph_parser/exporter_test.cljs | 10 +- .../logseq/graph_parser/extract_test.cljs | 6 +- .../test/logseq/graph_parser_test.cljs | 18 +-- .../exporter-test-graph/logseq/config.edn | 4 +- deps/outliner/script/transact.cljs | 2 +- deps/outliner/src/logseq/outliner/core.cljs | 26 ++-- .../src/logseq/outliner/pipeline.cljs | 4 +- .../src/logseq/outliner/property.cljs | 4 +- .../test/logseq/outliner/pipeline_test.cljs | 18 +-- .../test/logseq/outliner/property_test.cljs | 48 +++---- deps/publishing/src/logseq/publishing/db.cljs | 2 +- .../test/logseq/publishing/db_test.cljs | 4 +- docs/dev-practices.md | 6 +- .../create_graph_with_large_sizes.cljs | 6 +- .../create_graph_with_properties.cljs | 118 +++++++++--------- src/main/frontend/commands.cljs | 4 +- src/main/frontend/common_keywords.cljs | 12 +- src/main/frontend/components/block.cljs | 92 +++++++------- .../frontend/components/block/macros.cljs | 2 +- src/main/frontend/components/cmdk/core.cljs | 8 +- src/main/frontend/components/content.cljs | 2 +- src/main/frontend/components/editor.cljs | 4 +- src/main/frontend/components/imports.cljs | 4 +- src/main/frontend/components/page.cljs | 2 +- .../frontend/components/property/value.cljs | 6 +- .../frontend/components/query/builder.cljs | 2 +- src/main/frontend/components/query_table.cljs | 12 +- src/main/frontend/components/views.cljs | 8 +- src/main/frontend/db/model.cljs | 4 +- src/main/frontend/extensions/pdf/assets.cljs | 2 +- src/main/frontend/extensions/srs.cljs | 6 +- src/main/frontend/extensions/tldraw.cljs | 2 +- src/main/frontend/external/roam_export.cljs | 15 ++- src/main/frontend/format/block.cljs | 16 +-- src/main/frontend/fs/diff_merge.cljs | 4 +- src/main/frontend/handler/block.cljs | 4 +- src/main/frontend/handler/code.cljs | 2 +- .../frontend/handler/common/developer.cljs | 4 +- .../frontend/handler/db_based/editor.cljs | 32 ++--- src/main/frontend/handler/editor.cljs | 100 +++++++-------- .../frontend/handler/editor/lifecycle.cljs | 4 +- src/main/frontend/handler/events.cljs | 2 +- src/main/frontend/handler/export.cljs | 2 +- .../frontend/handler/file_based/editor.cljs | 36 +++--- .../handler/file_based/page_property.cljs | 6 +- .../frontend/handler/file_based/property.cljs | 4 +- src/main/frontend/handler/import.cljs | 2 +- src/main/frontend/handler/route.cljs | 4 +- src/main/frontend/handler/whiteboard.cljs | 2 +- .../schema/handler/common_config.cljc | 2 +- src/main/frontend/search/browser.cljs | 2 +- src/main/frontend/state.cljs | 5 +- src/main/frontend/util/drawer.cljs | 4 +- src/main/frontend/worker/export.cljs | 2 +- src/main/frontend/worker/file.cljs | 6 +- src/main/frontend/worker/file/core.cljs | 6 +- src/main/frontend/worker/handler/page.cljs | 8 +- .../worker/handler/page/db_based/page.cljs | 2 +- .../worker/handler/page/file_based/page.cljs | 4 +- .../handler/page/file_based/rename.cljs | 8 +- src/main/frontend/worker/rtc/const.cljs | 2 +- src/main/frontend/worker/rtc/db_listener.cljs | 2 +- .../frontend/worker/rtc/remote_update.cljs | 4 +- src/main/frontend/worker/rtc/skeleton.cljs | 2 +- src/main/frontend/worker/search.cljs | 20 ++- src/main/frontend/worker/undo_redo.cljs | 20 +-- src/main/frontend/worker/undo_redo2.cljs | 2 +- .../components/query/result_test.cljs | 8 +- .../frontend/components/query_table_test.cljs | 4 +- src/test/frontend/db/model_test.cljs | 4 +- src/test/frontend/db/query_custom_test.cljs | 12 +- src/test/frontend/db/query_dsl_test.cljs | 66 +++++----- src/test/frontend/db/query_react_test.cljs | 6 +- .../frontend/handler/editor_async_test.cljs | 12 +- src/test/frontend/handler/editor_test.cljs | 12 +- src/test/frontend/handler/paste_test.cljs | 4 +- src/test/frontend/handler/route_test.cljs | 8 +- .../frontend/modules/outliner/core_test.cljs | 12 +- src/test/frontend/test/generators.cljs | 2 +- src/test/frontend/test/helper.cljs | 16 +-- .../handler/page/file_based/rename_test.cljs | 2 +- .../worker/rtc/local_tx_to_remote_test.cljs | 4 +- .../worker/rtc/op_mem_layer_test.cljs | 14 +-- .../worker/rtc/remote_update_test.cljs | 8 +- .../frontend/worker/rtc/rtc_fns_test.cljs | 44 +++---- src/test/frontend/worker/undo_redo_test.cljs | 2 +- src/test/logseq/api_test.cljs | 8 +- 113 files changed, 634 insertions(+), 640 deletions(-) diff --git a/deps/common/resources/templates/config.edn b/deps/common/resources/templates/config.edn index 2ccb0f4b30..3995fe4aca 100644 --- a/deps/common/resources/templates/config.edn +++ b/deps/common/resources/templates/config.edn @@ -179,10 +179,10 @@ ;; Default value: false :shortcut/doc-mode-enter-for-new-block? false - ;; Block content larger than `block/content-max-length` will not be searchable + ;; Block content larger than `block/title-max-length` will not be searchable ;; or editable for performance. ;; Default value: 10000 - :block/content-max-length 10000 + :block/title-max-length 10000 ;; Display command documentation on hover. ;; Default value: true diff --git a/deps/db/script/create_graph.cljs b/deps/db/script/create_graph.cljs index e96d888026..128ce89f3a 100644 --- a/deps/db/script/create_graph.cljs +++ b/deps/db/script/create_graph.cljs @@ -30,7 +30,7 @@ conn (outliner-cli/init-conn dir db-name {:classpath (cp/get-classpath)}) {:keys [init-tx block-props-tx]} (outliner-cli/build-blocks-tx sqlite-build-edn)] (println "Generating" (count (filter :block/name init-tx)) "pages and" - (count (filter :block/content init-tx)) "blocks ...") + (count (filter :block/title init-tx)) "blocks ...") (d/transact! conn init-tx) (d/transact! conn block-props-tx) (println "Created graph" (str db-name "!")))) diff --git a/deps/db/script/query.cljs b/deps/db/script/query.cljs index aa7c16bd84..bf955c3b12 100644 --- a/deps/db/script/query.cljs +++ b/deps/db/script/query.cljs @@ -1,7 +1,7 @@ (ns query "An example script that queries any db graph from the commandline e.g. - $ yarn -s nbb-logseq script/query.cljs db-name '[:find (pull ?b [:block/name :block/content]) :where [?b :block/created-at]]'" + $ yarn -s nbb-logseq script/query.cljs db-name '[:find (pull ?b [:block/name :block/title]) :where [?b :block/created-at]]'" (:require [datascript.core :as d] [clojure.edn :as edn] [logseq.db.sqlite.cli :as sqlite-cli] @@ -72,4 +72,4 @@ (pprint/pprint results))))) (when (= nbb/*file* (:file (meta #'-main))) - (-main *command-line-args*)) \ No newline at end of file + (-main *command-line-args*)) diff --git a/deps/db/script/validate_client_db.cljs b/deps/db/script/validate_client_db.cljs index ecbd298326..50f7b8b378 100644 --- a/deps/db/script/validate_client_db.cljs +++ b/deps/db/script/validate_client_db.cljs @@ -80,7 +80,7 @@ (println "Read graph" (str db-name " with " (count datoms) " datoms, " (count ent-maps) " entities, " (count (filter :block/name ent-maps)) " pages, " - (count (filter :block/content ent-maps)) " blocks, " + (count (filter :block/title ent-maps)) " blocks, " (count (filter #(contains? (:block/type %) "class") ent-maps)) " classes, " (count (filter #(seq (:block/tags %)) ent-maps)) " objects, " (count (filter #(contains? (:block/type %) "property") ent-maps)) " properties and " @@ -97,4 +97,4 @@ (validate-graph graph-dir opts)))) (when (= nbb/*file* (:file (meta #'-main))) - (-main *command-line-args*)) \ No newline at end of file + (-main *command-line-args*)) diff --git a/deps/db/src/logseq/db.cljs b/deps/db/src/logseq/db.cljs index 1af01b3f32..61289cece4 100644 --- a/deps/db/src/logseq/db.cljs +++ b/deps/db/src/logseq/db.cljs @@ -28,7 +28,7 @@ :block/path-refs :block/tags :block/link - :block/content + :block/title :block/marker :block/priority :block/properties @@ -60,7 +60,7 @@ (let [tx-data (map (fn [m] (if (map? m) (dissoc m :block/children :block/meta :block/top? :block/bottom? :block/anchor - :block/title :block/body :block/level :block/container :db/other-tx + :block.temp/ast-title :block.temp/ast-body :block/level :block/container :db/other-tx :block/unordered) m)) tx-data) tx-data (->> (common-util/fast-remove-nils tx-data) @@ -245,7 +245,7 @@ (and first-child (= 1 (count children)) - (contains? #{"" "-" "*"} (string/trim (:block/content first-child)))))) + (contains? #{"" "-" "*"} (string/trim (:block/title first-child)))))) (not (contains? built-in-pages name)) (not (whiteboard-page? page)) (not (:block/_namespace page)) @@ -432,7 +432,7 @@ (when-let [e (d/entity db eid)] (or (some alias (map :db/id (:block/refs e))) (:block/link e) - (nil? (:block/content e))))) + (nil? (:block/title e))))) search-result-eids)] (when (seq eids) (d/pull-many db '[*] eids)))) @@ -481,7 +481,7 @@ "Builds tx for a favorite block in favorite page" [favorite-uuid] {:block/link [:block/uuid favorite-uuid] - :block/content "" + :block/title "" :block/format :markdown}) (defn create-views-page! @@ -498,7 +498,7 @@ :block/format :markdown}) (sqlite-util/block-with-timestamps {:block/uuid (common-uuid/gen-uuid) - :block/content "" + :block/title "" :block/format :markdown :block/parent [:block/uuid page-id] :block/order (db-order/gen-key nil) diff --git a/deps/db/src/logseq/db/frontend/content.cljs b/deps/db/src/logseq/db/frontend/content.cljs index 7c3d7842fe..2ea51b2ef0 100644 --- a/deps/db/src/logseq/db/frontend/content.cljs +++ b/deps/db/src/logseq/db/frontend/content.cljs @@ -93,9 +93,9 @@ "Replace `[[internal-id]]` with `[[page name]]`" [repo db item eid] (if (sqlite-util/db-based-graph? repo) - (if-let [content (:block/content item)] + (if-let [content (:block/title item)] (let [refs (:block/refs (d/entity db eid))] - (assoc item :block/content (special-id-ref->page-ref content refs))) + (assoc item :block/title (special-id-ref->page-ref content refs))) item) item)) diff --git a/deps/db/src/logseq/db/frontend/delete_blocks.cljs b/deps/db/src/logseq/db/frontend/delete_blocks.cljs index 7f15b14aea..11e3cd2974 100644 --- a/deps/db/src/logseq/db/frontend/delete_blocks.cljs +++ b/deps/db/src/logseq/db/frontend/delete_blocks.cljs @@ -13,7 +13,7 @@ (mapcat (fn [ref] (if replacing-block-ref (let [id (:db/id ref) - new-content (some-> (:block/content ref) + new-content (some-> (:block/title ref) (string/replace (block-ref/->block-ref (str (:block/uuid block))) (block-ref/->block-ref (str (:block/uuid replacing-block-ref))))) tx (cond-> @@ -22,11 +22,11 @@ [:db/add (:db/id ref) :block/refs (:db/id replacing-block-ref)] [:db/add (:db/id ref) :block/path-refs (:db/id replacing-block-ref)]] new-content - (conj [:db/add id :block/content new-content]))] + (conj [:db/add id :block/title new-content]))] tx) (let [id (:db/id ref) - block-content (:block/content block) - new-content (some-> (:block/content ref) + block-content (:block/title block) + new-content (some-> (:block/title ref) (string/replace (re-pattern (common-util/format "(?i){{embed \\(\\(%s\\)\\)\\s?}}" (str (:block/uuid block)))) block-content) (string/replace (block-ref/->block-ref (str (:block/uuid block))) @@ -35,7 +35,7 @@ [[:db/retract (:db/id ref) :block/refs (:db/id block)] [:db/retract (:db/id ref) :block/path-refs (:db/id block)]] new-content - (conj [:db/add id :block/content new-content]))] + (conj [:db/add id :block/title new-content]))] tx))) refs))) (apply concat))) diff --git a/deps/db/src/logseq/db/frontend/entity_plus.cljc b/deps/db/src/logseq/db/frontend/entity_plus.cljc index fd18b49f36..2014cd2a72 100644 --- a/deps/db/src/logseq/db/frontend/entity_plus.cljc +++ b/deps/db/src/logseq/db/frontend/entity_plus.cljc @@ -23,8 +23,8 @@ ([^Entity e k default-value] (when k (case k - :block/raw-content - (lookup-entity e :block/content default-value) + :block/raw-title + (lookup-entity e :block/title default-value) :block/properties (let [db (.-db e)] @@ -35,7 +35,7 @@ (into {}))) (lookup-entity e :block/properties nil))) - :block/content + :block/title (or (get (.-kv e) k) (let [result (lookup-entity e k default-value)] @@ -58,10 +58,6 @@ (->> (lookup-entity e :block/_closed-value-property default-value) (sort-by :block/order)) - :object/name - (or (lookup-entity e :block/title nil) - (lookup-entity e :block/content nil)) - (or (get (.-kv e) k) (lookup-entity e k default-value)))))) diff --git a/deps/db/src/logseq/db/frontend/malli_schema.cljs b/deps/db/src/logseq/db/frontend/malli_schema.cljs index 18adde556e..94d12860ac 100644 --- a/deps/db/src/logseq/db/frontend/malli_schema.cljs +++ b/deps/db/src/logseq/db/frontend/malli_schema.cljs @@ -331,7 +331,7 @@ (def block-attrs "Common attributes for normal blocks" - [[:block/content :string] + [[:block/title :string] [:block/parent :int] [:block/order block-order] ;; refs @@ -346,7 +346,7 @@ (vec (concat [:map] - [[:block/content :string] + [[:block/title :string] [:block/parent :int] ;; These blocks only associate with pages of type "whiteboard" [:block/page :int] @@ -359,7 +359,7 @@ (concat [:map] [[:property.value/content [:or :string :double :boolean]]] - (remove #(#{:block/content} (first %)) block-attrs) + (remove #(#{:block/title} (first %)) block-attrs) page-or-block-attrs))) (def closed-value-block* @@ -369,22 +369,22 @@ [[:block/type [:= #{"closed value"}]] ;; for built-in properties [:db/ident {:optional true} logseq-property-ident] - [:block/content {:optional true} :string] + [:block/title {:optional true} :string] [:property.value/content {:optional true} [:or :string :double]] [:block/closed-value-property {:optional true} [:set :int]] [:block/schema {:optional true} [:map [:description {:optional true} :string]]]] - (remove #(#{:block/content} (first %)) block-attrs) + (remove #(#{:block/title} (first %)) block-attrs) page-or-block-attrs))) (def closed-value-block "A closed value for a property with closed/allowed values" [:and closed-value-block* - [:fn {:error/message ":block/content or :property.value/content required" + [:fn {:error/message ":block/title or :property.value/content required" :error/path [:property.value/content]} (fn [m] - (or (:block/content m) (:property.value/content m)))]]) + (or (:block/title m) (:property.value/content m)))]]) (def normal-block "A block with content and no special type or tag behavior" diff --git a/deps/db/src/logseq/db/frontend/property.cljs b/deps/db/src/logseq/db/frontend/property.cljs index 862327f722..e5986d4610 100644 --- a/deps/db/src/logseq/db/frontend/property.cljs +++ b/deps/db/src/logseq/db/frontend/property.cljs @@ -249,14 +249,14 @@ (defn closed-value-content "Gets content/value of a given closed value ent/map. Works for all closed value types" [ent] - (or (:block/content ent) + (or (:block/title ent) (:property.value/content ent))) (defn property-value-content "Given an entity, gets the content for the property value of a ref type property i.e. what the user sees. For page types the content is the page name" [ent] - (or (:block/content ent) + (or (:block/title ent) (if-some [content (:property.value/content ent)] content (:block/title ent)))) diff --git a/deps/db/src/logseq/db/frontend/property/build.cljs b/deps/db/src/logseq/db/frontend/property/build.cljs index bf3971cbb5..7b8a4d2410 100644 --- a/deps/db/src/logseq/db/frontend/property/build.cljs +++ b/deps/db/src/logseq/db/frontend/property/build.cljs @@ -17,7 +17,7 @@ :block/parent property-id} (if (db-property-type/original-value-ref-property-types (get-in property [:block/schema :type])) {:property.value/content value} - {:block/content value})))) + {:block/title value})))) (defn build-closed-value-block "Builds a closed value block to be transacted" @@ -73,7 +73,7 @@ :block/order (db-order/gen-key)} (if (db-property-type/original-value-ref-property-types (get-in property [:block/schema :type])) {:property.value/content value} - {:block/content value})) + {:block/title value})) sqlite-util/block-with-timestamps)) (defn build-property-values-tx-m diff --git a/deps/db/src/logseq/db/frontend/property/type.cljs b/deps/db/src/logseq/db/frontend/property/type.cljs index 22648cd7c9..3d891d4dee 100644 --- a/deps/db/src/logseq/db/frontend/property/type.cljs +++ b/deps/db/src/logseq/db/frontend/property/type.cljs @@ -37,13 +37,13 @@ (def value-ref-property-types "Property value ref types where the refed entities either store their value in - :property.value/content or :block/content (for :default)" + :property.value/content or :block/title (for :default)" (into #{:default} original-value-ref-property-types)) (def ref-property-types "User facing ref types. Property values that users see are stored in either - :property.value/content, :block/content or :block/title. + :property.value/content, :block/title. :block/title is for all the page related types" (into #{:page :date :object} value-ref-property-types)) @@ -115,7 +115,7 @@ (if new-closed-value? (string? s) (when-let [ent (d/entity db s)] - (string? (:block/content ent))))) + (string? (:block/title ent))))) (defn- page? [db val] diff --git a/deps/db/src/logseq/db/frontend/rules.cljc b/deps/db/src/logseq/db/frontend/rules.cljc index efb357c537..a39227293e 100644 --- a/deps/db/src/logseq/db/frontend/rules.cljc +++ b/deps/db/src/logseq/db/frontend/rules.cljc @@ -120,7 +120,7 @@ :block-content '[(block-content ?b ?query) - [?b :block/content ?content] + [?b :block/title ?content] [(clojure.string/includes? ?content ?query)]] :page @@ -171,7 +171,7 @@ '[(page-property ?p ?prop ?val) [?p :block/name] [?p ?prop ?pv] - (or [?pv :block/content ?val] + (or [?pv :block/title ?val] [?pv :property.value/content ?val] [?pv :block/title ?val]) [?prop-e :db/ident ?prop] @@ -187,7 +187,7 @@ :property '[(property ?b ?prop ?val) [?b ?prop ?pv] - (or [?pv :block/content ?val] + (or [?pv :block/title ?val] [?pv :property.value/content ?val] [?pv :block/title ?val]) [(missing? $ ?b :block/name)] diff --git a/deps/db/src/logseq/db/frontend/schema.cljs b/deps/db/src/logseq/db/frontend/schema.cljs index f4d449e331..7476fe75d0 100644 --- a/deps/db/src/logseq/db/frontend/schema.cljs +++ b/deps/db/src/logseq/db/frontend/schema.cljs @@ -52,8 +52,6 @@ :block/alias {:db/valueType :db.type/ref :db/cardinality :db.cardinality/many} - :block/content {} - ;; todo keywords, e.g. "TODO", "DOING", "DONE" :block/marker {} diff --git a/deps/db/src/logseq/db/sqlite/build.cljs b/deps/db/src/logseq/db/sqlite/build.cljs index 08297be9e0..ba778a9c97 100644 --- a/deps/db/src/logseq/db/sqlite/build.cljs +++ b/deps/db/src/logseq/db/sqlite/build.cljs @@ -99,7 +99,7 @@ (db-property-build/build-property-values-tx-m new-block))) (defn- extract-content-refs - "Extracts basic refs from :block/content like `[[foo]]`. Adding more ref support would + "Extracts basic refs from :block/title like `[[foo]]`. Adding more ref support would require parsing each block with mldoc and extracting with text/extract-refs-from-mldoc-ast" [s] ;; FIXME: Better way to ignore refs inside a macro @@ -114,7 +114,7 @@ :block/order (db-order/gen-key nil) :block/parent (or (:block/parent m) {:db/id page-id})} pvalue-tx-m (->property-value-tx-m new-block properties properties-config all-idents) - ref-names (extract-content-refs (:block/content m))] + ref-names (extract-content-refs (:block/title m))] (cond-> [] ;; Place property values first since they are referenced by block (seq pvalue-tx-m) @@ -134,7 +134,7 @@ (throw (ex-info (str "No uuid for page ref name" (pr-str %)) {}))) :block/title %) ref-names)] - {:block/content (db-content/page-ref->special-id-ref (:block/content m) block-refs) + {:block/title (db-content/page-ref->special-id-ref (:block/title m) block-refs) :block/refs block-refs}))))))) (defn- build-properties-tx [properties page-uuids all-idents] @@ -222,7 +222,7 @@ {:closed true ;; Define recursive :block schema :registry {::block [:map - [:block/content :string] + [:block/title :string] [:build/children {:optional true} [:vector [:ref ::block]]] [:build/properties {:optional true} User-properties] [:build/tags {:optional true} [:vector Class]]]}} @@ -398,7 +398,7 @@ (mapcat (fn [{:keys [blocks]}] (->> blocks - (mapcat #(extract-content-refs (:block/content %))) + (mapcat #(extract-content-refs (:block/title %))) (remove existing-pages)))) distinct (map #(hash-map :page {:block/title %})))] @@ -557,7 +557,7 @@ is not required if using this since it generates one * :build/properties - Defines properties on a page * :blocks - This is a vec of datascript attribute maps for blocks with - :block/content required. e.g. `{:block/content \"bar\"}`. Additional keys available: + :block/title required. e.g. `{:block/title \"bar\"}`. Additional keys available: * :build/children - A vec of blocks that are nested (indented) under the current block. Allows for outlines to be expressed to whatever depth * :build/properties - Defines properties on a block diff --git a/deps/db/test/logseq/db/frontend/inputs_test.cljs b/deps/db/test/logseq/db/frontend/inputs_test.cljs index a0f2e195b2..0428bc26dd 100644 --- a/deps/db/test/logseq/db/frontend/inputs_test.cljs +++ b/deps/db/test/logseq/db/frontend/inputs_test.cljs @@ -20,12 +20,12 @@ _ (sqlite-build/create-blocks conn [{:page {:block/title "page1"} - :blocks [{:block/content "parent" + :blocks [{:block/title "parent" :build/children - [{:block/content "child 1"} - {:block/content "child 2"}]}]}])] + [{:block/title "child 1"} + {:block/title "child 2"}]}]}])] (is (= ["child 2" "child 1" "parent"] - (map :block/content + (map :block/title (custom-query @conn {:inputs [:current-page] :query '[:find (pull ?b [*]) @@ -36,7 +36,7 @@ ":current-page input resolves to current page name") (is (= [] - (map :block/content + (map :block/title (custom-query @conn {:inputs [:current-page] :query '[:find (pull ?b [*]) @@ -47,10 +47,10 @@ (is (= ["child 1" "child 2"] (let [block-uuid (-> (d/q '[:find (pull ?b [:block/uuid]) - :where [?b :block/content "parent"]] @conn) + :where [?b :block/title "parent"]] @conn) ffirst :block/uuid)] - (map :block/content + (map :block/title (custom-query @conn {:inputs [:current-block] :query '[:find (pull ?b [*]) @@ -83,10 +83,10 @@ (is (= ["parent"] (let [block-uuid (-> (d/q '[:find (pull ?b [:block/uuid]) - :where [?b :block/content "child 1"]] @conn) + :where [?b :block/title "child 1"]] @conn) ffirst :block/uuid)] - (map :block/content + (map :block/title (custom-query @conn {:inputs [:parent-block] :query '[:find (pull ?parent-block [*]) @@ -100,12 +100,12 @@ _ (sqlite-build/create-blocks conn [{:page {:build/journal 20230101} - :blocks [{:block/content "b1"}]} + :blocks [{:block/title "b1"}]} {:page {:build/journal 20230107} - :blocks [{:block/content "b2"}]}])] + :blocks [{:block/title "b2"}]}])] (is (= ["b2"] (with-redefs [t/today (constantly (t/date-time 2023 1 7))] - (map :block/content + (map :block/title (custom-query @conn {:inputs [:3d-before :today] :query '[:find (pull ?b [*]) @@ -115,7 +115,7 @@ (is (= ["b1"] (with-redefs [t/today (constantly (t/date-time 2022 12 31))] - (map :block/content + (map :block/title (custom-query @conn {:inputs [:tomorrow :4d-after] :query '[:find (pull ?b [*]) @@ -126,12 +126,12 @@ (defn- block-with-content [db block-content] (-> (d/q '[:find (pull ?b [:block/uuid]) :in $ ?content - :where [?b :block/content ?content]] + :where [?b :block/title ?content]] db block-content) ffirst)) (defn- blocks-on-journal-page-from-block-with-content [db page-input block-content current-page-date] - (map :block/content + (map :block/title (custom-query db {:inputs [page-input] :query '[:find (pull ?b [*]) @@ -149,9 +149,9 @@ conn (d/create-conn db-schema/schema-for-db-based-graph) _ (sqlite-build/create-blocks conn - [{:page {:build/journal 20221231} :blocks [{:block/content "-1d"}]} - {:page {:build/journal 20230101} :blocks [{:block/content "now"}]} - {:page {:build/journal 20230102} :blocks [{:block/content "+1d"}]}]) + [{:page {:build/journal 20221231} :blocks [{:block/title "-1d"}]} + {:page {:build/journal 20230101} :blocks [{:block/title "now"}]} + {:page {:build/journal 20230102} :blocks [{:block/title "+1d"}]}]) db @conn] (is (= ["now"] (blocks-on-journal-page-from-block-with-content db :current-page "now" current-date)) ":current-page resolves to the stateful page when called from a block on the stateful page") @@ -168,7 +168,7 @@ (defn- blocks-journaled-between-inputs [db a b] ;; reverse is for sort order and may be brittle (reverse - (map :block/content + (map :block/title (custom-query db {:inputs [a b] :query '[:find (pull ?b [*]) @@ -179,15 +179,15 @@ (let [conn (d/create-conn db-schema/schema-for-db-based-graph) _ (sqlite-build/create-blocks conn - [{:page {:build/journal 20220101} :blocks [{:block/content "-1y"}]} - {:page {:build/journal 20221201} :blocks [{:block/content "-1m"}]} - {:page {:build/journal 20221225} :blocks [{:block/content "-1w"}]} - {:page {:build/journal 20221231} :blocks [{:block/content "-1d"}]} - {:page {:build/journal 20230101} :blocks [{:block/content "now"}]} - {:page {:build/journal 20230102} :blocks [{:block/content "+1d"}]} - {:page {:build/journal 20230108} :blocks [{:block/content "+1w"}]} - {:page {:build/journal 20230201} :blocks [{:block/content "+1m"}]} - {:page {:build/journal 20240101} :blocks [{:block/content "+1y"}]}]) + [{:page {:build/journal 20220101} :blocks [{:block/title "-1y"}]} + {:page {:build/journal 20221201} :blocks [{:block/title "-1m"}]} + {:page {:build/journal 20221225} :blocks [{:block/title "-1w"}]} + {:page {:build/journal 20221231} :blocks [{:block/title "-1d"}]} + {:page {:build/journal 20230101} :blocks [{:block/title "now"}]} + {:page {:build/journal 20230102} :blocks [{:block/title "+1d"}]} + {:page {:build/journal 20230108} :blocks [{:block/title "+1w"}]} + {:page {:build/journal 20230201} :blocks [{:block/title "+1m"}]} + {:page {:build/journal 20240101} :blocks [{:block/title "+1y"}]}]) db @conn] (with-redefs [t/today (constantly (t/date-time 2023 1 1))] (is (= ["now" "-1d" "-1w" "-1m" "-1y"] (blocks-journaled-between-inputs db :-365d :today)) diff --git a/deps/db/test/logseq/db/sqlite/build_test.cljs b/deps/db/test/logseq/db/sqlite/build_test.cljs index 78b4fd1112..b3b3652b9a 100644 --- a/deps/db/test/logseq/db/sqlite/build_test.cljs +++ b/deps/db/test/logseq/db/sqlite/build_test.cljs @@ -12,11 +12,11 @@ _ (sqlite-build/create-blocks conn [{:page {:block/title "page1"} - :blocks [{:block/content "Jrue Holiday" :build/tags [:Person]}]} + :blocks [{:block/title "Jrue Holiday" :build/tags [:Person]}]} {:page {:block/title "Jayson Tatum" :build/tags [:Person]}}])] (is (= {:block/tags [{:block/title "Person", :block/type ["class" "page"]}]} (first (d/q '[:find [(pull ?b [{:block/tags [:block/title :block/type]}]) ...] - :where [?b :block/content "Jrue Holiday"]] + :where [?b :block/title "Jrue Holiday"]] @conn))) "Person class is created and correctly associated to a block") @@ -32,12 +32,12 @@ _ (sqlite-build/create-blocks conn [{:page {:block/title "page1"} - :blocks [{:block/content "Jrue Holiday" :build/properties {:description "Clutch defense"}}]} + :blocks [{:block/title "Jrue Holiday" :build/properties {:description "Clutch defense"}}]} {:page {:block/title "Jayson Tatum" :build/properties {:description "Awesome selfless basketball"}}}])] (is (= "Clutch defense" (->> @conn (d/q '[:find [(pull ?b [*]) ...] - :where [?b :block/content "Jrue Holiday"]]) + :where [?b :block/title "Jrue Holiday"]]) first :user.property/description (db-property/ref->property-value-contents @conn))) @@ -58,14 +58,14 @@ _ (sqlite-build/create-blocks conn [{:page {:block/title "page1"} - :blocks [{:block/content "some todo" + :blocks [{:block/title "some todo" :build/properties {:logseq.task/status :logseq.task/status.doing}} - {:block/content "some slide" + {:block/title "some slide" :build/properties {:logseq.property/background-image "https://placekitten.com/200/300"}}]}])] (is (= "Doing" (->> @conn (d/q '[:find [(pull ?b [*]) ...] - :where [?b :block/content "some todo"]]) + :where [?b :block/title "some todo"]]) first :logseq.task/status (db-property/ref->property-value-contents @conn))) @@ -74,7 +74,7 @@ (is (= "https://placekitten.com/200/300" (->> @conn (d/q '[:find [(pull ?b [*]) ...] - :where [?b :block/content "some slide"]]) + :where [?b :block/title "some slide"]]) first :logseq.property/background-image (db-property/ref->property-value-contents @conn))) diff --git a/deps/db/test/logseq/db/sqlite/common_db_test.cljs b/deps/db/test/logseq/db/sqlite/common_db_test.cljs index cdd4be551d..72af68db53 100644 --- a/deps/db/test/logseq/db/sqlite/common_db_test.cljs +++ b/deps/db/test/logseq/db/sqlite/common_db_test.cljs @@ -57,7 +57,7 @@ :block/created-at created-at :block/updated-at created-at} {:db/id 100002 - :block/content "test" + :block/title "test" :block/uuid block-uuid :block/page {:db/id 100001} :block/created-at created-at diff --git a/deps/db/test/logseq/db/sqlite/create_graph_test.cljs b/deps/db/test/logseq/db/sqlite/create_graph_test.cljs index b8ae5eebd4..025427749c 100644 --- a/deps/db/test/logseq/db/sqlite/create_graph_test.cljs +++ b/deps/db/test/logseq/db/sqlite/create_graph_test.cljs @@ -90,9 +90,9 @@ {:properties {:url {:block/schema {:type :url}}} :pages-and-blocks [{:page {:block/title "page1"} - :blocks [{:block/content "b1" :build/properties {:url "https://logseq.com"}} + :blocks [{:block/title "b1" :build/properties {:url "https://logseq.com"}} ;; :url macros are used for consistently building urls with the same hostname e.g. docs graph - {:block/content "b2" :build/properties {:url "{{docs-base-url test}}"}}]}]}) + {:block/title "b2" :build/properties {:url "{{docs-base-url test}}"}}]}]}) (is (empty? (map :entity (:errors (db-validate/validate-db! @conn)))) "Graph with different :url blocks has no validation errors")))) diff --git a/deps/graph-parser/src/logseq/graph_parser/block.cljs b/deps/graph-parser/src/logseq/graph_parser/block.cljs index 0287af9422..f27ed3df24 100644 --- a/deps/graph-parser/src/logseq/graph_parser/block.cljs +++ b/deps/graph-parser/src/logseq/graph_parser/block.cljs @@ -523,7 +523,7 @@ (map :block/title)) pre-block? (if (:heading properties) false true) block {:block/uuid id - :block/content content + :block/title content :block/level 1 :block/properties properties :block/properties-order (vec properties-order) @@ -531,7 +531,7 @@ :block/invalid-properties invalid-properties :block/pre-block? pre-block? :block/macros (extract-macros-from-ast body) - :block/body body} + :block.temp/ast-body body} {:keys [tags refs]} (with-page-block-refs {:body body :refs property-refs} db date-formatter)] (cond-> block @@ -583,7 +583,7 @@ (update :properties-order (fn [keys] (vec (remove #{:collapsed} keys))))) block) block (assoc block - :content (get-block-content encoded-content block format pos-meta block-pattern)) + :block/title (get-block-content encoded-content block format pos-meta block-pattern)) block (if (seq timestamps) (merge block (timestamps->scheduled-and-deadline timestamps)) block) @@ -604,13 +604,13 @@ (defn fix-duplicate-id [block] - (println "Logseq will assign a new id for block with content:" (pr-str (:block/content block))) + (println "Logseq will assign a new id for block with content:" (pr-str (:block/title block))) (-> block (assoc :block/uuid (d/squuid)) (update :block/properties dissoc :id) (update :block/properties-text-values dissoc :id) (update :block/properties-order #(vec (remove #{:id} %))) - (update :block/content (fn [c] + (update :block/title (fn [c] (let [replace-str (re-pattern (str "\n*\\s*" diff --git a/deps/graph-parser/src/logseq/graph_parser/exporter.cljs b/deps/graph-parser/src/logseq/graph_parser/exporter.cljs index e781a7f989..83aa4deaaa 100644 --- a/deps/graph-parser/src/logseq/graph_parser/exporter.cljs +++ b/deps/graph-parser/src/logseq/graph_parser/exporter.cljs @@ -111,12 +111,12 @@ (if (seq (:block/tags block)) (let [original-tags (remove :block.temp/new-class (:block/tags block))] (-> block - (update :block/content + (update :block/title content-without-tags-ignore-case (->> original-tags (filter #(tag-classes (:block/name %))) (map :block/title))) - (update :block/content + (update :block/title db-content/replace-tags-with-page-refs (->> original-tags (remove #(tag-classes (:block/name %))) @@ -146,7 +146,7 @@ :logseq.task/status.todo))] (-> block (assoc :logseq.task/status status-ident) - (update :block/content string/replace-first (re-pattern (str marker "\\s*")) "") + (update :block/title string/replace-first (re-pattern (str marker "\\s*")) "") (update :block/tags (fnil conj []) :logseq.class/task) (update :block/refs (fn [refs] (into (remove #(= marker (:block/title %)) refs) @@ -169,7 +169,7 @@ :logseq.task/priority.low))] (-> block (assoc :logseq.task/priority priority-value) - (update :block/content string/replace-first (re-pattern (str "\\[#" priority "\\]" "\\s*")) "") + (update :block/title string/replace-first (re-pattern (str "\\[#" priority "\\]" "\\s*")) "") (update :block/refs (fn [refs] (into (remove #(= priority (:block/title %)) refs) [:logseq.task/priority priority-value]))) @@ -180,7 +180,7 @@ block)) (defn- update-block-deadline - ":block/content doesn't contain DEADLINE.* text so unable to detect timestamp + ":block/title doesn't contain DEADLINE.* text so unable to detect timestamp or repeater usage and notify user that they aren't supported" [block db {:keys [user-config]}] (if-let [date-int (or (:block/deadline block) (:block/scheduled block))] @@ -288,13 +288,13 @@ (->> built-in-property-name-to-idents keys set)) (defn- update-built-in-property-values - [props {:keys [ignored-properties all-idents]} {:block/keys [content name]}] + [props {:keys [ignored-properties all-idents]} {:block/keys [title name]}] (->> props (keep (fn [[prop val]] (if (= :icon prop) (do (swap! ignored-properties conj - {:property prop :value val :location (if name {:page name} {:block content})}) + {:property prop :value val :location (if name {:page name} {:block title})}) nil) [(built-in-property-name-to-idents prop) (case prop @@ -435,7 +435,7 @@ (let [props' (-> (update-built-in-property-values (select-keys props built-in-property-names) (select-keys import-state [:ignored-properties :all-idents]) - (select-keys block [:block/name :block/content])) + (select-keys block [:block/name :block/title])) (merge (update-user-property-values user-properties page-names-to-uuids properties-text-values import-state options))) pvalue-tx-m (->property-value-tx-m block props' #(get @property-schemas %) @all-idents) block-properties (-> (merge props' (db-property-build/build-properties-with-ref-values pvalue-tx-m)) @@ -508,7 +508,7 @@ options' (assoc options :property-changes property-changes) {:keys [block-properties pvalues-tx]} (build-properties-and-values properties' db page-names-to-uuids - (select-keys block [:block/properties-text-values :block/name :block/content :block/uuid]) + (select-keys block [:block/properties-text-values :block/name :block/title :block/uuid]) options')] {:block (cond-> block @@ -585,8 +585,8 @@ [:block/uuid (:block/uuid ref)]) ref)) refs))) - (:block/content block) - (update :block/content + (:block/title block) + (update :block/title db-content/page-ref->special-id-ref ;; TODO: Handle refs for whiteboard block which has none (->> (:block/refs block) @@ -714,9 +714,9 @@ {:property-ident property-ident :block-uuid (:block-uuid m)}))) prop-value-content (get-pvalue-content (:block/uuid m) prop)] - ;; Switch to :block/content since :default is stored differently + ;; Switch to :block/title since :default is stored differently [[:db/retract prop-value-id :property.value/content] - [:db/add prop-value-id :block/content prop-value-content]])) + [:db/add prop-value-id :block/title prop-value-content]])) existing-blocks) ;; Look up blocks about to be transacted for current file a.k.a. pending ;; Map of property value uuids to their original block uuids @@ -735,7 +735,7 @@ (let [prop-value-content (get-pvalue-content original-block-uuid prop) prop-value-id [:block/uuid (:block/uuid m)]] [[:db/retract prop-value-id :property.value/content] - [:db/add prop-value-id :block/content prop-value-content]]))) + [:db/add prop-value-id :block/title prop-value-content]]))) blocks-tx)] (concat existing-blocks-tx pending-blocks-tx))) diff --git a/deps/graph-parser/src/logseq/graph_parser/extract.cljc b/deps/graph-parser/src/logseq/graph_parser/extract.cljc index c71a2a238c..33378f2d02 100644 --- a/deps/graph-parser/src/logseq/graph_parser/extract.cljc +++ b/deps/graph-parser/src/logseq/graph_parser/extract.cljc @@ -261,7 +261,7 @@ (assoc page :block/uuid page-id))) pages) blocks (->> (remove nil? blocks) - (map (fn [b] (dissoc b :block/body :block/level :block/children :block/meta))))] + (map (fn [b] (dissoc b :block/title :block.temp/ast-body :block/level :block/children :block/meta))))] [pages blocks]) (catch :default e (log/error :exception e)))) diff --git a/deps/graph-parser/src/logseq/graph_parser/test/docs_graph_helper.cljs b/deps/graph-parser/src/logseq/graph_parser/test/docs_graph_helper.cljs index 610a5ebb0f..3a1a36410a 100644 --- a/deps/graph-parser/src/logseq/graph_parser/test/docs_graph_helper.cljs +++ b/deps/graph-parser/src/logseq/graph_parser/test/docs_graph_helper.cljs @@ -165,7 +165,7 @@ (is (= 23 (ffirst (d/q '[:find (count ?b) - :where [?b :block/content ?content] + :where [?b :block/title ?content] [(clojure.string/includes? ?content "+BEGIN_QUERY")]] db))) "Advanced query count")) diff --git a/deps/graph-parser/src/logseq/graph_parser/whiteboard.cljs b/deps/graph-parser/src/logseq/graph_parser/whiteboard.cljs index 06328e3a53..d58d20014c 100644 --- a/deps/graph-parser/src/logseq/graph_parser/whiteboard.cljs +++ b/deps/graph-parser/src/logseq/graph_parser/whiteboard.cljs @@ -58,7 +58,7 @@ (defn- with-whiteboard-content "Main purpose of this function is to populate contents when shapes are used as references in outliner." [shape] - {:block/content (case (:type shape) + {:block/title (case (:type shape) "text" (:text shape) "logseq-portal" "" "line" (str "whiteboard arrow" (when-let [label (:label shape)] (str ": " label))) @@ -84,7 +84,7 @@ properties {(db-property-util/get-pid repo :logseq.property/ls-type) :whiteboard-shape (db-property-util/get-pid repo :logseq.property.tldraw/shape) shape} block {:block/uuid block-uuid - :block/content "" + :block/title "" :block/page page-id :block/parent page-id} block' (if (sqlite-util/db-based-graph? repo) diff --git a/deps/graph-parser/test/logseq/graph_parser/block_test.cljs b/deps/graph-parser/test/logseq/graph_parser/block_test.cljs index 4bd7403b0f..144c59eee8 100644 --- a/deps/graph-parser/test/logseq/graph_parser/block_test.cljs +++ b/deps/graph-parser/test/logseq/graph_parser/block_test.cljs @@ -23,7 +23,7 @@ (and (:block/uuid result) (not= (:uuid x) (:block/uuid result)) (= (select-keys result - [:block/properties :block/content :block/properties-text-values :block/properties-order]) (gp-block/block-keywordize y)))) + [:block/properties :block/title :block/properties-text-values :block/properties-order]) (gp-block/block-keywordize y)))) {:properties {:id "63f199bc-c737-459f-983d-84acfcda14fe"}, :tags [], :format :markdown, :meta {:start_pos 51, :end_pos 101}, :macros [], :content "bar\nid:: 63f199bc-c737-459f-983d-84acfcda14fe", :properties-text-values {:id "63f199bc-c737-459f-983d-84acfcda14fe"}, :level 1, :uuid #uuid "63f199bc-c737-459f-983d-84acfcda14fe", :properties-order [:id]} {:properties {}, :content "bar", @@ -114,7 +114,7 @@ [db content] (->> (d/q '[:find (pull ?b [* {:block/refs [:block/uuid]}]) :in $ ?content - :where [?b :block/content ?content]] + :where [?b :block/title ?content]] db content) (map first) diff --git a/deps/graph-parser/test/logseq/graph_parser/cli_test.cljs b/deps/graph-parser/test/logseq/graph_parser/cli_test.cljs index 1aa96215b9..32e3e78c11 100644 --- a/deps/graph-parser/test/logseq/graph_parser/cli_test.cljs +++ b/deps/graph-parser/test/logseq/graph_parser/cli_test.cljs @@ -92,7 +92,7 @@ ;; Hardcode journal name until more are added (path/join graph-dir "journals" "2023_07_20.md") (path/join graph-dir "pages" (str (:block/name page) ".md"))) - (string/join "\n" (map #(str "- " (:block/content %)) blocks)))) + (string/join "\n" (map #(str "- " (:block/title %)) blocks)))) (let [{:keys [conn]} (gp-cli/parse-graph graph-dir {:verbose false})] @conn)) (defn- create-frontend-blocks @@ -151,28 +151,28 @@ ;; pages and their blocks which are being tested pages-to-blocks {{:block/name "page1" :block/type ["page"]} - [{:block/content "block 1"} {:block/content "block 2"}] + [{:block/title "block 1"} {:block/title "block 2"}] {:block/name "jul 20th, 2023" :block/type #{"journal"} :block/journal-day 20230720} - [{:block/content "b1"} {:block/content "b2"}]} + [{:block/title "b1"} {:block/title "b2"}]} file-db (create-file-db graph-dir pages-to-blocks) graph-db (create-graph-db "tmp" "file-and-db-graph" pages-to-blocks) ;; Only test meaningful differences like content, name and set of block attributes. ;; Most attribute values won't be the same as they are random e.g. timestamps and db ids. file-ents (->> (d/datoms file-db :eavt) datoms->entity-maps - (map #(assoc (or (not-empty (select-keys % [:block/content :block/name])) + (map #(assoc (or (not-empty (select-keys % [:block/title :block/name])) %) :attributes (disj (set (keys %)) :block/file :block/format))) set) db-ents (->> (d/datoms graph-db :eavt) datoms->entity-maps - (map #(assoc (or (not-empty (select-keys % [:block/content :block/name])) + (map #(assoc (or (not-empty (select-keys % [:block/title :block/name])) %) :attributes (cond-> (disj (set (keys %)) ;; Don't compare :block/format as db graphs ;; are purposely different :block/format) - (seq (:block/content %)) + (seq (:block/title %)) (set/difference #{:block/created-at :block/updated-at})))) set)] (println "Datom counts for file and db graphs are" (count (d/datoms file-db :eavt)) "and" (count (d/datoms graph-db :eavt))) diff --git a/deps/graph-parser/test/logseq/graph_parser/exporter_test.cljs b/deps/graph-parser/test/logseq/graph_parser/exporter_test.cljs index dd005cea75..89c9c9325b 100644 --- a/deps/graph-parser/test/logseq/graph_parser/exporter_test.cljs +++ b/deps/graph-parser/test/logseq/graph_parser/exporter_test.cljs @@ -26,13 +26,13 @@ (->> content (d/q '[:find [(pull ?b [*]) ...] :in $ ?pattern - :where [?b :block/content ?content] [(re-find ?pattern ?content)]] + :where [?b :block/title ?content] [(re-find ?pattern ?content)]] db) first) (->> content (d/q '[:find [(pull ?b [*]) ...] :in $ ?content - :where [?b :block/content ?content]] + :where [?b :block/title ?content]] db) first))) @@ -289,7 +289,7 @@ (let [block (find-block-by-content @conn #"Inception") tag-page (find-page-by-name @conn "Movie") tagged-page (find-page-by-name @conn "Interstellar")] - (is (string/starts-with? (str (:block/content block)) "Inception [[") + (is (string/starts-with? (str (:block/title block)) "Inception [[") "tagged block tag converts tag to page ref") (is (= [(:db/id tag-page)] (map :db/id (:block/refs block))) "tagged block has correct refs") @@ -309,7 +309,7 @@ (let [block (find-block-by-content @conn #"Inception") tag-page (find-page-by-name @conn "Movie") another-tag-page (find-page-by-name @conn "p0")] - (is (= (:block/content block) "Inception") + (is (= (:block/title block) "Inception") "tagged block with configured tag strips tag from content") (is (= [:user.class/Movie] (:block/tags (readable-properties @conn block))) @@ -332,7 +332,7 @@ _ (import-files-to-db files conn {:property-classes ["type"]})] (let [block (find-block-by-content @conn #"The Creator") tag-page (find-page-by-name @conn "Movie")] - (is (= (:block/content block) "The Creator") + (is (= (:block/title block) "The Creator") "tagged block with configured tag strips tag from content") (is (= [:user.class/Movie] (:block/tags (readable-properties @conn block))) diff --git a/deps/graph-parser/test/logseq/graph_parser/extract_test.cljs b/deps/graph-parser/test/logseq/graph_parser/extract_test.cljs index 5541bef307..fbf1e4410c 100644 --- a/deps/graph-parser/test/logseq/graph_parser/extract_test.cljs +++ b/deps/graph-parser/test/logseq/graph_parser/extract_test.cljs @@ -52,7 +52,7 @@ (defn- extract-block-content [text] (let [{:keys [blocks]} (extract "a.md" text)] - (mapv :block/content blocks))) + (mapv :block/title blocks))) (defn- extract-title [file text] (-> (extract file text) :pages first :block/properties :title)) @@ -129,9 +129,9 @@ (def foo-edn "Example exported whiteboard page as an edn exportable." '{:blocks - ({:block/content "foo content a", + ({:block/title "foo content a", :block/format :markdown}, - {:block/content "foo content b", + {:block/title "foo content b", :block/format :markdown}), :pages ({:block/format :markdown, diff --git a/deps/graph-parser/test/logseq/graph_parser_test.cljs b/deps/graph-parser/test/logseq/graph_parser_test.cljs index 4c6bfad479..56056faeea 100644 --- a/deps/graph-parser/test/logseq/graph_parser_test.cljs +++ b/deps/graph-parser/test/logseq/graph_parser_test.cljs @@ -11,10 +11,10 @@ (def foo-edn "Example exported whiteboard page as an edn exportable." '{:blocks - ({:block/content "foo content a", + ({:block/title "foo content a", :block/format :markdown :block/parent {:block/uuid #uuid "16c90195-6a03-4b3f-839d-095a496d9acd"}}, - {:block/content "foo content b", + {:block/title "foo content b", :block/format :markdown :block/parent {:block/uuid #uuid "16c90195-6a03-4b3f-839d-095a496d9acd"}}), :pages @@ -27,9 +27,9 @@ (def foo-conflict-edn "Example exported whiteboard page as an edn exportable." '{:blocks - ({:block/content "foo content a", + ({:block/title "foo content a", :block/format :markdown}, - {:block/content "foo content b", + {:block/title "foo content b", :block/format :markdown}), :pages ({:block/format :markdown, @@ -40,11 +40,11 @@ (def bar-edn "Example exported whiteboard page as an edn exportable." '{:blocks - ({:block/content "foo content a", + ({:block/title "foo content a", :block/format :markdown :block/parent {:block/uuid #uuid "71515b7d-b5fc-496b-b6bf-c58004a34ee3" :block/name "foo"}}, - {:block/content "foo content b", + {:block/title "foo content b", :block/format :markdown :block/parent {:block/uuid #uuid "71515b7d-b5fc-496b-b6bf-c58004a34ee3" :block/name "foo"}}), @@ -65,7 +65,7 @@ (is (= [{:id "628953c1-8d75-49fe-a648-f4c612109098"}] (->> (d/q '[:find (pull ?b [*]) :in $ - :where [?b :block/content] [(missing? $ ?b :block/name)]] + :where [?b :block/title] [(missing? $ ?b :block/name)]] @conn) (map first) (map :block/properties))) @@ -94,7 +94,7 @@ {:block/file [:file/path]}]}]) :in $ - :where [?b :block/content] [(missing? $ ?b :block/name)]] + :where [?b :block/title] [(missing? $ ?b :block/name)]] @conn) parent (:block/page (ffirst blocks))] (is (= {:block/name "foo" @@ -137,7 +137,7 @@ _ (parse-file conn "foo.md" body) properties-orders (->> (d/q '[:find (pull ?b [*]) :in $ - :where [?b :block/content] [(missing? $ ?b :block/name)]] + :where [?b :block/title] [(missing? $ ?b :block/name)]] @conn) (map first) (map :block/properties-order))] diff --git a/deps/graph-parser/test/resources/exporter-test-graph/logseq/config.edn b/deps/graph-parser/test/resources/exporter-test-graph/logseq/config.edn index 8f789ad7f8..0ececd7ec1 100644 --- a/deps/graph-parser/test/resources/exporter-test-graph/logseq/config.edn +++ b/deps/graph-parser/test/resources/exporter-test-graph/logseq/config.edn @@ -176,10 +176,10 @@ ;; Default value: false :shortcut/doc-mode-enter-for-new-block? false - ;; Block content larger than `block/content-max-length` will not be searchable + ;; Block content larger than `block/title-max-length` will not be searchable ;; or editable for performance. ;; Default value: 10000 - :block/content-max-length 10000 + :block/title-max-length 10000 ;; Display command documentation on hover. ;; Default value: true diff --git a/deps/outliner/script/transact.cljs b/deps/outliner/script/transact.cljs index 6479093147..2f0bab7b2b 100644 --- a/deps/outliner/script/transact.cljs +++ b/deps/outliner/script/transact.cljs @@ -31,7 +31,7 @@ (do (println "Would update" (count blocks-to-update) "blocks with the following tx:") (prn update-tx) (println "With the following blocks updated:") - (prn (map #(select-keys (d/entity @conn %) [:block/name :block/content]) blocks-to-update))) + (prn (map #(select-keys (d/entity @conn %) [:block/name :block/title]) blocks-to-update))) (do (db-pipeline/add-listener conn) (d/transact! conn update-tx) diff --git a/deps/outliner/src/logseq/outliner/core.cljs b/deps/outliner/src/logseq/outliner/core.cljs index 21426e81fa..df47aa8ee7 100644 --- a/deps/outliner/src/logseq/outliner/core.cljs +++ b/deps/outliner/src/logseq/outliner/core.cljs @@ -163,7 +163,7 @@ :block/tags (:block/tags m) :block/format :markdown) {:db/id (:db/id block-entity) - :block/content "" + :block/title "" :block/refs [] :block/link [:block/uuid (:block/uuid page-m)]}] merge-tx)))))) @@ -194,7 +194,7 @@ (map (fn [id-or-map] (if (uuid? id-or-map) {:block/uuid id-or-map} id-or-map))) (remove (fn [b] (nil? (d/entity db [:block/uuid (:block/uuid b)]))))) - content-refs (when-let [content (:block/content block)] + content-refs (when-let [content (:block/title block)] (gp-block/extract-refs-from-text repo db content date-formatter))] (concat property-refs content-refs))) @@ -238,7 +238,7 @@ (dissoc :block/properties)) m* (-> data' (dissoc :block/children :block/meta :block.temp/top? :block.temp/bottom? :block/unordered - :block/title :block/body :block/level :block.temp/fully-loaded?) + :block.temp/ast-title :block.temp/ast-body :block/level :block.temp/fully-loaded?) common-util/remove-nils block-with-updated-at fix-tag-ids) @@ -263,7 +263,7 @@ (when eid ;; Retract attributes to prepare for tx which rewrites block attributes - (when (or (and retract-attributes? (:block/content m)) + (when (or (and retract-attributes? (:block/title m)) (seq retract-attributes)) (let [retract-attributes (concat (if db-based? @@ -280,7 +280,7 @@ ;; Update block's page attributes (update-page-when-save-block txs-state block-entity m) ;; Remove orphaned refs from block - (when (and (:block/content m) (not= (:block/content m) (:block/content block-entity))) + (when (and (:block/title m) (not= (:block/title m) (:block/title block-entity))) (remove-orphaned-refs-when-save @conn txs-state block-entity m {:db-graph? db-based?}))) ;; handle others txs @@ -293,7 +293,7 @@ ;; delete heading property for db-based-graphs (when (and db-based? (integer? (:logseq.property/heading block-entity)) - (not (some-> (:block/content data) (string/starts-with? "#")))) + (not (some-> (:block/title data) (string/starts-with? "#")))) (swap! txs-state (fn [txs] (conj (vec txs) [:db/retract (:db/id block-entity) :logseq.property/heading])))) this)) @@ -368,7 +368,7 @@ ;; replace existing block (and (contains? #{:paste :insert-blocks} outliner-op) replace-empty-target? - (string/blank? (:block/content target-block)) + (string/blank? (:block/title target-block)) (zero? idx)) (get-id (:block/parent target-block)) @@ -431,7 +431,7 @@ db-based? (sqlite-util/db-based-graph? repo)] (if-let [list-type (and target-block (list-type-fn target-block))] (mapv - (fn [{:block/keys [content format] :as block}] + (fn [{:block/keys [title format] :as block}] (let [list? (and (some? (:block/uuid block)) (nil? (list-type-fn block)))] (cond-> block @@ -442,7 +442,7 @@ (update b :block/properties assoc (db-property-util/get-pid repo :logseq.property/order-list-type) list-type)))) (not db-based?) - (assoc :block/content (gp-property/insert-property repo format content :logseq.order-list-type list-type))))) + (assoc :block/title (gp-property/insert-property repo format title :logseq.order-list-type list-type))))) blocks) blocks))) @@ -604,12 +604,12 @@ _ (assert (some? target-block) (str "Invalid target: " target-block)) sibling? (if (ldb/page? target-block) false sibling?) replace-empty-target? (if (and (some? replace-empty-target?) - (:block/content target-block) - (string/blank? (:block/content target-block))) + (:block/title target-block) + (string/blank? (:block/title target-block))) replace-empty-target? (and sibling? - (:block/content target-block) - (string/blank? (:block/content target-block)) + (:block/title target-block) + (string/blank? (:block/title target-block)) (> (count blocks) 1))) blocks' (let [blocks' (blocks-with-level blocks)] (cond->> (blocks-with-ordered-list-props repo blocks' target-block sibling?) diff --git a/deps/outliner/src/logseq/outliner/pipeline.cljs b/deps/outliner/src/logseq/outliner/pipeline.cljs index 9da6b9bff6..9c3df3d9d7 100644 --- a/deps/outliner/src/logseq/outliner/pipeline.cljs +++ b/deps/outliner/src/logseq/outliner/pipeline.cljs @@ -133,8 +133,8 @@ (defn block-content-refs "Return ref block ids for given block" [db block] - (let [content (or (:block/raw-content block) - (:block/content block))] + (let [content (or (:block/raw-title block) + (:block/title block))] (when (string? content) (->> (db-content/get-matched-special-ids content) (map (fn [id] diff --git a/deps/outliner/src/logseq/outliner/property.cljs b/deps/outliner/src/logseq/outliner/property.cljs index 15ed4a1121..75f1b1eb7f 100644 --- a/deps/outliner/src/logseq/outliner/property.cljs +++ b/deps/outliner/src/logseq/outliner/property.cljs @@ -202,7 +202,7 @@ :in $ ?property-id ?raw-value :where [?b ?property-id ?v] - (or [?v :block/content ?raw-value] + (or [?v :block/title ?raw-value] [?v :property.value/content ?raw-value])] db property-id @@ -417,7 +417,7 @@ (dissoc schema :description))} (if (db-property-type/original-value-ref-property-types (get-in property [:block/schema :type])) {:property.value/content resolved-value} - {:block/content resolved-value}))) + {:block/title resolved-value}))) icon (assoc :logseq.property/icon icon)))] (let [max-order (:block/order (last (:property/closed-values property))) diff --git a/deps/outliner/test/logseq/outliner/pipeline_test.cljs b/deps/outliner/test/logseq/outliner/pipeline_test.cljs index e47e7578d4..7ef29096d7 100644 --- a/deps/outliner/test/logseq/outliner/pipeline_test.cljs +++ b/deps/outliner/test/logseq/outliner/pipeline_test.cljs @@ -11,7 +11,7 @@ (defn- get-blocks [db] (->> (d/q '[:find (pull ?b [* {:block/path-refs [:block/name :db/id]}]) :in $ - :where [?b :block/content] [(missing? $ ?b :logseq.property/built-in?)]] + :where [?b :block/title] [(missing? $ ?b :logseq.property/built-in?)]] db) (map first))) @@ -25,15 +25,15 @@ conn [{:page {:block/title "bar"}} {:page {:block/title "page1"} - :blocks [{:block/content "parent [[foo]]" + :blocks [{:block/title "parent [[foo]]" :build/children - [{:block/content "child [[baz]]" + [{:block/title "child [[baz]]" :build/children - [{:block/content "grandchild [[bing]]"}]}]}]}]) + [{:block/title "grandchild [[bing]]"}]}]}]}]) blocks (get-blocks @conn) ;; Update parent block to replace 'foo' with 'bar' ref new-tag-id (ffirst (d/q '[:find ?b :where [?b :block/title "bar"]] @conn)) - modified-blocks (map #(if (string/starts-with? (:block/content %) "parent") + modified-blocks (map #(if (string/starts-with? (:block/title %) "parent") (assoc % :block/refs [{:db/id new-tag-id}] :block/path-refs [{:db/id new-tag-id}]) @@ -43,12 +43,12 @@ _ (d/transact! conn refs-tx {:pipeline-replace? true}) updated-blocks (->> (get-blocks @conn) ;; Only keep enough of content to uniquely identify block - (map #(hash-map :block/content (re-find #"\w+" (:block/content %)) + (map #(hash-map :block/title (re-find #"\w+" (:block/title %)) :path-ref-names (set (map :block/name (:block/path-refs %))))))] - (is (= [{:block/content "parent" + (is (= [{:block/title "parent" :path-ref-names #{"page1" "bar"}} - {:block/content "child" + {:block/title "child" :path-ref-names #{"page1" "bar" "baz"}} - {:block/content "grandchild" + {:block/title "grandchild" :path-ref-names #{"page1" "bar" "baz" "bing"}}] updated-blocks))))) diff --git a/deps/outliner/test/logseq/outliner/property_test.cljs b/deps/outliner/test/logseq/outliner/property_test.cljs index 6d1d013549..74bb2fb3a5 100644 --- a/deps/outliner/test/logseq/outliner/property_test.cljs +++ b/deps/outliner/test/logseq/outliner/property_test.cljs @@ -11,7 +11,7 @@ (->> content (d/q '[:find [(pull ?b [*]) ...] :in $ ?content - :where [?b :block/content ?content]] + :where [?b :block/title ?content]] @conn) first)) @@ -67,8 +67,8 @@ (testing "Create a new :default property value" (let [conn (create-conn-with-blocks [{:page {:block/title "page1"} - :blocks [{:block/content "b1" :build/properties {:default "foo"}} - {:block/content "b2"}]}]) + :blocks [{:block/title "b1" :build/properties {:default "foo"}} + {:block/title "b2"}]}]) block (find-block-by-content conn "b2") ;; Use same args as outliner.op _ (outliner-property/create-property-text-block! conn (:db/id block) :user.property/default "" {}) @@ -84,8 +84,8 @@ (testing "Create cases for a new :one :number property value" (let [conn (create-conn-with-blocks [{:page {:block/title "page1"} - :blocks [{:block/content "b1" :build/properties {:num 2}} - {:block/content "b2"}]}]) + :blocks [{:block/title "b1" :build/properties {:num 2}} + {:block/title "b2"}]}]) block (find-block-by-content conn "b2") ;; Use same args as outliner.op _ (outliner-property/create-property-text-block! conn (:db/id block) :user.property/num "3" {}) @@ -107,8 +107,8 @@ (testing "Create new :many :number property values" (let [conn (create-conn-with-blocks [{:page {:block/title "page1"} - :blocks [{:block/content "b1" :build/properties {:num-many #{2}}} - {:block/content "b2"}]}]) + :blocks [{:block/title "b1" :build/properties {:num-many #{2}}} + {:block/title "b2"}]}]) block (find-block-by-content conn "b2") ;; Use same args as outliner.op _ (outliner-property/create-property-text-block! conn (:db/id block) :user.property/num-many "3" {}) @@ -124,8 +124,8 @@ (testing "Set a :number value with existing value" (let [conn (create-conn-with-blocks [{:page {:block/title "page1"} - :blocks [{:block/content "b1" :build/properties {:num 2}} - {:block/content "b2"}]}]) + :blocks [{:block/title "b1" :build/properties {:num 2}} + {:block/title "b2"}]}]) property-value (:user.property/num (find-block-by-content conn "b1")) _ (assert (:db/id property-value)) block-uuid (:block/uuid (find-block-by-content conn "b2")) @@ -137,8 +137,8 @@ (testing "Update a :number value with existing value" (let [conn (create-conn-with-blocks [{:page {:block/title "page1"} - :blocks [{:block/content "b1" :build/properties {:num 2}} - {:block/content "b2" :build/properties {:num 3}}]}]) + :blocks [{:block/title "b1" :build/properties {:num 2}} + {:block/title "b2" :build/properties {:num 3}}]}]) property-value (:user.property/num (find-block-by-content conn "b1")) _ (assert (:db/id property-value)) block-uuid (:block/uuid (find-block-by-content conn "b2")) @@ -151,8 +151,8 @@ (testing "Setting :default with same property value reuses existing entity" (let [conn (create-conn-with-blocks [{:page {:block/title "page1"} - :blocks [{:block/content "b1" :build/properties {:logseq.property/order-list-type "number"}} - {:block/content "b2"}]}]) + :blocks [{:block/title "b1" :build/properties {:logseq.property/order-list-type "number"}} + {:block/title "b2"}]}]) property-value (:logseq.property/order-list-type (find-block-by-content conn "b1")) block-uuid (:block/uuid (find-block-by-content conn "b2")) ;; Use same args as outliner.op @@ -165,8 +165,8 @@ (testing "Setting :checkbox with same property value reuses existing entity" (let [conn (create-conn-with-blocks [{:page {:block/title "page1"} - :blocks [{:block/content "b1" :build/properties {:checkbox true}} - {:block/content "b2"}]}]) + :blocks [{:block/title "b1" :build/properties {:checkbox true}} + {:block/title "b2"}]}]) property-value (:user.property/checkbox (find-block-by-content conn "b1")) block-uuid (:block/uuid (find-block-by-content conn "b2")) ;; Use same args as outliner.op @@ -179,7 +179,7 @@ (deftest remove-block-property! (let [conn (create-conn-with-blocks [{:page {:block/title "page1"} - :blocks [{:block/content "b1" :build/properties {:default "foo"}}]}]) + :blocks [{:block/title "b1" :build/properties {:default "foo"}}]}]) block (find-block-by-content conn "b1") _ (assert (:user.property/default block)) ;; Use same args as outliner.op @@ -191,8 +191,8 @@ (deftest batch-set-property! (let [conn (create-conn-with-blocks [{:page {:block/title "page1"} - :blocks [{:block/content "item 1"} - {:block/content "item 2"}]}]) + :blocks [{:block/title "item 1"} + {:block/title "item 2"}]}]) block-ids (map #(-> (find-block-by-content conn %) :block/uuid) ["item 1" "item 2"]) _ (outliner-property/batch-set-property! conn block-ids :logseq.property/order-list-type "number") updated-blocks (map #(find-block-by-content conn %) ["item 1" "item 2"])] @@ -204,8 +204,8 @@ (deftest batch-remove-property! (let [conn (create-conn-with-blocks [{:page {:block/title "page1"} - :blocks [{:block/content "item 1" :build/properties {:logseq.property/order-list-type "number"}} - {:block/content "item 2" :build/properties {:logseq.property/order-list-type "number"}}]}]) + :blocks [{:block/title "item 1" :build/properties {:logseq.property/order-list-type "number"}} + {:block/title "item 2" :build/properties {:logseq.property/order-list-type "number"}}]}]) block-ids (map #(-> (find-block-by-content conn %) :block/uuid) ["item 1" "item 2"]) _ (outliner-property/batch-remove-property! conn block-ids :logseq.property/order-list-type) updated-blocks (map #(find-block-by-content conn %) ["item 1" "item 2"])] @@ -216,8 +216,8 @@ (deftest add-existing-values-to-closed-values! (let [conn (create-conn-with-blocks [{:page {:block/title "page1"} - :blocks [{:block/content "b1" :build/properties {:num 1}} - {:block/content "b2" :build/properties {:num 2}}]}]) + :blocks [{:block/title "b1" :build/properties {:num 1}} + {:block/title "b2" :build/properties {:num 2}}]}]) values (map (fn [d] (:block/uuid (d/entity @conn (:v d)))) (d/datoms @conn :avet :user.property/num)) _ (outliner-property/add-existing-values-to-closed-values! conn :user.property/num values)] (is (= [1 2] @@ -267,7 +267,7 @@ :block/schema {:type :default}}} :pages-and-blocks [{:page {:block/title "page1"} - :blocks [{:block/content "b1" :user.property/default [:block/uuid used-closed-value-uuid]}]}]}) + :blocks [{:block/title "b1" :user.property/default [:block/uuid used-closed-value-uuid]}]}]}) _ (assert (:user.property/default (find-block-by-content conn "b1"))) property-uuid (:block/uuid (d/entity @conn :user.property-default)) _ (outliner-property/delete-closed-value! conn property-uuid [:block/uuid closed-value-uuid])] @@ -300,7 +300,7 @@ :c2 {:build/schema-properties [:p2 :p3]}} :pages-and-blocks [{:page {:block/title "p1"} - :blocks [{:block/content "o1" + :blocks [{:block/title "o1" :build/tags [:c1 :c2]}]}]}) block (find-block-by-content conn "o1")] (is (= [:user.property/p1 :user.property/p2 :user.property/p3] diff --git a/deps/publishing/src/logseq/publishing/db.cljs b/deps/publishing/src/logseq/publishing/db.cljs index 739abb1e51..2197a5c6ec 100644 --- a/deps/publishing/src/logseq/publishing/db.cljs +++ b/deps/publishing/src/logseq/publishing/db.cljs @@ -128,7 +128,7 @@ (keep (fn [datom] (cond-> [] - (= :block/content (:a datom)) + (= :block/title (:a datom)) (concat (let [matched (re-seq #"\([./]*/assets/([^)]+)\)" (:v datom))] (when (seq matched) (for [[_ path] matched] diff --git a/deps/publishing/test/logseq/publishing/db_test.cljs b/deps/publishing/test/logseq/publishing/db_test.cljs index 7d54bb7f01..391ae41d7a 100644 --- a/deps/publishing/test/logseq/publishing/db_test.cljs +++ b/deps/publishing/test/logseq/publishing/db_test.cljs @@ -20,7 +20,7 @@ set) exported-blocks (->> (d/q '[:find (pull ?p [*]) :where - [?b :block/content] + [?b :block/title] [?b :block/page ?p]] filtered-db) (map (comp :block/name first)) @@ -47,7 +47,7 @@ set) exported-block-pages (->> (d/q '[:find (pull ?p [*]) :where - [?b :block/content] + [?b :block/title] [?b :block/page ?p]] filtered-db) (map (comp :block/name first)) diff --git a/docs/dev-practices.md b/docs/dev-practices.md index 3f8765d679..1810cc9aaf 100644 --- a/docs/dev-practices.md +++ b/docs/dev-practices.md @@ -365,7 +365,7 @@ These tasks are specific to database graphs. For these tasks there is a one time ```sh $ bb dev:db-query woot '[:find (pull ?b [*]) :where (block-content ?b "Dogma")]' DB contains 833 datoms - [{:block/tx-id 536870923, :block/link #:db{:id 100065}, :block/uuid #uuid "65565c26-f972-4400-bce4-a15df488784d", :block/updated-at 1700158508564, :block/order "a0", :block/refs [#:db{:id 100064}], :block/created-at 1700158502056, :block/format :markdown, :block/tags [#:db{:id 100064}], :block/content "Dogma #~^65565c2a-b1c5-4dc8-a0f0-81b786bc5c6d", :db/id 100090, :block/path-refs [#:db{:id 100051} #:db{:id 100064}], :block/parent #:db{:id 100051}, :block/page #:db{:id 100051}}] + [{:block/tx-id 536870923, :block/link #:db{:id 100065}, :block/uuid #uuid "65565c26-f972-4400-bce4-a15df488784d", :block/updated-at 1700158508564, :block/order "a0", :block/refs [#:db{:id 100064}], :block/created-at 1700158502056, :block/format :markdown, :block/tags [#:db{:id 100064}], :block/title "Dogma #~^65565c2a-b1c5-4dc8-a0f0-81b786bc5c6d", :db/id 100090, :block/path-refs [#:db{:id 100051} #:db{:id 100064}], :block/parent #:db{:id 100051}, :block/page #:db{:id 100051}}] ``` * `dev:db-transact` - Run a `d/transact!` against the queried results of a DB graph @@ -413,7 +413,7 @@ These tasks are specific to database graphs. For these tasks there is a one time # This snapshot correctly shows an added block with content "b7" and a property using a closed :default value $ bb dev:diff-datoms w2.edn w3.edn [[] - [[162 :block/content "b7" 536871039 true] + [[162 :block/title "b7" 536871039 true] [162 :block/created-at 1703004379103 536871037 true] [162 :block/format :markdown 536871037 true] [162 :block/page 149 536871037 true] @@ -450,7 +450,7 @@ These tasks are specific to database graphs. For these tasks there is a one time [nil nil 1703004380918 536871039] [nil nil 162 536871037] [nil nil 536871037 536871038] - [162 :block/content "b7" 536871039 true] + [162 :block/title "b7" 536871039 true] [162 :block/created-at 1703004379103 536871037 true] [162 :block/format :markdown 536871037 true] [162 :block/order "a0" 536871037 true] diff --git a/scripts/src/logseq/tasks/db_graph/create_graph_with_large_sizes.cljs b/scripts/src/logseq/tasks/db_graph/create_graph_with_large_sizes.cljs index 8dfc7ac9cb..4d78130a94 100644 --- a/scripts/src/logseq/tasks/db_graph/create_graph_with_large_sizes.cljs +++ b/scripts/src/logseq/tasks/db_graph/create_graph_with_large_sizes.cljs @@ -34,7 +34,7 @@ (fn [] (let [id (get-next-id)] {:block/uuid id - :block/content (str id)}))))) + :block/title (str id)}))))) (defn- create-init-data [options] @@ -70,14 +70,14 @@ _ (println "Building tx ...") {:keys [init-tx]} (outliner-cli/build-blocks-tx (create-init-data options))] (println "Built" (count init-tx) "tx," (count (filter :block/title init-tx)) "pages and" - (count (filter :block/content init-tx)) "blocks ...") + (count (filter :block/title init-tx)) "blocks ...") ;; Vary the chunking with page size up to a max to avoid OOM (let [tx-chunks (partition-all (min (:pages options) 30000) init-tx)] (loop [chunks tx-chunks chunk-num 1] (when-let [chunk (first chunks)] (println "Transacting chunk" chunk-num "of" (count tx-chunks) - "starting with block:" (pr-str (select-keys (first chunk) [:block/content :block/title]))) + "starting with block:" (pr-str (select-keys (first chunk) [:block/title :block/title]))) (d/transact! conn chunk) (recur (rest chunks) (inc chunk-num))))) #_(d/transact! conn blocks-tx) diff --git a/scripts/src/logseq/tasks/db_graph/create_graph_with_properties.cljs b/scripts/src/logseq/tasks/db_graph/create_graph_with_properties.cljs index 90a3efb732..5ed6da981a 100644 --- a/scripts/src/logseq/tasks/db_graph/create_graph_with_properties.cljs +++ b/scripts/src/logseq/tasks/db_graph/create_graph_with_properties.cljs @@ -73,7 +73,7 @@ :build/tags [:TestClass]}} {:page {:block/title "Blocks"} :blocks - [{:block/content "block object" + [{:block/title "block object" :block/uuid object-uuid :build/tags [:TestClass]}]}] @@ -81,55 +81,55 @@ [{:page {:build/journal (date-time-util/date->int today)} :blocks - [{:block/content "[[Block Properties]]"} - {:block/content "[[Block Property Queries]]"} - {:block/content "[[Page Property Queries]]"}]} + [{:block/title "[[Block Properties]]"} + {:block/title "[[Block Property Queries]]"} + {:block/title "[[Page Property Queries]]"}]} {:page {:build/journal (date-time-util/date->int yesterday)}} {:page {:build/journal (date-time-util/date->int two-days-ago)}} ;; Block property blocks and queries {:page {:block/title "Block Properties"} :blocks - [{:block/content "default property block" :build/properties {:default "haha"}} - {:block/content "default property block" :build/properties {:default-many #{"yee" "haw" "sir"}}} - {:block/content "default-closed property block" :build/properties {:default-closed (random-closed-value :default-closed)}} - {:block/content "url property block" :build/properties {:url "https://logseq.com"}} - {:block/content "url-many property block" :build/properties {:url-many #{"https://logseq.com" "https://docs.logseq.com"}}} - {:block/content "url-closed property block" :build/properties {:url-closed (random-closed-value :url-closed)}} - {:block/content "checkbox property block" :build/properties {:checkbox true}} - {:block/content "number property block" :build/properties {:number 5}} - {:block/content "number-many property block" :build/properties {:number-many #{5 10}}} - {:block/content "number-closed property block" :build/properties {:number-closed (random-closed-value :number-closed)}} - {:block/content "object property block" :build/properties {:object [:block/uuid object-uuid]}} - {:block/content "object-many property block" :build/properties {:object-many #{[:block/uuid object-uuid] [:page "Page object"]}}} - {:block/content "page property block" :build/properties {:page [:page "Page 1"]}} - {:block/content "page-many property block" :build/properties {:page-many #{[:page "Page 1"] [:page "Page 2"]}}} + [{:block/title "default property block" :build/properties {:default "haha"}} + {:block/title "default property block" :build/properties {:default-many #{"yee" "haw" "sir"}}} + {:block/title "default-closed property block" :build/properties {:default-closed (random-closed-value :default-closed)}} + {:block/title "url property block" :build/properties {:url "https://logseq.com"}} + {:block/title "url-many property block" :build/properties {:url-many #{"https://logseq.com" "https://docs.logseq.com"}}} + {:block/title "url-closed property block" :build/properties {:url-closed (random-closed-value :url-closed)}} + {:block/title "checkbox property block" :build/properties {:checkbox true}} + {:block/title "number property block" :build/properties {:number 5}} + {:block/title "number-many property block" :build/properties {:number-many #{5 10}}} + {:block/title "number-closed property block" :build/properties {:number-closed (random-closed-value :number-closed)}} + {:block/title "object property block" :build/properties {:object [:block/uuid object-uuid]}} + {:block/title "object-many property block" :build/properties {:object-many #{[:block/uuid object-uuid] [:page "Page object"]}}} + {:block/title "page property block" :build/properties {:page [:page "Page 1"]}} + {:block/title "page-many property block" :build/properties {:page-many #{[:page "Page 1"] [:page "Page 2"]}}} ;; ;; :page-closed and :date-closed disabled for now since they're not supported - ;; #_{:block/content "page-closed property block" :build/properties {:page-closed (random-closed-value :page-closed)}} - {:block/content "date property block" :build/properties {:date [:page (date-journal-title today)]}} - {:block/content "date-many property block" :build/properties {:date-many #{[:page (date-journal-title today)] + ;; #_{:block/title "page-closed property block" :build/properties {:page-closed (random-closed-value :page-closed)}} + {:block/title "date property block" :build/properties {:date [:page (date-journal-title today)]}} + {:block/title "date-many property block" :build/properties {:date-many #{[:page (date-journal-title today)] [:page (date-journal-title yesterday)]}}} - #_{:block/content "date-closed property block" :build/properties {:date-closed (random-closed-value :date-closed)}}]} + #_{:block/title "date-closed property block" :build/properties {:date-closed (random-closed-value :date-closed)}}]} {:page {:block/title "Block Property Queries"} :blocks - [{:block/content "{{query (property :default \"haha\")}}"} - {:block/content "{{query (property :default-many \"haw\")}}"} - {:block/content (str "{{query (property :default-closed " (pr-str (get-closed-value :default-closed)) ")}}")} - {:block/content "{{query (property :url \"https://logseq.com\")}}"} - {:block/content "{{query (property :url-many \"https://logseq.com\")}}"} - {:block/content (str "{{query (property :url-closed " (pr-str (get-closed-value :url-closed)) ")}}")} - {:block/content "{{query (property :checkbox true)}}"} - {:block/content "{{query (property :number 5)}}"} - {:block/content "{{query (property :number-many 10)}}"} - {:block/content (str "{{query (property :number-closed " (pr-str (get-closed-value :number-closed)) ")}}")} - {:block/content "{{query (property :object \"block object\")}}"} - {:block/content "{{query (property :object-many [[Page object]])}}"} - {:block/content "{{query (property :page [[Page 1]])}}"} - {:block/content "{{query (property :page-many [[Page 2]])}}"} - #_{:block/content (str "{{query (property :page-closed " (page-ref/->page-ref (string/capitalize (get-closed-value :page-closed))) ")}}")} - {:block/content (str "{{query (property :date " (page-ref/->page-ref (string/capitalize (date-journal-title today))) ")}}")} - {:block/content (str "{{query (property :date-many " (page-ref/->page-ref (string/capitalize (date-journal-title yesterday))) ")}}")} - #_{:block/content (str "{{query (property :date-closed " (page-ref/->page-ref (string/capitalize (get-closed-value :date-closed))) ")}}")}]} + [{:block/title "{{query (property :default \"haha\")}}"} + {:block/title "{{query (property :default-many \"haw\")}}"} + {:block/title (str "{{query (property :default-closed " (pr-str (get-closed-value :default-closed)) ")}}")} + {:block/title "{{query (property :url \"https://logseq.com\")}}"} + {:block/title "{{query (property :url-many \"https://logseq.com\")}}"} + {:block/title (str "{{query (property :url-closed " (pr-str (get-closed-value :url-closed)) ")}}")} + {:block/title "{{query (property :checkbox true)}}"} + {:block/title "{{query (property :number 5)}}"} + {:block/title "{{query (property :number-many 10)}}"} + {:block/title (str "{{query (property :number-closed " (pr-str (get-closed-value :number-closed)) ")}}")} + {:block/title "{{query (property :object \"block object\")}}"} + {:block/title "{{query (property :object-many [[Page object]])}}"} + {:block/title "{{query (property :page [[Page 1]])}}"} + {:block/title "{{query (property :page-many [[Page 2]])}}"} + #_{:block/title (str "{{query (property :page-closed " (page-ref/->page-ref (string/capitalize (get-closed-value :page-closed))) ")}}")} + {:block/title (str "{{query (property :date " (page-ref/->page-ref (string/capitalize (date-journal-title today))) ")}}")} + {:block/title (str "{{query (property :date-many " (page-ref/->page-ref (string/capitalize (date-journal-title yesterday))) ")}}")} + #_{:block/title (str "{{query (property :date-closed " (page-ref/->page-ref (string/capitalize (get-closed-value :date-closed))) ")}}")}]} ;; Page property pages and queries {:page {:block/title "default page" :build/properties {:default "yolo"}}} @@ -153,24 +153,24 @@ #_{:page {:block/title "date-closed page" :build/properties {:date-closed (random-closed-value :date-closed)}}} {:page {:block/title "Page Property Queries"} :blocks - [{:block/content "{{query (page-property :default \"yolo\")}}"} - {:block/content "{{query (page-property :default-many \"haw\")}}"} - {:block/content (str "{{query (page-property :default-closed " (pr-str (get-closed-value :default-closed)) ")}}")} - {:block/content "{{query (page-property :url \"https://logseq.com\")}}"} - {:block/content "{{query (page-property :url-many \"https://logseq.com\")}}"} - {:block/content (str "{{query (page-property :url-closed " (pr-str (get-closed-value :url-closed)) ")}}")} - {:block/content "{{query (page-property :checkbox true)}}"} - {:block/content "{{query (page-property :number 5)}}"} - {:block/content "{{query (page-property :number-many 10)}}"} - {:block/content (str "{{query (page-property :number-closed " (pr-str (get-closed-value :number-closed)) ")}}")} - {:block/content "{{query (page-property :object \"block object\")}}"} - {:block/content "{{query (page-property :object-many [[Page object]])}}"} - {:block/content "{{query (page-property :page [[Page 1]])}}"} - {:block/content "{{query (page-property :page-many [[Page 2]])}}"} - #_{:block/content (str "{{query (page-property :page-closed " (page-ref/->page-ref (string/capitalize (get-closed-value :page-closed))) ")}}")} - {:block/content (str "{{query (page-property :date " (page-ref/->page-ref (string/capitalize (date-journal-title today))) ")}}")} - {:block/content (str "{{query (page-property :date-many " (page-ref/->page-ref (string/capitalize (date-journal-title yesterday))) ")}}")} - #_{:block/content (str "{{query (page-property :date-closed " (page-ref/->page-ref (string/capitalize (get-closed-value :date-closed))) ")}}")}]}])) + [{:block/title "{{query (page-property :default \"yolo\")}}"} + {:block/title "{{query (page-property :default-many \"haw\")}}"} + {:block/title (str "{{query (page-property :default-closed " (pr-str (get-closed-value :default-closed)) ")}}")} + {:block/title "{{query (page-property :url \"https://logseq.com\")}}"} + {:block/title "{{query (page-property :url-many \"https://logseq.com\")}}"} + {:block/title (str "{{query (page-property :url-closed " (pr-str (get-closed-value :url-closed)) ")}}")} + {:block/title "{{query (page-property :checkbox true)}}"} + {:block/title "{{query (page-property :number 5)}}"} + {:block/title "{{query (page-property :number-many 10)}}"} + {:block/title (str "{{query (page-property :number-closed " (pr-str (get-closed-value :number-closed)) ")}}")} + {:block/title "{{query (page-property :object \"block object\")}}"} + {:block/title "{{query (page-property :object-many [[Page object]])}}"} + {:block/title "{{query (page-property :page [[Page 1]])}}"} + {:block/title "{{query (page-property :page-many [[Page 2]])}}"} + #_{:block/title (str "{{query (page-property :page-closed " (page-ref/->page-ref (string/capitalize (get-closed-value :page-closed))) ")}}")} + {:block/title (str "{{query (page-property :date " (page-ref/->page-ref (string/capitalize (date-journal-title today))) ")}}")} + {:block/title (str "{{query (page-property :date-many " (page-ref/->page-ref (string/capitalize (date-journal-title yesterday))) ")}}")} + #_{:block/title (str "{{query (page-property :date-closed " (page-ref/->page-ref (string/capitalize (get-closed-value :date-closed))) ")}}")}]}])) :classes {:TestClass {}} @@ -219,7 +219,7 @@ (js/process.exit 1)) (println "DB dir: " (node-path/join dir db-name)) (println "Generating" (count (filter :block/name init-tx)) "pages and" - (count (filter :block/content init-tx)) "blocks ...") + (count (filter :block/title init-tx)) "blocks ...") (d/transact! conn init-tx) (d/transact! conn block-props-tx) (println "Created graph" (str db-name " with " (count (d/datoms @conn :eavt)) " datoms!")))) diff --git a/src/main/frontend/commands.cljs b/src/main/frontend/commands.cljs index 2def226598..b90212a7bd 100644 --- a/src/main/frontend/commands.cljs +++ b/src/main/frontend/commands.cljs @@ -124,7 +124,7 @@ (defn db-based-statuses [] - (map (fn [e] (:block/content e)) + (map (fn [e] (:block/title e)) (db-pu/get-closed-property-values :logseq.task/status))) (defn db-based-embed-page @@ -164,7 +164,7 @@ (defn db-based-priorities [] - (map (fn [e] (:block/content e)) + (map (fn [e] (:block/title e)) (db-pu/get-closed-property-values :logseq.task/priority))) (defn get-priorities diff --git a/src/main/frontend/common_keywords.cljs b/src/main/frontend/common_keywords.cljs index c59f10991b..553180817b 100644 --- a/src/main/frontend/common_keywords.cljs +++ b/src/main/frontend/common_keywords.cljs @@ -11,10 +11,6 @@ "block name, lowercase, only page-blocks have this attr" :string) -(sr/defkeyword :block/title - "like `:block/name`, but not unified into lowercase" - :string) - (sr/defkeyword :block/type "block type" [:set [:enum "page" "property" "class" "whiteboard" "hidden"]]) @@ -28,13 +24,13 @@ - some no-order blocks don't have this attr too, TODO: list these types") -(sr/defkeyword :block/content - "content string of the blocks. +(sr/defkeyword :block/title + "Title or content string of the blocks. in db-version, page-references(e.g. [[page-name]]) are stored as [[~^uuid]]." :string) -(sr/defkeyword :block/raw-content - "like `:block/content`, +(sr/defkeyword :block/raw-title + "like `:block/title`, but when eval `(:block/raw-content block-entity)`, return raw-content of this block" :string) diff --git a/src/main/frontend/components/block.cljs b/src/main/frontend/components/block.cljs index 9f8fffd43c..6232cc4318 100644 --- a/src/main/frontend/components/block.cljs +++ b/src/main/frontend/components/block.cljs @@ -923,7 +923,7 @@ hl-type (pu/lookup properties :logseq.property/hl-type) repo (state/get-current-repo) stop-inner-events? (= block-type :whiteboard-shape)] - (if (and block (:block/content block)) + (if (and block (:block/title block)) (let [title [:span.block-ref (block-content (assoc config :block-ref? true :stop-events? stop-inner-events?) block nil (:block/uuid block) @@ -1805,16 +1805,18 @@ (block-list config' children))]]))) (defn- block-content-empty? - [{:block/keys [properties title body]}] - (and - (or - (empty? properties) - (and (not (config/db-based-graph? (state/get-current-repo))) - (property-file/properties-hidden? properties))) + [{:block/keys [properties] :as block}] + (let [ast-title (:block.temp/ast-title block) + ast-body (:block.temp/ast-body block)] + (and + (or + (empty? properties) + (and (not (config/db-based-graph? (state/get-current-repo))) + (property-file/properties-hidden? properties))) - (empty? title) + (empty? ast-title) - (every? #(= % ["Horizontal_Rule"]) body))) + (every? #(= % ["Horizontal_Rule"]) ast-body)))) (rum/defcs block-control < rum/reactive [state config block {:keys [uuid block-id collapsed? *control-show? edit? selected?]}] @@ -1925,9 +1927,9 @@ (declare block-content) (defn build-block-title - [config {:block/keys [title marker pre-block? properties] - :as t}] - (let [config (assoc config :block t) + [config {:block/keys [marker pre-block? properties] :as t}] + (let [block-title (:block.temp/ast-title t) + config (assoc config :block t) level (:level config) slide? (boolean (:slide? config)) block-ref? (:block-ref? config) @@ -2007,7 +2009,7 @@ (when-not area? [(hl-ref)]) (conj - (map-inline config title) + (map-inline config block-title) (when (= block-type :whiteboard-shape) [:span.mr-1 (ui/icon "whiteboard-element" {:extension? true})])) ;; highlight ref block (area) @@ -2226,10 +2228,10 @@ (dom/by-class "block-content-inner") first util/caret-range) - {:block/keys [content format]} block + {:block/keys [title format]} block content (if (config/db-based-graph? (state/get-current-repo)) - (or (:block/title block) content) - (->> content + (or (:block/title block) title) + (->> title (property-file/remove-built-in-properties-when-file-based (state/get-current-repo) format) (drawer/remove-logbook)))] @@ -2282,7 +2284,7 @@ (or (not collapsed?) (some? (mldoc/extract-first-query-from-ast body)))))) [:div.block-body - (let [body (block/trim-break-lines! (:block/body block)) + (let [body (block/trim-break-lines! (:block.temp/ast-body block)) uuid (:block/uuid block)] (for [[idx child] (medley/indexed body)] (when-let [block (markup-element-cp config child)] @@ -2326,20 +2328,22 @@ (pv/property-value block property (get block pid) (assoc opts :show-tooltip? true))))])))) (rum/defc ^:large-vars/cleanup-todo block-content < rum/reactive - [config {:block/keys [uuid content properties scheduled deadline format pre-block?] :as block} edit-input-id block-id slide?] + [config {:block/keys [uuid title properties scheduled deadline format pre-block?] :as block} edit-input-id block-id slide?] (let [repo (state/get-current-repo) - content (or (:block/title block) - (if (config/db-based-graph? (state/get-current-repo)) - (:block/content block) - (property-util/remove-built-in-properties format content))) - {:block/keys [title body] :as block} (if (:block/title block) block - (merge block (block/parse-title-and-body uuid format pre-block? content))) + content (if (config/db-based-graph? (state/get-current-repo)) + (:block/title block) + (property-util/remove-built-in-properties format title)) + block (merge block (block/parse-title-and-body uuid format pre-block? content)) + ;; _ (prn :debug :block block + ;; :parsed-result (block/parse-title-and-body uuid format pre-block? content)) + ast-body (:block.temp/ast-body block) + ast-title (:block.temp/ast-title block) collapsed? (util/collapsed? block) - block (assoc block :block/content content) + block (assoc block :block/title content) plugin-slotted? (and config/lsp-enabled? (state/slot-hook-exist? uuid)) block-ref? (:block-ref? config) stop-events? (:stop-events? config) - block-ref-with-title? (and block-ref? (not (state/show-full-blocks?)) (seq title)) + block-ref-with-title? (and block-ref? (not (state/show-full-blocks?)) (seq ast-title)) block-type (or (pu/lookup properties :logseq.property/ls-type) :default) @@ -2393,7 +2397,7 @@ :else (build-block-title config block))]) - (file-block/clock-summary-cp block body)] + (file-block/clock-summary-cp block ast-body)] (when deadline (when-let [deadline-ast (block-handler/get-deadline-ast block)] @@ -2410,13 +2414,13 @@ (when (and (seq properties) (let [hidden? (property-file/properties-hidden? properties)] (not hidden?)) - (not (and block-ref? (or (seq title) (seq body)))) + (not (and block-ref? (or (seq ast-title) (seq ast-body)))) (not (:slide? config)) (not= block-type :whiteboard-shape) (not (config/db-based-graph? repo))) (properties-cp config block)) - (block-content-inner config block body plugin-slotted? collapsed? block-ref-with-title?) + (block-content-inner config block ast-body plugin-slotted? collapsed? block-ref-with-title?) (case (:block/warning block) :multiple-blocks @@ -2478,7 +2482,7 @@ editor-id (str "editor-" edit-input-id) slide? (:slide? config) block-reference-only? (some-> - (:block/content block) + (:block/title block) string/trim block-ref/block-ref?) named? (some? (:block/name block)) @@ -2506,10 +2510,10 @@ [:div.flex.flex-1.w-full.block-content-wrapper {:style {:display (if (:slide? config) "block" "flex")}} (ui/catch-error (ui/block-error "Block Render Error:" - {:content (:block/content block) + {:content (:block/title block) :section-attrs {:on-click #(let [content (or (:block/title block) - (:block/content block))] + (:block/title block))] (editor-handler/clear-selection!) (editor-handler/unhighlight-blocks!) (state/set-editing! edit-input-id content block "" {:container-id (:container-id config)}))}}) @@ -2559,7 +2563,7 @@ :block? true :editor-box (state/get-component :editor/box) :in-whiteboard? true}] - (when (:block/content block) + (when (:block/title block) [:div.single-block (block-container config block)]))) @@ -2644,20 +2648,22 @@ (page-cp (dissoc config :breadcrumb? true) page) {:block/name (or page-title page-name)}]) parents-props (doall - (for [{:block/keys [uuid name content] :as block} parents] + (for [{:block/keys [uuid name title] :as block} parents] (if name [block (page-cp {} block)] - (let [{:block/keys [title body]} (block/parse-title-and-body + (let [result (block/parse-title-and-body uuid (:block/format block) (:block/pre-block? block) - content) + title) + ast-body (:block.temp/ast-body result) + ast-title (:block.temp/ast-title result) config (assoc config :block/uuid uuid)] [block - (when title - (if (seq title) - (->elem :span.inline-wrap (map-inline config title)) - (->elem :div (markup-elements-cp config body))))])))) + (when ast-title + (if (seq ast-title) + (->elem :span.inline-wrap (map-inline config ast-title)) + (->elem :div (markup-elements-cp config ast-body))))])))) breadcrumb (->> (into [] parents-props) (concat [page-name-props] (when more? [:more])) (filterv identity) @@ -2895,7 +2901,7 @@ custom-query? (boolean (:custom-query? config*)) ref-or-custom-query? (or ref? custom-query?) *navigating-block (get container-state ::navigating-block) - {:block/keys [uuid pre-block? content]} block + {:block/keys [uuid pre-block? title]} block config (build-config config* block {:navigated? navigated? :navigating-block navigating-block}) level (:level config) *control-show? (get container-state ::control-show?) @@ -2935,7 +2941,7 @@ (when selected? " selected") (when pre-block? " pre-block") (when order-list? " is-order-list") - (when (string/blank? content) " is-blank") + (when (string/blank? title) " is-blank") (when original-block " embed-block")) :haschild (str (boolean has-child?))} @@ -2996,7 +3002,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? content)) + (let [block (merge block (block/parse-title-and-body uuid (:block/format block) pre-block? title)) hide-block-refs-count? (or (and (:embed? config) (= (:block/uuid block) (:embed-id config))) table?)] diff --git a/src/main/frontend/components/block/macros.cljs b/src/main/frontend/components/block/macros.cljs index 42cc4050f7..710546f59f 100644 --- a/src/main/frontend/components/block/macros.cljs +++ b/src/main/frontend/components/block/macros.cljs @@ -33,7 +33,7 @@ ;; These keyword aliases should be the same as those used in the query-table for sorting (case f :block - :block/content + :block/title :page :block/name diff --git a/src/main/frontend/components/cmdk/core.cljs b/src/main/frontend/components/cmdk/core.cljs index 91f6c15571..7bf67f1fd3 100644 --- a/src/main/frontend/components/cmdk/core.cljs +++ b/src/main/frontend/components/cmdk/core.cljs @@ -281,7 +281,7 @@ (let [id (:block/uuid block)] {:icon "block" :icon-theme :gray - :text (highlight-content-query (:block/content block) @!input) + :text (highlight-content-query (:block/title block) @!input) :header (block/breadcrumb {:search? true} repo id {}) :current-page? (when-let [page-id (:block/page block)] (= page-id (:block/uuid current-page))) @@ -367,7 +367,7 @@ (uuid (:block/uuid block)))] {:icon "block" :icon-theme :gray - :text (highlight-content-query (:block/content block) @!input) + :text (highlight-content-query (:block/title block) @!input) :header (block/breadcrumb {:search? true} repo id {}) :current-page? true :source-block block})) blocks)] @@ -705,7 +705,7 @@ link (if (config/db-based-graph? repo) (some (fn [[k v]] (when (= :url (get-in (db/entity repo k) [:block/schema :type])) - (:block/content v))) + (:block/title v))) (:block/properties page')) (some #(re-find editor-handler/url-regex (val %)) (:block/properties page')))] (if link @@ -716,7 +716,7 @@ (p/let [block-id (:block/uuid (:source-block item)) _ (db-async/> (rum/react (get state ::result)) - (remove (fn [b] (string/blank? (:block/content (db-model/query-block-by-uuid (:block/uuid b))))))) + (remove (fn [b] (string/blank? (:block/title (db-model/query-block-by-uuid (:block/uuid b))))))) db? (config/db-based-graph? (state/get-current-repo)) embed? (and db? (= @commands/*current-command "Block embed")) chosen-handler (block-on-chosen-handler embed? input id q format selected-text) @@ -265,7 +265,7 @@ repo (state/sub :git/current-repo) format (get page-entity :block/format :markdown) block (db-model/query-block-by-uuid uuid) - content (:block/content block)] + content (:block/title block)] (when-not (string/blank? content) [:.py-2 (search/block-search-result-item repo uuid format content q :block)]))) :class "ac-block-search"}))) diff --git a/src/main/frontend/components/imports.cljs b/src/main/frontend/components/imports.cljs index 2f7389bc84..26ea7e12a1 100644 --- a/src/main/frontend/components/imports.cljs +++ b/src/main/frontend/components/imports.cljs @@ -215,7 +215,7 @@ :on-key-down (fn [e] (when (= "Enter" (util/ekey e)) (on-submit)))}) - + [:div.sm:flex.sm:items-start [:div.mt-3.text-center.sm:mt-0.sm:text-left [:h3#modal-headline.leading-6.font-medium @@ -237,7 +237,7 @@ [entities] {:entities (count entities) :pages (count (filter :block/name entities)) - :blocks (count (filter :block/content entities)) + :blocks (count (filter :block/title entities)) :classes (count (filter #(contains? (:block/type %) "class") entities)) :objects (count (filter #(seq (:block/tags %)) entities)) :properties (count (filter #(contains? (:block/type %) "property") entities)) diff --git a/src/main/frontend/components/page.cljs b/src/main/frontend/components/page.cljs index dec13428e2..ac036273df 100644 --- a/src/main/frontend/components/page.cljs +++ b/src/main/frontend/components/page.cljs @@ -86,7 +86,7 @@ (or preview? (not (contains? #{:home :all-journals} (state/get-current-route)))) (not sidebar?)) - (when (and (string/blank? (:block/content block)) + (when (and (string/blank? (:block/title block)) (not preview?)) (editor-handler/edit-block! block :max)))) state) diff --git a/src/main/frontend/components/property/value.cljs b/src/main/frontend/components/property/value.cljs index 77ac2e41fe..9d735c5274 100644 --- a/src/main/frontend/components/property/value.cljs +++ b/src/main/frontend/components/property/value.cljs @@ -310,7 +310,7 @@ (defn- get-title [e] (or (:block/title e) - (:block/content e))) + (:block/title e))) (rum/defc select-page < rum/reactive db-mixins/query [property @@ -612,7 +612,7 @@ (when-some [content (if (some? (:property.value/content value)) ;; content needs to be a string for display purposes (str (:property.value/content value)) - (:block/content value))] + (:block/title value))] (inline-text-cp content)) :else @@ -682,7 +682,7 @@ (when (and (= type :default) (nil? value)) ( (if page? result (attach-clock-property result)) db-graph? ((fn [res] - (map #(if (:block/content %) - (update % :block/content + (map #(if (:block/title %) + (update % :block/title db-content/special-id-ref->page-ref ;; Lookup here instead of initial query as advanced queries ;; won't usually have a ref's name diff --git a/src/main/frontend/components/views.cljs b/src/main/frontend/components/views.cljs index 8237db99a1..d18ceab4fc 100644 --- a/src/main/frontend/components/views.cljs +++ b/src/main/frontend/components/views.cljs @@ -140,7 +140,7 @@ (row-checkbox table row column)) :column-list? false} (when with-object-name? - {:id :object/name + {:id :block/title :name "Name" :type :string :header header-cp @@ -226,7 +226,7 @@ (case (:id column) :select 32 :add-property 160 - (:object/name :block/title :block/name :block/content) 360 + (:block/title :block/name) 360 (:block/created-at :block/updated-at) 160 180)) @@ -713,7 +713,7 @@ (map-indexed (fn [idx filter] (let [[property-ident operator value] filter - property (if (= property-ident :object/name) + property (if (= property-ident :block/title) {:db/ident property-ident :block/title "Name"} (or (db/entity property-ident) @@ -751,7 +751,7 @@ (if (string/blank? input) true (when row - (fuzzy-matched? input (:object/name row)))) + (fuzzy-matched? input (:block/title row)))) ;; filters check (every? (fn [[property-ident operator match]] diff --git a/src/main/frontend/db/model.cljs b/src/main/frontend/db/model.cljs index 733a19e1b8..e4b415486d 100644 --- a/src/main/frontend/db/model.cljs +++ b/src/main/frontend/db/model.cljs @@ -148,7 +148,7 @@ independent of format as format specific heading characters are stripped" [?page :block/uuid ?page-uuid] [?b :block/page ?page] (has-property ?b :logseq.property/heading) - [?b :block/content ?content] + [?b :block/title ?content] [(?content-matches ?content ?route-name ?b)]] db (uuid page-uuid-str) @@ -171,7 +171,7 @@ independent of format as format specific heading characters are stripped" [?b :block/page ?page] [?b :block/properties ?prop] [(get ?prop :heading) _] - [?b :block/content ?content] + [?b :block/title ?content] [(?content-matches ?content ?route-name)]] db (uuid page-uuid-str) diff --git a/src/main/frontend/extensions/pdf/assets.cljs b/src/main/frontend/extensions/pdf/assets.cljs index b02d8f8a1c..a6eccee766 100644 --- a/src/main/frontend/extensions/pdf/assets.cljs +++ b/src/main/frontend/extensions/pdf/assets.cljs @@ -201,7 +201,7 @@ (p/let [ref-page (when pdf-current (ensure-ref-page! pdf-current))] (when ref-page (let [ref-block (db-model/query-block-by-uuid id)] - (if-not (nil? (:block/content ref-block)) + (if-not (nil? (:block/title ref-block)) (do (println "[existed ref block]" ref-block) ref-block) diff --git a/src/main/frontend/extensions/srs.cljs b/src/main/frontend/extensions/srs.cljs index ff7ac29cfe..b835c24063 100644 --- a/src/main/frontend/extensions/srs.cljs +++ b/src/main/frontend/extensions/srs.cljs @@ -112,7 +112,7 @@ (editor-handler/save-block-if-changed! block (property-file/insert-properties-when-file-based - (state/get-current-repo) (:block/format block) (:block/content block) props) + (state/get-current-repo) (:block/format block) (:block/title block) props) {:force? true})) (defn- reset-block-card-properties! @@ -207,7 +207,7 @@ (defn- has-cloze? [blocks] - (->> (map :block/content blocks) + (->> (map :block/title blocks) (some #(string/includes? % "{{cloze ")))) (defn- clear-collapsed-property @@ -783,7 +783,7 @@ "given a block struct, adds the #card to title and returns a seq of [original-block new-content-string]" [block] - (when-let [content (:block/content block)] + (when-let [content (:block/title block)] (let [format (:block/format block) content (-> (property-file/remove-built-in-properties-when-file-based (state/get-current-repo) (:block/format block) content) diff --git a/src/main/frontend/extensions/tldraw.cljs b/src/main/frontend/extensions/tldraw.cljs index 6c788f472c..be076cd47a 100644 --- a/src/main/frontend/extensions/tldraw.cljs +++ b/src/main/frontend/extensions/tldraw.cljs @@ -76,7 +76,7 @@ blocks (map (fn [b] (-> b (update :block/uuid str) - (update :block/content #(->> (text-util/cut-by % "$pfts_2lqh>$" "$> (text-util/cut-by % "$pfts_2lqh>$" "$js {:pages pages :blocks blocks})))) diff --git a/src/main/frontend/external/roam_export.cljs b/src/main/frontend/external/roam_export.cljs index ac68a00600..0cd31d78e3 100644 --- a/src/main/frontend/external/roam_export.cljs +++ b/src/main/frontend/external/roam_export.cljs @@ -44,18 +44,18 @@ content uuids)))) -(defn update-uid [{:block/keys [uuid content] :as b} +(defn update-uid [{:block/keys [uuid title] :as b} uuid->uid-map] (cond-> b (contains? uuid->uid-map uuid) (assoc :block/uid (get uuid->uid-map uuid)) - (some (fn [id] (str/includes? (str content) (str id))) (keys uuid->uid-map)) - (update :block/content #(update-content % uuid->uid-map)))) + (some (fn [id] (str/includes? (str title) (str id))) (keys uuid->uid-map)) + (update :block/title #(update-content % uuid->uid-map)))) -(defn update-todo [{:block/keys [content] :as block}] - (if content - (update block :block/content +(defn update-todo [{:block/keys [title] :as block}] + (if title + (update block :block/title (fn [c] (-> c (str/replace todo-marker-regex "{{[[TODO]]}}") @@ -77,8 +77,7 @@ (update-todo) - (s/rename-keys {:block/title :page/title - :block/content :block/string}) + (s/rename-keys {:block/title :page/title}) (select-keys keyseq)) diff --git a/src/main/frontend/format/block.cljs b/src/main/frontend/format/block.cljs index 0a3cf649ac..c698676f53 100644 --- a/src/main/frontend/format/block.cljs +++ b/src/main/frontend/format/block.cljs @@ -68,19 +68,19 @@ and handles unexpected failure." (first))) (defn parse-block - [{:block/keys [uuid content format] :as block}] - (when-not (string/blank? content) + [{:block/keys [uuid title format] :as block}] + (when-not (string/blank? title) (let [block (dissoc block :block/pre-block?) format (or format :markdown) parse-config (mldoc/get-default-config format) - ast (format/to-edn content format parse-config) - blocks (extract-blocks ast content format {}) + ast (format/to-edn title format parse-config) + blocks (extract-blocks ast title format {}) new-block (first blocks) block (cond-> (merge block new-block) (> (count blocks) 1) (assoc :block/warning :multiple-blocks)) - block (dissoc block :block/body :block/level)] + block (dissoc block :block.temp/ast-body :block/level)] (if uuid (assoc block :block/uuid uuid) block)))) (defn parse-title-and-body @@ -90,7 +90,7 @@ and handles unexpected failure." (parse-title-and-body (:block/uuid block) (:block/format block) (:block/pre-block? block) - (:block/content block))))) + (:block/title block))))) ([block-uuid format pre-block? content] (when-not (string/blank? content) (let [content (if pre-block? content @@ -105,9 +105,9 @@ and handles unexpected failure." body (vec (if title (rest ast) ast)) body (drop-while gp-property/properties-ast? body) result (cond-> - (if (seq body) {:block/body body} {}) + (if (seq body) {:block.temp/ast-body body} {}) title - (assoc :block/title title))] + (assoc :block.temp/ast-title title))] (state/add-block-ast-cache! block-uuid content result) result)))))) diff --git a/src/main/frontend/fs/diff_merge.cljs b/src/main/frontend/fs/diff_merge.cljs index 77a87e5ff0..57b05a4531 100644 --- a/src/main/frontend/fs/diff_merge.cljs +++ b/src/main/frontend/fs/diff_merge.cljs @@ -30,11 +30,11 @@ [page-name] {:pre (string? page-name)} (let [walked (db-model/get-sorted-page-block-ids-and-levels page-name) - blocks (db-utils/pull-many [:block/uuid :block/content :block/level] (map :id walked)) + blocks (db-utils/pull-many [:block/uuid :block/title :block/level] (map :id walked)) levels (map :level walked) blocks (map (fn [block level] {:uuid (str (:block/uuid block)) ;; Force to be string - :body (:block/content block) + :body (:block/title block) :level level}) blocks levels)] blocks)) diff --git a/src/main/frontend/handler/block.cljs b/src/main/frontend/handler/block.cljs index c7c4fd5386..133ae537bc 100644 --- a/src/main/frontend/handler/block.cljs +++ b/src/main/frontend/handler/block.cljs @@ -35,7 +35,7 @@ (if (check? x) (reset! result (transform x)) x)) - (:block/body block)) + (:block.temp/ast-body block)) @result)) (defn get-timestamp @@ -200,7 +200,7 @@ block (or (db/entity [:block/uuid block-id]) block) content (if (and db-graph? (:block/name block)) (:block/title block) - (or custom-content (:block/content block) "")) + (or custom-content (:block/title block) "")) content-length (count content) text-range (cond (vector? pos) diff --git a/src/main/frontend/handler/code.cljs b/src/main/frontend/handler/code.cljs index 25c2da7d33..706d12b7ef 100644 --- a/src/main/frontend/handler/code.cljs +++ b/src/main/frontend/handler/code.cljs @@ -29,7 +29,7 @@ ;; save block content (:block/uuid config) (let [block (db/pull [:block/uuid (:block/uuid config)]) - content (:block/content block) + content (:block/title block) {:keys [start_pos end_pos]} (:pos_meta @(:code-options state)) offset (if (:block/pre-block? block) 0 2) raw-content (utf8/encode content) ;; NOTE: :pos_meta is based on byte position diff --git a/src/main/frontend/handler/common/developer.cljs b/src/main/frontend/handler/common/developer.cljs index 0dd1367d78..ea6b51f78f 100644 --- a/src/main/frontend/handler/common/developer.cljs +++ b/src/main/frontend/handler/common/developer.cljs @@ -70,8 +70,8 @@ (notification/show! "No block found" :warning))) (defn ^:export show-block-ast [] - (if-let [{:block/keys [content format]} (:block (first (state/get-editor-args)))] - (show-content-ast content format) + (if-let [{:block/keys [title format]} (:block (first (state/get-editor-args)))] + (show-content-ast title format) (notification/show! "No block found" :warning))) (defn ^:export show-page-data [] diff --git a/src/main/frontend/handler/db_based/editor.cljs b/src/main/frontend/handler/db_based/editor.cljs index 977f67b2ac..2dae41f633 100644 --- a/src/main/frontend/handler/db_based/editor.cljs +++ b/src/main/frontend/handler/db_based/editor.cljs @@ -61,7 +61,7 @@ (defn- replace-page-refs-with-ids [block] - (let [content (:block/content block) + (let [content (:block/title block) content' (if (some :block/name (:block/refs block)) (reduce (fn [content {:block/keys [title uuid]}] @@ -69,34 +69,34 @@ content (filter :block/name (:block/refs block))) content)] - (assoc block :block/content content'))) + (assoc block :block/title content'))) (defn wrap-parse-block - [{:block/keys [content level] :as block}] + [{:block/keys [title level] :as block}] (let [block (or (and (:db/id block) (db/pull (:db/id block))) block) - block (if (nil? content) + block (if (nil? title) block - (let [ast (mldoc/->edn (string/trim content) :markdown) + (let [ast (mldoc/->edn (string/trim title) :markdown) first-elem-type (first (ffirst ast)) block-with-title? (mldoc/block-with-title? first-elem-type) - content' (str (config/get-block-pattern :markdown) (if block-with-title? " " "\n") content) - parsed-block (block/parse-block (assoc block :block/content content')) + content' (str (config/get-block-pattern :markdown) (if block-with-title? " " "\n") title) + parsed-block (block/parse-block (assoc block :block/title content')) parsed-block' (cond-> (dissoc parsed-block :block/properties) (:block/properties parsed-block) (merge (update-keys (:block/properties parsed-block) (fn [k] (or ({:heading :logseq.property/heading} k) (throw (ex-info (str "Don't know how to save graph-parser property " (pr-str k)) {}))))))) - block' (merge block parsed-block' {:block/content content})] + block' (merge block parsed-block' {:block/title title})] (update block' :block/refs remove-non-existed-refs!))) result (-> block (merge (if level {:block/level level} {})) (replace-page-refs-with-ids))] (-> result ;; Remove tags from content - (assoc :block/content + (assoc :block/title (db-content/content-without-tags - (:block/content result) + (:block/title result) (->> (map (fn [tag] @@ -143,24 +143,24 @@ (and (or (nil? heading) (true? heading)) (number? old-heading)) - (let [content (commands/clear-markdown-heading (:block/content block))] - {:block/content content + (let [content (commands/clear-markdown-heading (:block/title block))] + {:block/title content :block/uuid (:block/uuid block)}) (and (or (nil? old-heading) (true? old-heading)) (number? heading)) - (let [content (commands/set-markdown-heading (:block/content block) heading)] - {:block/content content + (let [content (commands/set-markdown-heading (:block/title block) heading)] + {:block/title content :block/uuid (:block/uuid block)}) ;; heading-num1 -> heading-num2 :else (let [content (-> block - :block/content + :block/title commands/clear-markdown-heading (commands/set-markdown-heading heading))] {:block/uuid (:block/uuid block) - :block/content content})))) + :block/title content})))) (defn batch-set-heading! [repo block-ids heading] diff --git a/src/main/frontend/handler/editor.cljs b/src/main/frontend/handler/editor.cljs index 974ee38679..123276e7b7 100644 --- a/src/main/frontend/handler/editor.cljs +++ b/src/main/frontend/handler/editor.cljs @@ -261,7 +261,7 @@ [block value opts] (let [block {:db/id (:db/id block) :block/uuid (:block/uuid block) - :block/content value} + :block/title value} block' (-> (wrap-parse-block block) ;; :block/uuid might be changed when backspace/delete ;; a block that has been refed @@ -284,15 +284,15 @@ ([block value {:keys [force?] :as opts}] - (let [{:block/keys [uuid page format repo content properties]} block + (let [{:block/keys [uuid page format repo title properties]} block repo (or repo (state/get-current-repo)) format (or format (state/get-preferred-format)) page (db/entity repo (:db/id page)) block-id (when (and (not (config/db-based-graph? repo)) (map? properties)) (get properties :id)) content (if (config/db-based-graph? repo) - content - (-> (property-file/remove-built-in-properties-when-file-based repo format content) + title + (-> (property-file/remove-built-in-properties-when-file-based repo format title) (drawer/remove-logbook)))] (cond (another-block-with-same-id-exists? uuid block-id) @@ -359,7 +359,7 @@ input (gdom/getElement edit-input-id) input-text-selected? (util/input-text-selected? input) new-m {:block/uuid (db/new-block-id) - :block/content ""} + :block/title ""} prev-block (-> (merge (select-keys block [:block/parent :block/format :block/page]) new-m) (wrap-parse-block)) @@ -385,10 +385,10 @@ selection-start (util/get-selection-start input) selection-end (util/get-selection-end input) [fst-block-text snd-block-text] (compute-fst-snd-block-text value selection-start selection-end) - current-block (assoc block :block/content fst-block-text) + current-block (assoc block :block/title fst-block-text) current-block (apply dissoc current-block db-schema/retract-attributes) new-m {:block/uuid (db/new-block-id) - :block/content snd-block-text} + :block/title snd-block-text} next-block (-> (merge (select-keys block [:block/parent :block/format :block/page]) new-m) (wrap-parse-block)) @@ -518,7 +518,7 @@ container-id (get-new-container-id :insert {:sibling? sibling?})] (edit-block! next-block' (+ pos (count unsaved-chars)) {:container-id container-id - :custom-content (str unsaved-chars (:block/content next-block'))})))))) + :custom-content (str unsaved-chars (:block/title next-block'))})))))) (p/finally (fn [] (state/set-state! :editor/async-unsaved-chars nil)))))) @@ -552,7 +552,7 @@ (property-file/insert-properties-when-file-based repo format content properties) content) new-block (-> (select-keys block [:block/page]) - (assoc :block/content content + (assoc :block/title content :block/format format)) new-block (assoc new-block :block/page (if page @@ -594,7 +594,7 @@ (property-handler/set-block-properties! repo (:block/uuid new-block) properties))) (when edit-block? (if (and replace-empty-target? - (string/blank? (:block/content last-block))) + (string/blank? (:block/title last-block))) (edit-block! last-block :max) (edit-block! new-block :max))) new-block))))))) @@ -606,7 +606,7 @@ (when-let [page (db/get-page page-title)] (when (db/page-empty? (state/get-current-repo) (:db/id page)) (let [format (or (:block/format page) (state/get-preferred-format)) - new-block {:block/content "" + new-block {:block/title "" :block/format format}] (ui-outliner-tx/transact! {:outliner-op :insert-blocks} @@ -645,10 +645,10 @@ content)) (defn check - [{:block/keys [marker content repeated? uuid] :as block}] - (let [new-content (string/replace-first content marker "DONE") + [{:block/keys [marker title repeated? uuid] :as block}] + (let [new-content (string/replace-first title marker "DONE") new-content (if repeated? - (update-timestamps-content! block content) + (update-timestamps-content! block title) new-content) input-id (state/get-edit-input-id)] (if (and input-id @@ -657,11 +657,11 @@ (save-block-if-changed! block new-content)))) (defn uncheck - [{:block/keys [content uuid] :as block}] + [{:block/keys [title uuid] :as block}] (let [marker (if (= :now (state/get-preferred-workflow)) "LATER" "TODO") - new-content (string/replace-first content "DONE" marker) + new-content (string/replace-first title "DONE" marker) input-id (state/get-edit-input-id)] (if (and input-id (string/ends-with? input-id (str uuid))) @@ -677,13 +677,13 @@ if the `new-marker` is nil, it will generate it automatically." ([block] (set-marker block nil)) - ([{:block/keys [marker content format] :as block} new-marker] - (let [[new-content _] (status/cycle-marker content marker new-marker format (state/get-preferred-workflow))] + ([{:block/keys [marker title format] :as block} new-marker] + (let [[new-content _] (status/cycle-marker title marker new-marker format (state/get-preferred-workflow))] (save-block-if-changed! block new-content)))) (defn file-based-cycle-todo! [block] - (when (not-empty (:block/content block)) + (when (not-empty (:block/title block)) (set-marker block))) (defn db-based-cycle-todo! @@ -746,9 +746,9 @@ (cursor/move-cursor-to current-input new-pos)))))))) (defn set-priority - [{:block/keys [priority content] :as block} new-priority] + [{:block/keys [priority title] :as block} new-priority] (when-not (config/db-based-graph? (state/get-current-repo)) - (let [new-content (string/replace-first content + (let [new-content (string/replace-first title (util/format "[#%s]" priority) (util/format "[#%s]" new-priority))] (save-block-if-changed! block new-content)))) @@ -774,7 +774,7 @@ (let [db? (config/db-based-graph? repo) original-content (if (= (:db/id sibling-entity) (:db/id (state/get-edit-block))) (state/get-edit-content) - (:block/content sibling-entity)) + (:block/title sibling-entity)) value' (if db? original-content (-> (property-file/remove-built-in-properties-when-file-based repo format original-content) @@ -855,7 +855,7 @@ transact-opts (delete-block-aux! prev-block) (save-block! repo block new-content {})) - (edit-block! (assoc block :block/content new-content) (count (:block/content prev-block)))) + (edit-block! (assoc block :block/title new-content) (count (:block/title prev-block)))) (p/do! (ui-outliner-tx/transact! transact-opts @@ -923,8 +923,8 @@ block-id (if (string? block-id) (uuid block-id) block-id) value (str value)] (when-let [block (db/entity [:block/uuid block-id])] - (let [{:block/keys [content]} block - content (or content (state/get-edit-content)) + (let [{:block/keys [title]} block + content (or title (state/get-edit-content)) new-content (-> (text-util/remove-timestamp content key) (text-util/add-timestamp key value))] (when (not= content new-content) @@ -1304,7 +1304,7 @@ (let [value (string/trim value)] ;; FIXME: somehow frontend.components.editor's will-unmount event will loop forever ;; maybe we shouldn't save the block/file in "will-unmount" event? - (if (:block/title entity) + (if (ldb/page? entity) (let [existing-tags (:block/tags block) tags (mldoc/extract-tags value)] (when (seq tags) @@ -1357,11 +1357,11 @@ db-block (when-let [block-id (:block/uuid block)] (db/entity [:block/uuid block-id])) elem (and input-id (gdom/getElement input-id)) - db-content (:block/content db-block) + db-content (:block/title db-block) db-content-without-heading (and db-content (common-util/safe-subs db-content (:block/level db-block))) value (if (= (:block/uuid current-block) (:block/uuid block)) - (:block/content current-block) + (:block/title current-block) (and elem (gobj/get elem "value")))] (when value (cond @@ -1493,7 +1493,7 @@ [{:keys [repo href full-text block-id local? delete-local?] :as _opts}] (let [block (db-model/query-block-by-uuid block-id) _ (or block (throw (str block-id " not exists"))) - text (:block/content block) + text (:block/title block) content (string/replace text full-text "")] (save-block! repo block content) (when (and local? delete-local?) @@ -1762,7 +1762,7 @@ result))] (if edit-block-id (when-let [block (db/entity [:block/uuid edit-block-id])] - (let [blocks [(assoc block :block/content (state/get-edit-content))] + (let [blocks [(assoc block :block/title (state/get-edit-content))] container-id (get-new-container-id (if up? :move-up :move-down) {})] (p/do! (save-current-block!) @@ -1858,7 +1858,7 @@ image-part (first (string/split full_text #"\{")) new-full-text (str image-part (pr-str new-meta)) block (db/entity [:block/uuid block-id]) - value (:block/content block) + value (:block/title block) new-value (string/replace value full_text new-full-text)] (save-block-aux! block new-value {}))) @@ -2000,8 +2000,8 @@ (let [db-based? (config/db-based-graph? (state/get-current-repo)) new-content (if content-update-fn - (content-update-fn (:block/content block)) - (:block/content block)) + (content-update-fn (:block/title block)) + (:block/title block)) new-content (cond->> new-content (not keep-uuid?) (property-file/remove-property-when-file-based repo format "id") @@ -2018,7 +2018,7 @@ (when-not keep-uuid? [:id]) [:custom_id :custom-id] exclude-properties))) - :block/content new-content} + :block/title new-content} (not db-based?) (assoc :block/properties-text-values (apply dissoc (:block/properties-text-values block) (concat @@ -2052,16 +2052,16 @@ :or {exclude-properties []}}] (let [editing-block (when-let [editing-block (state/get-edit-block)] (some-> (db/entity [:block/uuid (:block/uuid editing-block)]) - (assoc :block/content (state/get-edit-content)))) + (assoc :block/title (state/get-edit-content)))) has-unsaved-edits (and editing-block - (not= (:block/content (db/entity (:db/id editing-block))) + (not= (:block/title (db/entity (:db/id editing-block))) (state/get-edit-content))) target-block (or target-block editing-block) block (db/entity (:db/id target-block)) page (if (:block/name block) block (when target-block (:block/page (db/entity (:db/id target-block))))) empty-target? (if (true? skip-empty-target?) false - (string/blank? (:block/content target-block))) + (string/blank? (:block/title target-block))) paste-nested-blocks? (nested-blocks blocks) target-block-has-children? (db/has-children? (:block/uuid target-block)) replace-empty-target? (and empty-target? @@ -2356,14 +2356,14 @@ (insert "\n"))))))) (defn toggle-list-checkbox - [{:block/keys [content] :as block} item-content] + [{:block/keys [title] :as block} item-content] (let [toggle-fn (fn [m x-mark] (case (string/lower-case x-mark) "[ ]" (str "[x] " item-content) "[x]" (str "[ ] " item-content) m)) pattern (re-pattern (str "(\\[[xX ]\\])\\s+?" (gstring/regExpEscape item-content))) - new-content (string/replace-first content pattern toggle-fn)] + new-content (string/replace-first title pattern toggle-fn)] (save-block-if-changed! block new-content))) (defn- dwim-in-list @@ -2588,13 +2588,13 @@ :down util/get-next-block-non-collapsed) current-block (util/rec-get-node input "ls-block") sibling-block (f current-block) - {:block/keys [uuid content format]} (state/get-edit-block)] + {:block/keys [uuid title format]} (state/get-edit-block)] (if sibling-block (when-let [sibling-block-id (dom/attr sibling-block "blockid")] (let [container-id (some-> (dom/attr sibling-block "containerid") js/parseInt) value (state/get-edit-content)] (p/do! - (when (not= (clean-content! repo format content) + (when (not= (clean-content! repo format title) (string/trim value)) (save-block! repo uuid value)) @@ -2642,7 +2642,7 @@ sibling-block (f editing-block)] (when sibling-block (when-let [sibling-block-id (dom/attr sibling-block "blockid")] - (let [content (:block/content block) + (let [content (:block/title block) value (state/get-edit-content)] (when (and value (not= (clean-content! repo format content) (string/trim value))) (save-block! repo uuid value))) @@ -2699,7 +2699,7 @@ (let [repo (state/get-current-repo) editor-state (assoc (get-state) :block-id (:block/uuid next-block) - :value (:block/content next-block))] + :value (:block/title next-block))] (delete-block-inner! repo editor-state))))) (defn keydown-delete-handler @@ -3387,7 +3387,7 @@ "Whether block has a valid custom query." [block] (let [entity (db/entity (:db/id block)) - content (:block/content entity)] + content (:block/title entity)] (when content (when (and (string/includes? content "#+BEGIN_QUERY") (string/includes? content "#+END_QUERY")) @@ -3422,7 +3422,7 @@ (and (:outliner/block-title-collapse-enabled? (state/get-config)) (block-with-title? (:block/format block) - (:block/content block) + (:block/title block) semantic?)))) false))))) @@ -3773,7 +3773,7 @@ (let [repo (state/get-current-repo)] (when-let [{:keys [start end link]} (thingatpt/block-ref-at-point)] (when-let [block (db/entity [:block/uuid link])] - (let [block-content (:block/content block) + (let [block-content (:block/title block) format (or (:block/format block) :markdown) block-content-without-prop (-> (property-file/remove-properties-when-file-based repo format block-content) (drawer/remove-logbook))] @@ -3794,7 +3794,7 @@ (when (and block ref-id) (let [match (re-pattern (str "\\s?" (string/replace (block-ref/->block-ref ref-id) #"([\(\)])" "\\$1"))) - content (string/replace-first (:block/content block) match "")] + content (string/replace-first (:block/title block) match "")] (save-block! (state/get-current-repo) (:block/uuid block) content)))) @@ -3805,10 +3805,10 @@ (let [repo (state/get-current-repo) match (block-ref/->block-ref ref-id) ref-block (db/entity [:block/uuid ref-id]) - block-ref-content (->> (or (:block/content ref-block) "") + block-ref-content (->> (or (:block/title ref-block) "") (property-file/remove-built-in-properties-when-file-based repo (:block/format ref-block)) (drawer/remove-logbook)) - content (string/replace-first (:block/content block) match + content (string/replace-first (:block/title block) match block-ref-content)] (save-block! (state/get-current-repo) (:block/uuid block) @@ -3818,7 +3818,7 @@ [block ref-id] (when (and block ref-id) (let [match (block-ref/->block-ref ref-id) - content (string/replace-first (:block/content block) match + content (string/replace-first (:block/title block) match (util/format "{{embed ((%s))}}" (str ref-id)))] (save-block! (state/get-current-repo) diff --git a/src/main/frontend/handler/editor/lifecycle.cljs b/src/main/frontend/handler/editor/lifecycle.cljs index 1876301020..b6fb62db2b 100644 --- a/src/main/frontend/handler/editor/lifecycle.cljs +++ b/src/main/frontend/handler/editor/lifecycle.cljs @@ -52,10 +52,10 @@ ;; (= (:block/uuid new-block) ;; (:block/uuid edit-block)) ;; (not= (some-> edit-block string/trim) -;; (some-> (:block/content new-block) string/trim))) +;; (some-> (:block/title new-block) string/trim))) ;; (when-let [input (state/get-input)] ;; (util/set-change-value input -;; (block-handler/sanity-block-content repo (get new-block :block/format :markdown) (:block/content new-block)))))) +;; (block-handler/sanity-block-content repo (get new-block :block/format :markdown) (:block/title new-block)))))) ;; state) diff --git a/src/main/frontend/handler/events.cljs b/src/main/frontend/handler/events.cljs index e2281acf8b..fd0b122f31 100644 --- a/src/main/frontend/handler/events.cljs +++ b/src/main/frontend/handler/events.cljs @@ -984,7 +984,7 @@ :edit-original-block (fn [{:keys [editing-default-property?]}] (when editing-block - (let [content (:block/content (db/entity (:db/id editing-block))) + (let [content (:block/title (db/entity (:db/id editing-block))) esc? (= "Escape" (state/get-ui-last-key-code)) [content' pos] (cond esc? diff --git a/src/main/frontend/handler/export.cljs b/src/main/frontend/handler/export.cljs index f206df252f..61886ed096 100644 --- a/src/main/frontend/handler/export.cljs +++ b/src/main/frontend/handler/export.cljs @@ -108,7 +108,7 @@ :block/properties :block/format :block/children - :block/content + :block/title :block/created-at :block/updated-at] pages)})) diff --git a/src/main/frontend/handler/file_based/editor.cljs b/src/main/frontend/handler/file_based/editor.cljs index 078c2fad6a..5bfc7ce88b 100644 --- a/src/main/frontend/handler/file_based/editor.cljs +++ b/src/main/frontend/handler/file_based/editor.cljs @@ -32,7 +32,7 @@ [content block format new-marker old-marker] (if (and (state/enable-timetracking?) new-marker) (try - (let [logbook-exists? (and (:block/body block) (drawer/get-logbook (:block/body block))) + (let [logbook-exists? (and (:block.temp/ast-body block) (drawer/get-logbook (:block.temp/ast-body block))) new-marker (string/trim (string/lower-case (name new-marker))) old-marker (when old-marker (string/trim (string/lower-case (name old-marker)))) new-content (cond @@ -61,7 +61,7 @@ (defn- with-timetracking [block value] (if (and (state/enable-timetracking?) - (not= (:block/content block) value)) + (not= (:block/title block) value)) (let [format (:block/format block) new-marker (last (util/safe-re-find (status/marker-pattern format) (or value ""))) new-value (with-marker-time value block format @@ -71,22 +71,22 @@ value)) (defn wrap-parse-block - [{:block/keys [content format uuid level pre-block?] :as block + [{:block/keys [title format uuid level pre-block?] :as block :or {format :markdown}}] (let [repo (state/get-current-repo) block (or (and (:db/id block) (db/pull (:db/id block))) block) page (:block/page block) block (merge block - (block/parse-title-and-body uuid format pre-block? (:block/content block))) + (block/parse-title-and-body uuid format pre-block? (:block/title block))) properties (:block/properties block) properties (if (and (= format :markdown) (number? (:heading properties))) (dissoc properties :heading) properties) - real-content (:block/content block) - content (if (and (seq properties) real-content (not= real-content content)) - (property-file/with-built-in-properties-when-file-based repo properties content format) - content) + real-content (:block/title block) + content (if (and (seq properties) real-content (not= real-content title)) + (property-file/with-built-in-properties-when-file-based repo properties title format) + title) content (drawer/with-logbook block content) content (with-timetracking block content) first-block? (= (:block/uuid (ldb/get-first-child (db/get-db) (:db/id page))) @@ -112,7 +112,7 @@ (let [content' (str (config/get-block-pattern format) (if block-with-title? " " "\n") content)] [content content'])) block (assoc block - :block/content content' + :block/title content' :block/format format) block (apply dissoc block (remove #{:block/pre-block?} db-schema/retract-attributes)) block (block/parse-block block) @@ -126,7 +126,7 @@ (-> block (dissoc :block.temp/top? :block.temp/bottom?) - (assoc :block/content content + (assoc :block/title content :block/properties new-properties) (merge (if level {:block/level level} {}))))) @@ -136,7 +136,7 @@ (uuid? block-or-id) (db/entity [:block/uuid block-or-id]) :else block-or-id)] (let [format (:block/format block) - content (:block/content block) + content (:block/title block) properties (:block/properties block) properties (if (nil? value) (dissoc properties key) @@ -148,7 +148,7 @@ {:block/uuid (:block/uuid block) :block/properties properties :block/properties-order (or (keys properties) []) - :block/content content}))) + :block/title content}))) (defn- set-heading-aux! [block-id heading] @@ -170,26 +170,26 @@ (and (or (nil? heading) (true? heading)) (number? old-heading)) (let [block' (set-block-property-aux! block :heading heading) - content (commands/clear-markdown-heading (:block/content block'))] - (merge block' {:block/content content})) + content (commands/clear-markdown-heading (:block/title block'))] + (merge block' {:block/title content})) (and (or (nil? old-heading) (true? old-heading)) (number? heading)) (let [block' (set-block-property-aux! block :heading nil) properties (assoc (:block/properties block) :heading heading) - content (commands/set-markdown-heading (:block/content block') heading)] - (merge block' {:block/content content :block/properties properties})) + content (commands/set-markdown-heading (:block/title block') heading)] + (merge block' {:block/title content :block/properties properties})) ;; heading-num1 -> heading-num2 :else (let [properties (assoc (:block/properties block) :heading heading) content (-> block - :block/content + :block/title commands/clear-markdown-heading (commands/set-markdown-heading heading))] {:block/uuid (:block/uuid block) :block/properties properties - :block/content content})) + :block/title content})) (set-block-property-aux! block :heading heading)))) (defn batch-set-heading! [block-ids heading] diff --git a/src/main/frontend/handler/file_based/page_property.cljs b/src/main/frontend/handler/file_based/page_property.cljs index 2648368020..9f03704285 100644 --- a/src/main/frontend/handler/file_based/page_property.cljs +++ b/src/main/frontend/handler/file_based/page_property.cljs @@ -61,11 +61,11 @@ (if pre-block (let [properties (:block/properties pre-block) new-properties (assoc properties key value) - content (:block/content pre-block) + content (:block/title pre-block) new-content (insert-property format content key value) block {:db/id (:db/id pre-block) :block/properties new-properties - :block/content new-content + :block/title new-content :block/page page-id} tx [(assoc page-id :block/properties new-properties) block]] @@ -73,7 +73,7 @@ (let [block {:block/uuid (db/new-block-id) :block/parent page-id :block/page page-id - :block/content (if org? + :block/title (if org? (str "#+" (string/upper-case (name key)) ": " value) (str (name key) ":: " value)) :block/format format diff --git a/src/main/frontend/handler/file_based/property.cljs b/src/main/frontend/handler/file_based/property.cljs index d6123dff47..7fb3fbcc9d 100644 --- a/src/main/frontend/handler/file_based/property.cljs +++ b/src/main/frontend/handler/file_based/property.cljs @@ -33,7 +33,7 @@ (map last items))] (when-let [block (db/entity [:block/uuid block-id])] (let [format (:block/format block) - content (:block/content block) + content (:block/title block) properties (:block/properties block) properties-text-values (:block/properties-text-values block) properties (-> (merge properties new-properties) @@ -54,7 +54,7 @@ :block/properties properties :block/properties-order property-ks :block/properties-text-values properties-text-values - :block/content content}] + :block/title content}] (outliner-op/save-block! block {:retract-attributes? false})))))) (let [block-id (ffirst col) block-id (if (string? block-id) (uuid block-id) block-id) diff --git a/src/main/frontend/handler/import.cljs b/src/main/frontend/handler/import.cljs index b4dd0050c0..f762873a28 100644 --- a/src/main/frontend/handler/import.cljs +++ b/src/main/frontend/handler/import.cljs @@ -106,7 +106,7 @@ blocks (db/sort-by-order children) last-block (last blocks) snd-last-block (last (butlast blocks)) - [target-block sibling?] (if (and last-block (seq (:block/content last-block))) + [target-block sibling?] (if (and last-block (seq (:block/title last-block))) [last-block true] (if snd-last-block [snd-last-block true] diff --git a/src/main/frontend/handler/route.cljs b/src/main/frontend/handler/route.cljs index 17ee73560f..96c11f7595 100644 --- a/src/main/frontend/handler/route.cljs +++ b/src/main/frontend/handler/route.cljs @@ -59,7 +59,7 @@ (if (pu/lookup properties :logseq.property/heading) {:to :page-block :path-params {:name (get-in block [:block/page :block/name]) - :block-route-name (model/heading-content->route-name (:block/content block))}} + :block-route-name (model/heading-content->route-name (:block/title block))}} {:to :page :path-params {:name (if (string? page-name-or-block-uuid) (util/page-name-sanity-lc page-name-or-block-uuid) @@ -134,7 +134,7 @@ block? (util/uuid-string? name) block-title (when (and block? (not page)) (when-let [block (db/entity [:block/uuid (uuid name)])] - (let [content (text/remove-level-spaces (:block/content block) + (let [content (text/remove-level-spaces (:block/title block) (:block/format block) (config/get-block-pattern (:block/format block)))] (if (> (count content) 48) (str (subs content 0 48) "...") diff --git a/src/main/frontend/handler/whiteboard.cljs b/src/main/frontend/handler/whiteboard.cljs index 7b20d3b29d..7c8c4a4172 100644 --- a/src/main/frontend/handler/whiteboard.cljs +++ b/src/main/frontend/handler/whiteboard.cljs @@ -321,7 +321,7 @@ page-entity (model/get-page page-uuid) tx (sqlite-util/block-with-timestamps {:block/uuid new-block-id - :block/content (or content "") + :block/title (or content "") :block/format :markdown :block/page (:db/id page-entity) :block/parent (:db/id page-entity)}) diff --git a/src/main/frontend/schema/handler/common_config.cljc b/src/main/frontend/schema/handler/common_config.cljc index 696955ae99..38ad703d2d 100644 --- a/src/main/frontend/schema/handler/common_config.cljc +++ b/src/main/frontend/schema/handler/common_config.cljc @@ -38,7 +38,7 @@ :keyword [:or :string false? [:vector :string]]]] [:shortcut/doc-mode-enter-for-new-block? :boolean] - [:block/content-max-length :int] + [:block/title-max-length :int] [:ui/show-command-doc? :boolean] [:ui/show-empty-bullets? :boolean] [:ui/show-full-blocks? :boolean] diff --git a/src/main/frontend/search/browser.cljs b/src/main/frontend/search/browser.cljs index 1fcac4215c..5d50709d8a 100644 --- a/src/main/frontend/search/browser.cljs +++ b/src/main/frontend/search/browser.cljs @@ -19,7 +19,7 @@ (keep (fn [{:keys [content page] :as block}] {:page? (= (:uuid block) page) :block/uuid (uuid (:uuid block)) - :block/content content + :block/title content :block/page (uuid page)}) result)) (p/resolved nil))) (rebuild-pages-indice! [_this] diff --git a/src/main/frontend/state.cljs b/src/main/frontend/state.cljs index 3ab7e72382..edda6b4b74 100644 --- a/src/main/frontend/state.cljs +++ b/src/main/frontend/state.cljs @@ -772,7 +772,10 @@ Similar to re-frame subscriptions" (defn block-content-max-length [repo] - (or (:block/content-max-length (sub-config repo)) 10000)) + (or (:block/title-max-length (sub-config repo)) + ;; backward compatible + (:block/content-max-length (sub-config repo)) + 10000)) (defn mobile? [] diff --git a/src/main/frontend/util/drawer.cljs b/src/main/frontend/util/drawer.cljs index baa418eb4d..53860375d2 100644 --- a/src/main/frontend/util/drawer.cljs +++ b/src/main/frontend/util/drawer.cljs @@ -125,7 +125,7 @@ (defn with-logbook [block content] (let [new-clocks (last (get-drawer-ast (:block/format block) content "logbook")) - logbook (get-logbook (:block/body block))] + logbook (get-logbook (:block.temp/ast-body block))] (if logbook (let [content (remove-logbook content) clocks (->> (concat new-clocks (when-not new-clocks (last logbook))) @@ -133,7 +133,7 @@ clocks (->> (map string/trim clocks) (remove string/blank?) (string/join "\n"))] - (if (:block/title block) + (if (:block.temp/ast-title block) (insert-drawer (:block/format block) content "LOGBOOK" clocks) content)) content))) diff --git a/src/main/frontend/worker/export.cljs b/src/main/frontend/worker/export.cljs index 0a566da4ac..41229e688d 100644 --- a/src/main/frontend/worker/export.cljs +++ b/src/main/frontend/worker/export.cljs @@ -45,7 +45,7 @@ blocks (map (fn [b] (let [b' (if (seq (:block/properties b)) - (update b :block/content + (update b :block/title (fn [content] (gp-property/remove-properties (:block/format b) content))) b)] diff --git a/src/main/frontend/worker/file.cljs b/src/main/frontend/worker/file.cljs index ca3e34ddcd..23d75c6e88 100644 --- a/src/main/frontend/worker/file.cljs +++ b/src/main/frontend/worker/file.cljs @@ -35,7 +35,7 @@ '[:block/properties :block/uuid :block/order - :block/content + :block/title :block/format :block/created-at :block/updated-at @@ -50,7 +50,7 @@ :db/id :block/uuid ;; shape block uuid is read from properties :block/collapsed? - :block/content + :block/title :block/format :block/order :block/page @@ -73,7 +73,7 @@ blocks (ldb/get-page-blocks @conn (:db/id page-block) {:pull-keys pull-keys}) blocks (if whiteboard? (map cleanup-whiteboard-block blocks) blocks)] (if (and (= 1 (count blocks)) - (string/blank? (:block/content (first blocks))) + (string/blank? (:block/title (first blocks))) (nil? (:block/file page-block)) (not whiteboard?)) (dissoc-request! request-id) diff --git a/src/main/frontend/worker/file/core.cljs b/src/main/frontend/worker/file/core.cljs index 1dcbd7443c..3818a2eeeb 100644 --- a/src/main/frontend/worker/file/core.cljs +++ b/src/main/frontend/worker/file/core.cljs @@ -48,13 +48,13 @@ content)) (defn- transform-content - [repo db {:block/keys [collapsed? format pre-block? content page properties] :as b} level {:keys [heading-to-list?]} context] + [repo db {:block/keys [collapsed? format pre-block? title page properties] :as b} level {:keys [heading-to-list?]} context] (let [block-ref-not-saved? (and (seq (:block/_refs (d/entity db (:db/id b)))) - (not (string/includes? content (str (:block/uuid b)))) + (not (string/includes? title (str (:block/uuid b)))) (not (sqlite-util/db-based-graph? repo))) heading (:heading properties) markdown? (= :markdown format) - content (or content "") + content (or title "") page-first-child? (= (:db/id b) (ldb/get-first-child db (:db/id page))) pre-block? (or pre-block? (and page-first-child? diff --git a/src/main/frontend/worker/handler/page.cljs b/src/main/frontend/worker/handler/page.cljs index 3e0ee2a652..5f063fca38 100644 --- a/src/main/frontend/worker/handler/page.cljs +++ b/src/main/frontend/worker/handler/page.cljs @@ -46,12 +46,12 @@ (let [refs (:block/_refs page-entity) id-ref->page #(db-content/special-id-ref->page % [page-entity])] (when (seq refs) - (let [tx-data (mapcat (fn [{:block/keys [raw-content] :as ref}] + (let [tx-data (mapcat (fn [{:block/keys [raw-title] :as ref}] ;; block content - (let [content' (id-ref->page raw-content) - content-tx (when (not= raw-content content') + (let [content' (id-ref->page raw-title) + content-tx (when (not= raw-title content') {:db/id (:db/id ref) - :block/content content'}) + :block/title content'}) tx content-tx] (concat [[:db/retract (:db/id ref) :block/refs (:db/id page-entity)]] diff --git a/src/main/frontend/worker/handler/page/db_based/page.cljs b/src/main/frontend/worker/handler/page/db_based/page.cljs index f4dc523292..05b2704b65 100644 --- a/src/main/frontend/worker/handler/page/db_based/page.cljs +++ b/src/main/frontend/worker/handler/page/db_based/page.cljs @@ -59,7 +59,7 @@ :block/page page-id :block/parent page-id :block/order (db-order/gen-key nil nil) - :block/content "" + :block/title "" :block/format format})])) (defn create! diff --git a/src/main/frontend/worker/handler/page/file_based/page.cljs b/src/main/frontend/worker/handler/page/file_based/page.cljs index 71d42e5b7e..6676e8837e 100644 --- a/src/main/frontend/worker/handler/page/file_based/page.cljs +++ b/src/main/frontend/worker/handler/page/file_based/page.cljs @@ -23,7 +23,7 @@ :block/refs refs :block/order (db-order/gen-key nil nil) :block/format format - :block/content content + :block/title content :block/parent page :block/page page})) @@ -61,7 +61,7 @@ :block/page page-id :block/parent page-id :block/order (db-order/gen-key nil nil) - :block/content "" + :block/title "" :block/format format})])) (defn create! diff --git a/src/main/frontend/worker/handler/page/file_based/rename.cljs b/src/main/frontend/worker/handler/page/file_based/rename.cljs index 205e892f99..6320880cb6 100644 --- a/src/main/frontend/worker/handler/page/file_based/rename.cljs +++ b/src/main/frontend/worker/handler/page/file_based/rename.cljs @@ -116,9 +116,9 @@ (let [to-page (ldb/get-page db new-name) old-title (:block/title page) blocks (:block/_refs (d/entity db (:db/id page))) - tx (->> (map (fn [{:block/keys [uuid content properties format] :as block}] - (let [content (let [content' (replace-old-page! config content old-title new-name format)] - (when-not (= content' content) + tx (->> (map (fn [{:block/keys [uuid title properties format] :as block}] + (let [content (let [content' (replace-old-page! config title old-title new-name format)] + (when-not (= content' title) content')) properties (let [properties' (walk-replace-old-page! config properties old-title new-name format)] (when-not (= properties' properties) @@ -126,7 +126,7 @@ (when (or content properties) (common-util/remove-nils-non-nested {:block/uuid uuid - :block/content content + :block/title content :block/properties properties :block/properties-order (when (seq properties) (map first properties)) diff --git a/src/main/frontend/worker/rtc/const.cljs b/src/main/frontend/worker/rtc/const.cljs index 5bd738901d..c227810f39 100644 --- a/src/main/frontend/worker/rtc/const.cljs +++ b/src/main/frontend/worker/rtc/const.cljs @@ -228,7 +228,7 @@ [:block/parent {:optional true} :uuid] [:block/type {:optional true} [:set :string]] [:block/order {:optional true} :string] - [:block/content {:optional true} :string]]]]]] + [:block/title {:optional true} :string]]]]]] ["get-assets-upload-urls" [:map diff --git a/src/main/frontend/worker/rtc/db_listener.cljs b/src/main/frontend/worker/rtc/db_listener.cljs index 035f4380cb..adb289e8cd 100644 --- a/src/main/frontend/worker/rtc/db_listener.cljs +++ b/src/main/frontend/worker/rtc/db_listener.cljs @@ -20,7 +20,7 @@ :else {false (conj {} latest-retract)}))) (def ^:private watched-attrs - #{:block/content :block/created-at :block/updated-at :block/alias + #{:block/title :block/created-at :block/updated-at :block/alias :block/tags :block/type :block/schema :block/link :block/journal-day :class/parent :class/schema.properties :property/schema.classes :property.value/content :db/index :db/valueType :db/cardinality}) diff --git a/src/main/frontend/worker/rtc/remote_update.cljs b/src/main/frontend/worker/rtc/remote_update.cljs index 7ab9b024fd..ff5f05748d 100644 --- a/src/main/frontend/worker/rtc/remote_update.cljs +++ b/src/main/frontend/worker/rtc/remote_update.cljs @@ -194,7 +194,7 @@ (transact-db! :move-blocks repo conn [b] local-parent false) (transact-db! :insert-blocks repo conn [{:block/uuid block-uuid - :block/content "" + :block/title "" :block/format :markdown}] local-parent {:sibling? false :keep-uuid? true})) (transact-db! :update-block-order-directly repo conn block-uuid first-remote-parent remote-block-order)) @@ -330,7 +330,7 @@ (transact-db! :upsert-whiteboard-block conn [(gp-whiteboard/shape->block repo shape page-id)]))))) (def ^:private update-op-watched-attrs - #{:block/content + #{:block/title :block/updated-at :block/created-at :block/alias diff --git a/src/main/frontend/worker/rtc/skeleton.cljs b/src/main/frontend/worker/rtc/skeleton.cljs index fa90248c3b..ceefb5bb2d 100644 --- a/src/main/frontend/worker/rtc/skeleton.cljs +++ b/src/main/frontend/worker/rtc/skeleton.cljs @@ -13,7 +13,7 @@ {:block/parent [:block/uuid]} :block/order :block/type - :block/content]) + :block/title]) (filter :block/uuid))] (map (fn [block] diff --git a/src/main/frontend/worker/search.cljs b/src/main/frontend/worker/search.cljs index 5ad9d98ac6..e8517594f8 100644 --- a/src/main/frontend/worker/search.cljs +++ b/src/main/frontend/worker/search.cljs @@ -188,7 +188,7 @@ "Returns property value if the given entity is type 'closed value' or nil" [ent] (when (contains? (:block/type ent) "closed value") - (:block/content ent)))) + (:block/title ent)))) (comment (defn- get-db-properties-str @@ -208,13 +208,9 @@ (property-value-when-closed e) ;; :page or :date properties (:block/title e) - ;; block generated by template - (and - (:logseq.property/created-from-template e) - (:block/content e)) - ;; first child + ;; first child (let [parent-id (:db/id e)] - (:block/content (ldb/get-first-child db parent-id))))] + (:block/title (ldb/get-first-child db parent-id))))] value) val))) (remove string/blank?)) @@ -227,12 +223,12 @@ (defn block->index "Convert a block to the index for searching" - [{:block/keys [uuid page content format] :as block}] + [{:block/keys [uuid page title format] :as block}] (when-not (or (:block/name block) (ldb/closed-value? block) - (and (string? content) (> (count content) 10000)) - (string/blank? content)) ; empty page or block + (and (string? title) (> (count title) 10000)) + (string/blank? title)) ; empty page or block ;; Should properties be included in the search indice? ;; It could slow down the search indexing, also it can be confusing ;; if the showing properties are not useful to users. @@ -242,7 +238,7 @@ (when uuid {:id (str uuid) :page (str (or (:block/uuid page) uuid)) - :content (sanitize content) + :content (sanitize title) :format format}))) @@ -328,7 +324,7 @@ datoms (filter (fn [datom] ;; Capture any direct change on page display title, page ref or block content - (contains? #{:block/uuid :block/name :block/title :block/content :block/properties :block/schema} (:a datom))) + (contains? #{:block/uuid :block/name :block/title :block/properties :block/schema} (:a datom))) data)] (when (seq datoms) (get-blocks-from-datoms-impl repo tx-report datoms)))) diff --git a/src/main/frontend/worker/undo_redo.cljs b/src/main/frontend/worker/undo_redo.cljs index 44875ebffa..83b3c62315 100644 --- a/src/main/frontend/worker/undo_redo.cljs +++ b/src/main/frontend/worker/undo_redo.cljs @@ -78,7 +78,7 @@ when undo this op, this original entity-map will be transacted back into db") [:block/uuid :uuid] [:block/left :uuid] [:block/parent :uuid] - [:block/content :string] + [:block/title :string] [:block/created-at {:optional true} :int] [:block/updated-at {:optional true} :int] [:block/format {:optional true} :any] @@ -112,7 +112,7 @@ when undo this op, this original entity-map will be transacted back into db") [:block/uuid {:block/left [:block/uuid]} {:block/parent [:block/uuid]} - :block/content + :block/title :block/created-at :block/updated-at :block/format @@ -161,7 +161,7 @@ when undo this op, this original entity-map will be transacted back into db") (let [value-keys (set (keys (second op))) block-entity (d/entity db [:block/uuid block-uuid]) block-origin-content (when (contains? value-keys :block-origin-content) - (:block/content block-entity)) + (:block/title block-entity)) block-origin-tags (when (contains? value-keys :block-origin-tags) (mapv :block/uuid (:block/tags block-entity))) block-origin-collapsed (when (contains? value-keys :block-origin-collapsed) @@ -272,7 +272,7 @@ when undo this op, this original entity-map will be transacted back into db") :conn conn}} (outliner-core/insert-blocks! repo conn [(cond-> {:block/uuid block-uuid - :block/content (:block/content block-entity-map) + :block/title (:block/title block-entity-map) :block/format :markdown} (:block/created-at block-entity-map) (assoc :block/created-at (:block/created-at block-entity-map)) @@ -357,7 +357,7 @@ when undo this op, this original entity-map will be transacted back into db") (ldb/transact! conn retract-attrs-tx-data {:gen-undo-ops? false})) new-block (cond-> block-entity (some? block-origin-content) - (assoc :block/content block-origin-content) + (assoc :block/title block-origin-content) (some? block-origin-tags) (assoc :block/tags (some->> block-origin-tags (map (partial vector :block/uuid)) @@ -420,7 +420,7 @@ when undo this op, this original entity-map will be transacted back into db") (let [editor-cursors (->> (filter #(= ::record-editor-info (first %)) ops) (map second) (reverse)) - block-content (:block/content (d/entity @conn [:block/uuid (:block-uuid (first editor-cursors))]))] + block-content (:block/title (d/entity @conn [:block/uuid (:block-uuid (first editor-cursors))]))] {:undo? true :editor-cursors editor-cursors :block-content block-content})) @@ -445,7 +445,7 @@ when undo this op, this original entity-map will be transacted back into db") (push-undo-ops repo page-block-uuid (vec (cons boundary rev-ops)))) (let [editor-cursors (->> (filter #(= ::record-editor-info (first %)) ops) (map second)) - block-content (:block/content (d/entity @conn [:block/uuid (:block-uuid (last editor-cursors))]))] + block-content (:block/title (d/entity @conn [:block/uuid (:block-uuid (last editor-cursors))]))] {:redo? true :editor-cursors editor-cursors :block-content block-content})) @@ -499,15 +499,15 @@ when undo this op, this original entity-map will be transacted back into db") other-ops (let [updated-attrs (seq (set/intersection updated-key-set - #{:block/content :block/tags :block/collapsed? :block/link}))] + #{:block/title :block/tags :block/collapsed? :block/link}))] (when-let [update-block-op-value (when (normal-block? entity-after) (some->> updated-attrs (keep (fn [attr-name] (case attr-name - :block/content - (when-let [origin-content (:block/content entity-before)] + :block/title + (when-let [origin-content (:block/title entity-before)] [:block-origin-content origin-content]) :block/tags diff --git a/src/main/frontend/worker/undo_redo2.cljs b/src/main/frontend/worker/undo_redo2.cljs index 1cdabb0ce4..28439ea47c 100644 --- a/src/main/frontend/worker/undo_redo2.cljs +++ b/src/main/frontend/worker/undo_redo2.cljs @@ -295,7 +295,7 @@ ((if undo? push-redo-op push-undo-op) repo op) (let [editor-cursors (->> (filter #(= ::record-editor-info (first %)) op) (map second)) - block-content (:block/content (d/entity @conn [:block/uuid (:block-uuid + block-content (:block/title (d/entity @conn [:block/uuid (:block-uuid (if undo? (first editor-cursors) (last editor-cursors)))]))] diff --git a/src/test/frontend/components/query/result_test.cljs b/src/test/frontend/components/query/result_test.cljs index dbb14004a3..41da531938 100644 --- a/src/test/frontend/components/query/result_test.cljs +++ b/src/test/frontend/components/query/result_test.cljs @@ -67,9 +67,9 @@ "Current block is not included in results"))))) (deftest get-query-result-with-remove-block-children-option - (let [result [{:db/id 1 :block/content "parent" :block/uuid 1} - {:db/id 2 :block/content "child" :block/uuid 2 :block/parent {:db/id 1}}]] - (is (= [{:db/id 1 :block/content "parent" :block/uuid 1}] + (let [result [{:db/id 1 :block/title "parent" :block/uuid 1} + {:db/id 2 :block/title "child" :block/uuid 2 :block/parent {:db/id 1}}]] + (is (= [{:db/id 1 :block/title "parent" :block/uuid 1}] (mock-get-query-result result {:remove-block-children? true} {:table? true})) "Removes children when :remove-block-children? is true") (is (= result @@ -77,7 +77,7 @@ "Doesn't remove children when :remove-block-children? is false"))) (deftest get-query-result-sets-result-in-config - (let [result [{:db/id 1 :block/content "parent" :block/uuid 1}] + (let [result [{:db/id 1 :block/title "parent" :block/uuid 1}] config {:query-result (atom nil)}] (is (= result (mock-get-query-result result {} {:table? true :config config}))) diff --git a/src/test/frontend/components/query_table_test.cljs b/src/test/frontend/components/query_table_test.cljs index 041bf3d897..8aa54a4d4f 100644 --- a/src/test/frontend/components/query_table_test.cljs +++ b/src/test/frontend/components/query_table_test.cljs @@ -22,8 +22,8 @@ (testing "sort by block column" (are [sort-state result sorted-result] - (= (mapv #(hash-map :block/content %) sorted-result) - (#'query-table/sort-result (mapv #(hash-map :block/content %) result) sort-state)) + (= (mapv #(hash-map :block/title %) sorted-result) + (#'query-table/sort-result (mapv #(hash-map :block/title %) result) sort-state)) {:sort-desc? true :sort-by-column :block} ["abc" "cde"] ["cde" "abc"] diff --git a/src/test/frontend/db/model_test.cljs b/src/test/frontend/db/model_test.cljs index a543cb0ed8..66940684ac 100644 --- a/src/test/frontend/db/model_test.cljs +++ b/src/test/frontend/db/model_test.cljs @@ -162,9 +162,9 @@ foo:: bar"}]) - child 2 - grandchild 2 - child 3"}]) - (let [parent (-> (d/q '[:find (pull ?b [*]) :where [?b :block/content "parent"]] + (let [parent (-> (d/q '[:find (pull ?b [*]) :where [?b :block/title "parent"]] (conn/get-db test-helper/test-db)) ffirst)] (is (= ["child 1" "child 2" "child 3"] - (map :block/content + (map :block/title (model/get-block-immediate-children test-helper/test-db (:block/uuid parent))))))) diff --git a/src/test/frontend/db/query_custom_test.cljs b/src/test/frontend/db/query_custom_test.cljs index c9d2ad881c..18a28ae063 100644 --- a/src/test/frontend/db/query_custom_test.cljs +++ b/src/test/frontend/db/query_custom_test.cljs @@ -23,7 +23,7 @@ (testing "advanced datalog queries" (is (= ["LATER b3"] - (map :block/content + (map :block/title (custom-query {:query '[:find (pull ?b [*]) :where (block-content ?b "b") @@ -31,7 +31,7 @@ "basic advanced query works") (is (= ["LATER b3"] - (map :block/content + (map :block/title (custom-query {:query '[:find (pull ?b [*]) :in $ :where @@ -40,7 +40,7 @@ "advanced query with an :in works") (is (= ["foo:: bar\n" "b3"] - (map :block/content + (map :block/title (custom-query {:query '[:find (pull ?b [*]) :in $ ?query % :where @@ -52,14 +52,14 @@ "advanced query that uses rule from logseq and rule from :inputs") (is (= ["LATER b3"] - (map :block/content + (map :block/title (custom-query {:query '[:find (pull ?b [*]) :in $ % :where (starts-with ?b "LA") (task ?b #{"LATER"})] :rules '[[(starts-with ?b ?substr) - [?b :block/content ?content] + [?b :block/title ?content] [(clojure.string/starts-with? ?content ?substr)]]]}))) "advanced query that uses :rules and rules from logseq") @@ -74,6 +74,6 @@ "advanced query with bound :in argument works")) (is (= ["LATER b3"] - (map :block/content + (map :block/title (custom-query {:query (list 'and '(task later) "b")}))) "Simple query returns correct results")) diff --git a/src/test/frontend/db/query_dsl_test.cljs b/src/test/frontend/db/query_dsl_test.cljs index b018e0c9ca..de14510994 100644 --- a/src/test/frontend/db/query_dsl_test.cljs +++ b/src/test/frontend/db/query_dsl_test.cljs @@ -72,9 +72,9 @@ "(and \"for #clojure\" #tag foo)"))) (defn- testable-content - "Only test :block/content up to page-ref as page-ref content varies between db and file graphs" - [{:block/keys [content]}] - (some->> content + "Only test :block/title up to page-ref as page-ref content varies between db and file graphs" + [{:block/keys [title]}] + (some->> title (re-find #"[^\[]+") str/trim)) @@ -97,51 +97,51 @@ prop-d:: [[nada]]"}]) (testing "Blocks have given property value" (is (= #{"b1" "b2"} - (set (map (comp first str/split-lines :block/content) + (set (map (comp first str/split-lines :block/title) (dsl-query "(property prop-a val-a)"))))) (is (= ["b2"] - (map (comp first str/split-lines :block/content) + (map (comp first str/split-lines :block/title) (dsl-query "(property prop-b val-b)"))))) (is (= ["b2"] - (map (comp first str/split-lines :block/content) + (map (comp first str/split-lines :block/title) (dsl-query "(and (property prop-b val-b))"))) "Blocks have property value with empty AND") (is (= ["b3"] - (map (comp first str/split-lines :block/content) + (map (comp first str/split-lines :block/title) (dsl-query "(and (property prop-c \"page c\"))"))) "Blocks have property value from a set of values") (is (= ["b3"] - (map (comp first str/split-lines :block/content) + (map (comp first str/split-lines :block/title) (dsl-query "(and (property prop-c \"page c\") (property prop-c \"page b\"))"))) "Blocks have ANDed property values") (is (= #{"b2" "b3"} (set - (map (comp first str/split-lines :block/content) + (map (comp first str/split-lines :block/title) (dsl-query "(or (property prop-c \"page c\") (property prop-b val-b))")))) "Blocks have ORed property values") (is (= ["b1"] - (map (comp first str/split-lines :block/content) + (map (comp first str/split-lines :block/title) (dsl-query "(property prop-num 2000)"))) "Blocks have integer property value") (is (= ["b3"] - (map (comp first str/split-lines :block/content) + (map (comp first str/split-lines :block/title) (dsl-query "(property prop-linked-num 3000)"))) "Blocks have property with integer page value") (is (= ["b3"] - (map (comp first str/split-lines :block/content) + (map (comp first str/split-lines :block/title) (dsl-query "(property prop-d no-space-link)"))) "Blocks have property value with no space") (is (= ["b3" "b4"] - (map (comp first str/split-lines :block/content) + (map (comp first str/split-lines :block/title) (dsl-query "(property prop-d)"))) "Blocks that have a property")) @@ -155,16 +155,16 @@ prop-d:: [[nada]]"}]) (deftest db-only-block-property-queries (load-test-files-for-db-graph [{:page {:block/title "page1"} - :blocks [{:block/content "b1" + :blocks [{:block/title "b1" :build/properties {:Foo "bar"}} - {:block/content "b2" + {:block/title "b2" :build/properties {:foo "bar"}}]}]) (is (= ["b1"] - (map :block/content (dsl-query "(property Foo)"))) + (map :block/title (dsl-query "(property Foo)"))) "filter is case sensitive") (is (= ["b2"] - (map :block/content (dsl-query "(property :user.property/foo)"))) + (map :block/title (dsl-query "(property :user.property/foo)"))) "filter can handle qualified keyword properties"))) (deftest block-property-query-performance @@ -312,11 +312,11 @@ prop-d:: [[nada]]"}]) (deftest priority-queries (load-test-files (if js/process.env.DB_GRAPH [{:page {:block/title "page1"} - :blocks [{:block/content "[#A] b1" + :blocks [{:block/title "[#A] b1" :build/properties {:logseq.task/priority :logseq.task/priority.high}} - {:block/content "[#B] b2" + {:block/title "[#B] b2" :build/properties {:logseq.task/priority :logseq.task/priority.medium}} - {:block/content "[#A] b3" + {:block/title "[#A] b3" :build/properties {:logseq.task/priority :logseq.task/priority.high}}]}] [{:file/path "pages/page1.md" @@ -327,23 +327,23 @@ prop-d:: [[nada]]"}]) (testing "one arg queries" (is (= #{"[#A] b1" "[#A] b3"} - (set (map :block/content + (set (map :block/title (dsl-query (if js/process.env.DB_GRAPH "(priority high)" "(priority a)")))))) (is (= #{"[#A] b1" "[#A] b3"} - (set (map :block/content + (set (map :block/title (dsl-query (if js/process.env.DB_GRAPH "(priority high)" "(priority a)"))))))) (testing "two arg queries" (is (= #{"[#A] b1" "[#B] b2" "[#A] b3"} - (set (map :block/content + (set (map :block/title (dsl-query (if js/process.env.DB_GRAPH "(priority high medium)" "(priority a b)")))))) (is (= #{"[#A] b1" "[#B] b2" "[#A] b3"} - (set (map :block/content + (set (map :block/title (dsl-query (if js/process.env.DB_GRAPH "(priority [high medium])" "(priority [a b])"))))) "Arguments with vector notation")) (is (= #{"[#A] b1" "[#B] b2" "[#A] b3"} - (set (map :block/content + (set (map :block/title (dsl-query (if js/process.env.DB_GRAPH "(priority high medium low)" "(priority a b c)"))))) "Three arg queries and args that have no match")) @@ -431,10 +431,10 @@ prop-d:: [[nada]]"}]) :file/content "- b1 Hit\n- b2 Another"}]) (is (= ["b1 Hit"] - (map :block/content (dsl-query "\"Hit\"")))) + (map :block/title (dsl-query "\"Hit\"")))) (is (= [] - (map :block/content (dsl-query "\"miss\""))) + (map :block/title (dsl-query "\"miss\""))) "Correctly returns no results")) (deftest page-queries @@ -508,10 +508,10 @@ prop-d:: [[nada]]"}]) (deftest nested-page-ref-queries (load-test-files (if js/process.env.DB_GRAPH [{:page {:block/title "page1"} - :blocks [{:block/content "p1 [[Parent page]]" - :build/children [{:block/content "[[Child page]]"}]} - {:block/content "p2 [[Parent page]]" - :build/children [{:block/content "Non linked content"}]}]}] + :blocks [{:block/title "p1 [[Parent page]]" + :build/children [{:block/title "[[Child page]]"}]} + {:block/title "p2 [[Parent page]]" + :build/children [{:block/title "Non linked content"}]}]}] [{:file/path "pages/page1.md" :file/content "foo:: bar - p1 [[Parent page]] @@ -563,10 +563,10 @@ created-at:: 1608968448116 '(task doing) '(task now))] (is (= ["NOW b1"] - (map :block/content (custom-query {:query task-query})))) + (map :block/title (custom-query {:query task-query})))) (is (= ["NOW b1"] - (map :block/content (custom-query {:query (list 'and task-query "b")}))) + (map :block/title (custom-query {:query (list 'and task-query "b")}))) "Query with rule that can't be derived from the form itself"))) (if js/process.env.DB_GRAPH diff --git a/src/test/frontend/db/query_react_test.cljs b/src/test/frontend/db/query_react_test.cljs index 1a2db355b4..27a49f4c2d 100644 --- a/src/test/frontend/db/query_react_test.cljs +++ b/src/test/frontend/db/query_react_test.cljs @@ -19,19 +19,19 @@ adds rules that users often use" (defn- blocks-created-between-inputs [a b] (sort - (map #(-> % :block/content string/split-lines first) + (map #(-> % :block/title string/split-lines first) (custom-query {:inputs [a b] :query '[:find (pull ?b [*]) :in $ ?start ?end :where - [?b :block/content] + [?b :block/title] [?b :block/created-at ?timestamp] [(>= ?timestamp ?start)] [(<= ?timestamp ?end)]]})))) (defn- blocks-with-tag-on-specified-current-page [& {:keys [current-page tag]}] - (map :block/content (custom-query {:title "Query title" + (map :block/title (custom-query {:title "Query title" :inputs [:current-page tag] :query '[:find (pull ?b [*]) :in $ ?current-page ?tag-name diff --git a/src/test/frontend/handler/editor_async_test.cljs b/src/test/frontend/handler/editor_async_test.cljs index a4726928dc..1a8fd31ada 100644 --- a/src/test/frontend/handler/editor_async_test.cljs +++ b/src/test/frontend/handler/editor_async_test.cljs @@ -60,7 +60,7 @@ -"}]) (p/let [conn (db/get-db test-helper/test-db false) block (->> (d/q '[:find (pull ?b [*]) - :where [?b :block/content ""] + :where [?b :block/title ""] [?p :block/name "page1"] [?b :block/page ?p]] @conn) @@ -68,9 +68,9 @@ (delete-block @conn block {:on-delete (fn [] (let [updated-blocks (->> (d/q '[:find (pull ?b [*]) - :where [?b :block/content] [(missing? $ ?b :block/pre-block?)]] + :where [?b :block/title] [(missing? $ ?b :block/pre-block?)]] @conn) - (map (comp :block/content first)))] + (map (comp :block/title first)))] (is (= ["b1" "b2"] updated-blocks) "Block is deleted")))}))) (testing "backspace deletes empty block in embedded context" @@ -83,7 +83,7 @@ -"}]) (p/let [conn (db/get-db test-helper/test-db false) block (->> (d/q '[:find (pull ?b [*]) - :where [?b :block/content ""] + :where [?b :block/title ""] [?p :block/name "page1"] [?b :block/page ?p]] @conn) @@ -92,7 +92,7 @@ {:embed? true :on-delete (fn [] (let [updated-blocks (->> (d/q '[:find (pull ?b [*]) - :where [?b :block/content] [(missing? $ ?b :block/pre-block?)]] + :where [?b :block/title] [(missing? $ ?b :block/pre-block?)]] @conn) - (map (comp :block/content first)))] + (map (comp :block/title first)))] (is (= ["b1" "b2"] updated-blocks) "Block is deleted")))})))) diff --git a/src/test/frontend/handler/editor_test.cljs b/src/test/frontend/handler/editor_test.cljs index c3e990298c..136b0ffc27 100644 --- a/src/test/frontend/handler/editor_test.cljs +++ b/src/test/frontend/handler/editor_test.cljs @@ -56,7 +56,7 @@ (let [actual-content (atom nil)] (with-redefs [editor/save-block-if-changed! (fn [_ content] (reset! actual-content content))] - (editor/set-marker {:block/marker marker :block/content content :block/format format}) + (editor/set-marker {:block/marker marker :block/title content :block/format format}) @actual-content))) (deftest set-marker-org @@ -227,7 +227,7 @@ (testing "updating block's content changes content and preserves path-refs" (let [conn (db/get-db test-helper/test-db false) block (->> (d/q '[:find (pull ?b [* {:block/path-refs [:block/name]}]) - :where [?b :block/content "b1 #foo"]] + :where [?b :block/title "b1 #foo"]] @conn) ffirst) prev-path-refs (set (map :block/name (:block/path-refs block))) @@ -236,7 +236,7 @@ ;; Use same options as edit-box-on-change! _ (editor/save-block-aux! block "b12 #foo" {:skip-properties? true}) updated-block (d/pull @conn '[* {:block/path-refs [:block/name]}] [:block/uuid (:block/uuid block)])] - (is (= "b12 #foo" (:block/content updated-block)) "Content updated correctly") + (is (= "b12 #foo" (:block/title updated-block)) "Content updated correctly") (is (= prev-path-refs (set (map :block/name (:block/path-refs updated-block)))) "Path-refs remain the same")))) @@ -249,10 +249,10 @@ page-uuid (:block/uuid (db/get-page "foo")) block-uuid (:block/uuid (model/get-block-by-page-name-and-block-route-name repo (str page-uuid) "foo"))] (editor/save-block! repo block-uuid "# bar") - (is (= "# bar" (:block/content (model/query-block-by-uuid block-uuid)))) + (is (= "# bar" (:block/title (model/query-block-by-uuid block-uuid)))) (editor/save-block! repo block-uuid "# foo" {:properties {:foo "bar"}}) - (is (= "# foo\nfoo:: bar" (:block/content (model/query-block-by-uuid block-uuid)))) + (is (= "# foo\nfoo:: bar" (:block/title (model/query-block-by-uuid block-uuid)))) (editor/save-block! repo block-uuid "# bar") - (is (= "# bar" (:block/content (model/query-block-by-uuid block-uuid))))))) + (is (= "# bar" (:block/title (model/query-block-by-uuid block-uuid))))))) diff --git a/src/test/frontend/handler/paste_test.cljs b/src/test/frontend/handler/paste_test.cljs index 459f994ea6..28982901a4 100644 --- a/src/test/frontend/handler/paste_test.cljs +++ b/src/test/frontend/handler/paste_test.cljs @@ -200,8 +200,8 @@ (deftest-async editor-on-paste-with-copied-blocks (let [actual-blocks (atom nil) ;; Simplified version of block attributes that are copied - expected-blocks [{:block/content "Test node"} - {:block/content "Notes\nid:: 6422ec75-85c7-4e09-9a4d-2a1639a69b2f"}] + expected-blocks [{:block/title "Test node"} + {:block/title "Notes\nid:: 6422ec75-85c7-4e09-9a4d-2a1639a69b2f"}] clipboard "- Test node\n\t- Notes\nid:: 6422ec75-85c7-4e09-9a4d-2a1639a69b2f"] (test-helper/with-reset reset diff --git a/src/test/frontend/handler/route_test.cljs b/src/test/frontend/handler/route_test.cljs index ecc7c65bef..5b705fbdca 100644 --- a/src/test/frontend/handler/route_test.cljs +++ b/src/test/frontend/handler/route_test.cljs @@ -20,7 +20,7 @@ foo:: bar (testing ":page-block route" (let [block (ffirst (db-utils/q '[:find (pull ?b [:block/uuid]) - :where [?b :block/content "## B1"]]))] + :where [?b :block/title "## B1"]]))] (is (= {:to :page-block :path-params {:name "foo" :block-route-name "b1"}} (#'route-handler/default-page-route (:block/uuid block))) @@ -28,7 +28,7 @@ foo:: bar (let [block (ffirst (db-utils/q '[:find (pull ?b [:block/uuid]) - :where [?b :block/content "### Header 2\nfoo:: bar"]]))] + :where [?b :block/title "### Header 2\nfoo:: bar"]]))] (is (= {:to :page-block :path-params {:name "foo" :block-route-name "header 2"}} (#'route-handler/default-page-route (:block/uuid block))) @@ -36,7 +36,7 @@ foo:: bar (let [block (ffirst (db-utils/q '[:find (pull ?b [:block/uuid]) - :where [?b :block/content "## Header 3 [[Dec 19th, 2022]]"]]))] + :where [?b :block/title "## Header 3 [[Dec 19th, 2022]]"]]))] (is (= {:to :page-block :path-params {:name "foo" :block-route-name "header 3 [[dec 19th, 2022]]"}} (#'route-handler/default-page-route (:block/uuid block))) @@ -44,7 +44,7 @@ foo:: bar (testing ":page route" (let [uuid (-> (db-utils/q '[:find (pull ?b [:block/uuid]) - :where [?b :block/content "b2"]]) + :where [?b :block/title "b2"]]) ffirst :block/uuid)] (is (= {:to :page :path-params {:name (str uuid)}} diff --git a/src/test/frontend/modules/outliner/core_test.cljs b/src/test/frontend/modules/outliner/core_test.cljs index 90ced620a2..3912b3794e 100644 --- a/src/test/frontend/modules/outliner/core_test.cljs +++ b/src/test/frontend/modules/outliner/core_test.cljs @@ -87,7 +87,7 @@ blocks (outliner-core/tree-vec-flatten blocks :block/children)] (map (fn [block] (assoc block :block/page 1 - :block/content "1")) blocks))) + :block/title "1")) blocks))) (defn- build-blocks [tree] @@ -416,21 +416,21 @@ " (transact-tree! tree) (db/transact! test-db [{:block/uuid 22 - :block/content ""}]) + :block/title ""}]) (let [target-block (get-block 22)] (outliner-tx/transact! (transact-opts) (outliner-core/insert-blocks! test-db (db/get-db test-db false) - [{:block/content "test" + [{:block/title "test" :block/parent 1 :block/page 1}] target-block {:sibling? false :outliner-op :paste :replace-empty-target? true})) - (is (= "test" (:block/content (get-block 22)))) + (is (= "test" (:block/title (get-block 22)))) (is (= [22] (get-children 1))) (is (= [2 12 16] (get-children 22)))))) @@ -555,10 +555,10 @@ tags:: tag1, tag2 pages (set (map first (d/q '[:find ?bn :where [?b :block/name ?bn]] @conn))) _ (assert (set/subset? #{"blarg" "bar"} pages) "Pages from block exist") block-with-refs (ffirst (d/q '[:find (pull ?b [* {:block/refs [*]}]) - :where [?b :block/content "block #blarg #bar"]] + :where [?b :block/title "block #blarg #bar"]] @conn)) _ (save-block! (-> block-with-refs - (assoc :block/content "block" + (assoc :block/title "block" :block/refs []))) updated-pages (set (map first (d/q '[:find ?bn :where [?b :block/name ?bn]] @conn)))] (is (not (contains? updated-pages "blarg")) diff --git a/src/test/frontend/test/generators.cljs b/src/test/frontend/test/generators.cljs index e891f1398e..f6a19990bc 100644 --- a/src/test/frontend/test/generators.cljs +++ b/src/test/frontend/test/generators.cljs @@ -58,7 +58,7 @@ (let [block-uuid (random-uuid)] [:insert-blocks [[{:block/uuid block-uuid - :block/content content + :block/title content :block/format :markdown}] (:db/id (d/entity db [:block/uuid target-block-uuid])) opts]])))) diff --git a/src/test/frontend/test/helper.cljs b/src/test/frontend/test/helper.cljs index f3d9dafc42..7dd63c907b 100644 --- a/src/test/frontend/test/helper.cljs +++ b/src/test/frontend/test/helper.cljs @@ -99,27 +99,27 @@ (->> (string/split content* #"\n-\s*") (mapv (fn [s] (let [[content & props] (string/split-lines s)] - (cond-> {:block/content content} + (cond-> {:block/title content} ;; If no property chars may accidentally parse child blocks ;; so don't do property parsing (and (string/includes? s ":: ") props) (merge (property-lines->attributes props))))))) ;; only has a page pre-block - [{:block/content content*}]) + [{:block/title content*}]) [page-attrs blocks*] - (if (string/includes? (:block/content (first blocks**)) "::") - [(property-lines->attributes (string/split-lines (:block/content (first blocks**)))) + (if (string/includes? (:block/title (first blocks**)) "::") + [(property-lines->attributes (string/split-lines (:block/title (first blocks**)))) (rest blocks**)] [nil blocks**]) blocks - (mapv #(if-let [status (some-> (second (re-find status/bare-marker-pattern (:block/content %))) + (mapv #(if-let [status (some-> (second (re-find status/bare-marker-pattern (:block/title %))) file-to-db-statuses)] (-> % (assoc :block/tags [{:db/ident :logseq.class/task}]) (update :build/properties merge {:logseq.task/status status})) %) blocks*)] - {:blocks (mapv (fn [b] (update b :block/content #(string/replace-first % #"^-\s*" ""))) + {:blocks (mapv (fn [b] (update b :block/title #(string/replace-first % #"^-\s*" ""))) blocks) :page-attributes page-attrs})) @@ -189,14 +189,14 @@ 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/content "block 1" + :block/title "block 1" :block/format :markdown} ;; second block {:block/uuid second-block-uuid :block/page page-id :block/parent page-id :block/order (db-order/gen-key nil) - :block/content "block 2" + :block/title "block 2" :block/format :markdown}] (map sqlite-util/block-with-timestamps)))) diff --git a/src/test/frontend/worker/handler/page/file_based/rename_test.cljs b/src/test/frontend/worker/handler/page/file_based/rename_test.cljs index a36be9f311..7ec7e1763d 100644 --- a/src/test/frontend/worker/handler/page/file_based/rename_test.cljs +++ b/src/test/frontend/worker/handler/page/file_based/rename_test.cljs @@ -73,7 +73,7 @@ ;; Blocks from both pages have been merged (is (= (count (:block/_page e2)) (+ 1 (dec (count init-data))))) ;; Content updated - (is (= "Block 1 [[Existing page]]" (:block/content (db/entity [:block/uuid fbid]))))))) + (is (= "Block 1 [[Existing page]]" (:block/title (db/entity [:block/uuid fbid]))))))) (defn- replace-page-ref! [content old-name new-name] diff --git a/src/test/frontend/worker/rtc/local_tx_to_remote_test.cljs b/src/test/frontend/worker/rtc/local_tx_to_remote_test.cljs index 8e7a07b2f0..c6c7009d10 100644 --- a/src/test/frontend/worker/rtc/local_tx_to_remote_test.cljs +++ b/src/test/frontend/worker/rtc/local_tx_to_remote_test.cljs @@ -58,9 +58,9 @@ repo conn [{:block/uuid uuid1 - :block/content "uuid1-client" + :block/title "uuid1-client" :block/parent [:block/uuid page1-uuid]} - {:block/uuid uuid2 :block/content "uuid2-client" + {:block/uuid uuid2 :block/title "uuid2-client" :block/parent [:block/uuid page1-uuid]}] (ldb/get-page @conn page1-name) {:sibling? true :keep-uuid? true})) diff --git a/src/test/frontend/worker/rtc/op_mem_layer_test.cljs b/src/test/frontend/worker/rtc/op_mem_layer_test.cljs index d671b63a0b..20285e3d21 100644 --- a/src/test/frontend/worker/rtc/op_mem_layer_test.cljs +++ b/src/test/frontend/worker/rtc/op_mem_layer_test.cljs @@ -20,7 +20,7 @@ :av-coll [[:block/updated-at "[\"~#'\",1715327859860]" 1 true] [:block/created-at "[\"~#'\",1715327859860]" 1 true] - [:block/content "[\"~#'\",\"\"]" 1 true]]}]]] + [:block/title "[\"~#'\",\"\"]" 1 true]]}]]] (op-layer/add-ops! repo ops) (is (= {:move [:move @@ -33,7 +33,7 @@ :av-coll [[:block/updated-at "[\"~#'\",1715327859860]" 1 true] [:block/created-at "[\"~#'\",1715327859860]" 1 true] - [:block/content "[\"~#'\",\"\"]" 1 true]]}]} + [:block/title "[\"~#'\",\"\"]" 1 true]]}]} (op-layer/get-block-ops repo block-uuid))))) (testing "more updates on this block" @@ -43,8 +43,8 @@ :av-coll [[:block/updated-at "[\"~#'\",1715327859860]" 2 false] [:block/updated-at "[\"~#'\",1715329245395]" 2 true] - [:block/content "[\"~#'\",\"\"]" 2 false] - [:block/content "[\"~#'\",\"iii\"]" 2 true]]}] + [:block/title "[\"~#'\",\"\"]" 2 false] + [:block/title "[\"~#'\",\"iii\"]" 2 true]]}] [:update 3 {:block-uuid block-uuid, @@ -63,11 +63,11 @@ :av-coll [[:block/updated-at "[\"~#'\",1715327859860]" 1 true] [:block/created-at "[\"~#'\",1715327859860]" 1 true] - [:block/content "[\"~#'\",\"\"]" 1 true] + [:block/title "[\"~#'\",\"\"]" 1 true] [:block/updated-at "[\"~#'\",1715327859860]" 2 false] [:block/updated-at "[\"~#'\",1715329245395]" 2 true] - [:block/content "[\"~#'\",\"\"]" 2 false] - [:block/content "[\"~#'\",\"iii\"]" 2 true] + [:block/title "[\"~#'\",\"\"]" 2 false] + [:block/title "[\"~#'\",\"iii\"]" 2 true] [:block/tags #uuid "663dd8e0-8840-4411-ab6f-2632ac36bf11" 3 true]]}]} (op-layer/get-block-ops repo block-uuid))) (is (= [1 block-uuid] diff --git a/src/test/frontend/worker/rtc/remote_update_test.cljs b/src/test/frontend/worker/rtc/remote_update_test.cljs index 096d262ed4..7f83caf91e 100644 --- a/src/test/frontend/worker/rtc/remote_update_test.cljs +++ b/src/test/frontend/worker/rtc/remote_update_test.cljs @@ -8,11 +8,11 @@ (deftest remote-op-value->tx-data-test (let [[block-uuid ref-uuid1 ref-uuid2] (repeatedly random-uuid) db (d/empty-db db-schema/schema-for-db-based-graph)] - (testing ":block/content" + (testing ":block/title" (let [db (d/db-with db [{:block/uuid block-uuid - :block/content "local-content"}]) - op-value {:block/content (ldb/write-transit-str "remote-content")}] - (is (= [[:db/add (:db/id (d/entity db [:block/uuid block-uuid])) :block/content "remote-content"]] + :block/title "local-content"}]) + op-value {:block/title (ldb/write-transit-str "remote-content")}] + (is (= [[:db/add (:db/id (d/entity db [:block/uuid block-uuid])) :block/title "remote-content"]] (#'subject/remote-op-value->tx-data db (d/entity db [:block/uuid block-uuid]) op-value))))) (testing ":block/tags (1)" diff --git a/src/test/frontend/worker/rtc/rtc_fns_test.cljs b/src/test/frontend/worker/rtc/rtc_fns_test.cljs index 77aa09e6e8..e448e8a6cf 100644 --- a/src/test/frontend/worker/rtc/rtc_fns_test.cljs +++ b/src/test/frontend/worker/rtc/rtc_fns_test.cljs @@ -28,17 +28,17 @@ :self uuid1 :parents [uuid2] :block/order "a0" - :block/content "content-str"}} + :block/title "content-str"}} unpushed-ops [[:update 1 {:block-uuid uuid1 - :av-coll [[:block/content "new-content-str" 1 true]]}]] + :av-coll [[:block/title "new-content-str" 1 true]]}]] r (#'r.remote/update-remote-data-by-local-unpushed-ops affected-blocks-map unpushed-ops)] (is (= {uuid1 {:op :move :self uuid1 :parents [uuid2] :block/order "a0" - :block/content "new-content-str"}} + :block/title "new-content-str"}} r)))) (testing "case2" (let [[uuid1] (repeatedly (comp str random-uuid)) @@ -72,14 +72,14 @@ :self uuid1 :parents [uuid2] :block/order "a0" - :block/content "update content"}} + :block/title "update content"}} unpushed-ops [[:move 1 {:block-uuid uuid1}]] r (#'r.remote/update-remote-data-by-local-unpushed-ops affected-blocks-map unpushed-ops)] (is (= {uuid1 {:op :update-attrs :self uuid1 - :block/content "update content"}} + :block/title "update content"}} r))))) (deftest gen-remote-ops-test @@ -95,10 +95,10 @@ (outliner-core/insert-blocks! repo conn - [{:block/uuid uuid2 :block/content "uuid2-block"} - {:block/uuid uuid3 :block/content "uuid3-block" + [{:block/uuid uuid2 :block/title "uuid2-block"} + {:block/uuid uuid3 :block/title "uuid3-block" :block/parent [:block/uuid uuid1]} - {:block/uuid uuid4 :block/content "uuid4-block" + {:block/uuid uuid4 :block/title "uuid4-block" :block/parent [:block/uuid uuid1]}] (ldb/get-page @conn "gen-remote-ops-test") {:sibling? true :keep-uuid? true})) @@ -108,7 +108,7 @@ [:move 2 {:block-uuid uuid4}] [:move 3 {:block-uuid uuid3}] [:update 4 {:block-uuid uuid4 - :av-coll [[:block/content (ldb/write-transit-str "uuid4-block") 4 true]]}]]) + :av-coll [[:block/title (ldb/write-transit-str "uuid4-block") 4 true]]}]]) (let [_ (op-mem-layer/new-branch! repo) r1 (#'r.client/gen-block-uuid->remote-ops repo conn :n 1) _ (op-mem-layer/rollback! repo) @@ -138,10 +138,10 @@ (outliner-core/insert-blocks! repo conn - [{:block/uuid uuid1-client :block/content "uuid1-client" + [{:block/uuid uuid1-client :block/title "uuid1-client" :block/left [:block/uuid page-uuid] :block/parent [:block/uuid page-uuid]} - {:block/uuid uuid2-client :block/content "uuid2-client" + {:block/uuid uuid2-client :block/title "uuid2-client" :block/left [:block/uuid uuid1-client] :block/parent [:block/uuid page-uuid]}] (ldb/get-page @conn page-name) @@ -210,10 +210,10 @@ ;; (outliner-core/insert-blocks! ;; repo ;; conn -;; [{:block/uuid uuid1-client :block/content "uuid1-client" +;; [{:block/uuid uuid1-client :block/title "uuid1-client" ;; :block/left [:block/uuid page-uuid] ;; :block/parent [:block/uuid page-uuid]} -;; {:block/uuid uuid2-client :block/content "uuid2-client" +;; {:block/uuid uuid2-client :block/title "uuid2-client" ;; :block/left [:block/uuid uuid1-client] ;; :block/parent [:block/uuid page-uuid]}] ;; (ldb/get-page @conn page-name) @@ -316,10 +316,10 @@ (outliner-core/insert-blocks! repo conn - [{:block/uuid uuid1-client :block/content "uuid1-client" + [{:block/uuid uuid1-client :block/title "uuid1-client" :block/left [:block/uuid page-uuid] :block/parent [:block/uuid page-uuid]} - {:block/uuid uuid2-client :block/content "uuid2-client" + {:block/uuid uuid2-client :block/title "uuid2-client" :block/left [:block/uuid uuid1-client] :block/parent [:block/uuid page-uuid]}] (ldb/get-page @conn page-name) @@ -383,13 +383,13 @@ result: ;; - 2 ;; - 3 repo conn - [{:block/uuid uuid1 :block/content "1" + [{:block/uuid uuid1 :block/title "1" :block/order "a0" :block/parent [:block/uuid page-uuid]} - {:block/uuid uuid2 :block/content "2" + {:block/uuid uuid2 :block/title "2" :block/order "a1" :block/parent [:block/uuid page-uuid]} - {:block/uuid uuid3 :block/content "3" + {:block/uuid uuid3 :block/title "3" :block/order "a0" :block/parent [:block/uuid uuid2]}] (ldb/get-page @conn page-name) @@ -473,11 +473,11 @@ result: repo conn [{:block/uuid uuid1-client - :block/content "uuid1-client" + :block/title "uuid1-client" :block/left [:block/uuid page1-uuid] :block/parent [:block/uuid page1-uuid]} {:block/uuid uuid2-client - :block/content "uuid2-client" + :block/title "uuid2-client" :block/left [:block/uuid uuid1-client] :block/parent [:block/uuid page1-uuid]}] (ldb/get-page @conn page-name) @@ -492,12 +492,12 @@ result: :self uuid1-remote :parents [page2-uuid] :left page2-uuid - :block/content "uuid1-remote"} + :block/title "uuid1-remote"} uuid2-remote {:op :move :self uuid2-remote :parents [page2-uuid] :left uuid1-remote - :block/content "uuid2-remote"}}} + :block/title "uuid2-remote"}}} all-ops (#'r.remote/affected-blocks->diff-type-ops repo (:affected-blocks data-from-ws)) update-page-ops (vals (:update-page-ops-map all-ops)) move-ops (#'r.remote/move-ops-map->sorted-move-ops (:move-ops-map all-ops))] diff --git a/src/test/frontend/worker/undo_redo_test.cljs b/src/test/frontend/worker/undo_redo_test.cljs index 76678b5afb..d086bdf005 100644 --- a/src/test/frontend/worker/undo_redo_test.cljs +++ b/src/test/frontend/worker/undo_redo_test.cljs @@ -73,7 +73,7 @@ {:block/uuid block-uuid :block/left left :block/parent parent - :block/content content}}])) + :block/title content}}])) (defn- gen-update-block-op [db] diff --git a/src/test/logseq/api_test.cljs b/src/test/logseq/api_test.cljs index 3ce60f9ae2..ab89a8b6ad 100644 --- a/src/test/logseq/api_test.cljs +++ b/src/test/logseq/api_test.cljs @@ -14,18 +14,18 @@ (db/transact! test-helper/test-db [{:db/id 10000 :block/uuid #uuid "4406f839-6410-43b5-87db-25e9b8f54cc0" - :block/content "1"} + :block/title "1"} {:db/id 10001 :block/uuid #uuid "d9b7b45f-267f-4794-9569-f43d1ce77172" - :block/content "2"} + :block/title "2"} {:db/id 10002 :block/uuid #uuid "adae3006-f03e-4814-a1f5-f17f15b86556" :block/parent 10001 - :block/content "3"} + :block/title "3"} {:db/id 10003 :block/uuid #uuid "0c3053c3-2dab-4769-badd-14ce16d8ba8d" :block/parent 10002 - :block/content "4"}]) + :block/title "4"}]) (is (= (:content (bean/->clj (api-block/get_block 10000 #js {}))) "1")) (is (= (:content (bean/->clj (api-block/get_block "d9b7b45f-267f-4794-9569-f43d1ce77172" #js {}))) "2"))