@samitouri / QOSami-HFS / commits / 4562e447

plugins: HFS.emit

Massimo Melina committed Jun 4, 2023 at 11:19 UTC 4562e4479db8485075d22c4738b1d1faa3d88eb7
2 files changed +3 -1
dev-plugins.md
+2 -1
@@ -170,6 +170,7 @@ The HFS objects contains many properties:
170 - `h` shortcut for React.createElement
171 - `t` [translator function](https://github.com/rejetto/hfs/blob/main/frontend/src/i18n.ts)
172 - `_` [lodash library](https://lodash.com/docs/)
173 +- `emit: (name: string, params?: object) => any[]` use this to emit a custom event. Prefix name with your plugin name to avoid conflicts.
174 - `Icon: ReactComponent` Properties:
175 - `name: string` refer to file `icons.ts` for names, but you can also enter an emoji instead.
176
@@ -290,7 +291,7 @@ HFS will scan through them in inverted alphabetical order searching for a compat
291 - 8.21 (v0.46.0)
292 - entry.getNext, getPrevious, getNextFiltered, getPreviousFiltered, getDefaultIcon
293 - platform-dependent distribution
293 - - HFS.watchState
294 + - HFS.watchState, emit
295 - api.storageDir
296 - 8.1 (v0.45.0) should have been 0.44.0 but forgot to update number
297 - full URL support for frontend_js and frontend_css
frontend/src/misc.ts
+1
@@ -68,6 +68,7 @@ const tools = { h, React, state, t, _, dialogLib, apiCall, reloadList, logout, I
68 }
69 Object.assign(getHFS(), {
70 ...tools,
71 + emit: hfsEvent,
72 onEvent(name: string, cb: (params:any, tools: any, output:any) => any) {
73 const key = 'hfs.' + name
74 document.addEventListener(key, wrapper)