mirror of https://github.com/logseq/logseq
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 readablepull/6024/head
parent
33318c395b
commit
7370716215
|
@ -160,8 +160,9 @@
|
|||
properties
|
||||
(remove (fn [[k _]]
|
||||
(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))
|
||||
(keyword k))))
|
||||
(map last)
|
||||
|
@ -222,7 +223,7 @@
|
|||
k (keyword k)
|
||||
v (if (and
|
||||
(string? v)
|
||||
(contains? #{:alias :aliases :tags} k))
|
||||
(contains? gp-property/editable-linkable-built-in-properties k))
|
||||
(set [v])
|
||||
v)
|
||||
v (if (coll? v) (set v) v)]
|
||||
|
|
|
@ -17,15 +17,24 @@
|
|||
#{"now" "later" "todo" "doing" "done" "wait" "waiting"
|
||||
"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 #{}))
|
||||
(defn register-built-in-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
|
||||
"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
|
||||
"Properties used by logseq that user can't edit or see"
|
||||
|
@ -34,7 +43,7 @@
|
|||
#{:id :custom-id :background-color :background_color :heading :collapsed
|
||||
:created-at :updated-at :last-modified-at :created_at :last_modified_at
|
||||
: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))
|
||||
@built-in-extended-properties))
|
||||
|
||||
|
|
|
@ -4,10 +4,16 @@
|
|||
|
||||
(deftest test-extract-properties
|
||||
(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"}
|
||||
[["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"] ["tags" "name/with space"]] {:year 1000, :tags #{"name/with space"}}
|
||||
[["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, [[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"
|
||||
(are [x y] (= (vec (:page-refs
|
||||
|
@ -53,9 +58,15 @@
|
|||
|
||||
(is (= ["year"]
|
||||
(: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")))
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
(deftest ^:integration parse-graph
|
||||
(let [graph-dir "test/docs"
|
||||
_ (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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue