Add setting to add a global _doc reference (closes #4)
This commit is contained in:
parent
5573a5b674
commit
ee99ab15dd
3 changed files with 45 additions and 2 deletions
36
module/settings/addGlobalDocReferrer.mjs
Normal file
36
module/settings/addGlobalDocReferrer.mjs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import { __ID__ } from "../consts.mjs";
|
||||
import { Logger } from "../utils/Logger.mjs";
|
||||
import { registerDevSetting } from "../utils/DevSettings.mjs";
|
||||
|
||||
const key = `addGlobalDocReferrer`;
|
||||
|
||||
export function addGlobalDocReferrer() {
|
||||
|
||||
// #region Registration
|
||||
Logger.log(`Registering setting: ${key}`);
|
||||
registerDevSetting(__ID__, key, {
|
||||
name: `OFT.setting.${key}.name`,
|
||||
hint: `OFT.setting.${key}.hint`,
|
||||
scope: `user`,
|
||||
type: Boolean,
|
||||
default: false,
|
||||
config: true,
|
||||
requiresReload: false,
|
||||
});
|
||||
// #endregion Registration
|
||||
|
||||
// #region Implementation
|
||||
Hooks.on(`getHeaderControlsDocumentSheetV2`, (app, controls) => {
|
||||
if (!game.settings.get(__ID__, key)) { return };
|
||||
|
||||
controls.push({
|
||||
icon: `fa-solid fa-file`,
|
||||
label: `OFT.apps.make-global-reference`,
|
||||
onClick: () => {
|
||||
globalThis._doc = app.document;
|
||||
},
|
||||
});
|
||||
});
|
||||
// #endregion Implementation
|
||||
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue