fix: disallow # in page name

Because it creates ambiguity in some cases:
1. With cmd-k we can’t tell the difference between an Apple page
tagged with Fruit and a page named "Apple #Fruit"
2. What should we do with [[Apple #Fruit king]]?
3. Is `#` for Markdown heading or part of a page name?

Fixes https://github.com/logseq/db-test/issues/100
Fixes https://github.com/logseq/db-test/issues/106
Fixes https://github.com/logseq/db-test/issues/105
This commit is contained in:
Tienson Qin
2024-09-19 02:50:47 +08:00
parent 55ce311173
commit c3f0cc1953
8 changed files with 110 additions and 93 deletions

View File

@@ -2845,6 +2845,11 @@
(state/set-state! :editor/start-pos pos))
(cond
(and (= :page-search (state/get-editor-action))
(= key commands/hashtag))
(do
(util/stop e)
(notification/show! "Page name can't include \"#\"." :warning))
;; stop accepting edits if the new block is not created yet
(some? @(:editor/async-unsaved-chars @state/state))
(do
@@ -3727,12 +3732,14 @@
([]
(escape-editing true))
([select?]
(p/do!
(save-current-block!)
(if select?
(when-let [node (some-> (state/get-input) (util/rec-get-node "ls-block"))]
(state/exit-editing-and-set-selected-blocks! [node]))
(state/clear-edit!)))))
(let [edit-block (state/get-edit-block)]
(p/do!
(save-current-block!)
(if select?
(when-let [node (some-> (state/get-input) (util/rec-get-node "ls-block"))]
(state/exit-editing-and-set-selected-blocks! [node]))
(when (= (:db/id edit-block) (:db/id (state/get-edit-block)))
(state/clear-edit!)))))))
(defn replace-block-reference-with-content-at-point
[]