Files
logseq/src/main/frontend/components/shell.cljs
Charlie 020317911f Enhance/plugin APIs (#7555)
* feat: WIP native cli command support

* Add :shell/command-whitelist option

* Integrate cli to code block

* Add :code-block/command-whitelist option

* fix: size of icon

* improve(shell): cache user shell whitelist on application configures file

* improve(electron): promisify run cli command

* chore(libs): update version

* fix(plugin): incorrect payload of pdf highlights section hook

* improve(plugin): block renderer with specific block uuid

* improve(plugin): expose logger for user lib

* improve(plugin): block hooks type

* improve(plugin): block slot hook with specific block

* improve(plugin): auto generate key for provide UI options

* improve(plugin): style of injected ui container

* improve(plugin): types

* improve(plugin): async messaging api from host to plugin

* improve(plugin): add types

* improve(apis): get external plugin metadata

* improve(apis): invoke external plugin impls

* improve(apis): call external plugin impls for simple commands

* enhance(apis): datascript query api for predicate inputs

* enhance(apis): datascript query api for predicate inputs

* fix(apis): redundant args of datascript query api

* enhance(plugins): position of float ui container

* enhance(plugins): style of setting options

* enhance(plugins): layouts data for float ui

* chore(plugins): update CHANGELOG.md

* improve(apis): add types

* chore: fix some inclusive terms

* improve(apis): types

* chore(plugins): update CHANGELOG.md

* chore(plugins): build libs

* chore: update CHANGELOG.md

* chore: remove experiemental alda integration

* fix(lint): remove unused methods

Co-authored-by: Tienson Qin <tiensonqin@gmail.com>
Co-authored-by: Andelf <andelf@gmail.com>
2022-12-19 20:23:25 +08:00

47 lines
1.4 KiB
Clojure

(ns frontend.components.shell
(:require [rum.core :as rum]
[frontend.ui :as ui]
[frontend.util :as util]
[frontend.handler.shell :as shell-handler]
[clojure.string :as string]
[frontend.mixins :as mixins]
[promesa.core :as p]))
(defonce *command (atom ""))
(defonce *loading? (atom nil))
(defn- run-command
[]
(reset! *loading? true)
(->
(p/let [_ (when-not (string/blank? @*command)
(shell-handler/run-command! @*command))]
(reset! *loading? false))
(p/finally (fn [] (reset! *loading? false)))))
(rum/defcs shell < rum/reactive
(mixins/event-mixin
(fn [state]
(mixins/on-enter state
:on-enter (fn [_state] (run-command)))))
[state]
(let [loading? (rum/react *loading?)]
[:div.flex.flex-col
[:div
[:div
[:div
[:h1.title
"Input command"]
[:div.mt-4.mb-4.relative.rounded-md.shadow-sm
[:input#run-command.form-input.font-mono.block.w-full.sm:text-sm.sm:leading-5
{:autoFocus true
:on-key-down util/stop-propagation
:placeholder "git commit -m ..."
:on-change (fn [e]
(reset! *command (util/evalue e)))}]]]]
[:div.flex.flex-row.items-center
(ui/button "Run" :on-click run-command)
[:div.ml-4
(when loading?
(ui/loading ""))]]]]))