plugins: onEvent now supports :after
Massimo Melina committed
Oct 22, 2025 at 20:29 UTC
e2768904e7f02a85ddcbb340be07b18140fa814a
3 files changed
+19
-6
dev-plugins.md
+12
-4
@@ -477,7 +477,7 @@ Some frontend events can return HTML, which can be expressed in several ways:
477
So when referring to type `Html`, below, we are actually meaning `Promisable<string | Element | ReactNode | ReactNode[]>`.
478
479
These events will receive, in addition event's specific properties, a `def` property
480
-with the *default* content that will be displayed if no callback return a valid output.
480
+with the *default* content that will be displayed if no callback returns a valid output.
481
It is useful if you want to embed such default content inside your content.
482
Most events have this `def` undefined as they have no default content and are designed for custom insertions,
483
but when this is not the case, you can replace the default content with nothing by returning `null`.
@@ -487,9 +487,15 @@ You can produce output for such events also by adding sections (with same name a
487
488
This is an advanced topic, rarely needed.
489
The "extra" object is the second parameter of your callback, and has the following properties:
490
-- `output: any[]` array of values returned by all plugin/callbacks.
490
+- `output: any[]` array of values returned by all plugin/callbacks (so far).
491
- `setOrder(order: number)` if you need to prioritize your output (and see it before) with respect to other plugins,
492
- you can specify a negative number. Use a positive number to get the opposite.
492
+ you can specify a negative number. Use a positive number to get the opposite.
493
+
494
+#### Execution order
495
+
496
+Callbacks configured by all plugins are executed in the order onEvent was called.
497
+You can require executing your callback after others by appending `:after` to the event name.
498
+E.g. HFS.onEvent("entryIcon:after", ...)
499
500
#### List of frontend events
501
@@ -1069,4 +1075,6 @@ If you want to override a text regardless of the language, use the special langu
1075
- fixed checkVfsPermission
1076
- 12.93 (v0.57.17)
1077
- uploadStart now gets fullPath, tempName, resume, fullSize
1072
- - ctx.disconnect(logMessage)
\ No newline at end of file
1078
+ - ctx.disconnect(logMessage)
1079
+- 12.94 (v0.57.24)
1080
+ - HFS.onEvent now supports :after
\ No newline at end of file
frontend/src/misc.ts
+6
-1
@@ -56,8 +56,13 @@ export function working() {
56
export function hfsEvent(name: string, params?:Dict) {
57
const output: any[] = []
58
const order: number[] = []
59
- const ev = new CustomEvent('hfs.'+name, { cancelable: true, detail: { params, output, order } })
59
+ const detail = { params, output, order }
60
+ let ev = new CustomEvent('hfs.'+name, { detail, cancelable: true })
61
document.dispatchEvent(ev)
62
+ if (!ev.defaultPrevented) {
63
+ ev = new CustomEvent('hfs.'+name+':after', { detail, cancelable: true })
64
+ document.dispatchEvent(ev)
65
+ }
66
const sortedOutput = order.length && _.sortBy(output.map((x, i) => [order[i] || 0, x]), '0').map(x => x[1])
67
return Object.assign(sortedOutput || output, {
68
isDefaultPrevented: () => ev.defaultPrevented,
src/const.ts
+1
-1
@@ -9,7 +9,7 @@ import { formatTimestamp } from './cross'
9
import { argv } from './argv'
10
export * from './cross-const'
11
12
-export const API_VERSION = 12.93
12
+export const API_VERSION = 12.94
13
export const COMPATIBLE_API_VERSION = 1 // while changes in the api are not breaking, this number stays the same, otherwise it is made equal to API_VERSION
14
15
// you can add arguments with this file, currently used for the update process on mac/linux