mirror of
https://github.com/logseq/logseq.git
synced 2026-05-03 02:16:30 +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:
@@ -33,7 +33,7 @@
|
||||
:notification/show? false
|
||||
:notification/content nil
|
||||
:repo/cloning? false
|
||||
;; :repo/loading-files? is only for github repos
|
||||
;; :repo/loading-files? is only for GitHub repos
|
||||
:repo/loading-files? {}
|
||||
:repo/changed-files nil
|
||||
:nfs/user-granted? {}
|
||||
@@ -160,8 +160,10 @@
|
||||
:plugin/indicator-text nil
|
||||
:plugin/installed-plugins {}
|
||||
:plugin/installed-themes []
|
||||
:plugin/installed-commands {}
|
||||
:plugin/installed-slash-commands {}
|
||||
:plugin/installed-ui-items {}
|
||||
:plugin/installed-resources {}
|
||||
:plugin/installed-hooks {}
|
||||
:plugin/simple-commands {}
|
||||
:plugin/selected-theme nil
|
||||
:plugin/selected-unpacked-pkg nil
|
||||
@@ -1294,7 +1296,7 @@
|
||||
|
||||
(defn get-plugins-commands
|
||||
[]
|
||||
(mapcat seq (flatten (vals (:plugin/installed-commands @state)))))
|
||||
(mapcat seq (flatten (vals (:plugin/installed-slash-commands @state)))))
|
||||
|
||||
(defn get-plugins-commands-with-type
|
||||
[type]
|
||||
@@ -1306,6 +1308,43 @@
|
||||
(filterv #(= (keyword (first %)) (keyword type))
|
||||
(apply concat (vals (:plugin/installed-ui-items @state)))))
|
||||
|
||||
(defn get-plugin-resources-with-type
|
||||
[pid type]
|
||||
(when-let [pid (and type (keyword pid))]
|
||||
(get-in @state [:plugin/installed-resources pid (keyword type)])))
|
||||
|
||||
(defn get-plugin-resource
|
||||
[pid type key]
|
||||
(when-let [resources (get-plugin-resources-with-type pid type)]
|
||||
(get resources key)))
|
||||
|
||||
(defn upt-plugin-resource
|
||||
[pid type key attr val]
|
||||
(when-let [resource (get-plugin-resource pid type key)]
|
||||
(let [resource (assoc resource (keyword attr) val)]
|
||||
(set-state!
|
||||
[:plugin/installed-resources (keyword pid) (keyword type) key] resource)
|
||||
resource)))
|
||||
|
||||
(defn install-plugin-hook
|
||||
[pid hook]
|
||||
(when-let [pid (keyword pid)]
|
||||
(set-state!
|
||||
[:plugin/installed-hooks hook]
|
||||
(conj
|
||||
((fnil identity #{}) (get-in @state [:plugin/installed-hooks hook]))
|
||||
pid)) true))
|
||||
|
||||
(defn uninstall-plugin-hook
|
||||
[pid hook-or-all]
|
||||
(when-let [pid (keyword pid)]
|
||||
(if (nil? hook-or-all)
|
||||
(swap! state update :plugin/installed-hooks #(medley/map-vals (fn [ids] (disj ids pid)) %))
|
||||
(when-let [coll (get-in @state [:plugin/installed-hooks hook-or-all])]
|
||||
(set-state! [:plugin/installed-hooks hook-or-all] (disj coll pid))))
|
||||
true))
|
||||
|
||||
|
||||
(defn get-scheduled-future-days
|
||||
[]
|
||||
(let [days (:scheduled/future-days (get-config))]
|
||||
@@ -1594,6 +1633,9 @@
|
||||
[]
|
||||
(:plugin/enabled @state))
|
||||
|
||||
(def lsp-enabled?
|
||||
(lsp-enabled?-or-theme))
|
||||
|
||||
(defn consume-updates-coming-plugin
|
||||
[payload updated?]
|
||||
(when-let [id (keyword (:id payload))]
|
||||
|
||||
Reference in New Issue
Block a user