mirror of
https://github.com/logseq/logseq.git
synced 2026-05-04 19:06:21 +00:00
Enhance/more ns plugin api (#4828)
* improve(plugin): WIP add settings schema * improve(plugin): add identity for settings modal * improve(plugin): WIP add settings input * fix(ui): scrollbar overlay of modal panel content * improve(plugin): WIP add more render types of setting item * improve(plugin): WIP polish settings items * improve(plugin): WIP settings list of plugins * improve(plugin): more settings types & polish releated ui * fix(plugin): sometimes disable plugin not work * improve(plugin): polish ui of plugin settings * fix(dev): warning of lint * improve(plugin): add api of settings changed * chore: build libs core * fix(ui): width of settings panel wrap * improve(plugin): separate layouts data from settings aio file * imporve(plugin): container size of single plugin settings * fix: add missing state * improve(plugin): add Git ns * improve(plugin): git related api * improve(api): type of git result * chore: build libs core * fix(dev): kondo lint * fix(plugin): use cdn sdk when js entry * chore: build libs core * fix(plugin): env condition * improve(plugin): add UI ns * fix(api): arguments of datascript query * enhance(api): manageable message instance of UI tools * enhance(api): WIP add experiments api * enhance(api): WIP add resources state of plugin * improve(plugin): add status of loading script resources * improve(plugin): more opts for script loader * improve(plugin): WIP add fenced code renderer hook * improve(plugin): fenced code renderer hook * fix(plugin): resource root path of plugin fs location * imporve(plugin): support local files for loading scripts * improve(plugin): types of expirements api * fix: typo of class * enhance(api): add namespace related apis * enhance(api): add linked refrences related apis * enhance(plugin): add sample links to related api comments * improve(plugin): add db changed hook & optimize strategy of caller for hooks * improve(plugin): compatible commands registration for old sdk * improve(plugin): collect user sdk version for plugin local * improve(plugin): add internal callable apis for user sdk * chore(plugin): missing files & bump libs version * improve(plugin): compatiable for old sdk about hook messaging optimization * improve(plugin): db hook optimization for old sdk * enhance(ux): auto focus searchbar when open plugins list * improve(plugin): api of a hook from specific block changed event * improve(plugin): api of db block change hook * improve(plugin): add show bracket user config of api * improve(plugin): api of db block change hook * fix(api): toggle collapsed of block * improve(api): try to init grpah with git before exec git commands * improve(plugin): attributes of sandbox container * improve(dev): support register command with keybinding * improve(plugin): add api of register shortcut command * fix(plugin): reubild slash commands when new command registration * fix(dev): lint * improve(dev): lint script of libs codebase * chore(dev): remove useless codes * improve(plugin):sanitize path string of plugin repo value * fix(plugin): rebuild commands list when unregister a plugin * fix(ui): overflow width of query result table * chore: rebuild libs core * improve(plugin): add assets related apis * chore: rebuild libs core * improve(plugin): support replace state of into block in page api * improve(plugin): prepend/append child block in page * improve(plugin): polished exceptions message of plugin update/install * fix(plugin): update settings within gui * improve(ux): debounce change event of input for plugin settings gui * chore: rebuild libs core * enhance(plugin): catch exception of hook plugin
This commit is contained in:
@@ -13,7 +13,6 @@
|
||||
[frontend.components.plugins-settings :as plugins-settings]
|
||||
[frontend.handler.notification :as notification]
|
||||
[frontend.handler.plugin :as plugin-handler]
|
||||
[frontend.handler.page :as page-handler]
|
||||
[clojure.string :as string]))
|
||||
|
||||
(rum/defcs installed-themes
|
||||
@@ -234,8 +233,7 @@
|
||||
|
||||
(ui/toggle (not disabled?)
|
||||
(fn []
|
||||
(js-invoke js/LSPluginCore (if disabled? "enable" "disable") id)
|
||||
(page-handler/init-commands!))
|
||||
(js-invoke js/LSPluginCore (if disabled? "enable" "disable") id))
|
||||
true)]])
|
||||
|
||||
(rum/defc plugin-item-card < rum/static
|
||||
@@ -316,10 +314,12 @@
|
||||
[:input.form-input.is-small
|
||||
{:placeholder "Search plugins"
|
||||
:ref *search-ref
|
||||
:auto-focus true
|
||||
:on-key-down (fn [^js e]
|
||||
(when (= 27 (.-keyCode e))
|
||||
(when-not (string/blank? search-key)
|
||||
(util/stop e)
|
||||
(util/stop e)
|
||||
(if (string/blank? search-key)
|
||||
(some-> (js/document.querySelector ".cp__plugins-page") (.focus))
|
||||
(reset! *search-key nil))))
|
||||
:on-change #(let [^js target (.-target %)]
|
||||
(reset! *search-key (util/trim-safe (.-value target))))
|
||||
@@ -726,10 +726,7 @@
|
||||
[:span])))
|
||||
|
||||
(rum/defcs hook-ui-items < rum/reactive
|
||||
"type
|
||||
- :toolbar
|
||||
- :pagebar
|
||||
"
|
||||
"type: :toolbar, :pagebar"
|
||||
[_state type]
|
||||
(when (state/sub [:plugin/installed-ui-items])
|
||||
(let [items (state/get-plugins-ui-items-with-type type)]
|
||||
@@ -739,6 +736,15 @@
|
||||
(for [[_ {:keys [key] :as opts} pid] items]
|
||||
(rum/with-key (ui-item-renderer pid type opts) key))]))))
|
||||
|
||||
(rum/defcs hook-ui-fenced-code < rum/reactive
|
||||
[_state content {:keys [render edit] :as _opts}]
|
||||
|
||||
[:div
|
||||
{:on-mouse-down (fn [e] (when (false? edit) (util/stop e)))
|
||||
:class (util/classnames [{:not-edit (false? edit)}])}
|
||||
(when (fn? render)
|
||||
(js/React.createElement render #js {:content content}))])
|
||||
|
||||
(rum/defc plugins-page
|
||||
[]
|
||||
|
||||
@@ -746,11 +752,6 @@
|
||||
market? (= active :marketplace)
|
||||
*el-ref (rum/create-ref)]
|
||||
|
||||
(rum/use-effect!
|
||||
#(let [^js el (rum/deref *el-ref)]
|
||||
(js/setTimeout (fn [] (.focus el)) 100))
|
||||
[])
|
||||
|
||||
[:div.cp__plugins-page
|
||||
{:ref *el-ref
|
||||
:tab-index "-1"}
|
||||
@@ -775,10 +776,13 @@
|
||||
|
||||
(rum/defcs focused-settings-content
|
||||
< rum/reactive
|
||||
(rum/local (state/sub :plugin/focused-settings) ::cache)
|
||||
[_state title]
|
||||
(let [focused (state/sub :plugin/focused-settings)
|
||||
(let [*cache (::cache _state)
|
||||
focused (state/sub :plugin/focused-settings)
|
||||
nav? (state/sub :plugin/navs-settings?)
|
||||
_ (state/sub :plugin/installed-plugins)]
|
||||
_ (state/sub :plugin/installed-plugins)
|
||||
_ (js/setTimeout #(reset! *cache focused) 100)]
|
||||
|
||||
[:div.cp__plugins-settings.cp__settings-main
|
||||
[:header
|
||||
@@ -802,7 +806,8 @@
|
||||
|
||||
[:article
|
||||
[:div.panel-wrap
|
||||
(when-let [^js pl (and focused (plugin-handler/get-plugin-inst focused))]
|
||||
(when-let [^js pl (and focused (= @*cache focused)
|
||||
(plugin-handler/get-plugin-inst focused))]
|
||||
(ui/catch-error
|
||||
[:p.warning.text-lg.mt-5 "Settings schema Error!"]
|
||||
(plugins-settings/settings-container
|
||||
|
||||
Reference in New Issue
Block a user