Merge pull request #636 from Kreijstal/globalThis-not-in-browser

check for globalThis.
This commit is contained in:
Sanchit Agarwal 2024-11-25 21:45:16 +05:30 committed by GitHub
commit 2629e8b51d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View File

@ -227,7 +227,7 @@ export function defaultContext(refs: RefValues): Context {
defaultrowNum: 84,
addDefaultRows: 50,
fullscreenmode: true,
devicePixelRatio: (globalThis || window).devicePixelRatio,
devicePixelRatio: (typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : {}).devicePixelRatio,
contextMenu: {},
sheetTabContextMenu: {},

View File

@ -30,7 +30,7 @@ const Sheet: React.FC<Props> = ({ sheet }) => {
if (!data) return;
setContext((draftCtx) => {
if (settings.devicePixelRatio === 0) {
draftCtx.devicePixelRatio = (globalThis || window).devicePixelRatio;
draftCtx.devicePixelRatio = (typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : {}).devicePixelRatio;
}
updateContextWithSheetData(draftCtx, data);
updateContextWithCanvas(