Răsfoiți Sursa

Move editable linkable built-in props to var

They were also being referred to elsewhere in block.cljs
Also moved filters to editable as that is existing behavior
Also disabled verbosity of cli tests to allow graph-parser tests to be
more readable
Gabriel Horner 3 ani în urmă
părinte
comite
7370716215

+ 4 - 3
deps/graph-parser/src/logseq/graph_parser/block.cljs

@@ -160,8 +160,9 @@
                    properties
                    properties
                    (remove (fn [[k _]]
                    (remove (fn [[k _]]
                              (contains?
                              (contains?
-                              (set/union (disj (gp-property/editable-built-in-properties)
-                                               :alias :aliases :tags)
+                              (set/union (apply disj
+                                           (gp-property/editable-built-in-properties)
+                                           gp-property/editable-linkable-built-in-properties)
                                          (gp-property/hidden-built-in-properties))
                                          (gp-property/hidden-built-in-properties))
                               (keyword k))))
                               (keyword k))))
                    (map last)
                    (map last)
@@ -222,7 +223,7 @@
                                            k (keyword k)
                                            k (keyword k)
                                            v (if (and
                                            v (if (and
                                                   (string? v)
                                                   (string? v)
-                                                  (contains? #{:alias :aliases :tags} k))
+                                                  (contains? gp-property/editable-linkable-built-in-properties k))
                                                (set [v])
                                                (set [v])
                                                v)
                                                v)
                                            v (if (coll? v) (set v) v)]
                                            v (if (coll? v) (set v) v)]

+ 11 - 2
deps/graph-parser/src/logseq/graph_parser/property.cljs

@@ -17,15 +17,24 @@
   #{"now" "later" "todo" "doing" "done" "wait" "waiting"
   #{"now" "later" "todo" "doing" "done" "wait" "waiting"
     "canceled" "cancelled" "started" "in-progress"})
     "canceled" "cancelled" "started" "in-progress"})
 
 
+;; Built-in properties are properties that logseq uses for its features. Most of
+;; these properties are hidden from the user but a few like the editable ones
+;; are visible for the user to edit.
+
 (def built-in-extended-properties (atom #{}))
 (def built-in-extended-properties (atom #{}))
 (defn register-built-in-properties
 (defn register-built-in-properties
   [props]
   [props]
   (reset! built-in-extended-properties (set/union @built-in-extended-properties props)))
   (reset! built-in-extended-properties (set/union @built-in-extended-properties props)))
 
 
+(def editable-linkable-built-in-properties
+  "Properties used by logseq that user can edit and that can have linkable property values"
+  #{:alias :aliases :tags})
+
 (defn editable-built-in-properties
 (defn editable-built-in-properties
   "Properties used by logseq that user can edit"
   "Properties used by logseq that user can edit"
   []
   []
-  #{:title :alias :aliases :tags :icon :template :template-including-parent :public})
+  (into #{:title :icon :template :template-including-parent :public :filters}
+        editable-linkable-built-in-properties))
 
 
 (defn hidden-built-in-properties
 (defn hidden-built-in-properties
   "Properties used by logseq that user can't edit or see"
   "Properties used by logseq that user can't edit or see"
@@ -34,7 +43,7 @@
    #{:id :custom-id :background-color :background_color :heading :collapsed
    #{:id :custom-id :background-color :background_color :heading :collapsed
      :created-at :updated-at :last-modified-at :created_at :last_modified_at
      :created-at :updated-at :last-modified-at :created_at :last_modified_at
      :query-table :query-properties :query-sort-by :query-sort-desc :ls-type
      :query-table :query-properties :query-sort-by :query-sort-desc :ls-type
-     :hl-type :hl-page :hl-stamp :filters :file-path}
+     :hl-type :hl-page :hl-stamp :file-path}
    (set (map keyword markers))
    (set (map keyword markers))
    @built-in-extended-properties))
    @built-in-extended-properties))
 
 

+ 20 - 9
deps/graph-parser/test/logseq/graph_parser/block_test.cljs

@@ -4,10 +4,16 @@
 
 
 (deftest test-extract-properties
 (deftest test-extract-properties
   (are [x y] (= (:properties (gp-block/extract-properties :markdown x {})) y)
   (are [x y] (= (:properties (gp-block/extract-properties :markdown x {})) y)
-       [["year" "1000"]] {:year 1000}
-       [["year" "\"1000\""]] {:year "\"1000\""}
+       ;; Built-in properties
        [["background-color" "#000000"]] {:background-color "#000000"}
        [["background-color" "#000000"]] {:background-color "#000000"}
        [["alias" "name/with space"]] {:alias #{"name/with space"}}
        [["alias" "name/with space"]] {:alias #{"name/with space"}}
+       [["tags" "foo, bar"]] {:tags #{"foo" "bar"}}
+       [["tags" "'bar'"]] {:tags #{"'bar'"}}
+       [["file-path" "file:///home/x, y.pdf"]] {:file-path "file:///home/x, y.pdf"}
+
+       ;; User properties
+       [["year" "1000"]] {:year 1000}
+       [["year" "\"1000\""]] {:year "\"1000\""}
        [["year" "1000"] ["alias" "name/with space"]] {:year 1000, :alias #{"name/with space"}}
        [["year" "1000"] ["alias" "name/with space"]] {:year 1000, :alias #{"name/with space"}}
        [["year" "1000"] ["tags" "name/with space"]] {:year 1000, :tags #{"name/with space"}}
        [["year" "1000"] ["tags" "name/with space"]] {:year 1000, :tags #{"name/with space"}}
        [["year" "1000"] ["tags" "name/with space, another"]] {:year 1000, :tags #{"name/with space" "another"}}
        [["year" "1000"] ["tags" "name/with space, another"]] {:year 1000, :tags #{"name/with space" "another"}}
@@ -21,8 +27,7 @@
        [["foo" "[[bar]], [[nested [[baz]]]]"]] {:foo #{"bar" "nested [[baz]]"}}
        [["foo" "[[bar]], [[nested [[baz]]]]"]] {:foo #{"bar" "nested [[baz]]"}}
        [["foo" "[[bar]], [[nested [[baz]]]]"]] {:foo #{"bar" "nested [[baz]]"}}
        [["foo" "[[bar]], [[nested [[baz]]]]"]] {:foo #{"bar" "nested [[baz]]"}}
        [["foo" "bar, [[baz, test]]"]] {:foo #{"bar" "baz, test"}}
        [["foo" "bar, [[baz, test]]"]] {:foo #{"bar" "baz, test"}}
-       [["foo" "bar, [[baz, test, [[nested]]]]"]] {:foo #{"bar" "baz, test, [[nested]]"}}
-       [["file-path" "file:///home/x, y.pdf"]] {:file-path "file:///home/x, y.pdf"})
+       [["foo" "bar, [[baz, test, [[nested]]]]"]] {:foo #{"bar" "baz, test, [[nested]]"}})
 
 
   (testing "page-refs"
   (testing "page-refs"
     (are [x y] (= (vec (:page-refs
     (are [x y] (= (vec (:page-refs
@@ -53,9 +58,15 @@
 
 
     (is (= ["year"]
     (is (= ["year"]
            (:page-refs
            (:page-refs
-                (gp-block/extract-properties :markdown
-                                             [["year" "1000"]]
-                                             {})))
-        "Default to enabled when :property-pages/enabled? is not in config")))
+            (gp-block/extract-properties :markdown
+                                         [["year" "1000"]]
+                                         {})))
+        "Default to enabled when :property-pages/enabled? is not in config")
 
 
-#_(cljs.test/run-tests)
+    (is (= ["foo" "bar"]
+           (:page-refs
+            (gp-block/extract-properties :markdown
+                                         ;; tags is linkable and background-color is not
+                                         [["tags" "foo, bar"] ["background-color" "#008000"]]
+                                         {:property-pages/enabled? true})))
+        "Only editable linkable built-in properties have page-refs in property values")))

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

@@ -8,7 +8,7 @@
 (deftest ^:integration parse-graph
 (deftest ^:integration parse-graph
   (let [graph-dir "test/docs"
   (let [graph-dir "test/docs"
         _ (docs-graph-helper/clone-docs-repo-if-not-exists graph-dir)
         _ (docs-graph-helper/clone-docs-repo-if-not-exists graph-dir)
-        {:keys [conn files asts]} (gp-cli/parse-graph graph-dir)]
+        {:keys [conn files asts]} (gp-cli/parse-graph graph-dir {:verbose false})]
 
 
     (docs-graph-helper/docs-graph-assertions @conn files)
     (docs-graph-helper/docs-graph-assertions @conn files)