mirror of https://github.com/logseq/logseq
parent
03ec9580c3
commit
c8b88c9d8f
|
@ -9,7 +9,6 @@
|
|||
[frontend.handler.draw :as draw]
|
||||
[frontend.handler.notification :as notification]
|
||||
[frontend.handler.plugin :as plugin-handler]
|
||||
[frontend.handler.property :as property-handler]
|
||||
[frontend.search :as search]
|
||||
[frontend.state :as state]
|
||||
[frontend.util :as util]
|
||||
|
@ -218,6 +217,7 @@
|
|||
|
||||
(defn commands-map
|
||||
[get-page-ref-text]
|
||||
(let [db? (config/db-based-graph? (state/get-current-repo))]
|
||||
(->>
|
||||
(concat
|
||||
;; basic
|
||||
|
@ -233,8 +233,9 @@
|
|||
["Underline" [[:editor/input "<ins></ins>"
|
||||
{:last-pattern command-trigger
|
||||
:backward-pos 6}]] "Create a underline text decoration"])
|
||||
(when-not db?
|
||||
["Template" [[:editor/input command-trigger nil]
|
||||
[:editor/search-template]] "Insert a created template here"]
|
||||
[:editor/search-template]] "Insert a created template here"])
|
||||
(cond
|
||||
(and (util/electron?) (config/local-file-based-graph? (state/get-current-repo)))
|
||||
|
||||
|
@ -298,8 +299,9 @@
|
|||
|
||||
["Embed Twitter tweet" [[:editor/input "{{tweet }}" {:last-pattern command-trigger
|
||||
:backward-pos 2}]]]
|
||||
(when db?
|
||||
["Add new property" [[:editor/clear-current-slash]
|
||||
[:editor/new-property]]]
|
||||
[:editor/new-property]]])
|
||||
|
||||
["Code block" [[:editor/input "```\n```\n" {:type "block"
|
||||
:backward-pos 5
|
||||
|
@ -312,7 +314,7 @@
|
|||
(state/get-commands)
|
||||
(state/get-plugins-slash-commands))
|
||||
(remove nil?)
|
||||
(util/distinct-by-last-wins first)))
|
||||
(util/distinct-by-last-wins first))))
|
||||
|
||||
(defn init-commands!
|
||||
[get-page-ref-text]
|
||||
|
|
|
@ -174,11 +174,12 @@
|
|||
(rum/defc ^:large-vars/cleanup-todo block-context-menu-content <
|
||||
shortcut/disable-all-shortcuts
|
||||
[_target block-id]
|
||||
(let [repo (state/get-current-repo)
|
||||
db? (config/db-based-graph? repo)]
|
||||
(when-let [block (db/entity [:block/uuid block-id])]
|
||||
(let [properties (:block/properties block)
|
||||
heading (or (pu/lookup properties :heading)
|
||||
false)
|
||||
repo (state/get-current-repo)]
|
||||
false)]
|
||||
[:.menu-links-wrapper
|
||||
(ui/menu-background-color #(property-handler/set-block-property! repo block-id :background-color %)
|
||||
#(property-handler/remove-block-property! repo block-id :background-color))
|
||||
|
@ -243,7 +244,8 @@
|
|||
|
||||
[:hr.menu-separator]
|
||||
|
||||
(block-template block-id)
|
||||
(when-not db?
|
||||
(block-template block-id))
|
||||
|
||||
(cond
|
||||
(srs/card-block? block)
|
||||
|
@ -302,7 +304,7 @@
|
|||
:on-click (fn []
|
||||
(let [block (db/pull [:block/uuid block-id])]
|
||||
(dev-common-handler/show-content-ast (:block/content block) (:block/format block))))}
|
||||
(t :dev/show-block-ast)))])))
|
||||
(t :dev/show-block-ast)))]))))
|
||||
|
||||
(rum/defc block-ref-custom-context-menu-content
|
||||
[block block-ref-id]
|
||||
|
|
|
@ -2053,11 +2053,13 @@
|
|||
([element-id db-id]
|
||||
(insert-template! element-id db-id {}))
|
||||
([element-id db-id {:keys [target] :as opts}]
|
||||
(let [repo (state/get-current-repo)
|
||||
db? (config/db-based-graph? repo)]
|
||||
(when-not db?
|
||||
(when-let [db-id (if (integer? db-id)
|
||||
db-id
|
||||
(:db/id (db-model/get-template-by-name (name db-id))))]
|
||||
(let [journal? (:block/journal? target)
|
||||
repo (state/get-current-repo)
|
||||
target (or target (state/get-edit-block))
|
||||
block (db/entity db-id)
|
||||
format (:block/format block)
|
||||
|
@ -2113,7 +2115,7 @@
|
|||
(notification/show!
|
||||
[:p.content
|
||||
(util/format "Template insert error: %s" (.-message e))]
|
||||
:error))))))))
|
||||
:error))))))))))
|
||||
|
||||
(defn template-on-chosen-handler
|
||||
[element-id]
|
||||
|
|
Loading…
Reference in New Issue