fix: exclude whiteboard properties for auto complete

pull/6560/head
Peng Xiao 2022-08-31 10:17:19 +08:00
parent b0b46ccc8d
commit 89c6f17283
4 changed files with 27 additions and 14 deletions

View File

@ -20,6 +20,14 @@
(vector? block)
(= "Heading" (first block))))
(defn whiteboard-properties?
[properties]
(and properties
(or (#{:whiteboard-shape :whiteboard-page} (:ls-type properties))
;; whiteboard page will have the following properties. We use them as a hint
(and (:assets properties)
(:bindings properties)))))
(defn get-tag
[block]
(when-let [tag-value (and (vector? block)

View File

@ -212,7 +212,7 @@
(defn with-whiteboard-block-props
[block page-name]
(let [shape (:block/properties block)
shape? (= :whiteboard-shape (:ls-type shape))
shape? (gp-block/whiteboard-properties? shape)
default-page-ref {:block/name (gp-util/page-name-sanity-lc page-name)}]
(merge (when shape?
(merge

View File

@ -17,6 +17,7 @@
[logseq.db.default :as default-db]
[logseq.db.rules :refer [rules]]
[logseq.db.schema :as db-schema]
[logseq.graph-parser.block :as gp-block]
[logseq.graph-parser.config :as gp-config]
[logseq.graph-parser.text :as text]
[logseq.graph-parser.util :as gp-util]))
@ -1354,7 +1355,8 @@
:where
[_ :block/properties ?p]]
(conn/get-db))
properties (remove (fn [m] (empty? m)) properties)]
properties (remove (fn [m] (or (empty? m)
(gp-block/whiteboard-properties? m))) properties)]
(->> (map keys properties)
(apply concat)
distinct
@ -1654,8 +1656,7 @@
(defn whiteboard-shape?
[block]
(= :whiteboard-shape
(get-in block [:block/properties :ls-type] nil)))
(gp-block/whiteboard-properties? (:properties block)))
;; ;; fixme: caching?
;; (defn get-all-whiteboard-tldrs

View File

@ -7,6 +7,7 @@
[frontend.modules.outliner.file :as outliner-file]
[frontend.state :as state]
[frontend.util :as util]
[logseq.graph-parser.block :as gp-block]
[logseq.graph-parser.extract :as gp-extract]))
;; (defn set-linked-page-or-block!
@ -59,7 +60,9 @@
page-entity (model/get-page page-name)
page-block (merge {:block/name page-name
:block/whiteboard? true
:block/properties (dissoc tldr-data :shapes)}
:block/properties (-> tldr-data
(dissoc :shapes)
(assoc :ls-type :whiteboard-page))}
(when page-entity (select-keys page-entity [:block/created-at])))
page-block (outliner/block-with-timestamps page-block)
;; todo: use get-paginated-blocks instead?
@ -99,7 +102,7 @@
(let [id (str (:block/uuid page-block))
shapes (->> blocks
(map block->shape)
(filter #(= :whiteboard-shape (:ls-type %)))
(filter gp-block/whiteboard-properties?)
(sort-by :index))
page-properties (:block/properties page-block)
assets (:assets page-properties)
@ -120,14 +123,15 @@
(defn get-default-tldr
[page-id]
#js {:currentPageId page-id,
:selectedIds #js [],
:pages #js [#js {:id page-id,
:name "Page",
:shapes #js [],
:bindings #js {},
:nonce 1}],
:assets #js []})
{:currentPageId page-id,
:selectedIds [],
:pages [{:id page-id
:name page-id
:ls-type :whiteboard-page
:shapes []
:bindings {}
:nonce 1}]
:assets []})
(defn get-whiteboard-entity [page-name]
(db-utils/entity [:block/name (util/page-name-sanity-lc page-name)]))