Skip to content

Commit

Permalink
chore: add some docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
Weihua Lu committed Sep 2, 2021
1 parent 29a3025 commit 0131229
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/main/frontend/handler/command_palette.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,22 @@
(reverse)
(take limit)))

(defn register [{:keys [id] :as command}]
(defn register
"Register a global command searchable by command palette.
`id` is defined as a global unique namespaced key :scope/command-name
`action` must be a zero arity function
Example:
```clojure
(register
{:id :document/open-logseq-doc
:desc \"Document: open Logseq documents\"
:action (fn [] (js/window.open \"https://logseq.github.io/\"))})
```
To add i18n support, prefix `id` with command and put that item in dict.
Example: {:zh-CN {:command.document/open-logseq-doc \"打开文档\"}}"
[{:keys [id] :as command}]
(spec/validate :command/command command)
(let [cmds (get-commands)]
(if (some (fn [existing-cmd] (= (:id existing-cmd) id)) cmds)
Expand Down

0 comments on commit 0131229

Please sign in to comment.