fix(editor): new-page auto-completion under non-en environment

Fix #5965
pull/5936/head^2
Andelf 2022-07-08 11:05:26 +08:00
parent 8e2aa8415c
commit d390842a07
1 changed files with 7 additions and 4 deletions

View File

@ -5,6 +5,7 @@
[datascript.core :as d]
[frontend.commands :as commands]
[frontend.config :as config]
[frontend.context.i18n :refer [t]]
[frontend.date :as date]
[frontend.db :as db]
[logseq.db.schema :as db-schema]
@ -716,8 +717,9 @@
(fn [chosen _click?]
(state/clear-editor-action!)
(let [wrapped? (= "[[" (gp-util/safe-subs edit-content (- pos 2) pos))
chosen (if (string/starts-with? chosen "New page: ") ;; FIXME: What if a page named "New page: XXX"?
(subs chosen 10)
prefix (str (t :new-page) ": ")
chosen (if (string/starts-with? chosen prefix) ;; FIXME: What if a page named "New page: XXX"?
(string/replace-first chosen prefix "")
chosen)
chosen (if (and (util/safe-re-find #"\s+" chosen) (not wrapped?))
(util/format "[[%s]]" chosen)
@ -737,8 +739,9 @@
:forward-pos forward-pos})))
(fn [chosen _click?]
(state/clear-editor-action!)
(let [chosen (if (string/starts-with? chosen "New page: ")
(subs chosen 10)
(let [prefix (str (t :new-page) ": ")
chosen (if (string/starts-with? chosen prefix)
(string/replace-first chosen prefix "")
chosen)
page-ref-text (get-page-ref-text chosen)]
(editor-handler/insert-command! id