File tree Expand file tree Collapse file tree 6 files changed +11
-11
lines changed Expand file tree Collapse file tree 6 files changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -53,8 +53,8 @@ export const holdDown = async (
53
53
target : element ,
54
54
clientX : options . X ,
55
55
clientY : options . Y ,
56
- pageX : options . X + window . scrollX ,
57
- pageY : options . Y + window . scrollY ,
56
+ pageX : options . X + globalThis . scrollX ,
57
+ pageY : options . Y + globalThis . scrollY ,
58
58
} ) ;
59
59
const mouseOptions = {
60
60
button : options . button ?? 0 ,
Original file line number Diff line number Diff line change 1
1
import { extractCodeFiles } from "./extractCodeFiles.ts" ;
2
2
import { Line } from "../../deps/scrapbox.ts" ;
3
3
import { assertSnapshot } from "../../deps/testing.ts" ;
4
- import sample from "./sample-lines1.json" assert { type : "json" } ;
4
+ import sample from "./sample-lines1.json" with { type : "json" } ;
5
5
6
6
Deno . test ( "extractCodeFiles" , async ( t ) => {
7
7
await assertSnapshot (
Original file line number Diff line number Diff line change 4
4
5
5
export const isHeightViewable = ( element : HTMLElement ) : boolean => {
6
6
const { top, bottom } = element . getBoundingClientRect ( ) ;
7
- return top >= 0 && bottom <= window . innerHeight ;
7
+ return top >= 0 && bottom <= globalThis . innerHeight ;
8
8
} ;
Original file line number Diff line number Diff line change @@ -161,7 +161,7 @@ const getVisibleLineCount = (): number => {
161
161
if ( clientHeight === undefined ) {
162
162
throw Error ( "Could not find .line:last-of-type" ) ;
163
163
}
164
- return Math . round ( window . innerHeight / clientHeight ) ;
164
+ return Math . round ( globalThis . innerHeight / clientHeight ) ;
165
165
} ;
166
166
167
167
/** 半ページ上にスクロールする
Original file line number Diff line number Diff line change @@ -58,14 +58,14 @@ export const open = (
58
58
options ?. newTab !== false &&
59
59
( options ?. newTab === true || project !== scrapbox . Project . name )
60
60
) {
61
- window . open ( url ) ;
61
+ globalThis . open ( url ) ;
62
62
return ;
63
63
}
64
64
if (
65
65
options ?. reload !== false &&
66
66
( options ?. reload === true || project !== scrapbox . Project . name )
67
67
) {
68
- window . open ( url , "_self" ) ;
68
+ globalThis . open ( url , "_self" ) ;
69
69
return ;
70
70
}
71
71
Original file line number Diff line number Diff line change @@ -3,9 +3,9 @@ import { BaseOptions } from "./util.ts";
3
3
4
4
// scrapbox.io内なら`window._csrf`にCSRF tokenが入っている
5
5
declare global {
6
- interface Window {
7
- _csrf ?: string ;
8
- }
6
+ // globalThisに変数を宣言するには、`var`を使うしかない
7
+ // deno-lint-ignore no-var
8
+ var _csrf : string | undefined ;
9
9
}
10
10
11
11
/** HTTP headerのCookieに入れる文字列を作る
@@ -21,7 +21,7 @@ export const cookie = (sid: string): string => `connect.sid=${sid}`;
21
21
export const getCSRFToken = async (
22
22
init ?: BaseOptions ,
23
23
) : Promise < string > => {
24
- if ( window . _csrf ) return window . _csrf ;
24
+ if ( globalThis . _csrf ) return globalThis . _csrf ;
25
25
26
26
const user = await getProfile ( init ) ;
27
27
return user . csrfToken ;
You can’t perform that action at this time.
0 commit comments