refactor(editor): Add types to global link actions event bus (no-changelog) (#10452)

Co-authored-by: Alex Grozav <alex@grozav.com>
This commit is contained in:
Tomi Turtiainen
2024-08-20 11:25:22 +03:00
committed by GitHub
parent 61ac0c7775
commit 51f3e84dff
4 changed files with 21 additions and 7 deletions

View File

@@ -3,15 +3,16 @@
* unsafe onclick attribute
*/
import { reactive, computed, onMounted, onUnmounted } from 'vue';
import type { LinkActionFn, RegisterCustomActionOpts } from '@/event-bus';
import { globalLinkActionsEventBus } from '@/event-bus';
const state = reactive({
customActions: {} as Record<string, Function>,
customActions: {} as Record<string, LinkActionFn>,
delegatedClickHandler: null as null | ((e: MouseEvent) => void),
});
export function useGlobalLinkActions() {
function registerCustomAction({ key, action }: { key: string; action: Function }) {
function registerCustomAction({ key, action }: RegisterCustomActionOpts) {
state.customActions[key] = action;
}
function unregisterCustomAction(key: string) {
@@ -51,7 +52,7 @@ export function useGlobalLinkActions() {
}
}
const availableActions = computed<{ [key: string]: Function }>(() => ({
const availableActions = computed<{ [key: string]: LinkActionFn }>(() => ({
reload,
...state.customActions,
}));