mirror of https://github.com/logseq/logseq
fix: regression of unwanted tag pages are created as you type
Fixes LOG-2820pull/10981/head
parent
a4ef8c6657
commit
1536d9aff5
|
@ -366,7 +366,8 @@
|
|||
m)
|
||||
m (cond->> m'
|
||||
db-based?
|
||||
(db-marker-handle conn))]
|
||||
(db-marker-handle conn))
|
||||
m (if db-based? (dissoc m :block/tags) m)]
|
||||
|
||||
;; Ensure block UUID never changes
|
||||
(when (and db-id block-uuid)
|
||||
|
|
|
@ -142,8 +142,7 @@
|
|||
(empty? matched-pages)
|
||||
(when-not (db/page-exists? q)
|
||||
(if db-tag?
|
||||
(concat [(str (t :new-page) " " q)
|
||||
(str (t :new-class) " " q)]
|
||||
(concat [(str (t :new-class) " " q)]
|
||||
matched-pages)
|
||||
(cons q matched-pages)))
|
||||
|
||||
|
|
|
@ -1300,37 +1300,37 @@
|
|||
(save-current-block! {}))
|
||||
([{:keys [force? skip-properties? current-block] :as opts}]
|
||||
;; non English input method
|
||||
(let [result (when-not (state/editor-in-composition?)
|
||||
(when (state/get-current-repo)
|
||||
(try
|
||||
(let [input-id (state/get-edit-input-id)
|
||||
block (state/get-edit-block)
|
||||
db-block (when-let [block-id (:block/uuid block)]
|
||||
(db/pull [:block/uuid block-id]))
|
||||
elem (and input-id (gdom/getElement input-id))
|
||||
db-content (:block/content 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)
|
||||
(and elem (gobj/get elem "value")))]
|
||||
(when value
|
||||
(cond
|
||||
force?
|
||||
(save-block-aux! db-block value opts)
|
||||
(when-not (or (state/editor-in-composition?)
|
||||
(state/get-editor-action))
|
||||
(when (state/get-current-repo)
|
||||
(try
|
||||
(let [input-id (state/get-edit-input-id)
|
||||
block (state/get-edit-block)
|
||||
db-block (when-let [block-id (:block/uuid block)]
|
||||
(db/pull [:block/uuid block-id]))
|
||||
elem (and input-id (gdom/getElement input-id))
|
||||
db-content (:block/content 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)
|
||||
(and elem (gobj/get elem "value")))]
|
||||
(when value
|
||||
(cond
|
||||
force?
|
||||
(save-block-aux! db-block value opts)
|
||||
|
||||
(and skip-properties?
|
||||
(db-model/top-block? block)
|
||||
(when elem (thingatpt/properties-at-point elem)))
|
||||
nil
|
||||
(and skip-properties?
|
||||
(db-model/top-block? block)
|
||||
(when elem (thingatpt/properties-at-point elem)))
|
||||
nil
|
||||
|
||||
(and block value db-content-without-heading
|
||||
(not= (string/trim db-content-without-heading)
|
||||
(string/trim value)))
|
||||
(save-block-aux! db-block value opts))))
|
||||
(catch :default error
|
||||
(log/error :save-block-failed error)))))]
|
||||
result)))
|
||||
(and block value db-content-without-heading
|
||||
(not= (string/trim db-content-without-heading)
|
||||
(string/trim value)))
|
||||
(save-block-aux! db-block value opts))))
|
||||
(catch :default error
|
||||
(log/error :save-block-failed error)))))))
|
||||
|
||||
(defn- clean-content!
|
||||
[repo format content]
|
||||
|
|
|
@ -218,7 +218,7 @@
|
|||
(fn [chosen e]
|
||||
(util/stop e)
|
||||
(state/clear-editor-action!)
|
||||
(let [class? (string/starts-with? chosen (t :new-class))
|
||||
(let [class? (and db-based? hashtag?)
|
||||
chosen (-> chosen
|
||||
(string/replace-first (str (t :new-class) " ") "")
|
||||
(string/replace-first (str (t :new-page) " ") ""))
|
||||
|
@ -242,11 +242,14 @@
|
|||
_ (when-not tag-entity
|
||||
(<create! tag {:redirect? false
|
||||
:create-first-block? false
|
||||
:class? class?}))]
|
||||
:class? class?}))
|
||||
tag-entity (db/entity [:block/name (util/page-name-sanity-lc tag)])]
|
||||
(when class?
|
||||
(let [repo (state/get-current-repo)
|
||||
tag-entity (or tag-entity (db/entity [:block/name (util/page-name-sanity-lc tag)]))
|
||||
tx-data [[:db/add [:block/uuid (:block/uuid edit-block)] :block/tags (:db/id tag-entity)]
|
||||
tx-data [[:db/add (:db/id tag-entity) :block/type "class"]
|
||||
[:db/add [:block/uuid (:block/uuid edit-block)] :block/tags (:db/id tag-entity)]
|
||||
;; TODO: Should classes counted as refs
|
||||
[:db/add [:block/uuid (:block/uuid edit-block)] :block/refs (:db/id tag-entity)]]]
|
||||
(db/transact! repo tx-data {:outliner-op :save-block})))))))
|
||||
(editor-handler/insert-command! id
|
||||
|
|
Loading…
Reference in New Issue