Fix the issue with ContextMenus being completely non-functional in v13 (closes #91)

This commit is contained in:
Oliver 2026-05-07 18:05:00 -06:00
parent 9177b7cc2d
commit b36fe27182
2 changed files with 24 additions and 5 deletions

View file

@ -3,6 +3,25 @@ This file contains utility methods used by Applications in order to be
DRYer
*/
/**
* A helper function that takes a v14-compatible ContextMenuEntry option
* and adjusts it for v13 if required
*
* @param {ContextMenuEntry} option The v14+ compatible menu entry option
* @returns {ContextMenuEntry} The v14+ or <v13 menu option object
*/
export function createContextMenuOption(option) {
if (game.release.generation < 14) {
return {
name: option.label,
visible: option.condition,
callback: (target) => option.onClick(null, target),
};
};
return option;
};
/**
* @param {Event} _event The click event
* @param {HTMLElement} target The element to operate on